diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index 115941d..ddb2451 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -63,11 +63,13 @@ public class ApiController { private TaskService taskService; @Value("${spring.profiles.active}") private String profiles; + @Value("${system.project.wlyCallback}") + private String wlyCallback; @ApiOperation(value = "通用识别") @RequestMapping("/identify") @Transactional @ResponseBody - @AutoLog(value = "api接口-通用识别",logType = CommonConstant.OPERATE_TYPE_1) + @AutoLog(value = "api接口-通用识别",logType = CommonConstant.LOG_TYPE_2,operateType=CommonConstant.OPERATE_TYPE_1) public Result pushSemantic(@RequestBody JSONObject requestBody) throws InterruptedException { // if (!"test".equals(profiles)) { // return Result.error("当前环境不支持该功能,请访问测试环境"); @@ -265,7 +267,7 @@ public class ApiController { Map configRuleMap = ocrRuleCheckVo.getConfigRuleMap();*/ OcrIdentifyDTO identifyDTO = ocrIdentifyService.findById("1702560400245035009"); List identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(identifyDTO.getId()); - CallBackWlyUtils.callbackWly(identifyDTO,identifyDetailList); + CallBackWlyUtils.callbackWly(wlyCallback,identifyDTO,identifyDetailList); return Result.OK(""); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index bf33cb6..c17560f 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -66,7 +66,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl identifyDetailList = ocrIdentifyDetailService.listByIdentifyId(ocrIdentifyId); ocrIdentifyCallbackLog.setStartTime(date); - boolean b = CallBackWlyUtils.callbackWly(ocrIdentify, identifyDetailList); + boolean b = CallBackWlyUtils.callbackWly(wlyCallback,ocrIdentify, identifyDetailList); ocrIdentifyCallbackLog.setStatus(b?1:0);//0-失败,1-成功 ocrIdentifyCallbackLog.setEndTime(new Date()); ocrIdentifyCallbackLogService.save(ocrIdentifyCallbackLog); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java index ce93a10..f18fc04 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/utils/CallBackWlyUtils.java @@ -27,27 +27,9 @@ import java.util.List; @Slf4j public class CallBackWlyUtils { - public static void main(String[] args) { - String taskResultInfo="[{\"failureReason\":\"\",\"inputText\":\"柳州市鱼峰区羊角山卫生院\",\"ocrPrecisionRate\":0.976898738386339,\"ocrText\":\"柳州市鱼峰区羊角山卫生院\",\"ruleValidation\":true,\"sourceImage\":{\"fileName\":\"5465539931838045.jpg\",\"path\":\"/nfs/ocr/shared_directory/78f6ba0bea8f4a1db9af6e3a4116c2a1/5465539931838045.jpg\",\"previewUrl\":\"http://47.103.213.109:8072/files/nfs/ocr/shared_directory/78f6ba0bea8f4a1db9af6e3a4116c2a1/5465539931838045.jpg\"},\"tag\":\"hospitalName\",\"tagName\":\"医院名称\",\"textRate\":100.0},{\"failureReason\":\"姓名未获取到结果\",\"inputText\":\"罗爱兰\",\"ocrPrecisionRate\":0.976898738386339,\"ruleValidation\":false,\"sourceImage\":{\"fileName\":\"5465539931838045.jpg\",\"path\":\"/nfs/ocr/shared_directory/78f6ba0bea8f4a1db9af6e3a4116c2a1/5465539931838045.jpg\",\"previewUrl\":\"http://47.103.213.109:8072/files/nfs/ocr/shared_directory/78f6ba0bea8f4a1db9af6e3a4116c2a1/5465539931838045.jpg\"},\"tag\":\"doctorName\",\"tagName\":\"姓名\",\"textRate\":0.0},{\"failureReason\":\"科室未获取到结果\",\"inputText\":\"全科\",\"ocrPrecisionRate\":0.976898738386339,\"ruleValidation\":false,\"sourceImage\":{\"fileName\":\"5465539931838045.jpg\",\"path\":\"/nfs/ocr/shared_directory/78f6ba0bea8f4a1db9af6e3a4116c2a1/5465539931838045.jpg\",\"previewUrl\":\"http://47.103.213.109:8072/files/nfs/ocr/shared_directory/78f6ba0bea8f4a1db9af6e3a4116c2a1/5465539931838045.jpg\"},\"tag\":\"departmentName\",\"tagName\":\"科室\",\"textRate\":0.0},{\"failureReason\":\"时间未获取到结果\",\"inputText\":\"2023-09-18\",\"ocrPrecisionRate\":0.976898738386339,\"ruleValidation\":false,\"sourceImage\":{\"fileName\":\"5465539931838045.jpg\",\"path\":\"/nfs/ocr/shared_directory/78f6ba0bea8f4a1db9af6e3a4116c2a1/5465539931838045.jpg\",\"previewUrl\":\"http://47.103.213.109:8072/files/nfs/ocr/shared_directory/78f6ba0bea8f4a1db9af6e3a4116c2a1/5465539931838045.jpg\"},\"tag\":\"time\",\"tagName\":\"时间\",\"textRate\":0.0}]"; - List taskResultInfoList = JSONArray.parseArray(taskResultInfo).toJavaList(JSONObject.class); - BigDecimal imageTagRetrievePercentage = new BigDecimal("0"); - for (JSONObject jsonObject : taskResultInfoList) { - Double ruleValidation = jsonObject.getDouble("textRate"); - if (ruleValidation!=null) { - BigDecimal bigDecimal = new BigDecimal(ruleValidation).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); - if(imageTagRetrievePercentage.compareTo(BigDecimal.ZERO)!=0){ - imageTagRetrievePercentage=imageTagRetrievePercentage.multiply(bigDecimal); - }else{ - imageTagRetrievePercentage=imageTagRetrievePercentage.add(bigDecimal); - } - } - } - imageTagRetrievePercentage = imageTagRetrievePercentage.multiply(new BigDecimal(100)); - System.out.println(imageTagRetrievePercentage); - } - public static boolean callbackWly(OcrIdentify ocrIdentify, List identifyDetails) { + public static boolean callbackWly(String url,OcrIdentify ocrIdentify, List identifyDetails) { String requestId = ocrIdentify.getRequestId(); log.info("数据准备:{}",requestId); //请求对象 @@ -111,10 +93,10 @@ public class CallBackWlyUtils { CallBackWlyRequestBody callBackWlyRequestBody = new CallBackWlyRequestBody(); callBackWlyRequestBody.setRequestId(requestId); callBackWlyRequestBody.setResult(result); - log.info("============================================="); - log.info(JSONObject.toJSONString(callBackWlyRequestBody)); - log.info("============================================="); - semanticResponseJson = RestUtil.post("https://192.168.1.100:8894/api/task/image/ocr/callback", JSONObject.parseObject(JSONObject.toJSONString(callBackWlyRequestBody, SerializerFeature.WriteNullStringAsEmpty))); + System.out.println("============================================="); + System.out.println(JSONObject.toJSONString(callBackWlyRequestBody)); + System.out.println("============================================="); + semanticResponseJson = RestUtil.post(url, JSONObject.parseObject(JSONObject.toJSONString(callBackWlyRequestBody, SerializerFeature.WriteNullStringAsEmpty))); } catch (org.springframework.web.client.ResourceAccessException e) { log.error("请求无量云回调接口失败-拒绝连接 (Connection refused)"); log.error(e.getMessage());