# app_script_history

id: 66a2f859993295696042f61d
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:14:28.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 
    
    return getListFromSQL2( '',  ` select * from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办') a group by corpid_ny_pzh   ` ) 


    
    return getListFromSQL2( '',  ` SELECT 
    max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    from (select * from pz_yjd_pzh where billtype='交办') a 
    left join (
        select a.* from pz_yjd a 
        left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
        on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    ) b on a.gguid=b.gguid   
    group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f623
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:14:47.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 
    
    return getListFromSQL2( '',  ` select * from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    return getListFromSQL2( '',  ` SELECT 
    max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    from (select * from pz_yjd_pzh where billtype='交办') a 
    left join (
        select a.* from pz_yjd a 
        left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
        on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    ) b on a.gguid=b.gguid   
    group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f629
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:15:19.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 
    
    return getListFromSQL2( '',  ` select * from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f62f
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:16:23.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f635
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:18:05.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where a1.billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f63b
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:18:15.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f641
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:22:05.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 


    
    return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
        left join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f647
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:22:08.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 


    
    return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
        left join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f64d
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:22:43.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 


    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    return getListFromSQL2( '',  ` sselect a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f653
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:23:18.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 


    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f659
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:24:39.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 


    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f65f
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:24:57.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 


    
    return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
        left join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f665
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:25:42.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from pz_yjd_pzh  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  a1.billtype='交办' and b1.corpid is not null   ` ) 


    
    return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
        left join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2f859993295696042f672
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:40:11.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh     ` ) 


    
    return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        left join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f678
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:40:31.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        left join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f67e
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:41:46.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f684
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:41:49.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f68a
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:43:39.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f696
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:44:11.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f69f
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:47:13.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f6a5
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:53:00.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' then '交办中' else
     case when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' else
     case when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回中' else
     case when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' else
      end as jb_state

    , case when jy.flow_instance_state='0' then '借阅中' else
     case when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' else
     case when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还中' else
     case when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' else
      end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f6ab
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:55:17.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' then '交办中' 
     case when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
     case when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回中' 
     case when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' then '借阅中' 
     case when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
     case when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还中' 
     case when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a2fe8e993295696042f6b1
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 09:55:49.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' then '交办中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' then '借阅中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a3033c993295696042f7c1
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 10:13:02.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a30c329932e2c04eefbdb9
scriptid: 669dc60c9932df22f60cad57
tablename: app_template
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 11:16:33.000
script:
//@comment (group=按钮,caption=凭证资料导入)
function cb_import_pz_onClick() {
    var p_gguid = currentGUID();

    back_get_pzdj_gguid(p_gguid, function(gguid){
        $.dialog({
            title: '凭证资料导入',
            boxWidth: '1000px',
            useBootstrap: false,
            content: `<iframe  style="width:100%;height:400px; border:0" src="billedit?id=pzdj${gguid?`&action=edit&gguid=${gguid}`:'&action=new'}&from_id=${p_gguid}"></iframe>`
        });
    })

    // let dlg= floatDialog( "凭证资料导入" ,"billlist" , "pzdj" , 1000,500, {} , "listToolbarVisible=true&editToolbarVisible=true&from_id="+currentGUID()  , function(val){alert(val);});
}


//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
        toastr.show("正在计算...");
        setTimeout(function () {
            back_build_sum(function () {
                toastr.hide();
                toastr.info("导入完成");
                $pz_yjd_ds.smartRetrieve();
                $pz_yjdex_ds.smartRetrieve();
                $pz_yjd_pzh_ds.smartRetrieve();
                $q_pz_yjd_pzh_ds.smartRetrieve();

            });
        }, 100);

    });

}


id: 66a30c329932e2c04eefbdcf
scriptid: 669dc60c9932df22f60cad3b
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 11:17:57.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary, a.state_jb=1     ` , true);
}


