| | |
| | | import com.zy.asrs.common.wms.entity.LocMast; |
| | | import com.zy.asrs.common.wms.service.LocMastService; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.model.MapNode; |
| | | import com.zy.asrs.wcs.core.model.NavigateNode; |
| | | import com.zy.asrs.wcs.core.model.enums.NavigationMapType; |
| | | import com.zy.asrs.wcs.core.service.LocService; |
| | | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.*; |
| | |
| | | */ |
| | | @Component |
| | | public class NavigateMapData { |
| | | |
| | | @Autowired |
| | | private LocService locService; |
| | | |
| | | private Integer lev;//地图楼层 |
| | | |
| | |
| | | |
| | | //获取JSON格式数据 |
| | | public List<List<MapNode>> getJsonData(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | String mapFilename = "map_" + lev + ".json"; |
| | | |
| | | String fileName = this.getClass().getClassLoader().getResource(mapFilename).getPath();//获取文件路径 |
| | | File file = new File(fileName); |
| | | StringBuffer stringBuffer = new StringBuffer(); |
| | | if (file.isFile() && file.exists()) { |
| | | InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "GBK"); |
| | | BufferedReader br = new BufferedReader(isr); |
| | | String lineTxt = null; |
| | | while ((lineTxt = br.readLine()) != null) { |
| | | stringBuffer.append(lineTxt); |
| | | } |
| | | br.close(); |
| | | |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class); |
| | | List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | |
| | | return lists; |
| | | } else { |
| | | System.out.println("文件不存在!"); |
| | | } |
| | | } catch (IOException ioException) { |
| | | ioException.printStackTrace(); |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | Object o = redisUtil.get(DeviceRedisConstant.MAP + lev); |
| | | if (o == null) { |
| | | return null; |
| | | } |
| | | return null; |
| | | |
| | | BasMap basMap = JSON.parseObject(o.toString(), BasMap.class); |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | return lists; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | //过滤数据 |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | //获取当前楼层库位数据 |
| | | List<LocMast> locMasts = locMastService.list(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLev1, lev)); |
| | | for (LocMast locMast : locMasts) { |
| | | Integer row = locMast.getRow1(); |
| | | Integer bay = locMast.getBay1(); |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLev, lev)); |
| | | for (Loc loc : locs) { |
| | | Integer row = loc.getRow(); |
| | | Integer bay = loc.getBay(); |
| | | |
| | | boolean whiteFlag = false;//默认不存在白名单 |
| | | if (whitePoints != null) { |
| | |
| | | } 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") |
| | | if (loc.getLocSts$().equals("F") |
| | | || loc.getLocSts$().equals("D") |
| | | || loc.getLocSts$().equals("X") |
| | | ) { |
| | | mapNode.setValue(-1);//禁用节点 |
| | | } |
| | | } else if (mapType == NavigationMapType.NORMAL.id) { |
| | | //过滤库位状态X |
| | | if (locMast.getLocSts().equals("X")) { |
| | | if (loc.getLocSts$().equals("X")) { |
| | | mapNode.setValue(-1);//禁用节点 |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | NavigateMapData mapData = new NavigateMapData(nodes.get(0).getZ()); |
| | | List<List<MapNode>> realMap = mapData.getJsonData(-1, null, null);//获取完整地图(包括入库出库) |
| | | this.setLev(nodes.get(0).getZ()); |
| | | List<List<MapNode>> realMap = this.getJsonData(-1, null, null);//获取完整地图(包括入库出库) |
| | | for (NavigateNode node : nodes) { |
| | | if (node.getZ() != lev) { |
| | | continue; |