浏览代码

试验自检、电签默认信息相关

liuyc 2 年之前
父节点
当前提交
54b53b2161
共有 23 个文件被更改,包括 555 次插入281 次删除
  1. 16 0
      blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java
  2. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSelfInspectionRecordDTO.java
  3. 1 2
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java
  4. 9 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/SampleAncillaryDocumentsVO.java
  5. 8 5
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/TableFile.java
  6. 28 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/TrialSelfDataRecord.java
  7. 17 4
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/ExcelTabClient.java
  8. 2 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/TableFileClient.java
  9. 26 6
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java
  10. 1 0
      blade-service/blade-business/src/main/java/org/springblade/business/feignClient/InformationQueryClientImpl.java
  11. 62 13
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  12. 19 13
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TableFileController.java
  13. 195 107
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java
  14. 3 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java
  15. 28 30
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java
  16. 3 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TableFileMapper.java
  17. 8 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TableFileMapper.xml
  18. 2 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IExcelTabService.java
  19. 2 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/ITableFileService.java
  20. 6 6
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreePrivateService.java
  21. 67 60
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
  22. 14 16
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TableFileServiceImpl.java
  23. 35 8
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

+ 16 - 0
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -170,4 +170,20 @@ public class CommonUtil {
         return batchIds;
     }
 
+    /**
+     * @param src
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    public static <T> List<T> deepCopy(List<T> src) throws IOException, ClassNotFoundException {
+        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream(byteOut);
+        out.writeObject(src);
+        ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
+        ObjectInputStream in = new ObjectInputStream(byteIn);
+        @SuppressWarnings("unchecked")
+        List<T> dest = (List<T>) in.readObject();
+        return dest;
+    }
+
 }

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

@@ -20,4 +20,7 @@ public class TrialSelfInspectionRecordDTO extends TrialSelfInspectionRecord {
     @ApiModelProperty(value = "引用设备仪器ids")
     private String deviceUseIds;
 
+    @ApiModelProperty(value = "是否批量保存 0=单保存,1=批量保存")
+    private Integer isBatchSave;
+
 }

+ 1 - 2
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java

@@ -2,7 +2,6 @@ package org.springblade.business.feign;
 
 import com.alibaba.fastjson.JSONObject;
 import org.springblade.common.constant.BusinessConstant;
-import org.springblade.core.secure.BladeUser;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -47,7 +46,7 @@ public interface InformationQueryClient {
                                             @RequestParam String firstFileName,
                                             @RequestBody List<JSONObject> linkDataList);
 
-    @PostMapping(API_PREFIX + "/saveData")
+    @PostMapping(API_PREFIX + "/informationQuerySaveData")
     void saveData(@RequestParam String nodeId, @RequestParam String projectId, @RequestParam String contractId, @RequestParam String classify, @RequestParam String link, @RequestParam String trialProjectName);
 
     @PostMapping(API_PREFIX + "/updateInformationQuery")

+ 9 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/SampleAncillaryDocumentsVO.java

@@ -18,10 +18,19 @@ public class SampleAncillaryDocumentsVO implements Serializable {
     @ApiModelProperty(value = "生产合格证")
     private String productionCertificate;
 
+    @ApiModelProperty(value = "生产合格证名称")
+    private String productionCertificateName;
+
     @ApiModelProperty(value = "厂家质检报告")
     private String qualityInspectionReport;
 
+    @ApiModelProperty(value = "厂家质检报告名称")
+    private String qualityInspectionReportName;
+
     @ApiModelProperty(value = "其他附件")
     private String otherAccessories;
 
+    @ApiModelProperty(value = "其他附件名称")
+    private String otherAccessoriesName;
+
 }

+ 8 - 5
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/TableFile.java

@@ -20,17 +20,15 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.io.Serializable;
-
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
-import lombok.NoArgsConstructor;
-import org.springblade.core.mp.base.BaseEntity;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
 
 /**
  * 表单附件信息实体类
@@ -88,4 +86,9 @@ public class TableFile implements Serializable {
 	@ApiModelProperty(value = "是否已删除")
 	private Integer isDeleted;
 
+	/**
+	 * 试验记录id
+	 */
+	private Long trialRecordId;
+
 }

+ 28 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/TrialSelfDataRecord.java

@@ -0,0 +1,28 @@
+package org.springblade.manager.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+@Data
+@TableName("u_trial_self_data_record")
+public class TrialSelfDataRecord implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    private Long recordId;
+
+    private Long tabId;
+
+    private Integer isBussShow;
+
+    private Integer isTabPdf;
+
+    private Integer isTabFileType;
+
+    private String pdfUrl;
+
+}

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

@@ -1,7 +1,6 @@
 package org.springblade.manager.feign;
 
 import com.alibaba.fastjson.JSONObject;
-import org.springblade.core.tool.api.R;
 import org.springblade.manager.entity.ExcelTab;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -22,12 +21,26 @@ public interface ExcelTabClient {
     ExcelTab getById(@RequestParam String id);
 
     @PostMapping(API_PREFIX + "/saveTabData")
-    String saveTabData(@RequestBody JSONObject dataInfo, @RequestParam Integer type, @RequestParam Integer tableType, @RequestParam Long id, @RequestParam String tabIds) throws Exception;
+    String saveTabData(@RequestParam Integer isBatchSave,
+                       @RequestBody JSONObject dataInfo,
+                       @RequestParam Integer type,
+                       @RequestParam Integer tableType,
+                       @RequestParam Long id,
+                       @RequestParam String tabIds) throws Exception;
 
     @PostMapping(API_PREFIX + "/getBussPDFTrial")
-    void getBussPDFTrial(@RequestParam Long pkeyId) throws Exception;
+    void getBussPDFTrial(@RequestParam Long pkeyId,
+                         @RequestParam String contractId,
+                         @RequestParam String id) throws Exception;
 
     @PostMapping(API_PREFIX + "/getBussPDFSTrial")
-    void getBussPDFSTrial(@RequestParam String nodeId, @RequestParam String tableType, @RequestParam String classify, @RequestParam String contractId, @RequestParam String projectId, @RequestParam String id) throws Exception;
+    String getBussPDFSTrial(@RequestParam String nodeId,
+                            @RequestParam String tableType,
+                            @RequestParam String classify,
+                            @RequestParam String contractId,
+                            @RequestParam String projectId,
+                            @RequestParam String id,
+                            @RequestParam String tabIds) throws Exception;
+
 
 }

+ 2 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/TableFileClient.java

@@ -3,6 +3,7 @@ package org.springblade.manager.feign;
 import org.springblade.manager.entity.TableFile;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import static org.springblade.core.launch.constant.AppConstant.APPLICATION_NAME_PREFIX;
 
@@ -16,6 +17,6 @@ public interface TableFileClient {
     String API_PREFIX = "/api/manager/tableFile";
 
     @PostMapping(API_PREFIX + "/saveFile")
-    void saveFile(TableFile tableFile);
+    void saveFile(@RequestBody TableFile tableFile);
 
 }

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

@@ -22,8 +22,11 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.manager.entity.TableFile;
+import org.springblade.manager.entity.TrialSelfDataRecord;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.feign.WbsTreePrivateClient;
+import org.springblade.manager.vo.TableFileVO;
 import org.springblade.manager.vo.WbsTreePrivateVO;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -162,12 +165,13 @@ public class TrialDetectionController extends BladeController {
 
     @GetMapping("/get-buss-pdf")
     @ApiOperationSupport(order = 17)
-    @ApiOperation(value = "自检单表PDF预览", notes = "传入pKeyId")
-    public R<Object> getBussPdfById(@RequestParam Long pKeyId) {
-        List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateClient.queryByPKeyIds(Func.toStrList(String.valueOf(pKeyId)));
-        WbsTreePrivate wbsTreePrivate = wbsTreePrivates.stream().findAny().orElse(null);
-        assert wbsTreePrivate != null;
-        return R.data(wbsTreePrivate.getPdfUrl());
+    @ApiOperation(value = "自检单表PDF预览", notes = "传入pKeyId、记录id")
+    public R<Object> getBussPdfById(@RequestParam Long id, @RequestParam Long pKeyId) {
+        String sql = "select * from u_trial_self_data_record where record_id = " + id + " and tab_id = " + pKeyId;
+        List<TrialSelfDataRecord> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+        TrialSelfDataRecord obj = query.stream().findAny().orElse(null);
+        assert obj != null;
+        return R.data(obj.getPdfUrl());
     }
 
     @GetMapping("/get-buss-pdfs")
@@ -244,4 +248,20 @@ public class TrialDetectionController extends BladeController {
         return R.data(iTrialSelfInspectionRecordService.addBussFile(file, pkeyId, nodeId, contractId, projectId, classify, id, tableType));
     }
 
+    @GetMapping("/self/file-list")
+    @ApiOperationSupport(order = 25)
+    @ApiOperation(value = "元素表附件列表", notes = "元素表附件列表")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "pkeyid", value = "表单pkeyid", required = true),
+            @ApiImplicitParam(name = "id", value = "试验记录id")
+    })
+    public R fileList(Long pkeyid, Long id) {
+        String sql = "select *,domain_url as url from m_table_file where is_deleted = 0 and type = 2 and tab_id = " + pkeyid + " and trial_record_id = " + id;
+        List<TableFileVO> fileVOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TableFileVO.class));
+        if (fileVOList.size() > 0) {
+            return R.data(fileVOList);
+        }
+        return R.fail(200, "未查询到数据");
+    }
+
 }

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

