|
@@ -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()) {
|