|
@@ -2124,16 +2124,37 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
public Long saveBaseInfo(TrialSeleInspectionRecordInfoDTO dto) {
|
|
public Long saveBaseInfo(TrialSeleInspectionRecordInfoDTO dto) {
|
|
TrialSelfInspectionRecord record = new TrialSelfInspectionRecord();
|
|
TrialSelfInspectionRecord record = new TrialSelfInspectionRecord();
|
|
BeanUtil.copyProperties(dto, record);
|
|
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();
|
|
TrialSeleInspectionRecordBaseInfoDTO baseInfo = new TrialSeleInspectionRecordBaseInfoDTO();
|
|
BeanUtil.copyProperties(dto, baseInfo);
|
|
BeanUtil.copyProperties(dto, baseInfo);
|
|
- record.setBaseInfo(JSON.toJSONString(baseInfo));
|
|
|
|
- if (record.getId() == null) {
|
|
|
|
- this.save(record);
|
|
|
|
- } else {
|
|
|
|
- this.updateById(record);
|
|
|
|
- }
|
|
|
|
EntrustInfo entrustInfo = null;
|
|
EntrustInfo entrustInfo = null;
|
|
- if (record.getEntrustId() != null) {
|
|
|
|
|
|
+ if (record.getEntrustId() != null && record.getEntrustId() > 0) {
|
|
entrustInfo = entrustInfoMapper.selectById(record.getEntrustId());
|
|
entrustInfo = entrustInfoMapper.selectById(record.getEntrustId());
|
|
}
|
|
}
|
|
List<TrialSampleInfo> trialSampleInfoList = dto.getTrialSampleInfoList();
|
|
List<TrialSampleInfo> trialSampleInfoList = dto.getTrialSampleInfoList();
|
|
@@ -2151,6 +2172,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) {
|
|
if (info != null) {
|
|
TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(info.getId());
|
|
TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(info.getId());
|
|
if (sampleInfo != null) {
|
|
if (sampleInfo != null) {
|
|
@@ -2227,6 +2288,19 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
|
|
recordDTO.setTrialUserName(AuthUtil.getUserName());
|
|
recordDTO.setTrialUserName(AuthUtil.getUserName());
|
|
this.trialDeviceUseService.addDeviceUseInfo(recordDTO, record.getId());
|
|
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();
|
|
return record.getId();
|
|
}
|
|
}
|
|
|
|
|