|  |  | 
 |  |  | import com.core.common.Arith; | 
 |  |  | import com.core.common.Cools; | 
 |  |  | import com.core.common.SpringUtils; | 
 |  |  | import com.zy.asrs.entity.DeviceConfig; | 
 |  |  | import com.zy.asrs.entity.LocMast; | 
 |  |  | import com.zy.asrs.entity.WrkMast; | 
 |  |  | import com.zy.asrs.service.DeviceConfigService; | 
 |  |  | import com.zy.asrs.service.LocMastService; | 
 |  |  | import com.zy.asrs.service.WrkMastService; | 
 |  |  | import com.zy.common.model.NavigateNode; | 
 |  |  | import com.zy.common.model.enums.NavigationMapType; | 
 |  |  | import com.zy.common.utils.NavigatePositionConvert; | 
 |  |  | import com.zy.common.utils.NavigateUtils; | 
 |  |  | import com.zy.core.cache.SlaveConnection; | 
 |  |  | import com.zy.core.enums.SlaveType; | 
 |  |  | import com.zy.core.model.ShuttleSlave; | 
 |  |  | import com.zy.core.model.protocol.ShuttleProtocol; | 
 |  |  | import com.zy.core.properties.SlaveProperties; | 
 |  |  | import com.zy.core.thread.ShuttleThread; | 
 |  |  | import java.text.DecimalFormat; | 
 |  |  | import java.util.*; | 
 |  |  | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //获取除白名单外的指定楼层全部穿梭车xy坐标点 | 
 |  |  |     //获取穿梭车xy坐标点 | 
 |  |  |     public static int[] getShuttlePoint(Integer shuttleNo) { | 
 |  |  |         //获取穿梭车所在节点位置 | 
 |  |  |         ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); | 
 |  |  | 
 |  |  |  | 
 |  |  |     //获取除白名单外的指定楼层全部穿梭车xy坐标点 | 
 |  |  |     public static List<int[]> getShuttlePoints(Integer whiteShuttle, Integer lev) { | 
 |  |  |         SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); | 
 |  |  |         DeviceConfigService deviceConfigService = SpringUtils.getBean(DeviceConfigService.class); | 
 |  |  |         ArrayList<int[]> list = new ArrayList<>(); | 
 |  |  |         for (ShuttleSlave slave : slaveProperties.getShuttle()) { | 
 |  |  |             if (slave.getId().intValue() == whiteShuttle) { | 
 |  |  |  | 
 |  |  |         List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() | 
 |  |  |                 .eq("device_type", String.valueOf(SlaveType.Shuttle))); | 
 |  |  |         for (DeviceConfig device : shuttleList) { | 
 |  |  |             if (device.getDeviceNo().intValue() == whiteShuttle) { | 
 |  |  |                 continue;//跳过白名单 | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //获取穿梭车所在节点位置 | 
 |  |  |             ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); | 
 |  |  |             ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); | 
 |  |  |             if (shuttleThread == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  | 
 |  |  |         return list; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //检测楼层是否有穿梭车 | 
 |  |  |     public static ShuttleThread searchShuttle(String locNo) { | 
 |  |  |         DeviceConfigService deviceConfigService = SpringUtils.getBean(DeviceConfigService.class); | 
 |  |  |         List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() | 
 |  |  |                 .eq("device_type", String.valueOf(SlaveType.Shuttle))); | 
 |  |  |         for (DeviceConfig device : shuttleList) { | 
 |  |  |             //获取穿梭车所在节点位置 | 
 |  |  |             ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); | 
 |  |  |             if (shuttleThread == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); | 
 |  |  |             if (shuttleProtocol == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             String currentLocNo = shuttleProtocol.getCurrentLocNo(); | 
 |  |  |             if (currentLocNo == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (currentLocNo.equals(locNo)) { | 
 |  |  |                 return shuttleThread; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //检测楼层是否有可用穿梭车 | 
 |  |  |     public static boolean checkLevHasShuttle(Integer lev) { | 
 |  |  |         SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); | 
 |  |  |         for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { | 
 |  |  |         DeviceConfigService deviceConfigService = SpringUtils.getBean(DeviceConfigService.class); | 
 |  |  |         WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class); | 
 |  |  |  | 
 |  |  |         List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() | 
 |  |  |                 .eq("device_type", String.valueOf(SlaveType.Shuttle))); | 
 |  |  |         for (DeviceConfig device : shuttleList) { | 
 |  |  |             //获取四向穿梭车线程 | 
 |  |  |             ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); | 
 |  |  |             ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); | 
 |  |  |             if (shuttleThread == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  | 
 |  |  |             } | 
 |  |  |             String currentLocNo = shuttleProtocol.getCurrentLocNo(); | 
 |  |  |             if (currentLocNo == null) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //小车正在充电 | 
 |  |  |             if (shuttleThread.isCharging()) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //小车有充电任务 | 
 |  |  |             WrkMast chargeWorking = wrkMastService.selectChargeWorking(shuttleProtocol.getShuttleNo()); | 
 |  |  |             if (chargeWorking != null) {//已有充电任务 | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             //小车处于故障状态 | 
 |  |  |             if (shuttleThread.isFault()) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class); | 
 |  |  |         if (slaveProperties == null) { | 
 |  |  |         DeviceConfigService deviceConfigService = SpringUtils.getBean(DeviceConfigService.class); | 
 |  |  |         if (deviceConfigService == null) { | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() | 
 |  |  |                 .eq("device_type", String.valueOf(SlaveType.Shuttle))); | 
 |  |  |  | 
 |  |  |         for (String loc : groupLoc) { | 
 |  |  |             for (ShuttleSlave slave : slaveProperties.getShuttle()) { | 
 |  |  |                 ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); | 
 |  |  |             for (DeviceConfig device : shuttleList) { | 
 |  |  |                 ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo()); | 
 |  |  |                 if (shuttleThread == null) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  | 
 |  |  |  | 
 |  |  |                 if (shuttleProtocol.getCurrentLocNo().equals(loc)) { | 
 |  |  |                     //存在小车 | 
 |  |  |                     return slave.getId(); | 
 |  |  |                     return device.getDeviceNo(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  | 
 |  |  |         String recentLocNo = null; | 
 |  |  |         for (LocMast locMast : locMasts) { | 
 |  |  |             //待机位到目标点距离 | 
 |  |  |             List<NavigateNode> currentShuttlePath = navigateUtils.calc(locNo, locMast.getLocNo(), NavigationMapType.NORMAL.id, Utils.getShuttlePoints(0, Utils.getLev(locNo)), null);//搜索空闲穿梭车,使用正常通道地图 | 
 |  |  |             List<NavigateNode> currentShuttlePath = navigateUtils.calc(locNo, locMast.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), Utils.getShuttlePoints(0, Utils.getLev(locNo)), null);//搜索空闲穿梭车,使用正常通道地图 | 
 |  |  |             if (currentShuttlePath == null) { | 
 |  |  |                 continue; | 
 |  |  |             } |