From d903f312cf6a1d0fc4c5745832a9d6fa681e5141 Mon Sep 17 00:00:00 2001 From: 于紫祥_1901 <email@yuzixiang_1910> Date: Tue, 30 Jun 2020 09:16:07 +0800 Subject: [PATCH] update(无组织排放) --- src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java | 375 +++++++++++++++++++++++++++------------------------- 1 files changed, 194 insertions(+), 181 deletions(-) diff --git a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java index e3aa674..3f1f427 100644 --- a/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java +++ b/src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java @@ -518,215 +518,228 @@ List<Map> windList = new ArrayList<Map>();//��������������������������������������� Map<String, Object> jsonMap = new HashMap<String, Object>();//��������������������� Map<String, Object> deviceMap = null; - for (Device device : deviceList) { - deviceMap = new HashMap<String, Object>(); - smac = device.getMac(); - latitude = device.getLatitude(); - longitude = device.getLongitude(); + if (deviceList.size()>1){ + for (Device device : deviceList) { + deviceMap = new HashMap<String, Object>(); + smac = device.getMac(); + latitude = device.getLatitude(); + longitude = device.getLongitude(); - jsonMap = historyHourlyService.getDataByMac(smac, Time); - deviceMap.put("longitude", longitude); - deviceMap.put("latitude", latitude); - if (jsonMap != null) { - deviceMap.put("jsonMap", jsonMap); - } else { - deviceMap.put("jsonMap", "������������������������������"); - } - - list.add(deviceMap); - } - Map<String, Object> mapData = new HashMap<String, Object>(); - Map<String, Object> mapDevice; - JSONArray windDir; - for (Map<String, Object> objectMap : list) { - mapDevice = new HashMap<String, Object>(); - Map<String, Object> map = null; - if (!(objectMap.get("jsonMap") instanceof String)) { - mapData = (Map<String, Object>) objectMap.get("jsonMap"); - map = (Map) JSON.parseObject((String) mapData.get("json")); - windDir = (JSONArray) JSONArray.toJSON(map.get("e23")); - JSONArray concentration = (JSONArray) JSONArray.toJSON(map.get(sensor)); - - BigDecimal bigDecimal1=new BigDecimal(0); - BigDecimal bigDecimal=new BigDecimal(0); - if (concentration!=null){ - if (concentration.get(0) instanceof Integer){ - bigDecimal1 =new BigDecimal(concentration.get(0).toString()); - }else { - bigDecimal1= (BigDecimal) concentration.get(0); - } - if (windDir!=null){ - if (windDir.get(0) instanceof Integer){ - bigDecimal =new BigDecimal(windDir.get(0).toString()); - }else { - bigDecimal=(BigDecimal) windDir.get(0); - } - mapDevice.put("e23", bigDecimal.doubleValue()); - mapDevice.put("sensor", bigDecimal1.doubleValue()); - mapDevice.put("longitude", objectMap.get("longitude")); - mapDevice.put("latitude", objectMap.get("latitude")); - }else { - mapDevice.put("noSensor", "���������������"); - mapDevice.put("longitude", objectMap.get("longitude")); - mapDevice.put("latitude", objectMap.get("latitude")); - } + jsonMap = historyHourlyService.getDataByMac(smac, Time); + deviceMap.put("longitude", longitude); + deviceMap.put("latitude", latitude); + if (jsonMap != null) { + deviceMap.put("jsonMap", jsonMap); + } else { + deviceMap.put("jsonMap", "������������������������������"); } - } else { - mapDevice.put("info", objectMap.get("jsonMap")); - mapDevice.put("longitude", objectMap.get("longitude")); - mapDevice.put("latitude", objectMap.get("latitude")); - } - windList.add(mapDevice); - } - // if (windDir!=null){} - Double differenceNum = 0.0; - Map<String, Object> indexMap; - List<Map> mapList = new ArrayList<>(); - for (int j = 0; j < windList.size(); j++) { - for (int k = 0; k < windList.size(); k++) { - if (k != j) { - indexMap = new HashMap<String, Object>(); - if (windList.get(k).containsKey("e23") && windList.get(j).containsKey("e23")) { - Double e23Numk = (Double) windList.get(k).get("e23"); - Double e23Numj = (Double) windList.get(j).get("e23"); - Double diff = e23Numk - e23Numj; - BigDecimal b = new BigDecimal(Math.abs(diff)); - differenceNum = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); - if (differenceNum > 180) { - differenceNum = 360 - differenceNum; + list.add(deviceMap); + } + Map<String, Object> mapData = new HashMap<String, Object>(); + Map<String, Object> mapDevice; + JSONArray windDir; + for (Map<String, Object> objectMap : list) { + mapDevice = new HashMap<String, Object>(); + Map<String, Object> map = null; + if (!(objectMap.get("jsonMap") instanceof String)) { + mapData = (Map<String, Object>) objectMap.get("jsonMap"); + map = (Map) JSON.parseObject((String) mapData.get("json")); + windDir = (JSONArray) JSONArray.toJSON(map.get("e23")); + JSONArray concentration = (JSONArray) JSONArray.toJSON(map.get(sensor)); + + BigDecimal bigDecimal1=new BigDecimal(0); + BigDecimal bigDecimal=new BigDecimal(0); + if (concentration!=null){ + if (concentration.get(0) instanceof Integer){ + bigDecimal1 =new BigDecimal(concentration.get(0).toString()); + }else { + bigDecimal1= (BigDecimal) concentration.get(0); } - indexMap.put("k", k); - indexMap.put("j", j); - indexMap.put("diff", differenceNum); - } else { - indexMap.put("k", k); - indexMap.put("j", j); - indexMap.put("info", "���������������"); + if (windDir!=null){ + if (windDir.get(0) instanceof Integer){ + bigDecimal =new BigDecimal(windDir.get(0).toString()); + }else { + bigDecimal=(BigDecimal) windDir.get(0); + } + mapDevice.put("e23", bigDecimal.doubleValue()); + mapDevice.put("sensor", bigDecimal1.doubleValue()); + mapDevice.put("longitude", objectMap.get("longitude")); + mapDevice.put("latitude", objectMap.get("latitude")); + }else { + mapDevice.put("noSensor", "���������������"); + mapDevice.put("longitude", objectMap.get("longitude")); + mapDevice.put("latitude", objectMap.get("latitude")); + } } + } else { + mapDevice.put("info", objectMap.get("jsonMap")); + mapDevice.put("longitude", objectMap.get("longitude")); + mapDevice.put("latitude", objectMap.get("latitude")); + } + windList.add(mapDevice); + } + // if (windDir!=null){} + Double differenceNum = 0.0; + Map<String, Object> indexMap; + List<Map> mapList = new ArrayList<>(); + for (int j = 0; j < windList.size(); j++) { + for (int k = 0; k < windList.size(); k++) { + if (k != j) { + indexMap = new HashMap<String, Object>(); + if (windList.get(k).containsKey("e23") && windList.get(j).containsKey("e23")) { + Double e23Numk = (Double) windList.get(k).get("e23"); + Double e23Numj = (Double) windList.get(j).get("e23"); + Double diff = e23Numk - e23Numj; + BigDecimal b = new BigDecimal(Math.abs(diff)); + + differenceNum = b.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); + if (differenceNum > 180) { + differenceNum = 360 - differenceNum; + } + indexMap.put("k", k); + indexMap.put("j", j); + indexMap.put("diff", differenceNum); + } else { + indexMap.put("k", k); + indexMap.put("j", j); + indexMap.put("info", "���������������"); + } // indexMap.put("longitude",windList.get(k).get("longitude")); // indexMap.put("latitude",windList.get(k).get("latitude")); - mapList.add(indexMap); - } else { - continue; - } + mapList.add(indexMap); + } else { + continue; + } + } } - } - Double min = 0.0; - int indexMin = 0; - if (mapList.size()>0){ - if (mapList.get(0).containsKey("diff")) { - min = (Double) mapList.get(0).get("diff"); - for (int q = 1; q < mapList.size(); q++) { - if (mapList.get(q).containsKey("diff")) { - if (min > (Double) mapList.get(q).get("diff")) { - min = (Double) mapList.get(q).get("diff"); + Double min = 0.0; + int indexMin = 0; + if (mapList.size()>0){ + if (mapList.get(0).containsKey("diff")) { + min = (Double) mapList.get(0).get("diff"); + for (int q = 1; q < mapList.size(); q++) { + if (mapList.get(q).containsKey("diff")) { + if (min > (Double) mapList.get(q).get("diff")) { + min = (Double) mapList.get(q).get("diff"); + indexMin = q; + } + } else { indexMin = q; } - } else { - indexMin = q; } } } - } - Map twoDeviceMap = mapList.get(indexMin); - List<Map> list1 = new ArrayList<Map>(); //��������������������������������������������������� - list1.add(windList.get((Integer) twoDeviceMap.get("k"))); - list1.add(windList.get((Integer) twoDeviceMap.get("j"))); - Double wind = 0.0; - Double sum = 0.0; - if (list1.get(0).containsKey("e23")) { - if (Math.abs((Double) list1.get(0).get("e23") - (Double) list1.get(1).get("e23")) > 180) { - sum = (Double) list1.get(0).get("e23") + (Double) list1.get(1).get("e23"); - wind = sum / 2 + 180; - if (wind > 360) { - wind = wind - 360; + Map twoDeviceMap = mapList.get(indexMin); + List<Map> list1 = new ArrayList<Map>(); //��������������������������������������������������� + list1.add(windList.get((Integer) twoDeviceMap.get("k"))); + list1.add(windList.get((Integer) twoDeviceMap.get("j"))); + + Double wind = 0.0; + Double sum = 0.0; + if (list1.get(0).containsKey("e23")) { + if (Math.abs((Double) list1.get(0).get("e23") - (Double) list1.get(1).get("e23")) > 180) { + sum = (Double) list1.get(0).get("e23") + (Double) list1.get(1).get("e23"); + wind = sum / 2 + 180; + if (wind > 360) { + wind = wind - 360; + } + } else { + for (Map map : list1) { + sum += (Double) map.get("e23"); + } + wind = sum / 2; } } else { - for (Map map : list1) { - sum += (Double) map.get("e23"); - } - wind = sum / 2; + wind = 0.0; } - } else { - wind = 0.0; - } - Map<String, Object> longAndLatiMap; - List<Map> longAndLatiList = new ArrayList<>();//������������������������������������windList������������������������������������������������������������������ - List<Map> preAngleDeviceList = new ArrayList<Map>(); //��������������������������������������� - if (wind != 0.0) { - for (int f = 0; f < windList.size(); f++) { - for (int h = 0; h < windList.size(); h++) { - if (f != h) { - longAndLatiMap = new HashMap<String, Object>(); - longAndLatiMap.put("h", h); - longAndLatiMap.put("f", f); - Double angle = mapUtils.getAngle( - new MyLatLng((Double) windList.get(h).get("longitude"), - (Double) windList.get(h).get("latitude")), - new MyLatLng((Double) windList.get(f).get("longitude"), - (Double) windList.get(f).get("latitude"))); - Double angleDiff = Math.abs(angle - wind); - longAndLatiMap.put("angle", angleDiff); - longAndLatiList.add(longAndLatiMap); + Map<String, Object> longAndLatiMap; + List<Map> longAndLatiList = new ArrayList<>();//������������������������������������windList������������������������������������������������������������������ + List<Map> preAngleDeviceList = new ArrayList<Map>(); //��������������������������������������� + if (wind != 0.0) { + for (int f = 0; f < windList.size(); f++) { + for (int h = 0; h < windList.size(); h++) { + if (f != h) { + longAndLatiMap = new HashMap<String, Object>(); + longAndLatiMap.put("h", h); + longAndLatiMap.put("f", f); + Double angle = mapUtils.getAngle( + new MyLatLng((Double) windList.get(h).get("longitude"), + (Double) windList.get(h).get("latitude")), + new MyLatLng((Double) windList.get(f).get("longitude"), + (Double) windList.get(f).get("latitude"))); + Double angleDiff = Math.abs(angle - wind); + longAndLatiMap.put("angle", angleDiff); + longAndLatiList.add(longAndLatiMap); + } } } - } - Double minAngle = (Double) longAndLatiList.get(0).get("angle"); - int indexAngle = 0; - for (int j = 0; j < longAndLatiList.size(); j++) { - if (minAngle > (Double) longAndLatiList.get(j).get("angle")) { - minAngle = (Double) longAndLatiList.get(j).get("angle"); - indexAngle = j; + Double minAngle = (Double) longAndLatiList.get(0).get("angle"); + int indexAngle = 0; + for (int j = 0; j < longAndLatiList.size(); j++) { + if (minAngle > (Double) longAndLatiList.get(j).get("angle")) { + minAngle = (Double) longAndLatiList.get(j).get("angle"); + indexAngle = j; + } } + //windList.get((Integer) longAndLatiList.get(indexAngle).get("f"))������������������������ + preAngleDeviceList.add(windList.get((Integer) longAndLatiList.get(indexAngle).get("h"))); + preAngleDeviceList.add(windList.get((Integer) longAndLatiList.get(indexAngle).get("f"))); + + Double length = mapUtils.getDistance((Double) preAngleDeviceList.get(0).get("longitude"), (Double) preAngleDeviceList.get(0).get("latitude"), + (Double) preAngleDeviceList.get(1).get("longitude"), (Double) preAngleDeviceList.get(1).get("latitude")); + Double subLength = length/5; + Double subLength1 = length/6.1; + Double angle = mapUtils.getAngle( + new MyLatLng((Double) preAngleDeviceList.get(0).get("longitude"), + (Double) preAngleDeviceList.get(0).get("latitude")), + new MyLatLng((Double) preAngleDeviceList.get(1).get("longitude"), + (Double) preAngleDeviceList.get(1).get("latitude"))); + + params.put("preAngleDeviceList", preAngleDeviceList); + params.put("angle", angle); + List locationList = new ArrayList(); + String[] firstLocation = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, (Double) preAngleDeviceList.get(0).get("longitude"), + (Double) preAngleDeviceList.get(0).get("latitude"), subLength); + String[] secondLoction = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(firstLocation[0]), + Double.parseDouble(firstLocation[1]), subLength); + String[] thirdLocation = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(secondLoction[0]), + Double.parseDouble(secondLoction[1]), subLength); + String[] fourthLoction = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(thirdLocation[0]), + Double.parseDouble(thirdLocation[1]), subLength); + String[] fivethLoction = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(fourthLoction[0]), + Double.parseDouble(fourthLoction[1]), subLength1); + locationList.add(firstLocation); + locationList.add(secondLoction); + locationList.add(thirdLocation); + locationList.add(fourthLoction); + locationList.add(fivethLoction); + params.put("locationList", locationList); + + String preAngleDeviceString = JSON.toJSON(preAngleDeviceList).toString(); + params.put("preAngleDeviceString", preAngleDeviceString);//��������������������������� + } else { + params.put("preAngleDeviceString", 0); } - //windList.get((Integer) longAndLatiList.get(indexAngle).get("f"))������������������������ - preAngleDeviceList.add(windList.get((Integer) longAndLatiList.get(indexAngle).get("h"))); - preAngleDeviceList.add(windList.get((Integer) longAndLatiList.get(indexAngle).get("f"))); - - Double length = mapUtils.getDistance((Double) preAngleDeviceList.get(0).get("longitude"), (Double) preAngleDeviceList.get(0).get("latitude"), - (Double) preAngleDeviceList.get(1).get("longitude"), (Double) preAngleDeviceList.get(1).get("latitude")); - Double subLength = length / 5; - Double angle = mapUtils.getAngle( - new MyLatLng((Double) preAngleDeviceList.get(0).get("longitude"), - (Double) preAngleDeviceList.get(0).get("latitude")), - new MyLatLng((Double) preAngleDeviceList.get(1).get("longitude"), - (Double) preAngleDeviceList.get(1).get("latitude"))); - - params.put("preAngleDeviceList", preAngleDeviceList); - params.put("angle", angle); - List locationList = new ArrayList(); - String[] firstLocation = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, (Double) preAngleDeviceList.get(0).get("longitude"), - (Double) preAngleDeviceList.get(0).get("latitude"), subLength); - String[] secondLoction = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(firstLocation[0]), - Double.parseDouble(firstLocation[1]), subLength); - String[] thirdLocation = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(secondLoction[0]), - Double.parseDouble(secondLoction[1]), subLength); - String[] fourthLoction = mapUtils.calLocationByDistanceAndLocationAndDirection(angle, Double.parseDouble(thirdLocation[0]), - Double.parseDouble(thirdLocation[1]), subLength); - locationList.add(firstLocation); - locationList.add(secondLoction); - locationList.add(thirdLocation); - locationList.add(fourthLoction); - params.put("locationList", locationList); - - String preAngleDeviceString = JSON.toJSON(preAngleDeviceList).toString(); - params.put("preAngleDeviceString", preAngleDeviceString);//��������������������������� - } else { - params.put("preAngleDeviceString", ""); + params.put("wind", wind); + //String preAngleDeviceString=preAngleDeviceList. + params.put("deviceList", deviceList); + }else { + if (deviceList.size()!=0){ + params.put("deviceList", deviceList.get(0)); + }else { + params.put("deviceList",""); + } + params.put("preAngleDeviceString", 1); + params.put("locationList", ""); } - //String preAngleDeviceString=preAngleDeviceList. - params.put("wind", wind); - params.put("list1", list1); - params.put("deviceList", deviceList); params.put("latitudeCompany", latitudeCompany); params.put("longitudeCompany", longitudeCompany); } - return params; } -- Gitblit v1.8.0