|  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.BasMap; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.SpringUtils; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.domain.dto.BasMapDto; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.domain.dto.RedisMapDto; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.entity.Loc; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.model.MapNode; | 
|---|
|  |  |  | 
|---|
|  |  |  | private LocService locService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DictService dictService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NavigateMapData navigateMapData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Integer lev;//地图楼层 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * 尝试从redis获取数据 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public int[][] getDataFromRedis(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { | 
|---|
|  |  |  | String constantMap = DeviceRedisConstant.MAP; | 
|---|
|  |  |  | if(mapType == NavigationMapType.NONE_LOCK.id){ | 
|---|
|  |  |  | constantMap = DeviceRedisConstant.BASE_MAP; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); | 
|---|
|  |  |  | Object o = redisUtil.get(DeviceRedisConstant.MAP + lev); | 
|---|
|  |  |  | Object o = redisUtil.get(constantMap + lev); | 
|---|
|  |  |  | if (o == null) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BasMap basMap = JSON.parseObject(o.toString(), BasMap.class); | 
|---|
|  |  |  | return this.getDataFormString(basMap.getData(), mapType, whitePoints, shuttlePoints); | 
|---|
|  |  |  | BasMapDto basMap = JSON.parseObject(o.toString(), BasMapDto.class); | 
|---|
|  |  |  | String mapData = basMap.getData(); | 
|---|
|  |  |  | return this.getDataFormString(mapData, mapType, whitePoints, shuttlePoints); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BasMap basMap = JSON.parseObject(o.toString(), BasMap.class); | 
|---|
|  |  |  | BasMapDto basMap = JSON.parseObject(o.toString(), BasMapDto.class); | 
|---|
|  |  |  | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); | 
|---|
|  |  |  | List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 | 
|---|
|  |  |  | return lists; | 
|---|
|  |  |  | 
|---|
|  |  |  | lists.add(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取严格模式参数 | 
|---|
|  |  |  | boolean mapStrict = true;//默认严格模式 | 
|---|
|  |  |  | Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, "shuttleMapStrict")); | 
|---|
|  |  |  | if (dict != null) { | 
|---|
|  |  |  | mapStrict = Boolean.parseBoolean(dict.getValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //过滤数据 | 
|---|
|  |  |  | //获取当前楼层库位数据 | 
|---|
|  |  |  | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>() | 
|---|
|  |  |  | .eq(Loc::getLev, lev) | 
|---|
|  |  |  | .eq(Loc::getStatus, 1) | 
|---|
|  |  |  | .orderByAsc(Loc::getRow, Loc::getBay)); | 
|---|
|  |  |  | for (Loc loc : locs) { | 
|---|
|  |  |  | Integer row = loc.getRow(); | 
|---|
|  |  |  | Integer bay = loc.getBay(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (mapStrict) {//严格模式下,载入库位状态 | 
|---|
|  |  |  | //过滤数据 | 
|---|
|  |  |  | //获取当前楼层库位数据 | 
|---|
|  |  |  | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>() | 
|---|
|  |  |  | .eq(Loc::getLev, lev) | 
|---|
|  |  |  | .orderByAsc(Loc::getRow, Loc::getBay)); | 
|---|
|  |  |  | for (Loc loc : locs) { | 
|---|
|  |  |  | Integer row = loc.getRow(); | 
|---|
|  |  |  | Integer bay = loc.getBay(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 (loc.getLocSts$().equals("F") | 
|---|
|  |  |  | || loc.getLocSts$().equals("D") | 
|---|
|  |  |  | || loc.getLocSts$().equals("X") | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (mapType == NavigationMapType.NORMAL.id) { | 
|---|
|  |  |  | //过滤库位状态X | 
|---|
|  |  |  | if (loc.getLocSts$().equals("X")) { | 
|---|
|  |  |  | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新list | 
|---|
|  |  |  | list.set(bay, mapNode); | 
|---|
|  |  |  | lists.set(row, list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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 (loc.getLocStsFlag().equals("F") | 
|---|
|  |  |  | || loc.getLocStsFlag().equals("D") | 
|---|
|  |  |  | || loc.getLocStsFlag().equals("X") | 
|---|
|  |  |  | ) { | 
|---|
|  |  |  | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (mapType == NavigationMapType.NORMAL.id || mapType == NavigationMapType.NONE_LOCK.id) { | 
|---|
|  |  |  | //过滤库位状态X | 
|---|
|  |  |  | if (loc.getLocStsFlag().equals("X")) { | 
|---|
|  |  |  | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新list | 
|---|
|  |  |  | list.set(bay, mapNode); | 
|---|
|  |  |  | lists.set(row, list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //加载车辆坐标到地图中 | 
|---|