Просмотр исходного кода

新增记录或报告单预览系统自动生成的编号回显

DengLinLang 2 месяцев назад
Родитель
Сommit
974b244682

+ 7 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/TrialSelfInspectionRecordClient.java

@@ -1,10 +1,14 @@
 package org.springblade.business.feign;
 
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.common.constant.BusinessConstant;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.util.HashMap;
+
 @FeignClient(value = BusinessConstant.APPLICATION_WEATHER_NAME)
 public interface TrialSelfInspectionRecordClient {
 
@@ -15,4 +19,7 @@ public interface TrialSelfInspectionRecordClient {
 
     @PostMapping(API_PREFIX + "/updateURL")
     void updateURL(@RequestParam String url, @RequestParam String pKeyId);
+
+    @PostMapping(API_PREFIX + "/previewGeneratedReportOrRecordNum")
+    HashMap<String,String> previewGeneratedReportOrRecordNum(@RequestBody TrialSelfInspectionRecordDTO dto);
 }

+ 9 - 0
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/TrialSelfInspectionRecordClientImpl.java

@@ -2,11 +2,14 @@ package org.springblade.business.feignClient;
 
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import lombok.AllArgsConstructor;
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.feign.TrialSelfInspectionRecordClient;
 import org.springblade.business.service.impl.TrialSelfInspectionRecordServiceImpl;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
+
 
 @RestController
 @AllArgsConstructor
@@ -14,6 +17,7 @@ public class TrialSelfInspectionRecordClientImpl implements TrialSelfInspectionR
 
     private TrialSelfInspectionRecordServiceImpl inspectionRecordService;
 
+
     @Override
     public void updateURL(String url, String pKeyId) {
         LambdaUpdateWrapper<TrialSelfInspectionRecord> updateWrapper = new LambdaUpdateWrapper<>();
@@ -21,4 +25,9 @@ public class TrialSelfInspectionRecordClientImpl implements TrialSelfInspectionR
         updateWrapper.eq(TrialSelfInspectionRecord::getId, pKeyId);
         inspectionRecordService.update(null, updateWrapper);
     }
+
+    @Override
+    public HashMap<String, String> previewGeneratedReportOrRecordNum(TrialSelfInspectionRecordDTO dto) {
+        return inspectionRecordService.buildNumberView(dto);
+    }
 }

+ 0 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java

@@ -45,5 +45,4 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
 
     R getSamplePdfUrl(String id,String contrctId);
-
 }

+ 177 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -992,7 +992,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             //如果传递了编号就修改对应记录的值 以第一张表的数据为准
             this.updateRecordNoOrReportNo(obj, dto);
             //------编辑时记录表编号或报告单编号为Null的重新生成------
-            if(this.judgingParameters(dto)){
+            if(!this.judgingParameters(dto)){
                 this.reBuildNumber(obj, dto);
             }
 
@@ -1449,6 +1449,182 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             }
         }
     }
