Bläddra i källkod

电签系统推荐优化:根据excel_id 和col_key进行推荐

lvy 3 veckor sedan
förälder
incheckning
8d2f0c998f

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.java

@@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.data.repository.query.Param;
 
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -52,4 +53,6 @@ public interface TextdictInfoMapper extends EasyBaseMapper<TextdictInfo> {
     TextdictInfo selectTextdictInfoOne(@Param("id") String id,@Param("sigRoleId") String sigRoleId,@Param("projectId") String projectId);
 
     void updateHtmlUrl(@Param("htmlUrl") String htmlUrl,@Param("projectId") String projectId, @Param("excelId") Long pKeyId);
+
+    List<TextdictInfoVO> selectTextdictInfoByExcelIdAndColKey(@Param("excelId") String excelId, @Param("colKeys") Collection<String> colKeys);
 }

+ 6 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TextdictInfoMapper.xml

@@ -65,6 +65,12 @@
             and sig_role_id = #{sigRoleId}
             and project_id= #{projectId}
     </select>
+    <select id="selectTextdictInfoByExcelIdAndColKey" resultMap="textdictInfoVoResultMap">
+        SELECT * from m_textdict_info where is_deleted = 0 and type in('2','6') and excel_id = #{excelId} and is_deleted = 0
+        <foreach collection="colKeys" item="key" separator="," open=" and col_key in ( " close=" )" >
+            #{key}
+        </foreach>
+    </select>
     <update id="updateHtmlUrl">
         update m_wbs_tree_contract set html_url = #{htmlUrl} where type = 2 and project_id = #{projectId} and is_type_private_pid = #{pKeyId};
     </update>

+ 2 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/ISignConfigService.java

@@ -12,6 +12,7 @@ import org.springblade.manager.vo.WbsFormElementVO3;
 import org.springblade.system.vo.RoleVO;
 import org.springblade.system.vo.RoleVO2;
 
+import java.util.Collection;
 import java.util.List;
 
 public interface ISignConfigService extends BaseService<SignConfig> {
@@ -30,5 +31,5 @@ public interface ISignConfigService extends BaseService<SignConfig> {
 
     List<TableInfo> tableList(Integer tableType, String name);
 
-    List<TextdictInfoVO> hasSignConfig(String initTableName, List<String> keys, TextdictInfoVO vo);
+    List<TextdictInfoVO> hasSignConfig(String initTableName, Collection<String> keys, TextdictInfoVO vo);
 }

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/SignConfigServiceImpl.java

@@ -293,7 +293,7 @@ public class SignConfigServiceImpl extends BaseServiceImpl<SignConfigMapper, Sig
     }
 
     @Override
-    public List<TextdictInfoVO> hasSignConfig(String initTableName, List<String> keyNames, TextdictInfoVO vo) {
+    public List<TextdictInfoVO> hasSignConfig(String initTableName, Collection<String> keyNames, TextdictInfoVO vo) {
         List<TextdictInfoVO> textdictInfoVOS = new ArrayList<>();
         if (keyNames == null || keyNames.isEmpty()) {
             return textdictInfoVOS;

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

@@ -76,14 +76,14 @@ 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> keys = new HashMap<>();
                 for(Element ek:table){
                     dqid.addAll(Func.toStrList("\\|\\|",ek.attr("dqid")));
                 }
                 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){
@@ -92,30 +92,36 @@ public class TextdictInfoServiceImpl extends ServiceImpl<TextdictInfoMapper, Tex
                     }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));
+                    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));
+                            textdictList = new ArrayList<>(map.values());
                         }
-                        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;
+                        if (textdict == null || textdict.isEmpty()) {
+                            textdict = textdictList;
+                            if (textdict != null) {
+                                textdict.forEach(textdictInfoVO -> textdictInfoVO.setIsSystem(2));
                             }
-                            return true;
-                        }).collect(Collectors.toList());
-                        textdict.addAll(collect);
-                        addSign(collect, doc, privateInfo, dqid,textdict);
-                    }
-                    if (!keys.isEmpty()) {
+                            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);
+                        }
+
                         TextdictInfoVO temp = null;
                         if (textdict != null && !textdict.isEmpty()) {
                             temp = textdict.get(0);
@@ -128,7 +134,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 +153,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);