|
@@ -101,12 +101,13 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
List<TextdictInfo> textdictInfos = new ArrayList<>();
|
|
|
if(Func.isNotEmpty(dqid) && dqid.size() > 0){
|
|
|
textdict = baseMapper.selectTextdictBYIds(dqid,privateInfo.getProjectId());
|
|
|
+ // 系统推荐方案一:根据dqId、col_key和col_name查询
|
|
|
textdict = getTextdictInfoByDqIdAndKeyName(textdict, dqIdMap, keys, textdictInfos);
|
|
|
}else {
|
|
|
- textdict = new ArrayList<>();
|
|
|
+ // 系统推荐方法二:根据excel_id, col_key, col_name查询
|
|
|
+ textdict = getTextDictInfoBySystem(textdictInfo, keys, textdict, doc, privateInfo, dqid);
|
|
|
}
|
|
|
if (!keys.isEmpty()) {
|
|
|
- textdict = getTextDictInfoBySystem(textdictInfo, keys, textdictInfos, textdict, doc, privateInfo, dqid);
|
|
|
TextdictInfoVO temp = null;
|
|
|
if (textdict != null && !textdict.isEmpty()) {
|
|
|
temp = textdict.get(0);
|
|
@@ -120,6 +121,7 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
}
|
|
|
// 查询电签库配置
|
|
|
List<TextdictInfoVO> textdictConfigList = iSignConfigService.hasSignConfig(privateInfo.getInitTableName(), keys.keySet(), temp);
|
|
|
+ saveSignTextDictInfo(textdictInfos, textdictConfigList, keys);
|
|
|
if (textdict == null || textdict.isEmpty()) {
|
|
|
textdict = textdictConfigList;
|
|
|
} else {
|
|
@@ -157,31 +159,39 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
return page.setRecords(textdict);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 系统推荐
|
|
|
- */
|
|
|
- @Nullable
|
|
|
- private List<TextdictInfoVO> getTextDictInfoBySystem(TextdictInfoVO textdictInfo, Map<String, String> keys, List<TextdictInfo> textdictInfos, List<TextdictInfoVO> textdict, Document doc, WbsTreePrivate privateInfo, List<String> dqid) {
|
|
|
- // 根据excel_id 和col_key 查询
|
|
|
- List<TextdictInfoVO> textdictList= baseMapper.selectTextdictInfoByExcelIdAndColKey(textdictInfo.getExcelId(), keys.keySet());
|
|
|
- if (textdictList != null) {
|
|
|
- Map<String, TextdictInfoVO> map = textdictList.stream().filter(vo -> vo.getColName() != null && vo.getColName().equals(keys.get(vo.getColKey()))).collect(Collectors.toMap(vo -> vo.getColKey() + vo.getSigRoleId(), v -> v, (v1, v2) -> v1));
|
|
|
- textdictList = new ArrayList<>(map.values());
|
|
|
- if (!textdictInfos.isEmpty()) {
|
|
|
- // 保存到数据库,从系统推荐中获取roleId
|
|
|
+ private void saveSignTextDictInfo(List<TextdictInfo> textdictInfos, List<TextdictInfoVO> textdictRecommendedList, Map<String, String> keys) {
|
|
|
+ if (!textdictInfos.isEmpty()) {
|
|
|
+ // 保存到数据库,从系统推荐中获取roleId
|
|
|
+ if (textdictRecommendedList != null && !textdictRecommendedList.isEmpty()) {
|
|
|
+ Map<String, TextdictInfoVO> map = textdictRecommendedList.stream().filter(vo -> vo.getColName() != null && vo.getColName().equals(keys.get(vo.getColKey()))).collect(Collectors.toMap(vo -> vo.getColKey() + vo.getSigRoleId(), v -> v, (v1, v2) -> v1));
|
|
|
+ Collection<TextdictInfoVO> values = map.values();
|
|
|
Map<String, TextdictInfo> collect = textdictInfos.stream().collect(Collectors.toMap(info -> info.getColKey() + info.getColName(), v -> v, (v1, v2) -> v1));
|
|
|
- for (TextdictInfoVO vo : textdictList) {
|
|
|
+ for (TextdictInfoVO vo : values) {
|
|
|
TextdictInfo info = collect.get(vo.getColKey() + vo.getColName());
|
|
|
if (info != null) {
|
|
|
vo.setId(info.getId());
|
|
|
vo.setProjectId("0");
|
|
|
BeanUtil.copyProperties(vo, info);
|
|
|
+ vo.setIsSystem(2);
|
|
|
}
|
|
|
}
|
|
|
List<TextdictInfo> list = textdictInfos.stream().filter(info -> StringUtil.hasText(info.getSigRoleId())).collect(Collectors.toList());
|
|
|
this.saveBatch( list);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 系统推荐
|
|
|
+ */
|
|
|
+ @Nullable
|
|
|
+ private List<TextdictInfoVO> getTextDictInfoBySystem(TextdictInfoVO textdictInfo, Map<String, String> keys, List<TextdictInfoVO> textdict, Document doc, WbsTreePrivate privateInfo, List<String> dqid) {
|
|
|
+ // 根据excel_id 和col_key 查询
|
|
|
+ List<TextdictInfoVO> textdictList= baseMapper.selectTextdictInfoByExcelIdAndColKey(textdictInfo.getExcelId(), keys.keySet());
|
|
|
+ if (textdictList != null) {
|
|
|
+ Map<String, TextdictInfoVO> map = textdictList.stream().filter(vo -> vo.getColName() != null && vo.getColName().equals(keys.get(vo.getColKey()))).collect(Collectors.toMap(vo -> vo.getColKey() + vo.getSigRoleId(), v -> v, (v1, v2) -> v1));
|
|
|
+ textdictList = new ArrayList<>(map.values());
|
|
|
+ }
|
|
|
if (textdict.isEmpty()) {
|
|
|
textdict = textdictList;
|
|
|
if (textdict != null) {
|
|
@@ -212,9 +222,10 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
if (textdict == null) {
|
|
|
textdict = new ArrayList<>();
|
|
|
}
|
|
|
- Map<String, TextdictInfoVO> map = textdict.stream().collect(Collectors.toMap(item -> item.getId() + "", v -> v, (v1, v2) -> v2));
|
|
|
+ Map<String, TextdictInfoVO> idsMap = textdict.stream().collect(Collectors.toMap(item -> item.getId() + "", v -> v, (v1, v2) -> v2));
|
|
|
+ Map<String, TextdictInfoVO> colKeyMap = textdict.stream().collect(Collectors.toMap(item -> item.getId() + "", v -> v, (v1, v2) -> v2));
|
|
|
dqIdMap.forEach((k, v) -> {
|
|
|
- if (map.containsKey(k)) {
|
|
|
+ if (idsMap.containsKey(k) || colKeyMap.containsKey(v)) {
|
|
|
return;
|
|
|
}
|
|
|
Long id = null;
|
|
@@ -230,16 +241,36 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
TextdictInfo info = new TextdictInfo();
|
|
|
info.setId(id);
|
|
|
info.setColKey(v);
|
|
|
- info.setColName(colName);
|
|
|
textdictInfos.add(info);
|
|
|
});
|
|
|
if (!textdictInfos.isEmpty()) {
|
|
|
List<TextdictInfoVO> list = baseMapper.selectTextDictInfoByIdAndColKeyAndColName(textdictInfos);
|
|
|
- Map<String, TextdictInfoVO> voMap = list.stream().collect(Collectors.toMap(item -> item.getId() + item.getColKey() + item.getColName(), item -> item, (v1, v2) -> v1));
|
|
|
- Collection<TextdictInfoVO> values = voMap.values();
|
|
|
- values.forEach(item -> item.setIsSystem(2));
|
|
|
- textdict.addAll(values);
|
|
|
- textdictInfos.removeIf(item -> voMap.containsKey(item.getId() + item.getColKey() + item.getColName()));
|
|
|
+ Map<String, List<TextdictInfoVO>> voMap = list.stream().collect(Collectors.groupingBy(item -> item.getId() + item.getColKey()));
|
|
|
+ List<TextdictInfoVO> tempList = new ArrayList<>();
|
|
|
+ voMap.forEach((key, values) -> {
|
|
|
+ TextdictInfoVO temp = null;
|
|
|
+ if (values.size() == 1) {
|
|
|
+ temp = values.get(0);
|
|
|
+ } else {
|
|
|
+ for (TextdictInfoVO value : values) {
|
|
|
+ String colName = keys.get(value.getColKey());
|
|
|
+ if (colName == null || colName.equals(value.getColName())) {
|
|
|
+ temp = value;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (temp == null) {
|
|
|
+ // 出现次数最多
|
|
|
+ Map<String, List<TextdictInfoVO>> collect = values.stream().collect(Collectors.groupingBy(TextdictInfoVO::getColName));
|
|
|
+ temp = collect.entrySet().stream().max(Comparator.comparingInt(entry -> entry.getValue().size())).get().getValue().get(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ temp.setIsSystem(2);
|
|
|
+ tempList.add(temp);
|
|
|
+ colKeyMap.put(temp.getColKey(), temp);
|
|
|
+ });
|
|
|
+ textdict.addAll(tempList);
|
|
|
+ textdictInfos.removeIf(item -> voMap.containsKey(item.getId() + item.getColKey()) || colKeyMap.containsKey(item.getColKey()));
|
|
|
}
|
|
|
return textdict;
|
|
|
}
|