|
@@ -22,6 +22,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
+import org.jetbrains.annotations.Nullable;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
@@ -76,46 +78,35 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
Elements table = doc.getElementsByAttribute("dqid");
|
|
|
List<String> dqid = new ArrayList<>();
|
|
|
- List<String> keys = new ArrayList<>();
|
|
|
+ Map<String, String> dqIdMap = new HashMap<>();
|
|
|
+ Map<String, String> keys = new HashMap<>();
|
|
|
for(Element ek:table){
|
|
|
- dqid.addAll(Func.toStrList("\\|\\|",ek.attr("dqid")));
|
|
|
+ List<String> list = Func.toStrList("\\|\\|", ek.attr("dqid"));
|
|
|
+ dqid.addAll(list);
|
|
|
+ Elements keyname = ek.getElementsByAttributeValueStarting("keyname", "key_");
|
|
|
+ if (keyname != null && !keyname.isEmpty()) {
|
|
|
+ String key = keyname.get(0).attr("keyname");
|
|
|
+ for (String s : list) {
|
|
|
+ dqIdMap.put(s, key);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
Elements keyNames = doc.getElementsByAttribute("keyname");
|
|
|
if(Func.isNotEmpty(keyNames)){
|
|
|
for(Element keyName:keyNames){
|
|
|
- keys.add(keyName.attr("keyname"));
|
|
|
+ keys.put(keyName.attr("keyname"), keyName.attr("placeholder"));
|
|
|
}
|
|
|
}
|
|
|
if(Func.isNotEmpty(textdictInfo.getShowType()) && textdictInfo.getShowType() == 1){
|
|
|
+ List<TextdictInfo> textdictInfos = new ArrayList<>();
|
|
|
if(Func.isNotEmpty(dqid) && dqid.size() > 0){
|
|
|
textdict = baseMapper.selectTextdictBYIds(dqid,privateInfo.getProjectId());
|
|
|
+ textdict = getTextdictInfoByDqIdAndKeyName(textdict, dqIdMap, keys, textdictInfos);
|
|
|
}else {
|
|
|
textdict = new ArrayList<>();
|
|
|
}
|
|
|
- List<TextdictInfoVO> textdictList= baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
|
|
|
- if (textdict == null || textdict.isEmpty()) {
|
|
|
- textdict = textdictList;
|
|
|
- if (textdict != null) {
|
|
|
- textdict.forEach(textdictInfoVO -> textdictInfoVO.setIsSystem(2));
|
|
|
- }
|
|
|
- addSign(textdict, doc, privateInfo, dqid, textdict);
|
|
|
- } else if (textdictList != null && !textdictList.isEmpty()) {
|
|
|
- Map<String, Map<String, TextdictInfoVO>> map = textdict.stream().filter(vo -> vo.getColKey() != null && vo.getColKey().contains("__")).collect(Collectors.groupingBy(vo -> vo.getColKey().split("__")[1], Collectors.toMap(TextdictInfoVO::getSigRoleId, v -> v, (v1, v2) -> v1)));
|
|
|
- List<TextdictInfoVO> collect = textdictList.stream().filter(textdictInfoVO -> {
|
|
|
- if (textdictInfoVO.getColKey() == null || !textdictInfoVO.getColKey().contains("__")) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- Map<String, TextdictInfoVO> voMap = map.get(textdictInfoVO.getColKey().split("__")[1]);
|
|
|
- textdictInfoVO.setIsSystem(2);
|
|
|
- if (voMap != null && !voMap.isEmpty() ) {
|
|
|
- return voMap.get(textdictInfoVO.getSigRoleId()) == null;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- textdict.addAll(collect);
|
|
|
- addSign(collect, doc, privateInfo, dqid,textdict);
|
|
|
- }
|
|
|
if (!keys.isEmpty()) {
|
|
|
+ textdict = getTextDictInfoBySystem(textdictInfo, keys, textdictInfos, textdict, doc, privateInfo, dqid);
|
|
|
TextdictInfoVO temp = null;
|
|
|
if (textdict != null && !textdict.isEmpty()) {
|
|
|
temp = textdict.get(0);
|
|
@@ -128,7 +119,7 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
temp.setType(2);
|
|
|
}
|
|
|
// 查询电签库配置
|
|
|
- List<TextdictInfoVO> textdictConfigList = iSignConfigService.hasSignConfig(privateInfo.getInitTableName(), keys, temp);
|
|
|
+ List<TextdictInfoVO> textdictConfigList = iSignConfigService.hasSignConfig(privateInfo.getInitTableName(), keys.keySet(), temp);
|
|
|
if (textdict == null || textdict.isEmpty()) {
|
|
|
textdict = textdictConfigList;
|
|
|
} else {
|
|
@@ -147,7 +138,15 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
- textdict = baseMapper.selectTextdictInfoByExcelId(page, textdictInfo);
|
|
|
+ if (!keys.isEmpty()) {
|
|
|
+ // 根据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));
|
|
|
+ textdict = new ArrayList<>(map.values());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
@@ -157,6 +156,94 @@ 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
|
|
|
+ Map<String, TextdictInfo> collect = textdictInfos.stream().collect(Collectors.toMap(info -> info.getColKey() + info.getColName(), v -> v, (v1, v2) -> v1));
|
|
|
+ for (TextdictInfoVO vo : textdictList) {
|
|
|
+ TextdictInfo info = collect.get(vo.getColKey() + vo.getColName());
|
|
|
+ if (info != null) {
|
|
|
+ vo.setId(info.getId());
|
|
|
+ vo.setProjectId("0");
|
|
|
+ BeanUtil.copyProperties(vo, info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TextdictInfo> list = textdictInfos.stream().filter(info -> StringUtil.hasText(info.getSigRoleId())).collect(Collectors.toList());
|
|
|
+ this.saveBatch( list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (textdict.isEmpty()) {
|
|
|
+ textdict = textdictList;
|
|
|
+ if (textdict != null) {
|
|
|
+ textdict.forEach(textdictInfoVO -> textdictInfoVO.setIsSystem(2));
|
|
|
+ }
|
|
|
+ addSign(textdict, doc, privateInfo, dqid, textdict);
|
|
|
+ } else if (textdictList != null && !textdictList.isEmpty()) {
|
|
|
+ Map<String, Map<String, TextdictInfoVO>> map = textdict.stream().filter(vo -> vo.getColKey() != null && vo.getColKey().contains("__")).collect(Collectors.groupingBy(vo -> vo.getColKey().split("__")[1], Collectors.toMap(TextdictInfoVO::getSigRoleId, v -> v, (v1, v2) -> v1)));
|
|
|
+ List<TextdictInfoVO> collect = textdictList.stream().filter(textdictInfoVO -> {
|
|
|
+ if (textdictInfoVO.getColKey() == null || !textdictInfoVO.getColKey().contains("__")) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ Map<String, TextdictInfoVO> voMap = map.get(textdictInfoVO.getColKey().split("__")[1]);
|
|
|
+ textdictInfoVO.setIsSystem(2);
|
|
|
+ if (voMap != null && !voMap.isEmpty() ) {
|
|
|
+ return voMap.get(textdictInfoVO.getSigRoleId()) == null;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ textdict.addAll(collect);
|
|
|
+ addSign(collect, doc, privateInfo, dqid, textdict);
|
|
|
+ }
|
|
|
+ return textdict;
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private List<TextdictInfoVO> getTextdictInfoByDqIdAndKeyName(List<TextdictInfoVO> textdict, Map<String, String> dqIdMap, Map<String, String> keys, List<TextdictInfo> textdictInfos) {
|
|
|
+ if (textdict == null) {
|
|
|
+ textdict = new ArrayList<>();
|
|
|
+ }
|
|
|
+ Map<String, TextdictInfoVO> map = textdict.stream().collect(Collectors.toMap(item -> item.getId() + "", v -> v, (v1, v2) -> v2));
|
|
|
+ dqIdMap.forEach((k, v) -> {
|
|
|
+ if (map.containsKey(k)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long id = null;
|
|
|
+ try {
|
|
|
+ id = Long.parseLong(k);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn(e.getMessage());
|
|
|
+ }
|
|
|
+ String colName = keys.get(v);
|
|
|
+ if (id == null || v == null || colName == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ 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()));
|
|
|
+ }
|
|
|
+ return textdict;
|
|
|
+ }
|
|
|
+
|
|
|
private void addSign(List<TextdictInfoVO> collect, Document doc, WbsTreePrivate privateInfo, List<String> dqid,List<TextdictInfoVO> allTextdict) {
|
|
|
if (collect == null || collect.isEmpty()) {
|
|
|
return;
|