liuyc преди 2 години
родител
ревизия
27022bc459

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialSelfInspectionRecordVO.java

@@ -26,4 +26,7 @@ public class TrialSelfInspectionRecordVO extends TrialSelfInspectionRecord {
     @ApiModelProperty("样品信息ids")
     private String sampleIds;
 
+    @ApiModelProperty("原材料检测报告ids(试验记录id)")
+    private String rawMaterialIds;
+
 }

+ 42 - 5
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.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -12,6 +13,7 @@ import org.apache.commons.lang.StringUtils;
 import org.springblade.business.dto.*;
 import org.springblade.business.entity.InformationQuery;
 import org.springblade.business.entity.TrialDetectionData;
+import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.service.ITrialDetectionDataService;
 import org.springblade.business.service.ITrialSampleInfoService;
 import org.springblade.business.service.ITrialSelfInspectionRecordService;
@@ -37,6 +39,7 @@ import javax.validation.Valid;
 import java.io.FileNotFoundException;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 @RestController
@@ -139,7 +142,33 @@ public class TrialDetectionController extends BladeController {
     @ApiOperationSupport(order = 13)
     @ApiOperation(value = "自检记录批量删除", notes = "传入ids,字符串逗号分隔")
     public R<Object> selfRemove(@Valid @RequestParam String ids) {
-        return R.status(iTrialSelfInspectionRecordService.deleteLogic(Func.toLongList(ids)));
+        List<TrialSelfInspectionRecord> recordList = iTrialSelfInspectionRecordService.getBaseMapper().selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
+                .select(TrialSelfInspectionRecord::getTaskStatus)
+                .ne(TrialSelfInspectionRecord::getTaskStatus, "未上报")
+                .in(TrialSelfInspectionRecord::getId, Func.toLongList(ids)));
+        if (recordList.size() > 0) {
+            return R.fail("只能删除未上报记录信息,操作失败");
+        }
+        //刪除按钮状态记录
+        String sql1 = "delete from u_trial_self_data_record where record_id in(" + ids + ")";
+        jdbcTemplate.execute(sql1);
+
+        //删除样品关联记录
+        String sql2 = "delete from u_trial_self_sample where self_id in(" + ids + ")";
+        jdbcTemplate.execute(sql2);
+
+        //删除工程部位关联记录
+        String sql3 = "delete from u_trial_raw_material_self_record where self_record_id in(" + ids + ")";
+        jdbcTemplate.execute(sql3);
+
+        //删除原材料检测报告关联记录
+        String sql4 = "delete from u_trial_self_quality_project where self_id in(" + ids + ")";
+        jdbcTemplate.execute(sql4);
+
+        //删除试验记录
+        String sql5 = "delete from u_trial_self_inspection_record where id in(" + ids + ")";
+        jdbcTemplate.execute(sql5);
+        return R.status(true);
     }
 
     @GetMapping("/self/show-buss-tab")
@@ -170,7 +199,7 @@ public class TrialDetectionController extends BladeController {
         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);
-        if (obj != null){
+        if (obj != null) {
             return R.data(obj.getPdfUrl());
         }
         return R.data("");
@@ -178,7 +207,7 @@ public class TrialDetectionController extends BladeController {
 
     @GetMapping("/get-buss-pdfs")
     @ApiOperationSupport(order = 18)
-    @ApiOperation(value = "自检多表PDF预览", notes = "传入nodeId、classify、contractId、projectId")
+    @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 + "'";
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
@@ -186,12 +215,20 @@ public class TrialDetectionController extends BladeController {
             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");
             }
+
+            //优先使用关联原材料检测报告的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();
+            }
+
             return R.data(pdfUrl);
         } else {
-            return R.fail("无历史数据预览,请保存数据");
+            return R.fail("无历史数据预览请保存数据");
         }
     }
 

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

@@ -27,7 +27,7 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     List<TrialSelfInspectionRecordVO2> getRawMaterialInfo(String nodeId, String contractId, String id);
 
-    boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto) throws FileNotFoundException;
+    boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto, TrialSelfInspectionRecord obj) throws FileNotFoundException;
 
     String selfPrintPdf(String ids) throws FileNotFoundException;
 

+ 90 - 125
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -3,7 +3,6 @@ package org.springblade.business.service.impl;
 import cn.hutool.core.date.LocalDateTimeUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -55,6 +54,7 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.util.*;
 import java.util.List;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Service
