Browse Source

[fix]#北斗-天奥

chenfangchao 2 years ago
parent
commit
236ed6b454

+ 149 - 149
simulation-track/src/main/java/cn/com/taiji/service/impl/SimulationTrackImpl.java

@@ -73,67 +73,67 @@ public class SimulationTrackImpl implements SimulationTrackService {
         if (0 == beidouStatus) {
             Thread thread = new Thread(() -> {
                 while (true) {
-                    if (beidouStatus == 1) {
-                        Thread.currentThread().interrupt();
-                    } else {
-                        List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67642971192785, 18.18460507789732, 109.69596855881268, 18.185299250953545);
-                        for (Location location : list) {
-                            BeidouShipTrackDTO beidouShipTrackDTO = new BeidouShipTrackDTO();
-                            beidouShipTrackDTO.setId("20236688");
-                            beidouShipTrackDTO.setCurren_time(DateUtil.now());
-                            beidouShipTrackDTO.setTrackId(20236688);
-                            beidouShipTrackDTO.setDeviceId(20236688);
-                            beidouShipTrackDTO.setSendTime(DateUtil.now());
-                            beidouShipTrackDTO.setLocationTime(DateUtil.now());
-                            beidouShipTrackDTO.setShipName("20236688测试船舶");
-                            beidouShipTrackDTO.setReceiveTime(DateUtil.now());
-                            beidouShipTrackDTO.setLongitude(location.getLog());
-                            beidouShipTrackDTO.setLatitude(location.getLat());
-                            String data = JSONUtil.toJsonStr(beidouShipTrackDTO);
-                            try {
-                                Thread.sleep(1000);
-                                kafkaTemplate.send(TopicConstants.BEIDOU_TOPIC, data);
-                                log.info(DateUtil.now() + "模拟北斗船舶:20236688测试船舶,终端号为20236688完成");
-                            } catch (InterruptedException e) {
-                                Thread.currentThread().interrupt();
-                                e.printStackTrace();
-                            }
+                    boolean interrupted = Thread.currentThread().isInterrupted();
+                    if (interrupted) {
+                        break;
+                    }
+                    List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67642971192785, 18.18460507789732, 109.69596855881268, 18.185299250953545);
+                    for (Location location : list) {
+                        BeidouShipTrackDTO beidouShipTrackDTO = new BeidouShipTrackDTO();
+                        beidouShipTrackDTO.setId("20236688");
+                        beidouShipTrackDTO.setCurren_time(DateUtil.now());
+                        beidouShipTrackDTO.setTrackId(20236688);
+                        beidouShipTrackDTO.setDeviceId(20236688);
+                        beidouShipTrackDTO.setSendTime(DateUtil.now());
+                        beidouShipTrackDTO.setLocationTime(DateUtil.now());
+                        beidouShipTrackDTO.setShipName("20236688测试船舶");
+                        beidouShipTrackDTO.setReceiveTime(DateUtil.now());
+                        beidouShipTrackDTO.setLongitude(location.getLog());
+                        beidouShipTrackDTO.setLatitude(location.getLat());
+                        String data = JSONUtil.toJsonStr(beidouShipTrackDTO);
+                        try {
+                            Thread.sleep(1000);
+                            kafkaTemplate.send(TopicConstants.BEIDOU_TOPIC, data);
+                            log.info(DateUtil.now() + "模拟北斗船舶:20236688测试船舶,终端号为20236688完成");
+                        } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
+                            e.printStackTrace();
                         }
                     }
                 }
             });
             Thread thread1 = new Thread(() -> {
                 while (true) {
-                    if (beidouStatus == 1) {
-                        Thread.currentThread().interrupt();
-                    } else {
-                        /**
-                         * 开始位置 109.67638187069215,18.184651060263896 三亚位置 西州偏北一点
-                         * 结束位置 109.69603272744908,18.18548237188056 三亚位置 东洲偏北一点
-                         */
-                        //模拟同船的第二个设备
-                        List<Location> list1 = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67638187069215, 18.184651060263896, 109.69603272744908, 18.18548237188056);
-                        for (Location location : list1) {
-                            BeidouShipTrackDTO beidouShipTrackDTO = new BeidouShipTrackDTO();
-                            beidouShipTrackDTO.setId("20236699");
-                            beidouShipTrackDTO.setCurren_time(DateUtil.now());
-                            beidouShipTrackDTO.setTrackId(20236699);
-                            beidouShipTrackDTO.setDeviceId(20236699);
-                            beidouShipTrackDTO.setSendTime(DateUtil.now());
-                            beidouShipTrackDTO.setLocationTime(DateUtil.now());
-                            beidouShipTrackDTO.setShipName("20236688测试船舶");
-                            beidouShipTrackDTO.setReceiveTime(DateUtil.now());
-                            beidouShipTrackDTO.setLongitude(location.getLog());
-                            beidouShipTrackDTO.setLatitude(location.getLat());
-                            String data = JSONUtil.toJsonStr(beidouShipTrackDTO);
-                            try {
-                                Thread.sleep(1000);
-                                kafkaTemplate.send(TopicConstants.BEIDOU_TOPIC, data);
-                                log.info(DateUtil.now() + "模拟北斗船舶:20236688测试船舶,终端号为20236699完成");
-                            } catch (InterruptedException e) {
-                                Thread.currentThread().interrupt();
-                                e.printStackTrace();
-                            }
+                    boolean interrupted = Thread.currentThread().isInterrupted();
+                    if (interrupted) {
+                        break;
+                    }
+                    /**
+                     * 开始位置 109.67638187069215,18.184651060263896 三亚位置 西州偏北一点
+                     * 结束位置 109.69603272744908,18.18548237188056 三亚位置 东洲偏北一点
+                     */
+                    //模拟同船的第二个设备
+                    List<Location> list1 = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67638187069215, 18.184651060263896, 109.69603272744908, 18.18548237188056);
+                    for (Location location : list1) {
+                        BeidouShipTrackDTO beidouShipTrackDTO = new BeidouShipTrackDTO();
+                        beidouShipTrackDTO.setId("20236699");
+                        beidouShipTrackDTO.setCurren_time(DateUtil.now());
+                        beidouShipTrackDTO.setTrackId(20236699);
+                        beidouShipTrackDTO.setDeviceId(20236699);
+                        beidouShipTrackDTO.setSendTime(DateUtil.now());
+                        beidouShipTrackDTO.setLocationTime(DateUtil.now());
+                        beidouShipTrackDTO.setShipName("20236688测试船舶");
+                        beidouShipTrackDTO.setReceiveTime(DateUtil.now());
+                        beidouShipTrackDTO.setLongitude(location.getLog());
+                        beidouShipTrackDTO.setLatitude(location.getLat());
+                        String data = JSONUtil.toJsonStr(beidouShipTrackDTO);
+                        try {
+                            Thread.sleep(1000);
+                            kafkaTemplate.send(TopicConstants.BEIDOU_TOPIC, data);
+                            log.info(DateUtil.now() + "模拟北斗船舶:20236688测试船舶,终端号为20236699完成");
+                        } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
+                            e.printStackTrace();
                         }
                     }
                 }
@@ -159,59 +159,59 @@ public class SimulationTrackImpl implements SimulationTrackService {
         if (hlxOneLevelStatus == 0) {
             Thread thread = new Thread(() -> {
                 while (true) {
-                    if (hlxOneLevelStatus == 1) {
-                        Thread.currentThread().interrupt();
-                    } else {
-                        List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67642971192785, 18.18460507789732, 109.69596855881268, 18.185299250953545);
-                        for (Location location : list) {
-                            HlxOneLevelTrackDTO hlxOneLevelTrack = new HlxOneLevelTrackDTO();
-                            hlxOneLevelTrack.setLatitude(location.getLat());
-                            hlxOneLevelTrack.setLongitude(location.getLog());
-                            hlxOneLevelTrack.setRadarID("20236666");
-                            hlxOneLevelTrack.setTargetID("20236666");
-                            hlxOneLevelTrack.setTime(DateUtil.now());
-                            hlxOneLevelTrack.setVesselName("测试船舶20236666");
-                            String data = JSONUtil.toJsonStr(hlxOneLevelTrack);
-                            try {
-                                Thread.sleep(1000);
-                                kafkaTemplate.send(TopicConstants.HLX_ONE_LEVEL, data);
-                                log.info(DateUtil.now() + "模拟海兰信一级融合船舶:测试船舶20236666,终端号为20236666完成");
-                            } catch (InterruptedException e) {
-                                Thread.currentThread().interrupt();
-                                e.printStackTrace();
-                            }
+                    boolean interrupted = Thread.currentThread().isInterrupted();
+                    if (interrupted) {
+                        break;
+                    }
+                    List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67642971192785, 18.18460507789732, 109.69596855881268, 18.185299250953545);
+                    for (Location location : list) {
+                        HlxOneLevelTrackDTO hlxOneLevelTrack = new HlxOneLevelTrackDTO();
+                        hlxOneLevelTrack.setLatitude(location.getLat());
+                        hlxOneLevelTrack.setLongitude(location.getLog());
+                        hlxOneLevelTrack.setRadarID("20236666");
+                        hlxOneLevelTrack.setTargetID("20236666");
+                        hlxOneLevelTrack.setTime(DateUtil.now());
+                        hlxOneLevelTrack.setVesselName("测试船舶20236666");
+                        String data = JSONUtil.toJsonStr(hlxOneLevelTrack);
+                        try {
+                            Thread.sleep(1000);
+                            kafkaTemplate.send(TopicConstants.HLX_ONE_LEVEL, data);
+                            log.info(DateUtil.now() + "模拟海兰信一级融合船舶:测试船舶20236666,终端号为20236666完成");
+                        } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
+                            e.printStackTrace();
                         }
                     }
                 }
             });
             Thread thread1 = new Thread(() -> {
                 while (true) {
-                    if (hlxOneLevelStatus == 1) {
-                        Thread.currentThread().interrupt();
-                    } else {
-                        /**
-                         * 开始位置 109.67638187069215,18.184651060263896
-                         * 结束位置 109.69603272744908,18.18548237188056
-                         */
-                        //模拟同船的第二个设备
-                        List<Location> list1 = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67638187069215, 18.184651060263896, 109.69603272744908, 18.18548237188056);
-                        for (Location location : list1) {
-                            HlxOneLevelTrackDTO hlxOneLevelTrack = new HlxOneLevelTrackDTO();
-                            hlxOneLevelTrack.setLatitude(location.getLat());
-                            hlxOneLevelTrack.setLongitude(location.getLog());
-                            hlxOneLevelTrack.setRadarID("20236677");
-                            hlxOneLevelTrack.setTargetID("20236677");
-                            hlxOneLevelTrack.setTime(DateUtil.now());
-                            hlxOneLevelTrack.setVesselName("测试船舶20236666");
-                            String data = JSONUtil.toJsonStr(hlxOneLevelTrack);
-                            try {
-                                Thread.sleep(1000);
-                                kafkaTemplate.send(TopicConstants.HLX_ONE_LEVEL, data);
-                                log.info(DateUtil.now() + "模拟海兰信一级融合船舶:测试船舶20236666,终端号为20236677完成");
-                            } catch (InterruptedException e) {
-                                Thread.currentThread().interrupt();
-                                e.printStackTrace();
-                            }
+                    boolean interrupted = Thread.currentThread().isInterrupted();
+                    if (interrupted) {
+                        break;
+                    }
+                    /**
+                     * 开始位置 109.67638187069215,18.184651060263896
+                     * 结束位置 109.69603272744908,18.18548237188056
+                     */
+                    //模拟同船的第二个设备
+                    List<Location> list1 = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67638187069215, 18.184651060263896, 109.69603272744908, 18.18548237188056);
+                    for (Location location : list1) {
+                        HlxOneLevelTrackDTO hlxOneLevelTrack = new HlxOneLevelTrackDTO();
+                        hlxOneLevelTrack.setLatitude(location.getLat());
+                        hlxOneLevelTrack.setLongitude(location.getLog());
+                        hlxOneLevelTrack.setRadarID("20236677");
+                        hlxOneLevelTrack.setTargetID("20236677");
+                        hlxOneLevelTrack.setTime(DateUtil.now());
+                        hlxOneLevelTrack.setVesselName("测试船舶20236666");
+                        String data = JSONUtil.toJsonStr(hlxOneLevelTrack);
+                        try {
+                            Thread.sleep(1000);
+                            kafkaTemplate.send(TopicConstants.HLX_ONE_LEVEL, data);
+                            log.info(DateUtil.now() + "模拟海兰信一级融合船舶:测试船舶20236666,终端号为20236677完成");
+                        } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
+                            e.printStackTrace();
                         }
                     }
                 }
@@ -235,58 +235,58 @@ public class SimulationTrackImpl implements SimulationTrackService {
         if (0 == beidouhlxOneLevelStatus) {
             Thread thread = new Thread(() -> {
                 while (true) {
-                    if (beidouhlxOneLevelStatus == 1) {
-                        Thread.currentThread().interrupt();
-                    } else {
-                        List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67642971192785, 18.18460507789732, 109.69596855881268, 18.185299250953545);
-                        for (Location location : list) {
-                            BeidouShipTrackDTO beidouShipTrackDTO = new BeidouShipTrackDTO();
-                            beidouShipTrackDTO.setId("20236688");
-                            beidouShipTrackDTO.setCurren_time(DateUtil.now());
-                            beidouShipTrackDTO.setTrackId(20236688);
-                            beidouShipTrackDTO.setDeviceId(20236688);
-                            beidouShipTrackDTO.setSendTime(DateUtil.now());
-                            beidouShipTrackDTO.setLocationTime(DateUtil.now());
-                            beidouShipTrackDTO.setShipName("20236688测试船舶");
-                            beidouShipTrackDTO.setReceiveTime(DateUtil.now());
-                            beidouShipTrackDTO.setLongitude(location.getLog());
-                            beidouShipTrackDTO.setLatitude(location.getLat());
-                            String data = JSONUtil.toJsonStr(beidouShipTrackDTO);
-                            try {
-                                Thread.sleep(2500);
-                                kafkaTemplate.send(TopicConstants.BEIDOU_TOPIC, data);
-                                log.info(DateUtil.now() + "模拟北斗船舶:20236688测试船舶,终端号为20236688完成");
-                            } catch (InterruptedException e) {
-                                Thread.currentThread().interrupt();
-                                e.printStackTrace();
-                            }
+                    boolean interrupted = Thread.currentThread().isInterrupted();
+                    if (interrupted) {
+                        break;
+                    }
+                    List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67642971192785, 18.18460507789732, 109.69596855881268, 18.185299250953545);
+                    for (Location location : list) {
+                        BeidouShipTrackDTO beidouShipTrackDTO = new BeidouShipTrackDTO();
+                        beidouShipTrackDTO.setId("20236688");
+                        beidouShipTrackDTO.setCurren_time(DateUtil.now());
+                        beidouShipTrackDTO.setTrackId(20236688);
+                        beidouShipTrackDTO.setDeviceId(20236688);
+                        beidouShipTrackDTO.setSendTime(DateUtil.now());
+                        beidouShipTrackDTO.setLocationTime(DateUtil.now());
+                        beidouShipTrackDTO.setShipName("20236688测试船舶");
+                        beidouShipTrackDTO.setReceiveTime(DateUtil.now());
+                        beidouShipTrackDTO.setLongitude(location.getLog());
+                        beidouShipTrackDTO.setLatitude(location.getLat());
+                        String data = JSONUtil.toJsonStr(beidouShipTrackDTO);
+                        try {
+                            Thread.sleep(2500);
+                            kafkaTemplate.send(TopicConstants.BEIDOU_TOPIC, data);
+                            log.info(DateUtil.now() + "模拟北斗船舶:20236688测试船舶,终端号为20236688完成");
+                        } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
+                            e.printStackTrace();
                         }
                     }
                 }
             });
             Thread thread1 = new Thread(() -> {
                 while (true) {
-                    if (beidouhlxOneLevelStatus == 1) {
-                        Thread.currentThread().interrupt();
-                    } else {
-                        List<Location> list1 = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67642971192785, 18.18460507789732, 109.69596855881268, 18.185299250953545);
-                        for (Location location : list1) {
-                            HlxOneLevelTrackDTO hlxOneLevelTrack = new HlxOneLevelTrackDTO();
-                            hlxOneLevelTrack.setLatitude(location.getLat());
-                            hlxOneLevelTrack.setLongitude(location.getLog());
-                            hlxOneLevelTrack.setRadarID("20236666");
-                            hlxOneLevelTrack.setTargetID("20236666");
-                            hlxOneLevelTrack.setTime(DateUtil.now());
-                            hlxOneLevelTrack.setVesselName("20236688测试船舶");
-                            String data = JSONUtil.toJsonStr(hlxOneLevelTrack);
-                            try {
-                                Thread.sleep(2500);
-                                kafkaTemplate.send(TopicConstants.HLX_ONE_LEVEL, data);
-                                log.info(DateUtil.now() + "模拟海兰信一级融合船舶:20236688测试船舶,终端号为20236666完成");
-                            } catch (InterruptedException e) {
-                                Thread.currentThread().interrupt();
-                                e.printStackTrace();
-                            }
+                    boolean interrupted = Thread.currentThread().isInterrupted();
+                    if (interrupted) {
+                        break;
+                    }
+                    List<Location> list1 = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:10", 109.67642971192785, 18.18460507789732, 109.69596855881268, 18.185299250953545);
+                    for (Location location : list1) {
+                        HlxOneLevelTrackDTO hlxOneLevelTrack = new HlxOneLevelTrackDTO();
+                        hlxOneLevelTrack.setLatitude(location.getLat());
+                        hlxOneLevelTrack.setLongitude(location.getLog());
+                        hlxOneLevelTrack.setRadarID("20236666");
+                        hlxOneLevelTrack.setTargetID("20236666");
+                        hlxOneLevelTrack.setTime(DateUtil.now());
+                        hlxOneLevelTrack.setVesselName("20236688测试船舶");
+                        String data = JSONUtil.toJsonStr(hlxOneLevelTrack);
+                        try {
+                            Thread.sleep(2500);
+                            kafkaTemplate.send(TopicConstants.HLX_ONE_LEVEL, data);
+                            log.info(DateUtil.now() + "模拟海兰信一级融合船舶:20236688测试船舶,终端号为20236666完成");
+                        } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
+                            e.printStackTrace();
                         }
                     }
                 }
@@ -424,7 +424,7 @@ public class SimulationTrackImpl implements SimulationTrackService {
             Thread thread = new Thread(() -> {
                 while (true) {
                     boolean interrupted = Thread.currentThread().isInterrupted();
-                    if(interrupted){
+                    if (interrupted) {
                         break;
                     }
                     List<Location> list = LocationUtils.generateLogLatBeidou("2023-02-19 14:00:00", "2023-02-19 14:30:00", 109.11032753891612, 19.687745190689267, 109.16730608884323, 19.68914959156775);