From 46fd7476c374b27171d7a1c4995c558ff12b4e24 Mon Sep 17 00:00:00 2001 From: liyawei Date: Thu, 3 Mar 2022 09:10:38 +0800 Subject: [PATCH] =?UTF-8?q?OCR=E8=AF=86=E5=88=AB-=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=A4=96=E9=83=A8=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jero-boot/jero-boot-module-system/pom.xml | 8 ++ .../FeignClient/LocalToolFeignClient.java | 20 +++++ .../com/jero/modules/system/vo/OcrVO.java | 85 +++++++++++++++++++ .../service/impl/OcrRestfulServiceImpl.java | 19 ++++- .../mapper/xml/SarFileSplitMenuEOMapper.xml | 26 +++--- 5 files changed, 142 insertions(+), 16 deletions(-) create mode 100644 jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/FeignClient/LocalToolFeignClient.java create mode 100644 jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/vo/OcrVO.java diff --git a/jero-boot/jero-boot-module-system/pom.xml b/jero-boot/jero-boot-module-system/pom.xml index d1ba0c229..2b4a19c1f 100644 --- a/jero-boot/jero-boot-module-system/pom.xml +++ b/jero-boot/jero-boot-module-system/pom.xml @@ -57,6 +57,14 @@ 1.1.8 + + + + + + org.springframework.cloud + spring-cloud-openfeign-core + diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/FeignClient/LocalToolFeignClient.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/FeignClient/LocalToolFeignClient.java new file mode 100644 index 000000000..c7414100e --- /dev/null +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/FeignClient/LocalToolFeignClient.java @@ -0,0 +1,20 @@ +package com.jero.modules.FeignClient; + +import com.jero.modules.system.vo.OcrVO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * @description + * @date 2021/12/8 14:53 + * @auth zhn + */ +@FeignClient(value = "local-tool") +public interface LocalToolFeignClient { + + @RequestMapping(value = "/local-tool/ocr/handleFile",method = RequestMethod.POST,headers = {"content-type=application/json"}) + ResponseEntity getFile(@RequestBody OcrVO ocrVO); +} diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/vo/OcrVO.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/vo/OcrVO.java new file mode 100644 index 000000000..0d24949c9 --- /dev/null +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/vo/OcrVO.java @@ -0,0 +1,85 @@ +package com.jero.modules.system.vo; + + +import java.io.Serializable; + +/** + * 功能:OCR_RECORD OcrRecordEOEntity
+ * 作者:code generator
+ * 日期: 2019-03-25
+ * 版权所有:版权归北京卡达克数据技术中心所有。
+ */ +public class OcrVO implements Serializable{ + private String restHandleFileUrl; + private String OcrUserId; + private String authCode; + private String convertType; + private String fileName; + private String fileContent; + private String taskId; + private String RestCallBackUrl; + + public String getRestHandleFileUrl() { + return restHandleFileUrl; + } + + public void setRestHandleFileUrl(String restHandleFileUrl) { + this.restHandleFileUrl = restHandleFileUrl; + } + + public String getOcrUserId() { + return OcrUserId; + } + + public void setOcrUserId(String ocrUserId) { + OcrUserId = ocrUserId; + } + + public String getAuthCode() { + return authCode; + } + + public void setAuthCode(String authCode) { + this.authCode = authCode; + } + + public String getConvertType() { + return convertType; + } + + public void setConvertType(String convertType) { + this.convertType = convertType; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFileContent() { + return fileContent; + } + + public void setFileContent(String fileContent) { + this.fileContent = fileContent; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getRestCallBackUrl() { + return RestCallBackUrl; + } + + public void setRestCallBackUrl(String restCallBackUrl) { + RestCallBackUrl = restCallBackUrl; + } +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/impl/OcrRestfulServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/impl/OcrRestfulServiceImpl.java index 9470b6d26..b6f297e14 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/impl/OcrRestfulServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/ocr/service/impl/OcrRestfulServiceImpl.java @@ -2,17 +2,17 @@ package com.jero.modules.ocr.service.impl; import com.alibaba.fastjson.JSONObject; import com.jero.common.api.vo.Result; -import com.jero.common.system.vo.LoginUser; +import com.jero.modules.FeignClient.LocalToolFeignClient; import com.jero.modules.ocr.entity.OcrRecordEO; import com.jero.modules.ocr.entity.OcrResultEO; import com.jero.modules.ocr.service.IOcrRecordEOService; import com.jero.modules.ocr.service.IOcrRestfulService; import com.jero.modules.ocr.util.Base64Util; import com.jero.modules.ocr.util.RsaUtil; +import com.jero.modules.system.vo.OcrVO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; @@ -46,6 +46,8 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { @Autowired private RestTemplate restTemplate; + @Autowired + private LocalToolFeignClient localToolFeignClient; @Autowired private IOcrRecordEOService ocrRecordEOService; @@ -113,7 +115,18 @@ public class OcrRestfulServiceImpl implements IOcrRestfulService { SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); log.info("处理完文件数据,开始请求OCR接口数据:【"+sdf.format(new Date())+"】"); try{ - ResponseEntity responseEntity = restTemplate.postForEntity(RestHandleFileUrl, httpEntity, String.class); +// ResponseEntity responseEntity = restTemplate.postForEntity(RestHandleFileUrl, httpEntity, String.class); + OcrVO ocrVO = new OcrVO(); + ocrVO.setRestHandleFileUrl(RestHandleFileUrl); + ocrVO.setOcrUserId(OcrUserId); + ocrVO.setAuthCode(authCode); + ocrVO.setConvertType(convertType); + ocrVO.setFileName(fileName); + ocrVO.setFileContent(fileContent); + ocrVO.setTaskId(taskId); + ocrVO.setRestCallBackUrl(RestCallBackUrl); + ResponseEntity responseEntity = localToolFeignClient.getFile(ocrVO); + log.info("请求OCR接口完毕,返回响应状态:【"+sdf.format(new Date())+"】"); HttpStatus statusCode = responseEntity.getStatusCode(); if(statusCode != HttpStatus.OK){ diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/mapper/xml/SarFileSplitMenuEOMapper.xml b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/mapper/xml/SarFileSplitMenuEOMapper.xml index 7b3c4ae2d..74b82cfc7 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/mapper/xml/SarFileSplitMenuEOMapper.xml +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/mapper/xml/SarFileSplitMenuEOMapper.xml @@ -19,7 +19,7 @@ - id, info_id, name, p_id, display_seq, valid_flag, creation_time, modify_time, remarks, creation_user, modify_user,item_name + id, info_id, name, parent_id, display_seq, valid_flag, creation_time, modify_time, remarks, creation_user, modify_user,item_name @@ -36,7 +36,7 @@ and name ${nameOperator} #{name} - and p_id ${pIdOperator} #{pId} + and parent_id ${pIdOperator} #{pId} and display_seq ${displaySeqOperator} #{displaySeq} @@ -93,7 +93,7 @@ id, info_id, name, - p_id, + parent_id, display_seq, valid_flag, creation_time, @@ -124,7 +124,7 @@ update SAR_FILE_SPLIT_MENU set info_id = #{infoId}, name = #{name}, - p_id = #{pId}, + parent_id = #{pId}, display_seq = #{displaySeq}, valid_flag = #{validFlag}, creation_time = #{creationTime}, @@ -146,7 +146,7 @@ name = #{name}, - p_id = #{pId}, + parent_id = #{pId}, display_seq = #{displaySeq}, @@ -265,29 +265,29 @@ delete from SAR_FILE_SPLIT_MENU where id in ( - select id from SAR_FILE_SPLIT_MENU start with id=#{id} connect by prior id= p_id + select id from SAR_FILE_SPLIT_MENU start with id=#{id} connect by prior id= parent_id ) @@ -296,7 +296,7 @@ modify_time = #{modifyTime}, modify_user = #{modifyUser} where id in ( SELECT id FROM - SAR_FILE_SPLIT_MENU START WITH id = #{id} CONNECT BY PRIOR id = p_id) + SAR_FILE_SPLIT_MENU START WITH id = #{id} CONNECT BY PRIOR id = parent_id) @@ -305,13 +305,13 @@ modify_time = #{modifyTime}, modify_user = #{modifyUser} where id in ( SELECT id FROM - SAR_FILE_SPLIT_MENU START WITH id = #{id} CONNECT BY PRIOR id = p_id) + SAR_FILE_SPLIT_MENU START WITH id = #{id} CONNECT BY PRIOR id = parent_id)