@@ -101,16 +101,18 @@ public class TrialSelfInspectionRecordServiceImpl
         IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderByDesc(true, TrialSelfInspectionRecord::getCreateTime));
         IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
         List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
-        List<Dict> trialDetectionCategory = iDictClient.getList("trial_detection_category").getData();
+        Map<String, Dict> map = iDictClient.getList("trial_detection_category").getData().stream().collect(Collectors.toMap(Dict::getDictKey, Function.identity()));
 
         for (TrialSelfInspectionRecordVO record : records) {
-            for (Dict dict : trialDetectionCategory) {
-                if (dict.getDictKey().equals(String.valueOf(record.getDetectionCategory()))) {
+            record.setIsUploadCertificateName((new Integer(1)).equals(record.getIsUploadCertificate()) ? "是" : "否");
+            record.setDetectionResultName((new Integer(1)).equals(record.getDetectionResult()) ? "合格" : "不合格");
+
+            if (ObjectUtils.isNotEmpty(record.getDetectionCategory())) {
+                Dict dict = map.get(String.valueOf(record.getDetectionCategory()));
+                if (dict != null) {
                     record.setDetectionCategoryName(dict.getDictValue());
                 }
             }
-            record.setIsUploadCertificateName(record.getIsUploadCertificate().equals(1) ? "是" : "否");
-            record.setDetectionResultName(record.getDetectionResult().equals(1) ? "合格" : "不合格");
 
             //工程部位及用途名称
             if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
@@ -131,6 +133,18 @@ public class TrialSelfInspectionRecordServiceImpl
             if (query.size() > 0) {
                 record.setSampleIds(org.apache.commons.lang.StringUtils.join(query, ","));
             }
+
+            String sql1 = "select raw_material_record_id,old_pdf_url from u_trial_raw_material_self_record where self_record_id = " + record.getId();
+            List<TrialRawMaterialSelfRecord> query1 = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
+            if (query1.size() > 0) {
+                //原材料检测报告ids
+                List<Long> ids = query1.stream().map(TrialRawMaterialSelfRecord::getRawMaterialRecordId).collect(Collectors.toList());
+                record.setRawMaterialIds(org.apache.commons.lang.StringUtils.join(ids, ","));
+
+                //pdfUrl
+                record.setPdfUrl(Objects.requireNonNull(query1.stream().findAny().orElse(null)).getOldPdfUrl());
+            }
+
         }
         return trialSelfInspectionRecordVOIPage.setRecords(records);
     }
@@ -166,13 +180,13 @@ public class TrialSelfInspectionRecordServiceImpl
         List<Attach> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Attach.class));
         for (SampleAncillaryDocumentsVO sampleAncillaryDocumentsVO : result) {
             for (Attach attach : query) {
-                if (sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
+                if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getOtherAccessories()) && sampleAncillaryDocumentsVO.getOtherAccessories().equals(attach.getLink())) {
                     sampleAncillaryDocumentsVO.setOtherAccessoriesName(attach.getOriginalName());
                 }
-                if (sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
+                if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getProductionCertificate()) && sampleAncillaryDocumentsVO.getProductionCertificate().equals(attach.getLink())) {
                     sampleAncillaryDocumentsVO.setProductionCertificateName(attach.getOriginalName());
                 }
-                if (sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
+                if (StringUtils.isNotEmpty(sampleAncillaryDocumentsVO.getQualityInspectionReport()) && sampleAncillaryDocumentsVO.getQualityInspectionReport().equals(attach.getLink())) {
                     sampleAncillaryDocumentsVO.setQualityInspectionReportName(attach.getOriginalName());
                 }
             }
@@ -229,12 +243,16 @@ public class TrialSelfInspectionRecordServiceImpl
         List<TrialSelfInspectionRecordVO2> recordVO2s;
         //编辑
         if (StringUtils.isNotEmpty(id)) {
-            //获取nodeId节点下的记录信息(排除当前id记录)
+            //获取nodeId节点下的合格的记录信息(排除当前id记录)
             List<TrialSelfInspectionRecord> result = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
+                    .eq(TrialSelfInspectionRecord::getDetectionResult, 1)
+                    .eq(TrialSelfInspectionRecord::getStatus, 1)
                     .eq(TrialSelfInspectionRecord::getNodeId, nodeId)
                     .eq(TrialSelfInspectionRecord::getContractId, contractId)
                     .ne(TrialSelfInspectionRecord::getId, id)
-                    .eq(TrialSelfInspectionRecord::getStatus, 1));
+                    .isNotNull(TrialSelfInspectionRecord::getReportNo)
+                    .orderByDesc(TrialSelfInspectionRecord::getCreateTime)
+            );
 
             recordVO2s = BeanUtil.copyProperties(result, TrialSelfInspectionRecordVO2.class);
 
