fix: 88337 企业标准-引用的标准没有收到消息

This commit is contained in:
2024-08-08 18:35:02 +08:00
parent c9d613a5c8
commit f050a5e059
@@ -148,39 +148,42 @@ public class LawsReplacedStandardServiceImpl extends ServiceImpl<LawsReplacedSta
log.error("企业标准不存在,id" + standardId);
return;
}
// 找到所有当前标准的老版本标准
LambdaQueryWrapper<LawsEnterpriseStandard> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(LawsEnterpriseStandard::getStandardNumberTemp, es.getStandardNumberTemp());
queryWrapper.eq(LawsEnterpriseStandard::getStandardCode, es.getStandardCode());
queryWrapper.eq(LawsEnterpriseStandard::getNameCode, es.getNameCode());
queryWrapper.eq(LawsEnterpriseStandard::getCategoryCode, es.getCategoryCode());
queryWrapper.ne(LawsEnterpriseStandard::getYearNumber, es.getYearNumber());
queryWrapper.ne(LawsEnterpriseStandard::getId, es.getId());
List<LawsEnterpriseStandard> oldVersionStandard = esService.list(queryWrapper);
// 找到所有代替的标准
LambdaQueryWrapper<LawsReplacedStandard> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(LawsReplacedStandard::getType, 1);
queryWrapper.eq(LawsReplacedStandard::getReplacedBy, es.getStandardNumber());
List<LawsReplacedStandard> replacedStandardList = list(queryWrapper);
List<String> replaceNumberList = new ArrayList<>();
replacedStandardList.forEach(e -> {
String standardNumber = e.getReplaced().split("")[0];
replaceNumberList.add(standardNumber);
});
LambdaQueryWrapper<LawsEnterpriseStandard> esQueryWrapper = new LambdaQueryWrapper<>();
esQueryWrapper.in(LawsEnterpriseStandard::getStandardNumber, replaceNumberList);
List<LawsEnterpriseStandard> oldVersionStandard = esService.list(esQueryWrapper);
if (CollUtil.isEmpty(oldVersionStandard)) {
log.info("企业标准没有老版本,id" + standardId);
return;
}
// 找到年代号最大的那个
LawsEnterpriseStandard maxYearNumberStandard = oldVersionStandard.stream()
.max(Comparator.comparing(LawsEnterpriseStandard::getYearNumber)).get();
// 找到所有引用这些标准的标准
LambdaQueryWrapper<LawsReplacedStandard> replacedStandardWrapper = new LambdaQueryWrapper<>();
replacedStandardWrapper.eq(LawsReplacedStandard::getType, "2");
replacedStandardWrapper.like(LawsReplacedStandard::getReplaced, maxYearNumberStandard.getStandardNumber());
List<LawsReplacedStandard> replacedStandardList = list(replacedStandardWrapper);
if (CollUtil.isEmpty(replacedStandardList)) {
replacedStandardWrapper.eq(LawsReplacedStandard::getType, 2);
for (LawsEnterpriseStandard standard : oldVersionStandard) {
replacedStandardWrapper.like(LawsReplacedStandard::getReplaced, standard.getStandardNumber()).or();
}
List<LawsReplacedStandard> referenceStandardList = list(replacedStandardWrapper);
if (CollUtil.isEmpty(referenceStandardList)) {
log.info("企业标准没有被引用,id" + standardId);
return;
}
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
esWrapper.in(LawsEnterpriseStandard::getStandardNumber, replacedStandardList.stream()
esWrapper.in(LawsEnterpriseStandard::getStandardNumber, referenceStandardList.stream()
.map(LawsReplacedStandard::getReplacedBy).collect(Collectors.toSet()));
List<LawsEnterpriseStandard> replacedStandard = esService.list(esWrapper);
List<LawsEnterpriseStandard> referenceStandard = esService.list(esWrapper);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 发消息
for (LawsEnterpriseStandard standard : replacedStandard) {
for (LawsEnterpriseStandard standard : referenceStandard) {
SendMessageDTO sendMessageDTO = new SendMessageDTO();
sendMessageDTO.setTemplateCode(MessageTemplateCodeCommon.IMPLEMENTATION_DATE_NEW_STANDARD);
Map<String, String> sendMap = new HashMap<>();