|
@@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -66,27 +67,43 @@ public class OcrServiceImpl implements OcrService {
|
|
|
private RecommendInfoService recommendInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
- private DealService dealService;
|
|
|
+ private LinkService linkService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BackService backService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Async("ocrFjsExecutor")
|
|
|
@Override
|
|
|
- public void uploading(String reqId, String fileType, String data, MultipartFile[] files, Long startTime, List<FileDetails> parsedFilePaths) throws IOException {
|
|
|
- log.info("step 2");
|
|
|
- // 2、调用OCR接口,并将返回的ocr数据保存至数据库表。
|
|
|
- String suffix = files[0].getOriginalFilename().substring(files[0].getOriginalFilename().lastIndexOf("."));
|
|
|
- String fileName = UUID.randomUUID().toString() + suffix;
|
|
|
- Map<String,Object> ocrMap = toOcr(reqId, fileType,JSON.toJSONString(parsedFilePaths),fileName,data,startTime);
|
|
|
- log.info("step 3");
|
|
|
- // 3、将ocr数据放入队列中。
|
|
|
- if(null != ocrMap && ocrMap.containsKey("type")){
|
|
|
- // 放入队列。
|
|
|
- CorrelationData correlationData = new CorrelationData(reqId);
|
|
|
- dealService.sendMessage(Constants.ROUTING_OP_KEY, JSON.toJSONString(ocrMap).getBytes(), correlationData);
|
|
|
+ public void toOcr(String reqId, String fileType, String url, String fileName, String data, Long startTime) throws IOException {
|
|
|
+ // 2.2 获取ocr返回值。
|
|
|
+ log.info("step ***2: ocr***");
|
|
|
+ Map<String,Object> ocrMap = toOcrMap(reqId,fileType,url,fileName,data,startTime);
|
|
|
+ System.err.println("***"+JSON.toJSONString(ocrMap));
|
|
|
+ if (null != ocrMap && ocrMap.containsKey("req_id")){
|
|
|
+ // 3、用户画像相似匹配。
|
|
|
+ linkService.match(ocrMap.get("req_id").toString(),ocrMap.get("type").toString(),startTime,
|
|
|
+ ocrMap.get("source_data").toString(), ocrMap.get("ocr_data").toString(),ocrMap.get("mid_ocr").toString(),ocrMap.get("acc_json").toString(),
|
|
|
+ ocrMap.get("recommends").toString());
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ String excTime = DateUtils.getExcTime(startTime, endTime);
|
|
|
+ log.info("match exctime:{}",excTime);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Map<String, Object> toOcr(String reqId, String fileType, String url, String fileName, String data, Long startTime) throws IOException {
|
|
|
+ /**
|
|
|
+ * ocr识别函数1。
|
|
|
+ * @param reqId
|
|
|
+ * @param fileType
|
|
|
+ * @param url
|
|
|
+ * @param fileName
|
|
|
+ * @param data
|
|
|
+ * @param startTime
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,Object> toOcrMap(String reqId, String fileType, String url, String fileName, String data, Long startTime){
|
|
|
Map<String,Object> ocrMap = new HashMap<>();
|
|
|
try {
|
|
|
// 解析已处理过的有效的图片url
|
|
@@ -109,14 +126,14 @@ public class OcrServiceImpl implements OcrService {
|
|
|
// 单文件上传。
|
|
|
ocrMap = toSingleFileOcr(reqId, fileType, effectiveImgpaths.get(0), effectiveImgpaths, data,startTime);
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
- log.info("ocrMap excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
+ log.info("step2 ocrMap excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
return ocrMap;
|
|
|
}
|
|
|
} else if (effectiveImgpaths.size() > 1) {
|
|
|
// 多文件上传,pdf转图片&两张图片,第8、15、16种。
|
|
|
ocrMap = toSingleFileOcr(reqId, fileType, effectiveImgpaths.get(0), effectiveImgpaths, data,startTime);
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
- log.info("ocrMap res excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
+ log.info("step2 ocrMap excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
return ocrMap;
|
|
|
} else {
|
|
|
// todo 没有图片,不合法等,待开发。
|
|
@@ -126,7 +143,7 @@ public class OcrServiceImpl implements OcrService {
|
|
|
resData.setRes(null);
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
back(resData, reqId, DateUtils.getExcTime(startTime,endTime), "0");
|
|
|
- log.info("ocrMap excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
+ log.info("step2 ocrMap excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.info("ocr:{}", e);
|
|
@@ -134,67 +151,8 @@ public class OcrServiceImpl implements OcrService {
|
|
|
return ocrMap;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void matching(String reqId,String type,String startTime,String sourceData, String ocrData,String mideOcr, String accJson, String recommends) {
|
|
|
- Map<String, Object> matchMap = new HashMap<>();
|
|
|
- if (type.equals("10") || type.equals("11")){
|
|
|
- try {
|
|
|
- JSONObject midOcr = new JSONObject();
|
|
|
- if (type.equals("10")) {
|
|
|
- midOcr = ParseUtils.midOcrFront(true,"1",type,ocrData);
|
|
|
- } else {
|
|
|
- midOcr = ParseUtils.midOcrReverse(true,"1",type,ocrData);
|
|
|
- }
|
|
|
- matchMap.put("source_data", sourceData);
|
|
|
- matchMap.put("ocr_data", ocrData);
|
|
|
- matchMap.put("acc_json",accJson);
|
|
|
- matchMap.put("type",type);
|
|
|
- matchMap.put("recommends",type.equals("3") ? JSON.toJSONString(recommendInfoService.findRecomInfo()) : "[]");
|
|
|
- // todo 放入队列中处理。
|
|
|
- String matchRes = internalSendService.match(matchMap);
|
|
|
- log.info("ocr-matching send back res:{}", matchRes);
|
|
|
- ResData resData = ParseUtils.parseRes(reqId, type, JSON.parseObject(sourceData),
|
|
|
- JSON.parseObject(ocrData), JSON.parseObject(matchRes));
|
|
|
- uploadService.saveBack(resData,JSON.toJSONString(midOcr),Long.valueOf(startTime));
|
|
|
- back(resData, reqId, type, "1");
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
- log.info("finish excTime:{}", DateUtils.getExcTime(Long.valueOf(startTime),endTime));
|
|
|
- }catch (Exception ex){
|
|
|
- log.info("matching:{}", ex);
|
|
|
- }
|
|
|
- }else {
|
|
|
- // 处理类型1、2、3、4、5、6、7、8、9、12、13、14、15、16
|
|
|
- // 4,8,15,后期可能不要。
|
|
|
- matchMap.put("source_data", sourceData);
|
|
|
- matchMap.put("ocr_data", ocrData);
|
|
|
- matchMap.put("acc_json",accJson);
|
|
|
- // todo 根据类型3判断该字段是否有值。类型为3时,有值,类型不为3时,已补充。
|
|
|
- matchMap.put("recommends",type.equals("3") ? JSON.toJSONString(recommendInfoService.findRecomInfo()) : "[]");
|
|
|
- ResData resData;
|
|
|
- String bo = StringUtils.substringBeforeLast(reqId,"-");
|
|
|
- if (uploadService.findLinkByBo(bo).size() > 1){
|
|
|
- log.info("关联数据START...");
|
|
|
- // todo ghj link数据部分也要新增类型三的findRecomInfo()数据。已补充。
|
|
|
- log.info("link param:{}", JSON.toJSONString(matchMap));
|
|
|
- String matchRes = internalSendService.link(matchMap);
|
|
|
- resData = ParseUtils.parseRes(reqId, type, JSON.parseObject(sourceData),
|
|
|
- JSON.parseObject(ocrData), JSON.parseObject(matchRes));
|
|
|
- }else {
|
|
|
- matchMap.put("type",type);
|
|
|
- log.info("match param:{}", JSON.toJSONString(matchMap));
|
|
|
- String matchRes = internalSendService.match(matchMap);
|
|
|
- resData = ParseUtils.parseRes(reqId, type, JSON.parseObject(sourceData),
|
|
|
- JSON.parseObject(ocrData), JSON.parseObject(matchRes));
|
|
|
- }
|
|
|
- uploadService.saveBack(resData,JSON.toJSONString(JSON.parseObject(mideOcr)),Long.valueOf(startTime));
|
|
|
- back(resData, reqId, type, JSON.parseObject(mideOcr).get("code").toString());
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
- log.info("finish excTime:{}", DateUtils.getExcTime(Long.valueOf(startTime),endTime));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
- * ocr识别函数。
|
|
|
+ * ocr识别函数2。
|
|
|
* @param reqId
|
|
|
* @param fileType
|
|
|
* @param parsedFilePath
|
|
@@ -211,7 +169,7 @@ public class OcrServiceImpl implements OcrService {
|
|
|
try {
|
|
|
ocr = JSON.parseObject(AipOcrUtils.sample(parsedFilePath.getUrls(), fileType));
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
- log.info("ocr excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
+ log.info("step2 ocr excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
log.info("ocr-mid res:{}", JSON.toJSONString(ocr));
|
|
|
if (null != ocr && ocr.get("image_status").toString().equals("normal")) {
|
|
|
// 解析ocr数据。
|
|
@@ -236,18 +194,10 @@ public class OcrServiceImpl implements OcrService {
|
|
|
// 将ocr结果信息及其他信息封装后写入source表中。
|
|
|
// uploadService.updateByReqIdAndType(reqId,fileType,"time",JSON.toJSONString(matchMap));
|
|
|
// 返回map.
|
|
|
- endTime = System.currentTimeMillis();
|
|
|
- log.info("finish excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
return matchMap;
|
|
|
} else {
|
|
|
- JSONObject midOcr = fileType.equals("10") ? ParseUtils.midOcrFront(false,"-1",fileType,"")
|
|
|
- : ParseUtils.midOcrReverse(false,"-1",fileType,"");
|
|
|
- // todo 直接返回,不用在调用match函数。
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(midOcr),startTime);
|
|
|
- boolean flag = null != ocr ? ocr.get("image_status").equals("non_idcard") ? true : false : false;
|
|
|
- back(getNullBackResData(reqId, fileType), reqId, fileType, flag ? "-1" : "0");
|
|
|
- endTime = System.currentTimeMillis();
|
|
|
- log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
+ // 返回至富士通。
|
|
|
+ backService.back(fileType,reqId,startTime,ocr);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.info("singleFileOcr:{}", e);
|
|
@@ -259,7 +209,7 @@ public class OcrServiceImpl implements OcrService {
|
|
|
ocrMap = getOcrMap(reqId, fileType, paths);
|
|
|
ocr = internalSendService.ocr(ocrMap);
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
- log.info("ocr sf excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
+ log.info("step2 ocr excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
log.info("ocr-mid result:{}", JSON.toJSONString(ocr));
|
|
|
if (null != ocr && ocr.get("code").toString().equals("1")) {
|
|
|
matchMap = matchMap(matchMap,fileType,reqId,ocr,sourceData);
|
|
@@ -268,22 +218,17 @@ public class OcrServiceImpl implements OcrService {
|
|
|
// uploadService.updateByReqIdAndType(reqId,fileType,"time",JSON.toJSONString(matchMap));
|
|
|
return matchMap;
|
|
|
} else if (null != ocr && ocr.get("code").toString().equals("-1")) {
|
|
|
- // todo 直接返回,不用在调用match函数。
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
- back(getNullBackResData(reqId, fileType), reqId, fileType, ocr.get("code").toString());
|
|
|
- endTime = System.currentTimeMillis();
|
|
|
- log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
+ // 返回至富士通。
|
|
|
+ backService.back(fileType,reqId,startTime,ocr);
|
|
|
} else {
|
|
|
- // 调用match函数。
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
- back(getNullBackResData(reqId, fileType), reqId, fileType, ocr.get("code").toString());
|
|
|
- endTime = System.currentTimeMillis();
|
|
|
- log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
+ // 返回至富士通。
|
|
|
+ backService.back(fileType,reqId,startTime,ocr);
|
|
|
}
|
|
|
}
|
|
|
return matchMap;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public void ocr(String reqId, String fileType, String url, String fileName, String sourceData,Long startTime) {
|
|
|
try {
|
|
@@ -328,251 +273,6 @@ public class OcrServiceImpl implements OcrService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Map<String, Object> res(String code, ResData resData) {
|
|
|
- log.info("res code:{}", code);
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("code", code.equals("1") ? "0" : "1");
|
|
|
- map.put("message", code.equals("1") ? "识别成功" : code.equals("-1") ? "文件内容不符,请上传正确的文件后重试。" :
|
|
|
- code.equals("-3") ? "请确保文件大小不超出4M,且最长边不超过4096像素" : "未识别出数据,请确保上传为正确文件后重试");
|
|
|
- map.put("reqId", resData.getReqId());
|
|
|
- map.put("fileType", resData.getType());
|
|
|
- map.put("data", resData.getRes());
|
|
|
- // 20200507 新增回传参数:
|
|
|
- map.put("overallConfidence",code.equals("-1") ? "0" : resData.getOverallConfidence());
|
|
|
- map.put("midConfidence",code.equals("-1") ? "0" : resData.getMidConfidence());
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ResData getNullBackResData(String reqId, String templateType) {
|
|
|
- ResData resData = new ResData();
|
|
|
- try {
|
|
|
- resData = new ResData();
|
|
|
- switch (templateType) {
|
|
|
- case "1":
|
|
|
- PciiAuth pciiAuth = new PciiAuth(new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(pciiAuth);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "2":
|
|
|
- // 待开发
|
|
|
- LoanApplicationForm loanApplicationForm = new LoanApplicationForm(new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(loanApplicationForm);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "3":
|
|
|
- // 待开发
|
|
|
- RecommendationLetter recommendationLetter = new RecommendationLetter(new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(recommendationLetter);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- // 待开发
|
|
|
- CreditConfirmationLetter creditConfirmationLetter = new CreditConfirmationLetter(new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(creditConfirmationLetter);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "5":
|
|
|
- // 待开发
|
|
|
- CreditLoanUseContract creditLoanUseContract = new CreditLoanUseContract(new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(creditLoanUseContract);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "6":
|
|
|
- // 待开发
|
|
|
- ConsumerFinanceHandlingInstructions consumerFinanceHandlingInstructions = new ConsumerFinanceHandlingInstructions(new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(consumerFinanceHandlingInstructions);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "7":
|
|
|
- // 待开发
|
|
|
- LoanPurposeCommitment loanPurposeCommitment = new LoanPurposeCommitment(new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(loanPurposeCommitment);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "8":
|
|
|
- // 待开发
|
|
|
- EnjoyLoansToClient enjoyLoansToClient = new EnjoyLoansToClient(new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(enjoyLoansToClient);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "9":
|
|
|
- // 待开发
|
|
|
- EnjoyLoansConfirm enjoyLoansConfirm = new EnjoyLoansConfirm(new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(enjoyLoansConfirm);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "10":
|
|
|
- // 待开发
|
|
|
- IdCardFront idCardFront = new IdCardFront(new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(idCardFront);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "11":
|
|
|
- // 待开发
|
|
|
- IdCardReverse idCardReverse = new IdCardReverse(new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(idCardReverse);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "12":
|
|
|
- // 待开发
|
|
|
- PersonalInfoUseAuthorization personalInfoUseAuthorization = new PersonalInfoUseAuthorization(new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(personalInfoUseAuthorization);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "13":
|
|
|
- // 待开发
|
|
|
- PayAndEnjoyLoanApplicationForm payAndEnjoyLoanApplicationForm = new PayAndEnjoyLoanApplicationForm(new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(payAndEnjoyLoanApplicationForm);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "14":
|
|
|
- // 待开发
|
|
|
- EnjoyLoanApplicationForm enjoyLoanApplicationForm = new EnjoyLoanApplicationForm(new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0")
|
|
|
- // ,new BackData("", "", "","0")
|
|
|
- );
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(enjoyLoanApplicationForm);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "15":
|
|
|
- // 待开发
|
|
|
- LetterOfCreditCommitment letterOfCreditCommitment = new LetterOfCreditCommitment(new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(letterOfCreditCommitment);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "16":
|
|
|
- // 待开发
|
|
|
- LeEnjoyLoanCommitmentLetter leEnjoyLoanCommitmentLetter = new LeEnjoyLoanCommitmentLetter(new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(leEnjoyLoanCommitmentLetter);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- case "17":
|
|
|
- // 待开发
|
|
|
- LoanApplicationFormEnjoyELoan loanApplicationFormEnjoyELoan = new LoanApplicationFormEnjoyELoan(new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"), new BackData("", "", "","0"),
|
|
|
- new BackData("", "", "","0"));
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes(loanApplicationFormEnjoyELoan);
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- break;
|
|
|
- default:
|
|
|
- // 待开发
|
|
|
- }
|
|
|
- return resData;
|
|
|
- } catch (Exception e) {
|
|
|
- log.info("getNullBackResData:{}", e);
|
|
|
- }
|
|
|
- resData.setReqId(reqId);
|
|
|
- resData.setType(templateType);
|
|
|
- resData.setRes("null");
|
|
|
- resData.setOverallConfidence("2");
|
|
|
- resData.setMidConfidence("2");
|
|
|
- return resData;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> res(String reqId, String fileType, MultipartFile[] files, String data, Long startTime) throws Exception {
|
|
@@ -630,9 +330,9 @@ public class OcrServiceImpl implements OcrService {
|
|
|
} else {
|
|
|
JSONObject midOcr = fileType.equals("10") ? ParseUtils.midOcrFront(false,"-1",fileType,"")
|
|
|
: ParseUtils.midOcrReverse(false,"-1",fileType,"");
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(midOcr),startTime);
|
|
|
+ uploadService.saveBack(backService.getNullBackResData(reqId, fileType),JSON.toJSONString(midOcr),startTime);
|
|
|
boolean flag = null != ocr ? ocr.get("image_status").equals("non_idcard") ? true : false : false;
|
|
|
- back(getNullBackResData(reqId, fileType), reqId, fileType, flag ? "-1" : "0");
|
|
|
+ back(backService.getNullBackResData(reqId, fileType), reqId, fileType, flag ? "-1" : "0");
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
}
|
|
@@ -656,14 +356,14 @@ public class OcrServiceImpl implements OcrService {
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
} else if (null != ocr && ocr.get("code").toString().equals("-1")) {
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
- back(getNullBackResData(reqId, fileType), reqId, fileType, ocr.get("code").toString());
|
|
|
+ uploadService.saveBack(backService.getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
+ back(backService.getNullBackResData(reqId, fileType), reqId, fileType, ocr.get("code").toString());
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
} else {
|
|
|
// todo 待处理。
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
- back(getNullBackResData(reqId, fileType), reqId, fileType, ocr.get("code").toString());
|
|
|
+ uploadService.saveBack(backService.getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
+ back(backService.getNullBackResData(reqId, fileType), reqId, fileType, ocr.get("code").toString());
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
}
|
|
@@ -679,7 +379,7 @@ public class OcrServiceImpl implements OcrService {
|
|
|
resData.setReqId(reqId);
|
|
|
resData.setType(fileType);
|
|
|
resData.setRes(null);
|
|
|
- return res("-3", getNullBackResData(reqId, fileType));
|
|
|
+ return backService.res("-3", backService.getNullBackResData(reqId, fileType));
|
|
|
} else {
|
|
|
// 单文件上传。
|
|
|
return singleFileOcrSyn(reqId, fileType, parsedFilePaths.get(0), parsedFilePaths, sourceData,startTime);
|
|
@@ -779,7 +479,7 @@ public class OcrServiceImpl implements OcrService {
|
|
|
uploadService.saveBack(resData,JSON.toJSONString(midOcr),startTime);
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
- return res("1", resData);
|
|
|
+ return backService.res("1", resData);
|
|
|
}else {
|
|
|
// todo 待处理。
|
|
|
ResData resData = new ResData();
|
|
@@ -790,11 +490,11 @@ public class OcrServiceImpl implements OcrService {
|
|
|
resData.setMidConfidence("2");
|
|
|
JSONObject midOcr = fileType.equals("10") ? ParseUtils.midOcrFront(false,"-1",fileType,"")
|
|
|
: ParseUtils.midOcrReverse(false,"-1",fileType,"");
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(midOcr),startTime);
|
|
|
+ uploadService.saveBack(backService.getNullBackResData(reqId, fileType),JSON.toJSONString(midOcr),startTime);
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
boolean flag = null != ocr ? ocr.get("image_status").equals("non_idcard") ? true : false : false;
|
|
|
- return res(flag ? "-1" : "0", getNullBackResData(reqId, fileType));
|
|
|
+ return backService.res(flag ? "-1" : "0", backService.getNullBackResData(reqId, fileType));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.info("singleFileOcrSyn:{}", e);
|
|
@@ -814,12 +514,12 @@ public class OcrServiceImpl implements OcrService {
|
|
|
uploadService.saveBack(resData,JSON.toJSONString(ocr),startTime);
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
- return res(ocr.get("code").toString(), resData);
|
|
|
+ return backService.res(ocr.get("code").toString(), resData);
|
|
|
} else if (null != ocr && ocr.get("code").toString().equals("-1")) {
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
+ uploadService.saveBack(backService.getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
- return res(ocr.get("code").toString(), getNullBackResData(reqId, fileType));
|
|
|
+ return backService.res(ocr.get("code").toString(), backService.getNullBackResData(reqId, fileType));
|
|
|
} else {
|
|
|
// todo 待处理。
|
|
|
ResData resData = new ResData();
|
|
@@ -828,13 +528,13 @@ public class OcrServiceImpl implements OcrService {
|
|
|
resData.setRes(null);
|
|
|
resData.setOverallConfidence("2");
|
|
|
resData.setMidConfidence("2");
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
+ uploadService.saveBack(backService.getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
- return res(ocr.get("code").toString(), getNullBackResData(reqId, fileType));
|
|
|
+ return backService.res(ocr.get("code").toString(), backService.getNullBackResData(reqId, fileType));
|
|
|
}
|
|
|
}
|
|
|
- uploadService.saveBack(getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
+ uploadService.saveBack(backService.getNullBackResData(reqId, fileType),JSON.toJSONString(ocr),startTime);
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
log.info("ocr back excTime:{}", DateUtils.getExcTime(startTime,endTime));
|
|
|
return resFailed(ocr.containsKey("code") ? ocr.get("code").toString() : "", "操作失败", reqId, fileType);
|
|
@@ -939,9 +639,9 @@ public class OcrServiceImpl implements OcrService {
|
|
|
// todo 记得清除。
|
|
|
String result = "";
|
|
|
if (code.equals("1")) {
|
|
|
- result = JSON.toJSONString(res(code, resData));
|
|
|
+ result = JSON.toJSONString(backService.res(code, resData));
|
|
|
} else {
|
|
|
- result = JSON.toJSONString(res(code, resData));
|
|
|
+ result = JSON.toJSONString(backService.res(code, resData));
|
|
|
}
|
|
|
// todo ghj-online 上线时放开。
|
|
|
String backRes = eternalSendService.send(result);
|