Commit 2fb10394 by 黄明步

更新

parent b03307c1
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>5.8.18</version> <version>5.8.24</version>
</dependency> </dependency>
<!-- 解决ModelAndView无法访问到templates目录下的页面 --> <!-- 解决ModelAndView无法访问到templates目录下的页面 -->
......
...@@ -9,10 +9,7 @@ import cn.hutool.core.util.IdUtil; ...@@ -9,10 +9,7 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.http.ContentType; import cn.hutool.http.*;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
...@@ -107,6 +104,11 @@ public class RetransmissionService { ...@@ -107,6 +104,11 @@ public class RetransmissionService {
**/ **/
private static final String SERVER_REQUEST_TASK = "server-request-task-"; private static final String SERVER_REQUEST_TASK = "server-request-task-";
private static final String LOCK_NAME = "server-task"; private static final String LOCK_NAME = "server-task";
/**
* 重试次数
*/
private static final int MAX_RETRIES = 3;
@PostConstruct @PostConstruct
...@@ -178,25 +180,44 @@ public class RetransmissionService { ...@@ -178,25 +180,44 @@ public class RetransmissionService {
file.transferTo(tempFile); file.transferTo(tempFile);
paramMap.put("file", tempFile); paramMap.put("file", tempFile);
paramMap.put("createOfd", createOfd); paramMap.put("createOfd", createOfd);
if (ocrServerAddress == null) { // 设置开始时间
return OcrResult.error("OCR云平台未配置服务器信息");
}
addServerRequestCount(ocrServerAddress.getIp(), 1);
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
// 开始阶段,设置请求开始时间
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String res = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/" + code)
.header("Authorization", request.getHeader("Authorization"))
.header("X-Timestamp", request.getHeader("X-Timestamp"))
.header("X-Checksum", request.getHeader("X-Checksum"))
.form(paramMap).execute().body();
// 记录请求结束时间
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
String res = "";
int retryCount = 0;
// 循环重试
while (retryCount < MAX_RETRIES) {
// 设置开始时间
startTime = System.currentTimeMillis();
ocrServerAddress = getServerAddressByRequestCount();
if (ocrServerAddress == null) {
log.error("OCR云平台未配置服务器信息");
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
}
addServerRequestCount(ocrServerAddress.getIp(), 1);
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
try {
res = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/1001")
.headerMap(getHeaderMap(request), true)
.form(paramMap)
.execute().body();
// 设置结束时间
endTime = System.currentTimeMillis();
// 拿到结果后终止循环
if (StringUtils.isNotEmpty(res)) {
break;
}
} catch (HttpException e) {
addServerRequestCount(ocrServerAddress.getIp(), -1);
retryCount++;
log.error("OCR云平台接口异常, 准备重试 fileId={}, serverIp={}, 当前重试次数={}", fileId, ocrServerAddress.getIp(), retryCount, e);
}
}
if (StringUtils.isEmpty(res)) { if (StringUtils.isEmpty(res)) {
this.setRequestToRedis(2, startTime, endTime, null, ocrServerAddress, request); this.setRequestToRedis(2, startTime, endTime, null, ocrServerAddress, request);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
...@@ -207,7 +228,7 @@ public class RetransmissionService { ...@@ -207,7 +228,7 @@ public class RetransmissionService {
saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId); saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
log.error("OCR云平台接口异常", e); log.error("OCR云平台接口异常, fileId={}, serverIp={}", fileId, ocrServerAddress.getIp(), e);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
} finally { } finally {
FileUtil.del(tempSaveDir); FileUtil.del(tempSaveDir);
...@@ -217,6 +238,36 @@ public class RetransmissionService { ...@@ -217,6 +238,36 @@ public class RetransmissionService {
} }
} }
public Map<String, String> getHeaderMap(HttpServletRequest request) {
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Authorization", request.getHeader("Authorization"));
headerMap.put("X-Timestamp", request.getHeader("X-Timestamp"));
headerMap.put("X-Checksum", request.getHeader("X-Checksum"));
return headerMap;
}
/**
* 根据文件大小计算超时时间
* @param fileSizeBytes 文件大小,单位:字节
* @return
*/
private static int calculateTimeout(long fileSizeBytes) {
// 每1 MB 增加 3 秒超时时间
int baseTimeout = 120;
int timeoutIncrement = 3;
// 对小于等于1 MB的文件,超时时间固定为10秒
if (fileSizeBytes <= 1024 * 1024) {
return baseTimeout * 1000;
}
// 对大于1 MB的文件,每增加1 MB增加3秒超时时间
int additionalTimeout = (int) ((fileSizeBytes - 1024 * 1024) / (1024 * 1024) * timeoutIncrement);
int timeout = (baseTimeout + additionalTimeout) * 1000;
return timeout;
}
public OcrResult commonRecognitionV2(String code, String fileId, MultipartFile file, Boolean createOfd, HttpServletRequest request) { public OcrResult commonRecognitionV2(String code, String fileId, MultipartFile file, Boolean createOfd, HttpServletRequest request) {
HashMap<String, Object> paramMap = new HashMap<>(); HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("fileId", fileId); paramMap.put("fileId", fileId);
...@@ -228,25 +279,44 @@ public class RetransmissionService { ...@@ -228,25 +279,44 @@ public class RetransmissionService {
file.transferTo(tempFile); file.transferTo(tempFile);
paramMap.put("file", tempFile); paramMap.put("file", tempFile);
paramMap.put("createOfd", createOfd); paramMap.put("createOfd", createOfd);
if (ocrServerAddress == null) { // 设置开始时间
return OcrResult.error("OCR云平台未配置服务器信息");
}
addServerRequestCount(ocrServerAddress.getIp(), 1);
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
// 开始阶段,设置请求开始时间
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String res = HttpRequest.post(ocrApi + "/ofs/api/sync/v2/" + code)
.header("Authorization", request.getHeader("Authorization"))
.header("X-Timestamp", request.getHeader("X-Timestamp"))
.header("X-Checksum", request.getHeader("X-Checksum"))
.form(paramMap).execute().body();
// 记录请求结束时间
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
String res = "";
int retryCount = 0;
// 循环重试
while (retryCount < MAX_RETRIES) {
// 设置开始时间
startTime = System.currentTimeMillis();
ocrServerAddress = getServerAddressByRequestCount();
if (ocrServerAddress == null) {
log.error("OCR云平台未配置服务器信息");
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
}
addServerRequestCount(ocrServerAddress.getIp(), 1);
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
try {
res = HttpRequest.post(ocrApi + "/ofs/api/sync/v2/1001")
.headerMap(getHeaderMap(request), true)
.form(paramMap)
.execute().body();
// 设置结束时间
endTime = System.currentTimeMillis();
// 拿到结果后终止循环
if (StringUtils.isNotEmpty(res)) {
break;
}
} catch (HttpException e) {
addServerRequestCount(ocrServerAddress.getIp(), -1);
retryCount++;
log.error("OCR云平台接口异常, 准备重试 fileId={}, serverIp={}, 当前重试次数={}", fileId, ocrServerAddress.getIp(), retryCount, e);
}
}
if (StringUtils.isEmpty(res)) { if (StringUtils.isEmpty(res)) {
this.setRequestToRedis(2, startTime, endTime, null, ocrServerAddress, request); this.setRequestToRedis(2, startTime, endTime, null, ocrServerAddress, request);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
...@@ -257,7 +327,7 @@ public class RetransmissionService { ...@@ -257,7 +327,7 @@ public class RetransmissionService {
saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId); saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
log.error("OCR云平台接口异常, ", e); log.error("OCR云平台接口异常, fileId={}, serverIp={}, tempPath={}", fileId, ocrServerAddress.getIp(), tempSaveDir, e);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
} finally { } finally {
FileUtil.del(tempSaveDir); FileUtil.del(tempSaveDir);
...@@ -277,9 +347,7 @@ public class RetransmissionService { ...@@ -277,9 +347,7 @@ public class RetransmissionService {
} }
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort(); String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
HttpResponse httpResponse = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/pdf") HttpResponse httpResponse = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/pdf")
.header("Authorization", request.getHeader("Authorization")) .headerMap(getHeaderMap(request), true)
.header("X-Timestamp", request.getHeader("X-Timestamp"))
.header("X-Checksum", request.getHeader("X-Checksum"))
.contentType("application/json;charset=UTF-8") .contentType("application/json;charset=UTF-8")
.body(body.toJSONString(0)).execute(); .body(body.toJSONString(0)).execute();
...@@ -353,9 +421,7 @@ public class RetransmissionService { ...@@ -353,9 +421,7 @@ public class RetransmissionService {
} }
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort(); String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
HttpResponse httpResponse = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/ofd") HttpResponse httpResponse = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/ofd")
.header("Authorization", request.getHeader("Authorization")) .headerMap(getHeaderMap(request), true)
.header("X-Timestamp", request.getHeader("X-Timestamp"))
.header("X-Checksum", request.getHeader("X-Checksum"))
.contentType("application/json;charset=UTF-8") .contentType("application/json;charset=UTF-8")
.body(body.toJSONString(0)).execute(); .body(body.toJSONString(0)).execute();
Map<String, List<String>> headers = httpResponse.headers(); Map<String, List<String>> headers = httpResponse.headers();
...@@ -417,36 +483,56 @@ public class RetransmissionService { ...@@ -417,36 +483,56 @@ public class RetransmissionService {
} }
} }
public OcrResult fullTextRecognition(String fileId, MultipartFile file, HttpServletRequest request) { public OcrResult fullTextRecognition(String fileId, MultipartFile file, HttpServletRequest request) {
HashMap<String, Object> paramMap = new HashMap<>(); HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("fileId", fileId); paramMap.put("fileId", fileId);
String tempSaveDir = tempDir + File.separator + IdUtil.fastSimpleUUID() + "_" + System.currentTimeMillis(); String tempSaveDir = tempDir + File.separator + IdUtil.fastSimpleUUID() + "_" + System.currentTimeMillis();
FileUtil.mkdir(tempSaveDir); FileUtil.mkdir(tempSaveDir);
File tempFile = new File(tempSaveDir, Objects.requireNonNull(FileUtil.getName(file.getOriginalFilename()))); File tempFile = new File(tempSaveDir, Objects.requireNonNull(FileUtil.getName(file.getOriginalFilename())));
ServerInfo ocrServerAddress = getServerAddressByRequestCount(); ServerInfo ocrServerAddress = null;
try { try {
file.transferTo(tempFile); file.transferTo(tempFile);
paramMap.put("file", tempFile); paramMap.put("file", tempFile);
if (ocrServerAddress == null) {
return OcrResult.error("OCR云平台未配置服务器信息");
}
addServerRequestCount(ocrServerAddress.getIp(), 1);
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
// 设置开始时间 // 设置开始时间
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String res = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/ft/1001")
.header("Authorization", request.getHeader("Authorization"))
.header("X-Timestamp", request.getHeader("X-Timestamp"))
.header("X-Checksum", request.getHeader("X-Checksum"))
.form(paramMap).execute().body();
// 设置结束时间
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
String res = "";
int retryCount = 0;
// 循环重试
while (retryCount < MAX_RETRIES) {
// 设置开始时间
startTime = System.currentTimeMillis();
ocrServerAddress = getServerAddressByRequestCount();
if (ocrServerAddress == null) {
log.error("OCR云平台未配置服务器信息");
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
}
addServerRequestCount(ocrServerAddress.getIp(), 1);
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
try {
res = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/ft/1001")
.headerMap(getHeaderMap(request), true)
.form(paramMap)
.execute().body();
// 设置结束时间
endTime = System.currentTimeMillis();
// 拿到结果后终止循环
if (StringUtils.isNotEmpty(res)) {
break;
}
} catch (HttpException e) {
addServerRequestCount(ocrServerAddress.getIp(), -1);
retryCount++;
log.error("OCR云平台接口异常, 准备重试 fileId={}, serverIp={}, 当前重试次数={}", fileId, ocrServerAddress.getIp(), retryCount, e);
}
}
if (StringUtils.isEmpty(res)) { if (StringUtils.isEmpty(res)) {
this.setRequestToRedis(2, startTime, endTime, null, ocrServerAddress, request); this.setRequestToRedis(2, startTime, endTime, null, ocrServerAddress, request);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
...@@ -457,7 +543,7 @@ public class RetransmissionService { ...@@ -457,7 +543,7 @@ public class RetransmissionService {
saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId); saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId);
return result; return result;
} catch (IOException e) { } catch (IOException e) {
log.error("OCR云平台接口异常", e); log.error("OCR云平台接口异常, fileId={}, serverIp={}", fileId, ocrServerAddress.getIp(), e);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
} finally { } finally {
FileUtil.del(tempSaveDir); FileUtil.del(tempSaveDir);
...@@ -479,25 +565,44 @@ public class RetransmissionService { ...@@ -479,25 +565,44 @@ public class RetransmissionService {
paramMap.put("file", tempFile); paramMap.put("file", tempFile);
if (ocrServerAddress == null) {
log.error("OCR云平台未配置服务器信息");
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
}
addServerRequestCount(ocrServerAddress.getIp(), 1);
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
// 设置开始时间 // 设置开始时间
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String res = HttpRequest.post(ocrApi + "/ofs/api/sync/v2/ft/1001")
.header("Authorization", request.getHeader("Authorization"))
.header("X-Timestamp", request.getHeader("X-Timestamp"))
.header("X-Checksum", request.getHeader("X-Checksum"))
.form(paramMap).execute().body();
// 设置结束时间
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
String res = "";
int retryCount = 0;
// 循环重试
while (retryCount < MAX_RETRIES) {
// 设置开始时间
startTime = System.currentTimeMillis();
ocrServerAddress = getServerAddressByRequestCount();
if (ocrServerAddress == null) {
log.error("OCR云平台未配置服务器信息");
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
}
addServerRequestCount(ocrServerAddress.getIp(), 1);
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String ocrApi = "http://" + ocrServerAddress.getIp() + ":" + ocrServerAddress.getOcrPort();
try {
res = HttpRequest.post(ocrApi + "/ofs/api/sync/v2/1001")
.headerMap(getHeaderMap(request), true)
.form(paramMap)
.execute().body();
// 设置结束时间
endTime = System.currentTimeMillis();
// 拿到结果后终止循环
if (StringUtils.isNotEmpty(res)) {
break;
}
} catch (HttpException e) {
addServerRequestCount(ocrServerAddress.getIp(), -1);
retryCount++;
log.error("OCR云平台接口异常, 准备重试 fileId={}, serverIp={}, 当前重试次数={}", fileId, ocrServerAddress.getIp(), retryCount);
}
}
if (StringUtils.isEmpty(res)) { if (StringUtils.isEmpty(res)) {
this.setRequestToRedis(2, startTime, endTime, null, ocrServerAddress, request); this.setRequestToRedis(2, startTime, endTime, null, ocrServerAddress, request);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
...@@ -508,7 +613,7 @@ public class RetransmissionService { ...@@ -508,7 +613,7 @@ public class RetransmissionService {
saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId); saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId);
return result; return result;
} catch (IOException e) { } catch (IOException e) {
log.error("OCR云平台接口异常", e); log.error("OCR云平台接口异常, fileId={}, serverIp={}", fileId, ocrServerAddress.getIp(), e);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
} finally { } finally {
FileUtil.del(tempSaveDir); FileUtil.del(tempSaveDir);
...@@ -540,10 +645,9 @@ public class RetransmissionService { ...@@ -540,10 +645,9 @@ public class RetransmissionService {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request); this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String res = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/kv/" + code) String res = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/kv/" + code)
.header("Authorization", request.getHeader("Authorization")) .headerMap(getHeaderMap(request), true)
.header("X-Timestamp", request.getHeader("X-Timestamp")) .form(paramMap)
.header("X-Checksum", request.getHeader("X-Checksum")) .execute().body();
.form(paramMap).execute().body();
// 设置结束时间 // 设置结束时间
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
...@@ -557,7 +661,7 @@ public class RetransmissionService { ...@@ -557,7 +661,7 @@ public class RetransmissionService {
saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId); saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId);
return result; return result;
} catch (IOException e) { } catch (IOException e) {
log.error("OCR云平台接口异常", e); log.error("OCR云平台接口异常, fileId={}, serverIp={}", fileId, ocrServerAddress.getIp(), e);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
} finally { } finally {
FileUtil.del(tempSaveDir); FileUtil.del(tempSaveDir);
...@@ -588,9 +692,7 @@ public class RetransmissionService { ...@@ -588,9 +692,7 @@ public class RetransmissionService {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request); this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String res = HttpRequest.post(ocrApi + "/ofs/api/async/minio/v1/" + code) String res = HttpRequest.post(ocrApi + "/ofs/api/async/minio/v1/" + code)
.header("Authorization", request.getHeader("Authorization")) .headerMap(getHeaderMap(request), true)
.header("X-Timestamp", request.getHeader("X-Timestamp"))
.header("X-Checksum", request.getHeader("X-Checksum"))
.contentType("application/json;charset=UTF-8") .contentType("application/json;charset=UTF-8")
.body(body.toJSONString(0)).execute().body(); .body(body.toJSONString(0)).execute().body();
// 设置结束时间 // 设置结束时间
...@@ -632,10 +734,9 @@ public class RetransmissionService { ...@@ -632,10 +734,9 @@ public class RetransmissionService {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request); this.setRequestToRedis(1, startTime, null, null, ocrServerAddress, request);
String res = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/6002") String res = HttpRequest.post(ocrApi + "/ofs/api/sync/v1/6002")
.header("Authorization", request.getHeader("Authorization")) .headerMap(getHeaderMap(request), true)
.header("X-Timestamp", request.getHeader("X-Timestamp")) .form(paramMap)
.header("X-Checksum", request.getHeader("X-Checksum")) .execute().body();
.form(paramMap).execute().body();
// 设置结束时间 // 设置结束时间
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
...@@ -650,7 +751,7 @@ public class RetransmissionService { ...@@ -650,7 +751,7 @@ public class RetransmissionService {
saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId); saveToAppAbilityRecordAll(result, request, ocrServerAddress.getIp(), fileId);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
log.error("OCR云平台接口异常", e); log.error("OCR云平台接口异常, fileId={}, serverIp={}", fileId, ocrServerAddress.getIp(), e);
return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date()); return new OcrResult("007500", "识别失败,请重试", null, DateUtil.date());
} finally { } finally {
FileUtil.del(tempSaveDir); FileUtil.del(tempSaveDir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment