| | |
| | | package com.zy.common.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasMap; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | 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.ShuttleTaskModeType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.ForkLiftSlave; |
| | | import com.zy.core.model.protocol.ForkLiftStaProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.ForkLiftThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Component |
| | | public class NavigateMapData { |
| | | |
| | | // private Integer lev;//地图楼层 |
| | | // |
| | | // public Integer getLev() { |
| | | // return lev; |
| | | // } |
| | | // |
| | | // public void setLev(Integer lev) { |
| | | // this.lev = lev; |
| | | // } |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | public int[][] getData(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | |
| | | |
| | | //过滤数据 |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | //获取当前楼层库位数据 |
| | | List<LocMast> locMasts = locMastService.selectLocByLev(lev); |
| | | for (LocMast locMast : locMasts) { |
| | | Integer row = locMast.getRow1(); |
| | | Integer bay = locMast.getBay1(); |
| | | try { |
| | | //获取当前楼层库位数据 |
| | | List<LocMast> locMasts = locMastService.selectLocByLev(lev); |
| | | for (LocMast locMast : locMasts) { |
| | | Integer row = locMast.getRow1(); |
| | | Integer bay = locMast.getBay1(); |
| | | |
| | | boolean whiteFlag = false;//默认不存在白名单 |
| | | if (whitePoints != null) { |
| | | for (int[] whitePoint : whitePoints) { |
| | | if (whitePoint[0] == row && whitePoint[1] == bay) { |
| | | //存在白名单 |
| | | whiteFlag = true; |
| | | break; |
| | | boolean whiteFlag = false;//默认不存在白名单 |
| | | if (whitePoints != null) { |
| | | for (int[] whitePoint : whitePoints) { |
| | | if (whitePoint[0] == row && whitePoint[1] == bay) { |
| | | //存在白名单 |
| | | whiteFlag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (whiteFlag) { |
| | | continue;//存在白名单,不执行下列过滤方案 |
| | | } |
| | | |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.NONE.id) { |
| | | //不过滤任何数据 |
| | | } else if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | //读取对应库位数据,将DFX库位状态的节点置为-1(障碍物) |
| | | if (locMast.getLocSts().equals("F") |
| | | || locMast.getLocSts().equals("D") |
| | | || locMast.getLocSts().equals("X") |
| | | || locMast.getLocSts().equals("R") |
| | | || locMast.getLocSts().equals("P") |
| | | ) { |
| | | mapNode.setValue(-1);//禁用节点 |
| | | if (whiteFlag) { |
| | | continue;//存在白名单,不执行下列过滤方案 |
| | | } |
| | | } else if (mapType == NavigationMapType.NORMAL.id) { |
| | | //过滤库位状态X |
| | | if (locMast.getLocSts().equals("X")) { |
| | | mapNode.setValue(-1);//禁用节点 |
| | | } |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.NONE.id) { |
| | | //不过滤任何数据 |
| | | } else if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | //读取对应库位数据,将DFX库位状态的节点置为-1(障碍物) |
| | | if (locMast.getLocSts().equals("F") |
| | | || locMast.getLocSts().equals("D") |
| | | || locMast.getLocSts().equals("X") |
| | | || locMast.getLocSts().equals("R") |
| | | || locMast.getLocSts().equals("P") |
| | | ) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 |
| | | } |
| | | } else if (mapType == NavigationMapType.NORMAL.id) { |
| | | //过滤库位状态X |
| | | if (locMast.getLocSts().equals("X")) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 |
| | | } |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | } |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | //加载车辆坐标到地图中 |
| | |
| | | int y = points[1]; |
| | | List<MapNode> list = lists.get(x); |
| | | MapNode mapNode = list.get(y); |
| | | mapNode.setValue(66);//设置为车辆代码66 |
| | | mapNode.setValue(MapNodeType.CAR.id);//设置为车辆代码66 |
| | | //更新list |
| | | list.set(y, mapNode); |
| | | lists.set(x, list); |
| | |
| | | } |
| | | } |
| | | |
| | | try { |
| | | //加载货叉提升机放货点位数据 |
| | | for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) { |
| | | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, forkLiftSlave.getId()); |
| | | if (forkLiftThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | for (ForkLiftStaProtocol staProtocol : forkLiftThread.getForkLiftStaProtocols()) { |
| | | int row = Utils.getRow(staProtocol.getLocNo()); |
| | | int bay = Utils.getBay(staProtocol.getLocNo()); |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | if (staProtocol.getHasTray() != null && staProtocol.getHasTray()) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id); |
| | | } |
| | | }else { |
| | | if (staProtocol.getHasCar() != null && staProtocol.getHasCar()) { |
| | | mapNode.setValue(MapNodeType.CAR.id); |
| | | } |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | } |
| | | |
| | | } |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return lists; |
| | | } |
| | | |