燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-06-16 73ff23c1359f5688760ea0279c526136414127ac
1
已添加1个文件
已修改6个文件
252 ■■■■ 文件已修改
src/main/java/com/yssh/dao/SuYuanMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/entity/Coordinate.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/entity/DistanceSuYuan.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/entity/Report.java 131 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/utils/CalculateUtils.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapping/SuYuanMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/dao/SuYuanMapper.java
@@ -26,6 +26,8 @@
    List<DistanceSuYuan> getDistanceSuYuan(@Param("tableName") String tableName, @Param("ids") List<String> ids);
    DistanceSuYuan getSuYuan500Max(@Param("tableName") String tableName, @Param("ids") List<String> ids);
    DistanceSuYuan getSuYuanById(@Param("tableName") String tableName, @Param("id") String id);
    
    List<Temporary> getTemporary(@Param("tableName") String tableName, @Param("ids") List<String> ids);
    
src/main/java/com/yssh/entity/Coordinate.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package com.yssh.entity;
/**
 * åæ ‡
 * @author WWW
 * @date 2023-06-18
 */
public class Coordinate {
    private double x;
    private double y;
    public Coordinate() {
    }
    public Coordinate(double x, double y) {
        this.x = x;
        this.y = y;
    }
    public double getX() {
        return x;
    }
    public void setX(double x) {
        this.x = x;
    }
    public double getY() {
        return y;
    }
    public void setY(double y) {
        this.y = y;
    }
}
src/main/java/com/yssh/entity/DistanceSuYuan.java
@@ -100,5 +100,28 @@
        }
        return 1;
    }
    public double getU() {
        return u;
    }
    public double getV() {
        return v;
    }
    public void setWindSpeed(double windSpeed) {
        this.windSpeed = windSpeed;
    }
    public void setWindDirection(double windDirection) {
        this.windDirection = windDirection;
    }
    public void setLon(double lon) {
        this.lon = lon;
    }
    public void setLat(double lat) {
        this.lat = lat;
    }
}
src/main/java/com/yssh/entity/Report.java
@@ -3,8 +3,6 @@
import com.yssh.utils.CalculateUtils;
import io.swagger.annotations.ApiModelProperty;
import java.text.SimpleDateFormat;
/**
 * æŠ¥å‘Š
 * @author WWW
@@ -21,61 +19,76 @@
    private double lat;
    @ApiModelProperty(value = "数值")
    private double value;
    private double val;
    @ApiModelProperty(value = "去年数值")
    private double lastVal;
    @ApiModelProperty(value = "时间")
    private String time;
    @ApiModelProperty(value = "500m范围最大值")
    private double max;
    @ApiModelProperty(value = "距离")
    private double dis;
    @ApiModelProperty(value = "风速")
    private double speed;
    @ApiModelProperty(value = "方向")
    private String dir;
    @ApiModelProperty(value = "500m范围最大值")
    private double maxVal;
    @ApiModelProperty(value = "距离")
    private double dis;
    @ApiModelProperty(value = "500m范围最大值的方向")
    private String maxDir;
    @ApiModelProperty(value = "是否一致")
    private int isSame;
    public Report() {
    }
    public Report(String name, double lon, double lat, double value, String time, double max, double dis, String dir) {
    public Report(String name, double lon, double lat, double val, double lastVal, String time, double speed, String dir, double maxVal, double dis, String maxDir, int isSame) {
        this.name = name;
        this.lon = lon;
        this.lat = lat;
        this.value = value;
        this.val = val;
        this.lastVal = lastVal;
        this.time = time;
        this.max = max;
        this.dis = dis;
        this.speed = speed;
        this.dir = dir;
        this.maxVal = maxVal;
        this.dis = dis;
        this.maxDir = maxDir;
        this.isSame = isSame;
    }
    /**
     * è®¡ç®—生成报告
     */
    public static Report calcReport(WarningDetail wd, DistanceSuYuan suYuan) {
        String[] sirs = wd.getSuYuanId().split("_");
        int x = Integer.parseInt(sirs[0]);
        int y = Integer.parseInt(sirs[1]);
        double lon = CalculateUtils.getLon(x, y);
        double lat = CalculateUtils.getLat(x, y);
    public static Report calcReport(WarningDetail wd, DistanceSuYuan suYuan, DistanceSuYuan suMax) {
        Coordinate c1 = CalculateUtils.getCoordinate(suYuan);
        Coordinate c2 = CalculateUtils.getCoordinate(suMax);
        String time = CalculateUtils.getYearMonthDayHour(wd.getCreateTime());
        String time = wd.getTableName().replace("su_yuan_", "");
        double lastVal = 0;
        double speed1 = CalculateUtils.getWindSpeed(suYuan.getV(), suYuan.getU());
        double direction1 = CalculateUtils.getWindDirection(suYuan.getV(), suYuan.getU());
        String dir = CalculateUtils.getDir(direction1);
        double max = suYuan.getVocsValue();
        double maxVal = suMax.getVocsValue();
        String[] sirs2=suYuan.getId().split("_");
        int x2 = Integer.parseInt(sirs2[0]);
        int y2 = Integer.parseInt(sirs2[1]);
        double lon2 = CalculateUtils.getLon(x2, y2);
        double lat2 = CalculateUtils.getLat(x2, y2);
        double dis = CalculateUtils.getDistance2(c1.getX(), c1.getY(), c2.getX(), c2.getY());
        double dis1 = CalculateUtils.getDistance1(c1.getX(), c1.getY(), c2.getX(), c2.getY());
        double angle = CalculateUtils.getAngle(c1.getX(), c1.getY(), c2.getX(), c2.getY());
        double dis = CalculateUtils.getDistance2(lon, lat, lon2, lat2);
        double dis1 = CalculateUtils.getDistance1(lon, lat, lon2, lat2);
        double angle = CalculateUtils.getAngle(lon, lat, lon2, lat2);
        double speed2 = CalculateUtils.getWindSpeed(suMax.getV(), suMax.getU());
        double direction2 = CalculateUtils.getWindDirection(suMax.getV(), suMax.getU());
        String maxDir = CalculateUtils.getDir(direction2);
        int isSame = (Math.abs(direction1 - direction2) < 15 && Math.abs(speed1 - speed2) < 0.3) ? 1 : 0;
        String dir = "";
        return new Report(wd.getLocationName(), lon, lat, wd.getValue(), time, max, dis, dir);
        return new Report(wd.getLocationName(), c1.getX(), c1.getY(), wd.getValue(), lastVal, time,
                speed1, dir, maxVal, dis, maxDir, isSame);
    }
    public String getName() {
@@ -102,12 +115,20 @@
        this.lat = lat;
    }
    public double getValue() {
        return value;
    public double getVal() {
        return val;
    }
    public void setValue(double value) {
        this.value = value;
    public void setVal(double val) {
        this.val = val;
    }
    public double getLastVal() {
        return lastVal;
    }
    public void setLastVal(double lastVal) {
        this.lastVal = lastVal;
    }
    public String getTime() {
@@ -118,12 +139,28 @@
        this.time = time;
    }
    public double getMax() {
        return max;
    public double getSpeed() {
        return speed;
    }
    public void setMax(double max) {
        this.max = max;
    public void setSpeed(double speed) {
        this.speed = speed;
    }
    public String getDir() {
        return dir;
    }
    public void setDir(String dir) {
        this.dir = dir;
    }
    public double getMaxVal() {
        return maxVal;
    }
    public void setMaxVal(double maxVal) {
        this.maxVal = maxVal;
    }
    public double getDis() {
@@ -134,11 +171,19 @@
        this.dis = dis;
    }
    public String getDir() {
        return dir;
    public String getMaxDir() {
        return maxDir;
    }
    public void setDir(String dir) {
        this.dir = dir;
    public void setMaxDir(String maxDir) {
        this.maxDir = maxDir;
    }
    public int getIsSame() {
        return isSame;
    }
    public void setIsSame(int isSame) {
        this.isSame = isSame;
    }
}
src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
@@ -384,16 +384,17 @@
            //String time = ymdh.format(wd.getCreateTime());
            //list.add(new WarningVo(wd.getLocationName(), wd.getSuYuanId(), 0.0, 0.0, wd.getValue(), time));
            int rows = suYuanMapper.isTableExists(wd.getTableName());
            DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(wd.getTableName(), wd.getSuYuanId());
            DistanceSuYuan suYuan = null;
            int rows = suYuanMapper.isTableExists(wd.getTableName());
            DistanceSuYuan suMax = null;
            if (rows > 0) {
                MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName());
                List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50);
                suYuan = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d);
                suMax = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d);
            }
            Report report = Report.calcReport(wd, suYuan);
            Report report = Report.calcReport(wd, suYuan, suMax);
            list.add(report);
        }
src/main/java/com/yssh/utils/CalculateUtils.java
@@ -3,6 +3,8 @@
import java.text.SimpleDateFormat;
import java.util.*;
import com.yssh.entity.Coordinate;
import com.yssh.entity.DistanceSuYuan;
import com.yssh.entity.MonitorPointPosition;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.referencing.CRS;
@@ -86,6 +88,22 @@
        } catch (Exception ex) {
            return 0;
        }
    }
    /**
     * èŽ·å–åæ ‡
     * @param su
     * @return
     */
    public static Coordinate getCoordinate(DistanceSuYuan su) {
        String[] sirs = su.getId().split("_");
        int x = Integer.parseInt(sirs[0]);
        int y = Integer.parseInt(sirs[1]);
        double lon = CalculateUtils.getLon(x, y);
        double lat = CalculateUtils.getLat(x, y);
        return new Coordinate(lon, lat);
    }
    /**
@@ -179,6 +197,27 @@
    }
    /**
     * èŽ·å–æ–¹å‘
     */
    public static String getDir(double direction) {
        if (direction < 0) {
            direction = direction + 360;
        }
        if (direction > 360) {
            direction = direction - 360;
        }
        if (direction > 315 && direction < 45)
            return "北";
        if (direction >= 45 && direction < 135)
            return "东";
        if (direction >= 135 && direction < 225)
            return "南";
        return "西";
    }
    /**
     * @param @return å‚æ•°
     * @return Double è¿”回类型
     * @throws
src/main/resources/mapping/SuYuanMapper.xml
@@ -3,7 +3,6 @@
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yssh.dao.SuYuanMapper">
    <resultMap id="SuYuan2dResult" type="com.yssh.entity.SuYuan2d">
        <result property="id"    column="id"    />
        <result property="x"    column="x"    />
@@ -52,8 +51,7 @@
        <result property="value"    column="c"    />
        <result property="time"    column="time"    />
    </resultMap>
    <select id="get2d" resultMap="SuYuan2dResult">
        SELECT id, x, y, c 
        FROM ${tableName} 
@@ -114,6 +112,12 @@
        order by c desc
        limit 1;
    </select>
    <select id="getSuYuanById" resultMap="DistanceSuYuanResult">
        select id, x, y, format(c, 2) "c", u, v
        from ${tableName}
        where id = #{id}
    </select>
    
    <select id="getAlarmsAnalyse" resultMap="SuYuan2dResult">
        SELECT id, x, y, c