diff --git a/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java b/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java index 9847919..7833051 100644 --- a/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java +++ b/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java @@ -91,19 +91,20 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen @Override public void afterExecuteOperationTransaction(AfterOperationArgs e) { super.afterExecuteOperationTransaction(e); - //audit审核通过后,判断当前是合同付款申请单还是无文本合同 - if("syncbip".equals(e.getOperationKey())){ + //audit审核 unaudit反审核 syncbip手动同步 三种情况进入如下代码 + String eok = e.getOperationKey(); + if("audit".equals(eok) || "unaudit".equals(eok) || "syncbip".equals(eok)){ DynamicObject[] dos = e.getDataEntities(); - DynamicObject payrequestinfo = null; + DynamicObject prinfo = null; for (int i = 0; i < dos.length; i++) { - payrequestinfo = dos[i]; - - if("recon_payreqbill".equals(payrequestinfo.getDataEntityType().getName())){ - //判断实体名称为合同付款申请单 - handleForBIP(e.getOperationKey(),payrequestinfo,false); - }else if("recon_connotextbill".equals(payrequestinfo.getDataEntityType().getName())){ + prinfo = dos[i]; + //审核时,如果用友单号已有,则不需要再推送给BIP + if("recon_payreqbill".equals(prinfo.getDataEntityType().getName()) && !prinfo.getBoolean("nocontractflag")){ + //判断实体名称为合同付款申请单,此时无合同付款 nocontractflag 不需要推送 + handleForBIP(eok,prinfo,false); + }else if("recon_connotextbill".equals(prinfo.getDataEntityType().getName())){ //无文本合同 - handleForBIP(e.getOperationKey(),payrequestinfo,true); + handleForBIP(eok,prinfo,true); } // payrequestinfo.getDynamicObjectType().getAlias();//获取数据库表名 } @@ -140,8 +141,8 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen JSONObject payData = new JSONObject(); String[] companyDept = getCompanyDeptNumber(payrequestinfo.getDynamicObject("usedepart").getString("number")); payData.put("pk_org",companyDept[0]);//财务公司组织编码,根据当前单据的用款部门获得对应关系表中的财务公司和部门 - payData.put("pk_tradetype","D3");//交易类型,传编码例:D3-采购付款单 - payData.put("billdate",DobeDWUtils.getDateString(payrequestinfo.getDate("bizdate")));//业务日期,YYYY-MM-DD + payData.put("pk_tradetype","F3-Cxx-03");//交易类型编码,传编码例:D3-采购付款单 + payData.put("billdate",DobeDWUtils.getDateString(payrequestinfo.getDate("auditDate")));//业务日期,YYYY-MM-DD String ap_recaccount = null;//收款银行账户编码 //无文本合同的个人垫付时,是业务员 boolean isgrdf = isnotext && payrequestinfo.getBoolean("qeug_grdf"); @@ -166,7 +167,10 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen payData.put("ap_payaccount",ap_payaccount);//如何取值?-从数仓获取的组织对应关系中获取默认付款银行账号 payData.put("ap_recaccount",ap_recaccount);//收款银行账户编码(客商),传编码例:3101040160000098225-上海达洋消防保安工程有限公司 payData.put("pk_balatype","07");//结算方式编码,传编码例:07-网银 - BigDecimal bcsqje = payrequestinfo.getBigDecimal("amount");//单据上的本次申请金额 + BigDecimal bcsqje = payrequestinfo.getBigDecimal("amount");//费用登记单据上的本次申请金额 + if(!isnotext){ + bcsqje = payrequestinfo.getBigDecimal("curactualamt");//付款申请单的本期应付金额 curactualamt + } payData.put("money",bcsqje.toString());//原币金额 取含税金额 payData.put("rate","1.00000000");//组织本币汇率,默认1.00000000 payData.put("local_money",bcsqje.toString());//组织本币金额 含税金额,xxxxx.00000000 @@ -186,21 +190,21 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen // String auditor = payrequestinfo.getDynamicObject("auditor").getString("number"); // payData.put("approver",auditor);//审核人编码 审核人工号 payData.put("approver",DobeDWUtils.clientid);//审核人编码 固定传ISC - payData.put("approvedate",DobeDWUtils.getDateString(payrequestinfo.getDate("auditDate")));//审核日期 YYYY-MM-DD + payData.put("approvedate",DobeDWUtils.getDateString(null));//审核日期 接口推送的日期 // payData.put("src_syscode","ISC");//单据来源系统编码 非必传 if(isnotext){ - payData.put("def11","无合同付款");//自定义项1 流程类型:有合同 无合同 + payData.put("def11","无合同付款");//自定义项11 流程类型:有合同 无合同 }else{ - payData.put("def11","合同付款");//自定义项1 流程类型:有合同 无合同 + payData.put("def11","合同付款");//自定义项11 流程类型:有合同 无合同 } - payData.put("def12",payrequestinfo.getString("billno"));//自定义项2 付款申请单的单号(全局唯一才行) - payData.put("def13","");//备注。传合同总金额及付款比例等,拼接凭证摘要 + payData.put("def12",payrequestinfo.getString("billno"));//自定义项12 付款申请单的单号(全局唯一才行) + payData.put("def13",payrequestinfo.getString("description"));//备注。传合同总金额及付款比例等,拼接凭证摘要 //------------------以下是表体组装-------------------- JSONArray jas = new JSONArray(); JSONObject items = new JSONObject(); // items.put("contractno",payrequestinfo.getDynamicObject("contractbill"));//合同号 - items.put("scomment",null);//摘要 按照现在NC57逻辑先来,涉及银企互联支付,原来是15个字符(7个中文)的样子 + items.put("scomment",payrequestinfo.getString("qeug_xf"));//摘要 按照现在NC57逻辑先来,涉及银企互联支付,原来是15个字符(7个中文)的样子 if(isgrdf){ items.put("objtype","3");//往来对象(0-客户 1-供应商 2-部门 3-业务员) @@ -265,7 +269,7 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen if(isnotext){ items.put("def13","");//供应链系统合同号,无合同怎么传递? }else{ - items.put("def13","");//供应链系统合同号 + items.put("def13",payrequestinfo.getDynamicObject("contractbill").getString("billno"));//供应链系统合同号 } items.put("def14",payrequestinfo.getString("id"));//供应链付款单ID jas.add(items); @@ -318,7 +322,7 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen if(!"true".equals(json_reuslt.getString("success"))){ log.error(String.format("用友付款接口处理失败,具体原因:%s", json_reuslt.toString())); //此时除了日志打印,增加日志记录 - DobeDWUtils.saveLog(payrequestinfo.getString("billno"),"用友BIP",payData.toString(),json_reuslt.toString(),false); + DobeDWUtils.saveLog(payrequestinfo.getString("billno"),"用友BIP",payData.toString(),json_reuslt.toString(),false,eventName); return; }else{ yynum = json_reuslt.getJSONObject("data").getString("billno"); @@ -326,27 +330,22 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen } catch (Exception e) { log.error(String.format("用友付款接口异常:%s", e.getMessage())); // throw new RuntimeException(e); - DobeDWUtils.saveLog(payrequestinfo.getString("billno"),"用友BIP",payData.toString(),e.getMessage(),false); + DobeDWUtils.saveLog(payrequestinfo.getString("billno"),"用友BIP",payData.toString(),e.getMessage(),false,eventName); } if(DobeDWUtils.isEmpty(yynum)){ log.error("用友付款接口返回的billno为空"); - DobeDWUtils.saveLog(payrequestinfo.getString("billno"),"用友BIP",payData.toString(),"用友billno为空"+json_reuslt.toString(),false); + DobeDWUtils.saveLog(payrequestinfo.getString("billno"),"用友BIP",payData.toString(),"用友billno为空"+json_reuslt.toString(),false,eventName); }else{ - //推送用友bip成功后,反写合同付款申请单的用友付款单id字段值 - String sql = "UPDATE t_xxx SET fk_qeug_yynum=? WHERE fid=?;"; + //推送用友bip成功后,反写费用登记和合同付款申请单的用友付款单id字段值 + String sql = "UPDATE t_recon_payreqbill SET fk_qeug_yynum=? WHERE fid=?;"; + if(isnotext){ + sql = "UPDATE t_recon_connotextbill SET fk_qeug_yynum=? WHERE fid=?;"; + } DB.update(DBRoute.of("scm"), sql, new Object[]{yynum, payrequestinfo.getLong("id")}); - DobeDWUtils.saveLog(payrequestinfo.getString("billno"),"用友BIP",payData.toString(),json_reuslt.toString(),true); + DobeDWUtils.saveLog(payrequestinfo.getString("billno"),"用友BIP",payData.toString(),json_reuslt.toString(),true,eventName); } } - private void handleWithOutContract(String eventName, DynamicObject payrequestinfo){ - //处理无文本合同的审核推送用友bip - String yyid = null;//用友单据id - //推送用友bip成功后,反写无文本合同的用友付款单id字段值 - String sql = "UPDATE t_recon_connotextbill SET fk_qeug_yynum=? WHERE fid=?;"; - DB.update(DBRoute.of("scm"), sql, new Object[]{yyid, payrequestinfo.getLong("id")}); - } - private String getSupplierType(long supplierid){ //根据供应商id从供应商F7中得到供应商的分类标准 DynamicObject supinfo = BusinessDataServiceHelper.loadSingle("resm_supplier_f7",new QFilter[]{new QFilter("id","=",supplierid)}); diff --git a/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/repc/task/YongyouBIPTask.java b/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/repc/task/YongyouBIPTask.java index b314767..d31d0fe 100644 --- a/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/repc/task/YongyouBIPTask.java +++ b/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/repc/task/YongyouBIPTask.java @@ -1,6 +1,9 @@ package shkd.repc.task; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import kd.bos.context.RequestContext; +import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.exception.KDException; @@ -8,7 +11,10 @@ import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import kd.bos.orm.query.QFilter; import kd.bos.schedule.executor.AbstractTask; +import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.QueryServiceHelper; +import kd.bos.servicehelper.operation.OperationServiceHelper; +import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.sdk.plugin.Plugin; import java.util.Map; @@ -23,17 +29,44 @@ public class YongyouBIPTask extends AbstractTask implements Plugin { private static final String payrequestEntity = "recon_payreqbill"; //费用登记的实体名称 private static final String notextEntity = "recon_connotextbill"; + private static final String payregisterEntity = "recon_payregister";//供应链库 t_recon_payregister @Override public void execute(RequestContext requestContext, Map map) throws KDException { //查找合同付款申请单已审核未付款的单子 - DynamicObjectCollection docs = QueryServiceHelper.query(payrequestEntity,"id,number,name",new QFilter[]{new QFilter("billstatus","=","C")}); - DynamicObject currentinfo = null; - for (int i = 0; i < docs.size(); i++) { - currentinfo = docs.get(i); - } +// DynamicObjectCollection docs = QueryServiceHelper.query(payrequestEntity,"id,number,name",new QFilter[]{new QFilter("billstatus","=","C")}); +// DynamicObject currentinfo = null; +// for (int i = 0; i < docs.size(); i++) { +// currentinfo = docs.get(i); +// } //查找无文本合同已审核未付款的单子 + //查找未审核的付款登记单,考虑费用登记和付款申请单如果是事后补单的话,此处是否需要过滤 + QFilter statusFilter = new QFilter("billstatus","=","A"); + String selectStr = "id,billno,bizdate,connotextbill.id,connotextbill.billno,connotextbill.qeug_yynum,payreqbill.id,payreqbill.billno,payreqbill.qeug_yynum"; + DynamicObject[] prs = BusinessDataServiceHelper.load(payregisterEntity,selectStr,new QFilter[]{statusFilter}); + DynamicObject prinfo = null; + DynamicObject requestinfo = null; + String yynum = null; + for (int i = 0; i < prs.length; i++) { + prinfo = prs[i]; + //费用登记 + requestinfo = prinfo.getDynamicObject("connotextbill"); + if(requestinfo == null){ + //付款申请 + requestinfo = prinfo.getDynamicObject("payreqbill"); + } + //看用友的实付款查询接口是一个个查询,还是集中查询 + yynum = requestinfo.getString("qeug_yynum"); + JSONObject resultData = JSON.parseObject("用友接口返回值"); + //根据查询结果设置付款登记对象 + prinfo.set("bizdate",resultData.getDate("bizdate")); + prinfo.set("billno",resultData.getString("billno")); + prinfo.set("status","B"); //单据状态改为已提交 + SaveServiceHelper.update(prinfo);//保存上述设置内容 + //调用付款登记单的审核方法 + OperationServiceHelper.executeOperate("audit",payregisterEntity,new DynamicObject[]{prinfo}, OperateOption.create()); + } } } \ No newline at end of file diff --git a/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/utils/DobeDWUtils.java b/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/utils/DobeDWUtils.java index 9876e6d..d82da5c 100644 --- a/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/utils/DobeDWUtils.java +++ b/fi/fi/shkd-fi-fi-plugin/src/main/java/shkd/utils/DobeDWUtils.java @@ -45,15 +45,16 @@ public class DobeDWUtils { return value == null || value.trim().length() <= 0; } - public static void saveLog(String billno,String jkname,String inputs,String outputs,boolean isSuccess){ + public static void saveLog(String billno,String jkname,String inputs,String outputs,boolean isSuccess,String operation){ //保存星瀚与第三方接口调用之间的日志记录 - //参数说明:单据编号、接口名称、接口入参、接口返回值、接口执行结果是否成功 + //参数说明:单据编号、接口名称、接口入参、接口返回值、接口执行结果是否成功、操作名称(audit、unaudit等) DynamicObject billinfo = BusinessDataServiceHelper.newDynamicObject(jklogEntityName); billinfo.set("number",billno); billinfo.set("name",jkname); billinfo.set("qeug_inputs_tag",inputs);//大文本赋值,标识后加_tag 是内容,不加是文本标题 billinfo.set("qeug_outputs_tag",outputs); billinfo.set("qeug_issuccess",isSuccess); + billinfo.set("qeug_operation",operation); billinfo.set("status","A"); //单据状态默认暂存 SaveServiceHelper.save(new DynamicObject[]{billinfo}); }