¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | |
| | | Map<String, List<Double>> select3Hours(); |
| | | |
| | | List<WarningVo> getAlarmAndWarnByTime(Date begin, Date end); |
| | | List<Report> getAlarmAndWarnByTime(Date begin, Date end); |
| | | } |
| | |
| | | } |
| | | |
| | | @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); |
| | | |
| | |
| | | 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; |
| | |
| | | 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 åæ° |
| | |
| | | } |
| | | |
| | | /** |
| | | * 计ç®ç»´åº¦ |
| | | * @param @param x |
| | | * @param @param y |
| | | * @param @return åæ° |