Compare commits
No commits in common. "24b8fe40858803937e2886c168c138439d5758af" and "b8a7658ce56bc05683266abbabbe4597f3d56f9e" have entirely different histories.
24b8fe4085
...
b8a7658ce5
|
@ -33,5 +33,9 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-core</artifactId>
|
<artifactId>cloud-common-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package com.muyu.cloud.common.many.datasource;
|
package com.muyu.cloud.common.many.datasource;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||||
|
@ -21,10 +22,12 @@ import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: DongZeLiang
|
* @Author: DongZeLiang
|
||||||
* @date: 2024/6/3
|
* @date: 2024/6/3
|
||||||
|
@ -64,6 +67,7 @@ public class ManyDataSource implements ApplicationRunner{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private List<EntInfo> dataPrimarySourceInfoList(){
|
// private List<EntInfo> dataPrimarySourceInfoList(){
|
||||||
// List<EntInfo> list = new ArrayList<>();
|
// List<EntInfo> list = new ArrayList<>();
|
||||||
// list.add(
|
// list.add(
|
||||||
|
@ -75,6 +79,7 @@ public class ManyDataSource implements ApplicationRunner{
|
||||||
// );
|
// );
|
||||||
// return list;
|
// return list;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
||||||
// 企业列表 企业CODE,端口,IP
|
// 企业列表 企业CODE,端口,IP
|
||||||
|
@ -93,6 +98,7 @@ public class ManyDataSource implements ApplicationRunner{
|
||||||
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||||
return dynamicDataSource;
|
return dynamicDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) {
|
public void run(ApplicationArguments args) {
|
||||||
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
||||||
|
|
|
@ -114,18 +114,6 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-rabbit</artifactId>
|
<artifactId>cloud-common-rabbit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu.common</groupId>
|
|
||||||
<artifactId>saas-common</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>saas-cache</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.muyu.event.consumer;
|
package com.muyu.event.consumer;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.muyu.event.basic.EventPublisher;
|
import com.muyu.event.basic.EventPublisher;
|
||||||
import com.muyu.event.service.IncidentService;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
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;
|
||||||
|
@ -9,10 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.bouncycastle.asn1.x500.style.RFC4519Style.l;
|
import static org.bouncycastle.asn1.x500.style.RFC4519Style.l;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka监听
|
* kafka监听
|
||||||
* @author 刘武
|
* @author 刘武
|
||||||
|
@ -26,18 +29,16 @@ public class MessageConsumer implements ApplicationRunner {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public KafkaConsumer consumer;
|
public KafkaConsumer consumer;
|
||||||
|
@Autowired
|
||||||
private EventPublisher eventPublisher;
|
private EventPublisher eventPublisher;
|
||||||
|
|
||||||
private final String topic="kafka-topic";
|
private final String topic="four_car";
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IncidentService incidentService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
List<String> list = Collections.singletonList(topic);
|
List<String> list = Collections.singletonList(topic);
|
||||||
consumer.subscribe(list);
|
consumer.subscribe(list);
|
||||||
|
|
||||||
while (true){
|
while (true){
|
||||||
ConsumerRecords<String,String> consumerRecords = consumer.poll(Duration.ofMillis(100));
|
ConsumerRecords<String,String> consumerRecords = consumer.poll(Duration.ofMillis(100));
|
||||||
consumerRecords.forEach(record -> {
|
consumerRecords.forEach(record -> {
|
||||||
|
@ -45,12 +46,6 @@ public class MessageConsumer implements ApplicationRunner {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(value);
|
JSONObject jsonObject = JSONObject.parseObject(value);
|
||||||
log.info("value:{}",value);
|
log.info("value:{}",value);
|
||||||
eventPublisher.publishEvent(jsonObject);
|
eventPublisher.publishEvent(jsonObject);
|
||||||
try {
|
|
||||||
incidentService.warnEventProcess(jsonObject);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package com.muyu.event.listener;
|
package com.muyu.event.listener;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.muyu.event.basic.EventCustom;
|
import com.muyu.event.basic.EventCustom;
|
||||||
import com.muyu.event.basic.EventListener;
|
import com.muyu.event.basic.EventListener;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加数据库事件
|
* 添加数据库事件
|
||||||
* @program: cloud-server
|
* @program: cloud-server
|
||||||
|
@ -25,6 +29,9 @@ public class AddDatabaseListener implements EventListener {
|
||||||
values.add((String) value);
|
values.add((String) value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.event.service;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author liuxinyue
|
|
||||||
* @Package:com.muyu.event.service
|
|
||||||
* @name:IncidentService
|
|
||||||
* @Date:2024/10/9 15:02
|
|
||||||
*/
|
|
||||||
public interface IncidentService {
|
|
||||||
|
|
||||||
void warnEventProcess(JSONObject jsonObject) throws Exception;
|
|
||||||
|
|
||||||
void eventAlarmProcessing(JSONObject jsonObject) throws Exception;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,178 +0,0 @@
|
||||||
package com.muyu.event.service.impl;
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.muyu.cache.*;
|
|
||||||
import com.muyu.common.domain.MessageTemplateType;
|
|
||||||
import com.muyu.common.domain.SysCar;
|
|
||||||
import com.muyu.common.domain.SysCarFault;
|
|
||||||
import com.muyu.common.domain.resp.SysCarVo;
|
|
||||||
import com.muyu.common.domain.resp.WarnRuleResp;
|
|
||||||
import com.muyu.common.domain.resp.WarnStrategyResp;
|
|
||||||
import com.muyu.event.consumer.MessageConsumer;
|
|
||||||
import com.muyu.event.service.IncidentService;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecords;
|
|
||||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
/**
|
|
||||||
* @author liuxinyue
|
|
||||||
* @Package:com.muyu.event.service.impl
|
|
||||||
* @name:IncidentServiceImpl
|
|
||||||
* @Date:2024/10/9 15:02
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@Service
|
|
||||||
public class IncidentServiceImpl implements IncidentService {
|
|
||||||
|
|
||||||
private static int DURATION_SECONDS = 5;
|
|
||||||
private static List<JSONObject> receivedStrings = new ArrayList<>();
|
|
||||||
private static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
|
||||||
private static int elapsedSeconds = 0;
|
|
||||||
private static String file="elapsed";
|
|
||||||
private static List<MessageTemplateType> messageTemplateTypes=null;
|
|
||||||
private static Long msgTypeId=null;
|
|
||||||
//滑窗时间
|
|
||||||
private static Long slideTime=null;
|
|
||||||
//增长率
|
|
||||||
private static Long slideFrequency=null;
|
|
||||||
//预警策略
|
|
||||||
@Resource
|
|
||||||
private WarnStrategyCacheService warnStrategyCacheService;
|
|
||||||
//车辆
|
|
||||||
@Resource
|
|
||||||
private SysCarCacheService sysCarCacheService;
|
|
||||||
//预警规则
|
|
||||||
@Resource
|
|
||||||
private WarnRuleCacheService warnRuleCacheService;
|
|
||||||
//报文模版
|
|
||||||
@Resource
|
|
||||||
private MessageTemplateTypeCacheService messageTemplateTypeCacheService;
|
|
||||||
//kafka的主题名称
|
|
||||||
private final String topic="kafka-topic";
|
|
||||||
@Autowired
|
|
||||||
private SysCarFaultCacheService sysCarFaultCacheService;
|
|
||||||
@Override
|
|
||||||
public void warnEventProcess(JSONObject jsonObject) throws Exception {
|
|
||||||
receivedStrings.add(jsonObject);
|
|
||||||
//协议解析:每秒穿过来一个JSONObject jsonObject; 添加进receivedStrings
|
|
||||||
//根据这个车辆VIN查询出他对应的车辆类型
|
|
||||||
String carVin=null;
|
|
||||||
//报文模版的ID
|
|
||||||
Integer templateId=null;
|
|
||||||
//取出这辆车的carVin
|
|
||||||
for (JSONObject receivedString : receivedStrings) {
|
|
||||||
carVin = (String) receivedString.get("carVin");
|
|
||||||
}
|
|
||||||
//这辆车的信息
|
|
||||||
SysCar carByVin = null;
|
|
||||||
List<SysCarVo> carVoList = sysCarCacheService.get(sysCarCacheService.keyPre());
|
|
||||||
Map<String, SysCarVo> carMap = carVoList.stream()
|
|
||||||
.collect(Collectors.toMap(SysCarVo::getCarVin, Function.identity()));
|
|
||||||
//获取到了这个车辆的信息
|
|
||||||
carByVin = carMap.get(carVin);
|
|
||||||
//获取到这辆车绑定的报文模版
|
|
||||||
templateId=carByVin.getTemplateId();
|
|
||||||
//这个是这辆车对应的所有策略
|
|
||||||
List<WarnStrategyResp> carWithWarnStrategyList=null;
|
|
||||||
List<WarnStrategyResp> warnStrategyResps = warnStrategyCacheService.get(warnStrategyCacheService.keyPre());
|
|
||||||
for (WarnStrategyResp warnStrategyResp : warnStrategyResps) {
|
|
||||||
//策略中有绑定的车辆ID
|
|
||||||
if(warnStrategyResp.getCarTypeId()==carByVin.getCarTypeId()){
|
|
||||||
carWithWarnStrategyList.add(warnStrategyResp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//该车对应的所有预警规则
|
|
||||||
List<WarnRuleResp> warnRuleResp=null;
|
|
||||||
List<WarnRuleResp> warnRuleResps = warnRuleCacheService.get(warnRuleCacheService.keyPre());
|
|
||||||
for (WarnStrategyResp warnStrategyResp : carWithWarnStrategyList) {
|
|
||||||
for (WarnRuleResp ruleResp : warnRuleResps) {
|
|
||||||
if(warnStrategyResp.getId().equals(ruleResp.getStrategyId())){
|
|
||||||
warnRuleResp.add(ruleResp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//报文模版
|
|
||||||
messageTemplateTypes = messageTemplateTypeCacheService.get(messageTemplateTypeCacheService.keyPre());
|
|
||||||
for (WarnRuleResp ruleResp : warnRuleResp) {
|
|
||||||
//每一个规则他绑定了报文模版里面对应的一个配置 比如:电池,或者车速
|
|
||||||
msgTypeId = ruleResp.getMsgTypeId();
|
|
||||||
//将规则中对应的滑窗时间赋值为DURATION_SECONDS
|
|
||||||
DURATION_SECONDS = Math.toIntExact(ruleResp.getSlideTime());
|
|
||||||
slideFrequency = ruleResp.getSlideFrequency();
|
|
||||||
}
|
|
||||||
// 定义一个任务,每秒执行一次
|
|
||||||
Runnable task = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// 清理超过的数据
|
|
||||||
cleanUpOldStrings();
|
|
||||||
// 检查超速条件
|
|
||||||
checkForSpeeding();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// 每隔1秒执行一次任务
|
|
||||||
scheduler.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
// 清理超过60秒的数据
|
|
||||||
private static void cleanUpOldStrings() {
|
|
||||||
long currentTime = System.currentTimeMillis();
|
|
||||||
receivedStrings.removeIf(jsonObject ->
|
|
||||||
currentTime - jsonObject.getLong("time") > TimeUnit.SECONDS.toMillis(DURATION_SECONDS)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// 检查是否有超速情况
|
|
||||||
private static void checkForSpeeding() {
|
|
||||||
if (receivedStrings.size() < 2) return; // 如果数据不足,直接返回
|
|
||||||
for (int i = 0; i < receivedStrings.size(); i++) {
|
|
||||||
JSONObject current = receivedStrings.get(i);
|
|
||||||
JSONObject next = receivedStrings.get(i + 1);
|
|
||||||
for (MessageTemplateType messageTemplateType : messageTemplateTypes) {
|
|
||||||
if(messageTemplateType.getMessageTemplateTypeId().equals(msgTypeId)){
|
|
||||||
Short currentElapsed = current.getShort(messageTemplateType.getMessageField());
|
|
||||||
Short nextElapsed = next.getShort(messageTemplateType.getMessageField());
|
|
||||||
if (nextElapsed > currentElapsed + slideFrequency) {
|
|
||||||
log.info("出错啦,出错啦,您的"+messageTemplateType.getMessageField()+"不正常,请检查!!!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void eventAlarmProcessing(JSONObject jsonObject) throws Exception {
|
|
||||||
String carVin = (String) jsonObject.get("carVin");
|
|
||||||
//车辆缓存配置
|
|
||||||
List<SysCarVo> carVoList = sysCarCacheService.get(sysCarCacheService.keyPre());
|
|
||||||
//这辆车的信息
|
|
||||||
SysCar carByVin = null;
|
|
||||||
Map<String, SysCarVo> carMap = carVoList.stream()
|
|
||||||
.collect(Collectors.toMap(SysCarVo::getCarVin, Function.identity()));
|
|
||||||
//获取到了这个车辆的信息
|
|
||||||
carByVin = carMap.get(carVin);
|
|
||||||
Long carTypeId = carByVin.getCarTypeId();
|
|
||||||
//车辆绑定的报警规则
|
|
||||||
List<SysCarFault> sysCarFaults = sysCarFaultCacheService.get(sysCarFaultCacheService.keyPre());
|
|
||||||
//车辆的所有报警规则都重新存储在sysCarFaultList里面
|
|
||||||
List<SysCarFault> sysCarFaultList=null;
|
|
||||||
SysCar finalCarByVin = carByVin;
|
|
||||||
sysCarFaults.forEach(sysCarFault -> {
|
|
||||||
if(sysCarFault.getCarTypeId().equals(carTypeId)){
|
|
||||||
sysCarFaultList.add(sysCarFault);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//报文模版
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.53.251:8848
|
addr: 47.101.53.251:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: lxy
|
namespace: yzl
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.53.251:8848
|
addr: 47.101.53.251:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: lxy
|
namespace: yzl
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 47.101.53.251:8848
|
addr: 47.101.53.251:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: lxy
|
namespace: yzl
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -104,6 +104,7 @@ public class MqttConfigure {
|
||||||
me.printStackTrace();
|
me.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject messageParsing(String templateMessage) {
|
public JSONObject messageParsing(String templateMessage) {
|
||||||
//给一个JSON对象
|
//给一个JSON对象
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
@ -160,6 +161,7 @@ public class MqttConfigure {
|
||||||
log.info("发送kafka成功");
|
log.info("发送kafka成功");
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
//kafka发送消息
|
//kafka发送消息
|
||||||
public void sendKafka(JSONObject jsonObject){
|
public void sendKafka(JSONObject jsonObject){
|
||||||
ProducerRecord<String, String> stringStringProducerRecord = new ProducerRecord<>("four_car", jsonObject.toString());
|
ProducerRecord<String, String> stringStringProducerRecord = new ProducerRecord<>("four_car", jsonObject.toString());
|
||||||
|
|
|
@ -50,7 +50,6 @@ public class test {
|
||||||
//报文模版
|
//报文模版
|
||||||
@Resource
|
@Resource
|
||||||
private MessageTemplateTypeCacheService messageTemplateTypeCacheService;
|
private MessageTemplateTypeCacheService messageTemplateTypeCacheService;
|
||||||
|
|
||||||
public void main(String[] args) {
|
public void main(String[] args) {
|
||||||
//协议解析:每秒穿过来一个JSONObject jsonObject; 添加进receivedStrings
|
//协议解析:每秒穿过来一个JSONObject jsonObject; 添加进receivedStrings
|
||||||
//根据这个车辆VIN查询出他对应的车辆类型
|
//根据这个车辆VIN查询出他对应的车辆类型
|
||||||
|
@ -108,6 +107,7 @@ public class test {
|
||||||
// 每隔1秒执行一次任务
|
// 每隔1秒执行一次任务
|
||||||
scheduler.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
|
scheduler.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理超过60秒的数据
|
// 清理超过60秒的数据
|
||||||
private static void cleanUpOldStrings() {
|
private static void cleanUpOldStrings() {
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
|
@ -115,6 +115,7 @@ public class test {
|
||||||
currentTime - jsonObject.getLong("time") > TimeUnit.SECONDS.toMillis(DURATION_SECONDS)
|
currentTime - jsonObject.getLong("time") > TimeUnit.SECONDS.toMillis(DURATION_SECONDS)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否有超速情况
|
// 检查是否有超速情况
|
||||||
private static void checkForSpeeding() {
|
private static void checkForSpeeding() {
|
||||||
if (receivedStrings.size() < 2) return; // 如果数据不足,直接返回
|
if (receivedStrings.size() < 2) return; // 如果数据不足,直接返回
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 15277
|
|
||||||
|
|
||||||
# nacos线上地址
|
|
||||||
nacos:
|
|
||||||
addr: 47.101.53.251:8848
|
|
||||||
user-name: nacos
|
|
||||||
password: nacos
|
|
||||||
namespace: lxy
|
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
mvc:
|
|
||||||
pathmatch:
|
|
||||||
matching-strategy: ant_path_matcher
|
|
||||||
amqp:
|
|
||||||
deserialization:
|
|
||||||
trust:
|
|
||||||
all: true
|
|
||||||
main:
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: cloud-template
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${nacos.addr}
|
|
||||||
# nacos用户名
|
|
||||||
username: ${nacos.user-name}
|
|
||||||
# nacos密码
|
|
||||||
password: ${nacos.password}
|
|
||||||
# 命名空间
|
|
||||||
namespace: ${nacos.namespace}
|
|
||||||
config:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${nacos.addr}
|
|
||||||
# nacos用户名
|
|
||||||
username: ${nacos.user-name}
|
|
||||||
# nacos密码
|
|
||||||
password: ${nacos.password}
|
|
||||||
# 命名空间
|
|
||||||
namespace: ${nacos.namespace}
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
# 系统共享配置
|
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# 系统环境Config共享配置
|
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# xxl-job 配置文件
|
|
||||||
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.muyu.system.mapper: DEBUG
|
|
|
@ -91,13 +91,6 @@
|
||||||
<artifactId>cloud-common-rabbit</artifactId>
|
<artifactId>cloud-common-rabbit</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>redis.clients</groupId>
|
|
||||||
<artifactId>jedis</artifactId>
|
|
||||||
<version>5.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
|
|
@ -14,7 +14,6 @@ import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -31,12 +30,10 @@ public class ManageInstance implements ApplicationRunner {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 镜像ID
|
* 镜像ID
|
||||||
*/
|
*/
|
||||||
public static final String IMAGE_ID = "m-uf62k8zpy0ga35jnmkwt";
|
public static final String IMAGE_ID = "m-uf6ffgkry85fwu4znr6s";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实例类型
|
* 实例类型
|
||||||
|
@ -60,8 +57,6 @@ public class ManageInstance implements ApplicationRunner {
|
||||||
public static final String INSTANCE_CHARGE_TY = "PostPaid";
|
public static final String INSTANCE_CHARGE_TY = "PostPaid";
|
||||||
|
|
||||||
public static List<String> generateInstance() throws Exception {
|
public static List<String> generateInstance() throws Exception {
|
||||||
|
|
||||||
|
|
||||||
// 创建阿里云ECS客户端
|
// 创建阿里云ECS客户端
|
||||||
// 创建ECS客户端对象,用于后续调用ECS相关API
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
Client client = CreateClient.createClient();
|
Client client = CreateClient.createClient();
|
||||||
|
@ -123,18 +118,16 @@ public class ManageInstance implements ApplicationRunner {
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
List<String> list = generateInstance();
|
List<String> list = generateInstance();
|
||||||
ArrayList<String> ipList = new ArrayList<>();
|
|
||||||
log.info("创建实例成功");
|
log.info("创建实例成功");
|
||||||
log.info("正在加载实例");
|
log.info("正在加载实例");
|
||||||
Thread.sleep(30000);
|
Thread.sleep(30000);
|
||||||
List<InstanceInfo> instanceInfos = SelectInstance.selectInstance(list);
|
List<InstanceInfo> instanceInfos = SelectInstance.selectInstance(list);
|
||||||
log.info("实例信息查询成功");
|
log.info("实例信息查询成功");
|
||||||
for (InstanceInfo instanceInfo : instanceInfos) {
|
for (InstanceInfo instanceInfo : instanceInfos) {
|
||||||
ipList.add(instanceInfo.getIpAddress());
|
|
||||||
redisService.setCacheObject("FourInstanceIdKey:"+instanceInfo.getInstanceId(),instanceInfo);
|
redisService.setCacheObject("FourInstanceIdKey:"+instanceInfo.getInstanceId(),instanceInfo);
|
||||||
}
|
}
|
||||||
redisService.setCacheList("FourIpList",ipList);
|
|
||||||
System.out.println("实例信息:"+instanceInfos);
|
System.out.println("实例信息:"+instanceInfos);
|
||||||
|
log.info("实例信息:", JSONObject.toJSONString(instanceInfos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,17 +8,13 @@ import com.aliyun.tea.TeaException;
|
||||||
import com.aliyun.teaopenapi.models.Config;
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
import com.aliyun.teautil.Common;
|
import com.aliyun.teautil.Common;
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
|
||||||
import com.muyu.vehicle.utils.CreateClient;
|
import com.muyu.vehicle.utils.CreateClient;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import redis.clients.jedis.Jedis;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除实例信息
|
* 删除实例信息
|
||||||
|
@ -27,8 +23,6 @@ import java.util.Set;
|
||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class CloseInstance implements DisposableBean{
|
public class CloseInstance implements DisposableBean{
|
||||||
@Autowired
|
|
||||||
private RedisService redisService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>description</b> :
|
* <b>description</b> :
|
||||||
|
@ -39,7 +33,6 @@ public class CloseInstance implements DisposableBean{
|
||||||
*/
|
*/
|
||||||
public static void delInstance() throws Exception {
|
public static void delInstance() throws Exception {
|
||||||
|
|
||||||
|
|
||||||
// 创建ECS客户端对象,用于后续调用ECS相关API
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
Client client = CreateClient.createClient();
|
Client client = CreateClient.createClient();
|
||||||
|
|
||||||
|
@ -102,19 +95,6 @@ public class CloseInstance implements DisposableBean{
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
log.info("开始删除实例");
|
log.info("开始删除实例");
|
||||||
delInstance();
|
delInstance();
|
||||||
redisService.deleteObject("FourIpList");
|
|
||||||
// 连接到Redis服务器
|
|
||||||
Jedis jedis = new Jedis("47.116.173.119", 6379);
|
|
||||||
// 指定要删除的文件夹(命名空间)
|
|
||||||
String namespace = "FourInstanceIdKey:";
|
|
||||||
// 获取所有以namespace为前缀的键
|
|
||||||
Set<String> keys = jedis.keys(namespace + "*");
|
|
||||||
// 如果存在键,则删除它们
|
|
||||||
if (keys.size() > 0) {
|
|
||||||
jedis.del(keys.toArray(new String[0]));
|
|
||||||
}
|
|
||||||
// 关闭连接
|
|
||||||
jedis.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,15 +9,10 @@ import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建交换机
|
|
||||||
*/
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Component
|
@Component
|
||||||
public class CreateExchange implements ApplicationRunner {
|
public class CreateExchange implements ApplicationRunner {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConnectionFactory connectionFactory;
|
private ConnectionFactory connectionFactory;
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,7 @@ import java.util.List;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class SelectInstance {
|
public class SelectInstance {
|
||||||
|
|
||||||
public static List<InstanceInfo> selectInstance(List<String> instanceIds) throws Exception {
|
public static List<InstanceInfo> selectInstance(List<String> instanceIds) throws Exception {
|
||||||
|
|
||||||
// 创建ECS客户端对象,用于后续调用ECS相关API
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
Client client = CreateClient.createClient();
|
Client client = CreateClient.createClient();
|
||||||
ArrayList<InstanceInfo> instanceInfos = new ArrayList<>();// 实例基础信息
|
ArrayList<InstanceInfo> instanceInfos = new ArrayList<>();// 实例基础信息
|
||||||
|
@ -58,6 +56,7 @@ public class SelectInstance {
|
||||||
list.add(instanceInfo);
|
list.add(instanceInfo);
|
||||||
}
|
}
|
||||||
System.out.println("实例信息:"+list);
|
System.out.println("实例信息:"+list);
|
||||||
|
log.info("实例信息:",list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,10 @@ public class CarInstanceController {
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/receiveMsg")
|
@PostMapping("/receiveMsg")
|
||||||
public Result<MqttServerModel> receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
public Result receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
||||||
log.info("=======>"+vehicleConnectionReq);
|
log.info("=======>"+vehicleConnectionReq);
|
||||||
Result<MqttServerModel> connect = vehicleConnectService.getConnect(vehicleConnectionReq);
|
Result<MqttServerModel> connect = vehicleConnectService.getConnect(vehicleConnectionReq);
|
||||||
MqttServerModel data = connect.getData();
|
return Result.success(connect);
|
||||||
return Result.success(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,10 @@ package com.muyu.vehicle.mapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface VehicleConnectMapper extends BaseMapper<VehicleConnectionReq> {
|
public interface VehicleConnectMapper extends BaseMapper<VehicleConnectionReq> {
|
||||||
|
|
||||||
Integer insertVehicleConnection(VehicleConnectionReq vehicleConnectionReq);
|
VehicleConnectionReq selectByVehicleVin(String vin);
|
||||||
VehicleConnectionReq selectByVehicleVin(@Param("vin") String vin);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,6 @@ import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
|
||||||
public interface VehicleConnectService extends IService<VehicleConnectionReq> {
|
public interface VehicleConnectService extends IService<VehicleConnectionReq> {
|
||||||
|
|
||||||
Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq);
|
Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,31 +3,20 @@ package com.muyu.vehicle.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
|
||||||
import com.muyu.rabbitmq.consumer.RabbitMQConsumerUtil;
|
|
||||||
import com.muyu.rabbitmq.producer.RabbitMQProducerUtil;
|
|
||||||
import com.muyu.vehicle.domain.MqttServerModel;
|
import com.muyu.vehicle.domain.MqttServerModel;
|
||||||
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
import com.muyu.vehicle.mapper.VehicleConnectMapper;
|
import com.muyu.vehicle.mapper.VehicleConnectMapper;
|
||||||
import com.muyu.vehicle.service.VehicleConnectService;
|
import com.muyu.vehicle.service.VehicleConnectService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class VehicleConnectServiceImpl extends ServiceImpl<VehicleConnectMapper, VehicleConnectionReq> implements VehicleConnectService {
|
public class VehicleConnectServiceImpl extends ServiceImpl<VehicleConnectMapper, VehicleConnectionReq> implements VehicleConnectService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private VehicleConnectMapper vehicleConnectMapper;
|
private VehicleConnectMapper vehicleConnectMapper;
|
||||||
|
|
||||||
@Autowired private RedisService redisService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RabbitMQProducerUtil rabbitMQProducerUtil;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq) {
|
public Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq) {
|
||||||
log.info("车辆连接信息:{}", vehicleConnectionReq);
|
log.info("车辆连接信息:{}", vehicleConnectionReq);
|
||||||
|
@ -35,43 +24,13 @@ public class VehicleConnectServiceImpl extends ServiceImpl<VehicleConnectMapper,
|
||||||
vehicleConnectionReq.setPassword(vehicleConnectionReq.getVehicleVin() + vehicleConnectionReq.getTimestamp()
|
vehicleConnectionReq.setPassword(vehicleConnectionReq.getVehicleVin() + vehicleConnectionReq.getTimestamp()
|
||||||
+ vehicleConnectionReq.getNonce());
|
+ vehicleConnectionReq.getNonce());
|
||||||
|
|
||||||
|
VehicleConnectionReq connection = vehicleConnectMapper.selectByVehicleVin(vehicleConnectionReq.getVehicleVin());
|
||||||
Integer i = vehicleConnectMapper.insertVehicleConnection(vehicleConnectionReq);
|
if (connection==null){
|
||||||
if (i > 0) {
|
vehicleConnectMapper.insert(vehicleConnectionReq);
|
||||||
log.info("车辆预上线成功");
|
log.info("车辆预上线成功");
|
||||||
}else {
|
}else {
|
||||||
log.info("车辆预上线失败");
|
log.info("车辆已预上线成功,禁止重复");
|
||||||
}
|
|
||||||
rabbitMQProducerUtil.basicSendMessage("SendVin",vehicleConnectionReq.getVehicleVin());
|
|
||||||
//从redis获取信息
|
|
||||||
// 获取名为 "ipList" 的列表
|
|
||||||
List<String> ipList = redisService.getCacheList("FourIpList");
|
|
||||||
if (ipList.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前使用的索引位置
|
|
||||||
String indexStr = redisService.getCacheObject("currentIndex");
|
|
||||||
int index = indexStr!= null? Integer.parseInt(indexStr) : 0;
|
|
||||||
String selectedIp = ipList.get(index);
|
|
||||||
// 获取该 IP 的使用次数
|
|
||||||
String countStr = redisService.getCacheMapValue("ipCounts", selectedIp);
|
|
||||||
log.info("IP:[{}]车辆连接数:[{}]",selectedIp,countStr);
|
|
||||||
int count = countStr!= null? Integer.parseInt(countStr) : 0;
|
|
||||||
if (count < 6) {
|
|
||||||
// 使用次数加一
|
|
||||||
count++;
|
|
||||||
redisService.setCacheMapValue("ipCounts", selectedIp, String.valueOf(count));
|
|
||||||
// 更新索引
|
|
||||||
index = (index + 1) % ipList.size();
|
|
||||||
redisService.setCacheObject("currentIndex", String.valueOf(index));
|
|
||||||
MqttServerModel mqttServerModel = new MqttServerModel("tcp://" + selectedIp.substring(1, selectedIp.length() - 1) + ":1883", "vehicle");
|
|
||||||
return Result.success(mqttServerModel);
|
|
||||||
} else {
|
|
||||||
// 如果使用次数达到 6 次,跳过该 IP 并更新索引
|
|
||||||
index = (index + 1) % ipList.size();
|
|
||||||
redisService.setCacheObject("currentIndex", String.valueOf(index));
|
|
||||||
return getConnect(vehicleConnectionReq);
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
|
|
||||||
<mapper namespace="com.muyu.vehicle.mapper.VehicleConnectMapper">
|
|
||||||
<insert id="insertVehicleConnection">
|
|
||||||
INSERT INTO `four`.`vehicle_connection` ( `vehicle_vin`, `timestamp`, `username`, `nonce`, `password`) VALUES
|
|
||||||
(#{vehicleVin},#{timestamp},#{username},#{nonce},#{password})
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<select id="selectByVehicleVin" resultType="com.muyu.vehicle.domain.req.VehicleConnectionReq">
|
|
||||||
select * from vehicle_connection where vehicle_vin=#{vin}
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
|
@ -1,4 +1,5 @@
|
||||||
package com.muyu.common.domain;
|
package com.muyu.common.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
@ -7,6 +8,7 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆管理表
|
* 车辆管理表
|
||||||
* @author sx
|
* @author sx
|
||||||
|
@ -20,7 +22,6 @@ import lombok.NoArgsConstructor;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName(value = "sys_car",autoResultMap = true)
|
@TableName(value = "sys_car",autoResultMap = true)
|
||||||
public class SysCar extends BaseEntity {
|
public class SysCar extends BaseEntity {
|
||||||
|
|
||||||
@TableId(value = "id",type = IdType.AUTO)
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
private String carVin;
|
private String carVin;
|
||||||
|
|
Loading…
Reference in New Issue