liuyc 2 yıl önce
ebeveyn
işleme
0bb2bb3c95
14 değiştirilmiş dosya ile 597 ekleme ve 216 silme
  1. 4 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/WbsTreePrivateClient.java
  2. 7 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/TrialRecordZJTreeLazyVO.java
  3. 31 2
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java
  4. 118 77
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDetectionDataServiceImpl.java
  5. 135 53
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  6. 2 2
      blade-service/blade-manager/src/main/java/com/mixsmart/utils/FormulaUtils.java
  7. 40 27
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java
  8. 2 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeController.java
  9. 19 9
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreePrivateClientImpl.java
  10. 23 15
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml
  11. 3 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreeContractService.java
  12. 22 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
  13. 163 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java
  14. 28 26
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

+ 4 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/WbsTreePrivateClient.java

@@ -1,6 +1,7 @@
 package org.springblade.manager.feign;
 
 import org.springblade.manager.entity.TextdictInfo;
+import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
 import org.springblade.manager.vo.WbsTreePrivateVO;
@@ -65,4 +66,7 @@ public interface WbsTreePrivateClient {
     @PostMapping(API_PREFIX + "/saveTextDictList")
     void saveTextDictList(@RequestBody ArrayList<TextdictInfo> obj);
 
+    @PostMapping(API_PREFIX + "/selectListNode")
+    List<WbsTreeContract> selectListNode(@RequestParam List<Long> fuIds, @RequestParam String projectId, @RequestParam String wbsId, @RequestParam String wbsType, @RequestParam String contractId);
+
 }

+ 7 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/TrialRecordZJTreeLazyVO.java

@@ -1,6 +1,7 @@
 package org.springblade.manager.vo;
 
 import lombok.Data;
+
 import java.io.Serializable;
 
 @Data
@@ -23,4 +24,10 @@ public class TrialRecordZJTreeLazyVO implements Serializable {
     //是否是最下级
     private Boolean notExsitChild;
 
+    private Integer nodeType;
+
+    private Integer type;
+
+    private Integer majorDataType;
+
 }