function back_get_pzdj_gguid(from_id){
    return getStringFromSQL2( '', `select gguid from pzdj where from_id='${from_id}'`  ) 
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交回') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交回') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交回',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66a315659932e2c04eefbde5
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 123.157.192.205
username: sa
createdate: 2024.07.26 14:34:28.000
script:
//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    
    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }
    
    if (data.pzh2 <= data.pzh1) {
        toastr.error( '终止凭证号要比起始凭证号大' );
        return false;
    }

    toastr.show("正在计算...");
        setTimeout(function () {
            back_add_pzh(data, function () {
                toastr.hide();
                toastr.info("导入完成");
                // $pz_yjd_ds.smartRetrieve();
                $pz_yjdex_ds.smartRetrieve();
                $pz_yjd_pzh_ds.smartRetrieve();
                $q_pz_yjd_pzh_ds.smartRetrieve();
            });
        }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');
    
    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }
    

    toastr.show("正在计算...");
        setTimeout(function () {
            back_import_pzh_data(data, function () {
                toastr.hide();
                toastr.info("导入完成");
                // $pz_yjd_ds.smartRetrieve();
                $pz_yjdex_ds.smartRetrieve();
                $pz_yjd_pzh_ds.smartRetrieve();
                $q_pz_yjd_pzh_ds.smartRetrieve();
            });
        }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function()
    {  
    $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
        toastr.show("正在计算...");
        setTimeout(function () {
            back_build_sum(function () {
                toastr.hide();
                toastr.info("导入完成");
                $pz_yjd_ds.smartRetrieve();
                $pz_yjdex_ds.smartRetrieve();
                $pz_yjd_pzh_ds.smartRetrieve();
                $q_pz_yjd_pzh_ds.smartRetrieve();

            });
        }, 100);

    });
    });

}


id: 66a315659932e2c04eefbdef
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 123.157.192.205
username: sa
createdate: 2024.07.26 14:35:27.000
script:
//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66a3456e9932e2c04eefbeac
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 14:43:39.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66a3456e9932e2c04eefbeb5
scriptid: 669dc6249932df22f60cc8cf
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 14:44:03.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary, a.state_jy=1     ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '借阅') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '借阅') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '借阅',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66a3456e9932e2c04eefbebe
scriptid: 669dc6399932df22f60ce463
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 14:44:11.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jy=0    ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '归还') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '归还') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '归还',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66a3456e9932e2c04eefbec7
scriptid: 669dc60c9932df22f60cad3b
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 14:44:20.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary, a.state_jb=1     ` , true);
}


function back_get_pzdj_gguid(from_id){
    return getStringFromSQL2( '', `select gguid from pzdj where from_id='${from_id}'`  ) 
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交回') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交回') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交回',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66a364fc9932e2c04eefbf70
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 16:58:29.000
script:
//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}

/**
 * 当结果集中的某行被删除后，触发本事件
 * @param dsname   结果集名称
 * @param row  被删除的行号 （此参数无使用意义，因为原来的row行已经删除，现在的第row行已不是原来的第row行
 */
function afterDeleteRow( dsname, row)
{
    if(dsname == 'q_pz_yjd_pzh'){
        
    }
}


id: 66a364fc9932e2c04eefbf82
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 17:19:51.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a364fc9932e2c04eefbf8e
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 17:20:28.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a364fc9932e2c04eefbf94
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 17:20:41.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a364fc9932e2c04eefbf9a
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 17:22:24.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' and a.flow_instance_status is null then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' and a.flow_instance_status is null then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a364fc9932e2c04eefbfa0
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 17:23:10.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    return getListFromSQL2( '',  `  select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' and a.flow_instance_status is null then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' and a.flow_instance_status is null then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a364fc9932e2c04eefbfa6
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 17:23:47.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  `  select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    // from (
    //     select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
    //     ) a 
    //     inner  join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' and a.flow_instance_status is not null then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' and a.flow_instance_status is not null then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a364fc9932e2c04eefbfac
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 17:24:38.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  `  select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    // from (
    //     select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
    //     ) a 
    //     inner  join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' and jb.flow_instance_status is not null then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' and jh.flow_instance_status is not null then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' and jy.flow_instance_status is not null then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' and gh.flow_instance_status is not null then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66a364fc9932e2c04eefbfb9
