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