@@ -53,6 +53,7 @@ public class InformationQueryClientImpl implements InformationQueryClient {
         obj.setProjectId(Long.valueOf(projectId));
         obj.setContractId(Long.valueOf(contractId));
         obj.setClassify(Integer.valueOf(classify));
+        obj.setType(2); //试验
         obj.setPdfUrl(link);
         obj.setName(trialProjectName);
         iInformationQueryService.save(obj);

+ 62 - 13
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -37,6 +37,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.*;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.feign.*;
+import org.springblade.resource.entity.Attach;
 import org.springblade.resource.feign.CommonFileClient;
 import org.springblade.resource.feign.IOSSClient;
 import org.springblade.resource.feign.NewIOSSClient;
@@ -156,6 +157,23 @@ public class TrialSelfInspectionRecordServiceImpl
                 }
             }
         }
+
+        String sql = "select link,original_name from blade_attach";
+        List<Attach> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Attach.class));
+        for (SampleAncillaryDocumentsVO sampleAncillaryDocumentsVO : result) {
+            for (Attach attach : query) {
+                if (sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
+                    sampleAncillaryDocumentsVO.setOtherAccessoriesName(attach.getOriginalName());
+                }
+                if (sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
+                    sampleAncillaryDocumentsVO.setProductionCertificateName(attach.getOriginalName());
+                }
+                if (sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
+                    sampleAncillaryDocumentsVO.setQualityInspectionReportName(attach.getOriginalName());
+                }
+            }
+        }
+
         return result;
     }
 
@@ -166,9 +184,15 @@ public class TrialSelfInspectionRecordServiceImpl
         if (ObjectUtil.isEmpty(trialMaterialMobilization)) {
             throw new ServiceException("未获取到对应材料信息,修改失败");
         }
-        trialMaterialMobilization.setQualityInspectionReport(vo.getQualityInspectionReport());
-        trialMaterialMobilization.setOtherAccessories(vo.getOtherAccessories());
-        trialMaterialMobilization.setProductionCertificate(vo.getProductionCertificate());
+        if (StringUtils.isNotEmpty(vo.getQualityInspectionReport())) {
+            trialMaterialMobilization.setQualityInspectionReport(vo.getQualityInspectionReport());
+        }
+        if (StringUtils.isNotEmpty(vo.getOtherAccessories())) {
+            trialMaterialMobilization.setOtherAccessories(vo.getOtherAccessories());
+        }
+        if (StringUtils.isNotEmpty(vo.getProductionCertificate())) {
+            trialMaterialMobilization.setProductionCertificate(vo.getProductionCertificate());
+        }
         trialMaterialMobilizationMapper.updateById(trialMaterialMobilization);
 
         return true;
@@ -382,8 +406,6 @@ 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 {
-        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-
         R<BladeFile> bladeFile = iossClient.addFileInfo(file);
         BladeFile bladeFile1 = bladeFile.getData();
         TableFile tableFile = new TableFile();
@@ -395,6 +417,8 @@ public class TrialSelfInspectionRecordServiceImpl
         tableFile.setIsDeleted(0);
         tableFile.setExtension(fileExtension);
 
+        tableFile.setTrialRecordId(Long.parseLong(id));
+
         NewBladeFile newBladeFile;
         if (fileExtension.contains("xlsx")) {
             newBladeFile = this.commonFileClient.excelToPdf(file);
@@ -416,13 +440,33 @@ public class TrialSelfInspectionRecordServiceImpl
         tableFileClient.saveFile(tableFile);
 
         //单个pdf
-        excelTabClient.getBussPDFTrial(pkeyId);
+        excelTabClient.getBussPDFTrial(pkeyId, contractId, id);
 
-        //修改tab_file_type = 2 、is_tab_pdf = 2
-        wbsTreePrivateClient.updateInfo(pkeyId);
+        //查找当前记录下所关联的表,用于合并时查询
+        TrialSelfInspectionRecord selfInspectionRecord = this.getBaseMapper().selectById(id);
 
-        //合并pdf
-        excelTabClient.getBussPDFSTrial(nodeId, tableType, classify, contractId, projectId, id);
+        String url = "";
+        if (StringUtils.isNotEmpty(selfInspectionRecord.getTableIds())) {
+            //合并pdf
+            url = excelTabClient.getBussPDFSTrial(nodeId, tableType, classify, contractId, projectId, id, selfInspectionRecord.getTableIds());
+
+            //修改按钮状态 is_tab_file_type = 2 、is_tab_pdf = 2
+            String sql = "select tab_id from m_table_file where trial_record_id = " + id + " group by tab_id";
+            List<TableFile> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TableFile.class));
+
+            for (TableFile tableFile1 : query) {  //TODO 修改一张表的状态,另一张修改失败
+                for (String tabId : Func.toStrList(selfInspectionRecord.getTableIds())) {
+                    if (tableFile1.getTabId().equals(tabId)) {
+                        String sqlUpdate = "update u_trial_self_data_record set is_tab_file_type = 2,is_tab_pdf = 2 where record_id = " + id + " and tab_id = " + tabId;
+                        jdbcTemplate.execute(sqlUpdate);
+                    }
+                }
+            }
+        }
+
+        //修改合并后的url路径地址
+        selfInspectionRecord.setPdfUrl(url);
+        this.updateById(selfInspectionRecord);
 
         return String.valueOf(tableFile.getId());
     }
