From 5d0f7a5aa4ee994782f3f3bcc66e23653a6ac40a Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期五, 19 七月 2024 10:07:46 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/SiteController.java |  255 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 234 insertions(+), 21 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/SiteController.java b/src/main/java/com/zy/asrs/controller/SiteController.java
index 9cc5b94..58e5cde 100644
--- a/src/main/java/com/zy/asrs/controller/SiteController.java
+++ b/src/main/java/com/zy/asrs/controller/SiteController.java
@@ -7,17 +7,23 @@
 import com.zy.asrs.domain.vo.PlcErrorTableVo;
 import com.zy.asrs.domain.vo.SiteTableVo;
 import com.zy.asrs.entity.BasDevp;
+import com.zy.asrs.entity.BasExt;
 import com.zy.asrs.service.BasDevpService;
+import com.zy.asrs.service.BasExtService;
 import com.zy.asrs.utils.CommandUtils;
 import com.zy.core.cache.MessageQueue;
 import com.zy.core.cache.OutputQueue;
 import com.zy.core.cache.SlaveConnection;
 import com.zy.core.enums.SlaveType;
 import com.zy.core.model.DevpSlave;
+import com.zy.core.model.ExtSlave;
 import com.zy.core.model.Task;
+import com.zy.core.model.protocol.ExtProtocol;
 import com.zy.core.model.protocol.StaProtocol;
 import com.zy.core.properties.SlaveProperties;
 import com.zy.core.DevpThread;
+import com.zy.core.thread.BarcodeThread;
+import com.zy.core.thread.MelsecExtThread;
 import com.zy.core.thread.SiemensDevpThread;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -36,6 +42,9 @@
     private SlaveProperties slaveProperties;
     @Autowired
     private BasDevpService basDevpService;
+    @Autowired
+    private BasExtService basExtService;
+
 
     @GetMapping("/io/mode/info/site")
     @ManagerAuth(memo = "鍏ュ嚭搴撴ā寮�")
@@ -110,8 +119,30 @@
             vo.setPakMk(staProtocol.isPakMk()?"Y":"N");       // 鍏ュ簱鏍囪
             vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N");     // 绌烘澘淇″彿
             vo.setStaNo(staProtocol.getStaNo());                // 鐩爣绔�
+            vo.setStaNo(staProtocol.getStaNo());                // 鐩爣绔�
+            vo.setStaNo(staProtocol.getStaNo());                // 鐩爣绔�
+            vo.setFullPlt(staProtocol.isFullPlt()?"Y":"N");
+            vo.setLow(staProtocol.isLow()?"Y":"N");
+            vo.setCar(staProtocol.isCar()?"Y":"N");
 //            vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "浣�" : "楂�");     //楂樹綆搴撲綅
             vo.setLocType1(devp.getDevNo()==102 ? "楂�" : "浣�");
+            vo.setBarcode(staProtocol.getBarcode());
+        }
+        return R.ok().add(list);
+    }
+
+    @GetMapping("/list/ext/auth")
+    @ManagerAuth(memo = "鏈烘鑷備俊鎭�")
+    public R extList(){
+        List<SiteTableVo> list = new ArrayList<>();
+        // 鎸佷箙鏁版嵁
+        List<BasExt> basExts = basExtService.selectList(new EntityWrapper<BasExt>().orderBy("ext_no"));
+        for (BasExt ext : basExts) {
+            SiteTableVo vo = new SiteTableVo();
+            vo.setDevNo(ext.getExtNo());    // 绔欑偣缂栧彿
+            vo.setInEnable(ext.getExtTask());   // 鍙叆  鍙彇
+            vo.setOutEnable(ext.getExtPut()); // 鍙嚭     鍙斁
+            list.add(vo);
         }
         return R.ok().add(list);
     }
@@ -125,29 +156,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);
     }
 
@@ -248,6 +262,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