@@ -256,9 +274,12 @@ public class TrialSelfInspectionRecordServiceImpl
         } else {
             //新增
             List<TrialSelfInspectionRecord> result = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
+                    .eq(TrialSelfInspectionRecord::getDetectionResult, 1)
+                    .eq(TrialSelfInspectionRecord::getStatus, 1)
                     .eq(TrialSelfInspectionRecord::getNodeId, nodeId)
                     .eq(TrialSelfInspectionRecord::getContractId, contractId)
-                    .eq(TrialSelfInspectionRecord::getStatus, 1));
+                    .isNotNull(TrialSelfInspectionRecord::getReportNo)
+                    .orderByDesc(TrialSelfInspectionRecord::getCreateTime));
 
             recordVO2s = BeanUtil.copyProperties(result, TrialSelfInspectionRecordVO2.class);
         }
@@ -285,110 +306,66 @@ public class TrialSelfInspectionRecordServiceImpl
 
     @Override
     @Async
-    public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto) throws FileNotFoundException {
+    public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto, TrialSelfInspectionRecord obj) throws FileNotFoundException {
         if (ObjectUtil.isEmpty(dto.getId())) {
             throw new ServiceException("请先保存填报数据后,再关联原材检测报告信息");
         } else {
-            TrialSelfInspectionRecord objMain = this.getBaseMapper().selectById(dto.getId());
-            if (ObjectUtil.isNotEmpty(objMain) && (("已审批").equals(objMain.getTaskStatus()) || ("待审批").equals(objMain.getTaskStatus()))) {
+            if (ObjectUtil.isNotEmpty(obj) && (("已审批").equals(obj.getTaskStatus()) || ("待审批").equals(obj.getTaskStatus()))) {
                 throw new ServiceException("当前填报数据已上报,无法进行关联操作");
             }
-            if (StringUtils.isNotEmpty(dto.getIds())) { //新增关系,合并pdf
-                List<String> idsList = Func.toStrList(dto.getIds());
-                //获取ids、id下的pdfUrl
-                List<String> ids = new ArrayList<>();
-                ids.add(dto.getId());
-                ids.addAll(idsList);
-                List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, ids).eq(TrialSelfInspectionRecord::getStatus, 1));
-                TrialSelfInspectionRecord oldObj = recordList.stream().filter(f -> f.getId().equals(Long.parseLong(dto.getId()))).findAny().orElse(null);
-                List<TrialSelfInspectionRecord> oldOther = recordList.stream().filter(f -> !f.getId().equals(Long.parseLong(dto.getId()))).collect(Collectors.toList());
-
-                //获取原始pdfUrl
-                String sql = "select * from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
-                TrialRawMaterialSelfRecord recordOld = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
-                if (recordOld != null && oldObj != null) {
-                    oldObj.setPdfUrl(recordOld.getOldPdfUrl());
-                }
 
-                //当前记录pdfUrl置顶
-                List<TrialSelfInspectionRecord> recordList2 = new ArrayList<>();
-                recordList2.add(oldObj);
-                recordList2.addAll(oldOther);
-                List<String> listPdfUrl = recordList2.stream().map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+            //新增或编辑
+            if (StringUtils.isNotEmpty(dto.getIds())) {
+                //当前关联的原材料记录id
+                List<String> idsNew = new ArrayList<>(Func.toStrList(dto.getIds()));
+                //当前记录id
+                idsNew.add(dto.getId());
+                //获取原材料的pdfUrl
+                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
+                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());
+                    pdfUrlAll.addAll(recordObjList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList()));
+                }
 
-                if (listPdfUrl.size() > 0) {
-                    //合并PDF
+                if (pdfUrlAll.size() > 0) {
                     String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
                     String listPdf = filePath + "/pdf/" + dto.getNodeId() + ".pdf";
                     File tabPDF = ResourceUtil.getFile(listPdf);
                     if (tabPDF.exists()) {
                         tabPDF.delete();
                     }
-                    FileUtils.mergePdfPublicMethods(listPdfUrl, listPdf);
+                    FileUtils.mergePdfPublicMethods(pdfUrlAll, listPdf);
                     BladeFile bladeFile = this.newIOSSClient.uploadFile(dto.getNodeId() + ".pdf", listPdf);
 
-                    //获取试验记录id的试验项目名称
-                    List<String> collect = recordList.stream().map(TrialSelfInspectionRecord::getTrialProjectName).collect(Collectors.toList());
-                    String name = collect.stream().findAny().orElse(null);
-                    String trialProjectName;
-                    if (collect.size() > 1) {
-                        trialProjectName = name + "等" + collect.size() + "个文件";
-                    } else {
-                        trialProjectName = name;
-                    }
-
-                    //删除当前记录关系信息
+                    //删除记录关系
                     String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
                     jdbcTemplate.execute(sql1);
-                    //新增当前记录关系信息
-                    for (String s : idsList) {
-                        if (oldObj != null) {
-                            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() + "," + s + ",'" + oldObj.getPdfUrl() + "')";
+                    //新增记录关系
+                    for (String recordId : idsNew) {
+                        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);
                         }
                     }
-
-                    if (ObjectUtil.isNotEmpty(bladeFile)) {
-                        //修改pdfURL
-                        String querySql = "select * from u_information_query where classify='" + dto.getType() + "' and wbs_id='" + dto.getId() + "' and contract_id ='" + dto.getContractId() + "'";
-                        List<Map<String, Object>> resultSQL = jdbcTemplate.queryForList(querySql);
-                        if (resultSQL.size() > 0) {
-                            String sql3 = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name = '" + trialProjectName + "' where classify= '" + dto.getType() + "' and wbs_id='" + dto.getId() + "' and contract_id ='" + dto.getContractId() + "'";
-                            jdbcTemplate.execute(sql3);
-                        } else {
-                            informationQueryClient.saveData(dto.getId(), dto.getProjectId(), dto.getContractId(), String.valueOf(dto.getType()), bladeFile.getLink(), trialProjectName);
-                        }
-
-                        //修改当前记录pdfUrl
-                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, bladeFile.getLink()).eq(TrialSelfInspectionRecord::getId, dto.getId()));
-
-                        return true;
-                    } else {
-                        //删除关系
-                        jdbcTemplate.execute(sql1);
-                        return false;
-                    }
+                    return true;
                 }
-            } else {
-                //删除关系,恢复当前记录的原始pdfUrl
-                TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
-                String sql = "select * from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
-                TrialRawMaterialSelfRecord record = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
-                if (record != null) {
-                    //修改pdfURL
-                    String querySql = "select * from u_information_query where classify='" + dto.getType() + "' and wbs_id='" + dto.getId() + "' and contract_id ='" + dto.getContractId() + "'";
-                    List<Map<String, Object>> resultSQL = jdbcTemplate.queryForList(querySql);
-                    if (resultSQL.size() > 0) {
-                        String sql3 = "update u_information_query set pdf_url ='" + record.getOldPdfUrl() + "', name = '" + obj.getTrialProjectName() + "' where classify= '" + dto.getType() + "' and wbs_id='" + dto.getId() + "' and contract_id ='" + dto.getContractId() + "'";
-                        jdbcTemplate.execute(sql3);
-                    } else {
-                        informationQueryClient.saveData(dto.getId(), dto.getProjectId(), dto.getContractId(), String.valueOf(dto.getType()), record.getOldPdfUrl(), obj.getTrialProjectName());
-                    }
-
-                    //修改当前记录pdfUrl
-                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, record.getOldPdfUrl()).eq(TrialSelfInspectionRecord::getId, dto.getId()));
 
-                    //删除当前记录关系信息
+            } else {
+                //删除全部
+                String sql = "select id from u_trial_raw_material_self_record where self_record_id =" + dto.getId();
+                List<TrialRawMaterialSelfRecord> recordList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class));
+                if (recordList.size() > 0) {
                     String sql1 = "delete from u_trial_raw_material_self_record where self_record_id ='" + dto.getId() + "'";
                     jdbcTemplate.execute(sql1);
                 }
@@ -645,16 +622,15 @@ public class TrialSelfInspectionRecordServiceImpl
         List<String> sampleIds = baseMapper.selectSelfSampleRecord(id);
         if (sampleIds.size() > 0) {
             List<TrialSampleInfo> trialSampleInfos = trialSampleInfoMapper.selectBatchIds(sampleIds);
-            List<User> users = iUserClient.selectUserAll();
+            Map<Long, User> map = iUserClient.selectUserAll().stream().collect(Collectors.toMap(User::getId, Function.identity()));
             if (trialSampleInfos.size() > 0) {
                 for (TrialSampleInfo trialSampleInfo : trialSampleInfos) {
-                    for (User user : users) {
-                        if (trialSampleInfo.getUserId().equals(user.getId())) {
-                            TrialSampleInfoVO trialSampleInfoVO = BeanUtil.copyProperties(trialSampleInfo, TrialSampleInfoVO.class);
-                            if (trialSampleInfoVO != null) {
-                                trialSampleInfoVO.setUserName(ObjectUtil.isNotEmpty(user.getName()) ? user.getName() : user.getRealName());
-                                result.add(trialSampleInfoVO);
-                            }
+                    User user = map.get(trialSampleInfo.getUserId());
+                    if (user != null) {
+                        TrialSampleInfoVO trialSampleInfoVO = BeanUtil.copyProperties(trialSampleInfo, TrialSampleInfoVO.class);
+                        if (trialSampleInfoVO != null) {
+                            trialSampleInfoVO.setUserName(ObjectUtil.isNotEmpty(user.getName()) ? user.getName() : user.getRealName());
+                            result.add(trialSampleInfoVO);
                         }
                     }
                 }
@@ -698,7 +674,7 @@ public class TrialSelfInspectionRecordServiceImpl
                 this.saveOrUpdate(dto);
             }
 
-            //TODO ------保存实体表数据、试验记录信息、生成pdf------
+            //------保存实体表数据、试验记录信息、生成pdf------
             try {
                 String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
                 if (StringUtils.isNotEmpty(pdfURL)) {
@@ -709,7 +685,7 @@ public class TrialSelfInspectionRecordServiceImpl
                 throw new ServiceException("保存实体表数据生成pdf时发生异常" + e.getMessage());
             }
 
-            //TODO ------关联工程及用途关系新增或删除------
+            //------关联工程及用途关系新增或删除------
             if (StringUtils.isEmpty(obj.getProjectPosition())) {
                 String delSql = "delete from u_trial_self_quality_project where self_id = " + obj.getId();
                 jdbcTemplate.execute(delSql);
@@ -725,7 +701,7 @@ public class TrialSelfInspectionRecordServiceImpl
                 }
             }
 
-            //TODO ------关联原材料检测报告------
+            //------关联原材料检测报告------
             RawMaterialSubmitRelationDTO relationDTO = new RawMaterialSubmitRelationDTO();
             relationDTO.setId(obj.getId().toString());
             relationDTO.setIds(dto.getRawMaterialIds());
@@ -733,19 +709,15 @@ public class TrialSelfInspectionRecordServiceImpl
             relationDTO.setContractId(dto.getContractId().toString());
             relationDTO.setProjectId(dto.getProjectId());
             relationDTO.setType(dto.getType());
-            if (StringUtils.isNotEmpty(relationDTO.getIds())) {
-                this.rawMaterialSubmitRelation(relationDTO);
-            }
+            this.rawMaterialSubmitRelation(relationDTO, obj);
 
-            //TODO ------关联取样信息------
+            //------关联取样信息------
             RecordSampleSubmitDTO recordSampleSubmitDTO = new RecordSampleSubmitDTO();
             recordSampleSubmitDTO.setId(obj.getId());
             recordSampleSubmitDTO.setSampleIds(dto.getSampleIds());
-            if (StringUtils.isNotEmpty(relationDTO.getIds())) {
-                this.recordSampleSubmit(recordSampleSubmitDTO);
-            }
+            this.recordSampleSubmit(recordSampleSubmitDTO);
 
-            //TODO ------新增设备使用记录信息------
+            //------新增设备使用记录信息------
             this.trialDeviceUseService.addDeviceUseInfo(dto);
         }
 
@@ -759,12 +731,12 @@ public class TrialSelfInspectionRecordServiceImpl
         if (ObjectUtil.isEmpty(dto.getId())) {
             throw new ServiceException("请先保存填报数据后,再关联取样信息");
         }
-        //删除关联信息
+        //删除关联
         baseMapper.delSelfSample(dto.getId());
         if (StringUtils.isNotEmpty(dto.getSampleIds())) {
             List<String> ids = Func.toStrList(dto.getSampleIds());
             for (String id : ids) {
-                //新增关联信息
+                //新增关联
                 baseMapper.saveSelfSample(SnowFlakeUtil.getId(), dto.getId(), id);
             }
 
@@ -1041,21 +1013,17 @@ public class TrialSelfInspectionRecordServiceImpl
 
     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();
             endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
             queryWrapper.lambda().between(TrialSelfInspectionRecord::getReportDate, dto.getStartTime(), endTime);
         }
-
         queryWrapper.lambda().eq(TrialSelfInspectionRecord::getTaskStatus, "已审批");
         queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionResult, 1); //合格
         queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionCategory, 1); //自检
