‘liusuyi’
2023-06-27 3be4440f6800e10efd8db51b957d17a6cc3b39df
增加雷达报警点坐标计算
增加雷达报警数据推送mqtt
已添加7个文件
已修改5个文件
已删除1个文件
1289 ■■■■ 文件已修改
pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/alarm/radar/domain/ArdEquipRadar.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/alarm/radar/domain/RadarAlarmInfo.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/alarm/radar/mapper/ArdEquipRadarMapper.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/alarm/radar/service/IArdEquipRadarService.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/alarm/radar/service/impl/ArdEquipRadarServiceImpl.java 121 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/alarm/tube/service/TubeAlarmService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/utils/LonlatConver.java 294 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/utils/tcp/NettyTcpClient.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/utils/tcp/NettyTcpClientHandler.java 388 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ard/utils/tcp/index.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ArdEquipRadarMapper.xml 180 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -79,6 +79,11 @@
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>
        <dependency>
            <groupId>org.gavaghan</groupId>
            <artifactId>geodesy</artifactId>
            <version>1.1.3</version>
        </dependency>
    </dependencies>
    <build>
src/main/java/com/ard/alarm/radar/domain/ArdEquipRadar.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,70 @@
package com.ard.alarm.radar.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
/**
 * radar对象 ard_equip_radar
 *
 * @author zj
 * @date 2023-03-11
 */
@Data
public class ArdEquipRadar
{
    private static final long serialVersionUID = 1L;
    /** id */
    private String id;
    /** åç§° */
    private String name;
    /** ç«¯å£ */
    private Integer port;
    /** æ“ä½œå‘˜id */
    private String operate;
    /** åˆ é™¤æ ‡è®° */
    private String delFlag;
    /** ç”¨æˆ·id */
    private String userId;
    /** ç»åº¦ */
    private Double longitude;
    /** ç»´åº¦ */
    private Double latitude;
    /** é«˜ç¨‹ */
    private Double altitude;
    /** å®‰è£…æ—¶é—´ */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date radarDate;
    /** éƒ¨é—¨id */
    private Long deptId;
    /** ä¿¯ä»°è§’ */
    private String pitch;
    /** å¡”id */
    private String towerId;
    private String towerName;
    /** å›¾åƒå®½åº¦ */
    private String imageWidth;
    /** å›¾åƒé«˜åº¦ */
    private String imageHeight;
    /** åž‹å· */
    private String type;
    /** ip */
    private String ip;
}
src/main/java/com/ard/alarm/radar/domain/RadarAlarmInfo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
package com.ard.alarm.radar.domain;
import lombok.Data;
import java.util.Date;
/**
 * @Description:
 * @ClassName: RadarAlarmInfo
 * @Author: åˆ˜è‹ä¹‰
 * @Date: 2023å¹´06月27日15:49
 * @Version: 1.0
 **/
@Data
public class RadarAlarmInfo {
    Integer id;
    String name;
    String alarmTime;
    Double longitude;
    Double lagitude;
}
src/main/java/com/ard/alarm/radar/mapper/ArdEquipRadarMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,63 @@
package com.ard.alarm.radar.mapper;
import java.util.List;
import com.ard.alarm.radar.domain.ArdEquipRadar;
import org.apache.ibatis.annotations.Mapper;
/**
 * radarMapper接口
 *
 * @author zj
 * @date 2023-03-11
 */
@Mapper
public interface ArdEquipRadarMapper
{
    /**
     * æŸ¥è¯¢radar
     *
     * @param id radar主键
     * @return radar
     */
    public ArdEquipRadar selectArdEquipRadarById(String id);
    /**
     * æŸ¥è¯¢radar列表
     *
     * @param ardEquipRadar radar
     * @return radar集合
     */
    public List<ArdEquipRadar> selectArdEquipRadarList(ArdEquipRadar ardEquipRadar);
    /**
     * æ–°å¢žradar
     *
     * @param ardEquipRadar radar
     * @return ç»“æžœ
     */
    public int insertArdEquipRadar(ArdEquipRadar ardEquipRadar);
    /**
     * ä¿®æ”¹radar
     *
     * @param ardEquipRadar radar
     * @return ç»“æžœ
     */
    public int updateArdEquipRadar(ArdEquipRadar ardEquipRadar);
    /**
     * åˆ é™¤radar
     *
     * @param id radar主键
     * @return ç»“æžœ
     */
    public int deleteArdEquipRadarById(String id);
    /**
     * æ‰¹é‡åˆ é™¤radar
     *
     * @param ids éœ€è¦åˆ é™¤çš„æ•°æ®ä¸»é”®é›†åˆ
     * @return ç»“æžœ
     */
    public int deleteArdEquipRadarByIds(String[] ids);
}
src/main/java/com/ard/alarm/radar/service/IArdEquipRadarService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
package com.ard.alarm.radar.service;
import java.util.List;
import com.ard.alarm.radar.domain.ArdEquipRadar;
/**
 * radarService接口
 *
 * @author zj
 * @date 2023-03-11
 */
public interface IArdEquipRadarService
{
    /**
     * æŸ¥è¯¢radar
     *
     * @param id radar主键
     * @return radar
     */
    public ArdEquipRadar selectArdEquipRadarById(String id);
    /**
     * æŸ¥è¯¢radar列表
     *
     * @param ardEquipRadar radar
     * @return radar集合
     */
    public List<ArdEquipRadar> selectArdEquipRadarList(ArdEquipRadar ardEquipRadar);
    /**
     * æ–°å¢žradar
     *
     * @param ardEquipRadar radar
     * @return ç»“æžœ
     */
    public int insertArdEquipRadar(ArdEquipRadar ardEquipRadar);
    /**
     * ä¿®æ”¹radar
     *
     * @param ardEquipRadar radar
     * @return ç»“æžœ
     */
    public int updateArdEquipRadar(ArdEquipRadar ardEquipRadar);
    /**
     * æ‰¹é‡åˆ é™¤radar
     *
     * @param ids éœ€è¦åˆ é™¤çš„radar主键集合
     * @return ç»“æžœ
     */
    public int deleteArdEquipRadarByIds(String[] ids);
    /**
     * åˆ é™¤radar信息
     *
     * @param id radar主键
     * @return ç»“æžœ
     */
    public int deleteArdEquipRadarById(String id);
}
src/main/java/com/ard/alarm/radar/service/impl/ArdEquipRadarServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,121 @@
package com.ard.alarm.radar.service.impl;
import java.util.List;
import com.ard.alarm.radar.domain.ArdEquipRadar;
import com.ard.alarm.radar.mapper.ArdEquipRadarMapper;
import com.ard.alarm.radar.service.IArdEquipRadarService;
import com.ard.utils.tcp.NettyTcpClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
/**
 * radarService业务层处理
 *
 * @author zj
 * @date 2023-03-11
 */
