瀏覽代碼

模板节点文件题名

cr 1 天之前
父節點
當前提交
a373244c01

+ 0 - 3
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/FlushQueryNameDTO.java

@@ -13,9 +13,6 @@ public class FlushQueryNameDTO {
     @ApiModelProperty(value = "1直接重置题名 2规则更改重置题名")
     private Integer type;
 
-    @ApiModelProperty(value = "模板节点的文件题名规则")
-    private String mbNameRule;
-
     @ApiModelProperty(value = "题名内容 type=2{资料查询ID:修改后文件题名},type=1{资料查询ID:空字符串}")
     private List<MapValue> list;
 

+ 10 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/GetNameRuleListDTO.java

@@ -0,0 +1,10 @@
+package org.springblade.business.dto;
+
+import lombok.Data;
+
+import java.util.List;
+@Data
+public class GetNameRuleListDTO {
+      private  List<PreviewNodeNameDTO> dtos;
+      private Integer templateType;
+}

+ 30 - 41
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -31,6 +31,8 @@ import org.springblade.business.dto.WbsTreeContractStatisticsDTO;
 import org.springblade.business.dto.FlushQueryNameDTO;
 import org.springblade.business.dto.PreviewNodeNameDTO;
 import org.springblade.business.dto.PreviewNodeNameDTO1;
+import org.springblade.business.dto.*;
+import org.springblade.business.dto.FlushQueryNameDTO;
 import org.springblade.business.entity.*;
 import org.springblade.business.feign.MessageWarningClient;
 import org.springblade.business.feign.OperationLogClient;
@@ -233,7 +235,6 @@ public class InformationWriteQueryController extends BladeController {
                 sgSuffix=projectInfos.get(0).getSgSuffix()==null?"":projectInfos.get(0).getSgSuffix();
                 jlSuffix=projectInfos.get(0).getJlSuffix()==null?"":projectInfos.get(0).getJlSuffix();
             }
-            if(projectInfos.get(0).getTemplateType()==2){
                 for (InformationQuery query : queryList) {
                     String result="";
                     String sql="select * from m_wbs_tree_contract where p_key_id="+query.getWbsId()+" and is_deleted=0";
@@ -250,13 +251,14 @@ public class InformationWriteQueryController extends BladeController {
                             }
                         }
                     }else {
+                        String mbnameRule = paramMap.get(query.getId());
                         //模板节点 先保存文件题名规则,在重刷
-                        if(StringUtils.isNotEmpty(dto.getMbNameRule())){
+                        if(StringUtils.isNotEmpty(mbnameRule)){
                             //先删在保存
-                            String delNameRule="delete mb_name_rule where wbs_id="+query.getWbsId()+" and classify="+query.getClassify();
+                            String delNameRule="delete from mb_name_rule where wbs_id="+query.getWbsId()+" and classify="+query.getClassify();
                             jdbcTemplate.execute(delNameRule);
                             String insertNameRule = "INSERT INTO mb_name_rule(id, wbs_id, name_rule, classify) VALUES(?, ?, ?, ?)";
-                            jdbcTemplate.update(insertNameRule, SnowFlakeUtil.getId(), query.getWbsId(), dto.getMbNameRule(), query.getClassify());
+                            jdbcTemplate.update(insertNameRule, SnowFlakeUtil.getId(), query.getWbsId(), mbnameRule, query.getClassify());
                             result=nodeNameMap.get(query.getId());
                         }
                     }
@@ -282,7 +284,7 @@ public class InformationWriteQueryController extends BladeController {
                     }
                     query.setName(result);
                 }
-            }
+
         }
         List<InformationQuery> taskList = queryList.stream().filter(o -> o.getStatus() == 1 || o.getStatus() == 2).collect(Collectors.toList());
         if(taskList.size()>0){
@@ -295,11 +297,9 @@ public class InformationWriteQueryController extends BladeController {
     }
 
 
-    public List<String> getNameRuleByPkeyId(Long pKeyId, Long projectId) {
+    public List<String> getNameRuleByPkeyId(Long pKeyId, Long projectId,Integer templateType) {
         NameRuleVo vo = new NameRuleVo();
-        String projectsql="select * from m_project_info where id="+projectId+" and is_deleted=0";
-        ProjectInfo projectInfo = jdbcTemplate.queryForObject(projectsql, new BeanPropertyRowMapper<>(ProjectInfo.class));
-        if (projectInfo != null && projectInfo.getTemplateType() == 2) {
+        if (templateType == 2) {
             String sql2 = "select * from m_wbs_param where node_id=" + pKeyId + " and type=200" + " and is_deleted=0 and k='FILE_TITLE'";
             List<WbsParam> wbsParams = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(WbsParam.class));
             WbsParam wbsParam = null;
@@ -381,8 +381,10 @@ public class InformationWriteQueryController extends BladeController {
             Integer classify=contract.getTableOwner()==null?1:"123".contains(contract.getTableOwner())?1:2;
             String sqlmbNameRule="select name_rule from mb_name_rule where wbs_id=? and classify=?";
             List<String> nameRuleVos = jdbcTemplate.query(sqlmbNameRule, new SingleColumnRowMapper<>(String.class), contract.getPKeyId(),classify);
+            if(!nameRuleVos.isEmpty()){
+                return Arrays.asList(nameRuleVos.get(0).split("-"));
+            }
         }
-
         return null;
     }
 
@@ -406,24 +408,15 @@ public class InformationWriteQueryController extends BladeController {
                         WbsTreeContract::getNodeName,
                         (existing, replacement) -> replacement // 如果键重复,保留后者
                 ));
-        StringBuilder result = new StringBuilder("");
+        List<String> result = new ArrayList<>();
         for (Integer i : index) {
-            if(i==0){
-                if(map.containsKey(1)){
-                    result.append(map.get(1));
-                }
-            }
-            else if(i==1){
-                if(map.containsKey(18)){
-                    result.append(map.get(18));
-                }
-            }else {
-                if(map.containsKey(i)){
-                    result.append(map.get(i));
-                }
+            String title = map.get(i == 0 ? 1 : i == 1 && map.containsKey(18) ? 18 : i);
+            if(title == null || result.stream().anyMatch(f -> f.contains(title))){
+                continue;
             }
+            result.add(title);
         }
-        return result.toString();
+        return String.join("", result);
     }
 
     @PostMapping("/previewNodeName")
@@ -473,10 +466,18 @@ public class InformationWriteQueryController extends BladeController {
 
     @PostMapping("/getNameRuleList")
     @ApiOperation(value = "获取题名规则列表")
-    public R<List<PreviewNodeNameVO>> getNameRuleList(@RequestBody List<PreviewNodeNameDTO>dtos){
+    public R<List<PreviewNodeNameVO>> getNameRuleList(@RequestBody GetNameRuleListDTO param){
         List<PreviewNodeNameVO>list=new ArrayList<>();
-        for (PreviewNodeNameDTO dto : dtos) {
-            List<String> nameRules = getNameRuleByPkeyId(dto.getWbsId(), dto.getProjectId());
+        String sql1="Select sg_suffix,jl_suffix,template_type from m_project_info where id="+param.getDtos().get(0).getProjectId()+" and is_deleted=0";
+        List<ProjectInfo> projectInfos = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
+        String sgSuffix="";
+        String jlSuffix="";
+        if(projectInfos.size()>0){
+            sgSuffix=projectInfos.get(0).getSgSuffix()==null?"":projectInfos.get(0).getSgSuffix();
+            jlSuffix=projectInfos.get(0).getJlSuffix()==null?"":projectInfos.get(0).getJlSuffix();
+        }
+        for (PreviewNodeNameDTO dto : param.getDtos()) {
+            List<String> nameRules = getNameRuleByPkeyId(dto.getWbsId(), dto.getProjectId(),param.getTemplateType());
             String sql="select p_key_id,ancestors_p_id,major_data_type from m_wbs_tree_contract where p_key_id="+dto.getWbsId()+" and is_deleted=0";
             WbsTreeContract contract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
             String sql2="select IFNULL(classify,0) from u_information_query where id="+dto.getId();
@@ -484,20 +485,8 @@ public class InformationWriteQueryController extends BladeController {
             String result="";
             if(nameRules!=null){
                 result= createFileTitle(contract, String.join("-", nameRules));
-                //result = nodeBaseInfoServiceClient.getNameRuleByRule(String.join("-", nameRules), contract.getPKeyId() + "");
                 if(contract!=null){
-                    String sql1="Select sg_suffix,jl_suffix,template_type from m_project_info where id="+dtos.get(0).getProjectId()+" and is_deleted=0";
-                    List<ProjectInfo> projectInfos = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
-                    String sgSuffix="";
-                    String jlSuffix="";
-                    if(projectInfos.size()>0){
-                        sgSuffix=projectInfos.get(0).getSgSuffix()==null?"":projectInfos.get(0).getSgSuffix();
-                        jlSuffix=projectInfos.get(0).getJlSuffix()==null?"":projectInfos.get(0).getJlSuffix();
-                    }
-                    if(contract!=null&&contract.getMajorDataType()!=null&&contract.getMajorDataType()==4){
-                        if(result==null){
-                            result="";
-                        }
+                    if(contract.getMajorDataType()!=null&&contract.getMajorDataType()==4){
                         if(classify==1&&StringUtils.isNotEmpty(sgSuffix)){
                             result=result+sgSuffix;
                         }else if(classify==2&&StringUtils.isNotEmpty(jlSuffix)){