From 7f42a1951c9aea0f03443c8b8f65b79df7168b36 Mon Sep 17 00:00:00 2001
From: zc <zc@123>
Date: 星期一, 05 五月 2025 09:12:53 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 199 +++++++++++++++++++++++++++++++++++++------------
1 files changed, 151 insertions(+), 48 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index 4840377..9215770 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -22,10 +22,7 @@
import com.zy.core.cache.SlaveConnection;
import com.zy.core.dispatcher.ShuttleDispatchUtils;
import com.zy.core.enums.*;
-import com.zy.core.model.DevpSlave;
-import com.zy.core.model.LiftSlave;
-import com.zy.core.model.ShuttleSlave;
-import com.zy.core.model.Task;
+import com.zy.core.model.*;
import com.zy.core.model.command.*;
import com.zy.core.model.protocol.ForkLiftStaProtocol;
import com.zy.core.model.protocol.LiftProtocol;
@@ -37,13 +34,13 @@
import com.zy.core.thread.LiftThread;
import com.zy.core.thread.ShuttleThread;
import com.zy.core.thread.impl.FyDevpThread;
+import com.zy.core.thread.impl.NormalLedThread;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import java.io.IOException;
import java.util.*;
/**
@@ -183,32 +180,33 @@
LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
String errMsg = "";
if (!back && staProtocol.isBackErr()) {
- errMsg = "瓒呭寮傚父";
+ errMsg = "鍚庤秴闄�";
back = true;
}
if (!back && staProtocol.isHighErr()) {
errMsg = "瓒呴珮寮傚父";
back = true;
}
- if (!back && staProtocol.isRightErr()) {
- errMsg = "瓒呴暱寮傚父";
+ if (!back && staProtocol.isWeightErr()) {
+ errMsg = "瓒呴噸寮傚父";
back = true;
}
- if (!back && staProtocol.isWeightErr()) {
- errMsg = "瓒呴噸";
+ if (!back && staProtocol.isRightErr()) {
+ errMsg = "鍙宠秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isLeftErr()) {
+ errMsg = "宸﹁秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isBarcodeErr()) {
+ errMsg = "鎵爜寮傚父";
back = true;
}
// 閫�鍥�
if (back) {
- if (!staProtocol.isLoading()) {
- continue;
- }
- if (!staProtocol.isPakMk()) {
- continue;
- }
// led 寮傚父鏄剧ず
if (ledThread != null) {
- MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
ledThread.error(errMsg);
}
}
@@ -231,8 +229,6 @@
wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts);
wrkMast.setModiTime(new Date());
wrkMastService.updateById(wrkMast);
- setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo());
-
} else if (wrkMast != null && wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts) {
continue;
}
@@ -293,6 +289,9 @@
.setJson(JSON.toJSONString(hashMap))
.build()
.doPost();
+// if (!Cools.isEmpty(msg)&&"璇峰厛缁勬墭".equalsIgnoreCase(msg)){
+// ledThread.error(msg);
+// }
News.error("鍏ュ簱鐢宠澶辫触锛屼换鍔℃暟鎹�={}锛岃姹傚搷搴�={}", JSON.toJSON(param), JSON.toJSON(jsonObject));
}
} catch (Exception e) {
@@ -308,6 +307,42 @@
} else {
staProtocol = staProtocol.clone();
}
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ String errMsg = "";
+ boolean back = false;
+ if (!back && staProtocol.isBackErr()) {
+ errMsg = "鍚庤秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isHighErr()) {
+ errMsg = "瓒呴珮寮傚父";
+ back = true;
+ }
+ if (!back && staProtocol.isWeightErr()) {
+ errMsg = "瓒呴噸寮傚父";
+ back = true;
+ }
+ if (!back && staProtocol.isRightErr()) {
+ errMsg = "鍙宠秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isLeftErr()) {
+ errMsg = "宸﹁秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isBarcodeErr()) {
+ errMsg = "鎵爜寮傚父";
+ back = true;
+ }
+ // 閫�鍥�
+ if (back) {
+
+ // led 寮傚父鏄剧ず
+ if (ledThread != null) {
+ ledThread.error(errMsg);
+ }
+ }
+
Short workNo = staProtocol.getWorkNo();
if (staProtocol.isAutoing() && staProtocol.isLoading() && isInEnable(devpThread, inSta.getStaNo()) && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999)) && staProtocol.isPakMk()) {
String barcode = staProtocol.getBarcode();
@@ -329,7 +364,6 @@
JSONObject jsonObject = JSON.parseObject(response);
Integer code = jsonObject.getInteger("code");
if (code.equals(200)) {
- setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo());
} else {
String msg = jsonObject.getString("msg");
@@ -342,6 +376,9 @@
.setJson(JSON.toJSONString(hashMap))
.build()
.doPost();
+// if (!Cools.isEmpty(msg)&&"璇峰厛缁勬墭".equalsIgnoreCase(msg)){
+// ledThread.error(msg);
+// }
News.error("鍏ュ簱鐢宠澶辫触锛屼换鍔℃暟鎹�={}锛岃姹傚搷搴�={}", JSON.toJSON(param), JSON.toJSON(jsonObject));
}
} catch (Exception e) {
@@ -388,6 +425,29 @@
if (wrkMast.getStaNo() == 1026) {
locNo = "1200305";
}
+ //鑾峰彇鎻愬崌鏈轰俊鎭�
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, 1);
+ if (liftThread == null) {
+ continue;
+ }
+
+ LiftProtocol liftProtocol = liftThread.getStatus();
+ if (liftProtocol == null) {
+ continue;
+ }
+
+ if (!liftThread.isIdle()) {
+ continue;
+ }
+
+
+ //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩�
+ if (liftProtocol.getHasTray()) {
+ News.info("{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満鍐呮棤鎵樼洏锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftProtocol.getLiftNo());
+ continue;
+ }
+
+
boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleNoLift(wrkMast.getWrkNo(), locNo, wrkMast.getLocNo(), "TRANSPORT_DEVP");
if (!dispatchShuttle) {
News.info("{}浠诲姟锛岃皟搴﹀皬杞﹀け璐�", wrkMast.getWrkNo());
@@ -401,6 +461,8 @@
wrkMast.setModiTime(new Date());
if (!wrkMastService.updateById(wrkMast)) {
News.info("{}浠诲姟锛屾洿鏂板伐浣滄。澶辫触", wrkMast.getWrkNo());
+ } else {
+ setLedData(Integer.parseInt(wrkMast.getWmsWrkNo()), wrkMast.getStaNo());
}
}
}
@@ -422,28 +484,41 @@
if (staProtocol == null) {
continue;
}
-
+ List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", WrkStsType.OUTBOUND_SHUTTLE_RUN.sts, WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts).in("sta_no", 1013, 1024));
+ if (wrkMastList != null && wrkMastList.size() >= 2) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岃烦杩囷紝瀛樺湪2鏉″伐浣滄。", wrkMast.getWrkNo());
+ continue;
+ }
if (!staProtocol.isAutoing()) {
- News.info("{}浠诲姟锛寋}绔欑偣锛屼笉鍦ㄨ嚜鍔ㄧ姸鎬�", wrkMast.getWrkNo(), staProtocol.getSiteId());
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣锛屼笉鍦ㄨ嚜鍔ㄧ姸鎬�", wrkMast.getWrkNo(), staProtocol.getSiteId());
continue;
}
if (!isOutEnable(devpThread, wrkMast.getStaNo())) {
- News.info("{}浠诲姟锛寋}绔欑偣锛屾病鏈夊彲鍑轰俊鍙�", wrkMast.getWrkNo(), staProtocol.getSiteId());
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣锛屾病鏈夊彲鍑轰俊鍙�", wrkMast.getWrkNo(), staProtocol.getSiteId());
+ continue;
+ }
+ StaProtocol staProtocol2 = station.get(wrkMast.getStaNo() + 2);
+ if (staProtocol2.isLoading()) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙疯緭閫佺嚎鏈夌墿222", wrkMast.getWrkNo(), wrkMast.getStaNo() + 2);
continue;
}
String locNo = "1200301";
if (wrkMast.getStaNo() == 1024) {
locNo = "1200305";
}
+
boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleNoLift(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), locNo, "TRANSPORT_DEVP");
if (!dispatchShuttle) {
- News.info("{}浠诲姟锛岃皟搴﹀皬杞﹀け璐�", wrkMast.getWrkNo());
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岃皟搴﹀皬杞﹀け璐�", wrkMast.getWrkNo());
continue;
}
-
+ WrkMast wrkMast2 = wrkMastService.selectByMainWrkNo(wrkMast.getWrkNo());
wrkMast.setWrkSts(WrkStsType.OUTBOUND_SHUTTLE_RUN.sts);
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
wrkMast.setModiTime(now);
+ if (wrkMast2 != null) {
+ wrkMast.setShuttleNo(wrkMast2.getShuttleNo());
+ }
if (!wrkMastService.updateById(wrkMast)) {
News.info("{}浠诲姟锛屾洿鏂板伐浣滄。澶辫触", wrkMast.getWrkNo());
} else {
@@ -516,7 +591,7 @@
wrkMast.setModiTime(new Date());
wrkMast.setShuttleNo(null);
wrkMastService.updateById(wrkMast);
- setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo());
+ setLedData(Integer.parseInt(wrkMast.getWmsWrkNo()), wrkMast.getStaNo());
}
}
}
@@ -526,7 +601,6 @@
private void setLedData(Integer wrkNo, Integer staNo) {
try {
- List<LedCommand> commands = new ArrayList<>();
Map<String, Object> param = new HashMap<>();
param.put("taskNo", wrkNo);
String response = null;
@@ -541,9 +615,10 @@
if (code.equals(200)) {
String data = jsonObject.getString("data");
List<LedCommand> wrkDetls = JSONArray.parseArray(data, LedCommand.class);
- commands.addAll(wrkDetls);
- redisUtil.set("LED_" + staNo, commands, 10);
- log.info("鐢佃鏈烘暟鎹缃細{}", data);
+ redisUtil.set("LED_" + staNo, wrkDetls, 30);
+ log.info("鐢佃鏈烘暟鎹缃細{},{}", staNo, data);
+ } else {
+ log.info("鐢佃鏈烘暟鎹缃紓甯革細{},{}", wrkNo, response);
}
} catch (Exception e) {
e.printStackTrace();
@@ -884,17 +959,17 @@
for (WrkMast wrkMast : wrkMasts) {
boolean step0 = this.liftInExecuteStep0(wrkMast);//璁惧涓婅蛋
if (!step0) {
- return;
+ continue;
}
boolean step1 = this.liftInExecuteStep1(wrkMast);//鎻愬崌鏈烘惉杩�
if (!step1) {
- return;
+ continue;
}
boolean step2 = this.liftInExecuteStep2(wrkMast);//瑙﹀彂鎼繍浠诲姟
if (!step2) {
- return;
+ continue;
}
}
} catch (Exception e) {
@@ -925,19 +1000,27 @@
LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led);
String errMsg = "";
if (!back && staProtocol.isBackErr()) {
- errMsg = "瓒呭寮傚父";
+ errMsg = "鍚庤秴闄�";
back = true;
}
if (!back && staProtocol.isHighErr()) {
errMsg = "瓒呴珮寮傚父";
back = true;
}
- if (!back && staProtocol.isRightErr()) {
- errMsg = "瓒呴暱寮傚父";
+ if (!back && staProtocol.isWeightErr()) {
+ errMsg = "瓒呴噸寮傚父";
back = true;
}
- if (!back && staProtocol.isWeightErr()) {
- errMsg = "瓒呴噸";
+ if (!back && staProtocol.isRightErr()) {
+ errMsg = "鍙宠秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isLeftErr()) {
+ errMsg = "宸﹁秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isBarcodeErr()) {
+ errMsg = "鎵爜寮傚父";
back = true;
}
// 閫�鍥�
@@ -949,19 +1032,20 @@
}
}
String barcode = staProtocol.getBarcode();
- if (Cools.isEmpty(barcode) || "?".endsWith(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
- return false;
- }
- if (!staProtocol.isAutoing()) {
- News.info("{}浠诲姟锛寋}绔欑偣锛屼笉鍦ㄨ嚜鍔ㄧ姸鎬�", wrkMast.getWrkNo(), staProtocol.getSiteId());
- return false;
- }
+
if (!staProtocol.isLoading()) {
News.info("{}浠诲姟锛寋}绔欑偣锛屾棤鎵樼洏", wrkMast.getWrkNo(), staProtocol.getSiteId());
return false;
}
if (wrkMast.getSourceStaNo() != 1031) {
+ if (!staProtocol.isAutoing()) {
+ News.info("{}浠诲姟锛寋}绔欑偣锛屼笉鍦ㄨ嚜鍔ㄧ姸鎬�", wrkMast.getWrkNo(), staProtocol.getSiteId());
+ return false;
+ }
+ if (Cools.isEmpty(barcode) || "?".endsWith(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
+ return false;
+ }
if (!staProtocol.getBarcode().equals(wrkMast.getBarcode())) {
News.info("{}浠诲姟锛寋}绔欑偣锛屾墭鐩樼爜涓嶅尮閰嶏紝绔欑偣鎵樼洏鐮侊細{}锛屼换鍔℃墭鐩樼爜锛歿}", wrkMast.getWrkNo(), staProtocol.getSiteId(), staProtocol.getBarcode(), wrkMast.getBarcode());
return false;
@@ -993,6 +1077,7 @@
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ setLedData(Integer.parseInt(wrkMast.getWmsWrkNo()), wrkMast.getStaNo());
return false;
}
return false;
@@ -1192,12 +1277,12 @@
for (WrkMast wrkMast : wrkMasts) {
boolean step1 = this.liftOutExecuteStep1(wrkMast);//瑙﹀彂鎼繍浠诲姟
if (!step1) {
- return;
+ continue;
}
boolean step2 = this.liftOutExecuteStep2(wrkMast);//鎻愬崌鏈烘惉杩�
if (!step2) {
- return;
+ continue;
}
}
} catch (Exception e) {
@@ -1341,7 +1426,7 @@
wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
- setLedData(wrkMast.getWrkNo(), wrkMast.getStaNo());
+ setLedData(Integer.parseInt(wrkMast.getWmsWrkNo()), wrkMast.getStaNo());
//涓嬪彂浠诲姟
liftAction.assignWork(wrkMast.getLiftNo(), assignCommand);
return false;
@@ -1393,6 +1478,7 @@
continue;//灏忚溅鏈埌杈剧洰鏍囧眰
}
wrkMast.setWrkSts(WrkStsType.MOVE_OUT_LIFT_COMPLETE.sts);
+ wrkMast.setLiftNo(null);
shuttleThread.setSyncTaskNo(0);
} else if (wrkMast.getWrkSts() == WrkStsType.MOVE_SHUTTLE.sts) {
//310.灏忚溅绉诲姩涓� ==> 311.灏忚溅绉诲姩瀹屾垚
@@ -1457,6 +1543,11 @@
notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//瑙﹀彂閫氱煡
} else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_12.sts) {
wrkMast.setWrkSts(WrkStsType.MOVE_OUT_NO_LIFT_13.sts);
+ WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkMast.getMainWrkNo());
+ if (wrkMast1 != null) {
+ wrkMast1.setShuttleNo(wrkMast.getShuttleNo());
+ log.info("瀵逛富宸ヤ綔妗h繘琛岀粦瀹氬皬杞︼紝涓轰簡灏忚溅杩涜绉昏溅,{},{}", wrkMast1.getWrkNo(), wrkMast.getShuttleNo());
+ }
shuttleThread.setSyncTaskNo(0);
notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//瑙﹀彂閫氱煡
} else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_NO_LIFT_10.sts) {
@@ -1778,6 +1869,14 @@
try {
this.recShuttleErr();
this.recLiftErr();
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, 1);
+ ledThread.errorReset();
+ ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, 2);
+ ledThread.errorReset();
+ ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, 3);
+ ledThread.errorReset();
+ ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, 4);
+ ledThread.errorReset();
} catch (Exception e) {
News.error("recErr fail", e);
}
@@ -2301,6 +2400,10 @@
* 鍏ュ嚭搴撴ā寮忓垏鎹㈠嚱鏁�
*/
public synchronized void ioConvert() {
+ for (LedSlave led : slaveProperties.getLed()) {
+ NormalLedThread ledThread = (NormalLedThread) SlaveConnection.get(SlaveType.Led, led.getId());
+ ledThread.reset();
+ }
try {
// 鏍规嵁杈撻�佺嚎plc閬嶅巻
FyDevpThread devpThread = (FyDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
--
Gitblit v1.9.1