|
|
|
|
@ -62,20 +62,20 @@ public class SupervisionService { |
|
|
|
|
return CommonResult.error(500, "参数异常"); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
String fileName = param.get("imageUrl").toString().substring(param.get("imageUrl").toString().lastIndexOf('/') + 1); |
|
|
|
|
String fileName = param.get("filePath").toString().substring(param.get("filePath").toString().lastIndexOf('/') + 1); |
|
|
|
|
OcrResponseVo redisValue = redisTemplate.opsForValue().get(fileName); |
|
|
|
|
if (redisValue != null) { |
|
|
|
|
return CommonResult.success(determineDocumentType(redisValue)); |
|
|
|
|
// return CommonResult.success(redisValue);
|
|
|
|
|
} |
|
|
|
|
String postfix = getFileExtensionFromUrl(param.get("imageUrl").toString()); |
|
|
|
|
String postfix = getFileExtensionFromUrl(param.get("filePath").toString()); |
|
|
|
|
String imageBase64 = null; |
|
|
|
|
if (Objects.equals(postfix, "pdf")) { |
|
|
|
|
//pdf
|
|
|
|
|
imageBase64 = convertPdfToBase64(param.get("imageUrl").toString()); |
|
|
|
|
imageBase64 = convertPdfToBase64(param.get("filePath").toString()); |
|
|
|
|
} else { |
|
|
|
|
//图片
|
|
|
|
|
imageBase64 = convertImageToBase64(param.get("imageUrl").toString()); |
|
|
|
|
imageBase64 = convertImageToBase64(param.get("filePath").toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasText(imageBase64)) { |
|
|
|
|
@ -102,11 +102,10 @@ public class SupervisionService { |
|
|
|
|
//表格返回参数table_res_list
|
|
|
|
|
if (CollectionUtil.isNotEmpty(result.getPrunedResult().getTable_res_list())) { |
|
|
|
|
texts = result.getPrunedResult().getTable_res_list().get(0).getTable_ocr_pred().getRec_texts(); |
|
|
|
|
} else { |
|
|
|
|
texts = result.getPrunedResult().getOverall_ocr_res().getRec_texts(); |
|
|
|
|
} |
|
|
|
|
if (null != result.getPrunedResult().getOverall_ocr_res()) { |
|
|
|
|
texts.addAll(result.getPrunedResult().getOverall_ocr_res().getRec_texts()); |
|
|
|
|
} |
|
|
|
|
EquipmentRegistryRespVO equipmentRegistryRespVO = new EquipmentRegistryRespVO(); |
|
|
|
|
EquipmentRegistryRespVO equipmentRegistryRespVO = null; |
|
|
|
|
//监督检验
|
|
|
|
|
boolean supervisionAndInspection = texts.stream().anyMatch(t -> t.contains("监督检验")); |
|
|
|
|
if (supervisionAndInspection) { |
|
|
|
|
@ -119,6 +118,9 @@ public class SupervisionService { |
|
|
|
|
equipmentRegistryRespVO = certificateOfApprovalService.getCertificateOfApproval(texts); |
|
|
|
|
equipmentRegistryRespVO.setType("certificateOfApproval"); |
|
|
|
|
} |
|
|
|
|
if (null == equipmentRegistryRespVO) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
equipmentRegistryRespVOS.add(equipmentRegistryRespVO); |
|
|
|
|
} |
|
|
|
|
param.put("extractedData", equipmentRegistryRespVOS); |
|
|
|
|
@ -131,8 +133,8 @@ public class SupervisionService { |
|
|
|
|
*/ |
|
|
|
|
private boolean validateParams(Map<String, Object> param) { |
|
|
|
|
return !ObjectUtils.isEmpty(param) && |
|
|
|
|
!ObjectUtils.isEmpty(param.get("imageUrl")) && |
|
|
|
|
param.get("imageUrl") instanceof String; |
|
|
|
|
!ObjectUtils.isEmpty(param.get("filePath")) && |
|
|
|
|
param.get("filePath") instanceof String; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|