From b8a05e777e760e1937258544da1494b2d93055d0 Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Thu, 17 Dec 2020 15:51:06 +0800
Subject: [PATCH] UV风向工具类修改,根据时间段获取五分钟数据

---
 src/main/java/com/moral/controller/ScreenController.java |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java
index a617066..3f68ae4 100644
--- a/src/main/java/com/moral/controller/ScreenController.java
+++ b/src/main/java/com/moral/controller/ScreenController.java
@@ -3013,6 +3013,7 @@
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "monitorPointId", value = "������Id", required = true, paramType = "query", dataType = "String"),
             @ApiImplicitParam(name = "sensorKey", value = "������", required = true, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "realTime", value = "������", required = true, paramType = "query", dataType = "String"),
             @ApiImplicitParam(name = "accountId", value = "������id", required = false, paramType = "query", dataType = "String")})
     public ModelAndView unorganizedEmissionsBackupsV2(HttpServletRequest request, ModelAndView model) {
         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
@@ -3023,9 +3024,18 @@
         List<Device> deviceList = deviceService.getDevicesByMonitorPointId(539);
         //���������������������
         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);
+        Date startTime = beforeTime.getTime();
+        beforeTime.add(Calendar.MINUTE,6);
+        Date endTime = beforeTime.getTime();
         //pa.put("sensorKey","e1");
-        pa.put("yearAndMonth","202012");
-        pa.put("time","2020-12-03 10:10:00");
+        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) {
@@ -3036,7 +3046,8 @@
         sensorKeys.add("e23");
         pa.put("macs",macs);
         pa.put("sensorKeys",sensorKeys);
-        List<Map<String, Object>> fiveMinuteDataList = historyFiveMinutelyService.getFiveMinutesSersorDataByMacsAndTime(pa);
+        pa.put("macNumber",macs.size());
+        List<Map<String, Object>> fiveMinuteDataList = historyFiveMinutelyService.getFiveMinutesDataByMacsAndTimeSolt(pa);
         //������������������������������������������
         double[] allDeviceData = new double[fiveMinuteDataList.size()];
         System.out.println(fiveMinuteDataList);
@@ -3045,6 +3056,9 @@
         List<Map<String,Object>> windList = new ArrayList<>();
         for (Map map:fiveMinuteDataList) {
             String[] wind_speed = map.get("e18").toString().split(",");
+            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()));
@@ -3056,7 +3070,9 @@
             i = i+1;
         }
         //���������������������������
+        System.out.println("windList:"+windList);
         Map<String,Double> res = WindUtils.getWind_direction_speed(windList);
+        System.out.println("res:"+res);
         //���������������������������������������������
         Map<String,Double> angleMap = new HashMap();
         MyLatLng pollutionSourcePoint_log_lat = new MyLatLng(pollutionSourcePoint.getLongitude(),pollutionSourcePoint.getLatitude());
@@ -3110,15 +3126,23 @@
         double deviceDataAvg = sum/allDeviceData.length;
         //���������������������������������������������
         double distance = mapUtils.getDistance(pollutionSourcePoint.getLongitude(),pollutionSourcePoint.getLatitude(),referenceDevice.getLongitude(),referenceDevice.getLatitude());
+        System.out.println("distance:"+distance);
         //���������������������������x,y
-        double x = Math.cos(minDisparity.get().getValue())*distance;
-        double y = Math.sin(minDisparity.get().getValue())*distance;
+        System.out.println(minDisparity.get().getValue());
+        double x = Math.cos(Math.toRadians(minDisparity.get().getValue()))*distance;
+        System.out.println("���������������"+Math.cos(minDisparity.get().getValue()));
+        System.out.println(x);
+        double y = Math.sin(Math.toRadians(minDisparity.get().getValue()))*distance;
         //���������������������
-        String[] fiveMinuteData = fiveMinuteDataMap.get("e21").toString().split(",");
+        String[] fiveMinuteData = fiveMinuteDataMap.get(sensorKey).toString().split(",");
         double c = Double.parseDouble(fiveMinuteData[0].substring(1,fiveMinuteData[0].length()))-deviceDataAvg;
         System.out.println(c);
         //������������
         double pollutionSourceIntensity = EmissionDataUtil.getPollutionSourceIntensity(c,x,y,res.get("wind_speed"));
+        System.out.println("c���"+c);
+        System.out.println("x���"+x);
+        System.out.println("y���"+y);
+        System.out.println("���������"+res.get("wind_speed"));
         System.out.println(pollutionSourceIntensity);
 
         //���������������������

--
Gitblit v1.8.0