Pārlūkot izejas kodu

试验bug修改

lvy 1 mēnesi atpakaļ
vecāks
revīzija
26d2bd11a3

+ 1 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSeleInspectionRecordInfoDTO.java

@@ -78,5 +78,6 @@ public class TrialSeleInspectionRecordInfoDTO extends TrialSeleInspectionRecordB
 		private Long id;
 		@ApiModelProperty("name")
 		private String name;
+		private List<StandardVo> info;
 	}
 }

+ 28 - 13
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -602,7 +602,7 @@ public class TrialDetectionController extends BladeController {
                     List<TrialSelfSample> selfSampleList = jdbcTemplate.query("select * from u_trial_self_sample where self_id = " + id, new BeanPropertyRowMapper<>(TrialSelfSample.class));
                     if (!selfSampleList.isEmpty()) {
                         String samplingIds = selfSampleList.stream().map(TrialSelfSample::getSamplingId).map(String::valueOf).collect(Collectors.joining(","));
-                        if (samplingIds != null && !"".equals(samplingIds)) {
+                        if (!samplingIds.isEmpty()) {
                             List<TrialSampleInfo> trialSampleInfoList = jdbcTemplate.query("select * from u_trial_sample_info where id in (" + samplingIds + ")", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
                             vo.setTrialSampleInfo(trialSampleInfoList.isEmpty() ? new TrialSampleInfo() : trialSampleInfoList.get(0));
                         }
@@ -614,21 +614,36 @@ public class TrialDetectionController extends BladeController {
                 vo.setStandardId(record.getStandardId());
                 vo.setStandardInfoIds(record.getStandardInfoIds());
                 if (record.getStandardInfoIds() != null && !record.getStandardInfoIds().isEmpty()) {
-                    List<StandardInfo> standardInfoList = jdbcTemplate.query("select * from u_standard_info where id in (" + record.getStandardInfoIds() + ")", new BeanPropertyRowMapper<>(StandardInfo.class));
+                    List<StandardInfo> standardInfoList = jdbcTemplate.query("select id,parent_id,name from u_standard_info where id in (" + record.getStandardInfoIds() + ")", new BeanPropertyRowMapper<>(StandardInfo.class));
                     if (!standardInfoList.isEmpty()) {
-                        Set<Long> ids = standardInfoList.stream().map(StandardInfo::getParentId).collect(Collectors.toSet());
-                        List<StandardInfo> parentStandardInfoList = jdbcTemplate.query("select * from u_standard_info where id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(StandardInfo.class));
+                        String ids = standardInfoList.stream().map(info -> info.getParentId() + "").distinct().collect(Collectors.joining(","));
+                        List<StandardInfo> allStandardInfoList = jdbcTemplate.query("select id,parent_id,name from u_standard_info where id in (" + ids + ") UNION select id,parent_id,name from u_standard_info where parent_id in ( " + ids + " )", new BeanPropertyRowMapper<>(StandardInfo.class));
                         Map<Long, List<StandardInfo>> map = standardInfoList.stream().collect(Collectors.groupingBy(StandardInfo::getParentId));
-                        List<TrialSeleInspectionRecordInfoDTO.StandardVo> standardVos = new ArrayList<>();
-                        parentStandardInfoList.forEach(standardInfo -> {
-                            TrialSeleInspectionRecordInfoDTO.StandardVo standardVo = new TrialSeleInspectionRecordInfoDTO.StandardVo();
-                            List<StandardInfo> list = map.get(standardInfo.getId());
-                            if (list != null && !list.isEmpty()) {
-                                standardVo.setId(list.get(0).getId());
-                                standardVo.setName(standardInfo.getName());
-                                standardVos.add(standardVo);
+                        Map<Long, List<StandardInfo>> allStandardInfoMap = allStandardInfoList.stream().peek(standardInfo -> {
+                            if (standardInfo.getParentId() == null) {
+                                standardInfo.setParentId(0L);
                             }
-                        });
+                        }).collect(Collectors.groupingBy(StandardInfo::getParentId));
+                        List<TrialSeleInspectionRecordInfoDTO.StandardVo> standardVos = new ArrayList<>();
+                        List<StandardInfo> parentStandardInfos = allStandardInfoMap.get(0L);
+                        if (parentStandardInfos != null && !parentStandardInfos.isEmpty()) {
+                            parentStandardInfos.forEach(standardInfo -> {
+                                TrialSeleInspectionRecordInfoDTO.StandardVo standardVo = new TrialSeleInspectionRecordInfoDTO.StandardVo();
+                                List<StandardInfo> list = map.get(standardInfo.getId());
+                                if (list != null && !list.isEmpty()) {
+                                    standardVo.setId(list.get(0).getId());
+                                    standardVo.setName(standardInfo.getName());
+                                    List<StandardInfo> standardInfos = allStandardInfoMap.get(standardInfo.getId());
+                                    standardVo.setInfo(standardInfos.stream().map(info -> {
+                                        TrialSeleInspectionRecordInfoDTO.StandardVo standardVo1 = new TrialSeleInspectionRecordInfoDTO.StandardVo();
+                                        standardVo1.setId(info.getId());
+                                        standardVo1.setName(info.getName());
+                                        return standardVo1;
+                                    }).collect(Collectors.toList()));
+                                    standardVos.add(standardVo);
+                                }
+                            });
+                        }
                         vo.setStandardInfos(standardVos);
                     }
                 }

+ 120 - 21
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -114,7 +114,24 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 queryWrapper.lambda().in(TrialSelfInspectionRecord::getNodeId, pIds);
             }
             if (StringUtils.isNotEmpty(dto.getQueryValue())) {
-                queryWrapper.lambda().like(TrialSelfInspectionRecord::getTrialProjectName, dto.getQueryValue());
+                //查询委托单编码
+                List<EntrustInfo> entrustInfos = entrustInfoMapper.selectList(Wrappers.<EntrustInfo>lambdaQuery()
+                        .like(EntrustInfo::getEntrustNo, dto.getQueryValue()));
+                List<Long> entrustIds;
+                if(CollectionUtil.isNotEmpty(entrustInfos)){
+                    entrustIds = entrustInfos.stream().map(EntrustInfo::getId).collect(Collectors.toList());
+                } else {
+                    entrustIds = null;
+                }
+
+                queryWrapper.lambda().and(
+                        wq ->
+                            wq.like(TrialSelfInspectionRecord::getTrialProjectName, dto.getQueryValue()).or()
+                                    .like(TrialSelfInspectionRecord::getRecordNo, dto.getQueryValue()).or()
+                                    .like(TrialSelfInspectionRecord::getReportNo, dto.getQueryValue()).or()
+                                    .like(TrialSelfInspectionRecord::getSpecificationNumber, dto.getQueryValue()).or()
+                                    .in(CollectionUtil.isNotEmpty(entrustIds),TrialSelfInspectionRecord::getEntrustId, entrustIds)
+                );
             }
             if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getStartTime()) && org.apache.commons.lang.StringUtils.isNotEmpty(dto.getEndTime())) {
                 String endTime = dto.getEndTime();
@@ -301,7 +318,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
      * @throws FileNotFoundException
      */
     private String getMergePdfToTrialNew(Long contractId, Long nodeId, Integer type) throws FileNotFoundException {
-        String sql = "select pdf_url,e_visa_pdf_url from u_information_query where wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' and classify = '" + type + "'" ;
+        String sql = "select pdf_url,e_visa_pdf_url from u_information_query where wbs_id='" + nodeId + "' and status in(0,1,2) and contract_id ='" + contractId + "' and classify = '" + type + "'" ;
         List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
         if (maps.size() >= 1) {
             Map<String, Object> stringObjectMap = maps.get(0);
@@ -1157,23 +1174,31 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             if (dto.getOldRecordNumber()!=null&&dto.getOldRecordNumber().equals(dto.getRecordNo())||dto.getOldReportNumber()!=null&&dto.getOldReportNumber().equals(dto.getReportNo())) {
                 if(strings.length==1){
                     if(strings[0].equals("1")){
-                        trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),4,dto.getId(),dto.getRecordAutoNumber());
+                        if(StringUtils.isNotEmpty(dto.getRecordAutoNumber())){
+                            trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),4,dto.getId(),dto.getRecordAutoNumber());
+                        }
                     }else {
-                        trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),5,dto.getId(),dto.getReportAutoNumber());
+                        if(StringUtils.isNotEmpty(dto.getReportAutoNumber())){
+                            trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),5,dto.getId(),dto.getReportAutoNumber());
+                        }
                     }
                 }else {
-                    trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),4,dto.getId(),dto.getRecordAutoNumber());
-                    trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),5,dto.getId(),dto.getReportAutoNumber());
+                    if(StringUtils.isNotEmpty(dto.getRecordAutoNumber())){
+                        trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),4,dto.getId(),dto.getRecordAutoNumber());
+                    }
+                    if(StringUtils.isNotEmpty(dto.getReportAutoNumber())){
+                        trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),5,dto.getId(),dto.getReportAutoNumber());
+                    }
                 }
             }
