From 9c248839d8750db523fe6192101bfa085fe1305f Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 26 三月 2024 16:20:23 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java          |  308 +++++++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java         |  915 +++++++++++++++++++++++++++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java      |   45 +
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/WorkZoneType.java      |   34 +
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/TaskService.java           |    7 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/TaskServiceImpl.java  |   45 +
 zy-asrs-wcs/src/main/resources/mapper/core/TaskMapper.xml                         |    8 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java |   19 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/MotionServiceImpl.java |   22 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCodeType.java      |   79 ++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/BuildSupport.java                  |    7 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/mapper/TaskMapper.java             |    5 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java       |  176 +++++
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/TaskStsType.java       |   49 +
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java          |   21 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java          |   40 +
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/Motion.java                  |   21 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/MotionService.java          |    5 
 18 files changed, 1,806 insertions(+), 0 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/BuildSupport.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/BuildSupport.java
new file mode 100644
index 0000000..bab5d00
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/BuildSupport.java
@@ -0,0 +1,7 @@
+package com.zy.asrs.wcs.core;
+
+public interface BuildSupport<T> {
+
+    void execute(T t);
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java
new file mode 100644
index 0000000..03e3d94
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/domain/dto/MotionDto.java
@@ -0,0 +1,40 @@
+package com.zy.asrs.wcs.core.domain.dto;
+
+import com.zy.asrs.wcs.core.BuildSupport;
+import lombok.Data;
+
+/**
+ * Created by vincent on 2023/10/16
+ */
+@Data
+public class MotionDto {
+
+    private Integer devpNo;
+
+    private Integer shuttleNo;
+
+    private Integer liftNo;
+
+    private String locNo;
+
+    private Integer row;
+
+    private Integer bay;
+
+    private Integer lev;
+
+    private Integer staNo;
+
+    private Boolean updateLiftNo;
+
+    protected Integer wrkNo;
+
+    public static MotionDto build(BuildSupport<MotionDto> support) {
+        MotionDto dto = new MotionDto();
+
+        support.execute(dto);
+
+        return dto;
+    }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
new file mode 100644
index 0000000..ae54ee7
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -0,0 +1,915 @@
+package com.zy.asrs.wcs.core.kernel;
+
+import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.wcs.core.domain.dto.MotionDto;
+import com.zy.asrs.wcs.core.entity.Task;
+import com.zy.asrs.wcs.core.model.enums.LiftCodeType;
+import com.zy.asrs.wcs.core.model.enums.MotionCtgType;
+import com.zy.asrs.wcs.core.model.enums.TaskStsType;
+import com.zy.asrs.wcs.core.model.enums.WorkZoneType;
+import com.zy.asrs.wcs.core.service.TaskService;
+import com.zy.asrs.wcs.core.utils.LiftDispatcher;
+import com.zy.asrs.wcs.core.utils.ShuttleDispatcher;
+import com.zy.asrs.wcs.core.utils.Utils;
+import com.zy.asrs.wcs.rcs.entity.Motion;
+import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
+import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
+import com.zy.asrs.wcs.rcs.service.MotionService;
+import com.zy.asrs.wcs.rcs.thread.LiftThread;
+import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * todo:luxiaotao 1.鍏呯數浠诲姟锛�2.搴撲綅绉昏浆锛�3.灏忚溅杩佺Щ
+ * Created by vincent on 2023/10/11
+ */
+@Service
+public class AnalyzeService {
+
+    @Autowired
+    private TaskService taskService;
+    @Autowired
+    private MotionService motionService;
+    @Autowired
+    private KernelService kernelService;
+    @Autowired
+    private ShuttleDispatcher shuttleDispatcher;
+    @Autowired
+    private LiftDispatcher liftDispatcher;
+//    @Autowired
+//    private ConveyorDispatcher conveyorDispatcher;
+
+    public List<Motion> generateMotion(Task task) {
+        List<Motion> motionList = new ArrayList<>();
+        switch (Objects.requireNonNull(WorkZoneType.query(task.getTaskSts() == TaskStsType.NEW_INBOUND.sts ? task.getOriginSite() : task.getDestSite()))) {
+            case FIRST_ZONE:
+                motionList = this.generateFirstZoneMotion(task);
+                break;
+            default:
+        }
+        return motionList;
+    }
+
+    public List<Motion> generateFirstZoneMotion(Task task) {
+        List<Motion> motionList = new ArrayList<>();
+
+        String shuttleNo = null;
+        String liftNo = null;
+        /**
+         * 鍏ュ簱
+         * 涓�銆佸叆搴撶洰鏍囧眰鏈夌┛姊溅
+         * 1.鎻愬崌鏈哄崌闄嶅埌婧愬眰
+         * 2.璐х墿浠庤緭閫佺嚎鍒版彁鍗囨満
+         * 3.鎻愬崌鏈鸿浇璐хЩ鍔紙闈炲繀闇�锛�
+         * 4.绌挎杞﹁蛋琛岃嚦鎻愬崌鏈�
+         * 5.绌挎杞﹀叆搴撹嚦鐩爣搴撲綅
+         */
+        if (task.getTaskSts() == TaskStsType.NEW_INBOUND.sts) {
+            // lift
+            LiftThread liftThread = liftDispatcher.queryLiftForTransport(task.getOriginSite());
+            LiftProtocol liftProtocol = liftThread.getStatus();
+            if (liftProtocol == null) {
+                return motionList;
+            }
+
+            // shuttle
+            ShuttleThread shuttleThread = shuttleDispatcher.queryShuttleWhichConvenient(task, Integer.parseInt(liftThread.getStatus().getLiftNo()));
+            if (Cools.isEmpty(shuttleThread)) { return motionList; }
+            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
+
+//            // conveyor
+//            DevpSlave devpSlave = conveyorDispatcher.queryByInBound(task.getSourceStaNo());
+//            DevpSlave.Sta slaveInSta = devpSlave.queryInSta(wrkMast.getSourceStaNo());
+
+//            //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹�
+//            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleProtocol.getShuttleNo().intValue());
+//            if (shuttleResult) {
+//                //瀛樺湪浠诲姟锛岀姝㈣В鏋�
+//                return motionList;
+//            }
+//
+//            //妫�娴嬫彁鍗囨満鏄惁鏈変换鍔$粦瀹�
+//            boolean liftResult = Utils.checkLiftHasBinding(liftSlave.getId());
+//            if (liftResult) {
+//                //瀛樺湪浠诲姟锛岀姝㈣В鏋�
+//                return motionList;
+//            }
+
+            //绌挎杞﹀埌鎻愬崌鏈哄簱浣嶅彿
+            String liftLocNoTo = LiftCodeType.getLocNo(Integer.parseInt(liftNo), Utils.getLev(shuttleLocNo), task.getHostId());
+
+            //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿
+            String liftLocNoFrom = LiftCodeType.getLocNo(Integer.parseInt(liftNo), Utils.getLev(task.getDestLoc()), task.getHostId());
+
+            //绌挎杞﹀埌鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙�
+            String standbyLocNoTo = LiftCodeType.getStandbyLocNo(Integer.parseInt(liftNo), Utils.getLev(shuttleLocNo));
+
+            //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙�
+            String standbyLocNoFrom = LiftCodeType.getStandbyLocNo(Integer.parseInt(liftNo), Utils.getLev(task.getDestLoc()));
+
+            // 鍏ュ簱鐩爣灞傛湁绌挎杞�
+            if (Utils.getLev(shuttleLocNo) == Utils.getLev(task.getOriginLoc())) {
+
+                // 绌挎杞﹁蛋琛岃嚦搴撲綅
+                motionList.addAll(kernelService.shuttleMove(
+                        MotionDto.build((dto -> {
+                            dto.setShuttleNo(Integer.valueOf(shuttleProtocol.getShuttleNo()));
+                            dto.setLocNo(shuttleLocNo);
+                        })),
+                        MotionDto.build((dto -> {
+                            dto.setShuttleNo(Integer.valueOf(shuttleProtocol.getShuttleNo()));
+                            dto.setLocNo(task.getDestLoc());
+                        })),
+                        MotionCtgType.SHUTTLE_MOVE
+                ));
+
+//                // 鎻愬崌鏈虹┖杞界Щ鍔�
+//                motionList.addAll(kernelService.liftMove(
+//                        null
+//                        , MotionDto.build((dto -> {
+//                            dto.setLiftNo(Integer.valueOf(liftProtocol.getLiftNo()));
+////                            dto.setLev(slaveInSta.getLiftLev());
+//                            dto.setLev(1);
+//                        }))
+//                ));
+//
+//                // 杈撻�佺嚎鍏ュ簱鑷虫彁鍗囨満鍙�
+//                motionList.addAll(kernelService.conveyorInbound(
+//                        MotionDto.build((dto -> {
+////                            dto.setDevpNo(devpSlave.getId());
+//                            dto.setDevpNo(1);
+//                            dto.setStaNo(Integer.valueOf(task.getOriginSite()));
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setLiftNo(Integer.valueOf(liftProtocol.getLiftNo()));
+////                            dto.setLev(slaveInSta.getLiftLev());
+//                            dto.setLev(1);
+//                        })),
+//                        MotionCtgType.CONVEYOR_INBOUND_TO_LIFT
+//                ));
+//
+//                // 鐩爣搴撲綅鏄惁涓庤緭閫佺嚎鍏ュ簱绔欏睘浜庡悓涓�灞�
+//                if (!slaveInSta.getLiftLev().equals(Utils.getLev(wrkMast.getLocNo()))) {
+//                    // 鎻愬崌鏈鸿浇璐хЩ鍔�
+//                    motionList.addAll(kernelService.liftMoveGoods(
+//                            MotionDto.build((dto -> {
+//                                dto.setLiftNo(liftSlave.getId());
+//                                dto.setLev(slaveInSta.getLiftLev());
+//                            }))
+//                            , MotionDto.build((dto -> {
+//                                dto.setLiftNo(liftSlave.getId());
+//                                dto.setLev(Utils.getLev(wrkMast.getLocNo()));
+//                            }))
+//                    ));
+//                }
+//
+//                // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣嶅緟鏈轰綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(shuttleLocNo);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(standbyLocNoTo);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE
+//                ));
+//
+//                // 鎻愬崌鏈虹Щ鍔ㄨ嚦灏忚溅妤煎眰
+//                motionList.addAll(kernelService.liftMove(
+//                        null
+//                        , MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(Utils.getLev(shuttleLocNo));
+//                        }))
+//                ));
+//
+//                // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満搴撲綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoTo);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoTo);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_TO_LIFT
+//                ));
+//
+//                // 绌挎杞﹀叆搴撻《鍗囧苟绉诲姩鑷虫彁鍗囨満寰呮満浣�
+//                motionList.addAll(kernelService.shuttleTransport(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionCtgType.SHUTTLE_TRANSPORT_FROM_LIFT
+//                ));
+//
+//                // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣嶅緟鏈轰綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(wrkMast.getLocNo());
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_DOWN_PALLET
+//                ));
+
+            /**
+             * 浜屻�佸叆搴撶洰鏍囧眰娌℃湁绌挎杞�
+             * 1.鎻愬崌鏈哄崌闄嶅埌绌挎杞﹀眰
+             * 2.绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅
+             * 3.鎻愬崌鏈烘惉杩愮┛姊溅鑷崇洰鏍囧眰
+             * 4.璐х墿浠庤緭閫佺嚎鍒版彁鍗囨満
+             * 5.鎻愬崌鏈鸿浇杞︿笌璐хЩ鍔紙闈炲繀闇�锛�
+             * 6.绌挎杞﹀叆搴撹嚦鐩爣搴撲綅
+             */
+            } else {
+//
+//                // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄簱浣嶅緟鏈轰綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(shuttleLocNo);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(standbyLocNoTo);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE
+//                ));
+//
+//                // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰
+//                motionList.addAll(kernelService.liftMove(
+//                        null
+//                        , MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(Utils.getLev(shuttleLocNo));
+//                        }))
+//                ));
+//
+//                // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満搴撲綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoTo);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoTo);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_TO_LIFT
+//                ));
+//
+//                // 鎻愬崌鏈烘惉杞� 鑷� 杈撻�佺嚎灞�
+//                motionList.addAll(kernelService.liftMoveShuttle(
+//                        MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(Utils.getLev(shuttleLocNo));
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(slaveInSta.getLiftLev());
+//                        }))
+//                ));
+//
+//                // 杈撻�佺嚎鍏ュ簱鑷虫彁鍗囨満鍙�
+//                motionList.addAll(kernelService.conveyorInbound(
+//                        MotionDto.build((dto -> {
+//                            dto.setDevpNo(devpSlave.getId());
+//                            dto.setStaNo(wrkMast.getSourceStaNo());
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(slaveInSta.getLiftLev());
+//                        })),
+//                        MotionCtgType.CONVEYOR_INBOUND_TO_LIFT
+//                ));
+//
+//                // 鐩爣搴撲綅鏄惁涓庤緭閫佺嚎鍏ュ簱绔欏睘浜庡悓涓�灞�
+//                if (!slaveInSta.getLiftLev().equals(Utils.getLev(wrkMast.getLocNo()))) {
+//                    // 鎻愬崌鏈鸿浇璐хЩ鍔�
+//                    motionList.addAll(kernelService.liftMoveGoodsAndShuttle(
+//                            MotionDto.build((dto -> {
+//                                dto.setLiftNo(liftSlave.getId());
+//                                dto.setLev(slaveInSta.getLiftLev());
+//                            }))
+//                            , MotionDto.build((dto -> {
+//                                dto.setLiftNo(liftSlave.getId());
+//                                dto.setLev(Utils.getLev(wrkMast.getLocNo()));
+//                            }))
+//                    ));
+//                }
+//
+//                // 绌挎杞﹀叆搴撻《鍗囧苟绉诲姩鑷虫彁鍗囨満寰呮満浣�
+//                motionList.addAll(kernelService.shuttleTransport(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionCtgType.SHUTTLE_TRANSPORT_FROM_LIFT
+//                ));
+//
+//                // 绌挎杞﹀緟鏈轰綅鑷冲叆搴撳簱浣�
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(wrkMast.getLocNo());
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_DOWN_PALLET
+//                ));
+
+            }
+
+            shuttleNo = String.valueOf(shuttleProtocol.getShuttleNo());
+            liftNo = String.valueOf(liftProtocol.getLiftNo());
+        }
+
+        /**
+         * 鍑哄簱
+         */
+        if (task.getTaskSts() == TaskStsType.NEW_OUTBOUND.sts) {
+//            // lift
+//            LiftProtocol liftProtocol = liftDispatcher.queryLiftForTransport(wrkMast.getStaNo());
+//            LiftSlave liftSlave = liftProtocol.querySlave();
+//
+//            // shuttle
+//            ShuttleProtocol shuttleProtocol = shuttleDispatcher.queryShuttleWhichConvenient(wrkMast, liftProtocol.getLiftNo().intValue());
+//            if (Cools.isEmpty(shuttleProtocol)) { return motionList; }
+//            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
+//
+//            // conveyor
+//            DevpSlave devpSlave = conveyorDispatcher.queryByOutBound(wrkMast.getSourceStaNo());
+//            DevpSlave.Sta slaveOutSta = devpSlave.queryOutSta(wrkMast.getSourceStaNo());
+//
+//            //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹�
+//            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleProtocol.getShuttleNo().intValue());
+//            if (shuttleResult) {
+//                //瀛樺湪浠诲姟锛岀姝㈣В鏋�
+//                return motionList;
+//            }
+//
+//            //妫�娴嬫彁鍗囨満鏄惁鏈変换鍔$粦瀹�
+//            boolean liftResult = Utils.checkLiftHasBinding(liftSlave.getId());
+//            if (liftResult) {
+//                //瀛樺湪浠诲姟锛岀姝㈣В鏋�
+//                return motionList;
+//            }
+//
+//            //绌挎杞﹀埌鎻愬崌鏈哄簱浣嶅彿
+//            String liftLocNoTo = LiftCodeType.getLocNo(liftSlave.getId(), Utils.getLev(shuttleLocNo));
+//
+//            //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿
+//            String liftLocNoFrom = LiftCodeType.getLocNo(liftSlave.getId(), Utils.getLev(wrkMast.getSourceLocNo()));
+//
+//            //绌挎杞﹀埌鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙�
+//            String standbyLocNoTo = LiftCodeType.getStandbyLocNo(liftSlave.getId(), Utils.getLev(shuttleLocNo));
+//
+//            //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙�
+//            String standbyLocNoFrom = LiftCodeType.getStandbyLocNo(liftSlave.getId(), Utils.getLev(wrkMast.getSourceLocNo()));
+//
+//            /**
+//             * 鍑哄簱
+//             * 涓�銆佸嚭搴撹捣濮嬪眰鏈夌┛姊溅
+//             * 1.绌挎杞﹁蛋琛岃嚦鍑哄簱搴撲綅
+//             * 2.鎻愬崌鏈哄埌鍑哄簱璧峰灞�
+//             * 3.绌挎杞﹀嚭搴撹嚦鎻愬崌鏈�
+//             * 4.绌挎杞︾寮�鎻愬崌鏈�
+//             * 5.鎻愬崌鏈鸿浇璐хЩ鍔紙闈炲繀闇�锛�
+//             * 6.杈撻�佺嚎杩愯緭鑷冲嚭搴撳彛
+//             */
+//            if (Utils.getLev(shuttleLocNo) == Utils.getLev(wrkMast.getSourceLocNo())) {
+//
+//                //绌挎杞︿笉鍦ㄥ嚭搴撳簱浣�
+//                if (!shuttleLocNo.equals(wrkMast.getSourceLocNo())) {
+//                    // 绌挎杞﹁蛋琛岃嚦鍑哄簱搴撲綅
+//                    motionList.addAll(kernelService.shuttleMove(
+//                            MotionDto.build((dto -> {
+//                                dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                                dto.setLocNo(shuttleLocNo);
+//                            })),
+//                            MotionDto.build((dto -> {
+//                                dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                                dto.setLocNo(wrkMast.getSourceLocNo());
+//                            })),
+//                            MotionCtgType.SHUTTLE_MOVE
+//                    ));
+//                }
+//
+//                // 绌挎杞﹀嚭搴撹嚦鎻愬崌鏈哄緟鏈轰綅
+//                motionList.addAll(kernelService.shuttleTransport(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(wrkMast.getSourceLocNo());
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(standbyLocNoTo);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_LIFT_PALLET
+//                ));
+//
+//                // 鎻愬崌鏈虹┖杞界Щ鍔�
+//                motionList.addAll(kernelService.liftMove(
+//                        null
+//                        , MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(Utils.getLev(wrkMast.getSourceLocNo()));
+//                        }))
+//                ));
+//
+//                // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満
+//                motionList.addAll(kernelService.shuttleTransport(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoTo);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoTo);
+//                        })),
+//                        MotionCtgType.SHUTTLE_TRANSPORT_TO_LIFT
+//                ));
+//
+//                // 绌挎杞︾寮�鎻愬崌鏈� - 鍒版彁鍗囨満寰呮満浣�
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
+//                ));
+//
+//                // 鎻愬崌鏈鸿浇璐хЩ鍔�
+//                // 鍑哄簱搴撲綅鏄惁涓庤緭閫佺嚎鍑哄簱绔欏睘浜庡悓涓�灞�
+//                if (!slaveOutSta.getLiftLev().equals(Utils.getLev(wrkMast.getSourceLocNo()))) {
+//                    motionList.addAll(kernelService.liftMoveGoods(
+//                            MotionDto.build((dto -> {
+//                                dto.setLiftNo(liftSlave.getId());
+//                                dto.setLev(Utils.getLev(wrkMast.getSourceLocNo()));
+//                            })),
+//                            MotionDto.build((dto -> {
+//                                dto.setLiftNo(liftSlave.getId());
+//                                dto.setLev(slaveOutSta.getLiftLev());
+//                            }))
+//                    ));
+//                }
+//
+//                LiftNeighborType neighborType = LiftNeighborType.query(liftSlave.getId(), slaveOutSta.getLiftLev(), false, wrkMast.getStaNo());
+//
+//                // 鎻愬崌鏈鸿繍杈撳埌杈撻�佺嚎
+//                motionList.addAll(kernelService.liftTransportGoodsToConveyor(
+//                        MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(slaveOutSta.getLiftLev());
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setDevpNo(devpSlave.getId());
+//                            dto.setStaNo(neighborType.staNo);
+//                        }))
+//                ));
+//
+//                // 绌挎杞︽彁鍗囨満寰呮満浣� - 鍒板緟鏈轰綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(
+//                                    ShuttleTempLocType.query(shuttleProtocol.getShuttleNo().intValue(), liftSlave.getId(), Utils.getLev(wrkMast.getSourceLocNo())).locNo
+//                            );
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE
+//                ));
+//
+//            /**
+//             * 浜屻�佸嚭搴撹捣濮嬪眰娌℃湁绌挎杞�
+//             *
+//             * 1.鎻愬崌鏈哄埌绌挎杞﹀眰
+//             * 2.绌挎杞﹁蛋琛岃嚦鎻愬崌鏈�
+//             * 3.鎻愬崌鏈鸿浇杞﹁嚦鍑哄簱璧峰灞�
+//             * 4.绌挎杞﹁蛋琛岃嚦鍑哄簱搴撲綅
+//             * 5.绌挎杞﹀嚭搴撹嚦鎻愬崌鏈�
+//             * 6.绌挎杞︾寮�鎻愬崌鏈�
+//             * 7.鎻愬崌鏈鸿浇璐хЩ鍔紙闈炲繀闇�锛�
+//             * 8.杈撻�佺嚎杩愯緭鑷冲嚭搴撳彛
+//             *
+//             */
+//            } else {
+//
+//                // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(shuttleLocNo);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(standbyLocNoTo);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE
+//                ));
+//
+//                // 鎻愬崌鏈哄埌绌挎杞﹀眰
+//                motionList.addAll(kernelService.liftMove(
+//                        null
+//                        , MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(Utils.getLev(shuttleLocNo));
+//                        }))
+//                ));
+//
+//                // 绌挎杞﹀緟鏈轰綅鑷虫彁鍗囨満
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoTo);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoTo);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_TO_LIFT
+//                ));
+//
+//                // 鎻愬崌鏈鸿浇杞﹁嚦鍑哄簱璧峰灞�
+//                motionList.addAll(kernelService.liftMoveShuttle(
+//                        MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(Utils.getLev(shuttleLocNo));
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(Utils.getLev(wrkMast.getSourceLocNo()));
+//                        }))
+//                ));
+//
+//                // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
+//                ));
+//
+//                // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鍑哄簱搴撲綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(wrkMast.getSourceLocNo());
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE
+//                ));
+//
+//                // 绌挎杞﹀嚭搴撹嚦鎻愬崌鏈哄緟鏈轰綅
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(wrkMast.getSourceLocNo());
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_LIFT_PALLET
+//                ));
+//
+//                // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鎻愬崌鏈�
+//                motionList.addAll(kernelService.shuttleTransport(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(standbyLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoFrom);
+//                        })),
+//                        MotionCtgType.SHUTTLE_TRANSPORT_TO_LIFT
+//                ));
+//
+//                // 绌挎杞︾寮�鎻愬崌鏈�
+//                motionList.addAll(kernelService.shuttleMove(
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLocNo(liftLocNoFrom);
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                            dto.setLocNo(
+//                                ShuttleTempLocType.query(shuttleProtocol.getShuttleNo().intValue(), liftSlave.getId(), Utils.getLev(wrkMast.getSourceLocNo())).locNo
+//                            );
+//                        })),
+//                        MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
+//                ));
+//
+//                // 鎻愬崌鏈鸿浇璐хЩ鍔�
+//                // 鍑哄簱搴撲綅鏄惁涓庤緭閫佺嚎鍑哄簱绔欏睘浜庡悓涓�灞�
+//                if (!slaveOutSta.getLiftLev().equals(Utils.getLev(wrkMast.getSourceLocNo()))) {
+//                    motionList.addAll(kernelService.liftMoveGoods(
+//                            MotionDto.build((dto -> {
+//                                dto.setLiftNo(liftSlave.getId());
+//                                dto.setLev(Utils.getLev(wrkMast.getSourceLocNo()));
+//                            })),
+//                            MotionDto.build((dto -> {
+//                                dto.setLiftNo(liftSlave.getId());
+//                                dto.setLev(slaveOutSta.getLiftLev());
+//                            }))
+//                    ));
+//                }
+//
+//                LiftNeighborType neighborType = LiftNeighborType.query(liftSlave.getId(), slaveOutSta.getLiftLev(), false, wrkMast.getStaNo());
+//
+//                // 鎻愬崌鏈鸿繍杈撳埌杈撻�佺嚎
+//                motionList.addAll(kernelService.liftTransportGoodsToConveyor(
+//                        MotionDto.build((dto -> {
+//                            dto.setLiftNo(liftSlave.getId());
+//                            dto.setLev(slaveOutSta.getLiftLev());
+//                        })),
+//                        MotionDto.build((dto -> {
+//                            dto.setDevpNo(devpSlave.getId());
+//                            dto.setStaNo(neighborType.staNo);
+//                        }))
+//                ));
+//
+//            }
+//
+//            shuttleNo = String.valueOf(shuttleProtocol.getShuttleNo());
+//            liftNo = String.valueOf(liftProtocol.getLiftNo());
+        }
+
+        assert !Cools.isEmpty(shuttleNo);
+//        task.setShuttleNo(Integer.parseInt(shuttleNo));
+//        task.setLiftNo(Integer.parseInt(liftNo));
+
+        return motionList;
+    }
+
+
+//    /**
+//     * 鐢熸垚鍏呯數鍔ㄤ綔
+//     */
+//    public List<Motion> generateChargeMotion(WrkCharge wrkCharge) {
+//        List<Motion> motionList = new ArrayList<>();
+//        if (wrkCharge.getWrkSts() != WrkMastStsType.NEW_CHARGE.sts || wrkCharge.getIoType() != WrkIoTypeType.CHARGE.sts) {
+//            return motionList;
+//        }
+//
+//        // locNo
+//        String chargeLocNo = wrkCharge.getLocNo();
+//
+//        // lift
+//        Integer transferLiftNo = 2;
+//        SiemensLiftThread liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, transferLiftNo);
+//        LiftProtocol liftProtocol = liftThread.getLiftProtocol();
+//        if (liftProtocol == null || liftProtocol.getLiftNo() == null) {
+//            return motionList;
+//        }
+//
+//        // shuttle
+//        Integer shuttleNo = wrkCharge.getShuttleNo();
+//        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
+//        ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+//        if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
+//            return motionList;
+//        }
+//        if (!shuttleProtocol.isIdle()) {
+//            return motionList;
+//        }
+//
+//        //妫�娴嬬┛姊溅鏄惁鏈変换鍔$粦瀹�
+//        boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleProtocol.getShuttleNo().intValue());
+//        if (shuttleResult) {
+//            //瀛樺湪浠诲姟锛岀姝㈣В鏋�
+//            return motionList;
+//        }
+//
+//        //妫�娴嬫彁鍗囨満鏄惁鏈変换鍔$粦瀹�
+//        boolean liftResult = Utils.checkLiftHasBinding(transferLiftNo);
+//        if (liftResult) {
+//            //瀛樺湪浠诲姟锛岀姝㈣В鏋�
+//            return motionList;
+//        }
+//
+//        String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
+//
+//        //绌挎杞﹀埌鎻愬崌鏈哄簱浣嶅彿
+//        String liftLocNoTo = LiftCodeType.getLocNo(transferLiftNo, Utils.getLev(shuttleLocNo));
+//
+//        //绌挎杞﹀嚭鎻愬崌鏈哄簱浣嶅彿
+//        String liftLocNoFrom = LiftCodeType.getLocNo(transferLiftNo, Utils.getLev(wrkCharge.getLocNo()));
+//
+//        //绌挎杞﹀埌鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙�
+//        String standbyLocNoTo = LiftCodeType.getStandbyLocNo(transferLiftNo, Utils.getLev(shuttleLocNo));
+//
+//        //绌挎杞﹀嚭鎻愬崌鏈哄緟鏈轰綅搴撲綅鍙�
+//        String standbyLocNoFrom = LiftCodeType.getStandbyLocNo(transferLiftNo, Utils.getLev(wrkCharge.getLocNo()));
+//
+//        // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鍏呯數灞�
+//        if (Utils.getLev(shuttleLocNo) == Utils.getLev(chargeLocNo)) {
+//
+//            // 绌挎杞﹁蛋琛岃嚦鍏呯數妗╁簱浣�
+//            motionList.addAll(kernelService.shuttleMove(
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(shuttleLocNo);
+//                    })),
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(chargeLocNo);
+//                    })),
+//                    MotionCtgType.SHUTTLE_MOVE
+//            ));
+//
+//        } else {
+//
+//            // 绌挎杞﹁蛋琛岃嚦鎻愬崌鏈哄緟鏈轰綅
+//            motionList.addAll(kernelService.shuttleMove(
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(shuttleLocNo);
+//                    })),
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(standbyLocNoTo);
+//                    })),
+//                    MotionCtgType.SHUTTLE_MOVE
+//            ));
+//
+//            // 鎻愬崌鏈虹┖杞界Щ鍔ㄥ埌绌挎杞﹀眰
+//            motionList.addAll(kernelService.liftMove(
+//                    null
+//                    , MotionDto.build((dto -> {
+//                        dto.setLiftNo(transferLiftNo);
+//                        dto.setLev(Utils.getLev(shuttleLocNo));
+//                    }))
+//            ));
+//
+//            // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鎻愬崌鏈哄簱浣�
+//            motionList.addAll(kernelService.shuttleMove(
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(standbyLocNoTo);
+//                    })),
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLiftNo(transferLiftNo);
+//                        dto.setLocNo(liftLocNoTo);
+//                    })),
+//                    MotionCtgType.SHUTTLE_MOVE_TO_LIFT
+//            ));
+//
+//            // 鎻愬崌鏈烘惉杞� 鑷� 杈撻�佺嚎灞�
+//            motionList.addAll(kernelService.liftMoveShuttle(
+//                    MotionDto.build((dto -> {
+//                        dto.setLiftNo(transferLiftNo);
+//                        dto.setLev(Utils.getLev(shuttleLocNo));
+//                    })),
+//                    MotionDto.build((dto -> {
+//                        dto.setLiftNo(transferLiftNo);
+//                        dto.setLev(Utils.getLev(chargeLocNo));
+//                    }))
+//            ));
+//
+//            // 绌挎杞︽彁鍗囨満鑷虫彁鍗囨満寰呮満浣�
+//            motionList.addAll(kernelService.shuttleMove(
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLiftNo(transferLiftNo);
+//                        dto.setLocNo(liftLocNoFrom);
+//                    })),
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(standbyLocNoFrom);
+//                    })),
+//                    MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
+//            ));
+//
+//            // 绌挎杞︽彁鍗囨満寰呮満浣嶈嚦鍏呯數浣�
+//            motionList.addAll(kernelService.shuttleMove(
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(standbyLocNoFrom);
+//                    })),
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(chargeLocNo);
+//                    })),
+//                    MotionCtgType.SHUTTLE_MOVE
+//            ));
+//
+//            wrkCharge.setLiftNo(transferLiftNo);
+//            wrkChargeMapper.updateById(wrkCharge);
+//        }
+//
+//        // 绌挎杞﹀紑濮嬪厖鐢�
+//        motionList.addAll(kernelService.shuttleCharge(
+//                null,
+//                MotionDto.build((dto -> {
+//                    dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                }))
+//        ));
+//
+//        return motionList;
+//    }
+//
+//    /**
+//     * 鐢熸垚鍏呯數瀹屾垚鍔ㄤ綔
+//     */
+//    public List<Motion> generateShuttleChargeWrkComplete(WrkCharge wrkCharge) {
+//        List<Motion> motionList = new ArrayList<>();
+//        if (wrkCharge.getWrkSts() != WrkMastStsType.NEW_MOVE.sts || wrkCharge.getIoType() != WrkIoTypeType.MOVE.sts) {
+//            return motionList;
+//        }
+//
+//        // locNo
+//        String locNo = wrkCharge.getLocNo();
+//
+//        // shuttle
+//        Integer shuttleNo = wrkCharge.getShuttleNo();
+//        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
+//        ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+//        if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
+//            return motionList;
+//        }
+//
+//        String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
+//
+//        // 鍒ゆ柇绌挎杞︽槸鍚﹀湪鐩爣灞�
+//        if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) {
+//
+//            // 绌挎杞﹁蛋琛岃嚦鐩爣搴撲綅
+//            motionList.addAll(kernelService.shuttleMove(
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(shuttleLocNo);
+//                    })),
+//                    MotionDto.build((dto -> {
+//                        dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
+//                        dto.setLocNo(locNo);
+//                    })),
+//                    MotionCtgType.SHUTTLE_MOVE
+//            ));
+//
+//        }
+//        return motionList;
+//    }
+
+
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java
new file mode 100644
index 0000000..86a7415
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java
@@ -0,0 +1,308 @@
+package com.zy.asrs.wcs.core.kernel;
+
+import com.zy.asrs.wcs.core.domain.dto.MotionDto;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
+import com.zy.asrs.wcs.core.model.enums.MotionCtgType;
+import com.zy.asrs.wcs.rcs.entity.Motion;
+import com.zy.asrs.wcs.rcs.service.MotionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by vincent on 2023/10/9
+ */
+@Service(value = "kernelService")
+public class KernelService {
+
+    @Autowired
+    private MotionService motionService;
+
+
+    // agv -----------------------------------------------------------------------------
+    @Deprecated
+    public List<Motion> agvTransport() {
+        List<Motion> motionList = new ArrayList<>();
+
+        // 1.AGV鎼繍璐х墿
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.AGV.val());
+            motion.setMotionCtg(MotionCtgType.AGV_TRANSPORT.val());
+        }));
+
+        return motionList;
+    }
+
+    // lift -----------------------------------------------------------------------------
+
+    /**
+     * 鎻愬崌鏈虹Щ鍔�
+     */
+    public List<Motion> liftMove(MotionDto origin, MotionDto target) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.LIFT.val());
+            motion.setDevice(String.valueOf(target.getLiftNo()));
+
+            motion.setMotionCtg(MotionCtgType.LIFT_MOVE.val());
+
+            if (null != origin) {
+                motion.setOrigin(String.valueOf(origin.getLev()));
+            }
+            motion.setTarget(String.valueOf(target.getLev()));
+        }));
+
+//        if (target.getUpdateLiftNo() != null && target.getWrkNo() != null) {
+//            if (target.getUpdateLiftNo()) {
+//
+//            }
+//        }
+
+        return motionList;
+    }
+
+    /**
+     * 鎻愬崌鏈鸿浇璐хЩ鍔�
+     */
+    public List<Motion> liftMoveGoods(MotionDto origin, MotionDto target) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.LIFT.val());
+            motion.setDevice(String.valueOf(target.getLiftNo()));
+
+            motion.setMotionCtg(MotionCtgType.LIFT_WITH_GOODS.val());
+
+            if (null != origin) {
+                motion.setOrigin(String.valueOf(origin.getLev()));
+            }
+            motion.setTarget(String.valueOf(target.getLev()));
+        }));
+
+        return motionList;
+    }
+
+    /**
+     * 鎻愬崌鏈烘惉杩愮┛姊溅
+     */
+    public List<Motion> liftMoveShuttle(MotionDto origin, MotionDto target) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.LIFT.val());
+            motion.setDevice(String.valueOf(target.getLiftNo()));
+
+            motion.setMotionCtg(MotionCtgType.LIFT_WITH_SHUTTLE.val());
+
+            if (null != origin) {
+                motion.setOrigin(String.valueOf(origin.getLev()));
+            }
+            motion.setTarget(String.valueOf(target.getLev()));
+        }));
+
+        return motionList;
+    }
+
+    /**
+     * 鎻愬崌鏈鸿浇绌挎杞︿笌璐хЩ鍔�
+     */
+    public List<Motion> liftMoveGoodsAndShuttle(MotionDto origin, MotionDto target) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.LIFT.val());
+            motion.setDevice(String.valueOf(target.getLiftNo()));
+
+            motion.setMotionCtg(MotionCtgType.LIFT_WITH_GOODS_AND_SHUTTLE.val());
+
+            if (null != origin) {
+                motion.setOrigin(String.valueOf(origin.getLev()));
+            }
+            motion.setTarget(String.valueOf(target.getLev()));
+        }));
+
+        return motionList;
+    }
+
+    /**
+     * 鎻愬崌鏈鸿浇绌挎杞︿笌璐хЩ鍔�
+     */
+    public List<Motion> liftTransportGoodsToConveyor(MotionDto origin, MotionDto target) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.LIFT.val());
+            motion.setDevice(String.valueOf(origin.getLiftNo()));
+
+            motion.setMotionCtg(MotionCtgType.LIFT_TRANSPORT_TO_CONVEYOR.val());
+
+            motion.setOrigin(String.valueOf(origin.getLev()));
+            motion.setDockNo(String.valueOf(target.getDevpNo()));
+            motion.setTarget(String.valueOf(target.getStaNo()));
+
+        }));
+
+        return motionList;
+    }
+
+
+    // shuttle -----------------------------------------------------------------------------
+
+    /**
+     * 绌挎杞︾┖杞界Щ鍔�
+     */
+    public List<Motion> shuttleMove(MotionDto origin, MotionDto target, MotionCtgType motionCtgType) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
+            motion.setDevice(String.valueOf(target.getShuttleNo()));
+
+            motion.setMotionCtg(motionCtgType.val());
+
+            motion.setOrigin(origin.getLocNo());
+            motion.setTarget(target.getLocNo());
+
+            switch (motionCtgType) {
+                case SHUTTLE_MOVE_FROM_LIFT://绌挎杞︾Щ鍑烘彁鍗囨満
+                    motion.setTemp(String.valueOf(origin.getLiftNo()));//淇濆瓨鎻愬崌鏈哄彿
+                    break;
+                case SHUTTLE_MOVE_TO_LIFT://绌挎杞︾Щ鍔ㄥ埌鎻愬崌鏈�
+                    motion.setTemp(String.valueOf(target.getLiftNo()));//淇濆瓨鎻愬崌鏈哄彿
+                    break;
+                case SHUTTLE_MOVE_FROM_CONVEYOR:
+                    motion.setDockNo(String.valueOf(origin.getStaNo()));
+                    break;
+                case SHUTTLE_MOVE_TO_CONVEYOR:
+                    motion.setDockNo(String.valueOf(target.getStaNo()));
+                    break;
+                case SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR://绌挎杞︾Щ鍑烘彁鍗囨満鍘昏緭閫佺嚎
+                    motion.setTemp(String.valueOf(origin.getLiftNo()));//淇濆瓨鎻愬崌鏈哄彿
+                    motion.setDockNo(String.valueOf(target.getStaNo()));
+                    break;
+                default:
+                    break;
+            }
+
+        }));
+
+        return motionList;
+    }
+
+    /**
+     * 绌挎杞﹁浇璐хЩ鍔�
+     */
+    public List<Motion> shuttleTransport(MotionDto origin, MotionDto target, MotionCtgType motionCtgType) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
+            motion.setDevice(String.valueOf(target.getShuttleNo()));
+
+            motion.setMotionCtg(motionCtgType.val());
+
+            switch (motionCtgType) {
+                case SHUTTLE_TRANSPORT_FROM_LIFT:
+                    motion.setTemp(String.valueOf(origin.getLiftNo()));//淇濆瓨鎻愬崌鏈哄彿
+                    break;
+                case SHUTTLE_TRANSPORT_TO_LIFT:
+                    motion.setTemp(String.valueOf(target.getLiftNo()));//淇濆瓨鎻愬崌鏈哄彿
+                    break;
+                case SHUTTLE_TRANSPORT_FROM_CONVEYOR:
+                    motion.setDockNo(String.valueOf(origin.getStaNo()));
+                    break;
+                case SHUTTLE_TRANSPORT_TO_CONVEYOR:
+                    motion.setDockNo(String.valueOf(target.getStaNo()));
+                    break;
+                default:
+                    break;
+            }
+
+            motion.setOrigin(origin.getLocNo());
+            motion.setTarget(target.getLocNo());
+        }));
+
+        return motionList;
+    }
+
+    public List<Motion> shuttleCharge(MotionDto origin, MotionDto target) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
+            motion.setDevice(String.valueOf(target.getShuttleNo()));
+
+            motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_ON.val());
+
+        }));
+
+        return motionList;
+    }
+
+    // conveyor -----------------------------------------------------------------------------
+
+    /**
+     * 杈撻�佺嚎鍏ュ簱
+     */
+    public List<Motion> conveyorInbound(MotionDto origin, MotionDto target, MotionCtgType motionCtgType) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.CONVEYOR.val());
+            motion.setDevice(String.valueOf(origin.getDevpNo()));
+
+            motion.setMotionCtg(motionCtgType.val());
+
+            switch (motionCtgType) {
+                case CONVEYOR_INBOUND:
+                    motion.setTarget(String.valueOf(target.getStaNo()));
+                    break;
+                case CONVEYOR_INBOUND_TO_LIFT:
+                    motion.setDockNo(String.valueOf(target.getLiftNo()));
+                    motion.setTarget(String.valueOf(target.getLev()));
+                    break;
+                default:
+                    break;
+            }
+
+            motion.setOrigin(String.valueOf(origin.getStaNo()));
+
+        }));
+
+        return motionList;
+    }
+
+    /**
+     * 杈撻�佺嚎鍑哄簱
+     */
+    public List<Motion> conveyorOutbound(MotionDto origin, MotionDto target, MotionCtgType motionCtgType) {
+        List<Motion> motionList = new ArrayList<>();
+
+        motionList.add(Motion.build(motion -> {
+            motion.setDeviceCtg(DeviceCtgType.CONVEYOR.val());
+            motion.setDevice(String.valueOf(origin.getDevpNo()));
+
+            motion.setMotionCtg(motionCtgType.val());
+
+            switch (motionCtgType) {
+                case CONVEYOR_OUTBOUND:
+                    motion.setOrigin(String.valueOf(origin.getStaNo()));
+                    break;
+                case CONVEYOR_OUTBOUND_FROM_LIFT:
+                    motion.setDockNo(String.valueOf(origin.getLiftNo()));
+                    break;
+                default:
+                    break;
+            }
+
+            motion.setTarget(String.valueOf(target.getStaNo()));
+
+        }));
+
+        return motionList;
+    }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/mapper/TaskMapper.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/mapper/TaskMapper.java
index c4079bf..bca7c4b 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/mapper/TaskMapper.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/mapper/TaskMapper.java
@@ -3,10 +3,15 @@
 import com.zy.asrs.wcs.core.entity.Task;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
+
+import java.util.List;
 
 @Mapper
 @Repository
 public interface TaskMapper extends BaseMapper<Task> {
 
+    List<Task> selectOutboundByShuttleNo(@Param("shuttleNo") Integer shuttleNo);
+
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCodeType.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCodeType.java
new file mode 100644
index 0000000..22465ab
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCodeType.java
@@ -0,0 +1,79 @@
+package com.zy.asrs.wcs.core.model.enums;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.framework.common.SpringUtils;
+import com.zy.asrs.wcs.core.entity.Loc;
+import com.zy.asrs.wcs.core.service.LocService;
+import com.zy.asrs.wcs.core.utils.Utils;
+
+public enum LiftCodeType {
+
+    NONE(-1, -1, "鏈煡", "0402001"),
+    LIFT_2(2, 198, "2鍙锋彁鍗囨満浜岀淮鐮�", "0402001"),
+    LIFT_1(1, 0, "1鍙锋彁鍗囨満鏃犱簩缁寸爜", "0800701"),
+    ;
+
+    public Integer liftNo;
+    public Integer code;
+    public String desc;
+    public String standbyLocNo;//寰呮満搴撲綅
+
+    LiftCodeType(Integer liftNo, Integer code, String desc, String standbyLocNo) {
+        this.liftNo = liftNo;
+        this.code = code;
+        this.desc = desc;
+        this.standbyLocNo = standbyLocNo;
+    }
+
+    public static LiftCodeType query(Integer code) {
+        for (LiftCodeType value : LiftCodeType.values()) {
+            if (value.code.equals(code)) {
+                return value;
+            }
+        }
+        return NONE;
+    }
+
+    public static String getLocNo(Integer liftNo, Integer lev, Long hostId) {
+        LiftCodeType type = null;
+        for (LiftCodeType value : LiftCodeType.values()) {
+            if (value.liftNo.equals(liftNo)) {
+                type = value;
+                break;
+            }
+        }
+
+        if (type == null) {
+            return null;
+        }
+
+        LocService locService = SpringUtils.getBean(LocService.class);
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
+                .eq(Loc::getHostId, hostId)
+                .eq(Loc::getCode, type.code)
+                .eq(Loc::getLev, lev));
+        if (loc == null) {
+            return null;
+        }
+
+        return loc.getLocNo();
+    }
+
+
+    public static String getStandbyLocNo(Integer liftNo, Integer lev) {
+        LiftCodeType type = null;
+        for (LiftCodeType value : LiftCodeType.values()) {
+            if (value.liftNo.equals(liftNo)) {
+                type = value;
+                break;
+            }
+        }
+
+        if (type == null) {
+            return null;
+        }
+
+        return Utils.getLocNo(Utils.getRow(type.standbyLocNo), Utils.getBay(type.standbyLocNo), lev);
+    }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/TaskStsType.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/TaskStsType.java
new file mode 100644
index 0000000..6f17dec
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/TaskStsType.java
@@ -0,0 +1,49 @@
+package com.zy.asrs.wcs.core.model.enums;
+
+import com.zy.asrs.framework.exception.CoolException;
+
+public enum TaskStsType {
+
+    NEW_INBOUND(1, "鐢熸垚鍏ュ簱浠诲姟"),
+    ANALYZE_INBOUND(2, "鍏ュ簱浠诲姟瑙f瀽"),
+    EXECUTE_INBOUND(3, "鎵ц鍏ュ簱浠诲姟"),
+    COMPLETE_INBOUND(9, "鍏ュ簱瀹屾垚"),
+    SETTLE_INBOUND(10, "鍏ュ簱搴撳瓨鏇存柊"),
+
+    NEW_OUTBOUND(101, "鐢熸垚鍑哄簱浠诲姟"),
+    ANALYZE_OUTBOUND(102, "鍑哄簱浠诲姟瑙f瀽"),
+    EXECUTE_OUTBOUND(103, "鎵ц鍑哄簱浠诲姟"),
+    COMPLETE_OUTBOUND(109, "鍑哄簱瀹屾垚"),
+    SETTLE_OUTBOUND(110, "鍑哄簱搴撳瓨鏇存柊"),
+
+    NEW_CHARGE(201, "鐢熸垚鍏呯數浠诲姟"),
+    ANALYZE_CHARGE(202, "鍏呯數浠诲姟瑙f瀽"),
+    EXECUTE_CHARGE(203, "鎵ц鍏呯數浠诲姟"),
+    CHARGE_WORKING(204, "鍏呯數涓�"),
+    COMPLETE_CHARGE(210, "鍏呯數瀹屾垚"),
+
+    NEW_MOVE(301, "鐢熸垚杩佺Щ浠诲姟"),
+    ANALYZE_MOVE(302, "杩佺Щ浠诲姟瑙f瀽"),
+    EXECUTE_MOVE(303, "鎵ц杩佺Щ浠诲姟"),
+    COMPLETE_MOVE(310, "杩佺Щ瀹屾垚"),
+    ;
+
+
+    public long sts;
+    public String desc;
+
+    TaskStsType(long sts, String desc) {
+        this.sts = sts;
+        this.desc = desc;
+    }
+
+    public static TaskStsType query(Long sts) {
+        for (TaskStsType value : TaskStsType.values()) {
+            if (value.sts == sts) {
+                return value;
+            }
+        }
+        throw new CoolException("TaskStsType Error!!!");
+    }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/WorkZoneType.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/WorkZoneType.java
new file mode 100644
index 0000000..db1659e
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/WorkZoneType.java
@@ -0,0 +1,34 @@
+package com.zy.asrs.wcs.core.model.enums;
+
+import com.zy.asrs.framework.exception.CoolException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum WorkZoneType {
+
+    FIRST_ZONE(new ArrayList<Integer>(){{add(1);add(2);}}, 2, 1),
+    SECOND_ZONE(new ArrayList<Integer>(){{add(3);add(4);}}, 2, 1),
+    THIRD_ZONE(new ArrayList<Integer>(){{add(5);add(6);add(7);add(8);add(9);add(10);add(11);}}, 1, 2)
+    ;
+
+    public List<Integer> staList;
+    public Integer liftNo;
+    public Integer devpPlcId;
+
+    WorkZoneType(List<Integer> staList, Integer liftNo, Integer devpPlcId) {
+        this.staList = staList;
+        this.liftNo = liftNo;
+        this.devpPlcId = devpPlcId;
+    }
+
+    public static WorkZoneType query(String sta) {
+        for (WorkZoneType value : WorkZoneType.values()) {
+            if (value.staList.contains(String.valueOf(sta))) {
+                return value;
+            }
+        }
+        throw new CoolException("WorkZoneType Error !!!");
+    }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/TaskService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/TaskService.java
index c2647f6..37c2839 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/TaskService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/TaskService.java
@@ -2,7 +2,14 @@
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zy.asrs.wcs.core.entity.Task;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface TaskService extends IService<Task> {
 
+    Boolean judgeInbound(Task task);
+
+    Boolean hasBusyOutboundByShuttle(Integer shuttleNo);
+
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/TaskServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/TaskServiceImpl.java
index 7131f9e..9103f8f 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/TaskServiceImpl.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/TaskServiceImpl.java
@@ -1,12 +1,57 @@
 package com.zy.asrs.wcs.core.service.impl;
 
+import com.zy.asrs.framework.common.Cools;
 import com.zy.asrs.wcs.core.mapper.TaskMapper;
 import com.zy.asrs.wcs.core.entity.Task;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
+import com.zy.asrs.wcs.core.model.enums.TaskStsType;
 import com.zy.asrs.wcs.core.service.TaskService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zy.asrs.wcs.rcs.service.MotionService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 @Service("taskService")
 public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
 
+    @Autowired
+    private MotionService motionService;
+
+    @Override
+    public Boolean judgeInbound(Task task) {
+        switch (TaskStsType.query(task.getTaskSts())) {
+            case NEW_INBOUND:
+            case ANALYZE_INBOUND:
+            case EXECUTE_INBOUND:
+            case COMPLETE_INBOUND:
+            case SETTLE_INBOUND:
+                return Boolean.TRUE;
+            case NEW_OUTBOUND:
+            case ANALYZE_OUTBOUND:
+            case EXECUTE_OUTBOUND:
+            case COMPLETE_OUTBOUND:
+            case SETTLE_OUTBOUND:
+                return Boolean.FALSE;
+        }
+        return Boolean.TRUE;
+    }
+
+    @Override
+    public Boolean hasBusyOutboundByShuttle(Integer shuttleNo) {
+        List<Task> tasks = this.baseMapper.selectOutboundByShuttleNo(shuttleNo);
+        if (Cools.isEmpty(tasks)) {
+            return false;
+        }
+        for (Task task : tasks) {
+            if (task.getTaskSts().equals(TaskStsType.NEW_OUTBOUND.sts) || task.getTaskSts().equals(TaskStsType.ANALYZE_OUTBOUND.sts)) {
+                return true;
+            }
+            if (!Cools.isEmpty(motionService.selectUnCompleteByUuidAndDeviceCtg(task.getUuid(), DeviceCtgType.SHUTTLE))) {
+                return true;
+            }
+        }
+        return false;
+    }
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java
new file mode 100644
index 0000000..3b268b3
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java
@@ -0,0 +1,45 @@
+//package com.zy.asrs.wcs.core.utils;
+//
+//import com.zy.core.model.DevpSlave;
+//import com.zy.core.properties.SlaveProperties;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//
+///**
+// * Created by vincent on 2023/10/20
+// */
+//@Slf4j
+//@Service
+//public class ConveyorDispatcher {
+//
+//    @Autowired
+//    private SlaveProperties slaveProperties;
+//
+//    public DevpSlave queryByInBound(Integer staNo) {
+//        for (DevpSlave devpSlave : slaveProperties.getDevp()) {
+//            for (DevpSlave.Sta sta : devpSlave.getInSta()) {
+//                if (sta.getStaNo().equals(staNo)) {
+//                    return devpSlave;
+//                }
+//            }
+//
+//        }
+//        return null;
+//    }
+//
+//    public DevpSlave queryByOutBound(Integer staNo) {
+//        for (DevpSlave devpSlave : slaveProperties.getDevp()) {
+//            for (DevpSlave.Sta sta : devpSlave.getOutSta()) {
+//                if (sta.getStaNo().equals(staNo)) {
+//                    return devpSlave;
+//                }
+//            }
+//
+//        }
+//        return null;
+//    }
+//
+//
+//
+//}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java
new file mode 100644
index 0000000..f849ab6
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java
@@ -0,0 +1,21 @@
+package com.zy.asrs.wcs.core.utils;
+
+import com.zy.asrs.wcs.core.model.enums.WorkZoneType;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
+import com.zy.asrs.wcs.rcs.thread.LiftThread;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by vincent on 2023/10/16
+ */
+@Service
+public class LiftDispatcher {
+
+    public LiftThread queryLiftForTransport(String staNo) {
+        WorkZoneType zoneType = WorkZoneType.query(staNo);
+        LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, zoneType.liftNo);
+        return liftThread;
+    }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
new file mode 100644
index 0000000..70f77a0
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
@@ -0,0 +1,176 @@
+package com.zy.asrs.wcs.core.utils;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.common.wms.service.CommonService;
+import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.common.SnowflakeIdWorker;
+import com.zy.asrs.framework.exception.CoolException;
+import com.zy.asrs.wcs.core.entity.Task;
+import com.zy.asrs.wcs.core.kernel.AnalyzeService;
+import com.zy.asrs.wcs.core.model.NavigateNode;
+import com.zy.asrs.wcs.core.model.enums.LiftCodeType;
+import com.zy.asrs.wcs.core.model.enums.NavigationMapType;
+import com.zy.asrs.wcs.core.service.TaskService;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.entity.DeviceType;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
+import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
+import com.zy.asrs.wcs.rcs.service.DeviceService;
+import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
+import com.zy.asrs.wcs.rcs.service.MotionService;
+import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by vincent on 2023/10/12
+ */
+@Service
+public class ShuttleDispatcher {
+
+    private static final Integer INF = 9999999;
+    private static final Integer WEIGHT = 1000000;
+
+    @Autowired
+    private TaskService taskService;
+    @Autowired
+    private LiftDispatcher liftDispatcher;
+    @Autowired
+    private SnowflakeIdWorker snowflakeIdWorker;
+//    @Autowired
+//    private CommonService commonService;
+    @Autowired
+    private AnalyzeService analyzeService;
+    @Autowired
+    private MotionService motionService;
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private DeviceTypeService deviceTypeService;
+
+    public ShuttleThread queryShuttleWhichConvenient(Task task, Integer liftNo) {
+        String locNo = taskService.judgeInbound(task) ? task.getDestLoc() : task.getOriginLoc();
+        ShuttleThread resThread = null;
+        Integer finalDistance = ShuttleDispatcher.INF;
+
+        DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>()
+                .eq(DeviceType::getHostId, task.getHostId())
+                .eq(DeviceType::getStatus, 1)
+                .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)));
+        if (deviceType == null) {
+            throw new CoolException("璁惧绫诲瀷涓嶅瓨鍦�");
+        }
+
+        List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>()
+                .eq(Device::getDeviceType, deviceType.getId())
+                .eq(Device::getHostId, task.getHostId())
+                .eq(Device::getStatus, 1));
+
+        for (Device device : list) {
+            if (taskService.hasBusyOutboundByShuttle(Integer.parseInt(device.getDeviceNo()))) {
+                continue;
+            }
+            //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
+            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
+                continue;
+            }
+
+            if (!shuttleProtocol.isIdle()) {
+                continue;
+            }
+
+//            //妫�娴嬫槸鍚﹀瓨鍦ㄥ厖鐢典换鍔�
+//            WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttle.getId());
+//            if (wrkCharge != null) {
+//                continue;
+//            }
+
+            // 鏈夋病鏈夎鍏朵粬浠诲姟璋冨害
+            int currentLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//灏忚溅褰撳墠灞傞珮
+            String currentLocNo = shuttleProtocol.getCurrentLocNo();//灏忚溅褰撳墠搴撲綅鍙�
+
+            if (currentLocNo.equals(locNo)) {
+                resThread = shuttleThread;
+                break;
+            }
+
+            String targetLocNo = LiftCodeType.getStandbyLocNo(liftNo, currentLev);//榛樿鍒版彁鍗囨満寰呮満浣�
+            // 鍚屾ゼ灞傜洿鎺ヨ绠楀埌鐩爣搴撲綅
+            if (currentLev == Utils.getLev(locNo)) {
+                targetLocNo = locNo;
+            }
+
+            //褰撳墠绌挎杞︾嚎绋嬪埌褰撳墠杞﹀瓙鎵�鍦ㄦゼ灞傜殑鎻愬崌鏈哄彛璺濈
+            List<NavigateNode> currentShuttlePath = NavigateUtils.calc(
+                    currentLocNo
+                    , targetLocNo
+                    , NavigationMapType.NORMAL.id
+                    , Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), currentLev)
+            );//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
+            if (currentShuttlePath == null) {
+                continue;
+            }
+
+            Integer currDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+
+            // 涓嶅悓妤煎眰鏉冮噸
+            if (currentLev != Utils.getLev(locNo)) {
+                currDistance += WEIGHT;
+            }
+
+//            // 鎸傝浇浠诲姟鏉冮噸
+//            List<Task> tasks = taskService.selectWorkingByShuttle(shuttle.getId());
+//            if (!Cools.isEmpty(tasks)) {
+//                currDistance += tasks.size() * WEIGHT;
+//            }
+
+            if (currDistance < finalDistance) {
+                finalDistance = currDistance;
+                resThread = shuttleThread;
+            }
+        }
+
+        return resThread;
+    }
+
+//    /**
+//     * 鐢熸垚绌挎杞﹁縼绉讳换鍔�
+//     */
+//    public WrkCharge generateShuttleChargeWrkComplete(Integer shuttleNo, String locNo) {
+//        WrkCharge wrkCharge = new WrkCharge();
+//        wrkCharge.setShuttleNo(shuttleNo);
+//        wrkCharge.setWrkNo(commonService.getChargeWorkNo(4));
+//        wrkCharge.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
+//        wrkCharge.setWrkSts(WrkMastStsType.NEW_MOVE.sts);   // 杩佺Щ浠诲姟
+//        wrkCharge.setIoType(WrkIoTypeType.MOVE.sts);
+//        wrkCharge.setIoPri((double) 10);
+//        wrkCharge.setLocNo(locNo);
+//        wrkCharge.setMemo("reset");
+//        wrkCharge.setAppeTime(new Date());
+//
+//        // generate motion list
+//        List<Motion> motionList = analyzeService.generateShuttleChargeWrkComplete(wrkCharge);
+//        if (Cools.isEmpty(motionList)) {
+//            News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅杩佺Щ浠诲姟澶辫触!!!", shuttleNo);
+//            return null;
+//        }
+//        motionService.batchInsert(motionList, wrkCharge.getUuid(), wrkCharge.getWrkNo());
+//
+//        wrkCharge.setWrkSts(WrkMastStsType.ANALYZE_MOVE.sts);
+//
+//        if (!wrkChargeService.insert(wrkCharge)) {
+//            News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅杩佺Щ浠诲姟澶辫触!!!", shuttleNo);
+//            return null;
+//        }
+//
+//        return wrkCharge;
+//    }
+
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/Motion.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/Motion.java
index 1aeec03..d508c7b 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/Motion.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/Motion.java
@@ -3,7 +3,9 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import com.zy.asrs.wcs.core.BuildSupport;
 import com.zy.asrs.wcs.core.entity.DeviceCtg;
+import com.zy.asrs.wcs.core.model.enums.MotionStsType;
 import com.zy.asrs.wcs.core.service.DeviceCtgService;
 import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
 import com.zy.asrs.wcs.rcs.service.MotionCtgService;
@@ -273,6 +275,25 @@
         this.hostId = hostId;
     }
 
+    public static Motion build(BuildSupport<Motion> support) {
+        Motion motion = new Motion();
+        Date date = new Date();
+
+        support.execute(motion);
+
+        if (null == motion.getSync()) {
+            motion.setSync(1);
+        }
+        if (null == motion.getMotionSts()) {
+            motion.setMotionSts(MotionStsType.INIT.val());
+        }
+
+        motion.setStatus(1);
+        motion.setCreateTime(date);
+        motion.setUpdateTime(date);
+        return motion;
+    }
+
 //    Motion motion = new Motion(
 //            null,    // 缂栧彿
 //            null,    // 浠诲姟鍙�
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
index d9a3147..9bf65b6 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
@@ -249,4 +249,23 @@
         return currentLoc.getLocNo();
     }
 
+    // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵��
+    public Boolean isIdle() {
+        if (this.deviceStatus == null
+                || this.pakMk == null
+                || this.errorCode == null
+                || this.protocolStatus == null
+        ) {
+            return false;
+        }
+
+        boolean res = this.deviceStatus.equals(ShuttleDeviceStatusType.IDLE)
+                && this.pakMk
+                && !this.errorCode.equals("0")
+                && this.getTaskNo() == 0
+                && this.protocolStatus.intValue() == ShuttleProtocolStatusType.IDLE.id
+                ;
+        return res;
+    }
+
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/MotionService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/MotionService.java
index 5b20073..8bf4ae8 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/MotionService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/MotionService.java
@@ -1,8 +1,13 @@
 package com.zy.asrs.wcs.rcs.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
 import com.zy.asrs.wcs.rcs.entity.Motion;
 