@@ -497,7 +541,7 @@ public class TrialSelfInspectionRecordServiceImpl
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+    /*@Transactional(rollbackFor = Exception.class)*/
     public boolean selfSubmit(TrialSelfInspectionRecordDTO dto) throws Exception {
         if (ObjectUtil.isEmpty(dto.getId())) {
             //构建记录表编号、报告单编号
@@ -516,11 +560,16 @@ public class TrialSelfInspectionRecordServiceImpl
         String tableIdsAll = Func.toStr(tableIds).replaceAll("\\[", "").replaceAll("]", "");
         dto.setTableIds(tableIdsAll);
 
-        //新增或修改
+        /*//只修改基础信息,未修改表信息
+        if (dataArray.size() == 0) {
+            return this.saveOrUpdate(dto);
+        } TODO */
+
+        //关联新增或修改了表信息
         if (this.saveOrUpdate(dto)) {
             try {
                 //保存实体表数据、记录信息、生成pdf
-                String pdfURL = excelTabClient.saveTabData(dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), dto.getTableIds());
+                String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), dto.getTableIds());
                 //返回合并pdfURL
                 if (StringUtils.isNotEmpty(pdfURL)) {
                     LambdaUpdateWrapper<TrialSelfInspectionRecord> updateWrapper = new LambdaUpdateWrapper<>();

+ 19 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TableFileController.java

@@ -31,6 +31,8 @@ import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.service.IExcelTabService;
 import org.springblade.manager.service.IWbsTreeContractService;
 import org.springblade.manager.service.IWbsTreePrivateService;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springblade.manager.vo.TableFileVO;
@@ -59,6 +61,8 @@ public class TableFileController extends BladeController {
     // excel 基本信息表
     private final IExcelTabService excelTabService;
 
+    private final JdbcTemplate jdbcTemplate;
+
     /**
      * 删除 表单附件信息
      */
@@ -70,7 +74,7 @@ public class TableFileController extends BladeController {
         TableFile tableFile = tableFileService.getById(ids);
 
         // 删除数据
-        tableFileService.delDataById(ids);
+        tableFileService.delDataById(ids, null);
 
         List<TableFileVO> fileVOList = tableFileService.selectTableFileList(Long.parseLong(tableFile.getTabId()));
         // 该文本无附件
@@ -106,23 +110,24 @@ public class TableFileController extends BladeController {
      * 删除 表单附件信息 - 试验
      */
     @PostMapping("/remove-trial")
-    @ApiOperationSupport(order = 1)
+    @ApiOperationSupport(order = 2)
     @ApiOperation(value = "逻辑删除", notes = "传入当前文件ids、tableType、合同段Id、当前自检记录id")
     public R removeTrial(@RequestParam String ids, @RequestParam Integer tableType, @RequestParam String contractId, @RequestParam Long id) throws Exception {
         // 查出基本信息
         TableFile tableFile = tableFileService.getById(ids);
 
         // 删除数据
-        tableFileService.delDataById(ids);
+        tableFileService.delDataById(ids, id);
 
-        List<TableFileVO> fileVOList = tableFileService.selectTableFileList(Long.parseLong(tableFile.getTabId()));
-        // 该文本无附件
-        if (fileVOList == null || fileVOList.size() <= 0) {
-            UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
-            updateWrapper.in("p_key_id", tableFile.getTabId());
-            updateWrapper.set("tab_file_type", 1);
-            wbsTreePrivateService.update(updateWrapper);
+        String sql = "select *,domain_url as url from m_table_file where is_deleted = 0 and type = 2 and tab_id = " + ids + " and trial_record_id = " + id;
+        List<TableFileVO> fileVOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TableFileVO.class));
+
+        //该文本无附件,修改状态
+        if (fileVOList.size() <= 0) {
+            String updateSql = "update u_trial_self_data_record set is_tab_file_type = 1 where tab_id = " + ids + " and record_id = " + id;
+            jdbcTemplate.execute(updateSql);
         }
+
         Long pkeyId = Long.parseLong(tableFile.getTabId() + "");
         excelTabService.getBussPDFTrial(pkeyId, contractId, id);
 
@@ -140,7 +145,8 @@ public class TableFileController extends BladeController {
         } else if (dataInfo.equals("4") || dataInfo.equals("5") || dataInfo.equals("6")) {
             classify = "2";
         }
-        excelTabService.getBussPDFSTrial(wbsTreePrivate1.getPKeyId() + "", tableType, classify, contractId, wbsTreePrivate.getProjectId(), id);
+        excelTabService.getBussPDFSTrial(wbsTreePrivate1.getPKeyId() + "", tableType, classify, contractId, wbsTreePrivate.getProjectId(), id, tableFile.getTabId());
+
         return R.status(true);
     }
 
@@ -148,10 +154,10 @@ public class TableFileController extends BladeController {
      * 获取附件列表
      */
     @GetMapping("/get-buss-fileList")
-    @ApiOperationSupport(order = 2)
+    @ApiOperationSupport(order = 3)
     @ApiOperation(value = "获取附件列表", notes = "获取附件列表")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "pkeyid", value = "表单pkeyid", required = true)
+            @ApiImplicitParam(name = "pkeyid", value = "表单pkeyid", required = true),
     })
     public R getBussFileList(Long pkeyid) {
         List<TableFileVO> fileVOList = tableFileService.selectTableFileList(pkeyid);

+ 195 - 107
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/TextdictInfoController.java

@@ -32,6 +32,8 @@ import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.BladeUser;
@@ -40,10 +42,13 @@ import org.springblade.core.tool.utils.*;
 import org.springblade.manager.entity.WbsFormElement;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
+import org.springblade.manager.excel.WbsExcelBatchUtil;
 import org.springblade.manager.mapper.WbsTreePrivateMapper;
+import org.springblade.manager.utils.CopyUtil;
 import org.springblade.manager.vo.TextdictBy345VO;
 import org.springblade.manager.vo.TextdictDataInfoVO;
 import org.springblade.manager.vo.TextdictInfo_vo;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -61,6 +66,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 参数信息表 控制器
@@ -146,37 +152,66 @@ public class TextdictInfoController extends BladeController {
     /**
      * 删除 参数信息表
      */
-	@PostMapping("/remove")
-	@ApiOperationSupport(order = 7)
-	@ApiOperation(value = "逻辑删除", notes = "传入ids")
-	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) throws FileNotFoundException {
-
-         TextdictInfo textdictInfo = textdictInfoService.getById(ids);
-        if(textdictInfo.getType()==5){
-            // 获取 节点信息
-            WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(Long.parseLong(textdictInfo.getTabId()));
+    @PostMapping("/remove")
+    @ApiOperationSupport(order = 7)
+    @ApiOperation(value = "逻辑删除", notes = "传入ids")
+    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) throws FileNotFoundException {
+        //获取节点信息
+        TextdictInfo textdictInfo = textdictInfoService.getById(ids);
+        WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(Long.parseLong(textdictInfo.getTabId()));
+
+        //获取当前项目下引用相同模板的元素表信息
+        List<WbsTreePrivate> wbsTreePrivatesEqual = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
+                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreePrivate::getHtmlUrl, wbsTreePrivate.getHtmlUrl())
+                .eq(WbsTreePrivate::getStatus, 1));
+        List<Long> pKeyIds = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+        String pIds = StringUtils.join(pKeyIds, ",");
+
+        //获取当前项目下相同模板的默认、提示信息
+        String sql = "select * from m_textdict_info where tab_id in (" + pIds + ")";
+        List<TextdictInfo> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TextdictInfo.class));
+
+        List<String> delIds = new ArrayList<>();
+        for (TextdictInfo info : query) {
+            if (info.getName().equals(textdictInfo.getName())
+                    && info.getType().equals(textdictInfo.getType())
+                    && info.getColKey().equals(textdictInfo.getColKey())
+                    && info.getColName().equals(textdictInfo.getColName())
+                    && info.getSigRoleName().equals(textdictInfo.getSigRoleName())
+                    && info.getPyzbx() == textdictInfo.getPyzbx()
+                    && info.getPyzby() == textdictInfo.getPyzby()
+                    && !info.getId().equals(textdictInfo.getId())
+                    && !info.getTabId().equals(textdictInfo.getTabId())) {
+                delIds.add(info.getId().toString());
+            }
+        }
 
-            // 读取html页面信息
+        if (textdictInfo.getType() == 5) {
+            //读取html页面信息
             File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
             String htmlString = IoUtil.readToString(new FileInputStream(file1));
-            // 样式集合
+            //样式集合
             Document doc = Jsoup.parse(htmlString);
             //解析
             Element table = doc.select("table").first();
             Elements trs = table.select("tr");
-            String trtd[] = textdictInfo.getColKey().split("__");
-            Element element = trs.get(Integer.parseInt(trtd[1].split("_")[0])).select("td").get(Integer.parseInt(trtd[1].split("_")[1]));
-            if(element.html().indexOf("el-tooltip")>=0){
-                Element newele = element.children().get(0).children().get(0);
-                element.empty().append(newele+"");
-                File writefile = new File(wbsTreePrivate.getHtmlUrl());
-                FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
+            String trTd[] = textdictInfo.getColKey().split("__");
+            Element element = trs.get(Integer.parseInt(trTd[1].split("_")[0])).select("td").get(Integer.parseInt(trTd[1].split("_")[1]));
+            if (element.html().indexOf("el-tooltip") >= 0) {
+                Element newEle = element.children().get(0).children().get(0);
+                element.empty().append(newEle + "");
+                File writeFile = new File(wbsTreePrivate.getHtmlUrl());
+                FileUtil.writeToFile(writeFile, doc.html(), Boolean.parseBoolean("UTF-8"));
             }
         }
 
-        textdictInfoService.deleDataInfoById(ids);
-		return R.success("成功");
-	}
+        //批量删除
+        delIds.add(ids);
+        textdictInfoService.getBaseMapper().deleteBatchIds(delIds);
+
+        return R.success("成功");
+    }
 
 
     /**
@@ -244,13 +279,13 @@ public class TextdictInfoController extends BladeController {
             List<TextdictInfo_vo> optionList = textdictInfo.getTextInfo();
             if (optionList != null && optionList.size() >= 1) {
                 JSONArray objs = new JSONArray();
-                for (int i = 0; i < optionList.size(); i++){
+                for (int i = 0; i < optionList.size(); i++) {
                     JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("key",optionList.get(i).getDictValue());
-                    jsonObject.put("name",optionList.get(i).getDictValue());
+                    jsonObject.put("key", optionList.get(i).getDictValue());
+                    jsonObject.put("name", optionList.get(i).getDictValue());
                     objs.add(jsonObject);
                 }
-                String checkbox = "<hc-form-checkbox-group :objs='"+objs+"'  @change='checkboxGroupChange' :val=" + vmode + " v-model=" + vmode + " keyname=" + keyname + " weighing=" + weighing + " placeholder=" + placeholder + " trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + "> </hc-form-checkbox-group>";
+                String checkbox = "<hc-form-checkbox-group :objs='" + objs + "'  @change='checkboxGroupChange' :val=" + vmode + " v-model=" + vmode + " keyname=" + keyname + " weighing=" + weighing + " placeholder=" + placeholder + " trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + "> </hc-form-checkbox-group>";
                 element.empty().append(checkbox);
             }
         } else if (textdictInfo.getTextId().equals("date")) { // 日期--年月日时分秒
@@ -261,22 +296,20 @@ public class TextdictInfoController extends BladeController {
             element.empty().append("<el-time-picker v-model=" + vmode + " type='date' format='HH:mm:ss' value-format='HH:mm:ss' placeholder=" + placeholder + " keyname=" + keyname + " weighing=" + weighing + "  @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%'   placeholder='" + placeholder + "'> </el-time-picker>");
         } else if (textdictInfo.getTextId().equals("dateSM")) { // 日期--时分
             element.empty().append("<el-time-picker v-model=" + vmode + " type='date' format='HH:mm' value-format='HH:mm' placeholder=" + placeholder + " keyname=" + keyname + " weighing=" + weighing + "  @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%'   placeholder='" + placeholder + "'> </el-time-picker>");
-        }else if (textdictInfo.getTextId().equals("dateMDHM")) { // 日期--月日时分
+        } else if (textdictInfo.getTextId().equals("dateMDHM")) { // 日期--月日时分
             element.empty().append("<el-date-picker v-model=" + vmode + " type='datetime' format='MM月DD日 HH:mm' value-format='MM-DD HH:mm' placeholder=" + placeholder + " keyname=" + keyname + " weighing=" + weighing + "  @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%'   placeholder='" + placeholder + "'> </el-time-picker>");
-        }else if (textdictInfo.getTextId().equals("dateDHM")) { // 日期--日时分
+        } else if (textdictInfo.getTextId().equals("dateDHM")) { // 日期--日时分
             element.empty().append("<el-date-picker v-model=" + vmode + " type='datetime' format='DD日 HH:mm' value-format='DD HH:mm' placeholder=" + placeholder + " keyname=" + keyname + " weighing=" + weighing + "  @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%'   placeholder='" + placeholder + "'> </el-time-picker>");
-        }
-
-        else if (textdictInfo.getTextId().equals("daterange")) { // 时间段
+        } else if (textdictInfo.getTextId().equals("daterange")) { // 时间段
             element.empty().append("<el-date-picker  v-model=" + vmode + " type='datetimerange' placeholder=" + placeholder + "  start-placeholder='开始日期'  end-placeholder='结束日期' format='YYYY年MM月DD日' trIndex=" + trindex + " keyname=" + keyname + " weighing=" + weighing + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + ">");
             element.children().get(0).attr("@change", "datePickerChange($event,'" + keyname + "')");
         } else if (textdictInfo.getTextId().equals("daterangeYMD")) { // 时间段 /
             element.empty().append("<el-date-picker  v-model=" + vmode + " type='datetimerange' range-separator='/' placeholder=" + placeholder + "  start-placeholder='开始日期'  end-placeholder='结束日期' format='YYYY年MM月DD日' trIndex=" + trindex + " keyname=" + keyname + " weighing=" + weighing + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + ">");
             element.children().get(0).attr("@change", "datePickerChange($event,'" + keyname + "')");
 
-        }else if (textdictInfo.getTextId().equals("img")) {
-            element.empty().append("<hc-table-form-upload :src='" + vmode + "' placeholder=" + placeholder + " v-model=" + vmode + "  keyName=" + keyname + " weighing=" + weighing + "  @success='formUploadSuccess' @del='delTableFormFile' trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" +y2+"></hc-table-form-upload> ");
-        }else if (textdictInfo.getTextId().equals("searchSelect")) { //搜索框
+        } else if (textdictInfo.getTextId().equals("img")) {
+            element.empty().append("<hc-table-form-upload :src='" + vmode + "' placeholder=" + placeholder + " v-model=" + vmode + "  keyName=" + keyname + " weighing=" + weighing + "  @success='formUploadSuccess' @del='delTableFormFile' trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + "></hc-table-form-upload> ");
+        } else if (textdictInfo.getTextId().equals("searchSelect")) { //搜索框
             element.empty().append("<hc-form-select-search type='dap_site_data' :val=" + vmode + " contractId=''  pkeyId='' @change='formRemoteChange' v-model=" + vmode + " placeholder=" + placeholder + " keyname=" + keyname + " weighing=" + weighing + "  @contextmenu.prevent.native='RightClick(" + parm + ")' trIndex=" + trindex + " tdIndex=" + tdindex + "  x1=" + x1 + " x2=" + x2 + " y1=" + y1 + " y2=" + y2 + " style='width:100%;height:100%' > </hc-form-select-search>");
         }
         element.attr("@click", "getInformation(" + oncklickText + ")");
@@ -288,7 +321,7 @@ public class TextdictInfoController extends BladeController {
         String tabName = wbsTreePrivate.getInitTableName();
         String isExitSql = " select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
         List<Map<String, Object>> tablist = jdbcTemplate.queryForList(isExitSql);
-        if (tablist != null && tablist.size() > 0 && wbsTreePrivate.getType()!=10) {
+        if (tablist != null && tablist.size() > 0 && wbsTreePrivate.getType() != 10) {
             String clarSql = "update  " + tabName + " set " + keyname.split("__")[0] + "=null where p_key_id in(SELECT p_key_id FROM m_wbs_tree_contract WHERE id ='" + wbsTreePrivate.getId() + "' and project_id='" + wbsTreePrivate.getProjectId() + "' )";
             jdbcTemplate.execute(clarSql);
         }
@@ -304,15 +337,24 @@ public class TextdictInfoController extends BladeController {
     @ApiOperationSupport(order = 7)
     @ApiOperation(value = "保存电签", notes = "保存电签")
     public R<String> saveSigInfo(@Valid @RequestBody JSONObject dataInfo) throws IOException {
-
         JSONArray jsonArray = dataInfo.getJSONArray("dataInfo");
         Long tableId = dataInfo.getLong("tabId");
-        // 删除
-        textdictInfoService.getBaseMapper().delete(Wrappers.<TextdictInfo>query().lambda()
-                .eq(TextdictInfo::getTabId, tableId).in(TextdictInfo::getType,2,6));
-
 
+        //当前清表信息
         WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(tableId);
+
+        //获取当前项目下引用相同模板的元素表信息
+        List<WbsTreePrivate> wbsTreePrivatesEqual = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
+                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreePrivate::getHtmlUrl, wbsTreePrivate.getHtmlUrl())
+                .eq(WbsTreePrivate::getStatus, 1));
+        List<Long> pKeyIds = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+        String ids = StringUtils.join(pKeyIds, ",");
+
+        //删除引用当前模板所有电签信息
+        String delSql = "delete from m_textdict_info where tab_id in(" + ids + ") and type in(2,6)";
+        jdbcTemplate.execute(delSql);
+
         // 读取html页面信息
         File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
         String htmlString = IoUtil.readToString(new FileInputStream(file1));
@@ -325,56 +367,64 @@ public class TextdictInfoController extends BladeController {
         Elements trs = table.select("tr");
 
         Elements onlyInfo = doc.select("[:readonly]");
-        if(onlyInfo!=null && onlyInfo.size()>=1){
-            for(Element element :onlyInfo ){
-                 element.removeAttr(":readonly");
-             }
+        if (onlyInfo != null && onlyInfo.size() >= 1) {
+            for (Element element : onlyInfo) {
+                element.removeAttr(":readonly");
+            }
         }
 
         Elements tryInfo = doc.select("td[dqid]");
-        if(tryInfo!=null && tryInfo.size()>=1){
-            for(Element element :tryInfo ){
+        if (tryInfo != null && tryInfo.size() >= 1) {
+            for (Element element : tryInfo) {
                 element.removeAttr("dqid");
             }
         }
 
-        if(jsonArray==null || jsonArray.size()==0 ){
+        if (jsonArray == null || jsonArray.size() == 0) {
             return R.success("操作成功");
         }
-        List<TextdictInfo> textdictInfos = new ArrayList<>();
-
-        for (int i = 0; i < jsonArray.size(); i++) {
-            JSONObject jsonObject = jsonArray.getJSONObject(i);
-            TextdictInfo textdictInfo = new TextdictInfo();
-            String[] trtd = jsonObject.getString("colKey").split("__")[1].split("_");
-            Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
-
-            String id = element.children().get(0).attr("keyname");
-            textdictInfo.setName("电签位置配置");
-            textdictInfo.setType(jsonObject.getInteger("type"));
-            textdictInfo.setColKey(id);
-            textdictInfo.setSigRoleId(jsonObject.getString("sigRoleId"));
-            textdictInfo.setTabId(jsonObject.getString("tabId"));
-            textdictInfo.setColName(jsonObject.getString("colName"));
-            textdictInfo.setSigRoleName(jsonObject.getString("sigRoleName"));
-            textdictInfo.setPyzbx(jsonObject.getDouble("pyzbx"));
-            textdictInfo.setPyzby(jsonObject.getDouble("pyzby"));
-            textdictInfo.setIsDeleted(0);
-            textdictInfoService.saveOrUpdate(textdictInfo);
-            element.removeAttr("dqId");
-            element.attr("dqId", textdictInfo.getId() + "");
-            if(jsonObject.getInteger("type")==2){ //个人签字 不能用户输入
-                if (element.html().indexOf("el-tooltip") >= 0) {
-                    element.children().get(0).children().get(0).attr(":readonly","true");
-                }else{
-                    element.children().get(0).attr(":readonly","true");
+
+        //当前项目下引用相同清表,同步保存电签信息
+        for (Long pKeyId : pKeyIds) {
+            for (int i = 0; i < jsonArray.size(); i++) {
+                JSONObject jsonObject = jsonArray.getJSONObject(i);
+                TextdictInfo textdictInfo = new TextdictInfo();
+                String[] trtd = jsonObject.getString("colKey").split("__")[1].split("_");
+                Element element = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
+
+                String id = element.children().get(0).attr("keyname");
+
+                textdictInfo.setId(SnowFlakeUtil.getId());
+                textdictInfo.setName("电签位置配置");
+                textdictInfo.setType(jsonObject.getInteger("type"));
+                textdictInfo.setColKey(id);
+                textdictInfo.setSigRoleId(jsonObject.getString("sigRoleId"));
+
+                textdictInfo.setTabId(pKeyId.toString());
+
+                textdictInfo.setColName(jsonObject.getString("colName"));
+                textdictInfo.setSigRoleName(jsonObject.getString("sigRoleName"));
+                textdictInfo.setPyzbx(jsonObject.getDouble("pyzbx"));
+                textdictInfo.setPyzby(jsonObject.getDouble("pyzby"));
+                textdictInfo.setIsDeleted(0);
+                textdictInfoService.saveOrUpdate(textdictInfo);
+
+                element.removeAttr("dqId");
+                element.attr("dqId", textdictInfo.getId() + "");
+                if (jsonObject.getInteger("type") == 2) { //个人签字 不能用户输入
+                    if (element.html().indexOf("el-tooltip") >= 0) {
+                        element.children().get(0).children().get(0).attr(":readonly", "true");
+                    } else {
+                        element.children().get(0).attr(":readonly", "true");
+                    }
                 }
             }
         }
 
-        // 写入 excel
-        File writefile = new File(wbsTreePrivate.getHtmlUrl());
-        FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
+        //写入excel
+        File writeFile = new File(wbsTreePrivate.getHtmlUrl());
+        FileUtil.writeToFile(writeFile, doc.html(), Boolean.parseBoolean("UTF-8"));
+
         return R.success("操作成功");
     }
 
@@ -384,20 +434,27 @@ public class TextdictInfoController extends BladeController {
     @PostMapping("/save_defaulVal")
     @ApiOperationSupport(order = 7)
     @ApiOperation(value = "保存默认值", notes = "保存默认值")
-    public R<String> saveDefaulVal(@Valid @RequestBody TextdictBy345VO textdictInfo) throws IOException {
+    public R<String> saveDefaulVal(@Valid @RequestBody TextdictBy345VO textdictInfo) throws IOException, ClassNotFoundException {
+        //当前清表信息
         WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(textdictInfo.getTableId());
 
-        // 读取html页面信息
+        //获取当前项目下引用相同模板的元素表信息
+        List<WbsTreePrivate> wbsTreePrivatesEqual = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
+                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreePrivate::getHtmlUrl, wbsTreePrivate.getHtmlUrl())
+                .eq(WbsTreePrivate::getStatus, 1));
+        List<Long> pKeyIds = wbsTreePrivatesEqual.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+
+        //读取html页面信息
         File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
         String htmlString = IoUtil.readToString(new FileInputStream(file1));
-        // 样式集合
+        //样式集合
         Document doc = Jsoup.parse(htmlString);
         //解析
         Element table = doc.select("table").first();
         Elements trs = table.select("tr");
         Element element = trs.get(textdictInfo.getTrIndex()).select("td").get(textdictInfo.getTdIndex());
 
-        //
         String placeholder = "";
         String id = element.children().get(0).attr("keyname");
         if (element.html().indexOf("el-tooltip") >= 0) {
@@ -408,41 +465,71 @@ public class TextdictInfoController extends BladeController {
             id = element.children().get(0).attr("keyname");
         }
 
-        TextdictInfo textdictBean = new TextdictInfo();
-        textdictBean.setIsDeleted(0);
-        textdictBean.setTabId(textdictInfo.getTableId() + "");
+        //查询当前类型该表的所有默认 或 提示信息
+        List<TextdictInfo> textDictInfosOld = textdictInfoService.getBaseMapper().selectList(Wrappers.<TextdictInfo>lambdaQuery()
+                .eq(TextdictInfo::getTabId, textdictInfo.getTableId())
+                .eq(TextdictInfo::getType, textdictInfo.getType()));
 
-        textdictBean.setColKey(id);
-        textdictBean.setColName(placeholder);
-        textdictBean.setSigRoleName(textdictInfo.getTextId());
+        for (Long pKeyId : pKeyIds) {
 
-        if (textdictInfo.getType() == 4) { //默认值
-            textdictBean.setType(4);
-            textdictBean.setName("编辑默认值");
-        }
-        if (textdictInfo.getType() == 5) { // 提示语
-            textdictBean.setType(5);
-            textdictBean.setName("提示信息");
-            String lastHmtl = "";
-            if (element.html().indexOf("el-tooltip") >= 0) {
-                element.children().attr("content", textdictInfo.getTextId());
-            } else {
-                lastHmtl = " <el-tooltip content='" + textdictInfo.getTextId() + "' placement='top' effect='customized'>" + element.html() + "</el-tooltip>";
-                element.empty().append(lastHmtl);
+            List<TextdictInfo> textDictInfosNew = CommonUtil.deepCopy(textDictInfosOld);
+
+            TextdictInfo textDictBean = new TextdictInfo();
+            textDictBean.setColKey(id);
+            textDictBean.setColName(placeholder);
+            textDictBean.setSigRoleName(textdictInfo.getTextId());
+            textDictBean.setIsDeleted(0);
+
+            if (textdictInfo.getType() == 4) { //默认值
+                textDictBean.setType(4);
+                textDictBean.setName("编辑默认值");
+            }
+
+            if (textdictInfo.getType() == 5) { // 提示语
+                textDictBean.setType(5);
+                textDictBean.setName("提示信息");
+                String lastHtml = "";
+                if (element.html().indexOf("el-tooltip") >= 0) {
+                    element.children().attr("content", textdictInfo.getTextId());
+                } else {
+                    lastHtml = " <el-tooltip content='" + textdictInfo.getTextId() + "' placement='top' effect='customized'>" + element.html() + "</el-tooltip>";
+                    element.empty().append(lastHtml);
+                }
+                File writeFile = new File(wbsTreePrivate.getHtmlUrl());
+                FileUtil.writeToFile(writeFile, doc.html(), Boolean.parseBoolean("UTF-8"));
+            }
+
+            textDictInfosNew.add(textDictBean);
+
+            //重新构造赋值
+            if (textDictBean.getType() == 4) {
+                for (TextdictInfo obj : textDictInfosNew) {
+                    obj.setId(SnowFlakeUtil.getId());
+                    obj.setTabId(pKeyId.toString());
+                    obj.setType(4);
+                    obj.setName("编辑默认值");
+                }
+            } else if (textDictBean.getType() == 5) {
+                for (TextdictInfo obj : textDictInfosNew) {
+                    obj.setId(SnowFlakeUtil.getId());
+                    obj.setTabId(pKeyId.toString());
+                    obj.setType(5);
+                    obj.setName("提示信息");
+                }
             }
-            File writefile = new File(wbsTreePrivate.getHtmlUrl());
-            FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
-        }
 
-        // 删除
-        textdictInfoService.getBaseMapper().delete(Wrappers.<TextdictInfo>query().lambda().eq(TextdictInfo::getTabId, textdictInfo.getTableId())
-                .eq(TextdictInfo::getType, textdictInfo.getType()).eq(TextdictInfo::getColKey, id));
+            //删除当前类型
+            textdictInfoService.getBaseMapper().delete(Wrappers.<TextdictInfo>query().lambda()
+                    .eq(TextdictInfo::getTabId, pKeyId)
+                    .eq(TextdictInfo::getType, textdictInfo.getType()));
 
-        textdictInfoService.saveOrUpdate(textdictBean);
+            //批量新增
+            textdictInfoService.saveBatch(textDictInfosNew);
+        }
         return R.success("操作成功");
     }
 
-/*	public static void main(String[] args) throws FileNotFoundException {
+    /*public static void main(String[] args) throws FileNotFoundException {
 		File file1 = ResourceUtil.getFile("/Users/hongchuangyanfa/Desktop/privateUrl/1567789917445029888.html");
 		String htmlString =  IoUtil.readToString(new FileInputStream(file1));
 		// 样式集合
@@ -463,4 +550,5 @@ public class TextdictInfoController extends BladeController {
 
 		System.out.println();
 	}*/
