From 2468af88e9ee9901f1d4d6f1cfdb6361c7400730 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期一, 02 二月 2026 15:52:05 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java | 518 ++++++++++++++++++++++++++++----------------------------
1 files changed, 259 insertions(+), 259 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
index c0b1e29..39895fe 100644
--- a/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
@@ -15,7 +15,6 @@
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.asrs.utils.Utils;
-import com.zy.common.entity.FindCrnNoResult;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
import com.zy.common.utils.RedisUtil;
@@ -27,6 +26,7 @@
import com.zy.core.model.Task;
import com.zy.core.model.command.DualCrnCommand;
import com.zy.core.model.command.StationCommand;
+import com.zy.core.model.param.SendDualCrnCommandParam;
import com.zy.core.model.protocol.DualCrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.thread.DualCrnThread;
@@ -101,44 +101,205 @@
return;
}
- List<WrkMast> allTaskList = new ArrayList<>();
- List<WrkMast> inTaskList = getInTaskList(basDualCrnp);
- List<WrkMast> outTaskList = getOutTaskList(basDualCrnp);
- List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp);
+ if (!(dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE) && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE))) {
+ return;
+ }
- if (!locMoveTaskList.isEmpty()) {
- allTaskList.addAll(locMoveTaskList);
+ Object clearLock = redisUtil.get(RedisKeyType.CLEAR_DUAL_CRN_TASK_LIMIT.key + basDualCrnp.getCrnNo());
+ if (clearLock != null) {
+ return;
}
// 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
if (dualCrnProtocol.getLastIo().equals("O")) {
- allTaskList.addAll(inTaskList);
- allTaskList.addAll(outTaskList);
+ boolean executeResult1 = processLoveMove(basDualCrnp, dualCrnThread);
+ if (executeResult1) {
+ return;
+ }
+ boolean executeResult2 = processIn(basDualCrnp, dualCrnThread);
+ if (executeResult2) {
+ return;
+ }
+ boolean executeResult3 = processOut(basDualCrnp, dualCrnThread);
+ if (executeResult3) {
+ return;
+ }
}
// 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
else if (dualCrnProtocol.getLastIo().equals("I")) {
- allTaskList.addAll(outTaskList);
- allTaskList.addAll(inTaskList);
+ boolean executeResult1 = processLoveMove(basDualCrnp, dualCrnThread);
+ if (executeResult1) {
+ return;
+ }
+ boolean executeResult2 = processOut(basDualCrnp, dualCrnThread);
+ if (executeResult2) {
+ return;
+ }
+ boolean executeResult3 = processIn(basDualCrnp, dualCrnThread);
+ if (executeResult3) {
+ return;
+ }
+ }
+ }
+
+ private boolean processIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
+ List<WrkMast> inTaskList = getInTaskList(basDualCrnp);
+ if (inTaskList.isEmpty()) {
+ return false;
}
- for (WrkMast wrkMast : allTaskList) {
- if (wrkMast.getIoType() == WrkIoType.IN.id) {
- boolean result = this.crnExecuteIn(basDualCrnp, dualCrnThread, wrkMast);
- if (result) {
- break;
+ WrkMast stationOneWrkMast = inTaskList.get(0);
+ WrkMast stationTwoWrkMast = null;
+
+ if (inTaskList.size() >= 2) {
+ stationTwoWrkMast = inTaskList.get(1);
+ }
+
+ SendDualCrnCommandParam oneResult = null;
+ SendDualCrnCommandParam twoResult = null;
+
+ if(stationOneWrkMast != null){
+ oneResult = crnExecuteIn(basDualCrnp, dualCrnThread, stationOneWrkMast);
+ }
+
+ if(stationTwoWrkMast != null){
+ twoResult = crnExecuteIn(basDualCrnp, dualCrnThread, stationTwoWrkMast);
+ }
+
+ List<SendDualCrnCommandParam> list = new ArrayList<>();
+ if (oneResult != null) {
+ list.add(oneResult);
+ }
+
+ if (twoResult != null) {
+ list.add(twoResult);
+ }
+
+ if (!list.isEmpty()) {
+ DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+ Integer crnNo = basDualCrnp.getCrnNo();
+ MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
+ News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(list));
+ dualCrnProtocol.setLastIo("I");
+ return true;
+ }
+ return false;
+ }
+
+ private boolean processOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
+ List<WrkMast> outTaskList = getOutTaskList(basDualCrnp);
+ if (outTaskList.isEmpty()) {
+ return false;
+ }
+
+ WrkMast stationOneWrkMast = null;
+ WrkMast stationTwoWrkMast = null;
+
+ List<Integer> disableList = basDualCrnp.getDisableStationOneBays$();
+
+ for (WrkMast wrkMast : outTaskList) {
+ if (stationOneWrkMast == null) {
+ if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
+ stationOneWrkMast = wrkMast;
+ continue;
}
- } else if (wrkMast.getIoType() == WrkIoType.OUT.id) {
- boolean result = this.crnExecuteOut(basDualCrnp, dualCrnThread, wrkMast);
- if (result) {
- break;
- }
- } else if (wrkMast.getIoType() == WrkIoType.LOC_MOVE.id) {
- boolean result = this.crnExecuteLocMove(basDualCrnp, dualCrnThread, wrkMast);
- if (result) {
- break;
+ }
+
+ if (stationTwoWrkMast == null) {
+ if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
+ stationTwoWrkMast = wrkMast;
+ continue;
}
}
}
+
+ SendDualCrnCommandParam oneResult = null;
+ SendDualCrnCommandParam twoResult = null;
+
+ if(stationOneWrkMast != null){
+ oneResult = crnExecuteOut(basDualCrnp, dualCrnThread, stationOneWrkMast, 1);
+ }
+
+ if(stationTwoWrkMast != null){
+ twoResult = crnExecuteOut(basDualCrnp, dualCrnThread, stationTwoWrkMast, 2);
+ }
+
+ List<SendDualCrnCommandParam> list = new ArrayList<>();
+ if (oneResult != null) {
+ list.add(oneResult);
+ }
+
+ if (twoResult != null) {
+ list.add(twoResult);
+ }
+
+ if (!list.isEmpty()) {
+ DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+ Integer crnNo = basDualCrnp.getCrnNo();
+ MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
+ News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(list));
+ dualCrnProtocol.setLastIo("O");
+ return true;
+ }
+ return false;
+ }
+
+ private boolean processLoveMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
+ List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp);
+ if (locMoveTaskList.isEmpty()) {
+ return false;
+ }
+
+ WrkMast stationOneWrkMast = null;
+ WrkMast stationTwoWrkMast = null;
+
+ List<Integer> disableList = basDualCrnp.getDisableStationOneBays$();
+
+ for (WrkMast wrkMast : locMoveTaskList) {
+ if (stationOneWrkMast == null) {
+ if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
+ stationOneWrkMast = wrkMast;
+ continue;
+ }
+ }
+
+ if (stationTwoWrkMast == null) {
+ if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
+ stationTwoWrkMast = wrkMast;
+ continue;
+ }
+ }
+ }
+
+ SendDualCrnCommandParam oneResult = null;
+ SendDualCrnCommandParam twoResult = null;
+
+ if(stationOneWrkMast != null){
+ oneResult = crnExecuteLocMove(basDualCrnp, dualCrnThread, stationOneWrkMast, 1);
+ }
+
+ if(stationTwoWrkMast != null){
+ twoResult = crnExecuteLocMove(basDualCrnp, dualCrnThread, stationTwoWrkMast, 2);
+ }
+
+ List<SendDualCrnCommandParam> list = new ArrayList<>();
+ if (oneResult != null) {
+ list.add(oneResult);
+ }
+
+ if (twoResult != null) {
+ list.add(twoResult);
+ }
+
+ if (!list.isEmpty()) {
+ DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+ Integer crnNo = basDualCrnp.getCrnNo();
+ MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
+ News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(list));
+ dualCrnProtocol.setLastIo("O");
+ return true;
+ }
+ return false;
}
private List<WrkMast> getInTaskList(BasDualCrnp basDualCrnp) {
@@ -148,55 +309,39 @@
return list;
}
+ List<Integer> taskList = new ArrayList<>();
List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
- if(inStationList.isEmpty()){
- News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍏ュ簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
- return list;
- }
-
for (StationObjModel stationObjModel : inStationList) {
StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
if (stationThread == null) {
continue;
}
- Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap();
- StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId());
+ Map<Integer, StationProtocol> map = stationThread.getStatusMap();
+ StationProtocol stationProtocol = map.get(stationObjModel.getStationId());
if (stationProtocol == null) {
continue;
}
- if (!stationProtocol.isAutoing()) {
- continue;
+ if (stationProtocol.isAutoing()
+ && stationProtocol.isLoading()
+ && stationProtocol.getTaskNo() > 0
+ ) {
+ taskList.add(stationProtocol.getTaskNo());
}
+ }
- if (!stationProtocol.isLoading()) {
- continue;
- }
-
- if (stationProtocol.getTaskNo() <= 0) {
- continue;
- }
-
- if (!stationProtocol.isInEnable()) {
- News.taskInfo(stationProtocol.getTaskNo(), "鍙栬揣绔欑偣:{} 娌℃湁鍙叆淇″彿", stationObjModel.getStationId());
- continue;
- }
-
- // 鑾峰彇浠诲姟
- WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
- if (null == wrkMast) {
- News.taskInfo(stationProtocol.getTaskNo(), "宸ヤ綔鍙�:{} 浠诲姟淇℃伅涓嶅瓨鍦�", stationProtocol.getTaskNo());
- continue;
- }
-
+ // 鑾峰彇浠诲姟
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .eq("dual_crn_no", basDualCrnp.getCrnNo())
+ .in("wrk_no", taskList)
+ );
+ for (WrkMast wrkMast : wrkMasts) {
if(wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts){
continue;
}
-
list.add(wrkMast);
}
-
return list;
}
@@ -231,46 +376,46 @@
return list;
}
- private synchronized boolean crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
+ private synchronized SendDualCrnCommandParam crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
if (dualCrnProtocol == null) {
- return false;
+ return null;
}
if (!basDualCrnp.getInEnable().equals("Y")) {
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙叆淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
- return false;
+ return null;
}
List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
if(inStationList.isEmpty()){
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍏ュ簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
- return false;
+ return null;
}
Integer crnNo = basDualCrnp.getCrnNo();
if (wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
- return false;
+ return null;
}
// 鑾峰彇搴撲綅淇℃伅
LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
if (locMast == null) {
News.taskInfo(wrkMast.getWrkNo(), "鐩爣搴撲綅:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getLocNo());
- return false;
+ return null;
}
if (!locMast.getLocSts().equals("S")) {
News.taskInfo(wrkMast.getWrkNo(), "鐩爣搴撲綅:{} 鐘舵�佸紓甯�", wrkMast.getLocNo());
- return false;
+ return null;
}
//妫�娴嬫祬搴撲綅鐘舵��
boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
if (!checkStatus) {
News.taskInfo(wrkMast.getWrkNo(), "鍥犳祬搴撲綅鍫靛鏃犳硶鎵ц");
- return false;
+ return null;
}
StationObjModel inStationObjModel = null;
@@ -307,38 +452,11 @@
inStationObjModel = stationObjModel;
break;
}
-
- StationObjModel dualCrnSlaveStationObjModel = stationObjModel.getDualCrnSlaveStation();
- if (dualCrnSlaveStationObjModel == null) {
- continue;
- }
-
- StationProtocol slaveStationProtocol = stationProtocolMap.get(dualCrnSlaveStationObjModel.getStationId());
- if (slaveStationProtocol == null) {
- continue;
- }
-
- if (!slaveStationProtocol.isAutoing()) {
- continue;
- }
-
- if (!slaveStationProtocol.isLoading()) {
- continue;
- }
-
- if (slaveStationProtocol.getTaskNo() <= 0) {
- continue;
- }
-
- if (slaveStationProtocol.getTaskNo().equals(wrkMast.getWrkNo())) {
- inStationObjModel = dualCrnSlaveStationObjModel;
- break;
- }
}
if (inStationObjModel == null) {
News.taskInfo(wrkMast.getWrkNo(), "鏈悳绱㈠埌鍙栬揣绔欑偣");
- return false;
+ return null;
}
Integer station = inStationObjModel.getDualCrnExecuteStation();
@@ -347,14 +465,14 @@
if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
//绂佹鏀捐揣鍒楋紝鐢宠閲嶆柊鍒嗛厤
reassignTaskLocNo(wrkMast, inStationObjModel);
- return false;
+ return null;
}
}else {
List<Integer> basList = basDualCrnp.getDisableStationTwoBays$();
if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
//绂佹鏀捐揣鍒楋紝鐢宠閲嶆柊鍒嗛厤
reassignTaskLocNo(wrkMast, inStationObjModel);
- return false;
+ return null;
}
}
@@ -371,60 +489,44 @@
wrkMast.setSystemMsg("");
wrkMast.setIoTime(new Date());
if (wrkMastService.updateById(wrkMast)) {
- MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
+ SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
+ sendDualCrnCommandParam.setCrnNo(crnNo);
+ sendDualCrnCommandParam.setStation(station);
+ sendDualCrnCommandParam.setCommands(commandList);
+ sendDualCrnCommandParam.setCommandIdx(0);
+
notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_IN_TASK_RUN, null);
- News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
- dualCrnProtocol.setLastIo("I");
- return true;
+ return sendDualCrnCommandParam;
}
- return false;
+ return null;
}
- private synchronized boolean crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
+ private synchronized SendDualCrnCommandParam crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast, int station) {
DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
if (dualCrnProtocol == null) {
- return false;
+ return null;
}
if (!basDualCrnp.getOutEnable().equals("Y")) {
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙嚭淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
- return false;
+ return null;
}
List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
if (outStationList.isEmpty()) {
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
- return false;
+ return null;
}
Integer crnNo = basDualCrnp.getCrnNo();
- int station = calcStation(dualCrnProtocol, "out");
- if (station == 0) {
- News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏃犲彲鐢ㄥ伐浣�", basDualCrnp.getCrnNo());
- return false;
- }
- List<StationObjModel> enableUseStationList = new ArrayList<>();
for (StationObjModel stationObjModel : outStationList) {
- if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
+ StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+ if (stationThread == null) {
continue;
}
- if(stationObjModel.getDualCrnExecuteStation().equals(station)) {
- enableUseStationList.add(stationObjModel);
- }
-
- StationObjModel dualCrnSlaveStation = stationObjModel.getDualCrnSlaveStation();
- if(dualCrnSlaveStation != null) {
- if (dualCrnSlaveStation.getDualCrnExecuteStation().equals(station)) {
- enableUseStationList.add(stationObjModel);
- }
- }
- }
-
- for (StationObjModel stationObjModel : enableUseStationList) {
- StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
- if (stationThread == null) {
+ if (stationObjModel.getDualCrnExecuteStation() != station) {
continue;
}
@@ -483,65 +585,58 @@
wrkMast.setSystemMsg("");
wrkMast.setIoTime(new Date());
if (wrkMastService.updateById(wrkMast)) {
- MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
- notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_RUN, null);
- News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
- dualCrnProtocol.setLastIo("O");
-
redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(stationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
- return true;
+
+ SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
+ sendDualCrnCommandParam.setCrnNo(crnNo);
+ sendDualCrnCommandParam.setStation(station);
+ sendDualCrnCommandParam.setCommands(commandList);
+ sendDualCrnCommandParam.setCommandIdx(0);
+
+ notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_RUN, null);
+ return sendDualCrnCommandParam;
}
}
- return false;
+ return null;
}
- private synchronized boolean crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
+ private synchronized SendDualCrnCommandParam crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast, int station) {
DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
if (dualCrnProtocol == null) {
- return false;
+ return null;
}
Integer crnNo = basDualCrnp.getCrnNo();
- int station = calcStation(dualCrnProtocol, "locMove");
- if (station == 0) {
- News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏃犲彲鐢ㄥ伐浣�", basDualCrnp.getCrnNo());
- return false;
- }
-
- List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
- .eq("crn_no", crnNo)
- .eq("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts)
- );
// 鑾峰彇婧愬簱浣嶄俊鎭�
LocMast sourceLocMast = locMastService.selectById(wrkMast.getSourceLocNo());
if (sourceLocMast == null) {
News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getSourceLocNo());
- return false;
+ return null;
}
- if(!sourceLocMast.getLocSts().equals("R")){
+ if (!sourceLocMast.getLocSts().equals("R")) {
News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 鐘舵�佸紓甯革紝涓嶅睘浜庡嚭搴撻绾︾姸鎬�", wrkMast.getSourceLocNo());
- return false;
+ return null;
}
// 鑾峰彇搴撲綅淇℃伅
LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
if (locMast == null) {
News.taskInfo(wrkMast.getWrkNo(), "搴撲綅:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getLocNo());
- return false;
+ return null;
}
if (!locMast.getLocSts().equals("S")) {
News.taskInfo(wrkMast.getWrkNo(), "搴撲綅:{} 鐘舵�佸紓甯革紝涓嶅睘浜庡叆搴撻绾︾姸鎬�", wrkMast.getLocNo());
- return false;
+ return null;
}
//妫�娴嬫祬搴撲綅鐘舵��
boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
if (!checkStatus) {
News.taskInfo(wrkMast.getWrkNo(), "鍥犳祬搴撲綅鍫靛鏃犳硶鎵ц");
- return false;
+ return null;
}
List<DualCrnCommand> commandList = new ArrayList<>();
@@ -555,13 +650,16 @@
wrkMast.setSystemMsg("");
wrkMast.setIoTime(new Date());
if (wrkMastService.updateById(wrkMast)) {
- MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
+ SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
+ sendDualCrnCommandParam.setCrnNo(crnNo);
+ sendDualCrnCommandParam.setStation(station);
+ sendDualCrnCommandParam.setCommands(commandList);
+ sendDualCrnCommandParam.setCommandIdx(0);
+
notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_TRANSFER_TASK_RUN, null);
- News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
- dualCrnProtocol.setLastIo("I");
- return true;
+ return sendDualCrnCommandParam;
}
- return false;
+ return null;
}
//鍙屽伐浣嶅爢鍨涙満浠诲姟鎵ц瀹屾垚
@@ -609,16 +707,13 @@
return;
}
- Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + wrkMast.getWrkNo());
- if (commandObj == null) {
- News.error("鍙屽伐浣嶅爢鍨涙満澶勪簬绛夊緟纭涓斾换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌鍛戒护銆傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basDualCrnp.getCrnNo(), taskNo);
- return;
+ int idx = 10;
+ Object idxObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_IDX.key + wrkMast.getWrkNo());
+ if(idxObj != null) {
+ idx = (Integer) idxObj;
}
- JSONObject commandMap = JSON.parseObject(commandObj.toString());
- Integer idx = commandMap.getInteger("idx");
- List<DualCrnCommand> commandList = commandMap.getJSONArray("commands").toJavaList(DualCrnCommand.class);
- if (idx >= commandList.size()) {
+ if (idx >= 2) {
Long updateWrkSts = null;
if (wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts) {
updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts;
@@ -631,25 +726,6 @@
if(outStationList.isEmpty()){
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
return;
- }
-
- StationObjModel outStationObjModel = null;
- for (StationObjModel stationObjModel : outStationList) {
- if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
- outStationObjModel = stationObjModel;
- break;
- }
- }
-
- if (outStationObjModel == null) {
- News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏈壘鍒板尮閰嶇殑浠诲姟鍑哄簱绔�", basDualCrnp.getCrnNo());
- return;
- }
-
- if (station == 1) {
- redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
- }else {
- redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel.getDualCrnSlaveStation(), SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
}
if(mainProcessPlugin.contains("Fake")) {
@@ -689,12 +765,6 @@
redisUtil.set(RedisKeyType.DUAL_CRN_IO_EXECUTE_FINISH_LIMIT.key + basDualCrnp.getCrnNo() + "_" + taskNo, "lock", 10);
}
}else {
- DualCrnCommand command = commandList.get(idx - 1);
- if (command.getTaskMode() == DualCrnTaskModeType.PICK.id.shortValue()) {
- //鍙栬揣鍚庣瓑寰呬笅涓�涓换鍔℃椂闀�
- redisUtil.set(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + basDualCrnp.getCrnNo(), "wait", 10);
- }
-
DualCrnCommand resetCommand = dualCrnThread.getResetCommand(dualCrnProtocol.getCrnNo(), station);
MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand));
News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护瀹屾垚纭鎴愬姛锛屽爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basDualCrnp.getCrnNo(), taskNo);
@@ -718,13 +788,13 @@
if (lock != null) {
return false;
}
- redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
Integer shallowRow = Utils.getShallowRowByDeepRow(Utils.getRow(locNo));
if (shallowRow == null) {
return true;
}
+ redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
String shallowLocNo = Utils.getLocNo(shallowRow, Utils.getBay(locNo), Utils.getLev(locNo));
LocMast shallowLocMast = locMastService.queryByLoc(shallowLocNo);
if (shallowLocMast == null) {
@@ -762,76 +832,6 @@
}
}
return false;
- }
-
- private int calcStation(DualCrnProtocol dualCrnProtocol, String type) {
- List<Integer> idleStationList = new ArrayList<>();
-
- if (dualCrnProtocol.getTaskNo() == 0
- && dualCrnProtocol.getLoaded() == 0
- && dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE)
- && dualCrnProtocol.getTaskReceive() == 0
- ) {
- idleStationList.add(1);
- }
-
- if (dualCrnProtocol.getTaskNoTwo() == 0
- && dualCrnProtocol.getLoadedTwo() == 0
- && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE)
- && dualCrnProtocol.getTaskReceiveTwo() == 0
- ) {
- idleStationList.add(2);
- }
-
- if (type.equals("locMove")) {
- if (idleStationList.size() != 2) {
- return 0;
- }
- return idleStationList.get(0);
- }
-
- if (idleStationList.size() == 2) {
- return idleStationList.get(0);
- }
-
- Integer idleStation = idleStationList.get(0);
- int workingStation = idleStation == 1 ? 2 : 1;
-
- int executeTaskNo = 0;
- if (workingStation == 1) {
- executeTaskNo = dualCrnProtocol.getTaskNo();
- //妫�娴嬪伐浣嶅凡杩涘叆鏀捐揣闃舵锛屾斁璐ч樁娈典笉鎺ユ柊浠诲姟
- if (dualCrnProtocol.getStatusType().equals(DualCrnStatusType.PUT_MOVING)
- || dualCrnProtocol.getStatusType().equals(DualCrnStatusType.PUTTING)
- || dualCrnProtocol.getStatusType().equals(DualCrnStatusType.WAITING)
- ) {
- return 0;
- }
- } else {
- executeTaskNo = dualCrnProtocol.getTaskNoTwo();
- //妫�娴嬪伐浣嶅凡杩涘叆鏀捐揣闃舵锛屾斁璐ч樁娈典笉鎺ユ柊浠诲姟
- if (dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.PUT_MOVING)
- || dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.PUTTING)
- || dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.WAITING)
- ) {
- return 0;
- }
- }
-
- if (executeTaskNo == 0) {
- return 0;
- }
-
- WrkMast wrkMast = wrkMastService.selectByWorkNo(executeTaskNo);
- if (wrkMast.getIoType().equals(WrkIoType.IN.id) && type.equals("in")) {
- return idleStation;
- }
-
- if (wrkMast.getIoType().equals(WrkIoType.OUT.id) && type.equals("out")) {
- return idleStation;
- }
-
- return 0;
}
private boolean reassignTaskLocNo(WrkMast wrkMast, StationObjModel stationObjModel) {
--
Gitblit v1.9.1