Compare commits

..

No commits in common. "cf92c15bf5da21e4540ecc9718368ed5656fbb8a" and "d41ac8c2fd0035e34b75a2bf5b142ce65692aa94" have entirely different histories.

18 changed files with 214 additions and 425 deletions

View File

@ -65,9 +65,4 @@ public class CoupletTroubleCode {
*/ */
@Excel(name = "故障位置") @Excel(name = "故障位置")
private String troublePosition; private String troublePosition;
/**
*
*/
private Integer processingState;
} }

View File

@ -1,19 +0,0 @@
package com.couplet.remote;
import com.couplet.common.core.constant.ServiceNameConstants;
import com.couplet.common.core.domain.Result;
import com.couplet.common.domain.CoupletTroubleCode;
import com.couplet.remote.factory.RemoteRealTimeFallbackFactory;
import com.couplet.remote.factory.RemoteTroubleFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(contextId = "remoteRealTimeService" ,
value = ServiceNameConstants.BUSINESS_SERVICE,
fallbackFactory = RemoteRealTimeFallbackFactory.class
)
public interface RemoteRealTimeService {
}

View File

@ -1,21 +0,0 @@
package com.couplet.remote.factory;
import com.couplet.common.core.domain.Result;
import com.couplet.common.domain.CoupletTroubleCode;
import com.couplet.remote.RemoteRealTimeService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* @Author: LiJiaYao
* @Date: 2024/4/8
* @Description:
*/
@Component
public class RemoteRealTimeFallbackFactory implements FallbackFactory<RemoteRealTimeService> {
@Override
public RemoteRealTimeService create(Throwable cause) {
return null;
}
}

View File

@ -1,31 +1,27 @@
package com.couplet.analyze.common.contents; package com.couplet.analyze.common.contents;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
/** /**
* @Author: LiJiaYao * @Author: LiJiaYao
* @Date: 2024/4/7 * @Date: 2024/4/7
* @Description: * @Description:
*/ */
public class AnalyzeEventContents {
public interface AnalyzeEventContents {
/** /**
* *
*/ */
static final String BREAKDOWN = "breakdown"; String BREAKDOWN = "breakdown";
/** /**
* *
*/ */
static final String ELECTRONIC_FENCE = "electronic-fence"; String ELECTRONIC_FENCE = "electronic-fence";
/** /**
* *
*/ */
static final String REAL_TIME_DATA = "real-time-data"; String REAL_TIME_DATA = "real-time-data";
/** /**
* *
*/ */
static final String STORED_EVENT = "stored-event"; String STORED_EVENT = "stored-event";
} }

View File