+
 }

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

@@ -571,9 +571,9 @@ public class WbsTreePrivateController extends BladeController {
      */
     @GetMapping("/search-node-tables")
     @ApiOperationSupport(order = 22)
-    @ApiOperation(value = "试验-根据所属方查询当前节点表信息", notes = "传入节点primaryKeyId、所属方type=1施工,=2监理 ;表单类型tableType=1记录表,=2报告单; 合同段id、项目id")
-    public R<List<WbsTreePrivate>> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId) {
-        return R.data(wbsTreePrivateService.searchNodeAllTable(primaryKeyId, type, tableType, contractId, projectId));
+    @ApiOperation(value = "试验-根据所属方查询当前节点表信息", notes = "传入节点primaryKeyId、所属方type=1施工,=2监理 ;表单类型tableType=1记录表,=2报告单; 合同段id、项目id、isAdd=是否新增、记录id")
+    public R<List<WbsTreePrivate>> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId, Integer isAdd, Long id) {
+        return R.data(wbsTreePrivateService.searchNodeAllTable(primaryKeyId, type, tableType, contractId, projectId, isAdd, id));
     }
 
     /**

+ 28 - 30
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -3,26 +3,23 @@ package org.springblade.manager.feign;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.AllArgsConstructor;
-import org.springblade.business.entity.TrialSelfInspectionRecord;
-import org.springblade.core.tool.api.R;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.bean.TableInfo;
 import org.springblade.manager.entity.ExcelTab;
-import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.service.IExcelTabService;
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.Iterator;
 import java.util.List;
-import java.util.stream.Collectors;
 
 @RestController
 @AllArgsConstructor
 public class ExcelTabClientImpl implements ExcelTabClient {
 
     private final IExcelTabService excelTabService;
+    private final JdbcTemplate jdbcTemplate;
 
     @Override
     public ExcelTab getById(String id) {
@@ -30,8 +27,7 @@ public class ExcelTabClientImpl implements ExcelTabClient {
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public String saveTabData(JSONObject dataInfo, Integer type, Integer tableType, Long id, String tabIds) throws Exception {
+    public String saveTabData(Integer isBatchSave, JSONObject dataInfo, Integer type, Integer tableType, Long id, String tabIds) throws Exception {
         //通用参数
         JSONArray dataArray = dataInfo.getJSONArray("orderList");
         JSONObject table = dataArray.getJSONObject(0);
@@ -41,8 +37,9 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
 
         String pdfUrl = "";
-        if (dataArray.size() == 1) {
-            //单表PDF
+
+        //单表PDF保存
+        if (isBatchSave == 0) {
             //保存数据到数据库-试验,当前记录id作为groupId
             this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);
             try {
@@ -55,10 +52,11 @@ public class ExcelTabClientImpl implements ExcelTabClient {
             //单表PDF
             TableInfo tableInfo = tableInfoList.stream().findAny().orElse(null);
             assert tableInfo != null;
-            pdfUrl = excelTabService.getBussPDFTrial(Long.valueOf(tableInfo.getPkeyId()), contractId, id);
+            if (tableInfo.getPkeyId().equals(tabIds)) {
+                excelTabService.getBussPDFTrial(Long.valueOf(tableInfo.getPkeyId()), contractId, id);
+            }
 
-        } else if (dataArray.size() > 1) {
-            //多表PDF
+        } else if (isBatchSave == 1) { //多表PDF保存
             //保存数据到数据库-试验,当前记录id作为groupId
             this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);
             try {
@@ -70,34 +68,34 @@ public class ExcelTabClientImpl implements ExcelTabClient {
 
             //多表合并PDF
             pdfUrl = excelTabService.getBussPDFSTrial(nodeId,
-                    tableType, //tableType = 表类型 1=记录表 2=报告单
-                    String.valueOf(type), //type = 所属方 1=施工质检 2=监理抽检
-                    contractId,
-                    projectId,
-                    id //记录id
+                    tableType, //tableType=表类型 1=记录表 2=报告单
+                    String.valueOf(type), //type=所属方 1=施工质检 2=监理抽检
+                    contractId, //合同段id
+                    projectId, //项目id
+                    id,  //记录id
+                    tabIds //新增的表的pKeyIds
             );
-        } else {
-            //没有表关联,只修改记录信息
-            return pdfUrl;
         }
 
         return pdfUrl;
     }
 
     @Override
-    public void getBussPDFTrial(Long pkeyId) throws Exception {
-        excelTabService.getBussPDFTrial(pkeyId, null, null);
+    public void getBussPDFTrial(Long pkeyId, String contractId, String id) throws Exception {
+        excelTabService.getBussPDFTrial(pkeyId, contractId, Long.parseLong(id));
     }
 
     @Override
-    public void getBussPDFSTrial(String nodeId, String tableType, String classify, String contractId, String projectId, String id) throws Exception {
+    public String getBussPDFSTrial(String nodeId, String tableType, String classify, String contractId, String projectId, String id, String tabIds) throws Exception {
         //合并PDF加载
-        excelTabService.getBussPDFSTrial(nodeId,
-                Integer.parseInt(tableType), //tableType = 表类型 1=记录表 2=报告单
-                classify, //type = 所属方 1=施工质检 2=监理抽检
-                contractId,
-                projectId,
-                Long.parseLong(id)); //记录id
+        return excelTabService.getBussPDFSTrial(nodeId,
+                Integer.parseInt(tableType), //tableType=表类型 1=记录表 2=报告单
+                classify, //type=所属方 1=施工质检 2=监理抽检
+                contractId, //合同段id
+                projectId, //项目id
+                Long.parseLong(id), //记录id
+                tabIds //新增的表的pKeyIds
+        );
     }
 
 

+ 3 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TableFileMapper.java

@@ -20,6 +20,7 @@ import org.springblade.manager.entity.TableFile;
 import org.springblade.manager.vo.TableFileVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+
 import java.util.List;
 
 /**
@@ -39,8 +40,8 @@ public interface TableFileMapper extends BaseMapper<TableFile> {
 	 */
 	List<TableFileVO> selectTableFilePage(IPage page, TableFileVO tableFile);
 
