ソースを参照

发票助手改造

徐昊 8 ヶ月 前
コミット
271cd6fafa

+ 51 - 24
src/main/java/kd/imc/rim/common/invoice/recognitionnew/impl/AwsRecognitionServiceEx.java → src/main/java/kd/imc/rim/AwsRecognitionServiceEx.java

@@ -3,17 +3,16 @@
 // (powered by FernFlower decompiler)
 // (powered by FernFlower decompiler)
 //
 //
 
 
-package kd.imc.rim.common.invoice.recognitionnew.impl;
+package kd.imc.rim;
 
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Maps;
-
+import java.io.ByteArrayInputStream;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
-
-import kd.imc.rim.utils.FileOutputStreamExample;
+import kd.bos.dataentity.resource.ResManager;
 import kd.bos.logging.Log;
 import kd.bos.logging.Log;
 import kd.bos.logging.LogFactory;
 import kd.bos.logging.LogFactory;
 import kd.bos.util.StringUtils;
 import kd.bos.util.StringUtils;
@@ -24,10 +23,15 @@ 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.RecognitionParam;
 import kd.imc.rim.common.invoice.recognitionnew.model.RecognitionResult;
 import kd.imc.rim.common.invoice.recognitionnew.model.RecognitionResult;
 import kd.imc.rim.common.message.exception.MsgException;
 import kd.imc.rim.common.message.exception.MsgException;
