From 5e4345b5903010cbd63bb7edad3bbce479e2b57d Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期二, 06 一月 2026 09:51:50 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java | 593 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 424 insertions(+), 169 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
index 68d3406..983b5db 100644
--- a/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
@@ -2,10 +2,10 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.exception.CoolException;
import com.zy.asrs.domain.param.CreateLocMoveTaskParam;
-import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.entity.BasDualCrnp;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
@@ -22,15 +22,14 @@
import com.zy.core.enums.*;
import com.zy.core.model.StationObjModel;
import com.zy.core.model.Task;
-import com.zy.core.model.command.CrnCommand;
import com.zy.core.model.command.DualCrnCommand;
-import com.zy.core.model.protocol.CrnProtocol;
+import com.zy.core.model.command.StationCommand;
import com.zy.core.model.protocol.DualCrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
-import com.zy.core.thread.CrnThread;
import com.zy.core.thread.DualCrnThread;
import com.zy.core.thread.StationThread;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
@@ -42,6 +41,8 @@
@Component
public class DualCrnOperateProcessUtils {
+ @Value("${mainProcessPlugin}")
+ private String mainProcessPlugin;
@Autowired
private WrkMastService wrkMastService;
@Autowired
@@ -56,7 +57,7 @@
private CommonService commonService;
//鍏ュ嚭搴� ===>> 鍙屽伐浣嶅爢鍨涙満鍏ュ嚭搴撲綔涓氫笅鍙�
- public synchronized void dualRrnIoExecute() {
+ public synchronized void dualCrnIoExecute() {
List<BasDualCrnp> basDualCrnps = basDualCrnpService.selectList(new EntityWrapper<>());
for (BasDualCrnp basDualCrnp : basDualCrnps) {
DualCrnThread dualCrnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, basDualCrnp.getCrnNo());
@@ -85,72 +86,67 @@
continue;
}
- int executeTaskNo = 0;
- if (dualCrnProtocol.getTaskNo() > 0) {
- executeTaskNo = dualCrnProtocol.getTaskNo();
- }
- if (dualCrnProtocol.getTaskNoTwo() > 0) {
- executeTaskNo = dualCrnProtocol.getTaskNoTwo();
- }
-
- if (executeTaskNo > 0) {
- WrkMast wrkMast = wrkMastService.selectByWorkNo(executeTaskNo);
- if (wrkMast != null) {
- if (wrkMast.getIoType().equals(WrkIoType.IN.id)) {
- this.crnExecuteIn(basDualCrnp, dualCrnThread); // 鍏ュ簱
- } else if (wrkMast.getIoType().equals(WrkIoType.OUT.id)) {
- this.crnExecuteOut(basDualCrnp, dualCrnThread); // 鍑哄簱
- }else {
- continue;
- }
- }
- }
-
- // 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
- if (dualCrnProtocol.getLastIo().equals("I")) {
- if (basDualCrnp.getInEnable().equals("Y")) {
- this.crnExecuteIn(basDualCrnp, dualCrnThread); // 鍏ュ簱
- dualCrnProtocol.setLastIo("O");
- } else if (basDualCrnp.getOutEnable().equals("Y")) {
- this.crnExecuteOut(basDualCrnp, dualCrnThread); // 鍑哄簱
- dualCrnProtocol.setLastIo("I");
- }
- }
- // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
- else if (dualCrnProtocol.getLastIo().equals("O")) {
- if (basDualCrnp.getOutEnable().equals("Y")) {
- this.crnExecuteOut(basDualCrnp, dualCrnThread); // 鍑哄簱
- dualCrnProtocol.setLastIo("I");
- } else if (basDualCrnp.getInEnable().equals("Y")) {
- this.crnExecuteIn(basDualCrnp, dualCrnThread); // 鍏ュ簱
- dualCrnProtocol.setLastIo("O");
- }
- }
+ this.crnExecute(basDualCrnp, dualCrnThread);
}
}
- private synchronized void crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
+ private synchronized void crnExecute(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
if(dualCrnProtocol == null){
return;
}
+ List<WrkMast> allTaskList = new ArrayList<>();
+ List<WrkMast> inTaskList = getInTaskList(basDualCrnp);
+ List<WrkMast> outTaskList = getOutTaskList(basDualCrnp);
+ List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp);
+
+ if (!locMoveTaskList.isEmpty()) {
+ allTaskList.addAll(locMoveTaskList);
+ }
+
+ // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
+ if (dualCrnProtocol.getLastIo().equals("O")) {
+ allTaskList.addAll(inTaskList);
+ allTaskList.addAll(outTaskList);
+ }
+ // 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
+ else if (dualCrnProtocol.getLastIo().equals("I")) {
+ allTaskList.addAll(outTaskList);
+ allTaskList.addAll(inTaskList);
+ }
+
+ for (WrkMast wrkMast : allTaskList) {
+ if (wrkMast.getIoType() == WrkIoType.IN.id) {
+ boolean result = this.crnExecuteIn(basDualCrnp, dualCrnThread, wrkMast);
+ if (result) {
+ break;
+ }
+ } 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;
+ }
+ }
+ }
+ }
+
+ private List<WrkMast> getInTaskList(BasDualCrnp basDualCrnp) {
+ List<WrkMast> list = new ArrayList<>();
if(!basDualCrnp.getInEnable().equals("Y")){
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙叆淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
- return;
+ return list;
}
List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
if(inStationList.isEmpty()){
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍏ュ簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
- return;
- }
-
- Integer crnNo = basDualCrnp.getCrnNo();
- int station = calcStation(dualCrnProtocol);
- if(station == 0){
- News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏃犲彲鐢ㄥ伐浣�", basDualCrnp.getCrnNo());
- return;
+ return list;
}
for (StationObjModel stationObjModel : inStationList) {
@@ -190,19 +186,217 @@
}
if(wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts){
- News.taskInfo(stationProtocol.getTaskNo(), "宸ヤ綔鍙�:{} 浠诲姟鐘舵�佸紓甯�", stationProtocol.getTaskNo());
+ continue;
+ }
+
+ list.add(wrkMast);
+ }
+
+ return list;
+ }
+
+ private List<WrkMast> getOutTaskList(BasDualCrnp basDualCrnp) {
+ List<WrkMast> list = new ArrayList<>();
+ if(!basDualCrnp.getOutEnable().equals("Y")){
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙嚭淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
+ return list;
+ }
+
+ List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
+ if(outStationList.isEmpty()){
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
+ return list;
+ }
+
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .eq("dual_crn_no", basDualCrnp.getCrnNo())
+ .eq("wrk_sts", WrkStsType.NEW_OUTBOUND.sts)
+ );
+ list.addAll(wrkMasts);
+ return list;
+ }
+
+ private List<WrkMast> getLocMoveTaskList(BasDualCrnp basDualCrnp) {
+ List<WrkMast> list = new ArrayList<>();
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .eq("dual_crn_no", basDualCrnp.getCrnNo())
+ .eq("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts)
+ );
+ list.addAll(wrkMasts);
+ return list;
+ }
+
+ private synchronized boolean crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
+ DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+ if (dualCrnProtocol == null) {
+ return false;
+ }
+
+ if (!basDualCrnp.getInEnable().equals("Y")) {
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙叆淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
+ return false;
+ }
+
+ List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
+ if(inStationList.isEmpty()){
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍏ュ簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
+ return false;
+ }
+
+ Integer crnNo = basDualCrnp.getCrnNo();
+ int station = calcStation(dualCrnProtocol, "in");
+ if (station == 0) {
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏃犲彲鐢ㄥ伐浣�", basDualCrnp.getCrnNo());
+ return false;
+ }
+
+ if (wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
+ return false;
+ }
+
+ // 鑾峰彇搴撲綅淇℃伅
+ LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
+ if (locMast == null) {
+ News.taskInfo(wrkMast.getWrkNo(), "鐩爣搴撲綅:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getLocNo());
+ return false;
+ }
+
+ if (!locMast.getLocSts().equals("S")) {
+ News.taskInfo(wrkMast.getWrkNo(), "鐩爣搴撲綅:{} 鐘舵�佸紓甯�", wrkMast.getLocNo());
+ return false;
+ }
+
+ //妫�娴嬫祬搴撲綅鐘舵��
+ boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
+ if (!checkStatus) {
+ News.taskInfo(wrkMast.getWrkNo(), "鍥犳祬搴撲綅鍫靛鏃犳硶鎵ц");
+ return false;
+ }
+
+ StationObjModel inStationObjModel = null;
+ 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());
+ if (stationProtocol == null) {
+ continue;
+ }
+
+ if (!stationProtocol.isAutoing()) {
+ continue;
+ }
+
+ if (!stationProtocol.isLoading()) {
+ continue;
+ }
+
+ if (stationProtocol.getTaskNo() <= 0) {
+ continue;
+ }
+
+ if (!stationProtocol.isInEnable()) {
+ News.taskInfo(stationProtocol.getTaskNo(), "鍙栬揣绔欑偣:{} 娌℃湁鍙叆淇″彿", stationObjModel.getStationId());
+ continue;
+ }
+
+ if (stationProtocol.getTaskNo().equals(wrkMast.getWrkNo())) {
+ inStationObjModel = stationObjModel;
+ break;
+ }
+ }
+
+ if (inStationObjModel == null) {
+ News.taskInfo(wrkMast.getWrkNo(), "鏈悳绱㈠埌鍙栬揣绔欑偣");
+ return false;
+ }
+
+ String sourceLocNo = Utils.getLocNo(inStationObjModel.getDeviceRow(), inStationObjModel.getDeviceBay(), inStationObjModel.getDeviceLev());
+
+ List<DualCrnCommand> commandList = new ArrayList<>();
+ DualCrnCommand pickCommand = dualCrnThread.getPickCommand(sourceLocNo, wrkMast.getWrkNo(), crnNo, station);
+ DualCrnCommand putCommand = dualCrnThread.getPutCommand(wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo, station);
+ commandList.add(pickCommand);
+ commandList.add(putCommand);
+
+ wrkMast.setWrkSts(WrkStsType.INBOUND_RUN.sts);
+ wrkMast.setDualCrnNo(crnNo);
+ wrkMast.setSystemMsg("");
+ wrkMast.setIoTime(new Date());
+ if (wrkMastService.updateById(wrkMast)) {
+ MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
+ News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
+ dualCrnProtocol.setLastIo("I");
+ return true;
+ }
+ return false;
+ }
+
+ private synchronized boolean crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
+ DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+ if (dualCrnProtocol == null) {
+ return false;
+ }
+
+ if (!basDualCrnp.getOutEnable().equals("Y")) {
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙嚭淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
+ return false;
+ }
+
+ List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
+ if (outStationList.isEmpty()) {
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
+ return false;
+ }
+
+ Integer crnNo = basDualCrnp.getCrnNo();
+ int station = calcStation(dualCrnProtocol, "out");
+ if (station == 0) {
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏃犲彲鐢ㄥ伐浣�", basDualCrnp.getCrnNo());
+ return false;
+ }
+
+ for (StationObjModel stationObjModel : outStationList) {
+ 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());
+ if (stationProtocol == null) {
+ continue;
+ }
+
+ if (!stationProtocol.isAutoing()) {
+ continue;
+ }
+
+ if (stationProtocol.isLoading()) {
+ continue;
+ }
+
+ if (stationProtocol.getTaskNo() != 0) {
+ continue;
+ }
+
+ if (!stationProtocol.isOutEnable()) {
+ News.info("鏀捐揣绔欑偣:{} 娌℃湁鍙嚭淇″彿", stationObjModel.getStationId());
continue;
}
// 鑾峰彇搴撲綅淇℃伅
- LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
+ LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());
if (locMast == null) {
- News.taskInfo(wrkMast.getWrkNo(), "鐩爣搴撲綅:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getLocNo());
+ News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getSourceLocNo());
continue;
}
- if (!locMast.getLocSts().equals("S")) {
- News.taskInfo(wrkMast.getWrkNo(), "鐩爣搴撲綅:{} 鐘舵�佸紓甯�", wrkMast.getLocNo());
+ if (!locMast.getLocSts().equals("R")) {
+ News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 鐘舵�佸紓甯�", wrkMast.getSourceLocNo());
continue;
}
@@ -213,124 +407,96 @@
continue;
}
- String sourceLocNo = Utils.getLocNo(stationObjModel.getDeviceRow(), stationObjModel.getDeviceBay(), stationObjModel.getDeviceLev());
+ String targetLocNo = Utils.getLocNo(stationObjModel.getDeviceRow(), stationObjModel.getDeviceBay(), stationObjModel.getDeviceLev());
List<DualCrnCommand> commandList = new ArrayList<>();
- DualCrnCommand pickCommand = dualCrnThread.getPickCommand(sourceLocNo, wrkMast.getWrkNo(), crnNo, station);
- DualCrnCommand putCommand = dualCrnThread.getPutCommand(wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo, station);
+ DualCrnCommand pickCommand = dualCrnThread.getPickCommand(wrkMast.getSourceLocNo(), wrkMast.getWrkNo(), crnNo, station);
+ DualCrnCommand putCommand = dualCrnThread.getPutCommand(targetLocNo, wrkMast.getWrkNo(), crnNo, station);
commandList.add(pickCommand);
commandList.add(putCommand);
- wrkMast.setWrkSts(WrkStsType.INBOUND_RUN.sts);
+ wrkMast.setWrkSts(WrkStsType.OUTBOUND_RUN.sts);
wrkMast.setDualCrnNo(crnNo);
wrkMast.setSystemMsg("");
wrkMast.setIoTime(new Date());
if (wrkMastService.updateById(wrkMast)) {
MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
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;
}
}
+ return false;
}
- private synchronized void crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
+ private synchronized boolean crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
- if(dualCrnProtocol == null){
- return;
- }
-
- if(!basDualCrnp.getOutEnable().equals("Y")){
- News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙嚭淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
- return;
- }
-
- List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
- if(outStationList.isEmpty()){
- News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
- return;
+ if (dualCrnProtocol == null) {
+ return false;
}
Integer crnNo = basDualCrnp.getCrnNo();
- int station = calcStation(dualCrnProtocol);
- if(station == 0){
+ int station = calcStation(dualCrnProtocol, "locMove");
+ if (station == 0) {
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏃犲彲鐢ㄥ伐浣�", basDualCrnp.getCrnNo());
- return;
+ return false;
}
List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
.eq("crn_no", crnNo)
- .eq("wrk_sts", WrkStsType.NEW_OUTBOUND.sts)
+ .eq("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts)
);
- for (WrkMast wrkMast : wrkMasts) {
- for (StationObjModel stationObjModel : outStationList) {
- 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());
- if (stationProtocol == null) {
- continue;
- }
-
- if (!stationProtocol.isAutoing()) {
- continue;
- }
-
- if (stationProtocol.isLoading()) {
- continue;
- }
-
- if (stationProtocol.getTaskNo() != 0) {
- continue;
- }
-
- if (!stationProtocol.isOutEnable()) {
- News.info("鏀捐揣绔欑偣:{} 娌℃湁鍙嚭淇″彿", stationObjModel.getStationId());
- continue;
- }
-
- // 鑾峰彇搴撲綅淇℃伅
- LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());
- if (locMast == null) {
- News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getSourceLocNo());
- continue;
- }
-
- if (!locMast.getLocSts().equals("R")) {
- News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 鐘舵�佸紓甯�", wrkMast.getSourceLocNo());
- continue;
- }
-
- //妫�娴嬫祬搴撲綅鐘舵��
- boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
- if (!checkStatus) {
- News.taskInfo(wrkMast.getWrkNo(), "鍥犳祬搴撲綅鍫靛鏃犳硶鎵ц");
- continue;
- }
-
- String targetLocNo = Utils.getLocNo(stationObjModel.getDeviceRow(), stationObjModel.getDeviceBay(), stationObjModel.getDeviceLev());
-
- List<DualCrnCommand> commandList = new ArrayList<>();
- DualCrnCommand pickCommand = dualCrnThread.getPickCommand(wrkMast.getSourceLocNo(), wrkMast.getWrkNo(), crnNo, station);
- DualCrnCommand putCommand = dualCrnThread.getPutCommand(targetLocNo, wrkMast.getWrkNo(), crnNo, station);
- commandList.add(pickCommand);
- commandList.add(putCommand);
-
- wrkMast.setWrkSts(WrkStsType.OUTBOUND_RUN.sts);
- wrkMast.setDualCrnNo(crnNo);
- wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
- if (wrkMastService.updateById(wrkMast)) {
- MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
- //鍙栬揣鍚庣瓑寰呬笅涓�涓换鍔℃椂闀�
- redisUtil.set(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnNo, "wait", 5);
- News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
- return;
- }
- }
+ // 鑾峰彇婧愬簱浣嶄俊鎭�
+ LocMast sourceLocMast = locMastService.selectById(wrkMast.getSourceLocNo());
+ if (sourceLocMast == null) {
+ News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getSourceLocNo());
+ return false;
}
+
+ if(!sourceLocMast.getLocSts().equals("R")){
+ News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 鐘舵�佸紓甯革紝涓嶅睘浜庡嚭搴撻绾︾姸鎬�", wrkMast.getSourceLocNo());
+ return false;
+ }
+
+ // 鑾峰彇搴撲綅淇℃伅
+ LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
+ if (locMast == null) {
+ News.taskInfo(wrkMast.getWrkNo(), "搴撲綅:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getLocNo());
+ return false;
+ }
+
+ if (!locMast.getLocSts().equals("S")) {
+ News.taskInfo(wrkMast.getWrkNo(), "搴撲綅:{} 鐘舵�佸紓甯革紝涓嶅睘浜庡叆搴撻绾︾姸鎬�", wrkMast.getLocNo());
+ return false;
+ }
+
+ //妫�娴嬫祬搴撲綅鐘舵��
+ boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
+ if (!checkStatus) {
+ News.taskInfo(wrkMast.getWrkNo(), "鍥犳祬搴撲綅鍫靛鏃犳硶鎵ц");
+ return false;
+ }
+
+ List<DualCrnCommand> commandList = new ArrayList<>();
+ DualCrnCommand pickCommand = dualCrnThread.getPickCommand(wrkMast.getSourceLocNo(), wrkMast.getWrkNo(), crnNo, station);
+ DualCrnCommand putCommand = dualCrnThread.getPutCommand(wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo, station);
+ commandList.add(pickCommand);
+ commandList.add(putCommand);
+
+ wrkMast.setWrkSts(WrkStsType.LOC_MOVE_RUN.sts);
+ wrkMast.setDualCrnNo(crnNo);
+ wrkMast.setSystemMsg("");
+ wrkMast.setIoTime(new Date());
+ if (wrkMastService.updateById(wrkMast)) {
+ MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
+ News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
+ dualCrnProtocol.setLastIo("I");
+ return true;
+ }
+ return false;
}
//鍙屽伐浣嶅爢鍨涙満浠诲姟鎵ц瀹屾垚
@@ -357,12 +523,10 @@
if(dualCrnProtocol.getTaskNo() > 0 && dualCrnProtocol.getStatus() == DualCrnStatusType.WAITING.id) {
executeFinish(basDualCrnp, dualCrnThread, dualCrnProtocol, dualCrnProtocol.getTaskNo(), 1);
- continue;
}
if(dualCrnProtocol.getTaskNoTwo() > 0 && dualCrnProtocol.getStatusTwo() == DualCrnStatusType.WAITING.id) {
executeFinish(basDualCrnp, dualCrnThread, dualCrnProtocol, dualCrnProtocol.getTaskNoTwo(), 2);
- continue;
}
}
}
@@ -395,6 +559,30 @@
updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts;
} else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts) {
updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
+
+ if(mainProcessPlugin.contains("Fake")) {
+ //鐢熸垚浠跨湡绔欑偣鏁版嵁
+ List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
+ if(outStationList.isEmpty()){
+ News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
+ return;
+ }
+
+ for (StationObjModel stationObjModel : outStationList) {
+ if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
+ continue;
+ }
+
+ StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+ if (stationThread == null) {
+ continue;
+ }
+ //鐢熸垚浠跨湡绔欑偣鏁版嵁
+ StationCommand command = stationThread.getMoveCommand(9998, wrkMast.getSourceStaNo(), 0, 0);
+ MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
+ }
+ }
+
} else if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts) {
updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
} else {
@@ -402,16 +590,24 @@
return;
}
- wrkMast.setWrkSts(updateWrkSts);
- wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
- if (wrkMastService.updateById(wrkMast)) {
- DualCrnCommand resetCommand = dualCrnThread.getResetCommand(dualCrnProtocol.getCrnNo(), station);
- MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand));
- News.info("鍙屽伐浣嶅爢鍨涙満浠诲姟鐘舵�佹洿鏂版垚鍔燂紝鍫嗗灈鏈哄彿={}锛屽伐浣滃彿={}", basDualCrnp.getCrnNo(), taskNo);
+ DualCrnCommand resetCommand = dualCrnThread.getResetCommand(dualCrnProtocol.getCrnNo(), station);
+ boolean offer = MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand));
+ if (offer) {
+ wrkMast.setWrkSts(updateWrkSts);
+ wrkMast.setSystemMsg("");
+ wrkMast.setIoTime(new Date());
+ if (wrkMastService.updateById(wrkMast)) {
+ News.info("鍙屽伐浣嶅爢鍨涙満浠诲姟鐘舵�佹洿鏂版垚鍔燂紝鍫嗗灈鏈哄彿={}锛屽伐浣滃彿={}", basDualCrnp.getCrnNo(), taskNo);
+ }
+ redisUtil.set(RedisKeyType.DUAL_CRN_IO_EXECUTE_FINISH_LIMIT.key + basDualCrnp.getCrnNo() + "_" + taskNo, "lock", 10);
}
- 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);
@@ -481,15 +677,74 @@
return false;
}
- private int calcStation(DualCrnProtocol dualCrnProtocol) {
- int station = 0;
- if(dualCrnProtocol.getTaskNo() == 0){
- station = 1;
- }else if (dualCrnProtocol.getTaskNoTwo() == 0){
- station = 2;
+ 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);
}
- return station;
+ 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;
}
}
--
Gitblit v1.9.1