liuyc 2 лет назад
Родитель
Сommit
2c7fe504a2

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

@@ -116,9 +116,12 @@ public class InformationQuery extends BaseEntity {
     @ApiModelProperty("排序")
     private Integer sort;
 
-    @ApiModelProperty("pdf路径,引用试验记录后合并的pdf")
+    @ApiModelProperty("关联试验文件后合并的pdf路径")
     private String pdfTrialUrl;
 
+    @ApiModelProperty("关联工程部位信息后合并的pdf路径")
+    private String pdfTrialUrlPosition;
+
     @ApiModelProperty("首件关联工序资料ids")
     private String sjRecordIds;
 

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

@@ -1,6 +1,7 @@
 package org.springblade.business.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
@@ -17,26 +18,35 @@ import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.service.ITrialDetectionDataService;
 import org.springblade.business.service.ITrialSampleInfoService;
 import org.springblade.business.service.ITrialSelfInspectionRecordService;
+import org.springblade.business.utils.FileUtils;
 import org.springblade.business.vo.*;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
+import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
 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.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.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
+import java.io.File;
 import java.io.FileNotFoundException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -53,6 +63,7 @@ public class TrialDetectionController extends BladeController {
     private final ITrialSelfInspectionRecordService iTrialSelfInspectionRecordService;
     private final WbsTreePrivateClient wbsTreePrivateClient;
     private final JdbcTemplate jdbcTemplate;
+    private final NewIOSSClient newIOSSClient;
 
     @GetMapping("/data/detail")
     @ApiOperationSupport(order = 1)
@@ -92,7 +103,7 @@ public class TrialDetectionController extends BladeController {
     @PostMapping("/self/page")
     @ApiOperationSupport(order = 6)
     @ApiOperation(value = "自检记录分页查询", notes = "传入TrialSelfInspectionRecordPageDTO")
-    public R<IPage<TrialSelfInspectionRecordVO>> selfPage(@RequestBody Query query, @RequestBody TrialSelfInspectionRecordPageDTO dto) {
+    public R<IPage<TrialSelfInspectionRecordVO>> selfPage(@RequestBody Query query, @RequestBody TrialSelfInspectionRecordPageDTO dto) throws FileNotFoundException {
         return R.data(iTrialSelfInspectionRecordService.selfPage(Condition.getPage(query), dto));
     }
 
@@ -208,8 +219,8 @@ public class TrialDetectionController extends BladeController {
     @GetMapping("/get-buss-pdfs")
     @ApiOperationSupport(order = 18)
     @ApiOperation(value = "自检多表PDF预览", notes = "传入nodeId=试验记录id、classify、contractId、projectId")
-    public R<Object> getPDFs(String nodeId, String classify, String contractId, String projectId) {
-        String sql = "select pdf_url, e_visa_pdf_url from u_information_query where project_id ='" + projectId + "' and classify='" + classify + "' and  wbs_id='" + nodeId + "' and contract_id ='" + contractId + "'";
+    public R<Object> getPDFs(String nodeId, String classify, String contractId, String projectId) throws FileNotFoundException {
+        String sql = "select pdf_url,e_visa_pdf_url from u_information_query where project_id ='" + projectId + "' and classify='" + classify + "' and  wbs_id='" + nodeId + "' and contract_id ='" + contractId + "'";
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
         if (maps.size() >= 1) {
             Map<String, Object> stringObjectMap = maps.get(0);
@@ -219,11 +230,30 @@ public class TrialDetectionController extends BladeController {
                 pdfUrl = stringObjectMap.get("e_visa_pdf_url");
             }
 
-            //优先使用关联原材料检测报告的pdf(合并后的dpf都一样,取其一)
+            //关联原材料检测报告的pdf(合并后的dpf都一样,取其一)
             String sqlRecord = "select old_pdf_url from u_trial_raw_material_self_record where self_record_id =" + nodeId;
             TrialRawMaterialSelfRecord recordObj = jdbcTemplate.query(sqlRecord, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
-            if (recordObj != null && recordObj.getOldPdfUrl() != null) {
-                pdfUrl = recordObj.getOldPdfUrl();
+            if (pdfUrl != null && recordObj != null && recordObj.getOldPdfUrl() != null) {
+                String pdfUrlTrialRawMaterial = recordObj.getOldPdfUrl();
+                List<String> pdfList = new ArrayList<>();
+                //试验原始pdf
+                pdfList.add(pdfUrl.toString());
+                //材料检测报告pdf
+                pdfList.add(pdfUrlTrialRawMaterial);
+                //合并
+                String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                Long id = SnowFlakeUtil.getId();
+                String trialPdf = file_path + "/pdf/" + id + ".pdf";
+                File trialPdf2 = ResourceUtil.getFile(trialPdf);
+                if (trialPdf2.exists()) {
+                    trialPdf2.delete();
+                }
+                //合并当前所有选择的试验pdf
+                FileUtils.mergePdfPublicMethods(pdfList, trialPdf);
+                BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
+                if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                    pdfUrl = bladeFile.getLink();
+                }
             }
 
             return R.data(pdfUrl);
@@ -305,15 +335,6 @@ public class TrialDetectionController extends BladeController {
         return R.fail(200, "未查询到数据");
     }
 
-    @PostMapping("/self/project-position/submit")
-    @ApiOperationSupport(order = 26)
-    @ApiOperation(value = "自检记录关联工程部位信息保存", notes = "传入SelfProjectPositionSubmitDTO")
-    public R<Object> recordProjectPosition(@Valid @RequestBody SelfProjectPositionSubmitDTO dto) throws FileNotFoundException {
-        //TODO 已剥离,融合到批量审批中
-        //return R.status(iTrialSelfInspectionRecordService.recordProjectPosition(dto));
-        return R.status(true);
-    }
-
     @PostMapping("/self/record-sample/submit")
     @ApiOperationSupport(order = 27)
     @ApiOperation(value = "自检记录关联取样信息保存", notes = "传入RecordSampleSubmitDTO")

+ 8 - 3
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.java

@@ -2,6 +2,7 @@ package org.springblade.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.manager.entity.WbsTreeContract;
 
@@ -9,7 +10,7 @@ import java.util.List;
 
 public interface TrialSelfInspectionRecordMapper extends BaseMapper<TrialSelfInspectionRecord> {
 
-    List<TrialSelfInspectionRecord> selectAll(Long nodeId,Long contractId);
+    List<TrialSelfInspectionRecord> selectAll(Long nodeId, Long contractId);
 
     void saveSelfSample(Long id, Long selfId, String samplingId);
 
@@ -23,13 +24,13 @@ public interface TrialSelfInspectionRecordMapper extends BaseMapper<TrialSelfIns
 
     void delSelfQuality(Long id);
 
-    void saveSelfQuality(Long id, Long selfId, String qualityNodeId);
+    void saveSelfQuality(Long id, Long selfId, Long qualityNodeId);
 
     List<String> selectQualityNodeId(String id);
 
     String selectInformationQuery(String id, String contractId, String classify);
 
-    void updateInformationQuery(String id, String contractId, String classify, String link);
+    void updateInformationQuery(Long id, Long contractId,String link);
 
     void deleteSeletedStatusByNodeId(String nodeId, Integer type, String recordId);
 
@@ -40,4 +41,8 @@ public interface TrialSelfInspectionRecordMapper extends BaseMapper<TrialSelfIns
     List<String> selectSelectedStatusList(Long nodeId, String type);
 
     List<WbsTreeContract> selectWbsTreeContractListByPKeyIds(@Param("idList") List<String> ids);
+
+    @Select("select self_id from u_trial_self_quality_project where quality_node_id = #{pKeyId}")
+    List<String> selectTrialIdByNodeId(Long pKeyId);
+
 }

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.xml

@@ -45,7 +45,7 @@
     </insert>
 
     <update id="updateInformationQuery">
-        update u_information_query set pdf_url = #{link} where wbs_id = #{id} and classify = #{classify} and contract_id = #{contractId} and is_deleted = 0
+        update u_information_query set pdf_trial_url_position = #{link} where wbs_id = #{id} and contract_id = #{contractId} and is_deleted = 0
     </update>
 
     <delete id="delSelfSample">

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

@@ -13,7 +13,7 @@ import java.util.List;
 
 public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelfInspectionRecord> {
 
-    IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto);
+    IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) throws FileNotFoundException;
 
     String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException;
 
@@ -42,8 +42,6 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     boolean fileSubmit(TrialFileSubmitDTO dto) throws FileNotFoundException;
 
-    boolean recordProjectPosition(SelfProjectPositionSubmitDTO dto) throws FileNotFoundException;
-
     boolean recordSampleSubmit(RecordSampleSubmitDTO dto);
 
 }

+ 38 - 12
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -13,10 +13,7 @@ import org.slf4j.LoggerFactory;
 import org.springblade.business.entity.*;
 import org.springblade.business.mapper.TaskMapper;
 import org.springblade.business.service.*;
-import org.springblade.business.vo.BusinessUserOpinionVO;
-import org.springblade.business.vo.MessageWarningVO;
-import org.springblade.business.vo.TaskApprovalVO;
-import org.springblade.business.vo.TaskVO;
+import org.springblade.business.vo.*;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
@@ -42,6 +39,8 @@ import org.springblade.manager.entity.ProjectInfo;
 import org.springblade.manager.feign.ContractClient;
 import org.springblade.manager.feign.ProjectClient;
 import org.springframework.beans.BeanUtils;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -92,6 +91,8 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 
     private final UserOpinionServiceImpl userOpinionService;
 
+    private final JdbcTemplate jdbcTemplate;
+
     @Override
     public List<TaskParallel> queryApprovalUser(String formDataIds) {
         //返回结果
@@ -216,9 +217,34 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                     }
                 }
 
-            } else {
+            } else if (new Integer("1").equals(query.getType())) {
+                //资料填报
+                if (StringUtils.isNotEmpty(query.getEVisaPdfUrl()) || StringUtils.isNotEmpty(query.getPdfUrl()) || StringUtils.isNotEmpty(query.getPdfTrialUrl()) || StringUtils.isNotEmpty(query.getPdfTrialUrlPosition())) {
+                    //资料填报原始pdf
+                    vo.setApprovalFileList(query.getName(), StringUtils.isNotEmpty(query.getEVisaPdfUrl()) ? query.getEVisaPdfUrl() : query.getPdfUrl());
+
+                    //试验关联文件合并pdf
+                    if (StringUtils.isNotEmpty(query.getPdfTrialUrl())) {
+                        vo.setApprovalFileList(query.getName() + "(关联试验文件)", StringUtils.isNotEmpty(query.getPdfTrialUrl()) ? query.getPdfTrialUrl() : null);
+                    }
+
+                    //试验关联的工程部位信息合并pdf
+                    if (StringUtils.isNotEmpty(query.getPdfTrialUrlPosition())) {
+                        vo.setApprovalFileList(query.getName() + "(关联试验工程部位信息文件)", StringUtils.isNotEmpty(query.getPdfTrialUrlPosition()) ? query.getPdfTrialUrlPosition() : null);
+                    }
+                }
+            } else if (new Integer("2").equals(query.getType())) {
+                //试验
                 if (StringUtils.isNotEmpty(query.getEVisaPdfUrl()) || StringUtils.isNotEmpty(query.getPdfUrl())) {
+                    //试验原始pdf
                     vo.setApprovalFileList(query.getName(), StringUtils.isNotEmpty(query.getEVisaPdfUrl()) ? query.getEVisaPdfUrl() : query.getPdfUrl());
+
+                    //试验关联的原材料检测报告合并pdf (wbsId=试验记录id)
+                    String sqlRecord = "select old_pdf_url from u_trial_raw_material_self_record where self_record_id =" + query.getWbsId();
+                    TrialRawMaterialSelfRecord recordObj = jdbcTemplate.query(sqlRecord, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
+                    if (recordObj != null) {
+                        vo.setApprovalFileList(query.getName() + "(原材料检测报告)", StringUtils.isNotEmpty(recordObj.getOldPdfUrl()) ? recordObj.getOldPdfUrl() : null);
+                    }
                 }
             }
         }
@@ -351,21 +377,21 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
     }
 
     @Override
-    public List<String> queryBatchListThree(String projectId, String contractId,String type) {
-        if ("1".equals(type)){
+    public List<String> queryBatchListThree(String projectId, String contractId, String type) {
+        if ("1".equals(type)) {
             return baseMapper.queryBatchListThree(projectId, contractId);
-        }else if ("2".equals(type)){
+        } else if ("2".equals(type)) {
             return baseMapper.queryBatchListFlagFirst(projectId, contractId);
-        }else {
+        } else {
             return baseMapper.queryBatchListFirst(projectId, contractId);
         }
     }
 
     @Override
     public Map<String, String> queryContractAllBatch(String contract) {
-        Map<String,String> map = new HashMap<>();
-        baseMapper.queryContractAllBatch(contract).stream().forEach(task->{
-            map.put(task.getFormDataId(),task.getBatch()+"");
+        Map<String, String> map = new HashMap<>();
+        baseMapper.queryContractAllBatch(contract).stream().forEach(task -> {
+            map.put(task.getFormDataId(), task.getBatch() + "");
         });
         return map;
     }

+ 108 - 146
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -68,12 +68,10 @@ public class TrialSelfInspectionRecordServiceImpl
     private final IUserClient iUserClient;
     private final ContractClient contractClient;
     private final WbsTreePrivateClient wbsTreePrivateClient;
-    private final WbsTreeContractClient wbsTreeContractClient;
     private final ExcelTabClient excelTabClient;
     private final IDictClient iDictClient;
     private final JdbcTemplate jdbcTemplate;
     private final NewIOSSClient newIOSSClient;
-    private final InformationQueryClient informationQueryClient;
     private final IOSSClient iossClient;
     private final CommonFileClient commonFileClient;
     private final TableFileClient tableFileClient;
@@ -82,7 +80,7 @@ public class TrialSelfInspectionRecordServiceImpl
     private final TrialDetectionDataServiceImpl trialDetectionDataService;
 
     @Override
-    public IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) {
+    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());
@@ -142,13 +140,58 @@ public class TrialSelfInspectionRecordServiceImpl
                 record.setRawMaterialIds(org.apache.commons.lang.StringUtils.join(ids, ","));
 
                 //pdfUrl
-                record.setPdfUrl(Objects.requireNonNull(query1.stream().findAny().orElse(null)).getOldPdfUrl());
+                String pdf = this.getMergePdfToTrial(record.getContractId(), record.getId());
+                record.setPdfUrl(pdf);
             }
 
         }
         return trialSelfInspectionRecordVOIPage.setRecords(records);
     }
 
+    private String getMergePdfToTrial(Long contractId, Long nodeId) throws FileNotFoundException {
+        String sql = "select pdf_url,e_visa_pdf_url from u_information_query where wbs_id='" + nodeId + "' and contract_id ='" + contractId + "'";
+        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
+        if (maps.size() >= 1) {
+            Map<String, Object> stringObjectMap = maps.get(0);
+            Object pdfUrl = stringObjectMap.get("pdf_url");
+
+            if (stringObjectMap.get("e_visa_pdf_url") != null) {
+                //优先使用电签的pdf
+                pdfUrl = stringObjectMap.get("e_visa_pdf_url");
+            }
+
+            //关联原材料检测报告的pdf(合并后的dpf都一样,取其一)
+            String sqlRecord = "select old_pdf_url from u_trial_raw_material_self_record where self_record_id =" + nodeId;
+            TrialRawMaterialSelfRecord recordObj = jdbcTemplate.query(sqlRecord, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
+            if (pdfUrl != null && recordObj != null && recordObj.getOldPdfUrl() != null) {
+                String pdfUrlTrialRawMaterial = recordObj.getOldPdfUrl();
+                List<String> pdfList = new ArrayList<>();
+                //试验原始pdf
+                pdfList.add(pdfUrl.toString());
+                //材料检测报告pdf
+                pdfList.add(pdfUrlTrialRawMaterial);
+                //合并
+                String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                Long id = SnowFlakeUtil.getId();
+                String trialPdf = file_path + "/pdf/" + id + ".pdf";
+                File trialPdf2 = ResourceUtil.getFile(trialPdf);
+                if (trialPdf2.exists()) {
+                    trialPdf2.delete();
+                }
+                //合并当前所有选择的试验pdf
+                FileUtils.mergePdfPublicMethods(pdfList, trialPdf);
+                BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
+                if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                    pdfUrl = bladeFile.getLink();
+                    return pdfUrl.toString();
+                }
+            }
+            assert pdfUrl != null;
+            return pdfUrl.toString();
+        }
+        return "";
+    }
+
     @Override
     public List<SampleAncillaryDocumentsVO> selfAncillaryDocumentsList(String id) {
         //获取材料附件信息
@@ -306,7 +349,8 @@ public class TrialSelfInspectionRecordServiceImpl
 
     @Override
     @Async
-    public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto, TrialSelfInspectionRecord obj) throws FileNotFoundException {
+    public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto, TrialSelfInspectionRecord obj) throws
+            FileNotFoundException {
         if (ObjectUtil.isEmpty(dto.getId())) {
             throw new ServiceException("请先保存填报数据后,再关联原材检测报告信息");
         } else {
@@ -317,24 +361,15 @@ public class TrialSelfInspectionRecordServiceImpl
             //新增或编辑
             if (StringUtils.isNotEmpty(dto.getIds())) {
                 //当前关联的原材料记录id
-                List<String> idsNew = new ArrayList<>(Func.toStrList(dto.getIds()));
-                //当前记录id
-                idsNew.add(dto.getId());
-                //获取原材料的pdfUrl
+                List<String> ids = Func.toStrList(dto.getIds());
+
+                //获取原材料的pdf
                 List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
                         .select(TrialSelfInspectionRecord::getPdfUrl, TrialSelfInspectionRecord::getId)
-                        .in(TrialSelfInspectionRecord::getId, idsNew).eq(TrialSelfInspectionRecord::getStatus, 1));
-
-                //当前记录的pdf
-                TrialSelfInspectionRecord nowObj = recordList.stream().filter(f -> f.getId().equals(Long.parseLong(dto.getId()))).findAny().orElse(null);
-
-                //关联的原材料pdf
+                        .in(TrialSelfInspectionRecord::getId, ids).eq(TrialSelfInspectionRecord::getStatus, 1));
                 List<TrialSelfInspectionRecord> recordObjList = recordList.stream().filter(f -> !f.getId().equals(Long.parseLong(dto.getId()))).collect(Collectors.toList());
-
-                //合并pdf,切当前记录pdfUrl置顶,关联原材料pdfUrl文件置尾
                 List<String> pdfUrlAll = new ArrayList<>();
-                if (StringUtils.isNotEmpty(Objects.requireNonNull(nowObj).getPdfUrl()) && recordObjList.size() > 0) {
-                    pdfUrlAll.add(nowObj.getPdfUrl());
+                if (recordObjList.size() > 0) {
                     pdfUrlAll.addAll(recordObjList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList()));
                 }
 
@@ -352,7 +387,7 @@ public class TrialSelfInspectionRecordServiceImpl
                     String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
                     jdbcTemplate.execute(sql1);
                     //新增记录关系
-                    for (String recordId : idsNew) {
+                    for (String recordId : ids) {
                         if (!recordId.equals(dto.getId())) {
                             String sql2 = "insert into u_trial_raw_material_self_record(id,self_record_id,raw_material_record_id,old_pdf_url) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + recordId + ",'" + bladeFile.getLink() + "')";
                             jdbcTemplate.execute(sql2);
@@ -449,41 +484,35 @@ public class TrialSelfInspectionRecordServiceImpl
                                 .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
                         );
 
-                        //TODO ------审批通过且合格的自检记录信息,关联到工程部位信息的施工质检节点上去------
                         TrialSelfInspectionRecord record = baseMapper.selectById(trialSelfInspectionRecordId);
                         if (("已审批").equals(record.getTaskStatus()) && (new Integer(1)).equals(record.getDetectionResult()) && (new Integer(1)).equals(record.getDetectionCategory())) {
+                            /**
+                             * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存(如果当前资料填报工序节点有其他多个试验记录pdf关联信息,那么合并存储,否则直接存储)
+                             */
                             if (StringUtils.isNotEmpty(record.getProjectPosition())) {
-                                List<String> ids = Func.toStrList(record.getProjectPosition());
-
-                                //删除当前试验记录关联信息
-                                baseMapper.delSelfQuality(record.getId());
-
-                                for (String pKeyId : ids) {
-                                    //新增关联信息
-                                    baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), record.getId(), pKeyId);
-
-                                    //合并pdf到质检树节点
-                                    WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(pKeyId);
-                                    if (wbsTreeContract != null) {
-                                        List<String> pdfUrlList = new ArrayList<>();
-                                        String classify;
-
-                                        if (wbsTreeContract.getTableOwner().contains("1") || wbsTreeContract.getTableOwner().contains("2") || wbsTreeContract.getTableOwner().contains("3")) {
-                                            classify = "1";
-                                        } else {
-                                            classify = "2";
-                                        }
-
-                                        String pdfUrlNodeAll = baseMapper.selectInformationQuery(pKeyId, wbsTreeContract.getContractId(), classify);
-
-                                        if (StringUtils.isEmpty(pdfUrlNodeAll) || StringUtils.isEmpty(record.getPdfUrl())) {
+                                //有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;
                                         }
 
-                                        //质检节点pdfUrl
-                                        pdfUrlList.add(pdfUrlNodeAll);
-                                        //试验记录pdfUrl
-                                        pdfUrlList.add(record.getPdfUrl());
+                                        //如果当前工程部位节点的关联试验记录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";
@@ -491,12 +520,14 @@ public class TrialSelfInspectionRecordServiceImpl
                                         if (tabPDF.exists()) {
                                             tabPDF.delete();
                                         }
-                                        FileUtils.mergePdfPublicMethods(pdfUrlList, listPdf);
+
+                                        FileUtils.mergePdfPublicMethods(pdfS, listPdf);
                                         BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
                                         if (bladeFile != null) {
-                                            //修改质检树合并后的pdfUrl
-                                            baseMapper.updateInformationQuery(pKeyId, wbsTreeContract.getContractId(), classify, bladeFile.getLink());
+                                            //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
+                                            baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
                                         }
+
                                     }
                                 }
                             }
@@ -508,7 +539,8 @@ 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 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();
@@ -685,8 +717,8 @@ public class TrialSelfInspectionRecordServiceImpl
                 throw new ServiceException("保存实体表数据生成pdf时发生异常" + e.getMessage());
             }
 
-            //------关联工程及用途关系新增或删除------
-            if (StringUtils.isEmpty(obj.getProjectPosition())) {
+            //------关联工程及用途关系新增或删除------(已做修改,在审批修改状态时,再建立关联关系)
+            /*if (StringUtils.isEmpty(obj.getProjectPosition())) {
                 String delSql = "delete from u_trial_self_quality_project where self_id = " + obj.getId();
                 jdbcTemplate.execute(delSql);
             } else {
@@ -699,7 +731,7 @@ public class TrialSelfInspectionRecordServiceImpl
                     String insertSql = "insert into u_trial_self_quality_project(id,self_id,quality_node_id) values (" + SnowFlakeUtil.getId() + "," + obj.getId() + "," + recordNodeId + ")";
                     jdbcTemplate.execute(insertSql);
                 }
-            }
+            }*/
 
             //------关联原材料检测报告------
             RawMaterialSubmitRelationDTO relationDTO = new RawMaterialSubmitRelationDTO();
@@ -786,72 +818,6 @@ public class TrialSelfInspectionRecordServiceImpl
         return true;
     }
 
-    @Override
-    public boolean recordProjectPosition(SelfProjectPositionSubmitDTO dto) throws FileNotFoundException {
-        if (ObjectUtil.isEmpty(dto.getId())) {
-            throw new ServiceException("请先保存填报数据后,再关联工程部位及用途信息");
-        }
-        //已审批记录关联
-        if (StringUtils.isNotEmpty(dto.getProjectPosition())) {
-            TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
-            if (("已审批").equals(obj.getTaskStatus())) {
-                //删除关联信息
-                baseMapper.delSelfQuality(dto.getId());
-
-                List<String> ids = Func.toStrList(dto.getProjectPosition());
-                //新增关联信息
-                for (String id : ids) {
-                    baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), dto.getId(), id);
-                }
-
-                //把当前试验的PDF合并关联到质检树节点下
-                List<String> contractNodePKeyIds = baseMapper.selectQualityNodeId(String.valueOf(dto.getId())); //获取合同段质检树的节点PkeyId
-                for (String pKeyId : contractNodePKeyIds) {
-                    WbsTreeContract wbsTreeContract = wbsTreeContractClient.getContractNodeByPrimaryKeyId(pKeyId);
-                    if (wbsTreeContract != null) {
-                        List<String> pdfUrlList = new ArrayList<>();
-                        String classify;
-                        if (wbsTreeContract.getTableOwner().contains("1") || wbsTreeContract.getTableOwner().contains("2") || wbsTreeContract.getTableOwner().contains("3")) {
-                            classify = "1";
-                        } else {
-                            classify = "2";
-                        }
-                        String pdfUrlNodeAll = baseMapper.selectInformationQuery(pKeyId, wbsTreeContract.getContractId(), classify);
-
-                        if (StringUtils.isEmpty(pdfUrlNodeAll) || StringUtils.isEmpty(obj.getPdfUrl())) {
-                            continue;
-                        }
-
-                        //质检节点合并pdfUrl
-                        pdfUrlList.add(pdfUrlNodeAll);
-                        //试验pdfUrl
-                        pdfUrlList.add(obj.getPdfUrl());
-
-                        //合并PDF
-                        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(pdfUrlList, listPdf);
-                        BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
-                        if (bladeFile != null) {
-                            //修改质检树合并后的pdfURL
-                            baseMapper.updateInformationQuery(pKeyId, wbsTreeContract.getContractId(), classify, bladeFile.getLink());
-                        }
-                    }
-                }
-            } else {
-                throw new ServiceException("当前试验记录任务未上报审批,关联工程部位及用途信息失败");
-            }
-        } else {
-            //删除关联信息
-            baseMapper.delSelfQuality(dto.getId());
-        }
-        return true;
-    }
-
     private void buildNumber(TrialSelfInspectionRecordDTO dto) {
         StringSPUtils spUtils = new StringSPUtils();
         List<TrialSelfInspectionRecord> result = baseMapper.selectAll(dto.getNodeId(), dto.getContractId());
@@ -1011,7 +977,8 @@ public class TrialSelfInspectionRecordServiceImpl
         }
     }
 
-    public IPage<TrialSelfInspectionRecordVO> trialDataPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) {
+    public IPage<TrialSelfInspectionRecordVO> trialDataPage
+            (IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) {
         QueryWrapper<TrialSelfInspectionRecord> queryWrapper = Condition.getQueryWrapper(dto);
         if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getStartTime()) && org.apache.commons.lang.StringUtils.isNotEmpty(dto.getEndTime())) {
             String endTime = dto.getEndTime();
@@ -1070,10 +1037,12 @@ public class TrialSelfInspectionRecordServiceImpl
 
     @Override
     public boolean fileSubmit(TrialFileSubmitDTO dto) throws FileNotFoundException {
+        /**
+         * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存
+         */
         if (ObjectUtil.isEmpty(dto.getType())) {
             throw new ServiceException("请选择一个类型");
-        }
-        if (ObjectUtil.isEmpty(dto.getNodeId())) {
+        } else if (ObjectUtil.isEmpty(dto.getNodeId())) {
             throw new ServiceException("未获取到当前节点信息");
         }
 
@@ -1085,14 +1054,14 @@ public class TrialSelfInspectionRecordServiceImpl
                 .eq(InformationQuery::getType, 1)).stream().findAny().orElse(null);
 
         if (StringUtils.isNotEmpty(dto.getIds())) {
-            if (informationQuery != null && StringUtils.isNotEmpty(informationQuery.getPdfUrl())) {
-
+            if (informationQuery != null) {
                 List<String> pdfList = new ArrayList<>();
-
                 //------自检------
                 if (dto.getType().equals(1)) {
-                    //当前施工pdf
-                    pdfList.add(informationQuery.getPdfUrl());
+                    if (informationQuery.getPdfTrialUrl() != null) {
+                        //如果当前存在第三方、外委的pdf,那么拼接
+                        pdfList.add(informationQuery.getPdfTrialUrl());
+                    }
 
                     //自检pdf
                     List<TrialSelfInspectionRecord> trialSelfInspectionRecords = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
@@ -1103,13 +1072,9 @@ public class TrialSelfInspectionRecordServiceImpl
 
                     //------第三方、外委------
                 } else if (dto.getType().equals(2) || dto.getType().equals(3)) {
-
                     if (informationQuery.getPdfTrialUrl() != null) {
-                        //如果当前存在自检pdf,那么拼接
+                        //如果当前存在试验自检pdf,那么拼接
                         pdfList.add(informationQuery.getPdfTrialUrl());
-                    } else {
-                        //当前施工pdf
-                        pdfList.add(informationQuery.getPdfUrl());
                     }
 
                     //第三方、外委pdf
@@ -1124,11 +1089,10 @@ public class TrialSelfInspectionRecordServiceImpl
                         }
                     }
                     pdfList.addAll(pdfURLs);
-
                 }
 
                 if (pdfList.size() > 0) {
-                    //合并pdf把试验自检记录、第三方、外委的pdf追加到当前质检合同段树节点下的pdf后显示
+                    //合并试验自检、第三方、外委的pdf
                     List<String> collect = pdfList.stream().filter(Objects::nonNull).collect(Collectors.toList());
                     String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
                     String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
@@ -1181,14 +1145,12 @@ public class TrialSelfInspectionRecordServiceImpl
                     List<TrialSelfInspectionRecord> trialSelfInspectionRecords = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, ids));
                     List<String> pdfURLs = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
                     pdfList.addAll(pdfURLs);
-
                 }
 
