From 16f1a5b3c7717d10f3d26c87a827339e7e9b8b0c Mon Sep 17 00:00:00 2001
From: lsh <lsh123456>
Date: 星期五, 07 十月 2022 15:12:34 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 129 ++++++++++++++++++++++++------------------
1 files changed, 74 insertions(+), 55 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 6fad629..8f0e4a6 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -103,12 +103,14 @@
for (DevpSlave devp : slaveProperties.getDevp()) {
// 閬嶅巻鍏ュ簱鍙�
for (DevpSlave.Sta inSta : devp.getInSta()) {
+// inSta.setStaNo(102);
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
if (barcodeThread == null) {
continue;
}
String barcode = barcodeThread.getBarcode();
+// barcode="ILY0127 0001";
if(!Cools.isEmpty(barcode)) {
log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
@@ -165,7 +167,7 @@
try {
LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
-
+// locTypeDto.setLocType1((short)1);
SearchLocParam param = new SearchLocParam();
param.setBarcode(barcode);
param.setIoType(1);
@@ -1978,73 +1980,91 @@
}
/**
- * 鏍规嵁PLC鎸夐挳娴嬭瘯淇″彿锛屽彂閫佸惎鍔ㄧ敵璇峰埌娴嬭瘯绯荤粺
+ * 鏍规嵁PLC鎸夐挳娴嬭瘯銆佸畬鎴愩�佹殏鍋滀俊鍙凤紝鏇存柊testMast琛ㄤ腑status鍊硷紝浜ょ敱WMS绯荤粺澶勭悊
*/
@Transactional
- public void startTest() {
+ public void packTest() {
try {
// 鏍规嵁杈撻�佺嚎plc閬嶅巻
for (DevpSlave devp : slaveProperties.getDevp()) {
SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
if(null != devpThread){
- int channel = 0;
- for (int i = 0; i < 4; i++){
- switch (i){
- case 0:
- channel = devpThread.startSignal1;
+ for (int i = 0; i < 48; i++){
+ int olsStatus = 0;//testMast琛ㄥ師鏉tatus鏁版嵁鐘舵��
+ int newStatus = 0;//testMast琛ㄥ緟淇敼鐨剆tatus鏁版嵁鐘舵��
+ short newSingle = 0; //PLC鍦板潃寰呬慨鏀圭殑鏂板��
+ switch (devpThread.startSignal[i]){//鏍规嵁淇″彿鏌ユ壘testMast琛ㄤ腑瀵瑰簲鐘舵�佹潯浠�,olsStatus锛宯ewStatus鏍规嵁瀹為檯娴佺▼璋冩暣
+ case 1://鍚姩澶嶆牳淇″彿
+ olsStatus = 2;
+ newStatus = 3;
+ newSingle = 2;//娴嬭瘯澶嶆牳锛屽瘎瀛樺櫒鍦板潃锛�1===>>2
break;
- case 1:
- channel = devpThread.startSignal2;
+ case 3://瀹屾垚娴嬭瘯淇″彿
+ olsStatus = 3;
+ newStatus = 4;
+ newSingle = 0;//娴嬭瘯瀹屾垚锛屽瘎瀛樺櫒鍦板潃娓呴浂锛�3===>>0
break;
- case 2:
- channel = devpThread.startSignal3;
+ case 5://鏆傚仠淇″彿
+ olsStatus = 99;//plc缁欏嚭鏆傚仠淇″彿
+ newStatus = 0;//WCS鏀跺埌鏆傚仠淇″彿鍚庯紝鏇存柊testMast
+ newSingle = 6;//鏆傚仠娴嬭瘯锛屽瘎瀛樺櫒鍦板潃锛�5===>>6
break;
- case 3:
- channel = devpThread.startSignal4;
+ case 7://绱ф�ュ嚭搴撶‘璁ゅ厖鐢电嚎宸茬粡鎷斿嚭
+ olsStatus = 99;//plc缁欏嚭鏆傚仠淇″彿
+ newStatus = 0;//WCS鏀跺埌鏆傚仠淇″彿鍚庯紝鏇存柊testMast
+ newSingle = 6;//鏆傚仠娴嬭瘯锛屽瘎瀛樺櫒鍦板潃锛�7===>>6
+ break;
+ case 8://瑙i櫎鏆傚仠
+ olsStatus = 99;
+ newStatus = 0;
+ newSingle = 0;//娴嬭瘯澶嶆牳锛屽瘎瀛樺櫒鍦板潃锛�6===>>0
break;
}
- if (channel == 1){
- TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
- .eq("channel",(i+1)).eq("status",0));
- if(null != testMast){
- Date now = new Date();
- //http璇锋眰娴嬭瘯
- TestDto testDto = new TestDto();
- testDto.setLocNo(testMast.getLocNo());
- testDto.setBarcode(testMast.getBarcode());
- testDto.setUserId(testMast.getUserId());
- testDto.setRequestTime(DateUtils.convert(now));
- String response = new HttpHandler.Builder()
- .setUri(testUrl)
- .setPath("/testUrlPath")
- .setJson(JSON.toJSONString(testDto))
- .build()
- .doPost();
- JSONObject jsonObject = JSON.parseObject(response);
- if (jsonObject.getInteger("code").equals(200)) {
- //鏇存柊娴嬭瘯琛ㄧ姸鎬�
- testMast.setStatus(1);
- testMast.setModiTime(now);
- if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
- .eq("channel",1).eq("status",0))){
- throw new CoolException("鏇存柊浜у搧娴嬭瘯鐘舵�佸け璐�");
- }
-// //鏇存柊搴撲綅鐘舵�侊紝閿佸畾pack鐘舵�侊紝绂佹鍏ュ嚭搴撲綔涓�
-// LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",testMast.getLocNo()));
-// if(null != locMast){
-// locMast.setPackStatus(2);//娴嬭瘯涓�
-// locMast.setModiTime(now);
-// if(!locMastService.update(locMast,new EntityWrapper<LocMast>().eq("loc_no",testMast.getLocNo()))){
-// throw new CoolException("浜у搧寮�濮嬫祴璇曪紝鏇存柊鐩爣搴撲綅閿佸畾鐘舵�佸け璐�");
-// }
-// }
- //澶嶄綅PLC淇″彿
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, i*2));
- } else {
- log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿},request锛歿},response锛歿}", testUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(testDto), response);
- }
+ TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
+ .eq("channel",(i+1)).eq("status",olsStatus));//鏌ユ壘鍘熸潵鐨勭姸鎬�
+ if(null != testMast &&
+ (devpThread.startSignal[i] == 1 || devpThread.startSignal[i] == 3)){
+ testMast.setStatus(newStatus);
+ testMast.setModiTime(new Date());
+ if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
+ .eq("channel",(i+1)).eq("status",olsStatus))){
+ throw new CoolException("鏇存柊浜у搧娴嬭瘯鐘舵�佸け璐�");
}
+ //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+ StaProtocol staProtocol = new StaProtocol();
+ staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+ staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,1==>2鎴�3==>0,5==>6
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
+ if(!result){
+ log.error("鏇存柊娴嬭瘯淇″彿澶辫触===>>[channel:{},locNo:{},barcode:{}]", i+1, testMast.getLocNo(), testMast.getBarcode());
+// throw new CoolException("鏇存柊娴嬭瘯淇″彿澶辫触===>>" + i);
+ } else {
+ devpThread.startSignal[i] = newSingle;
+ }
+ }else if (testMast == null && devpThread.startSignal[i] == 5){
+
+ }else if (testMast == null && devpThread.startSignal[i] == 7){
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
+ .eq("channel",(i+1)));
+ if (locMast.getLocSts().equals("F")){
+ locMast.setPackStatus(7); //7.绱ф�ュ嚭搴�
+ locMastService.update(locMast,new EntityWrapper<LocMast>()
+ .eq("channel",(i+1)));
+ }
+ //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+ StaProtocol staProtocol = new StaProtocol();
+ staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+ staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,7==>6
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
+ if(!result){
+ log.error("鏇存柊搴撲綅绱ф�ュ嚭搴撲俊鍙峰け璐�===>>[channel:{},locNo:{},barcode:{}]", i+1, locMast.getLocNo(), locMast.getBarcode());
+// throw new CoolException("鏇存柊娴嬭瘯淇″彿澶辫触===>>" + i);
+ } else {
+ devpThread.startSignal[i] = newSingle;
+ }
+ }else if (testMast == null && devpThread.startSignal[i] == 8){
+
}
}
@@ -2052,7 +2072,6 @@
}
}
-
} catch (Exception e) {
log.error("鍚姩娴嬭瘯 ===>> 鍚姩娴嬭瘯澶辫触", e);
e.printStackTrace();
--
Gitblit v1.9.1