|  |  | 
 |  |  |         String time1 = (String) parameters.get("time"); | 
 |  |  |         time1 = time1.replaceAll(" ", ""); | 
 |  |  |         parameters.put("time", time1); | 
 |  |  |  | 
 |  |  |         String mac1 = (String) parameters.get("mac"); | 
 |  |  |         List<Map<String, Object>> list = null; | 
 |  |  |         if (mac1 != null && mac1.equals("p5dnd7a0392018") && time1.substring(0, 4).equals("2019")) { | 
 |  |  | 
 |  |  |                 因为改动以前24点的数据是23-24,现在24点的数据是第二天0点的数据, | 
 |  |  |              */ | 
 |  |  |             /*改动范围start-------------------------------------------------------------------------*/ | 
 |  |  |             Iterator<Map<String, Object>> iterator = list.iterator(); | 
 |  |  |             while (iterator.hasNext()) { | 
 |  |  |                 Map<String, Object> next = iterator.next(); | 
 |  |  |                 String hour = next.get("time").toString().substring(11, 13); | 
 |  |  |                 if ("00".equals(hour)) { | 
 |  |  |                     iterator.remove(); | 
 |  |  |             Object type = parameters.get("type"); | 
 |  |  |             if ("day".equals(type)) { | 
 |  |  |                 Iterator<Map<String, Object>> iterator = list.iterator(); | 
 |  |  |                 while (iterator.hasNext()) { | 
 |  |  |                     Map<String, Object> next = iterator.next(); | 
 |  |  |                     String hour = next.get("time").toString().substring(11, 13); | 
 |  |  |                     if ("00".equals(hour)) { | 
 |  |  |                         iterator.remove(); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |             SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); | 
 |  |  |             //获取全格式时间yyyy-MM-dd HH:mm:ss | 
 |  |  |             time1 = time1 + " 00:00:00"; | 
 |  |  |             Date date = sdf.parse(time1); | 
 |  |  |             date = DateUtil.rollDay(date, 1); | 
 |  |  |             //将全格式时间截取 | 
 |  |  |             String time2 = sdf2.format(date); | 
 |  |  |             parameters.put("time", time2); | 
 |  |  |             /*查询第二天0点的数据,以24点的形式存进集合中*/ | 
 |  |  |             List<Map<String, Object>> nextDayList = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters); | 
 |  |  |             if (!ObjectUtils.isEmpty(nextDayList)) { | 
 |  |  |                 time1 = time1.replaceAll(" 00:00:00", " 24"); | 
 |  |  |                 for (Map<String, Object> map : nextDayList) { | 
 |  |  |                     String time = map.get("time").toString().substring(11, 13); | 
 |  |  |                     if("00".equals(time)){ | 
 |  |  |                         map.put("time", time1); | 
 |  |  |                         list.add(map); | 
 |  |  |                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |                 SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); | 
 |  |  |                 //获取全格式时间yyyy-MM-dd HH:mm:ss | 
 |  |  |                 time1 = time1 + " 00:00:00"; | 
 |  |  |                 Date date = sdf.parse(time1); | 
 |  |  |                 date = DateUtil.rollDay(date, 1); | 
 |  |  |                 //将全格式时间截取 | 
 |  |  |                 String time2 = sdf2.format(date); | 
 |  |  |                 parameters.put("time", time2); | 
 |  |  |                 /*查询第二天0点的数据,以24点的形式存进集合中*/ | 
 |  |  |                 List<Map<String, Object>> nextDayList = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters); | 
 |  |  |                 if (!ObjectUtils.isEmpty(nextDayList)) { | 
 |  |  |                     time1 = time1.replaceAll(" 00:00:00", " 24"); | 
 |  |  |                     for (Map<String, Object> map : nextDayList) { | 
 |  |  |                         String time = map.get("time").toString().substring(11, 13); | 
 |  |  |                         if ("00".equals(time)) { | 
 |  |  |                             map.put("time", time1); | 
 |  |  |                             list.add(map); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             /*改动范围end-------------------------------------------------------------------------*/ | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             for (Map<String, Object> map : list) { | 
 |  |  |                 String time = map.get("time").toString(); | 
 |  |  |                 time = time.substring(time.length() - 2); | 
 |  |  | 
 |  |  |  | 
 |  |  |     @PostMapping("byAccountGetDevices") | 
 |  |  |     public List<Device> byAccountGetDevices(@RequestBody Map<String, Object> parameters) { | 
 |  |  |         String id =parameters.get("id").toString(); | 
 |  |  |         String id = parameters.get("id").toString(); | 
 |  |  |         List<Device> devicesList = deviceService.getDevicesByAccountId(id); | 
 |  |  |         return devicesList; | 
 |  |  |     } | 
 |  |  | 
 |  |  |         //获取站点的所有设备 | 
 |  |  |         List<Device> deviceList = deviceService.getDevicesByMonitorPointId(539); | 
 |  |  |         //获取五分钟数据 | 
 |  |  |         Map<String,Object> pa = new HashMap<>(); | 
 |  |  |         Map<String, Object> pa = new HashMap<>(); | 
 |  |  |         //获取开始时间和结束时间 | 
 |  |  |         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |         Calendar beforeTime = Calendar.getInstance(); | 
 |  |  |         Date newTime = beforeTime.getTime(); | 
 |  |  |         beforeTime.add(Calendar.MINUTE,-5); | 
 |  |  |         beforeTime.add(Calendar.MINUTE, -5); | 
 |  |  |         Date startTime = beforeTime.getTime(); | 
 |  |  |         beforeTime.add(Calendar.MINUTE,6); | 
 |  |  |         beforeTime.add(Calendar.MINUTE, 6); | 
 |  |  |         Date endTime = beforeTime.getTime(); | 
 |  |  |         //pa.put("sensorKey","e1"); | 
 |  |  |         pa.put("yearAndMonth",sdf.format(newTime).substring(0,7).replace("-","")); | 
 |  |  |         pa.put("startTime",startTime); | 
 |  |  |         pa.put("endTime",endTime); | 
 |  |  |         pa.put("yearAndMonth", sdf.format(newTime).substring(0, 7).replace("-", "")); | 
 |  |  |         pa.put("startTime", startTime); | 
 |  |  |         pa.put("endTime", endTime); | 
 |  |  |         List<String> macs = new ArrayList<>(); | 
 |  |  |         List<String> sensorKeys = new ArrayList<>(); | 
 |  |  |         for (Device device:deviceList) { | 
 |  |  |         for (Device device : deviceList) { | 
 |  |  |             macs.add(device.getMac()); | 
 |  |  |         } | 
 |  |  |         sensorKeys.add(sensorKey); | 
 |  |  |         sensorKeys.add("e18"); | 
 |  |  |         sensorKeys.add("e23"); | 
 |  |  |         pa.put("macs",macs); | 
 |  |  |         pa.put("sensorKeys",sensorKeys); | 
 |  |  |         pa.put("macNumber",macs.size()); | 
 |  |  |         pa.put("macs", macs); | 
 |  |  |         pa.put("sensorKeys", sensorKeys); | 
 |  |  |         pa.put("macNumber", macs.size()); | 
 |  |  |         List<Map<String, Object>> fiveMinuteDataList = historyFiveMinutelyService.getFiveMinutesDataByMacsAndTimeSolt(pa); | 
 |  |  |         //声明数组,存放所有设备的数值 | 
 |  |  |         double[] allDeviceData = new double[fiveMinuteDataList.size()]; | 
 |  |  |         int i = 0; | 
 |  |  |         //计算风向 | 
 |  |  |         List<Map<String,Object>> windList = new ArrayList<>(); | 
 |  |  |         for (Map map:fiveMinuteDataList) { | 
 |  |  |         List<Map<String, Object>> windList = new ArrayList<>(); | 
 |  |  |         for (Map map : fiveMinuteDataList) { | 
 |  |  |             String[] wind_speed = map.get("e18").toString().split(","); | 
 |  |  |             if (!map.containsKey("e23")){ | 
 |  |  |             if (!map.containsKey("e23")) { | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             String[] wind_direction = map.get("e23").toString().split(","); | 
 |  |  |             Map<String,Object> windMap = new HashMap<>(); | 
 |  |  |             windMap.put("wind_speed",wind_speed[0].substring(1,wind_speed[0].length())); | 
 |  |  |             windMap.put("wind_direction",wind_direction[0].substring(1,wind_direction[0].length())); | 
 |  |  |             Map<String, Object> windMap = new HashMap<>(); | 
 |  |  |             windMap.put("wind_speed", wind_speed[0].substring(1, wind_speed[0].length())); | 
 |  |  |             windMap.put("wind_direction", wind_direction[0].substring(1, wind_direction[0].length())); | 
 |  |  |             windList.add(windMap); | 
 |  |  |             String[] sensorArr = map.get(sensorKey).toString().split(","); | 
 |  |  |             double sensorData = Double.parseDouble(sensorArr[0].substring(1,sensorArr[0].length())); | 
 |  |  |             double sensorData = Double.parseDouble(sensorArr[0].substring(1, sensorArr[0].length())); | 
 |  |  |             allDeviceData[i] = sensorData; | 
 |  |  |             i = i+1; | 
 |  |  |             i = i + 1; | 
 |  |  |         } | 
 |  |  |         //计算平均风向和风速 | 
 |  |  |         Map<String,Double> res = WindUtils.getWind_direction_speed(windList); | 
 |  |  |         Map<String, Double> res = WindUtils.getWind_direction_speed(windList); | 
 |  |  |         //计算该站点的点与污染源点的角度 | 
 |  |  |         Map<String,Double> angleMap = new HashMap(); | 
 |  |  |         MyLatLng pollutionSourcePoint_log_lat = new MyLatLng(pollutionSourcePoint.getLongitude(),pollutionSourcePoint.getLatitude()); | 
 |  |  |         for (Device device:deviceList) { | 
 |  |  |             MyLatLng device_log_lat = new MyLatLng(device.getLongitude(),device.getLatitude()); | 
 |  |  |         Map<String, Double> angleMap = new HashMap(); | 
 |  |  |         MyLatLng pollutionSourcePoint_log_lat = new MyLatLng(pollutionSourcePoint.getLongitude(), pollutionSourcePoint.getLatitude()); | 
 |  |  |         for (Device device : deviceList) { | 
 |  |  |             MyLatLng device_log_lat = new MyLatLng(device.getLongitude(), device.getLatitude()); | 
 |  |  |             //以设备为坐标原点,与污染源连线的角度 | 
 |  |  |             double angle = mapUtils.getAngle(device_log_lat,pollutionSourcePoint_log_lat); | 
 |  |  |             angleMap.put(device.getMac(),angle); | 
 |  |  |             double angle = mapUtils.getAngle(device_log_lat, pollutionSourcePoint_log_lat); | 
 |  |  |             angleMap.put(device.getMac(), angle); | 
 |  |  |         } | 
 |  |  |         Map<String,Double> disparityMap = new HashMap<>(); | 
 |  |  |         for (String key:angleMap.keySet()) { | 
 |  |  |             double angleDisparity = Math.abs(angleMap.get(key)-res.get("wind_direction")); | 
 |  |  |             if (angleDisparity>180){ | 
 |  |  |                 angleDisparity = 360-angleDisparity; | 
 |  |  |         Map<String, Double> disparityMap = new HashMap<>(); | 
 |  |  |         for (String key : angleMap.keySet()) { | 
 |  |  |             double angleDisparity = Math.abs(angleMap.get(key) - res.get("wind_direction")); | 
 |  |  |             if (angleDisparity > 180) { | 
 |  |  |                 angleDisparity = 360 - angleDisparity; | 
 |  |  |             } | 
 |  |  |             disparityMap.put(key,angleDisparity); | 
 |  |  |             disparityMap.put(key, angleDisparity); | 
 |  |  |         } | 
 |  |  |         Optional<Map.Entry<String, Double>> minDisparity = disparityMap.entrySet() | 
 |  |  |                 .stream() | 
 |  |  |                 .min(Map.Entry.comparingByValue()); | 
 |  |  |         //留下的任务:循环disparityMap,查出与minDisparity相等的值的key,以防出现两个点的角度差一样 | 
 |  |  |         List<String> minAngleDisparityMacList = new ArrayList<>(); | 
 |  |  |         for (String key:disparityMap.keySet()) { | 
 |  |  |             if (disparityMap.get(key) == minDisparity.get().getValue()){ | 
 |  |  |         for (String key : disparityMap.keySet()) { | 
 |  |  |             if (disparityMap.get(key) == minDisparity.get().getValue()) { | 
 |  |  |                 minAngleDisparityMacList.add(minDisparity.get().getKey()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         //定义一个map,存放设备点 | 
 |  |  |         Map<String,Object> fiveMinuteDataMap = new HashMap(); | 
 |  |  |         if (minAngleDisparityMacList.size()<2){//只有一个点 | 
 |  |  |             for (Map fiveMinuteData:fiveMinuteDataList) { | 
 |  |  |                 if (fiveMinuteData.get("mac").toString().equals(minAngleDisparityMacList.get(0))){ | 
 |  |  |         Map<String, Object> fiveMinuteDataMap = new HashMap(); | 
 |  |  |         if (minAngleDisparityMacList.size() < 2) {//只有一个点 | 
 |  |  |             for (Map fiveMinuteData : fiveMinuteDataList) { | 
 |  |  |                 if (fiveMinuteData.get("mac").toString().equals(minAngleDisparityMacList.get(0))) { | 
 |  |  |                     fiveMinuteDataMap.putAll(fiveMinuteData); | 
 |  |  |                     break; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         }else { | 
 |  |  |         } else { | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |         Device referenceDevice = new Device(); | 
 |  |  |         for (Device device:deviceList) { | 
 |  |  |             if (device.getMac().equals(fiveMinuteDataMap.get("mac"))){ | 
 |  |  |         for (Device device : deviceList) { | 
 |  |  |             if (device.getMac().equals(fiveMinuteDataMap.get("mac"))) { | 
 |  |  |                 referenceDevice = device; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         //计算污染平均值 | 
 |  |  |         double sum = 0; | 
 |  |  |         for (int j=0;j<allDeviceData.length;j++) { | 
 |  |  |             sum = sum+allDeviceData[j]; | 
 |  |  |         for (int j = 0; j < allDeviceData.length; j++) { | 
 |  |  |             sum = sum + allDeviceData[j]; | 
 |  |  |         } | 
 |  |  |         double deviceDataAvg = sum/allDeviceData.length; | 
 |  |  |         double deviceDataAvg = sum / allDeviceData.length; | 
 |  |  |         //计算污染源点与设备点之间的距离 | 
 |  |  |         double distance = mapUtils.getDistance(pollutionSourcePoint.getLongitude(),pollutionSourcePoint.getLatitude(),referenceDevice.getLongitude(),referenceDevice.getLatitude()); | 
 |  |  |         double distance = mapUtils.getDistance(pollutionSourcePoint.getLongitude(), pollutionSourcePoint.getLatitude(), referenceDevice.getLongitude(), referenceDevice.getLatitude()); | 
 |  |  |         //已知距离,角度,求x,y | 
 |  |  |         double x = Math.cos(Math.toRadians(minDisparity.get().getValue()))*distance; | 
 |  |  |         double y = Math.sin(Math.toRadians(minDisparity.get().getValue()))*distance; | 
 |  |  |         double x = Math.cos(Math.toRadians(minDisparity.get().getValue())) * distance; | 
 |  |  |         double y = Math.sin(Math.toRadians(minDisparity.get().getValue())) * distance; | 
 |  |  |         //获取设备的数值 | 
 |  |  |         String[] fiveMinuteData = fiveMinuteDataMap.get(sensorKey).toString().split(","); | 
 |  |  |         double c = Double.parseDouble(fiveMinuteData[0].substring(1,fiveMinuteData[0].length()))-deviceDataAvg; | 
 |  |  |         double c = Double.parseDouble(fiveMinuteData[0].substring(1, fiveMinuteData[0].length())) - deviceDataAvg; | 
 |  |  |         //计算源强 | 
 |  |  |         double pollutionSourceIntensity = EmissionDataUtil.getPollutionSourceIntensity(c,x,y,res.get("wind_speed")); | 
 |  |  |         double pollutionSourceIntensity = EmissionDataUtil.getPollutionSourceIntensity(c, x, y, res.get("wind_speed")); | 
 |  |  |  | 
 |  |  |         //存放地图中心点 | 
 |  |  |         Map<String,Object> center = new HashMap<>(); | 
 |  |  |         center.put("lng",120.997119); | 
 |  |  |         center.put("lat",31.451714); | 
 |  |  |         Map<String, Object> center = new HashMap<>(); | 
 |  |  |         center.put("lng", 120.997119); | 
 |  |  |         center.put("lat", 31.451714); | 
 |  |  |  | 
 |  |  |         //存放各个点位经纬度及数值 | 
 |  |  |         List<Map<String,Double>> numericalValueList = new ArrayList<>(); | 
 |  |  |         Map<String,Double> numericalValueMap = new HashMap<>(); | 
 |  |  |         numericalValueMap.put("lng",120.997119); | 
 |  |  |         numericalValueMap.put("lat",31.451714); | 
 |  |  |         numericalValueMap.put("count",0.027); | 
 |  |  |         List<Map<String, Double>> numericalValueList = new ArrayList<>(); | 
 |  |  |         Map<String, Double> numericalValueMap = new HashMap<>(); | 
 |  |  |         numericalValueMap.put("lng", 120.997119); | 
 |  |  |         numericalValueMap.put("lat", 31.451714); | 
 |  |  |         numericalValueMap.put("count", 0.027); | 
 |  |  |         numericalValueList.add(numericalValueMap); | 
 |  |  |         Map<String,Double> numericalValueMap2 = new HashMap<>(); | 
 |  |  |         numericalValueMap2.put("lng",120.99516); | 
 |  |  |         numericalValueMap2.put("lat",31.448664); | 
 |  |  |         numericalValueMap2.put("count",0.029); | 
 |  |  |         Map<String, Double> numericalValueMap2 = new HashMap<>(); | 
 |  |  |         numericalValueMap2.put("lng", 120.99516); | 
 |  |  |         numericalValueMap2.put("lat", 31.448664); | 
 |  |  |         numericalValueMap2.put("count", 0.029); | 
 |  |  |         numericalValueList.add(numericalValueMap2); | 
 |  |  |         Map<String,Double> numericalValueMap3 = new HashMap<>(); | 
 |  |  |         numericalValueMap3.put("lng",120.998538); | 
 |  |  |         numericalValueMap3.put("lat",31.449289); | 
 |  |  |         numericalValueMap3.put("count",0.033); | 
 |  |  |         Map<String, Double> numericalValueMap3 = new HashMap<>(); | 
 |  |  |         numericalValueMap3.put("lng", 120.998538); | 
 |  |  |         numericalValueMap3.put("lat", 31.449289); | 
 |  |  |         numericalValueMap3.put("count", 0.033); | 
 |  |  |         numericalValueList.add(numericalValueMap3); | 
 |  |  |         Map<String,Double> numericalValueMap4 = new HashMap<>(); | 
 |  |  |         numericalValueMap4.put("lng",120.998628); | 
 |  |  |         numericalValueMap4.put("lat",31.452027); | 
 |  |  |         numericalValueMap4.put("count",0.025); | 
 |  |  |         Map<String, Double> numericalValueMap4 = new HashMap<>(); | 
 |  |  |         numericalValueMap4.put("lng", 120.998628); | 
 |  |  |         numericalValueMap4.put("lat", 31.452027); | 
 |  |  |         numericalValueMap4.put("count", 0.025); | 
 |  |  |         numericalValueList.add(numericalValueMap4); | 
 |  |  |         Map<String,Double> numericalValueMap5 = new HashMap<>(); | 
 |  |  |         numericalValueMap5.put("lng",121.000383); | 
 |  |  |         numericalValueMap5.put("lat",31.451469); | 
 |  |  |         numericalValueMap5.put("count",0.05); | 
 |  |  |         Map<String, Double> numericalValueMap5 = new HashMap<>(); | 
 |  |  |         numericalValueMap5.put("lng", 121.000383); | 
 |  |  |         numericalValueMap5.put("lat", 31.451469); | 
 |  |  |         numericalValueMap5.put("count", 0.05); | 
 |  |  |         numericalValueList.add(numericalValueMap5); | 
 |  |  |         Map<String,Double> numericalValueMap6 = new HashMap<>(); | 
 |  |  |         numericalValueMap6.put("lng",120.999908); | 
 |  |  |         numericalValueMap6.put("lat",31.449389); | 
 |  |  |         numericalValueMap6.put("count",0.04); | 
 |  |  |         Map<String, Double> numericalValueMap6 = new HashMap<>(); | 
 |  |  |         numericalValueMap6.put("lng", 120.999908); | 
 |  |  |         numericalValueMap6.put("lat", 31.449389); | 
 |  |  |         numericalValueMap6.put("count", 0.04); | 
 |  |  |         numericalValueList.add(numericalValueMap6); | 
 |  |  |         Map<String,Double> numericalValueMap7 = new HashMap<>(); | 
 |  |  |         numericalValueMap7.put("lng",120.998519); | 
 |  |  |         numericalValueMap7.put("lat",31.450588); | 
 |  |  |         numericalValueMap7.put("count",0.10); | 
 |  |  |         Map<String, Double> numericalValueMap7 = new HashMap<>(); | 
 |  |  |         numericalValueMap7.put("lng", 120.998519); | 
 |  |  |         numericalValueMap7.put("lat", 31.450588); | 
 |  |  |         numericalValueMap7.put("count", 0.10); | 
 |  |  |         numericalValueList.add(numericalValueMap7); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         JSONObject params = new JSONObject(); | 
 |  |  |         params.put("accountId",190); | 
 |  |  |         params.put("level",17); | 
 |  |  |         params.put("center",center); | 
 |  |  |         params.put("points",numericalValueList); | 
 |  |  |  | 
 |  |  |         params.put("accountId", 190); | 
 |  |  |         params.put("level", 17); | 
 |  |  |         params.put("center", center); | 
 |  |  |         params.put("points", numericalValueList); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         //获取公司信息 |