fix(自定义对比): 查询问题修复

This commit is contained in:
yjz
2023-10-30 13:48:40 +08:00
parent 13818b0d59
commit 30f6073581
2 changed files with 37 additions and 27 deletions
@@ -23,9 +23,9 @@
list_name, list_name,
group_concat(s.standard_number order by s.create_by) referenceStandard, group_concat(s.standard_number order by s.create_by) referenceStandard,
(select group_concat(os.country_or_region order by s.create_by) (select group_concat(os.country_or_region order by s.create_by)
from laws_custom_compare_info_standard s from laws_custom_compare_info_standard s1
left join laws_overseas_standard os on s.standard_id = os.id and s.standard_type = '2' and os.del_flag = 0 left join laws_overseas_standard os on s1.standard_id = os.id and s1.standard_type = '2' and os.del_flag = 0
where s.del_flag = 0 where s1.del_flag = 0 and s1.info_id = i.id
) referenceCountry, ) referenceCountry,
is_show, is_show,
concat(u.realname, '(', u.username, ')') author, concat(u.realname, '(', u.username, ')') author,
@@ -35,8 +35,8 @@
i.update_time, i.update_time,
i.del_flag i.del_flag
from laws_custom_compare_info i from laws_custom_compare_info i
left join laws_custom_compare_info_standard s on i.id = s.info_id left join laws_custom_compare_info_standard s on i.id = s.info_id and s.del_flag = 0
left join sys_user u on i.create_by = u.username left join sys_user u on i.create_by = u.username and u.del_flag = 0
${ew.customSqlSegment} ${ew.customSqlSegment}
group by i.id group by i.id
</sql> </sql>
@@ -194,6 +194,7 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
List<StandardVO> standardVOS = queryStandardList(standardVO); List<StandardVO> standardVOS = queryStandardList(standardVO);
List<LawsCustomCompareInfoStandard> lawsCustomCompareInfoStandards = BeanCopyUtils.copyBeanList(standardVOS, LawsCustomCompareInfoStandard.class); List<LawsCustomCompareInfoStandard> lawsCustomCompareInfoStandards = BeanCopyUtils.copyBeanList(standardVOS, LawsCustomCompareInfoStandard.class);
for (LawsCustomCompareInfoStandard lawsCustomCompareInfoStandard : lawsCustomCompareInfoStandards) { for (LawsCustomCompareInfoStandard lawsCustomCompareInfoStandard : lawsCustomCompareInfoStandards) {
String standardId = lawsCustomCompareInfoStandard.getId();
String snowflakeId = String.valueOf(SnowflakeUtils.snowflake()); String snowflakeId = String.valueOf(SnowflakeUtils.snowflake());
// 自定义对比单元格数据更新 // 自定义对比单元格数据更新
lawsCustomCompareCellService.update( lawsCustomCompareCellService.update(
@@ -204,7 +205,7 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
lawsCustomCompareInfoStandard.setId(snowflakeId); lawsCustomCompareInfoStandard.setId(snowflakeId);
lawsCustomCompareInfoStandard.setInfoId(lawsCustomCompareInfo.getId()); lawsCustomCompareInfoStandard.setInfoId(lawsCustomCompareInfo.getId());
lawsCustomCompareInfoStandard.setStandardId(lawsCustomCompareInfoStandard.getId()); lawsCustomCompareInfoStandard.setStandardId(standardId);
lawsCustomCompareInfoStandard.setCreateBy(""); lawsCustomCompareInfoStandard.setCreateBy("");
lawsCustomCompareInfoStandard.setCreateTime(null); lawsCustomCompareInfoStandard.setCreateTime(null);
lawsCustomCompareInfoStandard.setUpdateBy(""); lawsCustomCompareInfoStandard.setUpdateBy("");
@@ -681,31 +682,40 @@ public class LawsCustomCompareInfoServiceImpl extends ServiceImpl<LawsCustomComp
standardVOList.addAll(domesticStandardVOList); standardVOList.addAll(domesticStandardVOList);
standardVOList.addAll(overseasStandardVOList); standardVOList.addAll(overseasStandardVOList);
standardVOList.addAll(enterpriseStandardVOList); standardVOList.addAll(enterpriseStandardVOList);
// 获取字典 Map<String, List<StandardVO>> countryMap = getCountryMap(infoId, standardVOList);
List<SysDictItem> sysDictItemList = getDicItem("country_or_region"); tableDetailVO.setCountryMap(countryMap);
}else {
Map<String, List<StandardVO>> countryMap = new HashMap<>();
tableDetailVO.setCountryMap(countryMap);
}
}
// 按国家/地区分组 @NotNull
Map<String, List<StandardVO>> countryMap = standardVOList.stream() private Map<String, List<StandardVO>> getCountryMap(String infoId, List<StandardVO> standardVOList) {
.map(v -> { // 获取字典
v.setInfoId(infoId); List<SysDictItem> sysDictItemList = getDicItem("country_or_region");
// 字典翻译 // 按国家/地区分组
String countryOrRegion = v.getCountryOrRegion(); List<StandardVO> countryMap = standardVOList.stream()
if (StringUtils.isNotBlank(countryOrRegion)){ .map(v -> {
List<String> list = Arrays.asList(countryOrRegion.split(",")); v.setInfoId(infoId);
List<String> sysDictItems = sysDictItemList.stream() // 字典翻译
.filter(o -> list String countryOrRegion = v.getCountryOrRegion();
.contains(o.getItemValue())).map(SysDictItem::getItemText).collect(Collectors.toList()); if (StringUtils.isNotBlank(countryOrRegion)) {
if (!sysDictItems.isEmpty()){ List<String> list = Arrays.asList(countryOrRegion.split(","));
v.setCountryOrRegion(String.join(",", sysDictItems)); List<String> sysDictItems = sysDictItemList.stream()
} .filter(o -> list
.contains(o.getItemValue())).map(SysDictItem::getItemText).collect(Collectors.toList());
if (!sysDictItems.isEmpty()) {
v.setCountryOrRegion(String.join(",", sysDictItems));
}else { }else {
v.setCountryOrRegion(""); v.setCountryOrRegion("");
} }
return v; } else {
}) v.setCountryOrRegion("");
.collect(Collectors.groupingBy(StandardVO::getCountryOrRegion)); }
tableDetailVO.setCountryMap(countryMap); return v;
} }).collect(Collectors.toList());
return countryMap.stream().collect(Collectors.groupingBy(StandardVO::getCountryOrRegion));
} }
private List<SysDictItem> getDicItem(String dicCode) { private List<SysDictItem> getDicItem(String dicCode) {