| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.zy.asrs.entity.BasMap; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.entity.LocMast; |
| | |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.MapNode; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.model.enums.NavigationMapType; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.MapNodeType; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.ShuttleCommandModeType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.TrafficControlDataModel; |
| | | import com.zy.core.model.command.ShuttleAssignCommand; |
| | | import com.zy.core.model.command.ShuttleCommand; |
| | | import com.zy.core.model.command.ShuttleRedisCommand; |
| | | import com.zy.core.model.protocol.ForkLiftStaProtocol; |
| | | import com.zy.core.thread.ForkLiftThread; |
| | | import com.zy.core.thread.TrafficControlThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | | private BasMapService basMapService; |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | |
| | | public int[][] getData(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | |
| | | if(mapType.equals(NavigationMapType.PATH_LOCK)) { |
| | | //加载路径锁 |
| | | lists = loadPathLock(lists, lev); |
| | | } |
| | | |
| | | if(mapType.equals(NavigationMapType.TRAFFIC_CONTROL)) { |
| | | //加载交通管制 |
| | | lists = loadTrafficControl(lists, lev); |
| | | } |
| | | } |
| | | |
| | |
| | | return lists; |
| | | } |
| | | |
| | | //加载交通管制 |
| | | public List<List<MapNode>> loadTrafficControl(List<List<MapNode>> lists, Integer lev) { |
| | | try { |
| | | TrafficControlThread trafficControlThread = (TrafficControlThread) SlaveConnection.get(SlaveType.TrafficControl, 1); |
| | | if (trafficControlThread == null) { |
| | | throw new CoolException("init traffic control thread error"); |
| | | } |
| | | |
| | | List<TrafficControlDataModel> trafficList = trafficControlThread.getAllTrafficControl(); |
| | | for (TrafficControlDataModel trafficControlDataModel : trafficList) { |
| | | List<NavigateNode> totalNodeList = trafficControlDataModel.getTotalNodeList(); |
| | | NavigateNode startNode = totalNodeList.get(0); |
| | | if (startNode.getZ() != lev) { |
| | | continue; |
| | | } |
| | | |
| | | for (NavigateNode node : totalNodeList) { |
| | | int row = node.getX(); |
| | | int bay = node.getY(); |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | //节点设置成Disable |
| | | mapNode.setValue(MapNodeType.DISABLE.id); |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | } |
| | | } |
| | | |
| | | // HashMap<String, Integer> deviceMap = trafficControlThread.getDeviceMap(); |
| | | // if(deviceMap == null) { |
| | | // throw new CoolException("get traffic control device map error"); |
| | | // } |
| | | // |
| | | // for (Map.Entry<String, Integer> entry : deviceMap.entrySet()) { |
| | | // String key = entry.getKey(); |
| | | // Integer shuttleNo = entry.getValue(); |
| | | // if (shuttleNo <= 0) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // Object object = redisUtil.get(RedisKeyType.SHUTTLE_FLAG.key + shuttleNo); |
| | | // if (object == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // int taskNo = Integer.parseInt(String.valueOf(object)); |
| | | // |
| | | // Object obj = redisUtil.get(RedisKeyType.SHUTTLE_WORK_FLAG.key + taskNo); |
| | | // if (obj == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // ShuttleRedisCommand redisCommand = null; |
| | | // try { |
| | | // redisCommand = objectMapper.readValue(String.valueOf(obj), ShuttleRedisCommand.class); |
| | | // } catch (IOException e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // |
| | | // if (redisCommand == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand(); |
| | | // List<ShuttleCommand> commands = assignCommand.getCommands(); |
| | | // |
| | | // List<NavigateNode> controlLocList = new ArrayList<>(); |
| | | // for (ShuttleCommand command : commands) { |
| | | // if (command.getComplete()) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // if (command.getMode() == ShuttleCommandModeType.MOVE.id) { |
| | | // List<NavigateNode> nodes = command.getNodes(); |
| | | // for (NavigateNode node : nodes) { |
| | | // if(!controlLocList.contains(node)) { |
| | | // controlLocList.add(node); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // for (NavigateNode node : controlLocList) { |
| | | // int row = node.getX(); |
| | | // int bay = node.getY(); |
| | | // |
| | | // List<MapNode> list = lists.get(row); |
| | | // MapNode mapNode = list.get(bay); |
| | | // |
| | | // //节点设置成Disable |
| | | // mapNode.setValue(MapNodeType.DISABLE.id); |
| | | // |
| | | // //更新list |
| | | // list.set(bay, mapNode); |
| | | // lists.set(row, list); |
| | | // } |
| | | // |
| | | // } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return lists; |
| | | } |
| | | |
| | | } |