【update】ASMS同步国标数据的处理
This commit is contained in:
+34
-3
@@ -67,6 +67,7 @@ import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -464,7 +465,15 @@ public class LawsAsmsOpenApiServiceImpl extends ServiceImpl<LawsAsmsOpenApiMappe
|
||||
List<LawsAsmsDomestic> lawsAsmsDomesticList = lawsAsmsDomesticService.list(queryWrapper);
|
||||
List<SysDictItem> sysDictItemList = sysDictItemService.list();
|
||||
List<LawsStandardization> lawsStandardizationList = lawsStandardizationService.list();
|
||||
AtomicInteger addNum = new AtomicInteger();
|
||||
lawsAsmsDomesticList.forEach(lawsAsmsDomestic -> {
|
||||
// 获取标准号,如果国标文件中存在则不进行后粗操作
|
||||
String standardCode = lawsAsmsDomestic.getCode();
|
||||
LawsDomesticStandard testStandard = lawsDomesticStandardService.queryByStandardNumber(standardCode);
|
||||
if(!Objects.isNull(testStandard)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] parts = lawsAsmsDomestic.getCode().split("[-\\s]"); // 使用空格或破折号作为分隔符
|
||||
if (parts.length < 3) {
|
||||
parts = lawsAsmsDomestic.getCode().split("[—\\s]"); // 使用空格或破折号作为分隔符
|
||||
@@ -546,20 +555,30 @@ public class LawsAsmsOpenApiServiceImpl extends ServiceImpl<LawsAsmsOpenApiMappe
|
||||
lawsDomesticStandardService.delById(lawsAsmsDomestic.getId());
|
||||
}
|
||||
lawsDomesticStandardService.saveOrUpdate(lawsDomesticStandard);
|
||||
addNum.getAndIncrement();
|
||||
// 同步es数据库
|
||||
lawsHomeSearchService.updateEsData(LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD, lawsDomesticStandard.getId(), LawsHomeSearchCommon.LAWS_ES_ADD);
|
||||
});
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), lawsAsmsDomesticList.size());
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), addNum);
|
||||
} else if ("3".equals(lawsAsmsOpenApi.getApiType()) && "xiaobodata/openApi/domesticLaws/getFile".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 国内法规相关文档
|
||||
LambdaQueryWrapper<LawsAsmsDomestic> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.orderByAsc(LawsAsmsDomestic::getId);
|
||||
List<LawsAsmsDomestic> lawsAsmsDomesticList = lawsAsmsDomesticService.list(queryWrapper);
|
||||
lawsAsmsDomesticList.forEach(lawsAsmsDomestic -> {
|
||||
String id = lawsAsmsDomestic.getId();
|
||||
// 初始化是通过ASMS同步过来的数据 进行标准表的匹配。
|
||||
// 但是20240320日 需要二次刷新标准的数据,所以就不能用ASMS表中标准的id了,需要用国标表中标准的信息去匹配。
|
||||
|
||||
String code = lawsAsmsDomestic.getCode();
|
||||
String id = lawsAsmsDomestic.getId();
|
||||
LawsDomesticStandard testStandard = lawsDomesticStandardService.queryByStandardNumber(code);
|
||||
|
||||
if(!Objects.isNull(testStandard)){
|
||||
id = testStandard.getId();
|
||||
}
|
||||
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("lawCode", code);
|
||||
Map<String, Object> objectMap = asmsPostUtil.sendGetReq2(lawsAsmsOpenApi.getApiUrl(), paramMap);
|
||||
@@ -988,7 +1007,19 @@ public class LawsAsmsOpenApiServiceImpl extends ServiceImpl<LawsAsmsOpenApiMappe
|
||||
ossFile.setStandardId(id);
|
||||
ossFile.setStandardNo(code);
|
||||
ossFile.setStandardFileType("publish_of_original");
|
||||
ossFileService.save(ossFile);
|
||||
// 需要先判断原系统中是否存在该文件地址的相关链接,存在则不进行上传了,不存在再上传。
|
||||
LambdaQueryWrapper<OSSFile> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OSSFile::getUrl, filePath + url);
|
||||
List<OSSFile> list = ossFileService.list(wrapper);
|
||||
if (list.isEmpty()){
|
||||
ossFileService.save(ossFile);
|
||||
}else if (list.size() > 1){
|
||||
// 很多个的话 删除后重新上传。
|
||||
for (OSSFile file : list) {
|
||||
ossFileService.removeById(file.getId());
|
||||
}
|
||||
ossFileService.save(ossFile);
|
||||
}
|
||||
log.info("存储文件:{},url:{}", fileName, url);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user