Prechádzať zdrojové kódy

重置文件题名

# Conflicts:
#	blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java
cr 1 týždeň pred
rodič
commit
ff98124a6f

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

@@ -0,0 +1,18 @@
+package org.springblade.business.dto;
+
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class FlushQueryNameDTO {
+
+    @ApiModelProperty(value = "1直接重置题名 2规则更改重置题名")
+    private Integer type;
+
+    @ApiModelProperty(value = "题名内容 type=2{资料查询ID:修改后文件题名},type=1{资料查询ID:空字符串}")
+    private Map<Long,String> map;
+}

+ 65 - 6
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
 import org.springblade.business.dto.CustomAddContractNodeDTO;
 import org.springblade.business.dto.ImportTreeDto;
 import org.springblade.business.dto.WbsTreeContractStatisticsDTO;
+import org.springblade.business.dto.FlushQueryNameDTO;
 import org.springblade.business.entity.*;
 import org.springblade.business.feign.MessageWarningClient;
 import org.springblade.business.feign.OperationLogClient;
@@ -196,13 +197,11 @@ public class InformationWriteQueryController extends BladeController {
     @PostMapping("/flushQueryName")
     @ApiModelProperty(value = "刷新文件题名")
     @ApiOperationSupport(order = 28)
-    public R<Boolean> flushQueryName(@RequestParam String ids){
-        if(ids==null){
+    public R<Boolean> flushQueryName(@RequestBody FlushQueryNameDTO dto){
+        if(dto.getMap().size()<=0){
             throw new ServiceException("请选择要刷新的文件");
         }
-        List<Long> idList = Arrays.stream(ids.split(","))
-            .map(Long::valueOf)
-            .collect(Collectors.toList());
+        List<Long> idList=new ArrayList<>(dto.getMap().keySet());
         List<InformationQuery> queryList = this.informationQueryService.list(Wrappers.<InformationQuery>lambdaQuery()
             .select(InformationQuery::getId, InformationQuery::getName,InformationQuery::getProjectId,InformationQuery::getClassify,InformationQuery::getStatus,InformationQuery::getWbsId).in(InformationQuery::getId, idList));
         String sgSuffix="";
@@ -215,9 +214,14 @@ public class InformationWriteQueryController extends BladeController {
                 jlSuffix=projectInfos.get(0).getJlSuffix()==null?"":projectInfos.get(0).getJlSuffix();
             }
             for (InformationQuery query : queryList) {
+                String result="";
                 String sql="select * from m_wbs_tree_contract where p_key_id="+query.getWbsId()+" and is_deleted=0";
                 WbsTreeContract contract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
-                  String result=wbsParamClient.createFileTitle(contract);
+                if(dto.getType()==1){
+                    result=wbsParamClient.createFileTitle(contract);
+                }else {
+                    result=dto.getMap().get(query.getId());
+                }
                 if(contract!=null&&contract.getMajorDataType()!=null&&contract.getMajorDataType()==4){
                     if(query.getClassify()!=null&&query.getClassify()==1&&StringUtils.isNotEmpty(sgSuffix)){
                         result=result+sgSuffix;
@@ -244,6 +248,61 @@ public class InformationWriteQueryController extends BladeController {
         return R.status(this.informationQueryService.updateBatchById(queryList));
     }
 
+    private String createFileTitle(WbsTreeContract contract, String param) {
+        if(contract==null){
+            return "";
+        }
+        String ancestorsPId = contract.getAncestorsPId();
+        if (ancestorsPId.startsWith("0,")) {
+            ancestorsPId = ancestorsPId.substring(2);
+        }
+        ancestorsPId=ancestorsPId+","+contract.getPKeyId();
+        String sql="select node_name,node_type from m_wbs_tree_contract where p_key_id in ("+ancestorsPId+") and is_deleted=0";
+        List<WbsTreeContract> nodeNames = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+        param = param.trim().replaceAll("(?i:c)", "");
+        List<String> list = Arrays.asList(param.split("[^.\\d]"));
+        List<Integer> index = list.stream().map(Integer::parseInt).collect(Collectors.toList());
+        Map<Integer, String> map = nodeNames.stream()
+                .collect(Collectors.toMap(
+                        WbsTreeContract::getNodeType,
+                        WbsTreeContract::getNodeName,
+                        (existing, replacement) -> replacement // 如果键重复,保留后者
+                ));
+        StringBuilder result = new StringBuilder("");
+        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));
+                }
+            }
+        }
+        return result.toString();
+    }
+
+    @GetMapping("/previewNodeName")
+    @ApiOperation(value = "预览节点名称")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "wbsId", value = "资料查询wbsId", required = true),
+            @ApiImplicitParam(name = "param", value = "题名规则", required = true)
+    })
+    public R<String> previewNodeName(@RequestParam String wbsId,@RequestParam String param){
+        String sql="select p_key_id,ancestors_p_id from m_wbs_tree_contract where p_key_id="+wbsId+" and is_deleted=0";
+        WbsTreeContract contract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+        if(contract!=null){
+            return R.data(createFileTitle(contract,param));
+        }
+        return R.success("暂无数据");
+    }
+
     /**
      * 初始化合同段导图树
      */