From 059568d3cd5c00c367c3c414fe07f641011d7944 Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期二, 28 二月 2023 16:02:43 +0800
Subject: [PATCH] phpswcs创建
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 205 ++++++++++++++++++++++++++++----------------------
1 files changed, 115 insertions(+), 90 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 5336b62..98acb5e 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -122,13 +122,12 @@
if (!Cools.isEmpty(barcode) && (staProtocol.getWorkNo() != 9998 || staProtocol.getWorkNo() != 9996)) {
log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+ String errorMsg = "15绔欐壂鐮佸け璐ワ紝宸查��鍥�14绔�";
staProtocol.setWorkNo((short) 9998);
staProtocol.setStaNo((short) 14);
devpThread.setPakMk(staProtocol.getSiteId(), false);
- MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
// led 寮傚父鏄剧ず
if (ledThread != null) {
- String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
News.error(methodName + ":鎵爜澶辫触锛岃閲嶈瘯");
MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
}
@@ -137,16 +136,6 @@
} else {
continue;
}
-
- // 鑾峰彇鍏ュ簱绔欎俊鎭�
-// SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
-
-
- // 鍏ュ嚭搴撴ā寮忓垽鏂�
-// if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; }
-// if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) {
-// continue;
-// }
// 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
if (staProtocol.isAutoing()
@@ -173,6 +162,10 @@
WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
if (wrkMast != null) {
News.error(methodName + ":宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
+ if (ledThread != null) {
+ News.error(methodName + ":鎵爜澶辫触锛岃閲嶈瘯");
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, "宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={"+ wrkMast.getWrkNo() + "}, 璇锋墜鍔ㄥ彇娑堝凡瀛樺湪宸ヤ綔妗�"));
+ }
continue;
}
@@ -213,10 +206,7 @@
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
- if (ledThread != null) {
- String successMsg = "鍏ュ簱宸ヤ綔妗�--宸ヤ綔鍙�:" + dto.getWorkNo() + " 鐩爣搴撲綅:" + dto.getLocNo();
- MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(7, successMsg));
- }
+
} else {
staProtocol.setWorkNo((short) 9998);
staProtocol.setStaNo((short) 14);
@@ -1498,109 +1488,144 @@
* 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣�
*/
public synchronized void ledExecute() {
- String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
+// String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
for (LedSlave led : slaveProperties.getLed()) {
// 鑾峰彇杈撻�佺嚎plc绾跨▼
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
- // 鍛戒护闆嗗悎
- List<LedCommand> commands = new ArrayList<>();
- // 宸ヤ綔妗i泦鍚�
- List<WrkMast> wrkMasts = new ArrayList<>();
+// // 鍛戒护闆嗗悎
+// List<LedCommand> commands = new ArrayList<>();
+// // 宸ヤ綔妗i泦鍚�
+// List<WrkMast> wrkMasts = new ArrayList<>();
for (Integer staNo : led.getStaArr()) {
// 鑾峰彇鍙夎溅绔欑偣
StaProtocol staProtocol = devpThread.getStation().get(staNo);
if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) {
+ MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, ""));
continue;
} else {
staProtocol = staProtocol.clone();
}
// 鑾峰彇宸ヤ綔妗f暟鎹�
WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
-// if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; }
if (null == wrkMast) {
+ MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, ""));
continue;
}
- wrkMasts.add(wrkMast);
- // 缁勮鍛戒护
+ ArrayList<MatDto> matDtos = new ArrayList<>();
+ Wrapper<WrkDetl> detlWrapper = new EntityWrapper<WrkDetl>()
+ .eq("wrk_no", wrkMast.getWrkNo());
LedCommand ledCommand = new LedCommand();
ledCommand.setWorkNo(wrkMast.getWrkNo());
+ ledCommand.setStaNo(wrkMast.getStaNo());
+ ledCommand.setSourceStaNo(wrkMast.getSourceStaNo());
+ ledCommand.setLocNo(wrkMast.getLocNo());
+ ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
ledCommand.setIoType(wrkMast.getIoType());
- // 鍑哄簱妯″紡
- switch (wrkMast.getIoType()) {
- case -1:
- ledCommand.setTitle("鍏ㄦ澘鍏ュ簱");
- break;
+ ledCommand.setTitle(wrkMast.getIoType$());
+
+ switch (wrkMast.getIoType()){
case 10:
- ledCommand.setTitle("绌烘澘鍏ュ簱");
- break;
- case 10-1:
- ledCommand.setTitle("鍏ㄦ澘鍑哄簱");
- break;
- case 103:
- ledCommand.setTitle("鎷f枡鍑哄簱");
- break;
- case 104:
- ledCommand.setTitle("骞舵澘鍑哄簱");
- break;
- case 107:
- ledCommand.setTitle("鐩樼偣鍑哄簱");
- break;
case 110:
- ledCommand.setTitle("绌烘澘鍑哄簱");
ledCommand.setEmptyMk(true);
break;
default:
- News.error(methodName + ":浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
+ ledCommand.setBarcode(wrkMast.getBarcode());
+ List<WrkDetl> wrkDetls = wrkDetlService.selectList(detlWrapper);
+ for (WrkDetl wrkDetl : wrkDetls) {
+ MatDto matDto = new MatDto();
+ matDto.setMaknx(wrkDetl.getMaktx());
+ matDto.setMatNo(wrkDetl.getMatnr());
+ matDto.setCount(wrkDetl.getAnfme());
+ matDtos.add(matDto);
+ }
break;
+
+
}
- ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
- ledCommand.setLocNo(wrkMast.getLocNo());
- ledCommand.setStaNo(wrkMast.getStaNo());
-// 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())));
- }
- commands.add(ledCommand);
- }
- Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
- // 鑾峰彇LED绾跨▼
- LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
- // 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护
-// if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
-// continue;
+ ledCommand.setMatDtos(matDtos);
+ MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, ledCommand.toString()));
+
+// wrkMasts.add(wrkMast);
+// // 缁勮鍛戒护
+// LedCommand ledCommand = new LedCommand();
+// ledCommand.setWorkNo(wrkMast.getWrkNo());
+// ledCommand.setIoType(wrkMast.getIoType());
+// // 鍑哄簱妯″紡
+// switch (wrkMast.getIoType()) {
+// case -1:
+// ledCommand.setTitle("鍏ㄦ澘鍏ュ簱");
+// break;
+// case 10:
+// ledCommand.setTitle("绌烘澘鍏ュ簱");
+// break;
+// case 10-1:
+// ledCommand.setTitle("鍏ㄦ澘鍑哄簱");
+// break;
+// case 103:
+// ledCommand.setTitle("鎷f枡鍑哄簱");
+// break;
+// case 104:
+// ledCommand.setTitle("骞舵澘鍑哄簱");
+// break;
+// case 107:
+// ledCommand.setTitle("鐩樼偣鍑哄簱");
+// break;
+// case 110:
+// ledCommand.setTitle("绌烘澘鍑哄簱");
+// ledCommand.setEmptyMk(true);
+// break;
+// default:
+// News.error(methodName + ":浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
+// break;
+// }
+// ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
+// ledCommand.setLocNo(wrkMast.getLocNo());
+// ledCommand.setStaNo(wrkMast.getStaNo());
+//// 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())));
+// }
+// commands.add(ledCommand);
// }
- // 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
- if (!commands.isEmpty()) {
- String errMsg = "";
- if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
- News.error(methodName + ":{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
- continue;
- } else {
- ledThread.setLedMk(false);
- }
-
-
+// Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
+// // 鑾峰彇LED绾跨▼
+// LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
+// // 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护
+//// if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
+//// continue;
+//// }
+// // 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
+// if (!commands.isEmpty()) {
+// String errMsg = "";
+// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
+// News.error(methodName + ":{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+// continue;
+// } else {
+// ledThread.setLedMk(false);
+// }
+//
+//
}
-
- try {
- // 淇敼涓绘。led鏍囪
- for (WrkMast wrkMast : wrkMasts) {
- wrkMast.setOveMk("Y");
- wrkMast.setModiTime(new Date());
- if (wrkMastMapper.updateById(wrkMast) == 0) {
- throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
- }
- }
-
- // 鏇存柊绾跨▼褰撳墠宸ヤ綔鍙烽泦鍚�
- ledThread.setWorkNos(workNos);
-
- } catch (Exception e) {
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- }
+//
+// try {
+// // 淇敼涓绘。led鏍囪
+// for (WrkMast wrkMast : wrkMasts) {
+// wrkMast.setOveMk("Y");
+// wrkMast.setModiTime(new Date());
+// if (wrkMastMapper.updateById(wrkMast) == 0) {
+// throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
+// }
+// }
+//
+// // 鏇存柊绾跨▼褰撳墠宸ヤ綔鍙烽泦鍚�
+// ledThread.setWorkNos(workNos);
+//
+// } catch (Exception e) {
+// e.printStackTrace();
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// }
}
}
--
Gitblit v1.9.1