+import kd.imc.rim.common.utils.AwsFpyService;
+import kd.imc.rim.common.utils.HttpUtil;
+import kd.imc.rim.common.utils.ImcConfigUtil;
+import kd.imc.rim.utils.ApiHttpUtils;
+import kd.imc.rim.utils.FileOutputStreamExample;
 import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.compress.utils.Lists;
 
 
 public class AwsRecognitionServiceEx implements RecognitionService {
 public class AwsRecognitionServiceEx implements RecognitionService {
-    private static Log logger = LogFactory.getLog(AwsRecognitionService.class);
+    private static Log logger = LogFactory.getLog(AwsRecognitionServiceEx.class);
     private static final int connectionTimeout = 3000;
     private static final int connectionTimeout = 3000;
     private static final int readTimeout = 60000;
     private static final int readTimeout = 60000;
 
 
@@ -55,22 +59,25 @@ public class AwsRecognitionServiceEx implements RecognitionService {
         String imgStrToBase64 = FileOutputStreamExample.getImgStrToBase64(fileUrl);
         String imgStrToBase64 = FileOutputStreamExample.getImgStrToBase64(fileUrl);
         try {
         try {
             String serviceType = this.getServiceType(recognitionParam);
             String serviceType = this.getServiceType(recognitionParam);
-            if (StringUtils.isNotEmpty(fileUrl)) {
+            Map<String, String> headers = Maps.newHashMap();
+            boolean overseaFlag = false;
+            if (!"".equals(imgStrToBase64)) {
                 long start = System.currentTimeMillis();
                 long start = System.currentTimeMillis();
-                String url = "http://ip:port/icr/demo/demo_receipt_crop_and_recog_image.html";
-                //ByteArrayInputStream valueInputStream = recognitionParam.getFileByteArrayInputStream();
-                //String valueFileName = recognitionParam.getFileName();
+                String url = "http://10.3.2.70:8115";
+                String valueFileName;
+                ByteArrayInputStream valueInputStream = recognitionParam.getFileByteArrayInputStream();
+                valueFileName = recognitionParam.getFileName();
                 int retryTimes = 1;
                 int retryTimes = 1;
                 for(int times = 1; times <= retryTimes; ++times) {
                 for(int times = 1; times <= retryTimes; ++times) {
-                    //调用接口位置
-                    String result = "";//ApiHttpUtils.Posthttp(url, imgStrToBase64)
+                    logger.info("aws识别bodyMap:{}", bodyMap);
+                    String result = ApiHttpUtils.Posthttp(url, imgStrToBase64);
                     logger.info("aws识别接口返回结果{}:{}", times, result);
                     logger.info("aws识别接口返回结果{}:{}", times, result);
                     boolean reTry = false;
                     boolean reTry = false;
                     if (!StringUtils.isNotEmpty(result)) {
                     if (!StringUtils.isNotEmpty(result)) {
                         break;
                         break;
                     }
                     }
 
 
-                    JSONArray recognitionArray = this.getRecoginitionData(recognitionResult, result);
+                    JSONArray recognitionArray = this.getRecoginitionData(recognitionResult, result, overseaFlag);
                     if (recognitionArray == null) {
                     if (recognitionArray == null) {
                         break;
                         break;
                     }
                     }
@@ -83,7 +90,7 @@ public class AwsRecognitionServiceEx implements RecognitionService {
                             saveFlag = false;
                             saveFlag = false;
                             if (times < retryTimes) {
                             if (times < retryTimes) {
                                 reTry = true;
                                 reTry = true;
-                                break;
+                                throw new MsgException("0002", ResManager.loadKDString("aws识别异常", "AwsRecognitionService_0", "imc-rim-common", new Object[0]));
                             }
                             }
                         }
                         }
 
 
@@ -104,12 +111,12 @@ public class AwsRecognitionServiceEx implements RecognitionService {
             }
             }
 
 
             return recognitionResult;
             return recognitionResult;
-        } catch (Throwable var20) {
-            logger.error("AwsRecognitionService exception:", var20);
-            if (var20 instanceof MsgException) {
-                throw new MsgException(((MsgException)var20).getErrorCode(), ((MsgException)var20).getErrorMsg());
+        } catch (Throwable var22) {
+            logger.error("AwsRecognitionService exception:", var22);
+            if (var22 instanceof MsgException) {
+                throw new MsgException(((MsgException)var22).getErrorCode(), ((MsgException)var22).getErrorMsg());
             } else {
             } else {
-                throw new MsgException("0001", "aws识别异常");
+                throw new MsgException("0001", ResManager.loadKDString("aws识别异常", "AwsRecognitionService_0", "imc-rim-common", new Object[0]));
             }
             }
         }
         }
     }
     }
@@ -121,7 +128,12 @@ public class AwsRecognitionServiceEx implements RecognitionService {
         if (StringUtils.isEmpty(resultStr)) {
         if (StringUtils.isEmpty(resultStr)) {
             return null;
             return null;
         } else {
         } else {
-            JSONArray recognitionArray = this.getRecoginitionData(recognitionResult, resultStr);
+            boolean overseaFlag = false;
+            if (!resultStr.contains("recoginitionData")) {
+                overseaFlag = true;
+            }
+
+            JSONArray recognitionArray = this.getRecoginitionData(recognitionResult, resultStr, overseaFlag);
             if (recognitionArray == null) {
             if (recognitionArray == null) {
                 return null;
                 return null;
             } else {
             } else {
@@ -136,15 +148,30 @@ public class AwsRecognitionServiceEx implements RecognitionService {
         }
         }
     }
     }
 
 
-    private JSONArray getRecoginitionData(RecognitionResult recognitionResult, String resultStr) {
+    private JSONArray getRecoginitionData(RecognitionResult recognitionResult, String resultStr, boolean overseaFlag) {
         if (StringUtils.isNotEmpty(resultStr)) {
         if (StringUtils.isNotEmpty(resultStr)) {
             JSONObject recognitionJson = JSONObject.parseObject(resultStr);
             JSONObject recognitionJson = JSONObject.parseObject(resultStr);
             recognitionResult.setErrcode(recognitionJson.getString("errcode"));
             recognitionResult.setErrcode(recognitionJson.getString("errcode"));
             recognitionResult.setDescription(recognitionJson.getString("description"));
             recognitionResult.setDescription(recognitionJson.getString("description"));
-            JSONObject data = recognitionJson.getJSONObject("data");
-            if (data != null) {
-                JSONArray recognitionArray = data.getJSONArray("recoginitionData");
-                return recognitionArray;
+
+            try {
+                if (overseaFlag) {
+                    JSONArray data = recognitionJson.getJSONArray("data");
+
+                    for(int i = 0; i < data.size(); ++i) {
+                        JSONObject overseaInfo = data.getJSONObject(i);
+                        overseaInfo.put("invoiceType", InputInvoiceTypeEnum.OVERSEA_INVOICE.getAwsType());
+                    }
+
+                    return data;
+                }
+
+                JSONObject data = recognitionJson.getJSONObject("data");
+                if (data != null) {
+                    return data.getJSONArray("recoginitionData");
+                }
+            } catch (Exception var8) {
+                logger.info("getRecoginitionData exception:", var8);
             }
             }
         }
         }
 
 

ファイルの差分が大きいため隠しています
+ 373 - 444
src/main/java/kd/imc/rim/FpzsMainPluginEx.java


+ 3 - 2
src/main/java/kd/imc/rim/formplugin/collector/InvoiceCollectPluginEx.java → src/main/java/kd/imc/rim/InvoiceCollectPluginEx.java

@@ -1,4 +1,4 @@
-package kd.imc.rim.formplugin.collector;
+package kd.imc.rim;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
@@ -18,10 +18,11 @@ import kd.imc.rim.common.service.DialogService;
 import kd.imc.rim.common.utils.BigDecimalUtil;
 import kd.imc.rim.common.utils.BigDecimalUtil;
 import kd.imc.rim.common.utils.PermissionUtils;
 import kd.imc.rim.common.utils.PermissionUtils;
 import kd.imc.rim.common.utils.RimConfigUtils;
 import kd.imc.rim.common.utils.RimConfigUtils;
+import kd.imc.rim.formplugin.collector.InvoiceCollectPlugin;
 
 
 import java.util.*;
 import java.util.*;
 
 
-public class InvoiceCollectPluginEx extends InvoiceCollectPlugin{
+public class InvoiceCollectPluginEx extends InvoiceCollectPlugin {
     private static Log logger = LogFactory.getLog(InvoiceCollectPluginEx.class);
     private static Log logger = LogFactory.getLog(InvoiceCollectPluginEx.class);
 
 
     @Override
     @Override

+ 219 - 98
src/main/java/kd/imc/rim/common/helper/RecognitionCheckHelperEx.java → src/main/java/kd/imc/rim/RecognitionCheckHelperEx.java

@@ -3,7 +3,7 @@
 // (powered by FernFlower decompiler)
 // (powered by FernFlower decompiler)
 //
 //
 
 
-package kd.imc.rim.common.helper;
+package kd.imc.rim;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
@@ -12,12 +12,14 @@ import com.google.common.collect.Maps;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
+import java.io.Serializable;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Iterator;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -26,7 +28,7 @@ import java.util.stream.Collectors;
 import kd.bos.context.RequestContext;
 import kd.bos.context.RequestContext;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
-import kd.bos.dataentity.utils.ObjectUtils;
+import kd.bos.dataentity.resource.ResManager;
 import kd.bos.dataentity.utils.StringUtils;
 import kd.bos.dataentity.utils.StringUtils;
 import kd.bos.fileservice.FileServiceFactory;
 import kd.bos.fileservice.FileServiceFactory;
 import kd.bos.logging.Log;
 import kd.bos.logging.Log;
@@ -35,6 +37,8 @@ import kd.bos.orm.query.QFilter;
 import kd.bos.servicehelper.BusinessDataServiceHelper;
 import kd.bos.servicehelper.BusinessDataServiceHelper;
 import kd.bos.servicehelper.QueryServiceHelper;
 import kd.bos.servicehelper.QueryServiceHelper;
 import kd.bos.servicehelper.operation.SaveServiceHelper;
 import kd.bos.servicehelper.operation.SaveServiceHelper;
+import kd.imc.aws.ofd.util.analysis.OfdReadUtils;
+import kd.imc.aws.ofd.util.model.VatInvoice;
 import kd.imc.rim.common.constant.AttachConstant;
 import kd.imc.rim.common.constant.AttachConstant;
 import kd.imc.rim.common.constant.FpzsConstant;
 import kd.imc.rim.common.constant.FpzsConstant;
 import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
 import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
@@ -64,13 +68,12 @@ import kd.imc.rim.common.utils.UUID;
 import kd.imc.rim.common.utils.itextpdf.ItextPdfUtils;
 import kd.imc.rim.common.utils.itextpdf.ItextPdfUtils;
 import kd.imc.rim.common.utils.itextpdf.UrlServiceUtils;
 import kd.imc.rim.common.utils.itextpdf.UrlServiceUtils;
 import kd.imc.rim.file.utils.FileConvertUtils;
 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.codec.binary.Base64;
 import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.compress.utils.Lists;
 
 
 public class RecognitionCheckHelperEx {
 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 Log logger = LogFactory.getLog(RecognitionCheckHelperEx.class);
+    private static final String awsRecognitionImpl = "kd.imc.rim.AwsRecognitionServiceEx";
     private static final String HANGXINCHECKSERIVCESTR = "kd.imc.rim.common.invoice.checknew.impl.HangxinCheckService";
     private static final String HANGXINCHECKSERIVCESTR = "kd.imc.rim.common.invoice.checknew.impl.HangxinCheckService";
     private InvoiceCollectService invoiceCollectService = new InvoiceCollectService();
     private InvoiceCollectService invoiceCollectService = new InvoiceCollectService();
 
 
@@ -88,7 +91,7 @@ public class RecognitionCheckHelperEx {
         int pageNo = 0;
         int pageNo = 0;
         Map<String, String> configMap = ImcConfigUtil.getValue("rim_recog_check");
         Map<String, String> configMap = ImcConfigUtil.getValue("rim_recog_check");
         String recognitionImplStr = (String)configMap.get("rimpl");
         String recognitionImplStr = (String)configMap.get("rimpl");
-        boolean isAwsRecognition = StringUtils.isEmpty(recognitionImplStr) || "kd.imc.rim.common.invoice.recognitionnew.impl.AwsRecognitionServiceEx".equals(recognitionImplStr);
+        boolean isAwsRecognition = StringUtils.isEmpty(recognitionImplStr) || "kd.imc.rim.AwsRecognitionServiceEx".equals(recognitionImplStr);
         String cachhour = (String)configMap.get("cache_hour");
         String cachhour = (String)configMap.get("cache_hour");
         int cacheHour = 24;
         int cacheHour = 24;
         if (!StringUtils.isEmpty(cachhour)) {
         if (!StringUtils.isEmpty(cachhour)) {
@@ -109,7 +112,7 @@ public class RecognitionCheckHelperEx {
             Throwable var16 = null;
             Throwable var16 = null;
 
 
             try {
             try {
-                if (fileEntityList == null || ((List)fileEntityList).isEmpty()) {
+                if (((List)fileEntityList).isEmpty()) {
                     fileEntity.setFileSize(fileInputStream.available());
                     fileEntity.setFileSize(fileInputStream.available());
                 }
                 }
 
 
@@ -143,23 +146,38 @@ public class RecognitionCheckHelperEx {
 
 
                         RecognitionResult recognitionResult = new RecognitionResult();
                         RecognitionResult recognitionResult = new RecognitionResult();
                         JSONObject analysisInvoiceInfo = entity.getInvoiceInfo();
                         JSONObject analysisInvoiceInfo = entity.getInvoiceInfo();
-                        boolean flag = !ObjectUtils.isEmpty(analysisInvoiceInfo) && analysisInvoiceInfo.getLong("invoiceType") != 0L;
-                        if (analysisInvoiceInfo != null && flag) {
+                        boolean resultFlag = false;
+                        boolean isMore = false;
+                        if (analysisInvoiceInfo != null) {
+                            Object invoice = analysisInvoiceInfo.get("invoice");
+                            if (invoice == null) {
+                                invoice = analysisInvoiceInfo;
+                            } else {
+                                isMore = true;
+                            }
+
+                            resultFlag = this.getValidateFlag(invoice);
+                        }
+
+                        if (resultFlag) {
                             List entityList = Lists.newArrayList();
                             List entityList = Lists.newArrayList();
                             JSONArray invoiceArray = new JSONArray();
                             JSONArray invoiceArray = new JSONArray();
-                            invoiceArray.add(analysisInvoiceInfo);
+                            if (isMore) {
+                                invoiceArray.addAll(analysisInvoiceInfo.getJSONArray("invoice"));
+                            } else {
+                                invoiceArray.add(analysisInvoiceInfo);
+                            }
+
                             String itemsKey = "items";
                             String itemsKey = "items";
                             ConvertFieldUtil.convertRecognitionEntity(entityList, invoiceArray, new String[]{itemsKey, "item"});
                             ConvertFieldUtil.convertRecognitionEntity(entityList, invoiceArray, new String[]{itemsKey, "item"});
                             recognitionResult.setErrcode("0000");
                             recognitionResult.setErrcode("0000");
                             recognitionResult.setData(entityList);
                             recognitionResult.setData(entityList);
-                            logger.info("全电票转识别结果:{}", recognitionResult);
+                            logger.info("识别结果取pdf解析..");
                         } else {
                         } else {
                             exceptionDecr = true;
                             exceptionDecr = true;
                             threadCount = CacheHelper.inc("recogThread", countTimeOut);
                             threadCount = CacheHelper.inc("recogThread", countTimeOut);
                             logger.info("识别线程数量{}", threadCount);
                             logger.info("识别线程数量{}", threadCount);
-                            //调用接口
-                            recognitionResult = RecognitionFactory.getRecognitionService(awsRecognitionImpl).recognitionInvoice(recognitionParam);
-
+                            recognitionResult = RecognitionFactory.getRecognitionService("kd.imc.rim.AwsRecognitionServiceEx").recognitionInvoice(recognitionParam);
                             threadCount = CacheHelper.decr("recogThread", countTimeOut);
                             threadCount = CacheHelper.decr("recogThread", countTimeOut);
                             exceptionDecr = false;
                             exceptionDecr = false;
                         }
                         }
@@ -174,23 +192,23 @@ public class RecognitionCheckHelperEx {
                             String salelistposturl = (String)configMap.get("salelistposturl");
                             String salelistposturl = (String)configMap.get("salelistposturl");
                             if (!StringUtils.isEmpty(salelistposturl)) {
                             if (!StringUtils.isEmpty(salelistposturl)) {
                                 ByteArrayInputStream saleListByteArrayStream = new ByteArrayInputStream(streamByte);
                                 ByteArrayInputStream saleListByteArrayStream = new ByteArrayInputStream(streamByte);
-                                Throwable var32 = null;
+                                Throwable var33 = null;
 
 
                                 try {
                                 try {
                                     RecognitionParam saleListParam = new RecognitionParam(saleListByteArrayStream, extMap);
                                     RecognitionParam saleListParam = new RecognitionParam(saleListByteArrayStream, extMap);
                                     saleListParam.setFileName(fileName);
                                     saleListParam.setFileName(fileName);
                                     saleListParam.setRecogConfigMap(configMap);
                                     saleListParam.setRecogConfigMap(configMap);
                                     this.saleListRecognition(recognitionDataList, saleListParam);
                                     this.saleListRecognition(recognitionDataList, saleListParam);
-                                } catch (Throwable var79) {
-                                    var32 = var79;
-                                    throw var79;
+                                } catch (Throwable var80) {
+                                    var33 = var80;
+                                    throw var80;
                                 } finally {
                                 } finally {
                                     if (saleListByteArrayStream != null) {
                                     if (saleListByteArrayStream != null) {
-                                        if (var32 != null) {
+                                        if (var33 != null) {
                                             try {
                                             try {
                                                 saleListByteArrayStream.close();
                                                 saleListByteArrayStream.close();
-                                            } catch (Throwable var78) {
-                                                var32.addSuppressed(var78);
+                                            } catch (Throwable var79) {
+                                                var33.addSuppressed(var79);
                                             }
                                             }
                                         } else {
                                         } else {
                                             saleListByteArrayStream.close();
                                             saleListByteArrayStream.close();
@@ -202,16 +220,16 @@ public class RecognitionCheckHelperEx {
 
 
                             this.supRecognitionInfo(recognitionDataList, isAwsRecognition, fileHash, fileName, pageNo, resultList, configMap);
                             this.supRecognitionInfo(recognitionDataList, isAwsRecognition, fileHash, fileName, pageNo, resultList, configMap);
                         }
                         }
-                    } catch (Throwable var81) {
-                        var24 = var81;
-                        throw var81;
+                    } catch (Throwable var82) {
+                        var24 = var82;
+                        throw var82;
                     } finally {
                     } finally {
                         if (byteArrayInputStream != null) {
                         if (byteArrayInputStream != null) {
                             if (var24 != null) {
                             if (var24 != null) {
                                 try {
                                 try {
                                     byteArrayInputStream.close();
                                     byteArrayInputStream.close();
-                                } catch (Throwable var77) {
-                                    var24.addSuppressed(var77);
+                                } catch (Throwable var78) {
+                                    var24.addSuppressed(var78);
                                 }
                                 }
                             } else {
                             } else {
                                 byteArrayInputStream.close();
                                 byteArrayInputStream.close();
@@ -219,24 +237,24 @@ public class RecognitionCheckHelperEx {
                         }
                         }
 
 
                     }
                     }
-                } catch (Throwable var83) {
+                } catch (Throwable var84) {
                     if (exceptionDecr && threadCount > 0L) {
                     if (exceptionDecr && threadCount > 0L) {
                         threadCount = CacheHelper.decr("recogThread", countTimeOut);
                         threadCount = CacheHelper.decr("recogThread", countTimeOut);
                     }
                     }
 
 
-                    logger.error("ByteArrayInputStream error:", var83);
-                    throw var83;
+                    logger.error("ByteArrayInputStream error:", var84);
+                    throw var84;
                 }
                 }
-            } catch (Throwable var84) {
-                var16 = var84;
-                throw var84;
+            } catch (Throwable var85) {
+                var16 = var85;
+                throw var85;
             } finally {
             } finally {
                 if (fileInputStream != null) {
                 if (fileInputStream != null) {
                     if (var16 != null) {
                     if (var16 != null) {
                         try {
                         try {
                             fileInputStream.close();
                             fileInputStream.close();
-                        } catch (Throwable var76) {
-                            var16.addSuppressed(var76);
+                        } catch (Throwable var77) {
+                            var16.addSuppressed(var77);
                         }
                         }
                     } else {
                     } else {
                         fileInputStream.close();
                         fileInputStream.close();
@@ -249,6 +267,63 @@ public class RecognitionCheckHelperEx {
         return resultList;
         return resultList;
     }
     }
 
 
+    private boolean getValidateFlag(Object analysisInvoiceInfo) {
+        if (analysisInvoiceInfo == null) {
+            return false;
+        } else {
+            boolean resultFlag = false;
+            if (analysisInvoiceInfo instanceof JSONObject) {
+                resultFlag = InputInvoiceTypeEnum.ELECTRIC_ORDINARY.getCode().equals(((JSONObject)analysisInvoiceInfo).getLong("invoiceType")) || InputInvoiceTypeEnum.ELECTRIC_SPECIAL.getCode().equals(((JSONObject)analysisInvoiceInfo).getLong("invoiceType"));
+                if (!resultFlag) {
+                    resultFlag = this.checkParamValidate((JSONObject)analysisInvoiceInfo);
+                }
+            } else if (analysisInvoiceInfo instanceof JSONArray) {
+                JSONArray array = (JSONArray)analysisInvoiceInfo;
+
+                for(int i = 0; i < array.size(); ++i) {
+                    resultFlag = InputInvoiceTypeEnum.ELECTRIC_ORDINARY.getCode().equals(array.getJSONObject(i).getLong("invoiceType")) || InputInvoiceTypeEnum.ELECTRIC_SPECIAL.getCode().equals(array.getJSONObject(i).getLong("invoiceType"));
+                    if (!resultFlag) {
+                        resultFlag = this.checkParamValidate(array.getJSONObject(i));
+                        if (!resultFlag) {
+                            return false;
+                        }
+                    }
+                }
+            } else if (analysisInvoiceInfo instanceof ArrayList) {
+                List<Map<String, Object>> list = (List)analysisInvoiceInfo;
+                Iterator var7 = list.iterator();
+
+                while(var7.hasNext()) {
+                    Map<String, Object> map = (Map)var7.next();
+                    resultFlag = InputInvoiceTypeEnum.ELECTRIC_ORDINARY.getCode().equals(Long.parseLong(map.get("invoiceType") + "")) || InputInvoiceTypeEnum.ELECTRIC_SPECIAL.getCode().equals(Long.parseLong(map.get("invoiceType") + ""));
+                    if (!resultFlag) {
+                        resultFlag = this.checkParamValidate(new JSONObject(map));
+                        if (!resultFlag) {
+                            return false;
+                        }
+                    }
+                }
+            }
+
+            return resultFlag;
+        }
+    }
+
+    public boolean checkParamValidate(JSONObject invoice) {
+        String invoiceCode = invoice.getString("invoiceCode");
+        String invoiceNo = invoice.getString("invoiceNo");
+        String invoiceAmount = invoice.getString("invoiceAmount");
+        String invoiceDate = invoice.getString("invoiceDate");
+        boolean validate = StringUtils.isNotEmpty(invoiceCode) && StringUtils.isNotEmpty(invoiceNo) && StringUtils.isNotEmpty(invoiceAmount) && StringUtils.isNotEmpty(invoiceDate);
+        Long invoiceType = invoice.getLong("invoiceType");
+        if (!InputInvoiceTypeEnum.ORDINARY_ELECTRON.getCode().equals(invoiceType) && !InputInvoiceTypeEnum.ORDINARY_PAPER.getCode().equals(invoiceType) && !InputInvoiceTypeEnum.ORDINARY_ROLL.getCode().equals(invoiceType) && !InputInvoiceTypeEnum.TOLL_ELECTRON.getCode().equals(invoiceType)) {
+            return validate;
+        } else {
+            String checkCode = invoice.getString("checkCode");
+            return validate && StringUtils.isNotEmpty(checkCode);
+        }
+    }
+
     private String getOverseaAppCode(Map<String, String> configMap) {
     private String getOverseaAppCode(Map<String, String> configMap) {
         if (configMap == null) {
         if (configMap == null) {
             return null;
             return null;
@@ -315,10 +390,8 @@ public class RecognitionCheckHelperEx {
 
 
     private StringBuilder getMsgExceptionInfo(RecognitionResult recognitionResult) {
     private StringBuilder getMsgExceptionInfo(RecognitionResult recognitionResult) {
         StringBuilder sb = new StringBuilder();
         StringBuilder sb = new StringBuilder();
-        sb.append("识别失败,识别接口返回:【");
-        sb.append(recognitionResult.getErrcode());
-        sb.append('】');
-        sb.append(recognitionResult.getDescription());
+        String str = String.format(ResManager.loadKDString("识别失败,识别接口返回:【%1$s】%2$s", "RecognitionCheckHelper_1", "imc-rim-common", new Object[0]), recognitionResult.getErrcode(), recognitionResult.getDescription());
+        sb.append(str);
         return sb;
         return sb;
     }
     }
 
 
@@ -351,12 +424,12 @@ public class RecognitionCheckHelperEx {
                 String invoiceCode;
                 String invoiceCode;
                 if (object.getClass() != null) {
                 if (object.getClass() != null) {
                     invoiceType = recognitionInfo.getLong("invoiceType");
                     invoiceType = recognitionInfo.getLong("invoiceType");
+                    String exit;
                     if (InputInvoiceTypeEnum.AIR_INVOICE.getCode().equals(invoiceType)) {
                     if (InputInvoiceTypeEnum.AIR_INVOICE.getCode().equals(invoiceType)) {
                         invoiceCode = recognitionInfo.getString("invoiceDate");
                         invoiceCode = recognitionInfo.getString("invoiceDate");
-                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
-                        String issueDate = recognitionInfo.getString("issueDate");
-                        if (StringUtils.isNotEmpty(issueDate)) {
-                            Date date = simpleDateFormat.parse(issueDate);
+                        exit = recognitionInfo.getString("issueDate");
+                        if (StringUtils.isNotBlank(exit)) {
+                            Date date = recognitionInfo.getDate("issueDate");
                             if (StringUtils.isEmpty(invoiceCode) || "OPEN".equalsIgnoreCase(invoiceCode)) {
                             if (StringUtils.isEmpty(invoiceCode) || "OPEN".equalsIgnoreCase(invoiceCode)) {
                                 recognitionInfo.put("invoiceDate", DateUtils.format(date, "yyyy-MM-dd"));
                                 recognitionInfo.put("invoiceDate", DateUtils.format(date, "yyyy-MM-dd"));
                             }
                             }
@@ -366,7 +439,7 @@ public class RecognitionCheckHelperEx {
                     isPass = ConvertFieldUtil.checkNullValidate(recognitionInfo, object.getClass());
                     isPass = ConvertFieldUtil.checkNullValidate(recognitionInfo, object.getClass());
                     if (isPass && InputInvoiceTypeEnum.ROAD_BRIDGE.getCode().equals(invoiceType)) {
                     if (isPass && InputInvoiceTypeEnum.ROAD_BRIDGE.getCode().equals(invoiceType)) {
                         invoiceCode = recognitionInfo.getString("invoiceCode");
                         invoiceCode = recognitionInfo.getString("invoiceCode");
-                        String exit = recognitionInfo.getString("exit");
+                        exit = recognitionInfo.getString("exit");
                         if (StringUtils.isEmpty(invoiceCode) && StringUtils.isEmpty(exit)) {
                         if (StringUtils.isEmpty(invoiceCode) && StringUtils.isEmpty(exit)) {
                             isPass = false;
                             isPass = false;
                         }
                         }
@@ -404,7 +477,7 @@ public class RecognitionCheckHelperEx {
                 }
                 }
 
 
                 if (InvoiceConvertUtils.isSaleListInvoiceType(invoiceType)) {
                 if (InvoiceConvertUtils.isSaleListInvoiceType(invoiceType)) {
-                    this.markSaleListInvoice(recognitionInfo);
+                    markSaleListInvoice(recognitionInfo);
                 }
                 }
 
 
                 recognitionInfo.put("fileHash", fileHash);
                 recognitionInfo.put("fileHash", fileHash);
@@ -425,7 +498,7 @@ public class RecognitionCheckHelperEx {
             if (valueObj instanceof BigDecimal) {
             if (valueObj instanceof BigDecimal) {
                 String valueObjStr = valueObj.toString().replace("-", "");
                 String valueObjStr = valueObj.toString().replace("-", "");
                 if (BigDecimalUtil.transDecimal(valueObjStr).compareTo(FpzsConstant.sysMaxAmount) > 0) {
                 if (BigDecimalUtil.transDecimal(valueObjStr).compareTo(FpzsConstant.sysMaxAmount) > 0) {
-                    valueObj = BigDecimal.ZERO;
+                     valueObj = BigDecimal.ZERO;
                     logger.info("发票{} 超过系统金额最大值:{} 置为0", object.getKey(), FpzsConstant.sysMaxAmount);
                     logger.info("发票{} 超过系统金额最大值:{} 置为0", object.getKey(), FpzsConstant.sysMaxAmount);
                     recognitionInfo.put((String)object.getKey(), valueObj);
                     recognitionInfo.put((String)object.getKey(), valueObj);
                 }
                 }
@@ -445,7 +518,7 @@ public class RecognitionCheckHelperEx {
 
 
     }
     }
 
 
-    private void markSaleListInvoice(JSONObject recognitionInfo) {
+    public static void markSaleListInvoice(JSONObject recognitionInfo) {
         JSONArray items = recognitionInfo.getJSONArray("items");
         JSONArray items = recognitionInfo.getJSONArray("items");
         recognitionInfo.put("isSaleListInvoice", "0");
         recognitionInfo.put("isSaleListInvoice", "0");
         if (items != null && items.size() == 1) {
         if (items != null && items.size() == 1) {
@@ -477,7 +550,7 @@ public class RecognitionCheckHelperEx {
             return ItextPdfUtils.extractpdf(url, fileName);
             return ItextPdfUtils.extractpdf(url, fileName);
         } else {
         } else {
             if (FileUtils.checkFileType(fileName, new String[]{"ofd"})) {
             if (FileUtils.checkFileType(fileName, new String[]{"ofd"})) {
-                JSONObject result = this.ofdAnalysis(url);
+                JSONObject result = (JSONObject) this.ofdAnalysis(url);
                 if (result != null) {
                 if (result != null) {
                     fileEntity.setFileSize(BigDecimalUtil.transDecimal(result.getString("fileSize")).intValue());
                     fileEntity.setFileSize(BigDecimalUtil.transDecimal(result.getString("fileSize")).intValue());
                 }
                 }
@@ -493,40 +566,43 @@ public class RecognitionCheckHelperEx {
         }
         }
     }
     }
 
 
-    private JSONObject ofdAnalysis(String fileUrl) {
+    private Serializable ofdAnalysis(String fileUrl) {
         try {
         try {
             InputStream fileInputStream = UrlServiceUtils.getAttachmentDecodedStream(FileServiceFactory.getAttachmentFileService().getInputStream(fileUrl));
             InputStream fileInputStream = UrlServiceUtils.getAttachmentDecodedStream(FileServiceFactory.getAttachmentFileService().getInputStream(fileUrl));
             Throwable var3 = null;
             Throwable var3 = null;
 
 
-            JSONObject var20;
+            Long invoiceType;
             try {
             try {
                 byte[] streamByte = FileUtils.getByte(fileInputStream);
                 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")));
-                    }
+                JSONObject result;
+                if (streamByte == null) {
+                    result = null;
+                    return null;
+                }
 
 
+                result = OfdReadUtils.readData(streamByte);
+                Object invoice = result.get("invoice");
+                VatInvoice vatInvoice = (VatInvoice)invoice;
+                result = JSON.parseObject(JSON.toJSONString(vatInvoice));
+                if (vatInvoice != null) {
+                    invoiceType = InputInvoiceTypeEnum.getInvoiceTypeByAwsType(vatInvoice.getInvoiceType());
+                    result.put("invoiceType", invoiceType);
                     result.put("fileSize", streamByte.length);
                     result.put("fileSize", streamByte.length);
+                    JSONObject var9 = result;
+                    return var9;
                 }
                 }
 
 
-                var20 = result;
-            } catch (Throwable var17) {
-                var3 = var17;
-                throw var17;
+                invoiceType = null;
+            } catch (Throwable var21) {
+                var3 = var21;
+                throw var21;
             } finally {
             } finally {
                 if (fileInputStream != null) {
                 if (fileInputStream != null) {
                     if (var3 != null) {
                     if (var3 != null) {
                         try {
                         try {
                             fileInputStream.close();
                             fileInputStream.close();
-                        } catch (Throwable var16) {
-                            var3.addSuppressed(var16);
+                        } catch (Throwable var20) {
+                            var3.addSuppressed(var20);
                         }
                         }
                     } else {
                     } else {
                         fileInputStream.close();
                         fileInputStream.close();
@@ -535,8 +611,9 @@ public class RecognitionCheckHelperEx {
 
 
             }
             }
 
 
-            return var20;
-        } catch (Exception var19) {
+            return invoiceType;
+        } catch (Exception var23) {
+            logger.info("ofdAnalysis exception :{}", var23);
             return null;
             return null;
         }
         }
     }
     }
@@ -569,7 +646,7 @@ public class RecognitionCheckHelperEx {
                     JSONObject invoiceInfo = (JSONObject)var5.next();
                     JSONObject invoiceInfo = (JSONObject)var5.next();
                     JSONObject result = invoiceInfo;
                     JSONObject result = invoiceInfo;
                     Long invoiceType = invoiceInfo.getLong("invoiceType");
                     Long invoiceType = invoiceInfo.getLong("invoiceType");
-                    if (!InvoiceConvertUtils.isVatInvoiceType(invoiceType)) {
+                    if (!InputInvoiceTypeEnum.needCheck(invoiceType)) {
                         checkResultList.add(invoiceInfo);
                         checkResultList.add(invoiceInfo);
                     } else {
                     } else {
                         CheckParam checkParam = ConvertFieldUtil.getInvoiceCheckPart(invoiceInfo);
                         CheckParam checkParam = ConvertFieldUtil.getInvoiceCheckPart(invoiceInfo);
@@ -583,6 +660,11 @@ public class RecognitionCheckHelperEx {
                                     String invoiceCheckStr = JSONObject.toJSONString(invoiceEntity);
                                     String invoiceCheckStr = JSONObject.toJSONString(invoiceEntity);
                                     JSONObject invoiceCheckInfo = JSON.parseObject(invoiceCheckStr);
                                     JSONObject invoiceCheckInfo = JSON.parseObject(invoiceCheckStr);
                                     this.putRecognitionInfo(invoiceCheckInfo, invoiceInfo);
                                     this.putRecognitionInfo(invoiceCheckInfo, invoiceInfo);
+                                    if (InputInvoiceTypeEnum.AIR_ELE_INVOICE.getCode().equals(invoiceType)) {
+                                        invoiceInfo.putAll(invoiceCheckInfo);
+                                        invoiceCheckInfo = this.mixAirEleData(invoiceInfo);
+                                    }
+
                                     result = invoiceCheckInfo;
                                     result = invoiceCheckInfo;
                                     String originalStateDefault = (String)extMap.get("originalStateDefault");
                                     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);
                                     boolean typeFlag = InputInvoiceTypeEnum.ORDINARY_ELECTRON.getCode().equals(invoiceType) || InputInvoiceTypeEnum.TOLL_ELECTRON.getCode().equals(invoiceType) || InputInvoiceTypeEnum.SPECIAL_ELECTRON.getCode().equals(invoiceType);
@@ -612,6 +694,26 @@ public class RecognitionCheckHelperEx {
         }
         }
     }
     }
 
 
+    private JSONObject mixAirEleData(JSONObject invoiceInfo) {
+        if (invoiceInfo == null) {
+            return new JSONObject();
+        } else {
+            Object issueDate = invoiceInfo.get("issueDate");
+            if (issueDate instanceof Integer) {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+
+                try {
+                    Date date = sdf.parse(String.valueOf(issueDate));
+                    invoiceInfo.put("invoiceDate", date);
+                    invoiceInfo.put("issueDate", date);
+                } catch (ParseException var5) {
+                }
+            }
+
+            return invoiceInfo;
+        }
+    }
+
     public static void markSaleListByCheckResult(JSONObject invoiceCheckInfo) {
     public static void markSaleListByCheckResult(JSONObject invoiceCheckInfo) {
         invoiceCheckInfo.put("isSaleListInvoice", "0");
         invoiceCheckInfo.put("isSaleListInvoice", "0");
         JSONArray items = invoiceCheckInfo.getJSONArray("items");
         JSONArray items = invoiceCheckInfo.getJSONArray("items");
@@ -737,6 +839,10 @@ public class RecognitionCheckHelperEx {
 
 
     }
     }
 
 
+    public JSONArray bindAttachInvoice(JSONArray targetArray, JSONObject businessParam) {
+        return this.bindAttachInvoice(targetArray, businessParam, new HashMap(0));
+    }
+
     public JSONArray bindAttachInvoice(JSONArray targetArray, JSONObject businessParam, Map<String, Long> invoiceTypeMap) {
     public JSONArray bindAttachInvoice(JSONArray targetArray, JSONObject businessParam, Map<String, Long> invoiceTypeMap) {
         JSONArray attachArray = new JSONArray();
         JSONArray attachArray = new JSONArray();
         if (targetArray.size() == 0) {
         if (targetArray.size() == 0) {
@@ -746,9 +852,11 @@ public class RecognitionCheckHelperEx {
                 JSONObject invoiceInfo = (JSONObject)i;
                 JSONObject invoiceInfo = (JSONObject)i;
                 int pageNo = invoiceInfo.getInteger("pageNo");
                 int pageNo = invoiceInfo.getInteger("pageNo");
                 boolean originalCheck = "1".equals(invoiceInfo.getString("originalState"));
                 boolean originalCheck = "1".equals(invoiceInfo.getString("originalState"));
-                if (!originalCheck) {
-                    String invoiceCode = invoiceInfo.getString("invoiceCode");
-                    String invoiceNo = invoiceInfo.getString("invoiceNo");
+                String invoiceCode = invoiceInfo.getString("invoiceCode");
+                String invoiceNo = invoiceInfo.getString("invoiceNo");
+                Long invoiceType = (Long)invoiceTypeMap.get(StringUtils.trimToEmpty(invoiceCode) + StringUtils.trimToEmpty(invoiceNo));
+                boolean salerInvoiceType = invoiceType == null || InvoiceConvertUtils.isSaleListInvoiceType(invoiceType);
+                if (!originalCheck && salerInvoiceType) {
                     DynamicObject attachObject = this.getAttachDynamicObject(invoiceInfo, businessParam);
                     DynamicObject attachObject = this.getAttachDynamicObject(invoiceInfo, businessParam);
                     DynamicObject attachSaveObject = (DynamicObject)SaveServiceHelper.save(new DynamicObject[]{attachObject})[0];
                     DynamicObject attachSaveObject = (DynamicObject)SaveServiceHelper.save(new DynamicObject[]{attachObject})[0];
                     JSONObject attachInfo = new JSONObject(DynamicObjectUtil.dynamicObject2Map(attachSaveObject));
                     JSONObject attachInfo = new JSONObject(DynamicObjectUtil.dynamicObject2Map(attachSaveObject));
@@ -817,11 +925,12 @@ public class RecognitionCheckHelperEx {
         QFilter filter3 = new QFilter("attach_hash_value", "=", invoiceInfo.getString("fileHash"));
         QFilter filter3 = new QFilter("attach_hash_value", "=", invoiceInfo.getString("fileHash"));
         DynamicObject idObject = QueryServiceHelper.queryOne("rim_attach", "id", new QFilter[]{filter1, filter2, filter3});
         DynamicObject idObject = QueryServiceHelper.queryOne("rim_attach", "id", new QFilter[]{filter1, filter2, filter3});
         DynamicObject attachObject = null;
         DynamicObject attachObject = null;
-        if (idObject == null) {
+        boolean pdfFlag = "1".equals(invoiceInfo.getString("fileType"));
+        if (idObject != null && !pdfFlag) {
+            attachObject = BusinessDataServiceHelper.loadSingle(idObject.get("id"), "rim_attach");
+        } else {
             attachObject = BusinessDataServiceHelper.newDynamicObject("rim_attach");
             attachObject = BusinessDataServiceHelper.newDynamicObject("rim_attach");
             attachObject.set("create_time", new Date());
             attachObject.set("create_time", new Date());
-        } else {
-            attachObject = BusinessDataServiceHelper.loadSingle(idObject.get("id"), "rim_attach");
         }
         }
 
 
         attachObject.set("update_time", new Date());
         attachObject.set("update_time", new Date());
@@ -831,24 +940,27 @@ public class RecognitionCheckHelperEx {
         }
         }
 
 
         attachObject.set("attach_no", attachNo);
         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"));
+        attachObject.set("attach_url", invoiceInfo.getString("snapshotUrl"));
+        String subFileName = invoiceInfo.getString("subFileName");
+        String pageNum;
+        if (StringUtils.isNotEmpty(subFileName)) {
+            attachObject.set("attach_type", "2");
+            attachObject.set("attach_name", subFileName);
+            pageNum = subFileName.substring(subFileName.lastIndexOf(46) + 1);
+            attachObject.set("file_extension", pageNum);
         } else {
         } else {
-            attachObject.set("attach_url", invoiceInfo.getString("snapshotUrl"));
+            attachObject.set("attach_type", invoiceInfo.getString("fileType"));
+            attachObject.set("attach_name", invoiceInfo.getString("fileName"));
+            pageNum = invoiceInfo.getString("fileName").substring(invoiceInfo.getString("fileName").lastIndexOf(46) + 1);
+            attachObject.set("file_extension", pageNum);
         }
         }
 
 
-        attachObject.set("attach_type", invoiceInfo.getString("fileType"));
         attachObject.set("attach_category", AttachConstant.ATTACH_LIST_CATEGORY_ID);
         attachObject.set("attach_category", AttachConstant.ATTACH_LIST_CATEGORY_ID);
-        attachObject.set("attach_name", invoiceInfo.getString("fileName"));
         attachObject.set("original_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("snapshot_url", invoiceInfo.getString("snapshotUrl"));
         attachObject.set("icon_url", invoiceInfo.getString("snapshotUrl"));
         attachObject.set("icon_url", invoiceInfo.getString("snapshotUrl"));
         attachObject.set("attach_hash_value", invoiceInfo.getString("fileHash"));
         attachObject.set("attach_hash_value", invoiceInfo.getString("fileHash"));
-        String pageNum = invoiceInfo.getString("pageNum");
+        pageNum = invoiceInfo.getString("pageNum");
         if (StringUtils.isNotEmpty(pageNum)) {
         if (StringUtils.isNotEmpty(pageNum)) {
             try {
             try {
                 String target = pageNum.replaceAll(" ", "");
                 String target = pageNum.replaceAll(" ", "");
@@ -860,8 +972,8 @@ public class RecognitionCheckHelperEx {
                 String pageNo = target.substring(index3, subStr.length()).substring(1);
                 String pageNo = target.substring(index3, subStr.length()).substring(1);
                 attachObject.set("page_sum", Integer.valueOf(pageSum));
                 attachObject.set("page_sum", Integer.valueOf(pageSum));
                 attachObject.set("page_no", Integer.valueOf(pageNo));
                 attachObject.set("page_no", Integer.valueOf(pageNo));
-            } catch (Exception var20) {
-                logger.info("截取总页码失败:", var20);
+            } catch (Exception var21) {
+                logger.info("截取总页码失败:", var21);
             }
             }
         }
         }
 
 
@@ -871,15 +983,20 @@ public class RecognitionCheckHelperEx {
     public JSONArray getTargetArray(JSONArray finalResult) {
     public JSONArray getTargetArray(JSONArray finalResult) {
         return (JSONArray)finalResult.stream().filter((f) -> {
         return (JSONArray)finalResult.stream().filter((f) -> {
             JSONObject invoiceInfo = (JSONObject)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;
+            return isSalePage(invoiceInfo);
         }).collect(Collectors.toCollection(JSONArray::new));
         }).collect(Collectors.toCollection(JSONArray::new));
     }
     }
 
 
+    public static boolean isSalePage(JSONObject invoiceInfo) {
+        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);
+        String title = invoiceInfo.getString("title");
+        boolean titleCheck = StringUtils.isNotEmpty(title) && (title.contains("清单") || title.contains("明细"));
+        return typeCheck && emptyCheck && titleCheck;
+    }
+
     public void dealInvoiceAttachRelation(JSONObject invoiceInfo) {
     public void dealInvoiceAttachRelation(JSONObject invoiceInfo) {
         if (invoiceInfo != null) {
         if (invoiceInfo != null) {
             logger.info("处理发票绑定附件关系....");
             logger.info("处理发票绑定附件关系....");
@@ -922,7 +1039,7 @@ public class RecognitionCheckHelperEx {
         String attachFields = MetadataUtil.getFields("rim_attach");
         String attachFields = MetadataUtil.getFields("rim_attach");
         DynamicObject[] attachCollect = BusinessDataServiceHelper.load("rim_attach", attachFields, new QFilter[]{attachNoFilter});
         DynamicObject[] attachCollect = BusinessDataServiceHelper.load("rim_attach", attachFields, new QFilter[]{attachNoFilter});
         int bindNum = 0;
         int bindNum = 0;
-        DynamicObject attachObject;
+        DynamicObject attachOne;
         if (attachCollect != null && attachCollect.length > 0) {
         if (attachCollect != null && attachCollect.length > 0) {
             String url = RimConfigUtils.getConfig("rim_recog_check", "salelistposturl");
             String url = RimConfigUtils.getConfig("rim_recog_check", "salelistposturl");
             if (StringUtils.isNotEmpty(url)) {
             if (StringUtils.isNotEmpty(url)) {
@@ -943,8 +1060,8 @@ public class RecognitionCheckHelperEx {
                 int var12 = attachCollect.length;
                 int var12 = attachCollect.length;
 
 
                 for(int var13 = 0; var13 < var12; ++var13) {
                 for(int var13 = 0; var13 < var12; ++var13) {
-                    attachObject = var18[var13];
-                    Long attachId = attachObject.getLong("id");
+                    attachOne = var18[var13];
+                    Long attachId = attachOne.getLong("id");
                     boolean isBind = this.checkBind(attachId);
                     boolean isBind = this.checkBind(attachId);
                     if (isBind) {
                     if (isBind) {
                         ++bindNum;
                         ++bindNum;
@@ -955,13 +1072,17 @@ public class RecognitionCheckHelperEx {
 
 
         QFilter invoiceNoFilter = new QFilter("invoice_no", "=", invoiceNo);
         QFilter invoiceNoFilter = new QFilter("invoice_no", "=", invoiceNo);
         QFilter invoiceCodeFilter = new QFilter("invoice_code", "=", invoiceCode);
         QFilter invoiceCodeFilter = new QFilter("invoice_code", "=", invoiceCode);
+        if (StringUtils.isNotEmpty(invoiceNo) && invoiceNo.length() == 20) {
+            invoiceCodeFilter = null;
+        }
+
         String mainFields = MetadataUtil.getFields("rim_invoice");
         String mainFields = MetadataUtil.getFields("rim_invoice");
         DynamicObject mainObject = BusinessDataServiceHelper.loadSingle("rim_invoice", mainFields, new QFilter[]{invoiceNoFilter, invoiceCodeFilter});
         DynamicObject mainObject = BusinessDataServiceHelper.loadSingle("rim_invoice", mainFields, new QFilter[]{invoiceNoFilter, invoiceCodeFilter});
         if (mainObject != null) {
         if (mainObject != null) {
             saleListSum = mainObject.getInt("salelist_sum");
             saleListSum = mainObject.getInt("salelist_sum");
             if (attachCollect != null && attachCollect.length > 0) {
             if (attachCollect != null && attachCollect.length > 0) {
-                attachObject = attachCollect[0];
-                int pageSum = attachObject.getInt("page_sum");
+                attachOne = attachCollect[0];
+                int pageSum = attachOne.getInt("page_sum");
                 if (pageSum != 0 && pageSum != saleListSum) {
                 if (pageSum != 0 && pageSum != saleListSum) {
                     mainObject.set("salelist_sum", pageSum);
                     mainObject.set("salelist_sum", pageSum);
                     saleListSum = pageSum;
                     saleListSum = pageSum;

+ 21 - 18
src/main/java/kd/imc/rim/common/service/RecognitionCheckServiceEx.java → src/main/java/kd/imc/rim/RecognitionCheckServiceEx.java

@@ -3,7 +3,7 @@
 // (powered by FernFlower decompiler)
 // (powered by FernFlower decompiler)
 //
 //
 
 
-package kd.imc.rim.common.service;
+package kd.imc.rim;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
@@ -38,8 +38,6 @@ import kd.bos.threads.ThreadPools;
 import kd.imc.rim.common.constant.CheckContant;
 import kd.imc.rim.common.constant.CheckContant;
 import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
 import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
 import kd.imc.rim.common.constant.InvoiceUploadErrorType;
 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.collector.InvoiceCollectService;
 import kd.imc.rim.common.invoice.model.ConvertFieldUtil;
 import kd.imc.rim.common.invoice.model.ConvertFieldUtil;
 import kd.imc.rim.common.invoice.recognition.listener.IRecognitionListener;
 import kd.imc.rim.common.invoice.recognition.listener.IRecognitionListener;
@@ -47,7 +45,12 @@ import kd.imc.rim.common.invoice.recognition.listener.RecognitionListenerResult;
 import kd.imc.rim.common.invoice.recognitionnew.task.FileUploadAndSignTask;
 import kd.imc.rim.common.invoice.recognitionnew.task.FileUploadAndSignTask;
 import kd.imc.rim.common.invoice.save.InvoiceSaveService;
 import kd.imc.rim.common.invoice.save.InvoiceSaveService;
 import kd.imc.rim.common.message.exception.MsgException;
 import kd.imc.rim.common.message.exception.MsgException;
-import kd.imc.rim.common.utils.*;
+import kd.imc.rim.common.utils.FileUploadUtils;
+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.RimConfigUtils;
 import kd.imc.rim.common.utils.itextpdf.UrlServiceUtils;
 import kd.imc.rim.common.utils.itextpdf.UrlServiceUtils;
 import kd.imc.rim.file.utils.FileConvertUtils;
 import kd.imc.rim.file.utils.FileConvertUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.CollectionUtils;
@@ -55,7 +58,7 @@ import org.apache.commons.compress.utils.Lists;
 
 
 public class RecognitionCheckServiceEx {
 public class RecognitionCheckServiceEx {
     private static RecognitionCheckServiceEx instance = null;
     private static RecognitionCheckServiceEx instance = null;
-    private static Log logger = LogFactory.getLog(RecognitionCheckService.class);
+    private static Log logger = LogFactory.getLog(RecognitionCheckServiceEx.class);
     private RecognitionCheckHelperEx RecognitionCheckHelperEx = new RecognitionCheckHelperEx();
     private RecognitionCheckHelperEx RecognitionCheckHelperEx = new RecognitionCheckHelperEx();
     private InvoiceCollectService invoiceCollectService = new InvoiceCollectService();
     private InvoiceCollectService invoiceCollectService = new InvoiceCollectService();
     private static Integer recheckorginPage = 999123413;
     private static Integer recheckorginPage = 999123413;
@@ -65,8 +68,8 @@ public class RecognitionCheckServiceEx {
     }
     }
 
 
     public static RecognitionCheckServiceEx getInstance() {
     public static RecognitionCheckServiceEx getInstance() {
-        Class var0 = RecognitionCheckService.class;
-        synchronized(RecognitionCheckService.class) {
+        Class var0 = RecognitionCheckServiceEx.class;
+        synchronized(RecognitionCheckServiceEx.class) {
             if (instance == null) {
             if (instance == null) {
                 instance = new RecognitionCheckServiceEx();
                 instance = new RecognitionCheckServiceEx();
             }
             }
@@ -77,7 +80,7 @@ public class RecognitionCheckServiceEx {
 
 
     public JSONObject recognitionCheckInvoice(String fileUrl, String fileName, IRecognitionListener recognitionListener, JSONObject businessParam) {
     public JSONObject recognitionCheckInvoice(String fileUrl, String fileName, IRecognitionListener recognitionListener, JSONObject businessParam) {
         logger.info("识别查验fileName:{},businessParam:{}", fileName, businessParam);
         logger.info("识别查验fileName:{},businessParam:{}", fileName, businessParam);
-        fileName = kd.imc.rim.common.utils.FileUtilsEx.truncateFileName(fileName, 50);
+        fileName = FileUtils.truncateFileName(fileName, 50);
         this.markDeleteByVerifySave(businessParam);
         this.markDeleteByVerifySave(businessParam);
         boolean isCheck = this.getCheckFlag(businessParam);
         boolean isCheck = this.getCheckFlag(businessParam);
         return this.extracted_new(fileUrl, fileName, recognitionListener, businessParam, isCheck);
         return this.extracted_new(fileUrl, fileName, recognitionListener, businessParam, isCheck);
@@ -117,13 +120,13 @@ public class RecognitionCheckServiceEx {
 
 
             String fileType = fileEntity.getFileType();
             String fileType = fileEntity.getFileType();
             Map<Integer, Object> subFileFutureMap = this.syncUploadSubFile(fileEntity);
             Map<Integer, Object> subFileFutureMap = this.syncUploadSubFile(fileEntity);
-            logger.info("RecognitionCheckService 文件解析耗时:{}", System.currentTimeMillis() - fileStartTime);
+            logger.info("RecognitionCheckServiceEx 文件解析耗时:{}", System.currentTimeMillis() - fileStartTime);
 
 
             List recognitionResultList;
             List recognitionResultList;
             try {
             try {
                 long recognitionStartTime = System.currentTimeMillis();
                 long recognitionStartTime = System.currentTimeMillis();
                 recognitionResultList = this.RecognitionCheckHelperEx.recognitionInvoiceFile(fileEntity, extMap);
                 recognitionResultList = this.RecognitionCheckHelperEx.recognitionInvoiceFile(fileEntity, extMap);
-                logger.info("RecognitionCheckService 识别总耗时:{}", System.currentTimeMillis() - recognitionStartTime);
+                logger.info("RecognitionCheckServiceEx 识别总耗时:{}", System.currentTimeMillis() - recognitionStartTime);
                 this.checkOriginal(fileEntity, subFileFutureMap, recognitionResultList);
                 this.checkOriginal(fileEntity, subFileFutureMap, recognitionResultList);
                 finalResult = JSONObject.parseArray(JSONObject.toJSONString(recognitionResultList));
                 finalResult = JSONObject.parseArray(JSONObject.toJSONString(recognitionResultList));
             } catch (Throwable var26) {
             } catch (Throwable var26) {
@@ -140,7 +143,7 @@ public class RecognitionCheckServiceEx {
                 try {
                 try {
                     long checkStartTime = System.currentTimeMillis();
                     long checkStartTime = System.currentTimeMillis();
                     List<JSONObject> checkResultList = this.RecognitionCheckHelperEx.checkInvoiceByRecognitionInfo(recognitionResultList, extMap);
                     List<JSONObject> checkResultList = this.RecognitionCheckHelperEx.checkInvoiceByRecognitionInfo(recognitionResultList, extMap);
-                    logger.info("RecognitionCheckService 查验总耗时:{}", System.currentTimeMillis() - checkStartTime);
+                    logger.info("RecognitionCheckServiceEx 查验总耗时:{}", System.currentTimeMillis() - checkStartTime);
                     finalResult = JSONObject.parseArray(JSONObject.toJSONString(checkResultList));
                     finalResult = JSONObject.parseArray(JSONObject.toJSONString(checkResultList));
                 } catch (Throwable var25) {
                 } catch (Throwable var25) {
                     this.handle(recognitionListener, listener);
                     this.handle(recognitionListener, listener);
@@ -176,24 +179,24 @@ public class RecognitionCheckServiceEx {
                 logger.info("发票保存错误:", var24);
                 logger.info("发票保存错误:", var24);
             }
             }
         } catch (IOException var27) {
         } catch (IOException var27) {
-            logger.info("RecognitionCheckService IOException :{}", var27);
+            logger.info("RecognitionCheckServiceEx IOException :{}", var27);
             this.handle(recognitionListener, listener);
             this.handle(recognitionListener, listener);
             return InvoiceUploadErrorType.getSplitErrorResult();
             return InvoiceUploadErrorType.getSplitErrorResult();
         } catch (MsgException var28) {
         } catch (MsgException var28) {
-            logger.info("RecognitionCheckService MsgException :{}", var28);
+            logger.info("RecognitionCheckServiceEx MsgException :{}", var28);
             this.handle(recognitionListener, listener);
             this.handle(recognitionListener, listener);
             JSONObject errorInfo = new JSONObject();
             JSONObject errorInfo = new JSONObject();
             errorInfo.put("errcode", var28.getErrorCode());
             errorInfo.put("errcode", var28.getErrorCode());
             errorInfo.put("description", var28.getMessage());
             errorInfo.put("description", var28.getMessage());
             return errorInfo;
             return errorInfo;
         } catch (Throwable var29) {
         } catch (Throwable var29) {
-            logger.info("RecognitionCheckService BaseErrorResult Throwable:{}", var29);
+            logger.info("RecognitionCheckServiceEx BaseErrorResult Throwable:{}", var29);
             this.handle(recognitionListener, listener);
             this.handle(recognitionListener, listener);
             return InvoiceUploadErrorType.getBaseErrorResult();
             return InvoiceUploadErrorType.getBaseErrorResult();
         }
         }
 
 
         boolean resultFlag = finalResult.size() != 0 || attachResult.size() != 0;
         boolean resultFlag = finalResult.size() != 0 || attachResult.size() != 0;
-        logger.info("RecognitionCheckService 识别查验入库总耗时:{}", System.currentTimeMillis() - startTime);
+        logger.info("RecognitionCheckServiceEx 识别查验入库总耗时:{}", System.currentTimeMillis() - startTime);
         if (resultFlag) {
         if (resultFlag) {
             return InvoiceUploadErrorType.getSuccessResult(finalResult, attachResult);
             return InvoiceUploadErrorType.getSuccessResult(finalResult, attachResult);
         } else {
         } else {
@@ -219,7 +222,7 @@ public class RecognitionCheckServiceEx {
 
 
             for(i = 1; i < recognitionResultList.size(); ++i) {
             for(i = 1; i < recognitionResultList.size(); ++i) {
                 JSONObject invoice = (JSONObject)recognitionResultList.get(i);
                 JSONObject invoice = (JSONObject)recognitionResultList.get(i);
-                if (!RecognitionCheckHelper.isSalePage(invoice)) {
+                if (!kd.imc.rim.RecognitionCheckHelperEx.isSalePage(invoice)) {
                     return;
                     return;
                 }
                 }
             }
             }
@@ -336,7 +339,7 @@ public class RecognitionCheckServiceEx {
                 JSONObject invoiceInfo = finalResult.getJSONObject(i);
                 JSONObject invoiceInfo = finalResult.getJSONObject(i);
                 Long invoiceType = invoiceInfo.getLong("invoiceType");
                 Long invoiceType = invoiceInfo.getLong("invoiceType");
                 String title = invoiceInfo.getString("title");
                 String title = invoiceInfo.getString("title");
-                if (!RecognitionCheckHelper.isSalePage(invoiceInfo) && InputInvoiceTypeEnum.OTHER_INVOICE.getCode().equals(invoiceType) && StringUtils.isNotEmpty(title) && title.indexOf("明细") > 0) {
+                if (!kd.imc.rim.RecognitionCheckHelperEx.isSalePage(invoiceInfo) && InputInvoiceTypeEnum.OTHER_INVOICE.getCode().equals(invoiceType) && StringUtils.isNotEmpty(title) && title.indexOf("明细") > 0) {
                     list.add(invoiceInfo);
                     list.add(invoiceInfo);
                 }
                 }
             }
             }
@@ -621,7 +624,7 @@ public class RecognitionCheckServiceEx {
 
 
                         this.invoiceCollectService.saveInvoice(invoiceInfo, fileUrl, fileHash);
                         this.invoiceCollectService.saveInvoice(invoiceInfo, fileUrl, fileHash);
                     } catch (Exception var28) {
                     } catch (Exception var28) {
-                        String errorMsg = ResManager.loadKDString("发票数据保存异常,请联系管理员", "RecognitionCheckService_0", "imc-rim-common", new Object[0]);
+                        String errorMsg = ResManager.loadKDString("发票数据保存异常,请联系管理员", "RecognitionCheckServiceEx_0", "imc-rim-common", new Object[0]);
                         if (var28 instanceof MsgException) {
                         if (var28 instanceof MsgException) {
                             errorMsg = ((MsgException)var28).getErrorMsg();
                             errorMsg = ((MsgException)var28).getErrorMsg();
                         }
                         }

+ 72 - 72
src/main/java/kd/imc/rim/common/invoice/recognition/impl/RecognitionCheckTaskEx.java → src/main/java/kd/imc/rim/RecognitionCheckTaskEx.java

@@ -3,7 +3,7 @@
 // (powered by FernFlower decompiler)
 // (powered by FernFlower decompiler)
 //
 //
 
 
-package kd.imc.rim.common.invoice.recognition.impl;
+package kd.imc.rim;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
@@ -29,7 +29,9 @@ import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
 import kd.imc.rim.common.constant.ResultContant;
 import kd.imc.rim.common.constant.ResultContant;
 import kd.imc.rim.common.invoice.fpzs.FpzsMainService;
 import kd.imc.rim.common.invoice.fpzs.FpzsMainService;
 import kd.imc.rim.common.invoice.recognition.listener.IRecognitionListener;
 import kd.imc.rim.common.invoice.recognition.listener.IRecognitionListener;
-import kd.imc.rim.common.service.*;
+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.utils.BigDecimalUtil;
 import kd.imc.rim.common.utils.BigDecimalUtil;
 import kd.imc.rim.common.utils.CacheHelper;
 import kd.imc.rim.common.utils.CacheHelper;
 import kd.imc.rim.common.utils.FileUtils;
 import kd.imc.rim.common.utils.FileUtils;
@@ -37,7 +39,7 @@ import kd.imc.rim.common.utils.MD5;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.lang3.tuple.Pair;
 
 
 public class RecognitionCheckTaskEx implements Callable<JSONObject> {
 public class RecognitionCheckTaskEx implements Callable<JSONObject> {
-    private static Log logger = LogFactory.getLog(RecognitionCheckTask.class);
+    private static Log logger = LogFactory.getLog(RecognitionCheckTaskEx.class);
     private static int cache_time_out = 1800;
     private static int cache_time_out = 1800;
     private JSONObject businessParam;
     private JSONObject businessParam;
     private Map<String, Object> customParam;
     private Map<String, Object> customParam;
@@ -108,7 +110,7 @@ public class RecognitionCheckTaskEx implements Callable<JSONObject> {
 
 
                 boolean isNeedDeal = FileUtils.checkFileType(this.fileName, new String[]{"zip", "ofd", "pdf"});
                 boolean isNeedDeal = FileUtils.checkFileType(this.fileName, new String[]{"zip", "ofd", "pdf"});
                 if (isNeedDeal) {
                 if (isNeedDeal) {
-                    ElectAccVoucherServiceEx electAccVoucherService = new ElectAccVoucherServiceEx();
+                    ElectAccVoucherService electAccVoucherService = new ElectAccVoucherService();
                     invoiceResult = electAccVoucherService.dealVoucher(this.url, this.fileName, orgId, this.businessParam, (IRecognitionListener)null);
                     invoiceResult = electAccVoucherService.dealVoucher(this.url, this.fileName, orgId, this.businessParam, (IRecognitionListener)null);
                 }
                 }
 
 
@@ -343,48 +345,45 @@ public class RecognitionCheckTaskEx implements Callable<JSONObject> {
             DLock lock = DLock.create("lock_" + cacheKey, ResManager.loadKDString("刷新卡片锁", "RecognitionCheckTask_1", "imc-rim-common", new Object[0]));
             DLock lock = DLock.create("lock_" + cacheKey, ResManager.loadKDString("刷新卡片锁", "RecognitionCheckTask_1", "imc-rim-common", new Object[0]));
             Throwable var6 = null;
             Throwable var6 = null;
 
 
-            JSONObject var10;
             try {
             try {
                 int times = 0;
                 int times = 0;
 
 
-                do {
-                    if (times >= 10) {
-                        return null;
-                    }
-
+                while(times < 10) {
                     ++times;
                     ++times;
-                } while(!lock.tryLock(100L));
-
+                    if (lock.tryLock(100L)) {
+                        try {
+                            String cache;
+                            if ("remove".equals(operate)) {
+                                CacheHelper.remove(cacheKey);
+                                cache = null;
+                                return null;
+                            }
 
 
-                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);
+                            }
 
 
-                    cache = CacheHelper.get(cacheKey);
-                    JSONObject obj = null;
-                    if (StringUtils.isEmpty(cache)) {
-                        obj = new JSONObject();
-                    } else {
-                        obj = JSON.parseObject(cache);
-                    }
+                            JSONObject var10;
+                            if ("query".equals(operate)) {
+                                var10 = obj;
+                                return var10;
+                            }
 
 
-                    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);
+                            }
 
 
-                    if (StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(operate) && StringUtils.isNotEmpty(cause)) {
-                        obj.put(url, cause);
-                        CacheHelper.put(cacheKey, obj.toJSONString(), cache_time_out);
+                            var10 = obj;
+                            return var10;
+                        } finally {
+                            lock.unlock();
+                        }
                     }
                     }
-
-                    var10 = obj;
-                } finally {
-                    lock.unlock();
                 }
                 }
             } catch (Throwable var29) {
             } catch (Throwable var29) {
                 var6 = var29;
                 var6 = var29;
@@ -404,7 +403,7 @@ public class RecognitionCheckTaskEx implements Callable<JSONObject> {
 
 
             }
             }
 
 
-            return var10;
+            return null;
         }
         }
     }
     }
 
 
@@ -417,49 +416,50 @@ public class RecognitionCheckTaskEx implements Callable<JSONObject> {
             DLock lock = DLock.create("lock_" + cacheKey, ResManager.loadKDString("刷新卡片锁", "RecognitionCheckTask_1", "imc-rim-common", new Object[0]));
             DLock lock = DLock.create("lock_" + cacheKey, ResManager.loadKDString("刷新卡片锁", "RecognitionCheckTask_1", "imc-rim-common", new Object[0]));
             Throwable var5 = null;
             Throwable var5 = null;
 
 
+            JSONObject var11;
             try {
             try {
                 int times = 0;
                 int times = 0;
 
 
-                while(times < 10) {
-                    ++times;
-                    if (lock.tryLock(100L)) {
-                        long starttime = System.currentTimeMillis();
+                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;
-                            }
+                long starttime = System.currentTimeMillis();
 
 
-                            cache = CacheHelper.get(cacheKey);
-                            JSONObject obj = null;
-                            if (StringUtils.isEmpty(cache)) {
-                                obj = new JSONObject();
-                            } else {
-                                obj = JSON.parseObject(cache);
-                            }
+                try {
+                    String cache;
+                    if ("remove".equals(operate)) {
+                        CacheHelper.remove(cacheKey);
+                        cache = null;
+                        return null;
+                    }
 
 
-                            JSONObject var11;
-                            if ("query".equals(operate)) {
-                                var11 = obj;
-                                return var11;
-                            }
+                    cache = CacheHelper.get(cacheKey);
+                    JSONObject obj = null;
+                    if (StringUtils.isEmpty(cache)) {
+                        obj = new JSONObject();
+                    } else {
+                        obj = JSON.parseObject(cache);
+                    }
 
 
-                            if (StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(operate)) {
-                                obj.put(url, operate);
-                                CacheHelper.put(cacheKey, obj.toJSONString(), cache_time_out);
-                            }
+                    if ("query".equals(operate)) {
+                        var11 = obj;
+                        return var11;
+                    }
 
 
-                            var11 = obj;
-                            return var11;
-                        } finally {
-                            logger.info("cacheFile总耗时:{}-{}", pageId, System.currentTimeMillis() - starttime);
-                            lock.unlock();
-                        }
+                    if (StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(operate)) {
+                        obj.put(url, operate);
+                        CacheHelper.put(cacheKey, obj.toJSONString(), cache_time_out);
                     }
                     }
+
+                    var11 = obj;
+                } finally {
+                    logger.info("cacheFile总耗时:{}-{}", pageId, System.currentTimeMillis() - starttime);
+                    lock.unlock();
                 }
                 }
             } catch (Throwable var30) {
             } catch (Throwable var30) {
                 var5 = var30;
                 var5 = var30;
@@ -479,7 +479,7 @@ public class RecognitionCheckTaskEx implements Callable<JSONObject> {
 
 
             }
             }
 
 
-            return null;
+            return var11;
         }
         }
     }
     }
 
 

+ 47 - 10
src/main/java/kd/imc/rim/common/invoice/collector/ScannerServiceEx.java → src/main/java/kd/imc/rim/ScannerServiceEx.java

@@ -3,11 +3,12 @@
 // (powered by FernFlower decompiler)
 // (powered by FernFlower decompiler)
 //
 //
 
 
-package kd.imc.rim.common.invoice.collector;
+package kd.imc.rim;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import java.util.Map;
 import java.util.Map;
 import kd.bos.context.RequestContext;
 import kd.bos.context.RequestContext;
+import kd.bos.dataentity.resource.ResManager;
 import kd.bos.ext.form.control.CustomControl;
 import kd.bos.ext.form.control.CustomControl;
 import kd.bos.form.ConfirmCallBackListener;
 import kd.bos.form.ConfirmCallBackListener;
 import kd.bos.form.ConfirmTypes;
 import kd.bos.form.ConfirmTypes;
@@ -17,7 +18,7 @@ import kd.bos.logging.Log;
 import kd.bos.logging.LogFactory;
 import kd.bos.logging.LogFactory;
 import kd.bos.threads.ThreadPool;
 import kd.bos.threads.ThreadPool;
 import kd.bos.threads.ThreadPools;
 import kd.bos.threads.ThreadPools;
-import kd.imc.rim.common.invoice.recognition.impl.RecognitionCheckTaskEx;
+import kd.imc.rim.common.invoice.collector.ScannerService;
 import kd.imc.rim.common.utils.BigDecimalUtil;
 import kd.imc.rim.common.utils.BigDecimalUtil;
 import kd.imc.rim.common.utils.FileUploadUtils;
 import kd.imc.rim.common.utils.FileUploadUtils;
 import kd.imc.rim.common.utils.ImcConfigUtil;
 import kd.imc.rim.common.utils.ImcConfigUtil;
@@ -27,7 +28,7 @@ import org.apache.commons.lang3.StringUtils;
 public class ScannerServiceEx {
 public class ScannerServiceEx {
     private static final int threadNum = 5;
     private static final int threadNum = 5;
     private static ThreadPool checkThreadPool = ThreadPools.newFixedThreadPool("scanner_check_pool_Ex", 5);
     private static ThreadPool checkThreadPool = ThreadPools.newFixedThreadPool("scanner_check_pool_Ex", 5);
-    private static final Log LOGGER = LogFactory.getLog(ScannerServiceEx.class);
+    private static final Log LOGGER = LogFactory.getLog(ScannerService.class);
     public static final String operate_invoice = "invoice";
     public static final String operate_invoice = "invoice";
     public static final String operate_attach = "attach";
     public static final String operate_attach = "attach";
 
 
@@ -79,21 +80,56 @@ public class ScannerServiceEx {
         map1.put("operate", "init");
         map1.put("operate", "init");
         map1.put("pageId", control.getView().getPageId());
         map1.put("pageId", control.getView().getPageId());
         map1.put("uploadUrl", request.getClientFullContextPath() + "attachment/upload.do");
         map1.put("uploadUrl", request.getClientFullContextPath() + "attachment/upload.do");
-        map1.put("fileLimitSize", "3");
         map1.put("title", title);
         map1.put("title", title);
-        map1.put("fileQuality", "0.98");
-        int maxfilesize = BigDecimalUtil.transDecimal(RimConfigUtils.getConfig("rim_fpzs", "maxfilesize")).intValue();
+        Map<String, String> rimFpzsConfig = ImcConfigUtil.getValue("rim_fpzs");
+        int maxfilesize = BigDecimalUtil.transDecimal(rimFpzsConfig.get("maxfilesize")).intValue();
         if (maxfilesize < 1) {
         if (maxfilesize < 1) {
             maxfilesize = 10;
             maxfilesize = 10;
         }
         }
 
 
-        map1.put("fileLimitPixel", "1500");
         map1.put("maxFileSize", maxfilesize);
         map1.put("maxFileSize", maxfilesize);
+        setImageCompress(map1, rimFpzsConfig);
         map1.put("fid", control.getView().getEntityId());
         map1.put("fid", control.getView().getEntityId());
+        map1.put("loadMsg", ResManager.loadKDString("上传中..", "ScannerService_0", "imc-rim-common", new Object[0]));
         map1.put("canImportExcels", canImportExcels);
         map1.put("canImportExcels", canImportExcels);
         control.setData(map1);
         control.setData(map1);
     }
     }
 
 
+    public static void setImageCompress(Map<String, Object> map1, Map<String, String> rimFpzsConfig) {
+        double fileLimitSize = 3.0;
+        double fileQuality = 0.98;
+        int fileLimitPixel = 1500;
+        if (rimFpzsConfig != null && StringUtils.isNotEmpty((CharSequence)rimFpzsConfig.get("imageCompress"))) {
+            String imageCompress = (String)rimFpzsConfig.get("imageCompress");
+            String[] str = imageCompress.split(",");
+            double limitSize;
+            if (str.length > 0) {
+                limitSize = BigDecimalUtil.transDecimal(str[0]).doubleValue();
+                if (limitSize > 0.0 && limitSize <= 8.0) {
+                    fileLimitSize = limitSize;
+                }
+            }
+
+            if (str.length > 1) {
+                limitSize = BigDecimalUtil.transDecimal(str[1]).doubleValue();
+                if (limitSize > 0.0) {
+                    fileQuality = limitSize;
+                }
+            }
+
+            if (str.length > 2) {
+                 limitSize = BigDecimalUtil.transDecimal(str[2]).intValue();
+                if (limitSize > 0) {
+                    fileLimitPixel = (int) limitSize;
+                }
+            }
+        }
+
+        map1.put("fileLimitSize", fileLimitSize);
+        map1.put("fileQuality", fileQuality);
+        map1.put("fileLimitPixel", fileLimitPixel);
+    }
+
     public static void upload(CustomControl control) {
     public static void upload(CustomControl control) {
         JSONObject map1 = new JSONObject();
         JSONObject map1 = new JSONObject();
         map1.put("operate", "upload");
         map1.put("operate", "upload");
@@ -165,22 +201,23 @@ public class ScannerServiceEx {
         param.put("scannerType", scannerType);
         param.put("scannerType", scannerType);
         param.put("resolution", resolution);
         param.put("resolution", resolution);
         param.put("fileLimitPixel", limitpixel);
         param.put("fileLimitPixel", limitpixel);
+        param.put("loadMsg", ResManager.loadKDString("扫描上传中..", "ScannerService_1", "imc-rim-common", new Object[0]));
     }
     }
 
 
     public static boolean scannerFail(AbstractFormPlugin plugin, String eventArgs) {
     public static boolean scannerFail(AbstractFormPlugin plugin, String eventArgs) {
         if (eventArgs != null) {
         if (eventArgs != null) {
             if (eventArgs.indexOf("JsScanner.msi") > 0) {
             if (eventArgs.indexOf("JsScanner.msi") > 0) {
-                plugin.getView().showConfirm("扫描仪需要安装JsScanner,是否安装?", MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("downJsScanner", plugin));
+                plugin.getView().showConfirm(ResManager.loadKDString("扫描仪需要安装JsScanner,是否安装?", "ScannerService_2", "imc-rim-common", new Object[0]), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("downJsScanner", plugin));
                 return false;
                 return false;
             }
             }
 
 
             if (eventArgs.indexOf("websocket connect error") > 0) {
             if (eventArgs.indexOf("websocket connect error") > 0) {
-                plugin.getView().showTipNotification("请确认已经连接并打开扫描仪!", 3000);
+                plugin.getView().showTipNotification(ResManager.loadKDString("请确认已经连接并打开扫描仪!", "ScannerService_3", "imc-rim-common", new Object[0]), 3000);
                 return false;
                 return false;
             }
             }
 
 
             if (eventArgs.indexOf("No data source found in this environment") > 0) {
             if (eventArgs.indexOf("No data source found in this environment") > 0) {
-                plugin.getView().showTipNotification("请检查是否正确安装扫描仪驱动!", 3000);
+                plugin.getView().showTipNotification(ResManager.loadKDString("请检查是否正确安装扫描仪驱动!", "ScannerService_4", "imc-rim-common", new Object[0]), 3000);
                 return false;
                 return false;
             }
             }
 
 

+ 0 - 453
src/main/java/kd/imc/rim/common/service/ElectAccVoucherServiceEx.java

@@ -1,453 +0,0 @@
-//
-// Source code recreated from a .class file by IntelliJ IDEA
-// (powered by FernFlower decompiler)
-//
-
-package kd.imc.rim.common.service;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.Future;
-import kd.bos.context.RequestContext;
-import kd.bos.dataentity.entity.DynamicObject;
-import kd.bos.dataentity.resource.ResManager;
-import kd.bos.dataentity.utils.ObjectUtils;
-import kd.bos.db.tx.TX;
-import kd.bos.db.tx.TXHandle;
-import kd.bos.dlock.DLock;
-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.bos.threads.ThreadPool;
-import kd.bos.threads.ThreadPools;
-import kd.bos.util.StringUtils;
-import kd.imc.rim.common.constant.InputInvoiceTypeEnum;
-import kd.imc.rim.common.constant.ResultContant;
-import kd.imc.rim.common.constant.XbrlTypeConstant;
-import kd.imc.rim.common.helper.ElectAccVoucherHelper;
-import kd.imc.rim.common.helper.RecognitionCheckHelper;
-import kd.imc.rim.common.invoice.collector.InvoiceCollectService;
-import kd.imc.rim.common.invoice.recognition.listener.IRecognitionListener;
-import kd.imc.rim.common.invoice.recognition.listener.RecognitionListenerResult;
-import kd.imc.rim.common.invoice.recognitionnew.task.FileUploadAndSignTask;
-import kd.imc.rim.common.invoice.save.InvoiceSaveService;
-import kd.imc.rim.common.message.exception.MsgException;
-import kd.imc.rim.common.utils.*;
-import kd.imc.rim.common.utils.extract.ZipExtractUtil;
-import kd.imc.rim.file.utils.FileConvertUtils;
-import kd.imc.rim.common.utils.FileUtilsEx;
-
-public class ElectAccVoucherServiceEx {
-    private static Log logger = LogFactory.getLog(ElectAccVoucherService.class);
-    private static final String awsRecognitionImpl = "kd.imc.rim.common.invoice.recognitionnew.impl.AwsRecognitionService";
-    private static ThreadPool xbrlUploadThreadPool = ThreadPools.newFixedThreadPool("xbrlUploadThreadPool", 10);
-    private ElectAccVoucherHelper electAccVoucherHelper = new ElectAccVoucherHelper();
-
-    public ElectAccVoucherServiceEx() {
-    }
-
-    public JSONObject dealVoucher(String fileUrl, String fileName, Object orgId, JSONObject businessParam, IRecognitionListener recognitionListener) throws IOException {
-        JSONObject result = new JSONObject();
-        boolean isVoucherOrg = checkOrg(orgId);
-        if (!isVoucherOrg) {
-            result.put("errcode", "0004");
-            result.put("description", ResManager.loadKDString("非电子会计凭证试点企业", "ElectAccVoucherService_0", "imc-rim-common", new Object[0]));
-            return result;
-        } else if (!StringUtils.isEmpty(fileUrl) && !StringUtils.isEmpty(fileName)) {
-            logger.info("电子会计凭证解析开始:{}", fileName);
-            return this.extracted(fileUrl, fileName, orgId, businessParam, recognitionListener);
-        } else {
-            return result;
-        }
-    }
-
-    private JSONObject extracted(String fileUrl, String fileName, Object orgId, JSONObject businessParam, IRecognitionListener recognitionListener) throws IOException {
-        JSONObject result = new JSONObject();
-        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.AwsRecognitionService".equals(recognitionImplStr);
-        RecognitionCheckHelper recognitionCheckHelper = new RecognitionCheckHelper();
-        FormFileEntity fileEntity = recognitionCheckHelper.getFormFileEntity(fileUrl, fileName);
-
-        try {
-            InputStream fileInputStream = FileServiceFactory.getAttachmentFileService().getInputStream(fileEntity.getFileUrl());
-            Throwable var13 = null;
-
-            try {
-                byte[] fileByte = FileUtilsEx.getByte(fileInputStream);
-                String fileType = FileUtilsEx.getFileType(fileName);
-                Future<JSONObject> xbrlUploadSubmit = null;
-                if (!"zip".equalsIgnoreCase(fileType)) {
-                    xbrlUploadSubmit = xbrlUploadThreadPool.submit(new FileUploadAndSignTask(fileEntity.getFileUrl(), fileByte, fileEntity.getFileName(), fileEntity.getFileType(), fileEntity.getFileHash(), fileEntity.getSignatureFlag(), RequestContext.get()));
-                }
-
-                JSONObject checkZipFileResult = this.checkZipFile(fileByte, fileType);
-                if (Objects.nonNull(checkZipFileResult)) {
-                    JSONObject var66 = checkZipFileResult;
-                    return var66;
-                } else {
-                    long startTime = System.currentTimeMillis();
-                    JSONObject var67;
-                    if (isAwsRecognition) {
-                        result = this.electAccVoucherHelper.getByAwsAPI(orgId, fileByte, fileName);
-                    } else {
-                        result = this.electAccVoucherHelper.getByAnalysis(fileType, fileByte);
-                        boolean signPassFlag = result.getBoolean("signPassFlag");
-                        if (!signPassFlag) {
-                            result.put("errcode", "0004");
-                            result.put("description", ResManager.loadKDString("电子会计凭证验签不通过", "ElectAccVoucherService_1", "imc-rim-common", new Object[0]));
-                            var67 = result;
-                            return var67;
-                        }
-                    }
-
-                    if (!"0000".equals(result.getString("errcode"))) {
-                        var67 = result;
-                        return var67;
-                    } else {
-                        String xbrlInfo = result.getString("xbrlInfo");
-                        JSONObject resultInvoice = this.electAccVoucherHelper.toInvoiceJson(xbrlInfo, orgId);
-                        if (resultInvoice == null) {
-                            result.put("errcode", "0005");
-                            result.put("description", ResManager.loadKDString("电子会计凭证转换失败", "ElectAccVoucherService_2", "imc-rim-common", new Object[0]));
-                            JSONObject var68 = result;
-                            return var68;
-                        } else {
-                            String voucherFileUrl = getVoucherFileUrl(fileType, fileByte, xbrlInfo);
-                            if (resultInvoice.containsKey("isUploadOriginal") && !resultInvoice.getBoolean("isUploadOriginal") && xbrlUploadSubmit != null) {
-                                uploadGet(xbrlUploadSubmit, resultInvoice);
-                            }
-
-                            if (resultInvoice.containsKey("isUploadOriginal") && resultInvoice.getBoolean("isUploadOriginal")) {
-                                resultInvoice.put("originalState", "1");
-                            } else if (!"zip".equalsIgnoreCase(fileType)) {
-                                resultInvoice.put("originalState", "1");
-                                resultInvoice.put("originalTime", new Date());
-                            } else {
-                                resultInvoice.put("originalState", "0");
-                            }
-
-                            String serialNo = resultInvoice.getString("serialNo");
-                            if (StringUtils.isEmpty(serialNo)) {
-                                serialNo = UUID.randomUUID();
-                                resultInvoice.put("serialNo", serialNo);
-                            }
-
-                            if ("zip".equalsIgnoreCase(fileType)) {
-                                resultInvoice.put("isZipFile", Boolean.TRUE);
-                            }
-
-                            resultInvoice.put("fileType", FileUtilsEx.convertFileTypeNum(fileType));
-                            resultInvoice.put("fileName", fileName);
-                            TXHandle h = TX.required();
-                            Throwable var26 = null;
-
-                            try {
-                                String errorMsg;
-                                try {
-                                    String xbrlType = resultInvoice.getString("xbrlType");
-                                    errorMsg = resultInvoice.getString("invoiceDate");
-                                    Long invoiceType = resultInvoice.getLong("invoiceType");
-                                    String xbrlName = this.getTargetName(serialNo, xbrlType, invoiceType, errorMsg);
-                                    if (xbrlName == null) {
-                                        xbrlName = fileName;
-                                    }
-
-                                    saveVoucher(serialNo, xbrlName, voucherFileUrl, xbrlType);
-                                    resultInvoice = this.saveInvoice(businessParam, resultInvoice, fileUrl, fileByte);
-                                } catch (Throwable var60) {
-                                    logger.info("保存电子会计凭证出错:{}", var60);
-                                    h.markRollback();
-                                    errorMsg = ResManager.loadKDString("电子会计凭证保存异常或者发票数据保存异常,请联系管理员", "ElectAccVoucherService_9", "imc-rim-common", new Object[0]);
-                                    if (var60 instanceof MsgException) {
-                                        errorMsg = ((MsgException)var60).getErrorMsg();
-                                    }
-
-                                    resultInvoice.put("errorMsg", errorMsg);
-                                    if (businessParam != null && "1".equals(businessParam.getString("throwSaveError"))) {
-                                        throw var60;
-                                    }
-                                }
-                            } catch (Throwable var61) {
-                                var26 = var61;
-                                throw var61;
-                            } finally {
-                                if (h != null) {
-                                    if (var26 != null) {
-                                        try {
-                                            h.close();
-                                        } catch (Throwable var59) {
-                                            var26.addSuppressed(var59);
-                                        }
-                                    } else {
-                                        h.close();
-                                    }
-                                }
-
-                            }
-
-                            if (resultInvoice.get("mainId") != null) {
-                                DynamicObject invoiceObject = BusinessDataServiceHelper.loadSingle(resultInvoice.get("mainId"), "rim_invoice");
-                                String invoiceType = resultInvoice.getString("invoiceType");
-                                InvoiceSaveService service = InvoiceSaveService.newInstance(invoiceType);
-                                if (service != null) {
-                                    service.setMainInvoiceInfo(invoiceObject);
-                                    SaveServiceHelper.save(new DynamicObject[]{invoiceObject});
-                                }
-                            }
-
-                            RecognitionCheckService.setInvoiceSeq(resultInvoice, businessParam, 0, 0);
-                            result.put("errcode", "0000");
-                            result.put("description", ResManager.loadKDString("操作成功", "ElectAccVoucherService_8", "imc-rim-common", new Object[0]));
-                            JSONArray resultArray = new JSONArray();
-                            resultInvoice.put("fileType", FileUtilsEx.convertFileTypeNum(FileUtils.getFileType(fileName)));
-                            resultArray.add(resultInvoice);
-                            result.put("data", resultArray);
-                            RecognitionListenerResult listener = new RecognitionListenerResult(fileUrl, fileName, 1, 1, resultArray);
-                            if (recognitionListener != null) {
-                                recognitionListener.handle(listener);
-                            }
-
-                            logger.info("电子会计凭证总耗时:{}", System.currentTimeMillis() - startTime);
-                            return result;
-                        }
-                    }
-                }
-            } catch (Throwable var63) {
-                var13 = var63;
-                throw var63;
-            } finally {
-                if (fileInputStream != null) {
-                    if (var13 != null) {
-                        try {
-                            fileInputStream.close();
-                        } catch (Throwable var58) {
-                            var13.addSuppressed(var58);
-                        }
-                    } else {
-                        fileInputStream.close();
-                    }
-                }
-
-            }
-        } catch (Throwable var65) {
-            logger.info("解析电子会计凭证出错:{}", var65);
-            result.put("errcode", "0002");
-            result.put("description", ResManager.loadKDString("解析电子会计凭证出错", "ElectAccVoucherService_4", "imc-rim-common", new Object[0]));
-            return result;
-        }
-    }
-
-    private String getTargetName(String serialNo, String xbrlType, Long invoiceType, String invoiceDate) {
-        String prefix = "";
-        if (StringUtils.isNotEmpty(invoiceDate)) {
-            invoiceDate = invoiceDate.replaceAll("-", "");
-        }
-
-        if (XbrlTypeConstant.AIR_ELE.getCode().equals(xbrlType)) {
-            prefix = "atr_issuer_";
-        } else if (XbrlTypeConstant.BANK_RECEIPT.getCode().equals(xbrlType)) {
-            prefix = "bker_issuer_";
-        } else if (XbrlTypeConstant.BANK_STATEMENT.getCode().equals(xbrlType)) {
-            prefix = "bkrs_issuer_";
-        } else if (XbrlTypeConstant.FINANCIAL.getCode().equals(xbrlType)) {
-            prefix = "efi_issuer_";
-        } else if (XbrlTypeConstant.TRAIN_ELE.getCode().equals(xbrlType)) {
-            prefix = "rai_issuer_";
-        } else if (XbrlTypeConstant.COVERINGWARRANT.getCode().equals(xbrlType)) {
-            prefix = "ntrev_gpm_issuer_";
-        } else if (XbrlTypeConstant.E_VAT.getCode().equals(xbrlType)) {
-            if (InputInvoiceTypeEnum.ORDINARY_ELECTRON.getCode().equals(invoiceType)) {
-                prefix = "inv_ord_issuer_";
-            } else {
-                prefix = "inv_spcl_issuer_";
-            }
-        }
-
-        return StringUtils.isEmpty(prefix) ? null : prefix + invoiceDate + '_' + serialNo + ".xml";
-    }
-
-    private JSONObject checkZipFile(byte[] fileByte, String fileType) {
-        if ("zip".equalsIgnoreCase(fileType)) {
-            int fileLimit = 2;
-            Map<String, String> zipFileMap = ZipExtractUtil.extractFileForXml(fileByte);
-            if (zipFileMap.isEmpty()) {
-                return ResultContant.createJSONObject("0002", ResManager.loadKDString("解析zip压缩包为空", "ElectAccVoucherService_5", "imc-rim-common", new Object[0]));
-            }
-
-            if (zipFileMap.size() != fileLimit) {
-                return ResultContant.createJSONObject("0003", String.format(ResManager.loadKDString("解析zip压缩包只包含%1$s个文件", "ElectAccVoucherService_6", "imc-rim-common", new Object[0]), zipFileMap.size()));
-            }
-
-            Iterator var5 = zipFileMap.entrySet().iterator();
-
-            while(var5.hasNext()) {
-                Map.Entry<String, String> map = (Map.Entry)var5.next();
-                String key = (String)map.getKey();
-                boolean checkFileType = FileUtils.checkFileType(key, new String[]{"xml", "sign"});
-                if (!checkFileType) {
-                    return ResultContant.createJSONObject("0003", ResManager.loadKDString("解析zip压缩包只能包含xml/sign文件", "ElectAccVoucherService_7", "imc-rim-common", new Object[0]));
-                }
-            }
-        }
-
-        return null;
-    }
-
-    private JSONObject saveInvoice(JSONObject businessParam, JSONObject resultInvoice, String fileUrl, byte[] fileByte) {
-        Long tax_org = null;
-        if (null != businessParam) {
-            resultInvoice.putAll(businessParam);
-            tax_org = businessParam.getLong("tax_org");
-        }
-
-        if (!ObjectUtils.isEmpty(tax_org)) {
-            resultInvoice.put("tax_org", tax_org);
-        }
-
-        InvoiceCollectService invoiceCollectService = new InvoiceCollectService();
-        String fileHash = FileConvertUtils.getSHA256(fileByte);
-        if (StringUtils.isEmpty(resultInvoice.getString("serialNo"))) {
-            resultInvoice.put("serialNo", UUID.randomUUID());
-        }
-
-        DLock lock = DLock.create(resultInvoice.getString("invoiceNo") + "saveVoucher", "saveVoucherLock");
-        Throwable var9 = null;
-
-        try {
-            if (lock.tryLock(10000L)) {
-                if (!resultInvoice.containsKey("checkStatus")) {
-                    resultInvoice.put("checkStatus", "1");
-                }
-
-                resultInvoice = invoiceCollectService.saveInvoice(resultInvoice, fileUrl, fileHash);
-                CacheHelper.put(resultInvoice.getString("invoiceNo") + "saveVoucher", resultInvoice.toJSONString(), 10000);
-            } else {
-                JSONObject cacheObject = JSON.parseObject(CacheHelper.get(resultInvoice.getString("invoiceNo") + "saveVoucher"));
-                if (cacheObject != null) {
-                    resultInvoice = cacheObject;
-                    CacheHelper.remove(cacheObject.getString("invoiceNo") + "saveVoucher");
-                }
-            }
-        } catch (Throwable var18) {
-            var9 = var18;
-            throw var18;
-        } finally {
-            if (lock != null) {
-                if (var9 != null) {
-                    try {
-                        lock.close();
-                    } catch (Throwable var17) {
-                        var9.addSuppressed(var17);
-                    }
-                } else {
-                    lock.close();
-                }
-            }
-
-        }
-
-        return resultInvoice;
-    }
-
-    public static boolean checkOrg(Object orgId) {
-        boolean isVoucherOrg = false;
-
-        try {
-            if (orgId != null) {
-                DynamicObject orgObject = BusinessDataServiceHelper.loadSingle(orgId, "bdm_org");
-                if (orgObject != null && "1".equals(orgObject.get("epinfo.isvoucher"))) {
-                    isVoucherOrg = true;
-                }
-            }
-        } catch (Throwable var3) {
-            logger.info("获取企业电子会计凭证开关出错:{}", var3);
-            isVoucherOrg = false;
-        }
-
-        return isVoucherOrg;
-    }
-
-    private static String getVoucherFileUrl(String fileType, byte[] fileByte, String xbrlInfo) throws IOException {
-        String fileUploadUrl;
-        if ("zip".equalsIgnoreCase(fileType)) {
-            fileUploadUrl = FileConvertUtils.upload(fileByte, fileType);
-        } else {
-            ByteArrayInputStream xbrlStream = new ByteArrayInputStream(xbrlInfo.getBytes(StandardCharsets.UTF_8));
-            Throwable var5 = null;
-
-            try {
-                fileUploadUrl = FileConvertUtils.upload(FileUtils.getByte(xbrlStream), "xml");
-            } catch (Throwable var14) {
-                var5 = var14;
-                throw var14;
-            } finally {
-                if (xbrlStream != null) {
-                    if (var5 != null) {
-                        try {
-                            xbrlStream.close();
-                        } catch (Throwable var13) {
-                            var5.addSuppressed(var13);
-                        }
-                    } else {
-                        xbrlStream.close();
-                    }
-                }
-
-            }
-        }
-
-        return fileUploadUrl;
-    }
-
-    private static void uploadGet(Future<JSONObject> xbrlUploadSubmit, JSONObject resultInvoice) {
-        try {
-            JSONObject result = (JSONObject)xbrlUploadSubmit.get();
-            if (result != null) {
-                resultInvoice.put("imageUrl", result.getString("imageUrl"));
-                resultInvoice.put("ofdUrl", result.getString("ofdUrl"));
-                resultInvoice.put("pdfUrl", result.getString("pdfUrl"));
-                resultInvoice.put("snapshotUrl", result.getString("imageUrl"));
-            }
-        } catch (Exception var3) {
-            logger.info("电子会计凭证文件上传出错:{}", var3);
-        }
-
-    }
-
-    public static void saveVoucher(String serialNo, String xbrlName, String fileUploadUrl, String xbrlType) {
-        DynamicObject voucherObject = QueryServiceHelper.queryOne("rim_invoice_voucher", "id, serial_no, xbrl_name, xbrl_url, xbrl_type, receive_xbrl_url, receive_xbrl_name, create_time, update_time", new QFilter[]{new QFilter("serial_no", "=", serialNo)});
-        if (voucherObject == null) {
-            voucherObject = BusinessDataServiceHelper.newDynamicObject("rim_invoice_voucher");
-            voucherObject.set("serial_no", serialNo);
-            voucherObject.set("xbrl_name", xbrlName);
-            voucherObject.set("xbrl_url", fileUploadUrl);
-            voucherObject.set("xbrl_type", xbrlType);
-            voucherObject.set("receive_xbrl_url", "");
-            voucherObject.set("receive_xbrl_name", "");
-            voucherObject.set("create_time", new Date());
-            voucherObject.set("update_time", new Date());
-        } else {
-            voucherObject = BusinessDataServiceHelper.loadSingle(voucherObject.get("id"), "rim_invoice_voucher");
-            voucherObject.set("xbrl_name", xbrlName);
-            voucherObject.set("xbrl_url", fileUploadUrl);
-            voucherObject.set("xbrl_type", xbrlType);
-            voucherObject.set("update_time", new Date());
-        }
-
-        SaveServiceHelper.save(new DynamicObject[]{voucherObject});
-    }
-}

+ 0 - 867
src/main/java/kd/imc/rim/common/utils/FileUtilsEx.java

@@ -1,867 +0,0 @@
-//
-// Source code recreated from a .class file by IntelliJ IDEA
-// (powered by FernFlower decompiler)
-//
-
-package kd.imc.rim.common.utils;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.MessageDigest;
-import java.sql.ResultSet;
-import java.util.Date;
-import kd.bos.cache.CacheFactory;
-import kd.bos.dataentity.entity.DynamicObject;
-import kd.bos.db.DB;
-import kd.bos.db.DBRoute;
-import kd.bos.db.ResultSetHandler;
-import kd.bos.fileservice.FileService;
-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 org.apache.commons.codec.binary.Base64;
-import org.apache.commons.codec.binary.Hex;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-
-public class FileUtilsEx {
-    private static Log logger = LogFactory.getLog(HttpUtil.class);
-    public static final String FILE_TYPE_PDF = "pdf";
-    public static final String FILE_TYPE_OFD = "ofd";
-    public static final String FILE_TYPE_JPG = "jpg";
-    public static final String FILE_TYPE_XML = "xml";
-    private static final String USER_DIR = "user.dir";
-    private static final String FILE_TEMP = "fileTemp";
-    public static final String BASE_UPLOAD_ABS_PATH;
-
-    public FileUtilsEx() {
-    }
-
-    public static boolean isImage(String fileType) {
-        return "png".equalsIgnoreCase(fileType) || "bmp".equalsIgnoreCase(fileType) || "jpg".equalsIgnoreCase(fileType) || "jpeg".equalsIgnoreCase(fileType) || "webp".equalsIgnoreCase(fileType);
-    }
-
-    public static String getSHA256(InputStream file) {
-        Object var2;
-        try {
-            MessageDigest MD5 = MessageDigest.getInstance("SHA-256");
-            byte[] buffer = new byte[8192];
-
-            int length;
-            while((length = file.read(buffer)) != -1) {
-                MD5.update(buffer, 0, length);
-            }
-
-            String var4 = new String(Hex.encodeHex(MD5.digest()));
-            return var4;
-        } catch (Exception var14) {
-            var2 = null;
-        } finally {
-            try {
-                if (file != null) {
-                    file.close();
-                }
-            } catch (IOException var13) {
-            }
-
-        }
-
-        return (String)var2;
-    }
-
-    public static String downLoadAndUpload(String fileUrl) {
-        return downLoadAndUpload(fileUrl, (String)null);
-    }
-
-    public static InputStream getInputStreamByGet(String url) throws ClientProtocolException, IOException {
-        return getInputStreamByGet(url, 60000, 60000);
-    }
-
-    private static InputStream getInputStreamByGet(String url, int connectionTimeout, int readTimeout) throws ClientProtocolException, IOException {
-        String proxy = HttpUtil.getProxy(url, (String)null);
-        CloseableHttpClient httpclient = HttpUtil.getConnection(proxy, false, connectionTimeout, readTimeout);
-        HttpGet httpGet = HttpUtil.getHttpGet(HttpUtil.replaceUrl(url));
-        CloseableHttpResponse response = httpclient.execute(httpGet);
-        return response.getEntity().getContent();
-    }
-
-    public static String downLoadAndUploadTemp(String fileUrl, String fileName) {
-        String tempSavePath = "";
-        if (!StringUtils.isEmpty(fileUrl) && fileUrl.indexOf("http") == 0) {
-            AwsFpyService service = AwsFpyService.newInstance();
-            HttpClient client = HttpUtil.getConnection(service.getProxy(), false);
-            HttpGet get = HttpUtil.getHttpGet(HttpUtil.replaceUrl(fileUrl));
-            CloseableHttpResponse response = null;
-
-            try {
-                long start = System.currentTimeMillis();
-                response = (CloseableHttpResponse)client.execute(get);
-                int statusCode = response.getStatusLine().getStatusCode();
-                if (200 == statusCode) {
-                    String fileType = "";
-                    fileType = getSuffixFromDisposition(response);
-                    if (StringUtils.isEmpty(fileType)) {
-                        fileType = getSuffixFromContentType(response);
-                    }
-
-                    HttpEntity entity = response.getEntity();
-                    if (StringUtils.isEmpty(fileName)) {
-                        fileName = UUID.randomUUIDZero() + '.' + fileType;
-                    } else if (fileName.indexOf(46) < 0) {
-                        fileName = fileName + '.' + fileType;
-                    }
-
-                    tempSavePath = CacheFactory.getCommonCacheFactory().getTempFileCache().saveAsUrl(fileName, entity.getContent(), 5000);
-                } else {
-                    if (302 == statusCode) {
-                        Header header = response.getFirstHeader("location");
-                        String newUrl = header.getValue();
-                        logger.info("重定向:" + newUrl);
-                        String var12 = downLoadAndUpload(newUrl, fileName);
-                        return var12;
-                    }
-
-                    logger.error(String.format("下载文件失败[%s]%s", statusCode, fileUrl));
-                }
-
-                logger.info(String.format("下载文件耗时[%s]%s", System.currentTimeMillis() - start, fileUrl));
-            } catch (IOException var28) {
-                logger.error("下载文件失败" + fileUrl, var28);
-            } finally {
-                if (response != null) {
-                    try {
-                        response.close();
-                    } catch (IOException var27) {
-                    }
-                }
-
-                try {
-                    get.abort();
-                    get.releaseConnection();
-                } catch (Exception var26) {
-                }
-
-            }
-
-            return tempSavePath;
-        } else {
-            return fileUrl;
-        }
-    }
-
-    public static String downLoadAndUpload(String fileUrl, String fileName) {
-        return (String)downLoadAndUpload(fileUrl, fileName, true, false);
-    }
-
-    public static JSONObject downLoadAndUploadWithFileType(String fileUrl, String fileName) {
-        return (JSONObject)downLoadAndUpload(fileUrl, fileName, true, true);
-    }
-
-    public static String downLoadAndUpload(String fileUrl, String fileName, boolean proxy) {
-        return (String)downLoadAndUpload(fileUrl, fileName, proxy, false);
-    }
-
-    public static Object downLoadAndUpload(String fileUrl, String fileName, boolean proxy, boolean needFileType) {
-        String tempSavePath = "";
-        String urlFileType = "";
-        if (!StringUtils.isEmpty(fileUrl) && fileUrl.indexOf("http") == 0) {
-            String fileId = MD5.md5Hex(fileUrl);
-            JSONObject pathAndType;
-            if (needFileType) {
-                pathAndType = queryFilePathAndType(fileId);
-                if (pathAndType != null) {
-                    return pathAndType;
-                }
-            } else {
-                String path = queryFilePath(fileId);
-                if (!StringUtils.isEmpty(path)) {
-                    return path;
-                }
-            }
-
-            pathAndType = null;
-            AwsFpyService service = AwsFpyService.newInstance();
-            CloseableHttpClient client;
-            if (proxy) {
-                client = HttpUtil.getConnection(service.getProxy(), false);
-            } else {
-                client = HttpUtil.getConnection((String)null, false);
-            }
-
-            HttpGet get = HttpUtil.getHttpGet(HttpUtil.replaceUrl(fileUrl));
-            CloseableHttpResponse response1 = null;
-            CloseableHttpResponse response302 = null;
-
-            try {
-                urlFileType = getFileType(fileUrl);
-                if (!StringUtils.isEmpty(urlFileType) && !"do".equals(urlFileType)) {
-                    fileName = UUID.randomUUIDZero() + '.' + urlFileType;
-                }
-
-                long start = System.currentTimeMillis();
-                response1 = (CloseableHttpResponse)client.execute(get);
-                int statusCode1 = response1.getStatusLine().getStatusCode();
-                if (200 == statusCode1) {
-                    Pair<String, String> pair = dealResponse(response1, fileName, fileUrl);
-                    tempSavePath = (String)pair.getLeft();
-                    if (StringUtils.isNotEmpty((String)pair.getRight())) {
-                        urlFileType = (String)pair.getRight();
-                    }
-                } else if (302 == statusCode1) {
-                    Header header = response1.getFirstHeader("location");
-                    String newUrl = header.getValue();
-                    logger.info("重定向:" + newUrl);
-                    if (StringUtils.isEmpty(fileName)) {
-                        urlFileType = getFileType(newUrl);
-                        if (!StringUtils.isEmpty(urlFileType)) {
-                            fileName = UUID.randomUUIDZero() + '.' + urlFileType;
-                        }
-                    }
-
-                    HttpGet newget = HttpUtil.getHttpGet(HttpUtil.replaceUrl(newUrl));
-                    response302 = (CloseableHttpResponse)client.execute(newget);
-                    int statusCode2 = response302.getStatusLine().getStatusCode();
-                    if (200 == statusCode2) {
-                        Pair<String, String> pair = dealResponse(response302, fileName, newUrl);
-                        tempSavePath = (String)pair.getLeft();
-                        if (StringUtils.isNotEmpty((String)pair.getRight())) {
-                            urlFileType = (String)pair.getRight();
-                        }
-                    } else {
-                        logger.error("下载文件失败302[{}]{}:{}", new Object[]{statusCode2, newUrl, JSON.toJSONString(response302)});
-                    }
-                } else {
-                    logger.error("下载文件失败[{}]{}:{}", new Object[]{statusCode1, fileUrl, JSON.toJSONString(response1)});
-                }
-
-                logger.info("下载文件耗时[{}]{}", System.currentTimeMillis() - start, fileUrl);
-            } catch (IOException var36) {
-                logger.error("下载文件失败" + fileUrl, var36);
-            } finally {
-                if (response1 != null) {
-                    try {
-                        response1.close();
-                    } catch (IOException var35) {
-                    }
-                }
-
-                if (response302 != null) {
-                    try {
-                        response302.close();
-                    } catch (IOException var34) {
-                    }
-                }
-
-                try {
-                    get.abort();
-                    get.releaseConnection();
-                } catch (Exception var33) {
-                }
-
-            }
-
-            if (!StringUtils.isEmpty(tempSavePath)) {
-                saveFilePath(fileUrl, tempSavePath, fileId, urlFileType);
-            }
-
-            if (needFileType) {
-                JSONObject result = new JSONObject();
-                result.put("file_url", tempSavePath);
-                result.put("file_type", urlFileType);
-                return result;
-            } else {
-                return tempSavePath;
-            }
-        } else if (needFileType) {
-            JSONObject result = new JSONObject();
-            result.put("file_url", fileUrl);
-            return result;
-        } else {
-            return fileUrl;
-        }
-    }
-
-    public static Pair<String, byte[]> downLoadFileToByte(String fileUrl, String fileName) {
-        return downLoadFileToByte(fileUrl, fileName, true);
-    }
-
-    public static Pair<String, byte[]> downLoadFileToByte(String fileUrl, String fileName, boolean proxy) {
-        logger.info("downLoadFileToByte,fileUrl:{}, fileName:{}", fileUrl, fileName);
-        if (!StringUtils.isEmpty(fileUrl) && fileUrl.indexOf("http") == 0) {
-            byte[] fileByte = null;
-            String urlFileType = "";
-            HttpClient client = null;
-            AwsFpyService service = AwsFpyService.newInstance();
-            if (proxy) {
-                client = HttpUtil.getConnection(service.getProxy(), false);
-            } else {
-                client = HttpUtil.getConnection((String)null, false);
-            }
-
-            HttpGet get = HttpUtil.getHttpGet(HttpUtil.replaceUrl(fileUrl));
-            CloseableHttpResponse response1 = null;
-            CloseableHttpResponse response302 = null;
-
-            try {
-                urlFileType = getFileType(fileUrl);
-                if (!StringUtils.isEmpty(urlFileType) && !"do".equals(urlFileType)) {
-                    fileName = UUID.randomUUIDZero() + '.' + urlFileType;
-                }
-
-                long start = System.currentTimeMillis();
-                response1 = (CloseableHttpResponse)client.execute(get);
-                int statusCode1 = response1.getStatusLine().getStatusCode();
-                if (200 == statusCode1) {
-                    HttpEntity entity1 = response1.getEntity();
-                    fileByte = getByte(entity1.getContent());
-                    if (StringUtils.isEmpty(urlFileType)) {
-                        urlFileType = getSuffixFromDisposition(response1);
-                    }
-                } else if (302 == statusCode1) {
-                    Header header = response1.getFirstHeader("location");
-                    String newUrl = header.getValue();
-                    logger.info("重定向:" + newUrl);
-                    if (StringUtils.isEmpty(fileName)) {
-                        urlFileType = getFileType(newUrl);
-                    }
-
-                    HttpGet newget = HttpUtil.getHttpGet(HttpUtil.replaceUrl(newUrl));
-                    response302 = (CloseableHttpResponse)client.execute(newget);
-                    int statusCode2 = response302.getStatusLine().getStatusCode();
-                    if (200 == statusCode2) {
-                        HttpEntity entity2 = response302.getEntity();
-                        fileByte = getByte(entity2.getContent());
-                        if (StringUtils.isEmpty(urlFileType)) {
-                            urlFileType = getSuffixFromDisposition(response302);
-                        }
-                    } else {
-                        logger.error("下载文件失败302[{}]{}:{}", new Object[]{statusCode2, newUrl, JSON.toJSONString(response302)});
-                    }
-                } else {
-                    logger.error("下载文件失败[{}]{}:{}", new Object[]{statusCode1, fileUrl, JSON.toJSONString(response1)});
-                }
-
-                logger.info("下载文件耗时[{}]{}", System.currentTimeMillis() - start, fileUrl);
-            } catch (IOException var34) {
-                logger.error("下载文件失败" + fileUrl, var34);
-            } finally {
-                if (response1 != null) {
-                    try {
-                        response1.close();
-                    } catch (IOException var33) {
-                    }
-                }
-
-                if (response302 != null) {
-                    try {
-                        response302.close();
-                    } catch (IOException var32) {
-                    }
-                }
-
-                try {
-                    get.abort();
-                    get.releaseConnection();
-                } catch (Exception var31) {
-                }
-
-            }
-
-            return Pair.of(urlFileType, fileByte);
-        } else {
-            return null;
-        }
-    }
-
-    private static Pair<String, String> dealResponse(CloseableHttpResponse response, String fileName, String fileUrl) throws UnsupportedOperationException, IOException {
-        String fileType = getSuffixFromDisposition(response);
-        if (StringUtils.isEmpty(fileType)) {
-            fileType = getSuffixFromContentType(response);
-            if ("ofd".equals(fileType)) {
-                String fileTypeFromName = getFileType(fileName);
-                if (!StringUtils.isEmpty(fileType)) {
-                    fileType = fileTypeFromName;
-                }
-            }
-        }
-
-        HttpEntity entity = response.getEntity();
-        if (StringUtils.isEmpty(fileName)) {
-            fileName = UUID.randomUUIDZero() + '.' + fileType;
-        } else if (fileName.indexOf(46) < 0) {
-            fileName = fileName + '.' + fileType;
-        }
-
-        if (StringUtils.isEmpty(fileType) && fileName.indexOf(46) < 0) {
-            logger.error("文件类型错误取消上传:" + fileUrl);
-            return Pair.of(((Object)null).toString(), fileType);
-        } else {
-            byte[] fileByte = getByte(entity.getContent());
-            ByteArrayInputStream bs = new ByteArrayInputStream(fileByte);
-            Throwable var7 = null;
-
-            Pair var9;
-            try {
-                String url = FileUploadUtils.upload(FileUploadUtils.getInvoiceDir("invoice") + fileName, fileName, bs);
-                var9 = Pair.of(url, fileType);
-            } catch (Throwable var18) {
-                var7 = var18;
-                throw var18;
-            } finally {
-                if (bs != null) {
-                    if (var7 != null) {
-                        try {
-                            bs.close();
-                        } catch (Throwable var17) {
-                            var7.addSuppressed(var17);
-                        }
-                    } else {
-                        bs.close();
-                    }
-                }
-
-            }
-
-            return var9;
-        }
-    }
-
-    public static void saveFilePath(String fileUrl, String attachPath, String fileId, String urlFileType) {
-        try {
-            DynamicObject downResult = BusinessDataServiceHelper.newDynamicObject("rim_download_file");
-            downResult.set("fileid", fileId);
-            downResult.set("http_url", fileUrl);
-            downResult.set("file_url", attachPath);
-            downResult.set("create_time", new Date());
-            downResult.set("file_type", convertFileType(urlFileType));
-            SaveServiceHelper.save(new DynamicObject[]{downResult});
-        } catch (Exception var5) {
-        }
-
-    }
-
-    public static String convertFileType(String fileType) {
-        logger.info("下载文件类型{}", fileType);
-        if (!"1".equals(fileType) && !"pdf".equals(fileType)) {
-            if (!"4".equals(fileType) && !"ofd".equals(fileType)) {
-                return !"9".equals(fileType) && !"xml".equals(fileType) ? "jpg" : "xml";
-            } else {
-                return "ofd";
-            }
-        } else {
-            return "pdf";
-        }
-    }
-
-    public static String convertFileTypeNum(String fileType) {
-        if (!"1".equals(fileType) && !"pdf".equals(fileType)) {
-            if (!"4".equals(fileType) && !"ofd".equals(fileType)) {
-                return !"9".equals(fileType) && !"xml".equals(fileType) ? "2" : "9";
-            } else {
-                return "4";
-            }
-        } else {
-            return "1";
-        }
-    }
-
-    public static String queryFilePath(String fileId) {
-        if (!StringUtils.isEmpty(fileId)) {
-            QFilter filter = new QFilter("fileid", "=", fileId);
-            DynamicObject obj = QueryServiceHelper.queryOne("rim_download_file", "id,file_url", new QFilter[]{filter});
-            if (obj != null && !StringUtils.isEmpty(obj.getString("file_url"))) {
-                return obj.getString("file_url");
-            }
-        }
-
-        return null;
-    }
-
-    public static JSONObject queryFilePathAndType(String fileId) {
-        if (!StringUtils.isEmpty(fileId)) {
-            JSONObject result = new JSONObject();
-            QFilter filter = new QFilter("fileid", "=", fileId);
-            DynamicObject obj = QueryServiceHelper.queryOne("rim_download_file", "id,file_url,file_type", new QFilter[]{filter});
-            if (obj != null && !StringUtils.isEmpty(obj.getString("file_url"))) {
-                result.put("file_url", obj.getString("file_url"));
-                result.put("file_type", obj.getString("file_type"));
-                return result;
-            }
-        }
-
-        return null;
-    }
-
-    private static String getSuffixFromDisposition(CloseableHttpResponse response) {
-        Header[] headers = response.getHeaders("Content-Disposition");
-        if (headers == null) {
-            headers = response.getHeaders("content-disposition");
-        }
-
-        if (headers != null) {
-            Header[] var2 = headers;
-            int var3 = headers.length;
-
-            for(int var4 = 0; var4 < var3; ++var4) {
-                Header header = var2[var4];
-                String value = header.getValue().replace("\"", "");
-                logger.info("getSuffixFromDisposition headervalue:{}", value);
-                int nameIndex = value.indexOf("filename");
-                if (nameIndex > 0 && value.length() > 10) {
-                    String fileName = value.substring(nameIndex + 10, value.length());
-                    fileName = fileName.replace(";", "");
-                    if (fileName.lastIndexOf(46) > 0) {
-                        return fileName.substring(fileName.lastIndexOf(46) + 1);
-                    }
-                }
-            }
-        }
-
-        return null;
-    }
-
-    private static String getSuffixFromContentType(CloseableHttpResponse response) {
-        Header[] headers = response.getHeaders("Content-Type");
-        if (headers != null) {
-            Header[] var2 = headers;
-            int var3 = headers.length;
-
-            for(int var4 = 0; var4 < var3; ++var4) {
-                Header header = var2[var4];
-                if (header.getValue().indexOf("pdf") > 0) {
-                    return "pdf";
-                }
-
-                if (header.getValue().indexOf("octet") > 0) {
-                    return "ofd";
-                }
-
-                if (header.getValue().indexOf("image/png") >= 0) {
-                    return "png";
-                }
-
-                if (header.getValue().indexOf("image/gif") >= 0) {
-                    return "gif";
-                }
-
-                if (header.getValue().indexOf("image") >= 0) {
-                    return "jpg";
-                }
-            }
-        }
-
-        return null;
-    }
-
-    public static ByteArrayOutputStream cloneInputStream(InputStream input) {
-        try {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            byte[] buffer = new byte[1024];
-
-            int len;
-            while((len = input.read(buffer)) > -1) {
-                baos.write(buffer, 0, len);
-            }
-
-            baos.flush();
-            return baos;
-        } catch (IOException var4) {
-            logger.error("获取开票人异常:" + var4.getMessage(), var4);
-            return null;
-        }
-    }
-
-    public static boolean isExcel(String fileName) {
-        return checkFileType(fileName, "xls", "xlsx");
-    }
-
-    public static boolean checkFileType(String fileName, String... types) {
-        if (fileName != null && types != null && types.length >= 1) {
-            String fileType = getFileType(fileName);
-            if ("".equals(fileType)) {
-                return false;
-            } else {
-                String[] var3 = types;
-                int var4 = types.length;
-
-                for(int var5 = 0; var5 < var4; ++var5) {
-                    String str = var3[var5];
-                    if (fileType.equalsIgnoreCase(str)) {
-                        return true;
-                    }
-                }
-
-                return false;
-            }
-        } else {
-            return false;
-        }
-    }
-
-    public static String getFileType(String fileName) {
-        try {
-            URL url = new URL(fileName);
-            return FilenameUtils.getExtension(url.getPath());
-        } catch (MalformedURLException var2) {
-            return FilenameUtils.getExtension(fileName);
-        }
-    }
-
-    public static String getRealPath(String fileId) {
-        if (StringUtils.isEmpty(fileId)) {
-            return "";
-        } else {
-            String path = "";
-
-            try {
-                String sql = "select fpath from t_bas_filepathmapping where FFILEID = ? ";
-                path = (String)DB.query(DBRoute.base, sql, new String[]{fileId}, new ResultSetHandler<String>() {
-                    public String handle(ResultSet rs) throws Exception {
-                        String path;
-                        for(path = ""; rs.next(); path = rs.getString("fpath")) {
-                        }
-
-                        return path;
-                    }
-                });
-            } catch (Exception var3) {
-                logger.info("查询真实地址失败:" + var3);
-            }
-
-            return path;
-        }
-    }
-
-    public static Pair<String, byte[]> getFileContent(String fileUrl) {
-        return getFileContent(fileUrl, Boolean.TRUE);
-    }
-
-    public static Pair<String, byte[]> getFileContent(String fileUrl, Boolean proxy) {
-        if (StringUtils.isEmpty(fileUrl)) {
-            return null;
-        } else if (fileUrl.indexOf("http") != 0) {
-            FileService service = FileServiceFactory.getAttachmentFileService();
-            if (service.exists(fileUrl)) {
-                String fileType = getFileType(fileUrl);
-                if (StringUtils.isEmpty(fileType)) {
-                    String path = getRealPath(fileUrl);
-                    fileType = getFileType(path);
-                }
-
-                return Pair.of(fileType, getByte(service.getInputStream(fileUrl)));
-            } else {
-                logger.info("文件不存在:" + fileUrl);
-                return null;
-            }
-        } else {
-            AwsFpyService service = AwsFpyService.newInstance();
-            HttpClient client = HttpUtil.getConnection(proxy ? service.getProxy() : null, false);
-            HttpGet get = HttpUtil.getHttpGet(HttpUtil.replaceUrl(fileUrl));
-            CloseableHttpResponse response = null;
-            CloseableHttpResponse response302 = null;
-
-            Pair var10;
-            try {
-                long start = System.currentTimeMillis();
-                response = (CloseableHttpResponse)client.execute(get);
-                int statusCode = response.getStatusLine().getStatusCode();
-                if (200 != statusCode) {
-                    if (302 == statusCode) {
-                        Header header = response.getFirstHeader("location");
-                        String newUrl = header.getValue();
-                        logger.info("重定向:" + newUrl);
-                        HttpGet get302 = HttpUtil.getHttpGet(HttpUtil.replaceUrl(newUrl));
-                        response302 = (CloseableHttpResponse)client.execute(get302);
-                        int statusCode302 = response302.getStatusLine().getStatusCode();
-                        if (200 == statusCode302) {
-                            Pair var14 = getContentFromResonse(fileUrl, response302);
-                            return var14;
-                        }
-
-                        logger.error(String.format("下载文件失败302[%s]%s:%s", statusCode, newUrl, JSON.toJSONString(response302)));
-                    }
-
-                    logger.info("下载文件耗时[{}]{},{}", new Object[]{System.currentTimeMillis() - start, statusCode, fileUrl});
-                    return null;
-                }
-
-                var10 = getContentFromResonse(fileUrl, response);
-            } catch (IOException var38) {
-                logger.error("下载文件失败" + fileUrl, var38);
-                return null;
-            } finally {
-                if (response != null) {
-                    try {
-                        response.close();
-                    } catch (IOException var37) {
-                    }
-                }
-
-                if (response302 != null) {
-                    try {
-                        response302.close();
-                    } catch (IOException var36) {
-                    }
-                }
-
-                try {
-                    get.abort();
-                    get.releaseConnection();
-                } catch (Exception var35) {
-                }
-
-            }
-
-            return var10;
-        }
-    }
-
-    private static Pair<String, byte[]> getContentFromResonse(String fileUrl, CloseableHttpResponse response) throws IOException {
-        String fileType = getSuffixFromDisposition(response);
-        if (StringUtils.isEmpty(fileType)) {
-            fileType = getSuffixFromContentType(response);
-            if ("ofd".equals(fileType)) {
-                fileType = getFileType(fileUrl);
-                if (StringUtils.isEmpty(fileType)) {
-                    fileType = "ofd";
-                }
-            }
-        }
-
-        HttpEntity entity = response.getEntity();
-        return Pair.of(fileType, getByte(entity.getContent()));
-    }
-
-    public static byte[] getAttachmentByte(String savePath) {
-        FileService service = FileServiceFactory.getAttachmentFileService();
-
-        try {
-            InputStream bos = service.getInputStream(savePath);
-            Throwable var3 = null;
-
-            byte[] var4;
-            try {
-                var4 = getByte(bos);
-            } catch (Throwable var14) {
-                var3 = var14;
-                throw var14;
-            } finally {
-                if (bos != null) {
-                    if (var3 != null) {
-                        try {
-                            bos.close();
-                        } catch (Throwable var13) {
-                            var3.addSuppressed(var13);
-                        }
-                    } else {
-                        bos.close();
-                    }
-                }
-
-            }
-
-            return var4;
-        } catch (IOException var16) {
-            return null;
-        }
-    }
-
-    public static byte[] getByte(InputStream inputStream) {
-        try {
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
-            Throwable var2 = null;
-
-            try {
-                byte[] buffer = new byte[1024];
-//                Boolean len = false;
-                int len;
-                while((len = inputStream.read(buffer)) != -1) {
-                    bos.write(buffer, 0, len);
-                }
-
-                byte[] var5 = bos.toByteArray();
-                return var5;
-            } catch (Throwable var15) {
-                var2 = var15;
-                throw var15;
-            } finally {
-                if (bos != null) {
-                    if (var2 != null) {
-                        try {
-                            bos.close();
-                        } catch (Throwable var14) {
-                            var2.addSuppressed(var14);
-                        }
-                    } else {
-                        bos.close();
-                    }
-                }
-
-            }
-        } catch (IOException var17) {
-            return null;
-        }
-    }
-
-    public static String encodeBase64File(InputStream inputFile) throws Exception {
-        if (inputFile == null) {
-            return null;
-        } else {
-            ByteArrayOutputStream output = new ByteArrayOutputStream();
-            byte[] buffer = new byte[4096];
-//            int n = false;
-
-            int n;
-            while(-1 != (n = inputFile.read(buffer))) {
-                output.write(buffer, 0, n);
-            }
-
-            String retStr = Base64.encodeBase64String(output.toByteArray());
-            return retStr;
-        }
-    }
-
-    public static String truncateFileName(String fileName, int maxLength) {
-        if (StringUtils.isEmpty(fileName)) {
-            return fileName;
-        } else if (fileName.length() <= maxLength) {
-            return fileName;
-        } else {
-            int dotIndex = fileName.lastIndexOf(46);
-            String extension = "";
-            String nameWithoutExtension;
-            if (dotIndex != -1) {
-                nameWithoutExtension = fileName.substring(0, dotIndex);
-                extension = fileName.substring(dotIndex);
-            } else {
-                nameWithoutExtension = fileName;
-            }
-
-            int availableLength = maxLength - extension.length();
-            return availableLength <= 0 ? "" : nameWithoutExtension.substring(0, Math.min(availableLength, nameWithoutExtension.length())) + extension;
-        }
-    }
-
-    static {
-        BASE_UPLOAD_ABS_PATH = System.getProperty("user.dir") + File.separator + "fileTemp" + File.separator;
-    }
-}

+ 101 - 53
src/main/java/kd/imc/rim/utils/ApiHttpUtils.java

@@ -8,12 +8,17 @@ import kd.bos.script.annotations.KSObject;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.apache.http.util.EntityUtils;
 
 
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
+import java.util.Base64;
 import java.util.Date;
 import java.util.Date;
 
 
 @KSObject
 @KSObject
@@ -45,12 +50,16 @@ public class ApiHttpUtils {
         httpPost.setHeader("reserve", "");
         httpPost.setHeader("reserve", "");
         httpPost.setHeader("dealcode", "");
         httpPost.setHeader("dealcode", "");
         httpPost.setHeader("dealmsg", "");
         httpPost.setHeader("dealmsg", "");
-        StringEntity entity = new StringEntity(Params,"UTF-8");
+        httpPost.setHeader("App_key", "XYK_DPJ_KEY");
+        httpPost.setHeader("App_secret", "XYK_DPJ_SECRET");
+        JSONObject object = new JSONObject();
+        object.put("file_base64",Params);
+        StringEntity entity = new StringEntity(object.toString(), ContentType.APPLICATION_JSON);
         // post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
         // post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
         // 设置编码格式
         // 设置编码格式
-        entity.setContentEncoding("UTF-8");
+//        entity.setContentEncoding("UTF-8");
         // 发送Json格式的数据请求
         // 发送Json格式的数据请求
-        entity.setContentType("application/json");
+//        entity.setContentType("application/json");
         httpPost.setEntity(entity);
         httpPost.setEntity(entity);
         // 响应模型(发送post请求)
         // 响应模型(发送post请求)
         CloseableHttpResponse response = httpClient.execute(httpPost);
         CloseableHttpResponse response = httpClient.execute(httpPost);
@@ -70,66 +79,105 @@ public class ApiHttpUtils {
         }
         }
         return "";
         return "";
     }
     }
+
+    public static String HttpPostExample () {
+        try { // 图片路径
+             String imagePath = "path_to_your_image_file.jpg";
+            // 将图片转换为Base64编码
+             byte[] imageBytes = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(imagePath));
+            String base64Image = Base64.getEncoder().encodeToString(imageBytes);
+            // 创建URL对象
+            URL url = new URL("http://10.3.2.70:8115");
+             //打开HTTP连接
+             HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+             connection.setRequestMethod("POST");
+             connection.setRequestProperty("Content-Type", "application/json");
+             connection.setRequestProperty("channelcode", "your_channel_code");
+             connection.setRequestProperty("channeldate", "your_channel_date");
+             connection.setDoOutput(true); // 将Base64编码的图片作为请求体发送
+             try (OutputStream os = connection.getOutputStream())
+             { os.write(base64Image.getBytes()); os.flush(); }
+             //检查响应代码
+             int responseCode = connection.getResponseCode();
+             if (responseCode == HttpURLConnection.HTTP_OK) {
+             System.out.println("Request was successful.");
+             } else { System.out.println("Request failed. Response Code: " + responseCode); }
+            // 关闭连接
+            connection.disconnect(); }
+             catch (Exception e) { e.printStackTrace(); }
+        return null;
+    }
     public static String toJsonString(String Params) throws Exception {
     public static String toJsonString(String Params) throws Exception {
+        if("".equals(Params)){return null;};
+        JSONArray objects = JSONArray.parseArray(Params);
+        Object object = objects.get(0);
+        JSONObject respenjson = (JSONObject) JSONObject.toJSON(object);
+        JSONArray itemList = respenjson.getJSONArray("item_list");
+        JSONObject item_list = new JSONObject();
+        for (int i=0;i<itemList.size();i++){
+            Object obj = itemList.get(i);
+            JSONObject respenjsons = (JSONObject) JSONObject.toJSON(obj);
+        }
+
         JSONObject json = new JSONObject();//返回最外层json
         JSONObject json = new JSONObject();//返回最外层json
-        json.put("errcode","");
+        json.put("errcode","0000");
         json.put("traceId","");
         json.put("traceId","");
-        json.put("description","");
+        json.put("description","操作成功");
         JSONObject data = new JSONObject();//数据层json
         JSONObject data = new JSONObject();//数据层json
         json.put("batchNo","");
         json.put("batchNo","");
         JSONArray recoginitionData = new JSONArray();//数据层数组
         JSONArray recoginitionData = new JSONArray();//数据层数组
         JSONObject fileObj = new JSONObject();//实际数据json
         JSONObject fileObj = new JSONObject();//实际数据json
-        fileObj.put("canBeDeduction","");
-        fileObj.put("salerName","");
-        fileObj.put("invoiceMoney","");
-        fileObj.put("signStatus","");
-        fileObj.put("downloadUrl","");
-        fileObj.put("fileHash","");
-        fileObj.put("invoiceAmount","");
-        fileObj.put("localUrl","");
-        fileObj.put("deductionStatus","");
-        fileObj.put("salerTaxNo","");
-        fileObj.put("invoiceType","");
-        fileObj.put("invoiceNo","");
-        fileObj.put("isRepeat","");
-        fileObj.put("pixel","");
-        fileObj.put("oriImageSize","");
-        fileObj.put("pdfToImgSnapshotUrl","");
-        fileObj.put("orientation","");
-        fileObj.put("batchNo","");
-        fileObj.put("clientId","");
-        fileObj.put("buyerTaxNo","");
-        fileObj.put("warningCode","");
-        fileObj.put("originalState","");
-        fileObj.put("companySeal","");
-        fileObj.put("originalUrl","");
-        fileObj.put("invoiceDate","");
-        fileObj.put("buyerName","");
-        fileObj.put("invoiceCode","");
-        fileObj.put("serialNo","");
-        fileObj.put("totalAmount","");
-        fileObj.put("taxRate","");
-        fileObj.put("oriOrientation","");
-        fileObj.put("oriRegion","");
-        fileObj.put("rotationAngle","");
-        fileObj.put("snapshotUrl","");
-        fileObj.put("imageSerialNo","");
-        fileObj.put("recognitionSerialNo","");
-        fileObj.put("totalTaxAmount","");
-        fileObj.put("taxAmount","");
-        fileObj.put("region","");
-        fileObj.put("isExpend","");
-        fileObj.put("expendStatus","");
-        fileObj.put("fileType","");
+        fileObj.put("canBeDeduction","");//0
+        fileObj.put("salerName","");//销售方名称  ocr字段:vat_invoice_seller_name
+        fileObj.put("invoiceMoney","");//金额明细 ocr字段:vat_invoice_price_list
+        fileObj.put("signStatus","");//0
+        fileObj.put("downloadUrl","");//下载地址链接
+        fileObj.put("fileHash","");//文件哈希值
+        fileObj.put("invoiceAmount","");//合计金额 ocr字段:vat_invoice_total
+        fileObj.put("localUrl","");//预览链接
+        fileObj.put("deductionStatus",1);//扣除
+        fileObj.put("salerTaxNo","");//纳税人识别号 ocr字段:vat_invoice_seller_id_invoice_seal
+        fileObj.put("invoiceType",1);//发票类型 ocr字段:type  1="增值税发票"
+        fileObj.put("invoiceNo","");//发票号码 ocr字段:vat_invoice_haoma_large_size
+        fileObj.put("isRepeat",false);//是否重复
+        fileObj.put("pixel","");//3962978 未知字段
+        fileObj.put("oriImageSize","");//base64编码长度
+        fileObj.put("pdfToImgSnapshotUrl","");//空
+        fileObj.put("orientation","0");//0
+        fileObj.put("batchNo",null);//null
+        fileObj.put("clientId","Vfz636yVhmk9HEu1QTAp");//客户端id
+        fileObj.put("buyerTaxNo","");//购买方纳税人识别号 ocr字段:vat_invoice_rate_payer_id
+        fileObj.put("warningCode","");//警告数量
+        fileObj.put("originalState",0);//原始状态0
+        fileObj.put("companySeal","1");//未知字段
+        fileObj.put("originalUrl","");//地址链接
+        fileObj.put("invoiceDate","");//开票日期 ocr字段:vat_invoice_issue_dat_print
+        fileObj.put("buyerName","");//购买方名称  ocr字段:vat_invoice_payer_name
+        fileObj.put("invoiceCode","");//发票代码 ocr字段: vat_invoice_daima
+        fileObj.put("serialNo","");//未知字段
+        fileObj.put("totalAmount","");//价税合计 ocr字段: vat_invoice_total_cover_tax_digits
+        fileObj.put("taxRate","");//税率 ocr字段 vat_invoice_tax_rate
+        fileObj.put("oriOrientation","0");//未知字段
+        fileObj.put("oriRegion","");//什么地区....
+        fileObj.put("rotationAngle","0");//未知字段
+        fileObj.put("snapshotUrl","");//图片地址
+        fileObj.put("imageSerialNo","");//图片编码?
+        fileObj.put("recognitionSerialNo","");//未知字段
+        fileObj.put("totalTaxAmount","");//税额合计 ocr字段 vat_invoice_tax_total
+        fileObj.put("taxAmount","");//税额 ocr字段 vat_invoice_tax_list
+        fileObj.put("region","");//未知字段
+        fileObj.put("isExpend","");//""
+        fileObj.put("expendStatus",null);//null
+        fileObj.put("fileType",1);//附件类型
         JSONArray items = new JSONArray();//数据明细层数组
         JSONArray items = new JSONArray();//数据明细层数组
         JSONObject mxFileObj = new JSONObject();//明细数据json
         JSONObject mxFileObj = new JSONObject();//明细数据json
-        mxFileObj.put("unitPrice","");
-        mxFileObj.put("taxRate","");
+        mxFileObj.put("unitPrice","");//合计金额 oct字段: vat_invoice_total
+        mxFileObj.put("taxRate","");//税率明细 vat_invoice_tax_rate_list
         mxFileObj.put("unit","");
         mxFileObj.put("unit","");
-        mxFileObj.put("num","");
-        mxFileObj.put("detailAmount","");
-        mxFileObj.put("taxAmount","");
-        mxFileObj.put("goodsName","");
+        mxFileObj.put("num","1");
+        mxFileObj.put("detailAmount","");//金额明细 ocr字段:vat_invoice_price_list
+        mxFileObj.put("taxAmount","");//税额明细 ocr字段 vat_invoice_tax_list
+        mxFileObj.put("goodsName","");//服务名称/项目名称 ocr字段 vat_invoice_goods_list
         //值拼接完成后开始set数据结构
         //值拼接完成后开始set数据结构
         items.add(mxFileObj);
         items.add(mxFileObj);
         fileObj.put("items",items);
         fileObj.put("items",items);

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません