Browse Source

试验自检关联工程部位相关

liuyc 2 năm trước cách đây
mục cha
commit
8344c87e7c

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

@@ -14,6 +14,12 @@ public class TrialSelfInspectionRecordDTO extends TrialSelfInspectionRecord {
     @ApiModelProperty("样品信息ids")
     private String sampleIds;
 
+    @ApiModelProperty("原材料检测报告ids(试验记录id)")
+    private String rawMaterialIds;
+
+    @ApiModelProperty("项目id")
+    private String projectId;
+
     @ApiModelProperty(value = "表类型 1=记录表 2=报告单 ,字符串拼接")
     private String tableType;
 

+ 16 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreePrivateVO4.java

@@ -0,0 +1,16 @@
+package org.springblade.manager.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.manager.entity.WbsTreePrivate;
+
+import java.util.Map;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class WbsTreePrivateVO4 extends WbsTreePrivate{
+    private static final long serialVersionUID = 1L;
+
+    private Map<String, Object> bussDataInfoTrial;
+
+}

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

@@ -286,7 +286,7 @@ public class TaskController extends BladeController {
 				taskApprovalVOS.add(approvalVO);
 			}
 
-			//修改试验填报状态
+			//修改试验填报状态,关联工程部位信息pdf
 			this.iTrialSelfInspectionRecordService.updateTrialSelfInspectionRecordStatus(taskApprovalVOS);
 
 			//审批

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

@@ -124,7 +124,7 @@ public class TrialDetectionController extends BladeController {
     @PostMapping("/self/submit")
     @ApiOperationSupport(order = 11)
     @ApiOperation(value = "自检记录新增或修改", notes = "传入TrialSelfInspectionRecordDTO")
-    public R<Object> selfSubmit(@Valid @RequestBody TrialSelfInspectionRecordDTO dto) {
+    public R<Object> selfSubmit(@Valid @RequestBody TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
         return R.data(iTrialSelfInspectionRecordService.selfSubmit(dto));
     }
 
@@ -215,7 +215,9 @@ public class TrialDetectionController extends BladeController {
     @ApiOperationSupport(order = 21)
     @ApiOperation(value = "关联原材检测报告保存或修改", notes = "传入RawMaterialSubmitRelationDTO")
     public R<Object> rawMaterialSubmitRelation(@RequestBody RawMaterialSubmitRelationDTO dto) throws FileNotFoundException {
-        return R.status(iTrialSelfInspectionRecordService.rawMaterialSubmitRelation(dto));
+        //TODO 已剥离,融合到自检记录保存中
+        //return R.status(iTrialSelfInspectionRecordService.rawMaterialSubmitRelation(dto));
+        return R.status(true);
     }
 
     @PostMapping("/self/print-pdf")
@@ -270,14 +272,18 @@ public class TrialDetectionController extends BladeController {
     @ApiOperationSupport(order = 26)
     @ApiOperation(value = "自检记录关联工程部位信息保存", notes = "传入SelfProjectPositionSubmitDTO")
     public R<Object> recordProjectPosition(@Valid @RequestBody SelfProjectPositionSubmitDTO dto) throws FileNotFoundException {
-        return R.status(iTrialSelfInspectionRecordService.recordProjectPosition(dto));
+        //TODO 已剥离,融合到批量审批中
+        //return R.status(iTrialSelfInspectionRecordService.recordProjectPosition(dto));
+        return R.status(true);
     }
 
     @PostMapping("/self/record-sample/submit")
     @ApiOperationSupport(order = 27)
     @ApiOperation(value = "自检记录关联取样信息保存", notes = "传入RecordSampleSubmitDTO")
     public R<Object> recordSampleSubmit(@Valid @RequestBody RecordSampleSubmitDTO dto) {
-        return R.status(iTrialSelfInspectionRecordService.recordSampleSubmit(dto));
+        //TODO 已剥离,融合到自检记录保存中
+        //return R.status(iTrialSelfInspectionRecordService.recordSampleSubmit(dto));
+        return R.status(true);
     }
 
 }

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

@@ -40,5 +40,4 @@ public interface TrialSelfInspectionRecordMapper extends BaseMapper<TrialSelfIns
     List<String> selectSelectedStatusList(Long nodeId, String type);
 
     List<WbsTreeContract> selectWbsTreeContractListByPKeyIds(@Param("idList") List<String> ids);
-
 }

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

@@ -15,7 +15,7 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto);
 
-    String selfSubmit(TrialSelfInspectionRecordDTO dto) ;
+    String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException;
 
     List<TrialSampleInfoVO> selfSampleList(String id);
 
@@ -34,7 +34,7 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
     String selfPrintNullPdf(String ids) throws Exception;
 
     @Async
-    void updateTrialSelfInspectionRecordStatus(List<TaskApprovalVO> obj);
+    void updateTrialSelfInspectionRecordStatus(List<TaskApprovalVO> obj) throws FileNotFoundException;
 
     String addBussFile(MultipartFile file, Long pkeyId, String nodeId, String contractId, String projectId, String classify, String id, String tableType) throws Exception;
 

+ 107 - 35
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -46,6 +46,7 @@ import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
 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;
 import org.springframework.web.multipart.MultipartFile;
@@ -283,6 +284,7 @@ public class TrialSelfInspectionRecordServiceImpl
     }
 
     @Override
+    @Async
     public boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto) throws FileNotFoundException {
         if (ObjectUtil.isEmpty(dto.getId())) {
             throw new ServiceException("请先保存填报数据后,再关联原材检测报告信息");
@@ -456,7 +458,8 @@ public class TrialSelfInspectionRecordServiceImpl
     }
 
     @Override
-    public void updateTrialSelfInspectionRecordStatus(List<TaskApprovalVO> obj) {
+    @Async
+    public void updateTrialSelfInspectionRecordStatus(List<TaskApprovalVO> obj) throws FileNotFoundException {
         for (TaskApprovalVO taskApprovalVO : obj) {
             if (ObjectUtil.isNotEmpty(taskApprovalVO.getParallelProcessInstanceId())) {
                 String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + taskApprovalVO.getParallelProcessInstanceId() + "'";
@@ -468,6 +471,58 @@ public class TrialSelfInspectionRecordServiceImpl
                                 .set(TrialSelfInspectionRecord::getTaskStatus, "OK".equals(taskApprovalVO.getFlag()) ? "已审批" : "已废除")
                                 .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())) {
+                            //删除关联信息
+                            baseMapper.delSelfQuality(record.getId());
+
+                            List<String> ids = Func.toStrList(record.getProjectPosition());
+                            //新增关联信息
+                            for (String id : ids) {
+                                baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), record.getId(), id);
+                            }
+
+                            //把当前试验的PDF合并关联到质检树节点下
+                            List<String> contractNodePKeyIds = baseMapper.selectQualityNodeId(String.valueOf(record.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(record.getPdfUrl())) {
+                                        continue;
+                                    }
+
+                                    //质检节点合并pdfUrl
+                                    pdfUrlList.add(pdfUrlNodeAll);
+                                    //试验pdfUrl
+                                    pdfUrlList.add(record.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());
+                                    }
+                                }
+                            }
+                        }
                     }
                 }
             }
