From 62b1f39e60f64ec4e05b21d11af3e36f5891a91a Mon Sep 17 00:00:00 2001
From: zc <zc@123>
Date: 星期二, 29 四月 2025 20:10:27 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 170 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 127 insertions(+), 43 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..3ac2728 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,7 +34,9 @@
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 io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -183,32 +182,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 +231,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;
}
@@ -308,6 +306,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 +363,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");
@@ -388,6 +421,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 +457,8 @@
wrkMast.setModiTime(new Date());
if (!wrkMastService.updateById(wrkMast)) {
News.info("{}浠诲姟锛屾洿鏂板伐浣滄。澶辫触", wrkMast.getWrkNo());
+ } else {
+ setLedData(Integer.parseInt(wrkMast.getWmsWrkNo()), wrkMast.getStaNo());
}
}
}
@@ -435,15 +493,19 @@
if (wrkMast.getStaNo() == 1024) {
locNo = "1200305";
}
+
boolean dispatchShuttle = shuttleDispatchUtils.searchDispatchShuttleNoLift(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), locNo, "TRANSPORT_DEVP");
if (!dispatchShuttle) {
News.info("{}浠诲姟锛岃皟搴﹀皬杞﹀け璐�", 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 +578,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 +588,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 +602,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 +946,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 +987,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 +1019,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 +1064,7 @@
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
+ setLedData(Integer.parseInt(wrkMast.getWmsWrkNo()), wrkMast.getStaNo());
return false;
}
return false;
@@ -1192,12 +1264,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 +1413,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;
@@ -1778,6 +1850,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 +2381,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