| | |
| | | RedisTemplate redisTemplate; |
| | | |
| | | |
| | | |
| | | /*@Override |
| | | public List<WebProvince> getMapPath(String token) { |
| | | List<WebProvince> results; |
| | | try { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Integer id = Integer.parseInt(WebTokenUtils.getIdBytoken(token)); |
| | | Organization organization = organizationService.getOrganizationByAccountId(id); |
| | | Map<String, Object> regionCodeAndType = getRegionCodeAndTypeByOrg(organization); |
| | | String regionType = (String) regionCodeAndType.get("regionType"); |
| | | String regionCode = (String) regionCodeAndType.get("regionCode"); |
| | | params.put(regionType, regionCode); |
| | | results = mapPathMapper.getMapPathByRegionCode(params); |
| | | filterMapPath(organization, results); |
| | | return results; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | return null; |
| | | }*/ |
| | | |
| | | /** |
| | | * @Description: 根据用户token获取用户地图权限 |
| | | * @Param: [token] |
| | |
| | | } |
| | | mapPath.add(webProvince); |
| | | } |
| | | return mapPath; |
| | | } |
| | | |
| | | @Override |
| | | public List<WebProvince> getMapPathTest(String token) { |
| | | long monitorStartTime = System.currentTimeMillis(); |
| | | Integer id = Integer.parseInt(WebTokenUtils.getIdBytoken(token)); |
| | | Organization organization = organizationService.getOrganizationByAccountId(id); |
| | | List<MonitorPoint> monitorPoints; |
| | | //判断是否属于超级组织,如果属于超级组织则返回所有存在设备的省市区,否则根据org下的站点进行查询。 |
| | | if (dictionaryDataService.querySupperOrgId().equals(organization.getId())) { |
| | | monitorPoints = monitorPointMapper.selectAll(); |
| | | } else { |
| | | Integer parentOrgId = organization.getId(); |
| | | Set<Integer> childOrgIds = organizationService.getChildOrganizationIds(parentOrgId); |
| | | childOrgIds.add(parentOrgId); |
| | | monitorPoints = monitorPointService.getMonitorPointsByOrganizationIds(childOrgIds); |
| | | } |
| | | System.out.println("查询站点消耗时间:" + String.valueOf(System.currentTimeMillis() - monitorStartTime)); |
| | | |
| | | long listStartTime = System.currentTimeMillis(); |
| | | Set<Integer> provinceCodesSet = new HashSet<>(); |
| | | Set<Integer> cityCodesSet = new HashSet<>(); |
| | | Set<Integer> areaCodesSet = new HashSet<>(); |
| | | for (MonitorPoint monitorPoint : monitorPoints) { |
| | | provinceCodesSet.add(monitorPoint.getProvinceCode()); |
| | | cityCodesSet.add(monitorPoint.getCityCode()); |
| | | areaCodesSet.add(monitorPoint.getAreaCode()); |
| | | } |
| | | |
| | | //Set转为List用于排序 |
| | | List<Integer> provinceCodes = new ArrayList<>(provinceCodesSet); |
| | | List<Integer> cityCodes = new ArrayList<>(cityCodesSet); |
| | | List<Integer> areaCodes = new ArrayList<>(areaCodesSet); |
| | | provinceCodes.removeAll(Collections.singleton(null)); |
| | | cityCodes.removeAll(Collections.singleton(null)); |
| | | areaCodes.removeAll(Collections.singleton(null)); |
| | | Comparator<Integer> comparator = new ComparatorUtil(); |
| | | Collections.sort(provinceCodes, comparator); |
| | | Collections.sort(cityCodes, comparator); |
| | | Collections.sort(areaCodes, comparator); |
| | | System.out.println("遍历站点集合转换消耗时间" + String.valueOf(System.currentTimeMillis() - listStartTime)); |
| | | |
| | | List<WebProvince> mapPath = new ArrayList<>(); |
| | | long redisStartTime = System.currentTimeMillis(); |
| | | for (Integer provinceCode : provinceCodes) { |
| | | String provinceCodeStr = String.valueOf(provinceCode); |
| | | Province province = new Province(); |
| | | province.setProvinceCode(provinceCode); |
| | | province = provinceMapper.selectOne(province); |
| | | WebProvince webProvince = new WebProvince(province.getProvinceCode(), province.getProvinceName(), new ArrayList<>()); |
| | | for (Integer cityCode : cityCodes) { |
| | | String cityCodeStr = String.valueOf(cityCode); |
| | | //判断该市是否属于该省 |
| | | if (cityCodeStr.substring(0, 2).equals(provinceCodeStr.substring(0, 2))) { |
| | | City city = new City(); |
| | | city.setCityCode(cityCode); |
| | | city = cityMapper.selectOne(city); |
| | | WebCity WebCity = new WebCity(city.getCityCode(), city.getCityName(), provinceCode, new ArrayList<>()); |
| | | for (Integer areaCode : areaCodes) { |
| | | String areaCodeStr = String.valueOf(areaCode); |
| | | if (cityCodeStr.substring(0, 4).equals(areaCodeStr.substring(0, 4))) { |
| | | Area area = new Area(); |
| | | area.setAreaCode(areaCode); |
| | | area = areaMapper.selectOne(area); |
| | | WebCity.getAreas().add(area); |
| | | } |
| | | } |
| | | webProvince.getCities().add(WebCity); |
| | | } |
| | | } |
| | | mapPath.add(webProvince); |
| | | } |
| | | System.out.println("redis转换时间:" + String.valueOf(System.currentTimeMillis() - redisStartTime)); |
| | | return mapPath; |
| | | } |
| | | |