@ -43,7 +43,8 @@ public class AnalyzeEventCache {
* *
* @return * @return
*/ */
public Set<String> getEventList(String vin){ public Set<Object> getEventList(String vin){
return redisService.getCacheSet(encode(vin)); return redisService.getCacheSet(encode(vin));
} }

View File

@ -182,32 +182,7 @@ public class RedisService {
} }
return setOperation; return setOperation;
} }
/**
* Set
*
* @param key
* @param setValue
*
* @return
*/
public <T> BoundSetOperations<String, T> setCacheSet (final String key, final T setValue) {
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
setOperation.add(setValue);
return setOperation;
}
/**
* Set
*
* @param key
* @param setValue
*
* @return
*/
public <T> void deleteSet(String key, String setValue) {
BoundSetOperations setOperations = redisTemplate.boundSetOps(key);
setOperations.remove(setValue);
}
/** /**
* set * set
* *
@ -219,8 +194,6 @@ public class RedisService {
return redisTemplate.opsForSet().members(key); return redisTemplate.opsForSet().members(key);
} }
/** /**
* Map * Map
* *

View File

@ -92,22 +92,10 @@
<groupId>com.couplet</groupId> <groupId>com.couplet</groupId>
<artifactId>couplet-common-event</artifactId> <artifactId>couplet-common-event</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.kafka</groupId> <groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId> <artifactId>spring-kafka</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.couplet</groupId>
<artifactId>couplet-common-business</artifactId>
</dependency>
<!-- RabbitMQ依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -54,142 +54,89 @@ public class CodeConsumer {
String faultCode = MsgUtils.generateGTA(); String faultCode = MsgUtils.generateGTA();
troubleCode.setTroubleCode(faultCode); troubleCode.setTroubleCode(faultCode);
switch (msgData.getVehicleStatus()) { // 检查车辆状态若为0则设置故障位置为"190"
case 0: if(msgData.getVehicleStatus() == 0) {
troubleCode.setTroublePosition("190"); troubleCode.setTroublePosition("190");
troubleCode.setProcessingState(0); }
break;
default: // 检查充电状态若为0则设置故障位置为"191"
switch (msgData.getChargingStatus()) { if (msgData.getChargingStatus() == 0) {
case 0: troubleCode.setTroublePosition("191");
troubleCode.setTroublePosition("191"); }
troubleCode.setProcessingState(0);
break; // 检查运行状态若为0则设置故障位置为"192"
default: if (msgData.getOperatingStatus() == 0) {
switch (msgData.getOperatingStatus()) { troubleCode.setTroublePosition("192");
case 0: }
troubleCode.setTroublePosition("192");
troubleCode.setProcessingState(0); // 检查电池荷电状态SOC, 若为0则设置故障位置为"193"
break; if (msgData.getSocStatus() == 0) {
default: troubleCode.setTroublePosition("193");
switch (msgData.getSocStatus()) { }
case 0:
troubleCode.setTroublePosition("193"); // 检查充电能源存储状态若为0则设置故障位置为"194"
troubleCode.setProcessingState(0); if (msgData.getChargingEnergyStorageStatus() == 0) {
break; troubleCode.setTroublePosition("194");
default: }
switch (msgData.getChargingEnergyStorageStatus()) {
case 0: // 检查驱动电机状态若为0则设置故障位置为"195"
troubleCode.setTroublePosition("194"); if (msgData.getDriveMotorStatus() == 0) {
troubleCode.setProcessingState(0); troubleCode.setTroublePosition("195");
break; }
default:
switch (msgData.getDriveMotorStatus()) { // 检查定位状态若为0则设置故障位置为"196"
case 0: if (msgData.getPositionStatus() == 0) {
troubleCode.setTroublePosition("195"); troubleCode.setTroublePosition("196");
troubleCode.setProcessingState(0); }
break;
default: // 检查电子驻车系统EAS状态若为0则设置故障位置为"197"
switch (msgData.getPositionStatus()) { if (msgData.getEasStatus() == 0) {
case 0: troubleCode.setTroublePosition("197");
troubleCode.setTroublePosition("196"); }
troubleCode.setProcessingState(0);
break; // 检查PTC正温度系数热敏电阻状态若为0则设置故障位置为"198"
default: if (msgData.getPtcStatus() == 0) {
switch (msgData.getEasStatus()) { troubleCode.setTroublePosition("198");
case 0: }
troubleCode.setTroublePosition("197");
troubleCode.setProcessingState(0); // 检查电动助力转向系统EPS状态若为0则设置故障位置为"199"
break; if (msgData.getEpsStatus() == 0) {
default: troubleCode.setTroublePosition("199");
switch (msgData.getPtcStatus()) { }
case 0:
troubleCode.setTroublePosition("198"); // 检查防抱死制动系统ABS状态若为0则设置故障位置为"200"
troubleCode.setProcessingState(0); if (msgData.getAbsStatus() == 0) {
break; troubleCode.setTroublePosition("200");
default: }
switch (msgData.getEpsStatus()) {
case 0: // 检查主控制器MCU状态若为0则设置故障位置为"201"
troubleCode.setTroublePosition("199"); if (msgData.getMcuStatus() == 0) {
troubleCode.setProcessingState(0); troubleCode.setTroublePosition("201");
break; }
default:
switch (msgData.getAbsStatus()) { // 检查加热状态若为0则设置故障位置为"202"
case 0: if (msgData.getHeatingStatus() == 0) {
troubleCode.setTroublePosition("200"); troubleCode.setTroublePosition("202");
troubleCode.setProcessingState(0); }
break;
default: // 检查电池状态若为0则设置故障位置为"203"
switch (msgData.getMcuStatus()) { if (msgData.getBatteryStatus() == 0) {
case 0: troubleCode.setTroublePosition("203");
troubleCode.setTroublePosition("201"); }
troubleCode.setProcessingState(0);
break; // 检查电池绝缘状态若为0则设置故障位置为"204"
default: if (msgData.getBatteryInsulationStatus() == 0) {
switch (msgData.getHeatingStatus()) { troubleCode.setTroublePosition("204");
case 0: }
troubleCode.setTroublePosition("202");
troubleCode.setProcessingState(0); // 检查直流-直流转换器DC/DC状态若为0则设置故障位置为"205"
break; if (msgData.getDcdcStatus() == 0) {
default: troubleCode.setTroublePosition("205");
switch (msgData.getBatteryStatus()) { }
case 0:
troubleCode.setTroublePosition("203"); // 检查充电机CHG状态若为0则设置故障位置为"206"
troubleCode.setProcessingState(0); if (msgData.getChgStatus() == 0) {
break; troubleCode.setTroublePosition("206");
default:
switch (msgData.getBatteryInsulationStatus()) {
case 0:
troubleCode.setTroublePosition("204");
troubleCode.setProcessingState(0);
break;
default:
switch (msgData.getDcdcStatus()) {
case 0:
troubleCode.setTroublePosition("205");
troubleCode.setProcessingState(0);
break;
default:
switch (msgData.getChgStatus()) {
case 0:
troubleCode.setTroublePosition("206");
troubleCode.setProcessingState(0);
break;
default:
// do nothing
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
} }
remoteTroubleService.newFaultData(troubleCode); remoteTroubleService.newFaultData(troubleCode);
}); });

View File

@ -2,9 +2,6 @@ package com.couplet.analyze.msg.mapper;
import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.domain.CoupletMsgData;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/** /**
* @Author: LiJiaYao * @Author: LiJiaYao
@ -23,6 +20,6 @@ public interface IncidentMapper {
* vin * vin
*/ */
// CoupletMsgData queryByIncident(RealTimeDataRequest realTimeDataRequest); // CoupletMsgData queryByIncident(RealTimeDataRequest realTimeDataRequest);
CoupletMsgData queryByIncident(@Param("vin") String vin, @Param("createTime") Date createTime); CoupletMsgData queryByIncident(String vin);
} }