scriptid: 650666139932de686bb62112
tablename: app_script
clientip: 122.235.158.135
username: sa
createdate: 2024.07.26 17:25:06.000
script:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{

// runSQL('', `alter table pz_yjd_pzh alter column lastmodifieddate set default =DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')`  ) 
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT(a.ny, a.pzh) AS ny_pzh,
    // case 
    //     when a.billtype ='交办' and b.flow_instance_state='0' then '交办中'
    //     when a.billtype ='交办' and b.flow_instance_state='1' and a.billtype ='交回' and b.flow_instance_state='0' then '交办没有交回' 
    // else end as jbzt
    // from pz_yjd_pzh a left join pz_yjd b on a.gguid=b.gguid  where a.billtype='交办'
    // group by ny_pzh` ) 
    
    // return getListFromSQL2( '',  `  select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    // from (
    //     select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
    //     ) a 
    //     inner  join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate      ` ) 


    
    return getListFromSQL2( '',  ` select jb.* 
    , case when jb.flow_instance_state='0' and jb.flow_instance_status is not null then '交办申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state is null then '交办没有交回' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='0' and jh.flow_instance_status is not null then '交回申请中' 
      when jb.flow_instance_state='1' and jh.flow_instance_state='1' then '交办且已交回' 
     else '' end as jb_state

    , case when jy.flow_instance_state='0' and jy.flow_instance_status is not null then '借阅申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state is null then '借阅没有归还' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='0' and gh.flow_instance_status is not null then '归还申请中' 
      when jy.flow_instance_state='1' and gh.flow_instance_state='1' then '借阅且已归还' 
     else '' end as jy_state
    
     from (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state,b1.flow_instance_status,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jb 
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交回'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jh on jb.corpid_ny_pzh=jh.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='借阅'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) jy on jb.corpid_ny_pzh=jy.corpid_ny_pzh
    left join (
        select  a.lastmodifieddate, a.corpid_ny_pzh, a.ny,  a.pzh, a.corpid, a.flow_instance_state,a.flow_instance_status
    from (
        select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid, b1.flow_instance_state, b1.flow_instance_status, CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  
        ) a 
        inner  join  (
            select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='归还'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
        ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate 
    ) gh  on jb.corpid_ny_pzh=gh.corpid_ny_pzh
    
    order by jb.lastmodifieddate desc` ) 
    
    // return getListFromSQL2( '',  ` select  max(a.lastmodifieddate) as lastmodifieddate, a.corpid_ny_pzh, max(a.ny) as ny,  max(a.pzh) as pzh, max(a.corpid) as corpid
    // from (select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a 
    //     left join  (
    //         select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) aa group by corpid_ny_pzh  
    //     ) b on a.corpid_ny_pzh=b.corpid_ny_pzh and a.lastmodifieddate=b.lastmodifieddate ` ) 
    
    
    // return getListFromSQL2( '',  ` select a1.pzh, a1.ny, b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ` ) 
    
    return getListFromSQL2( '',  ` select max(lastmodifieddate) as lastmodifieddate, corpid_ny_pzh from (select b1.lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
        from ( select * from pz_yjd_pzh where billtype='交办'  )  a1 left join pz_yjd b1 on a1.gguid=b1.gguid where  b1.corpid is not null  ) a group by corpid_ny_pzh   ` ) 


    
    // return getListFromSQL2( '',  ` SELECT 
    // max(b.corpid) as corpid,  max(a.ny) as ny, max(a.pzh) as pzh,   CONCAT( CONCAT(b.corpid, a.ny), a.pzh) AS corpid_ny_pzh, max(b.flow_instance_state) as flow_instance_state
    // from (select * from pz_yjd_pzh where billtype='交办') a 
    // left join (
    //     select a.* from pz_yjd a 
    //     left join ( select max(b1.lastmodifieddate) as lastmodifieddate, b1.corpid,  CONCAT( CONCAT(b1.corpid, a1.ny), a1.pzh) AS corpid_ny_pzh 
    //     from (select * from pz_yjd_pzh where billtype='交办')  a1 left join pz_yjd b1 on a1.gguid=b1.gguid   group by corpid_ny_pzh ) b 
    //     on b.lastmodifieddate=a.lastmodifieddate and a.corpid =b.corpid
    // ) b on a.gguid=b.gguid   
    // group by corpid_ny_pzh` ) 
    
    

    return false
    
   var t='2023-02-23 ';
var s= t.match(  /20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
return s;   
    
    return OCR ( { src:'fileServer?bucketName=电子凭证&objectName=dzpz_imgpool/2023/09/17/650665939932db10f02cebaf.jpg&fileName=p4.jpg&serverIndex=2&action=view' ,
             left:'50%' , top:'20%' ,height:'20%' ,width:'50%'} );


}


id: 66ba01c3993294a6b3485459
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 11:52:20.000
script:
/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66ba01c3993294a6b348545d
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 11:52:43.000
script:
/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('清单').getBrick('cb_import').visible=false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible=false;
}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66ba01c3993294a6b3485461
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 11:53:57.000
script:
/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('清单').getBrick('cb_import').visible=false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    
}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66ba01c3993294a6b3485465
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 11:54:31.000
script:
/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('清单').getBrick('cb_import').visible=false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable =false;
    
}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66ba01c3993294a6b3485469
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 11:54:33.000
script:
/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('清单').getBrick('cb_import').visible=false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable=false;
    
}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b348552a
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:00:54.000
script:
/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('清单').getBrick('cb_import').visible=false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible=false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable=false;
    
    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable=false;
    
    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable=false;
    
}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b348552e
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:01:00.000
script:
/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('清单').getBrick('cb_import').visible=false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible=false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable=false;
    
    book.getWorkSheet('清单').cells('qsqx').visible=false;
    book.getWorkSheet('清单').cells('qsqx').clickable=false;
    
    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable=false;
    
}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b3485532
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:01:03.000
script:
/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('清单').getBrick('cb_import').visible=false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible=false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable=false;
    
    book.getWorkSheet('清单').cells('qsqx').visible=false;
    book.getWorkSheet('清单').cells('qsqx').clickable=false;
    
    book.getWorkSheet('清单').cells('state').visible=false;
    book.getWorkSheet('清单').cells('state').clickable=false;
    
}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b3485536
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:06:44.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver()
{


}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible=false;
    book.getWorkSheet('清单').getBrick('cb_import').visible=false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible=false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible=false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable=false;
    
    book.getWorkSheet('清单').cells('qsqx').visible=false;
    book.getWorkSheet('清单').cells('qsqx').clickable=false;
    
    book.getWorkSheet('清单').cells('state').visible=false;
    book.getWorkSheet('清单').cells('state').clickable=false;
    
}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b348553a
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:07:10.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    console.log(data)

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;

    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b348554b
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:12:08.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    console.log(data)

    if(data.flow_instance_status.indexOf('接收方签收确认')){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = false;
    }

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;

    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b348554f
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:12:10.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)

    if(data.flow_instance_status.indexOf('接收方签收确认')){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = false;
    }

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;

    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b3485553
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:12:29.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)

    if(data.flow_instance_status.indexOf('接收方签收确认')){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
    }

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;

    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b3485557
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:13:23.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)
    console.log(data.flow_instance_status.indexOf('接收方签收确认'), data.flow_instance_status)
    if(data.flow_instance_status.indexOf('接收方签收确认')){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
    }

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;

    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b348555b
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:13:40.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)
    console.log(data.flow_instance_status.indexOf('接收方签收确认'), data.flow_instance_status)
    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
    }

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;

    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66baf21a993294a6b348555f
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:15:38.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)
    console.log(data.flow_instance_status.indexOf('接收方签收确认'), data.flow_instance_status)
    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
    }

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;

console.log('===============')

    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bafb5e993294a6b3485580
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:27:48.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}'`  ) 

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bafb5e993294a6b3485586
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:27:51.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}'`  );

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bafb5e993294a6b3485591
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:29:32.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)
    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
    }

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;

console.log('===============')

    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bafb5e993294a6b3485595
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:29:37.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)
    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
    }

}



/**
 * 当模板是单据模板，查看一张单据，初始化完成后执行本事件
 * 本事件执行前，先执行  formOpen ，本事件执行后，随后执行  afterOpen
 */
function viewOpen() {
console.log('===============')
    book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
    book.getWorkSheet('清单').getBrick('cb_import').visible = false;
    book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

    book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
    book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


    book.getWorkSheet('清单').cells('qsqx').visible = false;
    book.getWorkSheet('清单').cells('qsqx').clickable = false;

    book.getWorkSheet('清单').cells('state').visible = false;
    book.getWorkSheet('清单').cells('state').clickable = false;

}



//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bafb5e993294a6b3485599
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:30:41.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)
    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
    }

    if(urlArgs.action=='view'){
        book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
        book.getWorkSheet('清单').getBrick('cb_import').visible = false;
        book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


        book.getWorkSheet('清单').cells('qsqx').visible = false;
        book.getWorkSheet('清单').cells('qsqx').clickable = false;

        book.getWorkSheet('清单').cells('state').visible = false;
        book.getWorkSheet('清单').cells('state').clickable = false;
    }else{
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = true;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = true;
    }

}






//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bafb5e993294a6b348559d
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:30:48.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)
    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
    }

console.log(urlArgs.action)
    if(urlArgs.action=='view'){
        book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
        book.getWorkSheet('清单').getBrick('cb_import').visible = false;
        book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


        book.getWorkSheet('清单').cells('qsqx').visible = false;
        book.getWorkSheet('清单').cells('qsqx').clickable = false;

        book.getWorkSheet('清单').cells('state').visible = false;
        book.getWorkSheet('清单').cells('state').clickable = false;
    }else{
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = true;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = true;
    }

}






//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bafb5e993294a6b34855a1
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:32:00.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)
    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
        
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;
    }

console.log(urlArgs.action)
    if(urlArgs.action=='view'){
        book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
        book.getWorkSheet('清单').getBrick('cb_import').visible = false;
        book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


        book.getWorkSheet('清单').cells('qsqx').visible = false;
        book.getWorkSheet('清单').cells('qsqx').clickable = false;

        book.getWorkSheet('清单').cells('state').visible = false;
        book.getWorkSheet('清单').cells('state').clickable = false;
    }else{
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = true;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = true;
    }

}