@Service
@Slf4j(topic = "radar")
public class ArdEquipRadarServiceImpl implements IArdEquipRadarService
{
    @Autowired
    private ArdEquipRadarMapper ardEquipRadarMapper;
    @Resource
    NettyTcpClient nettyTcpClient;
    @Value("${spring.netty.tcp.enabled}")
    private Boolean tcpClientEnable;
    @PostConstruct
    public void init() {
        if(!tcpClientEnable)
        {
            return;
        }
        List<ArdEquipRadar> ardEquipRadars = selectArdEquipRadarList(new ArdEquipRadar());
        for (ArdEquipRadar ardEquipRadar:ardEquipRadars)
        {
            String host = ardEquipRadar.getIp();
            Integer port = Integer.valueOf(ardEquipRadar.getPort());
            log.info("TCP客户端尝试连接:"+host+":"+port);
            nettyTcpClient.init(ardEquipRadar);
        }
    }
    /**
     * æŸ¥è¯¢radar
     *
     * @param id radar主键
     * @return radar
     */
    @Override
    public ArdEquipRadar selectArdEquipRadarById(String id)
    {
        return ardEquipRadarMapper.selectArdEquipRadarById(id);
    }
    /**
     * æŸ¥è¯¢radar列表
     *
     * @param ardEquipRadar radar
     * @return radar
     */
    @Override
    public List<ArdEquipRadar> selectArdEquipRadarList(ArdEquipRadar ardEquipRadar)
    {
        return ardEquipRadarMapper.selectArdEquipRadarList(ardEquipRadar);
    }
    /**
     * æ–°å¢žradar
     *
     * @param ardEquipRadar radar
     * @return ç»“æžœ
     */
    @Override
    public int insertArdEquipRadar(ArdEquipRadar ardEquipRadar)
    {
        return ardEquipRadarMapper.insertArdEquipRadar(ardEquipRadar);
    }
    /**
     * ä¿®æ”¹radar
     *
     * @param ardEquipRadar radar
     * @return ç»“æžœ
     */
    @Override
    public int updateArdEquipRadar(ArdEquipRadar ardEquipRadar)
    {
        return ardEquipRadarMapper.updateArdEquipRadar(ardEquipRadar);
    }
    /**
     * æ‰¹é‡åˆ é™¤radar
     *
     * @param ids éœ€è¦åˆ é™¤çš„radar主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdEquipRadarByIds(String[] ids)
    {
        return ardEquipRadarMapper.deleteArdEquipRadarByIds(ids);
    }
    /**
     * åˆ é™¤radar信息
     *
     * @param id radar主键
     * @return ç»“æžœ
     */
    @Override
    public int deleteArdEquipRadarById(String id)
    {
        return ardEquipRadarMapper.deleteArdEquipRadarById(id);
    }
}
src/main/java/com/ard/alarm/tube/service/TubeAlarmService.java
@@ -14,8 +14,6 @@
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * @Description: ç®¡çº¿æ³„漏报警服务
@@ -29,11 +27,10 @@
public class TubeAlarmService {
    @Resource
    NettyUdpServer nettyUdpServer;
    @Resource
    NettyTcpClient nettyTcpClient;
    @Value("${spring.netty.port}")
    @Value("${spring.netty.udp.port}")
    private Integer udpPort;
    @Value("${spring.netty.enabled}")
    @Value("${spring.netty.udp.enabled}")
    private String UdpServerEnable;
    @PostConstruct
@@ -43,8 +40,6 @@
        }
        nettyUdpServer.init(udpPort);
        log.info("UDP服务已启动");
        nettyTcpClient.init("127.0.0.1",1200);
        log.info("TCP客户端已启动");
    }
    @Async("alarm")
