From b59324a7812fb5877bdb14f38228670520a9d95a Mon Sep 17 00:00:00 2001
From: 18516761980 <56479841@qq.com>
Date: 星期四, 06 十月 2022 19:35:56 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 79 +++++++++++++++------------------------
src/main/java/com/zy/core/MainProcess.java | 7 +--
2 files changed, 32 insertions(+), 54 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 40dd22c..37d31cf 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1980,32 +1980,55 @@
}
/**
- * 鏍规嵁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){
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 3://瀹屾垚娴嬭瘯淇″彿
+ olsStatus = 3;
+ newStatus = 5;
+ newSingle = 0;//娴嬭瘯瀹屾垚锛屽瘎瀛樺櫒鍦板潃娓呴浂锛�3===>>0
+ break;
+ case 5://鏆傚仠淇″彿
+ olsStatus = 5;//plc缁欏嚭鏆傚仠淇″彿
+ newStatus = 6;//WCS鏀跺埌鏆傚仠淇″彿鍚庯紝鏇存柊testMast
+ newSingle = 6;//鏆傚仠娴嬭瘯锛屽瘎瀛樺櫒鍦板潃锛�5===>>6
+ break;
+ }
+
TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
- .eq("channel",(i+1)).eq("status",0));//鏌ユ壘鍘熸潵鐨勭姸鎬�
+ .eq("channel",(i+1)).eq("status",olsStatus));//鏌ユ壘鍘熸潵鐨勭姸鎬�
if(null != testMast && devpThread.startSignal[i] == 1){
- testMast.setStatus(3);
+ testMast.setStatus(newStatus);
testMast.setModiTime(new Date());
if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
- .eq("channel",(i+1)).eq("status",0))){
+ .eq("channel",(i+1)).eq("status",olsStatus))){
throw new CoolException("鏇存柊浜у搧娴嬭瘯鐘舵�佸け璐�");
}
//澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
StaProtocol staProtocol = new StaProtocol();
staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
- staProtocol.setStaNo((short)2);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,浠�1鏀逛负2
+ staProtocol.setStaNo((short)newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,浠�1鏀逛负2
boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
if(!result){
- throw new CoolException("鍚姩娴嬭瘯淇″彿澶辫触===>>" + i);
+ throw new CoolException("鏇存柊娴嬭瘯淇″彿澶辫触===>>" + i);
+ } else {
+ devpThread.startSignal[i] = newSingle;
}
}
@@ -2016,48 +2039,6 @@
}
} catch (Exception e) {
log.error("鍚姩娴嬭瘯 ===>> 鍚姩娴嬭瘯澶辫触", e);
- e.printStackTrace();
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- }
- }
-
- /**
- * 鏍规嵁PLC鎸夐挳娴嬭瘯淇″彿锛屽彂閫佸惎鍔ㄧ敵璇峰埌娴嬭瘯绯荤粺
- */
- @Transactional
- public void finishTest() {
- try {
- // 鏍规嵁杈撻�佺嚎plc閬嶅巻
- for (DevpSlave devp : slaveProperties.getDevp()) {
- SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- if(null != devpThread){
- for (int i = 0; i < 48; i++){
- TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
- .eq("channel",(i+1)).eq("status",0));//鏌ユ壘鍘熸潵鐨勭姸鎬侊紝鏍规嵁涓氬姟閫昏緫淇敼
- if(null != testMast && devpThread.startSignal[i] == 3){
- testMast.setStatus(3);
- testMast.setModiTime(new Date());
- if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
- .eq("channel",(i+1)).eq("status",0))){
- throw new CoolException("鏇存柊浜у搧娴嬭瘯鐘舵�佸け璐�");
- }
- //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
- StaProtocol staProtocol = new StaProtocol();
- staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
- staProtocol.setStaNo((short)0);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,浠�3鏀逛负0
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
- if(!result){
- throw new CoolException("瀹屾垚娴嬭瘯淇″彿澶辫触===>>" + i);
- }
- }
-
- }
-
- }
-
- }
- } catch (Exception e) {
- log.error("瀹屾垚娴嬭瘯 ===>> 瀹屾垚娴嬭瘯澶辫触", e);
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
diff --git a/src/main/java/com/zy/core/MainProcess.java b/src/main/java/com/zy/core/MainProcess.java
index 48dcaa0..2060f13 100644
--- a/src/main/java/com/zy/core/MainProcess.java
+++ b/src/main/java/com/zy/core/MainProcess.java
@@ -67,11 +67,8 @@
mainService.outOfDevp();
- //鍚姩娴嬭瘯绯荤粺娴嬭瘯
- mainService.startTest();
-
- //娴嬭瘯绯荤粺瀹屾垚娴嬭瘯纭
- mainService.finishTest();
+ //鍚姩銆佸畬鎴愩�佹殏鍋滄祴璇曠郴缁熸祴璇�
+ mainService.packTest();
} catch (Exception e) {
e.printStackTrace();
--
Gitblit v1.9.1