|
|
@ -1,20 +1,17 @@ |
|
|
|
package a8k.service.app.appctrl.mainflowctrl.action; |
|
|
|
|
|
|
|
import a8k.constant.LogTopic; |
|
|
|
import a8k.hardware.type.a8kcanprotocol.A8kEcode; |
|
|
|
import a8k.service.app.appctrl.mainflowctrl.MainFlowCtrlScheduler; |
|
|
|
import a8k.service.app.appctrl.mainflowctrl.base.A8kActionStepType; |
|
|
|
import a8k.service.app.appctrl.mainflowctrl.base.A8kStepAction; |
|
|
|
import a8k.service.app.appctrl.mainflowctrl.base.MainFlowProcesser; |
|
|
|
import a8k.service.app.appdata.ProjInfoMgrService; |
|
|
|
import a8k.service.app.appstate.statemgr.ConsumablesMgrService; |
|
|
|
import a8k.service.app.appstate.statemgr.IncubationPlateStateMgrService; |
|
|
|
import a8k.service.app.appstate.statemgr.ProjectContextMgrService; |
|
|
|
import a8k.service.app.appstate.statemgr.TubeStateMgrService; |
|
|
|
import a8k.service.app.appstate.statemgr.*; |
|
|
|
import a8k.service.app.appstate.type.ProjectContext; |
|
|
|
import a8k.service.app.appstate.type.Tube; |
|
|
|
import a8k.service.app.appstate.type.state.TubeState; |
|
|
|
import a8k.service.bases.AppEventBusService; |
|
|
|
import a8k.service.bases.appevent.A8kErrorPromptEvent; |
|
|
|
import a8k.service.bases.appevent.A8kErrorsPromptEvent; |
|
|
|
import a8k.service.dao.type.ProjExtInfoCard; |
|
|
|
import a8k.type.IncubatorPos; |
|
|
|
import a8k.type.ecode.AEConsumeNotEnoughError; |
|
|
@ -23,11 +20,13 @@ import a8k.type.pos.Consumable; |
|
|
|
import a8k.type.pos.TipPos; |
|
|
|
import a8k.utils.ProjBuildinInfo; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/* |
|
|
@ -44,17 +43,21 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@MainFlowProcesser |
|
|
|
@Slf4j(topic = LogTopic.ACTION) |
|
|
|
public class SEQ3_APPLAY_RESOURCE extends A8kStepAction { |
|
|
|
static Logger logger = LoggerFactory.getLogger(SEQ3_APPLAY_RESOURCE.class); |
|
|
|
|
|
|
|
SEQ3_APPLAY_RESOURCE() { |
|
|
|
super(A8kActionStepType.SEQ3_APPLAY_RESOURCE); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
// BASE |
|
|
|
// |
|
|
|
@Resource |
|
|
|
AppEventBusService ebus; |
|
|
|
|
|
|
|
// |
|
|
|
// STATEMGR |
|
|
|
// |
|
|
|
@Resource |
|
|
|
ProjectContextMgrService projectContextMgrService; |
|
|
|
@Resource |
|
|
@ -63,12 +66,15 @@ public class SEQ3_APPLAY_RESOURCE extends A8kStepAction { |
|
|
|
ProjInfoMgrService projConfigMgrService; |
|
|
|
@Resource |
|
|
|
IncubationPlateStateMgrService incubationPlateStateMgrService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
TubeStateMgrService tubeStateMgrService; |
|
|
|
TubeStateMgrService tubeStateMgrService; |
|
|
|
@Resource |
|
|
|
MainFlowCtrlScheduler mainFlowCtrlScheduler; |
|
|
|
DeviceWorkStateMgrService deviceWorkStateMgrService; |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
// OVERRID |
|
|
|
// |
|
|
|
|
|
|
|
public Boolean isReady() { |
|
|
|
Tube tube = tubeStateMgrService.getCurProcessingTube(); |
|
|
@ -78,66 +84,59 @@ public class SEQ3_APPLAY_RESOURCE extends A8kStepAction { |
|
|
|
; |
|
|
|
} |
|
|
|
|
|
|
|
@Override public List<AppError> doActionInLine() { |
|
|
|
|
|
|
|
void bakResource( |
|
|
|
Consumable consumable, |
|
|
|
List<TipPos> tipPos, |
|
|
|
IncubatorPos incubatorPos |
|
|
|
) { |
|
|
|
if (consumable != null) { |
|
|
|
consumablesMgrService.backConsumable(consumable); |
|
|
|
} |
|
|
|
if (tipPos != null) { |
|
|
|
consumablesMgrService.backTipList(tipPos); |
|
|
|
} |
|
|
|
if (incubatorPos != null) { |
|
|
|
incubationPlateStateMgrService.resetIncubatorPos(incubatorPos); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 动作处理完成后的处理(串行),一般用于修改状态 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<AppError> afterDoAction(List<AppError> errors) { |
|
|
|
Tube tube = tubeStateMgrService.getCurProcessingTube(); |
|
|
|
Assert.isTrue(tube != null, "tube != null"); |
|
|
|
|
|
|
|
//如果试管待做项目为空,则直接跳过 |
|
|
|
if (tube.getProjIds().isEmpty()) { |
|
|
|
logger.warn("试管待做项目为空,skip"); |
|
|
|
log.warn("试管待做项目为空,skip"); |
|
|
|
tubeStateMgrService.changeTubeStateToProcessComplete(); |
|
|
|
return List.of(); |
|
|
|
} |
|
|
|
|
|
|
|
// |
|
|
|
List<AppError> errors = prePareResource(); |
|
|
|
if (errors != null && !errors.isEmpty()) { |
|
|
|
backProjectResource(tube); |
|
|
|
deviceWorkStateMgrService.setHumanInterventionReq(true); |
|
|
|
ebus.pushEvent(new A8kErrorsPromptEvent(errors)); |
|
|
|
} |
|
|
|
log.info("申请耗材完成"); |
|
|
|
return List.of(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
// Impl |
|
|
|
// |
|
|
|
List<AppError> prePareResource() { |
|
|
|
Tube tube = tubeStateMgrService.getCurProcessingTube(); |
|
|
|
Assert.isTrue(tube != null, "tube != null"); |
|
|
|
// |
|
|
|
//申请耗材 |
|
|
|
// |
|
|
|
|
|
|
|
boolean allySuc = true; |
|
|
|
List<AppError> errors = new ArrayList<>(); |
|
|
|
//判断是哪个项目耗材不足 |
|
|
|
for (var toDoProj : tube.getProjInfo()) { |
|
|
|
|
|
|
|
Consumable consumable = consumablesMgrService.takeConsumable(toDoProj.getProjId()); |
|
|
|
List<TipPos> tipPos = consumablesMgrService.takeTip(toDoProj.getReactionFlowType()); |
|
|
|
IncubatorPos incubatorPos = incubationPlateStateMgrService.takeOneIncubationIDLEPos(); |
|
|
|
|
|
|
|
if (consumable == null || tipPos == null || incubatorPos == null) { |
|
|
|
if (consumable == null) { |
|
|
|
mainFlowCtrlScheduler.reqHumanIntervention(); |
|
|
|
logger.error("申请耗材失败,sampleId == {} projindex == {}", tube.getSampleId(), toDoProj.getProjId()); |
|
|
|
ebus.pushEvent(new A8kErrorPromptEvent(new AEConsumeNotEnoughError(toDoProj.getProjName()))); |
|
|
|
log.error("申请耗材失败,sampleId == {} projindex == {}", tube.getSampleId(), toDoProj.getProjId()); |
|
|
|
errors.add(new AEConsumeNotEnoughError(toDoProj.getProjName())); |
|
|
|
} |
|
|
|
|
|
|
|
if (tipPos == null) { |
|
|
|
mainFlowCtrlScheduler.reqHumanIntervention(); |
|
|
|
logger.error("申请tip失败,sampleId == {} projindex == {}", tube.getSampleId(), toDoProj.getProjId()); |
|
|
|
ebus.pushEvent(new A8kErrorPromptEvent(new AppError(A8kEcode.APPE_TIP_NOT_ENOUGH))); |
|
|
|
log.error("申请tip失败,sampleId == {} projindex == {}", tube.getSampleId(), toDoProj.getProjId()); |
|
|
|
errors.add(new AppError(A8kEcode.APPE_TIP_NOT_ENOUGH)); |
|
|
|
} |
|
|
|
|
|
|
|
Assert.notNull(incubatorPos, "申请孵育盘位置失败"); |
|
|
|
bakResource(consumable, tipPos, incubatorPos); |
|
|
|
allySuc = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
@ -149,33 +148,57 @@ public class SEQ3_APPLAY_RESOURCE extends A8kStepAction { |
|
|
|
cxt.setProjInfoStorageCard(projInfo); |
|
|
|
} |
|
|
|
|
|
|
|
return errors; |
|
|
|
} |
|
|
|
|
|
|
|
if (!allySuc) { |
|
|
|
for (ProjBuildinInfo proj : tube.getProjInfo()) { |
|
|
|
void backProjectResource(Tube tube) { |
|
|
|
for (var toDoProj : tube.getProjInfo()) { |
|
|
|
ProjectContext cxt = projectContextMgrService.findCxt(tube.getSampleId(), toDoProj.getProjId()); |
|
|
|
backProjectResource(cxt); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ProjectContext cxt = projectContextMgrService.findCxt(tube.getSampleId(), proj.getProjId()); |
|
|
|
var consumable = cxt.getConsumable(); |
|
|
|
var tipPos = cxt.getTipPos(); |
|
|
|
var incubatorPos = cxt.getIncubatorPos(); |
|
|
|
void backProjectResource(ProjectContext cxt) { |
|
|
|
var consumable = cxt.getConsumable(); |
|
|
|
var tipPos = cxt.getTipPos(); |
|
|
|
var incubatorPos = cxt.getIncubatorPos(); |
|
|
|
|
|
|
|
if (consumable != null) { |
|
|
|
consumablesMgrService.backConsumable(consumable); |
|
|
|
} |
|
|
|
if (consumable != null) { |
|
|
|
consumablesMgrService.backConsumable(consumable); |
|
|
|
} |
|
|
|
|
|
|
|
if (tipPos != null) { |
|
|
|
consumablesMgrService.backTipList(tipPos); |
|
|
|
} |
|
|
|
if (tipPos != null) { |
|
|
|
consumablesMgrService.backTipList(tipPos); |
|
|
|
} |
|
|
|
|
|
|
|
cxt.setConsumable(null); |
|
|
|
cxt.setTipPos(null); |
|
|
|
cxt.setIncubatorPos(null); |
|
|
|
cxt.setProjInfoStorageCard(null); |
|
|
|
incubationPlateStateMgrService.resetIncubatorPos(incubatorPos); |
|
|
|
} |
|
|
|
cxt.setConsumable(null); |
|
|
|
cxt.setTipPos(null); |
|
|
|
cxt.setIncubatorPos(null); |
|
|
|
cxt.setProjInfoStorageCard(null); |
|
|
|
|
|
|
|
//因为incubatorPos只是打上标记,并没有真的推到赋予盘中,所以不需要执行机械动作 |
|
|
|
incubationPlateStateMgrService.resetIncubatorPos(incubatorPos); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
// Utils |
|
|
|
// |
|
|
|
|
|
|
|
void bakResource( |
|
|
|
Consumable consumable, |
|
|
|
List<TipPos> tipPos, |
|
|
|
IncubatorPos incubatorPos |
|
|
|
) { |
|
|
|
if (consumable != null) { |
|
|
|
consumablesMgrService.backConsumable(consumable); |
|
|
|
} |
|
|
|
if (tipPos != null) { |
|
|
|
consumablesMgrService.backTipList(tipPos); |
|
|
|
} |
|
|
|
if (incubatorPos != null) { |
|
|
|
incubationPlateStateMgrService.resetIncubatorPos(incubatorPos); |
|
|
|
} |
|
|
|
logger.info("申请资源成功"); |
|
|
|
tubeStateMgrService.changeTubeStateToResourceIsReady(); |
|
|
|
return List.of(); |
|
|
|
} |
|
|
|
|
|
|
|
} |