|
|
@ -115,6 +115,11 @@ public class TubeStateMgrService { |
|
|
|
sampleRecordDBDao.update(sampleRecord); |
|
|
|
} |
|
|
|
|
|
|
|
private void deleteSampleInfo(String sampleId) { |
|
|
|
sampleRecordDBDao.deleteBySampleId(sampleId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// |
|
|
|
//试管状态管理 |
|
|
|
// |
|
|
@ -165,6 +170,7 @@ public class TubeStateMgrService { |
|
|
|
// 急诊试管状态管理 |
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 提交紧急样本设置 |
|
|
|
* @param userid 用户ID |
|
|
@ -186,9 +192,35 @@ public class TubeStateMgrService { |
|
|
|
throw new AppException(A8kEcode.PROJ_CARD_ERROR_WRONG_UNSUPPORTED); |
|
|
|
} |
|
|
|
|
|
|
|
if (!tube.getState().isEq(TubeState.EMPTY, TubeState.TO_BE_PROCESSED, TubeState.PROCESS_COMPLETE, TubeState.ERROR)) { |
|
|
|
throw new AppException(A8kEcode.APPE_EMERGENCY_SAMPLE_IS_PROCESSING); |
|
|
|
} |
|
|
|
|
|
|
|
if (tube.getState().equals(TubeState.EMPTY) || tube.getState().equals(TubeState.PROCESS_COMPLETE) || tube.getState().equals(TubeState.ERROR)) { |
|
|
|
//try delete the last emergency sample |
|
|
|
if (tube.getState().isEq(TubeState.TO_BE_PROCESSED)) { |
|
|
|
//bak reserve consumable,delete cxt |
|
|
|
for (Integer projId : tube.getProjIds()) { |
|
|
|
var cxt = projectContextMgrService.findCxt(tube.getSampleId(), projId); |
|
|
|
if (cxt != null) { |
|
|
|
consumablesMgrService.bakReserveConsumable(cxt.getConsumable()); |
|
|
|
projectContextMgrService.deleteCxt(cxt); |
|
|
|
} |
|
|
|
} |
|
|
|
//delete sample info |
|
|
|
deleteSampleInfo(tube.getSampleId()); |
|
|
|
} |
|
|
|
|
|
|
|
var reports = ConsumableStateAnalyzer.analyze(consumablesMgrService, projIds); |
|
|
|
log.info("耗材状态 {}", reports); |
|
|
|
if (!ConsumableStateAnalyzer.isEnough(reports)) { |
|
|
|
throw new AppException(new AEConsumeNotEnoughError(reports)); |
|
|
|
} |
|
|
|
if (!ConsumableStateAnalyzer.isHasEnoughTip(consumablesMgrService, reports)) { |
|
|
|
throw new AppException(new AppError(A8kEcode.APPE_TIP_NOT_ENOUGH)); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
tube.setSampleId(newSample(tube)); |
|
|
|
tube.setUserid(userid); |
|
|
|
tube.setBloodType(bloodType); |
|
|
|
tube.setSampleBarcode(sampleBarcode); |
|
|
@ -196,16 +228,7 @@ public class TubeStateMgrService { |
|
|
|
tube.setProjInfo(ProjInfoUtils.buidProjBriefInfoList(projBuildInInfos)); |
|
|
|
tube.setProjIds(projIds); |
|
|
|
tube.setProjBuildinInfos(projBuildInInfos); |
|
|
|
tube.setSampleId(newSample(tube)); |
|
|
|
|
|
|
|
var reports = ConsumableStateAnalyzer.analyze(consumablesMgrService, tube); |
|
|
|
if (!ConsumableStateAnalyzer.isEnough(reports)) { |
|
|
|
throw new AppException(new AEConsumeNotEnoughError(reports)); |
|
|
|
} |
|
|
|
if (!ConsumableStateAnalyzer.isHasEnoughTip(consumablesMgrService, reports)) { |
|
|
|
throw new AppException(new AppError(A8kEcode.APPE_TIP_NOT_ENOUGH)); |
|
|
|
} |
|
|
|
|
|
|
|
//!! 这行代码后续代码需要保证无异常发生 |
|
|
|
for (Integer projId : projIds) { |
|
|
|
Consumable consumable = consumablesMgrService.reserveConsumable(projId); |
|
|
|
ZAppChecker.notNull(consumable, A8kEcode.CODEERROR, "APPLY CONSUMABLE ERROR,ID:%d", projId); |
|
|
@ -217,9 +240,24 @@ public class TubeStateMgrService { |
|
|
|
} |
|
|
|
tube.setState(TubeState.TO_BE_PROCESSED); |
|
|
|
log.info("添加紧急样本设置成功 {}", ZJsonHelper.objectToJson(tube)); |
|
|
|
} else { |
|
|
|
throw new AppException(A8kEcode.APPE_EMERGENCY_SAMPLE_IS_PROCESSING); |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
String sampleId = tube.getSampleId(); |
|
|
|
if (sampleId != null && !sampleId.isEmpty()) { |
|
|
|
for (Integer projId : tube.getProjIds()) { |
|
|
|
var cxt = projectContextMgrService.findCxt(sampleId, projId); |
|
|
|
if (cxt != null) { |
|
|
|
consumablesMgrService.bakReserveConsumable(cxt.getConsumable()); |
|
|
|
projectContextMgrService.deleteCxt(cxt); |
|
|
|
} |
|
|
|
} |
|
|
|
deleteSampleInfo(sampleId); |
|
|
|
} |
|
|
|
|
|
|
|
throw e; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|