From 36d6d945ad0664cc2adab24d65097d17f1ff663a Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期二, 25 六月 2024 15:54:45 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/components/edit.jsx                 |   12 ++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/BarcodeThread.java                |    2 
 zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/index.jsx                           |   13 ++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasConveyorSta.java              |    6 ++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java       |   16 +++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SuopaiSiemensDevpThread.java |   20 ++++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensBarcodeThread.java    |   67 +++++++++++----------
 7 files changed, 104 insertions(+), 32 deletions(-)

diff --git a/zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/components/edit.jsx b/zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/components/edit.jsx
index 3cbbfa0..387fa15 100644
--- a/zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/components/edit.jsx
+++ b/zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/components/edit.jsx
@@ -229,6 +229,18 @@
                             label="鐩爣绔�"
                             colProps={{ md: 12, xl: 12 }}
                         />
+                        <ProFormSelect
+                            name="barcodeId"
+                            label="鏉$爜鍣↖D"
+                            colProps={{ md: 12, xl: 12 }}
+                            fieldProps={{ precision: 0 }}
+                            showSearch
+                            debounceTime={300}
+                            request={async ({ keyWords }) => {
+                                const resp = await Http.doPostForm('api/deviceBarcode/query', { condition: keyWords });
+                                return resp.data;
+                            }}
+                        />
                     </ProForm.Group>
 
                 </ProForm>
diff --git a/zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/index.jsx b/zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/index.jsx
index 35e04a0..0ce8d9b 100644
--- a/zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/index.jsx
+++ b/zy-asrs-flow/src/pages/deviceConfig/basConveyorSta/index.jsx
@@ -420,6 +420,19 @@
                 setSearchParam={setSearchParam}
             />,
         },