-
-        IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialSelfInspectionRecord::getCreateTime));
+        IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderByDesc(TrialSelfInspectionRecord::getCreateTime));
         IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
         List<TrialSelfInspectionRecordVO> records = trialSelfInspectionRecordVOIPage.getRecords();
-
         //查询是否关联过
         if (ObjectUtil.isNotEmpty(dto.getQualityTestPKeyId())) {
             List<String> selectedIds = baseMapper.selectSelectedStatusList(Long.parseLong(dto.getQualityTestPKeyId()), "1");
@@ -1066,7 +1034,6 @@ public class TrialSelfInspectionRecordServiceImpl
                         record.setIsSelectedStatus(1);
                     }
                 }
-
                 record.setDetectionResultName(record.getDetectionResult().equals(1) ? "合格" : "不合格");
                 //工程部位及用途名称
                 if (ObjectUtil.isNotEmpty(record.getProjectPosition())) {
@@ -1081,7 +1048,6 @@ public class TrialSelfInspectionRecordServiceImpl
                     }
                 }
             }
-
         } else {
             for (TrialSelfInspectionRecordVO record : records) {
                 record.setDetectionResultName(record.getDetectionResult().equals(1) ? "合格" : "不合格");
@@ -1099,7 +1065,6 @@ public class TrialSelfInspectionRecordServiceImpl
                 }
             }
         }
-
         return trialSelfInspectionRecordVOIPage.setRecords(records);
     }
 
@@ -1124,7 +1089,7 @@ public class TrialSelfInspectionRecordServiceImpl
 
                 List<String> pdfList = new ArrayList<>();
 
