From bcd4e611a77fcb65dfc7bc1aacf26eb68095293f Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期六, 19 七月 2025 09:42:57 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 822 ++++++++++++++++++++++++++++++++++------------------------
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 6
2 files changed, 480 insertions(+), 348 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 2c6fa58..2685114 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -110,12 +110,7 @@
public Integer wrkNo = 10000;
@Autowired
private ConfigMapper configMapper;
-
- /**
- * 缁勬墭
- * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2
- */
- public synchronized void generateStoreWrkFile(Integer mark) {
+ public synchronized void generateStoreWrkFile3(Integer mark) {
String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
// 鏍规嵁杈撻�佺嚎plc閬嶅巻
for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -136,113 +131,44 @@
continue;
}
String barcode = barcodeThread.getBarcode();
- if(staProtocolIn.getStamp() == 1) {
- log.error("鐢熸垚浠诲姟涓�");
- WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
- .eq("barcode", barcode)
- .in("io_type", 107, 103, 57));
- if (!Cools.isEmpty(checkPick)) {
- continue;
- }
- try {
- LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
- SearchLocParam param = new SearchLocParam();
- locTypeDto.setLocType1((short) 1);
- param.setBarcode(barcode);
- param.setIoType(1);
- param.setSourceStaNo(inSta.getStaNo());
- param.setLocType1(locTypeDto.getLocType1());
- param.setWeight(staProtocol.getWeight());
- String response = new HttpHandler.Builder()
- .setTimeout(30, TimeUnit.SECONDS)
- .setUri(wmsUrl)
- .setPath("/rpc/pakin/loc/v1")
- .setJson(JSON.toJSONString(param))
- .build()
- .doPost();
- JSONObject jsonObject = JSON.parseObject(response);
- if (jsonObject.getInteger("code").equals(200)) {
- StartupDto dto = jsonObject.getObject("data", StartupDto.class);
- barcodeThread.setBarcode("");
- staProtocolIn.setWorkNo(dto.getWorkNo());
-// //staProtocol.setStaNo(RouteUtils.SouStaEnd(dto.getStaNo(),dto.getSourceStaNo()));
-// staProtocol.setStaNo(dto.getStaNo().shortValue());
-// devpThread.setPakMk(staProtocol.getSiteId(), false);
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocolIn));
- log.error("杈撻�佺嚎涓嬪彂2锛�" + dto.getWorkNo() + "," + dto.getStaNo());
- ledThread.errorReset();
- log.error("缁勬墭璇锋眰鍚嶭ED閿欒娓呴櫎");
-
- if (!result) {
- News.error(methodName + ":鏇存柊plc绔欑偣淇℃伅澶辫触");
-
- throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
- }
- continue;
- }
-// else {
-// if (jsonObject.getString("msg").equals("宸ヤ綔妗e凡瀛樺湪")) {
-// continue;
-// }
-// staProtocol.setWorkNo(wrkNo);
-// wrkNo++;
-// staProtocol.setStaNo(inSta.getBackSta().shortValue());
-// devpThread.setPakMk(staProtocol.getSiteId(), false);
-// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-// log.error("杈撻�佺嚎涓嬪彂2锛�" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo());
-//
-//// if (ledThread != null) {
-// String errorMsg = jsonObject.getString("msg");
-// if (!Cools.isEmpty(errorMsg)) {
-// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
-// }
-//// }
-//// News.error(methodName + ":璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
-// }
- } catch (Exception e) {
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- }
- }else{
- if (staProtocol == null) {
- continue;
- } else {
- staProtocol = staProtocol.clone();
- }
-
- // 灏哄妫�娴嬪紓甯�
- boolean back = false;
- String errMsg = "";
- if (staProtocol.isFrontErr()) {
- errMsg = "鍓嶈秴闄�";
- back = true;
- }
- if (!back && staProtocol.isBackErr()) {
- errMsg = "鍚庤秴闄�";
- back = true;
- }
- if (!back && staProtocol.isHighErr()) {
- errMsg = "楂樿秴闄�";
- back = true;
- }
- if (!back && staProtocol.isLeftErr()) {
- errMsg = "宸﹁秴闄�";
- back = true;
- }
- if (!back && staProtocol.isRightErr()) {
- errMsg = "鍙宠秴闄�";
- back = true;
- }
- if (!back && staProtocol.getWeight() > 1000) {
- errMsg = "瓒呴噸鎴栨湭璇诲彇";
- back = true;
- }
- if (!back && staProtocol.isBarcodeErr()) {
- errMsg = "鎵爜澶辫触";
- back = true;
- }
+ // 灏哄妫�娴嬪紓甯�
+ boolean back = false;
+ String errMsg = "";
+ if (staProtocol.isFrontErr()) {
+ errMsg = "鍓嶈秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isBackErr()) {
+ errMsg = "鍚庤秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isHighErr()) {
+ errMsg = "楂樿秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isLeftErr()) {
+ errMsg = "宸﹁秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.isRightErr()) {
+ errMsg = "鍙宠秴闄�";
+ back = true;
+ }
+ if (!back && staProtocol.getWeight() > 1000) {
+ errMsg = "瓒呴噸鎴栨湭璇诲彇";
+ back = true;
+ }
+ if (!back && staProtocol.isBarcodeErr()) {
+ errMsg = "鎵爜澶辫触";
+ back = true;
+ }
// if(staProtocol.getWeight() <= 0 ){
// continue;
// }
@@ -253,48 +179,48 @@
// News.info("{}閲嶉噺", staProtocol.getWeight());
- // 閫�鍥�
- if (back) {
- log.info("errmsg: " + errMsg);
+ // 閫�鍥�
+ if (back) {
+ log.info("errmsg: " + errMsg);
// News.warn("鎵爜鍏ュ簱澶辫触锛寋}鍏ュ簱绔欏洜{}寮傚父锛屾墭鐩樺凡琚��鍥�", inSta.getStaNo(), errMsg);
- MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
- if (!staProtocol.isLoading()) {
- continue;
- }
- if (!staProtocol.isPakMk()) {
- continue;
- }
+ if (!staProtocol.isLoading()) {
+ continue;
+ }
+ if (!staProtocol.isPakMk()) {
+ continue;
+ }
+ staProtocol.setWorkNo(wrkNo);
+ News.info("{}PLC鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg, wrkNo);
+ wrkNo++;
+ staProtocol.setStaNo(inSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ log.error("杈撻�佺嚎涓嬪彂1锛�" + wrkNo + "," + inSta.getBackSta());
+ }
+
+ // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
+ if (staProtocol.isAutoing()
+ && staProtocol.isLoading()
+ && staProtocol.isInEnable()
+ && !staProtocol.isEmptyMk()
+ && staProtocol.isPakMk()) {
+ if (Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
+ News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
+
staProtocol.setWorkNo(wrkNo);
- News.info("{}PLC鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg, wrkNo);
+ News.info("{}barcode鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg, wrkNo);
wrkNo++;
staProtocol.setStaNo(inSta.getBackSta().shortValue());
devpThread.setPakMk(staProtocol.getSiteId(), false);
MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
log.error("杈撻�佺嚎涓嬪彂1锛�" + wrkNo + "," + inSta.getBackSta());
+ continue;
}
-
- // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
- if (staProtocol.isAutoing()
- && staProtocol.isLoading()
- && staProtocol.isInEnable()
- && !staProtocol.isEmptyMk()
- && staProtocol.isPakMk()) {
- if (Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
- News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
-
- staProtocol.setWorkNo(wrkNo);
- News.info("{}barcode鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg, wrkNo);
- wrkNo++;
- staProtocol.setStaNo(inSta.getBackSta().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
- log.error("杈撻�佺嚎涓嬪彂1锛�" + wrkNo + "," + inSta.getBackSta());
- continue;
- }
- // 鍒ゆ柇閲嶅宸ヤ綔妗�
- WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
- if (wrkMast != null) {
+ // 鍒ゆ柇閲嶅宸ヤ綔妗�
+ WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
+ if (wrkMast != null) {
// int wrkNo1 = basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo()));
// if (wrkNo1 != 0){
// if (ledThread != null) {
@@ -302,9 +228,9 @@
// }
//
// }
- News.error(barcode + "鏉$爜宸插瓨鍦ㄧ姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,璇锋煡鐪媁CS杈撻�佺嚎鐣岄潰,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
+ News.error(barcode + "鏉$爜宸插瓨鍦ㄧ姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,璇锋煡鐪媁CS杈撻�佺嚎鐣岄潰,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, barcode + "鏉$爜宸插瓨鍦ㄧ姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑浠诲姟,宸ヤ綔鍙�=" + wrkMast.getWrkNo()));
- continue;
+ continue;
// barcodeThread.setBarcode("");
// staProtocol.setWorkNo(wrkMast.getWrkNo());
// staProtocol.setStaNo(RouteUtils.SouStaEnd(null,wrkMast.getSourceStaNo()));
@@ -323,13 +249,246 @@
// continue;
// }
+ }
+ WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
+ .eq("barcode", barcode)
+ .in("io_type", 107, 103, 57));
+ if (!Cools.isEmpty(checkPick)) {
+ continue;
+ }
+ try {
+ LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
+
+ SearchLocParam param = new SearchLocParam();
+ locTypeDto.setLocType1((short) 1);
+ param.setBarcode(barcode);
+ param.setIoType(1);
+ param.setSourceStaNo(inSta.getStaNo());
+ param.setLocType1(locTypeDto.getLocType1());
+ param.setWeight(staProtocol.getWeight());
+ String response = new HttpHandler.Builder()
+ .setTimeout(30,TimeUnit.SECONDS)
+ .setUri(wmsUrl)
+ .setPath("/rpc/pakin/loc/v1")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ if (jsonObject.getInteger("code").equals(200)) {
+ StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+ barcodeThread.setBarcode("");
+ staProtocol.setWorkNo(dto.getWorkNo());
+ //staProtocol.setStaNo(RouteUtils.SouStaEnd(dto.getStaNo(),dto.getSourceStaNo()));
+ staProtocol.setStaNo(dto.getStaNo().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ log.error("杈撻�佺嚎涓嬪彂2锛�" + dto.getWorkNo() + "," + dto.getStaNo());
+
+ ledThread.errorReset();
+ log.error("缁勬墭璇锋眰鍚嶭ED閿欒娓呴櫎");
+
+ if (!result) {
+ News.error(methodName + ":鏇存柊plc绔欑偣淇℃伅澶辫触");
+
+ throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+ }
+ } else {
+ if (jsonObject.getString("msg").equals("宸ヤ綔妗e凡瀛樺湪")) {
+ continue;
+ }
+ staProtocol.setWorkNo(wrkNo);
+ wrkNo++;
+ staProtocol.setStaNo(inSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ log.error("杈撻�佺嚎涓嬪彂2锛�" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo());
+
+// if (ledThread != null) {
+ String errorMsg = jsonObject.getString("msg");
+ if (!Cools.isEmpty(errorMsg)) {
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+ }
+// }
+// News.error(methodName + ":璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
}
- WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
- .eq("barcode", barcode)
- .in("io_type", 107, 103, 57));
- if (!Cools.isEmpty(checkPick)) {
- continue;
- }
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+
+ }
+
+
+ }
+ }
+// News.infoNoLog(""+mark+" - 0"+" - 缁勬墭 ===銆嬫墽琛屽畬鎴�");
+
+ }
+ /**
+ * 缁勬墭
+ * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2
+ */
+// public synchronized void generateStoreWrkFile(Integer mark) {
+// String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
+// // 鏍规嵁杈撻�佺嚎plc閬嶅巻
+// for (DevpSlave devp : slaveProperties.getDevp()) {
+// // 閬嶅巻鍏ュ簱鍙�
+// for (DevpSlave.Sta inSta : devp.getInSta()) {
+// // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+// BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
+// LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+// SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+// StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
+// StaProtocol staProtocolIn = devpThread.getStation().get(inSta.getStaNo() -1);
+// if (staProtocolIn == null) {
+// continue;
+// } else {
+// staProtocolIn = staProtocolIn.clone();
+// }
+// if (barcodeThread == null) {
+// continue;
+// }
+// String barcode = barcodeThread.getBarcode();
+// if(staProtocolIn.getStamp() == 1 && barcode!=null && !barcode.isEmpty()) {
+// log.error("鐢熸垚浠诲姟涓�");
+//
+// WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
+// .eq("barcode", barcode)
+// .in("io_type", 107, 103, 57));
+// if (!Cools.isEmpty(checkPick)) {
+// continue;
+// }
+// try {
+// LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
+//
+// SearchLocParam param = new SearchLocParam();
+// locTypeDto.setLocType1((short) 1);
+// param.setBarcode(barcode);
+// param.setIoType(1);
+// param.setSourceStaNo(inSta.getStaNo());
+// param.setLocType1(locTypeDto.getLocType1());
+// param.setWeight(staProtocol.getWeight());
+// String response = new HttpHandler.Builder()
+// .setTimeout(30, TimeUnit.SECONDS)
+// .setUri(wmsUrl)
+// .setPath("/rpc/pakin/loc/v1")
+// .setJson(JSON.toJSONString(param))
+// .build()
+// .doPost();
+// JSONObject jsonObject = JSON.parseObject(response);
+// if (jsonObject.getInteger("code").equals(200)) {
+// StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+// barcodeThread.setBarcode("");
+// staProtocolIn.setWorkNo(dto.getWorkNo());
+//// //staProtocol.setStaNo(RouteUtils.SouStaEnd(dto.getStaNo(),dto.getSourceStaNo()));
+//// staProtocol.setStaNo(dto.getStaNo().shortValue());
+// devpThread.setPakMk(staProtocolIn.getSiteId(), false);
+// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocolIn));
+// log.error("宸ヤ綔鍙蜂笅鍙�2锛�" + dto.getWorkNo() + "," + dto.getStaNo());
+// ledThread.errorReset();
+// log.error("缁勬墭璇锋眰鍚嶭ED閿欒娓呴櫎");
+// if (!result) {
+// News.error(methodName + ":鏇存柊plc绔欑偣淇℃伅澶辫触");
+//
+// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+// }
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+// }
+// }else{
+// if (staProtocol == null) {
+// continue;
+// } else {
+// staProtocol = staProtocol.clone();
+// }
+//
+// // 灏哄妫�娴嬪紓甯�
+// boolean back = false;
+// String errMsg = "";
+// if (staProtocol.isFrontErr()) {
+// errMsg = "鍓嶈秴闄�";
+// back = true;
+// }
+// if (!back && staProtocol.isBackErr()) {
+// errMsg = "鍚庤秴闄�";
+// back = true;
+// }
+// if (!back && staProtocol.isHighErr()) {
+// errMsg = "楂樿秴闄�";
+// back = true;
+// }
+// if (!back && staProtocol.isLeftErr()) {
+// errMsg = "宸﹁秴闄�";
+// back = true;
+// }
+// if (!back && staProtocol.isRightErr()) {
+// errMsg = "鍙宠秴闄�";
+// back = true;
+// }
+// if (!back && staProtocol.getWeight() > 1000) {
+// errMsg = "瓒呴噸鎴栨湭璇诲彇";
+// back = true;
+// }
+// if (!back && staProtocol.isBarcodeErr()) {
+// errMsg = "鎵爜澶辫触";
+// back = true;
+// }
+//
+// // 閫�鍥�
+// if (back) {
+// log.info("errmsg: " + errMsg);
+//// News.warn("鎵爜鍏ュ簱澶辫触锛寋}鍏ュ簱绔欏洜{}寮傚父锛屾墭鐩樺凡琚��鍥�", inSta.getStaNo(), errMsg);
+// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
+//
+// if (!staProtocol.isLoading()) {
+// continue;
+// }
+// if (!staProtocol.isPakMk()) {
+// continue;
+// }
+// staProtocol.setWorkNo(wrkNo);
+// News.info("{}PLC鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg, wrkNo);
+// wrkNo++;
+// staProtocol.setStaNo(inSta.getBackSta().shortValue());
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+// log.error("杈撻�佺嚎涓嬪彂1锛�" + wrkNo + "," + inSta.getBackSta());
+// }
+//
+// // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
+// if (staProtocol.isAutoing()
+// && staProtocol.isLoading()
+// && staProtocol.isInEnable()
+// && !staProtocol.isEmptyMk()
+// && staProtocol.isPakMk()) {
+// if (Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
+// News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
+//
+// staProtocol.setWorkNo(wrkNo);
+// News.info("{}barcode鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg, wrkNo);
+// wrkNo++;
+// staProtocol.setStaNo(inSta.getBackSta().shortValue());
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+// log.error("杈撻�佺嚎涓嬪彂1锛�" + wrkNo + "," + inSta.getBackSta());
+// continue;
+// }
+// // 鍒ゆ柇閲嶅宸ヤ綔妗�
+// WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
+// if (wrkMast != null) {
+// News.error(barcode + "鏉$爜宸插瓨鍦ㄧ姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,璇锋煡鐪媁CS杈撻�佺嚎鐣岄潰,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
+// continue;
+// }
+// WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
+// .eq("barcode", barcode)
+// .in("io_type", 107, 103, 57));
+// if (!Cools.isEmpty(checkPick)) {
+// continue;
+// }
// try {
// LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
//
@@ -377,219 +536,192 @@
// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
// log.error("杈撻�佺嚎涓嬪彂2锛�" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo());
//
-//// if (ledThread != null) {
// String errorMsg = jsonObject.getString("msg");
// if (!Cools.isEmpty(errorMsg)) {
// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
// }
-//// }
-//// News.error(methodName + ":璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
// }
-//
//
// } catch (Exception e) {
// e.printStackTrace();
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// }
+//
+// }
+// }
+// }
+// }
+//
+// }
+ public synchronized void generateStoreWrkFile(Integer mark) {
+ String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
+ final Set<String> INVALID_BARCODES = new HashSet<>(Arrays.asList("NG", "NoRead", "00000000"));
+
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ for (DevpSlave.Sta inSta : devp.getInSta()) {
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
+ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+ SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+
+ StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
+ StaProtocol staProtocolIn = devpThread.getStation().get(inSta.getStaNo() - 1);
+
+ if (staProtocolIn == null || barcodeThread == null) continue;
+ staProtocolIn = staProtocolIn.clone();
+ String barcode = barcodeThread.getBarcode();
+
+ // 濡傛灉鍓嶅伐浣嶆湁璐� + 鎵爜鍣ㄦ湁鏉$爜
+ if (staProtocolIn.getStamp() == 1 && barcode != null && !barcode.isEmpty()) {
+ if (wrkMastService.selectOne(new EntityWrapper<WrkMast>()
+ .eq("barcode", barcode)
+ .in("io_type", 107, 103, 57)) != null) {
+ continue;
}
+
+ try {
+ SearchLocParam param = new SearchLocParam();
+ param.setBarcode(barcode);
+ param.setIoType(1);
+ param.setSourceStaNo(inSta.getStaNo());
+ param.setLocType1((short) 1);
+ param.setWeight(staProtocolIn.getWeight());
+
+ String response = new HttpHandler.Builder()
+ .setTimeout(30, TimeUnit.SECONDS)
+ .setUri(wmsUrl)
+ .setPath("/rpc/pakin/loc/v1")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+
+ JSONObject json = JSON.parseObject(response);
+ if (json.getInteger("code").equals(200)) {
+ StartupDto dto = json.getObject("data", StartupDto.class);
+ barcodeThread.setBarcode("");
+ staProtocolIn.setWorkNo(dto.getWorkNo());
+ devpThread.setPakMk(staProtocolIn.getSiteId(), false);
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocolIn));
+ ledThread.errorReset();
+ log.error("宸ヤ綔鍙蜂笅鍙�2锛�" + dto.getWorkNo() + "," + dto.getStaNo());
+
+ if (!result) {
+ News.error(methodName + ":鏇存柊plc绔欑偣淇℃伅澶辫触");
+ throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+ }
+ }
+ } catch (Exception e) {
+ log.error("缁勬墭浠诲姟寮傚父锛�", e);
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+
+ continue;
}
-// if (staProtocol == null) {
-// continue;
-// } else {
-// staProtocol = staProtocol.clone();
-// }
-//
-// // 灏哄妫�娴嬪紓甯�
-// boolean back = false;
-// String errMsg = "";
-// if (staProtocol.isFrontErr()) {
-// errMsg = "鍓嶈秴闄�";
-// back = true;
-// }
-// if (!back && staProtocol.isBackErr()) {
-// errMsg = "鍚庤秴闄�";
-// back = true;
-// }
-// if (!back && staProtocol.isHighErr()) {
-// errMsg = "楂樿秴闄�";
-// back = true;
-// }
-// if (!back && staProtocol.isLeftErr()) {
-// errMsg = "宸﹁秴闄�";
-// back = true;
-// }
-// if (!back && staProtocol.isRightErr()) {
-// errMsg = "鍙宠秴闄�";
-// back = true;
-// }
-// if (!back && staProtocol.getWeight() > 1000) {
-// errMsg = "瓒呴噸鎴栨湭璇诲彇";
-// back = true;
-// }
-// if (!back && staProtocol.isBarcodeErr()) {
-// errMsg = "鎵爜澶辫触";
-// back = true;
-// }
-//// if(staProtocol.getWeight() <= 0 ){
-//// continue;
-//// }
-//// if (!back && staProtocol.getWeight() == 0.0) {
-//// errMsg = "閲嶉噺鑾峰彇澶辫触";
-//// back = true;
-//// }
-//
-//// News.info("{}閲嶉噺", staProtocol.getWeight());
-//
-// // 閫�鍥�
-// if (back) {
-// log.info("errmsg: " + errMsg);
-//// News.warn("鎵爜鍏ュ簱澶辫触锛寋}鍏ュ簱绔欏洜{}寮傚父锛屾墭鐩樺凡琚��鍥�", inSta.getStaNo(), errMsg);
-// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
-//
-// if (!staProtocol.isLoading()) {
-// continue;
-// }
-// if (!staProtocol.isPakMk()) {
-// continue;
-// }
-// staProtocol.setWorkNo(wrkNo);
-// News.info("{}PLC鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg, wrkNo);
-// wrkNo++;
-// staProtocol.setStaNo(inSta.getBackSta().shortValue());
-// devpThread.setPakMk(staProtocol.getSiteId(), false);
-// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-// log.error("杈撻�佺嚎涓嬪彂1锛�" + wrkNo + "," + inSta.getBackSta());
-// }
-//
-// // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢
-// if (staProtocol.isAutoing()
-// && staProtocol.isLoading()
-// && staProtocol.isInEnable()
-// && !staProtocol.isEmptyMk()
-// && staProtocol.isPakMk()) {
-// if (Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
-// News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
-//
-// staProtocol.setWorkNo(wrkNo);
-// News.info("{}barcode鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg, wrkNo);
-// wrkNo++;
-// staProtocol.setStaNo(inSta.getBackSta().shortValue());
-// devpThread.setPakMk(staProtocol.getSiteId(), false);
-// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-// log.error("杈撻�佺嚎涓嬪彂1锛�" + wrkNo + "," + inSta.getBackSta());
-// continue;
-// }
-// // 鍒ゆ柇閲嶅宸ヤ綔妗�
-// WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
-// if (wrkMast != null) {
-//// int wrkNo1 = basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo()));
-//// if (wrkNo1 != 0){
-//// if (ledThread != null) {
-//// News.error(methodName + ":鎵爜澶辫触锛岃閲嶈瘯");
-//// }
-////
-//// }
-// News.error(barcode + "鏉$爜宸插瓨鍦ㄧ姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,璇锋煡鐪媁CS杈撻�佺嚎鐣岄潰,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
-//// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, barcode + "鏉$爜宸插瓨鍦ㄧ姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑浠诲姟,宸ヤ綔鍙�=" + wrkMast.getWrkNo()));
-// continue;
-//// barcodeThread.setBarcode("");
-//// staProtocol.setWorkNo(wrkMast.getWrkNo());
-//// staProtocol.setStaNo(RouteUtils.SouStaEnd(null,wrkMast.getSourceStaNo()));
-//// devpThread.setPakMk(staProtocol.getSiteId(), false);
-//// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-//// log.info("杈撻�佺嚎涓嬪彂(瀛樺湪璁惧涓婅蛋鐨勫伐浣滄。锛岀洿鎺ヤ笅鍙戯紒))锛�"+wrkMast.getWrkNo()+","+wrkMast.getStaNo());
-////
-//// ledThread.errorReset();
-//// log.info("缁勬墭璇锋眰鍚嶭ED閿欒娓呴櫎");
-////
-//// if (!result) {
-//// News.error(methodName + ":鏇存柊plc绔欑偣淇℃伅澶辫触");
-//// log.error("杈撻�佺嚎涓嬪彂(瀛樺湪璁惧涓婅蛋鐨勫伐浣滄。锛岀洿鎺ヤ笅鍙戯紒)==>鏇存柊plc绔欑偣淇℃伅澶辫触");
-////
-////// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
-//// continue;
-//// }
-//
-// }
-// WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
-// .eq("barcode", barcode)
-// .in("io_type", 107, 103, 57));
-// if (!Cools.isEmpty(checkPick)) {
-// continue;
-// }
-// try {
-// LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
-//
-// SearchLocParam param = new SearchLocParam();
-// locTypeDto.setLocType1((short) 1);
-// param.setBarcode(barcode);
-// param.setIoType(1);
-// param.setSourceStaNo(inSta.getStaNo());
-// param.setLocType1(locTypeDto.getLocType1());
-// param.setWeight(staProtocol.getWeight());
-// String response = new HttpHandler.Builder()
-// .setTimeout(30,TimeUnit.SECONDS)
-// .setUri(wmsUrl)
-// .setPath("/rpc/pakin/loc/v1")
-// .setJson(JSON.toJSONString(param))
-// .build()
-// .doPost();
-// JSONObject jsonObject = JSON.parseObject(response);
-// if (jsonObject.getInteger("code").equals(200)) {
-// StartupDto dto = jsonObject.getObject("data", StartupDto.class);
-// barcodeThread.setBarcode("");
-// staProtocol.setWorkNo(dto.getWorkNo());
-// //staProtocol.setStaNo(RouteUtils.SouStaEnd(dto.getStaNo(),dto.getSourceStaNo()));
-// staProtocol.setStaNo(dto.getStaNo().shortValue());
-// devpThread.setPakMk(staProtocol.getSiteId(), false);
-// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-// log.error("杈撻�佺嚎涓嬪彂2锛�" + dto.getWorkNo() + "," + dto.getStaNo());
-//
-// ledThread.errorReset();
-// log.error("缁勬墭璇锋眰鍚嶭ED閿欒娓呴櫎");
-//
-// if (!result) {
-// News.error(methodName + ":鏇存柊plc绔欑偣淇℃伅澶辫触");
-//
-// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
-// }
-// } else {
-// if (jsonObject.getString("msg").equals("宸ヤ綔妗e凡瀛樺湪")) {
-// continue;
-// }
-// staProtocol.setWorkNo(wrkNo);
-// wrkNo++;
-// staProtocol.setStaNo(inSta.getBackSta().shortValue());
-// devpThread.setPakMk(staProtocol.getSiteId(), false);
-// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-// log.error("杈撻�佺嚎涓嬪彂2锛�" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo());
-//
-//// if (ledThread != null) {
-// String errorMsg = jsonObject.getString("msg");
-// if (!Cools.isEmpty(errorMsg)) {
-// MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
-// }
-//// }
-//// News.error(methodName + ":璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
-// }
-//
-//
-// } catch (Exception e) {
-// e.printStackTrace();
-// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-// }
-//
-// }
+ // 灏哄/閲嶉噺/鎵爜寮傚父妫�娴�
+ if (staProtocol == null) continue;
+ staProtocol = staProtocol.clone();
+ boolean back = false;
+ String errMsg = "";
+ if (staProtocol.isFrontErr()) { errMsg = "鍓嶈秴闄�"; back = true; }
+ else if (staProtocol.isBackErr()) { errMsg = "鍚庤秴闄�"; back = true; }
+ else if (staProtocol.isHighErr()) { errMsg = "楂樿秴闄�"; back = true; }
+ else if (staProtocol.isLeftErr()) { errMsg = "宸﹁秴闄�"; back = true; }
+ else if (staProtocol.isRightErr()) { errMsg = "鍙宠秴闄�"; back = true; }
+ else if (staProtocol.getWeight() > 1000) { errMsg = "瓒呴噸鎴栨湭璇诲彇"; back = true; }
+ else if (staProtocol.isBarcodeErr()) { errMsg = "鎵爜澶辫触"; back = true; }
+ // 灏哄寮傚父鍥為��
+ if (back) {
+ log.info("errmsg: " + errMsg);
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
+
+ if (!staProtocol.isLoading() || !staProtocol.isPakMk()) continue;
+ staProtocol.setWorkNo(wrkNo++);
+ staProtocol.setStaNo(inSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ log.error("杈撻�佺嚎涓嬪彂1锛�" + wrkNo + "," + inSta.getBackSta());
+ continue;
+ }
+
+ // 鍏ュ簱鏉′欢婊¤冻锛屽紑濮嬭姹傚叆搴撳湴鍧�
+ if (staProtocol.isAutoing() && staProtocol.isLoading()
+ && staProtocol.isInEnable() && !staProtocol.isEmptyMk() && staProtocol.isPakMk()) {
+
+ if (Cools.isEmpty(barcode) || INVALID_BARCODES.contains(barcode)) {
+ News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
+ staProtocol.setWorkNo(wrkNo++);
+ staProtocol.setStaNo(inSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ log.error("杈撻�佺嚎涓嬪彂1锛歿} , {}", wrkNo, inSta.getBackSta());
+ continue;
+ }
+
+ if (wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode) != null ||
+ wrkMastService.selectOne(new EntityWrapper<WrkMast>()
+ .eq("barcode", barcode)
+ .in("io_type", 107, 103, 57)) != null) {
+ News.error(barcode + "鏉$爜宸插瓨鍦ㄧ姸鎬佷负锛�2.璁惧涓婅蛋锛夌殑鏁版嵁锛岃鏌ョ湅WCS杈撻�佺嚎鐣岄潰");
+ continue;
+ }
+
+ try {
+ SearchLocParam param = new SearchLocParam();
+ param.setBarcode(barcode);
+ param.setIoType(1);
+ param.setSourceStaNo(inSta.getStaNo());
+ param.setLocType1((short) 1);
+ param.setWeight(staProtocol.getWeight());
+
+ String response = new HttpHandler.Builder()
+ .setTimeout(30, TimeUnit.SECONDS)
+ .setUri(wmsUrl)
+ .setPath("/rpc/pakin/loc/v1")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+
+ JSONObject json = JSON.parseObject(response);
+ if (json.getInteger("code").equals(200)) {
+ StartupDto dto = json.getObject("data", StartupDto.class);
+ barcodeThread.setBarcode("");
+ staProtocol.setWorkNo(dto.getWorkNo());
+ staProtocol.setStaNo(dto.getStaNo().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ ledThread.errorReset();
+ log.error("杈撻�佺嚎涓嬪彂2锛�" + dto.getWorkNo() + "," + dto.getStaNo());
+
+ if (!result) {
+ News.error(methodName + ":鏇存柊plc绔欑偣淇℃伅澶辫触");
+ throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+ }
+ } else {
+ String msg = json.getString("msg");
+ if (!"宸ヤ綔妗e凡瀛樺湪".equals(msg)) {
+ staProtocol.setWorkNo(wrkNo++);
+ staProtocol.setStaNo(inSta.getBackSta().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ log.error("杈撻�佺嚎涓嬪彂2锛�" + staProtocol.getWorkNo() + "," + staProtocol.getStaNo());
+ if (!Cools.isEmpty(msg)) {
+ MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, msg));
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("缁勬墭浠诲姟寮傚父锛�", e);
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+ }
}
}
-// News.infoNoLog(""+mark+" - 0"+" - 缁勬墭 ===銆嬫墽琛屽畬鎴�");
-
}
+
/**
* wms鍏ュ簱
* 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 1 ==>> 2
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index a36c7b6..facc3d0 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -494,13 +494,13 @@
write = siemensS7Net.Write("DB1000.0" + offset,staProtocol.getWorkNo()); // 宸ヤ綔鍙�
if(write.IsSuccess ){
- log.error("宸ヤ綔鍙穥}",staProtocol.getWorkNo());
- log.error("鍐欏叆杈撻�佺嚎鍛戒护鎴愬姛銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+ log.error("鍐欏叆宸ヤ綔鍙穥}",staProtocol.getWorkNo());
+ log.error("鍐欏叆杈撳懡浠ゆ垚鍔熴�傝緭閫佺嚎plc缂栧彿={}锛屽啓鍏ユ鏁�={}", slave.getId(), writeCount);
break;
}
else {
writeCount++;
- log.error("鍐欏叆杈撻�佺嚎鍛戒护澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+ log.error("鍐欏叆鍛戒护澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
}
}while (writeCount<5);
}
--
Gitblit v1.9.1