src/main/java/com/ard/utils/LonlatConver.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,294 @@
package com.ard.utils;
public class LonlatConver {
    /**
     * a
     */
    public final static double a = 6378245.0;
    /**
     * ee
     */
    public final static double ee = 0.00669342162296594323;
    //圆周率 GCJ_02_To_WGS_84
    public final static double pi = 3.14159265358979324;
    /**
     * @Description WGS84 to ç«æ˜Ÿåæ ‡ç³» (GCJ-02)
     * @param lon  ç»åº¦
     * @param lat  çº¬åº¦
     * @return
     */
    public static double[] wgs84_To_Gcj02(double lon, double lat) {
        if (outOfChina(lat, lon)) {
            return null;
        }
        double dLat = transformLat(lon - 105.0, lat - 35.0);
        double dLon = transformLon(lon - 105.0, lat - 35.0);
        double radLat = lat / 180.0 * pi;
        double magic = Math.sin(radLat);
        magic = 1 - ee * magic * magic;
        double sqrtMagic = Math.sqrt(magic);
        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
        double mgLat = lat + dLat;
        double mgLon = lon + dLon;
        return new double[] { mgLon, mgLat };
    }
    /**
     * @Description ç«æ˜Ÿåæ ‡ç³» (GCJ-02) to WGS84
     * @param lon
     * @param lat
     * @return
     */
    public static double[] gcj02_To_Wgs84(double lon, double lat) {
        double[] gps = transform(lat, lon);
        double lontitude = lon * 2 - gps[1];
        double latitude = lat * 2 - gps[0];
        return new double[] { lontitude, latitude };
    }
    /**
     * @Description ç«æ˜Ÿåæ ‡ç³» (GCJ-02) to ç™¾åº¦åæ ‡ç³» (BD-09)
     * @param gg_lon
     * @param gg_lat
     * @return
     */
    public static double[] gcj02_To_Bd09(double gg_lon, double gg_lat) {
        double x = gg_lon, y = gg_lat;
        double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
        double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
        double bd_lon = z * Math.cos(theta) + 0.0065;
        double bd_lat = z * Math.sin(theta) + 0.006;
        return new double[] { bd_lon, bd_lat };
    }
    /**
     * @Description ç™¾åº¦åæ ‡ç³» (BD-09) to ç«æ˜Ÿåæ ‡ç³» (GCJ-02)
     * @param bd_lon
     * @param bd_lat
     * @return
     */
    public static double[] bd09_To_Gcj02(double bd_lon, double bd_lat) {
        double x = bd_lon - 0.0065, y = bd_lat - 0.006;
        double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);
        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);
        double gg_lon = z * Math.cos(theta);
        double gg_lat = z * Math.sin(theta);
        return new double[] { gg_lon, gg_lat };
    }
    /**
     * @Description ç™¾åº¦åæ ‡ç³» (BD-09) to WGS84
     * @param bd_lat
     * @param bd_lon
     * @return
     */
    public static double[] bd09_To_Wgs84(double bd_lon,double bd_lat) {
        double[] gcj02 = LonlatConver.bd09_To_Gcj02(bd_lon, bd_lat);
        double[] map84 = LonlatConver.gcj02_To_Wgs84(gcj02[0], gcj02[1]);
        return map84;
    }
    /**
     * @Description åˆ¤æ–­æ˜¯å¦åœ¨ä¸­å›½èŒƒå›´å†…
     * @param lat
     * @param lon
     * @return
     */
    public static boolean outOfChina(double lat, double lon) {
        if (lon < 72.004 || lon > 137.8347)
            return true;
        if (lat < 0.8293 || lat > 55.8271)
            return true;
        return false;
    }
    /**
     * @Description transform
     * @param lat
     * @param lon
     * @return
     */
    private static double[] transform(double lat, double lon) {
        if (outOfChina(lat, lon)) {
            return new double[] { lat, lon };
        }
        double dLat = transformLat(lon - 105.0, lat - 35.0);
        double dLon = transformLon(lon - 105.0, lat - 35.0);
        double radLat = lat / 180.0 * pi;
        double magic = Math.sin(radLat);
        magic = 1 - ee * magic * magic;
        double sqrtMagic = Math.sqrt(magic);
        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
        double mgLat = lat + dLat;
        double mgLon = lon + dLon;
        return new double[] { mgLat, mgLon };
    }
    /**
     * @Description transformLat
     * @param x
     * @param y
     * @return
     */
    private static double transformLat(double x, double y) {
        double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
                + 0.2 * Math.sqrt(Math.abs(x));
        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
        ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
        return ret;
    }
    /**
     * @Description transformLon
     * @param x
     * @param y
     * @return
     */
    public static double transformLon(double x, double y) {
        double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
                * Math.sqrt(Math.abs(x));
        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
        ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0
                * pi)) * 2.0 / 3.0;
        return ret;
    }
    /**
     * GPS经纬度转换为 åº¦ï¼ˆ3114.1717,12122.1067 â†’ 121.37300779,31.23436014)
     * @param dms åæ ‡
     * @param type åæ ‡ç±»åž‹  E/N
     * @return String è§£æžåŽçš„经纬度
     */
    public static String gpsToWgs84(String dms, String type) {
        if (dms == null || dms.equals("")) {
            return "0.0";
        }
        double result = 0.0D;
        String temp = "";
        if (type.equals("E")) {//经度
            String e1 = dms.substring(0, 3);//截取3位数字,经度共3位,最多180度
            //经度是一伦敦为点作南北两极的线为0度,所有往西和往东各180度
            String e2 = dms.substring(3, dms.length());//需要运算的小数
            result = Double.parseDouble(e1);
    /*            System.out.println("e2===="+e2);
            System.out.println("===="+Double.parseDouble(e2) / 60.0D);*/
            result += (Double.parseDouble(e2) / 60.0D);
            temp = String.valueOf(result);
            if (temp.length() > 11) {
                temp = e1 + temp.substring(temp.indexOf("."), 11);
            }
        } else if (type.equals("N")) {        //纬度,纬度是以赤道为基准,相当于把地球分两半,两个半球面上的点和平面夹角0~90度
            String n1 = dms.substring(0, 2);//截取2位,纬度共2位,最多90度
            String n2 = dms.substring(2, dms.length());
            result = Double.parseDouble(n1);
    /*            System.out.println("n2===="+n2);
            System.out.println("===="+Double.parseDouble(n2) / 60.0D);*/
            result += Double.parseDouble(n2) / 60.0D;
            temp = String.valueOf(result);
            if (temp.length() > 10) {
                temp = n1 + temp.substring(temp.indexOf("."), 10);
            }
        }
        return temp;
    }
    /**
    *
    * @title è®¡ç®—点与点的距离
    * @param pointA
    * @param pointB
    * @description æ³¨æ„pointA,pointB中的经纬度坐标都是火星坐标
    * @return
    * @author huaqunzi
    */
    /*public static double distanceToPoint(PointEntity pointA,PointEntity pointB){
        //jts提供的几何要素工厂类
        GeometryFactory geometryFactory = new GeometryFactory();
        //火星坐标(gcj02)转GPS坐标(WGS84)
        double[] wgsPntA = CoordinateUtil.gcj02_To_Wgs84(pointA.x,pointA.y);
        double[] wgsPntB = CoordinateUtil.gcj02_To_Wgs84(pointB.x,pointB.y);
        //WGS84->高斯6度分带投影
        double[] gaussPntA = wgs84_To_Gauss6(wgsPntA[0], wgsPntA[1]);
        double[] gaussPntB = wgs84_To_Gauss6(wgsPntB[0], wgsPntB[1]);
        //通过几何要素工厂得到point实体
        Point pntA = geometryFactory.createPoint(new Coordinate(gaussPntA[0], gaussPntA[1]));
        Point pntB = geometryFactory.createPoint(new Coordinate(gaussPntB[0], gaussPntB[1]));
        // ä¸¤ç‚¹è·ç¦»
        return pntA.distance(pntB);
    }*/
    /**
    * @Description WGS84 to é«˜æ–¯æŠ•å½±(6度分带)
    * @param longitude ç»åº¦
    * @param latitude çº¬åº¦
    * @return double[] x y
    */
    public static double[] wgs84_To_Gauss6(double longitude, double latitude) {
        int ProjNo = 0;
        int ZoneWide; // //带宽
        double[] output = new double[2];
        double longitude1, latitude1, longitude0, X0, Y0, xval, yval;
        double a, f, e2, ee, NN, T, C, A, M, iPI;
        iPI = 0.0174532925199433; // //3.1415926535898/180.0;
        ZoneWide = 6; //6度带宽
        a = 6378137.0;
        f = 1.0 / 298.257223563; //WGS84坐标系参数
        //a = 6378245.0;f = 1.0 / 298.3; // 54年北京坐标系参数
        // //a=6378140.0; f=1/298.257; //80年西安坐标系参数
        ProjNo = (int) (longitude / ZoneWide);
        longitude0 = (double)(ProjNo * ZoneWide + ZoneWide / 2);
        longitude0 = longitude0 * iPI;
        longitude1 = longitude * iPI; // ç»åº¦è½¬æ¢ä¸ºå¼§åº¦
        latitude1 = latitude * iPI; // çº¬åº¦è½¬æ¢ä¸ºå¼§åº¦
        e2 = 2 * f - f * f;
        ee = e2 / (1.0 - e2);
        NN = a
                / Math.sqrt(1.0 - e2 * Math.sin(latitude1)
                * Math.sin(latitude1));
        T = Math.tan(latitude1) * Math.tan(latitude1);
        C = ee * Math.cos(latitude1) * Math.cos(latitude1);
        A = (longitude1 - longitude0) * Math.cos(latitude1);
        M = a
                * ((1 - e2 / 4 - 3 * e2 * e2 / 64 - 5 * e2 * e2 * e2 / 256)
                * latitude1
                - (3 * e2 / 8 + 3 * e2 * e2 / 32 + 45 * e2 * e2 * e2
                / 1024) * Math.sin(2 * latitude1)
                + (15 * e2 * e2 / 256 + 45 * e2 * e2 * e2 / 1024)
                * Math.sin(4 * latitude1) - (35 * e2 * e2 * e2 / 3072)
                * Math.sin(6 * latitude1));
        // å› ä¸ºæ˜¯ä»¥èµ¤é“为Y轴的,与我们南北为Y轴是相反的,所以xy与高斯投影的标准xy正好相反;
        xval = NN
                * (A + (1 - T + C) * A * A * A / 6 + (5 - 18 * T + T * T + 14
                * C - 58 * ee)
                * A * A * A * A * A / 120);
        yval = M
                + NN
                * Math.tan(latitude1)
                * (A * A / 2 + (5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24 + (61
                - 58 * T + T * T + 270 * C - 330 * ee)
                * A * A * A * A * A * A / 720);
        X0 = 1000000L * (ProjNo + 1) + 500000L;
        Y0 = 0;
        xval = xval + X0;
        yval = yval + Y0;
        output[0] = xval;
        output[1] = yval;
        return output;
    }
}
src/main/java/com/ard/utils/tcp/NettyTcpClient.java
@@ -1,5 +1,6 @@
package com.ard.utils.tcp;
import com.ard.alarm.radar.domain.ArdEquipRadar;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
@@ -11,6 +12,8 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
 * @Description:
@@ -24,7 +27,9 @@
@Slf4j(topic = "radar")
public class NettyTcpClient {
    @Async
    public void init(String host, Integer port) {
    public void init(ArdEquipRadar ardEquipRadar) {
        while (true) {
        NioEventLoopGroup group = new NioEventLoopGroup();
        try {
            Bootstrap bootstrap = new Bootstrap();
@@ -33,9 +38,11 @@
                    .handler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) throws Exception {
                            ch.pipeline().addLast(new NettyTcpClientHandler());
                                ch.pipeline().addLast(new NettyTcpClientHandler(ardEquipRadar));
                        }
                    });
                String host = ardEquipRadar.getIp();
                Integer port = ardEquipRadar.getPort();
            ChannelFuture future = bootstrap.connect(host, port).sync();
            // æ·»åŠ è¿žæŽ¥æˆåŠŸçš„ç›‘å¬å™¨
            future.addListener((ChannelFutureListener) future1 -> {
@@ -47,10 +54,16 @@
            });
            future.channel().closeFuture().sync();
        } catch (Exception ex) {
            log.error("nettyTcp客户端初始化异常:" + ex.getMessage());
            } catch (Exception e) {
                log.error("nettyTcp客户端初始化异常:" + e.getMessage());
                try {
                    TimeUnit.SECONDS.sleep(5); // ç­‰å¾…5秒后重新连接
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                }
        } finally {
            group.shutdownGracefully();
        }
    }
}
}
src/main/java/com/ard/utils/tcp/NettyTcpClientHandler.java
@@ -1,17 +1,30 @@
package com.ard.utils.tcp;
import com.alibaba.fastjson2.JSON;
import com.ard.alarm.radar.domain.ArdEquipRadar;
import com.ard.alarm.radar.domain.RadarAlarmInfo;
import com.ard.hiksdk.domain.alarmEventInfo;
import com.ard.utils.LonlatConver;
import com.ard.utils.SpringTool;
import com.ard.utils.mqtt.MqttConsumer;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GlobalCoordinates;
import sun.nio.cs.ext.GBK;
import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/**
 * @Description: tcp客户端处理
@@ -23,6 +36,23 @@
@Slf4j(topic = "radar")
public class NettyTcpClientHandler extends SimpleChannelInboundHandler<ByteBuf> {
    private String host;
    private Integer port;
    private Double longitude;
    private Double lagitude;
    private String name;
    public NettyTcpClientHandler(ArdEquipRadar ardEquipRadar) {
        this.host = ardEquipRadar.getIp();
        this.port = ardEquipRadar.getPort();
        this.longitude = ardEquipRadar.getLongitude();
        this.lagitude = ardEquipRadar.getLatitude();
        this.name=ardEquipRadar.getName();
    }
    private ChannelHandlerContext context;
    private ScheduledFuture<?> heartbeatTask;
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
        // å¤„理接收到的消息
@@ -30,155 +60,198 @@
        msg.getBytes(msg.readerIndex(), byteArray);
        byte[] bytes = receiveCompletePacket(byteArray);
        if (bytes != null) {
            String hexString = DatatypeConverter.printHexBinary(bytes);
            log.info(hexString);
          //  String hexString = DatatypeConverter.printHexBinary(bytes);
          //  log.info(hexString);
            processData(bytes);
        }
    }
    @Override
    public void channelActive(ChannelHandlerContext ctx) {
        // å½“客户端连接成功后,发送消息给服务器
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                ByteBuf message = ctx.alloc().buffer();
        context = ctx;
        startHeartbeatTask();//开始发送心跳
    }
    /**
     * å¼€å§‹å¿ƒè·³ä»»åŠ¡
     */
    private void startHeartbeatTask() {
        heartbeatTask = context.executor().scheduleAtFixedRate(() -> {
            // å‘送心跳消息
            ByteBuf message = context.alloc().buffer();
                byte[] heart = {0x01, 0x02, 0x01, 0x10, 0x00, 0x00, 0x00, (byte) 0x83, (byte) 0x88, 0x5d, 0x71, 0x01, 0x02, 0x00};
                String hexString = DatatypeConverter.printHexBinary(heart);
                log.info("发送心跳:" + hexString);
                message.writeBytes(heart);
                ctx.writeAndFlush(message);
            context.writeAndFlush(message);
        }, 0, 5, TimeUnit.SECONDS);
            }
        };
        Timer timer = new Timer();
        // timer.schedule(timerTask, 0, 6000);
    /**
     * åœæ­¢å¿ƒè·³ä»»åŠ¡
     */
    private void stopHeartbeatTask() {
        if (heartbeatTask != null) {
            heartbeatTask.cancel(false);
            heartbeatTask = null;
        }
    }
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        log.error("连接异常");
        log.info("tcp客户端连接异常");
        // å‘生异常时的处理
        cause.printStackTrace();
        ctx.close();
        stopHeartbeatTask();//停止心跳发送
    }
    public static void processData(byte[] data) {
    /**
     * è§£æžæŠ¥è­¦æ•°æ®
     */
    public void processData(byte[] data) {
        try {
            data = transferData(data);//去掉包头和包尾及转义
            String s = DatatypeConverter.printHexBinary(data);
            log.info(s);
            byte[] type = Arrays.copyOfRange(data, index.type[0], index.type[1]);//命令类型
            data = transferData(data);//去掉包头和包尾、校验及转义
            byte[] type = Arrays.copyOfRange(data, 0, 1);//命令类型
            log.info("命令类型:" + DatatypeConverter.printHexBinary(type));
            byte[] cmdId = Arrays.copyOfRange(data, index.funcc[0], index.funcc[1]);//命令ID
            byte[] cmdId = Arrays.copyOfRange(data, 1, 2);//命令ID
            log.info("命令ID:" + DatatypeConverter.printHexBinary(cmdId));
            byte[] payloadSize = Arrays.copyOfRange(data, index.payloadSize[0], index.payloadSize[1]);//有效负载大小
            //  log.info("有效负载大小:" + DatatypeConverter.printHexBinary(payloadSize));
            byte[] payloadSize = Arrays.copyOfRange(data, 2, 4);//有效负载大小
            payloadSize = toLittleEndian(payloadSize);
            // log.info("有效负载大小(转小端):" + DatatypeConverter.printHexBinary(payloadSize));
            int payloadSizeToDecimal = byteArrayToDecimal(payloadSize);
            log.info("有效负载大小(转整型):" + payloadSizeToDecimal);
            if (Arrays.equals(cmdId, new byte[]{0x01})) {
                byte[] dwTim = Arrays.copyOfRange(data, index.dwTim[0], index.dwTim[1]);
                // log.info("周视图像的出现时间:" + DatatypeConverter.printHexBinary(dwTim));
                byte[] dwTim = Arrays.copyOfRange(data, 4, 8);
                dwTim = toLittleEndian(dwTim);
                // log.info("周视图像的出现时间(转小端):" + DatatypeConverter.printHexBinary(dwTim));
                // log.info("周视图像的出现时间(转整型):" + byteArrayToDecimal(dwTim));
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                long l = byteArrayToDecimal(dwTim);
                String format = sdf.format(l * 1000);
                log.info("周视图像的出现时间(转date):" + format);
                String alarmTime = sdf.format(l * 1000);
                log.info("周视图像的出现时间(转date):" + alarmTime);
                byte[] wTargetNum = Arrays.copyOfRange(data, index.wTargetNum[0], index.wTargetNum[1]);
                byte[] wTargetNum = Arrays.copyOfRange(data, 8, 10);
                wTargetNum = toLittleEndian(wTargetNum);
                // log.info("目标总点数(转小端):" + DatatypeConverter.printHexBinary(wTargetNum));
                int targetNum = byteArrayToDecimal(wTargetNum);
                log.info("目标总点数(转整型):" + targetNum);
                //解析NET_TARGET_UNIT(64是NET_TARGET_HEAD的字节数)
                int unitIndex = index.acRes[1];
                log.info("有效负载无头起始位:" + unitIndex);
//                byte datum = data[unitIndex];
//                log.info("无头起始字节:" + SpringTool.byteToHex(datum));
                int UNITNum = (payloadSizeToDecimal - 64) / targetNum;
                log.info("单个Unit大小:" + UNITNum);
                int uintSize = (payloadSizeToDecimal - 64) / targetNum;
                log.info("单条报警大小:" + uintSize);
                for (int i = 0; i < targetNum; i++) {
                    Integer index = unitIndex + UNITNum * i;
                    Integer index = 68 + uintSize * i;
                    byte[] dwID = Arrays.copyOfRange(data, index, index + 4);
                    dwID = toLittleEndian(dwID);
                    // log.info("dwID:" + DatatypeConverter.printHexBinary(dwID));
                    int id = byteArrayToDecimal(dwID);
                    log.info("目标ID号:" + id);
                    byte[] dwGSum = Arrays.copyOfRange(data, index + 4, index + 8);
                    dwGSum = toLittleEndian(dwGSum);
                    int GSum = byteArrayToDecimal(dwGSum);
                    log.info("目标当前像素灰度和:" + GSum);
                    // log.info("目标ID号:" + id);
                    byte[] iDistance = Arrays.copyOfRange(data, index + 8, index + 12);
                    iDistance = toLittleEndian(iDistance);
                    int Distance = byteArrayToDecimal(iDistance);
                    log.info("目标当前距离(m):" + Distance);
                    byte[] iTw = Arrays.copyOfRange(data, index + 12, index + 16);
                    iTw = toLittleEndian(iTw);
                    int Tw = byteArrayToDecimal(iTw);
                    log.info("目标当前的像素宽度:" + Tw);
                    byte[] iTh = Arrays.copyOfRange(data, index + 16, index + 20);
                    iTh = toLittleEndian(iTh);
                    int Th = byteArrayToDecimal(iTh);
                    log.info("目标当前的像素高度:" + Th);
                    byte[] wPxlArea = Arrays.copyOfRange(data, index + 20, index + 22);
                    wPxlArea = toLittleEndian(wPxlArea);
                    int PxlArea = byteArrayToDecimal(wPxlArea);
                    log.info("目标当前像素面积:" + PxlArea);
                    byte[] cTrkNum = Arrays.copyOfRange(data, index + 22, index + 23);
                    cTrkNum = toLittleEndian(cTrkNum);
                    int TrkNum = byteArrayToDecimal(cTrkNum);
                    log.info("轨迹点数:" + TrkNum);
                    byte[] cStat = Arrays.copyOfRange(data, index + 23, index + 24);
                    cStat = toLittleEndian(cStat);
                    int Stat = byteArrayToDecimal(cStat);
                    log.info("目标当前状态:" + Stat);
                    byte[] sVx = Arrays.copyOfRange(data, index + 24, index + 26);
                    sVx = toLittleEndian(sVx);
                    int Vx = byteArrayToDecimal(sVx);
                    log.info("目标当前速度矢量(像素距离)X:" + Vx);
                    byte[] sVy = Arrays.copyOfRange(data, index + 26, index + 28);
                    sVy = toLittleEndian(sVy);
                    int Vy = byteArrayToDecimal(sVy);
                    log.info("目标当前速度矢量(像素距离)Y:" + Vy);
                    byte[] sAreaNo = Arrays.copyOfRange(data, index + 28, index + 30);
                    sAreaNo = toLittleEndian(sAreaNo);
                    int AreaNo = byteArrayToDecimal(sAreaNo);
                    log.info("目标归属的告警区域号:" + AreaNo);
                    byte[] cGrp = Arrays.copyOfRange(data, index + 30, index + 31);
                    cGrp = toLittleEndian(cGrp);
                    int Grp = byteArrayToDecimal(cGrp);
                    log.info("所属组:" + Grp);
                    // log.info("目标当前距离(m):" + Distance);
                    //region ä¸éœ€è¦çš„字段
//                    byte[] dwGSum = Arrays.copyOfRange(data, index + 4, index + 8);
//                    dwGSum = toLittleEndian(dwGSum);
//                    int GSum = byteArrayToDecimal(dwGSum);
//                    log.info("目标当前像素灰度和:" + GSum);
//                    byte[] iTw = Arrays.copyOfRange(data, index + 12, index + 16);
//                    iTw = toLittleEndian(iTw);
//                    int Tw = byteArrayToDecimal(iTw);
//                    log.info("目标当前的像素宽度:" + Tw);
//
//                    byte[] iTh = Arrays.copyOfRange(data, index + 16, index + 20);
//                    iTh = toLittleEndian(iTh);
//                    int Th = byteArrayToDecimal(iTh);
//                    log.info("目标当前的像素高度:" + Th);
//
//                    byte[] wPxlArea = Arrays.copyOfRange(data, index + 20, index + 22);
//                    wPxlArea = toLittleEndian(wPxlArea);
//                    int PxlArea = byteArrayToDecimal(wPxlArea);
//                    log.info("目标当前像素面积:" + PxlArea);
//
//                    byte[] cTrkNum = Arrays.copyOfRange(data, index + 22, index + 23);
//                    cTrkNum = toLittleEndian(cTrkNum);
//                    int TrkNum = byteArrayToDecimal(cTrkNum);
//                    log.info("轨迹点数:" + TrkNum);
//
//                    byte[] cStat = Arrays.copyOfRange(data, index + 23, index + 24);
//                    cStat = toLittleEndian(cStat);
//                    int Stat = byteArrayToDecimal(cStat);
//                    log.info("目标当前状态:" + Stat);
//
//                    byte[] sVx = Arrays.copyOfRange(data, index + 24, index + 26);
//                    sVx = toLittleEndian(sVx);
//                    int Vx = byteArrayToDecimal(sVx);
//                    log.info("目标当前速度矢量(像素距离)X:" + Vx);
//
//                    byte[] sVy = Arrays.copyOfRange(data, index + 26, index + 28);
//                    sVy = toLittleEndian(sVy);
//                    int Vy = byteArrayToDecimal(sVy);
//                    log.info("目标当前速度矢量(像素距离)Y:" + Vy);
//
//                    byte[] sAreaNo = Arrays.copyOfRange(data, index + 28, index + 30);
//                    sAreaNo = toLittleEndian(sAreaNo);
//                    int AreaNo = byteArrayToDecimal(sAreaNo);
//                    log.info("目标归属的告警区域号:" + AreaNo);
//
//                    byte[] cGrp = Arrays.copyOfRange(data, index + 30, index + 31);
//                    cGrp = toLittleEndian(cGrp);
//                    int Grp = byteArrayToDecimal(cGrp);
//                    log.info("所属组:" + Grp);
                    //endregion
                    byte[] szName = Arrays.copyOfRange(data, index + 64, index + 96);
                    String str = new String(szName, "GBK");
                    log.info("所属告警区域名称:" + str);
                    int position = findIndexOfDoubleZero(szName);
                    String alarmPointName = "";
                    if (position != -1) {
                        byte[] result = new byte[position];
                        System.arraycopy(szName, 0, result, 0, position);
                        alarmPointName = new String(result, "GBK");
                    } else {
                        alarmPointName = new String(szName, "GBK");
                    }
                    // log.info("所属告警区域名称:" + alarmPointName);
                    byte[] afTx = Arrays.copyOfRange(data, index + 96, index + 100);
                    afTx = toLittleEndian(afTx);
                    float fTx = bytesToFloat(afTx);
                    //  log.info("水平角度:" + fTx);
                    byte[] afTy = Arrays.copyOfRange(data, index + 112, index + 116);
                    afTy = toLittleEndian(afTy);
                    float fTy = bytesToFloat(afTy);
                    //  log.info("垂直角度:" + fTy);
                    log.info("雷达信息:" + host + "【port】" + port + "【X】" + longitude + "【Y】" + lagitude);
                    Double[] radarXY = {longitude, lagitude};
                    Double[] alarmXY = CalculateCoordinates(radarXY, Distance, (double) fTx);
                    log.info("报警信息:" + "【id】" + id + "【name】" + alarmPointName + "【alarmTime】" + alarmTime + "【distance】" + Distance + "【P】" + fTx + "【T】" + fTy + "【X】" + alarmXY[0] + "【Y】" + alarmXY[1]);
                    RadarAlarmInfo alarmInfo=new RadarAlarmInfo();
                    alarmInfo.setId(id);
                    alarmInfo.setAlarmTime(alarmTime);
                    alarmInfo.setName(alarmPointName+"("+name+")");
                    alarmInfo.setLongitude(alarmXY[0]);
                    alarmInfo.setLagitude(alarmXY[1]);
                    MqttConsumer.publish(2, false, "radar", JSON.toJSONString(alarmInfo));
                }
            }
        } catch (Exception ex) {
            log.error(ex.getMessage());
        }
    }
    /**
     * byte数组转float
     */
    private float bytesToFloat(byte[] bytes) {
        ByteBuffer buffer = ByteBuffer.wrap(bytes);
        return buffer.getFloat();
    }
    public static int byteArrayToDecimal(byte[] byteArray) {
    /**
     * byte数组转整型
     */
    public int byteArrayToDecimal(byte[] byteArray) {
        int decimalValue = 0;
        for (int i = 0; i < byteArray.length; i++) {
@@ -188,7 +261,10 @@
        return decimalValue;
    }
    public static byte[] toLittleEndian(byte[] bigEndianBytes) {
    /**
     * å¤§ç«¯è½¬å°ç«¯
     */
    public byte[] toLittleEndian(byte[] bigEndianBytes) {
        byte[] littleEndianBytes = new byte[bigEndianBytes.length];
        for (int i = 0; i < bigEndianBytes.length; i++) {
@@ -200,84 +276,12 @@
    }
    public static Integer processPayloadSize(String payloadSize) {//解析有效负载大小
        Integer payloadSizeInfo = 0;
        String[] payloadSizeArr = payloadSize.split("");
        for (int i = 0; i <= payloadSizeArr.length - 1; i++) {
            Integer num = null;
            switch (payloadSizeArr[i]) {
                case "0":
                    num = 0;
                    break;
                case "1":
                    num = 1;
                    break;
                case "2":
                    num = 2;
                    break;
                case "3":
                    num = 3;
                    break;
                case "4":
                    num = 4;
                    break;
                case "5":
                    num = 5;
                    break;
                case "6":
                    num = 6;
                    break;
                case "7":
                    num = 7;
                    break;
                case "8":
                    num = 8;
                    break;
                case "9":
                    num = 9;
                    break;
                case "a":
                    num = 10;
                    break;
                case "b":
                    num = 11;
                    break;
                case "c":
                    num = 12;
                    break;
                case "d":
                    num = 13;
                    break;
                case "e":
                    num = 14;
                    break;
                case "f":
                    num = 15;
                    break;
                default:
                    break;
            }
            if (i % 2 == 0) {
                payloadSizeInfo = payloadSizeInfo + num * 16;
            } else {
                payloadSizeInfo = payloadSizeInfo + num * 256;
            }
        }
        return payloadSizeInfo;
    }
    public static Boolean checkPayloadSize(Integer payloadSizeInfo, String data) {//校验有效负载大小
        Integer payloadSize = (data.length() - 8 - 8) / 2;//去除包头8位和校验8位
        if (payloadSize.equals(payloadSizeInfo)) {
            return true;
        } else {
            return false;
        }
    }
    // åˆ›å»ºç¼“冲区列表
    List<Byte> buffer = new ArrayList<>();
    /**
     * æŽ¥æ”¶å®Œæ•´åŒ…
     */
    public byte[] receiveCompletePacket(byte[] receivedData) {
        // å®šä¹‰åŒ…尾字节序列
        byte[] packetEnd = {0x01, 0x02, 0x00};
@@ -302,7 +306,10 @@
        return null;
    }
    public static int findPacketEndIndex(List<Byte> buffer, byte[] packetEnd) {
    /**
     * èŽ·å–åŒ…ç»“æŸç´¢å¼•
     */
    public int findPacketEndIndex(List<Byte> buffer, byte[] packetEnd) {
        for (int i = 0; i <= buffer.size() - packetEnd.length; i++) {
            boolean isMatch = true;
            for (int j = 0; j < packetEnd.length; j++) {
@@ -318,7 +325,10 @@
        return -1;
    }
    public static byte[] extractPacketFromBuffer(List<Byte> buffer, int endIndex) {
    /**
     * ä»Žç¼“冲区提取数据包
     */
    public byte[] extractPacketFromBuffer(List<Byte> buffer, int endIndex) {
        byte[] packet = new byte[endIndex];
        for (int i = 0; i < endIndex; i++) {
            packet[i] = buffer.get(i);
@@ -327,8 +337,10 @@
        return packet;
    }
    //去掉包头和包尾校验及转义
    public static byte[] transferData(byte[] data) {
    /**
     * åŽ»æŽ‰åŒ…å¤´å’ŒåŒ…å°¾æ ¡éªŒåŠè½¬ä¹‰
     */
    public byte[] transferData(byte[] data) {
        data = Arrays.copyOfRange(data, 3, data.length);
        data = Arrays.copyOfRange(data, 0, data.length - 7);
        String dataStr = DatatypeConverter.printHexBinary(data);
@@ -344,4 +356,32 @@
        data = DatatypeConverter.parseHexBinary(dataStr);
        return data;
    }
    /**
     * æ‰¾åˆ°00的索引位置
     */
    private int findIndexOfDoubleZero(byte[] bytes) {
        for (int i = 0; i < bytes.length - 1; i++) {
            if (bytes[i] == 0x00) {
                return i;
            }
        }
        return -1;
    }
    /**
     * é€šè¿‡A点坐标,长度和Y轴角度计算B点坐标
     */
    public Double[] CalculateCoordinates(Double[] radarCoordinates, Integer distance, Double angle) {
        double[] to_wgs84 = LonlatConver.gcj02_To_Wgs84(radarCoordinates[0], radarCoordinates[1]);
        double Ax = to_wgs84[0]; // A ç‚¹çš„ X åæ ‡
        double Ay = to_wgs84[1]; // A ç‚¹çš„ Y åæ ‡
        double AB = distance; // AB çš„长度
        double angleWithYAxisDegrees = angle; // AB ä¸Ž Y è½´çš„角度(以度数表示)
        GeodeticCalculator calculator = new GeodeticCalculator();
        GlobalCoordinates globalCoordinates = new GlobalCoordinates(Ay, Ax);
        GlobalCoordinates globalCoordinates1 = calculator.calculateEndingGlobalCoordinates(Ellipsoid.WGS84, globalCoordinates, angleWithYAxisDegrees, AB);
        return new Double[]{globalCoordinates1.getLongitude(), globalCoordinates1.getLatitude()};
    }
}
src/main/java/com/ard/utils/tcp/index.java
ÎļþÒÑɾ³ý
src/main/resources/application.yml
@@ -1,6 +1,11 @@
spring:
  netty:
    udp:
    port: 40000
      enabled: true
    tcp:
      host: 112.98.126.2
      port: 1200
    enabled: true
  mqtt:
    host: tcp://192.168.1.15:1883
@@ -15,15 +20,15 @@
    url: http://iot.zhdk.net:8090/Warning/GetWarning?userName=cy4oil
  datasource:
    driver-class-name: org.postgresql.Driver
#    url: jdbc:postgresql://111.40.46.199:15432/ry-vue?stringtype=unspecified
#    username: postgres
#    password: Yykj.2021
    url: jdbc:postgresql://192.168.1.15:5432/ry-vue?stringtype=unspecified
    url: jdbc:postgresql://111.40.46.199:15432/ry-vue?stringtype=unspecified
    username: postgres
    password: postgres
    password: Yykj.2021
#    url: jdbc:postgresql://192.168.1.15:5432/ry-vue?stringtype=unspecified
#    username: postgres
#    password: postgres
mybatis:
  type-aliases-package: com.ard.alarm.camera.domain.ArdCameras
  mapper-locations: classpath:/mapper/*.xml
  typeAliasesPackage: com.ard.alarm.**.domain
  mapperLocations: classpath:/mapper/*.xml
# minio配置
minio:
  endpoint: http://192.168.1.15:9001
src/main/resources/mapper/ArdEquipRadarMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,180 @@
<?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.ard.alarm.radar.mapper.ArdEquipRadarMapper">
    <resultMap type="ArdEquipRadar" id="ArdEquipRadarResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="port"    column="port"    />
        <result property="operate"    column="operate"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="userId"    column="user_id"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="altitude"    column="altitude"    />
        <result property="radarDate"    column="radar_date"    />
        <result property="deptId"    column="dept_id"    />
        <result property="pitch"    column="pitch"    />
        <result property="towerId"    column="tower_id"    />
        <result property="imageWidth"    column="image_width"    />
        <result property="imageHeight"    column="image_height"    />
        <result property="type"    column="type"    />
        <result property="ip"    column="ip"    />
        <result property="towerName"    column="name"    />
    </resultMap>
    <sql id="selectArdEquipRadarVo">
        select c.id,
               c.name,
               c.create_by,
               c.port,
               c.operate,
               c.create_time,
               c.update_by,
               c.update_time,
               c.del_flag,
               c.user_id,
               c.longitude,
               c.latitude,
               c.altitude,
               c.radar_date,
               c.dept_id,
               c.pitch,
               c.tower_id,
               c.image_width,
               c.image_height,
               c.type,
               c.ip
        from ard_equip_radar c
    </sql>
    <select id="selectArdEquipRadarList" parameterType="ArdEquipRadar" resultMap="ArdEquipRadarResult">
        select c.id,c.name,
        c.create_by,
        c.port,
        c.operate,
        c.create_time,
        c.update_by,
        c.update_time,
        c.del_flag,
        c.user_id,
        c.longitude,
        c.latitude,
        c.altitude,
        c.radar_date,
        c.dept_id,
        c.pitch,
        c.tower_id,
        c.image_width,
        c.image_height,
        c.type,
        c.ip,
        t.name
        from ard_equip_radar c
        left join sys_dept d on d.dept_id = c.dept_id
        left join sys_user u on u.user_id = c.user_id
        left join ard_towers t on t.id = c.tower_id
        <where>
            <if test="towerId != null  and towerId != ''"> and c.tower_id = #{towerId}</if>
            <if test="userId != null  and userId != ''">and c.user_id = #{userId}</if>
            <if test="deptId != null ">and (c.dept_id = #{deptId} OR c.dept_id IN ( SELECT t.dept_id FROM sys_dept t
                WHERE cast(#{deptId} as varchar) = any(string_to_array(ancestors,',')) ))
            </if>
        </where>
    </select>
    <select id="selectArdEquipRadarById" parameterType="String" resultMap="ArdEquipRadarResult">
        <include refid="selectArdEquipRadarVo"/>
        where id = #{id}
    </select>
    <insert id="insertArdEquipRadar" parameterType="ArdEquipRadar">
        insert into ard_equip_radar
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="createBy != null">create_by,</if>
            <if test="port != null">port,</if>
            <if test="operate != null">operate,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="userId != null">user_id,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="altitude != null">altitude,</if>
            <if test="radarDate != null">radar_date,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="pitch != null">pitch,</if>
            <if test="towerId != null">tower_id,</if>
            <if test="imageWidth != null">image_width,</if>
            <if test="imageHeight != null">image_height,</if>
            <if test="type != null">type,</if>
            <if test="ip != null">ip,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="port != null">#{port},</if>
            <if test="operate != null">#{operate},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="userId != null">#{userId},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="altitude != null">#{altitude},</if>
            <if test="radarDate != null">#{radarDate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="pitch != null">#{pitch},</if>
            <if test="towerId != null">#{towerId},</if>
            <if test="imageWidth != null">#{imageWidth},</if>
            <if test="imageHeight != null">#{imageHeight},</if>
            <if test="type != null">#{type},</if>
            <if test="ip != null">#{ip},</if>
         </trim>
    </insert>
    <update id="updateArdEquipRadar" parameterType="ArdEquipRadar">
        update ard_equip_radar
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="port != null">port = #{port},</if>
            <if test="operate != null">operate = #{operate},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="altitude != null">altitude = #{altitude},</if>
            <if test="radarDate != null">radar_date = #{radarDate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="pitch != null">pitch = #{pitch},</if>
            <if test="towerId != null">tower_id = #{towerId},</if>
            <if test="imageWidth != null">image_width = #{imageWidth},</if>
            <if test="imageHeight != null">image_height = #{imageHeight},</if>
            <if test="type != null">type = #{type},</if>
            <if test="ip != null">ip = #{ip},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteArdEquipRadarById" parameterType="String">
        delete from ard_equip_radar where id = #{id}
    </delete>
    <delete id="deleteArdEquipRadarByIds" parameterType="String">
        delete from ard_equip_radar where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>