From 80459108843177082c119647c480cc571e739fbc Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期五, 17 二月 2023 15:19:47 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 196 +++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 183 insertions(+), 13 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 4d3c3c0..9c919d3 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -35,6 +35,7 @@
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
import com.zy.core.thread.LedThread;
+import com.zy.core.thread.SiemensCrnThread;
import com.zy.core.thread.SiemensDevpThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -103,7 +104,7 @@
for (DevpSlave devp : slaveProperties.getDevp()) {
// 閬嶅巻鍏ュ簱鍙�
for (DevpSlave.Sta inSta : devp.getInSta()) {
-// inSta.setStaNo(102);
+ inSta.setStaNo(102);
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
if (barcodeThread == null) {
@@ -167,7 +168,7 @@
try {
LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
-// locTypeDto.setLocType1((short)1);
+ locTypeDto.setLocType1((short)1);
SearchLocParam param = new SearchLocParam();
param.setBarcode(barcode);
param.setIoType(1);
@@ -191,7 +192,21 @@
if (!result) {
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
- } else {
+ } else if (jsonObject.getInteger("code").equals(700) && (!barcodeThread.getBarcode().equals("NG"))){
+ StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+ barcodeThread.setBarcode("");
+ staProtocol.setWorkNo((short)9998);
+ staProtocol.setStaNo((short)101);
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ log.error("url锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+ }else {
+ StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+ barcodeThread.setBarcode("");
+ staProtocol.setWorkNo((short)9998);
+ staProtocol.setStaNo((short)101);
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
}
@@ -472,7 +487,7 @@
} else {
staProtocol = staProtocol.clone();
}
- if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
+ if (staProtocol.isAutoing() && (staProtocol.isLoading()||staProtocol.getSiteId()==109) && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
// 鏌ヨ宸ヤ綔妗�
WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId());
if (wrkMast == null) {
@@ -1999,22 +2014,46 @@
newStatus = 3;
newSingle = 2;//娴嬭瘯澶嶆牳锛屽瘎瀛樺櫒鍦板潃锛�1===>>2
break;
- case 3://瀹屾垚娴嬭瘯淇″彿
+ case 2://瀹屾垚娴嬭瘯淇″彿
olsStatus = 3;
- newStatus = 5;
- newSingle = 0;//娴嬭瘯瀹屾垚锛屽瘎瀛樺櫒鍦板潃娓呴浂锛�3===>>0
+ newStatus = 3;
+ newSingle = 3;//娴嬭瘯瀹屾垚锛屽瘎瀛樺櫒鍦板潃娓呴浂锛�2===>>3
+ case 4://瀹屾垚娴嬭瘯淇″彿
+ olsStatus = 3;
+ newStatus = 4;
+ newSingle = 0;//娴嬭瘯瀹屾垚锛屽瘎瀛樺櫒鍦板潃娓呴浂锛�4===>>0
break;
case 5://鏆傚仠淇″彿
- olsStatus = 5;//plc缁欏嚭鏆傚仠淇″彿
- newStatus = 6;//WCS鏀跺埌鏆傚仠淇″彿鍚庯紝鏇存柊testMast
+ olsStatus = 99;//plc缁欏嚭鏆傚仠淇″彿
+ newStatus = 0;//WCS鏀跺埌鏆傚仠淇″彿鍚庯紝鏇存柊testMast
newSingle = 6;//鏆傚仠娴嬭瘯锛屽瘎瀛樺櫒鍦板潃锛�5===>>6
+ break;
+ case 7://绱ф�ュ嚭搴撶‘璁ゅ厖鐢电嚎宸茬粡鎷斿嚭
+ olsStatus = 99;//plc缁欏嚭鏆傚仠淇″彿
+ newStatus = 0;//WCS鏀跺埌鏆傚仠淇″彿鍚庯紝鏇存柊testMast
+ newSingle = 6;//鏆傚仠娴嬭瘯锛屽瘎瀛樺櫒鍦板潃锛�7===>>6
+ break;
+ case 8://瑙i櫎鏆傚仠
+ olsStatus = 99;
+ newStatus = 0;
+ newSingle = 0;//娴嬭瘯澶嶆牳锛屽瘎瀛樺櫒鍦板潃锛�8===>>0
+ break;
+ case 11://鍏ュ簱鍓嶅垽鏂厖鐢电嚎鏄惁鏀惧ソ
+ olsStatus = 99;
+ newStatus = 0;
+ newSingle = 11;//
+ break;
+ case 12://鍏呯數绾挎斁濂�
+ olsStatus = 99;
+ newStatus = 0;
+ newSingle = 0;//娴嬭瘯澶嶆牳锛屽瘎瀛樺櫒鍦板潃锛�12===>>0
break;
}
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 || devpThread.startSignal[i] == 5)){
+ (devpThread.startSignal[i] == 1 || devpThread.startSignal[i] == 3)){
testMast.setStatus(newStatus);
testMast.setModiTime(new Date());
if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
@@ -2027,12 +2066,113 @@
staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,1==>2鎴�3==>0,5==>6
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
if(!result){
- throw new CoolException("鏇存柊娴嬭瘯淇″彿澶辫触===>>" + i);
+ log.error("鏇存柊娴嬭瘯淇″彿澶辫触===>>[channel:{},locNo:{},barcode:{}]", i+1, testMast.getLocNo(), testMast.getBarcode());
+// throw new CoolException("鏇存柊娴嬭瘯淇″彿澶辫触===>>" + i);
} else {
devpThread.startSignal[i] = newSingle;
}
- }
-
+ }else if (null != testMast && devpThread.startSignal[i] == 2){
+ if (testMast.getStatus()==3){
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
+ .eq("channel",(i+1)));
+ if (locMast.getLocSts().equals("F") && locMast.getPackStatus()==3){
+ //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+ StaProtocol staProtocol = new StaProtocol();
+ staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+ staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,2==>3
+ 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 (devpThread.startSignal[i] == 5){
+ SearchLocParam param = new SearchLocParam();
+ param.setBarcode(i+1+"");
+ String response = new HttpHandler.Builder()
+ .setUri(wmsUrl)
+ .setPath("/mobile/test/suspend/auth")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ if (jsonObject.getInteger("code").equals(200)) {
+ //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+ StaProtocol staProtocol = new StaProtocol();
+ staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+ staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,5==>6
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
+ if(!result){
+ log.error("鏆傚仠娴嬭瘯澶辫触===>>["+i+1+"]鍙烽�氶亾");
+// throw new CoolException("鏇存柊娴嬭瘯淇″彿澶辫触===>>" + i);
+ } else {
+ devpThread.startSignal[i] = newSingle;
+ }
+ } else {
+ log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/mobile/test/suspend/auth", JSON.toJSONString(param), response);
+ }
+ }else if (devpThread.startSignal[i] == 7){
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
+ .eq("channel",(i+1)));
+ if (locMast.getLocSts().equals("F")){
+ locMast.setPackStatus(8); //8.绱ф�ュ嚭搴�
+ 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 (devpThread.startSignal[i] == 8){
+ //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+ StaProtocol staProtocol = new StaProtocol();
+ staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+ staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,8==>0
+ 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 (devpThread.startSignal[i] == 11){
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
+ .eq("channel",(i+1)));
+ if (locMast.getLocSts().equals("O")){
+ locMast.setLocSts("X");
+ locMastService.update(locMast,new EntityWrapper<LocMast>()
+ .eq("channel",(i+1)));
+ }
+ }else if (devpThread.startSignal[i] == 12){
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
+ .eq("channel",(i+1)));
+ if (locMast.getLocSts().equals("X")){
+ locMast.setLocSts("O");
+ locMastService.update(locMast,new EntityWrapper<LocMast>()
+ .eq("channel",(i+1)));
+ }
+ //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+ StaProtocol staProtocol = new StaProtocol();
+ staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+ staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,12==>0
+ 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 { }
}
}
@@ -2045,4 +2185,34 @@
}
}
+ /**
+ * 灏嗙伀璀︽姤璀︿俊鍙峰啓鍏ュ埌鍫嗗灈鏈篜LC涓�
+ */
+ @Transactional
+ public void fierCrn() {
+ try {
+ for (CrnSlave crn :slaveProperties.getCrn()) {
+ // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
+ CrnProtocol crnProtocol = crnThread.getCrnProtocol();
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("fire_status", 1));
+ if (!Cools.isEmpty(locMast)){
+ //鎶ヨ淇″彿鍐欏叆1
+ if (!MessageQueue.offer(SlaveType.Crn, 1, new Task(4, (short)1))) {
+ log.error("鐏 ===>> 缁欏爢鍨涙満鍙戦�佹姤璀︿俊鍙峰け璐�");
+ }
+ } else {
+ //鎶ヨ淇″彿娌℃湁鍚庯紝澶嶄綅鍦板潃
+ if (!MessageQueue.offer(SlaveType.Crn, 1, new Task(4, (short)0))) {
+ log.error("鐏 ===>> 缁欏爢鍨涙満娓呴浂澶嶄綅鎶ヨ淇″彿澶辫触");
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("鐏 ===>> 缁欏爢鍨涙満鍙戦�佽鎶ュけ璐�", e);
+ e.printStackTrace();
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+ }
+
}
--
Gitblit v1.9.1