Commit 7a99f27e by HlQ

[fix] 捕获同步销帮帮合同文件时发生的异常

1 parent 1dc02c04
...@@ -647,7 +647,10 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont ...@@ -647,7 +647,10 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
var contractList = this.lambdaQuery().likeRight(Contract::getContractNo, "SC").list(); var contractList = this.lambdaQuery().likeRight(Contract::getContractNo, "SC").list();
var contractNo2IdMap = contractList.stream().collect(Collectors.toMap(Contract::getContractNo, Contract::getId)); var contractNo2IdMap = contractList.stream().collect(Collectors.toMap(Contract::getContractNo, Contract::getId));
var fileInfoList = fileService.lambdaQuery().in(FileInfo::getContractId, contractNo2IdMap.values()).eq(FileInfo::getSourceType, 5).list(); var fileInfoList = fileService.lambdaQuery()
.in(FileInfo::getContractId, contractNo2IdMap.values())
.eq(FileInfo::getSourceType, 5)
.list();
// 合同id -> sha256 的 List // 合同id -> sha256 的 List
var contractId2Sha256Map = fileInfoList.stream().collect(Collectors.groupingBy(FileInfo::getContractId, var contractId2Sha256Map = fileInfoList.stream().collect(Collectors.groupingBy(FileInfo::getContractId,
Collectors.mapping(FileInfo::getSha256, Collectors.toList()))); Collectors.mapping(FileInfo::getSha256, Collectors.toList())));
...@@ -670,7 +673,13 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont ...@@ -670,7 +673,13 @@ public class ContractServiceImpl extends MPJBaseServiceImpl<ContractMapper, Cont
var fileObj = JSONUtil.parseObj(o); var fileObj = JSONUtil.parseObj(o);
var filename = fileObj.getStr("filename"); var filename = fileObj.getStr("filename");
String path = fileUrl + FileUtil.FILE_SEPARATOR + "contract" + FileUtil.FILE_SEPARATOR + contractId + FileUtil.FILE_SEPARATOR + filename; String path = fileUrl + FileUtil.FILE_SEPARATOR + "contract" + FileUtil.FILE_SEPARATOR + contractId + FileUtil.FILE_SEPARATOR + filename;
var bytes = HttpDownloader.downloadBytes(fileObj.getStr("attachIndex")); byte[] bytes;
try {
bytes = HttpDownloader.downloadBytes(fileObj.getStr("attachIndex"));
} catch (Exception e) {
log.error("合同:{},[{}] 文件同步失败", contractNo, filename);
continue;
}
var sha256 = SecureUtil.sha256().digestHex(bytes).toUpperCase(); var sha256 = SecureUtil.sha256().digestHex(bytes).toUpperCase();
// sha256 对应的文件不存在已有的文件列表,才保存 // sha256 对应的文件不存在已有的文件列表,才保存
if (contractId2Sha256Map.getOrDefault(contractId, ListUtil.empty()).contains(sha256)) { if (contractId2Sha256Map.getOrDefault(contractId, ListUtil.empty()).contains(sha256)) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!