+        {
+            title: '鏉$爜鍣↖D',
+            dataIndex: 'barcodeId',
+            valueType: 'text',
+            hidden: false,
+            width: 140,
+            filterDropdown: (props) => <TextFilter
+                name='staNo'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
+        },
 
         {
             title: '鎿嶄綔',
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasConveyorSta.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasConveyorSta.java
index 4629b03..22fc0a3 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasConveyorSta.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasConveyorSta.java
@@ -185,6 +185,12 @@
     @ApiModelProperty(value= "鐩爣绔�")
     private Integer staNo;
 
+    /**
+     * 鏉$爜鍣↖D
+     */
+    @ApiModelProperty(value= "鏉$爜鍣↖D")
+    private Long barcodeId;
+
     public BasConveyorSta() {}
 
     public BasConveyorSta(Long conveyorId,Integer conveyorNo,Long updateBy,Long createBy,Date createTime,Date updateTime,String memo,Integer deleted,Long hostId,Integer siteNo,String inEnable,String outEnable,String autoing,String loading,String canining,String canouting,Integer locType1,Integer locType2,Integer locType3,String locNo,String qrCodeValue) {
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
index c8e4bfd..d99c407 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
@@ -82,6 +82,8 @@
     private BasConveyorPathService basConveyorPathService;
     @Autowired
     private BasLedService basLedService;
+    @Autowired
+    private DeviceBarcodeService deviceBarcodeService;
 
     /**
      * 缁勬墭
@@ -418,6 +420,20 @@
     // 瑙f瀽鍏ュ簱宸ヤ綔妗�
     public synchronized void analyzeInBoundTask() {
         for (Task task : taskService.selectWaitAnalyzeInBoundTask()) {
+//            BasConveyorSta basConveyorSta = basConveyorStaService.getOne(new LambdaQueryWrapper<BasConveyorSta>().eq(BasConveyorSta::getSiteNo, task.getDestSite()));
+//            if (basConveyorSta == null) {
+//                continue;
+//            }
+//            DeviceBarcode deviceBarcode = deviceBarcodeService.getById(basConveyorSta.getBarcodeId());
+//            if (deviceBarcode == null) {
+//                continue;
+//            }
+//            BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, Integer.parseInt(deviceBarcode.getDeviceId()));
+//            if (barcodeThread == null) {
+//                continue;
+//            }
+
+
             if (Cools.isEmpty(task.getShuttleNo())) {
                 //鍒嗛厤灏忚溅
                 //鎼滅储绌洪棽杞�
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/BarcodeThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/BarcodeThread.java
index ef5606d..b95f27d 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/BarcodeThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/BarcodeThread.java
@@ -4,4 +4,6 @@
 
     String getBarcode();
 
+    boolean setBarcode(String barcode);
+
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensBarcodeThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensBarcodeThread.java
index 9557786..a5aca2d 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensBarcodeThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SiemensBarcodeThread.java
@@ -39,7 +39,8 @@
         return String.valueOf(barcode);
     }
 
-    public void setBarcode(String barcode) {
+    @Override
+    public boolean setBarcode(String barcode) {
         this.lastBarcode = String.valueOf(this.barcode);
         this.barcode.delete(0, this.barcode.length());
         this.barcode.append(barcode);
@@ -52,7 +53,9 @@
                 OutputQueue.BARCODE.poll();
             }
             OutputQueue.BARCODE.offer(jsonObject);
+            return true;
         }
+        return false;
     }
 
     @Override
@@ -81,37 +84,37 @@
 
     @Override
     public void run() {
-        this.connect();
-        while (true) {
-            try {
-                DeviceBarcodeService deviceBarcodeService = SpringUtils.getBean(DeviceBarcodeService.class);
-                if (deviceBarcodeService == null) {
-                    continue;
-                }
-
-                DeviceBarcode deviceBarcode = deviceBarcodeService.getOne(new LambdaQueryWrapper<DeviceBarcode>()
-                        .eq(DeviceBarcode::getDeviceId, device.getId())
-                        .eq(DeviceBarcode::getHostId, device.getHostId())
-                        .eq(DeviceBarcode::getStatus, 1));
-                if (deviceBarcode == null) {
-                    continue;
-                }
-
-                JSONObject connect = JSON.parseObject(deviceBarcode.getConnect());
-                String address = connect.getString("address");
-                Short length = connect.getShort("length");
-
-                // 鏉$爜鎵弿鍣�
-                OperateResultExOne<byte[]> result = null;
-                result = siemensS7Net.Read(address, length);
-                if (result.IsSuccess) {
-                    String barcode = siemensS7Net.getByteTransform().TransString(result.Content, 0, length, "UTF-8");
-                    setBarcode(barcode);
-                }
-            } catch (Exception e) {
-//                e.printStackTrace();
-            }
-        }
+//        this.connect();
+//        while (true) {
+//            try {
+//                DeviceBarcodeService deviceBarcodeService = SpringUtils.getBean(DeviceBarcodeService.class);
+//                if (deviceBarcodeService == null) {
+//                    continue;
+//                }
+//
+//                DeviceBarcode deviceBarcode = deviceBarcodeService.getOne(new LambdaQueryWrapper<DeviceBarcode>()
+//                        .eq(DeviceBarcode::getDeviceId, device.getId())
+//                        .eq(DeviceBarcode::getHostId, device.getHostId())
+//                        .eq(DeviceBarcode::getStatus, 1));
+//                if (deviceBarcode == null) {
+//                    continue;
+//                }
+//
+//                JSONObject connect = JSON.parseObject(deviceBarcode.getConnect());
+//                String address = connect.getString("address");
+//                Short length = connect.getShort("length");
+//
+//                // 鏉$爜鎵弿鍣�
+//                OperateResultExOne<byte[]> result = null;
+//                result = siemensS7Net.Read(address, length);
+//                if (result.IsSuccess) {
+//                    String barcode = siemensS7Net.getByteTransform().TransString(result.Content, 0, length, "UTF-8");
+//                    setBarcode(barcode);
+//                }
+//            } catch (Exception e) {
+////                e.printStackTrace();
+//            }
+//        }
     }
 
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SuopaiSiemensDevpThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SuopaiSiemensDevpThread.java
index 64b602f..dec340d 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SuopaiSiemensDevpThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SuopaiSiemensDevpThread.java
@@ -11,15 +11,20 @@
 import com.zy.asrs.framework.common.SpringUtils;
 import com.zy.asrs.wcs.core.entity.BasConveyor;
 import com.zy.asrs.wcs.core.entity.BasConveyorSta;
+import com.zy.asrs.wcs.core.entity.DeviceBarcode;
 import com.zy.asrs.wcs.core.service.BasConveyorService;
 import com.zy.asrs.wcs.core.service.BasConveyorStaService;
+import com.zy.asrs.wcs.core.service.DeviceBarcodeService;
 import com.zy.asrs.wcs.core.utils.RedisUtil;
 import com.zy.asrs.wcs.rcs.News;
 import com.zy.asrs.wcs.rcs.cache.OutputQueue;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
 import com.zy.asrs.wcs.rcs.entity.Device;
 import com.zy.asrs.wcs.rcs.model.dto.WorkModeTypeDto;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
 import com.zy.asrs.wcs.rcs.model.enums.WorkModeType;
 import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol;
+import com.zy.asrs.wcs.rcs.thread.BarcodeThread;
 import com.zy.asrs.wcs.rcs.thread.DevpThread;
 import lombok.extern.slf4j.Slf4j;
 
@@ -121,6 +126,21 @@
                 staProtocol.setInEnable(siemensS7Net.getByteTransform().TransInt16(result.Content, i * 40 + 14) == 1); // 鍙叆
                 staProtocol.setOutEnable(siemensS7Net.getByteTransform().TransInt16(result.Content, i * 40 + 14) == 2);// 鍙嚭
                 staProtocol.setWorkMode((int) siemensS7Net.getByteTransform().TransInt16(result.Content, i * 40 + 8));// 宸ヤ綔妯″紡
+
+                String barcode = siemensS7Net.getByteTransform().TransString(result.Content,56,10, "UTF-8");// 鏉$爜
+                BasConveyorStaService basConveyorStaService = SpringUtils.getBean(BasConveyorStaService.class);
+                DeviceBarcodeService deviceBarcodeService = SpringUtils.getBean(DeviceBarcodeService.class);
+                BasConveyorSta basConveyorSta = basConveyorStaService.getOne(new LambdaQueryWrapper<BasConveyorSta>().eq(BasConveyorSta::getSiteNo, siteId));
+                if (basConveyorSta != null) {
+                    DeviceBarcode deviceBarcode = deviceBarcodeService.getById(basConveyorSta.getBarcodeId());
+                    if (deviceBarcode != null) {
+                        BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, Integer.parseInt(deviceBarcode.getDeviceId()));
+                        if (barcodeThread != null) {
+                            barcodeThread.setBarcode(barcode);
+                        }
+                    }
+                }
+
 //                staProtocol.setEmptyMk(status[4]);  // 绌烘澘淇″彿
 //                staProtocol.setFullPlt(status[5]);  // 婊℃墭鐩�
 //                staProtocol.setHigh(status[6]);     // 楂樺簱浣�

--
Gitblit v1.9.1