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

Merge branch 'master' of http://47.110.251.215:3000/java_org/bladex

huangtf 2 лет назад
Родитель
Сommit
b14678f192
45 измененных файлов с 1363 добавлено и 586 удалено
  1. 1 1
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSelfInspectionRecord.java
  2. 6 0
      blade-service-api/blade-manager-api/pom.xml
  3. 64 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ArchiveAutoRuleWbs.java
  4. 1 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ArchiveTree.java
  5. 3 3
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/ExcelTabClient.java
  6. 3 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/TableFileClient.java
  7. 5 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/WbsTreePrivateClient.java
  8. 34 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ArchiveAutoRuleWbsVO.java
  9. 35 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/TrialRecordZJTreeVO.java
  10. 13 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/NeiYeController.java
  11. 2 1
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java
  12. 3 3
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java
  13. 5 1
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java
  14. 7 2
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java
  15. 316 157
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  16. 4 2
      blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java
  17. 21 13
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ArchiveTreeController.java
  18. 20 15
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java
  19. 10 10
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/FormulaController.java
  20. 1 5
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java
  21. 7 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java
  22. 3 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/TableFileClientImpl.java
  23. 59 33
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreePrivateClientImpl.java
  24. 7 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/formula/Mileage.java
  25. 10 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/FormulaMileage.java
  26. 46 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveAutoRuleWbsMapper.java
  27. 36 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveAutoRuleWbsMapper.xml
  28. 10 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.java
  29. 17 17
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.xml
  30. 15 39
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.java
  31. 18 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml
  32. 1 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.java
  33. 8 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.xml
  34. 41 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IArchiveAutoRuleWbsService.java
  35. 12 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IArchiveTreeService.java
  36. 2 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IExcelTabService.java
  37. 3 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreePrivateService.java
  38. 41 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveAutoRuleWbsServiceImpl.java
  39. 289 126
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeServiceImpl.java
  40. 31 22
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java
  41. 74 49
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
  42. 17 5
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaOptionServiceImpl.java
  43. 31 66
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java
  44. 29 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java
  45. 2 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

+ 1 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSelfInspectionRecord.java

@@ -37,7 +37,7 @@ public class TrialSelfInspectionRecord extends BaseEntity {
     @ApiModelProperty(value = "检测类别")
     private Integer detectionCategory;
 
-    @ApiModelProperty(value = "是否上传合格证 '0'=是 ‘1’=否")
+    @ApiModelProperty(value = "是否上传合格证 '1'=是 '0'=否")
     private Integer isUploadCertificate;
 
     @ApiModelProperty(value = "合同段id")

+ 6 - 0
blade-service-api/blade-manager-api/pom.xml

@@ -17,6 +17,12 @@
             <groupId>com.alibaba</groupId>
             <artifactId>fastjson</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-business-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
     <packaging>jar</packaging>
 

+ 64 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ArchiveAutoRuleWbs.java

@@ -0,0 +1,64 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+@Data
+@TableName("m_archive_auto_rule_wbs")
+@EqualsAndHashCode(callSuper = true)
+public class ArchiveAutoRuleWbs extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* wbs节点id
+	*/
+		private Long wbsId;
+	/**
+	* wbs节点根节点id
+	*/
+		private Long wbsRootId;
+	/**
+	* 规则类型 1最高 2分类并卷 3单独组卷
+	*/
+		private Integer archiveAutoType;
+	/**
+	* 分类并卷规则的分组ID
+	*/
+		private Long archiveAutoGroupId;
+	/**
+	* 项目id 系统级的为0
+	*/
+		private Long projectId;
+	/**
+	* 1删除  0正常
+	*/
+		private Integer delete;
+
+
+}

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ArchiveTree.java