-                //TODO ------自检------
+                //------自检------
                 if (dto.getType().equals(1)) {
                     //当前施工pdf
                     pdfList.add(informationQuery.getPdfUrl());
@@ -1136,7 +1101,7 @@ public class TrialSelfInspectionRecordServiceImpl
                     List<String> pdfURLs = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
                     pdfList.addAll(pdfURLs);
 
-                    //TODO ------第三方、外委------
+                    //------第三方、外委------
                 } else if (dto.getType().equals(2) || dto.getType().equals(3)) {
 
                     if (informationQuery.getPdfTrialUrl() != null) {

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

@@ -639,6 +639,11 @@ public class WbsTreePrivateController extends BladeController {
                     treePrivate.setIsBussShow(record.getIsBussShow());
                     treePrivate.setIsTabPdf(record.getIsTabPdf());
                     treePrivate.setTabFileType(record.getIsTabFileType());
+                } else {
+                    treePrivate.setPdfUrl(null);
+                    treePrivate.setIsBussShow(1);
+                    treePrivate.setIsTabPdf(1);
+                    treePrivate.setTabFileType(1);
                 }
 
                 //表单数据

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

@@ -51,15 +51,17 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         String nodeId = table.getString("nodeId");
         String projectId = table.getString("projectId");
         String contractId = table.getString("contractId");
-
         List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
-
         String pdfUrl = "";
 
-        //TODO ------入库-试验填报数据,当前记录id作为groupId------
+        /**
+         * ------试验填报数据保存,当前记录id作为groupId------
+         */
         this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);
 
-        //TODO ------公式填充------
+        /**
+         * ------公式填充------
+         */
         try {
             this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId));
         } catch (Exception e) {
@@ -67,7 +69,9 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         }
 
         if (isBatchSave == 0) {
-            //TODO ------单表PDF保存------
+            /**
+             * ------单表PDF保存------
+             */
             TableInfo tableInfo = tableInfoList.stream().findAny().orElse(null);
             assert tableInfo != null;
             if (tabIds.contains(tableInfo.getPkeyId())) {
@@ -80,22 +84,21 @@ public class ExcelTabClientImpl implements ExcelTabClient {
                 List<String> pdfList = query.stream().map(TrialSelfDataRecord::getPdfUrl).collect(Collectors.toList());
 
                 String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                String pdfPath2 = file_path + "/pdf//" + id + "_2.pdf";
-                File tabPdf2 = ResourceUtil.getFile(pdfPath2);
-                if (tabPdf2.exists()) {
-                    tabPdf2.delete();
+                String pdfPath = file_path + "/pdf//" + id + "_2.pdf";
+                File tabPdf = ResourceUtil.getFile(pdfPath);
+                if (tabPdf.exists()) {
+                    tabPdf.delete();
                 }
-                FileUtils.mergePdfPublicMethods(pdfList, pdfPath2);
-                BladeFile bladeFile = newIOSSClient.uploadFile(id + "2.pdf", pdfPath2);
+                FileUtils.mergePdfPublicMethods(pdfList, pdfPath);
+                BladeFile bladeFile = newIOSSClient.uploadFile(id + "2.pdf", pdfPath);
 
                 String sqlUpdate = "update u_trial_self_inspection_record set pdf_url = '" + bladeFile.getLink() + "' where id = " + id;
                 jdbcTemplate.execute(sqlUpdate);
 
-                //获取试验记录id的试验项目名称
+                //获取试验记录id的试验项目名称,重新合并pdf集合(解决单表保存后上报找不到题名问题)
                 String sql2 = "select trial_project_name from u_trial_self_inspection_record where id = " + id;
                 TrialSelfInspectionRecord obj = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class)).stream().findAny().orElse(null);
                 assert obj != null;
-                //重新合并pdf集合(解决单表保存后上报找不到题名问题)
                 String querySql = "select id from u_information_query where classify ='" + type + "' and wbs_id ='" + id + "' and contract_id ='" + contractId + "'";
                 List<InformationQuery> query2 = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(InformationQuery.class));
                 if (query2.size() > 0) {
@@ -104,34 +107,20 @@ public class ExcelTabClientImpl implements ExcelTabClient {
                 } else {
                     informationQueryClient.saveData(id.toString(), projectId, contractId, type.toString(), bladeFile.getLink(), obj.getTrialProjectName());
                 }
-
-                //修改原材料检测报告原始pdfUrl
-                String sql3 = "select id from u_trial_raw_material_self_record where self_record_id =" + id;
-                TrialRawMaterialSelfRecord record = jdbcTemplate.query(sql3, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
-                if (ObjectUtil.isNotEmpty(record)) {
-                    String sqlUpdate2 = "update u_trial_raw_material_self_record set old_pdf_url = '" + bladeFile.getLink() + "' where self_record_id =" + id;
-                    jdbcTemplate.execute(sqlUpdate2);
-                }
             }
 
         } else if (isBatchSave == 1) {
-            //TODO ------多表PDF保存------
-            pdfUrl = excelTabService.getBussPDFSTrial(nodeId,
-                    tableType, //tableType=表类型 1=记录表 2=报告单
-                    String.valueOf(type), //type=所属方 1=施工质检 2=监理抽检
-                    contractId, //合同段id
-                    projectId, //项目id
-                    id,  //记录id
-                    tabIds //新增的表的pKeyIds
-            );
-
-            //TODO ------修改原材料检测报告原始pdfUrl------
-            String sql = "select id from u_trial_raw_material_self_record where self_record_id =" + id;
-            TrialRawMaterialSelfRecord record = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialRawMaterialSelfRecord.class)).stream().findAny().orElse(null);
-            if (ObjectUtil.isNotEmpty(record)) {
-                String sqlUpdate = "update u_trial_raw_material_self_record set old_pdf_url = '" + pdfUrl + "' where self_record_id =" + id;
-                jdbcTemplate.execute(sqlUpdate);
-            }
+            /**
+             * ------多表PDF保存------
+             * tableType=表类型 1=记录表 2=报告单
+             * type=所属方 1=施工质检 2=监理抽检
+             * contractId=合同段id
+             * projectId=项目id
+             * id=记录id
+             * tabIds=表的pKeyIds
+             */
+            pdfUrl = excelTabService.getBussPDFSTrial(nodeId, tableType, String.valueOf(type), contractId, projectId, id, tabIds);
+
         }
         return pdfUrl;
     }
