| | |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.entity.BasLift; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.entity.TaskSerialNo; |
| | | import com.zy.asrs.wcs.core.model.NavigateNode; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.NavigationMapType; |
| | | import com.zy.asrs.wcs.core.service.BasLiftService; |
| | | import com.zy.asrs.wcs.core.service.TaskSerialNoService; |
| | | 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.ShuttleProtocolStatusType; |
| | | 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.thread.ShuttleThread; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | //获取除白名单外的指定楼层全部穿梭车xy坐标点 |
| | | public static List<int[]> getShuttlePoints(Integer whiteShuttle, Integer lev) { |
| | | // SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); |
| | | DeviceService deviceService = SpringUtils.getBean(DeviceService.class); |
| | | ArrayList<int[]> list = new ArrayList<>(); |
| | | // for (ShuttleSlave slave : slaveProperties.getShuttle()) { |
| | | // if (slave.getId().intValue() == whiteShuttle) { |
| | | // continue;//跳过白名单 |
| | | // } |
| | | // |
| | | // //获取穿梭车所在节点位置 |
| | | // ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); |
| | | // if (shuttleThread == null) { |
| | | // continue; |
| | | // } |
| | | // ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | // if (shuttleProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // if (shuttleProtocol.getCurrentLocNo() == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // if (lev != Utils.getLev(shuttleProtocol.getCurrentLocNo())) { |
| | | // continue;//楼层不同 |
| | | // } |
| | | // |
| | | // int[] xyPosition = NavigatePositionConvert.positionToXY(shuttleProtocol.getCurrentLocNo());//通过库位号获取xy坐标 |
| | | // list.add(xyPosition); |
| | | // } |
| | | |
| | | List<Device> devices = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getStatus, 1)); |
| | | for (Device device : devices) { |
| | | if (Integer.parseInt(device.getDeviceNo()) == whiteShuttle) { |
| | | continue;//跳过白名单 |
| | | } |
| | | |
| | | //获取穿梭车所在节点位置 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (shuttleProtocol.getCurrentLocNo() == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (lev != Utils.getLev(shuttleProtocol.getCurrentLocNo())) { |
| | | continue;//楼层不同 |
| | | } |
| | | |
| | | int[] xyPosition = NavigatePositionConvert.positionToXY(shuttleProtocol.getCurrentLocNo());//通过库位号获取xy坐标 |
| | | list.add(xyPosition); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public static boolean hasShuttleInLoc(String locNo, Long deviceId) { |
| | | DeviceTypeService deviceTypeService = SpringUtils.getBean(DeviceTypeService.class); |
| | | DeviceService deviceService = SpringUtils.getBean(DeviceService.class); |
| | | |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return false; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Device::getStatus, 1)); |
| | | |
| | | for (Device device : list) { |
| | |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.OFFLINE)) { |
| | | continue; |
| | | } |
| | | |
| | | if (shuttleProtocol.getCurrentLocNo() == null) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | throw new CoolException("工作号生成失败"); |
| | | } |
| | | |
| | | /** |
| | | * 检测穿梭车是否有任务绑定 |
| | | */ |
| | | public static boolean checkShuttleHasBinding(Device device, String taskNo) { |
| | | TaskService taskService = SpringUtils.getBean(TaskService.class); |
| | | List<Task> tasks = taskService.selectWorkingByShuttle(Integer.parseInt(device.getDeviceNo()), taskNo); |
| | | if (tasks.isEmpty()) { |
| | | return false;//无任务绑定 |
| | | } |
| | | return true;//有任务绑定 |
| | | } |
| | | |
| | | /** |
| | | * 检测提升机是否有任务绑定 |
| | | */ |
| | | public static boolean checkLiftHasBinding(Integer liftNo) { |
| | | return checkLiftHasBinding(liftNo, null); |
| | | } |
| | | |
| | | /** |
| | | * 检测提升机是否有任务绑定 |
| | | */ |
| | | public static boolean checkLiftHasBinding(Integer liftNo, String taskNo) { |
| | | TaskService taskService = SpringUtils.getBean(TaskService.class); |
| | | List<Task> tasks = taskService.selectWorkingByLift(liftNo, taskNo); |
| | | if (tasks.isEmpty()) { |
| | | return false;//无任务绑定 |
| | | } |
| | | return true;//有任务绑定 |
| | | } |
| | | |
| | | } |