-                if (pdfList.size() > 0) {
-                    //合并pdf把试验自检记录、第三方、外委的pdf追加到当前质检合同段树节点下的pdf后显示
+                if (pdfList.size() > 0 && informationQuery != null) {
+                    //重新合并
                     List<String> collect = pdfList.stream().filter(Objects::nonNull).collect(Collectors.toList());
                     String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                    assert informationQuery != null;
                     String listPdf = filePath + "/pdf/" + informationQuery.getId() + ".pdf";
                     File tabPDF = ResourceUtil.getFile(listPdf);
                     if (tabPDF.exists()) {
@@ -1197,7 +1159,7 @@ public class TrialSelfInspectionRecordServiceImpl
                     FileUtils.mergePdfPublicMethods(collect, listPdf);
                     BladeFile bladeFile = this.newIOSSClient.uploadFile(informationQuery.getId() + ".pdf", listPdf);
                     if (bladeFile != null) {
-                        //修改当前节点的pdfTrialURL地址
+                        //修改当前节点最新的pdfTrialURL地址
                         if (informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, bladeFile.getLink()).eq(InformationQuery::getId, informationQuery.getId()))) {
                             for (String recordId : recordIds) {
                                 baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), recordId); //先删除对应记录
@@ -1210,16 +1172,16 @@ public class TrialSelfInspectionRecordServiceImpl
 
             } else {
                 //修改pdfTrialUrl=null
-                assert informationQuery != null;
-                informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, null).eq(InformationQuery::getId, informationQuery.getId()));
+                if (informationQuery != null) {
+                    informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().set(InformationQuery::getPdfTrialUrl, null).eq(InformationQuery::getId, informationQuery.getId()));
+                }
             }
             //删除该类型的所有记录信息
             baseMapper.deleteSeletedStatusByNodeId(dto.getNodeId(), dto.getType(), null);
-
             return true;
         }
-
         return false;
     }
 
+
 }

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

@@ -18,6 +18,7 @@ import lombok.SneakyThrows;
 import org.apache.commons.codec.Charsets;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -1514,24 +1515,23 @@ public class ExcelTabController extends BladeController {
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "nodeId", value = "当前节点Id", required = true),
             @ApiImplicitParam(name = "classify", value = "填报的类型(施工或监理)", required = true),
-            @ApiImplicitParam(name = "projectId", value = "项目ID", required = true),
             @ApiImplicitParam(name = "contractId", value = "合同段Id", required = true)
     })
-    public R getpdfs(String nodeId, String classify, String contractId, String projectId) {
-        String sql = "select pdf_url, e_visa_pdf_url,pdf_trial_url from u_information_query  where classify='" + classify + "' and  wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' ";
-
+    public R getPdfS(String nodeId, String classify, String contractId) throws FileNotFoundException {
+        String sql = "select pdf_url,e_visa_pdf_url,pdf_trial_url,pdf_trial_url_position from u_information_query where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'";
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
-        if (maps != null && maps.size() >= 1) {
+        if (maps.size() >= 1) {
             Map<String, Object> stringObjectMap = maps.get(0);
             Object pdfUrl = stringObjectMap.get("pdf_url");
             if (stringObjectMap.get("e_visa_pdf_url") != null) {
-                //优先使用电签的PDF
+                //优先使用电签的pdf
                 pdfUrl = stringObjectMap.get("e_visa_pdf_url");
+
             }
 
-            if (stringObjectMap.get("pdf_trial_url") != null) {
-                //优先使用试验合并的PDF
-                pdfUrl = stringObjectMap.get("pdf_trial_url");
+            if (stringObjectMap.get("pdf_trial_url") != null || stringObjectMap.get("pdf_trial_url_position") != null) {
+                //合并试验关联文件、试验工程部位信息的pdf
+                pdfUrl = this.mergePdfShow(pdfUrl, stringObjectMap);
             }
 
             if (StringUtils.isEmpty(pdfUrl + "")) {
@@ -1540,10 +1540,47 @@ public class ExcelTabController extends BladeController {
                 return R.data(pdfUrl);
             }
         } else {
-            return R.fail("无历史数据预览,请保存数据");
+            return R.fail("无历史数据预览请保存数据");
         }
     }
 
+    /**
+     * 合并pdf展示
+     */
+    private Object mergePdfShow(Object oldPdfUrl, Map<String, Object> stringObjectMap) throws FileNotFoundException {
+        Object pdfUrl = "";
+        List<String> pdfList = new ArrayList<>();
+        //施工填报的原始pdf
+        pdfList.add(oldPdfUrl.toString());
+        //关联试验的pdf
+        Object pdfTrialUrl = stringObjectMap.get("pdf_trial_url");
+        Object pdfTrialUrlPosition = stringObjectMap.get("pdf_trial_url_position");
+        if (pdfTrialUrl != null) {
+            pdfList.add(pdfTrialUrl.toString());
+        }
+        if (pdfTrialUrlPosition != null) {
+            pdfList.add(pdfTrialUrlPosition.toString());
+        }
+        //合并
+        if (pdfList.size() >= 2) {
+            String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+            Long id = SnowFlakeUtil.getId();
+            String trialPdf = file_path + "/pdf/" + id + ".pdf";
+            File trialPdf2 = ResourceUtil.getFile(trialPdf);
+            if (trialPdf2.exists()) {
+                trialPdf2.delete();
+            }
+            //合并当前所有选择的试验pdf
+            FileUtils.mergePdfPublicMethods(pdfList, trialPdf);
+            BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
+            if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                pdfUrl = bladeFile.getLink();
+            }
+        }
+        return pdfUrl;
+    }
+
+
     /**
      * 用户端删除复制信息表
      */
@@ -1582,12 +1619,12 @@ public class ExcelTabController extends BladeController {
             e.printStackTrace();
         }
 
-        try{
+        try {
             R info = this.excelTabService.saveOrUpdateInfo(tableInfoList);
             if (!info.isSuccess()) {
                 return info;
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             throw new ServiceException(e.getMessage());
         }
         //单个 pdf加载

+ 72 - 19
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1295,7 +1295,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             }
         }
 
-        //  wb.saveToFile(excelPath, ExcelVersion.Version2010);
+        //wb.saveToFile(excelPath, ExcelVersion.Version2010);
         //输出流
         FileOutputStream outputStream = new FileOutputStream(excelPath);
         workbook.write(outputStream);
@@ -1380,40 +1380,92 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             tabpdf2.delete();
         }
 
-        //TODO ------ 试验pdf关联部位工程及信息 liuYC 2023-03-13 ------
-        //获取试验记录id
-        List<String> recordIds = baseMapper.queryTrialRecordId(nodeId).stream().distinct().collect(Collectors.toList());
-        if (recordIds.size() > 0) {
-            String recordInfoSql = "select detection_category,detection_result,task_status,pdf_url from u_trial_self_inspection_record where pdf_url is not null and id in(" + StringUtils.join(recordIds, ",") + ")";
-            List<TrialSelfInspectionRecord> query = jdbcTemplate.query(recordInfoSql, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class));
-            if (query.size() > 0) {
-                //只获取已审批合格自检记录,追加试验pdf到质检后面
-                List<String> pdfUrlsTrail = query.stream().filter(f -> ("已审批").equals(f.getTaskStatus())
-                        && (new Integer(1).equals(f.getDetectionResult()))
-                        && (new Integer(1).equals(f.getDetectionCategory()))).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
-                if (pdfUrlsTrail.size() > 0) {
-                    data.addAll(pdfUrlsTrail);
-                }
-            }
-        }
+        //String trialPdfUrl = this.trialRecordProjectPositionInfo(nodeId, data, file_path);
 
+        //资料填报原始pdf合并
         FileUtils.mergePdfPublicMethods(data, listPdf);
         BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
 
         //获取当前填报节点sort
         WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
 
-        // 获取顺序
+        //获取顺序
         int sort = 0;
         if (ObjectUtil.isNotEmpty(wbsTreeContract)) {
             if (wbsTreeContract.getSort() != null) {
                 sort = wbsTreeContract.getSort();
             }
         }
+
+        //String sql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "' ,sort = " + sort + " ,pdf_trial_url_position= '" + (StringUtils.isNotEmpty(trialPdfUrl) ? trialPdfUrl : null) + "' where classify='" + classify + "' and  wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' ";
+
         String sql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "' ,sort = " + sort + " where classify='" + classify + "' and  wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' ";
         jdbcTemplate.execute(sql);
     }
 
