Procházet zdrojové kódy

业务处理单问题处理/发票助手改造

徐昊 před 10 měsíci
rodič
revize
fdf94251e2

+ 130 - 108
src/main/java/fi/em/editPlugin/BusinessProcessingEditPlugin.java

@@ -38,70 +38,70 @@ public class BusinessProcessingEditPlugin extends AbstractListPlugin implements
         if (btn_cysgzmx.equals(e.getOperateKey())) {
             Object value = this.getModel().getValue("nckd_payeenamev");//获取当前单据付款人
             Object nckd_orgv = this.getModel().getValue("nckd_orgv");//获取当前单据付款人
-            DynamicObject dynamicObject = (DynamicObject)value;
-            DynamicObject orgv = (DynamicObject)nckd_orgv;
-            if (dynamicObject == null){
+            DynamicObject dynamicObject = (DynamicObject) value;
+            DynamicObject orgv = (DynamicObject) nckd_orgv;
+            if (dynamicObject == null) {
                 throw new KDBizException("收款信息付款人为空!");
             }
-            if (orgv == null){
+            if (orgv == null) {
                 throw new KDBizException("收款信息收款人为空!");
             }
             String payeenamev = dynamicObject.getString("name");//当前单据付款供应商
             String orgnumber = orgv.getString("number");
-            nckd_agentparameterf7="nckd_cyfgzmxf7";
-            showParameter(nckd_agentparameterf7, btn_cysgzmx,payeenamev,btn_cysgzmx,orgnumber);//调用弹出页面
-        }else if (btn_cyfgzmx.equals(e.getOperateKey())) {
+            nckd_agentparameterf7 = "nckd_cysgzmxf7";
+            showParameter(nckd_agentparameterf7, btn_cysgzmx, payeenamev, btn_cysgzmx, orgnumber);//调用弹出页面
+        } else if (btn_cyfgzmx.equals(e.getOperateKey())) {
             Object value = this.getModel().getValue("nckd_payeenamevs");//获取当前单据付款人
             Object nckd_orgvs = this.getModel().getValue("nckd_orgvs");//获取当前单据收款人
-            DynamicObject dynamicObject = (DynamicObject)value;
-            DynamicObject orgvs = (DynamicObject)nckd_orgvs;
-            if (dynamicObject == null){
+            DynamicObject dynamicObject = (DynamicObject) value;
+            DynamicObject orgvs = (DynamicObject) nckd_orgvs;
+            if (dynamicObject == null) {
                 throw new KDBizException("付款信息收款人为空!");
             }
-            if (orgvs == null){
+            if (orgvs == null) {
                 throw new KDBizException("付款信息付款人为空!");
             }
             String payeenamev = dynamicObject.getString("number");//当前单据付款供应商编码
             String orgnumber = orgvs.getString("number");
-            nckd_agentparameterf7="nckd_cysgzmxf7";
-            showParameter(nckd_agentparameterf7, btn_cyfgzmx,payeenamev,btn_cyfgzmx,orgnumber);//调用弹出页面
-        } else if (btn_pzht.equals(e.getOperateKey())){
+            nckd_agentparameterf7 = "nckd_cyfgzmxf7";
+            showParameter(nckd_agentparameterf7, btn_cyfgzmx, payeenamev, btn_cyfgzmx, orgnumber);//调用弹出页面
+        } else if (btn_pzht.equals(e.getOperateKey())) {
             Object value = this.getModel().getValue("nckd_orgv");//获取当前单据核算组织
             Object nckd_payeenamevs = this.getModel().getValue("nckd_payeenamev");//获取当前单据付款人
-            DynamicObject dynamicObject = (DynamicObject)value;
-            DynamicObject payeenamevs = (DynamicObject)nckd_payeenamevs;
-            if (dynamicObject == null){
+            DynamicObject dynamicObject = (DynamicObject) value;
+            DynamicObject payeenamevs = (DynamicObject) nckd_payeenamevs;
+            if (dynamicObject == null) {
                 throw new KDBizException("收款信息收款人为空!");
             }
-            if (payeenamevs == null){
+            if (payeenamevs == null) {
                 throw new KDBizException("收款信息付款人为空!");
             }
             String payeenamev = dynamicObject.getString("number");//当前单据付款供应商编码
-            String nckdpayeenamevs = payeenamevs.getString("name");//当前单据付款供应商编码
-            nckd_agentparameterf7="nckd_pzhtf7";
-            showParameter(nckd_agentparameterf7, btn_pzht,nckdpayeenamevs,btn_pzht,payeenamev);//调用弹出页面
-        }else if (btn_skskzh.equals(e.getOperateKey())){
+            String nckdpayeenamevs = payeenamevs.getString("number");//当前单据付款供应商编码
+            nckd_agentparameterf7 = "nckd_pzhtf7";
+            showParameter(nckd_agentparameterf7, btn_pzht, nckdpayeenamevs, btn_pzht, payeenamev);//调用弹出页面
+        } else if (btn_skskzh.equals(e.getOperateKey())) {
             Object value = this.getModel().getValue("nckd_payeenamev");//获取当前收款信息付款人
-            DynamicObject dynamicObject = (DynamicObject)value;
-            if (dynamicObject == null){
+            DynamicObject dynamicObject = (DynamicObject) value;
+            if (dynamicObject == null) {
                 throw new KDBizException("收款信息付款人为空!");
             }
             String payeenamev = dynamicObject.getString("number");//当前单据付款供应商编码
-            nckd_agentparameterf7="nckd_supplierbank";
-            showParameter(nckd_agentparameterf7, btn_skskzh,payeenamev,btn_skskzh,"");//调用弹出页面
-        }else if (btn_fkfkzh.equals(e.getOperateKey())){
+            nckd_agentparameterf7 = "nckd_supplierbank";
+            showParameter(nckd_agentparameterf7, btn_skskzh, payeenamev, btn_skskzh, "");//调用弹出页面
+        } else if (btn_fkfkzh.equals(e.getOperateKey())) {
             Object value = this.getModel().getValue("nckd_payeenamevs");//获取当前付款信息付款人
-            DynamicObject dynamicObject = (DynamicObject)value;
-            if (dynamicObject == null){
+            DynamicObject dynamicObject = (DynamicObject) value;
+            if (dynamicObject == null) {
                 throw new KDBizException("付款信息收款人为空!");
             }
             String payeenamev = dynamicObject.getString("number");//当前单据付款供应商编码
-            nckd_agentparameterf7="nckd_supplierbank";
-            showParameter(nckd_agentparameterf7, btn_fkfkzh,payeenamev,btn_fkfkzh,"");//调用弹出页面
+            nckd_agentparameterf7 = "nckd_supplierbank";
+            showParameter(nckd_agentparameterf7, btn_fkfkzh, payeenamev, btn_fkfkzh, "");//调用弹出页面
         }
     }
 
-    public void showParameter(String formId, String actionId,String payeenamev,String controls,String orgnumber) {
+    public void showParameter(String formId, String actionId, String payeenamev, String controls, String orgnumber) {
         //创建弹出页面对象,FormShowParameter表示弹出页面为动态表单
         FormShowParameter ShowParameter = new FormShowParameter();
         //ListShowParameter ShowParameter = new ListShowParameter();
@@ -113,7 +113,7 @@ public class BusinessProcessingEditPlugin extends AbstractListPlugin implements
         ShowParameter.setFormId(formId);
 //        ShowParameter.setCaption();
         //设置弹出页面标题
-        if("cysgzmx".equals(actionId)){
+        if ("cysgzmx".equals(actionId)) {
             ShowParameter.setCaption("冲应收挂账");
         } else if ("cyfgzmx".equals(actionId)) {
             ShowParameter.setCaption("冲应付挂账");
@@ -126,12 +126,13 @@ public class BusinessProcessingEditPlugin extends AbstractListPlugin implements
         //弹出页面对象赋值给父页面
         this.getView().showForm(ShowParameter);
     }
+
     @Override
     public void closedCallBack(ClosedCallBackEvent e) {
         super.closedCallBack(e);
-        if ( null != e.getReturnData()) {
-            String billtype="";
-            String controls="";
+        if (null != e.getReturnData()) {
+            String billtype = "";
+            String controls = "";
             //父页面返回参数
             HashMap<String, String> returnData = (HashMap<String, String>) e.getReturnData();
             String reJaStr = returnData.get("reJaStr");
@@ -142,64 +143,66 @@ public class BusinessProcessingEditPlugin extends AbstractListPlugin implements
                 billtype = reJos.getString("billtype");
                 controls = reJos.getString("controls");
                 //删除分录信息
-                if(btn_cysgzmx.equals(controls)){
+                if (btn_cysgzmx.equals(controls)) {
                     this.getModel().deleteEntryData("nckd_entryentity1");
                 } else if (btn_cyfgzmx.equals(controls)) {
                     this.getModel().deleteEntryData("nckd_entryentity2");
-                }else if (btn_pzht.equals(controls)) {
+                } else if (btn_pzht.equals(controls)) {
                     this.getModel().deleteEntryData("nckd_entryentity3");
                 }
                 //循环返回数组插入分录
-                for(int i =0;i<reJa.size();i++){
+                for (int i = 0; i < reJa.size(); i++) {
                     //当前循环行
                     JSONObject reJo = reJa.getJSONObject(i);
                     billtype = reJo.getString("billtype");
                     controls = reJo.getString("controls");
-                    if(btn_cysgzmx.equals(controls)){
-                    String billno = reJo.getString("nckd_cysnumber");
-                    String cysfyxm = reJo.getString("nckd_cysfyxm");
-                    String settleorg = reJo.getString("settleorg");
-                    QFilter nckd_cysfyxmFilter = new QFilter("number", QCP.equals,cysfyxm);
-                    DynamicObject nckd_cysfyxm = BusinessDataServiceHelper.loadSingle("er_expenseitemedit","id",new QFilter[] {nckd_cysfyxmFilter});
-                    Date bizdate = reJo.getDate("nckd_cysdata");
-                    BigDecimal settleamount = reJo.getBigDecimal("nckd_cysgzbalance");
-                    //新增分录行
-                    int rowIndex = this.getModel().createNewEntryRow("nckd_entryentity1");
-                    //set分录字段
-                    this.getModel().setValue("nckd_cysnumber", billno, rowIndex);
-                    QFilter nckd_orgamountFilter = new QFilter("number", QCP.equals,settleorg);
-                    nckd_orgamountFilter.and("enable", QCP.equals,"1");
-                    DynamicObject nckd_org = BusinessDataServiceHelper.loadSingle(bos_org,"id",new QFilter[] {nckd_orgamountFilter});
-                    this.getModel().setValue("nckd_cysorg", nckd_org, rowIndex);
-                    Object nckd_costdept = this.getModel().getValue("nckd_costdept");//获取当前单据付款人
-                    DynamicObject costdept = (DynamicObject)nckd_costdept;
-                    this.getModel().setValue("nckd_cyssection", costdept, rowIndex);
-                    Object value = this.getModel().getValue("nckd_payeenamev");//获取当前单据付款人
-                    DynamicObject dynamicObject = (DynamicObject)value;
-                    this.getModel().setValue("nckd_cyswldw", dynamicObject, rowIndex);
-                    this.getModel().setValue("nckd_cysdata", bizdate, rowIndex);
-                    this.getModel().setValue("nckd_cysgzbalance", settleamount, rowIndex);
-                    this.getModel().setValue("nckd_cyscxbalance", settleamount, rowIndex);
-                    if(cysfyxm!=null && !cysfyxm.isEmpty()){
-                        this.getModel().setValue("nckd_cysfyxm", nckd_cysfyxm, rowIndex);
-                    }
-                    String cysgzbalance = this.getModel().getValue("nckd_ysgzjehj").toString();
-                    BigDecimal bigDecimal = new BigDecimal(cysgzbalance);
-                    this.getModel().setValue("nckd_ysgzjehj",bigDecimal.add(settleamount),0);
+                    if (btn_cysgzmx.equals(controls)) {
+                        String billno = reJo.getString("nckd_cysnumber");
+                        String cysfyxm = reJo.getString("nckd_cysfyxm");
+                        String settleorg = reJo.getString("settleorg");
+                        String expectdate = reJo.getString("expectdate");
+                        QFilter nckd_cysfyxmFilter = new QFilter("number", QCP.equals, cysfyxm);
+                        DynamicObject nckd_cysfyxm = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "id", new QFilter[]{nckd_cysfyxmFilter});
+                        Date bizdate = reJo.getDate("nckd_cysdata");
+                        BigDecimal settleamount = reJo.getBigDecimal("nckd_cysgzbalance");
+                        //新增分录行
+                        int rowIndex = this.getModel().createNewEntryRow("nckd_entryentity1");
+                        //set分录字段
+                        this.getModel().setValue("nckd_cysnumber", billno, rowIndex);
+                        QFilter nckd_orgamountFilter = new QFilter("number", QCP.equals, settleorg);
+                        nckd_orgamountFilter.and("enable", QCP.equals, "1");
+                        DynamicObject nckd_org = BusinessDataServiceHelper.loadSingle(bos_org, "id", new QFilter[]{nckd_orgamountFilter});
+                        this.getModel().setValue("nckd_cysorg", nckd_org, rowIndex);
+                        Object nckd_costdept = this.getModel().getValue("nckd_costdept");//获取当前单据付款人
+                        DynamicObject costdept = (DynamicObject) nckd_costdept;
+                        this.getModel().setValue("nckd_cyssection", costdept, rowIndex);
+                        Object value = this.getModel().getValue("nckd_payeenamev");//获取当前单据付款人
+                        DynamicObject dynamicObject = (DynamicObject) value;
+                        this.getModel().setValue("nckd_cyswldw", dynamicObject, rowIndex);
+                        this.getModel().setValue("nckd_datefield", expectdate, rowIndex);
+                        this.getModel().setValue("nckd_cysdata", bizdate, rowIndex);
+                        this.getModel().setValue("nckd_cysgzbalance", settleamount, rowIndex);
+                        this.getModel().setValue("nckd_cyscxbalance", settleamount, rowIndex);
+                        if (cysfyxm != null && !cysfyxm.isEmpty()) {
+                            this.getModel().setValue("nckd_cysfyxm", nckd_cysfyxm, rowIndex);
+                        }
+                        String cysgzbalance = this.getModel().getValue("nckd_ysgzjehj").toString();
+                        BigDecimal bigDecimal = new BigDecimal(cysgzbalance);
+                        this.getModel().setValue("nckd_ysgzjehj", bigDecimal.add(settleamount), 0);
                     } else if (btn_pzht.equals(controls)) {
                         //核算组织
                         String pzhtorg = reJo.getString("nckd_pzhtorg");
-                        QFilter nckd_orgamountFilter = new QFilter("number", QCP.equals,pzhtorg);
-                        nckd_orgamountFilter.and("enable", QCP.equals,"1");
-                        DynamicObject nckd_pzhtorg = BusinessDataServiceHelper.loadSingle(bos_org,"id",new QFilter[] {nckd_orgamountFilter});
+                        QFilter nckd_orgamountFilter = new QFilter("number", QCP.equals, pzhtorg);
+                        nckd_orgamountFilter.and("enable", QCP.equals, "1");
+                        DynamicObject nckd_pzhtorg = BusinessDataServiceHelper.loadSingle(bos_org, "id", new QFilter[]{nckd_orgamountFilter});
                         //合同号
                         String pzhthth = reJo.getString("nckd_pzhthth");
                         //合同名称
                         String pzhtname = reJo.getString("nckd_pzhtname");
                         //承租方
                         String pzhtczf = reJo.getString("nckd_pzhtczf");
-                        QFilter nckd_pzhtczfFilter = new QFilter("number", QCP.equals,pzhtczf);
-                        DynamicObject nckd_pzhtczf = BusinessDataServiceHelper.loadSingle("bd_supplier","id",new QFilter[] {nckd_pzhtczfFilter});
+                        QFilter nckd_pzhtczfFilter = new QFilter("number", QCP.equals, pzhtczf);
+                        DynamicObject nckd_pzhtczf = BusinessDataServiceHelper.loadSingle("bd_supplier", "id", new QFilter[]{nckd_pzhtczfFilter});
                         //资产名称
                         String pzhtzcname = reJo.getString("nckd_pzhtzcname");
                         //合同签订日期
@@ -224,35 +227,37 @@ public class BusinessProcessingEditPlugin extends AbstractListPlugin implements
                         Date bizdate = reJo.getDate("nckd_cyfdata");
                         String nckdCyffyxm = reJo.getString("nckd_cyffyxm");
                         String settleorg = reJo.getString("settleorg");
-                        QFilter nckd_cysfyxmFilter = new QFilter("number", QCP.equals,nckdCyffyxm);
-                        DynamicObject nckd_cyffyxm = BusinessDataServiceHelper.loadSingle("er_expenseitemedit","id",new QFilter[] {nckd_cysfyxmFilter});
+                        String duedate = reJo.getString("duedate");
+                        QFilter nckd_cysfyxmFilter = new QFilter("number", QCP.equals, nckdCyffyxm);
+                        DynamicObject nckd_cyffyxm = BusinessDataServiceHelper.loadSingle("er_expenseitemedit", "id", new QFilter[]{nckd_cysfyxmFilter});
                         BigDecimal settleamount = reJo.getBigDecimal("nckd_cyfgzbalance");
                         //新增分录行
                         int rowIndex = this.getModel().createNewEntryRow("nckd_entryentity2");
                         //set分录字段
                         this.getModel().setValue("nckd_cyfnumber", billno, rowIndex);
-                        QFilter nckd_orgamountFilter = new QFilter("number", QCP.equals,settleorg);
-                        nckd_orgamountFilter.and("enable", QCP.equals,"1");
-                        DynamicObject nckd_org = BusinessDataServiceHelper.loadSingle(bos_org,"id",new QFilter[] {nckd_orgamountFilter});
+                        QFilter nckd_orgamountFilter = new QFilter("number", QCP.equals, settleorg);
+                        nckd_orgamountFilter.and("enable", QCP.equals, "1");
+                        DynamicObject nckd_org = BusinessDataServiceHelper.loadSingle(bos_org, "id", new QFilter[]{nckd_orgamountFilter});
                         this.getModel().setValue("nckd_cyforg", nckd_org, rowIndex);
                         Object value = this.getModel().getValue("nckd_payeenamevs");//获取当前单据付款人
-                        DynamicObject dynamicObjects = (DynamicObject)value;
+                        DynamicObject dynamicObjects = (DynamicObject) value;
                         this.getModel().setValue("nckd_cyfwldw", dynamicObjects, rowIndex);
                         this.getModel().setValue("nckd_cyfdata", bizdate, rowIndex);
+                        this.getModel().setValue("nckd_datefield1", duedate, rowIndex);
                         this.getModel().setValue("nckd_cyfgzbalance", settleamount, rowIndex);
                         this.getModel().setValue("nckd_cyfcxbalance", settleamount, rowIndex);
-                        if(nckdCyffyxm!=null && !nckdCyffyxm.isEmpty()){
+                        if (nckdCyffyxm != null && !nckdCyffyxm.isEmpty()) {
                             this.getModel().setValue("nckd_cyffyxm", nckd_cyffyxm, rowIndex);
                         }
                         String cysgzbalance = this.getModel().getValue("nckd_yfgzjehj").toString();
                         BigDecimal bigDecimal = new BigDecimal(cysgzbalance);
-                        this.getModel().setValue("nckd_yfgzjehj",bigDecimal.add(settleamount),0);
-                    }else if (btn_skskzh.equals(controls)) {
+                        this.getModel().setValue("nckd_yfgzjehj", bigDecimal.add(settleamount), 0);
+                    } else if (btn_skskzh.equals(controls)) {
                         String nckd_bankaccount = reJo.getString("nckd_bankaccount");
                         String nckd_accountname = reJo.getString("nckd_accountname");
                         this.getModel().setValue("nckd_payeebanknumlb", nckd_bankaccount);
                         this.getModel().setValue("nckd_payeebanknamelb", nckd_accountname);
-                    }else if (btn_fkfkzh.equals(controls)) {
+                    } else if (btn_fkfkzh.equals(controls)) {
                         String nckd_bankaccount = reJo.getString("nckd_bankaccount");
                         String nckd_accountname = reJo.getString("nckd_accountname");
                         this.getModel().setValue("nckd_payeebanknumlbs", nckd_bankaccount);
@@ -270,36 +275,53 @@ public class BusinessProcessingEditPlugin extends AbstractListPlugin implements
             }
         }
     }
- /*   @Override
+
+    @Override
     public void propertyChanged(PropertyChangedArgs e) {
         super.beforePropertyChanged(e);
         String name = e.getProperty().getName();//获取字段标识
-        if ("nckd_skamount".equals(name)) {
+        if ("nckd_payeraccbanknum".equals(name)) {
+            ChangeData[] changeSet = e.getChangeSet();//获取值
+            for (ChangeData changeData : changeSet) {
+                int rowIndex = changeData.getRowIndex();
+                Object newValue = changeData.getNewValue();
+                Object oldValue = changeData.getOldValue();
+                DynamicObject payeenamevs = (DynamicObject) newValue;
+                DynamicObject bank = payeenamevs.getDynamicObject("bank");
+                this.getModel().setValue("nckd_payerbank", bank, rowIndex);
+            }
+        } else if ("nckd_payeeaccbanknum".equals(name)) {
             ChangeData[] changeSet = e.getChangeSet();//获取值
             for (ChangeData changeData : changeSet) {
-                String newValue = changeData.getNewValue().toString();
-                String oldValue =changeData.getOldValue().toString();
-                BigDecimal newValues = new BigDecimal(newValue);
-                BigDecimal oldValues = new BigDecimal(oldValue);
-                String skmxjehj = this.getModel().getValue("nckd_skmxjehj").toString();
-                BigDecimal bigDecimal = new BigDecimal(skmxjehj);
-                bigDecimal=bigDecimal.subtract(oldValues);
-                bigDecimal=bigDecimal.add(newValues);
-                this.getModel().setValue("nckd_skmxjehj", bigDecimal, 0);
+                int rowIndex = changeData.getRowIndex();
+                Object newValue = changeData.getNewValue();
+                Object oldValue = changeData.getOldValue();
+                DynamicObject payeenamevs = (DynamicObject) newValue;
+                DynamicObject bank = payeenamevs.getDynamicObject("bank");
+                this.getModel().setValue("nckd_payeebank", bank, rowIndex);
             }
-        } else if ("nckd_fkamount".equals(name)) {
+        }/*else if ("nckd_payeenamev".equals(name)) {
             ChangeData[] changeSet = e.getChangeSet();//获取值
             for (ChangeData changeData : changeSet) {
-                String newValue = changeData.getNewValue().toString();
-                String oldValue =changeData.getOldValue().toString();
-                BigDecimal newValues = new BigDecimal(newValue);
-                BigDecimal oldValues = new BigDecimal(oldValue);
-                String skmxjehj = this.getModel().getValue("nckd_fkmxjehj").toString();
-                BigDecimal bigDecimal = new BigDecimal(skmxjehj);
-                bigDecimal=bigDecimal.subtract(oldValues);
-                bigDecimal=bigDecimal.add(newValues);
-                this.getModel().setValue("nckd_fkmxjehj", bigDecimal, 0);
+                int rowIndex = changeData.getRowIndex();
+                Object newValue = changeData.getNewValue();
+                Object oldValue = changeData.getOldValue();
+                DynamicObject payeenamevs = (DynamicObject) newValue;
+                //构建查询供应商参数
+                QFilter nckd_orgamountFilter = new QFilter("number", QCP.equals, payeenamevs.getString("number"));
+                DynamicObject[] fa_lease_contract = BusinessDataServiceHelper.load("bd_supplier", "id", new QFilter[]{nckd_orgamountFilter});
+                for (int c = 0; c < fa_lease_contract.length; c++) {
+                    //当前单头
+                    DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(fa_lease_contract[c].getPkValue(), fa_lease_contract[c].getDynamicObjectType().getName());
+                    for (DynamicObject entryentity : dynamicObject.getDynamicObjectCollection("entry_bank")) {
+                        String bankaccount = entryentity.getString("bankaccount");
+                        String accountname = entryentity.getString("accountname");
+                        this.getModel().setValue("nckd_payeebanknumlb", bankaccount,rowIndex);
+                        this.getView().updateView("nckd_payeebanknumlb");
+                    }
+                }
             }
+            }*/
         }
-    }*/
-}
+    }
+

+ 13 - 3
src/main/java/fi/em/formPlugin/BusinessProcessingPlugin.java

@@ -106,6 +106,7 @@ public class BusinessProcessingPlugin extends AbstractFormPlugin implements Plug
                 String billno = dynamicObject.getString("billno");
                 //应收挂账日期
                 Date bizdate = dynamicObject.getDate("bizdate");
+                Date expectdate = dynamicObject.getDate("expectdate");
                 //应收挂账金额/冲销金额
                 BigDecimal settleamount = dynamicObject.getBigDecimal("unsettleamount");
                 for (DynamicObject entryentity : dynamicObject.getDynamicObjectCollection("entry")) {
@@ -125,6 +126,10 @@ public class BusinessProcessingPlugin extends AbstractFormPlugin implements Plug
                     this.getModel().setValue("nckd_cysdata", bizdate, rowIndex);
                     this.getModel().setValue("nckd_cysgzbalance", settleamount, rowIndex);
                     this.getModel().setValue("nckd_cyscxbalance", settleamount, rowIndex);
+                    this.getModel().setValue("nckd_datefield", expectdate, rowIndex);
+                    QFilter nckd_cysfyxmFilter = new QFilter("name", QCP.equals,payeenamev);
+                    DynamicObject nckd_cyffyxm = BusinessDataServiceHelper.loadSingle("bd_supplier","id",new QFilter[] {nckd_cysfyxmFilter});
+                    this.getModel().setValue("nckd_e_fundflowitem", nckd_cyffyxm, rowIndex);
                     //分录数据
                     if (eMaterial != null) {
                         this.getModel().setValue("nckd_materielfield", eMaterial, rowIndex);
@@ -160,6 +165,7 @@ public class BusinessProcessingPlugin extends AbstractFormPlugin implements Plug
                     JSONObject obj = new JSONObject();
                     obj.put("nckd_cysnumber", billno);
                     obj.put("nckd_cysdata", bizdate);
+                    obj.put("expectdate", expectdate);
                     obj.put("settleorg", settleorg.getString("number"));
                     if (eExpenseitem != null) {
                         obj.put("nckd_cysfyxm", eExpenseitem.getString("number"));
@@ -195,6 +201,7 @@ public class BusinessProcessingPlugin extends AbstractFormPlugin implements Plug
                 String billno = dynamicObject.getString("billno");
                 //应收挂账日期
                 Date bizdate = dynamicObject.getDate("bizdate");
+                Date duedate = dynamicObject.getDate("duedate");
                 DynamicObject org = dynamicObject.getDynamicObject("org");
                 //应收挂账金额/冲销金额
                 BigDecimal settleamount = dynamicObject.getBigDecimal("unsettleamount");
@@ -211,10 +218,13 @@ public class BusinessProcessingPlugin extends AbstractFormPlugin implements Plug
                     //赋值给新增分录
                     this.getModel().setValue("nckd_cyfnumber", billno, rowIndex);
                     this.getModel().setValue("nckd_cyfdata", bizdate, rowIndex);
-                    this.getModel().setValue("nckd_datefield", bizdate, rowIndex);
+                    this.getModel().setValue("nckd_datefield", duedate, rowIndex);
                     this.getModel().setValue("nckd_cyforg", org, rowIndex);
                     this.getModel().setValue("nckd_cyfgzbalance", settleamount, rowIndex);
                     this.getModel().setValue("nckd_cyfcxbalance", settleamount, rowIndex);
+                    QFilter nckd_cysfyxmFilter = new QFilter("number", QCP.equals,payeenamev);
+                    DynamicObject nckd_cyffyxm = BusinessDataServiceHelper.loadSingle("bd_supplier","id",new QFilter[] {nckd_cysfyxmFilter});
+                    this.getModel().setValue("nckd_basedatafield", nckd_cyffyxm, rowIndex);
                     //分录字段
                     if (material != null) {
                         this.getModel().setValue("nckd_materielfield", material, rowIndex);
@@ -237,6 +247,7 @@ public class BusinessProcessingPlugin extends AbstractFormPlugin implements Plug
                     obj.put("nckd_cyfnumber", billno);
                     obj.put("nckd_cyfwldw", "");
                     obj.put("nckd_cyfdata", bizdate);
+                    obj.put("duedate", duedate);
                     obj.put("nckd_cyfgzbalance", settleamount);
                     obj.put("settleorg", org.getString("number"));
                     if (expenseitem != null) {
@@ -259,9 +270,8 @@ public class BusinessProcessingPlugin extends AbstractFormPlugin implements Plug
             this.getModel().deleteEntryData("nckd_entryentity");
             //构建查询应收挂账单参数
             QFilter nckd_orgamountFilter = new QFilter("org.number", QCP.equals,orgnumber);
-            nckd_orgamountFilter.and("status", QCP.equals, "C");
+            //nckd_orgamountFilter.and("status", QCP.equals, "C");
             nckd_orgamountFilter.and("nckd_amountfield1", QCP.large_than, new BigDecimal(0));
-            nckd_orgamountFilter.and("nckd_amountfield1", QCP.is_notnull, "");
             nckd_orgamountFilter.and("leaser.number", QCP.equals, payeenamev);
             DynamicObject[] fa_lease_contract = BusinessDataServiceHelper.load("fa_lease_contract", "id", new QFilter[]{nckd_orgamountFilter});
             for (int c = 0; c < fa_lease_contract.length; c++) {

+ 1 - 6
src/main/java/fi/em/formPlugin/YwclF7ListtenerFromPlugin.java

@@ -59,12 +59,7 @@ public class YwclF7ListtenerFromPlugin extends AbstractBillPlugIn implements Plu
         if (StringUtils.equals(fieldKey, nckd_payeeaccbanknum)){
             this.getQFilters(beforeF7SelectEvent,nckd_payeeaccbanknum);
         }
-        if (StringUtils.equals(fieldKey, nckd_payeebanknumlb)){
-            this.getQFiltersfk(beforeF7SelectEvent,nckd_payeebanknumlb);
-        }
-        if (StringUtils.equals(fieldKey, nckd_payeebanknumlbs)){
-            this.getQFiltersfk(beforeF7SelectEvent,nckd_payeebanknumlbs);
-        }
+
     }
 
     private void getQFilter(BeforeF7SelectEvent arg0, String type) {

+ 23 - 5
src/main/java/fi/em/opplugin/BusinessProcessingOpPlugin.java

@@ -20,14 +20,14 @@ public class BusinessProcessingOpPlugin extends AbstractOperationServicePlugIn {
             //当前单头数据包
             DynamicObject info = BusinessDataServiceHelper.loadSingle(dynamicObjects[i].getPkValue(), dynamicObjects[i].getDynamicObjectType().getName());
             String detailtype = info.getString("nckd_detailtype");
-            if("A".equals(detailtype)){
+            if ("A".equals(detailtype)) {
                 DynamicObjectCollection nckdEntryentity1 = info.getDynamicObjectCollection("nckd_entryentity1");
-                if(!nckdEntryentity1.isEmpty()){
+                if (!nckdEntryentity1.isEmpty()) {
                     BigDecimal nckdSkmxjehj = info.getBigDecimal("nckd_skmxjehj");
                     BigDecimal nckdYsgzjehj = info.getBigDecimal("nckd_ysgzjehj");
                     double latitudeDou = nckdSkmxjehj.doubleValue();
                     double latitudeDous = nckdYsgzjehj.doubleValue();
-                    if(latitudeDou!=latitudeDous){
+                    if (latitudeDou != latitudeDous) {
                         throw new KDBizException("收款金额与冲销金额不一致!");
                     }
                 }
@@ -36,10 +36,28 @@ public class BusinessProcessingOpPlugin extends AbstractOperationServicePlugIn {
                 BigDecimal nckdYfgzjehj = info.getBigDecimal("nckd_yfgzjehj");
                 double latitudeDou = nckdFkmxjehj.doubleValue();
                 double latitudeDous = nckdYfgzjehj.doubleValue();
-                if(latitudeDou!=latitudeDous){
+                if (latitudeDou != latitudeDous) {
                     throw new KDBizException("付款金额与冲销金额不一致!");
                 }
             }
+            int count =0;
+            for (DynamicObject entryentity : info.getDynamicObjectCollection("nckd_entryentity2")) {
+                count++;
+                BigDecimal nckdCyfcxbalance = entryentity.getBigDecimal("nckd_cyfcxbalance");//冲销金额
+                BigDecimal nckdCyfgzbalance = entryentity.getBigDecimal("nckd_cyfgzbalance");//应付挂账
+                if(nckdCyfcxbalance.compareTo(nckdCyfgzbalance) == 1){
+                    throw new KDBizException("冲应付挂账明细第"+count+"行冲销金额大于应付挂账余额");
+                }
+            }
+            int counts =0;
+            for (DynamicObject entryentity : info.getDynamicObjectCollection("nckd_entryentity1")) {
+                counts++;
+                BigDecimal nckd_cyscxbalance = entryentity.getBigDecimal("nckd_cyscxbalance");//冲销金额
+                BigDecimal nckd_cysgzbalance = entryentity.getBigDecimal("nckd_cysgzbalance");//应付挂账
+                if(nckd_cyscxbalance.compareTo(nckd_cysgzbalance) == 1){
+                    throw new KDBizException("冲应收挂账明细第"+counts+"行冲销金额大于应收挂账余额");
+                }
+            }
         }
     }
-}
+}

+ 1059 - 0
src/main/java/kd/imc/rim/common/helper/RecognitionCheckHelperEx.java

@@ -0,0 +1,1059 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by FernFlower decompiler)
+//
+
+package kd.imc.rim.common.helper;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Maps;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import kd.bos.context.RequestContext;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.utils.ObjectUtils;
+import kd.bos.dataentity.utils.StringUtils;
+import kd.bos.fileservice.FileServiceFactory;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.bos.servicehelper.QueryServiceHelper;
+import kd.bos.servicehelper.operation.SaveServiceHelper;
+import kd.imc.rim.common.constant.AttachConstant;
+import kd.imc.rim.common.constant.FpzsConstant;
+import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
+import kd.imc.rim.common.invoice.checknew.model.CheckParam;
+import kd.imc.rim.common.invoice.checknew.model.CheckResult;
+import kd.imc.rim.common.invoice.collector.InvoiceCollectService;
+import kd.imc.rim.common.invoice.model.ConvertFieldUtil;
+import kd.imc.rim.common.invoice.model.type.OtherInvoice;
+import kd.imc.rim.common.invoice.recognitionnew.RecognitionFactory;
+import kd.imc.rim.common.invoice.recognitionnew.model.RecognitionParam;
+import kd.imc.rim.common.invoice.recognitionnew.model.RecognitionResult;
+import kd.imc.rim.common.message.exception.MsgException;
+import kd.imc.rim.common.service.SimplyCheckService;
+import kd.imc.rim.common.utils.BigDecimalUtil;
+import kd.imc.rim.common.utils.CacheHelper;
+import kd.imc.rim.common.utils.DateUtils;
+import kd.imc.rim.common.utils.DynamicObjectUtil;
+import kd.imc.rim.common.utils.FileUtils;
+import kd.imc.rim.common.utils.FormFileEntity;
+import kd.imc.rim.common.utils.ImcConfigUtil;
+import kd.imc.rim.common.utils.InvoiceConvertUtils;
+import kd.imc.rim.common.utils.MD5;
+import kd.imc.rim.common.utils.MetadataUtil;
+import kd.imc.rim.common.utils.RimConfigUtils;
+import kd.imc.rim.common.utils.TenantUtils;
+import kd.imc.rim.common.utils.UUID;
+import kd.imc.rim.common.utils.itextpdf.ItextPdfUtils;
+import kd.imc.rim.common.utils.itextpdf.UrlServiceUtils;
+import kd.imc.rim.file.utils.FileConvertUtils;
+import kd.imc.rim.file.utils.ofd.OfdUtil;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.compress.utils.Lists;
+
+public class RecognitionCheckHelperEx {
+    private static Log logger = LogFactory.getLog(RecognitionCheckHelper.class);
+    private static final String awsRecognitionImpl = "kd.imc.rim.common.invoice.recognitionnew.impl.AwsRecognitionServiceEx";
+    private static final String HANGXINCHECKSERIVCESTR = "kd.imc.rim.common.invoice.checknew.impl.HangxinCheckService";
+    private InvoiceCollectService invoiceCollectService = new InvoiceCollectService();
+
+    public RecognitionCheckHelperEx() {
+    }
+
+    public List<JSONObject> recognitionInvoiceFile(FormFileEntity fileEntity, Map<String, Object> extMap) throws Exception {
+        List<JSONObject> resultList = Lists.newArrayList();
+        List<FormFileEntity> fileEntityList = fileEntity.getSubFileList();
+        if (fileEntityList == null || ((List)fileEntityList).isEmpty()) {
+            fileEntityList = new ArrayList(1);
+            ((List)fileEntityList).add(fileEntity);
+        }
+
+        int pageNo = 0;
+        Map<String, String> configMap = ImcConfigUtil.getValue("rim_recog_check");
+        String recognitionImplStr = (String)configMap.get("rimpl");
+        boolean isAwsRecognition = StringUtils.isEmpty(recognitionImplStr) || "kd.imc.rim.common.invoice.recognitionnew.impl.AwsRecognitionServiceEx".equals(recognitionImplStr);
+        String cachhour = (String)configMap.get("cache_hour");
+        int cacheHour = 24;
+        if (!StringUtils.isEmpty(cachhour)) {
+            cacheHour = BigDecimalUtil.transDecimal(configMap.get("cache_hour")).intValue();
+            if (cacheHour < 0) {
+                cacheHour = 0;
+            }
+        }
+
+        String overseaAppCode = this.getOverseaAppCode(configMap);
+        Iterator var12 = ((List)fileEntityList).iterator();
+
+        while(var12.hasNext()) {
+            FormFileEntity entity = (FormFileEntity)var12.next();
+            ++pageNo;
+            String fileName = entity.getFileName();
+            InputStream fileInputStream = UrlServiceUtils.getAttachmentDecodedStream(FileServiceFactory.getAttachmentFileService().getInputStream(entity.getFileUrl()));
+            Throwable var16 = null;
+
+            try {
+                if (fileEntityList == null || ((List)fileEntityList).isEmpty()) {
+                    fileEntity.setFileSize(fileInputStream.available());
+                }
+
+                byte[] streamByte = FileUtils.getByte(fileInputStream);
+                String fileHash = FileConvertUtils.getSHA256(streamByte);
+                long threadCount = 0L;
+                boolean exceptionDecr = false;
+                int countTimeOut = 60;
+
+                try {
+                    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(streamByte);
+                    Throwable var24 = null;
+
+                    try {
+                        RecognitionParam recognitionParam = new RecognitionParam(byteArrayInputStream, extMap);
+                        recognitionParam.setFileName(fileName);
+                        recognitionParam.setLocalUrl(fileEntity.getFileUrl());
+                        recognitionParam.setLocalHash(fileEntity.getFileHash());
+                        recognitionParam.setRecogConfigMap(configMap);
+                        if (StringUtils.isEmpty(recognitionParam.getLocalHash())) {
+                            recognitionParam.setLocalHash(fileHash);
+                        }
+
+                        recognitionParam.setFileUrl(entity.getFileUrl());
+                        recognitionParam.setPageNo(pageNo);
+                        recognitionParam.setCacheHour(cacheHour);
+                        if (extMap.get("recogType") != null) {
+                            recognitionParam.setRecogType(extMap.get("recogType").toString());
+                            recognitionParam.setAppCode(overseaAppCode);
+                        }
+
+                        RecognitionResult recognitionResult = new RecognitionResult();
+                        JSONObject analysisInvoiceInfo = entity.getInvoiceInfo();
+                        boolean flag = !ObjectUtils.isEmpty(analysisInvoiceInfo) && analysisInvoiceInfo.getLong("invoiceType") != 0L;
+                        if (analysisInvoiceInfo != null && flag) {
+                            List entityList = Lists.newArrayList();
+                            JSONArray invoiceArray = new JSONArray();
+                            invoiceArray.add(analysisInvoiceInfo);
+                            String itemsKey = "items";
+                            ConvertFieldUtil.convertRecognitionEntity(entityList, invoiceArray, new String[]{itemsKey, "item"});
+                            recognitionResult.setErrcode("0000");
+                            recognitionResult.setData(entityList);
+                            logger.info("全电票转识别结果:{}", recognitionResult);
+                        } else {
+                            exceptionDecr = true;
+                            threadCount = CacheHelper.inc("recogThread", countTimeOut);
+                            logger.info("识别线程数量{}", threadCount);
+                            recognitionResult = RecognitionFactory.getRecognitionService(recognitionImplStr).recognitionInvoice(recognitionParam);
+                            threadCount = CacheHelper.decr("recogThread", countTimeOut);
+                            exceptionDecr = false;
+                        }
+
+                        if (recognitionResult != null) {
+                            if (!"0000".equals(recognitionResult.getErrcode())) {
+                                StringBuilder sb = this.getMsgExceptionInfo(recognitionResult);
+                                throw new MsgException(sb.toString());
+                            }
+
+                            List<Object> recognitionDataList = recognitionResult.getData();
+                            String salelistposturl = (String)configMap.get("salelistposturl");
+                            if (!StringUtils.isEmpty(salelistposturl)) {
+                                ByteArrayInputStream saleListByteArrayStream = new ByteArrayInputStream(streamByte);
+                                Throwable var32 = null;
+
+                                try {
+                                    RecognitionParam saleListParam = new RecognitionParam(saleListByteArrayStream, extMap);
+                                    saleListParam.setFileName(fileName);
+                                    saleListParam.setRecogConfigMap(configMap);
+                                    this.saleListRecognition(recognitionDataList, saleListParam);
+                                } catch (Throwable var79) {
+                                    var32 = var79;
+                                    throw var79;
+                                } finally {
+                                    if (saleListByteArrayStream != null) {
+                                        if (var32 != null) {
+                                            try {
+                                                saleListByteArrayStream.close();
+                                            } catch (Throwable var78) {
+                                                var32.addSuppressed(var78);
+                                            }
+                                        } else {
+                                            saleListByteArrayStream.close();
+                                        }
+                                    }
+
+                                }
+                            }
+
+                            this.supRecognitionInfo(recognitionDataList, isAwsRecognition, fileHash, fileName, pageNo, resultList, configMap);
+                        }
+                    } catch (Throwable var81) {
+                        var24 = var81;
+                        throw var81;
+                    } finally {
+                        if (byteArrayInputStream != null) {
+                            if (var24 != null) {
+                                try {
+                                    byteArrayInputStream.close();
+                                } catch (Throwable var77) {
+                                    var24.addSuppressed(var77);
+                                }
+                            } else {
+                                byteArrayInputStream.close();
+                            }
+                        }
+
+                    }
+                } catch (Throwable var83) {
+                    if (exceptionDecr && threadCount > 0L) {
+                        threadCount = CacheHelper.decr("recogThread", countTimeOut);
+                    }
+
+                    logger.error("ByteArrayInputStream error:", var83);
+                    throw var83;
+                }
+            } catch (Throwable var84) {
+                var16 = var84;
+                throw var84;
+            } finally {
+                if (fileInputStream != null) {
+                    if (var16 != null) {
+                        try {
+                            fileInputStream.close();
+                        } catch (Throwable var76) {
+                            var16.addSuppressed(var76);
+                        }
+                    } else {
+                        fileInputStream.close();
+                    }
+                }
+
+            }
+        }
+
+        return resultList;
+    }
+
+    private String getOverseaAppCode(Map<String, String> configMap) {
+        if (configMap == null) {
+            return null;
+        } else {
+            String appCode = (String)configMap.get("overappkey");
+            String appSect = (String)configMap.get("overappsecret");
+            if (!StringUtils.isEmpty(appCode) && !StringUtils.isEmpty(appSect)) {
+                String code = appCode + "@@@" + appSect;
+                String retStr = Base64.encodeBase64String(code.getBytes());
+                return retStr;
+            } else {
+                return null;
+            }
+        }
+    }
+
+    private void saleListRecognition(List<Object> recognitionDataList, RecognitionParam recognitionParam) {
+        List<Object> resultList = Lists.newArrayList();
+        recognitionDataList.stream().forEach((f) -> {
+            if (f instanceof OtherInvoice) {
+                OtherInvoice otherInvoice = (OtherInvoice)f;
+                String invoiceCode = otherInvoice.getInvoiceCode();
+                String invoiceNo = otherInvoice.getInvoiceNo();
+                boolean emptyCheck = StringUtils.isNotEmpty(invoiceCode) && StringUtils.isNotEmpty(invoiceNo);
+                boolean titleCheck = StringUtils.isNotEmpty(otherInvoice.getTitle()) && otherInvoice.getTitle().contains("清单");
+                if (emptyCheck && titleCheck) {
+                    try {
+                        List<JSONObject> saleListRecognitionList = this.saleListPost(recognitionParam);
+                        Iterator var10 = saleListRecognitionList.iterator();
+
+                        while(var10.hasNext()) {
+                            JSONObject saleList = (JSONObject)var10.next();
+                            String saleListCode = saleList.getString("invoiceCode");
+                            String saleListNo = saleList.getString("invoiceNo");
+                            String saleListPageNum = saleList.getString("pageNum");
+                            if (invoiceCode.equals(saleListCode) && invoiceNo.equals(saleListNo)) {
+                                otherInvoice.setPageNum(saleListPageNum);
+                            }
+                        }
+                    } catch (Exception var15) {
+                        logger.info("销货清单识别出错:", var15);
+                    }
+                }
+            }
+
+            resultList.add(f);
+        });
+    }
+
+    private List<JSONObject> saleListPost(RecognitionParam recognitionParam) throws Exception {
+        RecognitionResult recognitionResult = RecognitionFactory.getSaleListRecognitionService().recognitionInvoice(recognitionParam);
+        if (recognitionResult != null && "0000".equals(recognitionResult.getErrcode())) {
+            List<JSONObject> data = recognitionResult.getData();
+            return (List)data.stream().filter((f) -> {
+                String invoiceCode = f.getString("invoiceCode");
+                String invoiceNo = f.getString("invoiceNo");
+                String pageNum = f.getString("pageNum");
+                return StringUtils.isNotEmpty(invoiceCode) && StringUtils.isNotEmpty(invoiceNo) && StringUtils.isNotEmpty(pageNum);
+            }).collect(Collectors.toList());
+        } else {
+            return Lists.newArrayList();
+        }
+    }
+
+    private StringBuilder getMsgExceptionInfo(RecognitionResult recognitionResult) {
+        StringBuilder sb = new StringBuilder();
+        sb.append("识别失败,识别接口返回:【");
+        sb.append(recognitionResult.getErrcode());
+        sb.append('】');
+        sb.append(recognitionResult.getDescription());
+        return sb;
+    }
+
+    private void supRecognitionInfo(List<Object> recognitionDataList, boolean isAwsRecognition, String fileHash, String fileName, int pageNo, List<JSONObject> resultList, Map<String, String> configMap) throws ParseException {
+        if (recognitionDataList != null && recognitionDataList.size() != 0) {
+            String otherMust = ImcConfigUtil.getValue(configMap, "other_must", "0");
+            Iterator var9 = recognitionDataList.iterator();
+
+            while(true) {
+                Object object;
+                JSONObject recognitionInfo;
+                do {
+                    do {
+                        if (!var9.hasNext()) {
+                            return;
+                        }
+
+                        object = var9.next();
+                    } while(object == null);
+
+                    String invoiceStr = JSONObject.toJSONString(object);
+                    recognitionInfo = JSON.parseObject(invoiceStr);
+                } while(recognitionInfo == null);
+
+                this.setMaxAmount(recognitionInfo);
+                this.dealElectric(recognitionInfo);
+                this.dealBlockChain(recognitionInfo);
+                boolean isPass = false;
+                Long invoiceType;
+                String invoiceCode;
+                if (object.getClass() != null) {
+                    invoiceType = recognitionInfo.getLong("invoiceType");
+                    if (InputInvoiceTypeEnum.AIR_INVOICE.getCode().equals(invoiceType)) {
+                        invoiceCode = recognitionInfo.getString("invoiceDate");
+                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
+                        String issueDate = recognitionInfo.getString("issueDate");
+                        if (StringUtils.isNotEmpty(issueDate)) {
+                            Date date = simpleDateFormat.parse(issueDate);
+                            if (StringUtils.isEmpty(invoiceCode) || "OPEN".equalsIgnoreCase(invoiceCode)) {
+                                recognitionInfo.put("invoiceDate", DateUtils.format(date, "yyyy-MM-dd"));
+                            }
+                        }
+                    }
+
+                    isPass = ConvertFieldUtil.checkNullValidate(recognitionInfo, object.getClass());
+                    if (isPass && InputInvoiceTypeEnum.ROAD_BRIDGE.getCode().equals(invoiceType)) {
+                        invoiceCode = recognitionInfo.getString("invoiceCode");
+                        String exit = recognitionInfo.getString("exit");
+                        if (StringUtils.isEmpty(invoiceCode) && StringUtils.isEmpty(exit)) {
+                            isPass = false;
+                        }
+                    }
+
+                    if (isPass && InputInvoiceTypeEnum.OTHER_INVOICE.getCode().equals(invoiceType)) {
+                        if ("1".equals(otherMust) && StringUtils.isEmpty(recognitionInfo.getString("invoiceNo"))) {
+                            isPass = false;
+                        }
+
+                        if ("2".equals(otherMust) && (StringUtils.isEmpty(recognitionInfo.getString("invoiceNo")) || StringUtils.isEmpty(recognitionInfo.getString("invoiceCode")))) {
+                            isPass = false;
+                        }
+                    }
+                }
+
+                if (!isPass) {
+                    recognitionInfo.remove("serialNo");
+                }
+
+                if (isPass && StringUtils.isEmpty(recognitionInfo.getString("serialNo"))) {
+                    recognitionInfo.put("serialNo", UUID.randomUUID());
+                }
+
+                invoiceType = recognitionInfo.getLong("invoiceType");
+                invoiceCode = recognitionInfo.getString("currency_code");
+                recognitionInfo.put("currency", InvoiceConvertUtils.changeCurrency(invoiceCode));
+                if (!isAwsRecognition) {
+                    this.setOtherInfoByType(invoiceType, recognitionInfo);
+                }
+
+                if (!InvoiceConvertUtils.isVatInvoiceType(invoiceType)) {
+                    recognitionInfo.put("checkStatus", "1");
+                    this.recognitionInvoiceMix(recognitionInfo, invoiceType);
+                }
+
+                if (InvoiceConvertUtils.isSaleListInvoiceType(invoiceType)) {
+                    this.markSaleListInvoice(recognitionInfo);
+                }
+
+                recognitionInfo.put("fileHash", fileHash);
+                recognitionInfo.put("pageNo", pageNo);
+                recognitionInfo.put("fileName", fileName);
+                resultList.add(recognitionInfo);
+            }
+        }
+    }
+
+    private void setMaxAmount(JSONObject recognitionInfo) {
+        Set<Map.Entry<String, Object>> entries = recognitionInfo.entrySet();
+        Iterator var3 = entries.iterator();
+
+        while(var3.hasNext()) {
+            Map.Entry<String, Object> object = (Map.Entry)var3.next();
+            Object valueObj = object.getValue();
+            if (valueObj instanceof BigDecimal) {
+                String valueObjStr = valueObj.toString().replace("-", "");
+                if (BigDecimalUtil.transDecimal(valueObjStr).compareTo(FpzsConstant.sysMaxAmount) > 0) {
+                    valueObj = BigDecimal.ZERO;
+                    logger.info("发票{} 超过系统金额最大值:{} 置为0", object.getKey(), FpzsConstant.sysMaxAmount);
+                    recognitionInfo.put((String)object.getKey(), valueObj);
+                }
+            }
+        }
+
+    }
+
+    private void dealBlockChain(JSONObject recognitionInfo) {
+        String checkImplStr = RimConfigUtils.getConfig("rim_recog_check", "cimpl");
+        boolean isHangxinCheck = "kd.imc.rim.common.invoice.checknew.impl.HangxinCheckService".equals(checkImplStr);
+        boolean isBlockChainType = InvoiceConvertUtils.isBlockChainType(recognitionInfo.getString("invoiceCode"), recognitionInfo.getString("invoiceNo"));
+        boolean isYunnanChainType = InvoiceConvertUtils.isYunNanBlockchain(recognitionInfo.getString("invoiceCode"), recognitionInfo.getString("invoiceNo"));
+        if (isHangxinCheck && (isBlockChainType || isYunnanChainType)) {
+            recognitionInfo.put("invoiceType", InputInvoiceTypeEnum.GENERAL_ELECTRON.getCode());
+        }
+
+    }
+
+    private void markSaleListInvoice(JSONObject recognitionInfo) {
+        JSONArray items = recognitionInfo.getJSONArray("items");
+        recognitionInfo.put("isSaleListInvoice", "0");
+        if (items != null && items.size() == 1) {
+            String goodsName = items.getJSONObject(0).getString("goodsName");
+            if (StringUtils.isNotEmpty(goodsName) && goodsName.contains("详见") && goodsName.contains("清单")) {
+                recognitionInfo.put("isSaleListInvoice", "1");
+            }
+        }
+
+    }
+
+    private void dealElectric(JSONObject recognitionInfo) {
+        String invoiceNo = recognitionInfo.getString("invoiceNo");
+        String invoiceCode = recognitionInfo.getString("invoiceCode");
+        Long invoiceType = recognitionInfo.getLong("invoiceType");
+        if (StringUtils.isNotEmpty(invoiceNo) && invoiceNo.length() == 20 && InputInvoiceTypeEnum.ORDINARY_ROLL.getCode().equals(invoiceType) && StringUtils.isEmpty(invoiceCode)) {
+            recognitionInfo.put("invoiceType", InputInvoiceTypeEnum.ELECTRIC_SPECIAL.getCode());
+            String serialNo = recognitionInfo.getString("serialNo");
+            if (StringUtils.isEmpty(serialNo)) {
+                recognitionInfo.put("serialNo", UUID.randomUUID());
+            }
+        }
+
+    }
+
+    public FormFileEntity getFormFileEntity(String url, String fileName) throws IOException {
+        FormFileEntity fileEntity = new FormFileEntity(url, fileName);
+        if (FileUtils.checkFileType(fileName, new String[]{"pdf"})) {
+            return ItextPdfUtils.extractpdf(url, fileName);
+        } else {
+            if (FileUtils.checkFileType(fileName, new String[]{"ofd"})) {
+                JSONObject result = this.ofdAnalysis(url);
+                if (result != null) {
+                    fileEntity.setFileSize(BigDecimalUtil.transDecimal(result.getString("fileSize")).intValue());
+                }
+
+                fileEntity.setInvoiceInfo(result);
+                fileEntity.setFileType("ofd");
+                fileEntity.setSignatureFlag(Boolean.TRUE);
+            } else {
+                fileEntity.setFileType(FileUtils.getFileType(fileName));
+            }
+
+            return fileEntity;
+        }
+    }
+
+    private JSONObject ofdAnalysis(String fileUrl) {
+        try {
+            InputStream fileInputStream = UrlServiceUtils.getAttachmentDecodedStream(FileServiceFactory.getAttachmentFileService().getInputStream(fileUrl));
+            Throwable var3 = null;
+
+            JSONObject var20;
+            try {
+                byte[] streamByte = FileUtils.getByte(fileInputStream);
+                JSONObject result = OfdUtil.analysis(streamByte);
+                if (result != null) {
+                    if ("1".equals(result.getString("type"))) {
+                        String invoiceCode = result.getString("invoiceCode");
+                        String invoiceNo = result.getString("invoiceNo");
+                        String type = InvoiceConvertUtils.checkInvoiceType(invoiceCode, invoiceNo);
+                        result.put("invoiceType", InputInvoiceTypeEnum.getInvoiceTypeByAwsType(type));
+                        result.remove("type");
+                    } else {
+                        result.put("invoiceType", InputInvoiceTypeEnum.getInvoiceTypeByAwsType(result.getString("invoiceType")));
+                    }
+
+                    result.put("fileSize", streamByte.length);
+                }
+
+                var20 = result;
+            } catch (Throwable var17) {
+                var3 = var17;
+                throw var17;
+            } finally {
+                if (fileInputStream != null) {
+                    if (var3 != null) {
+                        try {
+                            fileInputStream.close();
+                        } catch (Throwable var16) {
+                            var3.addSuppressed(var16);
+                        }
+                    } else {
+                        fileInputStream.close();
+                    }
+                }
+
+            }
+
+            return var20;
+        } catch (Exception var19) {
+            return null;
+        }
+    }
+
+    public Map<String, Object> getRecognitionCheckExtMap(JSONObject businessParam) {
+        Map<String, Object> extMap = Maps.newHashMap();
+        Long orgId = RequestContext.get().getOrgId();
+        if (businessParam != null) {
+            if (businessParam.getLong("org_id") != null) {
+                orgId = businessParam.getLong("org_id");
+            }
+
+            extMap.put("recogType", businessParam.getString("recogType"));
+        }
+
+        String taxNo = TenantUtils.getTaxNoByOrgId(orgId);
+        extMap.put("eid", RequestContext.get().getUserId());
+        extMap.put("orgId", orgId);
+        extMap.put("taxNo", taxNo);
+        return extMap;
+    }
+
+    public List<JSONObject> checkInvoiceByRecognitionInfo(List<JSONObject> recognitionResultList, Map<String, Object> extMap) {
+        if (recognitionResultList != null && recognitionResultList.size() != 0) {
+            List<JSONObject> checkResultList = Lists.newArrayList();
+            Iterator var5 = recognitionResultList.iterator();
+
+            while(true) {
+                while(var5.hasNext()) {
+                    JSONObject invoiceInfo = (JSONObject)var5.next();
+                    JSONObject result = invoiceInfo;
+                    Long invoiceType = invoiceInfo.getLong("invoiceType");
+                    if (!InvoiceConvertUtils.isVatInvoiceType(invoiceType)) {
+                        checkResultList.add(invoiceInfo);
+                    } else {
+                        CheckParam checkParam = ConvertFieldUtil.getInvoiceCheckPart(invoiceInfo);
+                        if (checkParam != null) {
+                            try {
+                                Long orgId = (Long)extMap.get("orgId");
+                                String taxNo = (String)extMap.get("taxNo");
+                                CheckResult checkResult = SimplyCheckService.checkInvoice(checkParam, orgId, taxNo);
+                                if ("0000".equals(checkResult.getErrcode()) && checkResult.getData() != null) {
+                                    Object invoiceEntity = checkResult.getData();
+                                    String invoiceCheckStr = JSONObject.toJSONString(invoiceEntity);
+                                    JSONObject invoiceCheckInfo = JSON.parseObject(invoiceCheckStr);
+                                    this.putRecognitionInfo(invoiceCheckInfo, invoiceInfo);
+                                    result = invoiceCheckInfo;
+                                    String originalStateDefault = (String)extMap.get("originalStateDefault");
+                                    boolean typeFlag = InputInvoiceTypeEnum.ORDINARY_ELECTRON.getCode().equals(invoiceType) || InputInvoiceTypeEnum.TOLL_ELECTRON.getCode().equals(invoiceType) || InputInvoiceTypeEnum.SPECIAL_ELECTRON.getCode().equals(invoiceType);
+                                    if ("1".equals(originalStateDefault) && typeFlag) {
+                                        invoiceCheckInfo.put("originalState", "1");
+                                    }
+                                } else {
+                                    result = invoiceInfo;
+                                    invoiceInfo.put("checkStatus", "2");
+                                    invoiceInfo.put("errcode", checkResult.getErrcode());
+                                    invoiceInfo.put("description", checkResult.getDescription());
+                                }
+                            } catch (Exception var17) {
+                                logger.info("查验步骤报错:", var17);
+                                invoiceInfo.put("checkStatus", "2");
+                            }
+
+                            checkResultList.add(result);
+                        }
+                    }
+                }
+
+                return checkResultList;
+            }
+        } else {
+            return null;
+        }
+    }
+
+    public static void markSaleListByCheckResult(JSONObject invoiceCheckInfo) {
+        invoiceCheckInfo.put("isSaleListInvoice", "0");
+        JSONArray items = invoiceCheckInfo.getJSONArray("items");
+        if (items != null && items.size() > 8) {
+            invoiceCheckInfo.put("isSaleListInvoice", "1");
+            putSaleListSum(invoiceCheckInfo);
+        }
+
+    }
+
+    private JSONObject putRecognitionInfo(JSONObject invoiceCheckInfo, JSONObject recognitionInfo) {
+        invoiceCheckInfo.put("continuousNo", recognitionInfo.get("continuousNo"));
+        invoiceCheckInfo.put("currency", recognitionInfo.get("currency"));
+        invoiceCheckInfo.put("barcode", recognitionInfo.get("barcode"));
+        invoiceCheckInfo.put("qrcode", recognitionInfo.get("qrcode"));
+        invoiceCheckInfo.put("companySeal", recognitionInfo.get("companySeal"));
+        invoiceCheckInfo.put("region", recognitionInfo.get("region"));
+        invoiceCheckInfo.put("rotationAngle", recognitionInfo.get("rotationAngle"));
+        invoiceCheckInfo.put("pixel", recognitionInfo.get("pixel"));
+        invoiceCheckInfo.put("pageNo", recognitionInfo.get("pageNo"));
+        invoiceCheckInfo.put("fileName", recognitionInfo.get("fileName"));
+        String checkStatus = invoiceCheckInfo.getString("checkStatus");
+        String recognitionSaleList = recognitionInfo.getString("isSaleListInvoice");
+        String checkSaleList = invoiceCheckInfo.getString("isSaleListInvoice");
+        if ("1".equals(recognitionSaleList) || "1".equals(checkSaleList)) {
+            invoiceCheckInfo.put("isSaleListInvoice", "1");
+            if (!"1".equals(checkSaleList)) {
+                putSaleListSum(invoiceCheckInfo);
+            }
+        }
+
+        if (StringUtils.isEmpty(checkStatus)) {
+            invoiceCheckInfo.put("checkStatus", "1");
+            checkStatus = "1";
+        }
+
+        Long invoiceType = recognitionInfo.getLong("invoiceType");
+        if ((InputInvoiceTypeEnum.ORDINARY_PAPER.getCode().equals(invoiceType) || InputInvoiceTypeEnum.SPECIAL_PAPER.getCode().equals(invoiceType)) && "1".equals(checkStatus) && "1".equals(invoiceCheckInfo.getString("proxyMark"))) {
+            invoiceCheckInfo.put("companySeal", "1");
+        }
+
+        return invoiceCheckInfo;
+    }
+
+    private static void putSaleListSum(JSONObject invoiceInfo) {
+        int pageSum = 0;
+        String attachNo = invoiceInfo.getString("invoiceCode") + "_" + invoiceInfo.getString("invoiceNo");
+        QFilter qFilter = new QFilter("attach_no", "=", attachNo);
+        String attachFields = MetadataUtil.getFields("rim_attach");
+        DynamicObject[] attachCollect = BusinessDataServiceHelper.load("rim_attach", attachFields, new QFilter[]{qFilter});
+        if (attachCollect != null && attachCollect.length > 0) {
+            DynamicObject[] var6 = attachCollect;
+            int var7 = attachCollect.length;
+
+            for(int var8 = 0; var8 < var7; ++var8) {
+                DynamicObject attachInfo = var6[var8];
+                if (attachInfo.getInt("page_sum") != 0) {
+                    pageSum = attachInfo.getInt("page_sum");
+                    break;
+                }
+            }
+        }
+
+        JSONArray items = invoiceInfo.getJSONArray("items");
+        if (pageSum == 0) {
+            double itemsNum = (double)items.size();
+            double sum = Math.ceil(itemsNum / 25.0);
+            invoiceInfo.put("salelistSum", (int)sum == 0 ? 1 : (int)sum);
+        } else {
+            invoiceInfo.put("salelistSum", pageSum);
+        }
+
+    }
+
+    private void setOtherInfoByType(Long invoiceType, JSONObject recognitionInfo) {
+        String continuousNo = recognitionInfo.getString("continuousNo");
+        String numberConfirm = recognitionInfo.getString("numberConfirm");
+        String codeConfirm = recognitionInfo.getString("codeConfirm");
+        boolean isEquals;
+        if (StringUtils.isEmpty(continuousNo) && StringUtils.isNotEmpty(numberConfirm) && StringUtils.isNotEmpty(codeConfirm)) {
+            String invoiceCode = recognitionInfo.getString("invoiceCode");
+            String invoiceNo = recognitionInfo.getString("invoiceNo");
+            boolean isCodeEquals = invoiceCode.equals(codeConfirm);
+            isEquals = invoiceNo.equals(numberConfirm);
+            recognitionInfo.put("continuousNo", "0");
+            if (!isCodeEquals || !isEquals) {
+                recognitionInfo.put("continuousNo", "1");
+            }
+        }
+
+        if (InputInvoiceTypeEnum.TAXI_INVOICE.getCode().equals(invoiceType)) {
+            BigDecimal surcharge = recognitionInfo.getBigDecimal("surcharge");
+            BigDecimal totalAmount = recognitionInfo.getBigDecimal("totalAmount") == null ? BigDecimal.ZERO : recognitionInfo.getBigDecimal("totalAmount");
+            BigDecimal fare = recognitionInfo.getBigDecimal("fare") == null ? BigDecimal.ZERO : recognitionInfo.getBigDecimal("fare");
+            isEquals = totalAmount.compareTo(fare) == 0;
+            if (isEquals && surcharge != null) {
+                recognitionInfo.put("totalAmount", totalAmount.add(surcharge));
+            }
+        }
+
+    }
+
+    private void recognitionInvoiceMix(JSONObject recognitionInfo, Long invoiceType) {
+        String serialNo = recognitionInfo.getString("serialNo");
+        if (StringUtils.isNotEmpty(serialNo)) {
+            this.invoiceCollectService.convertUnVatInvoice(recognitionInfo, false);
+        } else {
+            this.convertFalseField(invoiceType, recognitionInfo);
+        }
+
+    }
+
+    private void convertFalseField(Long invoiceType, JSONObject recognitionInfo) {
+        if (InputInvoiceTypeEnum.TRAIN_INVOICE.getCode().equals(invoiceType)) {
+            recognitionInfo.put("printingSequenceNo", recognitionInfo.getString("sequenceNo"));
+            recognitionInfo.put("seat", recognitionInfo.getString("seatGrade"));
+            recognitionInfo.put("customerIdentityNum", recognitionInfo.getString("customerIdNo"));
+        } else if (InputInvoiceTypeEnum.AIR_INVOICE.getCode().equals(invoiceType)) {
+            recognitionInfo.put("electronicTicketNum", recognitionInfo.getString("eticketNo"));
+            recognitionInfo.put("customerIdentityNum", recognitionInfo.getString("customerIdNo"));
+            recognitionInfo.put("otherTotalTaxAmount", recognitionInfo.getString("otherAmount"));
+        }
+
+    }
+
+    public JSONArray bindAttachInvoice(JSONArray targetArray, JSONObject businessParam) {
+        JSONArray attachArray = new JSONArray();
+        if (targetArray.size() == 0) {
+            return attachArray;
+        } else {
+            targetArray.stream().forEach((i) -> {
+                JSONObject invoiceInfo = (JSONObject)i;
+                int pageNo = invoiceInfo.getInteger("pageNo");
+                boolean originalCheck = "1".equals(invoiceInfo.getString("originalState"));
+                if (!originalCheck) {
+                    String invoiceCode = invoiceInfo.getString("invoiceCode");
+                    String invoiceNo = invoiceInfo.getString("invoiceNo");
+                    DynamicObject attachObject = this.getAttachDynamicObject(invoiceInfo, businessParam);
+                    DynamicObject attachSaveObject = (DynamicObject)SaveServiceHelper.save(new DynamicObject[]{attachObject})[0];
+                    JSONObject attachInfo = new JSONObject(DynamicObjectUtil.dynamicObject2Map(attachSaveObject));
+                    attachInfo.put("invoiceCode", invoiceCode);
+                    attachInfo.put("invoiceNo", invoiceNo);
+                    DynamicObject attachTypeObj = BusinessDataServiceHelper.loadSingle(1503642129396971520L, "bdm_attach_type");
+                    attachInfo.put("simplify_name", attachTypeObj.getString("simplify_name"));
+                    attachInfo.put("attach_category_grid", attachTypeObj.getString("name"));
+                    attachInfo.put("serialNo", MD5.md5Hex(attachObject.get("id").toString()));
+                    attachInfo.put("pageNo", pageNo);
+                    long attachId = (Long)attachSaveObject.getPkValue();
+                    QFilter codeFilter = new QFilter("invoice_code", "=", invoiceCode);
+                    QFilter noFilter = new QFilter("invoice_no", "=", invoiceNo);
+                    Long[] vatTypes = InputInvoiceTypeEnum.getVatTypes();
+                    QFilter typeFilter = new QFilter("invoice_type", "in", vatTypes);
+                    String mainFields = MetadataUtil.getFields("rim_invoice");
+                    DynamicObject invoiceObject = BusinessDataServiceHelper.loadSingle("rim_invoice", mainFields, new QFilter[]{codeFilter, noFilter, typeFilter});
+                    if (invoiceObject != null) {
+                        attachInfo.put("isVat", "1");
+                        DynamicObject attachRelationObject = this.getAttachRelationDynamicObject(attachId, invoiceObject.getString("serial_no"));
+                        if (attachRelationObject != null) {
+                            SaveServiceHelper.save(new DynamicObject[]{attachRelationObject});
+                        }
+
+                        int page_sum = attachInfo.getInteger("page_sum");
+                        if (page_sum != 0) {
+                            invoiceObject.set("salelist_sum", page_sum);
+                            SaveServiceHelper.save(new DynamicObject[]{invoiceObject});
+                        }
+                    }
+
+                    attachArray.add(attachInfo);
+                }
+
+            });
+            return attachArray;
+        }
+    }
+
+    private DynamicObject getAttachRelationDynamicObject(long attachId, String serialNo) {
+        DynamicObjectCollection collect = QueryServiceHelper.query("rim_attach_relation", "id", new QFilter[]{new QFilter("attach_id", "=", String.valueOf(attachId))});
+        if (collect.size() > 0) {
+            return null;
+        } else {
+            DynamicObject relationObject = BusinessDataServiceHelper.newDynamicObject("rim_attach_relation");
+            relationObject.set("attach_id", attachId);
+            relationObject.set("relation_type", 3);
+            relationObject.set("relation_id", serialNo);
+            DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("rim_attach_relation", "expense_id", new QFilter[]{new QFilter("relation_id", "=", serialNo)});
+            if (dynamicObject != null) {
+                relationObject.set("expense_id", dynamicObject.getString("expense_id"));
+            }
+
+            return relationObject;
+        }
+    }
+
+    private DynamicObject getAttachDynamicObject(JSONObject invoiceInfo, JSONObject businessParam) {
+        Long userId = Long.valueOf(RequestContext.get().getUserId());
+        StringBuilder attachNoSb = new StringBuilder();
+        attachNoSb.append(invoiceInfo.getString("invoiceCode")).append('_');
+        attachNoSb.append(invoiceInfo.getString("invoiceNo"));
+        String attachNo = attachNoSb.toString();
+        QFilter filter1 = new QFilter("attach_no", "=", attachNo);
+        QFilter filter2 = new QFilter("attach_category", "=", AttachConstant.ATTACH_LIST_CATEGORY_ID);
+        QFilter filter3 = new QFilter("attach_hash_value", "=", invoiceInfo.getString("fileHash"));
+        DynamicObject idObject = QueryServiceHelper.queryOne("rim_attach", "id", new QFilter[]{filter1, filter2, filter3});
+        DynamicObject attachObject = null;
+        if (idObject == null) {
+            attachObject = BusinessDataServiceHelper.newDynamicObject("rim_attach");
+            attachObject.set("create_time", new Date());
+        } else {
+            attachObject = BusinessDataServiceHelper.loadSingle(idObject.get("id"), "rim_attach");
+        }
+
+        attachObject.set("update_time", new Date());
+        attachObject.set("user", userId);
+        if (businessParam != null) {
+            attachObject.set("rim_user", businessParam.get("rim_user"));
+        }
+
+        attachObject.set("attach_no", attachNo);
+        if ("1".equals(invoiceInfo.getString("fileType"))) {
+            attachObject.set("attach_url", invoiceInfo.getString("pdfUrl"));
+        } else if ("4".equals(invoiceInfo.getString("fileType"))) {
+            attachObject.set("attach_url", invoiceInfo.getString("ofdUrl"));
+        } else {
+            attachObject.set("attach_url", invoiceInfo.getString("snapshotUrl"));
+        }
+
+        attachObject.set("attach_type", invoiceInfo.getString("fileType"));
+        attachObject.set("attach_category", AttachConstant.ATTACH_LIST_CATEGORY_ID);
+        attachObject.set("attach_name", invoiceInfo.getString("fileName"));
+        attachObject.set("original_name", invoiceInfo.getString("fileName"));
+        String fileExtension = invoiceInfo.getString("fileName").substring(invoiceInfo.getString("fileName").lastIndexOf(46) + 1);
+        attachObject.set("file_extension", fileExtension);
+        attachObject.set("snapshot_url", invoiceInfo.getString("snapshotUrl"));
+        attachObject.set("icon_url", invoiceInfo.getString("snapshotUrl"));
+        attachObject.set("attach_hash_value", invoiceInfo.getString("fileHash"));
+        String pageNum = invoiceInfo.getString("pageNum");
+        if (StringUtils.isNotEmpty(pageNum)) {
+            try {
+                String target = pageNum.replaceAll(" ", "");
+                String subStr = target.substring(0, target.length() - 1);
+                int index = subStr.indexOf(20849);
+                int index2 = subStr.indexOf(39029);
+                int index3 = subStr.indexOf(31532);
+                String pageSum = target.substring(index, index2).substring(1);
+                String pageNo = target.substring(index3, subStr.length()).substring(1);
+                attachObject.set("page_sum", Integer.valueOf(pageSum));
+                attachObject.set("page_no", Integer.valueOf(pageNo));
+            } catch (Exception var20) {
+                logger.info("截取总页码失败:", var20);
+            }
+        }
+
+        return attachObject;
+    }
+
+    public JSONArray getTargetArray(JSONArray finalResult) {
+        return (JSONArray)finalResult.stream().filter((f) -> {
+            JSONObject invoiceInfo = (JSONObject)f;
+            String invoiceCode = invoiceInfo.getString("invoiceCode");
+            String invoiceNo = invoiceInfo.getString("invoiceNo");
+            boolean typeCheck = InputInvoiceTypeEnum.OTHER_INVOICE.getCode().equals(invoiceInfo.getLong("invoiceType"));
+            boolean emptyCheck = StringUtils.isNotEmpty(invoiceCode) && StringUtils.isNotEmpty(invoiceNo);
+            boolean titleCheck = StringUtils.isNotEmpty(invoiceInfo.getString("title")) && invoiceInfo.getString("title").contains("清单");
+            return typeCheck && emptyCheck && titleCheck;
+        }).collect(Collectors.toCollection(JSONArray::new));
+    }
+
+    public void dealInvoiceAttachRelation(JSONObject invoiceInfo) {
+        if (invoiceInfo != null) {
+            logger.info("处理发票绑定附件关系....");
+            String invoiceCode = invoiceInfo.getString("invoiceCode");
+            String invoiceNo = invoiceInfo.getString("invoiceNo");
+            invoiceCode = StringUtils.isNotEmpty(invoiceCode) ? invoiceCode : invoiceInfo.getString("invoice_code");
+            invoiceNo = StringUtils.isNotEmpty(invoiceNo) ? invoiceNo : invoiceInfo.getString("invoice_no");
+            StringBuilder attachNo = new StringBuilder();
+            attachNo.append(invoiceCode).append('_').append(invoiceNo);
+            DynamicObjectCollection attachCollect = this.getAttachDynamicByAttachNo(attachNo.toString());
+            Iterator var6 = attachCollect.iterator();
+
+            while(var6.hasNext()) {
+                DynamicObject attachInfo = (DynamicObject)var6.next();
+                String targetCode = attachInfo.getString("attach_no");
+                if (StringUtils.isNotEmpty(targetCode)) {
+                    String[] codeNo = targetCode.split("_");
+                    if (codeNo.length == 2 && invoiceCode.equals(codeNo[0]) && invoiceNo.equals(codeNo[1])) {
+                        DynamicObject attachRelationObject = this.getAttachRelationDynamicObject(attachInfo.getLong("id"), invoiceInfo.getString("serialNo"));
+                        if (attachRelationObject != null) {
+                            SaveServiceHelper.save(new DynamicObject[]{attachRelationObject});
+                        }
+
+                        logger.info("发票绑定附件关系保存成功....");
+                    }
+                }
+            }
+
+            JSONObject numObject = this.calcSaleListComplete(invoiceCode, invoiceNo, attachNo.toString());
+            invoiceInfo.put("salelistSum", numObject.getString("salelistSum"));
+            invoiceInfo.put("bindNum", numObject.getString("bindNum"));
+        }
+    }
+
+    public JSONObject calcSaleListComplete(String invoiceCode, String invoiceNo, String attachNo) {
+        logger.info("计算清单完整性,{},{}", invoiceCode, invoiceNo);
+        JSONObject numObject = new JSONObject();
+        int saleListSum = 0;
+        QFilter attachNoFilter = new QFilter("attach_no", "=", attachNo);
+        String attachFields = MetadataUtil.getFields("rim_attach");
+        DynamicObject[] attachCollect = BusinessDataServiceHelper.load("rim_attach", attachFields, new QFilter[]{attachNoFilter});
+        int bindNum = 0;
+        DynamicObject attachObject;
+        if (attachCollect != null && attachCollect.length > 0) {
+            String url = RimConfigUtils.getConfig("rim_recog_check", "salelistposturl");
+            if (StringUtils.isNotEmpty(url)) {
+                Set<Integer> numSet = (Set)Arrays.stream(attachCollect).filter((f) -> {
+                    if (f.getInt("page_no") == 0) {
+                        return false;
+                    } else {
+                        Long attachId = f.getLong("id");
+                        boolean isBind = this.checkBind(attachId);
+                        return isBind;
+                    }
+                }).map((m) -> {
+                    return m.getInt("page_no");
+                }).collect(Collectors.toSet());
+                bindNum = numSet.size();
+            } else {
+                DynamicObject[] var18 = attachCollect;
+                int var12 = attachCollect.length;
+
+                for(int var13 = 0; var13 < var12; ++var13) {
+                    attachObject = var18[var13];
+                    Long attachId = attachObject.getLong("id");
+                    boolean isBind = this.checkBind(attachId);
+                    if (isBind) {
+                        ++bindNum;
+                    }
+                }
+            }
+        }
+
+        QFilter invoiceNoFilter = new QFilter("invoice_no", "=", invoiceNo);
+        QFilter invoiceCodeFilter = new QFilter("invoice_code", "=", invoiceCode);
+        String mainFields = MetadataUtil.getFields("rim_invoice");
+        DynamicObject mainObject = BusinessDataServiceHelper.loadSingle("rim_invoice", mainFields, new QFilter[]{invoiceNoFilter, invoiceCodeFilter});
+        if (mainObject != null) {
+            saleListSum = mainObject.getInt("salelist_sum");
+            if (attachCollect != null && attachCollect.length > 0) {
+                attachObject = attachCollect[0];
+                int pageSum = attachObject.getInt("page_sum");
+                if (pageSum != 0 && pageSum != saleListSum) {
+                    mainObject.set("salelist_sum", pageSum);
+                    saleListSum = pageSum;
+                }
+            }
+
+            if (bindNum == 0) {
+                mainObject.set("salelist_complete", "3");
+            } else if (bindNum < saleListSum) {
+                mainObject.set("salelist_complete", "2");
+            } else {
+                mainObject.set("salelist_complete", "0");
+            }
+
+            SaveServiceHelper.save(new DynamicObject[]{mainObject});
+            logger.info("计算清单完整性完毕,{},{}", invoiceCode, invoiceNo);
+        }
+
+        numObject.put("salelistSum", saleListSum);
+        numObject.put("bindNum", bindNum);
+        return numObject;
+    }
+
+    private DynamicObjectCollection getAttachDynamicByAttachNo(String attachNo) {
+        DynamicObjectCollection result = new DynamicObjectCollection();
+        QFilter attachNoFilter = new QFilter("attach_no", "=", attachNo);
+        String attachFields = MetadataUtil.getFields("rim_attach");
+        DynamicObject[] attachCollect = BusinessDataServiceHelper.load("rim_attach", attachFields, new QFilter[]{attachNoFilter});
+        if (attachCollect != null && attachCollect.length > 0) {
+            DynamicObject[] var6 = attachCollect;
+            int var7 = attachCollect.length;
+
+            for(int var8 = 0; var8 < var7; ++var8) {
+                DynamicObject attachObject = var6[var8];
+                Long attachId = attachObject.getLong("id");
+                boolean isBind = this.checkBind(attachId);
+                if (!isBind) {
+                    result.add(attachObject);
+                }
+            }
+        }
+
+        return result;
+    }
+
+    public boolean checkBind(Long attachId) {
+        QFilter attachIdFilter = new QFilter("attach_id", "=", attachId.toString());
+        QFilter relationIdFilter = new QFilter("relation_id", "!=", " ");
+        String attachFields = MetadataUtil.getFields("rim_attach_relation");
+        DynamicObject[] attachCollect = BusinessDataServiceHelper.load("rim_attach_relation", attachFields, new QFilter[]{attachIdFilter, relationIdFilter});
+        return attachCollect != null && attachCollect.length > 0;
+    }
+
+    public Map<String, Integer> filterBindAttach(List<String> attachIds) {
+        QFilter attachIdFilter = new QFilter("attach_id", "in", attachIds);
+        QFilter relationIdFilter = new QFilter("relation_id", "!=", " ");
+        String attachFields = MetadataUtil.getFields("rim_attach_relation");
+        DynamicObject[] attachCollect = BusinessDataServiceHelper.load("rim_attach_relation", attachFields, new QFilter[]{attachIdFilter, relationIdFilter});
+        if (attachCollect.length == 0) {
+            return Maps.newHashMap();
+        } else {
+            Map<String, List<DynamicObject>> relationGroup = (Map)Arrays.stream(attachCollect).collect(Collectors.groupingBy((attach) -> {
+                return attach.getString("relation_id");
+            }));
+            Map<String, Integer> map = Maps.newHashMapWithExpectedSize(relationGroup.size());
+            List<String> serialList = Lists.newArrayList();
+            Iterator var9 = relationGroup.entrySet().iterator();
+
+            while(var9.hasNext()) {
+                Map.Entry<String, List<DynamicObject>> entry = (Map.Entry)var9.next();
+                map.put(entry.getKey(), ((List)entry.getValue()).size());
+                serialList.add(entry.getKey());
+            }
+
+            QFilter serialFilter = new QFilter("serial_no", "in", serialList);
+            DynamicObject[] invoiceCollect = BusinessDataServiceHelper.load("rim_invoice", "serial_no, invoice_code, invoice_no", new QFilter[]{serialFilter});
+            Map<String, String> invoiceMap = Maps.newHashMapWithExpectedSize(invoiceCollect.length);
+            DynamicObject[] var12 = invoiceCollect;
+            int var13 = invoiceCollect.length;
+
+            for(int var14 = 0; var14 < var13; ++var14) {
+                DynamicObject invoice = var12[var14];
+                invoiceMap.put(invoice.getString("serial_no"), invoice.getString("invoice_code") + "_" + invoice.getString("invoice_no"));
+            }
+
+            Map<String, Integer> result = Maps.newHashMapWithExpectedSize(map.size());
+            Iterator var19 = map.entrySet().iterator();
+
+            while(var19.hasNext()) {
+                Map.Entry<String, Integer> entry = (Map.Entry)var19.next();
+                result.put(invoiceMap.get(entry.getKey()), entry.getValue());
+            }
+
+            return result;
+        }
+    }
+}

+ 230 - 0
src/main/java/kd/imc/rim/common/invoice/collector/ScannerServiceEx.java

@@ -0,0 +1,230 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by FernFlower decompiler)
+//
+
+package kd.imc.rim.common.invoice.collector;
+
+import com.alibaba.fastjson.JSONObject;
+import java.util.Map;
+import kd.bos.context.RequestContext;
+import kd.bos.ext.form.control.CustomControl;
+import kd.bos.form.ConfirmCallBackListener;
+import kd.bos.form.ConfirmTypes;
+import kd.bos.form.MessageBoxOptions;
+import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.threads.ThreadPool;
+import kd.bos.threads.ThreadPools;
+import kd.imc.rim.common.invoice.recognition.impl.RecognitionCheckTaskEx;
+import kd.imc.rim.common.utils.BigDecimalUtil;
+import kd.imc.rim.common.utils.FileUploadUtils;
+import kd.imc.rim.common.utils.ImcConfigUtil;
+import kd.imc.rim.common.utils.RimConfigUtils;
+import org.apache.commons.lang3.StringUtils;
+
+public class ScannerServiceEx {
+    private static final int threadNum = 5;
+    private static ThreadPool checkThreadPool = ThreadPools.newFixedThreadPool("scanner_check_pool", 5);
+    private static final Log LOGGER = LogFactory.getLog(ScannerServiceEx.class);
+    public static final String operate_invoice = "invoice";
+    public static final String operate_attach = "attach";
+
+    public ScannerServiceEx() {
+    }
+
+    public static void startWebScoket(CustomControl control, String linkKey) {
+        RequestContext request = RequestContext.get();
+        String socketUrl = request.getClientFullContextPath() + "msgwatch/?identifytype=" + linkKey + "&tenantsessionkey=KERPSESSIONID" + request.getTenantId();
+        if (socketUrl.startsWith("https")) {
+            socketUrl = "wss" + socketUrl.substring(5);
+        } else if (socketUrl.startsWith("http")) {
+            socketUrl = "ws" + socketUrl.substring(4);
+        }
+
+        JSONObject map = new JSONObject();
+        map.put("operate", "open");
+        map.put("qrcodeType", "cloudhub");
+        map.put("socketUrl", socketUrl);
+        map.put("linkKey", linkKey);
+        map.put("enableWebSocket", "1");
+        if ("0".equals(RimConfigUtils.getConfig("rim_fpzs", "enablesocket"))) {
+            map.put("enableWebSocket", "0");
+        }
+
+        map.put("time", System.currentTimeMillis());
+        LOGGER.info("startWebScoket:" + JSONObject.toJSONString(map));
+        control.setData(map);
+    }
+
+    public static void startInterval(CustomControl control) {
+        JSONObject json = new JSONObject();
+        json.put("time", 1000);
+        json.put("millisec", 1000);
+        json.put("request", System.currentTimeMillis());
+        control.setData(json);
+    }
+
+    public static void removeUpload(CustomControl control) {
+        JSONObject map1 = new JSONObject();
+        map1.put("operate", "remove");
+        map1.put("fid", control.getView().getEntityId());
+        control.setData(map1);
+    }
+
+    public static void initUpload(CustomControl control, boolean canImportExcels, String title) {
+        JSONObject map1 = new JSONObject();
+        RequestContext request = RequestContext.get();
+        map1.put("operate", "init");
+        map1.put("pageId", control.getView().getPageId());
+        map1.put("uploadUrl", request.getClientFullContextPath() + "attachment/upload.do");
+        map1.put("fileLimitSize", "3");
+        map1.put("title", title);
+        map1.put("fileQuality", "0.98");
+        int maxfilesize = BigDecimalUtil.transDecimal(RimConfigUtils.getConfig("rim_fpzs", "maxfilesize")).intValue();
+        if (maxfilesize < 1) {
+            maxfilesize = 10;
+        }
+
+        map1.put("fileLimitPixel", "1500");
+        map1.put("maxFileSize", maxfilesize);
+        map1.put("fid", control.getView().getEntityId());
+        map1.put("canImportExcels", canImportExcels);
+        control.setData(map1);
+    }
+
+    public static void upload(CustomControl control) {
+        JSONObject map1 = new JSONObject();
+        map1.put("operate", "upload");
+        map1.put("time", System.currentTimeMillis());
+        control.setData(map1);
+    }
+
+    public static void init(CustomControl control, String pageId) {
+        RequestContext request = RequestContext.get();
+        JSONObject map1 = new JSONObject();
+        map1.put("pageId", pageId);
+        map1.put("init", "init");
+        map1.put("savePath", FileUploadUtils.getInvoiceDir("invoice") + pageId + "");
+        map1.put("uploadUrl", request.getClientFullContextPath() + "attachment/upload.do");
+        map1.put("time", System.currentTimeMillis());
+        map1.put("fid", control.getView().getEntityId());
+        setScannerParam(map1);
+        map1.put("downloadUrl", getJsScanner());
+        control.setData(map1);
+    }
+
+    public static void scanner(CustomControl control, String pageId, String operate) {
+        RequestContext request = RequestContext.get();
+        JSONObject map1 = new JSONObject();
+        map1.put("pageId", pageId);
+        map1.put("operate", operate);
+        map1.put("savePath", FileUploadUtils.getInvoiceDir("invoice") + pageId + "");
+        String contextPath = request.getClientFullContextPath();
+        if (contextPath.endsWith("/")) {
+            contextPath = contextPath.substring(0, contextPath.length() - 1);
+        }
+
+        map1.put("contextPath", contextPath);
+        map1.put("uploadUrl", contextPath + "/attachment/upload.do");
+        map1.put("time", System.currentTimeMillis());
+        map1.put("fid", control.getView().getEntityId());
+        setScannerParam(map1);
+        map1.put("downloadUrl", getJsScanner());
+        control.setData(map1);
+    }
+
+    private static void setScannerParam(JSONObject param) {
+        Map<String, String> map = ImcConfigUtil.getValue("rim_fpzs");
+        String resolution = null;
+        String scannerType = null;
+        String limitpixel = null;
+        if (map != null) {
+            resolution = StringUtils.trimToEmpty((String)map.get("resolution"));
+            scannerType = StringUtils.trimToEmpty((String)map.get("scanner_type"));
+            limitpixel = StringUtils.trimToEmpty((String)map.get("limitpixel"));
+        }
+
+        if (StringUtils.isEmpty(scannerType)) {
+            scannerType = "rq";
+        }
+
+        if (map != null && "dm".equals(scannerType)) {
+            param.put("productKey", map.get("productkey"));
+        }
+
+        if (StringUtils.isEmpty(resolution)) {
+            resolution = "100";
+        }
+
+        if (StringUtils.isEmpty(limitpixel)) {
+            limitpixel = "2000";
+        }
+
+        param.put("scannerType", scannerType);
+        param.put("resolution", resolution);
+        param.put("fileLimitPixel", limitpixel);
+    }
+
+    public static boolean scannerFail(AbstractFormPlugin plugin, String eventArgs) {
+        if (eventArgs != null) {
+            if (eventArgs.indexOf("JsScanner.msi") > 0) {
+                plugin.getView().showConfirm("扫描仪需要安装JsScanner,是否安装?", MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("downJsScanner", plugin));
+                return false;
+            }
+
+            if (eventArgs.indexOf("websocket connect error") > 0) {
+                plugin.getView().showTipNotification("请确认已经连接并打开扫描仪!", 3000);
+                return false;
+            }
+
+            if (eventArgs.indexOf("No data source found in this environment") > 0) {
+                plugin.getView().showTipNotification("请检查是否正确安装扫描仪驱动!", 3000);
+                return false;
+            }
+
+            JSONObject js = JSONObject.parseObject(eventArgs);
+            if (js != null) {
+                String description = js.getString("description");
+                if (!StringUtils.isEmpty(description)) {
+                    plugin.getView().showTipNotification(description, 3000);
+                    return true;
+                }
+            }
+        }
+
+        plugin.getView().showErrorNotification(eventArgs);
+        return false;
+    }
+
+    public static boolean uploadFinish(String eventArgs) {
+        return eventArgs != null && (eventArgs.indexOf("cancelSelectSource") > 0 || eventArgs.indexOf("confirmDownload") > 0 || eventArgs.indexOf("cancelDownload") > 0);
+    }
+
+    public static String getJsScanner() {
+        RequestContext request = RequestContext.get();
+        return request.getClientFullContextPath() + "kingdee/imc/scanner/rq-scanner/lib/JsScanner.msi";
+    }
+
+    public static void downJsScanner(AbstractFormPlugin plugin) {
+        RequestContext request = RequestContext.get();
+        plugin.getView().openUrl(request.getClientFullContextPath() + "kingdee/imc/scanner/rq-scanner/lib/JsScanner.msi");
+    }
+
+    public static void recognitionInvoice(String source, String pageId, String url, String fileName, JSONObject businessParam, Map<String, Object> customParam) {
+        LOGGER.info("Scanner recognitionInvoice...");
+        RecognitionCheckTaskEx task = new RecognitionCheckTaskEx(RequestContext.get(), source, pageId, businessParam, customParam, url, fileName);
+        checkThreadPool.submit(task);
+    }
+
+    public static Long getUploadIndex(JSONObject uploadResult) {
+        Long index = BigDecimalUtil.transDecimal(uploadResult.get("index")).longValue();
+        Long timeStamp = uploadResult.getLong("uploadTimeStamp");
+        if (timeStamp == null) {
+            timeStamp = System.currentTimeMillis();
+        }
+
+        return timeStamp + index;
+    }
+}

+ 346 - 0
src/main/java/kd/imc/rim/common/invoice/recognition/impl/RecognitionCheckTaskEx.java

@@ -0,0 +1,346 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by FernFlower decompiler)
+//
+
+package kd.imc.rim.common.invoice.recognition.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import kd.bos.context.RequestContext;
+import kd.bos.dataentity.utils.StringUtils;
+import kd.bos.dlock.DLock;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.orm.util.CollectionUtils;
+import kd.imc.rim.common.constant.ResultContant;
+import kd.imc.rim.common.invoice.fpzs.FpzsMainService;
+import kd.imc.rim.common.invoice.recognition.listener.IRecognitionListener;
+import kd.imc.rim.common.service.EInvoiceZipXmlDealService;
+import kd.imc.rim.common.service.ElectAccVoucherService;
+import kd.imc.rim.common.service.ExcelInvoiceUploadService;
+import kd.imc.rim.common.service.RecognitionCheckServiceEx;
+import kd.imc.rim.common.utils.CacheHelper;
+import kd.imc.rim.common.utils.FileUtils;
+import kd.imc.rim.common.utils.MD5;
+import org.apache.commons.lang3.tuple.Pair;
+
+public class RecognitionCheckTaskEx implements Callable<JSONObject> {
+    private static Log logger = LogFactory.getLog(RecognitionCheckTaskEx.class);
+    private static int cache_time_out = 1800;
+    private JSONObject businessParam;
+    private Map<String, Object> customParam;
+    private String url;
+    private String fileName;
+    private String pageId;
+    private String source;
+    private RequestContext ctx;
+    public static final String waiting = "waiting";
+    public static final String success = "success";
+    public static final String fail = "fail";
+
+    public RecognitionCheckTaskEx(RequestContext ctx, String source, String pageId, JSONObject businessParam, Map<String, Object> customParam, String url, String fileName) {
+        saveCacheFile(pageId, url, "waiting");
+        this.ctx = ctx;
+        this.pageId = pageId;
+        this.businessParam = businessParam;
+        this.url = url;
+        this.source = source;
+        this.fileName = fileName;
+        this.customParam = customParam;
+    }
+
+    public JSONObject call() throws Exception {
+        logger.info("begin RecognitionCheckTaskEx :{},{}", this.url, this.fileName);
+
+        try {
+            RequestContext.copyAndSet(this.ctx);
+            if (StringUtils.isEmpty(this.url)) {
+                return null;
+            } else {
+                JSONObject invoiceResult = new JSONObject();
+                Long orgId = RequestContext.get().getOrgId();
+                if (this.customParam != null) {
+                    try {
+                        orgId = (Long)this.customParam.get("orgId");
+                    } catch (Exception var12) {
+                    }
+                }
+
+                boolean isZipXmlEI = FileUtils.checkFileType(this.fileName, new String[]{"zip", "xml"});
+                if (isZipXmlEI) {
+                    invoiceResult = EInvoiceZipXmlDealService.analysisAndCheckSave(this.url, this.fileName, orgId, this.businessParam, (IRecognitionListener)null);
+                }
+
+                boolean isNeedDeal = FileUtils.checkFileType(this.fileName, new String[]{"zip", "ofd", "xml"});
+                if (isNeedDeal && !"0000".equals(invoiceResult.getString("errcode"))) {
+                    invoiceResult = ElectAccVoucherService.dealVoucher(this.url, this.fileName, orgId, this.businessParam, (IRecognitionListener)null);
+                }
+
+                String xbrlErrCode = invoiceResult.getString("errcode");
+                boolean dealResult = StringUtils.isEmpty(xbrlErrCode) || !xbrlErrCode.equals("0000");
+                boolean isZip = FileUtils.checkFileType(this.fileName, new String[]{"zip"});
+                if (dealResult && !isZip) {
+                    if (FileUtils.isExcel(this.fileName)) {
+                        invoiceResult = ExcelInvoiceUploadService.getInstance().uploadExcelInvoice(this.url, this.fileName, (IRecognitionListener)null, this.businessParam);
+                    } else {
+                        logger.info("RecognitionCheckTaskEx识别url:{}{}", this.fileName, this.url);
+                        invoiceResult = RecognitionCheckServiceEx.getInstance().recognitionCheckInvoice(this.url, this.fileName, (IRecognitionListener)null, this.businessParam);
+                    }
+                }
+
+                logger.info("发票助手本地上传最终数据返回:" + invoiceResult);
+                if (ResultContant.isSuccess(invoiceResult)) {
+                    JSONArray invoiceArray = invoiceResult.getJSONArray("data");
+                    JSONArray failInvoiceArray = invoiceResult.getJSONArray("failData");
+                    JSONArray attachArray = invoiceResult.getJSONArray("attach");
+                    if (!CollectionUtils.isEmpty(failInvoiceArray)) {
+                        CacheHelper.put(this.pageId + "failResult", failInvoiceArray.toJSONString(), cache_time_out);
+                    }
+
+                    if (invoiceArray == null && attachArray == null) {
+                        saveCacheFile(this.pageId, this.url, "fail");
+                    } else {
+                        CacheHelper.put(this.pageId + "refresh", "1", cache_time_out);
+                        if ("fpzs".equals(this.source)) {
+                            Pair<JSONObject, Boolean> cachePair = FpzsMainService.cacheInvoiceList(this.pageId, this.customParam, invoiceArray, attachArray);
+                            if ((Boolean)cachePair.getRight()) {
+                                CacheHelper.put(this.pageId + "scannerProcessRepeat", cachePair.getRight() + "", cache_time_out);
+                            }
+                        } else {
+                            saveCacheFileResult(this.url, invoiceArray);
+                        }
+
+                        saveCacheFile(this.pageId, this.url, "success");
+                    }
+                } else {
+                    saveCacheFile(this.pageId, this.url, "fail");
+                    saveCacheCause(this.pageId, this.url, "fail", invoiceResult.getString("description"));
+                }
+
+                return invoiceResult;
+            }
+        } catch (Throwable var13) {
+            logger.info("RecognitionCheckTaskEx throwable:{}", var13);
+            saveCacheFile(this.pageId, this.url, "fail");
+            saveCacheCause(this.pageId, this.url, "fail", "程序错误");
+            return new JSONObject();
+        }
+    }
+
+    public JSONObject getBusinessParam() {
+        return this.businessParam;
+    }
+
+    public void setBusinessParam(JSONObject businessParam) {
+        this.businessParam = businessParam;
+    }
+
+    public String getUrl() {
+        return this.url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public static void saveCacheFileResult(String url, JSONArray result) {
+        if (result != null) {
+            CacheHelper.put(MD5.md5Hex(url), result.toJSONString(), cache_time_out);
+        } else {
+            CacheHelper.remove(MD5.md5Hex(url));
+        }
+
+    }
+
+    public static JSONArray queryCacheFileResult(String url) {
+        String result = CacheHelper.get(MD5.md5Hex(url));
+        return result != null ? JSONArray.parseArray(result) : new JSONArray();
+    }
+
+    public static void saveCacheFile(String pageId, String url, String operate) {
+        cacheFile(pageId, url, operate);
+    }
+
+    public static void saveCacheCause(String pageId, String url, String operate, String cause) {
+        cacheCause(pageId, url, operate, cause);
+    }
+
+    public static JSONObject queryCacheFile(String pageId) {
+        return cacheFile(pageId, (String)null, "query");
+    }
+
+    public static JSONObject queryCacheCause(String pageId) {
+        return cacheCause(pageId, (String)null, "query", (String)null);
+    }
+
+    public static void clearCacheFile(String pageId) {
+        cacheFile(pageId, (String)null, "remove");
+    }
+
+    private static JSONObject cacheCause(String pageId, String url, String operate, String cause) {
+        logger.info(pageId + url + operate + cause);
+        if (StringUtils.isEmpty(pageId)) {
+            return null;
+        } else {
+            String cacheKey = "scaner_cause_" + pageId;
+            DLock lock = DLock.create("lock_" + cacheKey, "刷新卡片锁");
+            Throwable var6 = null;
+
+            JSONObject var10;
+            try {
+                int times = 0;
+
+                do {
+                    if (times >= 10) {
+                        return null;
+                    }
+
+                    ++times;
+                } while(!lock.tryLock(100L));
+
+
+
+                try {
+                    String cache;
+                    if ("remove".equals(operate)) {
+                        CacheHelper.remove(cacheKey);
+                        cache = null;
+                        return null;
+                    }
+
+                    cache = CacheHelper.get(cacheKey);
+                    JSONObject obj = null;
+                    if (StringUtils.isEmpty(cache)) {
+                        obj = new JSONObject();
+                    } else {
+                        obj = JSON.parseObject(cache);
+                    }
+
+                    if ("query".equals(operate)) {
+                        var10 = obj;
+                        return var10;
+                    }
+
+                    if (StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(operate) && StringUtils.isNotEmpty(cause)) {
+                        obj.put(url, cause);
+                        CacheHelper.put(cacheKey, obj.toJSONString(), cache_time_out);
+                    }
+
+                    var10 = obj;
+                } finally {
+                    lock.unlock();
+                }
+            } catch (Throwable var29) {
+                var6 = var29;
+                throw var29;
+            } finally {
+                if (lock != null) {
+                    if (var6 != null) {
+                        try {
+                            lock.close();
+                        } catch (Throwable var27) {
+                            var6.addSuppressed(var27);
+                        }
+                    } else {
+                        lock.close();
+                    }
+                }
+
+            }
+
+            return var10;
+        }
+    }
+
+    private static JSONObject cacheFile(String pageId, String url, String operate) {
+        logger.info(pageId + url + operate);
+        if (StringUtils.isEmpty(pageId)) {
+            return null;
+        } else {
+            String cacheKey = "scaner_" + pageId;
+            DLock lock = DLock.create("lock_" + cacheKey, "刷新卡片锁");
+            Throwable var5 = null;
+
+            try {
+                int times = 0;
+
+                while(times < 10) {
+                    ++times;
+                    if (lock.tryLock(100L)) {
+
+                        try {
+                            String cache;
+                            if ("remove".equals(operate)) {
+                                CacheHelper.remove(cacheKey);
+                                cache = null;
+                                return null;
+                            }
+
+                            cache = CacheHelper.get(cacheKey);
+                            JSONObject obj = null;
+                            if (StringUtils.isEmpty(cache)) {
+                                obj = new JSONObject();
+                            } else {
+                                obj = JSON.parseObject(cache);
+                            }
+
+                            JSONObject var9;
+                            if ("query".equals(operate)) {
+                                var9 = obj;
+                                return var9;
+                            }
+
+                            if (StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(operate)) {
+                                obj.put(url, operate);
+                                CacheHelper.put(cacheKey, obj.toJSONString(), cache_time_out);
+                            }
+
+                            var9 = obj;
+                            return var9;
+                        } finally {
+                            lock.unlock();
+                        }
+                    }
+                }
+            } catch (Throwable var28) {
+                var5 = var28;
+                throw var28;
+            } finally {
+                if (lock != null) {
+                    if (var5 != null) {
+                        try {
+                            lock.close();
+                        } catch (Throwable var26) {
+                            var5.addSuppressed(var26);
+                        }
+                    } else {
+                        lock.close();
+                    }
+                }
+
+            }
+
+            return null;
+        }
+    }
+
+    public String getSource() {
+        return this.source;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public Map<String, Object> getCustomParam() {
+        return this.customParam;
+    }
+
+    public void setCustomParam(Map<String, Object> customParam) {
+        this.customParam = customParam;
+    }
+}

+ 181 - 0
src/main/java/kd/imc/rim/common/invoice/recognitionnew/impl/AwsRecognitionServiceEx.java

@@ -0,0 +1,181 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by FernFlower decompiler)
+//
+
+package kd.imc.rim.common.invoice.recognitionnew.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Maps;
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.util.StringUtils;
+import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
+import kd.imc.rim.common.invoice.model.ConvertFieldUtil;
+import kd.imc.rim.common.invoice.query.convert.impl.AirConvertService;
+import kd.imc.rim.common.invoice.recognitionnew.RecognitionService;
+import kd.imc.rim.common.invoice.recognitionnew.model.RecognitionParam;
+import kd.imc.rim.common.invoice.recognitionnew.model.RecognitionResult;
+import kd.imc.rim.common.message.exception.MsgException;
+import kd.imc.rim.common.utils.AwsFpyService;
+import kd.imc.rim.common.utils.HttpUtil;
+import org.apache.commons.compress.utils.Lists;
+
+public class AwsRecognitionServiceEx implements RecognitionService {
+    private static Log logger = LogFactory.getLog(AwsRecognitionService.class);
+    private static final int connectionTimeout = 3000;
+    private static final int readTimeout = 60000;
+
+    public AwsRecognitionServiceEx() {
+    }
+
+    public RecognitionResult recognitionInvoice(RecognitionParam recognitionParam) {
+        RecognitionResult recognitionResult = this.getResultFromDb(recognitionParam);
+        if (recognitionResult == null) {
+            recognitionResult = this.getResultFromAws(recognitionParam);
+        }
+
+        return recognitionResult;
+    }
+
+    private RecognitionResult getResultFromAws(RecognitionParam recognitionParam) {
+        RecognitionResult recognitionResult = new RecognitionResult();
+        Map<String, Object> extMap = recognitionParam.getExtMap();
+        Map<String, Object> bodyMap = Maps.newHashMap();
+        bodyMap.put("eid", extMap.get("eid") + "");
+        bodyMap.put("taxNo", extMap.get("taxNo") + "");
+        bodyMap.put("recogType", recognitionParam.getRecogType());
+        bodyMap.put("overseaAppCode", recognitionParam.getAppCode());
+
+        try {
+            String serviceType = this.getServiceType(recognitionParam);
+            String token = AwsFpyService.newInstance().getAccessToken(Long.parseLong(extMap.get("orgId") + ""));
+            if (StringUtils.isNotEmpty(token)) {
+                long start = System.currentTimeMillis();
+                String url = AwsFpyService.newInstance().getUrl("pure_recognition", token);
+                ByteArrayInputStream valueInputStream = recognitionParam.getFileByteArrayInputStream();
+                String valueFileName = recognitionParam.getFileName();
+                int retryTimes = 1;
+
+                for(int times = 1; times <= retryTimes; ++times) {
+                    String result = HttpUtil.postFormData(url + "&t=" + start, AwsFpyService.newInstance().getProxy(), (Map)null, valueInputStream, valueFileName, bodyMap, 3000, 60000);
+                    logger.info("aws识别接口返回结果{}:{}", times, result);
+                    boolean reTry = false;
+                    if (!StringUtils.isNotEmpty(result)) {
+                        break;
+                    }
+
+                    JSONArray recognitionArray = this.getRecoginitionData(recognitionResult, result);
+                    if (recognitionArray == null) {
+                        break;
+                    }
+
+                    boolean saveFlag = true;
+
+                    for(int i = 0; i < recognitionArray.size(); ++i) {
+                        JSONObject invoiceInfo = recognitionArray.getJSONObject(i);
+                        if ("1".equals(invoiceInfo.getString("defaultOther"))) {
+                            saveFlag = false;
+                            if (times < retryTimes) {
+                                reTry = true;
+                                break;
+                            }
+                        }
+
+                        this.setResultValue(invoiceInfo);
+                    }
+
+                    if (!reTry) {
+                        if (saveFlag) {
+                            this.saveRecognition(recognitionParam, serviceType, result, System.currentTimeMillis() - start);
+                        }
+
+                        recognitionResult.setData(this.convertRecognition(recognitionArray));
+                        break;
+                    }
+                }
+            } else {
+                recognitionResult.setData(new ArrayList(1));
+            }
+
+            return recognitionResult;
+        } catch (Throwable var20) {
+            logger.error("AwsRecognitionService exception:", var20);
+            if (var20 instanceof MsgException) {
+                throw new MsgException(((MsgException)var20).getErrorCode(), ((MsgException)var20).getErrorMsg());
+            } else {
+                throw new MsgException("0001", "aws识别异常");
+            }
+        }
+    }
+
+    private RecognitionResult getResultFromDb(RecognitionParam recognitionParam) {
+        RecognitionResult recognitionResult = new RecognitionResult();
+        String serviceType = this.getServiceType(recognitionParam);
+        String resultStr = this.getRecognitionResultFromDb(recognitionParam, serviceType);
+        if (StringUtils.isEmpty(resultStr)) {
+            return null;
+        } else {
+            JSONArray recognitionArray = this.getRecoginitionData(recognitionResult, resultStr);
+            if (recognitionArray == null) {
+                return null;
+            } else {
+                for(int i = 0; i < recognitionArray.size(); ++i) {
+                    JSONObject invoiceInfo = recognitionArray.getJSONObject(i);
+                    this.setResultValue(invoiceInfo);
+                }
+
+                recognitionResult.setData(this.convertRecognition(recognitionArray));
+                return recognitionResult;
+            }
+        }
+    }
+
+    private JSONArray getRecoginitionData(RecognitionResult recognitionResult, String resultStr) {
+        if (StringUtils.isNotEmpty(resultStr)) {
+            JSONObject recognitionJson = JSONObject.parseObject(resultStr);
+            recognitionResult.setErrcode(recognitionJson.getString("errcode"));
+            recognitionResult.setDescription(recognitionJson.getString("description"));
+            JSONObject data = recognitionJson.getJSONObject("data");
+            if (data != null) {
+                JSONArray recognitionArray = data.getJSONArray("recoginitionData");
+                return recognitionArray;
+            }
+        }
+
+        return null;
+    }
+
+    private void setResultValue(JSONObject invoiceInfo) {
+        invoiceInfo.put("snapshotUrl", "");
+        invoiceInfo.put("kdcloudUrl", "");
+        invoiceInfo.put("downloadUrl", "");
+        Long invoiceType = InputInvoiceTypeEnum.getInvoiceTypeByAwsType(invoiceInfo.getString("invoiceType"));
+        invoiceInfo.put("invoiceType", invoiceType);
+        if (InputInvoiceTypeEnum.AIR_INVOICE.getCode().equals(invoiceType)) {
+            JSONArray items = invoiceInfo.getJSONArray("items");
+            if (items != null && items.size() > 0) {
+                JSONObject firstOne = items.getJSONObject(0);
+                invoiceInfo.put("seatGrade", firstOne.getString("seatGrade"));
+                invoiceInfo.put("flightNum", firstOne.getString("flightNum"));
+                invoiceInfo.put("seatGradeName", AirConvertService.convertSeatName(firstOne.getString("seatGrade")));
+            }
+        }
+
+    }
+
+    private List<Object> convertRecognition(JSONArray recognitionArray) {
+        List<Object> entityList = Lists.newArrayList();
+        ConvertFieldUtil.convertRecognitionEntity(entityList, recognitionArray, new String[]{"items"});
+        return entityList;
+    }
+
+    public String getServiceType(RecognitionParam recognitionParam) {
+        return "aws" + recognitionParam.getRecogType();
+    }
+}

+ 3 - 2
src/main/java/kd/imc/rim/common/service/RecognitionCheckServiceEx.java

@@ -15,7 +15,8 @@ import kd.bos.threads.ThreadPools;
 import kd.imc.rim.common.constant.CheckContant;
 import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
 import kd.imc.rim.common.constant.InvoiceUploadErrorType;
-import kd.imc.rim.common.helper.RecognitionCheckHelper;
+
+import kd.imc.rim.common.helper.RecognitionCheckHelperEx;
 import kd.imc.rim.common.invoice.collector.InvoiceCollectService;
 import kd.imc.rim.common.invoice.model.ConvertFieldUtil;
 import kd.imc.rim.common.invoice.recognition.listener.IRecognitionListener;
@@ -43,7 +44,7 @@ import java.util.stream.Collectors;
 public class RecognitionCheckServiceEx {
     private static RecognitionCheckServiceEx instance = null;
     private static Log logger = LogFactory.getLog(RecognitionCheckServiceEx.class);
-    private RecognitionCheckHelper recognitionCheckHelper = new RecognitionCheckHelper();
+    private RecognitionCheckHelperEx recognitionCheckHelper = new RecognitionCheckHelperEx();
     private InvoiceCollectService invoiceCollectService = new InvoiceCollectService();
     private static Integer recheckorginPage = 999123413;
     private static ThreadPool uploadThreadPool = ThreadPools.newFixedThreadPool("recognitionUploadThread_2", Runtime.getRuntime().availableProcessors() + 1);