zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -1,5 +1,6 @@ package com.zy.asrs.wcs.core.kernel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.wcs.core.domain.dto.MotionDto; import com.zy.asrs.wcs.core.entity.Task; @@ -12,9 +13,13 @@ import com.zy.asrs.wcs.core.utils.Utils; import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.core.entity.Motion; 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.core.service.MotionService; import com.zy.asrs.wcs.rcs.service.DeviceService; import com.zy.asrs.wcs.rcs.service.DeviceTypeService; import com.zy.asrs.wcs.rcs.thread.ShuttleThread; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -40,8 +45,12 @@ private ShuttleDispatcher shuttleDispatcher; @Autowired private LiftDispatcher liftDispatcher; // @Autowired // @Autowired // private ConveyorDispatcher conveyorDispatcher; @Autowired private DeviceService deviceService; @Autowired private DeviceTypeService deviceTypeService; public List<Motion> generateMotion(Task task) { List<Motion> motionList = new ArrayList<>(); @@ -912,6 +921,67 @@ return motionList; } /** * 生成小车迁移动作 */ public List<Motion> generateShuttleMoveMotion(Task task) { List<Motion> motionList = new ArrayList<>(); if (task.getTaskSts() != TaskStsType.NEW_MOVE.sts) { return motionList; } // locNo String locNo = task.getDestLoc(); //获取穿梭车类型 DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) .eq(DeviceType::getStatus, 1)); if (deviceType == null) { return motionList; } Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() .eq(Device::getDeviceNo, task.getShuttleNo()) .eq(Device::getDeviceType, deviceType.getId()) .eq(Device::getHostId, task.getHostId()) .eq(Device::getStatus, 1)); if (device == null) { return motionList; } ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); if (shuttleThread == null) { return motionList; } ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); 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; } } zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
@@ -7,13 +7,18 @@ import com.zy.asrs.framework.common.SnowflakeIdWorker; import com.zy.asrs.framework.exception.CoolException; import com.zy.asrs.wcs.core.entity.BasShuttle; import com.zy.asrs.wcs.core.entity.Motion; import com.zy.asrs.wcs.core.entity.Task; import com.zy.asrs.wcs.core.entity.TaskCtg; 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.model.enums.TaskStsType; import com.zy.asrs.wcs.core.service.BasShuttleService; import com.zy.asrs.wcs.core.service.TaskCtgService; import com.zy.asrs.wcs.core.service.TaskService; import com.zy.asrs.wcs.rcs.News; import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.rcs.entity.Device; import com.zy.asrs.wcs.rcs.entity.DeviceType; @@ -26,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; /** @@ -55,6 +61,8 @@ private DeviceTypeService deviceTypeService; @Autowired private BasShuttleService basShuttleService; @Autowired private TaskCtgService taskCtgService; public ShuttleThread queryShuttleWhichConvenient(Task task, Integer liftNo) { String locNo = taskService.judgeInbound(task) ? task.getDestLoc() : task.getOriginLoc(); @@ -143,6 +151,63 @@ return resThread; } //生成迁移任务 public synchronized Task generateMoveTask(Device device, String locNo) { // 已有迁移任务 if (taskService.selectMoveWorking(Integer.valueOf(device.getDeviceNo())) != null) { return null; } //获取迁移任务类型 TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>() .eq(TaskCtg::getFlag, "MOVE") .eq(TaskCtg::getStatus, 1)); if (taskCtg == null) { return null; } ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); if (shuttleThread == null) { return null; } //获取避让位置 String standByLocNo = this.searchStandByLocNo(Integer.valueOf(device.getDeviceNo()), device.getHostId(), shuttleThread.getStatus().getCurrentLocNo()); Task task = new Task(); task.setUuid(String.valueOf(snowflakeIdWorker.nextId())); task.setTaskNo(String.valueOf(Utils.getTaskNo("MOVE"))); task.setTaskSts(TaskStsType.NEW_MOVE.sts); task.setTaskCtg(taskCtg.getId()); task.setPriority(10); task.setOriginSite(null); task.setOriginLoc(null); task.setDestSite(null); task.setDestLoc(standByLocNo); // 避让位置 task.setIoTime(new Date()); task.setStartTime(new Date()); task.setHostId(device.getHostId()); task.setStatus(1); task.setShuttleNo(Integer.valueOf(device.getDeviceNo())); // generate motion list List<Motion> motionList = analyzeService.generateShuttleMoveMotion(task); if (Cools.isEmpty(motionList)) { News.error("保存{}号四向穿梭车迁移任务失败!!!", device.getDeviceNo()); return null; } motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); task.setTaskSts(TaskStsType.ANALYZE_MOVE.sts); if (!taskService.save(task)) { News.error("保存{}号四向穿梭车迁移任务失败!!!", device.getDeviceNo()); return null; } return task; } /** * 搜索避让库位,通过小车号和目标库位 */