| 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.core.entity.Motion; | 
| import com.zy.asrs.wcs.core.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; | 
|     } | 
|   | 
| } |