From 46f16aa85b0d41e812f8352003f54427a35e94e2 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 25 八月 2020 15:00:50 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/ConsoleController.java |   35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java
index ae31894..ef9a2c0 100644
--- a/src/main/java/com/zy/asrs/controller/ConsoleController.java
+++ b/src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -9,9 +9,11 @@
 import com.zy.asrs.domain.vo.*;
 import com.zy.asrs.entity.BasDevp;
 import com.zy.asrs.entity.WrkMast;
+import com.zy.asrs.mapper.LocMastMapper;
 import com.zy.asrs.service.BasDevpService;
 import com.zy.asrs.service.WrkMastService;
 import com.zy.common.CodeRes;
+import com.zy.core.Slave;
 import com.zy.core.cache.SlaveConnection;
 import com.zy.core.enums.CrnModeType;
 import com.zy.core.enums.SlaveType;
@@ -21,6 +23,7 @@
 import com.zy.core.model.protocol.StaProtocol;
 import com.zy.core.properties.SlaveProperties;
 import com.zy.core.properties.SystemProperties;
+import com.zy.core.thread.BarcodeThread;
 import com.zy.core.thread.CrnThread;
 import com.zy.core.thread.DevpThread;
 import lombok.extern.slf4j.Slf4j;
@@ -31,7 +34,6 @@
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * 涓绘帶鍥炬帴鍙�
@@ -48,8 +50,8 @@
     private WrkMastService wrkMastService;
     @Autowired
     private BasDevpService basDevpService;
-
-    public static AtomicInteger integer = new AtomicInteger();
+    @Autowired
+    private LocMastMapper locMastMapper;
 
     @PostMapping("/system/running/status")
     @ManagerAuth(memo = "绯荤粺杩愯鐘舵��")
@@ -114,19 +116,27 @@
                 continue;
             }
             CrnProtocol crnProtocol = crnThread.getCrnProtocol();
+            if (crnProtocol == null) {
+                log.error("{}鍙峰爢鍨涙満杩炴帴澶辫触", crn.getId());
+                continue;
+            }
             CrnLatestDataVo vo = new CrnLatestDataVo();
             vo.setCrnId(crn.getId());   //  鍫嗗灈鏈虹紪鍙�
+
+//            Short totalBay = locMastMapper.selectTotalBay();
+
             vo.setOffset((double) new Random().nextInt(560));     //  鍫嗗灈鏈哄亸绉婚噺
+            vo.setBay(crnProtocol.getBay());    //  褰撳墠鍒�
             /**
              * 鍫嗗灈鏈虹姸鎬佸垽鏂�
              */
             if (crnProtocol.getTaskNo()>0) {
                 WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo());
                 if (wrkMast != null) {
-                    vo.setCrnStatusType(CrnStatusType.process(wrkMast.getIoType()));
+                    vo.setCrnStatus(CrnStatusType.process(wrkMast.getIoType()));
                 }
             } else {
-                vo.setCrnStatusType(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.AUTO: CrnStatusType.UN_AUTO);
+                vo.setCrnStatus(crnProtocol.modeType.equals(CrnModeType.AUTO)? CrnStatusType.MACHINE_AUTO: CrnStatusType.MACHINE_UN_AUTO);
             }
             vos.add(vo);
 
@@ -137,16 +147,12 @@
     @PostMapping("/latest/data/barcode")
     @ManagerAuth(memo = "鏉$爜鎵弿浠疄鏃舵暟鎹�")
     public R barcodeLatestData(){
-        integer.getAndIncrement();
         List<BarcodeDataVo> list = new ArrayList<>();
-        for (int i=1;i<=1;i++){
+        for (Slave barcode : slaveProperties.getBarcode()) {
+            BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcode.getId());
             BarcodeDataVo vo = new BarcodeDataVo();
-            vo.setBarcodeId("1");
-            if (integer.get()%5 != 0) {
-                vo.setCodeValue("0");
-            } else {
-                vo.setCodeValue(String.valueOf(new Random().nextInt(5000)));
-            }
+            vo.setBarcodeId(barcode.getId());
+            vo.setCodeValue(barcodeThread.getBarcode());
             list.add(vo);
         }
         return R.ok().add(list);
@@ -227,9 +233,10 @@
                         vo.setError("");    // todo
                     }
                 }
+                return R.ok().add(vo);
             }
         }
-        return R.ok().add(vo);
+        return R.error();
     }
 
     @Deprecated

--
Gitblit v1.9.1