//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bafb5e993294a6b34855a5
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:32:21.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)

console.log(urlArgs.action)
    if(urlArgs.action=='view'){
        book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
        book.getWorkSheet('清单').getBrick('cb_import').visible = false;
        book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


        book.getWorkSheet('清单').cells('qsqx').visible = false;
        book.getWorkSheet('清单').cells('qsqx').clickable = false;

        book.getWorkSheet('清单').cells('state').visible = false;
        book.getWorkSheet('清单').cells('state').clickable = false;
    }else{
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = true;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = true;
    }

    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
        
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;
    }

}






//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bafb5e993294a6b34855a9
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:32:38.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)

    if(urlArgs.action=='view'){
        book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
        book.getWorkSheet('清单').getBrick('cb_import').visible = false;
        book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


        book.getWorkSheet('清单').cells('qsqx').visible = false;
        book.getWorkSheet('清单').cells('qsqx').clickable = false;

        book.getWorkSheet('清单').cells('state').visible = false;
        book.getWorkSheet('清单').cells('state').clickable = false;
    }else{
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = true;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = true;
    }

    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
        
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;
    }

}






//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bb0227993294a6b34855d9
scriptid: 662a47879932b5035f32efb0
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:50:51.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)

    if(urlArgs.action=='view'){
        book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
        book.getWorkSheet('清单').getBrick('cb_import').visible = false;
        book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


        book.getWorkSheet('清单').cells('qsqx').visible = false;
        book.getWorkSheet('清单').cells('qsqx').clickable = false;

        book.getWorkSheet('清单').cells('state').visible = false;
        book.getWorkSheet('清单').cells('state').clickable = false;
    }else{
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = true;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = true;
    }

    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
        
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;
    }

}


//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    form.save(false, function () {
        $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
            toastr.show("正在计算...");
            setTimeout(function () {
                back_build_sum(function () {
                    toastr.hide();
                    toastr.info("导入完成");
                    $pz_yjd_ds.smartRetrieve();
                    $pz_yjdex_ds.smartRetrieve();
                    $pz_yjd_pzh_ds.smartRetrieve();
                    $q_pz_yjd_pzh_ds.smartRetrieve();

                });
            }, 100);

        });
    });

}


id: 66bb0227993294a6b34855de
scriptid: 669dc60c9932df22f60cad57
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:51:02.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)

    if(urlArgs.action=='view'){
        book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
        book.getWorkSheet('清单').getBrick('cb_import').visible = false;
        book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


        book.getWorkSheet('清单').cells('qsqx').visible = false;
        book.getWorkSheet('清单').cells('qsqx').clickable = false;

        book.getWorkSheet('清单').cells('state').visible = false;
        book.getWorkSheet('清单').cells('state').clickable = false;
    }else{
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = true;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = true;
    }

    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
        
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;
    }

}

//@comment (group=按钮,caption=凭证资料导入)
function cb_import_pz_onClick() {
    var p_gguid = currentGUID();

    back_get_pzdj_gguid(p_gguid, function(gguid){
        $.dialog({
            title: '凭证资料导入',
            boxWidth: '1000px',
            useBootstrap: false,
            content: `<iframe  style="width:100%;height:400px; border:0" src="billedit?id=pzdj${gguid?`&action=edit&gguid=${gguid}`:'&action=new'}&from_id=${p_gguid}"></iframe>`
        });
    })

    // let dlg= floatDialog( "凭证资料导入" ,"billlist" , "pzdj" , 1000,500, {} , "listToolbarVisible=true&editToolbarVisible=true&from_id="+currentGUID()  , function(val){alert(val);});
}


//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }

    if (data.pzh2 <= data.pzh1) {
        toastr.error('终止凭证号要比起始凭证号大');
        return false;
    }

    toastr.show("正在计算...");
    setTimeout(function () {
        back_add_pzh(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');

    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }


    toastr.show("正在计算...");
    setTimeout(function () {
        back_import_pzh_data(data, function () {
            toastr.hide();
            toastr.info("导入完成");
            // $pz_yjd_ds.smartRetrieve();
            $pz_yjdex_ds.smartRetrieve();
            $pz_yjd_pzh_ds.smartRetrieve();
            $q_pz_yjd_pzh_ds.smartRetrieve();
        });
    }, 100);
}


function cb_buildsum_onClick() {
    $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
        toastr.show("正在计算...");
        setTimeout(function () {
            back_build_sum(function () {
                toastr.hide();
                toastr.info("导入完成");
                $pz_yjd_ds.smartRetrieve();
                $pz_yjdex_ds.smartRetrieve();
                $pz_yjd_pzh_ds.smartRetrieve();
                $q_pz_yjd_pzh_ds.smartRetrieve();

            });
        }, 100);

    });

}


