|
@@ -5,7 +5,6 @@ package com.usky.fire.service.util;
|
|
|
import com.alibaba.nacos.common.utils.StringUtils;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.usky.common.core.exception.BusinessException;
|
|
|
import com.usky.common.core.util.HttpUtils;
|
|
|
import com.usky.fire.service.vo.LocateInfo;
|
|
|
import com.usky.fire.service.vo.PatrolInspectionAreaVo;
|
|
@@ -32,20 +31,68 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
public class OnlineMethod {
|
|
|
|
|
|
- public static String getAlarmType(String value,Integer deviceType) {
|
|
|
+ /**
|
|
|
+ * 默认地球半径
|
|
|
+ */
|
|
|
+ private static double EARTH_RADIUS = 6371000;//赤道半径(单位m)
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转化为弧度(rad)
|
|
|
+ * */
|
|
|
+ private static double rad(double d)
|
|
|
+ {
|
|
|
+ return d * Math.PI / 180.0;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @param lon1 第一点的精度
|
|
|
+ * @param lat1 第一点的纬度
|
|
|
+ * @param lon2 第二点的精度
|
|
|
+ * @param lat2 第二点的纬度
|
|
|
+ * @return 返回的距离,单位m
|
|
|
+ * */
|
|
|
+ public static double GetDistance(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_RADIUS;
|
|
|
+ s = Math.round(s * 10000) / 10000;
|
|
|
+ return s;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算中心经纬度与目标经纬度的距离(米)
|
|
|
+ *
|
|
|
+ * @param centerLon 中心精度
|
|
|
+ * @param centerLat 中心纬度
|
|
|
+ * @param targetLon 需要计算的精度
|
|
|
+ * @param targetLat 需要计算的纬度
|
|
|
+ * @return 米
|
|
|
+ */
|
|
|
+ public static double distance(double centerLon, double centerLat, double targetLon, double targetLat) {
|
|
|
+ double jl_jd = 102834.74258026089786013677476285;// 每经度单位米;
|
|
|
+ double jl_wd = 111712.69150641055729984301412873;// 每纬度单位米;
|
|
|
+ double b = Math.abs((centerLat - targetLat) * jl_jd);
|
|
|
+ double a = Math.abs((centerLon - targetLon) * jl_wd);
|
|
|
+ return Math.sqrt((a * a + b * b));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String getAlarmType(String value, Integer deviceType) {
|
|
|
String alarmType = null;
|
|
|
switch (value) {
|
|
|
case "火警":
|
|
|
alarmType = "2";
|
|
|
break;
|
|
|
case "故障":
|
|
|
- if (deviceType==1){
|
|
|
+ if (deviceType == 1) {
|
|
|
alarmType = "4";
|
|
|
- }else if (deviceType==2){
|
|
|
+ } else if (deviceType == 2) {
|
|
|
alarmType = "WP3";
|
|
|
- }else if (deviceType==5){
|
|
|
+ } else if (deviceType == 5) {
|
|
|
alarmType = "LL3";
|
|
|
- }else if (deviceType==7){
|
|
|
+ } else if (deviceType == 7) {
|
|
|
alarmType = "y05";
|
|
|
}
|
|
|
break;
|
|
@@ -80,23 +127,23 @@ public class OnlineMethod {
|
|
|
alarmType = "EF8";
|
|
|
break;
|
|
|
case "离线":
|
|
|
- if (deviceType==2){
|
|
|
+ if (deviceType == 2) {
|
|
|
alarmType = "WP4";
|
|
|
- }else if (deviceType==7){
|
|
|
+ } else if (deviceType == 7) {
|
|
|
alarmType = "EF9";
|
|
|
}
|
|
|
break;
|
|
|
case "正常":
|
|
|
- if (deviceType==2){
|
|
|
+ if (deviceType == 2) {
|
|
|
alarmType = "WP0";
|
|
|
- }else if (deviceType==5){
|
|
|
+ } else if (deviceType == 5) {
|
|
|
alarmType = "LL0";
|
|
|
}
|
|
|
break;
|
|
|
case "低压":
|
|
|
- if (deviceType==2){
|
|
|
+ if (deviceType == 2) {
|
|
|
alarmType = "WP1";
|
|
|
- }else if (deviceType==3){
|
|
|
+ } else if (deviceType == 3) {
|
|
|
alarmType = "y04";
|
|
|
}
|
|
|
break;
|