Răsfoiți Sursa

试验基础信息保存修改,试验表单空白部分补充/

lvy 1 lună în urmă
părinte
comite
ac92cfd593

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

@@ -544,7 +544,7 @@ public class TrialDetectionController extends BladeController {
     @GetMapping("/self/getBaseInfo")
     @ApiOperationSupport(order = 30)
     @ApiOperation(value = "获取试验自检基础信息", notes = "传入节点pKeyId")
-    public R<TrialSeleInspectionRecordInfoDTO> getBaseInfo(@RequestParam Long projectId, @RequestParam Long contractId, @RequestParam Long nodeId, @RequestParam(required = false) Long id, @RequestParam(required = false) Boolean isReacquire) {
+    public R<TrialSeleInspectionRecordInfoDTO> getBaseInfo(@RequestParam Long projectId, @RequestParam Long contractId, @RequestParam Long nodeId, @RequestParam(required = false) Long id, @RequestParam(required = false, defaultValue = "false") Boolean isReacquire) {
         ProjectInfo projectInfo = jdbcTemplate.query("select * from m_project_info where id = " + projectId, new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().findAny().orElse(null);
         if (projectInfo == null) {
             return R.fail("未获取到项目信息");
@@ -674,7 +674,7 @@ public class TrialDetectionController extends BladeController {
             vo.setReportNo(map.get("trialNumber"));
             vo.setReportAutoNumber(map.get("trialAutoNumber"));
         }
-        List<TrialSeleInspectionRecordInfoDTO.StandardVo> mapList = jdbcTemplate.query("SELECT id,name from u_wbs_private_standard WHERE type = 2 and is_deleted = 0 and status = 1 and private_id = " + nodeId,
+        List<TrialSeleInspectionRecordInfoDTO.StandardVo> mapList = jdbcTemplate.query("SELECT id,name from u_wbs_private_standard WHERE type = 2 and is_deleted = 0  and private_id = " + nodeId,
                 new BeanPropertyRowMapper<>(TrialSeleInspectionRecordInfoDTO.StandardVo.class));
         vo.setStandardVos(mapList);
         return R.data(vo);
@@ -688,6 +688,25 @@ public class TrialDetectionController extends BladeController {
         return R.data(iTrialSelfInspectionRecordService.saveBaseInfo(vo));
     }
 
+    @GetMapping("/self/getTrialSampleInfoByEntrustId")
+    @ApiOperation(value = "根据委托单查询样品信息")
+    public R<TrialSampleInfo> getTrialSampleInfoByEntrustId(@RequestParam Long entrustId) {
+        EntrustInfo entrustInfo = jdbcTemplate.query("select * from u_entrust_info where id = " + entrustId, new BeanPropertyRowMapper<>(EntrustInfo.class)).stream().findAny().orElse(null);
+        if (entrustInfo != null && entrustInfo.getSampleId() != null) {
+            List<TrialSampleInfo> trialSampleInfoList = jdbcTemplate.query("select * from u_trial_sample_info where id = (" + entrustInfo.getSampleId() + ")", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
+            TrialSampleInfo sampleInfo = trialSampleInfoList.stream().findFirst().orElse(null);
+            return R.data(sampleInfo);
+        }
+        return R.data(null);
+    }
+
+    @GetMapping("/self/getEntrustInfoBySampleId")
+    @ApiOperation(value = "根据样品id查询关联的委托单信息")
+    public R<EntrustInfo> getEntrustInfoBySampleId(@RequestParam Long sampleId) {
+        EntrustInfo entrustInfo = jdbcTemplate.query("select * from u_entrust_info where sample_id = " + sampleId, new BeanPropertyRowMapper<>(EntrustInfo.class)).stream().findAny().orElse(null);
+        return R.data(entrustInfo);
+    }
+
     /**
      * 获取最近一次使用的设备信息
      */

+ 69 - 36
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -2114,56 +2114,89 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         } else {
             this.updateById(record);
         }
+        EntrustInfo entrustInfo = null;
+        if (record.getEntrustId() != null) {
+            entrustInfo = entrustInfoMapper.selectById(record.getEntrustId());
+        }
         List<TrialSampleInfo> trialSampleInfoList = dto.getTrialSampleInfoList();
         TrialSampleInfo info = dto.getTrialSampleInfo();
-        if (trialSampleInfoList == null) {
-            trialSampleInfoList = new ArrayList<>();
+        if (info == null && !trialSampleInfoList.isEmpty()) {
+            info = trialSampleInfoList.get(0);
+        }
+        if (entrustInfo != null && info != null) {
+            // 判断是否冲突
+            if (entrustInfo.getSampleId() != null && !entrustInfo.getSampleId().equals(info.getId())) {
+                // 判断是否是现场试验节点
+                WbsTreePrivate wbs = wbsTreePrivateClient.getNodeByPrimaryKeyId(entrustInfo.getNodeId());
+                if (wbs == null || wbs.getNodeType() != 51) {
+                    throw new ServiceException("关联的委托单与取样材料不匹配,请重新选择");
+                }
+            }
         }
         if (info != null) {
-            trialSampleInfoList.add(info);
+            TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(info.getId());
+            if (sampleInfo != null) {
+                //------关联取样信息------
+                RecordSampleSubmitDTO sampleSubmitDTO = new RecordSampleSubmitDTO();
+                sampleSubmitDTO.setId(record.getId());
+                sampleSubmitDTO.setSampleIds(info.getId() + "");
+                //删除关联
+                baseMapper.delSelfSample(record.getId());
+                baseMapper.saveSelfSample(SnowFlakeUtil.getId(), record.getId(), info.getId() + "");
+                String samplingLocation = sampleInfo.getSamplingLocation();
+                String calculationUnit = sampleInfo.getCalculationUnit();
+                String specificationNumber = info.getSpecificationNumber();
+                String specificationModel = sampleInfo.getSpecificationModel();
+                //更新
+                if (StringUtils.isNotBlank(samplingLocation) || StringUtils.isNotBlank(calculationUnit) || StringUtils.isNotBlank(specificationNumber) || StringUtils.isNotBlank(specificationModel)) {
+                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                            .set(StringUtils.isNotBlank(samplingLocation), TrialSelfInspectionRecord::getSamplingLocation, samplingLocation)
+                            .set(StringUtils.isNotBlank(calculationUnit),TrialSelfInspectionRecord::getCompany, calculationUnit)
+                            .set(StringUtils.isNotBlank(specificationNumber),TrialSelfInspectionRecord::getSpecificationNumber, specificationNumber)
+                            .set(StringUtils.isNotBlank(specificationModel),TrialSelfInspectionRecord::getSpecificationModel, specificationModel)
+                            .eq(TrialSelfInspectionRecord::getId, record.getId()));
+                }
+                if (entrustInfo == null) {
+                    // 根据样品关联的委托单关联委托单
+                    entrustInfo = entrustInfoMapper.selectList(Wrappers.<EntrustInfo>lambdaQuery().eq(EntrustInfo::getSampleId, info.getId())).stream().findFirst().orElse(null);
+                    if (entrustInfo != null) {
+                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                                .set(TrialSelfInspectionRecord::getEntrustId, entrustInfo.getId())
+                                .eq(TrialSelfInspectionRecord::getId, record.getId()));
+                    }
+                }
+            }
         }
-        if (!trialSampleInfoList.isEmpty()) {
-            List<TrialSampleInfo> trialSampleInfos = new ArrayList<>();
-            trialSampleInfoList.forEach(trialSampleInfo -> {
-                TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(trialSampleInfo.getId());
+        // ---- 修改样品单号信息 --------
+        if(entrustInfo != null){
+            //修改项目节点基础信息
+            jdbcTemplate.update("update u_entrust_info set sample_status=4 where id ='"+entrustInfo.getId()+"'");
+            if (entrustInfo.getSampleId() != null) {
+                TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(entrustInfo.getSampleId());
                 if (sampleInfo != null) {
                     //------关联取样信息------
                     RecordSampleSubmitDTO sampleSubmitDTO = new RecordSampleSubmitDTO();
                     sampleSubmitDTO.setId(record.getId());
-                    sampleSubmitDTO.setSampleIds(trialSampleInfo.getId() + "");
+                    sampleSubmitDTO.setSampleIds(sampleInfo.getId() + "");
                     //删除关联
                     baseMapper.delSelfSample(record.getId());
-                    baseMapper.saveSelfSample(SnowFlakeUtil.getId(), record.getId(), trialSampleInfo.getId() + "");
-                    trialSampleInfos.add(sampleInfo);
+                    baseMapper.saveSelfSample(SnowFlakeUtil.getId(), record.getId(), sampleInfo.getId() + "");
+                    String samplingLocation = sampleInfo.getSamplingLocation();
+                    String calculationUnit = sampleInfo.getCalculationUnit();
+                    String specificationNumber = sampleInfo.getSpecificationNumber();
+                    String specificationModel = sampleInfo.getSpecificationModel();
+                    //更新
+                    if (StringUtils.isNotBlank(samplingLocation) || StringUtils.isNotBlank(calculationUnit) || StringUtils.isNotBlank(specificationNumber) || StringUtils.isNotBlank(specificationModel)) {
+                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                                .set(StringUtils.isNotBlank(samplingLocation), TrialSelfInspectionRecord::getSamplingLocation, samplingLocation)
+                                .set(StringUtils.isNotBlank(calculationUnit),TrialSelfInspectionRecord::getCompany, calculationUnit)
+                                .set(StringUtils.isNotBlank(specificationNumber),TrialSelfInspectionRecord::getSpecificationNumber, specificationNumber)
+                                .set(StringUtils.isNotBlank(specificationModel),TrialSelfInspectionRecord::getSpecificationModel, specificationModel)
+                                .eq(TrialSelfInspectionRecord::getId, record.getId()));
+                    }
                 }
-            });
-            List<String> samplingLocations = trialSampleInfos.stream().map(TrialSampleInfo::getSamplingLocation).filter(string -> string !=null && !string.isEmpty()).collect(Collectors.toList());
-            String samplingLocation = org.apache.commons.lang.StringUtils.join(samplingLocations, "、");
-
-            List<String> calculationUnits = trialSampleInfos.stream().map(TrialSampleInfo::getCalculationUnit).filter(string -> string !=null && !string.isEmpty()).collect(Collectors.toList());
-            String calculationUnit = org.apache.commons.lang.StringUtils.join(calculationUnits, "、");
-
-            List<String> specificationNumbers = trialSampleInfoList.stream().map(TrialSampleInfo::getSpecificationNumber).filter(string -> string !=null && !string.isEmpty()).collect(Collectors.toList());
-            String specificationNumber = org.apache.commons.lang.StringUtils.join(specificationNumbers, "、");
-
-            List<String> specificationModels = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationModel).filter(string -> string !=null && !string.isEmpty()).collect(Collectors.toList());
-            String specificationModel = org.apache.commons.lang.StringUtils.join(specificationModels, "、");
-
-            //更新
-            if (StringUtils.isNotBlank(samplingLocation) || StringUtils.isNotBlank(calculationUnit) || StringUtils.isNotBlank(specificationNumber) || StringUtils.isNotBlank(specificationModel)) {
-                this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
-                        .set(StringUtils.isNotBlank(samplingLocation), TrialSelfInspectionRecord::getSamplingLocation, samplingLocation)
-                        .set(StringUtils.isNotBlank(calculationUnit),TrialSelfInspectionRecord::getCompany, calculationUnit)
-                        .set(StringUtils.isNotBlank(specificationNumber),TrialSelfInspectionRecord::getSpecificationNumber, specificationNumber)
-                        .set(StringUtils.isNotBlank(specificationModel),TrialSelfInspectionRecord::getSpecificationModel, specificationModel)
-                        .eq(TrialSelfInspectionRecord::getId, record.getId()));
             }
         }
-        // ---- 修改样品单号信息 --------
-        if(Func.isNotEmpty(dto.getEntrustId())){
-            //修改项目节点基础信息
-            jdbcTemplate.update("update u_entrust_info set sample_status=4 where id ='"+dto.getEntrustId()+"'");
-        }
         //------关联新增设备使用记录信息------
         List<TrailDeviceUseInfoDTO> deviceUseInfoDTOS = dto.getTrailDeviceUseInfoDTOS();
         if (deviceUseInfoDTOS != null && !deviceUseInfoDTOS.isEmpty()) {

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

@@ -12,8 +12,6 @@ import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.nodes.Node;
 import org.jsoup.select.Elements;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springblade.business.dto.ReSigningEntrustDto;
 import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.business.entity.ContractLog;
@@ -40,7 +38,6 @@ import org.springblade.manager.utils.FileUtils;
 import org.springblade.manager.utils.RandomNumberHolder;
 import org.springblade.manager.vo.TrialSelfDataRecordVO1;
 import org.springblade.resource.feign.NewIOSSClient;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.RestController;
@@ -90,7 +87,7 @@ public class ExcelTabClientImpl implements ExcelTabClient {
 
         //应用抽取的数据
         dataArray = excelTabService.addLoadDataInfo(dataArray);
-
+        dataArray = putIfAbsent(dataArray);
         List<TableInfo> tableInfoList = this.excelTabService.getTableInfoListTrial(dataArray, tabIds);
         try {
             //试验特殊处理
@@ -884,4 +881,28 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         return R.data(resultMapList);
     }
 
+    private JSONArray putIfAbsent(JSONArray jsonArray) {
+        JSONArray json2 = new JSONArray();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject jsonObject = jsonArray.getJSONObject(i);
+            String pkeyId = jsonObject.getString("pkeyId");
+            WbsTreePrivate wbsTreePrivate = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pkeyId));
+            String htmlString = null;
+            try {
+                htmlString = IoUtil.readToString(FileUtils.getInputStreamByUrl(wbsTreePrivate.getHtmlUrl()));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            Document doc = Jsoup.parse(htmlString);
+            for (Element element : doc.getElementsByAttributeValueStarting("id", "key_")) {
+                String id = element.attr("id");
+                String text = jsonObject.getString(id);
+                if (text == null || text.trim().isEmpty()) {
+                    jsonObject.put(id, "/");
+                }
+            }
+            json2.add(jsonObject);
+        }
+        return json2;
+    }
 }