故障解析
parent
0d79359080
commit
ffb033957a
|
@ -0,0 +1,14 @@
|
|||
package com.parseSystem.domain;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class FaultRecord {
|
||||
private Integer id;
|
||||
private String vin;
|
||||
private String breakdown;
|
||||
|
||||
|
||||
}
|
|
@ -3,25 +3,59 @@ package com.parseSystem.event.impl;
|
|||
import com.parseSystem.event.EventHandlerService;
|
||||
import com.parseSystem.event.VehicleEventService;
|
||||
import com.parseSystem.vehicle.VehicleData;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* 故障事件
|
||||
*
|
||||
* @author 冯凯
|
||||
* @version 1.0
|
||||
*
|
||||
* @date 2023/11/27 20:59
|
||||
*/
|
||||
@Service("faultEvent")
|
||||
public class FaultEvent extends EventHandlerService implements VehicleEventService {
|
||||
@Service ("faultEvent")
|
||||
@Log4j2
|
||||
public class FaultEvent extends EventHandlerService implements VehicleEventService {
|
||||
|
||||
/**
|
||||
* 故障事件执行逻辑
|
||||
* @param vehicleData
|
||||
*/
|
||||
@Override
|
||||
public void executeEvent(VehicleData vehicleData) {
|
||||
System.out.println("你好故障");
|
||||
}
|
||||
/**
|
||||
* 故障事件执行逻辑
|
||||
*
|
||||
* @param vehicleData
|
||||
*/
|
||||
@Override
|
||||
public void executeEvent (VehicleData vehicleData) {
|
||||
String vin = vehicleData.getVin ();
|
||||
Map<String, Integer> statusMap = new HashMap<> ();
|
||||
statusMap.put("车辆状态", vehicleData.getVehicleStatus());
|
||||
statusMap.put("充电状态", vehicleData.getChargingStatus());
|
||||
statusMap.put("运行状态", vehicleData.getOperatingStatus());
|
||||
statusMap.put("SOC", vehicleData.getSocStatus());
|
||||
statusMap.put("可充电储能装置工作状态", vehicleData.getChargingEnergyStorageStatus());
|
||||
statusMap.put("驱动电机状态", vehicleData.getDriveMotorStatus());
|
||||
statusMap.put("定位是否有效", vehicleData.getPositionStatus());
|
||||
statusMap.put("EAS(汽车防盗系统)状态", vehicleData.getEasStatus());
|
||||
statusMap.put("PTC(电动加热器)状态", vehicleData.getPtcStatus());
|
||||
statusMap.put("EPS(电动助力系统)状态", vehicleData.getEpsStatus());
|
||||
statusMap.put("ABS(防抱死)状态", vehicleData.getAbsStatus());
|
||||
statusMap.put("MCU(电机/逆变器)状态", vehicleData.getMcuStatus());
|
||||
statusMap.put("动力电池加热状态", vehicleData.getHeatingStatus());
|
||||
statusMap.put("动力电池当前状态", vehicleData.getBatteryStatus());
|
||||
statusMap.put("动力电池保温状态", vehicleData.getBatteryInsulationStatus());
|
||||
|
||||
for (Map.Entry<String, Integer> entry : statusMap.entrySet ()) {
|
||||
if (entry.getValue() == 1) {
|
||||
// 执行相应的逻辑
|
||||
log.info ("出现故障的地方是:{}",entry.getKey() );
|
||||
|
||||
|
||||
} else {
|
||||
// 执行其他逻辑
|
||||
System.out.println(entry.getKey() + "不为1");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Properties;
|
|||
/**
|
||||
* @author 冯凯
|
||||
* @version 1.0
|
||||
* @description:
|
||||
* @description: kafka消费者配置
|
||||
* @date 2023/11/25 15:37
|
||||
*/
|
||||
@Component
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Collections;
|
|||
/**
|
||||
* @author 冯凯
|
||||
* @version 1.0
|
||||
* @description:
|
||||
* @description: 消费者服务
|
||||
* @date 2023/11/25 15:52
|
||||
*/
|
||||
@Service
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Collections;
|
|||
|
||||
/**
|
||||
*
|
||||
* 监听车辆事件变更消费队列
|
||||
* 监听事件更改 Rabbit Mq
|
||||
* @author 冯凯
|
||||
* @version 1.0
|
||||
*
|
||||
|
@ -34,12 +34,14 @@ import java.util.Collections;
|
|||
@Log4j2
|
||||
public class ListenEventChangeRabbitMq {
|
||||
@Autowired
|
||||
private KafkaConsumer<String, String> consumer;
|
||||
@Autowired
|
||||
private StorageDateService storageDateService;
|
||||
private KafkaConsumer<String, String> consumer; // 自动装配一个String类型键和String类型值的Kafka消费者
|
||||
|
||||
@Autowired
|
||||
private EventHandlerService eventHandlerService;
|
||||
private StorageDateService storageDateService; // 自动装配StorageDateService对象
|
||||
|
||||
@Autowired
|
||||
private EventHandlerService eventHandlerService; // 自动装配EventHandlerService对象
|
||||
|
||||
|
||||
/**
|
||||
* RabbitMQ消费者,订阅"kafka_top"队列中的消息并处理
|
||||
|
|
Loading…
Reference in New Issue