View File

@ -1,5 +1,6 @@
package com.couplet.analyze.msg.model; package com.couplet.analyze.msg.model;
import com.couplet.analyze.common.contents.AnalyzeEventContents;
import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.domain.CoupletMsgData;
import com.couplet.analyze.msg.service.IncidentService; import com.couplet.analyze.msg.service.IncidentService;
import com.couplet.common.core.exception.vehicle.VehicleException; import com.couplet.common.core.exception.vehicle.VehicleException;
@ -8,7 +9,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
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;
@ -34,12 +34,19 @@ public class ModelsKafkaMessage {
private static final String TOPIC_NAME = "online"; private static final String TOPIC_NAME = "online";
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
@Autowired static ArrayList<String> strings = new ArrayList<>() {
private AnalyzeEventCache analyzeEventCache; {
add("breakdown");
add("electronic-fence");
add("real-time-data");
add("stored-event");
}
};
// @Autowired
// private RabbitTemplate rabbitTemplate;
/** /**
* *
*
* @return * @return
*/ */
@Scheduled(fixedDelay = 50) @Scheduled(fixedDelay = 50)
@ -57,6 +64,7 @@ public class ModelsKafkaMessage {
//订阅主题 //订阅主题
consumer.subscribe(Collections.singletonList(TOPIC_NAME)); consumer.subscribe(Collections.singletonList(TOPIC_NAME));
//持续消费消息 //持续消费消息
while (true) { while (true) {
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100)); ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
@ -66,12 +74,11 @@ public class ModelsKafkaMessage {
List<CoupletMsgData> coupletMsgDataList = sendMsg(str); List<CoupletMsgData> coupletMsgDataList = sendMsg(str);
for (CoupletMsgData msgData : coupletMsgDataList) { for (CoupletMsgData msgData : coupletMsgDataList) {
log.info("解析到车辆数据:{}", msgData); log.info("解析到车辆数据:{}", msgData);
Set<String> eventList = analyzeEventCache.getEventList(msgData.getVin()); for (String string : strings) {
for (String string : eventList) {
IncidentService incidentService = SpringUtils.getBean(string); IncidentService incidentService = SpringUtils.getBean(string);
incidentService.incident(msgData); incidentService.incident(msgData);
} }
// 发送消息 //发送消息
// rabbitTemplate.convertAndSend("couplet-code-queue",msgData,message -> { // rabbitTemplate.convertAndSend("couplet-code-queue",msgData,message -> {
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString()); // message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
// return message; // return message;
@ -80,7 +87,7 @@ public class ModelsKafkaMessage {
try { try {
sleep(100); sleep(100);
} catch (Exception e) { } catch (Exception e) {
throw new VehicleException("睡眠失败" + e); throw new VehicleException("睡眠失败"+e);
} }
} }
}); });

