| | |
| | | import com.moral.api.pojo.bo.ExcelBO; |
| | | import com.moral.api.pojo.vo.excel.SyExcelVo; |
| | | import com.moral.api.service.HnExcelService; |
| | | import com.moral.api.utils.AqiUtils; |
| | | import com.moral.api.utils.ExcelUtils; |
| | | import com.moral.pojo.AQI; |
| | | import com.moral.util.AQIUtils; |
| | | import com.moral.util.AmendUtils; |
| | | import com.moral.util.DateUtils; |
| | |
| | | if (s.equals("count")){ |
| | | ArrayList<String> list1 = new ArrayList<>(); |
| | | List<Integer> list = stringListMap.get(s); |
| | | String season; |
| | | Integer sum =0; |
| | | if (data>=1 && data<=3){ |
| | | sum = list.get(0) + list.get(1) + list.get(2); |
| | | season = "一"; |
| | | }else if (data>=4 &&data<=6){ |
| | | sum = list.get(3) + list.get(4) + list.get(5); |
| | | season = "二"; |
| | | }else if (data>=7 &&data<=9){ |
| | | sum = list.get(6) + list.get(7) + list.get(8); |
| | | season = "三"; |
| | | }else { |
| | | sum = list.get(9) + list.get(10) + list.get(11); |
| | | season = "四"; |
| | | } |
| | | syExcelVo.setCode5(sum.toString()); |
| | | syExcelVo.setSeason(season); |
| | | for (int i = 0; i < list.size()-1; i++) { |
| | | if (list.get(i)==0){ |
| | | list1.add(""); |
| | |
| | | if (objects.length == 9) { |
| | | map.put("time", objects[0]); |
| | | map.put("PM10", objects[1]); |
| | | map.put("a34004", objects[2]); |
| | | map.put("PM2_5", objects[2]); |
| | | map.put("SO2", objects[3]); |
| | | map.put("NO2", objects[4]); |
| | | map.put("CO", objects[5]); |
| | |
| | | if (objects.length == 18) { |
| | | map.put("time", objects[0]); |
| | | map.put("PM10", objects[1]); |
| | | map.put("a34004", objects[2]); |
| | | map.put("PM2_5", objects[2]); |
| | | map.put("SO2", objects[3]); |
| | | map.put("NO2", objects[4]); |
| | | map.put("CO", objects[5]); |
| | |
| | | { |
| | | map1.put("time", objects[10]); |
| | | map1.put("PM10", objects[11]); |
| | | map1.put("a34004", objects[12]); |
| | | map1.put("PM2_5", objects[12]); |
| | | map1.put("SO2", objects[13]); |
| | | map1.put("NO2", objects[14]); |
| | | map1.put("CO", objects[15]); |
| | |
| | | if (objects.length == 27) { |
| | | map.put("time", objects[0]); |
| | | map.put("PM10", objects[1]); |
| | | map.put("a34004", objects[2]); |
| | | map.put("PM2_5", objects[2]); |
| | | map.put("SO2", objects[3]); |
| | | map.put("NO2", objects[4]); |
| | | map.put("CO", objects[5]); |
| | |
| | | |
| | | map1.put("time", objects[10]); |
| | | map1.put("PM10", objects[11]); |
| | | map1.put("a34004", objects[12]); |
| | | map1.put("PM2_5", objects[12]); |
| | | map1.put("SO2", objects[13]); |
| | | map1.put("NO2", objects[14]); |
| | | map1.put("CO", objects[15]); |
| | |
| | | ) { |
| | | map2.put("time", objects[19]); |
| | | map2.put("PM10", objects[20]); |
| | | map2.put("a34004", objects[21]); |
| | | map2.put("PM2_5", objects[21]); |
| | | map2.put("SO2", objects[22]); |
| | | map2.put("NO2", objects[23]); |
| | | map2.put("CO", objects[24]); |
| | |
| | | |
| | | } |
| | | //计算本年度pm2.5和优良天数 |
| | | Map<String, List<Integer>> map = getMap(rsMap3); |
| | | Map<String, List<Integer>> map = getMap(rsMap3,time); |
| | | //计算去年PM2.5和优良天数 |
| | | Map<String, Integer> map2 = getResult(rsMap2, time); |
| | | Map<String, List<Integer>> map2 = getResult(rsMap2, time); |
| | | List<Integer> list = map.get("count"); |
| | | list.add(map2.get("count")); |
| | | list.add(map2.get("count").get(0)); |
| | | List<Integer> list1 = map.get("PM2_5"); |
| | | list1.add(map2.get("PM2_5")); |
| | | list1.add(map2.get("PM2_5").get(0)); |
| | | map.put("去年",map2.get("去年")); |
| | | return map; |
| | | } |
| | | |
| | |
| | | * |
| | | * @param rsMap3 |
| | | */ |
| | | private Map<String, List<Integer>> getMap(HashMap<String, Object> rsMap3) { |
| | | private Map<String, List<Integer>> getMap(HashMap<String, Object> rsMap3,String time) { |
| | | HashMap<String, List<Integer>> listMap = new HashMap<>(); |
| | | Set<String> strings = rsMap3.keySet(); |
| | | ArrayList<Double> list1 = new ArrayList<>(); |
| | |
| | | ArrayList<Double> resList = new ArrayList<>(); |
| | | ArrayList<Integer> list = new ArrayList<>(); |
| | | ArrayList<Integer> listPM = new ArrayList<>(); |
| | | ArrayList<Double> AQI = new ArrayList<>(); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | int count1 = 0; |
| | | int count2 = 0; |
| | | int count3 = 0; |
| | |
| | | int count10 = 0; |
| | | int count11 = 0; |
| | | int count12 = 0; |
| | | String rsTime = time.substring(0, 4); |
| | | integers.add(Integer.parseInt(rsTime)); |
| | | for (String string : strings) { |
| | | String substring = string.substring(5, 7); |
| | | |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list1.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count1++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list2.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count2++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list3.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count3++; |
| | | } |
| | | } |
| | |
| | | Object o = rsMap3.get(string); |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | |
| | | String aqi = map.get("AQI").toString(); |
| | | |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list4.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count4++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list5.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count5++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list6.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count6++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list7.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count7++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list8.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count8++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list9.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count9++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list10.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count10++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list11.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count11++; |
| | | } |
| | | } |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list12.add(Double.parseDouble(pm2_5)); |
| | | resList.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count12++; |
| | | } |
| | | } |
| | | |
| | | } |
| | | int code1 =0; |
| | | int code2 =0; |
| | | int code3 =0; |
| | | int code4 =0; |
| | | int code5 =0; |
| | | int code6 =0; |
| | | int i; |
| | | for (double aDouble : AQI) { |
| | | i=(int)aDouble; |
| | | String s = AQIUtils.classOfPollutionByAqi(i); |
| | | if (s.equals("优")){ |
| | | code1++; |
| | | } |
| | | if (s.equals("良")){ |
| | | code2++; |
| | | } |
| | | if (s.equals("轻度污染")){ |
| | | code3++; |
| | | } |
| | | if (s.equals("中度污染")){ |
| | | code4++; |
| | | } |
| | | if (s.equals("重度污染")){ |
| | | code5++; |
| | | } |
| | | if (s.equals("严重污染")){ |
| | | code6++; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | integers.add(code1+code2); |
| | | integers.add(code1); |
| | | integers.add(code2); |
| | | integers.add(code3); |
| | | integers.add(code4); |
| | | integers.add(code5); |
| | | integers.add(code6); |
| | | |
| | | list.add(count1); |
| | | list.add(count2); |
| | | list.add(count3); |
| | |
| | | list.add(count12); |
| | | |
| | | Integer sum = list.stream().reduce(Integer::sum).orElse(0); |
| | | |
| | | list.add(sum); |
| | | listMap.put("count", list); |
| | | |
| | | Integer collect1 = 0; |
| | | if (list1.size() > 0) { |
| | | collect1 = Math.toIntExact(Math.round(list1.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect1 = Math.toIntExact(Math.round(list1.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect1 = (int) AmendUtils.sciCal(list1.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect2 = 0; |
| | | if (list2.size() > 0) { |
| | | collect2 = Math.toIntExact(Math.round(list2.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect2 = Math.toIntExact(Math.round(list2.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect2= (int) AmendUtils.sciCal(list2.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect3 = 0; |
| | | if (list3.size() > 0) { |
| | | collect3 = Math.toIntExact(Math.round(list3.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect3 = Math.toIntExact(Math.round(list3.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect3 = (int) AmendUtils.sciCal(list3.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect4 = 0; |
| | | if (list4.size() > 0) { |
| | | collect4 = Math.toIntExact(Math.round(list4.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect4 = Math.toIntExact(Math.round(list4.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect4 = (int) AmendUtils.sciCal(list4.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect5 = 0; |
| | | if (list5.size() > 0) { |
| | | collect5 = Math.toIntExact(Math.round(list5.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect5 = Math.toIntExact(Math.round(list5.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect5 = (int) AmendUtils.sciCal(list5.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect6 = 0; |
| | | if (list6.size() > 0) { |
| | | collect6 = Math.toIntExact(Math.round(list6.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect6 = Math.toIntExact(Math.round(list6.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect6 = (int) AmendUtils.sciCal(list6.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | |
| | | Integer collect7 = 0; |
| | | if (list7.size() > 0) { |
| | | collect7 = Math.toIntExact(Math.round(list7.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect7 = Math.toIntExact(Math.round(list7.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect7 = (int) AmendUtils.sciCal(list7.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect8 = 0; |
| | | if (list8.size() > 0) { |
| | | collect8 = Math.toIntExact(Math.round(list8.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect8 = Math.toIntExact(Math.round(list8.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect8 = (int) AmendUtils.sciCal(list8.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect9 = 0; |
| | | if (list9.size() > 0) { |
| | | collect9 = Math.toIntExact(Math.round(list9.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect9 = Math.toIntExact(Math.round(list9.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect9 = (int) AmendUtils.sciCal(list9.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect10 = 0; |
| | | if (list10.size() > 0) { |
| | | collect10 = Math.toIntExact(Math.round(list10.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect10 = Math.toIntExact(Math.round(list10.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect10 = (int) AmendUtils.sciCal(list10.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect11 = 0; |
| | | if (list11.size() > 0) { |
| | | collect11 = Math.toIntExact(Math.round(list11.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect11 = Math.toIntExact(Math.round(list11.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect11 = (int) AmendUtils.sciCal(list11.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | Integer collect12 = 0; |
| | | if (list12.size() > 0) { |
| | | collect12 = Math.toIntExact(Math.round(list12.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // collect12 = Math.toIntExact(Math.round(list12.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | collect12 = (int) AmendUtils.sciCal(list12.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | } |
| | | //今年的pm2.5累计 |
| | | int resPM25 = Math.toIntExact(Math.round(resList.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | // int resPM25 = Math.toIntExact(Math.round(resList.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | int resPM25 = (int) AmendUtils.sciCal(resList.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | listPM.add(collect1); |
| | | listPM.add(collect2); |
| | | listPM.add(collect3); |
| | |
| | | listPM.add(collect11); |
| | | listPM.add(collect12); |
| | | listPM.add(resPM25); |
| | | listMap.put("PM2_5", listPM); |
| | | listMap.put("PM2_5",listPM); |
| | | listMap.put("今年",integers); |
| | | return listMap; |
| | | } |
| | | |
| | |
| | | * |
| | | * @param rsMap2 |
| | | */ |
| | | private Map<String, Integer> getResult(HashMap<String, Object> rsMap2, String time) throws ParseException { |
| | | HashMap<String, Integer> rsMap = new HashMap<>(); |
| | | private Map<String, List<Integer>> getResult(HashMap<String, Object> rsMap2, String time) throws ParseException { |
| | | HashMap<String, List<Integer>> rsMap = new HashMap<>(); |
| | | ArrayList<Double> list = new ArrayList<>(); |
| | | ArrayList<Integer> list2 = new ArrayList<>(); |
| | | ArrayList<Integer> list3 = new ArrayList<>(); |
| | | ArrayList<Double> AQI = new ArrayList<>(); |
| | | ArrayList<Integer> rsAqi = new ArrayList<>(); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.setTime(sdf1.parse(time)); |
| | | instance.add(Calendar.YEAR, -1); |
| | | Date date = instance.getTime(); |
| | | //获取年 |
| | | String format = sdf1.format(date); |
| | | String rsTime = format.substring(0, 4); |
| | | //时间戳 |
| | | long time1 = date.getTime(); |
| | | int count = 0; |
| | |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | String aqi = map.get("AQI").toString(); |
| | | String pm2_5 = map.get("a34004").toString(); |
| | | String pm2_5 = map.get("PM2_5").toString(); |
| | | list.add(Double.parseDouble(pm2_5)); |
| | | if (Double.parseDouble(aqi) < 100) { |
| | | AQI.add(Double.parseDouble(aqi)); |
| | | if (Double.parseDouble(aqi) <= 100) { |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | list2.add(count); |
| | | int code1 =0; |
| | | int code2 =0; |
| | | int code3 =0; |
| | | int code4 =0; |
| | | int code5 =0; |
| | | int code6 =0; |
| | | int i; |
| | | for (double adouble : AQI) { |
| | | i =(int) adouble; |
| | | String s = AQIUtils.classOfPollutionByAqi(i); |
| | | if (s.equals("优")){ |
| | | code1++; |
| | | } |
| | | if (s.equals("良")){ |
| | | code2++; |
| | | } |
| | | if (s.equals("轻度污染")){ |
| | | code3++; |
| | | } |
| | | if (s.equals("中度污染")){ |
| | | code4++; |
| | | } |
| | | if (s.equals("重度污染")){ |
| | | code5++; |
| | | } |
| | | if (s.equals("严重污染")){ |
| | | code6++; |
| | | } |
| | | } |
| | | rsAqi.add(Integer.parseInt(rsTime)); |
| | | rsAqi.add(code1+code2); |
| | | rsAqi.add(code1); |
| | | rsAqi.add(code2); |
| | | rsAqi.add(code3); |
| | | rsAqi.add(code4); |
| | | rsAqi.add(code5); |
| | | rsAqi.add(code6); |
| | | |
| | | //去年的pm2.5累积 |
| | | int PM2_5 = Math.toIntExact(Math.round(list.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | rsMap.put("count", count); |
| | | rsMap.put("PM2_5", PM2_5); |
| | | // int PM2_5 = Math.toIntExact(Math.round(list.stream().collect(Collectors.averagingDouble(Double::doubleValue)))); |
| | | int PM2_5 = (int) AmendUtils.sciCal(list.stream().collect(Collectors.averagingDouble(Double::doubleValue)), 0); |
| | | list3.add(PM2_5); |
| | | rsMap.put("count", list2); |
| | | rsMap.put("PM2_5", list3); |
| | | rsMap.put("去年",rsAqi); |
| | | |
| | | return rsMap; |
| | | } |
| | |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | HashMap<String, Object> map2 = new HashMap<>(); |
| | | if (objects.length == 18) { |
| | | if ( !objects[11].toString().contains("H") |
| | | && !objects[12].toString().contains("H") |
| | | && !objects[13].toString().contains("H") |
| | | && !objects[14].toString().contains("H") |
| | | && !objects[15].toString().contains("H") |
| | | && !objects[16].toString().contains("H") |
| | | ) { |
| | | // map1.put("time", objects[10]); |
| | | //PM10 |
| | | map1.put("a34002", objects[11]); |
| | | //PM2_5 |
| | | map1.put("a34004", objects[12]); |
| | | //SO2 |
| | | map1.put("a21026", objects[13]); |
| | | //NO2 |
| | | map1.put("a21004", objects[14]); |
| | | //CO |
| | | map1.put("a21005", objects[15]); |
| | | //O3_8H |
| | | map1.put("a05024", objects[16]); |
| | | |
| | | rsMap1.put(objects[10].toString(), map1); |
| | | } |
| | | map1.put("PM10", objects[11]); |
| | | map1.put("PM2_5", objects[12]); |
| | | map1.put("SO2", objects[13]); |
| | | map1.put("NO2", objects[14]); |
| | | map1.put("CO", objects[15]); |
| | | map1.put("O3", objects[16]); |
| | | |
| | | rsMap1.put(objects[10].toString(), map1); |
| | | |
| | | } |
| | | |
| | | if (objects.length == 27) { |
| | | if ( !objects[11].toString().contains("H") |
| | | && !objects[12].toString().contains("H") |
| | | && !objects[13].toString().contains("H") |
| | | && !objects[14].toString().contains("H") |
| | | && !objects[15].toString().contains("H") |
| | | && !objects[16].toString().contains("H") |
| | | |
| | | ) { |
| | | map1.put("a34002", objects[11]); |
| | | map1.put("a34004", objects[12]); |
| | | map1.put("a21026", objects[13]); |
| | | map1.put("a21004", objects[14]); |
| | | map1.put("a21005", objects[15]); |
| | | map1.put("a05024", objects[16]); |
| | | map1.put("PM10", objects[11]); |
| | | map1.put("PM2_5", objects[12]); |
| | | map1.put("SO2", objects[13]); |
| | | map1.put("NO2", objects[14]); |
| | | map1.put("CO", objects[15]); |
| | | map1.put("O3", objects[16]); |
| | | |
| | | rsMap1.put(objects[10].toString(), map1); |
| | | } |
| | | if ( |
| | | !objects[20].toString().contains("H") |
| | | && !objects[21].toString().contains("H") |
| | | && !objects[22].toString().contains("H") |
| | | && !objects[23].toString().contains("H") |
| | | && !objects[24].toString().contains("H") |
| | | && !objects[25].toString().contains("H")) |
| | | { |
| | | map2.put("a34002", objects[20]); |
| | | map2.put("a34004", objects[21]); |
| | | map2.put("a21026", objects[22]); |
| | | map2.put("a21004", objects[23]); |
| | | map2.put("a21005", objects[24]); |
| | | map2.put("a05024", objects[25]); |
| | | rsMap1.put(objects[10].toString(), map1); |
| | | |
| | | rsMap2.put(objects[19].toString(), map2); |
| | | } |
| | | |
| | | map2.put("PM10", objects[20]); |
| | | map2.put("PM2_5", objects[21]); |
| | | map2.put("SO2", objects[22]); |
| | | map2.put("NO2", objects[23]); |
| | | map2.put("CO", objects[24]); |
| | | map2.put("O3", objects[25]); |
| | | |
| | | rsMap2.put(objects[19].toString(), map2); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | HashMap<String, Object> map2 = new HashMap<>(); |
| | | if (objects.length == 18) { |
| | | if ( !objects[11].toString().contains("H") |
| | | && !objects[12].toString().contains("H") |
| | | && !objects[13].toString().contains("H") |
| | | && !objects[14].toString().contains("H") |
| | | && !objects[15].toString().contains("H") |
| | | && !objects[16].toString().contains("H") |
| | | ) { |
| | | // map1.put("time", objects[10]); |
| | | map1.put("a34002", objects[11]); |
| | | map1.put("a34004", objects[12]); |
| | | map1.put("a21026", objects[13]); |
| | | map1.put("a21004", objects[14]); |
| | | map1.put("a21005", objects[15]); |
| | | map1.put("a05024", objects[16]); |
| | | |
| | | rsMap3.put(objects[10].toString(), map1); |
| | | } |
| | | map1.put("PM10", objects[11]); |
| | | map1.put("PM2_5", objects[12]); |
| | | map1.put("SO2", objects[13]); |
| | | map1.put("NO2", objects[14]); |
| | | map1.put("CO", objects[15]); |
| | | map1.put("O3", objects[16]); |
| | | |
| | | rsMap3.put(objects[10].toString(), map1); |
| | | |
| | | |
| | | } |
| | | |
| | | if (objects.length == 27) { |
| | | if ( !objects[11].toString().contains("H") |
| | | && !objects[12].toString().contains("H") |
| | | && !objects[13].toString().contains("H") |
| | | && !objects[14].toString().contains("H") |
| | | && !objects[15].toString().contains("H") |
| | | && !objects[16].toString().contains("H")) |
| | | { |
| | | map1.put("a34002", objects[11]); |
| | | map1.put("a34004", objects[12]); |
| | | map1.put("a21026", objects[13]); |
| | | map1.put("a21004", objects[14]); |
| | | map1.put("a21005", objects[15]); |
| | | map1.put("a05024", objects[16]); |
| | | |
| | | rsMap3.put(objects[10].toString(), map1); |
| | | } |
| | | if ( !objects[20].toString().contains("H") |
| | | && !objects[21].toString().contains("H") |
| | | && !objects[22].toString().contains("H") |
| | | && !objects[23].toString().contains("H") |
| | | && !objects[24].toString().contains("H") |
| | | && !objects[25].toString().contains("H") |
| | | ) { |
| | | // map2.put("time", objects[19]); |
| | | map2.put("a34002", objects[20]); |
| | | map2.put("a34004", objects[21]); |
| | | map2.put("a21026", objects[22]); |
| | | map2.put("a21004", objects[23]); |
| | | map2.put("a21005", objects[24]); |
| | | map2.put("a05024", objects[25]); |
| | | rsMap4.put(objects[19].toString(), map2); |
| | | } |
| | | map1.put("PM10", objects[11]); |
| | | map1.put("PM2_5", objects[12]); |
| | | map1.put("SO2", objects[13]); |
| | | map1.put("NO2", objects[14]); |
| | | map1.put("CO", objects[15]); |
| | | map1.put("O3", objects[16]); |
| | | |
| | | rsMap3.put(objects[10].toString(), map1); |
| | | |
| | | |
| | | map2.put("PM10", objects[20]); |
| | | map2.put("PM2_5", objects[21]); |
| | | map2.put("SO2", objects[22]); |
| | | map2.put("NO2", objects[23]); |
| | | map2.put("CO", objects[24]); |
| | | map2.put("O3", objects[25]); |
| | | rsMap4.put(objects[19].toString(), map2); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | Object o = rsMap1.get(string); |
| | | String s = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s, Map.class); |
| | | if (!rsMap3.containsKey(string)){ |
| | | hnMap1.put(string,map); |
| | | continue; |
| | | } |
| | | |
| | | Object o1 = rsMap3.get(string); |
| | | String s1 = JSON.toJSONString(o1); |
| | | Map map1 = JSON.parseObject(s1, Map.class); |
| | | Set sets = map1.keySet(); |
| | | HashMap<Object, Object> hs = new HashMap<>(); |
| | | for (Object set : sets) { |
| | | if (set.toString().equals("a21005")){ |
| | | if (set.toString().equals("CO")){ |
| | | String s3 = map1.get(set).toString(); |
| | | String s2 = map.get(set).toString(); |
| | | hs.put(set,new BigDecimal((Double.parseDouble(s3)+Double.parseDouble(s2))/2).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | if (s3.contains("H") && !s2.contains("H")){ |
| | | hs.put(set,Double.parseDouble(s2)); |
| | | }else if(!s3.contains("H") && s2.contains("H")){ |
| | | hs.put(set,Double.parseDouble(s3)); |
| | | }else if(s3.contains("H") && s2.contains("H")){ |
| | | break; |
| | | }else { |
| | | // hs.put(set,new BigDecimal((Double.parseDouble(s3)+Double.parseDouble(s2))/2).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | hs.put(set, AmendUtils.sciCal((Double.parseDouble(s3)+Double.parseDouble(s2))/2,1)); |
| | | } |
| | | continue; |
| | | } |
| | | String s3 = map1.get(set).toString(); |
| | | String s2 = map.get(set).toString(); |
| | | hs.put(set,Math.round((Double.parseDouble(s3)+Double.parseDouble(s2))/2)); |
| | | if (s3.contains("H") && !s2.contains("H")){ |
| | | hs.put(set,Double.parseDouble(s2)); |
| | | }else if(!s3.contains("H") && s2.contains("H")){ |
| | | hs.put(set,Double.parseDouble(s3)); |
| | | }else if(s3.contains("H") && s2.contains("H")){ |
| | | break; |
| | | }else { |
| | | // hs.put(set,Math.round((Double.parseDouble(s3)+Double.parseDouble(s2))/2)); |
| | | hs.put(set, AmendUtils.sciCal((Double.parseDouble(s3)+Double.parseDouble(s2))/2,0)); |
| | | } |
| | | } |
| | | hnMap1.put(string,hs); |
| | | if (hs.size()==6){ |
| | | hnMap1.put(string,hs); |
| | | } |
| | | |
| | | } |
| | | |
| | | Set<String> strings2 = rsMap3.keySet(); |
| | | for (String s : strings2) { |
| | | Object o = rsMap3.get(s); |
| | | String s1 = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s1, Map.class); |
| | | if (!hnMap1.containsKey(s)){ |
| | | hnMap1.put(s,map); |
| | | } |
| | | } |
| | | |
| | | |
| | | Set<String> strings1 = rsMap2.keySet(); |
| | | for (String s : strings1) { |
| | | Object o = rsMap2.get(s); |
| | | String s1 = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s1, Map.class); |
| | | if (!rsMap4.containsKey(s)){ |
| | | hnMap2.put(s,map); |
| | | continue; |
| | | } |
| | | Object o1 = rsMap4.get(s); |
| | | String s2 = JSON.toJSONString(o1); |
| | | Map map1 = JSON.parseObject(s2, Map.class); |
| | | Set sets = map1.keySet(); |
| | | HashMap<Object, Object> hs = new HashMap<>(); |
| | | for (Object set : sets) { |
| | | if (set.toString().equals("a21005")){ |
| | | if (set.toString().equals("CO")){ |
| | | String s3 = map1.get(set).toString(); |
| | | String s4 = map.get(set).toString(); |
| | | hs.put(set,new BigDecimal((Double.parseDouble(s3)+Double.parseDouble(s4))/2).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | if (s3.contains("H") && !s4.contains("H")){ |
| | | hs.put(set,Double.parseDouble(s4)); |
| | | }else if(!s3.contains("H") && s4.contains("H")){ |
| | | hs.put(set,Double.parseDouble(s3)); |
| | | }else if(s3.contains("H") && s4.contains("H")){ |
| | | break; |
| | | }else { |
| | | hs.put(set, AmendUtils.sciCal((Double.parseDouble(s3)+Double.parseDouble(s4))/2,1)); |
| | | } |
| | | continue; |
| | | } |
| | | String s3 = map1.get(set).toString(); |
| | | String s4 = map.get(set).toString(); |
| | | hs.put(set,Math.round((Double.parseDouble(s3)+Double.parseDouble(s4))/2)); |
| | | if (s3.contains("H") && !s4.contains("H")){ |
| | | hs.put(set,Double.parseDouble(s4)); |
| | | }else if(!s3.contains("H") && s4.contains("H")){ |
| | | hs.put(set,Double.parseDouble(s3)); |
| | | }else if(s3.contains("H") && s4.contains("H")){ |
| | | break; |
| | | }else { |
| | | hs.put(set, AmendUtils.sciCal((Double.parseDouble(s3)+Double.parseDouble(s4))/2,0)); |
| | | } |
| | | |
| | | } |
| | | hnMap2.put(s,hs); |
| | | if (hs.size()==6){ |
| | | hnMap2.put(s,hs); |
| | | } |
| | | |
| | | } |
| | | |
| | | Set<String> strings3 = rsMap4.keySet(); |
| | | for (String s : strings3) { |
| | | Object o = rsMap4.get(s); |
| | | String s1 = JSON.toJSONString(o); |
| | | Map map = JSON.parseObject(s1, Map.class); |
| | | if (!rsMap2.containsKey(s1)){ |
| | | hnMap2.put(s,map); |
| | | } |
| | | } |
| | | |
| | | //计算今年的aqi |
| | | getHnMap(hnMap2); |
| | | //计算去年的aqi |
| | | getHnMap(hnMap1); |
| | | // |
| | | Map<String, List<Integer>> map = getMap(hnMap2); |
| | | Map<String, List<Integer>> map = getMap(hnMap2,time); |
| | | |
| | | |
| | | Map<String, Integer> map2 = getResult(hnMap1, time); |
| | | Map<String, List<Integer>> map2 = getResult(hnMap1, time); |
| | | |
| | | List<Integer> list = map.get("count"); |
| | | list.add(map2.get("count")); |
| | | list.add(map2.get("count").get(0)); |
| | | List<Integer> list1 = map.get("PM2_5"); |
| | | list1.add(map2.get("PM2_5")); |
| | | list1.add(map2.get("PM2_5").get(0)); |
| | | |
| | | return map; |
| | | |
| | | } |
| | | |
| | | //计算aqi |
| | | private void getHnMap(HashMap<String, Object> hnMap2) { |
| | | Set<String> strings4 = hnMap2.keySet(); |
| | |
| | | Object o = hnMap2.get(s); |
| | | String s1 = JSON.toJSONString(o); |
| | | Map rs = JSON.parseObject(s1, Map.class); |
| | | AQI aqi = AQIUtils.dailyAQI(rs); |
| | | Map aqi1 = AqiUtils.getAqi(rs); |
| | | JSONObject jsonObject = JSON.parseObject(s1); |
| | | jsonObject.put("AQI",aqi.getAQIValue()); |
| | | jsonObject.put("AQI",aqi1.get("AQI")); |
| | | String s2 = JSON.toJSONString(jsonObject); |
| | | Map map = JSON.parseObject(s2, Map.class); |
| | | hnMap2.put(s,map); |