|
@@ -1,10 +1,33 @@
|
|
|
|
+//
|
|
|
|
+// Source code recreated from a .class file by IntelliJ IDEA
|
|
|
|
+// (powered by FernFlower decompiler)
|
|
|
|
+//
|
|
|
|
+
|
|
package kd.imc.rim.common.service;
|
|
package kd.imc.rim.common.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
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.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.HashSet;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
|
+import java.util.concurrent.Future;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
+import java.util.concurrent.TimeoutException;
|
|
|
|
+import java.util.stream.Collectors;
|
|
import kd.bos.context.RequestContext;
|
|
import kd.bos.context.RequestContext;
|
|
|
|
+import kd.bos.dataentity.resource.ResManager;
|
|
import kd.bos.dataentity.utils.ObjectUtils;
|
|
import kd.bos.dataentity.utils.ObjectUtils;
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
import kd.bos.fileservice.FileServiceFactory;
|
|
import kd.bos.fileservice.FileServiceFactory;
|
|
@@ -15,7 +38,7 @@ 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.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;
|
|
@@ -26,25 +49,14 @@ 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.*;
|
|
import kd.imc.rim.common.utils.itextpdf.UrlServiceUtils;
|
|
import kd.imc.rim.common.utils.itextpdf.UrlServiceUtils;
|
|
-import kd.imc.rim.file.model.FileConvertResult;
|
|
|
|
|
|
+import kd.imc.rim.file.utils.FileConvertUtils;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.compress.utils.Lists;
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.text.DecimalFormat;
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.concurrent.ExecutionException;
|
|
|
|
-import java.util.concurrent.Future;
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
-import java.util.concurrent.TimeoutException;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
public class RecognitionCheckServiceEx {
|
|
public class RecognitionCheckServiceEx {
|
|
private static RecognitionCheckServiceEx instance = null;
|
|
private static RecognitionCheckServiceEx instance = null;
|
|
- private static Log logger = LogFactory.getLog(RecognitionCheckServiceEx.class);
|
|
|
|
- private RecognitionCheckHelperEx recognitionCheckHelper = new RecognitionCheckHelperEx();
|
|
|
|
|
|
+ private static Log logger = LogFactory.getLog(RecognitionCheckService.class);
|
|
|
|
+ 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;
|
|
private static ThreadPool uploadThreadPool = ThreadPools.newFixedThreadPool("recognitionUploadThread_2", Runtime.getRuntime().availableProcessors() + 1);
|
|
private static ThreadPool uploadThreadPool = ThreadPools.newFixedThreadPool("recognitionUploadThread_2", Runtime.getRuntime().availableProcessors() + 1);
|
|
@@ -53,8 +65,8 @@ public class RecognitionCheckServiceEx {
|
|
}
|
|
}
|
|
|
|
|
|
public static RecognitionCheckServiceEx getInstance() {
|
|
public static RecognitionCheckServiceEx getInstance() {
|
|
- Class var0 = RecognitionCheckServiceEx.class;
|
|
|
|
- synchronized(RecognitionCheckServiceEx.class) {
|
|
|
|
|
|
+ Class var0 = RecognitionCheckService.class;
|
|
|
|
+ synchronized(RecognitionCheckService.class) {
|
|
if (instance == null) {
|
|
if (instance == null) {
|
|
instance = new RecognitionCheckServiceEx();
|
|
instance = new RecognitionCheckServiceEx();
|
|
}
|
|
}
|
|
@@ -65,6 +77,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);
|
|
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);
|
|
@@ -89,14 +102,14 @@ public class RecognitionCheckServiceEx {
|
|
JSONArray attachResult;
|
|
JSONArray attachResult;
|
|
try {
|
|
try {
|
|
long fileStartTime = System.currentTimeMillis();
|
|
long fileStartTime = System.currentTimeMillis();
|
|
- FormFileEntity fileEntity = this.recognitionCheckHelper.getFormFileEntity(fileUrl, fileName);
|
|
|
|
|
|
+ FormFileEntity fileEntity = this.RecognitionCheckHelperEx.getFormFileEntity(fileUrl, fileName);
|
|
if (!fileEntity.getSuccess()) {
|
|
if (!fileEntity.getSuccess()) {
|
|
this.handle(recognitionListener, listener);
|
|
this.handle(recognitionListener, listener);
|
|
return InvoiceUploadErrorType.getSplitErrorResult();
|
|
return InvoiceUploadErrorType.getSplitErrorResult();
|
|
}
|
|
}
|
|
|
|
|
|
int totalPage = CollectionUtils.isEmpty(fileEntity.getSubFileList()) ? 1 : fileEntity.getSubFileList().size();
|
|
int totalPage = CollectionUtils.isEmpty(fileEntity.getSubFileList()) ? 1 : fileEntity.getSubFileList().size();
|
|
- Map<String, Object> extMap = this.recognitionCheckHelper.getRecognitionCheckExtMap(businessParam);
|
|
|
|
|
|
+ Map<String, Object> extMap = this.RecognitionCheckHelperEx.getRecognitionCheckExtMap(businessParam);
|
|
String originalStateDefault = fileEntity.getOriginalStateDefault();
|
|
String originalStateDefault = fileEntity.getOriginalStateDefault();
|
|
if ("1".equals(originalStateDefault)) {
|
|
if ("1".equals(originalStateDefault)) {
|
|
extMap.put("originalStateDefault", originalStateDefault);
|
|
extMap.put("originalStateDefault", originalStateDefault);
|
|
@@ -104,13 +117,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("RecognitionCheckServiceEx 文件解析耗时:{}", System.currentTimeMillis() - fileStartTime);
|
|
|
|
|
|
+ logger.info("RecognitionCheckService 文件解析耗时:{}", System.currentTimeMillis() - fileStartTime);
|
|
|
|
|
|
List recognitionResultList;
|
|
List recognitionResultList;
|
|
try {
|
|
try {
|
|
long recognitionStartTime = System.currentTimeMillis();
|
|
long recognitionStartTime = System.currentTimeMillis();
|
|
- recognitionResultList = this.recognitionCheckHelper.recognitionInvoiceFile(fileEntity, extMap);
|
|
|
|
- logger.info("RecognitionCheckServiceEx 识别总耗时:{}", System.currentTimeMillis() - recognitionStartTime);
|
|
|
|
|
|
+ recognitionResultList = this.RecognitionCheckHelperEx.recognitionInvoiceFile(fileEntity, extMap);
|
|
|
|
+ logger.info("RecognitionCheckService 识别总耗时:{}", 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) {
|
|
@@ -122,14 +135,12 @@ public class RecognitionCheckServiceEx {
|
|
logger.info("识别程序错误:", var26);
|
|
logger.info("识别程序错误:", var26);
|
|
return InvoiceUploadErrorType.getRecognitionErrorResult();
|
|
return InvoiceUploadErrorType.getRecognitionErrorResult();
|
|
}
|
|
}
|
|
- //改了的地方
|
|
|
|
- isCheck=false;
|
|
|
|
|
|
|
|
if (isCheck && recognitionResultList.size() > 0) {
|
|
if (isCheck && recognitionResultList.size() > 0) {
|
|
try {
|
|
try {
|
|
long checkStartTime = System.currentTimeMillis();
|
|
long checkStartTime = System.currentTimeMillis();
|
|
- List<JSONObject> checkResultList = this.recognitionCheckHelper.checkInvoiceByRecognitionInfo(recognitionResultList, extMap);
|
|
|
|
- logger.info("RecognitionCheckServiceEx 查验总耗时:{}", System.currentTimeMillis() - checkStartTime);
|
|
|
|
|
|
+ List<JSONObject> checkResultList = this.RecognitionCheckHelperEx.checkInvoiceByRecognitionInfo(recognitionResultList, extMap);
|
|
|
|
+ logger.info("RecognitionCheckService 查验总耗时:{}", 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);
|
|
@@ -143,6 +154,7 @@ public class RecognitionCheckServiceEx {
|
|
fileBaseInfo.put("fileUrl", fileUrl);
|
|
fileBaseInfo.put("fileUrl", fileUrl);
|
|
fileBaseInfo.put("fileName", fileName);
|
|
fileBaseInfo.put("fileName", fileName);
|
|
fileBaseInfo.put("size", fileEntity.getFileSize());
|
|
fileBaseInfo.put("size", fileEntity.getFileSize());
|
|
|
|
+ fileBaseInfo.put("fileHash", fileEntity.getFileHash());
|
|
finalResult = this.putFileInfo(fileBaseInfo, finalResult, subFileFutureMap, originalStateDefault);
|
|
finalResult = this.putFileInfo(fileBaseInfo, finalResult, subFileFutureMap, originalStateDefault);
|
|
attachResult = this.dealSaleList(finalResult, businessParam);
|
|
attachResult = this.dealSaleList(finalResult, businessParam);
|
|
boolean isHandleAttach = attachResult.size() > 0 && finalResult.size() == 0;
|
|
boolean isHandleAttach = attachResult.size() > 0 && finalResult.size() == 0;
|
|
@@ -153,6 +165,7 @@ public class RecognitionCheckServiceEx {
|
|
|
|
|
|
try {
|
|
try {
|
|
if (fileBaseInfo.get("totalPage") == null) {
|
|
if (fileBaseInfo.get("totalPage") == null) {
|
|
|
|
+ totalPage = this.getTotalPage(finalResult, attachResult);
|
|
fileBaseInfo.put("totalPage", totalPage);
|
|
fileBaseInfo.put("totalPage", totalPage);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -163,24 +176,24 @@ public class RecognitionCheckServiceEx {
|
|
logger.info("发票保存错误:", var24);
|
|
logger.info("发票保存错误:", var24);
|
|
}
|
|
}
|
|
} catch (IOException var27) {
|
|
} catch (IOException var27) {
|
|
- logger.info("RecognitionCheckServiceEx IOException :{}", var27);
|
|
|
|
|
|
+ logger.info("RecognitionCheckService IOException :{}", var27);
|
|
this.handle(recognitionListener, listener);
|
|
this.handle(recognitionListener, listener);
|
|
return InvoiceUploadErrorType.getSplitErrorResult();
|
|
return InvoiceUploadErrorType.getSplitErrorResult();
|
|
} catch (MsgException var28) {
|
|
} catch (MsgException var28) {
|
|
- logger.info("RecognitionCheckServiceEx MsgException :{}", var28);
|
|
|
|
|
|
+ logger.info("RecognitionCheckService 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("RecognitionCheckServiceEx BaseErrorResult Throwable:{}", var29);
|
|
|
|
|
|
+ logger.info("RecognitionCheckService 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("RecognitionCheckServiceEx 识别查验入库总耗时:{}", System.currentTimeMillis() - startTime);
|
|
|
|
|
|
+ logger.info("RecognitionCheckService 识别查验入库总耗时:{}", System.currentTimeMillis() - startTime);
|
|
if (resultFlag) {
|
|
if (resultFlag) {
|
|
return InvoiceUploadErrorType.getSuccessResult(finalResult, attachResult);
|
|
return InvoiceUploadErrorType.getSuccessResult(finalResult, attachResult);
|
|
} else {
|
|
} else {
|
|
@@ -206,17 +219,12 @@ 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);
|
|
- Long invoiceType1 = invoice.getLong("invoiceType");
|
|
|
|
- if (InputInvoiceTypeEnum.OTHER_INVOICE.getCode().equals(invoiceType1)) {
|
|
|
|
- String title = invoice.getString("title");
|
|
|
|
- boolean saleTitle = !StringUtils.isEmpty(title) && title.indexOf("清单") > 0;
|
|
|
|
- if (!saleTitle) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!RecognitionCheckHelper.isSalePage(invoice)) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- FileUploadAndSignTask task = new FileUploadAndSignTask(fileEntity.getFileUrl(), (byte[])null, "pdf", true, RequestContext.get());
|
|
|
|
|
|
+ FileUploadAndSignTask task = new FileUploadAndSignTask(fileEntity.getFileUrl(), (byte[])null, fileEntity.getFileName(), "pdf", fileEntity.getFileHash(), true, RequestContext.get());
|
|
task.setSignOnly(true);
|
|
task.setSignOnly(true);
|
|
Future<JSONObject> subUploadFuture = uploadThreadPool.submit(task);
|
|
Future<JSONObject> subUploadFuture = uploadThreadPool.submit(task);
|
|
subFileFutureMap.put(recheckorginPage, subUploadFuture);
|
|
subFileFutureMap.put(recheckorginPage, subUploadFuture);
|
|
@@ -224,6 +232,24 @@ public class RecognitionCheckServiceEx {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private int getTotalPage(JSONArray finalResult, JSONArray attachArray) {
|
|
|
|
+ Set<Integer> pageNumSet = new HashSet(8);
|
|
|
|
+ int i;
|
|
|
|
+ if (finalResult != null && !finalResult.isEmpty()) {
|
|
|
|
+ for(i = 0; i < finalResult.size(); ++i) {
|
|
|
|
+ pageNumSet.add(finalResult.getJSONObject(i).getInteger("pageNo"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (attachArray != null && !attachArray.isEmpty()) {
|
|
|
|
+ for(i = 0; i < attachArray.size(); ++i) {
|
|
|
|
+ pageNumSet.add(attachArray.getJSONObject(i).getInteger("pageNo"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return pageNumSet.size();
|
|
|
|
+ }
|
|
|
|
+
|
|
private void handleAttach(JSONArray attachResult, IRecognitionListener recognitionListener, String fileUrl, String fileName, int totalPage) {
|
|
private void handleAttach(JSONArray attachResult, IRecognitionListener recognitionListener, String fileUrl, String fileName, int totalPage) {
|
|
if (attachResult != null && attachResult.size() != 0) {
|
|
if (attachResult != null && attachResult.size() != 0) {
|
|
if (recognitionListener != null) {
|
|
if (recognitionListener != null) {
|
|
@@ -250,14 +276,15 @@ public class RecognitionCheckServiceEx {
|
|
if (finalResult.size() == 0) {
|
|
if (finalResult.size() == 0) {
|
|
return new JSONArray();
|
|
return new JSONArray();
|
|
} else {
|
|
} else {
|
|
- JSONArray targetArray = this.recognitionCheckHelper.getTargetArray(finalResult);
|
|
|
|
- finalResult.removeAll(targetArray);
|
|
|
|
Map<String, String> configMap = ImcConfigUtil.getValue("rim_recog_check");
|
|
Map<String, String> configMap = ImcConfigUtil.getValue("rim_recog_check");
|
|
String isDealSaleList = (String)configMap.get("is_dealsalelist");
|
|
String isDealSaleList = (String)configMap.get("is_dealsalelist");
|
|
if ("0".equals(isDealSaleList)) {
|
|
if ("0".equals(isDealSaleList)) {
|
|
return new JSONArray();
|
|
return new JSONArray();
|
|
} else {
|
|
} else {
|
|
- JSONArray attachArray = this.recognitionCheckHelper.bindAttachInvoice(targetArray, businessParam);
|
|
|
|
|
|
+ JSONArray targetArray = this.RecognitionCheckHelperEx.getTargetArray(finalResult);
|
|
|
|
+ finalResult.removeAll(targetArray);
|
|
|
|
+ Map<String, Long> invoiceTypeMap = this.getInvoiceTypeMapAndRemoveFinancialDetail(finalResult);
|
|
|
|
+ JSONArray attachArray = this.RecognitionCheckHelperEx.bindAttachInvoice(targetArray, businessParam, invoiceTypeMap);
|
|
List<String> finishList = Lists.newArrayList();
|
|
List<String> finishList = Lists.newArrayList();
|
|
if (attachArray.size() > 0) {
|
|
if (attachArray.size() > 0) {
|
|
for(int i = 0; i < attachArray.size(); ++i) {
|
|
for(int i = 0; i < attachArray.size(); ++i) {
|
|
@@ -269,7 +296,7 @@ public class RecognitionCheckServiceEx {
|
|
StringBuilder attachNo = new StringBuilder();
|
|
StringBuilder attachNo = new StringBuilder();
|
|
attachNo.append(invoiceCode).append('_').append(invoiceNo);
|
|
attachNo.append(invoiceCode).append('_').append(invoiceNo);
|
|
if (!finishList.contains(attachNo.toString())) {
|
|
if (!finishList.contains(attachNo.toString())) {
|
|
- JSONObject numObject = this.recognitionCheckHelper.calcSaleListComplete(invoiceCode, invoiceNo, attachNo.toString());
|
|
|
|
|
|
+ JSONObject numObject = this.RecognitionCheckHelperEx.calcSaleListComplete(invoiceCode, invoiceNo, attachNo.toString());
|
|
int salelistSum = numObject.getInteger("salelistSum");
|
|
int salelistSum = numObject.getInteger("salelistSum");
|
|
if (salelistSum == 0) {
|
|
if (salelistSum == 0) {
|
|
salelistSum = attachInfo.getInteger("page_sum");
|
|
salelistSum = attachInfo.getInteger("page_sum");
|
|
@@ -288,6 +315,40 @@ public class RecognitionCheckServiceEx {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private Map<String, Long> getInvoiceTypeMapAndRemoveFinancialDetail(JSONArray finalResult) {
|
|
|
|
+ Map<String, Long> invoiceTypeMap = new HashMap(8);
|
|
|
|
+ boolean notFINANCIAL = false;
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < finalResult.size(); ++i) {
|
|
|
|
+ JSONObject invoiceInfo = finalResult.getJSONObject(i);
|
|
|
|
+ Long invoiceType = invoiceInfo.getLong("invoiceType");
|
|
|
|
+ if (!InputInvoiceTypeEnum.OTHER_INVOICE.getCode().equals(invoiceType)) {
|
|
|
|
+ invoiceTypeMap.put(StringUtils.trimToEmpty(invoiceInfo.getString("invoiceCode")) + StringUtils.trimToEmpty(invoiceInfo.getString("invoiceNo")), invoiceType);
|
|
|
|
+ } else if (!InputInvoiceTypeEnum.FINANCIAL_INVOICE.getCode().equals(invoiceType) && !InputInvoiceTypeEnum.OTHER_INVOICE.getCode().equals(invoiceType)) {
|
|
|
|
+ notFINANCIAL = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (invoiceTypeMap.size() > 0 && !notFINANCIAL) {
|
|
|
|
+ List<JSONObject> list = new ArrayList(8);
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < finalResult.size(); ++i) {
|
|
|
|
+ JSONObject invoiceInfo = finalResult.getJSONObject(i);
|
|
|
|
+ Long invoiceType = invoiceInfo.getLong("invoiceType");
|
|
|
|
+ String title = invoiceInfo.getString("title");
|
|
|
|
+ if (!RecognitionCheckHelper.isSalePage(invoiceInfo) && InputInvoiceTypeEnum.OTHER_INVOICE.getCode().equals(invoiceType) && StringUtils.isNotEmpty(title) && title.indexOf("明细") > 0) {
|
|
|
|
+ list.add(invoiceInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
+ finalResult.removeAll(list);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return invoiceTypeMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
public void handle(IRecognitionListener recognitionListener, RecognitionListenerResult listener) {
|
|
public void handle(IRecognitionListener recognitionListener, RecognitionListenerResult listener) {
|
|
if (recognitionListener != null) {
|
|
if (recognitionListener != null) {
|
|
recognitionListener.handle(listener);
|
|
recognitionListener.handle(listener);
|
|
@@ -331,7 +392,9 @@ public class RecognitionCheckServiceEx {
|
|
|
|
|
|
for(int i = 0; i < finalResult.size(); ++i) {
|
|
for(int i = 0; i < finalResult.size(); ++i) {
|
|
JSONObject invoiceInfo = (JSONObject)finalResult.get(i);
|
|
JSONObject invoiceInfo = (JSONObject)finalResult.get(i);
|
|
|
|
+ Long invoiceType = invoiceInfo.getLong("invoiceType");
|
|
invoiceInfo.put("fileName", fileBaseInfo.get("fileName"));
|
|
invoiceInfo.put("fileName", fileBaseInfo.get("fileName"));
|
|
|
|
+ invoiceInfo.put("fileHash", fileBaseInfo.get("fileHash"));
|
|
int pageNo = (Integer)invoiceInfo.get("pageNo");
|
|
int pageNo = (Integer)invoiceInfo.get("pageNo");
|
|
Object feature = subFileFutureMap.get(pageNo);
|
|
Object feature = subFileFutureMap.get(pageNo);
|
|
if (feature != null) {
|
|
if (feature != null) {
|
|
@@ -344,17 +407,17 @@ public class RecognitionCheckServiceEx {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- String path;
|
|
|
|
if (fileReuslt != null) {
|
|
if (fileReuslt != null) {
|
|
- path = fileReuslt.getString("isOriginal");
|
|
|
|
|
|
+ String isOriginal = fileReuslt.getString("isOriginal");
|
|
if (!"1".equals(invoiceInfo.getString("originalState"))) {
|
|
if (!"1".equals(invoiceInfo.getString("originalState"))) {
|
|
- if ("true".equals(path)) {
|
|
|
|
|
|
+ if ("true".equals(isOriginal)) {
|
|
invoiceInfo.put("originalState", "1");
|
|
invoiceInfo.put("originalState", "1");
|
|
} else {
|
|
} else {
|
|
invoiceInfo.put("originalState", "0");
|
|
invoiceInfo.put("originalState", "0");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ invoiceInfo.put("subFileName", fileReuslt.getString("subFileName"));
|
|
invoiceInfo.put("snapshotUrl", fileReuslt.getString("snapshotUrl"));
|
|
invoiceInfo.put("snapshotUrl", fileReuslt.getString("snapshotUrl"));
|
|
invoiceInfo.put("imageUrl", fileReuslt.getString("imageUrl"));
|
|
invoiceInfo.put("imageUrl", fileReuslt.getString("imageUrl"));
|
|
invoiceInfo.put("ofdUrl", fileReuslt.getString("ofdUrl"));
|
|
invoiceInfo.put("ofdUrl", fileReuslt.getString("ofdUrl"));
|
|
@@ -374,32 +437,12 @@ public class RecognitionCheckServiceEx {
|
|
}
|
|
}
|
|
|
|
|
|
invoiceInfo.put("synConvert", fileReuslt.getString("synConvert"));
|
|
invoiceInfo.put("synConvert", fileReuslt.getString("synConvert"));
|
|
- } else if (!StringUtils.isEmpty(updateFileUrl)) {
|
|
|
|
- path = FileUploadUtils.getSnapshotPathByUploadUrl(updateFileUrl);
|
|
|
|
- String imageUrl = path + ".jpg";
|
|
|
|
- if ("pdf".equals(updateFileType)) {
|
|
|
|
- invoiceInfo.put("pdfUrl", updateFileUrl);
|
|
|
|
- invoiceInfo.put("snapshotUrl", imageUrl);
|
|
|
|
- invoiceInfo.put("imageUrl", imageUrl);
|
|
|
|
- invoiceInfo.put("synConvert", true);
|
|
|
|
- invoiceInfo.put("fileType", "1");
|
|
|
|
- FileUploadAndSignTask.saveFileAws(new FileConvertResult(), updateFileUrl, "1");
|
|
|
|
- } else if ("ofd".equals(updateFileType)) {
|
|
|
|
- invoiceInfo.put("ofdUrl", updateFileUrl);
|
|
|
|
- invoiceInfo.put("pdfUrl", path + ".pdf");
|
|
|
|
- invoiceInfo.put("snapshotUrl", imageUrl);
|
|
|
|
- invoiceInfo.put("imageUrl", imageUrl);
|
|
|
|
- invoiceInfo.put("synConvert", true);
|
|
|
|
- invoiceInfo.put("fileType", "4");
|
|
|
|
- FileUploadAndSignTask.saveFileAws(new FileConvertResult(), updateFileUrl, "4");
|
|
|
|
- } else {
|
|
|
|
- invoiceInfo.put("snapshotUrl", updateFileUrl);
|
|
|
|
- invoiceInfo.put("imageUrl", updateFileUrl);
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ invoiceInfo.put("synConvert", true);
|
|
}
|
|
}
|
|
|
|
|
|
logger.info("获取文件处理结果等待时长{},{}", System.currentTimeMillis() - start, fileReuslt);
|
|
logger.info("获取文件处理结果等待时长{},{}", System.currentTimeMillis() - start, fileReuslt);
|
|
- if (returnFirst) {
|
|
|
|
|
|
+ if (returnFirst && !InputInvoiceTypeEnum.HGJKS.getCode().equals(invoiceType)) {
|
|
JSONArray finalResult2 = new JSONArray();
|
|
JSONArray finalResult2 = new JSONArray();
|
|
invoiceInfo.put("originalState", "1");
|
|
invoiceInfo.put("originalState", "1");
|
|
finalResult2.add(invoiceInfo);
|
|
finalResult2.add(invoiceInfo);
|
|
@@ -465,6 +508,7 @@ public class RecognitionCheckServiceEx {
|
|
result.put("fileType", "2");
|
|
result.put("fileType", "2");
|
|
result.put("imageUrl", fileFile.getFileUrl());
|
|
result.put("imageUrl", fileFile.getFileUrl());
|
|
result.put("snapshotUrl", fileFile.getFileUrl());
|
|
result.put("snapshotUrl", fileFile.getFileUrl());
|
|
|
|
+ result.put("subFileName", fileFile.getFileName());
|
|
return result;
|
|
return result;
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
@@ -473,7 +517,11 @@ public class RecognitionCheckServiceEx {
|
|
|
|
|
|
try {
|
|
try {
|
|
byte[] streamByte = FileUtils.getByte(fileInputStream);
|
|
byte[] streamByte = FileUtils.getByte(fileInputStream);
|
|
- subUploadFuture = uploadThreadPool.submit(new FileUploadAndSignTask(fileFile.getFileUrl(), streamByte, fileFile.getFileType(), fileFile.getSignatureFlag(), context));
|
|
|
|
|
|
+ if (StringUtils.isEmpty(fileFile.getFileHash())) {
|
|
|
|
+ fileFile.setFileHash(FileConvertUtils.getSHA256(streamByte));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ subUploadFuture = uploadThreadPool.submit(new FileUploadAndSignTask(fileFile.getFileUrl(), streamByte, fileFile.getFileName(), fileFile.getFileType(), fileFile.getFileHash(), fileFile.getSignatureFlag(), context));
|
|
} catch (Throwable var16) {
|
|
} catch (Throwable var16) {
|
|
var6 = var16;
|
|
var6 = var16;
|
|
throw var16;
|
|
throw var16;
|
|
@@ -573,6 +621,12 @@ 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]);
|
|
|
|
+ if (var28 instanceof MsgException) {
|
|
|
|
+ errorMsg = ((MsgException)var28).getErrorMsg();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ invoiceInfo.put("errorMsg", errorMsg);
|
|
mayErrorResult.add(invoiceInfo);
|
|
mayErrorResult.add(invoiceInfo);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -580,7 +634,7 @@ public class RecognitionCheckServiceEx {
|
|
Map<String, String> configMap = ImcConfigUtil.getValue("rim_recog_check");
|
|
Map<String, String> configMap = ImcConfigUtil.getValue("rim_recog_check");
|
|
String isDealSaleList = (String)configMap.get("is_dealsalelist");
|
|
String isDealSaleList = (String)configMap.get("is_dealsalelist");
|
|
if ("1".equals(isSaleListInvoice) && !"0".equals(isDealSaleList)) {
|
|
if ("1".equals(isSaleListInvoice) && !"0".equals(isDealSaleList)) {
|
|
- this.recognitionCheckHelper.dealInvoiceAttachRelation(invoiceInfo);
|
|
|
|
|
|
+ this.RecognitionCheckHelperEx.dealInvoiceAttachRelation(invoiceInfo);
|
|
}
|
|
}
|
|
|
|
|
|
logger.info("发票助手本地上传保存发票后的数据:" + invoiceInfo);
|
|
logger.info("发票助手本地上传保存发票后的数据:" + invoiceInfo);
|
|
@@ -659,6 +713,7 @@ public class RecognitionCheckServiceEx {
|
|
if (businessParam != null) {
|
|
if (businessParam != null) {
|
|
isCheck = !"1".equals(businessParam.getString("notCheck"));
|
|
isCheck = !"1".equals(businessParam.getString("notCheck"));
|
|
}
|
|
}
|
|
|
|
+
|
|
if (!isCheck) {
|
|
if (!isCheck) {
|
|
businessParam.put("errcode", "4999");
|
|
businessParam.put("errcode", "4999");
|
|
businessParam.put("description", CheckContant.getCheckResultDesc("4999"));
|
|
businessParam.put("description", CheckContant.getCheckResultDesc("4999"));
|