+    /*private String trialRecordProjectPositionInfo(String nodeId, List<String> data, String file_path) throws FileNotFoundException {
+        String trialPdfUrl = "";
+        List<String> recordIds = baseMapper.queryTrialRecordId(nodeId).stream().distinct().collect(Collectors.toList());//获取试验记录id
+
+        *//*if (recordIds.size() > 0) {
+            List<String> dataTrialPdfList = new ArrayList<>();
+            String recordInfoSql = "select detection_category,detection_result,task_status,pdf_url from u_trial_self_inspection_record where pdf_url is not null and id in(" + StringUtils.join(recordIds, ",") + ")";
+            List<TrialSelfInspectionRecord> query = jdbcTemplate.query(recordInfoSql, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class));
+            if (query.size() > 0) {
+                //只获取已审批合格自检记录,追加试验pdf到质检后面
+                List<String> pdfUrlsTrail = query.stream().filter(f -> ("已审批").equals(f.getTaskStatus())
+                        && (new Integer(1).equals(f.getDetectionResult()))
+                        && (new Integer(1).equals(f.getDetectionCategory()))).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+                if (pdfUrlsTrail.size() > 0) {
+                    dataTrialPdfList.addAll(data); //质检
+                    dataTrialPdfList.addAll(pdfUrlsTrail); //对应试验的pdf
+                }
+
+                Long id = SnowFlakeUtil.getId();
+
+                String trialPdf = file_path + "/pdf/" + id + ".pdf";
+                File trialPdf2 = ResourceUtil.getFile(trialPdf);
+                if (trialPdf2.exists()) {
+                    trialPdf2.delete();
+                }
+                //合并关联部位工程及信息pdf
+                FileUtils.mergePdfPublicMethods(dataTrialPdfList, trialPdf);
+                BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
+                if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                    trialPdfUrl = bladeFile.getLink();
+                }
+            }
+        }*//*
+
+     *//**
+     * 已改逻辑,在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存
+     *//*
+        if (recordIds.size() > 0) {
+            String recordInfoSql = "select detection_category,detection_result,task_status,pdf_url from u_trial_self_inspection_record where pdf_url is not null and id in(" + StringUtils.join(recordIds, ",") + ")";
+            List<TrialSelfInspectionRecord> query = jdbcTemplate.query(recordInfoSql, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class));
+            if (query.size() > 0) {
+                //只获取已审批合格试验自检记录pdf
+                List<String> pdfUrlsTrail = query.stream().filter(f -> ("已审批").equals(f.getTaskStatus())
+                        && (new Integer(1).equals(f.getDetectionResult()))
+                        && (new Integer(1).equals(f.getDetectionCategory()))).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+                if (pdfUrlsTrail.size() > 0) {
+                    Long id = SnowFlakeUtil.getId();
+                    String trialPdf = file_path + "/pdf/" + id + ".pdf";
+                    File trialPdf2 = ResourceUtil.getFile(trialPdf);
+                    if (trialPdf2.exists()) {
+                        trialPdf2.delete();
+                    }
+                    //合并当前所有选择的试验pdf
+                    FileUtils.mergePdfPublicMethods(pdfUrlsTrail, trialPdf);
+                    BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
+                    if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                        trialPdfUrl = bladeFile.getLink();
+                    }
+                }
+            }
+        }
+        return trialPdfUrl;
+    }*/
 
     /**
      * 试验 获取填报信息
@@ -1956,7 +2008,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         List<WbsTreePrivate> recordTable = queryList.stream().filter(f -> f.getTableType() == 1).collect(Collectors.toList());
         if (queryList.size() > 0) {
             for (WbsTreePrivate report : reportTable) {
-                if (StringUtils.isNotEmpty(report.getHtmlUrl())) { //没有excel表单的不生成pdf
+                //没有excel表单的不生成pdf
+                if (StringUtils.isNotEmpty(report.getHtmlUrl())) {
                     //生成报告单pdf
                     String bussPdfInfo = this.getBussPDFTrial(report.getPKeyId(), contractId, id);
                     if (StringUtils.isNotEmpty(bussPdfInfo)) {