-	List<TableFileVO> selectTableFileList(String pkid);
+	List<TableFileVO> selectTableFileList(Long pKid);
 
-	void delDataById(String id);
+	void delDataById(String id, Long recordId);
 
 }

+ 8 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/TableFileMapper.xml

@@ -12,6 +12,7 @@
         <result column="extension" property="extension"/>
         <result column="type" property="type"/>
         <result column="domain_pdf_url" property="domainPdfUrl"/>
+        <result column="trial_record_id" property="trialRecordId"/>
     </resultMap>
 
     <resultMap id="TableFileVO" type="org.springblade.manager.vo.TableFileVO">
@@ -24,6 +25,7 @@
         <result column="type" property="type"/>
         <result column="domain_pdf_url" property="domainPdfUrl"/>
         <result column="url" property="url"/>
+        <result column="trial_record_id" property="trialRecordId"/>
     </resultMap>
 
 
@@ -32,10 +34,14 @@
     </select>
 
     <select id="selectTableFileList" resultMap="TableFileVO">
-        select *,domain_url as url from m_table_file where is_deleted = 0 and type=2 and tab_id =#{pkid}
+        select *,domain_url as url from m_table_file where is_deleted = 0 and type=2 and tab_id = #{pKid}
     </select>
 
     <delete id="delDataById" >
-        delete  from m_table_file where id=#{id}
+        delete from m_table_file where id= #{id}
+        <if test="recordId != null and recordId != ''">
+            and trial_record_id = #{recordId}
+        </if>
     </delete>
+
 </mapper>

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

@@ -110,6 +110,7 @@ public interface IExcelTabService extends BaseService<ExcelTab> {
 
 
     // 试验
+
     /**
      * 结果信息持久化 - 试验
      */
@@ -128,7 +129,7 @@ public interface IExcelTabService extends BaseService<ExcelTab> {
     /**
      * 多PDF 合并 - 试验
      */
-    String getBussPDFSTrial(String nodeId, Integer tableType, String classify, String contractId, String projectId, Long id) throws Exception;
+    String getBussPDFSTrial(String nodeId, Integer tableType, String classify, String contractId, String projectId, Long id, String tabIds) throws Exception;
 
 
     /**

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

@@ -41,8 +41,8 @@ public interface ITableFileService extends IService<TableFile> {
 	 */
 	IPage<TableFileVO> selectTableFilePage(IPage<TableFileVO> page, TableFileVO tableFile);
 
-	List<TableFileVO> selectTableFileList(long pkid);
+	List<TableFileVO> selectTableFileList(Long pKid);
 
-	void delDataById(String pkid);
+	void delDataById(String pkid,Long id);
 
 }

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

@@ -28,7 +28,7 @@ public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
     IPage<TreeNodeVOByTabType> tabTypeLazyTree(IPage<TreeNodeVOByTabType> page, Long parentId, String projectId, String titleName);
 
     // 元素
-    IPage<TreeNodeVOByTabType> tabTypeLazyTreeAll(IPage<TreeNodeVOByTabType> page, Long parentId,String titleName);
+    IPage<TreeNodeVOByTabType> tabTypeLazyTreeAll(IPage<TreeNodeVOByTabType> page, Long parentId, String titleName);
 
     List<WbsTreePrivateDTO2> findWbsTreePrivateSameLevel(String projectId, String parentId, String wbsId);
 
@@ -56,20 +56,20 @@ public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
 
     boolean syncNodeTable(String primaryKeyId);
 
-    R addWbsTreeContractInfo(String nodeId, String primaryKeyIds,long contractId);
+    R addWbsTreeContractInfo(String nodeId, String primaryKeyIds, long contractId);
 
     // 向项目添加元素
-    R addWbsTreeProjectInfo (String primaryKeyIds,String projectId);
+    R addWbsTreeProjectInfo(String primaryKeyIds, String projectId);
 
-    R delTabProjectById(String primaryKeyIds,String projectId);
+    R delTabProjectById(String primaryKeyIds, String projectId);
 
     // 元素删除
     R delTableById(String primaryKeyIds);
 
     // 元素关联
-    R saveLinkeTableInfo(String tabId,String linkids,String type,String wbsId);
+    R saveLinkeTableInfo(String tabId, String linkids, String type, String wbsId);
 
-    List<WbsTreePrivate> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId);
+    List<WbsTreePrivate> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId, Integer isAdd, Long id);
 
     Object getExcelHtml(String primaryKeyId) throws IOException;
 

+ 67 - 60
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -22,17 +22,17 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.mixsmart.utils.ListUtils;
 import com.spire.xls.*;
-import io.swagger.models.auth.In;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
-import org.springblade.business.entity.TrialSelfInspectionRecord;
+import org.springblade.business.entity.InformationQuery;
 import org.springblade.business.feign.ContractLogClient;
 import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.business.feign.OperationLogClient;
@@ -42,6 +42,7 @@ import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -51,16 +52,15 @@ import org.springblade.manager.bean.TableInfo;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.formula.KeyMapper;
 import org.springblade.manager.formula.impl.TableElementConverter;
+import org.springblade.manager.mapper.ExcelTabMapper;
 import org.springblade.manager.service.*;
 import org.springblade.manager.utils.FileUtils;
 import org.springblade.manager.vo.*;
-import org.springblade.manager.mapper.ExcelTabMapper;
-import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.cache.ParamCache;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.imageio.ImageIO;
@@ -69,10 +69,9 @@ import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.sql.SQLException;
 import java.text.SimpleDateFormat;
-import java.util.*;
 import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -1305,7 +1304,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
      * 试验 单pdf
      */
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public String getBussPDFTrial(Long pkeyId, String contractId, Long id) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
@@ -1494,7 +1492,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         FileUtils.excelToPdf(excelPath, pdfPath);
         BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
         TableFile tableFile1 = tableFileService.getBaseMapper().selectOne(Wrappers.<TableFile>query().lambda()
-                .eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getType, 1));
+                .eq(TableFile::getTabId, pkeyId + "")
+                .eq(TableFile::getType, 1)
+                .eq(TableFile::getTrialRecordId, id));
+
         if (tableFile1 != null) {
             tableFile1.setDomainPdfUrl(bladeFile.getLink());
             tableFileService.saveOrUpdate(tableFile1);
@@ -1508,58 +1509,70 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             tableFile.setIsDeleted(0);
             tableFile.setExtension(fileExtension);
             tableFile.setDomainPdfUrl(bladeFile.getLink());
+
+            tableFile.setTrialRecordId(id);
+
             tableFileService.saveOrUpdate(tableFile);
         }
 
-        List<TableFile> tableFileList = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getIsDeleted, 0));
-        tableFileList.sort(Comparator.comparing(TableFile::getType));
+        //获取当前试验记录的中的元素表的附件文件
+        List<TableFile> tableFileList = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda()
+                .eq(TableFile::getTabId, pkeyId + "")
+                .eq(TableFile::getTrialRecordId, id)
+        );
 
