src/main/java/com/moral/controller/ScreenController.java
@@ -727,6 +727,7 @@ */ /*改动范围start-------------------------------------------------------------------------*/ list.remove(0); //if (list.size() == 23) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); //获取全格式时间yyyy-MM-dd HH:mm:ss @@ -744,9 +745,10 @@ datas.put("time",time1); list.add(datas); } //} /*改动范围end-------------------------------------------------------------------------*/ for (Map<String, Object> map : list) { String time = map.get("time").toString(); time = time.substring(time.length() - 2); src/main/java/com/moral/entity/PollutionSourcePoint.java
New file @@ -0,0 +1,17 @@ package com.moral.entity; import lombok.Data; import javax.persistence.Id; @Data public class PollutionSourcePoint { @Id Integer id; Integer monitorPointId; Double longitude; Double latitude; } src/main/java/com/moral/mapper/HistoryFiveMinutelyMapper.java
@@ -9,4 +9,5 @@ Map<String,Object> getFiveMinutesDataByMac(Map<String,Object> parameters); List<Map<String,Object>> getFiveMinutesSersorDataByMacsAndTime(Map<String,Object> parameters); } src/main/java/com/moral/mapper/PollutionSourcPointMapper.java
New file @@ -0,0 +1,13 @@ package com.moral.mapper; import com.moral.entity.DeviceAdjustValueTiming; import com.moral.entity.PollutionSourcePoint; import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; public interface PollutionSourcPointMapper { PollutionSourcePoint selectByMonitorPointId(@Param("monitorPointId") Integer monitorPointId); } src/main/java/com/moral/service/HistoryFiveMinutelyService.java
@@ -7,4 +7,6 @@ List<Map<String, Object>> getFiveMinutesDataByMacsAndTime(Map<String, Object> parameters); Map<String,Object> getFiveMinutesDataByMac(Map<String, Object> parameters); List<Map<String, Object>> getFiveMinutesSersorDataByMacsAndTime(Map<String,Object> parameters); } src/main/java/com/moral/service/PollutioSourcePointService.java
New file @@ -0,0 +1,7 @@ package com.moral.service; import com.moral.entity.PollutionSourcePoint; public interface PollutioSourcePointService { PollutionSourcePoint selectByMonitorPointId(Integer monitorPointId); } src/main/java/com/moral/service/impl/HistoryFiveMinutelyServiceImpl.java
@@ -26,5 +26,11 @@ return historyFiveMinutelyMapper.getFiveMinutesDataByMac(parameters); } @Override public List<Map<String, Object>> getFiveMinutesSersorDataByMacsAndTime(Map<String, Object> parameters) { ValidateUtil.notNull(parameters,"查询五分钟数据参数为空"); return historyFiveMinutelyMapper.getFiveMinutesSersorDataByMacsAndTime(parameters); } } src/main/java/com/moral/service/impl/PollutioSourcePointServiceImpl.java
New file @@ -0,0 +1,21 @@ package com.moral.service.impl; import com.moral.entity.PollutionSourcePoint; import com.moral.mapper.PollutionSourcPointMapper; import com.moral.service.PollutioSourcePointService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @Service public class PollutioSourcePointServiceImpl implements PollutioSourcePointService { @Resource private PollutionSourcPointMapper pollutionSourcPointMapper; @Override public PollutionSourcePoint selectByMonitorPointId(Integer monitorPointId) { PollutionSourcePoint result = pollutionSourcPointMapper.selectByMonitorPointId(monitorPointId); return result; } } src/main/java/com/moral/util/EmissionDataUtil.java
New file @@ -0,0 +1,27 @@ package com.moral.util; public class EmissionDataUtil { //计算污染源强度(参数:c:设备点测到是数据,x:源点到【设备点与风向垂线交点】的距离,y:设备点到【设备点与风向垂线交点】的距离,u:风速) public static Double getPollutionSourceIntensity(Double c, Double x, Double y, Double u){ double e = 2.718281828; double r1 = 0.281846; double r2 = 0.127190; double x1 = 0.914370; double x2 = 0.964435; double π = Math.PI; double diffusionCoefficient_y = r1*Math.pow(x,x1);//扩散系数y double diffusionCoefficient_z = r2*Math.pow(x,x2);//扩散系数z double molecule = c*2*π*u*diffusionCoefficient_y*diffusionCoefficient_z; double power = -1/2*(Math.pow(y,2)/Math.pow(diffusionCoefficient_y,2)); double denominator = Math.pow(e,power); double pollutionSourceIntensity = molecule/denominator; return pollutionSourceIntensity; } public static void main(String[] args) { double result = EmissionDataUtil.getPollutionSourceIntensity(100.0,10.0,5.0,3.0); System.out.println(result); } } src/main/java/com/moral/util/WindUtils.java
New file @@ -0,0 +1,88 @@ package com.moral.util; import java.util.HashMap; import java.util.List; import java.util.Map; public class WindUtils { /** *@Description: 根据方向和风速,获取UV风向 * @return: < com.moral.entity.Device>> * @Author: lizijie * @Date: 2020/12/03 * * */ public static Map<String, Double> getWind_direction_speed(List<Map<String, Object>> list){ //定义u:水平方向,v:竖直方向 double u = 0; double v = 0; for (Map map:list) { double u1 = 0; double v1 = 0; double wind_speed = Double.parseDouble(map.get("wind_speed").toString()); double wind_direction = Double.parseDouble(map.get("wind_direction").toString()); if (wind_speed == 0){ continue;//如果风速为0,结束此次循环,进入下次循环 } if (wind_direction==0){ u1 = 0; v1 = wind_speed*1; }else if (0<wind_direction&&wind_direction<90){ u1 = wind_speed*Math.sin(wind_direction); v1 = wind_speed*Math.cos(wind_direction); }else if (wind_direction == 90){ u1 = wind_speed*1; v1 = 0; }else if (90<wind_direction&&wind_direction<180){ u1 = wind_speed*Math.sin(180-wind_direction); v1 = -1*wind_speed*Math.cos(180-wind_direction); }else if (wind_direction == 180){ u1 = 0; v1 = wind_speed*-1; }else if (180<wind_direction&&wind_direction<270){ u1 = -1*wind_speed*Math.sin(wind_direction-180); v1 = -1*wind_speed*Math.cos(wind_direction-180); }else if (wind_direction == 270){ u1 = wind_speed*-1; v1 = 0; }else if (270<wind_direction&&wind_direction<360){ u1 = wind_speed*Math.sin(360-wind_direction); v1 = -1*wind_speed*Math.cos(360-wind_direction); } u = u+u1; v = v+v1; } Map<String,Double> windDirectionSpeedMap = new HashMap<>(); if (u==0&&v==0){ windDirectionSpeedMap.put("wind_direction",0.0); windDirectionSpeedMap.put("wind_speed",0.0); }else if (u==0&&v>0){ windDirectionSpeedMap.put("wind_direction",0.0); windDirectionSpeedMap.put("wind_speed",v); }else if (u>0&&v>0){ windDirectionSpeedMap.put("wind_direction",Math.atan2(u,v)); windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)); }else if (u>0&&v==0){ windDirectionSpeedMap.put("wind_direction",90.0); windDirectionSpeedMap.put("wind_speed",u); }else if (u>0&&v<0){ windDirectionSpeedMap.put("wind_direction",Math.atan2(-v,u)+90); windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)); }else if (u==0&&v<0){ windDirectionSpeedMap.put("wind_direction",180.0); windDirectionSpeedMap.put("wind_speed",-v); }else if (u<0&&v<0){ windDirectionSpeedMap.put("wind_direction",Math.atan2(-u,-v)+180); windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)); }else if (u<0&&v==0){ windDirectionSpeedMap.put("wind_direction",270.0); windDirectionSpeedMap.put("wind_speed",-u); }else if (u<0&&v>0){ windDirectionSpeedMap.put("wind_direction",Math.atan2(v,-u)+270); windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)); } return windDirectionSpeedMap; } } src/main/resources/mapper/HistoryFiveMinutelyMapper.xml
@@ -20,4 +20,16 @@ where h.time = #{time} and h.mac = #{mac} </select> <select id="getFiveMinutesSersorDataByMacsAndTime" resultType="map"> SELECT h.mac,h.time, <foreach collection="sensorKeys" separator="," item="sensorKey"> json->'$.${sensorKey}' AS '${sensorKey}' </foreach> from history_five_minutely_${yearAndMonth} h where time = #{time} and mac IN <foreach collection="macs" separator="," open="(" close=")" item="mac"> #{mac} </foreach> </select> </mapper> src/main/resources/mapper/PollutionSourcePointMapper.xml
New file @@ -0,0 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.moral.mapper.PollutionSourcPointMapper"> <resultMap id="BaseResultMap" type="com.moral.entity.PollutionSourcePoint" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="monitor_point_id" property="monitorPointId" jdbcType="INTEGER" /> <result column="longitude" property="longitude" jdbcType="NUMERIC" /> <result column="latitude" property="latitude" jdbcType="NUMERIC" /> </resultMap> <select id="selectByMonitorPointId" resultType="com.moral.entity.PollutionSourcePoint" resultMap="BaseResultMap"> select * from pollution_source_point where monitor_point_id = #{monitorPointId} </select> </mapper>