-            if(strings.length==1&&strings[0].equals("1")){
-                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 4 + ":" + dto.getId() + ":" + "lock:" + dto.getRecordAutoNumber());
-            }else if(strings.length==1&&strings[0].equals("2")){
-                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 5 + ":" + dto.getId() + ":" + "lock:" + dto.getReportAutoNumber());
-            }else {
-                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 4 + ":" + dto.getId() + ":" + "lock:" + dto.getRecordAutoNumber());
-                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 5 + ":" + dto.getId() + ":" + "lock:" + dto.getReportAutoNumber());
-            }
+//            if(strings.length==1&&strings[0].equals("1")){
+//                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 4 + ":" + dto.getId() + ":" + "lock:" + dto.getRecordAutoNumber());
+//            }else if(strings.length==1&&strings[0].equals("2")){
+//                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 5 + ":" + dto.getId() + ":" + "lock:" + dto.getReportAutoNumber());
+//            }else {
+//                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 4 + ":" + dto.getId() + ":" + "lock:" + dto.getRecordAutoNumber());
+//                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 5 + ":" + dto.getId() + ":" + "lock:" + dto.getReportAutoNumber());
+//            }
         }
         return dto.getId().toString();
     }
@@ -2106,16 +2131,37 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     public Long saveBaseInfo(TrialSeleInspectionRecordInfoDTO dto) {
         TrialSelfInspectionRecord record = new TrialSelfInspectionRecord();
         BeanUtil.copyProperties(dto, record);
+        if (record.getEntrustId() == null) {
+            record.setEntrustId(0L);
+        }
+        TrialSelfInspectionRecord oldRecord = null;
+        EntrustInfo oldEntrustInfo = null;
+        TrialSampleInfo oldTrialSampleInfo = null;
+        if (dto.getId() != null) {
+            oldRecord = baseMapper.selectById(dto.getId());
+            if (oldRecord != null) {
+                if (oldRecord.getTaskStatus() != null && !oldRecord.getTaskStatus().equals("未上报") && !oldRecord.getTaskStatus().isEmpty()) {
+                    throw new ServiceException("当前试验已上报,请勿修改");
+                }
+                if (oldRecord.getEntrustId() != null) {
+                    oldEntrustInfo = entrustInfoMapper.selectById(oldRecord.getEntrustId());
+                }
+                try {
+                    if (oldRecord.getBaseInfo() != null && !oldRecord.getBaseInfo().isEmpty()) {
+                        TrialSeleInspectionRecordBaseInfoDTO baseInfo = JSONObject.parseObject(oldRecord.getBaseInfo(), TrialSeleInspectionRecordBaseInfoDTO.class);
+                        if (baseInfo != null) {
+                            oldTrialSampleInfo = baseInfo.getTrialSampleInfo();
+                        }
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
         TrialSeleInspectionRecordBaseInfoDTO baseInfo = new TrialSeleInspectionRecordBaseInfoDTO();
         BeanUtil.copyProperties(dto, baseInfo);
-        record.setBaseInfo(JSON.toJSONString(baseInfo));
-        if (record.getId() == null) {
-            this.save(record);
-        } else {
-            this.updateById(record);
-        }
         EntrustInfo entrustInfo = null;
-        if (record.getEntrustId() != null) {
+        if (record.getEntrustId() != null && record.getEntrustId() > 0) {
             entrustInfo = entrustInfoMapper.selectById(record.getEntrustId());
         }
         List<TrialSampleInfo> trialSampleInfoList = dto.getTrialSampleInfoList();
@@ -2133,6 +2179,46 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 }
             }
         }
+        if ((entrustInfo == null && oldEntrustInfo != null) && info != null) {
+            // 判断是否关联,如果关联一起取消
+            if (oldEntrustInfo.getSampleId() != null && oldEntrustInfo.getSampleId().equals(info.getId())) {
+                //删除关联
+                baseMapper.delSelfSample(record.getId());
+                info = null;
+                baseInfo.setTrialSampleInfo(null);
+            }
+        }
+        if (entrustInfo != null && info == null && oldTrialSampleInfo != null) {
+            if (entrustInfo.getSampleId() != null && entrustInfo.getSampleId().equals(oldTrialSampleInfo.getId())) {
+                record.setEntrustId(null);
+                baseInfo.setEntrustId( null);
+                baseInfo.setEntrustNo(null);
+            }
+        }
+        boolean a=true;
+        boolean b=true;
+        record.setBaseInfo(JSON.toJSONString(baseInfo));
+        if (oldRecord == null) {
+            if(StringUtils.isNotEmpty(record.getRecordNo())){
+                if(StringUtils.isNotEmpty(record.getRecordNo())){
+                    a= trialNumberRuleService.checkTrialNumberIsExist(record.getRecordNo(), 4);
+                }
+            }
+            if(StringUtils.isNotEmpty(record.getRecordNo())){
+                if(StringUtils.isNotEmpty(record.getReportNo())){
+                    b= trialNumberRuleService.checkTrialNumberIsExist(record.getReportNo(), 5);
+                }
+            }
+            if(!a){
+                throw new ServiceException("记录编号已存在");
+            }
+            if(!b){
+                throw new ServiceException("报告编号已存在");
+            }
+            this.save(record);
+        } else {
+            this.updateById(record);
+        }
         if (info != null) {
             TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(info.getId());
             if (sampleInfo != null) {
@@ -2209,6 +2295,19 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             recordDTO.setTrialUserName(AuthUtil.getUserName());
             this.trialDeviceUseService.addDeviceUseInfo(recordDTO, record.getId());
         }
+            if(dto.getOldRecordNumber()!=null&&dto.getOldRecordNumber().equals(dto.getRecordNo())){
+                if(StringUtils.isNotEmpty(dto.getRecordAutoNumber())){
+                    trialNumberRuleService.checkSave(dto.getContractId(),4,record.getId(),dto.getRecordAutoNumber());
+                    bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 4 + ":" + record.getNodeId() + ":" + "lock:" + dto.getRecordAutoNumber());
+                }
+            }
+            if(dto.getOldReportNumber()!=null&&dto.getOldReportNumber().equals(dto.getReportNo())){
+                if(StringUtils.isNotEmpty(dto.getReportAutoNumber())){
+                    trialNumberRuleService.checkSave(dto.getContractId(),5,record.getId(),dto.getReportAutoNumber());
+                    bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 5 + ":" + record.getNodeId() + ":" + "lock:" + dto.getReportAutoNumber());
+                }
+            }
+
         return record.getId();
     }