+ 31 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -2,6 +2,7 @@ package org.springblade.business.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
@@ -239,9 +240,37 @@ public class TrialDetectionController extends BladeController {
     @ApiOperation(value = "自检删除复制的表", notes = "传入节点pKeyId")
     public R<String> removeBussTabInfo(@RequestParam Long pKeyId) {
         //查询当前表是否已经填报
-        List<TrialSelfDataRecord> query = jdbcTemplate.query("select id from u_trial_self_data_record where tab_id = " + pKeyId, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+        List<TrialSelfDataRecord> query = jdbcTemplate.query("select record_id from u_trial_self_data_record where tab_id = " + pKeyId, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
         if (query.size() > 0) {
-            return R.fail("当前表在试验记录中有填报数据,删除失败");
+            WbsTreePrivate tab = wbsTreePrivateClient.queryByPKeyIds(Collections.singletonList(pKeyId + "")).stream().findAny().orElse(null);
+            List<String> names = new ArrayList<>();
+            if (tab != null) {
+                if (tab.getTableType().equals(1) || tab.getTableType().equals(9)) {
+                    List<Long> recordIds = query.stream().map(TrialSelfDataRecord::getRecordId).collect(Collectors.toList());
+                    List<TrialSelfInspectionRecord> recordList = iTrialSelfInspectionRecordService.getBaseMapper().selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, recordIds));
+                    for (TrialSelfInspectionRecord record : recordList) {
+                        StringBuilder stringBuilder = new StringBuilder();
+                        if (StringUtils.isNotEmpty(record.getRecordNo())) {
+                            stringBuilder.append(record.getRecordNo());
+                        }
+                        names.add(stringBuilder.toString());
+                    }
+                    return R.fail("当前表在试验记录【记录编号:" + org.apache.commons.lang.StringUtils.join(names, ",") + "】中有填报数据,删除失败");
+                }
+                if (tab.getTableType().equals(2) || tab.getTableType().equals(10)) {
+                    List<Long> recordIds = query.stream().map(TrialSelfDataRecord::getRecordId).collect(Collectors.toList());
+                    List<TrialSelfInspectionRecord> recordList = iTrialSelfInspectionRecordService.getBaseMapper().selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, recordIds));
+                    for (TrialSelfInspectionRecord record : recordList) {
+                        StringBuilder stringBuilder = new StringBuilder();
+                        if (StringUtils.isNotEmpty(record.getReportNo())) {
+                            stringBuilder.append(record.getReportNo());
+                        }
+                        names.add(stringBuilder.toString());
+                    }
+                    return R.fail("当前表在试验记录【报告编号:" + org.apache.commons.lang.StringUtils.join(names, ",") + "】中有填报数据,删除失败");
+                }
+            }
+            return R.fail("未获取到当前表的信息,删除失败");
         } else {
             jdbcTemplate.execute("delete from m_wbs_tree_private where p_key_id = " + pKeyId);
             return R.success("删除成功");

+ 118 - 77
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDetectionDataServiceImpl.java

@@ -31,6 +31,7 @@ import org.springblade.core.mp.utils.PageUtil;
 import org.springblade.core.tool.utils.*;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
+import org.springblade.manager.feign.WbsTreePrivateClient;
 import org.springblade.resource.entity.Attach;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
@@ -50,6 +51,7 @@ import java.util.stream.Collectors;
 public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectionDataMapper, TrialDetectionData> implements ITrialDetectionDataService {
 
     private final TrialSelfInspectionRecordMapper inspectionRecordMapper;
+    private final WbsTreePrivateClient wbsTreePrivateClient;
     private final JdbcTemplate jdbcTemplate;
 
     @Override
@@ -343,105 +345,144 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
         }
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
-        //拼接工程部位names 单位、分部、分项
-        List<WbsTreeContract> query = jdbcTemplate.query("select node_name,node_type,id,ancestors from m_wbs_tree_contract where node_type is not null and p_key_id in(" + projectPositionIds + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
-        List<WbsTreeContract> dw = query.stream().filter(f -> f.getNodeType().equals(1)).collect(Collectors.toList());
-        List<WbsTreeContract> fb = query.stream().filter(f -> f.getNodeType().equals(2)).collect(Collectors.toList());
-        List<WbsTreeContract> fx = query.stream().filter(f -> f.getNodeType().equals(4)).collect(Collectors.toList());
-        Set<String> set = new HashSet<>();
-        if (dw.size() > 0 && fb.size() > 0 && fx.size() > 0) {
-            for (WbsTreeContract fxNode : fx) {
-                for (WbsTreeContract fbNode : fb) {
-                    if (fxNode.getAncestors().contains(fbNode.getId().toString())) {
-                        for (WbsTreeContract dwNode : dw) {
-                            if (fbNode.getAncestors().contains(dwNode.getId().toString())) {
-                                set.add(dwNode.getNodeName() + "/" + fbNode.getNodeName() + "/" + fxNode.getNodeName());
+        List<WbsTreeContract> query = jdbcTemplate.query("select full_name,node_type,id,ancestors,parent_id,wbs_id,wbs_type,project_id from m_wbs_tree_contract where node_type is not null and p_key_id in(" + projectPositionIds + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
+        List<WbsTreeContract> collect = query.stream().filter(f -> !f.getNodeType().equals(6)).collect(Collectors.toList());
+        if (collect.size() > 0) {
+            List<String> names = collect.stream().map(WbsTreeContract::getFullName).collect(Collectors.toList());
+            throw new ServiceException("选择的节点:【" + StringUtils.join(names, ",") + "】不是工序节点,操作失败");
+        }
+        WbsTreeContract node = query.stream().findAny().orElse(null);
+        Set<WbsTreeContract> resultNode = new HashSet<>();
+        if (node != null) {
+            this.fxSelectParentNode(query, resultNode, node.getProjectId(), node.getWbsId(), node.getWbsType().toString(), contractId);
+        }
+        if (resultNode.size() > 0) {
+            List<WbsTreeContract> dw = resultNode.stream()
+                    .filter(f -> !f.getParentId().equals(0L) && f.getNodeType().equals(1))
+                    .filter(f -> {
+                        String[] split = f.getAncestors().split(",");
+                        return split.length > 2;
+                    })
+                    .peek(obj -> {
+                        String fullName = obj.getFullName();
+                        obj.setFullName(fullName.trim());
+                    })
+                    .collect(Collectors.collectingAndThen(
+                            Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContract::getFullName))),
+                            ArrayList::new)
+                    );
+
+            List<WbsTreeContract> fb = resultNode.stream().filter(f -> f.getNodeType().equals(2)).collect(Collectors.toList());
+            List<WbsTreeContract> fx = resultNode.stream().filter(f -> f.getNodeType().equals(4)).collect(Collectors.toList());
+
+            //拼接工程部位names 单位、分部、分项
+            Set<String> set = new HashSet<>();
+            if (dw.size() > 0 && fb.size() > 0 && fx.size() > 0) {
+                for (WbsTreeContract fxNode : fx) {
+                    for (WbsTreeContract fbNode : fb) {
+                        if (fxNode.getAncestors().contains(fbNode.getId().toString())) {
+                            for (WbsTreeContract dwNode : dw) {
+                                if (fbNode.getAncestors().contains(dwNode.getId().toString())) {
+                                    set.add(dwNode.getFullName().trim() + "、" + fbNode.getFullName().trim() + "、" + fxNode.getFullName().trim());
+                                }
                             }
                         }
                     }
                 }
-            }
-        } else if (dw.size() > 0 && fb.size() > 0) {
-            for (WbsTreeContract fbNode : fb) {
-                for (WbsTreeContract dwNode : dw) {
-                    if (fbNode.getAncestors().contains(dwNode.getId().toString())) {
-                        set.add(dwNode.getNodeName() + "/" + fbNode.getNodeName() + "/");
+            } else if (dw.size() > 0 && fb.size() > 0) {
+                for (WbsTreeContract fbNode : fb) {
+                    for (WbsTreeContract dwNode : dw) {
+                        if (fbNode.getAncestors().contains(dwNode.getId().toString())) {
+                            set.add(dwNode.getFullName().trim() + "、" + fbNode.getFullName().trim());
+                        }
                     }
                 }
-            }
-        } else if (dw.size() > 0 && fx.size() > 0) {
-            for (WbsTreeContract fxNode : fx) {
-                for (WbsTreeContract dwNode : dw) {
-                    if (fxNode.getAncestors().contains(dwNode.getId().toString())) {
-                        set.add(dwNode.getNodeName() + "/" + fxNode.getNodeName() + "/");
+            } else if (dw.size() > 0 && fx.size() > 0) {
+                for (WbsTreeContract fxNode : fx) {
+                    for (WbsTreeContract dwNode : dw) {
+                        if (fxNode.getAncestors().contains(dwNode.getId().toString())) {
+                            set.add(dwNode.getFullName().trim() + "、" + fxNode.getFullName().trim());
+                        }
                     }
                 }
-            }
-        } else if (fb.size() > 0 && fx.size() > 0) {
-            for (WbsTreeContract fxNode : fx) {
-                for (WbsTreeContract fbNode : fb) {
-                    if (fxNode.getAncestors().contains(fbNode.getId().toString())) {
-                        set.add(fbNode.getNodeName() + "/" + fxNode.getNodeName());
+            } else if (fb.size() > 0 && fx.size() > 0) {
+                for (WbsTreeContract fxNode : fx) {
+                    for (WbsTreeContract fbNode : fb) {
+                        if (fxNode.getAncestors().contains(fbNode.getId().toString())) {
+                            set.add(fbNode.getFullName().trim() + "、" + fxNode.getFullName().trim());
+                        }
                     }
                 }
+            } else if (dw.size() > 0) {
+                for (WbsTreeContract dwNode : dw) {
+                    set.add(dwNode.getFullName().trim());
+                }
+            } else if (fb.size() > 0) {
+                for (WbsTreeContract dwNode : fb) {
+                    set.add(dwNode.getFullName().trim());
+                }
+            } else if (fx.size() > 0) {
+                for (WbsTreeContract dwNode : fx) {
+                    set.add(dwNode.getFullName().trim());
+                }
             }
-        } else if (dw.size() > 0) {
-            for (WbsTreeContract dwNode : dw) {
-                set.add(dwNode.getNodeName());
-            }
-        } else if (fb.size() > 0) {
-            for (WbsTreeContract dwNode : fb) {
-                set.add(dwNode.getNodeName());
-            }
-        } else if (fx.size() > 0) {
-            for (WbsTreeContract dwNode : fx) {
-                set.add(dwNode.getNodeName());
-            }
-        }
 
-        if (set.size() > 0) {
-            List<Map<String, String>> resultMapList = new ArrayList<>();
-            //获取当前合同段下的试验节点下的表
-            WbsTreePrivate trialNode = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id =" + nodePKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
-            if (trialNode != null) {
-                List<WbsTreePrivate> trialNodeTabs = jdbcTemplate.query("select p_key_id,html_url from m_wbs_tree_private where html_url is not null and is_deleted = 0 and status = 1 and type = 2 and parent_id =" + trialNode.getId() + " and project_id =" + trialNode.getProjectId() + " and wbs_id = " + trialNode.getWbsId() + " and wbs_type = " + trialNode.getWbsType() + " and (trial_tab_contract_id is null OR (trial_tab_contract_id = " + contractId + "))", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
-                for (WbsTreePrivate trialNodeTab : trialNodeTabs) {
-                    //匹配关联
-                    try {
-                        Map<String, String> map = new HashMap<>();
-                        File file1 = ResourceUtil.getFile(trialNodeTab.getHtmlUrl());
-                        InputStream fileInputStream;
-                        if (file1.exists()) {
-                            fileInputStream = new FileInputStream(file1);
-                        } else {
-                            String path = sys_file_net_url + trialNodeTab.getHtmlUrl().replaceAll("//", "/").replaceAll(file_path, "");
-                            fileInputStream = CommonUtil.getOSSInputStream(path);
-                        }
-                        String htmlString = IoUtil.readToString(fileInputStream);
-                        htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
-                        htmlString = htmlString.replaceAll("title", "titlexx");
+            if (set.size() > 0) {
+                List<Map<String, String>> resultMapList = new ArrayList<>();
+                //获取当前合同段下的试验节点下的表
+                WbsTreePrivate trialNode = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id =" + nodePKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
+                if (trialNode != null) {
+                    List<WbsTreePrivate> trialNodeTabs = jdbcTemplate.query("select p_key_id,html_url from m_wbs_tree_private where html_url is not null and is_deleted = 0 and status = 1 and type = 2 and parent_id =" + trialNode.getId() + " and project_id =" + trialNode.getProjectId() + " and wbs_id = " + trialNode.getWbsId() + " and wbs_type = " + trialNode.getWbsType() + " and (trial_tab_contract_id is null OR (trial_tab_contract_id = " + contractId + "))", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+                    for (WbsTreePrivate trialNodeTab : trialNodeTabs) {
+                        //匹配关联
+                        try {
+                            Map<String, String> map = new LinkedHashMap<>();
+                            File file1 = ResourceUtil.getFile(trialNodeTab.getHtmlUrl());
+                            InputStream fileInputStream;
+                            if (file1.exists()) {
+                                fileInputStream = new FileInputStream(file1);
+                            } else {
+                                String path = sys_file_net_url + trialNodeTab.getHtmlUrl().replaceAll("//", "/").replaceAll(file_path, "");
+                                fileInputStream = CommonUtil.getOSSInputStream(path);
+                            }
+                            String htmlString = IoUtil.readToString(fileInputStream);
+                            htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
+                            htmlString = htmlString.replaceAll("title", "titlexx");
 
-                        Document doc = Jsoup.parse(htmlString);
-                        Elements ppName = doc.select("el-input[placeholderxx~=工程部位.*]");
-                        //工程部位
-                        if (ppName.size() >= 1) {
-                            for (Element element : ppName) {
-                                map.put("tabPKeyId", trialNodeTab.getPKeyId().toString());
-                                map.put(element.attr("keyname"), StringUtils.join(set, "、"));
-                                resultMapList.add(map);
-                                break;
+                            Document doc = Jsoup.parse(htmlString);
+                            Elements ppName = doc.select("el-input[placeholderxx~=工程部位.*]");
+                            //工程部位
+                            if (ppName.size() >= 1) {
+                                for (Element element : ppName) {
+                                    map.put("tabPKeyId", trialNodeTab.getPKeyId().toString());
+                                    map.put(element.attr("keyname"), StringUtils.join(set, " / "));
+                                    resultMapList.add(map);
+                                    break;
+                                }
                             }
+                        } catch (Exception e) {
+                            e.printStackTrace();
                         }
-                    } catch (Exception e) {
-                        e.printStackTrace();
                     }
                 }
+                return resultMapList;
             }
-            return resultMapList;
         }
         return null;
     }
 
+    //反向递归查询父级节点
+    private void fxSelectParentNode(List<WbsTreeContract> wbsTreeContracts, Set<WbsTreeContract> resultNode, String projectId, String wbsId, String wbsType, String contractId) {
+        List<Long> fuIds = wbsTreeContracts.stream().map(WbsTreeContract::getParentId).distinct().collect(Collectors.toList());
+        if (fuIds.size() > 0 && fuIds.get(0) != 0L) {
+            List<WbsTreeContract> fuNodes = wbsTreePrivateClient.selectListNode(fuIds, projectId, wbsId, wbsType, contractId);
+            if (fuNodes.size() > 0) {
+                resultNode.addAll(fuNodes);
+                this.fxSelectParentNode(fuNodes, resultNode, projectId, wbsId, wbsType, contractId);
+            }
+        }
+    }
+
 }
 
 

+ 135 - 53
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -313,19 +313,19 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 dto.setId(SnowFlakeUtil.getId());
                 if (StringUtils.isNotEmpty(dto.getRecordNo())) {
                     dto.setTableType("1");
-                } else if (StringUtils.isNotEmpty(dto.getReportNo())) {
+                }
+                if (StringUtils.isNotEmpty(dto.getReportNo())) {
                     dto.setTableType("2");
-                } else if (StringUtils.isNotEmpty(dto.getReportNo()) && StringUtils.isNotEmpty(dto.getRecordNo())) {
+                }
+                if (StringUtils.isNotEmpty(dto.getReportNo()) && StringUtils.isNotEmpty(dto.getRecordNo())) {
                     dto.setTableType("1,2");
                 }
 
-                //重构编号
-                //this.buildNumber(dto);
-                this.reNumberNo(trialSelfInspectionRecord, dto);
-
                 dto.setCreateTime(new Date());
                 dto.setTaskStatus("未上报");
                 dto.setId(SnowFlakeUtil.getId());
+                //编号
+                this.reNumberNo(trialSelfInspectionRecord, dto);
                 this.save(dto);
 
                 //复制表数据、表附件文件
@@ -388,6 +388,13 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                                 }
                             }
                             tableFileClient.saveBatch(newFiles);
+
+                            //修改文件上传按钮状态(剔除原表pdf)
+                            if (newFiles.size() >= 2) {
+                                String sqlAdd = "insert into u_trial_self_data_record(id,record_id,tab_id,is_buss_show,is_tab_pdf,is_tab_file_type,pdf_url) values" +
+                                        "(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + pKeyId + "," + 1 + "," + 1 + "," + 2 + ",null)";
+                                jdbcTemplate.execute(sqlAdd);
+                            }
                         }
                     }
                 }
@@ -424,60 +431,108 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
 
         List<TrialSelfInspectionRecord> bg = recordList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getReportNo()) && f.getReportNo().contains("BG-")).collect(Collectors.toList());
         List<TrialSelfInspectionRecord> jl = recordList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getRecordNo()) && f.getRecordNo().contains("JL-")).collect(Collectors.toList());
-        String maxRecordNo = "";
-        String maxReportNo = "";
-        if (jl.size() > 0) {
-            List<String> numberRecordNos = new ArrayList<>();
-            for (String recordNo : jl.stream().map(TrialSelfInspectionRecord::getRecordNo).collect(Collectors.toList())) {
-                String number = recordNo.split("-")[recordNo.split("-").length - 1];
-                numberRecordNos.add(number);
+
+        if (dto.getTableType().contains("1,2") || dto.getTableType().contains("2,1") || dto.getTableType().contains("9,10") || dto.getTableType().contains("10,9")) {
+            String maxRecordNo = "";
+            String maxReportNo = "";
+            if (jl.size() > 0) {
+                List<String> numberRecordNos = new ArrayList<>();
+                for (String recordNo : jl.stream().map(TrialSelfInspectionRecord::getRecordNo).collect(Collectors.toList())) {
+                    String number = recordNo.split("-")[recordNo.split("-").length - 1];
+                    numberRecordNos.add(number);
+                }
+                int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
+                if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
+                    if (ObjectUtil.isEmpty(dto.getRecordNo())) {
+                        maxRecordNo = "0001";
+                    } else {
+                        String recordNo = dto.getRecordNo();
+                        String substring = recordNo.substring(recordNo.length() - 4);
+                        String s = spUtils.buildSerial(maxRecordNo1, 4);
+                        String replace = recordNo.replace(substring, s);
+                        dto.setRecordNo(replace);
+                    }
+                } else {
+                    throw new ServiceException("当前编号已达到最大值9999,操作失败");
+                }
             }
-            int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
-            if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
-                if (ObjectUtil.isEmpty(dto.getRecordNo())) {
-                    maxRecordNo = "0001";
+            if (bg.size() > 0) {
+                List<String> numberReportNos = new ArrayList<>();
+                for (String reportNo : bg.stream().map(TrialSelfInspectionRecord::getReportNo).collect(Collectors.toList())) {
+                    String number = reportNo.split("-")[reportNo.split("-").length - 1];
+                    numberReportNos.add(number);
+                }
+                int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNos)) + 1;
+                if (maxReportNo1 < 9999 && maxReportNo1 > 0) {
+                    if (ObjectUtil.isEmpty(dto.getReportNo())) {
+                        maxReportNo = "0001";
+                    } else {
+                        String reportNo = dto.getReportNo();
+                        String substring = reportNo.substring(reportNo.length() - 4);
+                        String s = spUtils.buildSerial(maxReportNo1, 4);
+                        String replace = reportNo.replace(substring, s);
+                        dto.setReportNo(replace);
+                    }
                 } else {
-                    String recordNo = dto.getRecordNo();
-                    String substring = recordNo.substring(recordNo.length() - 4);
-                    String s = spUtils.buildSerial(maxRecordNo1, 4);
-                    String replace = recordNo.replace(substring, s);
-                    dto.setRecordNo(replace);
+                    throw new ServiceException("当前编号已达到最大值9999,操作失败");
                 }
+            }
+
+            List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId())));
+            WbsTreePrivate wbsTreePrivate = wbsTreePrivates.stream().findAny().orElse(null);
+            ContractInfo contract = contractClient.getContractById(dto.getContractId());
+            int year = LocalDateTimeUtil.now().getYear();
+            if (wbsTreePrivate == null) {
+                throw new ServiceException("未找到当前节点信息,操作失败!");
             } else {
-                throw new ServiceException("当前编号已达到最大值9999,操作失败");
+                //记录表
+                if (StringUtils.isNotEmpty(maxRecordNo)) {
+                    String str1 = "JL" +
+                            "-" + contract.getContractNumber() +
+                            "-" + year +
+                            "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
+                            "-" + maxRecordNo;
+                    dto.setRecordNo(str1);
+                }
+
+                //报告单
+                if (StringUtils.isNotEmpty(maxReportNo)) {
+                    String str2 = "BG" +
+                            "-" + contract.getContractNumber() +
+                            "-" + year +
+                            "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
+                            "-" + maxReportNo;
+                    dto.setReportNo(str2);
+                }
             }
         }
-        if (bg.size() > 0) {
-            List<String> numberReportNos = new ArrayList<>();
-            for (String reportNo : bg.stream().map(TrialSelfInspectionRecord::getReportNo).collect(Collectors.toList())) {
-                String number = reportNo.split("-")[reportNo.split("-").length - 1];
-                numberReportNos.add(number);
-            }
-            int maxReportNo1 = Integer.parseInt(Collections.max(numberReportNos)) + 1;
-            if (maxReportNo1 < 9999 && maxReportNo1 > 0) {
-                if (ObjectUtil.isEmpty(dto.getReportNo())) {
-                    maxReportNo = "0001";
+        //记录表
+        else if (("1").equals(dto.getTableType()) || ("9").equals(dto.getTableType())) {
+            //获取记录表最大编号
+            List<String> recordNos = jl.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];
+                    numberRecordNos.add(number);
+                }
+                int maxRecordNo1 = Integer.parseInt(Collections.max(numberRecordNos)) + 1;
+                if (maxRecordNo1 < 9999 && maxRecordNo1 > 0) {
+                    maxRecordNo = spUtils.buildSerial(maxRecordNo1, 4);
                 } else {
-                    String reportNo = dto.getReportNo();
-                    String substring = reportNo.substring(reportNo.length() - 4);
-                    String s = spUtils.buildSerial(maxReportNo1, 4);
-                    String replace = reportNo.replace(substring, s);
-                    dto.setReportNo(replace);
+                    throw new ServiceException("当前编号已达到最大值9999,操作失败");
                 }
-            } else {
-                throw new ServiceException("当前编号已达到最大值9999,操作失败");
             }
-        }
-
-        List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(dto.getNodeId())));
-        WbsTreePrivate wbsTreePrivate = wbsTreePrivates.stream().findAny().orElse(null);
-        ContractInfo contract = contractClient.getContractById(dto.getContractId());
-        int year = LocalDateTimeUtil.now().getYear();
-        if (wbsTreePrivate == null) {
-            throw new ServiceException("未找到当前节点信息,操作失败!");
-        } else {
-            //记录表
-            if (StringUtils.isNotEmpty(maxRecordNo)) {
+            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 +
@@ -486,8 +541,35 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 dto.setRecordNo(str1);
             }
 
-            //报告单
-            if (StringUtils.isNotEmpty(maxReportNo)) {
+        }
+        //报告单
+        else if (("2").equals(dto.getTableType()) || ("10").equals(dto.getTableType())) {
+
+            //获取报告单最大编号
+            List<String> reportNos = bg.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,操作失败");
+                }
+            }
+            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 +

+ 2 - 2
blade-service/blade-manager/src/main/java/com/mixsmart/utils/FormulaUtils.java

@@ -457,10 +457,10 @@ public class FormulaUtils {
         }
     }
 
-    public static void main(String[] args) {
+    /*public static void main(String[] args) {
         Map<String,String> map =getElementCell("");
         System.out.println();
-    }
+    }*/
 
 
     public static List<String> itemNames =Arrays.asList(

+ 40 - 27
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

@@ -38,33 +38,33 @@ public class WbsTreeContractController extends BladeController {
     @ApiOperation(value = "查询当前节点下所有元素表信息", notes = "传入节点primaryKeyId、type、合同段id、项目id")
     public R searchNodeAllTable(String primaryKeyId, String type, String contractId, String projectId) {
         List<AppWbsTreeContractVO> list = iWbsTreeContractService.searchNodeAllTable(primaryKeyId, type, contractId, projectId);
-//        boolean flag = false;
-//        Set<Long> l1 = new HashSet<>();
-//        for (AppWbsTreeContractVO vo : list) {
-//            if (vo.getNodeName().contains("_PL_")){
-//                l1.add(vo.getId());
-//                flag = true;
-//            }
-//        }
-//        if (flag){
-//            for (Long aLong : l1) {
-//                List<AppWbsTreeContractVO> vos = new ArrayList<>();
-//                for (AppWbsTreeContractVO vo : list) {
-//                    if (aLong.equals(vo.getId())){
-//                        vos.add(vo);
-//                    }
-//                }
-//                list = list.stream().filter(l -> {
-//                    if (l.getId().equals(aLong)){
-//                        return false;
-//                    }else {
-//                        return true;
-//                    }
-//                }).collect(Collectors.toList());
-//                vos = vos.stream().sorted(Comparator.comparing(AppWbsTreeContractVO::getPKeyId)).collect(Collectors.toList());
-//                list.addAll(vos);
-//            }
-//        }
+        /*boolean flag = false;
+        Set<Long> l1 = new HashSet<>();
+        for (AppWbsTreeContractVO vo : list) {
+            if (vo.getNodeName().contains("_PL_")){
+                l1.add(vo.getId());
+                flag = true;
+            }
+        }
+        if (flag){
+            for (Long aLong : l1) {
+                List<AppWbsTreeContractVO> vos = new ArrayList<>();
+                for (AppWbsTreeContractVO vo : list) {
+                    if (aLong.equals(vo.getId())){
+                        vos.add(vo);
+                    }
+                }
+                list = list.stream().filter(l -> {
+                    if (l.getId().equals(aLong)){
+                        return false;
+                    }else {
+                        return true;
+                    }
+                }).collect(Collectors.toList());
+                vos = vos.stream().sorted(Comparator.comparing(AppWbsTreeContractVO::getPKeyId)).collect(Collectors.toList());
+                list.addAll(vos);
+            }
+        }*/
         if (list.size() > 0) {
             list.stream().forEach(l -> {
                 if (StringUtils.isNotBlank(l.getHtmlUrl())) {
@@ -157,4 +157,17 @@ public class WbsTreeContractController extends BladeController {
                 .eq(WbsTreeContract::getPKeyId, id).eq(WbsTreeContract::getIsDeleted, 0)));
     }
 
+    /**
+     * 资料填报 - 同步相同表数据(同一节点下,把施工表数据同步到监理表中)
+     */
+    @PostMapping("/sync-tab-data")
+    @ApiOperationSupport(order = 8)
+    @ApiOperation(value = "资料填报 - 同步相同表数据", notes = "传入节点pKeyId")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "pKeyId", value = "节点pKeyId", required = true)
+    })
+    public R syncTabData(@RequestParam("pKeyId") String pKeyId) {
+        return R.status(iWbsTreeContractService.syncTabData(pKeyId));
+    }
+
 }

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

@@ -215,9 +215,9 @@ public class WbsTreeController extends BladeController {
 
                     //删除对应到项目合同段的表
                     List<String> projectPKeyIds = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
-                            .select(WbsTreePrivate::getPKeyId).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 2).eq(WbsTreePrivate::getId, id)).stream().map(WbsTreePrivate::getPKeyId).map(String::valueOf).collect(Collectors.toList());
+                            .select(WbsTreePrivate::getPKeyId).eq(WbsTreePrivate::getType, 2).eq(WbsTreePrivate::getId, id)).stream().map(WbsTreePrivate::getPKeyId).map(String::valueOf).collect(Collectors.toList());
                     List<String> contractPKeyIds = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>query().lambda()
-                            .select(WbsTreeContract::getPKeyId).eq(WbsTreeContract::getStatus, 1).eq(WbsTreeContract::getType, 2).and(obj -> obj.eq(WbsTreeContract::getId, id).or().eq(WbsTreeContract::getOldId, id))).stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
+                            .select(WbsTreeContract::getPKeyId).eq(WbsTreeContract::getType, 2).and(obj -> obj.eq(WbsTreeContract::getId, id).or().eq(WbsTreeContract::getOldId, id))).stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
                     if (projectPKeyIds.size() > 0) {
                         String join = StringUtils.join(projectPKeyIds, ",");
                         String sql = "update m_wbs_tree_private set is_deleted = 1 where p_key_id in(" + join + ")";

+ 19 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreePrivateClientImpl.java

@@ -9,26 +9,22 @@ import com.mixsmart.utils.StringUtils;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springblade.common.utils.SnowFlakeUtil;
-import org.springblade.core.log.exception.ServiceException;
-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.mapper.WbsTreeContractMapper;
 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;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.*;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @RestController
@@ -151,10 +147,12 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
             if (newFiles.size() > 0) {
                 tableFileClient.saveBatch(newFiles);
 
-                //修改文件上传按钮状态
-                String sqlAdd = "insert into u_trial_self_data_record(id,record_id,tab_id,is_buss_show,is_tab_pdf,is_tab_file_type,pdf_url) values" +
-                        "(" + SnowFlakeUtil.getId() + "," + id + "," + newPkId + "," + 1 + "," + 1 + "," + 2 + ",null)";
-                jdbcTemplate.execute(sqlAdd);
+                //修改文件上传按钮状态(剔除原表pdf)
+                if (newFiles.size() >= 2) {
+                    String sqlAdd = "insert into u_trial_self_data_record(id,record_id,tab_id,is_buss_show,is_tab_pdf,is_tab_file_type,pdf_url) values" +
+                            "(" + SnowFlakeUtil.getId() + "," + id + "," + newPkId + "," + 1 + "," + 1 + "," + 2 + ",null)";
+                    jdbcTemplate.execute(sqlAdd);
+                }
             }
             if (ObjectUtils.isNotEmpty(wbsTreePrivate)) {
                 wbsTreePrivateService.save(wbsTreePrivate);
@@ -226,6 +224,18 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
         textDictInfoService.insertBatch(obj, 1000);
     }
 
+    @Override
+    public List<WbsTreeContract> selectListNode(List<Long> fuIds, String projectId, String wbsId, String wbsType, String contractId) {
+        return wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>lambdaQuery()
+                .in(WbsTreeContract::getId, fuIds)
+                .eq(WbsTreeContract::getProjectId, projectId)
+                .eq(WbsTreeContract::getWbsId, wbsId)
+                .eq(WbsTreeContract::getWbsType, wbsType)
+                .eq(WbsTreeContract::getContractId, contractId)
+                .eq(WbsTreeContract::getType, 1)
+                .eq(WbsTreeContract::getStatus, 1));
+    }
+
     private void foreachSetChildList(List<WbsTreeContractTreeVOS> vosResult, List<WbsTreePrivateVO> voList) {
         voList.forEach(wbsTreePrivateVO -> {
             WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();

+ 23 - 15
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml

@@ -111,7 +111,9 @@
     </insert>
 
     <delete id="deleteContractRelationJLYZ">
-        delete from m_contract_relation_jlyz where contract_id_jlyz = #{id}
+        delete
+        from m_contract_relation_jlyz
+        where contract_id_jlyz = #{id}
     </delete>
 
     <select id="selectContractByProjectIds" resultMap="contractInfoResultMap">
@@ -417,7 +419,11 @@
     </select>
 
     <select id="selectContractUserInfo" resultType="org.springblade.manager.entity.SaveUserInfoByProject">
-        select * from m_project_assignment_user where contract_id = #{contractId} and is_deleted = 0 and status = 1
+        select *
+        from m_project_assignment_user
+        where contract_id = #{contractId}
+          and is_deleted = 0
+          and status = 1
     </select>
 
     <select id="userListByIds" resultType="org.springblade.system.user.vo.UserContractInfoVO">
@@ -428,18 +434,17 @@
     </select>
 
     <select id="tree5" resultType="org.springblade.manager.vo.WbsTreeContractTreeAllVO">
-        SELECT
-            d.p_key_id                                                               AS "primaryKeyId",
-            d.id,
-            d.parent_id                                                              AS "parentId",
-            IFNULL(if(length(trim(full_name)) > 0, full_name, node_name), node_name) AS title,
-            partition_code,
-            node_type,
-            sort,
-            d.contract_id                                                            AS contractIdRelation,
-            d.type,
-            d.major_data_type                                                        AS majorDataType,
-            d.create_time
+        SELECT d.p_key_id                                                               AS "primaryKeyId",
+               d.id,
+               d.parent_id                                                              AS "parentId",
+               IFNULL(if(length(trim(full_name)) > 0, full_name, node_name), node_name) AS title,
+               partition_code,
+               node_type,
+               sort,
+               d.contract_id                                                            AS contractIdRelation,
+               d.type,
+               d.major_data_type                                                        AS majorDataType,
+               d.create_time
         FROM m_wbs_tree_contract d
         WHERE contract_id = #{contractId}
           AND d.type = 1
@@ -495,6 +500,9 @@
 
     <select id="trialRelationTreeLazy" resultType="org.springblade.manager.vo.TrialRecordZJTreeLazyVO">
         SELECT d.p_key_id                                                                       AS "primaryKeyId",
+               d.node_type                                                                      AS "nodeType",
+               d.type                                                                           AS "type",
+               d.major_data_type                                                                AS "majorDataType",
                d.id                                                                             AS id,
                IFNULL(if(length(trim(d.full_name)) > 0, d.full_name, d.node_name), d.node_name) AS fullName,
                d.parent_id                                                                      AS "parentId",
@@ -506,7 +514,7 @@
                   and contract_id = #{contractId}
                   and wbs_id = #{wbsId}
                   and type = 1
-                   )                                                        AS "status"
+               )                                                                                AS "status"
         FROM m_wbs_tree_contract d
         WHERE d.is_deleted = 0
           AND d.status = 1

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

@@ -56,4 +56,7 @@ public interface IWbsTreeContractService extends BaseService<WbsTreeContract> {
 
     // 频率设计值  添加表单
     boolean addTabInfoByRan(RangeInfo info, List<Object> moreData, String[] excLenght) throws FileNotFoundException;
+
+    boolean syncTabData(String pKeyId);
+
 }

+ 22 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1782,7 +1782,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             htmlString = htmlString.replaceAll("title", "titlexx");
             Document doc = Jsoup.parse(htmlString);
             //匹配
-            Elements bgHB = doc.select("el-input[placeholderxx~=报告编号.*]");
+            Elements bgBH = doc.select("el-input[placeholderxx~=报告编号.*]");
+            Elements cbdwBH = doc.select("el-input[placeholderxx~=承包单位.*]");
+            Elements jldwBH = doc.select("el-input[placeholderxx~=监理单位.*]");
             Elements jlBH = doc.select("el-input[placeholderxx~=记录编号.*]");
             Elements gcName = doc.select("el-input[placeholderxx~=工程名称.*]");
             Elements sgName = doc.select("el-input[placeholderxx~=施工单位.*]");
@@ -1791,6 +1793,22 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
             ContractInfo contractInfo = jdbcTemplate.query("select construction_unit_name,supervision_unit_name,contract_name from m_contract_info where id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
             if (contractInfo != null) {
+                //承包单位
+                if (cbdwBH.size() >= 1) {
+                    for (Element element : cbdwBH) {
+                        reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(contractInfo.getConstructionUnitName()) ? contractInfo.getConstructionUnitName() : "");
+                        break;
+                    }
+                }
+
+                //监理单位
+                if (jldwBH.size() >= 1) {
+                    for (Element element : jldwBH) {
+                        reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(contractInfo.getSupervisionUnitName()) ? contractInfo.getSupervisionUnitName() : "");
+                        break;
+                    }
+                }
+
                 //施工单位
                 if (sgName.size() >= 1) {
                     for (Element element : sgName) {
@@ -1798,6 +1816,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         break;
                     }
                 }
+
                 //委托单位
                 if (wtName.size() >= 1) {
                     for (Element element : wtName) {
@@ -1827,8 +1846,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 TrialSelfInspectionRecord record = jdbcTemplate.query("select record_no,report_no from u_trial_self_inspection_record where id = " + groupId, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class)).stream().findAny().orElse(null);
                 if (record != null) {
                     //报告编号
-                    if (bgHB.size() >= 1) {
-                        for (Element element : bgHB) {
+                    if (bgBH.size() >= 1) {
+                        for (Element element : bgBH) {
                             reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(record.getReportNo()) ? record.getReportNo() : "");
                             break;
                         }

+ 163 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -43,6 +43,8 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.*;
 import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 @Service
@@ -534,6 +536,167 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         return false;
     }
 
+    @Override
+    public boolean syncTabData(String pKeyId) {
+        WbsTreeContract node = baseMapper.selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pKeyId));
+        if (node != null) {
+            List<WbsTreeContract> tabs = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getParentId, node.getId())
+                    .select(WbsTreeContract::getNodeName, WbsTreeContract::getTableOwner, WbsTreeContract::getPKeyId, WbsTreeContract::getInitTableName, WbsTreeContract::getSort, WbsTreeContract::getFullName, WbsTreeContract::getUpdateTime, WbsTreeContract::getOldId)
+                    .eq(WbsTreeContract::getContractId, node.getContractId()).eq(WbsTreeContract::getType, 2)
+                    .eq(WbsTreeContract::getWbsId, node.getWbsId()).eq(WbsTreeContract::getWbsType, node.getWbsType())
+                    .eq(WbsTreeContract::getStatus, 1));
+
+            List<WbsTreeContract> sgTab = tabs.stream().filter(f -> "1,2,3".contains(f.getTableOwner())).collect(Collectors.toList());
+            List<WbsTreeContract> jlTab = tabs.stream().filter(f -> "4,5,6".contains(f.getTableOwner())).collect(Collectors.toList());
+
+            List<WbsTreeContract> sgTabSort = sgTab.stream()
+                    .sorted((a, b) -> {
+                        Integer aSort = a.getSort() != null ? a.getSort() : 0;
+                        Integer bSort = b.getSort() != null ? b.getSort() : 0;
+                        int compareSort = aSort.compareTo(bSort);
+                        if (compareSort != 0) return compareSort;
+
+                        String aFullName = a.getFullName() != null ? a.getFullName() : "";
+                        String bFullName = b.getFullName() != null ? b.getFullName() : "";
+                        int compareFullName = aFullName.compareToIgnoreCase(bFullName);
+                        if (compareFullName != 0) return compareFullName;
+
+                        long aPKeyId = a.getPKeyId() != null ? a.getPKeyId() : 0L;
+                        long bPKeyId = b.getPKeyId() != null ? b.getPKeyId() : 0L;
+                        int comparePKeyId = Long.compare(aPKeyId, bPKeyId);
+                        if (comparePKeyId != 0) return comparePKeyId;
+
+                        Long aUpdateTime = a.getUpdateTime() != null ? a.getUpdateTime().getTime() : 0L;
+                        Long bUpdateTime = b.getUpdateTime() != null ? b.getUpdateTime().getTime() : 0L;
+                        return aUpdateTime.compareTo(bUpdateTime);
+                    })
+                    .collect(Collectors.toList());
+
+            Map<Long, String> sgYsNodeMaps = new HashMap<>();
+            Map<Long, String> jlYsNodeMaps = new HashMap<>();
+            Map<Long, String> plYsMaps = new HashMap<>();
+
+            Map<Long, String> sgCopyNodeMaps = new HashMap<>();
+            Map<Long, String> jlCopyNodeMaps = new HashMap<>();
+            Map<Long, String> plJlNodeMaps = new HashMap<>();
+
+            for (WbsTreeContract wbsTreeContract : sgTabSort) {
+                if (wbsTreeContract.getOldId() == null) {
+                    //施工原始表
+                    String s = extractAlphameric(wbsTreeContract.getNodeName());
+                    if (StringUtils.isNotEmpty(s)) {
+                        sgYsNodeMaps.put(wbsTreeContract.getPKeyId(), s + "---" + wbsTreeContract.getInitTableName());
+                    }
+                } else {
+                    //复制表
+                    if (wbsTreeContract.getNodeName().contains("__")) {
+                        String s = extractAlphameric(wbsTreeContract.getNodeName());
+                        if (StringUtils.isNotEmpty(s)) {
+                            sgCopyNodeMaps.put(wbsTreeContract.getPKeyId(), s + "---" + wbsTreeContract.getInitTableName());
+                        }
+                    }
+                    //原始频率表
+                    if (wbsTreeContract.getNodeName().contains("pl")) {
+                        String s = extractAlphameric(wbsTreeContract.getNodeName());
+                        if (StringUtils.isNotEmpty(s)) {
+                            plYsMaps.put(wbsTreeContract.getPKeyId(), s + "---" + wbsTreeContract.getInitTableName());
+                        }
+                    }
+                }
+
+            }
+
+            List<WbsTreeContract> jlTabSort = jlTab.stream()
+                    .sorted((a, b) -> {
+                        Integer aSort = a.getSort() != null ? a.getSort() : 0;
+                        Integer bSort = b.getSort() != null ? b.getSort() : 0;
+                        int compareSort = aSort.compareTo(bSort);
+                        if (compareSort != 0) return compareSort;
+
+                        String aFullName = a.getFullName() != null ? a.getFullName() : "";
+                        String bFullName = b.getFullName() != null ? b.getFullName() : "";
+                        int compareFullName = aFullName.compareToIgnoreCase(bFullName);
+                        if (compareFullName != 0) return compareFullName;
+
+                        long aPKeyId = a.getPKeyId() != null ? a.getPKeyId() : 0L;
+                        long bPKeyId = b.getPKeyId() != null ? b.getPKeyId() : 0L;
+                        int comparePKeyId = Long.compare(aPKeyId, bPKeyId);
+                        if (comparePKeyId != 0) return comparePKeyId;
+
+                        Long aUpdateTime = a.getUpdateTime() != null ? a.getUpdateTime().getTime() : 0L;
+                        Long bUpdateTime = b.getUpdateTime() != null ? b.getUpdateTime().getTime() : 0L;
+                        return aUpdateTime.compareTo(bUpdateTime);
+                    })
+                    .collect(Collectors.toList());
+
+            for (WbsTreeContract wbsTreeContract : jlTabSort) {
+                if (wbsTreeContract.getOldId() == null) {
+                    //监理原始表
+                    String s = extractAlphameric(wbsTreeContract.getNodeName());
+                    if (StringUtils.isNotEmpty(s)) {
+                        jlYsNodeMaps.put(wbsTreeContract.getPKeyId(), s + "---" + wbsTreeContract.getInitTableName());
+                    }
+                } else {
+                    //复制表
+                    if (wbsTreeContract.getNodeName().contains("__")) {
+                        String s = extractAlphameric(wbsTreeContract.getNodeName());
+                        if (StringUtils.isNotEmpty(s)) {
+                            jlCopyNodeMaps.put(wbsTreeContract.getPKeyId(), s + "---" + wbsTreeContract.getInitTableName());
+                        }
+                    }
+                    //频率表
+                    if (wbsTreeContract.getNodeName().contains("pl")) {
+                        String s = extractAlphameric(wbsTreeContract.getNodeName());
+                        if (StringUtils.isNotEmpty(s)) {
+                            plJlNodeMaps.put(wbsTreeContract.getPKeyId(), s + "---" + wbsTreeContract.getInitTableName());
+                        }
+                    }
+                }
+            }
+
+
+        }
+        return false;
+    }
+
+    private void syncTabDataImpl(Map<Long, String> sgData, Map<Long, String> jlData) {
+        for (Map.Entry<Long, String> sgTab : sgData.entrySet()) {
+            Long pKeyId = sgTab.getKey();
+            String[] split = sgTab.getValue().split("---");
+            String tabNameRe = split[0];
+            String initTabName = split[1];
+
+
+
+
+            // TODO
+        }
+
+    }
+
+
+    /**
+     * 截取字符串中的英文和数字,返回处理后的字符串
+     *
+     * @param str 待处理的字符串
+     * @return 处理后得到的字符串
+     */
+    private static String extractAlphameric(String str) {
+        if (str == null) {
+            return "";
+        }
+
+        Pattern pattern = Pattern.compile("[a-zA-Z0-9]+");
+        Matcher matcher = pattern.matcher(str);
+
+        StringBuilder resultBuilder = new StringBuilder();
+        while (matcher.find()) {
+            resultBuilder.append(matcher.group());
+        }
+
+        return resultBuilder.toString();
+    }
+
     @Override
     public List<WbsTreeContract> updateAllNodeTabById(WbsTreePrivate aPrivate) {
         return baseMapper.updateAllNodeTabById(aPrivate);

+ 28 - 26
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -403,6 +403,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         //获取当前项目下所有合同段信息
         List<ContractInfo> contractInfos = contractInfoMapper.selectList(Wrappers.<ContractInfo>query().lambda().select(ContractInfo::getId, ContractInfo::getContractType).eq(ContractInfo::getPId, projectId));
         List<Long> contractInfosIds = contractInfos.stream().filter(f -> 1 == f.getContractType()).map(ContractInfo::getId).collect(Collectors.toList());
+
         Map<Long, WbsTreePrivate> maps = wbsTreePrivatesAll.stream().collect(Collectors.toMap(WbsTreePrivate::getId, wbsTreePrivate -> wbsTreePrivate, (obj1, obj2) -> obj1));
 
         for (WbsTree wbsTree : wbsTreeListAll) {
@@ -437,7 +438,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
             //获取当前项目下所有合同段下的复制、新增节点
             String sql = "select id,old_id,project_id,contract_id from m_wbs_tree_contract where old_id is not null and project_id = " + projectId + " and contract_id in(" + org.apache.commons.lang.StringUtils.join(contractInfosIds, ",") + ") and wbs_type = " + wbsType + " and type = 1 and status = 1 and is_deleted = 0 and old_id is not null";
             List<WbsTreeContract> wbsTreeContractsCopyOrAddAll = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
-            Map<String, List<WbsTreeContract>> copyAddNodes = wbsTreeContractsCopyOrAddAll.stream().collect(Collectors.groupingBy(WbsTreeContract::getOldId));
+            Map<String, List<WbsTreeContract>> copyAddNodes = wbsTreeContractsCopyOrAddAll.stream().filter(f -> Objects.nonNull(f.getOldId())).collect(Collectors.groupingBy(WbsTreeContract::getOldId));
             List<WbsTreeContract> listContractAdd = new ArrayList<>();
             for (WbsTreeContract obj1 : listContract) {
                 List<WbsTreeContract> copyAddNodesNow = copyAddNodes.get(obj1.getId().toString());
@@ -521,7 +522,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
             //获取当前项目下所有合同段下的复制、新增节点
             String sql = "select id,old_id,project_id,contract_id from m_wbs_tree_contract where old_id is not null and project_id = " + projectId + " and contract_id in(" + org.apache.commons.lang.StringUtils.join(contractInfosIds, ",") + ") and wbs_type = " + wbsType + " and type = 1 and status = 1 and is_deleted = 0 and old_id is not null";
             List<WbsTreeContract> wbsTreeContractsCopyOrAddAll = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
-            Map<String, List<WbsTreeContract>> copyAddNodes = wbsTreeContractsCopyOrAddAll.stream().collect(Collectors.groupingBy(WbsTreeContract::getOldId));
+            Map<String, List<WbsTreeContract>> copyAddNodes = wbsTreeContractsCopyOrAddAll.stream().filter(f -> Objects.nonNull(f.getOldId())).collect(Collectors.groupingBy(WbsTreeContract::getOldId));
             List<WbsTreeContract> listContractAdd = new ArrayList<>();
             for (WbsTreeContract obj1 : listContract) {
                 List<WbsTreeContract> copyAddNodesNow = copyAddNodes.get(obj1.getId().toString());
@@ -727,10 +728,10 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                 //TODO ---------公有引用同步---------
                 //获取对应公有树节点
                 Map<Long, WbsTree> treePublicNodeAll = wbsTreeMapper.selectList(Wrappers.<WbsTree>query().lambda()
-                                .select(WbsTree::getId)
-                                .in(WbsTree::getId, privateNodeIds)
-                                .eq(WbsTree::getStatus, 1)
-                                .eq(WbsTree::getType, 1))
+                        .select(WbsTree::getId)
+                        .in(WbsTree::getId, privateNodeIds)
+                        .eq(WbsTree::getStatus, 1)
+                        .eq(WbsTree::getType, 1))
                         .stream().collect(Collectors.toMap(WbsTree::getId, Function.identity()));
 
                 Map<String, Long> map = new HashMap<>();
@@ -892,9 +893,10 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         }
         return false;
     }
+
     @Override
-    public boolean syncNodeParam(String projectId, String pKeyId){
-        projectId=null;//暂不执行
+    public boolean syncNodeParam(String projectId, String pKeyId) {
+        projectId = null;//暂不执行
         if (StringUtils.isNotEmpty(projectId) && StringUtils.isNotEmpty(pKeyId)) {
             ProjectInfo projectInfo = projectInfoMapper.selectById(projectId);
             //当前选择同步的节点信息
@@ -904,7 +906,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
             }
 
             //获取当前选择的节点与它所有子节点
-            List<WbsTreePrivate>selectNodeAndChildNodes=Optional.ofNullable(this.getChildNodes(selectNodeNow)).orElse(new ArrayList<>());
+            List<WbsTreePrivate> selectNodeAndChildNodes = Optional.ofNullable(this.getChildNodes(selectNodeNow)).orElse(new ArrayList<>());
             selectNodeAndChildNodes.add(selectNodeNow);
             List<Long> privateNodeIds = selectNodeAndChildNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList());
             List<Long> privateNodePKeyIds = selectNodeAndChildNodes.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
@@ -966,12 +968,12 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                         }
                     });
                     if (!insertList.isEmpty()) {
-                        insertList.forEach(i->i.setId(SnowFlakeUtil.getId()));
+                        insertList.forEach(i -> i.setId(SnowFlakeUtil.getId()));
                         this.wbsParamServiceImpl.saveOrUpdateBatch(insertList, 1000);
                         /*生成公式,并自动绑定元素*/
-                        Map<Long,Formula> insertFormulaMap = insertList.stream().map(e->{
+                        Map<Long, Formula> insertFormulaMap = insertList.stream().map(e -> {
                             Map<String, Object> tmpMap = new HashMap<>();
-                            Formula  formula = new Formula();
+                            Formula formula = new Formula();
                             formula.setOutm(Formula.FULL);
                             formula.setParamId(e.getId());
                             Map<String, String> keyMap = new HashMap<>();
@@ -988,20 +990,20 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                             formula.setMap(JSON.toJSONString(tmpMap));
                             formula.setId(SnowFlakeUtil.getId());
                             return formula;
-                        }).collect(Collectors.toMap(Formula::getParamId,f->f));
-                        List<String> nodeIds= insertList.stream().map(WbsParam::getNodeId).distinct().map(Objects::toString).collect(Collectors.toList());
+                        }).collect(Collectors.toMap(Formula::getParamId, f -> f));
+                        List<String> nodeIds = insertList.stream().map(WbsParam::getNodeId).distinct().map(Objects::toString).collect(Collectors.toList());
                         /*每道工序下包含的元素集合*/
-                        List<Map<String, Object>> listMaps  = this.jdbcTemplate.queryForList(
+                        List<Map<String, Object>> listMaps = this.jdbcTemplate.queryForList(
                                 "select c.e_name as name ,c.id,a.p_key_id pKeyId from m_wbs_tree_private a " +
                                         "inner join m_wbs_tree_private b on (a.id=b.parent_id and a.wbs_id=b.wbs_id) " +
                                         "inner join m_wbs_form_element c on  b.init_table_id=c.f_id " +
-                                        "where  b.project_id=" + projectId + " and a.p_key_id in(?)  and b.is_deleted=0 and c.is_deleted=0 ",nodeIds);
+                                        "where  b.project_id=" + projectId + " and a.p_key_id in(?)  and b.is_deleted=0 and c.is_deleted=0 ", nodeIds);
 
-                        Map<String,List<Map<String, Object>>> groupElementNode = listMaps.stream().collect(Collectors.groupingBy(e->Func.toStr(e.get("pKeyId"))));
-                        List<ElementFormulaMapping> insertEfm= new ArrayList<>();
-                        insertList.forEach(p->{
-                            List<Map<String, Object>> elementMap =groupElementNode.get(p.getNodeId().toString());
-                            Formula formula= insertFormulaMap.get(p.getId());
+                        Map<String, List<Map<String, Object>>> groupElementNode = listMaps.stream().collect(Collectors.groupingBy(e -> Func.toStr(e.get("pKeyId"))));
+                        List<ElementFormulaMapping> insertEfm = new ArrayList<>();
+                        insertList.forEach(p -> {
+                            List<Map<String, Object>> elementMap = groupElementNode.get(p.getNodeId().toString());
+                            Formula formula = insertFormulaMap.get(p.getId());
                             elementMap.forEach(m -> {
                                 if (com.mixsmart.utils.StringUtils.handleNull(m.get("name")).contains(p.getName())) {
                                     /*匹配名称,且该元素没有绑定任何节点参数公式*/
@@ -1022,11 +1024,11 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                                 }
                             });
                         });
-                        if(insertFormulaMap.size()>0){
-                            this.formulaService.saveBatch(insertFormulaMap.values(),1000);
+                        if (insertFormulaMap.size() > 0) {
+                            this.formulaService.saveBatch(insertFormulaMap.values(), 1000);
                         }
-                        if(insertEfm.size()>0){
-                            this.elementFormulaMappingService.saveBatch(insertEfm,1000);
+                        if (insertEfm.size() > 0) {
+                            this.elementFormulaMappingService.saveBatch(insertEfm, 1000);
                         }
                     }
                 }
@@ -1681,7 +1683,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
     }
 
     //反向递归查询父级节点
-    private void fxSelectParentNode(List<WbsTreePrivate> wbsTreePrivates, Set<WbsTreePrivate> resultNode, String projectId, String wbsId, String wbsType) {
+    public void fxSelectParentNode(List<WbsTreePrivate> wbsTreePrivates, Set<WbsTreePrivate> resultNode, String projectId, String wbsId, String wbsType) {
         List<Long> fuIds = wbsTreePrivates.stream().map(WbsTreePrivate::getParentId).distinct().collect(Collectors.toList());
         if (fuIds.size() > 0 && fuIds.get(0) != 0L) {
             List<WbsTreePrivate> fuNodes = baseMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()