瀏覽代碼

电签配置修改

lvy 2 月之前
父節點
當前提交
4644289767

+ 25 - 26
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TextdictInfoServiceImpl.java

@@ -16,10 +16,12 @@
  */
 package org.springblade.manager.service.impl;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 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.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -30,6 +32,7 @@ import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.common.utils.SystemUtils;
 import org.springblade.core.tool.utils.*;
 import org.springblade.manager.entity.TextdictInfo;
+import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.mapper.TextdictInfoMapper;
 import org.springblade.manager.mapper.WbsTreePrivateMapper;
@@ -95,7 +98,7 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
                         if (textdict != null) {
                             textdict.forEach(textdictInfoVO -> textdictInfoVO.setIsSystem(2));
                         }
-                        addSign(textdict, doc, privateInfo, dqid);
+                        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 -> {
@@ -110,7 +113,7 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
                             return true;
                         }).collect(Collectors.toList());
                         textdict.addAll(collect);
-                        addSign(collect, doc, privateInfo, dqid);
+                        addSign(collect, doc, privateInfo, dqid,textdict);
                     }
                     if (!keys.isEmpty()) {
                         TextdictInfoVO temp = null;
@@ -154,14 +157,13 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
         }
         return page.setRecords(textdict);
     }
-    private void addSign(List<TextdictInfoVO> collect, Document doc, WbsTreePrivate privateInfo, List<String> dqid) {
+    private void addSign(List<TextdictInfoVO> collect, Document doc, WbsTreePrivate privateInfo, List<String> dqid,List<TextdictInfoVO> allTextdict) {
         if (collect == null || collect.isEmpty()) {
             return;
         }
-        List<TextdictInfoVO> textdict = collect;
         if (dqid != null && !dqid.isEmpty()) {
-            textdict = collect.stream().filter(textdictInfoVO -> !dqid.contains(textdictInfoVO.getId() + "")).collect(Collectors.toList());
-            if (textdict.isEmpty()) {
+            collect = collect.stream().filter(textdictInfoVO -> !dqid.contains(textdictInfoVO.getId() + "")).collect(Collectors.toList());
+            if (collect.isEmpty()) {
                 return;
             }
         }
@@ -169,35 +171,32 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
         Element table = doc.select("table").first();
         Elements trs = table.select("tr");
         AtomicBoolean isUpdate = new AtomicBoolean(false);
-        textdict.forEach(textdictInfoVO -> {
-            if (StringUtil.hasText(textdictInfoVO.getColKey())) {
-                String keky = textdictInfoVO.getColKey();
-                String[] trtd = keky.split("__")[1].split("_");
+        Map<String, List<TextdictInfoVO>> colKeyMap = allTextdict.stream().collect(Collectors.groupingBy(TextdictInfoVO::getColKey));
+        colKeyMap.forEach((colKey, textdictInfoVOs) -> {
+            if (StringUtil.hasText(colKey)) {
+                String[] trtd = colKey.split("__")[1].split("_");
                 Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
-                String ids = element.attr("dqId");
-                if (StringUtil.hasText(ids) && ids.contains(textdictInfoVO.getId() + "")) {
-                    return;
-                }
-                ids = StringUtil.hasText(ids) ? ids + "||" + textdictInfoVO.getId() : textdictInfoVO.getId() +  "";
-                element.removeAttr("dqId");
-                element.attr("dqId", ids);
-                if (textdictInfoVO.getType() == 2) { //个人签字 不能用户输入
-                    if (element.html().contains("el-tooltip")) {
-                        element.children().get(0).children().get(0).attr(":readonly", "true");
-                    } else {
-                        element.children().get(0).attr(":readonly", "true");
+                String dqIds = textdictInfoVOs.stream().map(vo -> vo.getId() + "").distinct().collect(Collectors.joining("||"));
+                if (StringUtil.hasText(dqIds)) {
+                    element.removeAttr("dqId");
+                    element.attr("dqId", dqIds);
+                    if (textdictInfoVOs.get(0).getType() == 2) { //个人签字 不能用户输入
+                        if (element.html().contains("el-tooltip")) {
+                            element.children().get(0).children().get(0).attr(":readonly", "true");
+                        } else {
+                            element.children().get(0).attr(":readonly", "true");
+                        }
                     }
+                    isUpdate.set(true);
                 }
-                isUpdate.set(true);
             }
         });
         if (!isUpdate.get() || !SystemUtils.isLinux()) {
             return;
         }
-        String file_path = FileUtils.getSysLocalFileUrl();
-        String filecode = SnowFlakeUtil.getId() + "";
-        String thmlUrl = file_path + "privateUrlCopy/" + privateInfo.getProjectId()+"/"+filecode + ".html";
         try {
+            String thmlUrl = privateInfo.getHtmlUrl().replace("Desktop//privateUrl", "Desktop/privateUrl");
+            thmlUrl = thmlUrl.replace("\\", "\\\\");
             File file_out = ResourceUtil.getFile(thmlUrl);
             if(!file_out.exists()){
                 FileUtils.ensureFileExists(thmlUrl);