OCR识别-调用外部服务
This commit is contained in:
@@ -57,6 +57,14 @@
|
||||
<version>1.1.8</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-netflix-core</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-openfeign-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
+20
@@ -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<String> getFile(@RequestBody OcrVO ocrVO);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.jero.modules.system.vo;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <b>功能:</b>OCR_RECORD OcrRecordEOEntity<br>
|
||||
* <b>作者:</b>code generator<br>
|
||||
* <b>日期:</b> 2019-03-25 <br>
|
||||
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
+16
-3
@@ -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<String> responseEntity = restTemplate.postForEntity(RestHandleFileUrl, httpEntity, String.class);
|
||||
// ResponseEntity<String> 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<String> responseEntity = localToolFeignClient.getFile(ocrVO);
|
||||
|
||||
log.info("请求OCR接口完毕,返回响应状态:【"+sdf.format(new Date())+"】");
|
||||
HttpStatus statusCode = responseEntity.getStatusCode();
|
||||
if(statusCode != HttpStatus.OK){
|
||||
|
||||
+13
-13
@@ -19,7 +19,7 @@
|
||||
|
||||
<!-- SAR_FILE_SPLIT_MENU table all fields -->
|
||||
<sql id="Base_Column_List" >
|
||||
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
|
||||
</sql>
|
||||
|
||||
<!-- 查询条件 -->
|
||||
@@ -36,7 +36,7 @@
|
||||
and name ${nameOperator} #{name}
|
||||
</if>
|
||||
<if test="pId != null" >
|
||||
and p_id ${pIdOperator} #{pId}
|
||||
and parent_id ${pIdOperator} #{pId}
|
||||
</if>
|
||||
<if test="displaySeq != null" >
|
||||
and display_seq ${displaySeqOperator} #{displaySeq}
|
||||
@@ -93,7 +93,7 @@
|
||||
<if test="id != null" >id,</if>
|
||||
<if test="infoId != null" >info_id,</if>
|
||||
<if test="name != null" >name,</if>
|
||||
<if test="pId != null" >p_id,</if>
|
||||
<if test="pId != null" >parent_id,</if>
|
||||
<if test="displaySeq != null" >display_seq,</if>
|
||||
<if test="validFlag != null" >valid_flag,</if>
|
||||
<if test="creationTime != null" >creation_time,</if>
|
||||
@@ -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},
|
||||
</if>
|
||||
<if test="pId != null" >
|
||||
p_id = #{pId},
|
||||
parent_id = #{pId},
|
||||
</if>
|
||||
<if test="displaySeq != null" >
|
||||
display_seq = #{displaySeq},
|
||||
@@ -265,29 +265,29 @@
|
||||
<select id="queryByPidExcpetSelf" resultMap="BaseResultMap" parameterType="com.jero.modules.split.entity.SarFileSplitMenuEO">
|
||||
select SAR_FILE_SPLIT_MENU.* from SAR_FILE_SPLIT_MENU
|
||||
where valid_flag=0 and id != #{id}
|
||||
start with id=#{id} connect by prior id= p_id
|
||||
start with id=#{id} connect by prior id= parent_id
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPId" parameterType="java.lang.String">
|
||||
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
|
||||
)
|
||||
|
||||
</delete>
|
||||
|
||||
<select id="getMaxDisplayByid" resultType="java.lang.Integer" parameterType="com.jero.modules.split.common.BasePage">
|
||||
SELECT max(SAR_FILE_SPLIT_MENU.DISPLAY_SEQ) 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
|
||||
</select>
|
||||
|
||||
<select id="getMaxDisplayByidNextLevel" resultType="java.lang.Integer" parameterType="java.lang.String">
|
||||
SELECT max(SAR_FILE_SPLIT_MENU.DISPLAY_SEQ) FROM
|
||||
SAR_FILE_SPLIT_MENU where P_ID = #{id}
|
||||
SAR_FILE_SPLIT_MENU where parent_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getChildrenCountByParentId" resultType="java.lang.Integer" parameterType="com.jero.modules.split.common.BasePage">
|
||||
SELECT count(*) 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
|
||||
</select>
|
||||
|
||||
<update id="updateChildrenDisplaySeqByIDAdd" parameterType="com.jero.modules.split.entity.SarFileSplitMenuEO" >
|
||||
@@ -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)
|
||||
</update>
|
||||
|
||||
<update id="updateChildrenDisplaySeqByIDCut" parameterType="com.jero.modules.split.entity.SarFileSplitMenuEO" >
|
||||
@@ -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)
|
||||
</update>
|
||||
|
||||
<select id="queryAllChildrenByid" resultMap="BaseResultMap" parameterType="com.jero.modules.split.entity.SarFileSplitMenuEO">
|
||||
select SAR_FILE_SPLIT_MENU.* from SAR_FILE_SPLIT_MENU
|
||||
where valid_flag=0
|
||||
start with id=#{id} connect by prior id= p_id
|
||||
start with id=#{id} connect by prior id= parent_id
|
||||
</select>
|
||||
|
||||
<delete id="deleteByIdList" parameterType="java.util.List">
|
||||
|
||||
Reference in New Issue
Block a user