@@ -141,7 +141,7 @@ public class ArchiveTree extends BaseEntity {
     @ApiModelProperty(value = "扩展关联Id")
     private Long extId;
 	/**
-	* 自动立卷类型
+	* 自动立卷类型 1最高 2分类并卷 3单独并卷
 	*/
     @ApiModelProperty(value = "自动立卷类型")
     private Integer archiveAutoType;

+ 3 - 3
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/ExcelTabClient.java

@@ -1,6 +1,6 @@
 package org.springblade.manager.feign;
 
-import com.alibaba.fastjson.JSONObject;
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.manager.entity.ExcelTab;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -21,8 +21,8 @@ public interface ExcelTabClient {
     ExcelTab getById(@RequestParam String id);
 
     @PostMapping(API_PREFIX + "/saveTabData")
-    String saveTabData(@RequestParam Integer isBatchSave,
-                       @RequestBody JSONObject dataInfo,
+    String saveTabData(@RequestBody TrialSelfInspectionRecordDTO dto,
+                       @RequestParam Integer isBatchSave,
                        @RequestParam Integer type,
                        @RequestParam String tableType,
                        @RequestParam Long id,

+ 3 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/TableFileClient.java

@@ -25,4 +25,7 @@ public interface TableFileClient {
     @PostMapping(API_PREFIX + "/saveBatchFile")
     void saveBatchFile(@RequestBody List<TableFile> query,@RequestParam Long addTablePkeyId);
 
+    @PostMapping(API_PREFIX + "/saveBatch")
+    boolean saveBatch(@RequestBody List<TableFile> newFiles);
+
 }

+ 5 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/WbsTreePrivateClient.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
+import java.util.Map;
 
 import static org.springblade.core.launch.constant.AppConstant.APPLICATION_NAME_PREFIX;
 
@@ -39,7 +40,7 @@ public interface WbsTreePrivateClient {
     List<WbsTreeContractTreeVOS> queryWbsTreePrivateByProjectIdAndId(@RequestParam String projectId, @RequestParam Long id);
 
     @PostMapping(API_PREFIX + "/copyBussTab")
-    boolean copyBussTab(@RequestParam Long pKeyId);
+    boolean copyBussTab(@RequestParam Long pKeyId, @RequestParam Long id);
 
     @PostMapping(API_PREFIX + "/removeBussTabInfoById")
     boolean removeBussTabInfoById(@RequestParam Long pKeyId);
@@ -56,4 +57,7 @@ public interface WbsTreePrivateClient {
     @PostMapping(API_PREFIX + "/updateInfo")
     void updateInfo(@RequestParam Long pkeyId);
 
+    @PostMapping(API_PREFIX + "/getTrialDataInfo")
+    List<Map<String, Object>> getTrialDataInfo(@RequestParam String pKeyId, @RequestParam Long id);
+
 }

+ 34 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ArchiveAutoRuleWbsVO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.vo;
+
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 视图实体类
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ArchiveAutoRuleWbsVO extends ArchiveAutoRuleWbs {
+	private static final long serialVersionUID = 1L;
+
+}

+ 35 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/TrialRecordZJTreeVO.java

@@ -0,0 +1,35 @@
+package org.springblade.manager.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import org.springblade.core.tool.node.INode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+public class TrialRecordZJTreeVO implements INode<TrialRecordZJTreeVO> {
+
+    private Long id;
+
+    private String primaryKeyId;
+
+    private String fullName;
+
+    private Long parentId;
+
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    private Boolean hasChildren;
+
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    private List<TrialRecordZJTreeVO> children;
+
+    @Override
+    public List<TrialRecordZJTreeVO> getChildren() {
+        if (this.children == null) {
+            this.children = new ArrayList<>();
+        }
+        return this.children;
+    }
+
+}

+ 13 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/NeiYeController.java

@@ -24,6 +24,7 @@ import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.feign.ContractClient;
 import org.springblade.manager.feign.WbsTreeContractClient;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springblade.core.mp.support.Query;
 
@@ -46,6 +47,8 @@ public class NeiYeController {
 
     private final TaskClient taskClient;
 
+    private final JdbcTemplate jdbcTemplate;
+
     /**
      * 获取内业台账列表
      * @return 内业台账列表
@@ -98,6 +101,16 @@ public class NeiYeController {
             if (queryDataResult != null && queryDataResult.size() > 0) {
                 //删除掉首件
                 queryDataResult.removeIf(query -> StringUtils.isNotEmpty(query.getQueryType()) && "3".equals(query.getQueryType()));
+                //判断是否关联工程部位
+                String sql = "select quality_node_id from u_trial_self_quality_project";
+                List<String> stringList = jdbcTemplate.queryForList(sql, String.class);
+                if (stringList != null && stringList.size() > 0){
+                    queryDataResult.stream().forEach(qdr->{
+                        if (stringList.contains(qdr.getPrimaryKeyId())){
+                            qdr.setIsExperiment("true");
+                        }
+                    });
+                }
                 //过滤试验
                 String isExperiment = queryVO.getIsExperiment()+"";
                 if (!"".equals(isExperiment) && !"null".equals(isExperiment) && isExperiment != null) {

+ 2 - 1
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -165,7 +165,8 @@ public class TaskController extends BladeController {
     @ApiOperationSupport(order = 10)
     @ApiOperation(value = "短信验证")
     public R<Boolean> sendNotice(@RequestParam String phone) {
-        String code = CommonUtil.getCharAndNumber(4);
+//        String code = CommonUtil.getCharAndNumber(4);
+        String code = String.valueOf((int)(Math.random()*9000 + 1000));
         Map<String, String> params = new HashMap<>(3);
         params.put("code", code);
         R<SmsResponse> result = this.newSmsClient.sendMessage("test_code", JsonUtil.toJson(params), phone);

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

@@ -203,9 +203,9 @@ public class TrialDetectionController extends BladeController {
 
     @GetMapping("/self/copy-buss-tab")
     @ApiOperationSupport(order = 15)
-    @ApiOperation(value = "自检表单复制", notes = "传入节点pKeyId")
-    public R<Object> copyBussTab(@RequestParam Long pKeyId) {
-        return R.status(wbsTreePrivateClient.copyBussTab(pKeyId));
+    @ApiOperation(value = "自检表单复制", notes = "传入节点pKeyId,当前记录id")
+    public R<Object> copyBussTab(@RequestParam Long pKeyId, @RequestParam Long id) {
+        return R.status(wbsTreePrivateClient.copyBussTab(pKeyId, id));
     }
 
     @PostMapping("/self/remove-buss-tabInfo")

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

@@ -32,7 +32,10 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
     String selfPrintNullPdf(String ids) throws Exception;
 
     @Async
-    void updateTrialSelfInspectionRecordStatus(String pdfUrlEVisa, List<TaskApprovalVO> obj) throws FileNotFoundException;
+    void updateTrialSelfInspectionRecordStatus(String pdfUrlEVisa, TaskApprovalVO obj) throws FileNotFoundException;
+
+    @Async
+    void updateTrialSelfInspectionRecordStatusFC(TaskApprovalVO obj);
 
     String addBussFile(MultipartFile file, Long pkeyId, String nodeId, String contractId, String projectId, String classify, String id, String tableType) throws Exception;
 
@@ -40,4 +43,5 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     boolean fileSubmit(TrialFileSubmitDTO dto) throws FileNotFoundException;
 
+
 }

+ 7 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -451,8 +451,13 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                 String pdfUrlEVisa = this.completeApprovalTask(taskApprovalVO);
 
                 //TODO ============== 电签成功,修改试验状态,关联工程部位信息pdf(只有电签成功,才修改) liuYc 2023-03-16 ==============
-                if (StringUtils.isNotEmpty(pdfUrlEVisa)){
-                    this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatus(pdfUrlEVisa, taskApprovalVOS);
+                if ("OK".equals(taskApprovalVO.getFlag()) && StringUtils.isNotEmpty(pdfUrlEVisa)) {
+                    //已审批
+                    this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatus(pdfUrlEVisa, taskApprovalVO);
+                }
+                if (!"OK".equals(taskApprovalVO.getFlag())) {
+                    //已废除
+                    this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatusFC(taskApprovalVO);
                 }
 
             }

+ 316 - 157
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.spire.xls.*;
 import io.swagger.models.auth.In;
+import jdk.nashorn.internal.scripts.JD;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.time.DateUtils;
 import org.springblade.business.dto.*;
@@ -59,9 +60,7 @@ import java.util.stream.Collectors;
 
 @Service
 @AllArgsConstructor
-public class TrialSelfInspectionRecordServiceImpl
-        extends BaseServiceImpl<TrialSelfInspectionRecordMapper, TrialSelfInspectionRecord>
-        implements ITrialSelfInspectionRecordService {
+public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialSelfInspectionRecordMapper, TrialSelfInspectionRecord> implements ITrialSelfInspectionRecordService {
 
     private final TrialSampleInfoMapper trialSampleInfoMapper;
     private final TrialMaterialMobilizationMapper trialMaterialMobilizationMapper;
@@ -81,70 +80,109 @@ public class TrialSelfInspectionRecordServiceImpl
 
     @Override
     public IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) throws FileNotFoundException {
-        QueryWrapper<TrialSelfInspectionRecord> queryWrapper = Condition.getQueryWrapper(dto);
-        if (StringUtils.isNotEmpty(dto.getQueryValue())) {
-            queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialProjectName, dto.getQueryValue());
-        }
-        if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getStartTime()) && org.apache.commons.lang.StringUtils.isNotEmpty(dto.getEndTime())) {
-            String endTime = dto.getEndTime();
-            endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
-            queryWrapper.lambda().between(TrialSelfInspectionRecord::getReportDate, dto.getStartTime(), endTime);
-        }
-        if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryName())) {
-            queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialUserName, dto.getQueryName());
-        }
-        if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryStatus())) {
-            queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionResult, dto.getQueryStatus());
-        }
-        IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderByDesc(true, TrialSelfInspectionRecord::getCreateTime));
-        IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
-        List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
-        Map<String, Dict> map = iDictClient.getList("trial_detection_category").getData().stream().collect(Collectors.toMap(Dict::getDictKey, Function.identity()));
+        //获取当前选择节点所有的子级节点pKeyIds
+        WbsTreePrivate selectedNode = jdbcTemplate.query("select id,project_id from m_wbs_tree_private where p_key_id = " + dto.getNodeId(), new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
+        if (selectedNode != null) {
+            List<WbsTreePrivate> ziNodePKeyIds = jdbcTemplate.query("select p_key_id from m_wbs_tree_private where type = 1 and is_deleted = 0 and project_id = " + selectedNode.getProjectId() + " and find_in_set('" + selectedNode.getId() + "',ancestors)", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+            QueryWrapper<TrialSelfInspectionRecord> queryWrapper = Condition.getQueryWrapper(dto);
+            if (ziNodePKeyIds.size() > 0) {
+                dto.setNodeId(null);
+                List<Long> pIds = ziNodePKeyIds.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+                queryWrapper.lambda().in(TrialSelfInspectionRecord::getNodeId, pIds);
+            }
+            if (StringUtils.isNotEmpty(dto.getQueryValue())) {
+                queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialProjectName, dto.getQueryValue());
+            }
+            if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getStartTime()) && org.apache.commons.lang.StringUtils.isNotEmpty(dto.getEndTime())) {
+                String endTime = dto.getEndTime();
+                endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
+                queryWrapper.lambda().between(TrialSelfInspectionRecord::getReportDate, dto.getStartTime(), endTime);
+            }
+            if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryName())) {
+                queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialUserName, dto.getQueryName());
+            }
+            if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryStatus())) {
+                queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionResult, dto.getQueryStatus());
+            }
 
-        for (TrialSelfInspectionRecordVO record : records) {
-            record.setIsUploadCertificateName((new Integer(1)).equals(record.getIsUploadCertificate()) ? "是" : "否");
-            record.setDetectionResultName((new Integer(1)).equals(record.getDetectionResult()) ? "合格" : "不合格");
+            IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderByDesc(true, TrialSelfInspectionRecord::getCreateTime));
+            IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
+            List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
+            Map<String, Dict> map = iDictClient.getList("trial_detection_category").getData().stream().collect(Collectors.toMap(Dict::getDictKey, Function.identity()));
 
-            if (ObjectUtils.isNotEmpty(record.getDetectionCategory())) {
-                Dict dict = map.get(String.valueOf(record.getDetectionCategory()));
-                if (dict != null) {
-                    record.setDetectionCategoryName(dict.getDictValue());
+            for (TrialSelfInspectionRecordVO record : records) {
+                record.setDetectionResultName((new Integer(1)).equals(record.getDetectionResult()) ? "合格" : "");
+                if (StringUtils.isNotEmpty(record.getDetectionResultName())) {
+                    record.setDetectionResult(1);
+                } else {
+                    record.setDetectionResult(0);
                 }
-            }
 
-            //工程部位及用途名称
-            if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
-                List<String> ids = Func.toStrList(record.getProjectPosition()); //关联的工程部位ids
-                List<WbsTreeContract> result = baseMapper.selectWbsTreeContractListByPKeyIds(ids); //查询工程部位节点名称信息
-                List<String> projectPositionNames = result.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
-                String name = projectPositionNames.stream().findAny().orElse(null);
-                if (projectPositionNames.size() > 1) {
-                    record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
+                if (ObjectUtils.isNotEmpty(record.getDetectionCategory())) {
+                    Dict dict = map.get(String.valueOf(record.getDetectionCategory()));
+                    if (dict != null) {
+                        record.setDetectionCategoryName(dict.getDictValue());
+                    }
+                }
+
+                //工程部位及用途名称
+                if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
+                    List<String> ids = Func.toStrList(record.getProjectPosition()); //关联的工程部位ids
+                    List<WbsTreeContract> result = baseMapper.selectWbsTreeContractListByPKeyIds(ids); //查询工程部位节点名称信息
+                    List<String> projectPositionNames = result.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
+                    String name = projectPositionNames.stream().findAny().orElse(null);
+                    if (projectPositionNames.size() > 1) {
+                        record.setProjectPositionName(name + "等" + projectPositionNames.size() + "个工程部位信息");
+                    } else {
+                        record.setProjectPositionName(name);
+                    }
+                }
+
+                //关联取样ids
+                String sql = "select sampling_id from u_trial_self_sample where self_id = " + record.getId();
+                List<Long> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfSample.class)).stream().map(TrialSelfSample::getSamplingId).collect(Collectors.toList());
+                if (query.size() > 0) {
+                    record.setSampleIds(org.apache.commons.lang.StringUtils.join(query, ","));
+                    this.getIsUploadCertificateStatus(record.getSampleIds(), record);
                 } else {
-                    record.setProjectPositionName(name);
+                    record.setIsUploadCertificate(-1);
+                    record.setIsUploadCertificateName(""); //没关联材料显示null
                 }
-            }
 
-            //关联取样ids
-            String sql = "select sampling_id from u_trial_self_sample where self_id = " + record.getId();
-            List<Long> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfSample.class)).stream().map(TrialSelfSample::getSamplingId).collect(Collectors.toList());
-            if (query.size() > 0) {
-                record.setSampleIds(org.apache.commons.lang.StringUtils.join(query, ","));
-            }
+                //原材料检测报告ids
+                String sql1 = "select raw_material_record_id,old_pdf_url from u_trial_raw_material_self_record where self_record_id = " + record.getId();
+                List<TrialRawMaterialSelfRecord> query1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
+                if (query1.size() > 0) {
+                    List<Long> ids = query1.stream().map(TrialRawMaterialSelfRecord::getRawMaterialRecordId).collect(Collectors.toList());
+                    record.setRawMaterialIds(org.apache.commons.lang.StringUtils.join(ids, ","));
+                }
 
-            //原材料检测报告ids
-            String sql1 = "select raw_material_record_id,old_pdf_url from u_trial_raw_material_self_record where self_record_id = " + record.getId();
-            List<TrialRawMaterialSelfRecord> query1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
-            if (query1.size() > 0) {
-                List<Long> ids = query1.stream().map(TrialRawMaterialSelfRecord::getRawMaterialRecordId).collect(Collectors.toList());
-                record.setRawMaterialIds(org.apache.commons.lang.StringUtils.join(ids, ","));
+                //合并的pdfUrl
+                String pdf = this.getMergePdfToTrial(record.getContractId(), record.getId());
+                record.setPdfUrl(pdf);
             }
 
-            //合并的pdfUrl
-            String pdf = this.getMergePdfToTrial(record.getContractId(), record.getId());
-            record.setPdfUrl(pdf);
+            return trialSelfInspectionRecordVOIPage.setRecords(records);
         }
-        return trialSelfInspectionRecordVOIPage.setRecords(records);
+        return null;
+    }
+
+    private void getIsUploadCertificateStatus(String sampleIds, TrialSelfInspectionRecordVO record) {
+        List<TrialSamplingRecord> mobilizationIds = jdbcTemplate.query("select mobilization_id from u_trial_sampling_record where sample_info_id in(" + sampleIds + ")", new BeanPropertyRowMapper<>(TrialSamplingRecord.class));
+        if (mobilizationIds.size() > 0) {
+            List<Long> collect = mobilizationIds.stream().map(TrialSamplingRecord::getMobilizationId).collect(Collectors.toList());
+            String join = org.apache.commons.lang.StringUtils.join(collect, ",");
+            List<TrialMaterialMobilization> mobilizations = jdbcTemplate.query("select production_certificate from u_trial_material_mobilization where id in(" + join + ")", new BeanPropertyRowMapper<>(TrialMaterialMobilization.class));
+            List<TrialMaterialMobilization> notUpdate = mobilizations.stream().filter(f -> ObjectUtils.isEmpty(f.getProductionCertificate())).collect(Collectors.toList());
+            if (notUpdate.size() != 0) {
+                record.setIsUploadCertificate(1);
+                record.setIsUploadCertificateName("是");
+            } else {
+                record.setIsUploadCertificate(0);
+                record.setIsUploadCertificateName("否");
+            }
+        }
+
     }
 
     private String getMergePdfToTrial(Long contractId, Long nodeId) throws FileNotFoundException {
@@ -224,12 +262,20 @@ public class TrialSelfInspectionRecordServiceImpl
             for (Attach attach : query) {
                 if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getOtherAccessories()) && sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
                     sampleAncillaryDocumentsVO.setOtherAccessoriesName(attach.getOriginalName());
+                } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getOtherAccessories()) && !sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
+                    sampleAncillaryDocumentsVO.setOtherAccessoriesName(sampleAncillaryDocumentsVO.getOtherAccessories());
                 }
+
                 if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getProductionCertificate()) && sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
                     sampleAncillaryDocumentsVO.setProductionCertificateName(attach.getOriginalName());
+                } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getProductionCertificate()) && !sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
+                    sampleAncillaryDocumentsVO.setProductionCertificateName(sampleAncillaryDocumentsVO.getProductionCertificate());
                 }
+
                 if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getQualityInspectionReport()) && sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
                     sampleAncillaryDocumentsVO.setQualityInspectionReportName(attach.getOriginalName());
+                } else if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getQualityInspectionReport()) && !sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
+                    sampleAncillaryDocumentsVO.setQualityInspectionReportName(sampleAncillaryDocumentsVO.getQualityInspectionReport());
                 }
             }
         }
@@ -272,14 +318,146 @@ public class TrialSelfInspectionRecordServiceImpl
                 } else 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.save(dto);
+
+                //复制表数据、表附件文件
+                String tableIds = trialSelfInspectionRecord.getTableIds();
+                if (StringUtils.isNotEmpty(tableIds)) {
+                    //获取表的数据源
+                    List<String> pKeyIds = Func.toStrList(tableIds);
+                    for (String pKeyId : pKeyIds) {
+                        WbsTreePrivate tab = wbsTreePrivateClient.getNodeByPrimaryKeyId(pKeyId);
+                        //复制数据
+                        List<Map<String, Object>> oneTabData = wbsTreePrivateClient.getTrialDataInfo(pKeyId, trialSelfInspectionRecord.getId());
+                        if (oneTabData.size() >= 1) {
+                            Map<String, Object> dataMap2 = oneTabData.get(0);
+
+                            dataMap2.remove("id");
+                            dataMap2.remove("p_key_id");
+                            dataMap2.remove("group_id");
+
+                            //sql组装
+                            String sqlInfo = "";
+                            sqlInfo = "INSERT INTO " + tab.getInitTableName() + " (";
+                            StringBuilder keyStr = new StringBuilder("id,p_key_id,group_id,");
+                            StringBuilder valStr = new StringBuilder(SnowFlakeUtil.getId() + "," + pKeyId + "," + dto.getId() + ",");
+                            for (String keys : dataMap2.keySet()) {
+                                if (!(dataMap2.get(keys) + "").equals("null")) {
+                                    String keysResult = keys.split("__")[0];
+                                    String keysResult2 = keys.split("__")[1];
+                                    keyStr.append(keysResult).append(",");
+                                    Object value = dataMap2.get(keys);
+
+                                    //替换报告单号、记录编号
+                                    if (String.valueOf(value).contains("JL-")) {
+                                        value = StringUtils.isNotEmpty(dto.getRecordNo()) ? dto.getRecordNo() : null;
+                                    }
+                                    if (String.valueOf(value).contains("BG-")) {
+                                        value = StringUtils.isNotEmpty(dto.getReportNo()) ? dto.getReportNo() : null;
+                                    }
+
+                                    String values = value + "_^_" + keysResult2;
+                                    valStr.append("'").append(values).append("',");
+                                }
+                            }
+                            keyStr = new StringBuilder(keyStr.substring(0, keyStr.lastIndexOf(",")));
+                            valStr = new StringBuilder(valStr.substring(0, valStr.lastIndexOf(",")));
+                            sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
+                            //新增
+                            jdbcTemplate.execute(sqlInfo);
+                        }
+
+                        //复制附件文件
+                        List<TableFile> oldFiles = jdbcTemplate.query("select domain_url,name,extension,type,is_deleted,domain_pdf_url,status from m_table_file where is_deleted = 0 and tab_id = '" + pKeyId + "' and trial_record_id = " + trialSelfInspectionRecord.getId(), new BeanPropertyRowMapper<>(TableFile.class));
+                        List<TableFile> newFiles = new ArrayList<>();
+                        for (TableFile oldFile : oldFiles) {
+                            TableFile obj = BeanUtil.copyProperties(oldFile, TableFile.class);
+                            if (obj != null) {
+                                obj.setId(SnowFlakeUtil.getId());
+                                obj.setTabId(pKeyId + ""); //表pKeyId
+                                obj.setTrialRecordId(dto.getId()); //当前记录id
+                                newFiles.add(obj);
+                            }
+                        }
+                        tableFileClient.saveBatch(newFiles);
+                    }
+                }
+
+                //复制试验记录关联相关信息:工程部位、原材料检测报告、取样信息
+                //1、工程部位与projectPosition字段绑定,在审批时建立关联关系
+
+                //2、原材料检测报告
+                List<TrialRawMaterialSelfRecord> query = jdbcTemplate.query("select self_record_id,raw_material_record_id,old_pdf_url from u_trial_raw_material_self_record where self_record_id = " + trialSelfInspectionRecord.getId(), new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
+                for (TrialRawMaterialSelfRecord record : query) {
+                    //新增关系
+                    jdbcTemplate.execute("insert into u_trial_raw_material_self_record(id,self_record_id,raw_material_record_id,old_pdf_url) values (" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + record.getRawMaterialRecordId() + "," + (StringUtils.isNotEmpty(record.getOldPdfUrl()) ? record.getOldPdfUrl() : null) + ")");
+                }
+
+                //3、取样信息
+                List<TrialSelfSample> qyInfo = jdbcTemplate.query("select sampling_id from u_trial_self_sample where self_id = " + trialSelfInspectionRecord.getId(), new BeanPropertyRowMapper<>(TrialSelfSample.class));
+                for (TrialSelfSample trialSelfSample : qyInfo) {
+                    //新增关系
+                    jdbcTemplate.execute("insert into u_trial_self_sample(id,self_id,sampling_id) values (" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + trialSelfSample.getSamplingId() + ")");
+                }
             }
         }
         return true;
     }
 
+    private void reNumberNo(TrialSelfInspectionRecord trialSelfInspectionRecord, TrialSelfInspectionRecordDTO dto) {
+        StringSPUtils spUtils = new StringSPUtils();
+        List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
+                .select(TrialSelfInspectionRecord::getReportNo, TrialSelfInspectionRecord::getRecordNo)
+                .and(obj -> obj.like(TrialSelfInspectionRecord::getReportNo, "BG-").or().like(TrialSelfInspectionRecord::getRecordNo, "JL-"))
+                .eq(TrialSelfInspectionRecord::getContractId, trialSelfInspectionRecord.getContractId()).eq(TrialSelfInspectionRecord::getNodeId, trialSelfInspectionRecord.getNodeId()));
+
+        List<TrialSelfInspectionRecord> bg = recordList.stream().filter(f -> f.getReportNo().contains("BG-")).collect(Collectors.toList());
+        List<TrialSelfInspectionRecord> jl = recordList.stream().filter(f -> f.getRecordNo().contains("JL-")).collect(Collectors.toList());
+
+        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) {
+                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,操作失败");
+            }
+        }
+        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) {
+                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 {
+                throw new ServiceException("当前编号已达到最大值9999,操作失败");
+            }
+        }
+    }
+
     @Override
     public List<TrialSelfInspectionRecordVO2> getRawMaterialInfo(String nodeId, String contractId, String id) {
         List<TrialSelfInspectionRecordVO2> recordVO2s;
@@ -407,64 +585,62 @@ public class TrialSelfInspectionRecordServiceImpl
 
     @Override
     @Async
-    public void updateTrialSelfInspectionRecordStatus(String pdfUrlEVisa, List<TaskApprovalVO> obj) throws FileNotFoundException {
-        for (TaskApprovalVO taskApprovalVO : obj) {
-            if (ObjectUtil.isNotEmpty(taskApprovalVO.getParallelProcessInstanceId())) {
-                String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + taskApprovalVO.getParallelProcessInstanceId() + "'";
-                TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
-                if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
-                    String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
-                    if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
-                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
-                                .set(TrialSelfInspectionRecord::getTaskStatus, "OK".equals(taskApprovalVO.getFlag()) ? "已审批" : "已废除")
-                                .set(TrialSelfInspectionRecord::getPdfUrl, pdfUrlEVisa) //pdfUrlEVisa=电签后的pdf
-                                .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
-                        );
-
-                        TrialSelfInspectionRecord record = baseMapper.selectById(trialSelfInspectionRecordId);
-                        //此时的record.getPdfUrl()为电签后的pdf信息
-                        if (("已审批").equals(record.getTaskStatus()) && (new Integer(1)).equals(record.getDetectionResult()) && (new Integer(1)).equals(record.getDetectionCategory())) {
-                            /**
-                             * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存(如果当前资料填报工序节点有其他多个试验记录pdf关联信息,那么合并存储,否则直接存储)
-                             */
-                            if (StringUtils.isNotEmpty(record.getProjectPosition())) {
-                                //有pdf的节点
-                                String sqlNodeAll = "select wbs_id from u_information_query where wbs_id in(" + record.getProjectPosition() + ") and contract_id = " + record.getContractId();
-                                List<Long> collect = jdbcTemplate.query(sqlNodeAll, new BeanPropertyRowMapper<>(InformationQuery.class)).stream().map(InformationQuery::getWbsId).collect(Collectors.toList());
-                                if (collect.size() > 0) {
-                                    //删除当前记录关联记录
-                                    baseMapper.delSelfQuality(record.getId());
-                                    for (Long pKeyId : collect) {
-                                        //新增当前记录关联信息
-                                        baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), record.getId(), pKeyId);
-
-                                        //获取当前工程部位节点最新的关联试验记录ids
-                                        List<String> trialRecordIds = baseMapper.selectTrialIdByNodeId(pKeyId);
-
-                                        //如果当前工程部位节点的关联试验记录id只有一条,且等于当前关联试验记录id,那么不合并,直接存储该条试验记录的pdf
-                                        if (trialRecordIds.size() == 1 && trialRecordIds.get(0).equals(record.getId().toString())) {
-                                            //修改当前试验pdf到质检树节点的pdf_trial_url_position上存储
-                                            baseMapper.updateInformationQuery(pKeyId, record.getContractId(), record.getPdfUrl());
-                                            continue;
-                                        }
-
-                                        //如果当前工程部位节点的关联试验记录id有多条,那么合并
-                                        List<TrialSelfInspectionRecord> pdfUrlList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getPdfUrl).in(TrialSelfInspectionRecord::getId, trialRecordIds));
-                                        List<String> pdfS = pdfUrlList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
-
-                                        String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                                        String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
-                                        File tabPDF = ResourceUtil.getFile(listPdf);
-                                        if (tabPDF.exists()) {
-                                            tabPDF.delete();
-                                        }
-
-                                        FileUtils.mergePdfPublicMethods(pdfS, listPdf);
-                                        BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
-                                        if (bladeFile != null) {
-                                            //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
-                                            baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
-                                        }
+    public void updateTrialSelfInspectionRecordStatus(String pdfUrlEVisa, TaskApprovalVO obj) throws FileNotFoundException {
+        if (ObjectUtil.isNotEmpty(obj.getParallelProcessInstanceId())) {
+            String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + obj.getParallelProcessInstanceId() + "'";
+            TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
+            if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
+                String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
+                if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
+                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                            .set(TrialSelfInspectionRecord::getTaskStatus, "已审批")
+                            .set(TrialSelfInspectionRecord::getPdfUrl, pdfUrlEVisa) //pdfUrlEVisa=电签后的pdf
+                            .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
+                    );
+
+                    TrialSelfInspectionRecord record = baseMapper.selectById(trialSelfInspectionRecordId);
+                    //此时的record.getPdfUrl()为电签后的pdf信息
+                    if (("已审批").equals(record.getTaskStatus()) && (new Integer(1)).equals(record.getDetectionResult()) && (new Integer(1)).equals(record.getDetectionCategory())) {
+                        /**
+                         * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存(如果当前资料填报工序节点有其他多个试验记录pdf关联信息,那么合并存储,否则直接存储)
+                         */
+                        if (StringUtils.isNotEmpty(record.getProjectPosition())) {
+                            //有pdf的节点
+                            String sqlNodeAll = "select wbs_id from u_information_query where wbs_id in(" + record.getProjectPosition() + ") and contract_id = " + record.getContractId();
+                            List<Long> collect = jdbcTemplate.query(sqlNodeAll, new BeanPropertyRowMapper<>(InformationQuery.class)).stream().map(InformationQuery::getWbsId).collect(Collectors.toList());
+                            if (collect.size() > 0) {
+                                //删除当前记录关联记录
+                                baseMapper.delSelfQuality(record.getId());
+                                for (Long pKeyId : collect) {
+                                    //新增当前记录关联信息
+                                    baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), record.getId(), pKeyId);
+
+                                    //获取当前工程部位节点最新的关联试验记录ids
+                                    List<String> trialRecordIds = baseMapper.selectTrialIdByNodeId(pKeyId);
+
+                                    //如果当前工程部位节点的关联试验记录id只有一条,且等于当前关联试验记录id,那么不合并,直接存储该条试验记录的pdf
+                                    if (trialRecordIds.size() == 1 && trialRecordIds.get(0).equals(record.getId().toString())) {
+                                        //修改当前试验pdf到质检树节点的pdf_trial_url_position上存储
+                                        baseMapper.updateInformationQuery(pKeyId, record.getContractId(), record.getPdfUrl());
+                                        continue;
+                                    }
+
+                                    //如果当前工程部位节点的关联试验记录id有多条,那么合并
+                                    List<TrialSelfInspectionRecord> pdfUrlList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getPdfUrl).in(TrialSelfInspectionRecord::getId, trialRecordIds));
+                                    List<String> pdfS = pdfUrlList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+
+                                    String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                                    String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
+                                    File tabPDF = ResourceUtil.getFile(listPdf);
+                                    if (tabPDF.exists()) {
+                                        tabPDF.delete();
+                                    }
+
+                                    FileUtils.mergePdfPublicMethods(pdfS, listPdf);
+                                    BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
+                                    if (bladeFile != null) {
+                                        //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
+                                        baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
                                     }
                                 }
                             }
@@ -476,8 +652,26 @@ public class TrialSelfInspectionRecordServiceImpl
     }
 
     @Override
-    public String addBussFile(MultipartFile file, Long pkeyId, String nodeId, String contractId, String
-            projectId, String classify, String id, String tableType) throws Exception {
+    public void updateTrialSelfInspectionRecordStatusFC(TaskApprovalVO obj) {
+        if (ObjectUtil.isNotEmpty(obj.getParallelProcessInstanceId())) {
+            String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + obj.getParallelProcessInstanceId() + "'";
+            TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
+            if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
+                String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
+                if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
+                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                            .set(TrialSelfInspectionRecord::getTaskStatus, "已废除")
+                            .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
+                    );
+                    //废除后修改电签为null
+                    jdbcTemplate.execute("update u_information_query set e_visa_pdf_url = null where wbs_id = " + trialSelfInspectionRecordId);
+                }
+            }
+        }
+    }
+
+    @Override
+    public String addBussFile(MultipartFile file, Long pkeyId, String nodeId, String contractId, String projectId, String classify, String id, String tableType) throws Exception {
         R<BladeFile> bladeFile = iossClient.addFileInfo(file);
         BladeFile bladeFile1 = bladeFile.getData();
         TableFile tableFile = new TableFile();
@@ -610,12 +804,12 @@ public class TrialSelfInspectionRecordServiceImpl
 
     @Override
     public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
+        //------初始当前填报的表pKeyIds------
+        this.initTrialTabIds(dto);
+
         //------初始编号信息------
         this.initBuildNumber(dto);
 
-        //------初始当前填报的表------
-        this.initTrialTabIds(dto);
-
         //------新增或编辑------
         this.saveOrUpdate(dto);
 
@@ -623,7 +817,7 @@ public class TrialSelfInspectionRecordServiceImpl
             //------获取最新试验记录------
             TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
 
-            //------编辑时生成为Null的记录表编号或报告单编号------
+            //------编辑时记录表编号或报告单编号为Null的重新生成------
             this.reBuildNumber(obj, dto);
 
             //------保存实体表数据、试验记录信息、生成PDF------
@@ -635,7 +829,7 @@ public class TrialSelfInspectionRecordServiceImpl
             //------关联取样信息------
             this.recordSampleSubmit(dto, obj);
 
-            //------新增设备使用记录信息------
+            //------关联新增设备使用记录信息------
             this.trialDeviceUseService.addDeviceUseInfo(dto);
         }
         return dto.getId().toString();
@@ -659,41 +853,6 @@ public class TrialSelfInspectionRecordServiceImpl
         List<String> ids = tableIds.stream().distinct().collect(Collectors.toList());
         String join = org.apache.commons.lang.StringUtils.join(ids, ",");
         dto.setTableIds(join);
-
-        // TODO 如果前端处理了隐藏表入参的情况(即:隐藏表单pKeyId不传),那么接口就不处理
-        /*//获取按钮状态,是否为隐藏表单,移除隐藏表单(编辑时)
-        if (ObjectUtils.isNotEmpty(dto.getId())) {
-            List<TrialSelfDataRecord> tabStatus = jdbcTemplate.query("select is_buss_show,tab_id from u_trial_self_data_record where record_id = " + dto.getId(), new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
-            if (tabStatus.size() > 0) {
-                Map<Long, TrialSelfDataRecord> collect = tabStatus.stream().collect(Collectors.toMap(TrialSelfDataRecord::getTabId, Function.identity()));
-                List<Long> pKeyIds = Func.toLongList(dto.getTableIds());
-                List<Long> addPkeyIds = new ArrayList<>();
-                for (Long pId : pKeyIds) {
-                    TrialSelfDataRecord record = collect.get(pId);
-                    if (record != null) {
-                        //隐藏的不添加
-                        if (!new Integer(2).equals(record.getIsBussShow())) {
-                            addPkeyIds.add(pId);
-                        }
-                    } else {
-                        //未生成记录的添加进去
-                        addPkeyIds.add(pId);
-                    }
-                }
-                //重新赋值
-                String joinNew = org.apache.commons.lang.StringUtils.join(addPkeyIds, ",");
-                dto.setTableIds(joinNew);
-            }
-        } else {
-            //获取按钮状态,是否为隐藏表单,移除隐藏表单(新增时)
-            String tablePkeyIds = dto.getTableIds();
-            List<WbsTreePrivate> tableList = jdbcTemplate.query("select is_buss_show,p_key_id from m_wbs_tree_private where status = 1 and p_key_id in(" + tablePkeyIds + ")", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
-            List<Long> addPkeyIds = tableList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getIsBussShow()) && !(new Integer(2).equals(f.getIsBussShow()))).map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
-
-            //重新赋值
-            String joinNew = org.apache.commons.lang.StringUtils.join(addPkeyIds, ",");
-            dto.setTableIds(joinNew);
-        }*/
     }
 
     private void reBuildNumber(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
@@ -709,7 +868,7 @@ public class TrialSelfInspectionRecordServiceImpl
     @Async
     public void submitTrialData(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
         try {
-            String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
+            String pdfURL = excelTabClient.saveTabData(dto, dto.getIsBatchSave(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
             if (StringUtils.isNotEmpty(pdfURL)) {
                 this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
             }

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

@@ -2796,8 +2796,10 @@ public class CustomFunction {
 		return "";
 	}
 
-
-
+	public static void main(String[] args) {
+		String s="边坡或仰坡坡度_不大于设计_尺量:每洞口检查10处_实测";
+		System.out.println(s.split("[((].+[))]|_")[0]);
+	}
 
 
 }

+ 21 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ArchiveTreeController.java

@@ -209,28 +209,36 @@ public class ArchiveTreeController extends BladeController {
     @ApiOperationSupport(order = 8)
     @ApiOperation(value = "保存立卷规则设置", notes = "传入archiveAutoType规则类型,nodeIds逗号拼接选择节点id")
     public R saveArchiveAutoRule(@ApiParam(value = "立卷规则", required = true) @RequestParam Integer archiveAutoType,
-                                 @ApiParam(value = "主键集合", required = true) @RequestParam String nodeIds) {
-        return R.status(archiveTreeService.saveArchiveAutoRule(archiveAutoType,nodeIds));
+                                 @ApiParam(value = "主键集合", required = true) @RequestParam String nodeIds,
+                                 @ApiParam(value = "是否wbs节点", required = true) @RequestParam Boolean iswbsNode) {
+        return R.status(archiveTreeService.saveArchiveAutoRule(archiveAutoType,nodeIds,iswbsNode));
     }
 
 
     /**
-     * 查看立卷规则设置
+     * 修改立卷规则设置
      */
-    @PostMapping("/getArchiveAutoRule")
-    @ApiOperationSupport(order = 9)
-    @ApiOperation(value = "查看立卷规则设置", notes = "传入节点id")
-    public R getArchiveAutoRule(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
-        Map<String, Object> ruleMap=archiveTreeService.getArchiveAutoRule(id);
-        return R.data(ruleMap);
+    @PostMapping("/updateArchiveAutoRule")
+    public R updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto,boolean iswbsNode) {
+        return R.status(archiveTreeService.updateArchiveAutoRule(dto,iswbsNode));
     }
 
     /**
-     * 修改立卷规则设置
+     * 取消立卷规则设置
      */
-    @PostMapping("/updateArchiveAutoRule")
-    public R updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto) {
-        return R.status(archiveTreeService.updateArchiveAutoRule(dto));
+    @PostMapping("/removeArchiveAutoRule")
+    public R removeArchiveAutoRule(Long nodeId,boolean iswbsNode) {
+        Map<String, String> map = archiveTreeService.removeArchiveAutoRule(nodeId, iswbsNode);
+        return R.data(map);
+    }
+
+    /**
+     * 查看立卷规则设置
+     */
+    @PostMapping("/getArchiveAutoRule")
+    public R getArchiveAutoRule(Long id,boolean iswbsNode) {
+        Map<String, Object> ruleMap=archiveTreeService.getArchiveAutoRule(id,iswbsNode);
+        return R.data(ruleMap);
     }
 
 }

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

@@ -23,6 +23,8 @@ import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
+import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.feign.ContractLogClient;
 import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.business.vo.SaveContractLogVO;
@@ -55,6 +57,7 @@ import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.resource.vo.NewBladeFile;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -1413,7 +1416,7 @@ public class ExcelTabController extends BladeController {
         String tabName = wbsTreeContract.getInitTableName();
         // 字段查询 并去掉公式字段
 
-        String colkeys = "SELECT GROUP_CONCAT(COLUMN_NAME) as colkeys from information_schema.COLUMNS c where c.table_name='"+tabName+"' and COLUMN_NAME not in('id','p_key_id')";
+        String colkeys = "SELECT GROUP_CONCAT(COLUMN_NAME) as colkeys from information_schema.COLUMNS c where c.table_name='" + tabName + "' and COLUMN_NAME not in('id','p_key_id')";
         Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(colkeys);
         colkeys = stringObjectMap.get("colkeys") + "";
         // 复制表数据
@@ -1621,22 +1624,24 @@ public class ExcelTabController extends BladeController {
         //
         String pkeyIds = pkeyId;
         String groupIds = groupId;
-        for(int i=1;i<dataArray.size();i++){
+        for (int i = 1; i < dataArray.size(); i++) {
             JSONObject jsonObject = dataArray.getJSONObject(i);
-            pkeyIds +=","+ jsonObject.getString("pkeyId");;
-            groupIds +=","+ jsonObject.getString("tabGroupId");;
+            pkeyIds += "," + jsonObject.getString("pkeyId");
+            ;
+            groupIds += "," + jsonObject.getString("tabGroupId");
+            ;
         }
-        if(StringUtils.isNotEmpty(groupIds)){
+        if (StringUtils.isNotEmpty(groupIds)) {
             List<WbsTreeContract> wbsTreeContractList = this.wbsTreeContractService.getBaseMapper().selectList(
                     Wrappers.<WbsTreeContract>lambdaQuery()
                             .in(WbsTreeContract::getTabGroupId, groupIds)
-                            .notIn(WbsTreeContract::getPKeyId,pkeyIds)
-                            .eq(WbsTreeContract::getIsDeleted,BladeConstant.DB_NOT_DELETED)
+                            .notIn(WbsTreeContract::getPKeyId, pkeyIds)
+                            .eq(WbsTreeContract::getIsDeleted, BladeConstant.DB_NOT_DELETED)
             );
-            if(wbsTreeContractList!=null && wbsTreeContractList.size()>=1){
-                for(WbsTreeContract data: wbsTreeContractList){
-                     R bussDataInfo = this.getBussDataInfo(data.getPKeyId());
-                     Object data1 = bussDataInfo.getData();
+            if (wbsTreeContractList != null && wbsTreeContractList.size() >= 1) {
+                for (WbsTreeContract data : wbsTreeContractList) {
+                    R bussDataInfo = this.getBussDataInfo(data.getPKeyId());
+                    Object data1 = bussDataInfo.getData();
                     dataArray.add(data1);
                 }
             }
@@ -1650,10 +1655,10 @@ public class ExcelTabController extends BladeController {
             e.printStackTrace();
         }
 
-            R info = this.excelTabService.saveOrUpdateInfo(tableInfoList);
-            if (!info.isSuccess()) {
-                return info;
-            }
+        R info = this.excelTabService.saveOrUpdateInfo(tableInfoList);
+        if (!info.isSuccess()) {
+            return info;
+        }
 
         //单个 pdf加载
         for (TableInfo tableInfo : tableInfoList) {

+ 10 - 10
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/FormulaController.java

@@ -296,15 +296,16 @@ public class FormulaController {
             if(dw.length==1){
                 result.put(info.getKey()+"__"+dw[0],data.stream().filter(StringUtils::isNotEmpty).map(Func::toStr).collect(Collectors.joining("、")));
             }else{
-                for(int i=0;i<dw.length;i++){
-                    if(data.size()>i){
-                        result.put(info.getKey()+"__"+dw[i],data.get(i));
+                int start=new ArrayList<>(Arrays.asList(dw)).indexOf(bak);
+                for(int i=start;i<dw.length;i++){
+                    if(data.size()>i-start){
+                        result.put(info.getKey()+"__"+dw[i],data.get(i-start));
                     }else{
                         break;
                     }
                 }
-                if(data.size()>dw.length){
-                    result.put("more",data.stream().skip(dw.length).map(StringUtils::handleNull).collect(Collectors.joining(StringPool.SEMICOLON)));
+                if(data.size()>dw.length-start){
+                    result.put("more",data.stream().skip(dw.length-start).map(StringUtils::handleNull).collect(Collectors.joining(StringPool.SEMICOLON)));
                 }
             }
             /*保存实测值参数*/
@@ -358,13 +359,12 @@ public class FormulaController {
               }
               if(keyMapper!=null&&Func.isNotEmpty(keyMapper.getFormulaId())){
                    Formula formula = this.service.getById(keyMapper.getFormulaId());
-                  String data = this.formulaOptionService.queryOption(fo.getContractId(),fo.getParentId(),fo.getPkeyId(),fo.getKey());
                   /*临时处理,等确定数据结构在优化*/
                    if(formula.getFormula().contains(".option")){
-                       return R.data(createRadioPanel(0,"是否引用公式数据",data));
+                       return R.data(createRadioPanel(0,"是否引用公式数据",this.formulaOptionService.queryOption(fo.getContractId(),fo.getParentId(),fo.getPkeyId(),key)));
                    }else if (StringUtils.isEquals("MILE",formula.getNumber())||StringUtils.isEquals("TURN_POINT",formula.getNumber())){
                       if(StringUtils.isEquals(key,formula.getRelyList().get(0).split(StringPool.COLON)[1])){
-                          return R.data(createRadioPanel(1,"竖直方向",data));
+                          return R.data(createRadioPanel(1,"竖直方向",this.formulaOptionService.queryOption(fo.getContractId(),fo.getParentId(),fo.getPkeyId(),fo.getKey())));
                       }
                   }
                   R.success("暂无公式控件");
@@ -374,9 +374,9 @@ public class FormulaController {
 
     public JSONObject createRadioPanel(Integer scope,String label,String data){
         JSONObject jo =JSON.parseObject(TEMPLATE);
-        jo.put("scope",1);
+        jo.put("scope",scope);
         JSONObject info =jo.getJSONObject("info");
-        info.put("label","竖直方向");
+        info.put("label",label);
         info.put("code","TF");
         if(Func.isNotEmpty(data)){
             info.put("data",data);

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

@@ -1,15 +1,13 @@
 package org.springblade.manager.controller;
 
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.mixsmart.utils.StringUtils;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
+import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.vo.SaveLogContractVO;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.boot.ctrl.BladeController;
@@ -20,10 +18,8 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.support.Kv;
-import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.StringUtil;
-import org.springblade.manager.bean.TableInfo;
 import org.springblade.manager.dto.WbsTreePrivateDTO2;
 import org.springblade.manager.dto.WbsTreePrivateDTO3;
 import org.springblade.manager.entity.*;

+ 7 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -3,6 +3,7 @@ package org.springblade.manager.feign;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.AllArgsConstructor;
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.business.entity.InformationQuery;
 import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.feign.InformationQueryClient;
@@ -10,6 +11,8 @@ import org.springblade.business.vo.TrialRawMaterialSelfRecord;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.beans.BeanProperty;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.ResourceUtil;
@@ -20,6 +23,7 @@ import org.springblade.manager.service.IExcelTabService;
 import org.springblade.manager.utils.FileUtils;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.cache.ParamCache;
+import org.springframework.beans.BeanUtils;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.Transactional;
@@ -47,17 +51,17 @@ public class ExcelTabClientImpl implements ExcelTabClient {
     }
 
     @Override
-    public String saveTabData(Integer isBatchSave, JSONObject dataInfo, Integer type, String tableType, Long id, String tabIds) throws Exception {
+    public String saveTabData(TrialSelfInspectionRecordDTO dto, Integer isBatchSave,Integer type, String tableType, Long id, String tabIds) throws Exception {
         //通用参数
         String pdfUrl = "";
-        JSONArray dataArray = dataInfo.getJSONArray("orderList");
+        JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
         JSONObject table = dataArray.getJSONObject(0);
         String nodeId = table.getString("nodeId");
         String projectId = table.getString("projectId");
         String contractId = table.getString("contractId");
 
         //获取表模板,已处理隐藏表问题
-        List<TableInfo> tableInfoList = this.excelTabService.getTableInfoListTrial(dataArray,tabIds);
+        List<TableInfo> tableInfoList = this.excelTabService.getTableInfoListTrial(dataArray, tabIds);
 
         //------试验填报数据保存,当前记录id作为groupId------
         this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);

+ 3 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/TableFileClientImpl.java

@@ -29,5 +29,7 @@ public class TableFileClientImpl implements TableFileClient {
         this.tableFileService.saveBatch(query, 100);
     }
 
-
+    public boolean saveBatch(List<TableFile> newFiles) {
+        return tableFileService.saveBatch(newFiles, 100);
+    }
 }

+ 59 - 33
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreePrivateClientImpl.java

@@ -12,13 +12,16 @@ import org.springblade.common.utils.SnowFlakeUtil;
 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.TableFile;
 import org.springblade.manager.entity.TrialSelfDataRecord;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.service.IWbsTreePrivateService;
+import org.springblade.manager.service.impl.ExcelTabServiceImpl;
 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.*;
@@ -30,6 +33,8 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
 
     private final IWbsTreePrivateService wbsTreePrivateService;
     private final JdbcTemplate jdbcTemplate;
+    private final TableFileClientImpl tableFileClient;
+    private final ExcelTabServiceImpl excelTabServiceImpl;
 
     @Override
     public List<WbsTreePrivate> queryAllNodeByProjectId(String projectId) {
@@ -65,24 +70,14 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
     }
 
     @Override
-    public boolean copyBussTab(Long pKeyId) {
-        WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
-                .eq(WbsTreePrivate::getPKeyId, pKeyId));
-
-        List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateService.getBaseMapper().selectList(Wrappers.<WbsTreePrivate>query().lambda()
-                .eq(WbsTreePrivate::getId, wbsTreePrivate.getId())
-                .eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
-                .eq(WbsTreePrivate::getWbsType, wbsTreePrivate.getWbsType())
-                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
-                .eq(WbsTreePrivate::getParentId, wbsTreePrivate.getParentId()));
-
+    public boolean copyBussTab(Long pKeyId, Long id) {
+        WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getPKeyId, pKeyId));
+        List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateService.getBaseMapper().selectList(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getId, wbsTreePrivate.getId()).eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId()).eq(WbsTreePrivate::getWbsType, wbsTreePrivate.getWbsType()).eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId()).eq(WbsTreePrivate::getParentId, wbsTreePrivate.getParentId()));
         List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateList.stream().sorted(Comparator.comparing(WbsTreePrivate::getCreateTime).reversed()).collect(Collectors.toList());
-
         long newPkId = SnowFlakeUtil.getId();
         wbsTreePrivate.setPKeyId(newPkId);
         wbsTreePrivate.setCreateTime(new Date());
         String nodeName = wbsTreePrivates.get(0).getNodeName();
-
         if (nodeName.contains("__")) {
             String[] oldName = nodeName.split("__");
             nodeName = oldName[0] + "__" + (Integer.parseInt(oldName[1]) + 1);
@@ -90,51 +85,74 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
             nodeName = nodeName + "__" + 1;
         }
         wbsTreePrivate.setNodeName(nodeName);
-        wbsTreePrivate.setIsTabPdf(1); // pdf=不能预览
-        wbsTreePrivate.setIsBussShow(1); // 是否隐藏表=否
-        wbsTreePrivate.setTabFileType(1); // 是否上传文件=否
-        wbsTreePrivate.setPdfUrl("");
-
         String tabName = wbsTreePrivate.getInitTableName();
 
         //字段查询 并去掉公式字段
-        String colkeys = "SELECT GROUP_CONCAT(e_key) as colkeys from m_wbs_tree a ,m_wbs_form_element b WHERE a.init_table_name = '" + tabName + "' and a.id=b.f_id and b.id not in(SELECT element_id from m_formula c where c.is_deleted=0) ";
+        /*String colkeys = "SELECT GROUP_CONCAT(e_key) as colkeys from m_wbs_tree a ,m_wbs_form_element b WHERE a.init_table_name = '" + tabName + "' and a.id=b.f_id and b.id not in(SELECT element_id from m_formula c where c.is_deleted=0) ";
         Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(colkeys);
-        colkeys = stringObjectMap.get("colkeys") + "";
+        colkeys = stringObjectMap.get("colkeys") + "";*/
+
+        //查询字段
+        String sql = "select COLUMN_NAME from information_schema.`COLUMNS` WHERE table_name = '" + tabName + "'";
+        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
+        List<Object> filed = new ArrayList<>();
+        for (Map<String, Object> map : maps) {
+            Object column_name = map.get("COLUMN_NAME");
+            if (!(("id").equals(column_name) || ("group_id").equals(column_name) || ("p_key_id").equals(column_name))) {
+                filed.add(column_name);
+            }
+        }
+
         //复制表数据
-        String querySql = "select " + colkeys + " from " + tabName + " where p_key_id=" + pKeyId;
+        String querySql = "select " + org.apache.commons.lang3.StringUtils.join(filed, ",") + " from " + tabName + " where p_key_id=" + pKeyId + " and group_id = " + id;
         List<Map<String, Object>> dataList = jdbcTemplate.queryForList(querySql);
-        if (dataList != null && dataList.size() >= 1) {
+        if (dataList.size() >= 1) {
             Map<String, Object> dataMap2 = dataList.get(0);
 
-            dataMap2.remove("p_key_id");
             dataMap2.remove("id");
+            dataMap2.remove("p_key_id");
+            dataMap2.remove("group_id");
 
             //sql组装
             String sqlInfo = "";
 
             sqlInfo = "INSERT INTO " + tabName + " ( ";
 
-            String keyStr = "id,p_key_id,";
-            String valStr = SnowFlakeUtil.getId() + "," + wbsTreePrivate.getPKeyId() + ",";
+            StringBuilder keyStr = new StringBuilder("id,p_key_id,group_id,");
+            StringBuilder valStr = new StringBuilder(SnowFlakeUtil.getId() + "," + wbsTreePrivate.getPKeyId() + "," + id + ",");
 
             for (String keys : dataMap2.keySet()) {
                 if (!(dataMap2.get(keys) + "").equals("null")) {
-                    keyStr += keys + ",";
-                    valStr += "'" + dataMap2.get(keys) + "',";
+                    keyStr.append(keys).append(",");
+                    valStr.append("'").append(dataMap2.get(keys)).append("',");
                 }
             }
-            keyStr = keyStr.substring(0, keyStr.lastIndexOf(","));
-            valStr = valStr.substring(0, valStr.lastIndexOf(","));
+            keyStr = new StringBuilder(keyStr.substring(0, keyStr.lastIndexOf(",")));
+            valStr = new StringBuilder(valStr.substring(0, valStr.lastIndexOf(",")));
 
             sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
 
-            //huangJN 保存成功后调用生成资料查询列表数据
             jdbcTemplate.execute(sqlInfo);
         }
-        wbsTreePrivateService.save(wbsTreePrivate);
 
-        return true;
+        //复制附件文件
+        List<TableFile> oldFiles = jdbcTemplate.query("select domain_url,name,extension,type,is_deleted,domain_pdf_url,status from m_table_file where is_deleted = 0 and tab_id = '" + pKeyId + "' and trial_record_id = " + id, new BeanPropertyRowMapper<>(TableFile.class));
+        List<TableFile> newFiles = new ArrayList<>();
+        for (TableFile oldFile : oldFiles) {
+            TableFile obj = BeanUtil.copyProperties(oldFile, TableFile.class);
+            if (obj != null) {
+                obj.setId(SnowFlakeUtil.getId());
+                obj.setTabId(newPkId + ""); //新表pKeyId
+                obj.setTrialRecordId(id);
+                newFiles.add(obj);
+            }
+        }
+        boolean result = tableFileClient.saveBatch(newFiles);
+        if (result) {
+            wbsTreePrivateService.save(wbsTreePrivate);
+            return true;
+        }
+        return false;
     }
 
     @Override
@@ -176,7 +194,10 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
 
     @Override
     public WbsTreePrivate getNodeByPrimaryKeyId(String primaryKeyId) {
-        return wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, primaryKeyId));
+        return wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>lambdaQuery()
+                .select(WbsTreePrivate::getInitTableName)
+                .eq(WbsTreePrivate::getStatus, 1)
+                .eq(WbsTreePrivate::getPKeyId, primaryKeyId));
     }
 
     @Override
@@ -188,6 +209,11 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
         this.wbsTreePrivateService.update(updateWrapper);
     }
 
+    @Override
+    public List<Map<String, Object>> getTrialDataInfo(String pKeyId, Long id) {
+        return excelTabServiceImpl.getBussDataInfoTrial(id, Long.parseLong(pKeyId));
+    }
+
     private void foreachSetChildList(List<WbsTreeContractTreeVOS> vosResult, List<WbsTreePrivateVO> voList) {
         voList.forEach(wbsTreePrivateVO -> {
             WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();

+ 7 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/Mileage.java

@@ -26,6 +26,7 @@ public class Mileage {
     private String dy;
     private String ds;
     private LinkedHashMap<String, ElementData> dataMap;
+    private Boolean isVertical=false;
 
     public Mileage(LinkedHashMap<String, ElementData> dataMap) {
         this.dataMap = dataMap;
@@ -186,5 +187,11 @@ public class Mileage {
         this.dataMap = dataMap;
     }
 
+    public Boolean getVertical() {
+        return isVertical;
+    }
 
+    public void setVertical(Boolean vertical) {
+        isVertical = vertical;
+    }
 }

+ 10 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/FormulaMileage.java

@@ -1,5 +1,6 @@
 package org.springblade.manager.formula.impl;
 
+import com.jfireel.expression.Expression;
 import com.mixsmart.utils.CustomFunction;
 import com.mixsmart.utils.FormulaUtils;
 import com.mixsmart.utils.ListUtils;
@@ -9,10 +10,12 @@ import org.springblade.business.feign.MileageClient;
 import org.springblade.common.utils.BaseUtils;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringPool;
+import org.springblade.manager.bean.TableInfo;
 import org.springblade.manager.dto.ElementData;
 import org.springblade.manager.dto.FormData;
 import org.springblade.manager.entity.Formula;
 import org.springblade.manager.formula.FormulaStrategy;
+import org.springblade.manager.formula.KeyMapper;
 import org.springblade.manager.formula.Mileage;
 import org.springframework.stereotype.Component;
 
@@ -65,10 +68,15 @@ public class FormulaMileage implements FormulaStrategy {
         FormData line0=data.get(0);
         if(line0!=null&&Func.isNotEmpty(line0.getValues())){
                List<ElementData> eds=line0.getValues();
+            List<Long> tableInfoIds= tec.getKeyMappers().stream().filter(k->k.getTableName().equals(cur.getTableName())).map(KeyMapper::getPkId).distinct().collect(Collectors.toList());
             for (ElementData ed : eds) {
                 LinkedHashMap<String, ElementData> row = new LinkedHashMap<>();
                 Mileage mileage = new Mileage(row);
                 mileage.setValue(0, ed.stringValue());
+                Long pkeyId=tableInfoIds.get(ed.getIndex());
+                String findStr="OP['"+cur.getTableName()+"']['"+pkeyId+"@"+cur.getKey()+"__"+ed.getY()+"_"+ed.getX()+"']['TF']";
+                String flag=StringUtils.handleNull(Expression.parse(findStr).calculate(tec.getConstantMap()));
+                mileage.setVertical(StringUtils.isEquals(1,StringUtils.handleNull(Expression.parse(findStr).calculate(tec.getConstantMap()))));
                 row.put(line0.getCode(), ed);
                 for (int j = 1; j < relyList.size(); j++) {
                     FormData rely = data.get(j);
@@ -88,6 +96,8 @@ public class FormulaMileage implements FormulaStrategy {
         if(Func.isNotEmpty(mileageList)){
               List<String>  zhpw =mileageList.stream().filter(Mileage::isChecked).map(Mileage::getZhPw).collect(Collectors.toList());
             Map<String,String[]> coordinateMap  =  mileageClient.mileage2Coordinate(zhpw,Func.toLong(tec.getConstantMap().get("contractId")));
+            /*G10缓存对象*/
+            tec.getConstantMap().put("G10",new Object());
             if(coordinateMap.size()>0){
                 mileageList.forEach(m->{
                     String[] coordinate = coordinateMap.get(m.getZhPw());

+ 46 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveAutoRuleWbsMapper.java

@@ -0,0 +1,46 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.mapper;
+
+import feign.Param;
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
+import org.springblade.manager.vo.ArchiveAutoRuleWbsVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+public interface ArchiveAutoRuleWbsMapper extends BaseMapper<ArchiveAutoRuleWbs> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param archiveAutoRuleWbs
+	 * @return
+	 */
+	List<ArchiveAutoRuleWbsVO> selectArchiveAutoRuleWbsPage(IPage page, ArchiveAutoRuleWbsVO archiveAutoRuleWbs);
+
+	int removeNodeForArchiveAutoRule_Group(@Param("archiveAutoGroupId") Long archiveAutoGroupId,
+										   @Param("projectId") Long projectId);
+
+}

+ 36 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveAutoRuleWbsMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="archiveAutoRuleWbsResultMap" type="org.springblade.manager.entity.ArchiveAutoRuleWbs">
+        <result column="id" property="id"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="create_user" property="createUser"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="wbs_id" property="wbsId"/>
+        <result column="wbs_root_id" property="wbsRootId"/>
+        <result column="archive_auto_type" property="archiveAutoType"/>
+        <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
+        <result column="project_id" property="projectId"/>
+        <result column="delete" property="delete"/>
+    </resultMap>
+
+
+    <select id="selectArchiveAutoRuleWbsPage" resultMap="archiveAutoRuleWbsResultMap">
+        select * from m_archive_auto_rule_wbs where is_deleted = 0
+    </select>
+
+    <update id="removeNodeForArchiveAutoRule_Group">
+        /**取消同一组的分类并卷规则*/
+        update m_archive_auto_rule_wbs
+        set
+            is_deleted = 1
+        where
+          is_deleted = 0
+          and project_id = #{projectId}
+          and archive_auto_group_id = #{archiveAutoGroupId}
+    </update>
+
+</mapper>

+ 10 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.java

@@ -28,16 +28,22 @@ public interface ArchiveTreeMapper extends BaseMapper<ArchiveTree> {
      * @param tree
      * @return
      */
-    int updateAllSonNodeIdsForArchiveAutoRule(@Param("treeContract") ArchiveTree tree);
+    int updateAllSonNodeIdsForArchiveAutoRule(@Param("archiveAutoType") Integer archiveAutoType,
+                                              @Param("archiveAutoNodeId") Long archiveAutoNodeId,
+                                              @Param("archiveAutoGroupId") Long archiveAutoGroupId,
+                                              @Param("ancestors") String ancestors);
 
     /**
      * 删除立卷规则设置
      * @param tree
      * @return
      */
-    int removeAllSonNodeIdsForArchiveAutoRule_1(@Param("tree") ArchiveTree tree);
-    int removeAllSonNodeIdsForArchiveAutoRule_2(@Param("tree") ArchiveTree tree);
-    int removeAllSonNodeIdsForArchiveAutoRule_3(@Param("tree") ArchiveTree tree);
+    int removeAllSonNodeIdsForArchiveAutoRule_1(@Param("archiveAutoType") Integer archiveAutoType,
+                                                @Param("ancestors") String ancestors);
+    int removeAllSonNodeIdsForArchiveAutoRule_2(@Param("archiveAutoType") Integer archiveAutoType,
+                                                @Param("ancestors") String ancestors);
+    int removeAllSonNodeIdsForArchiveAutoRule_3(@Param("archiveAutoType") Integer archiveAutoType,
+                                                @Param("ancestors") String ancestors);
     int removeNodeForArchiveAutoRule_Group(@Param("archiveAutoGroupId") Long archiveAutoGroupId);
     /**
      * 查看分类并卷规则-获取大类所有节点

+ 17 - 17
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.xml

@@ -283,29 +283,29 @@
 
     <update id="updateAllSonNodeIdsForArchiveAutoRule">
 
-        <if test="tree.archiveAutoType ==1 ">
+        <if test="archiveAutoType ==1 ">
             update m_archive_tree
             set
-            archive_auto_node_id = #{tree.archiveAutoNodeId}
+            archive_auto_node_id = #{archiveAutoNodeId}
             where
-            is_deleted = 0 and ancestors like concat('', #{tree.ancestors}, '%');
+            is_deleted = 0 and ancestors like concat('', #{ancestors}, '%');
         </if>
 
         update m_archive_tree
         set
-        archive_auto_type= #{tree.archiveAutoType},
-        <if test="tree.archiveAutoType ==2 ">
-            archive_auto_group_id=#{tree.archiveAutoGroupId},
+        archive_auto_type= #{archiveAutoType},
+        <if test="archiveAutoType ==2 ">
+            archive_auto_group_id=#{archiveAutoGroupId},
             archive_auto_group_select=0
         </if>
         where
-        is_deleted = 0 and ancestors like concat('', #{tree.ancestors}, '%')
+        is_deleted = 0 and ancestors like concat('', #{ancestors}, '%')
         /*最高并卷规则不能覆盖 分类并卷规则,单独组卷规则*/
-        <if test="tree.archiveAutoType ==1 ">
+        <if test="archiveAutoType ==1 ">
             and archive_auto_type != 2 and archive_auto_type != 3
         </if>
         /*分类并卷规则不能覆盖单独组卷规则*/
-        <if test="tree.archiveAutoType ==2 ">
+        <if test="archiveAutoType ==2 ">
             and archive_auto_type != 3
         </if>
     </update>
@@ -316,7 +316,7 @@
             archive_auto_node_id = NULL
         where
             is_deleted = 0
-          and ancestors like concat('', #{tree.ancestors}, '%');
+          and ancestors like concat('', #{ancestors}, '%');
 
 
         update m_archive_tree
@@ -324,9 +324,9 @@
             archive_auto_type = NULL
         where
             is_deleted = 0
-          and ancestors like concat('', #{tree.ancestors}, '%')
+          and ancestors like concat('', #{ancestors}, '%')
             /*取消规则 只取消规则与自己一致的*/
-          and archive_auto_type = #{tree.archiveAutoType} ;
+          and archive_auto_type = #{archiveAutoType} ;
     </update>
 
     <update id="removeAllSonNodeIdsForArchiveAutoRule_3">
@@ -336,9 +336,9 @@
             archive_auto_type = 1
         where
             is_deleted = 0
-          and ancestors like concat('', #{tree.ancestors}, '%')
+          and ancestors like concat('', #{ancestors}, '%')
             /*取消规则 只取消规则与自己一致的*/
-          and archive_auto_type = #{tree.archiveAutoType}
+          and archive_auto_type = #{archiveAutoType}
     </update>
     <update id="removeAllSonNodeIdsForArchiveAutoRule_2">
         /*取消单个节点的分类并卷规则*/
@@ -349,10 +349,10 @@
             archive_auto_group_id = NULL,
             archive_auto_group_select =NULL
         where
-            is_deleted = 0
-          and ancestors like concat('', #{tree.ancestors}, '%')
+          is_deleted = 0
+          and ancestors like concat('', #{ancestors}, '%')
             /*取消规则 只取消规则与自己一致的*/
-          and archive_auto_type = #{tree.archiveAutoType}
+          and archive_auto_type = #{archiveAutoType}
     </update>
 
     <update id="removeNodeForArchiveAutoRule_Group">

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

@@ -1,7 +1,6 @@
 package org.springblade.manager.mapper;
 
 import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
 import org.springblade.manager.dto.FindAllUserByConditionDTO;
 import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.entity.ContractRelationJlyz;
@@ -19,8 +18,7 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
 
     List<ContractInfo> selectContractByProjectIds(@Param("ids") List<Long> ids);
 
-    List<ContractInfoVO> selectContractInfoPage(IPage page,
-                                                ContractInfoVO contractInfo);
+    List<ContractInfoVO> selectContractInfoPage(IPage page, ContractInfoVO contractInfo);
 
     List<ContractlnfoCountVO> selectContractInfoCount();
 
@@ -28,44 +26,31 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
 
     List<CRolePostVO> findJobByRoleId(@Param("id") String id);
 
-    List<UserVO2> findAllUserByCondition(IPage page,
-                                         @Param("Values") FindAllUserByConditionDTO values);
+    List<UserVO2> findAllUserByCondition(IPage page, @Param("Values") FindAllUserByConditionDTO values);
 
-    List<User> findUserListByCondition(IPage page,
-                                       @Param("Values") FindAllUserByConditionDTO values);
+    List<User> findUserListByCondition(IPage page, @Param("Values") FindAllUserByConditionDTO values);
 
-    List<User> findUserInfoByCondition(@Param("rId") String rId,
-                                       @Param("pId") String pId,
-                                       @Param("userName") String userName);
+    List<User> findUserInfoByCondition(@Param("rId") String rId, @Param("pId") String pId, @Param("userName") String userName);
 
     List<User> findUserList();
 
-    Integer updatePasswordByUserId(@Param("userId") String userId,
-                                   @Param("password") String password);
+    Integer updatePasswordByUserId(@Param("userId") String userId, @Param("password") String password);
 
     Boolean deleteFile(@Param("url") String url);
 
-    List<WbsTreeContractTreeVO> tree(@Param("wbsId") String wbsId,
-                                     @Param("projectId") String projectId,
-                                     @Param("contractId") String contractId,
-                                     @Param("wbsType") Integer wbsType,
-                                     @Param("parentId") String parentId);
+    List<WbsTreeContractTreeVO> tree(@Param("wbsId") String wbsId, @Param("projectId") String projectId, @Param("contractId") String contractId, @Param("wbsType") Integer wbsType, @Param("parentId") String parentId);
 
-    List<WbsTreeContractVO> tree2(@Param("wbsId") Long wbsId,
-                                  @Param("projectId") Long projectId,
-                                  @Param("contractId") Long contractId,
-                                  @Param("wbsType") Integer wbsType,
-                                  @Param("parentId") String parentId,
-                                  @Param("queryValue") String queryValue);
+    List<WbsTreeContractVO> tree2(@Param("wbsId") Long wbsId, @Param("projectId") Long projectId, @Param("contractId") Long contractId, @Param("wbsType") Integer wbsType, @Param("parentId") String parentId, @Param("queryValue") String queryValue);
 
-    List<WbsTreeContractVO> tree3(@Param("wbsId") String wbsId,
-                                  @Param("projectId") String projectId,
-                                  @Param("contractId") String contractId,
-                                  @Param("wbsType") Integer wbsType,
-                                  @Param("parentId") String parentId);
+    List<WbsTreeContractVO> tree3(@Param("wbsId") String wbsId, @Param("projectId") String projectId, @Param("contractId") String contractId, @Param("wbsType") Integer wbsType, @Param("parentId") String parentId);
 
-    List<WbsTreeContractVO> tree4(@Param("contractId") String contractId,
-                                  @Param("parentId") String parentId);
+    List<WbsTreeContractVO> tree4(@Param("contractId") String contractId, @Param("parentId") String parentId);
+
+    List<WbsTreeContractTreeAllVO> tree5(@Param("contractId") Long contractId);
+
+    List<WbsTreeContractVO6> tree6(@Param("wbsId") Long wbsId, @Param("projectId") Long projectId, @Param("contractId") Long contractId);
+
+    List<TrialRecordZJTreeVO> trialRelationTree(@Param("projectId") Long projectId, @Param("contractId") Long contractId, @Param("wbsId") Long wbsId);
 
     List<WbsTreeContractVO3> selectLists(@Param("contractInfo") ContractInfo contractInfo, @Param("contractType") Integer contractType);
 
@@ -81,13 +66,4 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
 
     List<UserContractInfoVO> userListByIds(@Param("ids") List<String> ids);
 
-    @Select("select quality_node_id from u_trial_self_quality_project where self_id = #{selfId}")
-    List<String> queryList(@Param("selfId") String selfId);
-
-    List<WbsTreeContractTreeAllVO> tree5(@Param("contractId") Long contractId);
-
-    List<WbsTreeContractVO6> tree6(@Param("wbsId") Long wbsId,
-                                  @Param("projectId") Long projectId,
-                                  @Param("contractId") Long contractId);
-
 }

+ 18 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml

@@ -464,4 +464,22 @@
         ORDER BY d.sort
     </select>
 
+    <select id="trialRelationTree" resultType="org.springblade.manager.vo.TrialRecordZJTreeVO">
+        SELECT
+            d.p_key_id AS "primaryKeyId",
+            d.id AS id,
+            d.full_name AS fullName,
+            d.parent_id AS "parentId"
+        FROM m_wbs_tree_contract d
+        WHERE
+            d.is_deleted = 0
+        AND d.status = 1
+        AND d.type = 1
+        AND wbs_type = 1
+        AND project_id = #{projectId}
+        AND contract_id = #{contractId}
+        AND wbs_id = #{wbsId}
+        ORDER BY d.sort,d.create_time
+    </select>
+
 </mapper>

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.java

@@ -90,4 +90,5 @@ public interface WbsTreePrivateMapper extends EasyBaseMapper<WbsTreePrivate> {
 
     List<TableInfo> selectTabInfoAll();
 
+    void updateBatchByPKeyId(@Param("list")List<WbsTreePrivate> wbsTreePrivateList);
 }

+ 8 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.xml

@@ -312,6 +312,13 @@
             AND is_deleted = 0
         </foreach>
     </update>
+    <update id="updateBatchByPKeyId">
+        <foreach item="item" collection="list" separator=";">
+            UPDATE m_wbs_tree_private
+            <set>html_url = #{item.htmlUrl}</set>
+            where p_key_id = #{item.pKeyId}
+        </foreach>
+    </update>
 
     <select id="lazyTree" resultMap="treeNodeResultMap">
         SELECT
@@ -333,7 +340,7 @@
         FROM
         m_wbs_tree_private
         WHERE
-        parent_id = d.id and is_deleted = 0
+        parent_id = d.id and is_deleted = 0 and type != 2
         ) AS "has_children"
         FROM
         m_wbs_tree_private d

+ 41 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IArchiveAutoRuleWbsService.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service;
+
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
+import org.springblade.manager.vo.ArchiveAutoRuleWbsVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+public interface IArchiveAutoRuleWbsService extends BaseService<ArchiveAutoRuleWbs> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param archiveAutoRuleWbs
+	 * @return
+	 */
+	IPage<ArchiveAutoRuleWbsVO> selectArchiveAutoRuleWbsPage(IPage<ArchiveAutoRuleWbsVO> page, ArchiveAutoRuleWbsVO archiveAutoRuleWbs);
+
+}

+ 12 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IArchiveTreeService.java

@@ -42,15 +42,24 @@ public interface IArchiveTreeService extends BaseService<ArchiveTree> {
 	 *项目级立卷规则新增
 	 * @return
 	 */
-	boolean saveArchiveAutoRule(Integer archiveAutoType,String nodeIds);
+	boolean saveArchiveAutoRule(Integer archiveAutoType,String nodeIds,boolean iswbsNode);
 
 
 
-	Map<String,Object> getArchiveAutoRule(Long id);
+	Map<String,Object> getArchiveAutoRule(Long id,boolean iswbsNode);
 
 	/**
 	 *项目级立卷规则更新
 	 * @return
 	 */
-	boolean updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto);
+	boolean updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto,boolean iswbsNode);
+
+
+	/**
+	 * 移除节点立卷规则
+	 * @param nodeId
+	 * @param iswbsNode
+	 * @return
+	 */
+	Map<String,String> removeArchiveAutoRule(Long nodeId,boolean iswbsNode);
 }

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

@@ -17,6 +17,7 @@
 package org.springblade.manager.service;
 
 import com.alibaba.fastjson.JSONArray;
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.core.tool.api.R;
 import org.springblade.manager.bean.TableInfo;
 import org.springblade.manager.entity.ExcelEditCallback;
@@ -114,6 +115,7 @@ public interface IExcelTabService extends BaseService<ExcelTab> {
     void getBussPdfs(String nodeId, String classify, String contractId, String projectId) throws Exception;
 
     // 试验
+
     /**
      * 表格数据封装 - 试验
      */

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

@@ -79,4 +79,7 @@ public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
 
     void eVisInfoRepeatDel(String pid);
 
+    //批量重新保存文件htmlUrl
+    void batchResetHtmlUrl(List<WbsTreePrivate> wbsTreePrivateList) throws IOException, InterruptedException;
+
 }

+ 41 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveAutoRuleWbsServiceImpl.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service.impl;
+
+import org.springblade.manager.entity.ArchiveAutoRuleWbs;
+import org.springblade.manager.vo.ArchiveAutoRuleWbsVO;
+import org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper;
+import org.springblade.manager.service.IArchiveAutoRuleWbsService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务实现类
+ *
+ * @author BladeX
+ * @since 2023-03-20
+ */
+@Service
+public class ArchiveAutoRuleWbsServiceImpl extends BaseServiceImpl<ArchiveAutoRuleWbsMapper, ArchiveAutoRuleWbs> implements IArchiveAutoRuleWbsService {
+
+	@Override
+	public IPage<ArchiveAutoRuleWbsVO> selectArchiveAutoRuleWbsPage(IPage<ArchiveAutoRuleWbsVO> page, ArchiveAutoRuleWbsVO archiveAutoRuleWbs) {
+		return page.setRecords(baseMapper.selectArchiveAutoRuleWbsPage(page, archiveAutoRuleWbs));
+	}
+
+}

+ 289 - 126
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeServiceImpl.java

@@ -14,9 +14,8 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.dto.ArchiveTreeContractAutoRuleMapDTO;
 import org.springblade.manager.dto.ArchiveTreeDTO;
 import org.springblade.manager.dto.ArchiveTreeSortDTO;
-import org.springblade.manager.entity.ArchiveTree;
-import org.springblade.manager.entity.ArchiveTreeContract;
-import org.springblade.manager.entity.ProjectInfo;
+import org.springblade.manager.entity.*;
+import org.springblade.manager.mapper.ArchiveAutoRuleWbsMapper;
 import org.springblade.manager.service.IProjectInfoService;
 import org.springblade.manager.service.IWbsTreePrivateService;
 import org.springblade.manager.service.IWbsTreeService;
@@ -41,6 +40,8 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
     private final IWbsTreePrivateService wbsTreePrivateService;
     private final IProjectInfoService projectInfoService;
 
+    private final ArchiveAutoRuleWbsMapper archiveAutoRuleWbsMapper;
+
     @Override
     public boolean initArchiveTree(Long projectId) {
         if (projectId != null && projectId != 0) {
@@ -435,20 +436,33 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
      * @return
      */
     @Override
-    public boolean saveArchiveAutoRule(Integer archiveAutoType, String nodeIds) {
-        //项目级不需要考虑是否为wbs节点,已经同步出来了都属于归档树节点,直接按归档树节点处理
+    public boolean saveArchiveAutoRule(Integer archiveAutoType, String nodeIds,boolean iswbsNode) {
+        if(iswbsNode){
+            return saveArchiveAutoRule_WbsTreeNode(archiveAutoType, nodeIds);
+        }else{
+            return saveArchiveAutoRule_ArchiveTreeNode(archiveAutoType, nodeIds);
+        }
+    }
+
+    /**
+     * 归档树节点规则设置保存(系统级)
+     * @param archiveAutoType
+     * @param nodeIds
+     * @return
+     */
+    private Boolean saveArchiveAutoRule_ArchiveTreeNode(Integer archiveAutoType, String nodeIds){
         try{
-            //步骤1保存选择节点的立卷规则。
             String[] ids = nodeIds.split(",");
-
             Long archiveAutoGroupId=null;
-
             //分类并卷规则的需要生成个随机数,作为同一个分类赋值archiveAutoNodeId
             if(archiveAutoType==2){
-                double ran=(Math.random()*100000000) + 1;
+                double v = Math.random() * 10000;
+                int ran = (int)v;
                 archiveAutoGroupId=Long.parseLong(System.currentTimeMillis()+""+ran);
             }
+
             for(String nodeId:ids){
+                //步骤1:保存选择节点的立卷规则。
                 long nodeIdLong = Long.parseLong(nodeId);
                 ArchiveTree archiveTree = baseMapper.selectById(nodeIdLong);
                 archiveTree.setArchiveAutoType(archiveAutoType);
@@ -463,157 +477,306 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                 }
                 baseMapper.updateById(archiveTree);
 
-                //步骤2保存选择节点下所有子节点的立卷规则。注意立卷规则优先级覆盖原则。(单独组卷>分类并卷>最高并卷)
-                baseMapper.updateAllSonNodeIdsForArchiveAutoRule(archiveTree);
+                //步骤2保存选择节点下所有子节点的立卷规则。注意立卷规则优先级覆盖原则。(单独组卷,分类并卷>最高并卷)
+                baseMapper.updateAllSonNodeIdsForArchiveAutoRule(
+                        archiveTree.getArchiveAutoType(),
+                        archiveTree.getArchiveAutoNodeId(),
+                        archiveTree.getArchiveAutoGroupId(),
+                        archiveTree.getAncestors()
+                );
             }
 
             return true;
-
         }catch (Exception e){
             e.printStackTrace();
             return false;
         }
     }
 
-
     /**
-     * 获取节点规则查看
-     * @param id
+     * 归档树wbs节点规则设置保存(系统级)
+     * @param archiveAutoType
+     * @param nodeIds
      * @return
      */
-    @Override
-    public Map<String,Object> getArchiveAutoRule(Long id) {
-
-        Map<String,Object> map= new HashMap<>();
-
-        ArchiveTree archiveTree = baseMapper.selectById(id);
-        Integer archiveAutoType = archiveTree.getArchiveAutoType();
-        if(archiveAutoType!=null){
-            if(archiveAutoType==1){
-                //最高并卷层级 默认规则的节点 显示最高并卷层级节点
-                Long archiveAutoNodeId = archiveTree.getArchiveAutoNodeId();
-                ArchiveTree archiveAutoNode = baseMapper.selectById(archiveAutoNodeId);
-                StringBuffer allName= new StringBuffer();
-                String ancestors = archiveAutoNode.getAncestors();
-                String[] ancestorssplit = ancestors.split(",");//全路径ID
-                for(String pId:ancestorssplit){
-                    long pIdLong = Long.parseLong(pId);
-                    ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
-                    allName.append(pIdNode.getNodeName()+"/");
-                }
-                allName.append(archiveAutoNode.getNodeName());
-                ArchiveTreeAutoRuleVO vo= new ArchiveTreeAutoRuleVO();
-                vo.setAllName(allName.toString());
-                vo.setNodeId(archiveAutoNode.getId());
-                vo.setArchiveAutoType(archiveAutoType);
-                map.put("type",archiveAutoType);
-                map.put("data",vo);
-                return map;
-            }
+    private Boolean saveArchiveAutoRule_WbsTreeNode(Integer archiveAutoType, String nodeIds){
+        try{
+            String[] ids = nodeIds.split(",");
+            Long archiveAutoGroupId=null;
+            //分类并卷规则的需要生成个随机数,作为同一个分类赋值archiveAutoNodeId
             if(archiveAutoType==2){
-                //分类并卷显示所在大类下树结构,过滤单独规则,其他分类并卷规则组节点 本节点分类组显示打钩
-                //找出当前节点大类
-                String ancestors = archiveTree.getAncestors();
-                String[] ancestorssplit = ancestors.split(",");//全路径ID
-                String nodeAncestors = ancestorssplit[0]+","+ancestorssplit[1]; //大类的ancestors
-                //获取大类下所有节点,过滤单独规则,其他分类并卷规则组节点
-                List<ArchiveTreeAutoRuleVO> nodetree = ForestNodeMerger.merge(baseMapper.getAllSonNodeforGroupView(nodeAncestors, archiveTree.getArchiveAutoNodeId()));
-                //获取与当前节点同一分类的节点
-                List<ArchiveTree> listGroup= baseMapper.selectList(Wrappers.<ArchiveTree>lambdaQuery()
-                        .eq(ArchiveTree::getArchiveAutoGroupId, archiveTree.getArchiveAutoGroupId())
-                        .orderByAsc(ArchiveTree::getSort));
-                StringBuffer nodeSelect = new StringBuffer();
-
-                for(ArchiveTree node:listGroup){
-                    nodeSelect.append(node.getId()+",");
-                }
-                map.put("type",archiveAutoType);
-                map.put("tree",nodetree);
-                map.put("data",nodeSelect.toString());
-                return map;
+                double ran=(Math.random()*100000000) + 1;
+                archiveAutoGroupId=Long.parseLong(System.currentTimeMillis()+""+ran);
             }
-            if(archiveAutoType==3){
-                //单独组卷规则 显示当前节点
-                StringBuffer allName= new StringBuffer();
-                String ancestors = archiveTree.getAncestors();
-                String[] ancestorssplit = ancestors.split(",");//全路径ID
-                for(String pId:ancestorssplit){
-                    long pIdLong = Long.parseLong(pId);
-                    ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
-                    allName.append(pIdNode.getNodeName()+"/");
+
+            for(String nodeId:ids){
+                //步骤1:保存选择节点的立卷规则。
+                long nodeIdLong = Long.parseLong(nodeId);
+                //1.1最高规则和单独规则 将选择的wbs节点ID(wbsId),规则类型(archive_auto_type), 保存表m_archive_auto_rule_wbs
+                WbsTree wbsTree = wbsTreeService.getById(nodeIdLong);
+                ArchiveAutoRuleWbs autoRuleWbs = new ArchiveAutoRuleWbs();
+                autoRuleWbs.setWbsId(nodeIdLong);
+                autoRuleWbs.setArchiveAutoType(archiveAutoType);
+                if(archiveAutoType==2){
+                    autoRuleWbs.setArchiveAutoGroupId(archiveAutoGroupId);
                 }
-                allName.append(archiveTree.getNodeName());
-                ArchiveTreeAutoRuleVO vo= new ArchiveTreeAutoRuleVO();
-                vo.setAllName(allName.toString());
-                vo.setNodeId(archiveTree.getId());
-                vo.setArchiveAutoType(archiveAutoType);
-                map.put("type",archiveAutoType);
-                map.put("data",vo);
-                return map;
+                autoRuleWbs.setProjectId(0L);//TODO
+                autoRuleWbs.setWbsRootId(null);//TODO
+                archiveAutoRuleWbsMapper.insert(autoRuleWbs);
             }
+            return true;
+        }catch (Exception e){
+            e.printStackTrace();
+            return false;
         }
-        return map;
     }
 
 
-    public void removeArchiveAutoRule(Long nodeId){
-        ArchiveTree node = baseMapper.selectById(nodeId);
-        Integer archiveAutoType = node.getArchiveAutoType();
-        if(archiveAutoType!=null){
-            //删除默认规则
-            if(archiveAutoType==1){
-                baseMapper.removeAllSonNodeIdsForArchiveAutoRule_1(node);
-            }
-            //删除节点及所有子节点 分类并卷规则
-            if(archiveAutoType==2){
-                //删除规则
-                baseMapper.removeAllSonNodeIdsForArchiveAutoRule_2(node);
-                //TODO 验证节点的父节点是否为分类并卷规则,如是则取消。若无其他兄弟节点,继续往上验证。
-            }
-            //删除节点及所有子节点 单独并卷规则
-            if(archiveAutoType==3){
-                baseMapper.removeAllSonNodeIdsForArchiveAutoRule_3(node);
-            }
+    @Override
+    public boolean updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto,boolean iswbsNode) {
+        if(iswbsNode){
+            return updateArchiveAutoRule_WbsTreeNode(dto);
+        }else{
+            return updateArchiveAutoRule_ArchiveTreeNode(dto);
         }
 
     }
 
+    /**
+     * 归档树节点规则更新
+     * @param dto
+     * @return
+     */
+    private boolean updateArchiveAutoRule_ArchiveTreeNode(ArchiveTreeContractAutoRuleMapDTO dto) {
+        try{
+            Integer archiveAutoType = dto.getArchiveAutoType();
+            if(archiveAutoType!=null){
+                if(archiveAutoType==2){
+                    Long groupId = dto.getArchiveAutoGroupId();
+                    String selectNodeIds = dto.getSelectNodeIds();
+                    List<String> selectNodeIdlist = Arrays.asList(selectNodeIds);
+                    //先将同一分组的节点删除配置,。
+                    baseMapper.removeNodeForArchiveAutoRule_Group(groupId);
+                    //然后再按照选择节点保存新的设置
+                    for(String nodeId:selectNodeIdlist){
+                        long nodeIdLong = Long.parseLong(nodeId);
+                        ArchiveTree archiveTree = baseMapper.selectById(nodeIdLong);
+                        archiveTree.setArchiveAutoType(archiveAutoType);
+                        //分类并卷规则 提交都是一个分类类型
+                        archiveTree.setArchiveAutoGroupId(groupId);
+                        archiveTree.setArchiveAutoGroupSelect(1);
+                        baseMapper.updateById(archiveTree);
+                        //保存选择节点下所有子节点的立卷规则。注意立卷规则优先级覆盖原则。(单独组卷>分类并卷>最高并卷)
+                        baseMapper.updateAllSonNodeIdsForArchiveAutoRule(
+                                archiveTree.getArchiveAutoType(),
+                                archiveTree.getArchiveAutoNodeId(),
+                                archiveTree.getArchiveAutoGroupId(),
+                                archiveTree.getAncestors()
+                        );
+                    }
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return false;
+        }
 
-    @Override
-    public boolean updateArchiveAutoRule(ArchiveTreeContractAutoRuleMapDTO dto) {
-        //项目级不需要考虑是否为wbs节点,已经同步出来了都属于归档树节点,直接按归档树节点处理
+        return true;
+    }
 
-        Integer archiveAutoType = dto.getArchiveAutoType();
-        if(archiveAutoType!=null){
-            if(archiveAutoType==2){
-                Long groupId = dto.getArchiveAutoGroupId();
-                String selectNodeIds = dto.getSelectNodeIds();
-                List<String> selectNodeIdlist = Arrays.asList(selectNodeIds);
-                //先将同一分类的节点删除配置,。
-                baseMapper.removeNodeForArchiveAutoRule_Group(groupId);
-                //然后再按照选择节点保存新的设置
-                for(String nodeId:selectNodeIdlist){
-                    long nodeIdLong = Long.parseLong(nodeId);
-                    ArchiveTree archiveTree = baseMapper.selectById(nodeIdLong);
-                    archiveTree.setArchiveAutoType(archiveAutoType);
-                    //分类并卷规则 提交都是一个分类类型
-                    archiveTree.setArchiveAutoGroupId(groupId);
-                    archiveTree.setArchiveAutoGroupSelect(1);
-                    baseMapper.updateById(archiveTree);
-                    //保存选择节点下所有子节点的立卷规则。注意立卷规则优先级覆盖原则。(单独组卷>分类并卷>最高并卷)
-                    baseMapper.updateAllSonNodeIdsForArchiveAutoRule(archiveTree);
+    /**
+     * 归档树wbs节点更新
+     * @param dto
+     * @return
+     */
+    private boolean updateArchiveAutoRule_WbsTreeNode(ArchiveTreeContractAutoRuleMapDTO dto) {
+        try{
+            Integer archiveAutoType = dto.getArchiveAutoType();
+            if(archiveAutoType!=null){
+                if(archiveAutoType==2){
+                    Long groupId = dto.getArchiveAutoGroupId();
+                    String selectNodeIds = dto.getSelectNodeIds();
+                    List<String> selectNodeIdlist = Arrays.asList(selectNodeIds);
+                    //先将同一分组的节点删除配置,。
+                    archiveAutoRuleWbsMapper.removeNodeForArchiveAutoRule_Group(groupId,0L);
+                    //然后再按照选择节点保存新的设置
+                    for(String nodeId:selectNodeIdlist){
+                        long nodeIdLong = Long.parseLong(nodeId);
+                        ArchiveAutoRuleWbs autoRuleWbs = new ArchiveAutoRuleWbs();
+                        autoRuleWbs.setWbsId(nodeIdLong);
+                        autoRuleWbs.setArchiveAutoType(archiveAutoType);
+                        if(archiveAutoType==2){
+                            autoRuleWbs.setArchiveAutoGroupId(groupId);
+                        }
+                        autoRuleWbs.setProjectId(0L);//TODO
+                        autoRuleWbs.setWbsRootId(null);//TODO
+                        archiveAutoRuleWbsMapper.insert(autoRuleWbs);
+                    }
                 }
             }
-            if(archiveAutoType==1){
+        }catch (Exception e){
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
 
+    /**
+     * 移除节点规则
+     * @param nodeId
+     */
+    public Map<String,String> removeArchiveAutoRule(Long nodeId,boolean iswbsNode){
+        Map<String,String> returnMap= new HashMap<>();
+        returnMap.put("code","1");
+        try{
+            if(iswbsNode){
+                ArchiveAutoRuleWbs archiveAutoRuleWbs = archiveAutoRuleWbsMapper.selectById(nodeId);
+                archiveAutoRuleWbs.setDelete(1);
+                archiveAutoRuleWbs.setUpdateTime(new Date());
+                archiveAutoRuleWbsMapper.updateById(archiveAutoRuleWbs);
+            }else{
+                ArchiveTree node = baseMapper.selectById(nodeId);
+                Integer archiveAutoType = node.getArchiveAutoType();
+                if(archiveAutoType!=null){
+                    //删除默认规则
+                    if(archiveAutoType==1){
+                        baseMapper.removeAllSonNodeIdsForArchiveAutoRule_1(node.getArchiveAutoType(),node.getAncestors());
+                    }
+                    //删除节点及所有子节点 分类并卷规则
+                    if(archiveAutoType==2){
+                        if(node.getArchiveAutoGroupSelect()==1){
+                            //删除规则  只能修改archive_auto_group_select=1的节点,
+                            // 因为分类并卷规则影响范围包括下面所有子节点,如果给archive_auto_group_select=0的节点也就是范围内的子节点单独取消规则,会造成案卷归属节点错乱。
+                            // (不理那么多,就这样限制先 。如业务非要发神经就要 TODO 验证节点的父节点是否为分类并卷规则,如是则取消。若无其他兄弟节点,继续往上验证。)
+                            baseMapper.removeAllSonNodeIdsForArchiveAutoRule_2(node.getArchiveAutoType(),node.getAncestors());
+                        }
+                        returnMap.put("code","0");
+                        returnMap.put("msg","只能取消设置的节点,不能取消设置节点范围下节点");
+                    }
+                    //删除节点及所有子节点 单独并卷规则
+                    if(archiveAutoType==3){
+                        baseMapper.removeAllSonNodeIdsForArchiveAutoRule_3(node.getArchiveAutoType(),node.getAncestors());
+                    }
+                }
             }
-            if(archiveAutoType==3){
+        }catch (Exception e){
+            e.printStackTrace();
+            returnMap.put("code","0");
+            returnMap.put("msg",e.getMessage());
+        }
+        return returnMap;
+    }
 
-            }
+    /**
+     * 获取节点规则查看
+     * @param id
+     * @return
+     */
+    @Override
+    public Map<String,Object> getArchiveAutoRule(Long id,boolean iswbsNode) {
 
+        if(iswbsNode){
+            return getArchiveAutoRule_ArchiveTreeNode(id);
+        }else{
+            return getArchiveAutoRule_WbsTreeNode(id);
         }
+    }
 
-        return false;
+    /**
+     * 查看归档树节点立卷规则
+     * @param id
+     * @return
+     */
+    private Map<String,Object> getArchiveAutoRule_ArchiveTreeNode(Long id) {
+        Map<String,Object> map= new HashMap<>();
+        try{
+            ArchiveTree archiveTree = baseMapper.selectById(id);
+            Integer archiveAutoType = archiveTree.getArchiveAutoType();
+            if(archiveAutoType!=null){
+                if(archiveAutoType==1){
+                    //最高并卷层级 默认规则的节点 显示最高并卷层级节点
+                    Long archiveAutoNodeId = archiveTree.getArchiveAutoNodeId();
+                    ArchiveTree archiveAutoNode = baseMapper.selectById(archiveAutoNodeId);
+                    StringBuffer allName= new StringBuffer();
+                    String ancestors = archiveAutoNode.getAncestors();
+                    String[] ancestorssplit = ancestors.split(",");//全路径ID
+                    for(String pId:ancestorssplit){
+                        long pIdLong = Long.parseLong(pId);
+                        ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
+                        allName.append(pIdNode.getNodeName()+"/");
+                    }
+                    allName.append(archiveAutoNode.getNodeName());
+                    ArchiveTreeAutoRuleVO vo= new ArchiveTreeAutoRuleVO();
+                    vo.setAllName(allName.toString());
+                    vo.setNodeId(archiveAutoNode.getId());
+                    vo.setArchiveAutoType(archiveAutoType);
+                    map.put("type",archiveAutoType);
+                    map.put("data",vo);
+                    return map;
+                }
+                if(archiveAutoType==2){
+                    //分类并卷显示所在大类下树结构,过滤单独规则,其他分类并卷规则组节点 本节点分类组显示打钩
+                    //找出当前节点大类
+                    String ancestors = archiveTree.getAncestors();
+                    String[] ancestorssplit = ancestors.split(",");//全路径ID
+                    String nodeAncestors = ancestorssplit[0]+","+ancestorssplit[1]; //大类的ancestors
+                    //获取大类下所有节点,过滤单独规则,其他分类并卷规则组节点
+                    List<ArchiveTreeAutoRuleVO> nodetree = ForestNodeMerger.merge(baseMapper.getAllSonNodeforGroupView(nodeAncestors, archiveTree.getArchiveAutoNodeId()));
+                    //获取与当前节点设置同一分类分组的节点
+                    List<ArchiveTree> listGroup= baseMapper.selectList(Wrappers.<ArchiveTree>lambdaQuery()
+                            .eq(ArchiveTree::getArchiveAutoGroupId, archiveTree.getArchiveAutoGroupId())
+                            .eq(ArchiveTree::getArchiveAutoGroupSelect,1)
+                            .orderByAsc(ArchiveTree::getSort));
+                    StringBuffer nodeSelect = new StringBuffer();
+
+                    for(ArchiveTree node:listGroup){
+                        nodeSelect.append(node.getId()+",");
+                    }
+                    map.put("type",archiveAutoType);
+                    map.put("tree",nodetree);
+                    map.put("data",nodeSelect.toString());
+                    return map;
+                }
+                if(archiveAutoType==3){
+                    //单独组卷规则 显示当前节点
+                    StringBuffer allName= new StringBuffer();
+                    String ancestors = archiveTree.getAncestors();
+                    String[] ancestorssplit = ancestors.split(",");//全路径ID
+                    for(String pId:ancestorssplit){
+                        long pIdLong = Long.parseLong(pId);
+                        ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
+                        allName.append(pIdNode.getNodeName()+"/");
+                    }
+                    allName.append(archiveTree.getNodeName());
+                    ArchiveTreeAutoRuleVO vo= new ArchiveTreeAutoRuleVO();
+                    vo.setAllName(allName.toString());
+                    vo.setNodeId(archiveTree.getId());
+                    vo.setArchiveAutoType(archiveAutoType);
+                    map.put("type",archiveAutoType);
+                    map.put("data",vo);
+                    return map;
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return map;
+        }
+        return map;
     }
 
+    /**
+     * 归档树wbs节点规则查看
+     * @param id
+     * @return
+     */
+    private Map<String,Object> getArchiveAutoRule_WbsTreeNode(Long id) {
+        Map<String,Object> map= new HashMap<>();
+        try{
+            //TODO 需要了解关联的wbs节点
+        }catch (Exception e){
+            e.printStackTrace();
+            return map;
+        }
+        return map;
+    }
 }

+ 31 - 22
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -194,15 +194,16 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     public List<WbsTreeContractVO6> tree6List(String wbsId, String projectId, String contractId) {
         return baseMapper.tree6(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId));
     }
+
     @Override
     public List<WbsTreeContractVO6> tree6(String wbsId, String projectId, String contractId) {
-        List<WbsTreeContractVO6> wbsTreeContractVOS =  baseMapper.tree6(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId));
+        List<WbsTreeContractVO6> wbsTreeContractVOS = baseMapper.tree6(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId));
         return buildWbsTreeByStream6(wbsTreeContractVOS);
     }
 
     @Override
     public List<WbsTreeContractVO6> tree8(String wbsId, String projectId, String contractId) {
-        List<WbsTreeContractVO6> wbsTreeContractVOS =  baseMapper.tree6(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId));
+        List<WbsTreeContractVO6> wbsTreeContractVOS = baseMapper.tree6(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId));
         List<WbsTreeContractVO6> wbsTreeVO2s = ForestNodeMerger.merge(wbsTreeContractVOS);
         List<WbsTreeContractVO6> list = wbsTreeVO2s.stream().filter(f -> f.getParentId() == 0L).collect(Collectors.toList());
 
@@ -260,8 +261,6 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     }
 
 
-
-
     public void recursionFnTreeAll(List<WbsTreeContractTreeAllVO> list, Map<Long, List<WbsTreeContractTreeAllVO>> map) {
         for (WbsTreeContractTreeAllVO wbsTreeContractVO : list) {
             List<WbsTreeContractTreeAllVO> childrenList = map.get(wbsTreeContractVO.getId());
@@ -520,28 +519,38 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
 
     @Override
     public Map<String, Object> trialRelationTree(String wbsId, String projectId, String contractId, String selfId) {
-        //合同段树
-        List<WbsTreeContractVO> wbsTreeContractVOS = baseMapper.tree2(null, Long.parseLong(projectId), Long.parseLong(contractId), null, null, null);
-        List<WbsTreeContractVO> wbsTreeContractVOList = buildWbsTreeByStream(wbsTreeContractVOS);
-        //是否勾选-试验关联工程部位信息
-        /*List<String> listResult = new ArrayList<>();
-        if (StringUtils.isNotEmpty(selfId)) {
-            List<String> list = baseMapper.queryList(selfId);
-            if (list.size() > 0) {
-                for (WbsTreeContractVO wbsTreeContractVO : wbsTreeContractVOS) {
-                    for (String s : list) {
-                        if (wbsTreeContractVO.getPrimaryKeyId().equals(s)) {
-                            listResult.add(s);
-                        }
-                    }
-                }
+        //当前合同段施工质检树
+        List<TrialRecordZJTreeVO> wbsTreeContractVOS = baseMapper.trialRelationTree(Long.parseLong(projectId), Long.parseLong(contractId), Long.parseLong(wbsId));
+        List<TrialRecordZJTreeVO> trialRecordZJTreeVOS = buildWbsTreeByStreamTrialRecordZJTree(wbsTreeContractVOS);
+        ContractInfo contractInfo = jdbcTemplate.query("select contract_name from m_contract_info where id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
+        for (TrialRecordZJTreeVO node : trialRecordZJTreeVOS) {
+            if (node.getParentId() == 0 && contractInfo != null) {
+                node.setFullName(contractInfo.getContractName());
+                break;
             }
-        }*/
+        }
         Map<String, Object> maps = new HashMap<>();
-        maps.put("treeContractAll", wbsTreeContractVOList);
-        //maps.put("isSelectedStatus", listResult.stream().distinct().collect(Collectors.toList()));
+        maps.put("treeContractAll", trialRecordZJTreeVOS);
         return maps;
     }
 
+    private List<TrialRecordZJTreeVO> buildWbsTreeByStreamTrialRecordZJTree(List<TrialRecordZJTreeVO> wbsTreeVO2s) {
+        List<TrialRecordZJTreeVO> list = wbsTreeVO2s.stream().filter(f -> f.getParentId() == 0L).collect(Collectors.toList());
+        Map<Long, List<TrialRecordZJTreeVO>> map = wbsTreeVO2s.stream().collect(Collectors.groupingBy(TrialRecordZJTreeVO::getParentId));
+        this.recursionFnTreeTrialRecordZJTree(list, map);
+        return list;
+    }
+
+    private void recursionFnTreeTrialRecordZJTree(List<TrialRecordZJTreeVO> list, Map<Long, List<TrialRecordZJTreeVO>> map) {
+        for (TrialRecordZJTreeVO trialRecordZJTreeVO : list) {
+            List<TrialRecordZJTreeVO> childrenList = map.get(trialRecordZJTreeVO.getId());
+            if (childrenList != null && childrenList.size() > 0) {
+                trialRecordZJTreeVO.setChildren(childrenList);
+                trialRecordZJTreeVO.setHasChildren(true);
+                recursionFnTreeTrialRecordZJTree(childrenList, map);
+            }
+        }
+    }
+
 
 }

+ 74 - 49
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -42,6 +42,7 @@ import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.business.entity.InformationQuery;
 import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.feign.ContractLogClient;
@@ -1543,39 +1544,75 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
             String htmlString = IoUtil.readToString(new FileInputStream(file1));
             Document doc = Jsoup.parse(htmlString);
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        }
+            //匹配
+            Elements bgHB = doc.select("el-input[placeholder~=报告编号.*]");
+            Elements jlBH = doc.select("el-input[placeholder~=记录编号.*]");
+
+            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) {
+                        int trIndex = Integer.parseInt(element.attr("trindex"));
+                        if (trIndex <= 6) {
+                            reData.put(element.attr("keyName"), ObjectUtils.isNotEmpty(record.getReportNo()) ? record.getReportNo() : "");
+                        }
+                    }
+                }
+                //记录编号
+                if (jlBH.size() >= 1) {
+                    for (Element element : jlBH) {
+                        int trIndex = Integer.parseInt(element.attr("trindex"));
+                        if (trIndex <= 6) {
+                            reData.put(element.attr("keyName"), ObjectUtils.isNotEmpty(record.getRecordNo()) ? record.getRecordNo() : "");
+                        }
+                    }
+                }
+            }
 
-        if (dataIn.size() >= 1) {
-            Map<String, Object> mysqlData = dataIn.get(0);
-            for (String key : mysqlData.keySet()) {
-                String tabVal = mysqlData.get(key) + "";
+            if (dataIn.size() >= 1) {
+                Map<String, Object> mysqlData = dataIn.get(0);
+                for (String key : mysqlData.keySet()) {
+                    String tabVal = mysqlData.get(key) + "";
 
-                // 时间段处理
-                if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
-                    if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
-                        String[] tabData = tabVal.split("_\\^_");
+                    // 时间段处理
+                    if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
+                        if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
+                            String[] tabData = tabVal.split("_\\^_");
 
-                        if (reData.containsKey("pickerKey")) {
-                            String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
-                            reData.put("pickerKey", pickerKey);
-                        } else {
-                            reData.put("pickerKey", key + "__" + tabData[1]);
-                        }
+                            if (reData.containsKey("pickerKey")) {
+                                String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
+                                reData.put("pickerKey", pickerKey);
+                            } else {
+                                reData.put("pickerKey", key + "__" + tabData[1]);
+                            }
 
-                        String sql = tabData[0];
-                        sql = sql.replaceAll("\\[", "['");
-                        sql = sql.replaceAll("]", "']");
-                        sql = sql.replaceAll("000Z,", "000Z',");
-                        sql = sql.replaceAll(", 20", ", '20");
-                        //   sql = sql.replaceAll("'", "");
-                        if (StringUtils.isNotEmpty(tabData[0])) {
-                            reData.put(key + "__" + tabData[1], sql);
-                        }
-                    } else if (tabVal.contains("T") && tabVal.contains(".000Z")) { //时间
-                        // 时间和字符串合作
-                        if (tabVal.contains("☆")) {
+                            String sql = tabData[0];
+                            sql = sql.replaceAll("\\[", "['");
+                            sql = sql.replaceAll("]", "']");
+                            sql = sql.replaceAll("000Z,", "000Z',");
+                            sql = sql.replaceAll(", 20", ", '20");
+                            //   sql = sql.replaceAll("'", "");
+                            if (StringUtils.isNotEmpty(tabData[0])) {
+                                reData.put(key + "__" + tabData[1], sql);
+                            }
+                        } else if (tabVal.contains("T") && tabVal.contains(".000Z")) { //时间
+                            // 时间和字符串合作
+                            if (tabVal.contains("☆")) {
+                                String[] mysql = tabVal.split("☆");
+                                for (String data : mysql) {
+                                    String[] tabData = data.split("_\\^_");
+                                    if (StringUtils.isNotEmpty(tabData[0])) {
+                                        reData.put(key + "__" + tabData[1], tabData[0]);
+                                    }
+                                }
+                            } else {
+                                String[] tabData = tabVal.split("_\\^_");
+                                if (StringUtils.isNotEmpty(tabData[0])) {
+                                    reData.put(key + "__" + tabData[1], tabData[0]);
+                                }
+                            }
+                        } else if (tabVal.contains("☆")) {
                             String[] mysql = tabVal.split("☆");
                             for (String data : mysql) {
                                 String[] tabData = data.split("_\\^_");
@@ -1583,30 +1620,19 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                     reData.put(key + "__" + tabData[1], tabData[0]);
                                 }
                             }
-                        } else {
+                        } else if (tabVal.contains("_^_")) {
                             String[] tabData = tabVal.split("_\\^_");
                             if (StringUtils.isNotEmpty(tabData[0])) {
                                 reData.put(key + "__" + tabData[1], tabData[0]);
                             }
+                        } else {
+                            reData.put(key, tabVal);
                         }
-                    } else if (tabVal.contains("☆")) {
-                        String[] mysql = tabVal.split("☆");
-                        for (String data : mysql) {
-                            String[] tabData = data.split("_\\^_");
-                            if (StringUtils.isNotEmpty(tabData[0])) {
-                                reData.put(key + "__" + tabData[1], tabData[0]);
-                            }
-                        }
-                    } else if (tabVal.contains("_^_")) {
-                        String[] tabData = tabVal.split("_\\^_");
-                        if (StringUtils.isNotEmpty(tabData[0])) {
-                            reData.put(key + "__" + tabData[1], tabData[0]);
-                        }
-                    } else {
-                        reData.put(key, tabVal);
                     }
                 }
             }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
         }
 
         // 获取默认值
@@ -1821,7 +1847,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(id, pkeyId);
         Map<String, Object> DataInfo = bussDataInfoTrial.stream().findAny().orElse(null);
 
-        // 获取excel流 和 html流
+        //获取excel流 和 html流
         Workbook wb = new Workbook();
         wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
         //获取工作表
@@ -2039,10 +2065,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     @Override
     public String getBussPDFSTrial(String nodeId, String tableType, String classify, String contractId, String projectId, Long id, String tabIds) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-        //获取有权限的节点信息
-        String sql = "select p_key_id,html_url,table_type from m_wbs_tree_private where is_deleted = 0 and p_key_id in (" + tabIds + ")";
+        //获取有权限的表的信息
+        String sql = "select p_key_id,html_url,table_type,sort,node_name,create_time from m_wbs_tree_private where is_deleted = 0 and p_key_id in (" + tabIds + ") order by sort,node_name,create_time";
         List<WbsTreePrivate> queryList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
-
         List<String> dataPdfUrls = new ArrayList<>();
 
         //报告单

+ 17 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaOptionServiceImpl.java

@@ -33,12 +33,24 @@ public class FormulaOptionServiceImpl extends ServiceImpl<FormulaOptionMapper, F
             FormulaOption fo = this.getOne(Wrappers.<FormulaOption>lambdaQuery().eq(FormulaOption::getParentId,parentId).eq(FormulaOption::getContractId,contractId));
             if(fo!=null&&wbc!=null){
                 JSONObject jo = JSON.parseObject(fo.getVal());
-                 if(jo.containsKey(pkeyId.toString())){
+                 if(jo.containsKey(wbc.getInitTableName())){
                      JSONObject tableJson=jo.getJSONObject(wbc.getInitTableName());
-                     if(tableJson.containsKey(pkeyId.toString())){
-                         JSONObject excel = tableJson.getJSONObject(pkeyId.toString());
-                         if(excel.containsKey(key)){
-                             return excel.getString(key);
+                     if(key.contains("__")){
+                         String cellKey= pkeyId+"@"+key;
+                         if(tableJson.containsKey(cellKey)){
+                             JSONObject excel = tableJson.getJSONObject(cellKey);
+                             if(excel.containsKey("TF")){
+                                 /*暂时只有TF:是或否*/
+                                 return excel.getString("TF");
+                             }
+                         }
+                     }else{
+                         if(tableJson.containsKey(key)){
+                             JSONObject excel = tableJson.getJSONObject(key);
+                             if(excel.containsKey("TF")){
+                                 /*暂时只有TF:是或否*/
+                                 return excel.getString("TF");
+                             }
                          }
                      }
 

+ 31 - 66
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -74,7 +74,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     /*元素标识*/
     public final static String E="E";
     /*公式参数*/
-    public final static String FMOT="FORMULA_OPTION";
+    public final static String FMOT="OP";
     /**表单信息*/
     public final static String TEXT_INFO_MAP="textInfoMap";
 
@@ -186,7 +186,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             for(String s:cki){
                 FormData fdTmp=this.formDataMap.get(s);
                 if(fdTmp!=null&&fdTmp.getValues().stream().map(ElementData::getValue).anyMatch(e->StringUtils.isNotEmpty(e)&&StringUtils.isNotEquals("/",e))){
-                    sb.append(fdTmp.getEName().split("[((].+[))]")[0]).append(",");
+                    sb.append(fdTmp.getEName().replaceAll("^[^\\u4e00-\\u9fa5]+","").split("[((].+[))]|_")[0]).append(",");
                 }
             }
             if(sb.length()>1){
@@ -424,18 +424,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                     continue;
                 }
                 String tmp =fd.getFormula().getFormula();
+                /*假如是直接取数,则补充上非空过滤*/
+                if(tmp.matches("^E\\[m__[0-9]{14}_[0-9]{19}:key_[0-9]{0,3}]$")){
+                    tmp="FC.removeEmpty("+tmp+")";
+                }
                 tmp = tmp.replace(FC, CustomFunction.CLASS_CALL);
-//                if(tmp.contains(CustomFunction.CLASS_CALL+"ifelse")){
-//                    Matcher im =IF.matcher(tmp);
-//                    while (im.find()){
-//                        String rep =im.group();
-//                        Matcher fm=P.matcher(rep);
-//                        while (fm.find()){
-//                            rep=rep.replace(fm.group(),"'"+fm.group()+"'");
-//                        }
-//                        tmp=tmp.replace(im.group(),rep);
-//                    }
-//                }
                 if(tmp.contains("E[")||tmp.contains("WP[")){
                     Matcher am = AP.matcher(tmp);
                     while (am.find()){
@@ -553,53 +546,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     }
 
     public  void write(FormData fd,Object data){
-        if(data instanceof List){
-            List<Object> values = (List<Object>) data;
-            if(values.size()>fd.getValues().size()){
-                /*当生成的数据超过实际容量的时候,会自动追加页数*/
-                if(fd.getCoordsList().size()==1){
-                    fd.getValues().get(0).setValue(values.stream().map(StringUtils::handleNull).collect(Collectors.joining("、")));
-                }else{
-                   // copy(fd,values);
-                    for(int n=0;n<fd.getValues().size();n++){
-                        fd.getValues().get(n).setValue(values.get(n));
-                    }
-                    List<Object> overList=values.stream().skip(fd.getValues().size()).collect(Collectors.toList());
-                    List<Coords> coordsList = fd.getCoordsList();
-                    int addPage=(int)Math.ceil((double)overList.size()/(double)coordsList.size());
-                    fd.setAddPages(addPage);
-                    ElementData last =fd.getValues().get(fd.getValues().size()-1);
-                    int indexBase=last.getIndex()+1;
-                    List<ElementData> addList= new ArrayList<>();
-                    for(int i=0;i<addPage;i++){
-                          for(int j=0;j<coordsList.size();j++){
-                              /*超页就尽管写进去,格式化阶段再加表*/
-                              Coords coords = coordsList.get(j);
-                              Object v=null;
-                              int st=i*coordsList.size()+j;
-                              if(st<overList.size()){
-                                 v= overList.get(st);
-                              }
-                              addList.add(new ElementData(indexBase+i,last.getGroupId(),v,coords.getX(),coords.getY()));
-                          }
-                    }
-                    fd.getValues().addAll(addList);
-                }
-
-            }else{
-                for(int n=0;n<values.size();n++){
-                    fd.getValues().get(n).setValue(values.get(n));
-                }
-            }
-        }else{
-            if(Formula.FULL.equals(fd.getFormula().getOutm())){
-                /*填充策略*/
-                fd.getValues().forEach(e->e.setValue(data));
-            }else{
-                fd.getValues().get(0).setValue(data);
-            }
-        }
-
+        /*如果需要向额外元素或对象输出数据,在此处修改*/
+               FormulaUtils.write(fd,data);
     }
 
     /**加页增容*/
@@ -673,11 +621,29 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                 }
             }
         }
+
+         try {
+             /*检验单附表处理*/
+             List<FormData>  inspectionList= new ArrayList<>();
+             this.tec.getTableAll().stream().filter(e->e.getNodeName().contains("检验单")).forEach(e->{
+                 this.tec.getKeyMappers().stream().filter(p->p.getPkId().equals(e.getPKeyId())).forEach(k->{
+                     this.formDataMap.values().stream().filter(f->f.getCode().equals(k.getCode())&&f.getAddPages()>0).forEach(inspectionList::add);
+                 });
+             });
+             if(Func.isNotEmpty(inspectionList)){
+                 Map<String,List<ElementData>> overMap=new HashMap<>();
+                 inspectionList.forEach(f->{
+
+                 });
+             }
+         }catch (Exception e){
+             e.printStackTrace();
+         }
+
         /*检查超页情况*/
         this.formDataMap.values().stream().filter(e->e.getUpdate()==1&&e.getAddPages()>0).sorted(Comparator.comparing(FormData::getAddPages).reversed())
                         .collect(Collectors.groupingBy(FormData::getTableName,LinkedHashMap::new,Collectors.toList())).values()
-                        .forEach(l->copy(l.get(0)));;
-
+                        .forEach(l->copy(l.get(0)));
     }
 
     @Override
@@ -843,9 +809,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                            Optional<KeyMapper> kOp=tec.getKeyMappers().stream().filter(e->StringUtils.isEquals(e.getCode(),fd.getCode())).findFirst();
                            if(kOp.isPresent()){
                                /*表名+合同段+父节点*/
-                               Map<String,Object> optionMap = (Map<String, Object>) this.constantMap.computeIfAbsent(FMOT,k->new HashMap<>());
-                               String findStr=fd.getTableName()+"['"+fd.getKey()+"']['TF']";
-                               flag=StringUtils.handleNull(Expression.parse(findStr).calculate(optionMap));
+                               String findStr="OP['"+fd.getTableName()+"']['"+fd.getKey()+"']['TF']";
+                               flag=StringUtils.handleNull(Expression.parse(findStr).calculate(this.constantMap));
                            }
                        }else if(flag.contains("E[")){
                            List<FormData> target = getFormDataByCode(flag);
@@ -853,7 +818,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                               flag= target.get(0).getValues().stream().map(ElementData::stringValue).filter(StringUtils::isNotEmpty).findFirst().orElse("0");
                            }
                        }
-                       if(Func.isBlank(flag)){
+                       if(Func.isBlank(flag)||"OPTION".equals(flag)){
                            /*默认0*/
                            flag="0";
                        }

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

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.google.common.collect.Lists;
+import com.mysql.cj.x.protobuf.MysqlxDatatypes;
 import lombok.AllArgsConstructor;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
@@ -33,6 +34,7 @@ import org.springblade.manager.vo.*;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -1512,6 +1514,32 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
 
     }
 
+    /**
+     * 批量重新保存文件htmlUrl
+     * @param wbsTreePrivateList
+     */
+    @Async
+    @Override
+    public void batchResetHtmlUrl(List<WbsTreePrivate> wbsTreePrivateList) throws IOException, InterruptedException {
+        if (wbsTreePrivateList != null) {
+            //存在htmlUrl才重新保存
+            wbsTreePrivateList = wbsTreePrivateList.stream().filter(wtp -> StringUtils.isNotBlank(wtp.getHtmlUrl())).collect(Collectors.toList());
+            String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+            //批量复制保存html
+            for (WbsTreePrivate tree : wbsTreePrivateList) {
+                File file_in = ResourceUtil.getFile(tree.getHtmlUrl());
+                String fileCode = SnowFlakeUtil.getId() + "";
+                String htmlUrl = file_path + "/privateUrlCopy/" + fileCode + ".html";
+//                String htmlUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrlCopy\\" + fileCode + ".html";
+                File file_out = ResourceUtil.getFile(htmlUrl);
+                FileUtil.copy(file_in, file_out);
+                tree.setHtmlUrl(htmlUrl);
+            }
+            //批量修改
+            baseMapper.updateBatchByPKeyId(wbsTreePrivateList);
+        }
+    }
+
     @Override
     public R addWbsTreeContractInfo(String nodeId, String primaryKeyIds, long contractId) {
         if (com.alibaba.cloud.commons.lang.StringUtils.isEmpty(nodeId)) {
@@ -1562,7 +1590,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                     .last("limit 1"));
             //如果存在则复制最新表的配置,调整表单的值
             if (wbsTreePrivate != null) {
-                if (StringUtils.isNotEmpty(wbsTreePrivate.getExcelId().toString())) {
+                if (wbsPrivate.getExcelId() != null) {
                     wbsPrivate.setExcelId(wbsTreePrivate.getExcelId());
                 }
                 if (StringUtils.isNotEmpty(wbsTreePrivate.getHtmlUrl())){

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

@@ -807,7 +807,8 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                                     wbsTreePrivateService.insertBatch(addList, 1000);
                                 }, executor)).toArray(CompletableFuture[]::new));
                         handle.join();
-
+                        //异步修改htmlUrl ,数据都在inserData2里
+                        wbsTreePrivateService.batchResetHtmlUrl(insertData2);
                         //修改状态
                         if (pawDTO.getWbsType() == 1) {
                             projectInfoMapper.updateTemplateInfoQuality(pawDTO.getProjectId(), pawDTO.getPrimaryKeyId(), "private");