@@ -608,48 +663,31 @@ public class TrialSelfInspectionRecordServiceImpl
     }
 
     @Override
-    public String selfSubmit(TrialSelfInspectionRecordDTO dto) {
+    public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
         if (ObjectUtil.isEmpty(dto.getId()) && StringUtils.isNotEmpty(dto.getTableType())) {
             //构建记录表编号、报告单编号
             this.buildNumber(dto);
 
             //任务流程状态初始化未上报
             dto.setTaskStatus("未上报");
+        }
 
-            //初始化tabIds
-            JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
-            List<String> tableIds = new ArrayList<>();
-            for (int i = 0; i < dataArray.size(); i++) {
-                String pkeyId = dataArray.getJSONObject(i).getString("pkeyId");
-                tableIds.add(pkeyId);
-            }
-            String join = org.apache.commons.lang.StringUtils.join(tableIds, ",");
-            dto.setTableIds(join);
+        //初始化tabIds
+        JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
+        List<String> tableIds = new ArrayList<>();
+        for (int i = 0; i < dataArray.size(); i++) {
+            String pkeyId = dataArray.getJSONObject(i).getString("pkeyId");
+            tableIds.add(pkeyId);
         }
+        String join = org.apache.commons.lang.StringUtils.join(tableIds, ",");
+        dto.setTableIds(join);
+
         this.saveOrUpdate(dto);
 
         if (ObjectUtil.isNotEmpty(dto.getId())) {
             //获取当前最新的试验记录信息
             TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
 
-            //编辑时处理表单pKeyIds问题 TODO 如果前端传全pKeyId就不需要该逻辑
-            if (StringUtils.isNotEmpty(obj.getTableIds())) {
-                JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
-                List<String> tableIds = new ArrayList<>();
-                for (int i = 0; i < dataArray.size(); i++) {
-                    String pkeyId = dataArray.getJSONObject(i).getString("pkeyId");
-                    tableIds.add(pkeyId);
-                }
-                List<String> ids = Func.toStrList(obj.getTableIds());
-                tableIds.addAll(ids);
-
-                List<String> tabIds = tableIds.stream().distinct().collect(Collectors.toList());
-                dto.setTableIds(org.apache.commons.lang.StringUtils.join(tabIds, ","));
-                //更新当前记录绑定的最新的表单
-                this.saveOrUpdate(dto);
-                obj.setTableIds(dto.getTableIds());
-            }
-
             //编辑时生成记录表编号或报告单编号,如果新增时不是两种类型表都填报过,那么有一项编号为Null
             if (StringUtils.isEmpty(obj.getRecordNo()) && dto.getTableType().contains("1")) {
                 this.buildNumber(dto);
@@ -659,20 +697,53 @@ public class TrialSelfInspectionRecordServiceImpl
                 this.saveOrUpdate(dto);
             }
 
-            //保存实体表数据、试验记录信息、生成pdf
+            //TODO ------保存实体表数据、试验记录信息、生成pdf------
             try {
                 String pdfURL = excelTabClient.saveTabData(dto.getIsBatchSave(), dto.getDataInfo(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
                 if (StringUtils.isNotEmpty(pdfURL)) {
                     //修改合并pdf
-                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
-                            .set(TrialSelfInspectionRecord::getPdfUrl, pdfURL)
-                            .eq(TrialSelfInspectionRecord::getId, dto.getId()));
+                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
                 }
             } catch (Exception e) {
-                throw new ServiceException("保存实体表数据生成pdf时发生异常 " + e.getMessage());
+                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);
+            } else {
+                List<Long> recordIds = Func.toLongList(obj.getProjectPosition());
+                String delSql = "delete from u_trial_self_quality_project where self_id = " + obj.getId();
+                jdbcTemplate.execute(delSql);
+                //保留新增
+                for (Long recordNodeId : recordIds) {
+                    String insertSql = "insert into u_trial_self_quality_project(id,self_id,quality_node_id) values (" + SnowFlakeUtil.getId() + "," + obj.getId() + "," + recordNodeId + ")";
+                    jdbcTemplate.execute(insertSql);
+                }
+            }
+
+            //TODO ------关联原材料检测报告------
+            RawMaterialSubmitRelationDTO relationDTO = new RawMaterialSubmitRelationDTO();
+            relationDTO.setId(obj.getId().toString());
+            relationDTO.setIds(dto.getRawMaterialIds());
+            relationDTO.setNodeId(dto.getNodeId().toString());
+            relationDTO.setContractId(dto.getContractId().toString());
+            relationDTO.setProjectId(dto.getProjectId());
+            relationDTO.setType(dto.getType());
+            if (StringUtils.isNotEmpty(relationDTO.getIds())) {
+                this.rawMaterialSubmitRelation(relationDTO);
+            }
+
+            //TODO ------关联取样信息------
+            RecordSampleSubmitDTO recordSampleSubmitDTO = new RecordSampleSubmitDTO();
+            recordSampleSubmitDTO.setId(obj.getId());
+            recordSampleSubmitDTO.setSampleIds(dto.getSampleIds());
+            if (StringUtils.isNotEmpty(relationDTO.getIds())) {
+                this.recordSampleSubmit(recordSampleSubmitDTO);
             }
 
-            //新增设备使用记录信息
+            //TODO ------新增设备使用记录信息------
             this.trialDeviceUseService.addDeviceUseInfo(dto);
         }
 
@@ -681,6 +752,7 @@ public class TrialSelfInspectionRecordServiceImpl
     }
 
     @Override
