feat(本地工具): OCR识别

This commit is contained in:
yjz
2024-06-03 14:45:45 +08:00
parent f850aa3091
commit 02ec24e0d1
27 changed files with 2739 additions and 1 deletions
+7 -1
View File
@@ -178,5 +178,11 @@
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
</dependency>-->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.56</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
</project>
File diff suppressed because one or more lines are too long
@@ -0,0 +1,77 @@
package com.jero.modules.laws.ocr;
import java.security.MessageDigest;
/**
* 采用MD5加密解密
* @author tfq
* @datetime 2011-10-13
*/
public class MD5Util {
/***
* MD5加码 生成32位md5码
*/
public static String string2MD5(String inStr){
MessageDigest md5 = null;
try{
md5 = MessageDigest.getInstance("MD5");
}catch (Exception e){
System.out.println(e.toString());
e.printStackTrace();
return "";
}
char[] charArray = inStr.toCharArray();
byte[] byteArray = new byte[charArray.length];
for (int i = 0; i < charArray.length; i++)
byteArray[i] = (byte) charArray[i];
byte[] md5Bytes = md5.digest(byteArray);
StringBuffer hexValue = new StringBuffer();
for (int i = 0; i < md5Bytes.length; i++){
int val = ((int) md5Bytes[i]) & 0xff;
if (val < 16)
hexValue.append("0");
hexValue.append(Integer.toHexString(val));
}
return hexValue.toString();
}
/**
* 加密解密算法 执行一次加密,两次解密
*/
public static String convertMD5(String inStr){
char[] a = inStr.toCharArray();
for (int i = 0; i < a.length; i++){
a[i] = (char) (a[i] ^ 't');
}
String s = new String(a);
return s;
}
// 测试主函数
public static void main(String args[]) {
/* String s = new String("tangfuqiang");
System.out.println("原始:" + s);
System.out.println("MD5后:" + string2MD5(s));
System.out.println("加密的:" + convertMD5(s));
System.out.println("解密的:" + convertMD5(convertMD5(s)));*/
// String fileId = "ATT_FILE_07_JLBUTUSFXDRUKTVX5BT5";
// String key = "dufy20170329java";
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH");
// String time = df.format(new Date());
// String sign = fileId + time + key;
String str="GVJ3EZKW6NTK6Z5U92QE"+"EC4KKA6ZDTCPAOCRBC5M";
String key="ecd2c0791b398882310c4edcc1eee42b";
String entoryStr = string2MD5(str);
System.out.println(entoryStr);
System.out.println(key);
}
}
@@ -0,0 +1,193 @@
package com.jero.modules.laws.ocr;
import okhttp3.*;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.Iterator;
import java.util.Map;
/**
*
* @author David
*/
@Component
public class OkHttpUtil {
private static final Logger logger = LoggerFactory.getLogger(OkHttpUtil.class);
@Autowired
private OkHttpClient okHttpClient;
/**
* get
*
* @param url 请求的url
* @param queries 请求的参数,在浏览器?后面的数据,没有可以传null
* @return
*/
public String get(String url, Map<String, String> queries, Map<String, String> headerParams) {
String responseBody = "";
StringBuffer sb = new StringBuffer(url);
if (queries != null && queries.keySet().size() > 0) {
boolean firstFlag = true;
Iterator iterator = queries.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry<String, String>) iterator.next();
if (firstFlag) {
sb.append("?" + entry.getKey() + "=" + entry.getValue());
firstFlag = false;
} else {
sb.append("&" + entry.getKey() + "=" + entry.getValue());
}
}
}
Request.Builder requestBuilder = new Request.Builder().url(url);
if(headerParams != null){
for(Map.Entry<String, String> entry : headerParams.entrySet()) {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
}
Request request = requestBuilder.url(sb.toString())
.build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
int status = response.code();
if (status == 200) {
return response.body().string();
}
} catch (Exception e) {
logger.error("okhttp put error >> ex = {}", ExceptionUtils.getStackTrace(e));
} finally {
if (response != null) {
response.close();
}
}
return responseBody;
}
/**
* post
*
* @param url 请求的url
* @param params post form 提交的参数
* @return
*/
public String post(String url, Map<String, String> params, Map<String, String> headerParams) {
String responseBody = "";
FormBody.Builder builder = new FormBody.Builder();
//添加参数
if (params != null && params.keySet().size() > 0) {
for (String key : params.keySet()) {
builder.add(key, params.get(key));
}
}
Request.Builder requestBuilder = new Request.Builder().url(url);
for(Map.Entry<String, String> entry : headerParams.entrySet()) {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
Request request = requestBuilder.post(builder.build()).build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
int status = response.code();
if (status == 200) {
return response.body().string();
}
} catch (Exception e) {
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
} finally {
if (response != null) {
response.close();
}
}
return responseBody;
}
/**
* post
*
* @param url 请求的url
* @param params post form 提交的参数
* @return
*/
public String postForJson(String url, String json, Map<String, String> headerParams) {
RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), json);
String responseBody = "";
Request.Builder requestBuilder = new Request.Builder().url(url);
for(Map.Entry<String, String> entry : headerParams.entrySet()) {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
Request request = requestBuilder.post(requestBody).build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
int status = response.code();
if (status == 200) {
return response.body().string();
}
} catch (Exception e) {
logger.error("okhttp post error >> ex = {}", ExceptionUtils.getStackTrace(e));
} finally {
if (response != null) {
response.close();
}
}
return responseBody;
}
/**
* post 上传文件
*
* @param url
* @param params
* @param fileType
* @return
*/
public String postFile(String url, Map<String, Object> params, String fileType, Map<String, String> headerParams) {
String responseBody = "";
MultipartBody.Builder builder = new MultipartBody.Builder();
//添加参数
if (params != null && params.keySet().size() > 0) {
for (String key : params.keySet()) {
if (params.get(key) instanceof File) {
File file = (File) params.get(key);
builder.addFormDataPart(key, file.getName(), RequestBody.create(MediaType.parse(fileType), file));
continue;
}
builder.addFormDataPart(key, params.get(key).toString());
}
}
Request.Builder requestBuilder = new Request.Builder();
for(Map.Entry<String, String> entry : headerParams.entrySet()) {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
Request request = requestBuilder.url(url).post(builder.build()).build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
int status = response.code();
if (status == 200) {
return response.body().string();
}
} catch (Exception e) {
logger.error("okhttp postFile error >> ex = {}", ExceptionUtils.getStackTrace(e));
} finally {
if (response != null) {
response.close();
}
}
return responseBody;
}
}
@@ -0,0 +1,132 @@
package com.jero.modules.laws.ocr;
import com.aliyuncs.utils.IOUtils;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.crypto.params.RSAKeyParameters;
import org.bouncycastle.crypto.util.SubjectPublicKeyInfoFactory;
import org.bouncycastle.util.encoders.Base64;
import org.dom4j.DocumentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
/**
* @program: OcrDemo
* @description: rsa加密解密
* @author: duyunbao
* @create: 2019-03-14 19:54
*/
public class RsaUtil {
private static final Logger logger = LoggerFactory.getLogger(RsaUtil.class);
public static final String CHARSET = "UTF-8";
public static final String RSA_ALGORITHM = "RSA";
/// RSA公钥格式转换,.net->java
public static String RSAPublicKeyDotNet2Java() throws IOException, DocumentException {
/* SAXReader reader = new SAXReader();
Document document = reader.read(new File("../../../resources/rsa/publicRSAXML.xml"));
Element root = document.getRootElement();
Element ModulusElem = root.element("Modulus");
Element ExponentElem = root.element("Exponent");
BigInteger m = new BigInteger(1, Base64.decode(ModulusElem.elements().get(0).getData().toString()));
BigInteger p = new BigInteger(1, Base64.decode(ExponentElem.elements().get(0).getData().toString()));*/
BigInteger m = new BigInteger(1, Base64.decode("ncJeLmq4CT6t07x1Ct8LJn8/h6vPaSoySEcirRxAfFS7uoxxaWTyQE3khA4idvwky2ZrLtZjqVCFWRlHADKB5OCbRsVxvQv7kAR3VASJnCUtXH1lm+5zF9vxcw20ISfqEYUwikMDDogbVyLzNjwU/7ZfzzNY5lG+KsZxV8tuOE8="));
BigInteger p = new BigInteger(1, Base64.decode("AQAB"));
RSAKeyParameters pub = new RSAKeyParameters(false, m, p);
SubjectPublicKeyInfo publicKeyInfo = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(pub);
byte[] serializedPublicBytes = publicKeyInfo.toASN1Primitive().getEncoded();
return Base64.toBase64String(serializedPublicBytes);
}
/**
}
* 得到公钥
* @param publicKey 密钥字符串(经过base64编码)
* @throws Exception
*/
public static RSAPublicKey getPublicKey(String publicKey) throws NoSuchAlgorithmException, InvalidKeySpecException {
// 通过X509编码的Key指令获得公钥对象
KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM);
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(Base64.decode(publicKey));
RSAPublicKey key = (RSAPublicKey) keyFactory.generatePublic(x509KeySpec);
return key;
}
/**
* 公钥加密
* @param data
* @return
*/
public static String publicEncrypt(String data) {
RSAPublicKey publicKey = null;
try {
publicKey = getPublicKey(RSAPublicKeyDotNet2Java());
}catch (Exception e){
logger.error(e.getMessage(),e);
return null;
}
try {
Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
return Base64.toBase64String(rsaSplitCodec(cipher, Cipher.ENCRYPT_MODE, data.getBytes(CHARSET),
publicKey.getModulus().bitLength()));
} catch (Exception e) {
logger.error("加密字符串[" + data + "]时遇到异常",e);
return null;
}
}
private static byte[] rsaSplitCodec(Cipher cipher, int opmode, byte[] datas, int keySize) {
int maxBlock = 0;
if (opmode == Cipher.DECRYPT_MODE) {
maxBlock = keySize / 8;
} else {
maxBlock = keySize / 8 - 11;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] buff;
int i = 0;
try {
while (datas.length > offSet) {
if (datas.length - offSet > maxBlock) {
buff = cipher.doFinal(datas, offSet, maxBlock);
} else {
buff = cipher.doFinal(datas, offSet, datas.length - offSet);
}
out.write(buff, 0, buff.length);
i++;
offSet = i * maxBlock;
}
} catch (Exception e) {
logger.error("加解密阀值为[" + maxBlock + "]的数据时发生异常",e);
}
byte[] resultDatas = out.toByteArray();
IOUtils.closeQuietly(out);
return resultDatas;
}
}
@@ -0,0 +1,40 @@
package com.jero.modules.laws.ocr;
import com.jero.common.util.RandomUtils;
import java.util.Random;
public class UUIDUtils {
public static String randomUUID10() {
return RandomUtils.randomString(10);
}
public static String randomUUID20() {
return RandomUtils.randomString(20);
}
public static String randomUUID(int length) {
return RandomUtils.randomString(length);
}
public static String getUUIDPath(String uuid){
StringBuilder builder=new StringBuilder();
builder.append("/");
builder.append((uuid.substring(0, 3).hashCode())%100+"").append("/");
builder.append((uuid.substring(7,10).hashCode())%100+"").append("/");
builder.append((uuid.substring(11,14).hashCode())%100+"").append("/");
return builder.toString();
}
public static String getAttTable(){
Random rand = new Random();
int nextInt = rand.nextInt(10)+1;
StringBuilder builder=new StringBuilder();
builder.append("ATT_FILE_").append(String.format("%02d", nextInt));
return builder.toString();
}
}
@@ -0,0 +1,69 @@
package com.jero.modules.laws.ocr.config;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.concurrent.TimeUnit;
@Configuration
public class OkHttpConfig {
@Bean
public X509TrustManager x509TrustManager() {
return new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
};
}
@Bean
public SSLSocketFactory sslSocketFactory() {
try {
//信任任何链接
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom());
return sslContext.getSocketFactory();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
return null;
}
/**
* Create a new connection pool with tuning parameters appropriate for a single-user application.
* The tuning parameters in this pool are subject to change in future OkHttp releases. Currently
*/
@Bean
public ConnectionPool pool() {
return new ConnectionPool(200, 5, TimeUnit.MINUTES);
}
@Bean
public OkHttpClient okHttpClient() {
return new OkHttpClient.Builder()
.sslSocketFactory(sslSocketFactory(), x509TrustManager())
.retryOnConnectionFailure(false)//是否开启缓存
.connectionPool(pool())//连接池
.connectTimeout(10L, TimeUnit.SECONDS)
.readTimeout(10L, TimeUnit.SECONDS)
.build();
}
}
@@ -0,0 +1,181 @@
package com.jero.modules.laws.ocr.controller;
import com.alibaba.fastjson.JSON;
import com.jero.modules.laws.ocr.MD5Util;
import com.jero.modules.laws.ocr.entity.OcrCallBackResultEo;
import com.jero.modules.laws.ocr.entity.OcrRecordEO;
import com.jero.modules.laws.ocr.http.PageInfo;
import com.jero.modules.laws.ocr.http.ResponseMessage;
import com.jero.modules.laws.ocr.http.Result;
import com.jero.modules.laws.ocr.page.OcrRecordEOPage;
import com.jero.modules.laws.ocr.service.OCRRestfulService;
import com.jero.modules.laws.ocr.service.OcrRecordEOService;
import com.jero.modules.laws.ocr.web.BaseController;
import com.jero.modules.onlyoffice.entity.AttFileEO;
import com.jero.modules.onlyoffice.service.IAttFileEOService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.apache.http.entity.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileInputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @program: OcrDemo
* @description: ocr接口对接类
* @author: duyunbao
* @create: 2019-03-13 18:21
*/
@RestController
@RequestMapping("/laws/ocr/OCRRestful")
@Api(description = "|OCR识别 |")
public class OCRRestfulController extends BaseController<OcrRecordEO> {
private static final Logger logger = LoggerFactory.getLogger(OCRRestfulController.class);
@Autowired
private OCRRestfulService ocrRestfulService;
@Autowired
private OcrRecordEOService ocrRecordEOService;
@Autowired
private IAttFileEOService attFileEOService;
//接口回调公钥
@Value("${OCR.publicKey}")
private String OcrPublicKey;
@Value("${OCR.ocrDownPath}")
private String ocrDownPath;
@Value("${file.path}")
private String filePath;//文件存储路径
@ApiOperation(value = "请求ocr")
@PostMapping(value="/upload",consumes="multipart/*",headers="content-type=multipart/form-data" )
public ResponseMessage<String> handleFile(@RequestParam("file") MultipartFile file) throws Exception {
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
logger.info("收到文件上传请求,开始处理文件:【"+sdf.format(new Date())+"");
return ocrRestfulService.handleFile(file,file.getOriginalFilename(),null,"add");
}
@ApiOperation(value = "ocr回调")
@PostMapping("/OcrHandleResult")
public String OcrHandleResult(@RequestParam("wordFile") MultipartFile wordFile,@RequestParam("jsonFile") MultipartFile jsonFile, OcrCallBackResultEo ocrCallBackResultEo) {
try{
logger.info("调取到我了");
logger.info("接口回调结果:"+ JSON.toJSONString(ocrCallBackResultEo));
logger.info("接口回调时所传文件---wordFile:"+ wordFile.toString() +"; jsonFile:"+jsonFile.toString());
if("error".equals(ocrCallBackResultEo.getResult())){
logger.info("客户接口处理文件失败");
ocrRestfulService.updateDb(ocrCallBackResultEo.getTaskID(),"客户接口处理文件失败");
return "{\"result\":\"error\"}";
}
//1.验证 key 是否符合,不符合打回,符合继续
//2.向后传递文件
String key = ocrCallBackResultEo.getKey();
String sign = ocrCallBackResultEo.getTaskID() + OcrPublicKey;
String signMD5 = MD5Util.string2MD5(sign);
if(!signMD5.equals(key)){
//不同,则认证失败
logger.info("认证失败");
ocrRestfulService.updateDb(ocrCallBackResultEo.getTaskID(),"回调接口认证失败");
return "{\"result\":\"Authentication failed\"}";
}
return ocrRestfulService.OcrHandleResult(wordFile,jsonFile,ocrCallBackResultEo.getTaskID());
}catch (Exception e){
logger.error(e.getMessage(),e);
return "{\"result\":\"runTimeException\"}";
}
}
@ApiOperation(value = "获取所有ocr结果")
@PostMapping("/getAllOcrResult")
public ResponseMessage<PageInfo<OcrRecordEO>> page(OcrRecordEOPage page) throws Exception {
if(org.apache.commons.lang3.StringUtils.isNotBlank(page.getPaixu()) && org.apache.commons.lang3.StringUtils.isNotBlank(page.getShunxu())){
String sql = page.getPaixu()+" "+page.getShunxu();
page.setSql(sql);
}else{
page.setOrderBy("creation_time");
page.setOrder("desc");
}
List<OcrRecordEO> rows = ocrRecordEOService.queryByPage(page);
Integer integer = ocrRecordEOService.queryByPageCount(page);
DecimalFormat df = new DecimalFormat("0.00");//设置保留位数
for (OcrRecordEO ocrRecordEO : rows){
ocrRecordEO.setDocRealFile(ocrDownPath+ocrRecordEO.getDocRealName());
ocrRecordEO.setJsonRealFile(ocrDownPath+ocrRecordEO.getJsonRealName());
}
page.getPager().setRowCount(integer);
return Result.success(getPageInfo(page.getPager(), rows));
}
@ApiOperation(value = "新增ocr内容")
@PostMapping("/addOcrRecord")
public ResponseMessage<OcrRecordEO> addOcrRecord(OcrRecordEO ocrRecordEO) throws Exception {
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
logger.info("收到文件上传请求,开始处理文件:【"+sdf.format(new Date())+"");
// 根据attID查找文件
String fileId = ocrRecordEO.getAttId();
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
if (attFileEO != null) {
String fileOriPath = filePath + attFileEO.getFilePath();
String oriName = attFileEO.getOldFileName();
File pdfFile = new File(fileOriPath+attFileEO.getFileName());
FileInputStream fileInputStream = new FileInputStream(pdfFile);
MultipartFile multipartFile = new MockMultipartFile(oriName, oriName,
ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
return ocrRestfulService.handleFile(multipartFile,multipartFile.getOriginalFilename(),ocrRecordEO,"add");
} else {
return Result.error("0","无法找到该文件",null);
}
}
@ApiOperation(value = "修改ocr内容")
@PutMapping("/updateOcrRecord")
public ResponseMessage<OcrRecordEO> updateOcrRecord(@RequestBody OcrRecordEO ocrRecordEO) throws Exception {
if (StringUtils.isEmpty(ocrRecordEO.getAttId())) {
ocrRecordEOService.updateByPrimaryKeySelective(ocrRecordEO);
return Result.success("0","保存成功",ocrRecordEO);
} else {
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
logger.info("收到文件上传请求,开始处理文件:【"+sdf.format(new Date())+"");
// 根据attID查找文件
String fileId = ocrRecordEO.getAttId();
AttFileEO attFileEO = attFileEOService.getFileInfo(fileId);
if (attFileEO != null) {
String fileOriPath = filePath + attFileEO.getFilePath();
String oriName = attFileEO.getOldFileName();
File pdfFile = new File(fileOriPath+attFileEO.getFileName());
FileInputStream fileInputStream = new FileInputStream(pdfFile);
MultipartFile multipartFile = new MockMultipartFile(oriName, oriName,
ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
return ocrRestfulService.handleFile(multipartFile,multipartFile.getOriginalFilename(),ocrRecordEO,"update");
} else {
return Result.error("0","无法找到该文件",null);
}
}
}
@ApiOperation(value = "删除ocr内容")
@DeleteMapping("/deleteOcrRecord")
public ResponseMessage deleteOcrRecord(String ids) throws Exception {
if (StringUtils.isNotEmpty(ids)) {
String[] idArr = ids.split(",");
List<String> idList = Arrays.asList(idArr);
int i = ocrRecordEOService.deleteByIds(idList);
return Result.success("0","删除成功",i);
} else {
return Result.error("删除数据不能为空");
}
}
}
@@ -0,0 +1,6 @@
package com.jero.modules.laws.ocr.entity;
public class BaseEntity {
public BaseEntity() {
}
}
@@ -0,0 +1,76 @@
package com.jero.modules.laws.ocr.entity;
/**
* @program: OcrDemo
* @description: orc调取回调函数的参数
* @author: duyunbao
* @create: 2019-03-13 16:14
*/
public class OcrCallBackResultEo {
private String result ;
private String taskID ;
// private String wordFileName;
// private String wordFileContent;
// private String jsonFileName;
// private String jsonFileContent;
private String key;
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getTaskID() {
return taskID;
}
public void setTaskID(String taskID) {
this.taskID = taskID;
}
//
// public String getWordFileName() {
// return wordFileName;
// }
//
// public void setWordFileName(String wordFileName) {
// this.wordFileName = wordFileName;
// }
//
// public String getWordFileContent() {
// return wordFileContent;
// }
//
// public void setWordFileContent(String wordFileContent) {
// this.wordFileContent = wordFileContent;
// }
//
// public String getJsonFileName() {
// return jsonFileName;
// }
//
// public void setJsonFileName(String jsonFileName) {
// this.jsonFileName = jsonFileName;
// }
// public String getJsonFileContent() {
// return jsonFileContent;
// }
//
// public void setJsonFileContent(String jsonFileContent) {
// this.jsonFileContent = jsonFileContent;
// }
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
@@ -0,0 +1,278 @@
package com.jero.modules.laws.ocr.entity;
import java.io.Serializable;
import java.util.Date;
/**
* <b>功能:</b>OCR_RECORD OcrRecordEOEntity<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2019-03-25 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
public class OcrRecordEO extends BaseEntity implements Serializable{
private static final long serialVersionUID = -5464438392516276473L;
private Object wordFileCode;
private Object jsonFileCode;
private String id;
private String docRealName;
private String jsonRealName;
private String fileName;
private String docName;
private String jsonName;
@org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date creationTime;
@org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date modifyTime;
private String docRealFile;
private String jsonRealFile;
//计算文件转换耗费时间
private String spendTime;
//转换结果
private String resultContent;
//新增字段
private String fileType;
private String standNumber;
private String standName;
private String creationUser;
private String attId;
/**
* java字段名转换为原始数据库列名。<b>如果不存在则返回null</b><br>
* <p>字段列表:</p>
* <li>wordFileCode -> word_file_code</li>
* <li>jsonFileCode -> json_file_code</li>
* <li>id -> id</li>
* <li>docRealName -> doc_real_name</li>
* <li>jsonRealName -> json_real_name</li>
* <li>fileName -> file_name</li>
* <li>docName -> doc_name</li>
* <li>jsonName -> json_name</li>
* <li>creationTime -> creation_time</li>
* <li>modifyTime -> modify_time</li>
*/
public static String fieldToColumn(String fieldName) {
if (fieldName == null) return null;
switch (fieldName) {
case "wordFileCode": return "word_file_code";
case "jsonFileCode": return "json_file_code";
case "id": return "id";
case "docRealName": return "doc_real_name";
case "jsonRealName": return "json_real_name";
case "fileName": return "file_name";
case "docName": return "doc_name";
case "jsonName": return "json_name";
case "creationTime": return "creation_time";
case "modifyTime": return "modify_time";
default: return null;
}
}
/**
* 原始数据库列名转换为java字段名。<b>如果不存在则返回null</b><br>
* <p>字段列表:</p>
* <li>word_file_code -> wordFileCode</li>
* <li>json_file_code -> jsonFileCode</li>
* <li>id -> id</li>
* <li>doc_real_name -> docRealName</li>
* <li>json_real_name -> jsonRealName</li>
* <li>file_name -> fileName</li>
* <li>doc_name -> docName</li>
* <li>json_name -> jsonName</li>
* <li>creation_time -> creationTime</li>
* <li>modify_time -> modifyTime</li>
*/
public static String columnToField(String columnName) {
if (columnName == null) return null;
switch (columnName) {
case "word_file_code": return "wordFileCode";
case "json_file_code": return "jsonFileCode";
case "id": return "id";
case "doc_real_name": return "docRealName";
case "json_real_name": return "jsonRealName";
case "file_name": return "fileName";
case "doc_name": return "docName";
case "json_name": return "jsonName";
case "creation_time": return "creationTime";
case "modify_time": return "modifyTime";
default: return null;
}
}
/** **/
public Object getWordFileCode() {
return this.wordFileCode;
}
/** **/
public void setWordFileCode(Object wordFileCode) {
this.wordFileCode = wordFileCode;
}
/** **/
public Object getJsonFileCode() {
return this.jsonFileCode;
}
/** **/
public void setJsonFileCode(Object jsonFileCode) {
this.jsonFileCode = jsonFileCode;
}
/** **/
public String getId() {
return this.id;
}
/** **/
public void setId(String id) {
this.id = id;
}
/** **/
public String getDocRealName() {
return this.docRealName;
}
/** **/
public void setDocRealName(String docRealName) {
this.docRealName = docRealName;
}
/** **/
public String getJsonRealName() {
return this.jsonRealName;
}
/** **/
public void setJsonRealName(String jsonRealName) {
this.jsonRealName = jsonRealName;
}
/** **/
public String getFileName() {
return this.fileName;
}
/** **/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/** **/
public String getDocName() {
return this.docName;
}
/** **/
public void setDocName(String docName) {
this.docName = docName;
}
/** **/
public String getJsonName() {
return this.jsonName;
}
/** **/
public void setJsonName(String jsonName) {
this.jsonName = jsonName;
}
/** **/
public Date getCreationTime() {
return this.creationTime;
}
/** **/
public void setCreationTime(Date creationTime) {
this.creationTime = creationTime;
}
/** **/
public Date getModifyTime() {
return this.modifyTime;
}
/** **/
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getDocRealFile() {
return docRealFile;
}
public void setDocRealFile(String docRealFile) {
this.docRealFile = docRealFile;
}
public String getJsonRealFile() {
return jsonRealFile;
}
public void setJsonRealFile(String jsonRealFile) {
this.jsonRealFile = jsonRealFile;
}
public String getSpendTime() {
return spendTime;
}
public void setSpendTime(String spendTime) {
this.spendTime = spendTime;
}
public String getResultContent() {
return resultContent;
}
public void setResultContent(String resultContent) {
this.resultContent = resultContent;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getStandNumber() {
return standNumber;
}
public void setStandNumber(String standNumber) {
this.standNumber = standNumber;
}
public String getStandName() {
return standName;
}
public void setStandName(String standName) {
this.standName = standName;
}
public String getCreationUser() {
return creationUser;
}
public void setCreationUser(String creationUser) {
this.creationUser = creationUser;
}
public String getAttId() {
return attId;
}
public void setAttId(String attId) {
this.attId = attId;
}
}
@@ -0,0 +1,83 @@
package com.jero.modules.laws.ocr.entity;
/**
* @program: OcrDemo
* @description: ocr接口请求实体类
* @author: duyunbao
* @create: 2019-03-13 20:46
*/
public class OcrRequestEo {
private String userId;
private String authCode;
private String convertType;
private String Filename;
private String taskId;
private String callBackUrl;
private String callBackMethod;
private String fileContent;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
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) {
Filename = filename;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getCallBackUrl() {
return callBackUrl;
}
public void setCallBackUrl(String callBackUrl) {
this.callBackUrl = callBackUrl;
}
public String getCallBackMethod() {
return callBackMethod;
}
public void setCallBackMethod(String callBackMethod) {
this.callBackMethod = callBackMethod;
}
public String getFileContent() {
return fileContent;
}
public void setFileContent(String fileContent) {
this.fileContent = fileContent;
}
}
@@ -0,0 +1,30 @@
package com.jero.modules.laws.ocr.entity;
/**
* @program: OcrDemo
* @description: ocr返回结果
* @author: duyunbao
* @create: 2019-03-13 15:35
*/
public class OcrResultEo {
private String resultCode;
private String returnMessage;
public String getResultCode() {
return resultCode;
}
public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}
public String getReturnMessage() {
return returnMessage;
}
public void setReturnMessage(String returnMessage) {
this.returnMessage = returnMessage;
}
}
@@ -0,0 +1,168 @@
package com.jero.modules.laws.ocr.http;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PageInfo<T> {
private Integer pageNo;
private Integer pageSize;
private Long count;
private Long pageCount;
private List<T> list;
private List<Map<String, Object>> title;
private Map<String, String> ext;
private String orderBy;
public PageInfo() {
this.pageNo = 1;
this.pageSize = 10;
this.list = new ArrayList();
this.title = new ArrayList();
this.ext = new HashMap();
this.orderBy = "";
this.pageSize = 1;
}
public PageInfo(HttpServletRequest request) {
this.pageNo = 1;
this.pageSize = 10;
this.list = new ArrayList();
this.title = new ArrayList();
this.ext = new HashMap();
this.orderBy = "";
String no = request.getParameter("pageNo");
if (StringUtils.isEmpty(no)) {
this.setPageNo(1);
} else if (StringUtils.isNumeric(no)) {
this.setPageNo(Integer.parseInt(no));
}
String size = request.getParameter("pageSize");
if (StringUtils.isEmpty(size)) {
this.setPageSize(10);
}
if (StringUtils.isNumeric(size)) {
this.setPageSize(Integer.parseInt(size));
}
String orderByParam = request.getParameter("orderBy");
if (StringUtils.isNotBlank(orderByParam)) {
this.setOrderBy(orderByParam);
}
}
public PageInfo(Integer pageNo, Integer pageSize) {
this(pageNo, pageSize, 0L);
}
public PageInfo(Integer pageNo, Integer pageSize, Long count) {
this(pageNo, pageSize, count, new ArrayList());
}
public PageInfo(Integer pageNo, Integer pageSize, Long count, List<T> list) {
this.pageNo = 1;
this.pageSize = 10;
this.list = new ArrayList();
this.title = new ArrayList();
this.ext = new HashMap();
this.orderBy = "";
if (pageNo == null) {
pageNo = 1;
}
if (pageSize == null) {
pageSize = 10;
}
this.setCount(count);
this.setPageNo(Math.abs(pageNo));
this.setPageSize(Math.abs(pageSize));
this.setList(list);
}
public Long getCount() {
return this.count;
}
public void setCount(Long count) {
this.count = count;
if ((long) this.pageSize >= count) {
this.pageNo = 1;
}
}
public Integer getPageNo() {
return this.pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return this.pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize <= 0 ? 10 : pageSize;
}
public List<T> getList() {
return this.list;
}
public PageInfo<T> setList(List<T> list) {
this.list = list;
return this;
}
public String getOrderBy() {
return this.orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public Map<String, String> getExt() {
return this.ext;
}
public void setExt(Map<String, String> ext) {
this.ext = ext;
}
public Long getPageCount() {
if (this.count % (long) this.pageSize != 0L) {
this.pageCount = this.count / (long) this.pageSize + 1L;
} else {
this.pageCount = this.count / (long) this.pageSize;
}
if (this.pageCount < 1L) {
this.pageCount = 1L;
}
return this.pageCount;
}
public void setPageCount(Long pageCount) {
this.pageCount = pageCount;
}
public List<Map<String, Object>> getTitle() {
return this.title;
}
public void setTitle(List<Map<String, Object>> title) {
this.title = title;
}
}
@@ -0,0 +1,62 @@
package com.jero.modules.laws.ocr.http;
public class ResponseMessage<T> {
private String respCode;
private String respMsg;
private T data;
private boolean ok;
public ResponseMessage() {
}
public ResponseMessage(String respCode, String message) {
this.respCode = respCode;
this.respMsg = message;
}
public ResponseMessage(String respCode, String message, boolean ok) {
this.respCode = respCode;
this.respMsg = message;
this.ok = ok;
}
public ResponseMessage(String respCode, String message, boolean ok, T data) {
this.respCode = respCode;
this.respMsg = message;
this.ok = ok;
this.data = data;
}
public ResponseMessage(T data) {
this.data = data;
}
public String getRespCode() {
return this.respCode;
}
public void setRespCode(String respCode) {
this.respCode = respCode;
}
public String getMessage() {
return this.respMsg;
}
public void setMessage(String message) {
this.respMsg = message;
}
public T getData() {
return this.data;
}
public void setData(T data) {
this.data = data;
}
public boolean isOk() {
return this.ok;
}
}
@@ -0,0 +1,21 @@
package com.jero.modules.laws.ocr.http;
public enum ResponseMessageCodeEnum {
SUCCESS("0"),
ERROR("-1"),
ERROR_TOKEN("LE505"),
VALID_ERROR("1000"),
SAVE_SUCCESS("r0001"),
UPDATE_SUCCESS("r0002"),
REMOVE_SUCCESS("r0003");
private String code;
private ResponseMessageCodeEnum(String code) {
this.code = code;
}
public String getCode() {
return this.code;
}
}
@@ -0,0 +1,50 @@
package com.jero.modules.laws.ocr.http;
public class Result {
public Result() {
}
public static ResponseMessage success() {
return new ResponseMessage(ResponseMessageCodeEnum.SUCCESS.getCode(), "", true);
}
public static <T> ResponseMessage<T> success(String code, T t) {
return new ResponseMessage(code, "", true, t);
}
public static <T> ResponseMessage<T> success(String code, String message) {
return new ResponseMessage(code, message);
}
public static <T> ResponseMessage<T> success(String code, String message, T t) {
return new ResponseMessage(code, message, true, t);
}
public static ResponseMessage success(String code, String message,Boolean t) {
return new ResponseMessage(code, message, true);
}
public static <T> ResponseMessage<T> success(T t) {
return new ResponseMessage(ResponseMessageCodeEnum.SUCCESS.getCode(), "", true, t);
}
public static ResponseMessage error() {
return error("");
}
public static ResponseMessage error(String message) {
return error(ResponseMessageCodeEnum.ERROR.getCode(), message);
}
public static ResponseMessage error(String code, String message) {
return error(code, message, (Object)null);
}
public static <T> ResponseMessage<T> error(String code, String message, T t) {
return new ResponseMessage(code, message, false, t);
}
public static <T> ResponseMessage<T> error( T t) {
return new ResponseMessage(t);
}
}
@@ -0,0 +1,32 @@
package com.jero.modules.laws.ocr.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.modules.laws.ocr.entity.OcrRecordEO;
import com.jero.modules.laws.ocr.page.BasePage;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
* <br>
* <b>功能:</b>OCR_RECORD OcrRecordEODao<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2019-03-25 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
public interface OcrRecordEOMapper extends BaseMapper<OcrRecordEO> {
// List<OcrRecordEO> getAllOcrResult();
//
// int deleteByIds(@Param("idList") List<String> idList);
List<OcrRecordEO> queryByPage(BasePage var1);
Integer queryByPageCount(BasePage var1);
int insertSelective(OcrRecordEO ocrRecordEO);
int updateByPrimaryKeySelective(OcrRecordEO ocrRecordEO);
int deleteByIds(@Param("idList") List<String> idList);
}
@@ -0,0 +1,259 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jero.modules.laws.ocr.mapper.OcrRecordEOMapper" >
<!-- Result Map-->
<resultMap id="BaseResultMap" type="com.jero.modules.laws.ocr.entity.OcrRecordEO" >
<id column="id" property="id" />
<result column="word_file_code" property="wordFileCode" />
<result column="json_file_code" property="jsonFileCode" />
<result column="doc_real_name" property="docRealName" />
<result column="json_real_name" property="jsonRealName" />
<result column="file_name" property="fileName" />
<result column="doc_name" property="docName" />
<result column="json_name" property="jsonName" />
<result column="creation_time" property="creationTime" />
<result column="modify_time" property="modifyTime" />
<result column="result_content" property="resultContent" />
<result column="file_type" property="fileType" />
<result column="stand_number" property="standNumber" />
<result column="stand_name" property="standName" />
</resultMap>
<!-- OCR_RECORD table all fields -->
<sql id="Base_Column_List" >
word_file_code, json_file_code, id, doc_real_name, json_real_name, file_name, doc_name, json_name,
creation_time, modify_time,result_content,file_type,stand_number,stand_name
</sql>
<!-- 查询条件 -->
<sql id="Base_Where_Clause">
where 1=1
<trim suffixOverrides="," >
<if test="wordFileCode != null" >
and word_file_code ${wordFileCodeOperator} #{wordFileCode}
</if>
<if test="jsonFileCode != null" >
and json_file_code ${jsonFileCodeOperator} #{jsonFileCode}
</if>
<if test="id != null" >
and id ${idOperator} #{id}
</if>
<if test="docRealName != null" >
and doc_real_name ${docRealNameOperator} #{docRealName}
</if>
<if test="jsonRealName != null" >
and json_real_name ${jsonRealNameOperator} #{jsonRealName}
</if>
<if test="fileName != null" >
and file_name ${fileNameOperator} #{fileName}
</if>
<if test="docName != null" >
and doc_name ${docNameOperator} #{docName}
</if>
<if test="jsonName != null" >
and json_name ${jsonNameOperator} #{jsonName}
</if>
<if test="creationTime != null" >
and creation_time ${creationTimeOperator} #{creationTime}
</if>
<if test="creationTime1 != null" >
and creation_time &gt;= #{creationTime1}
</if>
<if test="creationTime2 != null" >
and creation_time &lt;= #{creationTime2}
</if>
<if test="modifyTime != null" >
and modify_time ${modifyTimeOperator} #{modifyTime}
</if>
<if test="modifyTime1 != null" >
and modify_time &gt;= #{modifyTime1}
</if>
<if test="modifyTime2 != null" >
and modify_time &lt;= #{modifyTime2}
</if>
</trim>
</sql>
<!-- 插入记录 -->
<insert id="insert" parameterType="com.jero.modules.laws.ocr.entity.OcrRecordEO" >
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
SELECT SEQ_OCR_RECORD.NEXTVAL FROM DUAL
</selectKey> -->
insert into OCR_RECORD(<include refid="Base_Column_List" />)
values (#{wordFileCode, jdbcType=VARCHAR}, #{jsonFileCode, jdbcType=VARCHAR}, #{id, jdbcType=VARCHAR}, #{docRealName, jdbcType=VARCHAR}, #{jsonRealName, jdbcType=VARCHAR}, #{fileName, jdbcType=VARCHAR}, #{docName, jdbcType=VARCHAR}, #{jsonName, jdbcType=VARCHAR}, #{creationTime, jdbcType=TIMESTAMP}, #{modifyTime, jdbcType=TIMESTAMP})
</insert>
<!-- 动态插入记录 主键是序列 -->
<insert id="insertSelective" parameterType="com.jero.modules.laws.ocr.entity.OcrRecordEO" >
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
SELECT SEQ_OCR_RECORD.NEXTVAL FROM DUAL
</selectKey> -->
insert into OCR_RECORD
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="wordFileCode != null" >word_file_code,</if>
<if test="jsonFileCode != null" >json_file_code,</if>
<if test="id != null" >id,</if>
<if test="docRealName != null" >doc_real_name,</if>
<if test="jsonRealName != null" >json_real_name,</if>
<if test="fileName != null" >file_name,</if>
<if test="docName != null" >doc_name,</if>
<if test="jsonName != null" >json_name,</if>
<if test="creationTime != null" >creation_time,</if>
<if test="modifyTime != null" >modify_time,</if>
<if test="resultContent != null" >result_content,</if>
<if test="fileType != null" >file_type,</if>
<if test="standNumber != null" >stand_number,</if>
<if test="standName != null" >stand_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="wordFileCode != null" >#{wordFileCode, jdbcType=VARCHAR},</if>
<if test="jsonFileCode != null" >#{jsonFileCode, jdbcType=VARCHAR},</if>
<if test="id != null" >#{id, jdbcType=VARCHAR},</if>
<if test="docRealName != null" >#{docRealName, jdbcType=VARCHAR},</if>
<if test="jsonRealName != null" >#{jsonRealName, jdbcType=VARCHAR},</if>
<if test="fileName != null" >#{fileName, jdbcType=VARCHAR},</if>
<if test="docName != null" >#{docName, jdbcType=VARCHAR},</if>
<if test="jsonName != null" >#{jsonName, jdbcType=VARCHAR},</if>
<if test="creationTime != null" >#{creationTime, jdbcType=TIMESTAMP},</if>
<if test="modifyTime != null" >#{modifyTime, jdbcType=TIMESTAMP},</if>
<if test="resultContent != null" >#{resultContent, jdbcType=VARCHAR},</if>
<if test="fileType != null" >#{fileType, jdbcType=VARCHAR},</if>
<if test="standNumber != null" >#{standNumber, jdbcType=VARCHAR},</if>
<if test="standName != null" >#{standName, jdbcType=VARCHAR},</if>
</trim>
</insert>
<!-- 根据pk,修改记录-->
<update id="updateByPrimaryKey" parameterType="com.jero.modules.laws.ocr.entity.OcrRecordEO" >
update OCR_RECORD
set word_file_code = #{wordFileCode},
json_file_code = #{jsonFileCode},
doc_real_name = #{docRealName},
json_real_name = #{jsonRealName},
file_name = #{fileName},
doc_name = #{docName},
json_name = #{jsonName},
creation_time = #{creationTime},
modify_time = #{modifyTime}
where id = #{id}
</update>
<!-- 修改记录,只修改只不为空的字段 -->
<update id="updateByPrimaryKeySelective" parameterType="com.jero.modules.laws.ocr.entity.OcrRecordEO" >
update OCR_RECORD
<set >
<if test="wordFileCode != null" >
word_file_code = #{wordFileCode},
</if>
<if test="jsonFileCode != null" >
json_file_code = #{jsonFileCode},
</if>
<if test="docRealName != null" >
doc_real_name = #{docRealName},
</if>
<if test="jsonRealName != null" >
json_real_name = #{jsonRealName},
</if>
<if test="fileName != null" >
file_name = #{fileName},
</if>
<if test="docName != null" >
doc_name = #{docName},
</if>
<if test="jsonName != null" >
json_name = #{jsonName},
</if>
<if test="creationTime != null" >
creation_time = #{creationTime},
</if>
<if test="modifyTime != null" >
modify_time = #{modifyTime},
</if>
<if test="resultContent != null" >
result_content = #{resultContent},
</if>
<if test="fileType != null" >
file_type = #{fileType},
</if>
<if test="standNumber != null" >
stand_number = #{standNumber},
</if>
<if test="standName != null" >
stand_name = #{standName},
</if>
</set>
where id = #{id}
</update>
<!-- 根据id查询 OCR_RECORD -->
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select <include refid="Base_Column_List" />
from OCR_RECORD
where id = #{value}
</select>
<!-- 删除记录 -->
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from OCR_RECORD
where id = #{value}
</delete>
<!-- OCR_RECORD 列表总数-->
<select id="queryByCount" resultType="java.lang.Integer" parameterType="com.jero.modules.laws.ocr.page.BasePage">
select count(1) from OCR_RECORD
<include refid="Base_Where_Clause"/>
</select>
<!-- 查询OCR_RECORD列表 -->
<select id="queryByPage" resultMap="BaseResultMap" parameterType="com.jero.modules.laws.ocr.page.BasePage">
select <include refid="Base_Column_List" />,(UNIX_TIMESTAMP(modify_time)-UNIX_TIMESTAMP(creation_time)) as spendTime from
(select tmp_tb.* from
(select <include refid="Base_Column_List" />,(UNIX_TIMESTAMP(modify_time)-UNIX_TIMESTAMP(creation_time)) as spendTime from OCR_RECORD
<include refid="Base_Where_Clause"/>
<if test="pager.orderCondition != null and pager.orderCondition != ''" >
${pager.orderCondition}
</if>
<if test="sql != null">
ORDER BY ${sql}
</if>
) tmp_tb limit ${pager.startIndex-1},${pageSize}) a
</select>
<select id="queryByPageCount" parameterType="com.jero.modules.laws.ocr.page.BasePage" resultType="java.lang.Integer">
select count(id) from
(select tmp_tb.* from
(select <include refid="Base_Column_List" />,(UNIX_TIMESTAMP(modify_time)-UNIX_TIMESTAMP(creation_time)) as spendTime from OCR_RECORD
<include refid="Base_Where_Clause"/>
<if test="pager.orderCondition != null and pager.orderCondition != ''" >
${pager.orderCondition}
</if>
<if test="sql != null">
ORDER BY ${sql}
</if>
) tmp_tb ) a
</select>
<select id="queryByList" resultMap="BaseResultMap" parameterType="com.jero.modules.laws.ocr.page.BasePage">
select <include refid="Base_Column_List"/> from OCR_RECORD
<include refid="Base_Where_Clause"/>
<if test="pager.orderCondition != null and pager.orderCondition != ''" >
${pager.orderCondition}
</if>
</select>
<select id="getAllOcrResult" resultMap="BaseResultMap" >
select id, doc_real_name, json_real_name, file_name, doc_name, json_name, creation_time, modify_time,file_type,stand_number,stand_name
from OCR_RECORD ORDER BY creation_time DESC
</select>
<delete id="deleteByIds" parameterType="java.lang.String">
delete from OCR_RECORD
where id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</mapper>
@@ -0,0 +1,102 @@
package com.jero.modules.laws.ocr.page;
import com.baomidou.mybatisplus.annotation.TableField;
import com.jero.modules.split.common.Pager;
public class BasePage {
@TableField(exist = false)
private Integer page = 1;
@TableField(exist = false)
private Integer pageSize = 20;
@TableField(exist = false)
private Integer startIndex;
@TableField(exist = false)
private Integer endIndex;
@TableField(exist = false)
private String orderBy;
@TableField(exist = false)
private String order;
@TableField(exist = false)
private String q;
@TableField(exist = false)
private Pager pager = new Pager();
public BasePage() {
}
public Pager getPager() {
this.pager.setPageId(this.getPage());
this.pager.setPageSize(this.getPageSize());
String orderField = "";
if (this.orderBy != null && this.orderBy.trim().length() > 0) {
orderField = this.orderBy;
}
if (orderField.trim().length() > 0 && this.order != null && this.order.trim().length() > 0) {
orderField = orderField + " " + this.order;
}
this.pager.setOrderField(orderField);
return this.pager;
}
public void setPager(Pager pager) {
this.pager = pager;
}
public Integer getPage() {
return this.page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getPageSize() {
return this.pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getOrderBy() {
return this.orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public String getOrder() {
return this.order;
}
public void setOrder(String order) {
this.order = order;
}
public String getQ() {
return this.q;
}
public void setQ(String q) {
this.q = q;
}
public Integer getStartIndex() {
return this.startIndex;
}
public void setStartIndex(Integer startIndex) {
this.startIndex = (this.page - 1) * this.pageSize + 1;
}
public Integer getEndIndex() {
return this.endIndex;
}
public void setEndIndex(Integer endIndex) {
this.endIndex = this.page * this.pageSize;
}
}
@@ -0,0 +1,255 @@
package com.jero.modules.laws.ocr.page;
/**
* <b>功能:</b>OCR_RECORD OcrRecordEOPage<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2019-03-25 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
public class OcrRecordEOPage extends BasePage {
private String wordFileCode;
private String wordFileCodeOperator = "=";
private String jsonFileCode;
private String jsonFileCodeOperator = "=";
private String id;
private String idOperator = "=";
private String docRealName;
private String docRealNameOperator = "=";
private String jsonRealName;
private String jsonRealNameOperator = "=";
private String fileName;
private String fileNameOperator = "=";
private String docName;
private String docNameOperator = "=";
private String jsonName;
private String jsonNameOperator = "=";
private String creationTime;
private String creationTime1;
private String creationTime2;
private String creationTimeOperator = "=";
private String modifyTime;
private String modifyTime1;
private String modifyTime2;
private String modifyTimeOperator = "=";
private String paixu;
private String shunxu;
private String sql;
public String getWordFileCode() {
return this.wordFileCode;
}
public void setWordFileCode(String wordFileCode) {
this.wordFileCode = wordFileCode;
}
public String getWordFileCodeOperator() {
return this.wordFileCodeOperator;
}
public void setWordFileCodeOperator(String wordFileCodeOperator) {
this.wordFileCodeOperator = wordFileCodeOperator;
}
public String getJsonFileCode() {
return this.jsonFileCode;
}
public void setJsonFileCode(String jsonFileCode) {
this.jsonFileCode = jsonFileCode;
}
public String getJsonFileCodeOperator() {
return this.jsonFileCodeOperator;
}
public void setJsonFileCodeOperator(String jsonFileCodeOperator) {
this.jsonFileCodeOperator = jsonFileCodeOperator;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getIdOperator() {
return this.idOperator;
}
public void setIdOperator(String idOperator) {
this.idOperator = idOperator;
}
public String getDocRealName() {
return this.docRealName;
}
public void setDocRealName(String docRealName) {
this.docRealName = docRealName;
}
public String getDocRealNameOperator() {
return this.docRealNameOperator;
}
public void setDocRealNameOperator(String docRealNameOperator) {
this.docRealNameOperator = docRealNameOperator;
}
public String getJsonRealName() {
return this.jsonRealName;
}
public void setJsonRealName(String jsonRealName) {
this.jsonRealName = jsonRealName;
}
public String getJsonRealNameOperator() {
return this.jsonRealNameOperator;
}
public void setJsonRealNameOperator(String jsonRealNameOperator) {
this.jsonRealNameOperator = jsonRealNameOperator;
}
public String getFileName() {
return this.fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileNameOperator() {
return this.fileNameOperator;
}
public void setFileNameOperator(String fileNameOperator) {
this.fileNameOperator = fileNameOperator;
}
public String getDocName() {
return this.docName;
}
public void setDocName(String docName) {
this.docName = docName;
}
public String getDocNameOperator() {
return this.docNameOperator;
}
public void setDocNameOperator(String docNameOperator) {
this.docNameOperator = docNameOperator;
}
public String getJsonName() {
return this.jsonName;
}
public void setJsonName(String jsonName) {
this.jsonName = jsonName;
}
public String getJsonNameOperator() {
return this.jsonNameOperator;
}
public void setJsonNameOperator(String jsonNameOperator) {
this.jsonNameOperator = jsonNameOperator;
}
public String getCreationTime() {
return this.creationTime;
}
public void setCreationTime(String creationTime) {
this.creationTime = creationTime;
}
public String getCreationTime1() {
return this.creationTime1;
}
public void setCreationTime1(String creationTime1) {
this.creationTime1 = creationTime1;
}
public String getCreationTime2() {
return this.creationTime2;
}
public void setCreationTime2(String creationTime2) {
this.creationTime2 = creationTime2;
}
public String getCreationTimeOperator() {
return this.creationTimeOperator;
}
public void setCreationTimeOperator(String creationTimeOperator) {
this.creationTimeOperator = creationTimeOperator;
}
public String getModifyTime() {
return this.modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyTime1() {
return this.modifyTime1;
}
public void setModifyTime1(String modifyTime1) {
this.modifyTime1 = modifyTime1;
}
public String getModifyTime2() {
return this.modifyTime2;
}
public void setModifyTime2(String modifyTime2) {
this.modifyTime2 = modifyTime2;
}
public String getModifyTimeOperator() {
return this.modifyTimeOperator;
}
public void setModifyTimeOperator(String modifyTimeOperator) {
this.modifyTimeOperator = modifyTimeOperator;
}
public String getPaixu() {
return paixu;
}
public void setPaixu(String paixu) {
this.paixu = paixu;
}
public String getShunxu() {
return shunxu;
}
public void setShunxu(String shunxu) {
this.shunxu = shunxu;
}
public String getSql() {
return sql;
}
public void setSql(String sql) {
this.sql = sql;
}
}
@@ -0,0 +1,15 @@
package com.jero.modules.laws.ocr.service;
import com.jero.modules.laws.ocr.entity.OcrRecordEO;
import com.jero.modules.laws.ocr.http.ResponseMessage;
import org.springframework.web.multipart.MultipartFile;
public interface OCRRestfulService{
ResponseMessage handleFile(MultipartFile file, String fileName, OcrRecordEO getOcrEO, String type) throws Exception;
void updateDb(String taskId,String result) throws Exception;
String OcrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception;
}
@@ -0,0 +1,18 @@
package com.jero.modules.laws.ocr.service;
import com.jero.modules.laws.ocr.entity.OcrRecordEO;
import com.jero.modules.laws.ocr.page.OcrRecordEOPage;
import java.util.List;
public interface OcrRecordEOService {
List<OcrRecordEO> queryByPage(OcrRecordEOPage page);
Integer queryByPageCount(OcrRecordEOPage page);
int updateByPrimaryKeySelective(OcrRecordEO ocrRecordEO);
int deleteByIds(List<String> idList);
}
@@ -0,0 +1,230 @@
package com.jero.modules.laws.ocr.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.jero.modules.laws.ocr.Base64Util;
import com.jero.modules.laws.ocr.OkHttpUtil;
import com.jero.modules.laws.ocr.RsaUtil;
import com.jero.modules.laws.ocr.UUIDUtils;
import com.jero.modules.laws.ocr.mapper.OcrRecordEOMapper;
import com.jero.modules.laws.ocr.entity.OcrRecordEO;
import com.jero.modules.laws.ocr.entity.OcrResultEo;
import com.jero.modules.laws.ocr.http.ResponseMessage;
import com.jero.modules.laws.ocr.http.Result;
import com.jero.modules.laws.ocr.service.OCRRestfulService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class OCRRestfulServiceImpl implements OCRRestfulService {
private static final Logger logger = LoggerFactory.getLogger(OCRRestfulServiceImpl.class);
//请求处理客户认证码
@Value("${OCR.authCode}")
private String OcrAuthCode;
//请求处理文件url
@Value("${OCR.handleFileUrl}")
private String RestHandleFileUrl;
//接口回调url
@Value("${OCR.callBackUrl}")
private String RestCallBackUrl;
//请求处理usrid
@Value("${OCR.userId}")
private String OcrUserId;
@Value("${OCR.convertType}")
private String convertType;
@Autowired
private RestTemplate restTemplate;
@Autowired
private OkHttpUtil okHttpUtil;
@Autowired
private OcrRecordEOMapper ocrRecordEOMapper;
//ocr处理文件后存放url
@Value("${OCR.ocrPath}")
private String ocrFilePath;
@Value("${OCR.ocrDownPath}")
private String ocrDownPath;
public ResponseMessage handleFile(MultipartFile file, String fileName, OcrRecordEO getOcrEO, String type)
throws Exception {
String taskId = "";
if ("add".equals(type)) {
taskId = UUIDUtils.randomUUID20();
} else {
taskId = getOcrEO.getId();
}
String authCode = RsaUtil.publicEncrypt(OcrAuthCode);
if(authCode == null){
logger.error("客户认证RSA加密失败");
return Result.error("客户认证RSA加密失败");
}
String fileContent = Base64Util.PDFToBase64(file);
if(fileContent == null || "".equals(fileContent)){
logger.error("PDF转Base64失败");
return Result.error("PDF转Base64失败");
}
SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
try{
//ResponseEntity<String> responseEntity = restTemplate.postForEntity(RestHandleFileUrl, httpEntity, String.class);
Map<String,String> map = new HashMap<>();
map.put("userId",OcrUserId);
map.put("authCode",authCode);
map.put("convertType",convertType);
map.put("fileName",fileName);
map.put("fileContent",fileContent);
map.put("taskId",taskId);
map.put("callBackUrl",RestCallBackUrl);
map.put("callBackMethod","");
logger.info("处理完文件数据,开始请求OCR接口数据:【"+sdf.format(new Date())+"");
String result = okHttpUtil.post(RestHandleFileUrl,map,new HashMap<>());
logger.info("okHttp结果:"+result);
logger.info("请求OCR接口完毕,返回响应状态:【"+sdf.format(new Date())+"");
if(!result.contains("请求成功")){
logger.error("请求出现异常:"+result);
return Result.error("请求出现异常");
}else{
OcrResultEo ocrResultEo = JSONObject.parseObject(result, OcrResultEo.class);
if(ocrResultEo.getResultCode().equals("0")){
if ("add".equals(type)) {
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(taskId);
ocrRecordEO.setCreationUser("LoginUserUtil.getUserId()");
ocrRecordEO.setFileName(fileName);
ocrRecordEO.setCreationTime(new Date());
ocrRecordEO.setResultContent("转换中");
ocrRecordEO.setStandNumber(getOcrEO.getStandNumber());
ocrRecordEO.setStandName(getOcrEO.getStandName());
ocrRecordEO.setFileType(getOcrEO.getFileType());
ocrRecordEOMapper.insertSelective(ocrRecordEO);
return Result.success(ocrResultEo.getResultCode(), "加入转换成功", taskId);
} else {
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(taskId);
ocrRecordEO.setFileName(fileName);
ocrRecordEO.setResultContent("转换中");
ocrRecordEO.setStandNumber(getOcrEO.getStandNumber());
ocrRecordEO.setStandName(getOcrEO.getStandName());
ocrRecordEO.setFileType(getOcrEO.getFileType());
ocrRecordEO.setCreationTime(new Date());
ocrRecordEOMapper.updateByPrimaryKeySelective(ocrRecordEO);
return Result.success(ocrResultEo.getResultCode(), "加入转换成功", taskId);
}
}else{
return Result.error(ocrResultEo.getReturnMessage());
}
}
}catch (Exception e){
logger.error(e.getMessage(),e);
return Result.error("OCR接口请求出现异常,无法将文件传输到OCR引擎!");
}
}
public void updateDb(String taskId,String result) throws Exception {
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(taskId);
ocrRecordEO.setModifyTime(new Date());
ocrRecordEO.setResultContent(result);
ocrRecordEOMapper.updateByPrimaryKeySelective(ocrRecordEO);
}
public String OcrHandleResult(MultipartFile wordFile,MultipartFile jsonFile,String taskId) throws Exception {
//首先将文件保存至本地
String saveWordFilePath=null;
String saveWordFileName=null;
logger.info("将文件保存至本地");
if(wordFile!=null && !wordFile.isEmpty()){
saveWordFileName=UUIDUtils.randomUUID20()+"_"+wordFile.getOriginalFilename().replace("/","_");
saveWordFilePath=ocrFilePath+saveWordFileName;
logger.info(saveWordFilePath);
//生成保存文件
File saveWordFile = new File(saveWordFilePath);
System.out.println(saveWordFile);
wordFile.transferTo(saveWordFile);
// FileUtils.copyInputStreamToFile(wordFile.getInputStream(),new File(saveWordFilePath));
// savePic(wordFile.getInputStream(),saveWordFilePath);
logger.info("word存储完成");
}
String saveJsonFilePath=null;
String saveJsonFileName=null;
if(jsonFile!=null && !jsonFile.isEmpty()){
saveJsonFileName=UUIDUtils.randomUUID20()+"_"+jsonFile.getOriginalFilename().replace("/","_");
saveJsonFilePath=ocrFilePath+saveJsonFileName;
logger.info(saveJsonFilePath);
File saveJsonFile = new File(saveJsonFilePath);
System.out.println(saveJsonFile);
jsonFile.transferTo(saveJsonFile);
// FileUtils.copyInputStreamToFile(jsonFile.getInputStream(),new File(saveJsonFilePath));
// savePic(jsonFile.getInputStream(),saveJsonFilePath);
logger.info("Json存储完成");
}
//开始将文件保存至数据库中
if(StringUtils.isNotEmpty(saveWordFilePath) && StringUtils.isNotEmpty(saveJsonFilePath)){
OcrRecordEO ocrRecordEO = new OcrRecordEO();
ocrRecordEO.setId(taskId);
ocrRecordEO.setDocName(saveWordFilePath);
ocrRecordEO.setJsonName(saveJsonFilePath);
ocrRecordEO.setDocRealName(saveWordFileName);
ocrRecordEO.setWordFileCode(null);
ocrRecordEO.setJsonRealName(saveJsonFileName);
ocrRecordEO.setJsonFileCode(null);
ocrRecordEO.setModifyTime(new Date());
ocrRecordEO.setResultContent("转换成功");
ocrRecordEOMapper.updateByPrimaryKeySelective(ocrRecordEO);
return "{\"result\":\"success\"}";
}else{
updateDb(taskId,"error:File does not exist");
return "{\"result\":\"error:File does not exist\"}";//文件不存在
}
}
private void savePic(InputStream inputStream, String filePath) {
OutputStream os = null;
try {
// 2、保存到临时文件
// 1K的数据缓冲
byte[] bs = new byte[1024];
// 读取到的数据长度
int len;
// 输出的文件流保存到本地文件
File tempFile = new File(ocrFilePath);
if (!tempFile.exists()) {
tempFile.mkdirs();
}
os = new FileOutputStream(filePath);
// 开始读取
while ((len = inputStream.read(bs)) != -1) {
os.write(bs, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
// 完毕,关闭所有链接
try {
os.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
@@ -0,0 +1,44 @@
package com.jero.modules.laws.ocr.service.impl;
import com.jero.modules.laws.ocr.mapper.OcrRecordEOMapper;
import com.jero.modules.laws.ocr.entity.OcrRecordEO;
import com.jero.modules.laws.ocr.page.OcrRecordEOPage;
import com.jero.modules.laws.ocr.service.OcrRecordEOService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class OcrRecordEOServiceImpl implements OcrRecordEOService {
private static final Logger logger = LoggerFactory.getLogger(OcrRecordEOServiceImpl.class);
@Autowired
private OcrRecordEOMapper ocrRecordEOMapper;
@Override
public List<OcrRecordEO> queryByPage(OcrRecordEOPage page) {
return ocrRecordEOMapper.queryByPage(page);
}
@Override
public Integer queryByPageCount(OcrRecordEOPage page) {
return ocrRecordEOMapper.queryByPageCount(page);
}
@Override
public int updateByPrimaryKeySelective(OcrRecordEO ocrRecordEO) {
return ocrRecordEOMapper.updateByPrimaryKeySelective(ocrRecordEO);
}
@Override
public int deleteByIds(List<String> idList){
return ocrRecordEOMapper.deleteByIds(idList);
}
}
@@ -0,0 +1,82 @@
package com.jero.modules.laws.ocr.web;
import com.jero.modules.laws.ocr.http.PageInfo;
import com.jero.modules.split.common.Pager;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BaseController<T> {
private static final String DATA = "data";
private static final String TOTAL = "total";
protected BaseController() {
}
public PageInfo<T> getPageInfo(Pager pager, List<T> rows) {
PageInfo<T> pageInfo = new PageInfo();
pageInfo.setList(rows);
pageInfo.setCount((long)pager.getRowCount());
pageInfo.setPageSize(pager.getPageSize());
pageInfo.setPageCount((long)pager.getPageCount());
pageInfo.setPageNo(pager.getPageId());
return pageInfo;
}
public static Map<String, Object> getGridData(int total, List<?> rows) {
Map<String, Object> response = new HashMap();
response.put("total", total);
response.put("data", rows);
return response;
}
public static Map<String, Object> getData(Object data) {
Map<String, Object> response = new HashMap();
response.put("data", data);
return response;
}
public static void download(HttpServletResponse response, File file) throws IOException {
download(response, file, file.getName());
}
public static void download(HttpServletResponse response, File file, String fileName) throws IOException {
FileInputStream in = new FileInputStream(file);
Throwable var4 = null;
try {
download(response, (InputStream)in, fileName);
} catch (Throwable var13) {
var4 = var13;
throw var13;
} finally {
if (in != null) {
if (var4 != null) {
try {
in.close();
} catch (Throwable var12) {
var4.addSuppressed(var12);
}
} else {
in.close();
}
}
}
}
public static void download(HttpServletResponse response, InputStream in, String fileName) throws IOException {
response.setContentType("application/x-msdownload;");
response.addHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.setCharacterEncoding("UTF-8");
}
}
@@ -522,3 +522,19 @@ bindPart:
auth_username: CNHTC_PO_PSRMS
#Authorization
auth_password: Cnhtcpsrms2024
# 云端OCR识别集成配置参数
OCR:
#OCR请求识别URL地址
handleFileUrl: http://61.136.1.103:8091/WebService.asmx/FileConversion
# OCR回调接口地址 配置客户本地的IP及端口号
callBackUrl: https://srms.foton.com.cn/laws/ocr/OCRRestful/OcrHandleResult
userId: dayuzhou1234
authCode: 123456
publicKey: EC4KKA6ZDTCPAOCRBC5M
# OCR文件存储路径
ocrPath: /data/slrs/ocrResultFile/
# OCR文件请求下载或在线预览时URL
ocrDownPath: /data/slrs/ocrResultFile/
times: 20
convertType: BOTH