+import java.util.List;
+
 public interface MotionService extends IService<Motion> {
 
+    List<Motion> selectUnCompleteByUuidAndDeviceCtg(String uuid, DeviceCtgType deviceCtgType);
+
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/MotionServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/MotionServiceImpl.java
index 3180bb0..57df7a0 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/MotionServiceImpl.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/service/impl/MotionServiceImpl.java
@@ -1,12 +1,34 @@
 package com.zy.asrs.wcs.rcs.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
+import com.zy.asrs.wcs.core.model.enums.MotionStsType;
+import com.zy.asrs.wcs.core.service.DeviceCtgService;
 import com.zy.asrs.wcs.rcs.mapper.MotionMapper;
 import com.zy.asrs.wcs.rcs.entity.Motion;
 import com.zy.asrs.wcs.rcs.service.MotionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zy.asrs.wcs.rcs.service.MotionStsService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 @Service("motionService")
 public class MotionServiceImpl extends ServiceImpl<MotionMapper, Motion> implements MotionService {
 
+    @Autowired
+    private DeviceCtgService deviceCtgService;
+    @Autowired
+    private MotionStsService motionStsService;
+
+    @Override
+    public List<Motion> selectUnCompleteByUuidAndDeviceCtg(String uuid, DeviceCtgType deviceCtgType) {
+        return this.list(new LambdaQueryWrapper<Motion>()
+                .eq(Motion::getUuid, uuid)
+                .eq(Motion::getDeviceCtg, deviceCtgService.selectByFlag(deviceCtgType.toString()).getId())
+                .lt(Motion::getMotionSts, motionStsService.selectByFlag(MotionStsType.COMPLETE.toString()).getId())
+                .orderByDesc(Motion::getPriority)
+        );
+    }
 }
diff --git a/zy-asrs-wcs/src/main/resources/mapper/core/TaskMapper.xml b/zy-asrs-wcs/src/main/resources/mapper/core/TaskMapper.xml
index 283c334..dd069ab 100644
--- a/zy-asrs-wcs/src/main/resources/mapper/core/TaskMapper.xml
+++ b/zy-asrs-wcs/src/main/resources/mapper/core/TaskMapper.xml
@@ -2,4 +2,12 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zy.asrs.wcs.core.mapper.TaskMapper">
 
+    <select id="selectOutboundByShuttleNo" resultType="com.zy.asrs.wcs.core.entity.Task">
+        select * from wcs_task
+        where 1=1
+        and task_sts in (101, 102, 103)
+        and shuttle_no = #{shuttleNo}
+        order by priority desc,start_time,task_no asc
+    </select>
+
 </mapper>

--
Gitblit v1.9.1