【update】ASMS同步国标数据的处理
This commit is contained in:
@@ -6,3 +6,62 @@ ALTER TABLE `laws_overseas_standard` MODIFY COLUMN `country_or_region` varchar(5
|
||||
-- 20240319 夏工开发的标签管理 需要增加新的生成逻辑。
|
||||
INSERT INTO `sys_fill_rule` (`id`, `rule_name`, `rule_code`, `rule_class`, `rule_params`, `update_by`, `update_time`, `create_by`, `create_time`) VALUES ('1202787665403065860', '标签编码生成', 'label_tree_node', 'com.jero.modules.laws.labeldatabase.rule.LabelTreeRule', NULL, 'admin', '2019-12-09 10:36:54', 'admin', '2019-12-06 11:11:31');
|
||||
|
||||
-- ASMS 对接 国标数据的处理
|
||||
-- 1、删除系统中同步的带 长横杠 且没有体系数据的标准 20240320
|
||||
|
||||
SELECT laws.standard_name, laws.id, laws.standard_number , node.node_code
|
||||
FROM laws_domestic_standard AS laws
|
||||
LEFT JOIN laws_node_relation AS node
|
||||
ON laws.id = node.unique_relation_flag
|
||||
WHERE laws.standard_number LIKE '%—%' AND laws.del_flag != 1 AND node.node_code IS NULL
|
||||
|
||||
|
||||
DELETE laws
|
||||
FROM laws_domestic_standard AS laws
|
||||
LEFT JOIN laws_node_relation AS node
|
||||
ON laws.id = node.unique_relation_flag
|
||||
WHERE laws.standard_number LIKE '%—%' AND laws.del_flag != 1 AND node.node_code IS NULL;
|
||||
|
||||
|
||||
-- 2、删除 ASMS系统中同步的带 长横杠 有体系数据 且 系统中有 短横杠的 标准数据 20240320
|
||||
DELETE
|
||||
FROM
|
||||
laws_domestic_standard
|
||||
WHERE
|
||||
standard_number IN (
|
||||
SELECT
|
||||
standard_number
|
||||
FROM
|
||||
(
|
||||
SELECT REPLACE
|
||||
( laws.standard_number, '—', '-' ) AS standard_number
|
||||
FROM
|
||||
laws_domestic_standard AS laws
|
||||
LEFT JOIN laws_node_relation AS node ON laws.id = node.unique_relation_flag
|
||||
WHERE
|
||||
laws.standard_number LIKE '%—%'
|
||||
AND laws.del_flag != 1
|
||||
) AS tmp
|
||||
);
|
||||
|
||||
|
||||
-- 3、代替、被代替 引用被引用 数据的处理. 可以在3执行之前对 代替、被代替 引用、被应用的数据做处理 20240320
|
||||
|
||||
UPDATE laws_replaced_standard
|
||||
SET replaced = REPLACE ( replaced, '-', '—' )
|
||||
WHERE
|
||||
replaced IN ( SELECT * FROM ( SELECT standard_number FROM laws_domestic_standard WHERE standard_number LIKE '%-%' ) AS tmp );
|
||||
|
||||
UPDATE laws_replaced_standard
|
||||
SET replaced_by = REPLACE ( replaced_by, '-', '—' )
|
||||
WHERE
|
||||
replaced_by IN ( SELECT * FROM ( SELECT standard_number FROM laws_domestic_standard WHERE standard_number LIKE '%-%' ) AS tmp );
|
||||
|
||||
-- 4、将所有国标数据中的 标准号修改成 长横杆 20240320
|
||||
UPDATE laws_domestic_standard
|
||||
SET standard_number = REPLACE ( standard_number, '-', '—' )
|
||||
WHERE
|
||||
standard_number IN ( SELECT * FROM ( SELECT standard_number FROM laws_domestic_standard WHERE standard_number LIKE '%-%' ) AS tmp );
|
||||
|
||||
|
||||
|
||||
|
||||
+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