From a6f6f82ccb56c168ecd564eca377b41f25a901bb Mon Sep 17 00:00:00 2001
From: ZY <zc857179121@qq.com>
Date: 星期一, 07 四月 2025 17:20:44 +0800
Subject: [PATCH] 还没有写完

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  133 +++++++++++++++++++++++++++----------------
 1 files changed, 83 insertions(+), 50 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 8edd7e5..aa40e13 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -85,6 +85,8 @@
     @Autowired
     private CrnController crnController;
 
+    @Autowired
+    private TransferTaskService transferTaskService;
 
     public void generateStoreWrkFile() throws IOException, InterruptedException {
         try {
@@ -836,6 +838,9 @@
         try {
             // 鏍规嵁杈撻�佺嚎plc閬嶅巻
             for (DevpSlave devp : slaveProperties.getDevp()) {
+                if (devp.getId() == 2){
+                    continue;
+                }
                 SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                 for (DevpSlave.Sta inSta : devp.getInSta()) {
                     WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getBackSta());
@@ -996,56 +1001,6 @@
 
 
     /**
-     * 鐙珛杈撻�佺嚎
-     */
-    public void onlyDevp() {
-        DevpSlave devpSlave = slaveProperties.getDevp().get(1);
-        List<DevpSlave.Sta> inSta = devpSlave.getInSta();
-        // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
-        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devpSlave.getId());
-        for (DevpSlave.Sta sta : inSta) {
-            try {
-                StaProtocol staProtocol = devpThread.getStation().get(sta.getStaNo());
-                if (staProtocol == null) {
-                    continue;
-                } else {
-                    staProtocol = staProtocol.clone();
-                }
-                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == 0)) {
-                    // 鏌ヨ宸ヤ綔妗�
-//                    TaskWrk taskWrk = devpTaskMapper.selectCrnStaWorking(crnSlave.getId(), staDesc.getStnNo().toString());
-//                    if (taskWrk == null) {
-//                        continue;
-//                    }
-//                    log.info("涓嬪彂杈撻�佺嚎浠诲姟锛歵askWrk:" + JSON.toJSONString(taskWrk));
-//                    staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue());
-//                    staProtocol.setStaNo(staDesc.getStnNo().shortValue());
-//                    boolean offer = false;
-//                    try {
-//                        offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
-//                    } catch (Exception e) {
-//                        log.error("涓嬪彂杈撻�佺嚎浠诲姟澶辫触锛氬紓甯�:" + e);
-//                        log.error("涓嬪彂杈撻�佺嚎浠诲姟澶辫触锛氬紓甯�:offer:" + offer);
-//                    }
-//                    if (offer) {
-//                        log.info("涓嬪彂杈撻�佺嚎浠诲姟鎴愬姛锛歵askWrk:" + JSON.toJSONString(taskWrk));
-//                        taskWrk.setStatus(5);
-//                        taskWrk.setWrkSts(14);
-//                        taskWrkService.updateById(taskWrk);
-//
-//                    } else {
-//                        log.error("涓嬪彂杈撻�佺嚎浠诲姟澶辫触锛歵askWrk:" + JSON.toJSONString(taskWrk));
-//                    }
-                }
-            } catch (Exception e) {
-                log.error("鍑哄簱鍒板嚭搴撶珯寮傚父:寮傚父淇℃伅锛�" + e);
-            }
-        }
-
-    }
-
-
-    /**
      * 璺戝簱绋嬪簭
      */
     public void debug() {
@@ -1059,4 +1014,82 @@
 
     }
 
+
+    /**
+     * 杞Щ浠诲姟涓嬪彂
+     */
+    public void transferTaskStart() {
+
+        for (DevpSlave.Sta sta : slaveProperties.getDevp().get(1).getInSta()) {
+            try {
+                // 鑾峰彇鍏ュ簱绔欎俊鎭�
+                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 2);
+                StaProtocol staProtocol = devpThread.getStation().get(sta.getStaNo());
+                if (staProtocol == null) {
+                    continue;
+                } else {
+                    staProtocol = staProtocol.clone();
+                }
+                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == 0)) {
+                    // 鏌ヨ宸ヤ綔妗�
+                    TransferTask transferTask = transferTaskService.selectByStartPoint(sta.getStaNo());
+                    if (transferTask == null) {
+                        continue;
+                    }
+                    log.info("涓嬪彂杈撻�佺嚎杞Щ浠诲姟锛歵askWrk:" + JSON.toJSONString(transferTask));
+                    staProtocol.setWorkNo(transferTask.getWrkNo().shortValue());
+                    staProtocol.setStaNo(transferTask.getTargetPoint().shortValue());
+                    boolean offer = false;
+                    try {
+                        offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
+                    } catch (Exception e) {
+                        log.error("涓嬪彂杈撻�佺嚎杞Щ浠诲姟锛氬紓甯�:" + e);
+                        log.error("涓嬪彂杈撻�佺嚎杞Щ浠诲姟锛氬紓甯�:offer:" + offer);
+                    }
+                    if (offer) {
+                        log.info("涓嬪彂杈撻�佺嚎浠诲姟鎴愬姛锛歵askWrk:" + JSON.toJSONString(transferTask));
+                        transferTask.setStatus(2);
+                        transferTaskService.updateById(transferTask);
+                    } else {
+                        log.error("涓嬪彂杈撻�佺嚎浠诲姟澶辫触锛歵askWrk:" + JSON.toJSONString(transferTask));
+                    }
+                }
+            } catch (Exception e) {
+                log.error("杞Щ浠诲姟寮傚父:寮傚父淇℃伅锛�" + e);
+            }
+        }
+
+    }
+
+    /**
+     * 杞Щ浠诲姟瀹屾垚
+     */
+    public void transferTaskEnd() {
+        for (DevpSlave.Sta sta : slaveProperties.getDevp().get(1).getInSta()) {
+            try {
+                // 鑾峰彇缁堢偣绔�
+                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 2);
+                StaProtocol staProtocol = devpThread.getStation().get(sta.getOverSta());
+                if (staProtocol == null) {
+                    continue;
+                } else {
+                    staProtocol = staProtocol.clone();
+                }
+                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == 0)) {
+                    // 鏌ヨ宸ヤ綔妗�
+                    TransferTask transferTask = transferTaskService.selectByEndPoint(sta.getStaNo());
+                    if (transferTask == null) {
+                        continue;
+                    }
+                    log.info("杞Щ浠诲姟瀹屾垚锛歵ransferTask:" + JSON.toJSONString(transferTask));
+                    transferTask.setStatus(5);
+                    transferTaskService.updateById(transferTask);
+                }
+            } catch (Exception e) {
+                log.error("杞Щ浠诲姟寮傚父:寮傚父淇℃伅锛�" + e);
+            }
+        }
+
+    }
+
 }

--
Gitblit v1.9.1