-        List<String> dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && (tableFile.getType() == 1 || tableFile.getType() == 2)).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
+        if (tableFileList.size() > 0) {
 
-        String pdfPath2 = file_path + "/pdf//" + pkeyId + "_2.pdf";
+            tableFileList.sort(Comparator.comparing(TableFile::getType));
 
-        File tabPdf2 = ResourceUtil.getFile(pdfPath2);
-        if (tabPdf2.exists()) {
-            tabPdf2.delete();
-        }
-        FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
+            List<String> dataListPdf = tableFileList.stream().filter(tableFile ->
+                    tableFile.getDomainPdfUrl() != null
+                            && (tableFile.getType() == 1 || tableFile.getType() == 2)
+            ).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
 
-        BladeFile bladeFile2 = newIOSSClient.uploadFile(pkeyId + "2.pdf", pdfPath2);
+            String pdfPath2 = file_path + "/pdf//" + pkeyId + "_2.pdf";
 
-        UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.in("p_key_id", pkeyId + "");
-        updateWrapper.set("pdf_url", bladeFile2.getLink());
-        wbsTreePrivateService.update(updateWrapper);
-        wb.dispose();
-        return bladeFile2.getLink();
+            File tabPdf2 = ResourceUtil.getFile(pdfPath2);
+            if (tabPdf2.exists()) {
+                tabPdf2.delete();
+            }
+            FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
+
+            BladeFile bladeFile2 = newIOSSClient.uploadFile(pkeyId + "2.pdf", pdfPath2);
+
+            //删除关系
+            String delSql = "delete from u_trial_self_data_record where record_id = " + id + " and tab_id = " + pkeyId;
+            jdbcTemplate.execute(delSql);
+
+            //新增关系
+            String sql = "insert into u_trial_self_data_record(id,record_id,tab_id,is_buss_show,is_tab_pdf,is_tab_file_type,pdf_url) values" +
+                    "(" + SnowFlakeUtil.getId() + "," + id + "," + pkeyId + "," + 1 + "," + 2 + "," + 1 + ",'" + bladeFile2.getLink() + "')";
+            jdbcTemplate.execute(sql);
+
+            wb.dispose();
+            return bladeFile2.getLink();
+        }
+
+        return "";
     }
 
     /**
      * 试验 多pdf
      */
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public String getBussPDFSTrial(String nodeId, Integer tableType, String classify, String contractId, String projectId, Long id) throws Exception {
+    public String getBussPDFSTrial(String nodeId, Integer tableType, String classify, String contractId, String projectId, Long id, String tabIds) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         //获取有权限的节点信息
-        List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateService.searchNodeAllTable(nodeId, classify, String.valueOf(tableType), contractId, projectId);
-
-        List<String> data = new ArrayList<>();
-        if (wbsTreePrivateList != null && wbsTreePrivateList.size() >= 1) {
-            for (WbsTreePrivate wbsInfo : wbsTreePrivateList) {
-                //隐藏的不生成pdf
-                if (wbsInfo.getIsBussShow() == null || wbsInfo.getIsBussShow() != 2) { //
-                    /*if (StringUtils.isNotEmpty(wbsInfo.getPdfUrl())) {
-                        data.add(wbsInfo.getPdfUrl());
-                    } else {*/
-
-                    //重新生成pdf
-                    String bussPdfInfo = this.getBussPDFTrial(wbsInfo.getPKeyId(), contractId, id);
-                    if (StringUtils.isNotEmpty(bussPdfInfo)) {
-                        data.add(bussPdfInfo);
-                    }
-                    //}
-
+        String sql = "select * from m_wbs_tree_private where is_deleted = 0 and p_key_id in (" + tabIds + ")";
+        List<WbsTreePrivate> queryList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+
+        List<String> dataPdfUrls = new ArrayList<>();
+        if (queryList.size() > 0) {
+            for (WbsTreePrivate record : queryList) {
+                //生成pdf
+                String bussPdfInfo = this.getBussPDFTrial(record.getPKeyId(), contractId, id);
+                if (StringUtils.isNotEmpty(bussPdfInfo)) {
+                    dataPdfUrls.add(bussPdfInfo);
                 }
             }
         }
@@ -1569,22 +1582,22 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         if (tabPdf2.exists()) {
             tabPdf2.delete();
         }
-        FileUtils.mergePdfPublicMethods(data, listPdf);
+        FileUtils.mergePdfPublicMethods(dataPdfUrls, listPdf);
         BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
 
         //获取试验记录id的试验项目名称
         String trialProjectName = baseMapper.selectTrialRecordOne(id);
 
         //合并PDF集合
-        String querySql = "select * from u_information_query where classify='" + classify + "' and  wbs_id='" + id + "' and contract_id ='" + contractId + "'";
-        List<Map<String, Object>> resultSQL = jdbcTemplate.queryForList(querySql);
-        if (resultSQL.size() > 0) {
-            String updateSql = "update u_information_query set pdf_url = '" + bladeFile.getLink() + "', name = '" + trialProjectName + "'  where classify='" + classify + "' and  wbs_id='" + id + "' and contract_id ='" + contractId + "'";
+        String querySql = "select * from u_information_query where classify ='" + classify + "' and wbs_id ='" + id + "' and contract_id ='" + contractId + "'";
+        List<InformationQuery> query = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(InformationQuery.class));
+        if (query.size() > 0) {
+            String updateSql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name ='" + trialProjectName + "'  where classify='" + classify + "' and  wbs_id='" + id + "' and contract_id ='" + contractId + "'";
             jdbcTemplate.execute(updateSql);
-            //informationQueryClient.updateInformationQuery(bladeFile.getLink(), classify, id.toString(), contractId);
         } else {
             informationQueryClient.saveData(id.toString(), projectId, contractId, classify, bladeFile.getLink(), trialProjectName);
         }
+
         return bladeFile.getLink();
     }
 
@@ -1592,8 +1605,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
      * 试验 保存修改信息
      */
     @Override
-    @Transactional
-    public void saveOrUpdateInfoTrial(List<TableInfo> tableInfoList, Long groupId) throws SQLException {
+    public void saveOrUpdateInfoTrial(List<TableInfo> tableInfoList, Long groupId) {
         //试验填报
         if (ListUtils.isNotEmpty(tableInfoList)) {
             try {
@@ -1605,8 +1617,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     }
 
                     String tabName = wbsTreePrivate.getInitTableName();
-                    // 判读修改还是 添加
-                    String delSql = "delete from " + tabName + " where p_key_id=" + tableInfo.getPkeyId() + " and group_id = " + groupId;
+                    //判读修改还是添加
+                    String delSql = "delete from " + tabName + " where p_key_id='" + tableInfo.getPkeyId() + "' and group_id = '" + groupId + "'";
                     jdbcTemplate.execute(delSql);
 
                     String sqlInfo = "";
@@ -1622,13 +1634,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     valStr = valStr.substring(0, valStr.lastIndexOf(","));
                     sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
 
-                    UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
-                    updateWrapper.in("p_key_id", tableInfo.getPkeyId());
-                    updateWrapper.set("is_tab_pdf", 2);
-                    wbsTreePrivateService.update(updateWrapper);
                     jdbcTemplate.execute(sqlInfo);
                 }
-
             } catch (Exception e) {
                 e.printStackTrace();
             }

+ 14 - 16
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TableFileServiceImpl.java

@@ -16,14 +16,13 @@
  */
 package org.springblade.manager.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springblade.manager.entity.TableFile;
-import org.springblade.manager.vo.TableFileVO;
 import org.springblade.manager.mapper.TableFileMapper;
 import org.springblade.manager.service.ITableFileService;
-import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.manager.vo.TableFileVO;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 
 import java.util.List;
 
@@ -36,20 +35,19 @@ import java.util.List;
 @Service
 public class TableFileServiceImpl extends ServiceImpl<TableFileMapper, TableFile> implements ITableFileService {
 
-	@Override
-	public IPage<TableFileVO> selectTableFilePage(IPage<TableFileVO> page, TableFileVO tableFile) {
-		return page.setRecords(baseMapper.selectTableFilePage(page, tableFile));
-	}
-
-	@Override
-	public List<TableFileVO> selectTableFileList(long pkid) {
+    @Override
+    public IPage<TableFileVO> selectTableFilePage(IPage<TableFileVO> page, TableFileVO tableFile) {
+        return page.setRecords(baseMapper.selectTableFilePage(page, tableFile));
+    }
 
-		return baseMapper.selectTableFileList(pkid+"");
-	}
+    @Override
+    public List<TableFileVO> selectTableFileList(Long pKid) {
+        return baseMapper.selectTableFileList(pKid);
+    }
 
-	@Override
-	public void delDataById(String pkid) {
-		 baseMapper.delDataById(pkid);
-	}
+    @Override
+    public void delDataById(String pkid, Long id) {
+        baseMapper.delDataById(pkid, id);
+    }
 
 }

+ 35 - 8
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -20,16 +20,18 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.constant.BladeConstant;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.*;
-import org.springblade.manager.dto.FormElementDTO2;
 import org.springblade.manager.dto.WbsTreeContractDTO;
 import org.springblade.manager.dto.WbsTreePrivateDTO2;
 import org.springblade.manager.dto.WbsTreePrivateDTO3;
 import org.springblade.manager.entity.*;
-
 import org.springblade.manager.mapper.*;
 import org.springblade.manager.service.ITableInfoService;
 import org.springblade.manager.service.IWbsTreePrivateService;
-import org.springblade.manager.vo.*;
+import org.springblade.manager.vo.TreeNodeVOByTabType;
+import org.springblade.manager.vo.WbsNodeTabAndParamVO;
+import org.springblade.manager.vo.WbsNodeTableVO;
+import org.springblade.manager.vo.WbsTreePrivateVO;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
@@ -40,7 +42,6 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 @Service
 @AllArgsConstructor
@@ -1346,7 +1347,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                 tree.setWbsId(wbsId);
 
                 this.submit2(tree);
-
             }
         } else if (type.equals("3")) {
             WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(Long.parseLong(tabId));
@@ -1378,7 +1378,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
     }
 
     @Override
-    public List<WbsTreePrivate> searchNodeAllTable(String primaryKeyId, String tableOwner, String tableType, String contractId, String projectId) {
+    public List<WbsTreePrivate> searchNodeAllTable(String primaryKeyId, String tableOwner, String tableType, String contractId, String projectId, Integer isAdd, Long id) {
         WbsTreePrivate wbsTreePrivate = baseMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
                 .eq(WbsTreePrivate::getPKeyId, primaryKeyId));
         if (wbsTreePrivate == null) {
@@ -1403,7 +1403,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         List<String> tableOwnerList = null;
         if (org.apache.commons.lang.StringUtils.isNotEmpty(tableOwner)) {
             String tableOwners = "";
-            //此处加载字典owner_type 固定写死 施工质检1= 1 2 3 , 监理抽检2= 4 5 6
+            //此处加载字典owner_type
             if (tableOwner.equals("1")) {
                 tableOwners = "1,2,3";
             } else if (tableOwner.equals("2")) {
@@ -1412,7 +1412,34 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
             tableOwnerList = Func.toStrList(tableOwners);
         }
 
-        return baseMapper.selectWbsTreeContractList(tableOwnerNumbers, tableType, wbsTreePrivate.getProjectId(), wbsTreePrivate.getWbsId(), wbsTreePrivate.getId(), tableOwnerList);
+        List<WbsTreePrivate> wbsTreePrivates = baseMapper.selectWbsTreeContractList(tableOwnerNumbers, tableType, wbsTreePrivate.getProjectId(), wbsTreePrivate.getWbsId(), wbsTreePrivate.getId(), tableOwnerList);
+
+        if (ObjectUtil.isNotEmpty(id)) { //编辑
+            //获取当前试验记录信息中的表状态
+            String sql = "select * from u_trial_self_data_record where record_id = " + id;
+            List<TrialSelfDataRecord> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+
+            for (WbsTreePrivate treePrivate : wbsTreePrivates) {
+                for (TrialSelfDataRecord record : query) {
+                    if (treePrivate.getPKeyId().equals(record.getTabId())){
+                        treePrivate.setIsBussShow(record.getIsBussShow());
+                        treePrivate.setIsTabPdf(record.getIsTabPdf());
+                        treePrivate.setTabFileType(record.getIsTabFileType());
+                    }
+                }
+            }
+            return wbsTreePrivates;
+        }
+
+        if (isAdd == 1 && ObjectUtil.isEmpty(id)) { //新增时处理按钮显示问题
+            for (WbsTreePrivate treePrivate : wbsTreePrivates) {
+                treePrivate.setPdfUrl(null);
+                treePrivate.setIsBussShow(1);
+                treePrivate.setIsTabPdf(1);
+                treePrivate.setTabFileType(1);
+            }
+        }
+        return wbsTreePrivates;
     }
 
     @Override