@@ -143,15 +132,7 @@ public class ExcelTabClientImpl implements ExcelTabClient {
 
     @Override
     public String getBussPDFSTrial(String nodeId, String tableType, String classify, String contractId, String projectId, String id, String tabIds) throws Exception {
-        //合并PDF加载
-        return excelTabService.getBussPDFSTrial(nodeId,
-                tableType, //tableType=表类型 1=记录表 2=报告单
-                classify, //type=所属方 1=施工质检 2=监理抽检
-                contractId, //合同段id
-                projectId, //项目id
-                Long.parseLong(id), //记录id
-                tabIds //新增的表的pKeyIds
-        );
+        return excelTabService.getBussPDFSTrial(nodeId, tableType, classify, contractId, projectId, Long.parseLong(id), tabIds);
     }
 
 

+ 9 - 35
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -1601,13 +1601,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
                         if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
 
-                            //处理相同字段名称问题,同一个KeyName,那么拼接value
-                            Object oldValue = reData.get(key);
-                            if (oldValue != null) {
-                                reData.put(key, oldValue + "、" + tabVal);
-                                continue;
-                            }
-
                             //时间段处理
                             if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
                                 String[] tabData = tabVal.split("_\\^_");
@@ -1649,7 +1642,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                 for (String data : mysql) {
                                     String[] tabData = data.split("_\\^_");
                                     if (StringUtils.isNotEmpty(tabData[0])) {
-                                        reData.put(key, tabData[0]);
+                                        //处理相同字段名称问题,同一个KeyName,那么拼接value
+                                        Object oldValue = reData.get(key);
+                                        if (ObjectUtils.isNotEmpty(oldValue)) {
+                                            reData.put(key, oldValue + "、" + tabData[0]);
+                                        } else {
+                                            reData.put(key, tabData[0]);
+                                        }
                                     }
                                 }
                             } else if (tabVal.contains("_^_")) {
@@ -1800,31 +1799,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                     }
                                 }
 
-                                /*if (myData.contains("T") && myData.contains("-") && myData.contains(":")) {
-                                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
-                                    sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
-                                    SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
-
-                                    if (myData.contains(",") && myData.contains("]")) {
-                                        myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
-                                        String[] dataVal = myData.split(",");
-                                        String[] Start_dataStr = dataVal[0].split("T")[0].split("-");
-                                        String StartDate = StringUtil.format("{}年{}月{}日", Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1).trim();
-
-                                        String[] end_dataStr = dataVal[1].split("T")[0].split("-");
-
-                                        String endDate = StringUtil.format("{}年{}月{}日", end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1).trim();
-                                        if (StartDate.equals(endDate)) {
-                                            myData = StartDate;
-                                        } else {
-                                            myData = StartDate + "-" + endDate;
-                                        }
-                                    } else {
-                                        String[] dataStr = myData.split("T")[0].split("-");
-                                        myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
-                                    }
-                                }*/
-
                                 if (myData.contains("https") && myData.contains("aliyuncs")) {
                                     BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
                                     int colspan = data.attr("COLSPAN").equals("") ? 0 : Integer.parseInt(data.attr("COLSPAN"));
@@ -1879,9 +1853,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 }
                 // 组装电签设置
                 QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
+                queryWrapper.select("col_key", "id");
                 queryWrapper.eq("type", 2);
                 queryWrapper.eq("tab_id", wbsTreePrivate.getPKeyId());
-
                 List<TextdictInfo> textDictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
                 if (textDictInfos != null && !textDictInfos.isEmpty()) {
                     for (TextdictInfo e : textDictInfos) {
@@ -1991,7 +1965,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 }
             }
             for (WbsTreePrivate record : recordTable) {
-                if (StringUtils.isNotEmpty(record.getHtmlUrl())) { //没有excel表单的不生成pdf
+                if (StringUtils.isNotEmpty(record.getHtmlUrl())) {
                     //生成记录表pdf
                     String bussPdfInfo = this.getBussPDFTrial(record.getPKeyId(), contractId, id);
                     if (StringUtils.isNotEmpty(bussPdfInfo)) {