id: 66bb0227993294a6b34855e7
scriptid: 669dc6249932df22f60cc8eb
tablename: app_template
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:51:42.000
script:
/**
 * 一个单据打开，
 * 1 先对类型为“表”的结果集做数据异步检索
 * 2 全部表检索完成之后，再执行 formOpen 事件
 * 3 再根据  actio 执行 newOpen/viewOpen/editOpen 之一
 * 4 再执行  afterOpen
 * 5 对类型为“结果集”的且需要自动检索的结果集，做异步检索
 * 6 异步检索完成后，最后执行  formOpenOver 事件
 */
//@comment (group=表单事件,caption=表单初始化全部完成之后)
function formOpenOver() {
    var data = $pz_yjd_ds.getJSON(0);
    // console.log(data)

    if(urlArgs.action=='view'){
        book.getWorkSheet('汇总').getBrick('cb_add_pz').visible = false;
        book.getWorkSheet('清单').getBrick('cb_import').visible = false;
        book.getWorkSheet('清单').getBrick('cb_buildsum').visible = false;

        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;


        book.getWorkSheet('清单').cells('qsqx').visible = false;
        book.getWorkSheet('清单').cells('qsqx').clickable = false;

        book.getWorkSheet('清单').cells('state').visible = false;
        book.getWorkSheet('清单').cells('state').clickable = false;
    }else{
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = true;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = true;
    }

    if(data.flow_instance_status.indexOf('接收方签收确认')>0){
        book.getWorkSheet('清单').cells('qsqx').editable = true;
        book.getWorkSheet('清单').cells('state').editable = true;
        
        book.getWorkSheet('清单').cells('c_db_deleterow').visible = false;
        book.getWorkSheet('清单').cells('c_db_deleterow').clickable = false;
    }

}

//@comment (group=按钮,caption=添加凭证号)
function cb_add_pz_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    
    sheet.cells('ny').setValue('');
    sheet.cells('pzh1').setValue('');
    sheet.cells('pzh2').setValue('');

    sheet.float('fa fa-cog', "添加凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 900, height: 400 });

}

//@comment (group=添加凭证号按钮,caption=取消)
function cb_cancel_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();
}

//@comment (group=添加凭证号按钮,caption=确认)
function cb_comfirn_onClick() {
    var sheet = book.getWorkSheet('添加凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh1: sheet.cells('pzh1').getValue(),
        pzh2: sheet.cells('pzh2').getValue(),
    }
    
    if (data.pzh2 <= data.pzh1) {
        toastr.error( '终止凭证号要比起始凭证号大' );
        return false;
    }

    toastr.show("正在计算...");
        setTimeout(function () {
            back_add_pzh(data, function () {
                toastr.hide();
                toastr.info("导入完成");
                // $pz_yjd_ds.smartRetrieve();
                $pz_yjdex_ds.smartRetrieve();
                $pz_yjd_pzh_ds.smartRetrieve();
                $q_pz_yjd_pzh_ds.smartRetrieve();
            });
        }, 100);
}

function cb_import_onClick() {

    var sheet = book.getWorkSheet('导入凭证号');
    
    sheet.cells('ny').setValue('');
    sheet.cells('pzh').setValue('');

    sheet.float('fa fa-cog', "导入凭证号", {
        my: 'center',
        at: 'center',
        autoposition: 'down',
        offsetX: -5,
        offsetY: 5
    }, { width: 500, height: 400 });


    // inputBox("提示", "请将凭证号粘贴在此", "", "", function (val) {
    //     toastr.show("正在计算...");
    //     setTimeout(function () {
    //         back_import_pzh(val, function () {
    //             toastr.hide();
    //             toastr.info("导入完成");
    //             $pz_yjd_ds.smartRetrieve();
    //             $pz_yjdex_ds.smartRetrieve();
    //             $pz_yjd_pzh_ds.smartRetrieve();
    //             $q_pz_yjd_pzh_ds.smartRetrieve();
    //         });
    //     }, 100);
    // }, false, {}, 10);
}


//@comment (group=导入凭证号按钮,caption=取消)
function cb_cancel2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();
}

//@comment (group=导入凭证号按钮,caption=确认)
function cb_comfirn2_onClick() {
    var sheet = book.getWorkSheet('导入凭证号');
    sheet.floatPanelClose();

    var data = {
        ny: sheet.cells('ny').getValue(),
        pzh: sheet.cells('pzh').getValue(),
    }
    

    toastr.show("正在计算...");
        setTimeout(function () {
            back_import_pzh_data(data, function () {
                toastr.hide();
                toastr.info("导入完成");
                // $pz_yjd_ds.smartRetrieve();
                $pz_yjdex_ds.smartRetrieve();
                $pz_yjd_pzh_ds.smartRetrieve();
                $q_pz_yjd_pzh_ds.smartRetrieve();
            });
        }, 100);
}


function cb_buildsum_onClick() {
    $confirm("提示", "确信要根据凭证号清单生成凭证号汇总信息吗?", function () {
        toastr.show("正在计算...");
        setTimeout(function () {
            back_build_sum(function () {
                toastr.hide();
                toastr.info("导入完成");
                $pz_yjd_ds.smartRetrieve();
                $pz_yjdex_ds.smartRetrieve();
                $pz_yjd_pzh_ds.smartRetrieve();
                $q_pz_yjd_pzh_ds.smartRetrieve();

            });
        }, 100);

    });

}


id: 66bb0227993294a6b34855f5
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:52:19.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`  );

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb0227993294a6b3485602
scriptid: 669dc60c9932df22f60cad3b
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:52:28.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");
    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`  );

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary, a.state_jb=1     ` , true);
}


function back_get_pzdj_gguid(from_id){
    return getStringFromSQL2( '', `select gguid from pzdj where from_id='${from_id}'`  ) 
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交回') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交回') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交回',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb0227993294a6b348560b
scriptid: 669dc6249932df22f60cc8cf
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:52:33.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");
    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`  );

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary, a.state_jy=1     ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '借阅') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '借阅') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '借阅',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb0227993294a6b3485614
scriptid: 669dc6399932df22f60ce463
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 14:52:38.000
script:
/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");
    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`  );

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jy=0    ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '归还') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '归还') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '归还',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb03a1993294a6b34856bf
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 15:00:08.000
script:
function verifyGZL(){
    
}


/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`  );

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb03a1993294a6b34856c7
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 15:01:21.000
script:
function verifyGZL(gguid){


return '有凭证式延迟确认，不能提交结束工作流！'
}


/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`  );

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data){

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb03a1993294a6b34856cd
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 15:01:25.000
script:
function verifyGZL(gguid) {


    return '有凭证式延迟确认，不能提交结束工作流！'
}


/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`);

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data) {

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb03a1993294a6b34856df
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 15:03:11.000
script:
function verifyGZL(gguid) {
    var count = getValueFromSQL2( "", `select * from pz_yjd_pzh where gguid='${gguid}'`  ) 

    return '有凭证式延迟确认，不能提交结束工作流！'
}


/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`);

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data) {

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb03a1993294a6b34856f2
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 15:04:14.000
script:
function verifyGZL(gguid) {
    var count = getValueFromSQL2( "", `select * from pz_yjd_pzh where gguid='${gguid}' and qsqx is not null and qsqx>0`  );
    println( 'count  ' + count ) 

    return '有凭证式延迟确认，不能提交结束工作流！'
}


/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`);

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data) {

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


id: 66bb0584993294a6b34856fb
scriptid: 662a47879932b5035f32efab
tablename: app_script
clientip: 122.234.136.22
username: sa
createdate: 2024.08.13 15:04:38.000
script:
function verifyGZL(gguid) {
    var count = getValueFromSQL2( "", `select count(0) from pz_yjd_pzh where gguid='${gguid}' and qsqx is not null and qsqx>0`  );
    println( 'count  ' + count ) 

    return '有凭证式延迟确认，不能提交结束工作流！'
}


/**
 * 工作结束
 * @param flow 流程定义
 * @param node 开始节点
 * @param gguid 单据的gguid

 */
//@comment (group=工作流事件,caption=工作结束)
function onWorkFlowEnd(flow, node, gguid) {
    // println( flow.id) ; //流程定义的ID
    println(gguid + "工作结束了");

    runSQL("", ` update pz_yjd_pzh set state=1 where gguid='${gguid}' and  state=0`);

    runSQL("", `UPDATE pzbmx a
            INNER JOIN  pz_yjdex b  inner join pz_yjd c on (b.gguid=c.gguid) 
             ON a.pzh  >= b.pzh1 and a.pzh<= b.pzh2 and b.gguid=${gguid}
            SET a.pos  = c.towhere , a.memo = c.summary , a.state_jb=0, a.state_jy=0   ` , true);
}


function back_add_pzh(data) {
    var count = (data.pzh2 / 1) - (data.pzh1 / 1);


    var gguid = currentGUID();
    for (var i = 0; i <= count; i++) {
        var newid = newGuid();
        var pzh = (data.pzh1 / 1) + i;
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype) values ( ${newid} , ${gguid} , '${data.ny}', '${pzh}', '交办') `, true);
    }

    back_build_sum();
    return { success: true };

}

function back_import_pzh_data(data) {

    var t = data.pzh.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, ny, pzh, billtype ) values ( ${newid} , ${gguid} , '${data.ny}' , '${pzh}', '交办') `, true);
    }
    back_build_sum();
}

