|
@@ -2087,40 +2087,66 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean saveBaseInfo(TrialSeleInspectionRecordInfoDTO dto) {
|
|
|
+ public Long saveBaseInfo(TrialSeleInspectionRecordInfoDTO dto) {
|
|
|
TrialSelfInspectionRecord record = new TrialSelfInspectionRecord();
|
|
|
BeanUtil.copyProperties(dto, record);
|
|
|
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();
|
|
|
+ TrialSampleInfo info = dto.getTrialSampleInfo();
|
|
|
+ if (trialSampleInfoList == null) {
|
|
|
+ trialSampleInfoList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ if (info != null) {
|
|
|
+ trialSampleInfoList.add(info);
|
|
|
+ }
|
|
|
+ if (!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())){
|
|
|
//修改项目节点基础信息
|
|
|
jdbcTemplate.update("update u_entrust_info set sample_status=4 where id ='"+dto.getEntrustId()+"'");
|
|
|
}
|
|
|
- return true;
|
|
|
+ return record.getId();
|
|
|
}
|
|
|
|
|
|
|