燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-06-16 b546994ced2db809d4efe9a7a338892c4df27e75
1
已添加1个文件
已修改3个文件
251 ■■■■■ 文件已修改
src/main/java/com/yssh/entity/Report.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/IWarningAnalyseService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/utils/CalculateUtils.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/entity/Report.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,144 @@
package com.yssh.entity;
import com.yssh.utils.CalculateUtils;
import io.swagger.annotations.ApiModelProperty;
import java.text.SimpleDateFormat;
/**
 * æŠ¥å‘Š
 * @author WWW
 * @date 2023-06-18
 */
public class Report {
    @ApiModelProperty(value = "点位名称")
    private String name;
    @ApiModelProperty(value = "经度")
    private double lon;
    @ApiModelProperty(value = "纬度")
    private double lat;
    @ApiModelProperty(value = "数值")
    private double value;
    @ApiModelProperty(value = "时间")
    private String time;
    @ApiModelProperty(value = "500m范围最大值")
    private double max;
    @ApiModelProperty(value = "距离")
    private double dis;
    @ApiModelProperty(value = "方向")
    private String dir;
    public Report() {
    }
    public Report(String name, double lon, double lat, double value, String time, double max, double dis, String dir) {
        this.name = name;
        this.lon = lon;
        this.lat = lat;
        this.value = value;
        this.time = time;
        this.max = max;
        this.dis = dis;
        this.dir = dir;
    }
    /**
     * è®¡ç®—生成报告
     */
    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);
        String time = CalculateUtils.getYearMonthDayHour(wd.getCreateTime());
        double max = suYuan.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(lon, lat, lon2, lat2);
        double dis1 = CalculateUtils.getDistance1(lon, lat, lon2, lat2);
        double angle = CalculateUtils.getAngle(lon, lat, lon2, lat2);
        String dir = "";
        return new Report(wd.getLocationName(), lon, lat, wd.getValue(), time, max, dis, dir);
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public double getLon() {
        return lon;
    }
    public void setLon(double lon) {
        this.lon = lon;
    }
    public double getLat() {
        return lat;
    }
    public void setLat(double lat) {
        this.lat = lat;
    }
    public double getValue() {
        return value;
    }
    public void setValue(double value) {
        this.value = value;
    }
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    public double getMax() {
        return max;
    }
    public void setMax(double max) {
        this.max = max;
    }
    public double getDis() {
        return dis;
    }
    public void setDis(double dis) {
        this.dis = dis;
    }
    public String getDir() {
        return dir;
    }
    public void setDir(String dir) {
        this.dir = dir;
    }
}
src/main/java/com/yssh/service/IWarningAnalyseService.java
@@ -5,6 +5,7 @@
import java.util.Map;
import com.yssh.entity.Qxsh;
import com.yssh.entity.Report;
import com.yssh.entity.WarningDetail;
import com.yssh.entity.vo.WarningVo;
@@ -30,5 +31,5 @@
    Map<String, List<Double>> select3Hours();
    List<WarningVo> getAlarmAndWarnByTime(Date begin, Date end);
    List<Report> getAlarmAndWarnByTime(Date begin, Date end);
}
src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
@@ -368,7 +368,7 @@
    }
    @Override
    public List<WarningVo> getAlarmAndWarnByTime(Date begin, Date end) {
    public List<Report> getAlarmAndWarnByTime(Date begin, Date end) {
        String startTime = ymdhms.format(begin);
        String endTime = ymdhms.format(end);
@@ -379,10 +379,22 @@
        List<WarningDetail> rsBj = warningDetailMapper.selectByTimeForBj(startTime, endTime);
        if (null != rsBj && rsBj.size() > 0) rs.addAll(rsBj);
        List<WarningVo> list = new ArrayList<>();
        List<Report> list = new ArrayList<>();
        for (WarningDetail wd : rs) {
            String time = ymdh.format(wd.getCreateTime());
            list.add(new WarningVo(wd.getLocationName(), wd.getSuYuanId(), 0.0, 0.0, wd.getValue(), time));
            //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 = null;
            if (rows > 0) {
                MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName());
                List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50);
                suYuan = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d);
            }
            Report report = Report.calcReport(wd, suYuan);
            list.add(report);
        }
        return list;
src/main/java/com/yssh/utils/CalculateUtils.java
@@ -1,12 +1,95 @@
package com.yssh.utils;
import java.text.SimpleDateFormat;
import java.util.*;
import com.yssh.entity.MonitorPointPosition;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.referencing.CRS;
import org.geotools.referencing.GeodeticCalculator;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
public class CalculateUtils {
    private final static SimpleDateFormat ymdh = new SimpleDateFormat("yyyyMMddHH");
    /**
     * èŽ·å–å¹´æœˆæ—¥æ—¶
     */
    public static String getYearMonthDayHour(Date date) {
        return ymdh.format(date);
    }
    /**
     * é»˜è®¤åœ°çƒåŠå¾„,赤道半径(单位m)
     */
    private final static double EARTH_RADIUS1 = 6371000;
    /**
     * è½¬åŒ–为弧度(rad)
     */
    private static double rad(double d)
    {
        return d * Math.PI / 180.0;
    }
    /**
     * è®¡ç®—距离1
     */
    public static double getDistance1(double lon1, double lat1, double lon2, double lat2) {
        double radLat1 = rad(lat1);
        double radLat2 = rad(lat2);
        double a = radLat1 - radLat2;
        double b = rad(lon1) - rad(lon2);
        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
        s = s * EARTH_RADIUS1;
        return Math.round(s * 100) / 100;
    }
    /**
     * è®¡ç®—距离2
     */
    public static double getDistance2(double x1, double y1, double x2, double y2) {
        // 84坐标系构造GeodeticCalculator
        GeodeticCalculator geodeticCalculator = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
        // èµ·ç‚¹ç»çº¬åº¦
        geodeticCalculator.setStartingGeographicPoint(x1, y1);
        // æœ«ç‚¹ç»çº¬åº¦
        geodeticCalculator.setDestinationGeographicPoint(x2, y2);
        // è®¡ç®—距离,单位:米
        double distance = geodeticCalculator.getOrthodromicDistance();
        return Math.round(distance * 100) / 100;
    }
    /**
     * è®¡ç®—角度
     */
    public static double getAngle(double x1, double y1, double x2, double y2) {
        try {
            CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
            DirectPosition2D p1 = new DirectPosition2D(crs, x1, y1);
            DirectPosition2D p2 = new DirectPosition2D(crs, x2, y2);
            GeodeticCalculator gc = new GeodeticCalculator();
            gc.setStartingGeographicPoint(p1);
            gc.setDestinationGeographicPoint(p2);
            double angle = gc.getAzimuth();
            return Math.round(angle * 100) / 100;
        } catch (Exception ex) {
            return 0;
        }
    }
    /**
     * è®¡ç®—经度
     * @param @param  x
     * @param @param  y
     * @param @return å‚æ•°
@@ -24,6 +107,7 @@
    }
    /**
     * è®¡ç®—维度
     * @param @param  x
     * @param @param  y
     * @param @return å‚æ•°