View File

@ -18,7 +18,6 @@ import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -104,7 +103,6 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
for (CoupletMsgData member : members) { for (CoupletMsgData member : members) {
Set<String> breakdownIds = redisService.getCacheSet(member.getVin()+":"+key); Set<String> breakdownIds = redisService.getCacheSet(member.getVin()+":"+key);
if (breakdownIds.size()==0){ if (breakdownIds.size()==0){
CompletableFuture.runAsync(() -> {
CoupletTroubleCode troubleCode = new CoupletTroubleCode(); CoupletTroubleCode troubleCode = new CoupletTroubleCode();
troubleCode.setTroubleStartTime(new Date()); troubleCode.setTroubleStartTime(new Date());
troubleCode.setTroubleVin(member.getVin()); troubleCode.setTroubleVin(member.getVin());
@ -112,149 +110,96 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
String faultCode = MsgUtils.generateGTA(); String faultCode = MsgUtils.generateGTA();
troubleCode.setTroubleCode(faultCode); troubleCode.setTroubleCode(faultCode);
switch (member.getVehicleStatus()) { // 检查车辆状态若为0则设置故障位置为"190"
case 0: if(member.getVehicleStatus() == 0) {
troubleCode.setTroublePosition("190"); troubleCode.setTroublePosition("190");
troubleCode.setProcessingState(0); }
break;
default: // 检查充电状态若为0则设置故障位置为"191"
switch (member.getChargingStatus()) { if (member.getChargingStatus() == 0) {
case 0: troubleCode.setTroublePosition("191");
troubleCode.setTroublePosition("191"); }
troubleCode.setProcessingState(0);
break; // 检查运行状态若为0则设置故障位置为"192"
default: if (member.getOperatingStatus() == 0) {
switch (member.getOperatingStatus()) { troubleCode.setTroublePosition("192");
case 0: }
troubleCode.setTroublePosition("192");
troubleCode.setProcessingState(0); // 检查电池荷电状态SOC, 若为0则设置故障位置为"193"
break; if (member.getSocStatus() == 0) {
default: troubleCode.setTroublePosition("193");
switch (member.getSocStatus()) { }
case 0:
troubleCode.setTroublePosition("193"); // 检查充电能源存储状态若为0则设置故障位置为"194"
troubleCode.setProcessingState(0); if (member.getChargingEnergyStorageStatus() == 0) {
break; troubleCode.setTroublePosition("194");
default: }
switch (member.getChargingEnergyStorageStatus()) {
case 0: // 检查驱动电机状态若为0则设置故障位置为"195"
troubleCode.setTroublePosition("194"); if (member.getDriveMotorStatus() == 0) {
troubleCode.setProcessingState(0); troubleCode.setTroublePosition("195");
break; }
default:
switch (member.getDriveMotorStatus()) { // 检查定位状态若为0则设置故障位置为"196"
case 0: if (member.getPositionStatus() == 0) {
troubleCode.setTroublePosition("195"); troubleCode.setTroublePosition("196");
troubleCode.setProcessingState(0); }
break;
default: // 检查电子驻车系统EAS状态若为0则设置故障位置为"197"
switch (member.getPositionStatus()) { if (member.getEasStatus() == 0) {
case 0: troubleCode.setTroublePosition("197");
troubleCode.setTroublePosition("196"); }
troubleCode.setProcessingState(0);
break; // 检查PTC正温度系数热敏电阻状态若为0则设置故障位置为"198"
default: if (member.getPtcStatus() == 0) {
switch (member.getEasStatus()) { troubleCode.setTroublePosition("198");
case 0: }
troubleCode.setTroublePosition("197");
troubleCode.setProcessingState(0); // 检查电动助力转向系统EPS状态若为0则设置故障位置为"199"
break; if (member.getEpsStatus() == 0) {
default: troubleCode.setTroublePosition("199");
switch (member.getPtcStatus()) { }
case 0:
troubleCode.setTroublePosition("198"); // 检查防抱死制动系统ABS状态若为0则设置故障位置为"200"
troubleCode.setProcessingState(0); if (member.getAbsStatus() == 0) {
break; troubleCode.setTroublePosition("200");
default: }
switch (member.getEpsStatus()) {
case 0: // 检查主控制器MCU状态若为0则设置故障位置为"201"
troubleCode.setTroublePosition("199"); if (member.getMcuStatus() == 0) {
troubleCode.setProcessingState(0); troubleCode.setTroublePosition("201");
break; }
default:
switch (member.getAbsStatus()) { // 检查加热状态若为0则设置故障位置为"202"
case 0: if (member.getHeatingStatus() == 0) {
troubleCode.setTroublePosition("200"); troubleCode.setTroublePosition("202");
troubleCode.setProcessingState(0); }
break;
default: // 检查电池状态若为0则设置故障位置为"203"
switch (member.getMcuStatus()) { if (member.getBatteryStatus() == 0) {
case 0: troubleCode.setTroublePosition("203");
troubleCode.setTroublePosition("201"); }
troubleCode.setProcessingState(0);
break; // 检查电池绝缘状态若为0则设置故障位置为"204"
default: if (member.getBatteryInsulationStatus() == 0) {
switch (member.getHeatingStatus()) { troubleCode.setTroublePosition("204");
case 0: }
troubleCode.setTroublePosition("202");
troubleCode.setProcessingState(0); // 检查直流-直流转换器DC/DC状态若为0则设置故障位置为"205"
break; if (member.getDcdcStatus() == 0) {
default: troubleCode.setTroublePosition("205");
switch (member.getBatteryStatus()) { }
case 0:
troubleCode.setTroublePosition("203"); // 检查充电机CHG状态若为0则设置故障位置为"206"
troubleCode.setProcessingState(0); if (member.getChgStatus() == 0) {
break; troubleCode.setTroublePosition("206");
default: }
switch (member.getBatteryInsulationStatus()) {
case 0:
troubleCode.setTroublePosition("204");
troubleCode.setProcessingState(0);
break;
default:
switch (member.getDcdcStatus()) {
case 0:
troubleCode.setTroublePosition("205");
troubleCode.setProcessingState(0);
break;
default:
switch (member.getChgStatus()) {
case 0:
troubleCode.setTroublePosition("206");
troubleCode.setProcessingState(0);
break;
default:
// do nothing
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
remoteTroubleService.newFaultData(troubleCode); remoteTroubleService.newFaultData(troubleCode);
});
redisService.setCacheSet(member.getVin()+":"+key, member.getVin()+":"+member); redisService.setCacheSet(member.getVin()+":"+key, member.getVin()+":"+member);
long expireTime = 30; long expireTime = 30;
redisService.expire(member.getVin()+":"+key, expireTime, TimeUnit.MINUTES); redisService.expire(member.getVin()+":"+key, expireTime, TimeUnit.MINUTES);
} }
} }
} }

View File

@ -4,17 +4,11 @@ import com.couplet.analyze.msg.domain.CoupletMsgData;
import com.couplet.analyze.msg.mapper.IncidentMapper; import com.couplet.analyze.msg.mapper.IncidentMapper;
import com.couplet.analyze.msg.service.IncidentService; import com.couplet.analyze.msg.service.IncidentService;
import com.couplet.analyze.msg.service.impl.realTimeData.RealTimeJudge; import com.couplet.analyze.msg.service.impl.realTimeData.RealTimeJudge;
import com.couplet.common.core.utils.StringUtils;
import com.couplet.common.domain.request.RealTimeDataRequest;
import com.couplet.common.redis.service.RedisService;
import com.couplet.remote.RemoteRealTimeService;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
/** /**
* @Author: LiJiaYao * @Author: LiJiaYao
* @Date: 2024/4/2 * @Date: 2024/4/2
@ -31,9 +25,7 @@ public class RealTimeDataServiceImpl implements IncidentService {
private IncidentMapper incidentMapper; private IncidentMapper incidentMapper;
@Autowired @Autowired
private RedisService redisService; private StringRedisTemplate redisTemplate;
@Autowired
private RemoteRealTimeService remoteRealTimeService;
/** /**
* *
@ -45,16 +37,7 @@ public class RealTimeDataServiceImpl implements IncidentService {
log.info("实时数据事件开始....."); log.info("实时数据事件开始.....");
RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin()); if (RealTimeJudge.isJudge(coupletMsgData.getVin())){
if (RealTimeJudge.addRealTime(cacheObject)) {
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
CoupletMsgData query = incidentMapper.queryByIncident(coupletMsgData.getVin(), new Date());
redisService.setCacheObject("vin:" + cacheObject.getVin(), query);
} else {
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
}
if (RealTimeJudge.isJudge(coupletMsgData.getVin())) {
log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin()); log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin());
} }
log.info("[{}]开始传输实时数据", coupletMsgData.getVin()); log.info("[{}]开始传输实时数据", coupletMsgData.getVin());
@ -65,7 +48,6 @@ public class RealTimeDataServiceImpl implements IncidentService {
/** /**
* *
*
* @return * @return
*/ */
@Override @Override

View File

@ -15,6 +15,7 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
@ -23,6 +24,7 @@ spring:
# 共享配置 # 共享配置
shared-configs: shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
rabbitmq: rabbitmq:

View File

@ -72,7 +72,7 @@
</insert> </insert>
<select id="queryByIncident" resultType="com.couplet.analyze.msg.domain.CoupletMsgData" <select id="queryByIncident" resultType="com.couplet.analyze.msg.domain.CoupletMsgData"
parameterType="com.couplet.common.domain.request.RealTimeDataRequest"> parameterType="com.couplet.common.domain.request.RealTimeDataRequest">
SELECT * FROM couplet_msg_data WHERE vin=#{vin} and create_time = #{createTime} SELECT * FROM couplet_msg_data WHERE vin =#{vin}
</select> </select>

View File

@ -25,21 +25,21 @@ public class ParsingMsg {
String hexStringWithoutSpaces = substring.replaceAll("\\s+", ""); String hexStringWithoutSpaces = substring.replaceAll("\\s+", "");
String asciiString = hexToString(hexStringWithoutSpaces); String asciiString = hexToString(hexStringWithoutSpaces);
System.out.println("16进制解析后的数据"+asciiString); System.out.println("16进制解析后的数据"+asciiString);
// //截取前17位 //截取前17位
// String substring1 = asciiString.substring(0, 17); String substring1 = asciiString.substring(0, 17);
// System.out.println("VIN"+substring1); System.out.println("VIN"+substring1);
// String substring2 = asciiString.substring(17, 30); String substring2 = asciiString.substring(17, 30);
// System.out.println("时间戳:"+substring2); System.out.println("时间戳:"+substring2);
// String substring3 = asciiString.substring(30, 40); String substring3 = asciiString.substring(30, 40);
// System.out.println("经度:" +substring3); System.out.println("经度:" +substring3);
// String substring4 = asciiString.substring(41, 50); String substring4 = asciiString.substring(41, 50);
// System.out.println("纬度:"+ substring4); System.out.println("纬度:"+ substring4);
// String substring5 = asciiString.substring(51, 56); String substring5 = asciiString.substring(51, 56);
// System.out.println("车速:"+ substring5); System.out.println("车速:"+ substring5);
// String substring6 = asciiString.substring(57, 67); String substring6 = asciiString.substring(57, 67);
// System.out.println("总里程:"+ substring6); System.out.println("总里程:"+ substring6);
// String substring7 = asciiString.substring(68, 73); String substring7 = asciiString.substring(68, 73);
// System.out.println("总电压:"+ substring7); System.out.println("总电压:"+ substring7);
String pattern = "(.{17})(.{10})(.{9})(.{8})(.{2})"; String pattern = "(.{17})(.{10})(.{9})(.{8})(.{2})";
Pattern compile = Pattern.compile(pattern); Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(asciiString); Matcher matcher = compile.matcher(asciiString);

View File

@ -16,11 +16,9 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置

View File

@ -8,9 +8,9 @@
<id property="troubleId" column="trouble_id"/> <id property="troubleId" column="trouble_id"/>
<result property="troubleCode" column="trouble_code"/> <result property="troubleCode" column="trouble_code"/>
<result property="troubleVin" column="trouble_vin"/> <result property="troubleVin" column="trouble_vin"/>
<result property="troubleTag" column="trouble_tag"/>
<result property="troubleStartTime" column="trouble_start_time"/> <result property="troubleStartTime" column="trouble_start_time"/>
<result property="troubleEndTime" column="trouble_end_time"/> <result property="troubleEndTime" column="trouble_end_time"/>
<result property="processingState" column="processing_state"/>
</resultMap> </resultMap>
<sql id="selectTroubleVo"> <sql id="selectTroubleVo">
@ -19,9 +19,9 @@
</sql> </sql>
<insert id="newFaultData"> <insert id="newFaultData">
INSERT INTO `couplet-cloud`.`couplet_trouble_code` INSERT INTO `couplet-cloud`.`couplet_trouble_code`
(`trouble_code`,`trouble_vin`,`trouble_position`,`trouble_start_time`,`processing_state`) (`trouble_code`,`trouble_vin`,`trouble_position`,`trouble_start_time`)
VALUES VALUES
(#{troubleCode},#{troubleVin}, #{troublePosition},#{troubleStartTime},#{processingState}) (#{troubleCode},#{troubleVin}, #{troublePosition},#{troubleStartTime})
</insert> </insert>
<update id="cleanTroubleCode"> <update id="cleanTroubleCode">
truncate table couplet_trouble_code truncate table couplet_trouble_code

View File

@ -15,11 +15,9 @@ spring:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 121.89.211.230:8848 server-addr: 121.89.211.230:8848
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置