19 changed files with 522 additions and 410 deletions
-
7src/main/java/a8k/baseservice/AppExceptionBuilder.java
-
1src/main/java/a8k/hardware/type/a8kcanprotocol/A8kEcode.java
-
18src/main/java/a8k/service/appctrl/MainFlowCtrlService.java
-
3src/main/java/a8k/service/appctrl/action/base/A8kActionStepType.java
-
55src/main/java/a8k/service/appctrl/action/mainflow/SEQ2_SWITCH_TO_THE_NEXT_TUBE.java
-
130src/main/java/a8k/service/appctrl/action/mainflow/SEQ3_APPLAY_RESOURCE.java
-
44src/main/java/a8k/service/appctrl/action/mainflow/SEQ4_PRE_PROCESS.java
-
6src/main/java/a8k/service/appstate/ConsumablesMgrService.java
-
8src/main/java/a8k/service/appstate/GStateService.java
-
21src/main/java/a8k/service/appstate/IncubationPlateMgrService.java
-
24src/main/java/a8k/service/appstate/TubeProcessContextMgrService.java
-
46src/main/java/a8k/service/appstate/TubeProcessStateMgrService.java
-
1src/main/java/a8k/service/appstate/resource/A8kPublicResourceType.java
-
29src/main/java/a8k/service/appstate/type/IncubationPlate.java
-
13src/main/java/a8k/service/appstate/type/ProjProcessContext.java
-
1src/main/java/a8k/service/appstate/type/Tube.java
-
13src/main/java/a8k/service/appstate/type/state/TubeState.java
-
4src/main/java/a8k/type/ecode/ConsumeNotEnoughError.java
@ -0,0 +1,130 @@ |
|||
package a8k.service.appctrl.action.mainflow; |
|||
|
|||
import a8k.baseservice.AppExceptionBuilder; |
|||
import a8k.hardware.type.a8kcanprotocol.A8kEcode; |
|||
import a8k.service.appdata.AppProjInfoMgrService; |
|||
import a8k.service.appctrl.action.base.A8kActionStepType; |
|||
import a8k.service.appctrl.action.base.A8kStepAction; |
|||
import a8k.service.appstate.*; |
|||
import a8k.service.appstate.resource.A8kPublicResourceType; |
|||
import a8k.service.appstate.type.Tube; |
|||
import a8k.service.appstate.type.state.TubeState; |
|||
import a8k.type.Consumable; |
|||
import a8k.type.IncubatorPos; |
|||
import a8k.type.TipPos; |
|||
import a8k.type.exception.AppException; |
|||
import a8k.type.projecttype.A8kReactionFlowType; |
|||
import a8k.type.projecttype.a8kidcard.A8kIdCardInfo; |
|||
import jakarta.annotation.PostConstruct; |
|||
import jakarta.annotation.Resource; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* |
|||
* 核对物料资源是否足够 |
|||
* |
|||
* TUBE |
|||
* TO_BE_PROCESSED --> PRE_PROCESSING |
|||
*/ |
|||
@Component |
|||
public class SEQ3_APPLAY_RESOURCE extends A8kStepAction { |
|||
static Logger logger = LoggerFactory.getLogger(SEQ3_APPLAY_RESOURCE.class); |
|||
|
|||
SEQ3_APPLAY_RESOURCE() { |
|||
super(A8kActionStepType.SEQ3_APPLAY_RESOURCE); |
|||
} |
|||
|
|||
@Resource |
|||
GStateService gstate; |
|||
@Resource |
|||
ConsumablesMgrService consumablesMgrService; //耗材管理 |
|||
@Resource |
|||
AppExceptionBuilder ebuilder; //异常构造器 |
|||
@Resource |
|||
IncubationPlateMgrService incubationPlateMgrService; //孵育盘管理 |
|||
@Resource |
|||
AppProjInfoMgrService appProjInfoMgrService; //项目信息管理 |
|||
@Resource |
|||
TubeProcessStateMgrService tubeProcessStateMgrService; //试管处理状态管理 |
|||
|
|||
|
|||
@PostConstruct |
|||
void init() { |
|||
} |
|||
|
|||
@Override public void doaction() throws AppException { |
|||
Tube tube = gstate.getCurProcessingTube(); |
|||
assert tube != null; |
|||
List<Integer> projs = gstate.getCurProcessingTube().projIndex; |
|||
|
|||
//检查是否有足够的耗材 |
|||
for (Integer projin : projs) { |
|||
if (!consumablesMgrService.isHasEnoughConsumables(projs)) { |
|||
throw ebuilder.buildConsumeNotEnoughError(projin); |
|||
} |
|||
} |
|||
logger.info("check consumables ok"); |
|||
|
|||
//检查tip是否足够 |
|||
int tipNum = 0; |
|||
for (Integer proj : projs) { |
|||
A8kReactionFlowType flow = appProjInfoMgrService.getA8kReactionFlowTypeByProjIndex(proj); |
|||
assert flow != null; //由于先核对的耗材,这里就一定有对应的项目 |
|||
tipNum += flow.tipUseNum; |
|||
} |
|||
if (!consumablesMgrService.isHasEnoughTips(tipNum)) { |
|||
throw ebuilder.buildAppException(A8kEcode.TipNotEnough); |
|||
} |
|||
logger.info("check tips ok"); |
|||
|
|||
assert incubationPlateMgrService.isHasEnoughIncubationIDLEPos(projs.size()); |
|||
logger.info("check incubationPlate ok"); |
|||
|
|||
//申请项目耗材 |
|||
List<Consumable> consumables = consumablesMgrService.takeConsumables(projs); |
|||
//申请孵育盘位置 |
|||
List<IncubatorPos> incubatorPoss = incubationPlateMgrService.takeIncubationIDLEPos(projs.size()); |
|||
assert consumables != null; |
|||
assert incubatorPoss != null; |
|||
//找到项目对应的A8kIdCardInfo |
|||
List<A8kIdCardInfo> a8kIdCardInfo = new ArrayList<>(); |
|||
for (Consumable consumable : consumables) { |
|||
A8kIdCardInfo idcardInfo = appProjInfoMgrService.getA8kIdCardInfoByLotId(consumable.lotId); |
|||
assert idcardInfo != null; |
|||
a8kIdCardInfo.add(idcardInfo); |
|||
} |
|||
//申请tip头 |
|||
List<List<TipPos>> tipPos = new ArrayList<>(); |
|||
for (int i = 0; i < projs.size(); i++) { |
|||
List<TipPos> tips = consumablesMgrService.takeTip(a8kIdCardInfo.get(i).reactionFlowType); |
|||
assert tips != null; |
|||
tipPos.add(tips); |
|||
} |
|||
//创建项目处理上下文 |
|||
tubeProcessStateMgrService.startProcessTube(a8kIdCardInfo, consumables, tipPos, incubatorPoss); |
|||
logger.info("apply resource ok"); |
|||
} |
|||
|
|||
@Override public Boolean checkCondition() { |
|||
Tube tube = gstate.getCurProcessingTube(); |
|||
if (tube == null) |
|||
return false; |
|||
|
|||
//当前正在工作 |
|||
Boolean cond1 = gstate.isWorking(); |
|||
//没有试管在处理 或者 当前试管处理完成 |
|||
Boolean cond2 = tube.state.equals(TubeState.PENDING); |
|||
//急诊有待处理的试管,或者试管架正在处理 |
|||
Boolean cond3 = incubationPlateMgrService.isHasEnoughIncubationIDLEPos(tube.projIndex.size()); |
|||
return cond1 && cond2 && cond3; |
|||
} |
|||
|
|||
@Override public List<A8kPublicResourceType> getResourceList() { |
|||
return List.of(A8kPublicResourceType.CurTubeProcessToken); |
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
package a8k.service.appstate; |
|||
|
|||
import a8k.service.appstate.type.Tube; |
|||
import a8k.service.appstate.type.state.TubeState; |
|||
import a8k.type.Consumable; |
|||
import a8k.type.IncubatorPos; |
|||
import a8k.type.TipPos; |
|||
import a8k.type.projecttype.a8kidcard.A8kIdCardInfo; |
|||
import jakarta.annotation.Resource; |
|||
import org.jetbrains.annotations.NotNull; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Component |
|||
public class TubeProcessStateMgrService { |
|||
@Resource |
|||
GStateService gstate; |
|||
|
|||
@Resource |
|||
TubeProcessContextMgrService tubeProcessContextMgrService; |
|||
|
|||
synchronized public void setCurTubeState(TubeState state) { |
|||
Tube tube = gstate.getCurProcessingTube(); |
|||
assert tube != null; |
|||
tube.state = state; |
|||
} |
|||
|
|||
synchronized public void startProcessTube(@NotNull List<A8kIdCardInfo> idCardInfo, @NotNull List<Consumable> consumable, @NotNull List<List<TipPos>> tipPos, |
|||
@NotNull List<IncubatorPos> incubatorPos) { |
|||
Tube tube = gstate.getCurProcessingTube(); |
|||
assert tube != null; |
|||
for (int i = 0; i < tube.projIndex.size(); i++) { |
|||
tubeProcessContextMgrService.createProjProcessContext(tube, idCardInfo.get(i), consumable.get(i), tipPos.get(i), incubatorPos.get(i)); |
|||
} |
|||
tube.state = TubeState.PRE_PROCESSING; |
|||
} |
|||
|
|||
synchronized public void pendingTube(Tube tube) { |
|||
tube.state = TubeState.PENDING; |
|||
gstate.curProcessingTube = tube; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue