|
@@ -0,0 +1,84 @@
|
|
|
+package cn.com.taiji.service.impl;
|
|
|
+
|
|
|
+import cn.com.taiji.constants.TopicConstants;
|
|
|
+import cn.com.taiji.entity.BeidouShipTrackDTO;
|
|
|
+import cn.com.taiji.entity.GlobalAisTrackDTO;
|
|
|
+import cn.com.taiji.entity.Location;
|
|
|
+import cn.com.taiji.service.SimulationTrackService;
|
|
|
+import cn.com.taiji.utils.LocationUtils;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import org.springframework.kafka.core.KafkaTemplate;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author chenfangchao
|
|
|
+ * @title: SimulationTrackImpl
|
|
|
+ * @projectName es-track-analysis
|
|
|
+ * @description: TODO
|
|
|
+ * @date 2023/2/7 5:16 PM
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class SimulationTrackImpl implements SimulationTrackService {
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private KafkaTemplate<String, Object> kafkaTemplate;
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:00", 109.287806, 19.718716, 101.287806, 19.918716);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void beidouTrack() {
|
|
|
+ List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:00", 109.287806, 19.718716, 101.287806, 20.918716);
|
|
|
+ for (Location location : list) {
|
|
|
+ BeidouShipTrackDTO beidouShipTrackDTO = new BeidouShipTrackDTO();
|
|
|
+ beidouShipTrackDTO.setTrackId(20236688L);
|
|
|
+ beidouShipTrackDTO.setTime(DateUtil.now());
|
|
|
+ beidouShipTrackDTO.setDeviceId("2023111,2023222");
|
|
|
+ beidouShipTrackDTO.setShipType(1L);
|
|
|
+ beidouShipTrackDTO.setWorkType(1L);
|
|
|
+ beidouShipTrackDTO.setWorkWay(1);
|
|
|
+ beidouShipTrackDTO.setSendTime(DateUtil.now());
|
|
|
+ beidouShipTrackDTO.setLocationTime(DateUtil.now());
|
|
|
+ beidouShipTrackDTO.setOnline(1);
|
|
|
+ beidouShipTrackDTO.setShipLength(1);
|
|
|
+ beidouShipTrackDTO.setShipWidth(1);
|
|
|
+ beidouShipTrackDTO.setTexture(1);
|
|
|
+ beidouShipTrackDTO.setDirection(1D);
|
|
|
+ beidouShipTrackDTO.setSpeed(1D);
|
|
|
+ beidouShipTrackDTO.setKwh(1);
|
|
|
+ beidouShipTrackDTO.setShipName("模拟北斗船舶");
|
|
|
+ beidouShipTrackDTO.setLatitude(location.getLat());
|
|
|
+ beidouShipTrackDTO.setLongitude(location.getLog());
|
|
|
+ String data = JSONUtil.toJsonStr(beidouShipTrackDTO);
|
|
|
+ kafkaTemplate.send(TopicConstants.BEIDOU_TOPIC,data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void aisTrack() {
|
|
|
+ List<Location> list = LocationUtils.generateLogLat("2023-02-03 00:00:00", "2023-02-03 00:02:00", 101.287806, 20.718716, 101.387806, 20.818716);
|
|
|
+ for (Location location : list) {
|
|
|
+ GlobalAisTrackDTO globalAisTrackDTO = new GlobalAisTrackDTO();
|
|
|
+ globalAisTrackDTO.setUserid("2023111,2023222");
|
|
|
+ globalAisTrackDTO.setReceiveTime(DateUtil.now());
|
|
|
+ globalAisTrackDTO.setMessageid("2023");
|
|
|
+ globalAisTrackDTO.setNavStatus("1");
|
|
|
+ globalAisTrackDTO.setRot("1");
|
|
|
+ globalAisTrackDTO.setSog("1");
|
|
|
+ globalAisTrackDTO.setCog("1");
|
|
|
+ globalAisTrackDTO.setTrueHeading("1");
|
|
|
+ globalAisTrackDTO.setDsource("1");
|
|
|
+ globalAisTrackDTO.setLongitude(location.getLog());
|
|
|
+ globalAisTrackDTO.setLatitude(location.getLat());
|
|
|
+ String data = JSONUtil.toJsonStr(globalAisTrackDTO);
|
|
|
+ kafkaTemplate.send(TopicConstants.GLOBAL_AIS,data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|