|  |  |  | 
|---|
|  |  |  | resultMap.put(h.getMac(),maps); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Map.Entry entry : resultMap.entrySet()){ | 
|---|
|  |  |  | boolean dimension = false; | 
|---|
|  |  |  | String mapKey = (String) entry.getKey(); | 
|---|
|  |  |  | Map<String,ArrayList<Double>> mapValue = (Map<String,ArrayList<Double>>)entry.getValue(); | 
|---|
|  |  |  | Map<String, Object> data = new HashMap<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.put("PM2_5",rsAvg); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | data.put("PM2_5",0); | 
|---|
|  |  |  | dimension = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(mapValue.containsKey("PM10")){ | 
|---|
|  |  |  | Double ListAvg = mapValue.get("PM10").stream().collect(Collectors.averagingDouble(Double::doubleValue)); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.put("PM10",rsAvg); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | data.put("PM10",0); | 
|---|
|  |  |  | dimension = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(mapValue.containsKey("SO2")){ | 
|---|
|  |  |  | Double ListAvg = mapValue.get("SO2").stream().collect(Collectors.averagingDouble(Double::doubleValue)); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.put("SO2",rsAvg); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | data.put("SO2",0); | 
|---|
|  |  |  | dimension = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(mapValue.containsKey("NO2")){ | 
|---|
|  |  |  | Double ListAvg = mapValue.get("NO2").stream().collect(Collectors.averagingDouble(Double::doubleValue)); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.put("NO2",rsAvg); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | data.put("NO2",0); | 
|---|
|  |  |  | dimension = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(mapValue.containsKey("CO")){ | 
|---|
|  |  |  | Double ListAvg = percentile(mapValue.get("CO"),95d); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.put("CO",rsAvg); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | data.put("CO",0); | 
|---|
|  |  |  | dimension = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(mapValue.containsKey("O3")){ | 
|---|
|  |  |  | Double ListAvg = percentile(mapValue.get("O3"),90d); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.put("O3",rsAvg); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | data.put("O3",0); | 
|---|
|  |  |  | dimension = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(mapValue.containsKey("TVOC")){ | 
|---|
|  |  |  | Double ListAvg = mapValue.get("TVOC").stream().collect(Collectors.averagingDouble(Double::doubleValue)); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.put("TVOC",rsAvg); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | data.put("TVOC",0); | 
|---|
|  |  |  | dimension = true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Double resultNum = ComprehensiveIndexUtils.dailyData(data); | 
|---|
|  |  |  | if(dimension){ | 
|---|
|  |  |  | resultNum = 0d; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MonitoringStationDTO monitoringStationDTO = new MonitoringStationDTO(); | 
|---|
|  |  |  | monitoringStationDTO.setPM25(BigDecimal.valueOf(Double.parseDouble(data.get("PM2_5").toString()))); | 
|---|
|  |  |  | monitoringStationDTO.setO3(BigDecimal.valueOf(Double.parseDouble(data.get("O3").toString()))); | 
|---|
|  |  |  | 
|---|
|  |  |  | monitoringStationDTO.setMac(mapKey); | 
|---|
|  |  |  | list.add(monitoringStationDTO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<MonitoringStationDTO> compositeListResult = fun3(list,0); | 
|---|
|  |  |  | List<MonitoringStationDTO> compositeList = fun3(list,1); | 
|---|
|  |  |  | List<MonitoringStationDTO> pM25List = fun3(list,2); | 
|---|
|  |  |  | List<MonitoringStationDTO> o3List = fun3(list,3); | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String,String> deviceMap =  new HashMap<>(); | 
|---|
|  |  |  | wrapper.list().forEach(it->deviceMap.put(it.getMac(),it.getName())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (MonitoringStationDTO m :compositeList ){ | 
|---|
|  |  |  | for (MonitoringStationDTO m :compositeListResult ){ | 
|---|
|  |  |  | MonitoringStationDTO monit = new MonitoringStationDTO(); | 
|---|
|  |  |  | String mac = m.getMac(); | 
|---|
|  |  |  | monit.setMac(mac); | 
|---|
|  |  |  | monit.setName(deviceMap.get(mac)); | 
|---|
|  |  |  | monit.setComposite(m.getComposite()); | 
|---|
|  |  |  | monit.setCompositeNum(m.getCompositeNum()); | 
|---|
|  |  |  | List<String> listComposite = compositeList.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList()); | 
|---|
|  |  |  | monit.setComposite(listComposite.indexOf(mac) == -1?BigDecimal.ZERO:compositeList.get(listComposite.indexOf(mac)).getComposite()); | 
|---|
|  |  |  | monit.setCompositeNum(listComposite.indexOf(mac) == -1?0:compositeList.get(listComposite.indexOf(mac)).getCompositeNum()); | 
|---|
|  |  |  | List<String> listPM25 = pM25List.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList()); | 
|---|
|  |  |  | List<String> listO3 = o3List.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList()); | 
|---|
|  |  |  | List<String> listTovc = tovcList.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList()); | 
|---|
|  |  |  | monit.setO3(o3List.get(listO3.indexOf(mac)).getO3()); | 
|---|
|  |  |  | monit.setO3Num(o3List.get(listO3.indexOf(mac)).getO3Num()); | 
|---|
|  |  |  | monit.setPM25(pM25List.get(listPM25.indexOf(mac)).getPM25()); | 
|---|
|  |  |  | monit.setPM25Num(pM25List.get(listPM25.indexOf(mac)).getPM25Num()); | 
|---|
|  |  |  | monit.setTovc(tovcList.get(listTovc.indexOf(mac)).getTovc()); | 
|---|
|  |  |  | monit.setTOVCNum(tovcList.get(listTovc.indexOf(mac)).getTOVCNum()); | 
|---|
|  |  |  | monit.setO3(listO3.indexOf(mac) == -1?BigDecimal.ZERO:o3List.get(listO3.indexOf(mac)).getO3()); | 
|---|
|  |  |  | monit.setO3Num(listO3.indexOf(mac) == -1?0:o3List.get(listO3.indexOf(mac)).getO3Num()); | 
|---|
|  |  |  | monit.setPM25(listPM25.indexOf(mac) == -1?BigDecimal.ZERO:pM25List.get(listPM25.indexOf(mac)).getPM25()); | 
|---|
|  |  |  | monit.setPM25Num(listPM25.indexOf(mac) == -1?0:pM25List.get(listPM25.indexOf(mac)).getPM25Num()); | 
|---|
|  |  |  | monit.setTovc(listTovc.indexOf(mac) == -1?BigDecimal.ZERO:tovcList.get(listTovc.indexOf(mac)).getTovc()); | 
|---|
|  |  |  | monit.setTOVCNum(listTovc.indexOf(mac) == -1?0:tovcList.get(listTovc.indexOf(mac)).getTOVCNum()); | 
|---|
|  |  |  | List<String> listSO2 = SO2List.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList()); | 
|---|
|  |  |  | monit.setSO2(SO2List.get(listSO2.indexOf(mac)).getSO2()); | 
|---|
|  |  |  | monit.setSO2Num(SO2List.get(listSO2.indexOf(mac)).getSO2Num()); | 
|---|
|  |  |  | monit.setSO2(listSO2.indexOf(mac) == -1?BigDecimal.ZERO:SO2List.get(listSO2.indexOf(mac)).getSO2()); | 
|---|
|  |  |  | monit.setSO2Num(listSO2.indexOf(mac) == -1?0:SO2List.get(listSO2.indexOf(mac)).getSO2Num()); | 
|---|
|  |  |  | List<String> listNO2 = NO2cList.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList()); | 
|---|
|  |  |  | monit.setNO2(NO2cList.get(listNO2.indexOf(mac)).getNO2()); | 
|---|
|  |  |  | monit.setNO2Num(NO2cList.get(listNO2.indexOf(mac)).getNO2Num()); | 
|---|
|  |  |  | monit.setNO2(listNO2.indexOf(mac) == -1?BigDecimal.ZERO:NO2cList.get(listNO2.indexOf(mac)).getNO2()); | 
|---|
|  |  |  | monit.setNO2Num(listNO2.indexOf(mac) == -1?0:NO2cList.get(listNO2.indexOf(mac)).getNO2Num()); | 
|---|
|  |  |  | List<String> listPM10 = PM10List.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList()); | 
|---|
|  |  |  | monit.setPM10(PM10List.get(listPM10.indexOf(mac)).getPM10()); | 
|---|
|  |  |  | monit.setPM10Num(PM10List.get(listPM10.indexOf(mac)).getPM10Num()); | 
|---|
|  |  |  | monit.setPM10(listPM10.indexOf(mac) == -1?BigDecimal.ZERO:PM10List.get(listPM10.indexOf(mac)).getPM10()); | 
|---|
|  |  |  | monit.setPM10Num(listPM10.indexOf(mac) == -1?0:PM10List.get(listPM10.indexOf(mac)).getPM10Num()); | 
|---|
|  |  |  | List<String> listCO = COList.stream().map(MonitoringStationDTO::getMac).collect(Collectors.toList()); | 
|---|
|  |  |  | monit.setCO(COList.get(listCO.indexOf(mac)).getCO()); | 
|---|
|  |  |  | monit.setCONum(COList.get(listCO.indexOf(mac)).getCONum()); | 
|---|
|  |  |  | monit.setCO(listCO.indexOf(mac) == -1?BigDecimal.ZERO:COList.get(listCO.indexOf(mac)).getCO()); | 
|---|
|  |  |  | monit.setCONum(listCO.indexOf(mac) == -1?0:COList.get(listCO.indexOf(mac)).getCONum()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | resultList.add(monit); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | List<MonitoringStationDTO> compositeList = new ArrayList<>(); | 
|---|
|  |  |  | Map<BigDecimal,List<MonitoringStationDTO>> map1 = new HashMap<>(); | 
|---|
|  |  |  | if(type == 1){ | 
|---|
|  |  |  | compositeList = monList.stream().filter(it->it.getComposite().compareTo(BigDecimal.ZERO)!=0).sorted(Comparator.comparing(MonitoringStationDTO::getComposite)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getComposite,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | }else if(type == 0){ | 
|---|
|  |  |  | compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getComposite)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getComposite,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | }else if(type == 2){ | 
|---|
|  |  |  | compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getPM25)).collect(Collectors.toList()); | 
|---|
|  |  |  | compositeList = monList.stream().filter(it->it.getPM25().compareTo(BigDecimal.ZERO)!=0).sorted(Comparator.comparing(MonitoringStationDTO::getPM25)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getPM25,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | }else if(type == 3){ | 
|---|
|  |  |  | compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getO3)).collect(Collectors.toList()); | 
|---|
|  |  |  | compositeList = monList.stream().filter(it->it.getO3().compareTo(BigDecimal.ZERO)!=0).sorted(Comparator.comparing(MonitoringStationDTO::getO3)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getO3,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | }else if(type == 4){ | 
|---|
|  |  |  | compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getTovc)).collect(Collectors.toList()); | 
|---|
|  |  |  | compositeList = monList.stream().filter(it->it.getTovc().compareTo(BigDecimal.ZERO)!=0).sorted(Comparator.comparing(MonitoringStationDTO::getTovc)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getTovc,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | }else if(type == 5){ | 
|---|
|  |  |  | compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getSO2)).collect(Collectors.toList()); | 
|---|
|  |  |  | compositeList = monList.stream().filter(it->it.getSO2().compareTo(BigDecimal.ZERO)!=0).sorted(Comparator.comparing(MonitoringStationDTO::getSO2)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getSO2,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | }else if(type == 6){ | 
|---|
|  |  |  | compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getNO2)).collect(Collectors.toList()); | 
|---|
|  |  |  | compositeList = monList.stream().filter(it->it.getNO2().compareTo(BigDecimal.ZERO)!=0).sorted(Comparator.comparing(MonitoringStationDTO::getNO2)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getNO2,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | }else if(type == 7){ | 
|---|
|  |  |  | compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getPM10)).collect(Collectors.toList()); | 
|---|
|  |  |  | compositeList = monList.stream().filter(it->it.getPM10().compareTo(BigDecimal.ZERO)!=0).sorted(Comparator.comparing(MonitoringStationDTO::getPM10)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getPM10,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | }else if(type == 8){ | 
|---|
|  |  |  | compositeList = monList.stream().sorted(Comparator.comparing(MonitoringStationDTO::getCO)).collect(Collectors.toList()); | 
|---|
|  |  |  | compositeList = monList.stream().filter(it->it.getCO().compareTo(BigDecimal.ZERO)!=0).sorted(Comparator.comparing(MonitoringStationDTO::getCO)).collect(Collectors.toList()); | 
|---|
|  |  |  | map1 = compositeList.stream().collect(Collectors.groupingBy(MonitoringStationDTO::getCO,LinkedHashMap::new,Collectors.toList())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int index = 1; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(type == 1){ | 
|---|
|  |  |  | stationDTO.setComposite(m.getComposite()); | 
|---|
|  |  |  | stationDTO.setCompositeNum(index); | 
|---|
|  |  |  | }else if(type == 0){ | 
|---|
|  |  |  | stationDTO.setComposite(m.getComposite()); | 
|---|
|  |  |  | stationDTO.setCompositeNum(index); | 
|---|
|  |  |  | }else if(type == 2){ | 
|---|
|  |  |  | stationDTO.setPM25(m.getPM25()); | 
|---|
|  |  |  | stationDTO.setPM25Num(index); | 
|---|