+    @Async
     public boolean recordSampleSubmit(RecordSampleSubmitDTO dto) {
         if (ObjectUtil.isEmpty(dto.getId())) {
             throw new ServiceException("请先保存填报数据后,再关联取样信息");

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

@@ -1,7 +1,9 @@
 package org.springblade.manager.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.mixsmart.utils.StringUtils;
@@ -17,16 +19,15 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.support.Kv;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.manager.bean.TableInfo;
 import org.springblade.manager.dto.WbsTreePrivateDTO2;
 import org.springblade.manager.dto.WbsTreePrivateDTO3;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.mapper.WbsTreeContractMapper;
 import org.springblade.manager.mapper.WbsTreePrivateMapper;
-import org.springblade.manager.service.IProjectInfoService;
-import org.springblade.manager.service.IWbsFormElementService;
-import org.springblade.manager.service.IWbsTreePrivateService;
-import org.springblade.manager.service.IWbsTreeService;
+import org.springblade.manager.service.*;
 import org.springblade.manager.vo.*;
 import org.springblade.manager.wrapper.WbsTreePrivateWrapper;
 import org.springframework.beans.BeanUtils;
@@ -52,6 +53,7 @@ public class WbsTreePrivateController extends BladeController {
     private final IWbsTreeService wbsTreeService;
     private final IProjectInfoService projectInfoService;
     private final IWbsFormElementService wbsFormElementService;
+    private final IExcelTabService iExcelTabService;
 
     /**
      * 保存项目日志划分
@@ -605,8 +607,21 @@ public class WbsTreePrivateController extends BladeController {
     @GetMapping("/search-node-tables")
     @ApiOperationSupport(order = 22)
     @ApiOperation(value = "试验-根据所属方查询当前节点表信息", notes = "传入节点primaryKeyId;所属方type=1施工,=2监理 ;表单类型tableType=1记录表、=2报告单; 合同段id;项目id;isAdd=是否新增;记录id")
-    public R<List<WbsTreePrivate>> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId, Integer isAdd, Long id) {
-        return R.data(wbsTreePrivateService.searchNodeAllTable(primaryKeyId, type, tableType, contractId, projectId, isAdd, id));
+    public R<List<WbsTreePrivateVO4>> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId, Integer isAdd, Long id) {
+        List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateService.searchNodeAllTable(primaryKeyId, type, tableType, contractId, projectId, isAdd, id);
+        List<WbsTreePrivateVO4> list = new ArrayList<>();
+        //数据包装
+        for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
+            WbsTreePrivateVO4 wbsTreePrivateVO4 = BeanUtil.copyProperties(wbsTreePrivate, WbsTreePrivateVO4.class);
+            List<Map<String, Object>> bussDataInfoTrial = iExcelTabService.getBussDataInfoTrial(id, wbsTreePrivate.getPKeyId());
+            if (wbsTreePrivateVO4 != null && bussDataInfoTrial.size() > 0) {
+                wbsTreePrivateVO4.setBussDataInfoTrial(bussDataInfoTrial.get(0));
+            }
+            list.add(wbsTreePrivateVO4);
+        }
+        return R.data(list);
+
+        //return R.data(wbsTreePrivateService.searchNodeAllTable(primaryKeyId, type, tableType, contractId, projectId, isAdd, id));
     }
 
     /**

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

@@ -52,14 +52,14 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         String projectId = table.getString("projectId");
         String contractId = table.getString("contractId");
 
-        List<TableInfo> tableInfoList = this.excelTabService.getTableInfoListTrial(dataArray, tabIds);
+        List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
 
         String pdfUrl = "";
 
-        //入库-试验填报数据,当前记录id作为groupId
+        //TODO ------入库-试验填报数据,当前记录id作为groupId------
         this.excelTabService.saveOrUpdateInfoTrial(tableInfoList, id);
 
-        //公式填充
+        //TODO ------公式填充------
         try {
             this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId));
         } catch (Exception e) {
@@ -67,7 +67,7 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         }
 
         if (isBatchSave == 0) {
-            //单表PDF保存
+            //TODO ------单表PDF保存------
             TableInfo tableInfo = tableInfoList.stream().findAny().orElse(null);
             assert tableInfo != null;
             if (tabIds.contains(tableInfo.getPkeyId())) {
@@ -115,7 +115,7 @@ public class ExcelTabClientImpl implements ExcelTabClient {
             }
 
         } else if (isBatchSave == 1) {
-            //多表PDF保存
+            //TODO ------多表PDF保存------
             pdfUrl = excelTabService.getBussPDFSTrial(nodeId,
                     tableType, //tableType=表类型 1=记录表 2=报告单
                     String.valueOf(type), //type=所属方 1=施工质检 2=监理抽检
@@ -125,7 +125,7 @@ public class ExcelTabClientImpl implements ExcelTabClient {
                     tabIds //新增的表的pKeyIds
             );
 
-            //修改原材料检测报告原始pdfUrl
+            //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)) {

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

@@ -71,4 +71,7 @@ public interface ExcelTabMapper extends BaseMapper<ExcelTab> {
 	@Select("select trial_project_name from u_trial_self_inspection_record where id = #{id}")
     String selectTrialRecordOne(@Param("id") Long id);
 
+	@Select("select self_id from u_trial_self_quality_project where quality_node_id = #{nodeId}")
+	List<String> queryTrialRecordId(String nodeId);
+
 }

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

@@ -136,12 +136,6 @@ public interface IExcelTabService extends BaseService<ExcelTab> {
      */
     String getBussPDFSTrial(String nodeId, String tableType, String classify, String contractId, String projectId, Long id, String tabIds) throws Exception;
 
-    /**
-     * 表格数据封装 - 试验
-     */
-    List<TableInfo> getTableInfoListTrial(JSONArray dataArray, String tabIds);
-
-
     /**
      * 保存 首件数据
      */

+ 29 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -42,6 +42,7 @@ import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 import org.springblade.business.entity.InformationQuery;
+import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.feign.ContractLogClient;
 import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.business.feign.OperationLogClient;
@@ -1114,13 +1115,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 newStyle.cloneStyleFrom(cell.getCellStyle());
 
 
-
                 short fontHeightInPoints = redFont.getFontHeightInPoints();
-                if (fontHeightInPoints >= 14 && StringUtils.isEmpty(cell.getStringCellValue()) && fisRow<=8) {
+                if (fontHeightInPoints >= 14 && StringUtils.isEmpty(cell.getStringCellValue()) && fisRow <= 8) {
 
-                    String title=projectInfo.getProjectName();
-                    if(title.length()>=44){
-                        sheet.getRow(fisRow).setHeight((short)900);
+                    String title = projectInfo.getProjectName();
+                    if (title.length() >= 44) {
+                        sheet.getRow(fisRow).setHeight((short) 900);
                         newStyle.setWrapText(true);
                     }
                     redFont.setBold(true);
@@ -1147,7 +1147,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         if (val.indexOf("__") >= 0) {
                             String[] DataVal = val.split("__");
                             String[] xy = DataVal[1].split("_");
-                            if (Integer.parseInt(xy[0])<trs.size()) {
+                            if (Integer.parseInt(xy[0]) < trs.size()) {
                                 Element ytzData = trs.get(Integer.parseInt(xy[0]));
                                 if (ytzData != null) {
                                     Elements tdsx = ytzData.select("td");
@@ -1258,11 +1258,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         String key = e.getColKey();
                         String[] keys = key.split("__");
                         String[] trtd = keys[1].split("_");
-                        if (Integer.parseInt(trtd[0])<trs.size()) {
+                        if (Integer.parseInt(trtd[0]) < trs.size()) {
                             Element ytzData = trs.get(Integer.parseInt(trtd[0]));
                             if (ytzData != null) {
                                 Elements tdsx = ytzData.select("td");
-                                if (Integer.parseInt(trtd[1])<tdsx.size()) {
+                                if (Integer.parseInt(trtd[1]) < tdsx.size()) {
                                     Element data = ytzData.select("td").get(Integer.parseInt(trtd[1]));
                                     int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
                                     if (x1 == 0) {
@@ -1356,7 +1356,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     @Override
     public void getBussPdfs(String nodeId, String classify, String contractId, String projectId) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-       // String file_path = "/Users/hongchuangyanfa/Desktop/";
+        // String file_path = "/Users/hongchuangyanfa/Desktop/";
         // 获取有权限的节点信息
         List<AppWbsTreeContractVO> wbsTreeContractList = wbsTreeContractService.searchNodeAllTable(nodeId, classify, contractId, projectId);
         List<String> data = new ArrayList<>();
@@ -1381,6 +1381,22 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         if (tabpdf2.exists()) {
             tabpdf2.delete();
         }
+
+        //TODO ------ 试验pdf关联部位工程及信息 liuYC 2023-03-13 ------
+        //获取试验记录id
+        List<String> recordIds = baseMapper.queryTrialRecordId(nodeId).stream().distinct().collect(Collectors.toList());
+        String recordInfoSql = "select detection_category,detection_result,task_status,pdf_url from u_trial_self_inspection_record where 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);
+            }
+        }
+
         FileUtils.mergePdfPublicMethods(data, listPdf);
         BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
 
@@ -1388,13 +1404,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
 
         // 获取顺序
-        int sort =0;
-        if(ObjectUtil.isNotEmpty(wbsTreeContract)){
-            if(wbsTreeContract.getSort()!=null){
+        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 +" 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);
     }