// === EIP4 P4 脚本迁移产出 === // template_id : 209698e6-38fb-4c4e-8106-bf28fc9ca87e // template_name: 外经证开具申请 // seq : 1 // label : NO_S3 // 处置 : 无 S3 模式,原样进 P4 def id = getFieldValue("PM_EXTERNALAPPLY_ID"); def sql = ""; sql+=" select c.externalmoney-coalesce(a.externalmoney,0) as lastmoney"; sql+=" from pm_externalapply c "; sql+=" left join lateral("; sql+=" select sum(coalesce(a.externalmoney,0)) as externalmoney "; sql+=" from pm_invoiceapply_external a "; sql+=" join pm_invoiceapply b on a.invoiceapplyid = b.pm_invoiceapply_id "; sql+=" left join sys_datastatus s on b.pm_invoiceapply_id = s.businesskey and s.tablename = 'PM_INVOICEAPPLY' "; sql+=" where coalesce(s.datastatus,1) in (1,2,3,5) and a.externalapplyid = c.pm_externalapply_id"; sql+=" ) a on true "; sql+=" where c.pm_externalapply_id ='"+id+"'"; def returnmap = GetServicesFunction.executeQueryForMap(sql); if(returnmap!=null){ bindField("WRITEOFF",returnmap["LASTMONEY"]); }else{ bindField("WRITEOFF",null); }