dxd解析报文
parent
72b634fcc1
commit
b644752443
|
@ -86,18 +86,6 @@
|
||||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
<version>1.2.5</version>
|
<version>1.2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- RabbitMQ依赖-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Kafka依赖-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.kafka</groupId>
|
|
||||||
<artifactId>spring-kafka</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.couplet.analyze.msg;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongXiaoDong
|
* @author DongXiaoDong
|
||||||
|
@ -11,6 +12,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
* @description
|
* @description
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableScheduling
|
||||||
@EnableFeignClients(basePackages = "com.couplet.**")
|
@EnableFeignClients(basePackages = "com.couplet.**")
|
||||||
public class CoupletMsgApplication {
|
public class CoupletMsgApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.couplet.analyze.msg.contents;
|
package com.couplet.analyze.msg.contents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongZl
|
* @author DongXiaoDong
|
||||||
* @description: kafka常量类
|
* @description: Mqtt常量类
|
||||||
* @Date 2023/8/25 18:47
|
* @Date 2024/4/1 18:47
|
||||||
*/
|
*/
|
||||||
public class MsgContent {
|
public class MsgContent {
|
||||||
|
|
||||||
public static final String BROKER_URL = "tcp://111.229.33.194:1883";
|
public static final String BROKER_URL = "tcp://8.130.181.16:1883";
|
||||||
|
|
||||||
public static final String CLIENT_ID = "mqttx_32dcaf76";
|
public static final String CLIENT_ID = "mqttx_32dcaf76";
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Date;
|
||||||
* @author DongXiaoDong
|
* @author DongXiaoDong
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2024/4/2 15:26
|
* @date 2024/4/2 15:26
|
||||||
* @description
|
* @description 报文信息实体类
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.couplet.analyze.msg.mapper;
|
||||||
|
|
||||||
|
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/4/2 19:58
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CoupletMapper {
|
||||||
|
void insertMsgData(CoupletMsgData msgData);
|
||||||
|
}
|
|
@ -1,27 +1,44 @@
|
||||||
package com.couplet.analyze.msg.model;
|
package com.couplet.analyze.msg.model;
|
||||||
|
|
||||||
|
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||||
import com.couplet.analyze.msg.service.CoupletMsgService;
|
import com.couplet.analyze.msg.service.CoupletMsgService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static com.couplet.analyze.msg.contents.MsgContent.BROKER_URL;
|
import static com.couplet.analyze.msg.contents.MsgContent.BROKER_URL;
|
||||||
import static com.couplet.analyze.msg.contents.MsgContent.CLIENT_ID;
|
import static com.couplet.analyze.msg.contents.MsgContent.CLIENT_ID;
|
||||||
|
import static io.lettuce.core.pubsub.PubSubOutput.Type.message;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongXiaoDong
|
* @author DongXiaoDong
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2024/4/2 15:41
|
* @date 2024/4/2 15:41
|
||||||
* @description
|
* @description 解析报文数据
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class ModelMessage {
|
public class ModelMessage {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CoupletMsgService coupletMsgService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ModelMessage(CoupletMsgService coupletMsgService){
|
||||||
|
this.coupletMsgService = coupletMsgService;
|
||||||
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0/5 * * * * ?")
|
@Scheduled(cron = "0/5 * * * * ?")
|
||||||
public void startMsg() {
|
public void startMsg() {
|
||||||
try {
|
try {
|
||||||
|
@ -30,8 +47,329 @@ public class ModelMessage {
|
||||||
MqttConnectOptions options = new MqttConnectOptions();
|
MqttConnectOptions options = new MqttConnectOptions();
|
||||||
|
|
||||||
options.setCleanSession(true);
|
options.setCleanSession(true);
|
||||||
|
mqttClient.connect(options);
|
||||||
|
|
||||||
|
mqttClient.setCallback(new MqttCallback() {
|
||||||
|
@Override
|
||||||
|
public void connectionLost(Throwable throwable) {
|
||||||
|
log.error("Mqtt[{}-{}]连接断开:[{}]", CLIENT_ID, BROKER_URL, throwable.getMessage(), throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
|
||||||
|
//打印接收到的消息和主题
|
||||||
|
log.info("主题='{}':消息内容={}", topic, new String(mqttMessage.getPayload()));
|
||||||
|
String str = hexToString(new String(mqttMessage.getPayload()));
|
||||||
|
List<CoupletMsgData> coupletMsgDataList = sendMsg(str);
|
||||||
|
|
||||||
|
for (CoupletMsgData msgData : coupletMsgDataList) {
|
||||||
|
log.info("解析到车辆数据:{}", msgData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken token) {
|
||||||
|
log.info("消息已投递成功:{}",token);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mqttClient.subscribe("test",0);
|
||||||
|
|
||||||
|
Thread.sleep(1000*60*10);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将16进制字符串转换为ASCII字符串
|
||||||
|
* @param s 16进制字符串
|
||||||
|
* @return ASCII字符串
|
||||||
|
*/
|
||||||
|
public static String hexToString(String s) {
|
||||||
|
if (s == null || s.equals("")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
s = s.replace(" ", "");
|
||||||
|
byte[] baKeyword = new byte[s.length() / 2];
|
||||||
|
for (int i = 0; i < baKeyword.length; i++) {
|
||||||
|
try {
|
||||||
|
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
s = new String(baKeyword, StandardCharsets.UTF_8);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<CoupletMsgData> sendMsg(String str) {
|
||||||
|
List<CoupletMsgData> coupletMsgDataList = new ArrayList<>();
|
||||||
|
CoupletMsgData coupletMsgData = new CoupletMsgData();
|
||||||
|
|
||||||
|
coupletMsgData.setVin(str.substring(1,18));
|
||||||
|
|
||||||
|
log.info("vin=="+coupletMsgData.getVin());
|
||||||
|
|
||||||
|
//时间
|
||||||
|
String tim =str.substring(18,31);
|
||||||
|
long timestamp = Long.parseLong(tim);
|
||||||
|
|
||||||
|
Date date = new Date(timestamp);
|
||||||
|
coupletMsgData.setCreateTime(date);
|
||||||
|
|
||||||
|
//经度
|
||||||
|
String lt = str.substring(31,42);
|
||||||
|
// 如果末尾是零,则舍去
|
||||||
|
int endIndex = lt.length() - 1;
|
||||||
|
while (lt.charAt(endIndex) == '0'){
|
||||||
|
endIndex--;
|
||||||
|
}
|
||||||
|
|
||||||
|
String longitude = lt.substring(0, endIndex + 1);
|
||||||
|
coupletMsgData.setLongitude(longitude);
|
||||||
|
|
||||||
|
//维度
|
||||||
|
String latitudeIndex =str.substring(42,52);
|
||||||
|
int endIndexT = latitudeIndex.length() - 1;
|
||||||
|
while (latitudeIndex.charAt(endIndexT) == '0'){
|
||||||
|
endIndexT--;
|
||||||
|
}
|
||||||
|
|
||||||
|
String latitude = latitudeIndex.substring(0, endIndexT + 1);
|
||||||
|
coupletMsgData.setLatitude(latitude);
|
||||||
|
|
||||||
|
//速度speed
|
||||||
|
String speed =str.substring(52,58);
|
||||||
|
coupletMsgData.setSpeed(speed);
|
||||||
|
|
||||||
|
//里程
|
||||||
|
BigDecimal mileage= new BigDecimal(str.substring(58,69));
|
||||||
|
mileage=mileage.stripTrailingZeros();
|
||||||
|
coupletMsgData.setMileage(mileage);
|
||||||
|
|
||||||
|
//总电压
|
||||||
|
String voltage =str.substring(69,75);
|
||||||
|
while (voltage.endsWith("0")) {
|
||||||
|
voltage = voltage.substring(0, voltage.length() - 1); // 去除末尾的零
|
||||||
|
}
|
||||||
|
coupletMsgData.setVoltage(voltage);
|
||||||
|
|
||||||
|
//总电流
|
||||||
|
String current =str.substring(75,80);
|
||||||
|
while (current.endsWith("0")){
|
||||||
|
current=current.substring(0,current.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setCurrent(current);
|
||||||
|
|
||||||
|
//绝缘电阻 resistance
|
||||||
|
String res =str.substring(80,89);
|
||||||
|
String resistance = res.substring(0, 5);
|
||||||
|
coupletMsgData.setResistance(resistance);
|
||||||
|
|
||||||
|
//档位
|
||||||
|
String gear =str.substring(89,90);
|
||||||
|
coupletMsgData.setGear(gear);
|
||||||
|
|
||||||
|
//accelerationPedal 加速踏板行程值
|
||||||
|
String accelerationPedal =str.substring(90,91);
|
||||||
|
coupletMsgData.setAccelerationPedal(accelerationPedal);
|
||||||
|
|
||||||
|
//brakePedal 制动踏板行程值
|
||||||
|
String brakePedal =str.substring(92,93);
|
||||||
|
coupletMsgData.setBrakePedal(brakePedal);
|
||||||
|
|
||||||
|
//fuelConsumptionRate 燃料消耗率
|
||||||
|
String fuelConsumptionRate =str.substring(94,99);
|
||||||
|
coupletMsgData.setFuelConsumptionRate(fuelConsumptionRate);
|
||||||
|
|
||||||
|
//motorControllerTemperature 电机控制器温度
|
||||||
|
String motorControllerTemperature =str.substring(99,105);
|
||||||
|
while (motorControllerTemperature.endsWith("0")){
|
||||||
|
motorControllerTemperature=motorControllerTemperature.substring(0,motorControllerTemperature.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setMotorControllerTemperature(motorControllerTemperature);
|
||||||
|
|
||||||
|
//motorSpeed 电机转速
|
||||||
|
String motorSpeed =str.substring(105,110);
|
||||||
|
coupletMsgData.setMotorSpeed(motorSpeed);
|
||||||
|
|
||||||
|
//motorTorque 电机转矩
|
||||||
|
String motorTorque =str.substring(110,114);
|
||||||
|
while (motorTorque.endsWith("0")){
|
||||||
|
motorTorque=motorTorque.substring(0,motorTorque.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setMotorTorque(motorTorque);
|
||||||
|
|
||||||
|
//motorTemperature 电机温度
|
||||||
|
String motorTemperature =str.substring(114,120);
|
||||||
|
while (motorTemperature.endsWith("0")){
|
||||||
|
motorTemperature=motorTemperature.substring(0,motorTemperature.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setMotorTemperature(motorTemperature);
|
||||||
|
|
||||||
|
//motorVoltage 电机电压
|
||||||
|
String motorVoltage =str.substring(120,125);
|
||||||
|
while (motorVoltage.endsWith("0")){
|
||||||
|
motorVoltage=motorVoltage.substring(0,motorVoltage.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setMotorVoltage(motorVoltage);
|
||||||
|
|
||||||
|
//motorCurrent 电机电流
|
||||||
|
String motorCurrent =str.substring(125,133);
|
||||||
|
while (motorCurrent.endsWith("0")){
|
||||||
|
motorCurrent=motorCurrent.substring(0,motorCurrent.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setMotorCurrent(motorCurrent);
|
||||||
|
|
||||||
|
//remainingBattery 动力电池剩余电量SOC
|
||||||
|
BigDecimal remainingBattery = new BigDecimal(str.substring(133,138));
|
||||||
|
coupletMsgData.setRemainingBattery(remainingBattery);
|
||||||
|
|
||||||
|
//maximumFeedbackPower 当前状态允许的最大反馈功率
|
||||||
|
String maximumFeedbackPower =str.substring(139,144);
|
||||||
|
while (maximumFeedbackPower.endsWith("0")){
|
||||||
|
maximumFeedbackPower=maximumFeedbackPower.substring(0,maximumFeedbackPower.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setMaximumFeedbackPower(maximumFeedbackPower);
|
||||||
|
|
||||||
|
//maximumDischargePower 当前状态允许最大放电功率
|
||||||
|
String maximumDischargePower =str.substring(145,151);
|
||||||
|
while (maximumDischargePower.endsWith("0")){
|
||||||
|
maximumDischargePower=maximumDischargePower.substring(0,maximumDischargePower.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setMaximumDischargePower(maximumDischargePower);
|
||||||
|
|
||||||
|
//selfCheckCounter BMS自检计数器
|
||||||
|
String selfCheckCounter =str.substring(151,153);
|
||||||
|
String selfCheckCounterReplace = selfCheckCounter.replace("0", "");
|
||||||
|
coupletMsgData.setSelfCheckCounter(selfCheckCounterReplace);
|
||||||
|
|
||||||
|
//totalBatteryCurrent 动力电池充放电电流
|
||||||
|
String totalBatteryCurrent =str.substring(153,158);
|
||||||
|
while (totalBatteryCurrent.endsWith("0")){
|
||||||
|
totalBatteryCurrent=totalBatteryCurrent.substring(0,totalBatteryCurrent.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setTotalBatteryCurrent(totalBatteryCurrent);
|
||||||
|
|
||||||
|
//totalBatteryVoltage 动力电池负载端总电压V3
|
||||||
|
String totalBatteryVoltage =str.substring(158,164);
|
||||||
|
while (totalBatteryVoltage.endsWith("0")){
|
||||||
|
totalBatteryVoltage=totalBatteryVoltage.substring(0,totalBatteryVoltage.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setTotalBatteryVoltage(totalBatteryVoltage);
|
||||||
|
|
||||||
|
//singleBatteryMaxVoltage 单次最大电压
|
||||||
|
String singleBatteryMaxVoltage =str.substring(164,168);
|
||||||
|
while (singleBatteryMaxVoltage.endsWith("0")){
|
||||||
|
singleBatteryMaxVoltage=singleBatteryMaxVoltage.substring(0,singleBatteryMaxVoltage.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setSingleBatteryMaxVoltage(singleBatteryMaxVoltage);
|
||||||
|
|
||||||
|
//singleBatteryMinVoltage 单体电池最低电压
|
||||||
|
String singleBatteryMinVoltage =str.substring(168,172);
|
||||||
|
while (singleBatteryMinVoltage.endsWith("0")){
|
||||||
|
singleBatteryMinVoltage=singleBatteryMinVoltage.substring(0,singleBatteryMinVoltage.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
coupletMsgData.setSingleBatteryMinVoltage(singleBatteryMinVoltage);
|
||||||
|
|
||||||
|
//singleBatteryMaxTemperature 单体电池最高温度
|
||||||
|
String singleBatteryMaxTemperature =str.substring(172,178);
|
||||||
|
while (singleBatteryMaxTemperature.endsWith("0")){
|
||||||
|
singleBatteryMaxTemperature=singleBatteryMaxTemperature.substring(0,singleBatteryMaxTemperature.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setSingleBatteryMaxTemperature(singleBatteryMaxTemperature);
|
||||||
|
|
||||||
|
//singleBatteryMinTemperature 单体电池最低温度
|
||||||
|
String singleBatteryMinTemperature =str.substring(178,184);
|
||||||
|
while (singleBatteryMinTemperature.endsWith("0")){
|
||||||
|
singleBatteryMinTemperature=singleBatteryMinTemperature.substring(0,singleBatteryMinTemperature.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setSingleBatteryMinTemperature(singleBatteryMinTemperature);
|
||||||
|
|
||||||
|
//availableBatteryCapacity 可用电池容量
|
||||||
|
String availableBatteryCapacity =str.substring(184,190);
|
||||||
|
while (availableBatteryCapacity.endsWith("0")){
|
||||||
|
availableBatteryCapacity=availableBatteryCapacity.substring(0,availableBatteryCapacity.length()-1);
|
||||||
|
}
|
||||||
|
coupletMsgData.setAvailableBatteryCapacity(availableBatteryCapacity);
|
||||||
|
|
||||||
|
//vehicleStatus 车辆状态
|
||||||
|
int vehicleStatus = Integer.parseInt(str.substring(190,191));
|
||||||
|
coupletMsgData.setVehicleStatus(vehicleStatus);
|
||||||
|
|
||||||
|
//chargingStatus 充电状态
|
||||||
|
int chargingStatus = Integer.parseInt(str.substring(191,192));
|
||||||
|
coupletMsgData.setChargingStatus(chargingStatus);
|
||||||
|
|
||||||
|
//operatingStatus 运行状态
|
||||||
|
int operatingStatus = Integer.parseInt(str.substring(192,193));
|
||||||
|
coupletMsgData.setOperatingStatus(operatingStatus);
|
||||||
|
|
||||||
|
//socStatus SOC
|
||||||
|
int socStatus = Integer.parseInt(str.substring(193,194));
|
||||||
|
coupletMsgData.setSocStatus(socStatus);
|
||||||
|
|
||||||
|
//chargingEnergyStorageStatus 可充电储能装置工作状态
|
||||||
|
int chargingEnergyStorageStatus = Integer.parseInt(str.substring(194,195));
|
||||||
|
coupletMsgData.setChargingEnergyStorageStatus(chargingEnergyStorageStatus);
|
||||||
|
|
||||||
|
//driveMotorStatus 驱动电机状态
|
||||||
|
int driveMotorStatus = Integer.parseInt(str.substring(195,196));
|
||||||
|
coupletMsgData.setDriveMotorStatus(driveMotorStatus);
|
||||||
|
|
||||||
|
//positionStatus 定位是否有效
|
||||||
|
int positionStatus = Integer.parseInt(str.substring(196,197));
|
||||||
|
coupletMsgData.setPositionStatus(positionStatus);
|
||||||
|
|
||||||
|
//easStatus EAS(汽车防盗系统)状态
|
||||||
|
int easStatus = Integer.parseInt(str.substring(197,198));
|
||||||
|
coupletMsgData.setEasStatus(easStatus);
|
||||||
|
|
||||||
|
//ptcStatus PTC(电动加热器)状态
|
||||||
|
int ptcStatus = Integer.parseInt(str.substring(198,199));
|
||||||
|
coupletMsgData.setPtcStatus(ptcStatus);
|
||||||
|
|
||||||
|
//epsStatus
|
||||||
|
int epsStatus = Integer.parseInt(str.substring(199,200));
|
||||||
|
coupletMsgData.setEpsStatus(epsStatus);
|
||||||
|
|
||||||
|
//absStatus EPS(电动助力系统)状态
|
||||||
|
int absStatus = Integer.parseInt(str.substring(200,201));
|
||||||
|
coupletMsgData.setAbsStatus(absStatus);
|
||||||
|
|
||||||
|
//mcuStatus MCU(电机/逆变器)状态
|
||||||
|
int mcuStatus = Integer.parseInt(str.substring(201,202));
|
||||||
|
coupletMsgData.setMcuStatus(mcuStatus);
|
||||||
|
|
||||||
|
//heatingStatus 动力电池加热状态
|
||||||
|
int heatingStatus = Integer.parseInt(str.substring(202,203));
|
||||||
|
coupletMsgData.setHeatingStatus(heatingStatus);
|
||||||
|
|
||||||
|
//batteryStatus 动力电池当前状态
|
||||||
|
int batteryStatus = Integer.parseInt(str.substring(203,204));
|
||||||
|
coupletMsgData.setBatteryStatus(batteryStatus);
|
||||||
|
|
||||||
|
//batteryInsulationStatus 动力电池保温状态
|
||||||
|
int batteryInsulationStatus = Integer.parseInt(str.substring(204,205));
|
||||||
|
coupletMsgData.setBatteryInsulationStatus(batteryInsulationStatus);
|
||||||
|
|
||||||
|
//dcdcStatus DCDC(电力交换系统)状态
|
||||||
|
int dcdcStatus = Integer.parseInt(str.substring(205,206));
|
||||||
|
coupletMsgData.setDcdcStatus(dcdcStatus);
|
||||||
|
|
||||||
|
//chgStatus CHG(充电机)状态
|
||||||
|
int chgStatus = Integer.parseInt(str.substring(206,207));
|
||||||
|
coupletMsgData.setChgStatus(chgStatus);
|
||||||
|
|
||||||
|
coupletMsgDataList.add(coupletMsgData);
|
||||||
|
|
||||||
|
return coupletMsgDataList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package com.couplet.analyze.msg.service;
|
package com.couplet.analyze.msg.service;
|
||||||
|
|
||||||
|
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongXiaoDong
|
* @author DongXiaoDong
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2024/4/2 16:44
|
* @date 2024/4/2 16:44
|
||||||
* @description
|
* @description 存储报文数据信息
|
||||||
*/
|
*/
|
||||||
public interface CoupletMsgService {
|
public interface CoupletMsgService {
|
||||||
|
void saveDataToDatabase(CoupletMsgData msgData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.couplet.analyze.msg.service.impl;
|
||||||
|
|
||||||
|
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||||
|
import com.couplet.analyze.msg.mapper.CoupletMapper;
|
||||||
|
import com.couplet.analyze.msg.service.CoupletMsgService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/4/2 19:57
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CoupletMsgServiceImpl implements CoupletMsgService {
|
||||||
|
@Autowired
|
||||||
|
private CoupletMapper coupletMapper;
|
||||||
|
@Override
|
||||||
|
public void saveDataToDatabase(CoupletMsgData msgData) {
|
||||||
|
coupletMapper.insertMsgData(msgData);
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,8 @@ spring:
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.couplet.msg.mapper: DEBUG
|
com.couplet.msg.mapper: DEBUG
|
||||||
mybatis-plus:
|
# RabbitMQ配置
|
||||||
configuration:
|
#mq:
|
||||||
map-underscore-to-camel-case: true
|
# queueName: queue
|
||||||
|
# exchangeName: exchange
|
||||||
|
# routingKey: routingKey
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?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.couplet.analyze.msg.mapper.CoupletMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="insertMsgData">
|
||||||
|
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
|
@ -1,41 +0,0 @@
|
||||||
<?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.couplet.trouble.mapper.SysTroubleMapper">
|
|
||||||
|
|
||||||
<resultMap type="com.couplet.trouble.domain.CoupletTroubleCode" id="SysTroubleResult">
|
|
||||||
<id property="troubleId" column="trouble_id"/>
|
|
||||||
<result property="troubleCode" column="trouble_code"/>
|
|
||||||
<result property="troubleValue" column="trouble_value"/>
|
|
||||||
<result property="troublePosition" column="trouble_position"/>
|
|
||||||
<result property="troubleTag" column="trouble_tag"/>
|
|
||||||
<result property="typeId" column="type_id"/>
|
|
||||||
<result property="gradeId" column="grade_id"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectTroubleVo">
|
|
||||||
select t.*,g.grade_name,y.type_name from couplet_trouble_code t
|
|
||||||
LEFT JOIN couplet_trouble_grade g on t.grade_id = g.grade_id
|
|
||||||
LEFT JOIN couplet_trouble_type y on t.type_id= y.type_id
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectTroubleList" parameterType="com.couplet.trouble.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
|
|
||||||
<include refid="selectTroubleVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="troubleCode != null and troubleCode != ''">
|
|
||||||
AND trouble_code = #{troubleCode}
|
|
||||||
</if>
|
|
||||||
<if test="troublePosition != null and troublePosition != ''">
|
|
||||||
AND trouble_position like concat('%', #{troublePosition}, '%')
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
<select id="selectTroubleListByType" resultType="com.couplet.trouble.domain.CoupletTroubleType">
|
|
||||||
select * from couplet_trouble_type
|
|
||||||
</select>
|
|
||||||
<select id="selectTroubleListByGrade" resultType="com.couplet.trouble.domain.CoupletTroubleGrade">
|
|
||||||
select * from couplet_trouble_grade
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
|
Loading…
Reference in New Issue