function back_import_pzh(s) {
    var t = s.split(/[\s]/);
    for (var i = 0; i < t.length; i++) {
        var pzh = t[i].trim();
        if (pzh == '') continue;
        var newid = newGuid();
        var gguid = currentGUID();
        runSQL("", `insert into  pz_yjd_pzh (id, gguid, pzh ) values ( ${newid} , ${gguid} , '${pzh}') `, true);
    }
    back_build_sum();
}

//  根据凭证号清单生成凭证号汇总信息 
function back_build_sum() {
    var gguid = currentGUID();
    $back_build_sum(gguid);
}


function $back_build_sum(gguid) {


    var sql = `
            
        SELECT
            MAX( ny ) as ny , MIN( pzh ) as pzh1 ,   MAX( pzh )  AS  pzh2,
        COUNT(*) AS c 
        FROM
        (
            SELECT
            ny,
            pzh,
            CONCAT(ny, pzh) as ny_pzh,
            @group_id := IF( pzh  = @prev_number + 1, @group_id, @group_id + 1) AS group_id,
            @prev_number := pzh 
            FROM
            pz_yjd_pzh,
            (SELECT @group_id := 0, @prev_number := NULL) AS vars 
                    where  gguid= ${gguid}
            ORDER BY
            ny_pzh 
        ) AS subquery
        GROUP BY
        group_id;
            
    ` ;

    println(sql);
    var tds = newDataStore("", sql);
    var n = tds.retrieve();

    runSQL("", `delete from  pz_yjdex where gguid= ${gguid} `, true);

    var pz_yjdex_ds = newDataStore("", "select * from pz_yjdex");
    pz_yjdex_ds.setUpdateProperty('pz_yjdex', 'id', '*', 'id');
    for (var i = 0; i < n; i++) {
        var row = pz_yjdex_ds.insertRow(9999);
        pz_yjdex_ds.setValue(row, {
            id: newGuid(), gguid: gguid, inner_xh: row + 1,
            billtype: '交办',
            ny: tds.getString(i, 'ny'),
            pzh1: tds.getString(i, "pzh1"),
            pzh2: tds.getString(i, "pzh2"),
            pzs: tds.getInt(i, "c")


        });
    }

    //
    pz_yjdex_ds.executeAfterUpdate(`update  pz_yjd  set pzs= (select count(*) from  pz_yjd_pzh where gguid= ${gguid} ) where   id= ${gguid}  `);
    pz_yjdex_ds.update(true);


}


/**
 * 单据点击保存，前端所有的操作被转译成3种操作:insert , delete , update ,
 *  并且可以在  beforeBillSaveOnServer 中返回一些SQL语句，可以在afterBillSaveOnServer中返回一些SQL语句
 *
 * 系统分别在需要的数据库连接中执行这些语句 ， 当所有语句执行成功后，事件被提交。一些细节如下 ：
 *
 * 1 如果单据中的表，属于不同的数据库连接，那么所有的SQL语句会以连接为单位，对语句进行批量执行
 * 2 这些语句的执行顺序是：对同一个数据库连接中的语句， 先执行 beforeBillSaveOnServer 中返回的SQL语句，再执行单据操作转译得到的SQL语句，
 *   再执行 afterBillSaveOnServer 中返回的SQL语句， 当多个（或一个）数据库连接执行完这些语句，且没有错误时，所有的数据库连接做提交，否则全部回滚
 * 3 不要在 beforeBillSaveOnServer 或 afterBillSaveOnServer 中直接执行数据库操作，而是返回SQL语句，让系统批量执行它们，并控制好事务
 * 4 当执行成功后，系统再执行事件函数  afterBillSaveSuccessfulOnServer 。 此事件中可以执行任意操作，它与单据保存事件结束后才被触发执行，
 *   与单据保存并不在一个事务中。
 *
 *
 * @param gguid  要删除记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据保存过程中的各个事件之间传递数据。本事件做为单据保存的最后一个事件，session对象在使用后将被丢弃
 *
 *
 * @return 本函数不需要返回值
 *
 */
//@comment (group=单据保存,caption=单据保存成功后)
function afterBillSaveSuccessfulOnServer(gguid, session) {

    $back_build_sum(gguid);
}


