|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取除白名单外的指定楼层全部穿梭车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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("工作号生成失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 检测穿梭车是否有任务绑定 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkShuttleHasBinding(Device device) { | 
|---|
|  |  |  | TaskService taskService = SpringUtils.getBean(TaskService.class); | 
|---|
|  |  |  | List<Task> tasks = taskService.selectWorkingByShuttle(Integer.parseInt(device.getDeviceNo())); | 
|---|
|  |  |  | if (tasks.isEmpty()) { | 
|---|
|  |  |  | return false;//无任务绑定 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return true;//有任务绑定 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 检测提升机是否有任务绑定 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static boolean checkLiftHasBinding(Integer liftNo) { | 
|---|
|  |  |  | TaskService taskService = SpringUtils.getBean(TaskService.class); | 
|---|
|  |  |  | List<Task> tasks = taskService.selectWorkingByLift(liftNo); | 
|---|
|  |  |  | if (tasks.isEmpty()) { | 
|---|
|  |  |  | return false;//无任务绑定 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return true;//有任务绑定 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取距离目标库位最近的提升机 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Device getRecentTransferLift(String locNo, Integer shuttleNo) { | 
|---|
|  |  |  | BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class); | 
|---|
|  |  |  | DeviceService deviceService = SpringUtils.getBean(DeviceService.class); | 
|---|
|  |  |  | if (basLiftService == null) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer distance = Integer.MAX_VALUE; | 
|---|
|  |  |  | Long liftDeviceId = null; | 
|---|
|  |  |  | for (BasLift basLift : basLiftService.list(new LambdaQueryWrapper<BasLift>() | 
|---|
|  |  |  | .eq(BasLift::getStatus, 1) | 
|---|
|  |  |  | .eq(BasLift::getTransfer, 1))) { | 
|---|
|  |  |  | int lev = Utils.getLev(locNo); | 
|---|
|  |  |  | String liftLocNo = Utils.getLocNo(basLift.getRow(), basLift.getBay(), lev); | 
|---|
|  |  |  | List<NavigateNode> nodeList = NavigateUtils.calc(locNo, liftLocNo, NavigationMapType.NONE.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(locNo))); | 
|---|
|  |  |  | Integer originPathAllDistance = NavigateUtils.getOriginPathAllDistance(nodeList);//总距离 | 
|---|
|  |  |  | if (originPathAllDistance < distance) { | 
|---|
|  |  |  | distance = originPathAllDistance; | 
|---|
|  |  |  | liftDeviceId = basLift.getDeviceId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (liftDeviceId == null) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Device device = deviceService.getById(liftDeviceId); | 
|---|
|  |  |  | if (device == null) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return device; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|