From 0bbf40741cdff18ecbcc61b66ee517002bb4959e Mon Sep 17 00:00:00 2001
From: dongxiaodong <13970843+dxdwork@user.noreply.gitee.com>
Date: Tue, 2 Apr 2024 16:56:39 +0800
Subject: [PATCH] =?UTF-8?q?dxd=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../couplet-analyze-msg/pom.xml | 83 ++++
.../msg/CoupletMsgApplication.java | 2 +-
.../analyze/msg/contents/MsgContent.java | 13 +
.../analyze/msg/domain/CoupletMsgData.java | 263 ++++++++++++
.../analyze/msg/model/ModelMessage.java | 26 ++
.../msg/service/CoupletMsgService.java | 10 +
.../java/com/couplet/msg/domain/MsgData.java | 382 ------------------
7 files changed, 396 insertions(+), 383 deletions(-)
rename couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/{ => analyze}/msg/CoupletMsgApplication.java (93%)
create mode 100644 couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/contents/MsgContent.java
create mode 100644 couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/domain/CoupletMsgData.java
create mode 100644 couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java
create mode 100644 couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/CoupletMsgService.java
delete mode 100644 couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/domain/MsgData.java
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml b/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml
index 2c78901..9b3c2e4 100644
--- a/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml
+++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml
@@ -17,4 +17,87 @@
UTF-8
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ ${swagger.fox.version}
+
+
+
+
+ com.mysql
+ mysql-connector-j
+
+
+
+
+ com.couplet
+ couplet-common-datasource
+
+
+
+
+ com.couplet
+ couplet-common-datascope
+
+
+
+
+ com.couplet
+ couplet-common-log
+
+
+
+
+ com.couplet
+ couplet-common-swagger
+
+
+
+
+ org.eclipse.paho
+ org.eclipse.paho.client.mqttv3
+ 1.2.5
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-amqp
+
+
+
+
+ org.springframework.kafka
+ spring-kafka
+
+
+
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/CoupletMsgApplication.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java
similarity index 93%
rename from couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/CoupletMsgApplication.java
rename to couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java
index 9814995..e6a7d38 100644
--- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/CoupletMsgApplication.java
+++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java
@@ -1,4 +1,4 @@
-package com.couplet.msg;
+package com.couplet.analyze.msg;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/contents/MsgContent.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/contents/MsgContent.java
new file mode 100644
index 0000000..5d96e67
--- /dev/null
+++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/contents/MsgContent.java
@@ -0,0 +1,13 @@
+package com.couplet.analyze.msg.contents;
+
+/**
+ * @author DongZl
+ * @description: kafka常量类
+ * @Date 2023/8/25 18:47
+ */
+public class MsgContent {
+
+ public static final String BROKER_URL = "tcp://111.229.33.194:1883";
+
+ public static final String CLIENT_ID = "mqttx_32dcaf76";
+}
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/domain/CoupletMsgData.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/domain/CoupletMsgData.java
new file mode 100644
index 0000000..9283c60
--- /dev/null
+++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/domain/CoupletMsgData.java
@@ -0,0 +1,263 @@
+package com.couplet.analyze.msg.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author DongXiaoDong
+ * @version 1.0
+ * @date 2024/4/2 15:26
+ * @description
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class CoupletMsgData {
+ /**
+ * 主键id
+ */
+ private Long id;
+
+ /**
+ * VIN 车辆编码
+ */
+ private String vin;
+
+ /**
+ * 报文创建时间
+ */
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+ /**
+ * 经度
+ */
+ private String longitude;
+
+ /**
+ * 维度
+ */
+ private String latitude;
+
+ /**
+ * 速度
+ */
+ private String speed;
+
+ /**
+ * 里程
+ */
+ private BigDecimal mileage;
+
+ /**
+ * 总电压
+ */
+ private String voltage;
+
+ /**
+ * 总电流
+ */
+ private String current;
+
+ /**
+ * 绝缘电阻
+ */
+ private String resistance;
+
+ /**
+ * 档位 P:停车 D:运行
+ */
+ 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;
+
+ /**
+ * 车辆状态 1:正常 0:故障
+ */
+ private int vehicleStatus;
+
+ /**
+ * 充电状态 1:正常 0:故障
+ */
+ private int chargingStatus;
+
+ /**
+ * 运行状态 1:正常 0:故障
+ */
+ private int operatingStatus;
+
+ /**
+ * SOC 状态 1:正常 0:故障
+ */
+ private int socStatus;
+
+ /**
+ * 可充电储能装置工作状态 1:正常 0:故障
+ */
+ private int chargingEnergyStorageStatus;
+
+ /**
+ * 驱动电机状态 1:正常 0:故障
+ */
+ private int driveMotorStatus;
+
+ /**
+ * 定位是否有效 1:有效 0:无效
+ */
+ private int positionStatus;
+
+ /**
+ * EAS(汽车防盗系统)状态 1:正常 0:故障
+ */
+ private int easStatus;
+
+ /**
+ * PTC(电动加热器)状态 1:正常 0:故障
+ */
+ private int ptcStatus;
+
+ /**
+ * EPS(电动助力系统)状态 1:正常 0:故障
+ */
+ private int epsStatus;
+
+ /**
+ * ABS(防抱死)状态 1:正常 0:故障
+ */
+ private int absStatus;
+
+ /**
+ * MCU(电机/逆变器)状态 1:正常 0:故障
+ */
+ private int mcuStatus;
+
+ /**
+ * 动力电池加热状态 1:正常 0:故障
+ */
+ private int heatingStatus;
+
+ /**
+ * 动力电池当前状态 1:正常 0:故障
+ */
+ private int batteryStatus;
+
+ /**
+ * 动力电池保温状态 1:正常 0:故障
+ */
+ private int batteryInsulationStatus;
+
+ /**
+ * DCDC(电力交换系统) 状态 1:正常 0:故障
+ */
+ private int dcdcStatus;
+
+ /**
+ * CHG(充电机)状态 1:正常 0:故障
+ */
+ private int chgStatus;
+}
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java
new file mode 100644
index 0000000..2011b6a
--- /dev/null
+++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java
@@ -0,0 +1,26 @@
+package com.couplet.analyze.msg.model;
+
+import com.couplet.analyze.msg.service.CoupletMsgService;
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author DongXiaoDong
+ * @version 1.0
+ * @date 2024/4/2 15:41
+ * @description
+ */
+@Slf4j
+@Component
+public class ModelMessage {
+
+ @Scheduled(cron = "0/5 * * * * ?")
+ public void startMsg() {
+// try {
+// new MqttClient()
+// }
+ }
+}
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/CoupletMsgService.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/CoupletMsgService.java
new file mode 100644
index 0000000..011572e
--- /dev/null
+++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/CoupletMsgService.java
@@ -0,0 +1,10 @@
+package com.couplet.analyze.msg.service;
+
+/**
+ * @author DongXiaoDong
+ * @version 1.0
+ * @date 2024/4/2 16:44
+ * @description
+ */
+public interface CoupletMsgService {
+}
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/domain/MsgData.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/domain/MsgData.java
deleted file mode 100644
index 750b5f0..0000000
--- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/msg/domain/MsgData.java
+++ /dev/null
@@ -1,382 +0,0 @@
-package com.couplet.msg.domain;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.math.BigDecimal;
-
-/**
- * @author DongXiaoDong
- * @version 1.0
- * @date 2024/3/31 16:01
- * @description
- */
-@Data
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class MsgData {
- /**
- * VIN
- */
- private String vin;
- /**
- * 行驶路线
- */
- private String drivingRoute;
-
- /**
- * 经度
- */
- private String longitude;
-
- /**
- * 维度
- */
- private String latitude;
-
- /**
- * 速度
- */
- private String speed;
-
- /**
- * 里程
- */
- private BigDecimal mileage;
-
- /**
- * 总电压
- */
- private String voltage;
-
- /**
- * 总电流
- */
- private String current;
-
- /**
- * 绝缘电阻
- */
- private String resistance;
-
- /**
- * 档位
- */
- private String gear = "P";
-
- /**
- * 加速踏板行程值
- */
- 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 BigDecimal batteryLevel;
-
- /**
- * 当前状态允许的最大反馈功率
- */
- 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 = 1;
-
- /**
- * 充电状态
- */
- private int chargingStatus = 1;
-
- /**
- * 运行状态
- */
- private int operatingStatus = 1;
-
- /**
- * SOC
- */
- private int socStatus = 1;
-
- /**
- * 可充电储能装置工作状态
- */
- private int chargingEnergyStorageStatus = 1;
-
- /**
- * 驱动电机状态
- */
- private int driveMotorStatus = 1;
-
- /**
- * 定位是否有效
- */
- private int positionStatus = 1;
-
- /**
- * EAS(汽车防盗系统)状态
- */
- private int easStatus = 1;
-
- /**
- * PTC(电动加热器)状态
- */
- private int ptcStatus = 1;
-
- /**
- * EPS(电动助力系统)状态
- */
- private int epsStatus = 1;
-
- /**
- * ABS(防抱死)状态
- */
- private int absStatus = 1;
-
- /**
- * MCU(电机/逆变器)状态
- */
- private int mcuStatus = 1;
-
- /**
- * 动力电池加热状态
- */
- private int heatingStatus = 1;
-
- /**
- * 动力电池当前状态
- */
- private int batteryStatus = 1;
-
- /**
- * 动力电池保温状态
- */
- private int batteryInsulationStatus = 1;
-
- /**
- * DCDC(电力交换系统)状态
- */
- private int dcdcStatus = 1;
-
- /**
- * CHG(充电机)状态
- */
- private int chgStatus = 1;
-
- /**
- * 车辆状态 报文
- */
- private String vehicleStatusMsg;
- /**
- * 智能硬件 报文
- */
- private String smartHardwareMsg;
- /**
- * 电池报文
- */
- private String batteryMsg;
-
- public String getMsg(){
- //第一位VIN
- return vin +
- // 当前时间戳
- System.currentTimeMillis() +
- //第二位经度 longitude latitude
- getValue(longitude, 11) +
- //第三位维度 longitude latitude
- getValue(latitude, 10) +
- //车速
- getValue(speed, 6) +
- //总里程
- getValue(mileage == null ? "" : mileage.toString(), 11) +
- // 总电压
- getValue(voltage, 6) +
- //总电流
- getValue(current, 5) +
- //绝缘电阻 79 - 87
- getValue(resistance, 9) +
- //档位
- (gear == null ? "D" : gear) +
- // 加速踏板行程值
- getValue(accelerationPedal, 2) +
- // 制动踏板行程值
- getValue(brakePedal, 2) +
- // 燃料消耗率
- getValue(fuelConsumptionRate, 5) +
- //电机控制器温度
- getValue(motorControllerTemperature, 6) +
- //电机转速
- getValue(motorSpeed, 5) +
- //点击转矩
- getValue(motorTorque, 4) +
- //电机温度
- getValue(motorTemperature, 6) +
- //电机电压
- getValue(motorVoltage, 5) +
- //电机电流
- getValue(motorCurrent, 8) +
- //动力电池剩余电量SOC
- getValue(remainingBattery == null ? "" : remainingBattery.toString(), 6) +
- //当前状态允许的最大反馈功率
- getValue(maximumFeedbackPower, 6) +
- //当前状态允许最大放电功率
- getValue(maximumDischargePower, 6) +
- //BMS自检计数器
- getValue(selfCheckCounter, 2) +
- //动力电池充放电电流
- getValue(totalBatteryCurrent, 5) +
- //动力电池负载端总电压V3
- getValue(totalBatteryVoltage, 6) +
- //单次最大电压
- getValue(singleBatteryMaxVoltage, 4) +
- //单体电池最低电压
- getValue(singleBatteryMinVoltage, 4) +
- //单体电池最高温度
- getValue(singleBatteryMaxTemperature, 6) +
- //单体电池最低温度
- getValue(singleBatteryMinTemperature, 6) +
- //动力电池可用容量
- getValue(availableBatteryCapacity, 6) +
- //车辆状态
- vehicleStatus +
- //充电状态
- chargingStatus +
- //运行状态
- operatingStatus +
- //SOC
- socStatus +
- //可充电储能装置工作状态
- chargingEnergyStorageStatus +
- //驱动电机状态
- driveMotorStatus +
- //定位是否有效
- positionStatus +
- //EAS
- easStatus +
- //PTC
- ptcStatus +
- //EPS
- epsStatus +
- //ABS
- absStatus +
- //MCU
- mcuStatus +
- //动力电池加热状态
- heatingStatus +
- //动力电池当前状态
- batteryStatus +
- //动力电池保温状态
- batteryInsulationStatus +
- //DCDC
- dcdcStatus +
- //CHG
- chgStatus;
- }
-
- public String getValue(String val , int valLength){
- if(val == null){
- val = "";
- }
- int length = val.length();
- if (length > valLength){
- return val.substring( 0 , valLength);
- }
- val = val + "0".repeat(valLength - length);
- return val;
- }
-
-}