From 25c4aae722215bfd3960e628c386dc1a5d50be66 Mon Sep 17 00:00:00 2001 From: ZhangXushuo <3508242435.com> Date: Fri, 1 Dec 2023 15:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=9E=90=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/bootstrap.yml | 1 - .../com/fivegroup/analysis/domain/Topic.java | 37 +++ .../analysis/domain/VehicleData.java | 300 ++++++++++++++++++ .../domain/constant/KafkaConstant.java | 16 + .../mapper/VehicleHistoryIncidentMapper.java | 15 + .../analysis/service/KafkaConsumerConfig.java | 36 +++ .../service/KafkaConsumerService.java | 119 +++++++ .../service/VehicleIncidentService.java | 14 + .../VehicleBreakdownIncidentServiceImpl.java | 30 ++ .../impl/VehicleFenceIncidentServiceImpl.java | 31 ++ .../VehicleHistoryIncidentServiceImpl.java | 29 ++ .../impl/VehicleRealIncidentServiceImpl.java | 32 ++ .../mapper/VehicleHistoryIncidentMapper.xml | 57 ++++ .../src/main/resources/bootstrap.yml | 2 +- fivegroup-modules/fivegroup-wall/pom.xml | 3 - fivegroup-modules/pom.xml | 1 + 16 files changed, 718 insertions(+), 5 deletions(-) create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/Topic.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/VehicleData.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/constant/KafkaConstant.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/mapper/VehicleHistoryIncidentMapper.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/KafkaConsumerConfig.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/KafkaConsumerService.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/VehicleIncidentService.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleBreakdownIncidentServiceImpl.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleFenceIncidentServiceImpl.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleHistoryIncidentServiceImpl.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleRealIncidentServiceImpl.java create mode 100644 fivegroup-modules/fivegroup-analysis/src/main/resources/mapper/VehicleHistoryIncidentMapper.xml diff --git a/fivegroup-gateway/src/main/resources/bootstrap.yml b/fivegroup-gateway/src/main/resources/bootstrap.yml index 1b6abd8..6f8fb00 100644 --- a/fivegroup-gateway/src/main/resources/bootstrap.yml +++ b/fivegroup-gateway/src/main/resources/bootstrap.yml @@ -1,7 +1,6 @@ # Tomcat server: port: 8080 - # Spring spring: application: diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/Topic.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/Topic.java new file mode 100644 index 0000000..8d81f21 --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/Topic.java @@ -0,0 +1,37 @@ +package com.fivegroup.analysis.domain; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 主题 + * + * @author ZhangXushuo + * @version 2023/11/30 - 19:25 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Topic { + /** + * id + */ + private long id; + /** + * 车辆VIN + */ + private String vehicleVin; + /** + * 车辆主题 + */ + private String topic; + + /** + * 车辆分区 + */ + private Integer subzone; + +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/VehicleData.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/VehicleData.java new file mode 100644 index 0000000..8a79643 --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/VehicleData.java @@ -0,0 +1,300 @@ +package com.fivegroup.analysis.domain; + +import lombok.*; + +import java.math.BigDecimal; +import java.util.Date; +/** + * 车辆数据 + * + * @author ZhangXushuo + * @version 2023/11/30 - 20:28 + */ +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class VehicleData { + /** + * VIN + */ + private String vin; + + /** + * 时间戳 + */ + private Date createTime; + + /** + * 经度 + */ + private String longitude; + + /** + * 维度 + */ + private String latitude; + + /** + * 速度 + */ + private String speed; + + /** + * 里程 + */ + private BigDecimal mileage; + + /** + * 总电压 + */ + private String voltage; + + /** + * 总电流 + */ + private String current; + + /** + * 绝缘电阻 + */ + private String resistance; + + /** + * 档位 + */ + private String gear; + + /** + * 加速踏板行程值 + */ + private String accelerationPedal; + + /** + * 制动踏板行程值 + */ + private String brakePedal; + + /** + * 燃料消耗率 + */ + private String fuelConsumptionRate; + + /** + * 电机控制器温度 + */ + private String motorControllerTemperature; + + /** + * 电机转速 + */ + private String motorSpeed; + + /** + * 电机转矩 + */ + private String motorTorque; + + /** + * 电机温度 + */ + private String motorTemperature; + + /** + * 电机电压 + */ + private String motorVoltage; + + /** + * 电机电流 + */ + private String motorCurrent; + + /** + * 动力电池剩余电量SOC + */ + private BigDecimal remainingBattery; + + + /** + * 当前状态允许的最大反馈功率 + */ + private String maximumFeedbackPower; + + /** + * 当前状态允许最大放电功率 + */ + private String maximumDischargePower; + + /** + * BMS自检计数器 + */ + private String selfCheckCounter; + + /** + * 动力电池充放电电流 + */ + private String totalBatteryCurrent; + + /** + * 动力电池负载端总电压V3 + */ + private String totalBatteryVoltage; + + /** + * 单次最大电压 + */ + private String singleBatteryMaxVoltage; + + /** + * 单体电池最低电压 + */ + private String singleBatteryMinVoltage; + + /** + * 单体电池最高温度 + */ + private String singleBatteryMaxTemperature; + + /** + * 单体电池最低温度 + */ + private String singleBatteryMinTemperature; + + /** + * 动力电池可用容量 + */ + private String availableBatteryCapacity; + + /** + * 车辆状态 + */ + private int vehicleStatus; + + /** + * 充电状态 + */ + private int chargingStatus; + + /** + * 运行状态 + */ + private int operatingStatus; + + /** + * SOC + */ + private int socStatus; + + /** + * 可充电储能装置工作状态 + */ + private int chargingEnergyStorageStatus; + + /** + * 驱动电机状态 + */ + private int driveMotorStatus; + + /** + * 定位是否有效 + */ + private int positionStatus; + + /** + * EAS(汽车防盗系统)状态 + */ + private int easStatus; + + /** + * PTC(电动加热器)状态 + */ + private int ptcStatus; + + /** + * EPS(电动助力系统)状态 + */ + private int epsStatus; + + /** + * ABS(防抱死)状态 + */ + private int absStatus; + + /** + * MCU(电机/逆变器)状态 + */ + private int mcuStatus; + + /** + * 动力电池加热状态 + */ + private int heatingStatus; + + /** + * 动力电池当前状态 + */ + private int batteryStatus; + + /** + * 动力电池保温状态 + */ + private int batteryInsulationStatus; + + + public static VehicleData getBuild(String messages) { + char start = messages.charAt(0); + char end = messages.charAt(messages.length() - 1); + System.out.println(start); + System.out.println(end); + return VehicleData.builder() + .vin(messages.substring(1, 18)) + .createTime(new Date(Long.parseLong(messages.substring(18, 31)))) + .longitude(messages.substring(31, 42)) + .latitude(messages.substring(42, 52)) + .speed(messages.substring(52, 58)) + .mileage(new BigDecimal(messages.substring(58, 69))) + .voltage(messages.substring(69, 75)) + .current(messages.substring(75, 80)) + .resistance(messages.substring(80, 89)) + .gear(messages.substring(89, 90)) + .accelerationPedal(messages.substring(90, 92)) + .brakePedal(messages.substring(92, 94)) + .fuelConsumptionRate(messages.substring(94, 99)) + .motorControllerTemperature(messages.substring(99, 105)) + .motorSpeed(messages.substring(105, 110)) + .motorTorque(messages.substring(110, 114)) + .motorTemperature(messages.substring(114, 120)) + .motorVoltage(messages.substring(120, 125)) + .motorCurrent(messages.substring(125, 133)) + .remainingBattery(new BigDecimal(messages.substring(133, 139))) + .maximumFeedbackPower(messages.substring(139, 145)) + .maximumDischargePower(messages.substring(145, 151)) + .selfCheckCounter(messages.substring(151, 153)) + .totalBatteryCurrent(messages.substring(153, 158)) + .totalBatteryVoltage(messages.substring(158, 164)) + .singleBatteryMaxVoltage(messages.substring(164, 168)) + .singleBatteryMinVoltage(messages.substring(168, 172)) + .singleBatteryMaxTemperature(messages.substring(172, 178)) + .singleBatteryMinTemperature(messages.substring(178, 184)) + .availableBatteryCapacity(messages.substring(184, 190)) + .vehicleStatus(Integer.valueOf(messages.substring(190, 191))) + .chargingStatus(Integer.valueOf(messages.substring(191, 192))) + .operatingStatus(Integer.valueOf(messages.substring(192, 193))) + .socStatus(Integer.valueOf(messages.substring(193, 194))) + .chargingEnergyStorageStatus(Integer.valueOf(messages.substring(194, 195))) + .driveMotorStatus(Integer.valueOf(messages.substring(195, 196))) + .positionStatus(Integer.valueOf(messages.substring(196, 197))) + .easStatus(Integer.valueOf(messages.substring(197, 198))) + .ptcStatus(Integer.valueOf(messages.substring(198, 199))) + .epsStatus(Integer.valueOf(messages.substring(199, 200))) + .absStatus(Integer.valueOf(messages.substring(200, 201))) + .mcuStatus(Integer.valueOf(messages.substring(201, 202))) + .heatingStatus(Integer.valueOf(messages.substring(202, 203))) + .batteryStatus(Integer.valueOf(messages.substring(203, 204))) + .batteryInsulationStatus(Integer.valueOf(messages.substring(204, 205))) + .build(); + + } +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/constant/KafkaConstant.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/constant/KafkaConstant.java new file mode 100644 index 0000000..9a1ad47 --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/domain/constant/KafkaConstant.java @@ -0,0 +1,16 @@ +package com.fivegroup.analysis.domain.constant; + +/** + * kafka + * + * @author ZhangXushuo + * @version 2023/11/30 - 19:26 + */ +public class KafkaConstant { + public static final String KAFKA_BOOTSTRAP_SERVERS = "101.34.69.116:9092"; + + /** + * kafka主题 + */ + public static final String KAFKA_TOPIC = "fiveGroup"; +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/mapper/VehicleHistoryIncidentMapper.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/mapper/VehicleHistoryIncidentMapper.java new file mode 100644 index 0000000..e66f5e6 --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/mapper/VehicleHistoryIncidentMapper.java @@ -0,0 +1,15 @@ +package com.fivegroup.analysis.mapper; + +import com.fivegroup.analysis.domain.VehicleData; +import org.apache.ibatis.annotations.Mapper; + +/** + * 车辆信息 + * + * @author ZhangXushuo + * @version 2023/11/30 - 22:36 + */ +@Mapper +public interface VehicleHistoryIncidentMapper { + void vehicleInsert(VehicleData vehicleDate); +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/KafkaConsumerConfig.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/KafkaConsumerConfig.java new file mode 100644 index 0000000..4800cc7 --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/KafkaConsumerConfig.java @@ -0,0 +1,36 @@ +package com.fivegroup.analysis.service; + +import com.fivegroup.analysis.domain.constant.KafkaConstant; +import org.apache.kafka.clients.consumer.Consumer; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import lombok.extern.log4j.Log4j2; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Service; + +import java.util.Properties; + +/** + * 消费者 + * + * @author ZhangXushuo + * @version 2023/12/1 - 11:13 + */ +@Service +@Log4j2 +public class KafkaConsumerConfig { + @Bean + public Consumer consumerInit(){ + log.info("kafka消费者初始化开始"); + long startTime = System.currentTimeMillis(); + Properties props = new Properties(); + props.put("bootstrap.servers", KafkaConstant.KAFKA_BOOTSTRAP_SERVERS); + props.put("group.id", "group01"); + props.put("enable.auto.commit", "true"); + props.put("auto.commit.interval.ms", "1000"); + props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + log.info("kafka消费者初始化结束, 耗时:[{}MS]", System.currentTimeMillis() - startTime); + return new KafkaConsumer<>(props); + } + +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/KafkaConsumerService.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/KafkaConsumerService.java new file mode 100644 index 0000000..68c76c0 --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/KafkaConsumerService.java @@ -0,0 +1,119 @@ +package com.fivegroup.analysis.service; + +import com.alibaba.fastjson.JSONObject; +import com.fivegroup.analysis.domain.Topic; +import com.fivegroup.analysis.domain.VehicleData; +import com.fivegroup.common.core.utils.SpringUtils; +import com.fivegroup.common.redis.service.RedisService; +import com.rabbitmq.client.Channel; +import lombok.extern.log4j.Log4j2; +import org.apache.kafka.clients.consumer.Consumer; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.common.TopicPartition; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.time.Duration; +import java.util.*; +/** + * 消费者 + * + * @author ZhangXushuo + * @version 2023/12/1 - 11:24 + */ +@Service +@Log4j2 +public class KafkaConsumerService { + @Autowired + private Consumer consumer; + @Autowired + private RedisService redisService; + public static final String KAFKA_NAME = "test"; + + public static final String REDIS_NAME = "mq_message"; + @RabbitListener(queuesToDeclare = {@Queue(name = "test")}) + public void add(String parameter, Message message, Channel channel) { + log.info("开始消费了消费"); + String messageId = message.getMessageProperties().getMessageId(); + try { + log.info("UUID为:{}", messageId); + Long add = redisService.redisTemplate.opsForSet().add(REDIS_NAME, messageId); + log.info("add为:" + add); + if (1 == add && null != add) { + log.info("已开始消费"); + Topic topic = JSONObject.parseObject(parameter, Topic.class); + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + TopicPartition topicPartition = new TopicPartition(topic.getTopic(), topic.getSubzone()); + // 订阅特定分区 + consumer.assign(Collections.singleton(topicPartition)); + new Thread(() -> { + while (true) { + ConsumerRecords records = null; + try { + records = consumer.poll(Duration.ofMillis(1000)); + for (ConsumerRecord record : records) { + String value = record.value(); + String messages = KafkaConsumerService.sixteenToStr(value); + VehicleData build = VehicleData.getBuild(messages); + if (redisService.hasKey(build.getVin())) { + System.out.println(build.getVin()); + List range = redisService.redisTemplate.opsForList().range(build.getVin(), 0, -1); + if (range.size() > 0) { + range.forEach(l -> { + System.out.println(l); + VehicleIncidentService vehicleIncidentService = SpringUtils.getBean(l); + vehicleIncidentService.execute(build); + }); + } + } + } + } catch (Exception e) { + log.info("records: {}", records); + log.error(e); + } + } + + }).start(); + } + } catch (Exception e) { + try { + //删除redis添加的数据 + redisService.redisTemplate.opsForSet().remove(REDIS_NAME, messageId); + //退回 + channel.basicReject(message.getMessageProperties().getDeliveryTag(), true); + log.info("异常数据已回退"); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + } + public static String sixToStrteen(String s) { + StringBuilder builder1 = new StringBuilder(); + int length = s.length(); + for (int i = 0; i < length; i++) { + int c = s.charAt(i); + String s1 = Integer.toHexString(c); + builder1.append(s1 + " "); + } + return builder1.toString(); + } + + public static String sixteenToStr(String s) { + StringBuilder builder1 = new StringBuilder(); + String[] arr = s.split(" "); + int length = arr.length; + for (int i = 0; i < length; i++) { + int integer = Integer.parseInt(arr[i], 16); + builder1.append((char) integer); + } + return builder1.toString(); + } + + + +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/VehicleIncidentService.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/VehicleIncidentService.java new file mode 100644 index 0000000..4d04891 --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/VehicleIncidentService.java @@ -0,0 +1,14 @@ +package com.fivegroup.analysis.service; + + +import com.fivegroup.analysis.domain.VehicleData; + +/** + * 车辆事件 + * + * @author ZhangXushuo + * @version 2023/11/30 - 20:58 + */ +public interface VehicleIncidentService { + void execute(VehicleData vehicleDate); +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleBreakdownIncidentServiceImpl.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleBreakdownIncidentServiceImpl.java new file mode 100644 index 0000000..daf6614 --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleBreakdownIncidentServiceImpl.java @@ -0,0 +1,30 @@ +package com.fivegroup.analysis.service.impl; + +import com.fivegroup.common.redis.service.RedisService; +import com.fivegroup.analysis.domain.VehicleData; +import com.fivegroup.analysis.service.VehicleIncidentService; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; + +/** + * 车辆故障事件检测 + * + * @author ZhangXushuo + * @version 2023/11/30 - 22:04 + */ +@Log4j2 +@Service("breakdown") +@AllArgsConstructor +public class VehicleBreakdownIncidentServiceImpl implements VehicleIncidentService { + private final RedisService redisService; + + /** + * 车辆故障信息 + * @param vehicleDate + */ + @Override + public void execute(VehicleData vehicleDate) { + log.info("vehicleDate: [{}]车辆故障触发事件" , vehicleDate.getVin()); + } +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleFenceIncidentServiceImpl.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleFenceIncidentServiceImpl.java new file mode 100644 index 0000000..6f9afad --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleFenceIncidentServiceImpl.java @@ -0,0 +1,31 @@ +package com.fivegroup.analysis.service.impl; + +import com.fivegroup.analysis.domain.VehicleData; +import com.fivegroup.analysis.service.VehicleIncidentService; +import com.fivegroup.common.redis.service.RedisService; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; + +/** + * 车辆的电子围栏 + * + * @author ZhangXushuo + * @version 2023/11/30 - 22:25 + */ +@Log4j2 +@Service("fence") +@AllArgsConstructor +public class VehicleFenceIncidentServiceImpl implements VehicleIncidentService { + private final RedisService redisService; + + /** + * 车辆电子围栏事件 + * @param vehicleDate + */ + + @Override + public void execute(VehicleData vehicleDate) { + log.info("车辆电子围栏事件",vehicleDate.getVin()); + } +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleHistoryIncidentServiceImpl.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleHistoryIncidentServiceImpl.java new file mode 100644 index 0000000..facc77b --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleHistoryIncidentServiceImpl.java @@ -0,0 +1,29 @@ +package com.fivegroup.analysis.service.impl; +import com.fivegroup.analysis.domain.VehicleData; +import com.fivegroup.common.redis.service.RedisService; +import com.fivegroup.analysis.service.VehicleIncidentService; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; + +/** + * 车辆的历史轨迹 + * + * @author ZhangXushuo + * @version 2023/11/30 - 22:28 + */ +@AllArgsConstructor +@Log4j2 +@Service("history") +public class VehicleHistoryIncidentServiceImpl implements VehicleIncidentService { + private final RedisService redisService; + + /** + * 车辆的历史轨迹 + * @param vehicleDate + */ + @Override + public void execute(VehicleData vehicleDate) { + log.info("车辆的历史轨迹+[{}]",vehicleDate.getVin()); + } +} diff --git a/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleRealIncidentServiceImpl.java b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleRealIncidentServiceImpl.java new file mode 100644 index 0000000..601b8ca --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/java/com/fivegroup/analysis/service/impl/VehicleRealIncidentServiceImpl.java @@ -0,0 +1,32 @@ +package com.fivegroup.analysis.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.fivegroup.common.redis.service.RedisService; +import com.fivegroup.analysis.domain.VehicleData; +import com.fivegroup.analysis.service.VehicleIncidentService; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springframework.stereotype.Service; + +/** + * 车辆实时数据 + * + * @author ZhangXushuo + * @version 2023/11/30 - 22:32 + */ +@Service("incident") +@Log4j2 +@AllArgsConstructor +public class VehicleRealIncidentServiceImpl implements VehicleIncidentService { + private final RedisService redisService; + private static final String MD5_KEY = "MD5_KEY"; + + @Override + public void execute(VehicleData vehicleDate) { + Long along = redisService.redisTemplate.opsForList().leftPush(vehicleDate.getVin() + ""+ MD5_KEY, JSONObject.toJSONString(vehicleDate)); + if(along>0){ + log.info("车辆实时数据",vehicleDate.getVin()); + } + } +} + diff --git a/fivegroup-modules/fivegroup-analysis/src/main/resources/mapper/VehicleHistoryIncidentMapper.xml b/fivegroup-modules/fivegroup-analysis/src/main/resources/mapper/VehicleHistoryIncidentMapper.xml new file mode 100644 index 0000000..2c6993d --- /dev/null +++ b/fivegroup-modules/fivegroup-analysis/src/main/resources/mapper/VehicleHistoryIncidentMapper.xml @@ -0,0 +1,57 @@ + + + + + + diff --git a/fivegroup-modules/fivegroup-trajectory/src/main/resources/bootstrap.yml b/fivegroup-modules/fivegroup-trajectory/src/main/resources/bootstrap.yml index 6a6a74d..e52d7c2 100644 --- a/fivegroup-modules/fivegroup-trajectory/src/main/resources/bootstrap.yml +++ b/fivegroup-modules/fivegroup-trajectory/src/main/resources/bootstrap.yml @@ -1,6 +1,6 @@ # Tomcat server: - port: 9210 + port: 9211 # Spring spring: diff --git a/fivegroup-modules/fivegroup-wall/pom.xml b/fivegroup-modules/fivegroup-wall/pom.xml index 2f6f6e0..4b0b3be 100644 --- a/fivegroup-modules/fivegroup-wall/pom.xml +++ b/fivegroup-modules/fivegroup-wall/pom.xml @@ -88,9 +88,6 @@ - - - diff --git a/fivegroup-modules/pom.xml b/fivegroup-modules/pom.xml index 616a8cf..c8d70d8 100644 --- a/fivegroup-modules/pom.xml +++ b/fivegroup-modules/pom.xml @@ -18,6 +18,7 @@ fivegroup-fault fivegroup-wall fivegroup-trajectory + fivegroup-analysis fivegroup-modules