Просмотр исходного кода

Merge branch 'lvy' of http://219.151.181.73:3000/zhuwei/bladex into test-merge-02

lvy 3 месяцев назад
Родитель
Сommit
ba34a75f44

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

@@ -65,6 +65,10 @@ public class TrialSeleInspectionRecordInfoDTO extends TrialSeleInspectionRecordB
 	@ApiModelProperty("设备信息和使用信息")
 	private List<TrailDeviceUseInfoDTO> trailDeviceUseInfoDTOS;
 
+
+	@ApiModelProperty("样品信息")
+	private List<TrialSampleInfo> trialSampleInfoList;
+
 	@Data
 	public static class StandardVo {
 		@ApiModelProperty("id")

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

@@ -2101,27 +2101,46 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         TrialSeleInspectionRecordBaseInfoDTO baseInfo = new TrialSeleInspectionRecordBaseInfoDTO();
         BeanUtil.copyProperties(dto, baseInfo);
         record.setBaseInfo(JSON.toJSONString(baseInfo));
-        this.saveOrUpdate(record);
-        TrialSampleInfo trialSampleInfo = dto.getTrialSampleInfo();
-        if (trialSampleInfo != null) {
-            TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(trialSampleInfo.getId());
-            if (sampleInfo != null) {
-                //------关联取样信息------
-                RecordSampleSubmitDTO sampleSubmitDTO = new RecordSampleSubmitDTO();
-                sampleSubmitDTO.setId(record.getId());
-                sampleSubmitDTO.setSampleIds(trialSampleInfo.getId() + "");
-                //删除关联
-                baseMapper.delSelfSample(record.getId());
-                baseMapper.saveSelfSample(SnowFlakeUtil.getId(), record.getId(), trialSampleInfo.getId() + "");
-                //更新
-                this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
-                        .set(sampleInfo.getSamplingLocation() != null && !sampleInfo.getSamplingLocation().isEmpty(),TrialSelfInspectionRecord::getSamplingLocation, sampleInfo.getSamplingLocation())
-                        .set(sampleInfo.getCalculationUnit() != null && !sampleInfo.getCalculationUnit().isEmpty(), TrialSelfInspectionRecord::getCompany, sampleInfo.getCalculationUnit())
-                        .set(trialSampleInfo.getSpecificationNumber() != null && !trialSampleInfo.getSpecificationNumber().isEmpty(), TrialSelfInspectionRecord::getSpecificationNumber, trialSampleInfo.getSpecificationNumber())
-                        .set(sampleInfo.getSpecificationModel() != null && !sampleInfo.getSpecificationModel().isEmpty(), TrialSelfInspectionRecord::getSpecificationModel, sampleInfo.getSpecificationModel())
-                        .eq(TrialSelfInspectionRecord::getId, sampleSubmitDTO.getId())
-                );
-            }
+        if (record.getId() == null) {
+            this.save(record);
+        } else {
+            this.updateById(record);
+        }
+        List<TrialSampleInfo> trialSampleInfoList = dto.getTrialSampleInfoList();
+        if (trialSampleInfoList != null && !trialSampleInfoList.isEmpty()) {
+            List<TrialSampleInfo> trialSampleInfos = new ArrayList<>();
+            trialSampleInfoList.forEach(trialSampleInfo -> {
+                TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(trialSampleInfo.getId());
+                if (sampleInfo != null) {
+                    //------关联取样信息------
+                    RecordSampleSubmitDTO sampleSubmitDTO = new RecordSampleSubmitDTO();
+                    sampleSubmitDTO.setId(record.getId());
+                    sampleSubmitDTO.setSampleIds(trialSampleInfo.getId() + "");
+                    //删除关联
+                    baseMapper.delSelfSample(record.getId());
+                    baseMapper.saveSelfSample(SnowFlakeUtil.getId(), record.getId(), trialSampleInfo.getId() + "");
+                    trialSampleInfos.add(sampleInfo);
+                }
+            });
+            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, "、");
+
+            //更新
+            this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                    .set(samplingLocation != null && !samplingLocation.isEmpty(), TrialSelfInspectionRecord::getSamplingLocation, samplingLocation)
+                    .set(calculationUnit != null && !calculationUnit.isEmpty(),TrialSelfInspectionRecord::getCompany, calculationUnit)
+                    .set(specificationNumber != null && !specificationNumber.isEmpty(),TrialSelfInspectionRecord::getSpecificationNumber, specificationNumber)
+                    .set(specificationModel != null && !specificationModel.isEmpty(),TrialSelfInspectionRecord::getSpecificationModel, specificationModel)
+                    .eq(TrialSelfInspectionRecord::getId, dto.getId()));
         }
         // ---- 修改样品单号信息 --------
         if(Func.isNotEmpty(dto.getEntrustId())){