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 | 279 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 217 insertions(+), 62 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 bdb7662..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,12 +104,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 +168,7 @@
try {
LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
-
+ locTypeDto.setLocType1((short)1);
SearchLocParam param = new SearchLocParam();
param.setBarcode(barcode);
param.setIoType(1);
@@ -189,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);
}
@@ -470,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) {
@@ -1414,7 +1431,7 @@
ledCommand.setStaNo(wrkMast.getStaNo());
if (wrkMast.getIoType() != 110) {
List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
- wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatNo(), wrkDetl.getMatName(), wrkDetl.getQty())));
+ wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme())));
}
commands.add(ledCommand);
}
@@ -1559,7 +1576,7 @@
WrkDetl wrkDetl = new WrkDetl();
wrkDetl.setWrkNo(workNo);
wrkDetl.setIoTime(now);
- wrkDetl.setQty(locDetl.getQty());
+ wrkDetl.setAnfme(locDetl.getAnfme());
VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗
wrkDetl.setAppeTime(now);
wrkDetl.setModiTime(now);
@@ -1676,7 +1693,7 @@
WrkDetl wrkDetl = new WrkDetl();
wrkDetl.setWrkNo(workNo);
wrkDetl.setIoTime(new Date());
- wrkDetl.setQty(locDetl.getQty());
+ wrkDetl.setAnfme(locDetl.getAnfme());
VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗
wrkDetl.setAppeTime(new Date());
wrkDetl.setModiTime(new Date());
@@ -1978,81 +1995,189 @@
}
/**
- * 鏍规嵁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 2://瀹屾垚娴嬭瘯淇″彿
+ olsStatus = 3;
+ newStatus = 3;
+ newSingle = 3;//娴嬭瘯瀹屾垚锛屽瘎瀛樺櫒鍦板潃娓呴浂锛�2===>>3
+ case 4://瀹屾垚娴嬭瘯淇″彿
+ olsStatus = 3;
+ newStatus = 4;
+ newSingle = 0;//娴嬭瘯瀹屾垚锛屽瘎瀛樺櫒鍦板潃娓呴浂锛�4===>>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;//娴嬭瘯澶嶆牳锛屽瘎瀛樺櫒鍦板潃锛�8===>>0
+ break;
+ case 11://鍏ュ簱鍓嶅垽鏂厖鐢电嚎鏄惁鏀惧ソ
+ olsStatus = 99;
+ newStatus = 0;
+ newSingle = 11;//
+ break;
+ case 12://鍏呯數绾挎斁濂�
+ olsStatus = 99;
+ newStatus = 0;
+ newSingle = 0;//娴嬭瘯澶嶆牳锛屽瘎瀛樺櫒鍦板潃锛�12===>>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 (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 { }
}
}
}
-
} catch (Exception e) {
log.error("鍚姩娴嬭瘯 ===>> 鍚姩娴嬭瘯澶辫触", e);
e.printStackTrace();
@@ -2060,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