+    //提前构建记录或者报告编号 供用户保存前提交时使用(新增保存前显示系统引用的记录编号或者报告编号)
+    public HashMap<String,String> buildNumberView(TrialSelfInspectionRecordDTO dto) {
+        StringSPUtils spUtils = new StringSPUtils();
+        List<TrialSelfInspectionRecord> result = baseMapper.selectAll(dto.getNodeId(), dto.getContractId(), dto.getType());
+        List<TrialSelfInspectionRecord> trialSelfInspectionRecords = result.stream().filter(Objects::nonNull).collect(Collectors.toList());
+
+        //两种类型同时生成
+        if (dto.getTableType().contains("1,2") || dto.getTableType().contains("2,1") || dto.getTableType().contains("9,10") || dto.getTableType().contains("10,9")) {
+            String maxRecordNo = "";
+            if (StringUtils.isEmpty(dto.getRecordNo())) {
+                //获取记录表最大编号
+                List<String> recordNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getRecordNo).filter(ObjectUtils::isNotEmpty).collect(Collectors.toList());
+                if (recordNos.size() == 0 || ObjectUtil.isEmpty(recordNos)) {
+                    maxRecordNo = "0001";
+                } else {
+                   /* List<String> numberRecordNos = new ArrayList<>();
+                    for (String recordNo : recordNos) {
+                        String number = recordNo.split("-")[recordNo.split("-").length - 1];
+                        numberRecordNos.add(number);
+                    }
+                    int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
+                    if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
+                        maxRecordNo = spUtils.buildSerial(maxRecordNo1, 4);
+                    } else {
+                        throw new ServiceException("当前编号已达到最大值9999,操作失败");
+                    }*/
+
+                    maxRecordNo = recordNos.size()+"";
+                }
+
+            }
+
+            String maxReportNo = "";
+            if (StringUtils.isEmpty(dto.getReportNo())) {
+                //获取报告单最大编号
+                List<String> reportNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getReportNo).filter(ObjectUtils::isNotEmpty).collect(Collectors.toList());
+                if (reportNos.size() == 0 || ObjectUtil.isEmpty(reportNos)) {
+                    maxReportNo = "0001";
+                } else {
+                    /*List<String> numberReportNo = new ArrayList<>();
+                    for (String reportNo : reportNos) {
+                        String number = reportNo.split("-")[reportNo.split("-").length - 1];
+                        numberReportNo.add(number);
+                    }
+                    int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNo)) + 1;
+                    if (maxReportNo1 < 9999 && maxReportNo1 > 0) {
+                        maxReportNo = spUtils.buildSerial(maxReportNo1, 4);
+                    } else {
+                        throw new ServiceException("当前编号已达到最大值9999,操作失败");
+                    }*/
+                    maxReportNo = reportNos.size()+"";
+
+                }
+            }
+
+            WbsTreePrivate wbsTreePrivate = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId()))).stream().findAny().orElse(null);
+            ContractInfo contract = contractClient.getContractById(dto.getContractId());
+            int year = LocalDateTimeUtil.now().getYear();
+            if (wbsTreePrivate == null || contract == null) {
+                throw new ServiceException("未找到当前项目合同段的节点信息,操作失败!");
+            } else {
+                //记录表
+                if (StringUtils.isNotEmpty(maxRecordNo)) {
+                    String str1 = "JL" +
+                            "-" + contract.getContractNumber() +
+                            "-" + year +
+                            "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
+                            "-" + maxRecordNo;
+                    HashMap<String, String> stringStringHashMap = new HashMap<>();
+                    stringStringHashMap.put("type","记录表");
+                    stringStringHashMap.put("valueStr",str1);
+                    return stringStringHashMap;
+                }
+
+                //报告单
+                if (StringUtils.isNotEmpty(maxReportNo)) {
+                    String str2 = "BG" +
+                            "-" + contract.getContractNumber() +
+                            "-" + year +
+                            "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
+                            "-" + maxReportNo;
+                    HashMap<String, String> stringStringHashMap = new HashMap<>();
+                    stringStringHashMap.put("type","报告单");
+                    stringStringHashMap.put("valueStr",str2);
+                    return stringStringHashMap;
+                }
+            }
+        }
+
+        //记录表
+        else if (("1").equals(dto.getTableType()) || ("9").equals(dto.getTableType())) {
+            if (StringUtils.isEmpty(dto.getRecordNo())) {
+                //获取记录表最大编号
+                List<String> recordNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getRecordNo).filter(ObjectUtils::isNotEmpty).collect(Collectors.toList());
+                String maxRecordNo;
+                if (recordNos.size() == 0 || ObjectUtil.isEmpty(recordNos)) {
+                    maxRecordNo = "0001";
+                } else {
+                    /*List<String> numberRecordNos = new ArrayList<>();
+                    for (String recordNo : recordNos) {
+                        String number = (recordNo.split("-")[recordNo.split("-").length - 1]).replaceAll("]","");
+                        numberRecordNos.add(number);
+                    }
+                    int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
+                    if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
+                        maxRecordNo = spUtils.buildSerial(maxRecordNo1, 4);
+                    } else {
+                        throw new ServiceException("当前编号已达到最大值9999,操作失败");
+                    }*/
+                    maxRecordNo = recordNos.size()+"";
+                }
+
+                WbsTreePrivate wbsTreePrivate = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId()))).stream().findAny().orElse(null);
+                ContractInfo contract = contractClient.getContractById(dto.getContractId());
+                int year = LocalDateTimeUtil.now().getYear();
+                if (wbsTreePrivate == null || contract == null) {
+                    throw new ServiceException("未找到当前项目合同段的节点信息,操作失败!");
+                } else {
+                    //记录表
+                    String str1 = "JL" +
+                            "-" + contract.getContractNumber() +
+                            "-" + year +
+                            "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
+                            "-" + maxRecordNo;
+                    HashMap<String, String> stringStringHashMap = new HashMap<>();
+                    stringStringHashMap.put("type","记录表");
+                    stringStringHashMap.put("valueStr",str1);
+                    return stringStringHashMap;
+                }
+            }
+        }
+
+        //报告单
+        else if (("2").equals(dto.getTableType()) || ("10").equals(dto.getTableType())) {
+            if (StringUtils.isEmpty(dto.getReportNo())) {
+                //获取报告单最大编号
+                List<String> reportNos = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getReportNo).filter(ObjectUtils::isNotEmpty).collect(Collectors.toList());
+                String maxReportNo;
+                if (reportNos.size() == 0 || ObjectUtil.isEmpty(reportNos)) {
+                    maxReportNo = "0001";
+                } else {
+                   /* List<String> numberReportNo = new ArrayList<>();
+                    for (String reportNo : reportNos) {
+                        String number = reportNo.split("-")[reportNo.split("-").length - 1];
+                        numberReportNo.add(number);
+                    }
+                    int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNo)) + 1;
+                    if (maxReportNo1 < 9999 && maxReportNo1 > 0) {
+                        maxReportNo = spUtils.buildSerial(maxReportNo1, 4);
+                    } else {
+                        throw new ServiceException("当前编号已达到最大值9999,操作失败");
+                    }*/
+                    maxReportNo = reportNos.size()+"";
+                }
+
+                WbsTreePrivate wbsTreePrivate = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId()))).stream().findAny().orElse(null);
+                ContractInfo contract = contractClient.getContractById(dto.getContractId());
+                int year = LocalDateTimeUtil.now().getYear();
+                if (wbsTreePrivate == null || contract == null) {
+                    throw new ServiceException("未找到当前项目合同段的节点信息,操作失败!");
+                } else {
+                    //报告单
+                    String str2 = "BG" +
+                            "-" + contract.getContractNumber() +
+                            "-" + year +
+                            "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
+                            "-" + maxReportNo;
+                    HashMap<String, String> stringStringHashMap = new HashMap<>();
+                    stringStringHashMap.put("type","报告单");
+                    stringStringHashMap.put("valueStr",str2);
+                    return stringStringHashMap;
+                }
+            }
+        }
+        return null;
+    }
 
     public IPage<TrialSelfInspectionRecordVO> trialDataPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) {
         QueryWrapper<TrialSelfInspectionRecord> queryWrapper = Condition.getQueryWrapper(dto);

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -3610,8 +3610,8 @@ public class ExcelTabController extends BladeController {
             @ApiImplicitParam(name = "id", value = "记录id-当做groupId", required = true),
             @ApiImplicitParam(name = "contractId", value = "合同段id", required = true)
     })
