Compare commits
9 Commits
404f434d62
...
43f51881ca
Author | SHA1 | Date |
---|---|---|
|
43f51881ca | |
|
e5c4c0b9a4 | |
|
8803a91628 | |
|
b1d3443ddb | |
|
65c64098ab | |
|
165583d024 | |
|
1e08ce9bd7 | |
|
de9f2e6a24 | |
|
d8e65c8da3 |
|
@ -46,12 +46,6 @@ public class CoupletTroubleCode {
|
|||
@Excel(name = "vin")
|
||||
private String troubleVin;
|
||||
|
||||
/**
|
||||
* 故障标签
|
||||
*/
|
||||
@Excel(name = "故障标签")
|
||||
private Integer troubleTag;
|
||||
|
||||
/**
|
||||
* 故障开始时间
|
||||
*/
|
||||
|
@ -65,4 +59,10 @@ public class CoupletTroubleCode {
|
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date troubleEndTime;
|
||||
|
||||
/**
|
||||
* 故障位置
|
||||
*/
|
||||
@Excel(name = "故障位置")
|
||||
private String troublePosition;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ public class Fence extends BaseEntity{
|
|||
*/
|
||||
|
||||
private Integer alarmStatus;
|
||||
private Integer fenceCondition;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -93,24 +94,6 @@ public class Fence extends BaseEntity{
|
|||
@TableField(exist = false)
|
||||
private String logoName;
|
||||
|
||||
public static Fence updateFenceStatus(FenceUpdateRequest fenceUpdateRequest) {
|
||||
|
||||
return Fence.builder()
|
||||
.fenceName(fenceUpdateRequest.getFenceName())
|
||||
.fenceDescription(fenceUpdateRequest.getFenceDescription())
|
||||
.fenceState(fenceUpdateRequest.getFenceState())
|
||||
.fenceLongitudeLatitude(fenceUpdateRequest.getFenceLongitudeLatitude())
|
||||
.createName(fenceUpdateRequest.getCrateName())
|
||||
.createTime(fenceUpdateRequest.getCreateTime())
|
||||
.isDelete(fenceUpdateRequest.getIsDelete())
|
||||
.maintainerName(fenceUpdateRequest.getMaintainerName())
|
||||
.alarmStatus(fenceUpdateRequest.getAlarmStatus())
|
||||
.updateTime(fenceUpdateRequest.getUpdateTime())
|
||||
.fenceId(fenceUpdateRequest.getFenceId())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public static Fence fenceInsert(FenceRequest fenceRequest) {
|
||||
//
|
||||
|
|
|
@ -65,6 +65,7 @@ public class FenceRequest {
|
|||
* 报警状态
|
||||
*/
|
||||
private Integer alarmStatus;
|
||||
private Integer fenceCondition;
|
||||
/**
|
||||
* 标识
|
||||
*/
|
||||
|
|
|
@ -68,6 +68,7 @@ public class FenceUpdateRequest {
|
|||
* 报警状态
|
||||
*/
|
||||
private Integer alarmStatus;
|
||||
private Integer fenceCondition;
|
||||
|
||||
public Integer getIsDelete() {
|
||||
return isDelete;
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-business</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.couplet.common.redis.service;
|
||||
|
||||
import com.couplet.common.domain.CoupletVehicleData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -19,6 +20,12 @@ public class RedisService {
|
|||
@Resource
|
||||
public RedisTemplate redisTemplate;
|
||||
|
||||
|
||||
public List<CoupletVehicleData> getList () {
|
||||
return redisTemplate.opsForList().range("coupletMsgData", 0, -1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
|
|
|
@ -17,5 +17,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
public class CoupletMsgApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CoupletMsgApplication.class);
|
||||
System.out.println("解析系统启动成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,17 +39,22 @@ public class FenceConsumer {
|
|||
if (!redisTemplate.hasKey("消息不丢失:" + messageId)) {
|
||||
redisTemplate.opsForValue().set("消息不丢失:" + messageId, "" + deliveryTag, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
if (redisTemplate.hasKey("fence")){
|
||||
redisTemplate.delete("fence");
|
||||
}
|
||||
|
||||
Long add = redisTemplate.opsForSet().add("消息不重复:" + messageId, messageId);
|
||||
redisTemplate.expire("消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
||||
try {
|
||||
if (0 < add) {
|
||||
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
HashSet<FenceUpdateRequest> hashSet = new HashSet<>();
|
||||
hashSet.add(fenceUpdateRequest);
|
||||
hashMap.put(fenceUpdateRequest.getFenceId()+"",fenceUpdateRequest);
|
||||
redisTemplate.opsForValue().set("fence", JSON.toJSONString(hashMap),10,TimeUnit.MINUTES);
|
||||
// redisTemplate.opsForH("fence", JSON.toJSONString(hashMap),10,TimeUnit.MINUTES);
|
||||
// redisTemplate.opsForHash().put("fence", fenceUpdateRequest.getFenceId()+"", JSON.toJSONString(hashMap));
|
||||
redisTemplate.opsForList().rightPush("fence",JSON.toJSONString(hashMap));
|
||||
redisTemplate.expire("fence", 10, TimeUnit.MINUTES);
|
||||
//判断车辆是否有实时数据,如果没有则删除数据
|
||||
channel.basicAck(deliveryTag, false);
|
||||
} else {
|
||||
|
|
|
@ -47,10 +47,9 @@ public class MsgConsumer {
|
|||
redisTemplate.expire("消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
||||
try {
|
||||
if (0 < add) {
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(String.valueOf(realTimeDataRequest));
|
||||
String vin = jsonObject.getString("vin");
|
||||
Long userId = jsonObject.getLong("userId");
|
||||
String vin = jsonObject.getString("vin");
|
||||
RealTimeDataRequest request = new RealTimeDataRequest();
|
||||
request.setVin(vin);
|
||||
request.setUserId(userId);
|
||||
|
|
|
@ -1,396 +0,0 @@
|
|||
package com.couplet.analyze.msg.model;
|
||||
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.utils.SpringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
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.*;
|
||||
|
||||
import static com.couplet.analyze.msg.contents.MsgContent.BROKER_URL;
|
||||
import static com.couplet.analyze.msg.contents.MsgContent.CLIENT_ID;
|
||||
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/2 15:41
|
||||
* @description 解析报文数据
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ModelMessage {
|
||||
|
||||
// @Autowired
|
||||
// private RabbitTemplate rabbitTemplate;
|
||||
// static ArrayList<String> strings = new ArrayList<>() {
|
||||
// {
|
||||
// add("breakdown");
|
||||
// add("electronic-fence");
|
||||
// add("real-time-data");
|
||||
// add("stored-event");
|
||||
// }
|
||||
// };
|
||||
//
|
||||
//// @Value("${mq.queueName}")
|
||||
//// public String queueName;
|
||||
////
|
||||
//// //交换机
|
||||
//// @Value("${mq.exchangeName}")
|
||||
//// public String exchangeName;
|
||||
////
|
||||
//// //路由键
|
||||
//// @Value("${mq.routingKey}")
|
||||
//// public String routingKey;
|
||||
//
|
||||
// @Scheduled(cron = "0/5 * * * * ?")
|
||||
// public void startMsg() {
|
||||
// try {
|
||||
// MqttClient mqttClient = new MqttClient(BROKER_URL, CLIENT_ID);
|
||||
//
|
||||
// MqttConnectOptions options = new MqttConnectOptions();
|
||||
//
|
||||
// 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);
|
||||
// for (String string : strings) {
|
||||
// IncidentService incidentService = SpringUtils.getBean(string);
|
||||
// incidentService.incident(msgData);
|
||||
// }
|
||||
//// 不睡眠,他们也会主动拉取数据,不会影响其他服务
|
||||
//// try {
|
||||
//// Thread.sleep(1000);
|
||||
//// } catch (InterruptedException e) {
|
||||
//// throw new RuntimeException(e);
|
||||
//// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void deliveryComplete(IMqttDeliveryToken token) {
|
||||
// log.info("消息已投递成功:{}",token);
|
||||
// }
|
||||
// });
|
||||
// mqttClient.subscribe("test",0);
|
||||
//
|
||||
// Thread.sleep(1000*60*10);
|
||||
// } catch (Exception 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;
|
||||
// }
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.couplet.analyze.msg.contents.StateConstant;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.analyze.msg.utils.MsgUtils;
|
||||
import com.couplet.common.domain.CoupletTroubleCode;
|
||||
import com.couplet.remote.RemoteTroubleService;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -107,9 +108,95 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
|||
if (breakdownIds.size()==0){
|
||||
CoupletTroubleCode troubleCode = new CoupletTroubleCode();
|
||||
troubleCode.setTroubleStartTime(new Date());
|
||||
// 插入数据库
|
||||
troubleCode.setTroubleTag(0);
|
||||
troubleCode.setTroubleVin(code.getVin());
|
||||
// 随机生成故障码
|
||||
String faultCode = MsgUtils.generateGTA();
|
||||
troubleCode.setTroubleCode(faultCode);
|
||||
|
||||
// 检查车辆状态,若为0,则设置故障位置为"190"
|
||||
if(code.getVehicleStatus() == 0) {
|
||||
troubleCode.setTroublePosition("190");
|
||||
}
|
||||
|
||||
// 检查充电状态,若为0,则设置故障位置为"191"
|
||||
if (code.getChargingStatus() == 0) {
|
||||
troubleCode.setTroublePosition("191");
|
||||
}
|
||||
|
||||
// 检查运行状态,若为0,则设置故障位置为"192"
|
||||
if (code.getOperatingStatus() == 0) {
|
||||
troubleCode.setTroublePosition("192");
|
||||
}
|
||||
|
||||
// 检查电池荷电状态(SOC), 若为0,则设置故障位置为"193"
|
||||
if (code.getSocStatus() == 0) {
|
||||
troubleCode.setTroublePosition("193");
|
||||
}
|
||||
|
||||
// 检查充电能源存储状态,若为0,则设置故障位置为"194"
|
||||
if (code.getChargingEnergyStorageStatus() == 0) {
|
||||
troubleCode.setTroublePosition("194");
|
||||
}
|
||||
|
||||
// 检查驱动电机状态,若为0,则设置故障位置为"195"
|
||||
if (code.getDriveMotorStatus() == 0) {
|
||||
troubleCode.setTroublePosition("195");
|
||||
}
|
||||
|
||||
// 检查定位状态,若为0,则设置故障位置为"196"
|
||||
if (code.getPositionStatus() == 0) {
|
||||
troubleCode.setTroublePosition("196");
|
||||
}
|
||||
|
||||
// 检查电子驻车系统(EAS)状态,若为0,则设置故障位置为"197"
|
||||
if (code.getEasStatus() == 0) {
|
||||
troubleCode.setTroublePosition("197");
|
||||
}
|
||||
|
||||
// 检查PTC(正温度系数热敏电阻)状态,若为0,则设置故障位置为"198"
|
||||
if (code.getPtcStatus() == 0) {
|
||||
troubleCode.setTroublePosition("198");
|
||||
}
|
||||
|
||||
// 检查电动助力转向系统(EPS)状态,若为0,则设置故障位置为"199"
|
||||
if (code.getEpsStatus() == 0) {
|
||||
troubleCode.setTroublePosition("199");
|
||||
}
|
||||
|
||||
// 检查防抱死制动系统(ABS)状态,若为0,则设置故障位置为"200"
|
||||
if (code.getAbsStatus() == 0) {
|
||||
troubleCode.setTroublePosition("200");
|
||||
}
|
||||
|
||||
// 检查主控制器(MCU)状态,若为0,则设置故障位置为"201"
|
||||
if (code.getMcuStatus() == 0) {
|
||||
troubleCode.setTroublePosition("201");
|
||||
}
|
||||
|
||||
// 检查加热状态,若为0,则设置故障位置为"202"
|
||||
if (code.getHeatingStatus() == 0) {
|
||||
troubleCode.setTroublePosition("202");
|
||||
}
|
||||
|
||||
// 检查电池状态,若为0,则设置故障位置为"203"
|
||||
if (code.getBatteryStatus() == 0) {
|
||||
troubleCode.setTroublePosition("203");
|
||||
}
|
||||
|
||||
// 检查电池绝缘状态,若为0,则设置故障位置为"204"
|
||||
if (code.getBatteryInsulationStatus() == 0) {
|
||||
troubleCode.setTroublePosition("204");
|
||||
}
|
||||
|
||||
// 检查直流-直流转换器(DC/DC)状态,若为0,则设置故障位置为"205"
|
||||
if (code.getDcdcStatus() == 0) {
|
||||
troubleCode.setTroublePosition("205");
|
||||
}
|
||||
|
||||
// 检查充电机(CHG)状态,若为0,则设置故障位置为"206"
|
||||
if (code.getChgStatus() == 0) {
|
||||
troubleCode.setTroublePosition("206");
|
||||
}
|
||||
remoteTroubleService.newFaultData(troubleCode);
|
||||
redisTemplate.opsForSet().add(code.getVin(), code.getVin()+":"+code);
|
||||
long expireTime = 30;
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.couplet.analyze.msg.service.impl.ElectronicFence;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.common.domain.Fence;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/6
|
||||
* @Description:
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class ElectronicFenceJuge {
|
||||
|
||||
@Autowired
|
||||
public static StringRedisTemplate redisTemplate;
|
||||
public static boolean isJudge() {
|
||||
String fenceKey="fence";
|
||||
if (redisTemplate.hasKey(fenceKey)) {
|
||||
|
||||
ArrayList<Fence> fences = new ArrayList<>();
|
||||
List<String> fence = redisTemplate.opsForList().range(fenceKey, 0, -1);
|
||||
for (String s : fence) {
|
||||
Fence parseObject = JSON.parseObject(s, Fence.class);
|
||||
fences.add(parseObject);
|
||||
}
|
||||
log.info("更改的电子围栏内容是:"+fence);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,12 +1,18 @@
|
|||
package com.couplet.analyze.msg.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.domain.Fence;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
|
@ -28,11 +34,51 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
|||
public void incident(CoupletMsgData coupletMsgData) {
|
||||
|
||||
log.info("电子围栏事件开始.......");
|
||||
String fenceKey="fence";
|
||||
|
||||
if (redisTemplate.hasKey("fence")) {
|
||||
ArrayList<Fence> fences = new ArrayList<>();
|
||||
if (redisTemplate.hasKey(fenceKey)) {
|
||||
log.info("电子围栏事件redis存在.......");
|
||||
String s = redisTemplate.opsForValue().get("fence");
|
||||
log.info("更改的电子围栏内容是:"+s);
|
||||
List<String> fence = redisTemplate.opsForList().range(fenceKey, 0, -1);
|
||||
for (String s : fence) {
|
||||
Fence parseObject = JSON.parseObject(s, Fence.class);
|
||||
fences.add(parseObject);
|
||||
}
|
||||
// jingdu;
|
||||
// longitude;
|
||||
// weidu;
|
||||
// latitude;
|
||||
for (Fence data : fences) {
|
||||
|
||||
String fenceLongitudeLatitude = data.getFenceLongitudeLatitude();
|
||||
/**
|
||||
* 先通过;号切割
|
||||
*/
|
||||
String[] split = fenceLongitudeLatitude.split(";");
|
||||
for (String s : split) {
|
||||
|
||||
String[] strings = s.split(",");
|
||||
if (strings.length == 2){
|
||||
Double trim = Double.valueOf(strings[0].trim());
|
||||
Double trim1 = Double.valueOf(strings[1].trim());
|
||||
boolean a = trim<= Double.valueOf(coupletMsgData.getLongitude());
|
||||
boolean b = trim1 < Double.valueOf(coupletMsgData.getLatitude());
|
||||
if (a && b){
|
||||
log.info("电子围栏报警啦!!!!您的车驶出范围啦!!!");
|
||||
}else {
|
||||
log.info("电子围栏报警啦!!!!正常啦!!!");
|
||||
}
|
||||
log.info("经度是:"+trim);
|
||||
log.info("纬度是:"+trim1);
|
||||
}else {
|
||||
throw new RuntimeException("电子围栏经纬度格式错误"+strings);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
log.info("更改的电子围栏内容是:"+fence);
|
||||
log.info("电子围栏事件结束.......");
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
log.info("实时数据事件开始.....");
|
||||
|
||||
if (RealTimeJudge.isJudge(coupletMsgData.getVin())){
|
||||
log.info("[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
}
|
||||
log.info("[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
|
@ -18,6 +19,26 @@ import java.util.List;
|
|||
@Slf4j
|
||||
public class MsgUtils {
|
||||
|
||||
public static String generateGTA() {
|
||||
// 生成四位以"GTA"开头的字符串
|
||||
String prefix = "GTA";
|
||||
// 生成三位随机数字
|
||||
String randomNumber = generateRandomNumber(4);
|
||||
// 拼接字符串
|
||||
return prefix + randomNumber;
|
||||
}
|
||||
|
||||
public static String generateRandomNumber(int length) {
|
||||
// 生成随机数
|
||||
Random random = new Random();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; i++) {
|
||||
// 生成0到9之间的随机数字,并转换为字符串
|
||||
sb.append(random.nextInt(10));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将16进制字符串转换为ASCII字符串
|
||||
* @param s 16进制字符串
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
`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`,
|
||||
`operating_status`, `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`)
|
||||
|
|
|
@ -30,8 +30,4 @@ public class OnLineVehicleController {
|
|||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -184,11 +184,10 @@ public class VehicleController extends BaseController {
|
|||
@GetMapping("onOrOutLineByVIN")
|
||||
public Integer onOrOutLineByVIN(@RequestParam("params") String params) {
|
||||
String[] split = params.split(",");
|
||||
|
||||
|
||||
return vehicleService.onOrOutLineByVIN(split[0], Integer.parseInt(split[1]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.core.domain.Result;
|
|||
import com.couplet.common.domain.CoupletVehicleData;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -31,6 +32,8 @@ public class VehicleDetectionController {
|
|||
private VehicleDetectionService vehicleDetectionService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
private final String REDIS_LIST_KEY = "coupletMsgData";
|
||||
/*
|
||||
* @param :
|
||||
|
@ -65,7 +68,11 @@ public class VehicleDetectionController {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("realData")
|
||||
public Result<List<CoupletVehicleData>> realData(){
|
||||
List<CoupletVehicleData> list = redisService.getList();
|
||||
Result<List<CoupletVehicleData>> success = Result.success(list);
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,12 +29,4 @@ public interface SysTroubleMapper extends BaseMapper<CoupletTroubleCode> {
|
|||
void newFaultData(CoupletTroubleCode code);
|
||||
|
||||
void cleanTroubleCode();
|
||||
|
||||
int insertMsgResq(CoupletTroubleCode coupletTroubleCode);
|
||||
|
||||
|
||||
|
||||
// int addTrouble(TroubleAddReq troubleAddReq);
|
||||
|
||||
// int updateTrouble(TroubleUpdReq troubleUpdReq);
|
||||
}
|
||||
|
|
|
@ -16,11 +16,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -14,17 +14,17 @@
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectTroubleVo">
|
||||
select * from couplet_trouble_code
|
||||
select t.*,f.trouble_fault_type,f.trouble_fault_tag from couplet_trouble_code t
|
||||
LEFT JOIN couplet_trouble_fault f on t.trouble_position = f.trouble_fault_position
|
||||
</sql>
|
||||
<insert id="newFaultData">
|
||||
INSERT INTO `couplet-cloud`.`couplet_trouble_code`
|
||||
(`trouble_vin`, `trouble_tag`,
|
||||
`trouble_start_time`)
|
||||
(`trouble_code`,`trouble_vin`,`trouble_position`,`trouble_start_time`)
|
||||
VALUES
|
||||
(#{troubleVin}, #{troubleTag}, #{troubleStartTime})
|
||||
(#{troubleCode},#{troubleVin}, #{troublePosition},#{troubleStartTime})
|
||||
</insert>
|
||||
<update id="cleanTroubleCode">
|
||||
|
||||
truncate table couplet_trouble_code
|
||||
</update>
|
||||
|
||||
<select id="selectTroubleList" parameterType="com.couplet.business.server.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
|
||||
|
|
|
@ -28,23 +28,26 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
|||
public String queueName;
|
||||
//队列名
|
||||
public static final String finByVinQueueName="finByVinQueueName";
|
||||
public static final String FENCE_QUEUE ="fenceQueue";
|
||||
//交换机
|
||||
public static final String VinExchangeName="vinExchangeName";
|
||||
public static final String FENCE_EXCHANGE="fenceExchange";
|
||||
|
||||
//路由键
|
||||
public static final String VinRoutingKey="vinRoutingKey";
|
||||
public static final String FENCE_ROUTINGKEY="fenceRoutingKey";
|
||||
//队列名
|
||||
public static final String FENCE_QUEUE ="fenceQueue";
|
||||
|
||||
|
||||
//交换机
|
||||
@Value("exchangeName")
|
||||
public String exchangeName;
|
||||
public static final String FENCE_EXCHANGE="fenceExchange";
|
||||
|
||||
//路由键
|
||||
@Value("routingKey")
|
||||
public String routingKey;
|
||||
//路由键
|
||||
public static final String FENCE_ROUTINGKEY="fenceRoutingKey";
|
||||
|
||||
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
|
|
|
@ -75,7 +75,8 @@ public class MqController {
|
|||
realTimeDataRequest.setVin(vin);
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
realTimeDataRequest.setUserId(userId);
|
||||
rabbitTemplate.convertAndSend(RabbitMQConfig.VinExchangeName, RabbitMQConfig.VinRoutingKey, realTimeDataRequest, message -> {
|
||||
rabbitTemplate.convertAndSend(RabbitMQConfig.VinExchangeName, RabbitMQConfig.VinRoutingKey, realTimeDataRequest,
|
||||
message -> {
|
||||
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
||||
return message;
|
||||
}, new CorrelationData(IdUtils.randomUUID())
|
||||
|
|
|
@ -14,6 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
public interface RemoteFenceService {
|
||||
|
||||
@PostMapping("/mq/fenceQueue")
|
||||
public void fenceQueue(@RequestBody FenceUpdateRequest fenceUpdateRequest);
|
||||
public void fenceQueue(@RequestBody FenceUpdateRequest teRequest);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,12 +18,9 @@ import static com.couplet.common.core.domain.Result.error;
|
|||
@Component
|
||||
public class RemoteFenceFallbackFactory implements FallbackFactory<RemoteFenceService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteFenceFallbackFactory.class);
|
||||
|
||||
|
||||
@Override
|
||||
public RemoteFenceService create(Throwable cause) {
|
||||
return new RemoteFenceService() {
|
||||
|
||||
@Override
|
||||
public void fenceQueue(FenceUpdateRequest fenceUpdateRequest) {
|
||||
error("调用失败...."+cause.getMessage());
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue