From ab246a3f1e94056d57df505b5cc56a08fe6be24e Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期四, 13 七月 2023 09:51:34 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 129 +++++++++++++++++++++++++++++--------------
1 files changed, 87 insertions(+), 42 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 e2bfc50..6644885 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -97,12 +97,12 @@
*/
public synchronized void generateStoreWrkFile(Integer mark) {
// 鏍规嵁杈撻�佺嚎plc閬嶅巻
- for (DevpSlave devp : slaveProperties.getDevp()) {
+ for (DevpSlave devp : slaveProperties.getDevp()) { //閬嶅巻杈撻�佺嚎
// 閬嶅巻鍏ュ簱鍙�
- for (DevpSlave.Sta inSta : devp.getInSta()) {
+ for (DevpSlave.Sta inSta : devp.getInSta()) { // 閬嶅巻鍏ュ簱鍙�
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
- if (barcodeThread == null) {
+ if (barcodeThread == null) { //濡傛灉鎵弿浠病鏈夋暟鎹紝鍒欒烦鍑烘娆″惊鐜紝閬嶅巻涓嬩竴涓叆搴撳彛鎵弿浠�
continue;
}
@@ -127,9 +127,26 @@
if (!staProtocol.isLoading()){
continue;
}
+// String barcode11 = barcodeThread.getBarcode();
+// if (Cools.isEmpty(barcode11)){
+// if (staProtocol.isAutoing()&& !staProtocol.isEmptyMk() && staProtocol.getWorkNo() == 9999 && staProtocol.isPakMk() && staProtocol.getStamp()>=2){
+// staProtocol.setStamp(0);
+// News.info(""+mark+" - 7"+" - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode11, inSta.getStaNo());
+// staProtocol.setWorkNo((short) 9989);
+// staProtocol.setStaNo(inSta.getBackSta().shortValue());
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+// // led 寮傚父鏄剧ず
+// if (ledThread != null) {
+// String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
+// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+// }
+// continue;
+// }
+// }
if (staProtocol.isAutoing() && staProtocol.isInEnable()
&& !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990)
- && staProtocol.isPakMk() && staProtocol.getStamp()>=2) {// && !Cools.isEmpty(barcode)) {
+ && staProtocol.isPakMk()) { //&& staProtocol.getStamp()>=2) {// && !Cools.isEmpty(barcode)) {
News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�");
// try {
// Thread.sleep(300);
@@ -138,6 +155,9 @@
String barcode = barcodeThread.getBarcode();
if(!Cools.isEmpty(barcode)) {
News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
+ if(staProtocol.getStamp()<2){
+ continue;
+ }
if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
staProtocol.setWorkNo((short) 9999);
staProtocol.setStaNo(inSta.getBackSta().shortValue());
@@ -153,6 +173,9 @@
continue;
}
} else {
+ if(staProtocol.getStamp()<2){
+ continue;
+ }
staProtocol.setWorkNo((short) 9999);
staProtocol.setStaNo(inSta.getBackSta().shortValue());
devpThread.setPakMk(staProtocol.getSiteId(), false);
@@ -266,7 +289,7 @@
}
}
- News.infoNoLog(""+mark+" - 0"+" - 鎵ц瀹屾垚");
+ News.infoNoLog(""+mark+" - 0"+" - 缁勬墭 ===銆嬫墽琛屽畬鎴�");
}
@@ -332,7 +355,7 @@
}
}
}
- News.infoNoLog(""+mark+" - 0"+" - 鎵ц瀹屾垚");
+ News.infoNoLog(""+mark+" - 0"+" - wms鍏ュ簱 ===銆嬫墽琛屽畬鎴�");
}
@@ -400,6 +423,17 @@
StaDesc staDesc = staDescService.selectOne(wrapper);
if (Cools.isEmpty(staDesc)) {
News.error(""+mark+" - 2"+" - 鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
+ staProtocol.setWorkNo((short) 9989);
+ staProtocol.setStaNo(pickSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ //LED
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
+ // led 寮傚父鏄剧ず
+ if (ledThread != null) {
+ String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�"+pickSta.getBackSta().shortValue()+"绔欑偣";
+ MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(5, errorMsg));
+ }
continue;
}
@@ -460,7 +494,7 @@
}
}
- News.infoNoLog(""+mark+" - 0"+" - 鎵ц瀹屾垚");
+ News.infoNoLog(""+mark+" - 0"+" - 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱 ===銆嬫墽琛屽畬鎴�");
}
/**
@@ -532,7 +566,7 @@
}
}
}
- News.infoNoLog(""+mark+" - 0"+" - 鎵ц瀹屾垚");
+ News.infoNoLog(""+mark+" - 0"+" - 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 ===銆嬫墽琛屽畬鎴�");
}
/**
@@ -672,6 +706,7 @@
News.error(""+mark+" - 1"+" - 2"+" - 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
continue;
}
+
if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
&& staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
flag = true;
@@ -1071,12 +1106,12 @@
* 搴撲綅绉昏浆
*/
public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol,Integer mark) {
- News.warnNoLog(""+mark+" - 3"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽簱浣嶇Щ杞�");
// 鑾峰彇宸ヤ綔妗d俊鎭�
WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId());
if (null == wrkMast) {
return;
}
+ News.warnNoLog(""+mark+" - 3"+" - 0"+" - 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂锛氭墽琛屽簱浣嶇Щ杞�");
// 鑾峰彇婧愬簱浣嶄俊鎭�
LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
if (null == sourceSta) {
@@ -1204,10 +1239,11 @@
// if (crnProtocol.getModeType() != CrnModeType.STOP) {
// 鏈変换鍔�
if (crnProtocol.getTaskNo() != 0) {
- News.warnNoLog(""+mark+" - 1"+" - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏈変换鍔�");
+
BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue());
// 鏈夊紓甯�
if (latest == null) {
+ News.warnNoLog(""+mark+" - 1"+" - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏈変换鍔★紝鏈夊紓甯�");
if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) {
WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo());
if (wrkMast == null) {
@@ -1239,7 +1275,7 @@
"浠诲姟涓紓甯�" // 澶囨敞
);
if (!basErrLogService.insert(basErrLog)) {
- News.error(""+mark+" - 1"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName);
+ News.error(""+mark+" - 2"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName);
}
}
} else {
@@ -1249,16 +1285,16 @@
latest.setUpdateTime(now);
latest.setStatus(2);
if (!basErrLogService.updateById(latest)) {
- News.error(""+mark+" - 2"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
+ News.error(""+mark+" - 3"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
}
}
}
// 鏃犱换鍔�
} else {
- News.warnNoLog(""+mark+" - 1"+" - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏃犱换鍔�");
BasErrLog latest = basErrLogService.findLatest(crn.getId());
// 鏈夊紓甯�
if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) {
+ News.warnNoLog(""+mark+" - 4"+" - 寮�濮嬫墽琛岋細鍫嗗灈鏈哄紓甯镐俊鎭褰� 锛� 鏃犱换鍔★紝鏈夊紓甯�");
// 璁板綍鏂板紓甯�
if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) {
BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm());
@@ -1287,7 +1323,7 @@
"鏃犱换鍔″紓甯�" // 澶囨敞
);
if (!basErrLogService.insert(basErrLog)) {
- News.error(""+mark+" - 3"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName);
+ News.error(""+mark+" - 5"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName);
}
}
// 鏃犲紓甯�
@@ -1298,7 +1334,7 @@
latest.setUpdateTime(now);
latest.setStatus(2);
if (!basErrLogService.updateById(latest)) {
- News.error(""+mark+" - 4"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
+ News.error(""+mark+" - 6"+" - 鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
}
}
}
@@ -1337,13 +1373,12 @@
if (!staProtocol.isLoading()){
continue;
}
-
// 绔欑偣鏉′欢鍒ゆ柇
if (staProtocol.isAutoing()
&& staProtocol.isInEnable()
&& staProtocol.isEmptyMk()
&& (staProtocol.getWorkNo() > 9990 && staProtocol.getWorkNo() <= 9999)
- && staProtocol.isPakMk()) {
+ && staProtocol.isPakMk() ) {
News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛岋細绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�");
try {
@@ -1388,8 +1423,8 @@
// ledThread.errorReset();
}
} else {
- staProtocol.setWorkNo((short)9999);
- staProtocol.setStaNo(emptyInSta.getBackSta().shortValue());
+ staProtocol.setWorkNo((short)9991);
+ staProtocol.setStaNo((short)100);
devpThread.setPakMk(staProtocol.getSiteId(), false);
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
if (!result) {
@@ -1417,7 +1452,7 @@
}
}
}
- News.infoNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�");
+ News.infoNoLog(""+mark+" - 0"+" - 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐ф墽琛屽畬鎴�");
}
/**
@@ -1426,7 +1461,6 @@
public synchronized void ledExecute(Integer mark) {
for (LedSlave led : slaveProperties.getLed()) {
- News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�:鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣�");
// 鑾峰彇杈撻�佺嚎plc绾跨▼
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
// 鍛戒护闆嗗悎
@@ -1447,6 +1481,7 @@
if (null == wrkMast) {
continue;
}
+ News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�:鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣�");
wrkMasts.add(wrkMast);
// 缁勮鍛戒护
LedCommand ledCommand = new LedCommand();
@@ -1486,7 +1521,7 @@
// ledCommand.setSourceStaNo(wrkMast.getSourceStaNo());
if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) {
List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
- wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme())));
+ wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs())));
}
commands.add(ledCommand);
}
@@ -1497,24 +1532,33 @@
if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
continue;
}
+// 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
+// if (!commands.isEmpty()) {
+// if (led.getId() < 7) {
+// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
+// News.error(""+mark+" - 2"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+// continue;
+// } else {
+// ledThread.setLedMk(false);
+// }
+// } else {
+// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
+// News.error(""+mark+" - 3"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+// continue;
+// } else {
+// ledThread.setLedMk(false);
+// }
+// }
+//
+// }
// 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
if (!commands.isEmpty()) {
- if (led.getId() == 7) {
- if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
- News.error(""+mark+" - 2"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
- continue;
- } else {
- ledThread.setLedMk(false);
- }
- } else {
- if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
- News.error(""+mark+" - 3"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
- continue;
- } else {
- ledThread.setLedMk(false);
- }
+ if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
+ News.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+ continue;
+ }else {
+ ledThread.setLedMk(false);
}
-
}
try {
@@ -1537,7 +1581,7 @@
}
}
- News.infoNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�");
+ News.infoNoLog(""+mark+" - 0"+" - 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣ㄦ墽琛屽畬鎴�");
}
/**
@@ -1545,8 +1589,9 @@
*/
public synchronized void ledReset(Integer mark) {
+ News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�:鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅");
for (LedSlave led : slaveProperties.getLed()) {
- News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�:鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅");
+
// 鑾峰彇杈撻�佺嚎plc绾跨▼
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
// 鍛戒护闆嗗悎
@@ -1996,8 +2041,8 @@
public synchronized void outOfDevp(Integer mark) {
List<WrkMast> wrkMasts = wrkMastMapper.selectPick();
- if (wrkMasts!=null){
- News.warn(""+mark+" - 0"+" - 寮�濮嬫墽琛宱utOfDevp");
+ if (wrkMasts.size()!=0){
+ News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛宱utOfDevp");
}
for (WrkMast wrkMast : wrkMasts) {
if (basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo())) == 0) {
@@ -2007,7 +2052,7 @@
}
}
}
- News.info(""+mark+" - 0"+" - outOfDevp鎵ц瀹屾垚");
+ News.infoNoLog(""+mark+" - 0"+" - outOfDevp鎵ц瀹屾垚");
}
--
Gitblit v1.9.1