-    public R<List<Map<String, Object>>> getBussDataInfoTrial(Long id, Long pkeyId, Long contractId, Long entrustId) {
-        List<Map<String, Object>> bussDataInfoTrial = excelTabService.getBussDataInfoTrial(id, pkeyId, contractId, entrustId);
+    public R<List<Map<String, Object>>> getBussDataInfoTrial(Long id, Long pkeyId, Long contractId, Long entrustId ,Integer type,Long nodeId ) {
+        List<Map<String, Object>> bussDataInfoTrial = excelTabService.getBussDataInfoTrial(id, pkeyId, contractId, entrustId, type, nodeId);
         return R.data(bussDataInfoTrial);
     }
 

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java

@@ -707,7 +707,7 @@ public class WbsTreePrivateController extends BladeController {
                 }
 
                 //表单数据
-                List<Map<String, Object>> bussDataInfoTrial = iExcelTabService.getBussDataInfoTrial(id, treePrivate.getPKeyId(), Long.parseLong(contractId),null);
+                List<Map<String, Object>> bussDataInfoTrial = iExcelTabService.getBussDataInfoTrial(id, treePrivate.getPKeyId(), Long.parseLong(contractId),null,null,null);
                 if (bussDataInfoTrial != null && bussDataInfoTrial.size() > 0) {
                     bussDataInfoTrial.get(0).remove("group_id");
                     treePrivate.setBussDataInfoTrial(bussDataInfoTrial.get(0));

+ 5 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreePrivateClientImpl.java

@@ -13,13 +13,15 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
-import org.springblade.manager.entity.*;
+import org.springblade.manager.entity.TableFile;
+import org.springblade.manager.entity.TextdictInfo;
+import org.springblade.manager.entity.WbsTreeContract;
+import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.mapper.WbsTreePrivateMapper;
 import org.springblade.manager.service.IWbsTreePrivateService;
 import org.springblade.manager.service.impl.ExcelTabServiceImpl;
 import org.springblade.manager.service.impl.TextdictInfoServiceImpl;
 import org.springblade.manager.service.impl.WbsTreeContractServiceImpl;
-import org.springblade.manager.service.impl.WbsTreePrivateServiceImpl;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
 import org.springblade.manager.vo.WbsTreePrivateVO;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
@@ -213,7 +215,7 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
 
     @Override
     public List<Map<String, Object>> getTrialDataInfo(String pKeyId, Long id) {
-        return excelTabServiceImpl.getBussDataInfoTrial(id, Long.parseLong(pKeyId), null,null);
+        return excelTabServiceImpl.getBussDataInfoTrial(id, Long.parseLong(pKeyId), null,null,null,null);
     }
 
     @Override

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

@@ -136,7 +136,7 @@ public interface IExcelTabService extends BaseService<ExcelTab> {
     /**
      * 获取试验用户端 单个表单接口数据
      */
-    List<Map<String, Object>> getBussDataInfoTrial(Long id, Long pkeyId, Long contractId, Long entrustId);
+    List<Map<String, Object>> getBussDataInfoTrial(Long id, Long pkeyId, Long contractId, Long entrustId, Integer type,Long nodeId);
 
     /**
      * 获取试验用户端 单个表单接口数据 - 关联施工

+ 37 - 7
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -34,6 +34,7 @@ import org.springblade.business.entity.*;
 import org.springblade.business.feign.ContractLogClient;
 import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.business.feign.OperationLogClient;
+import org.springblade.business.feign.TrialSelfInspectionRecordClient;
 import org.springblade.business.vo.SaveContractLogVO;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
@@ -115,6 +116,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     private final IProjectInfoService projectInfoService;
     private final OperationLogClient operationLogClient;
     private final TableInfoServiceImpl tableInfoService;
+    private final TrialSelfInspectionRecordClient trialSelfInspectionRecordClient;
+
 
     @Autowired
     StringRedisTemplate RedisTemplate;
@@ -2418,13 +2421,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
      * 试验 获取填报信息
      */
     @Override
-    public List<Map<String, Object>> getBussDataInfoTrial(Long groupId, Long pkeyId, Long contractId, Long entrustId) {
+    public List<Map<String, Object>> getBussDataInfoTrial(Long groupId, Long pkeyId, Long contractId, Long entrustId, Integer type,Long nodeId) {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
         List<Map<String, Object>> list = new ArrayList<>();
         Map<String, Object> reData = new HashMap<>();
         WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
-                .select(WbsTreePrivate::getInitTableName, WbsTreePrivate::getHtmlUrl, WbsTreePrivate::getPKeyId, WbsTreePrivate::getProjectId)
+                .select(WbsTreePrivate::getInitTableName, WbsTreePrivate::getHtmlUrl, WbsTreePrivate::getPKeyId, WbsTreePrivate::getProjectId, WbsTreePrivate::getParentId, WbsTreePrivate::getTableType)
                 .eq(WbsTreePrivate::getPKeyId, pkeyId));
         if (wbsTreePrivate == null) {
             return list;
@@ -2494,6 +2497,26 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 //通过html获取页面上的key值 返回key值对应的数据
                 setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization,entrustInfo);
             }
+            //第一次新增 回显系统生成的编号
+            if(type != null && nodeId != null){
+                TrialSelfInspectionRecordDTO trialSelfInspectionRecordDTO = new TrialSelfInspectionRecordDTO();
+                trialSelfInspectionRecordDTO.setTableType(wbsTreePrivate.getTableType().toString());
+                trialSelfInspectionRecordDTO.setProjectId(wbsTreePrivate.getProjectId());
+                trialSelfInspectionRecordDTO.setContractId(contractId);
+                trialSelfInspectionRecordDTO.setNodeId(nodeId);
+                trialSelfInspectionRecordDTO.setType(type);
+                HashMap<String, String> stringStringHashMap = trialSelfInspectionRecordClient.previewGeneratedReportOrRecordNum(trialSelfInspectionRecordDTO);
+                String mapType = stringStringHashMap.get("type");
+                if("报告单".equals(mapType)){
+                    //获取页面上的key值
+                    String bgbhKey = doc.select("el-input[placeholderxx~=报告编号.*]").attr("keyname");
+                    reData.put(bgbhKey, stringStringHashMap.get("valueStr"));
+                }else {
+                    //获取页面上的key值
+                    String bgbhKey = doc.select("el-input[placeholderxx~=记录编号.*]").attr("keyname");
+                    reData.put(bgbhKey, stringStringHashMap.get("valueStr"));
+                }
+            }
 
 
             //匹配
@@ -2740,7 +2763,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         if (wbsTreePrivate.getHtmlUrl() == null) {
             return list;
         }
-
         //表单是否存储在
         String tabName = wbsTreePrivate.getInitTableName();
         String isExitSql = "select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
@@ -2899,7 +2921,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         }
 
         //获取数据信息info
-        List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(id, pkeyId, Long.parseLong(contractId),null);
+        List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(id, pkeyId, Long.parseLong(contractId),null,null,null);
         Map<String, Object> DataInfo = new HashMap<>();
         if (bussDataInfoTrial.size() > 0) {
             DataInfo.putAll(bussDataInfoTrial.stream().findAny().orElse(null));
@@ -3908,8 +3930,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                             newStyle.setFont(redFont);
                             newStyle.setShrinkToFit(true);
                             cell.setCellStyle(newStyle);
-                            cell.setCellValue(dqid);
-                            sign.add(dqid);
+                            if(dqid.contains("||")){
+                                String[] split = dqid.split("\\|\\|");
+                                for (String singleDqid : split) {
+                                    cell.setCellValue(singleDqid);
+                                    sign.add(singleDqid);
+                                }
+                            }else {
+                                cell.setCellValue(dqid);
+                                sign.add(dqid);
+                            }
                         }
                     }
                 }
@@ -3976,7 +4006,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         }
 
         //获取数据信息info
-        List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(groupId, pkeyId, Long.parseLong(contractId),null);
+        List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(groupId, pkeyId, Long.parseLong(contractId),null,null,null);
         Map<String, Object> DataInfo = new HashMap<>();
         if (bussDataInfoTrial.size() > 0) {
             DataInfo.putAll(bussDataInfoTrial.stream().findAny().orElse(null));