From 12d887af5b4ecb77e46be58735fa702385d2970d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期日, 07 四月 2024 09:43:48 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java |   30 ++++++++++++++++++++++++++----
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasShuttle.java             |   18 +++++++++++++-----
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasShuttle.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasShuttle.java
index 7d84ce8..575f680 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasShuttle.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/BasShuttle.java
@@ -35,7 +35,7 @@
      * 鍥涘悜绌挎杞﹀彿
      */
     @ApiModelProperty(value= "鍥涘悜绌挎杞﹀彿")
-    @TableId(value = "shuttle_no", type = IdType.AUTO)
+    @TableId(value = "shuttle_no", type = IdType.INPUT)
     private Integer shuttleNo;
 
     /**
@@ -54,7 +54,7 @@
      * 浠诲姟鍙�
      */
     @ApiModelProperty(value= "浠诲姟鍙�")
-    private Integer wrkNo;
+    private Integer taskNo;
 
     /**
      * 鏆傚瓨搴撲綅
@@ -125,12 +125,19 @@
     @ApiModelProperty(value= "鎵�灞炴満鏋�")
     private Long hostId;
 
+    /**
+     * 璁惧鐘舵��
+     */
+    @ApiModelProperty(value= "璁惧鐘舵��")
+    private String protocol;
+
     public BasShuttle() {}
 
-    public BasShuttle(Integer status,Integer shuttleStatus,Integer wrkNo,String idleLoc,Integer autoCharge,Integer chargeLine,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo,Integer runSpeed,Integer deleted,Long hostId) {
+    public BasShuttle(Integer shuttleNo, Integer status, Integer shuttleStatus, Integer taskNo, String idleLoc, Integer autoCharge, Integer chargeLine, Long createBy, Date createTime, Long updateBy, Date updateTime, String memo, Integer runSpeed, Integer deleted, Long hostId, String protocol) {
+        this.shuttleNo = shuttleNo;
         this.status = status;
         this.shuttleStatus = shuttleStatus;
-        this.wrkNo = wrkNo;
+        this.taskNo = taskNo;
         this.idleLoc = idleLoc;
         this.autoCharge = autoCharge;
         this.chargeLine = chargeLine;
@@ -142,9 +149,10 @@
         this.runSpeed = runSpeed;
         this.deleted = deleted;
         this.hostId = hostId;
+        this.protocol = protocol;
     }
 
-//    BasShuttle basShuttle = new BasShuttle(
+    //    BasShuttle basShuttle = new BasShuttle(
 //            null,    // 鐘舵��
 //            null,    // 褰撳墠灏忚溅鐘舵��
 //            null,    // 浠诲姟鍙�
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
index 852ca7c..1d298e2 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
@@ -134,10 +134,10 @@
                     shuttleProtocol.setPakMk(true);
                 }
 
-//                if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == ShuttleDeviceStatusType.IDLE.id) {
-//                    //灏忚溅绌洪棽鐘舵�併�佸皬杞︿换鍔$姸鎬佷负鏈煡锛岃瀹氭浘绂荤嚎杩囷紝闇�瑕佸浣嶆垚绌洪棽
-//                    shuttleProtocol.setProtocolStatusType(ShuttleProtocolStatusType.IDLE);
-//                }
+                if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == 3) {
+                    //灏忚溅绌洪棽鐘舵�併�佸皬杞︿换鍔$姸鎬佷负鏈煡锛岃瀹氭浘绂荤嚎杩囷紝闇�瑕佸浣嶆垚绌洪棽
+                    shuttleProtocol.setProtocolStatusType(ShuttleProtocolStatusType.IDLE);
+                }
 
                 if (System.currentTimeMillis() - shuttleProtocol.getDeviceDataLog() > 1000 * 5) {
                     //閲囬泦鏃堕棿瓒呰繃5s锛屼繚瀛樹竴娆℃暟鎹褰�
@@ -155,6 +155,28 @@
                     //鏇存柊閲囬泦鏃堕棿
                     shuttleProtocol.setDeviceDataLog(System.currentTimeMillis());
                 }
+
+                //灏嗗洓鍚戠┛姊溅鐘舵�佷繚瀛樿嚦鏁版嵁搴�
+                BasShuttleService shuttleService = SpringUtils.getBean(BasShuttleService.class);
+                BasShuttle basShuttle = shuttleService.getOne(new LambdaQueryWrapper<BasShuttle>()
+                        .eq(BasShuttle::getShuttleNo, device.getDeviceNo())
+                        .eq(BasShuttle::getHostId, device.getHostId()));
+                if (basShuttle == null) {
+                    basShuttle = new BasShuttle();
+                    //鍥涘悜绌挎杞﹀彿
+                    basShuttle.setShuttleNo(Integer.valueOf(device.getDeviceNo()));
+                    basShuttle.setHostId(device.getHostId());
+                    shuttleService.save(basShuttle);
+                }
+                //浠诲姟鍙�
+                basShuttle.setTaskNo(shuttleProtocol.getTaskNo().intValue());
+                //淇敼鏃堕棿
+                basShuttle.setUpdateTime(new Date());
+                //璁惧鐘舵��
+                basShuttle.setProtocol(JSON.toJSONString(shuttleProtocol));
+                if (shuttleService.updateById(basShuttle)) {
+                    OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), device.getDeviceNo()));
+                }
             } else {
                 OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆憑1}璇诲彇鍥涘悜绌挎杞︾姸鎬佷俊鎭け璐�", DateUtils.convert(new Date()), device.getDeviceNo()));
                 throw new CoolException(MessageFormat.format("璇诲彇鍥涘悜绌挎杞︾姸鎬佷俊鎭け璐� ===>> [id:{0}] [ip:{1}] [port:{2}]", device.getDeviceNo(), device.getIp(), device.getPort()));

--
Gitblit v1.9.1