jc获取报文数据同步数据库,vehiclesStatus字段数据有异常
parent
3222b3ed2e
commit
bd85703b70
|
@ -0,0 +1,263 @@
|
|||
package com.zhilian.common.resolver.domain;
|
||||
|
||||
import lombok.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName ResolverReportData
|
||||
* @Description 解析报文数据
|
||||
* @Author Can.J
|
||||
* @Date 2024/4/1 11:49
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Setter
|
||||
@Getter
|
||||
public class ResolverReportData {
|
||||
/**
|
||||
* 主键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;
|
||||
|
||||
}
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
package com.zhilian.common.resolver.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class VehicleData {
|
||||
/**
|
||||
* 车辆编码
|
||||
*/
|
||||
private String vin;
|
||||
|
||||
/**
|
||||
* 行驶路线
|
||||
*/
|
||||
private String drivingRoute;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
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 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;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.zhilian.business;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class zhilianOnLineApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(zhilianOnLineApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.zhilian.manager;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class zhilianMangerApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(zhilianMangerApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -4,9 +4,12 @@ import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
|||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@EnableCustomSwagger2
|
||||
@EnableScheduling
|
||||
@EnableMyFeignClients
|
||||
@MapperScan("com.zhilian.resolver.mapper")
|
||||
@MapperScan({"com.zhilian.resolver.mapper", "com.zhilian.resolver.resolverReport"})
|
||||
@SpringBootApplication
|
||||
public class ZhiLianResolverApplication {
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package com.zhilian.resolver.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||
import com.zhilian.common.resolver.domain.ResolverReportInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ResolverReportInfoMapper extends BaseMapper<ResolverReportInfo> {
|
||||
|
||||
// void saveDataToDatabase(ResolverReportData resolverReportData);
|
||||
|
||||
void reportMapper(ResolverReportData vehicleData);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,42 @@
|
|||
package com.zhilian.resolver.resolverReport;
|
||||
|
||||
|
||||
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||
import com.zhilian.resolver.mapper.ResolverReportInfoMapper;
|
||||
import com.zhilian.resolver.service.ResolverReportInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @ClassName ResolverMqttMsg
|
||||
* @Description 获取mqtt报文消息
|
||||
* @Author Can.J
|
||||
* @Date 2024/3/30 8:36
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ResolverMqttMsg {
|
||||
@Autowired
|
||||
private ResolverReportInfoService resolverReportInfoService;
|
||||
private static final String BROKER_URL = "tcp://111.229.33.194:1883";
|
||||
private static final String CLIENT_ID = "mqttx_e9f5976f";
|
||||
private static final String CLIENT_ID = "mqttx_53f082e9";
|
||||
@Autowired
|
||||
public ResolverMqttMsg(ResolverReportInfoService resolverReportInfoService) {
|
||||
this.resolverReportInfoService = resolverReportInfoService;
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0/5 * * * * ?")
|
||||
public void start() {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
MqttClient mqttClient = new MqttClient(BROKER_URL, CLIENT_ID);
|
||||
|
||||
|
@ -21,29 +48,409 @@ public class ResolverMqttMsg {
|
|||
mqttClient.setCallback(new MqttCallback() {
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
log.info("连接断开");
|
||||
log.error("Mqtt[{}-{}]连接断开:[{}]", CLIENT_ID, BROKER_URL, throwable.getMessage(), throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) throws Exception {
|
||||
log.info("Message received from topic '{}': {}", topic, new String(message.getPayload()));
|
||||
log.info("主题='{}':消息内容={}", topic, new String(message.getPayload()));
|
||||
String str = hexStringToString(new String(message.getPayload()));
|
||||
List<ResolverReportData> vehicleDataList = parseVehicleData(str);
|
||||
|
||||
for (ResolverReportData vehicleData : vehicleDataList) {
|
||||
log.info("解析到车辆数据:{}", vehicleData);
|
||||
resolverReportInfoService.saveDataToDatabase(vehicleData);
|
||||
}
|
||||
log.info("字符串:{}",str);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken token) {
|
||||
log.info("消息已成功投递:{}",token);
|
||||
}
|
||||
});
|
||||
|
||||
mqttClient.subscribe("cartest",1);
|
||||
mqttClient.subscribe("cartest",0);
|
||||
|
||||
Thread.sleep(1000*60*10);
|
||||
|
||||
mqttClient.disconnect();
|
||||
// mqttClient.disconnect();
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 16进制转换成为string类型字符串
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static String hexStringToString(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;
|
||||
}
|
||||
private static List<ResolverReportData> parseVehicleData(String str) {
|
||||
List<ResolverReportData> vehicleDataList = new ArrayList<>();
|
||||
ResolverReportData vehicleData = new ResolverReportData();
|
||||
|
||||
vehicleData.setVin(str.substring(1,18));
|
||||
|
||||
log.info("vin=="+vehicleData.getVin());
|
||||
|
||||
//时间
|
||||
String tim =str.substring(18,31);
|
||||
long timestamp = Long.parseLong(tim);
|
||||
|
||||
log.info("时间串=="+tim);
|
||||
Date date = new Date(timestamp);
|
||||
System.out.println("时间"+date);
|
||||
vehicleData.setCreateTime(date);
|
||||
log.info("shijian =="+vehicleData.getCreateTime());
|
||||
|
||||
//经度
|
||||
String lt = str.substring(31,42);
|
||||
log.info("经度串==:{}",lt);
|
||||
// 如果末尾是零,则舍去
|
||||
int endIndex = lt.length() - 1;
|
||||
while (lt.charAt(endIndex) == '0'){
|
||||
endIndex--;
|
||||
}
|
||||
|
||||
String longitude = lt.substring(0, endIndex + 1);
|
||||
vehicleData.setLongitude(longitude);
|
||||
log.info("经度 =="+vehicleData.getLongitude());
|
||||
|
||||
//维度
|
||||
String latitudeIndex =str.substring(42,52);
|
||||
log.info("维度串==:{}",latitudeIndex);
|
||||
int endIndexT = latitudeIndex.length() - 1;
|
||||
while (latitudeIndex.charAt(endIndexT) == '0'){
|
||||
endIndexT--;
|
||||
}
|
||||
|
||||
String latitude = latitudeIndex.substring(0, endIndexT + 1);
|
||||
vehicleData.setLatitude(latitude);
|
||||
log.info("维度==:{}",vehicleData.getLatitude());
|
||||
|
||||
//速度speed
|
||||
String speed =str.substring(52,58);
|
||||
log.info("速度==:{}",speed);
|
||||
vehicleData.setSpeed(speed);
|
||||
log.info("速度==:{}",vehicleData.getSpeed());
|
||||
|
||||
//里程
|
||||
BigDecimal mileage= new BigDecimal(str.substring(58,69));
|
||||
log.info("里程==:{}",mileage);
|
||||
mileage=mileage.stripTrailingZeros();
|
||||
vehicleData.setMileage(mileage);
|
||||
log.info("里程==:{}",vehicleData.getMileage());
|
||||
|
||||
//总电压
|
||||
String voltage =str.substring(69,75);
|
||||
log.info("总电压==:{}",voltage);
|
||||
while (voltage.endsWith("0")) {
|
||||
voltage = voltage.substring(0, voltage.length() - 1); // 去除末尾的零
|
||||
}
|
||||
vehicleData.setVoltage(voltage);
|
||||
log.info("总电压==:{}",vehicleData.getVoltage());
|
||||
|
||||
//总电流
|
||||
String current =str.substring(75,80);
|
||||
log.info("总电流==:{}",current);
|
||||
while (current.endsWith("0")){
|
||||
current=current.substring(0,current.length()-1);
|
||||
}
|
||||
vehicleData.setCurrent(current);
|
||||
log.info("总电流==:{}",vehicleData.getCurrent());
|
||||
|
||||
//绝缘电阻 resistance
|
||||
String res =str.substring(80,89);
|
||||
log.info("绝缘电阻==:{}",res);
|
||||
String resistance = res.substring(0, 5);
|
||||
vehicleData.setResistance(resistance);
|
||||
log.info("绝缘电阻==:{}",vehicleData.getResistance());
|
||||
|
||||
//档位
|
||||
String gear =str.substring(89,90);
|
||||
log.info("档位==:{}",gear);
|
||||
vehicleData.setGear(gear);
|
||||
log.info("档位==:{}",vehicleData.getGear());
|
||||
|
||||
//accelerationPedal 加速踏板行程值
|
||||
String accelerationPedal =str.substring(90,91);
|
||||
log.info("加速踏板行程值==:{}",accelerationPedal);
|
||||
vehicleData.setAccelerationPedal(accelerationPedal);
|
||||
log.info("加速踏板行程值==:{}",vehicleData.getAccelerationPedal());
|
||||
|
||||
//brakePedal 制动踏板行程值
|
||||
String brakePedal =str.substring(92,93);
|
||||
log.info("制动踏板行程值==:{}",brakePedal);
|
||||
vehicleData.setBrakePedal(brakePedal);
|
||||
log.info("制动踏板行程值==:{}",vehicleData.getBrakePedal());
|
||||
|
||||
//fuelConsumptionRate 燃料消耗率
|
||||
String fuelConsumptionRate =str.substring(94,99);
|
||||
log.info("燃料消耗率==:{}",fuelConsumptionRate);
|
||||
vehicleData.setFuelConsumptionRate(fuelConsumptionRate);
|
||||
log.info("燃料消耗率==:{}",vehicleData.getFuelConsumptionRate());
|
||||
|
||||
//motorControllerTemperature 电机控制器温度
|
||||
String motorControllerTemperature =str.substring(99,105);
|
||||
while (motorControllerTemperature.endsWith("0")){
|
||||
motorControllerTemperature=motorControllerTemperature.substring(0,motorControllerTemperature.length()-1);
|
||||
}
|
||||
log.info("电机控制器温度==:{}",motorControllerTemperature);
|
||||
vehicleData.setMotorControllerTemperature(motorControllerTemperature);
|
||||
log.info("电机控制器温度==:{}",vehicleData.getMotorControllerTemperature());
|
||||
|
||||
//motorSpeed 电机转速
|
||||
String motorSpeed =str.substring(105,110);
|
||||
log.info("电机转速==:{}",motorSpeed);
|
||||
vehicleData.setMotorSpeed(motorSpeed);
|
||||
log.info("电机转速==:{}",vehicleData.getMotorSpeed());
|
||||
|
||||
//motorTorque 电机转矩
|
||||
String motorTorque =str.substring(110,114);
|
||||
log.info("电机转矩==:{}",motorTorque);
|
||||
while (motorTorque.endsWith("0")){
|
||||
motorTorque=motorTorque.substring(0,motorTorque.length()-1);
|
||||
}
|
||||
vehicleData.setMotorTorque(motorTorque);
|
||||
log.info("电机转矩==:{}",vehicleData.getMotorTorque());
|
||||
|
||||
|
||||
//motorTemperature 电机温度
|
||||
String motorTemperature =str.substring(114,120);
|
||||
log.info("电机温度==:{}",motorTemperature);
|
||||
while (motorTemperature.endsWith("0")){
|
||||
motorTemperature=motorTemperature.substring(0,motorTemperature.length()-1);
|
||||
}
|
||||
vehicleData.setMotorTemperature(motorTemperature);
|
||||
log.info("电机温度==:{}",vehicleData.getMotorTemperature());
|
||||
|
||||
//motorVoltage 电机电压
|
||||
String motorVoltage =str.substring(120,125);
|
||||
log.info("电机电压==:{}",motorVoltage);
|
||||
while (motorVoltage.endsWith("0")){
|
||||
motorVoltage=motorVoltage.substring(0,motorVoltage.length()-1);
|
||||
}
|
||||
vehicleData.setMotorVoltage(motorVoltage);
|
||||
log.info("电机电压==:{}",vehicleData.getMotorVoltage());
|
||||
|
||||
//motorCurrent 电机电流
|
||||
String motorCurrent =str.substring(125,133);
|
||||
log.info("电机电流==:{}",motorCurrent);
|
||||
while (motorCurrent.endsWith("0")){
|
||||
motorCurrent=motorCurrent.substring(0,motorCurrent.length()-1);
|
||||
}
|
||||
vehicleData.setMotorCurrent(motorCurrent);
|
||||
log.info("电机电流==:{}",vehicleData.getMotorCurrent());
|
||||
|
||||
//remainingBattery 动力电池剩余电量SOC
|
||||
BigDecimal remainingBattery = new BigDecimal(str.substring(133,138));
|
||||
log.info("动力电池剩余电量SOC==:{}",remainingBattery);
|
||||
vehicleData.setRemainingBattery(remainingBattery);
|
||||
log.info("动力电池剩余电量SOC==:{}",vehicleData.getRemainingBattery());
|
||||
|
||||
//maximumFeedbackPower 当前状态允许的最大反馈功率
|
||||
String maximumFeedbackPower =str.substring(139,144);
|
||||
log.info("当前状态允许的最大反馈功率==:{}",maximumFeedbackPower);
|
||||
while (maximumFeedbackPower.endsWith("0")){
|
||||
maximumFeedbackPower=maximumFeedbackPower.substring(0,maximumFeedbackPower.length()-1);
|
||||
}
|
||||
vehicleData.setMaximumFeedbackPower(maximumFeedbackPower);
|
||||
log.info("当前状态允许的最大反馈功率==:{}",vehicleData.getMaximumFeedbackPower());
|
||||
|
||||
//maximumDischargePower 当前状态允许最大放电功率
|
||||
String maximumDischargePower =str.substring(145,151);
|
||||
log.info("当前状态允许最大放电功率:{}",maximumDischargePower);
|
||||
while (maximumDischargePower.endsWith("0")){
|
||||
maximumDischargePower=maximumDischargePower.substring(0,maximumDischargePower.length()-1);
|
||||
}
|
||||
vehicleData.setMaximumDischargePower(maximumDischargePower);
|
||||
log.info("当前状态允许最大放电功率:{}",vehicleData.getMaximumDischargePower());
|
||||
|
||||
//selfCheckCounter BMS自检计数器
|
||||
String selfCheckCounter =str.substring(151,153);
|
||||
String selfCheckCounterReplace = selfCheckCounter.replace("0", "");
|
||||
log.info("BMS自检计数器==:{}",selfCheckCounter);
|
||||
vehicleData.setSelfCheckCounter(selfCheckCounterReplace);
|
||||
log.info("BMS自检计数器==:{}",vehicleData.getSelfCheckCounter());
|
||||
|
||||
//totalBatteryCurrent 动力电池充放电电流
|
||||
String totalBatteryCurrent =str.substring(153,158);
|
||||
log.info("BMS自检计数器==:{}",totalBatteryCurrent);
|
||||
while (totalBatteryCurrent.endsWith("0")){
|
||||
totalBatteryCurrent=totalBatteryCurrent.substring(0,totalBatteryCurrent.length()-1);
|
||||
}
|
||||
vehicleData.setTotalBatteryCurrent(totalBatteryCurrent);
|
||||
log.info("BMS自检计数器==:{}",vehicleData.getTotalBatteryCurrent());
|
||||
|
||||
//totalBatteryVoltage 动力电池负载端总电压V3
|
||||
String totalBatteryVoltage =str.substring(158,164);
|
||||
log.info("动力电池负载端总电压V3==:{}",totalBatteryVoltage);
|
||||
while (totalBatteryVoltage.endsWith("0")){
|
||||
totalBatteryVoltage=totalBatteryVoltage.substring(0,totalBatteryVoltage.length()-1);
|
||||
}
|
||||
vehicleData.setTotalBatteryVoltage(totalBatteryVoltage);
|
||||
log.info("动力电池负载端总电压V3==:{}",vehicleData.getTotalBatteryVoltage());
|
||||
|
||||
//singleBatteryMaxVoltage 单次最大电压
|
||||
String singleBatteryMaxVoltage =str.substring(164,168);
|
||||
log.info("单次最大电压==:{}",singleBatteryMaxVoltage);
|
||||
while (singleBatteryMaxVoltage.endsWith("0")){
|
||||
singleBatteryMaxVoltage=singleBatteryMaxVoltage.substring(0,singleBatteryMaxVoltage.length()-1);
|
||||
}
|
||||
vehicleData.setSingleBatteryMaxVoltage(singleBatteryMaxVoltage);
|
||||
log.info("单次最大电压==:{}",vehicleData.getSingleBatteryMaxVoltage());
|
||||
|
||||
//singleBatteryMinVoltage 单体电池最低电压
|
||||
String singleBatteryMinVoltage =str.substring(168,172);
|
||||
log.info("单体电池最低电压==:{}",singleBatteryMinVoltage);
|
||||
while (singleBatteryMinVoltage.endsWith("0")){
|
||||
singleBatteryMinVoltage=singleBatteryMinVoltage.substring(0,singleBatteryMinVoltage.length()-1);
|
||||
}
|
||||
|
||||
vehicleData.setSingleBatteryMinVoltage(singleBatteryMinVoltage);
|
||||
log.info("单体电池最低电压==:{}",vehicleData.getSingleBatteryMinVoltage());
|
||||
|
||||
//singleBatteryMaxTemperature 单体电池最高温度
|
||||
String singleBatteryMaxTemperature =str.substring(172,178);
|
||||
log.info("单体电池最高温度==:{}",singleBatteryMaxTemperature);
|
||||
while (singleBatteryMaxTemperature.endsWith("0")){
|
||||
singleBatteryMaxTemperature=singleBatteryMaxTemperature.substring(0,singleBatteryMaxTemperature.length()-1);
|
||||
}
|
||||
vehicleData.setSingleBatteryMaxTemperature(singleBatteryMaxTemperature);
|
||||
log.info("单体电池最高温度==:{}",vehicleData.getSingleBatteryMaxTemperature());
|
||||
|
||||
//singleBatteryMinTemperature 单体电池最低温度
|
||||
String singleBatteryMinTemperature =str.substring(178,184);
|
||||
log.info("单体电池最低温度==:{}",singleBatteryMinTemperature);
|
||||
while (singleBatteryMinTemperature.endsWith("0")){
|
||||
singleBatteryMinTemperature=singleBatteryMinTemperature.substring(0,singleBatteryMinTemperature.length()-1);
|
||||
}
|
||||
vehicleData.setSingleBatteryMinTemperature(singleBatteryMinTemperature);
|
||||
log.info("单体电池最低温度==:{}",vehicleData.getSingleBatteryMinTemperature());
|
||||
|
||||
//availableBatteryCapacity 可用电池容量
|
||||
String availableBatteryCapacity =str.substring(184,190);
|
||||
log.info("可用电池容量==:{}",availableBatteryCapacity);
|
||||
while (availableBatteryCapacity.endsWith("0")){
|
||||
availableBatteryCapacity=availableBatteryCapacity.substring(0,availableBatteryCapacity.length()-1);
|
||||
}
|
||||
vehicleData.setAvailableBatteryCapacity(availableBatteryCapacity);
|
||||
log.info("可用电池容量==:{}",vehicleData.getAvailableBatteryCapacity());
|
||||
|
||||
//vehicleStatus 车辆状态
|
||||
int vehicleStatus = Integer.parseInt(str.substring(190,191));
|
||||
vehicleData.setVehicleStatus(vehicleStatus);
|
||||
log.info("车辆状态==:{}",vehicleData.getVehicleStatus());
|
||||
|
||||
//chargingStatus 充电状态
|
||||
int chargingStatus = Integer.parseInt(str.substring(191,192));
|
||||
vehicleData.setChargingStatus(chargingStatus);
|
||||
log.info("充电状态==:{}",vehicleData.getChargingStatus());
|
||||
|
||||
//operatingStatus 运行状态
|
||||
int operatingStatus = Integer.parseInt(str.substring(192,193));
|
||||
vehicleData.setOperatingStatus(operatingStatus);
|
||||
log.info("运行状态==:{}",vehicleData.getOperatingStatus());
|
||||
|
||||
//socStatus SOC
|
||||
int socStatus = Integer.parseInt(str.substring(193,194));
|
||||
vehicleData.setSocStatus(socStatus);
|
||||
log.info("SOC==:{}",vehicleData.getSocStatus());
|
||||
|
||||
//chargingEnergyStorageStatus 可充电储能装置工作状态
|
||||
int chargingEnergyStorageStatus = Integer.parseInt(str.substring(194,195));
|
||||
vehicleData.setChargingEnergyStorageStatus(chargingEnergyStorageStatus);
|
||||
log.info("可充电储能装置工作状态==:{}",vehicleData.getChargingEnergyStorageStatus());
|
||||
|
||||
//driveMotorStatus 驱动电机状态
|
||||
int driveMotorStatus = Integer.parseInt(str.substring(195,196));
|
||||
vehicleData.setDriveMotorStatus(driveMotorStatus);
|
||||
log.info("驱动电机状态==:{}",vehicleData.getDriveMotorStatus());
|
||||
|
||||
//positionStatus 定位是否有效
|
||||
int positionStatus = Integer.parseInt(str.substring(196,197));
|
||||
vehicleData.setPositionStatus(positionStatus);
|
||||
log.info("定位是否有效==:{}",vehicleData.getPositionStatus());
|
||||
|
||||
//easStatus EAS(汽车防盗系统)状态
|
||||
int easStatus = Integer.parseInt(str.substring(197,198));
|
||||
vehicleData.setEasStatus(easStatus);
|
||||
log.info("EAS(汽车防盗系统)状态==:{}",vehicleData.getEasStatus());
|
||||
|
||||
//ptcStatus PTC(电动加热器)状态
|
||||
int ptcStatus = Integer.parseInt(str.substring(198,199));
|
||||
vehicleData.setPtcStatus(ptcStatus);
|
||||
log.info("PTC(电动加热器)状态==:{}",vehicleData.getPtcStatus());
|
||||
|
||||
//epsStatus
|
||||
int epsStatus = Integer.parseInt(str.substring(199,200));
|
||||
vehicleData.setEpsStatus(epsStatus);
|
||||
log.info("车辆状态==:{}",vehicleData.getEpsStatus());
|
||||
|
||||
//absStatus EPS(电动助力系统)状态
|
||||
int absStatus = Integer.parseInt(str.substring(200,201));
|
||||
vehicleData.setAbsStatus(absStatus);
|
||||
log.info("EPS(电动助力系统)状态==:{}",vehicleData.getAbsStatus());
|
||||
|
||||
//mcuStatus MCU(电机/逆变器)状态
|
||||
int mcuStatus = Integer.parseInt(str.substring(201,202));
|
||||
vehicleData.setMcuStatus(mcuStatus);
|
||||
log.info("MCU(电机/逆变器)状态==:{}",vehicleData.getMcuStatus());
|
||||
|
||||
//heatingStatus 动力电池加热状态
|
||||
int heatingStatus = Integer.parseInt(str.substring(202,203));
|
||||
vehicleData.setHeatingStatus(heatingStatus);
|
||||
log.info("动力电池加热状态==:{}",vehicleData.getHeatingStatus());
|
||||
|
||||
//batteryStatus 动力电池当前状态
|
||||
int batteryStatus = Integer.parseInt(str.substring(203,204));
|
||||
vehicleData.setBatteryStatus(batteryStatus);
|
||||
log.info("动力电池当前状态==:{}",vehicleData.getBatteryStatus());
|
||||
|
||||
//batteryInsulationStatus 动力电池保温状态
|
||||
int batteryInsulationStatus = Integer.parseInt(str.substring(204,205));
|
||||
vehicleData.setBatteryInsulationStatus(batteryInsulationStatus);
|
||||
log.info("动力电池保温状态==:{}",vehicleData.getBatteryInsulationStatus());
|
||||
|
||||
//dcdcStatus DCDC(电力交换系统)状态
|
||||
int dcdcStatus = Integer.parseInt(str.substring(205,206));
|
||||
vehicleData.setDcdcStatus(dcdcStatus);
|
||||
log.info("DCDC(电力交换系统)状态==:{}",vehicleData.getDcdcStatus());
|
||||
|
||||
//chgStatus CHG(充电机)状态
|
||||
int chgStatus = Integer.parseInt(str.substring(206,207));
|
||||
vehicleData.setChgStatus(chgStatus);
|
||||
log.info("CHG(充电机)状态 ==:{}",vehicleData.getChgStatus());
|
||||
|
||||
log.info("车辆数据解析完成:{}",vehicleData);
|
||||
|
||||
vehicleDataList.add(vehicleData);
|
||||
|
||||
return vehicleDataList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.zhilian.resolver.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||
import com.zhilian.common.resolver.domain.ResolverReportInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,7 +12,10 @@ import java.util.List;
|
|||
* @Author Can.J
|
||||
* @Date 2024/3/26 22:30
|
||||
*/
|
||||
@Service
|
||||
public interface ResolverReportInfoService extends IService<ResolverReportInfo> {
|
||||
|
||||
List<ResolverReportInfo> pageQuery(ResolverReportInfo report);
|
||||
|
||||
void saveDataToDatabase(ResolverReportData vehicleData);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.common.core.utils.StringUtils;
|
||||
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||
import com.zhilian.common.resolver.domain.ResolverReportInfo;
|
||||
import com.zhilian.resolver.mapper.ResolverReportInfoMapper;
|
||||
import com.zhilian.resolver.service.ResolverReportInfoService;
|
||||
|
@ -82,6 +83,11 @@ public class ResolverReportInfoServiceImpl extends ServiceImpl<ResolverReportInf
|
|||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDataToDatabase(ResolverReportData vehicleData) {
|
||||
reportMapper.reportMapper(vehicleData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成缓存的key
|
||||
|
|
|
@ -33,3 +33,10 @@ es:
|
|||
host: 111.229.33.194
|
||||
port: 9200
|
||||
scheme: http
|
||||
# 服务器配置
|
||||
#mqtt:
|
||||
# server:
|
||||
# broker-url: tcp://111.229.33.194:1883
|
||||
# client-id: mqttx_53f082e9
|
||||
# topic: cartest
|
||||
|
||||
|
|
|
@ -3,55 +3,72 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhilian.resolver.mapper.ResolverReportInfoMapper">
|
||||
<!-- <resultMap type="com.zhilian.resolver.domain.Report" id="resolverResult">-->
|
||||
<!-- <id property="reportId" column="report_id"/>-->
|
||||
<!-- <result property="vin" column="vin"/>-->
|
||||
<!-- <result property="onlineTime" column="online_time"/>-->
|
||||
<!-- <result property="downLineTime" column="down_line_time"/>-->
|
||||
<!-- <result property="longitude" column="longitude"/>-->
|
||||
<!-- <result property="latitude" column="latitude"/>-->
|
||||
<!-- <result property="remainingBattery" column="remaining_battery"/>-->
|
||||
<!-- <result property="batteryLevel" column="battery_level"/>-->
|
||||
<!-- <result property="totalMileage" column="total_mileage"/>-->
|
||||
<!-- <result property="isOnline" column="is_online"/>-->
|
||||
<!-- <result property="createTime" column="create_time"/>-->
|
||||
<!-- <result property="isBreakDown" column="is_break_down"/>-->
|
||||
<!-- <result property="isSolve" column="is_solve"/>-->
|
||||
<!-- <result property="isDelay" column="is_delay"/>-->
|
||||
<!-- <result property="isRepeat" column="is_repeat"/>-->
|
||||
<!-- <result property="status" column="status"/>-->
|
||||
<!-- <result property="companyId" column="company_id"/>-->
|
||||
<!-- </resultMap>-->
|
||||
<!-- <sql id="resolverList">-->
|
||||
<!-- SELECT report_id,-->
|
||||
<!-- vin,-->
|
||||
<!-- online_time,-->
|
||||
<!-- down_line_time,-->
|
||||
<!-- longitude,-->
|
||||
<!-- latitude,-->
|
||||
<!-- remaining_battery,-->
|
||||
<!-- battery_level,-->
|
||||
<!-- total_mileage,-->
|
||||
<!-- is_online,-->
|
||||
<!-- create_time,-->
|
||||
<!-- is_break_down,-->
|
||||
<!-- is_solve,-->
|
||||
<!-- is_delay,-->
|
||||
<!-- is_repeat,-->
|
||||
<!-- status,-->
|
||||
<!-- company_id-->
|
||||
<!-- from t_report WHERE is_delete=1-->
|
||||
<!-- </sql>-->
|
||||
|
||||
<!-- <select id="queryReports" resultType="com.zhilian.resolver.domain.ResReport" resultMap="resolverResult">-->
|
||||
<!-- <include refid="resolverList"/>-->
|
||||
<!-- <where>-->
|
||||
<!-- <if test="vin != null and vin != ''">-->
|
||||
<!-- AND vin like concat('%',#{vin},'%')-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="status != null ">-->
|
||||
<!-- AND status = #{status}-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- </select>-->
|
||||
<insert id="reportMapper">
|
||||
INSERT INTO `vehicle-resolver`.`resolver_report_data`
|
||||
(`vin`, `create_time`, `longitude`, `latitude`,
|
||||
`speed`, `mileage`, `voltage`, `current`, `resistance`, `gear`,
|
||||
`acceleration_pedal`, `fuel_consumption_rate`,
|
||||
`motor_controller_temperature`, `motor_speed`,
|
||||
`motor_torque`, `motor_temperature`, `motor_voltage`,
|
||||
`motor_current`, `remaining_battery`, `maximum_feedback_power`,
|
||||
`maximum_discharge_power`, `self_check_counter`,
|
||||
`total_battery_current`, `total_battery_voltage`,
|
||||
`single_battery_max_voltage`, `single_battery_min_voltage`,
|
||||
`single_battery_max_temperature`, `single_battery_min_temperature`,
|
||||
`available_battery_capacity`, `vehicle_status`, `charging_status`,
|
||||
`operatingStatus`, `soc_status`, `charging_energy_storage_status`,
|
||||
`drive_motor_status`, `position_status`, `eas_status`, `ptc_status`,
|
||||
`eps_status`, `abs_status`, `mcu_status`, `heating_status`, `battery_status`,
|
||||
`battery_insulation_status`, `dcdc_status`, `chg_status`, `brake_pedal`)
|
||||
VALUES (#{vin},
|
||||
#{createTime},
|
||||
#{longitude},
|
||||
#{latitude},
|
||||
#{speed},
|
||||
#{mileage},
|
||||
#{voltage},
|
||||
#{current},
|
||||
#{resistance},
|
||||
#{gear},
|
||||
#{accelerationPedal},
|
||||
#{brakePedal},
|
||||
#{fuelConsumptionRate},
|
||||
#{motorControllerTemperature},
|
||||
#{motorSpeed},
|
||||
#{motorTorque},
|
||||
#{motorTemperature},
|
||||
#{motorVoltage},
|
||||
#{motorCurrent},
|
||||
#{remainingBattery},
|
||||
#{maximumFeedbackPower},
|
||||
#{maximumDischargePower},
|
||||
#{selfCheckCounter},
|
||||
#{totalBatteryCurrent},
|
||||
#{totalBatteryVoltage},
|
||||
#{singleBatteryMaxVoltage},
|
||||
#{singleBatteryMinVoltage},
|
||||
#{singleBatteryMaxTemperature},
|
||||
#{singleBatteryMinTemperature},
|
||||
#{availableBatteryCapacity},
|
||||
#{vehicleStatus},
|
||||
#{chargingStatus},
|
||||
#{operatingStatus},
|
||||
#{socStatus},
|
||||
#{chargingEnergyStorageStatus},
|
||||
#{driveMotorStatus},
|
||||
#{positionStatus},
|
||||
#{easStatus},
|
||||
#{ptcStatus},
|
||||
#{epsStatus},
|
||||
#{absStatus},
|
||||
#{mcuStatus},
|
||||
#{heatingStatus},
|
||||
#{batteryStatus},
|
||||
#{batteryInsulationStatus},
|
||||
#{dcdcStatus},
|
||||
#{chgStatus}
|
||||
);
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue