From 8bae75b786264cc0d1d95b648e403ad2c3b88c52 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期五, 23 五月 2025 15:52:33 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/SiteController.java | 228 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 206 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/SiteController.java b/src/main/java/com/zy/asrs/controller/SiteController.java
index d3fd0ff..45efdff 100644
--- a/src/main/java/com/zy/asrs/controller/SiteController.java
+++ b/src/main/java/com/zy/asrs/controller/SiteController.java
@@ -8,6 +8,7 @@
import com.zy.asrs.domain.vo.SiteTableVo;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.service.BasDevpService;
+import com.zy.asrs.utils.CommandUtils;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
@@ -35,6 +36,7 @@
private SlaveProperties slaveProperties;
@Autowired
private BasDevpService basDevpService;
+
@GetMapping("/io/mode/info/site")
@ManagerAuth(memo = "鍏ュ嚭搴撴ā寮�")
@@ -124,29 +126,12 @@
Map<Integer, StaProtocol> station = devpThread.getStation();
for(Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
- StaProtocol staProtocol = entry.getValue();
-// if (staProtocol) {
-// PlcErrorTableVo vo = new PlcErrorTableVo();
-// vo.setNo(entry.getKey()); // 搴忓彿
-//
-// vo.setPlcDesc(""); // todo:luxiaotao plc閿欒鎻忚堪
-// vo.setError(""); // todo:luxiaotao 寮傚父淇℃伅
-// list.add(vo);
-// }
- }
+ if (!Cools.isEmpty(staPlcErr(entry))){
+ list.add(staPlcErr(entry).get(0)) ;
+ }
+ }
}
-
- list.sort((o1, o2) -> {
- if (o1.getNo().compareTo(o2.getNo()) > 0){
- return 1;
- }else if (o1.getNo().compareTo(o2.getNo()) < 0){
- return 0;
- }else{
- return -1;
- }
-
- });
return R.ok().add(list);
}
@@ -236,7 +221,7 @@
basDevp.setOutEnable(outEnable ? "Y" : "N");
}
basDevpService.updateById(basDevp);
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol), false);
if (result) {
return R.ok();
} else {
@@ -247,6 +232,205 @@
}
return R.error("鏇存柊澶辫触");
}
+ @PostMapping("/detl/out")
+ @ManagerAuth(memo = "淇敼绔欑偣鏁版嵁")
+ public R siteDetlout(@RequestParam Integer devNo,
+ @RequestParam Short workNo,
+ @RequestParam Short staNo,
+ @RequestParam(required = false) String pakMk,
+ @RequestParam(required = false) Boolean inEnable,
+ @RequestParam(required = false) Boolean outEnable
+ ) {
+ BasDevp basDevp = basDevpService.selectById(devNo);
+ if (basDevp == null) {
+ return R.error("绔欑偣涓嶅瓨鍦�");
+ }
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ Map<Integer, StaProtocol> station = devpThread.getStation();
+ for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
+ if (devNo.equals(entry.getKey())) {
+ StaProtocol staProtocol = entry.getValue();
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+ if (pakMk != null) {
+ staProtocol.setPakMk(pakMk.equals("Y"));
+ }
+ if (inEnable != null) {
+ staProtocol.setInEnable(inEnable);
+ basDevp.setInEnable(inEnable ? "Y" : "N");
+ }
+ if (outEnable != null) {
+ staProtocol.setOutEnable(outEnable);
+ basDevp.setOutEnable(outEnable ? "Y" : "N");
+ }
+ staProtocol.setWorkNo((short) 0);
+ staProtocol.setStaNo((short) 0);
+ basDevpService.updateById(basDevp);
+ boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol), false);
+ if (result) {
+ return R.ok();
+ } else {
+ return R.error("涓嬪彂鍛戒护澶辫触");
+ }
+ }
+ }
+ }
+ return R.error("鏇存柊澶辫触");
+ }
+ @PostMapping("/detl/in")
+ @ManagerAuth(memo = "淇敼绔欑偣鏁版嵁")
+ public R siteDetlint(@RequestParam Integer devNo,
+ @RequestParam Short workNo,
+ @RequestParam Short staNo,
+ @RequestParam(required = false) String pakMk,
+ @RequestParam(required = false) Boolean inEnable,
+ @RequestParam(required = false) Boolean outEnable
+ ) {
+ BasDevp basDevp = basDevpService.selectById(devNo);
+ if (basDevp == null) {
+ return R.error("绔欑偣涓嶅瓨鍦�");
+ }
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ // 閬嶅巻鍏ュ簱鍙�
+ for (DevpSlave.Sta inSta : devp.getInSta()) {
+ if (!devNo.equals(inSta.getBackSta()) ){
+ continue;
+ }
+ // 鑾峰彇鍏ュ簱绔欎俊鎭�
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ StaProtocol staProtocol = devpThread.getStation().get(inSta.getBackSta());
+ if (staProtocol == null) {
+ continue;
+ } else {
+ staProtocol = staProtocol.clone();
+ }
+ staProtocol.setWorkNo((short) 9999);
+ staProtocol.setStaNo(inSta.getStaNo().shortValue());
+ boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol), false);
+ if (result) {
+ return R.ok();
+ } else {
+ return R.error("涓嬪彂鍛戒护澶辫触");
+ }
+ }
+ }
+ return R.error("鏇存柊澶辫触");
+ }
+ public List<PlcErrorTableVo> staPlcErr(Map.Entry<Integer, StaProtocol> entry){
+ List<PlcErrorTableVo> list = new ArrayList<>();
+ StaProtocol staProtocol = entry.getValue();
+ if (staProtocol.getBreakerErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+ vo.setPlcDesc("鏂矾鍣ㄦ晠闅�");
+ vo.setError("鏂矾鍣ㄦ晠闅�");
+ list.add(vo);
+ }
+ if (staProtocol.getInfraredErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+ vo.setPlcDesc("鍏夌數寮傚父");
+ vo.setError("鍏夌數寮傚父");
+ list.add(vo);
+ }
+ if (staProtocol.getOutTimeErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+
+ vo.setPlcDesc("杩愯瓒呮椂");
+ vo.setError("杩愯瓒呮椂");
+ list.add(vo);
+ }
+ if (staProtocol.getSeizeSeatErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+
+ vo.setPlcDesc("鍗犱綅瓒呮椂");
+ vo.setError("鍗犱綅瓒呮椂");
+ list.add(vo);
+ }
+ if (staProtocol.getWrkYgoodsN()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+
+ vo.setPlcDesc("鏈変换鍔℃棤璐ф晠闅�");
+ vo.setError("鏈変换鍔℃棤璐ф晠闅�");
+ list.add(vo);
+ }
+ if (staProtocol.getInverterErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+
+ vo.setPlcDesc("鍙橀鍣ㄦ晠闅�");
+ vo.setError("鍙橀鍣ㄦ晠闅�");
+ list.add(vo);
+ }
+ if (staProtocol.getContactErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+
+ vo.setPlcDesc("鐢垫満鎺ヨЕ鍣ㄦ晠闅�");
+ vo.setError("鐢垫満鎺ヨЕ鍣ㄦ晠闅�");
+ list.add(vo);
+ }
+ if (staProtocol.getUpcontactErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+
+ vo.setPlcDesc("椤跺崌鐢垫満鎺ヨЕ鍣ㄦ晠闅�");
+ vo.setError("椤跺崌鐢垫満鎺ヨЕ鍣ㄦ晠闅�");
+ list.add(vo);
+ }
+ if (staProtocol.isFrontErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+ vo.setPlcDesc("鍓嶈秴闄�");
+ vo.setError("鍓嶈秴闄�");
+ list.add(vo);
+ }
+ if (staProtocol.isBackErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+ vo.setPlcDesc("鍚庤秴闄�");
+ vo.setError("鍚庤秴闄�");
+ list.add(vo);
+ }
+ if (staProtocol.isHighErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+ vo.setPlcDesc("楂樿秴闄�");
+ vo.setError("楂樿秴闄�");
+ list.add(vo);
+ }
+ if (staProtocol.isLeftErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+ vo.setPlcDesc("宸﹁秴闄�");
+ vo.setError("宸﹁秴闄�");
+ list.add(vo);
+ }
+ if (staProtocol.isRightErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+ vo.setPlcDesc("鍙宠秴闄�");
+ vo.setError("鍙宠秴闄�");
+ list.add(vo);
+ }
+ if (staProtocol.isBarcodeErr()){
+ PlcErrorTableVo vo = new PlcErrorTableVo();
+ vo.setNo(entry.getKey()); // 搴忓彿
+ vo.setPlcDesc("鎵爜澶辫触");
+ vo.setError("鎵爜澶辫触");
+ list.add(vo);
+ }
+
+
+ return list;
+ }
}
--
Gitblit v1.9.1