From d8f676ad00f7053180bcbdb91b8abe511eae208e Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期四, 10 四月 2025 15:53:20 +0800
Subject: [PATCH] #motion == null时释放小车

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MotionServiceImpl.java |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MotionServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MotionServiceImpl.java
index 70f38b1..60ce3cf 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MotionServiceImpl.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MotionServiceImpl.java
@@ -42,8 +42,29 @@
 
     @Override
     public Boolean hasRunningMotion(String uuid, Long hostId) {
-        return null != this.selectOfTop1(uuid, MotionStsType.EXECUTING.val(), hostId)
-                || null != this.selectOfTop1(uuid, MotionStsType.ERROR.val(), hostId);
+        Motion executeMotion = this.selectOfTop1(uuid, MotionStsType.EXECUTING.val(), hostId);
+        Motion errorMotion = this.selectOfTop1(uuid, MotionStsType.ERROR.val(), hostId);
+        if(errorMotion != null) {
+            return true;
+        }
+
+        if(executeMotion != null) {
+            if (executeMotion.getSync() == 0) {
+                //妫�娴嬫槸鍚︽湁鍚屾鍔ㄤ綔
+                List<Motion> syncMotion = this.list(new LambdaQueryWrapper<Motion>()
+                        .eq(Motion::getUuid, uuid)
+                        .eq(Motion::getMotionSts, MotionStsType.EXECUTING.val())
+                        .eq(Motion::getHostId, hostId)
+                        .eq(Motion::getSync, 1));
+                if (!syncMotion.isEmpty()) {
+                    return true;//瀛樺湪鍚屾鍔ㄤ綔
+                }
+                return false;//褰撳墠鍔ㄤ綔涓哄紓姝ユ搷浣�
+            }
+            return true;
+        }
+
+        return false;
     }
 
     @Override
@@ -77,12 +98,15 @@
     }
 
     @Override
-    public int batchInsert(List<Motion> motionList, String uuid, Integer taskNo) {
+    public int batchInsert(List<Motion> motionList, String uuid, Integer taskNo, Long hostId) {
         int i = motionList.size();
         for (Motion motion : motionList) {
             motion.setPriority(i);
-            motion.setWrkNo(taskNo);
+            motion.setTaskNo(taskNo);
             motion.setUuid(uuid);
+            if (hostId != null) {
+                motion.setHostId(hostId);
+            }
             if (!this.save(motion)) {
                 throw new CoolException(JSON.toJSONString(motion) + "鍔ㄤ綔淇濆瓨澶辫触");
             }
@@ -90,4 +114,9 @@
         }
         return motionList.size();
     }
+
+    @Override
+    public int batchInsert(List<Motion> motionList, String uuid, Integer taskNo) {
+        return batchInsert(motionList, uuid, taskNo, null);
+    }
 }

--
Gitblit v1.9.1