Compare commits
35 Commits
cf286d48f9
...
2e940349ef
Author | SHA1 | Date |
---|---|---|
|
2e940349ef | |
|
88fdcfcbab | |
|
0aa33b36a0 | |
|
6e5e07af85 | |
|
d0e51b14b1 | |
|
59c16de298 | |
|
efa6861d2f | |
|
0ebf046e25 | |
|
2a0bd1178e | |
|
97994a0452 | |
|
cd5e46b650 | |
|
f6baa83c94 | |
|
2235097f05 | |
|
9e94cf5674 | |
|
ca505dc2c4 | |
|
c90845d508 | |
|
c1f24c8d03 | |
|
f45e6865d9 | |
|
abf186e99c | |
|
2186c58122 | |
|
e2897c4bb7 | |
|
9499d9738e | |
|
ae7294da6f | |
|
fe3ce0e291 | |
|
bd0214ccd9 | |
|
d01a3d5ce1 | |
|
705414778c | |
|
dd319599b6 | |
|
875391757f | |
|
b9c4334cb5 | |
|
87d104cf9b | |
|
a63bde6c84 | |
|
6ba71a95d4 | |
|
c5f0d52aa6 | |
|
e2fc097b14 |
|
@ -7,6 +7,7 @@ import com.muyu.auth.form.RegisterBody;
|
||||||
import com.muyu.auth.service.SysFirmService;
|
import com.muyu.auth.service.SysFirmService;
|
||||||
import com.muyu.auth.service.SysLoginService;
|
import com.muyu.auth.service.SysLoginService;
|
||||||
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
||||||
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.JwtUtils;
|
import com.muyu.common.core.utils.JwtUtils;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
@ -14,6 +15,10 @@ import com.muyu.common.security.auth.AuthUtil;
|
||||||
import com.muyu.common.security.service.TokenService;
|
import com.muyu.common.security.service.TokenService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
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.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
@ -30,6 +35,7 @@ import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* token 控制
|
* token 控制
|
||||||
|
@ -38,6 +44,7 @@ import java.sql.Statement;
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@RestController
|
@RestController
|
||||||
|
@Tag(name = "auth",description = "auth")
|
||||||
public class TokenController {
|
public class TokenController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
@ -48,7 +55,11 @@ public class TokenController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysFirmService sysFirmService;
|
private SysFirmService sysFirmService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
|
@Operation(summary = "登录", description = "登录")
|
||||||
public Result<?> login (@RequestBody LoginBody form) {
|
public Result<?> login (@RequestBody LoginBody form) {
|
||||||
//查询企业是否存在
|
//查询企业是否存在
|
||||||
Firm firm = sysFirmService.findFirmByName(form.getFirmName());
|
Firm firm = sysFirmService.findFirmByName(form.getFirmName());
|
||||||
|
@ -62,6 +73,7 @@ public class TokenController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("logout")
|
@DeleteMapping("logout")
|
||||||
|
@Operation(summary = "退出", description = "退出")
|
||||||
public Result<?> logout (HttpServletRequest request) {
|
public Result<?> logout (HttpServletRequest request) {
|
||||||
String token = SecurityUtils.getToken(request);
|
String token = SecurityUtils.getToken(request);
|
||||||
if (StringUtils.isNotEmpty(token)) {
|
if (StringUtils.isNotEmpty(token)) {
|
||||||
|
@ -75,6 +87,7 @@ public class TokenController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("refresh")
|
@PostMapping("refresh")
|
||||||
|
@Operation(summary = "刷新token", description = "刷新token")
|
||||||
public Result<?> refresh (HttpServletRequest request) {
|
public Result<?> refresh (HttpServletRequest request) {
|
||||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||||
if (StringUtils.isNotNull(loginUser)) {
|
if (StringUtils.isNotNull(loginUser)) {
|
||||||
|
@ -86,6 +99,7 @@ public class TokenController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("register")
|
@PostMapping("register")
|
||||||
|
@Operation(summary = "注册用户", description = "注册用户")
|
||||||
public Result<?> register (@RequestBody RegisterBody registerBody) {
|
public Result<?> register (@RequestBody RegisterBody registerBody) {
|
||||||
// 用户注册
|
// 用户注册
|
||||||
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
||||||
|
@ -98,6 +112,7 @@ public class TokenController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/enterprise")
|
@PostMapping("/enterprise")
|
||||||
|
@Operation(summary = "企业入驻", description = "企业入驻")
|
||||||
public Result<?> enterprise( @RequestBody EnterpriseSettlement settlement){
|
public Result<?> enterprise( @RequestBody EnterpriseSettlement settlement){
|
||||||
|
|
||||||
String createDatabaseUrl="jdbc:mysql://"+ DatasourceContent.IP+":"+DatasourceContent.PORT+"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
String createDatabaseUrl="jdbc:mysql://"+ DatasourceContent.IP+":"+DatasourceContent.PORT+"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||||
|
@ -112,6 +127,13 @@ public class TokenController {
|
||||||
} else {
|
} else {
|
||||||
log.warn("数据库 {} 创建成功", settlement.getDatabaseName());
|
log.warn("数据库 {} 创建成功", settlement.getDatabaseName());
|
||||||
|
|
||||||
|
|
||||||
|
SysUser sysUser = new SysUser();
|
||||||
|
sysUser.setCreateTime(new Date());
|
||||||
|
sysUser.setUserName(settlement.getFirmName());
|
||||||
|
sysUser.setDatabaseName(settlement.getDatabaseName());
|
||||||
|
remoteUserService.addUser(sysUser, SecurityConstants.INNER);
|
||||||
|
|
||||||
// 切换到新的数据库连接
|
// 切换到新的数据库连接
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.muyu.auth.service;
|
package com.muyu.auth.service;
|
||||||
|
|
||||||
import com.muyu.auth.form.EnterpriseSettlement;
|
|
||||||
import com.muyu.common.core.constant.CacheConstants;
|
import com.muyu.common.core.constant.CacheConstants;
|
||||||
import com.muyu.common.core.constant.Constants;
|
import com.muyu.common.core.constant.Constants;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
|
@ -13,8 +13,10 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.ip.IpUtils;
|
import com.muyu.common.core.utils.ip.IpUtils;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.Enterprise;
|
|
||||||
|
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
import com.muyu.common.system.domain.Business;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -144,7 +146,7 @@ public class SysLoginService {
|
||||||
if (fileName.length() < UserConstants.Firm_NAME_MIN_LENGTH || fileName.length() > UserConstants.Firm_NAME_MAX_LENGTH) {
|
if (fileName.length() < UserConstants.Firm_NAME_MIN_LENGTH || fileName.length() > UserConstants.Firm_NAME_MAX_LENGTH) {
|
||||||
throw new ServiceException("企业名称长度必须在2到20个字符之间");
|
throw new ServiceException("企业名称长度必须在2到20个字符之间");
|
||||||
}
|
}
|
||||||
Enterprise settlement = new Enterprise();
|
Business settlement = new Business();
|
||||||
settlement.setDatabaseName(databaseName);
|
settlement.setDatabaseName(databaseName);
|
||||||
settlement.setFirmName(fileName);
|
settlement.setFirmName(fileName);
|
||||||
|
|
||||||
|
|
|
@ -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: four
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.muyu.common.kafka.config;
|
package com.muyu.common.kafka.config;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.constant.KafkaConstant;
|
import com.muyu.common.core.constant.KafkaConstant;
|
||||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
import org.apache.kafka.common.serialization.StringDeserializer;
|
||||||
|
|
|
@ -49,8 +49,6 @@ public class KafkaProducerConfig {
|
||||||
private String acks;
|
private String acks;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public KafkaProducer kafkaProducer() {
|
public KafkaProducer kafkaProducer() {
|
||||||
Map<String, Object> configs = new HashMap<>();
|
Map<String, Object> configs = new HashMap<>();
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-redis</artifactId>
|
<artifactId>cloud-common-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
package com.muyu.common.rabbit.config;
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.rabbit.constants.RabbitmqConstants;
|
|
||||||
import org.springframework.amqp.core.*;
|
|
||||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName: DelayedQueueConfig
|
|
||||||
* @Description: 延迟队列配置类
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class DelayedQueueConfig {
|
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RabbitAdmin rabbitAdmin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 声明队列
|
|
||||||
* @return 返回队列
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public Queue delayedQueue() {
|
|
||||||
Queue queue = new Queue(RabbitmqConstants.DELAYED_QUEUE_NAME);
|
|
||||||
rabbitAdmin.declareQueue(queue);
|
|
||||||
return queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 声明交换机
|
|
||||||
* @return 返回交换机
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public Exchange delayedExchange() {
|
|
||||||
HashMap<String, Object> arguments = new HashMap<>(3);
|
|
||||||
|
|
||||||
arguments.put("x-delayed-type", "direct");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 声明自定义交换机
|
|
||||||
* 第一个参数:交换机的名称
|
|
||||||
* 第二个参数:交换机的类型
|
|
||||||
* 第三个参数:是否需要持久化
|
|
||||||
* 第四个参数:是否自动删除
|
|
||||||
* 第五个参数:其他参数
|
|
||||||
*/
|
|
||||||
CustomExchange customExchange = new CustomExchange(
|
|
||||||
RabbitmqConstants.DELAYED_EXCHANGE_NAME,
|
|
||||||
"x-delayed-message",
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
arguments);
|
|
||||||
rabbitAdmin.declareExchange(customExchange);
|
|
||||||
return customExchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 绑定交换机
|
|
||||||
* @param delayedQueue 队列对象
|
|
||||||
* @param delayedExchange 交换机对象
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public Binding delayedQueueBindingDelayedExchange(
|
|
||||||
@Qualifier("delayedQueue") Queue delayedQueue,
|
|
||||||
@Qualifier("delayedExchange") Exchange delayedExchange) {
|
|
||||||
|
|
||||||
Binding noargs = BindingBuilder.bind(delayedQueue)
|
|
||||||
.to(delayedExchange)
|
|
||||||
.with(RabbitmqConstants.DELAYED_ROUTING_KEY)
|
|
||||||
.noargs();
|
|
||||||
rabbitAdmin.declareBinding(noargs);
|
|
||||||
return noargs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
package com.muyu.common.rabbit.config;
|
|
||||||
|
|
||||||
import org.springframework.amqp.core.*;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: WangXin
|
|
||||||
* @Time: 2024/4/22 11:55
|
|
||||||
* @Description: 主题模式配置
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class TopicConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主题模式交换机
|
|
||||||
* @return exchange
|
|
||||||
*/
|
|
||||||
@Bean(name = "topicExchange")
|
|
||||||
public Exchange getTopicExchange(){
|
|
||||||
return ExchangeBuilder
|
|
||||||
.topicExchange("exchange_topic")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主题队列 01
|
|
||||||
* @return queue
|
|
||||||
*/
|
|
||||||
@Bean(name = "topicQueue01")
|
|
||||||
public Queue getTopicQueue01(){
|
|
||||||
return QueueBuilder
|
|
||||||
.durable("queue_topic_01")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主题队列 02
|
|
||||||
* @return queue
|
|
||||||
*/
|
|
||||||
@Bean(name = "topicQueue02")
|
|
||||||
public Queue getTopicQueue02(){
|
|
||||||
return QueueBuilder
|
|
||||||
.durable("queue_topic_02")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 绑定队列 01
|
|
||||||
* @return binding
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public Binding getTopicBinding01(){
|
|
||||||
return BindingBuilder
|
|
||||||
.bind(getTopicQueue01())
|
|
||||||
.to(getTopicExchange())
|
|
||||||
//路由键 队列1接收debug级别的消息
|
|
||||||
.with("front.#")
|
|
||||||
.noargs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 绑定队列 02
|
|
||||||
* @return binding
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public Binding getTopicBinding02(){
|
|
||||||
return BindingBuilder
|
|
||||||
.bind(getTopicQueue02())
|
|
||||||
.to(getTopicExchange())
|
|
||||||
// 路由键 队列2接收info级别的消息
|
|
||||||
.with("back.order.*")
|
|
||||||
.noargs();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,172 +0,0 @@
|
||||||
package com.muyu.common.rabbit.producer;
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.rabbit.constants.RabbitmqConstants;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.amqp.core.MessageProperties;
|
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName: RabbitMQProducer
|
|
||||||
* @Description: rabbitmq生产者
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Log4j2
|
|
||||||
public class RabbitMQProducerUtil {
|
|
||||||
//redis工具类对象
|
|
||||||
|
|
||||||
//rabbit
|
|
||||||
private final RabbitTemplate rabbitTemplate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简单模型
|
|
||||||
*
|
|
||||||
* @param param 传递的消息 (如果是对象需要序列化)
|
|
||||||
* @return 结果集
|
|
||||||
* 一对一消费,只有一个消费者能接收到
|
|
||||||
*/
|
|
||||||
public Result<?> basicSendMessage(String queueName, Object param, String msg) {
|
|
||||||
|
|
||||||
log.info("【简单模型mq】 : method: 【 basicSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", RabbitmqConstants.BASIC_QUEUE_NAME, param, msg);
|
|
||||||
// 发送简单模型消息
|
|
||||||
// 第一个参数: 绑定规则 相当于 队列名称
|
|
||||||
// 第二个参数:消息内容
|
|
||||||
rabbitTemplate.convertAndSend(queueName, param, message -> {
|
|
||||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
|
||||||
return message;
|
|
||||||
} );
|
|
||||||
|
|
||||||
log.info("【简单模型mq】 : method: 【 basicSendMessage 】- queue: 【 {} 】 ---> 【 消息发送成功 】", RabbitmqConstants.BASIC_QUEUE_NAME);
|
|
||||||
|
|
||||||
return Result.success(msg!=null?msg:"消息发送成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Work queue 工作模型
|
|
||||||
*
|
|
||||||
* @param obj 传递的消息 (如果是对象需要序列化)
|
|
||||||
* @return 结果集
|
|
||||||
* 多个消费者,你一个我一个分配消费消息,有预取机制,默认公平消费,可配置 能者多劳模式(),谁完成的快,谁多做一点
|
|
||||||
*/
|
|
||||||
public Result<?> workSendMessage(String queueName, Object obj, String msg) {
|
|
||||||
|
|
||||||
log.info("【工作模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", queueName, obj, msg);
|
|
||||||
// 发送简单模型消息
|
|
||||||
// 第一个参数: 绑定规则 相当于 队列名称
|
|
||||||
// 第二个参数:消息内容
|
|
||||||
rabbitTemplate.convertAndSend(queueName, obj, message -> {
|
|
||||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
|
||||||
return message;
|
|
||||||
} );
|
|
||||||
|
|
||||||
log.info("【工作模型mq】 : method: 【 workSendMessage 】- queue: 【 {} 】 ---> 【 消息发送成功 】", queueName);
|
|
||||||
|
|
||||||
return Result.success("消息发送成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Publish/Subscribe 发布订阅者模型
|
|
||||||
* 多个消费者,多个消费者可以同时接收到消息 有交换机 类型 fanout
|
|
||||||
* @param exchange 交换机名称
|
|
||||||
* @param obj 发送的消息Object
|
|
||||||
* @param msg 响应的内容
|
|
||||||
* @return 结果集
|
|
||||||
*/
|
|
||||||
public Result<?> publishSubscribeSendMessage(String exchange, Object obj, String msg) {
|
|
||||||
|
|
||||||
log.info("【订阅模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", exchange, obj, msg);
|
|
||||||
// 发送简单模型消息
|
|
||||||
// 第一个参数: exchange 交换机的名称
|
|
||||||
// 第二个参数: 绑定规则 发布订阅者模型 不写 默认 "" 只要绑定就行 不需要规则
|
|
||||||
// 第三个参数:消息内容
|
|
||||||
rabbitTemplate.convertAndSend(exchange, "", obj, message -> {
|
|
||||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
|
||||||
return message;
|
|
||||||
} );
|
|
||||||
|
|
||||||
log.info("【订阅模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
|
||||||
|
|
||||||
return Result.success("消息发送成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Routing路由模型
|
|
||||||
* 使用的是 Direct 类型的交换机,会将接收到的消息根据 规则 路由到指定的Queue(队列),因此称为路由模式
|
|
||||||
*
|
|
||||||
* @param exchange 交换机名称
|
|
||||||
* @param rule 绑定规则 一个字符串即可
|
|
||||||
* @param obj 发送的消息Object
|
|
||||||
* @param msg 响应的内容
|
|
||||||
* @return 结果集
|
|
||||||
*/
|
|
||||||
public Result<?> routingSendMessage(String exchange, String rule, Object obj, String msg) {
|
|
||||||
|
|
||||||
log.info("【路由模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", exchange, obj, msg);
|
|
||||||
// 发送简单模型消息
|
|
||||||
// 第一个参数: 绑定规则 相当于 队列名称
|
|
||||||
// 第二个参数:消息内容
|
|
||||||
rabbitTemplate.convertAndSend(exchange, rule, obj, message -> {
|
|
||||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
|
||||||
return message;
|
|
||||||
} );
|
|
||||||
|
|
||||||
log.info("【路由模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
|
||||||
|
|
||||||
return Result.success("消息发送成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Topic主题模型模型
|
|
||||||
* 使用的是 topic 类型的交换机
|
|
||||||
*
|
|
||||||
* @param exchange 交换机名称
|
|
||||||
* @param rule 绑定规则 可以绑定多个单词以 . 拼接 也可以使用 #(匹配 零个 一个 或 多个 单词) 或 *(匹配 一个 单词) 通配符(例如:name.msg, *.msg, age.# )
|
|
||||||
* @param obj 发送的消息Object
|
|
||||||
* @param msg 响应的内容
|
|
||||||
* @return 结果集
|
|
||||||
*/
|
|
||||||
public Result<?> topicSendMessage(String exchange, String rule, Object obj) {
|
|
||||||
|
|
||||||
log.info("【主题模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {} 】 ---> 【 消息发送中。。。 】", exchange, obj);
|
|
||||||
// 发送简单模型消息
|
|
||||||
// 第一个参数: 绑定规则 相当于 队列名称
|
|
||||||
// 第二个参数:消息内容
|
|
||||||
rabbitTemplate.convertAndSend(exchange, rule, obj, message -> {
|
|
||||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
|
||||||
return message;
|
|
||||||
} );
|
|
||||||
|
|
||||||
log.info("【主题模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
|
||||||
|
|
||||||
return Result.success(obj,"消息发送成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 延迟队列模型
|
|
||||||
* @param param 传输内容
|
|
||||||
* @param delayTime 延迟时间
|
|
||||||
* @return 结果集
|
|
||||||
*/
|
|
||||||
public Result<?> delayedSendMessage(Long delayTime, Object param) {
|
|
||||||
log.info("【延迟队列模型】 : method: 【 delayedSendMessage 】 消息内容:{}---> 【 消息发送中。。。 】",param);
|
|
||||||
|
|
||||||
rabbitTemplate.convertAndSend(RabbitmqConstants.DELAYED_EXCHANGE_NAME, RabbitmqConstants.DELAYED_ROUTING_KEY,param, message -> {
|
|
||||||
MessageProperties messageProperties = message.getMessageProperties();
|
|
||||||
messageProperties.setMessageId(UUID.randomUUID().toString());
|
|
||||||
messageProperties.setDelayLong(delayTime);
|
|
||||||
return message;
|
|
||||||
});
|
|
||||||
log.info("【延迟队列模型】 : method: 【 delayedSendMessage 】 消息内容:{}---> 【 消息发送成功 】",param);
|
|
||||||
|
|
||||||
return Result.success(param,"消息发送成功");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.common.rabbit.config;
|
package com.muyu.rabbitmq.config;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.common.rabbit.config;
|
package com.muyu.rabbitmq.config;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,16 +21,16 @@ public class RabbitAdminConfig {
|
||||||
private String username;
|
private String username;
|
||||||
@Value("${spring.rabbitmq.password}")
|
@Value("${spring.rabbitmq.password}")
|
||||||
private String password;
|
private String password;
|
||||||
@Value("${spring.rabbitmq.virtualhost}")
|
@Value("${spring.rabbitmq.port}")
|
||||||
private String virtualHost;
|
private Integer port;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ConnectionFactory connectionFactory() {
|
public ConnectionFactory connectionFactory() {
|
||||||
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
|
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
|
||||||
cachingConnectionFactory.setHost(host);
|
cachingConnectionFactory.setHost(host);
|
||||||
|
cachingConnectionFactory.setPort(port);
|
||||||
cachingConnectionFactory.setUsername(username);
|
cachingConnectionFactory.setUsername(username);
|
||||||
cachingConnectionFactory.setPassword(password);
|
cachingConnectionFactory.setPassword(password);
|
||||||
cachingConnectionFactory.setVirtualHost(virtualHost);
|
|
||||||
return cachingConnectionFactory;
|
return cachingConnectionFactory;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.common.rabbit.config;
|
package com.muyu.rabbitmq.config;
|
||||||
|
|
||||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||||
import org.springframework.amqp.support.converter.MessageConverter;
|
import org.springframework.amqp.support.converter.MessageConverter;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.common.rabbit.config;
|
package com.muyu.rabbitmq.config;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.amqp.core.ReturnedMessage;
|
import org.springframework.amqp.core.ReturnedMessage;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.common.rabbit.constants;
|
package com.muyu.rabbitmq.constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
|
@ -1,11 +1,15 @@
|
||||||
package com.muyu.common.rabbit.consumer;
|
package com.muyu.rabbitmq.consumer;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
//import com.muyu.rabbitmq.util.CacheUtil;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -22,6 +26,9 @@ public class RabbitMQConsumerUtil {
|
||||||
|
|
||||||
private final RedisService redisService;
|
private final RedisService redisService;
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private CacheUtil cacheUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 普通消费者
|
* 普通消费者
|
||||||
|
@ -29,17 +36,30 @@ public class RabbitMQConsumerUtil {
|
||||||
* @param message
|
* @param message
|
||||||
* @param channel
|
* @param channel
|
||||||
*/
|
*/
|
||||||
public void rabbitMQBasicConsumer(Object data ,Message message , Channel channel) {
|
// @RabbitListener(queuesToDeclare = @Queue(name = "basic"))
|
||||||
|
public void rabbitMQBasicConsumer(String data ,Message message , Channel channel) {
|
||||||
log.info("当前时间:{} :RabbitMQConsumerUtil : {}", new Date(), message);
|
log.info("当前时间:{} :RabbitMQConsumerUtil : {}", new Date(), message);
|
||||||
try {
|
try {
|
||||||
// 获取到消息 开始消费
|
// 获取到消息 开始消费
|
||||||
log.info("消息消费者接收到消息,消息内容:{}", JSONObject.toJSONString(data));
|
log.info("消息消费者接收到消息,消息内容:{}", JSONObject.toJSONString(data));
|
||||||
|
|
||||||
|
|
||||||
Long add = redisService.redisTemplate.opsForSet().add(data, message.getMessageProperties().getMessageId());
|
Long add = redisService.redisTemplate.opsForSet().add(data, message.getMessageProperties().getMessageId());
|
||||||
|
|
||||||
if (add != 1) {
|
if (add != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------以下为异步业务操作----------------------------
|
||||||
|
*/
|
||||||
|
String carList = (String) redisService.redisTemplate.opsForValue().get("carList");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
// 消费消息成功之后需要确认
|
// 消费消息成功之后需要确认
|
||||||
// long deliveryTag 消息投递序号 自增的数字 在整个队列中唯一 拿到这个序号就相当于拿到这条消息
|
// long deliveryTag 消息投递序号 自增的数字 在整个队列中唯一 拿到这个序号就相当于拿到这条消息
|
||||||
// boolean multiple 是否批量确认 true 批量 确认小于等于当前投递序号的消息 false 单个确认
|
// boolean multiple 是否批量确认 true 批量 确认小于等于当前投递序号的消息 false 单个确认
|
||||||
|
@ -66,6 +86,7 @@ public class RabbitMQConsumerUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 普通消费者
|
* 普通消费者
|
||||||
* @param data 数据类型
|
* @param data 数据类型
|
||||||
|
@ -85,6 +106,7 @@ public class RabbitMQConsumerUtil {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* -----------------------------------以下为异步业务操作----------------------------
|
* -----------------------------------以下为异步业务操作----------------------------
|
||||||
*/
|
*/
|
|
@ -0,0 +1,174 @@
|
||||||
|
package com.muyu.rabbitmq.producer;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.rabbitmq.constants.RabbitmqConstants;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.core.MessageProperties;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: RabbitMQProducer
|
||||||
|
* @Description: rabbitmq生产者
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Log4j2
|
||||||
|
public class RabbitMQProducerUtil {
|
||||||
|
//redis工具类对象
|
||||||
|
|
||||||
|
//rabbit
|
||||||
|
private final RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简单模型
|
||||||
|
*
|
||||||
|
* @param param 传递的消息 (如果是对象需要序列化)
|
||||||
|
* @return 结果集
|
||||||
|
* 一对一消费,只有一个消费者能接收到
|
||||||
|
*/
|
||||||
|
public void basicSendMessage(String queueName, String param) {
|
||||||
|
|
||||||
|
log.info("【简单模型mq】 : method: 【 basicSendMessage 】 - ages: 【 String : {}, Object : {}】 ---> 【 消息发送中。。。 】", RabbitmqConstants.BASIC_QUEUE_NAME, param);
|
||||||
|
// 发送简单模型消息
|
||||||
|
// 第一个参数: 绑定规则 相当于 队列名称
|
||||||
|
// 第二个参数:消息内容
|
||||||
|
rabbitTemplate.convertAndSend(queueName, param, message -> {
|
||||||
|
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
return message;
|
||||||
|
} );
|
||||||
|
|
||||||
|
log.info("【简单模型mq】 : method: 【 basicSendMessage 】- queue: 【 {} 】 ---> 【 消息发送成功 】", RabbitmqConstants.BASIC_QUEUE_NAME);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Work queue 工作模型
|
||||||
|
// *
|
||||||
|
// * @param obj 传递的消息 (如果是对象需要序列化)
|
||||||
|
// * @return 结果集
|
||||||
|
// * 多个消费者,你一个我一个分配消费消息,有预取机制,默认公平消费,可配置 能者多劳模式(),谁完成的快,谁多做一点
|
||||||
|
// */
|
||||||
|
// public Result<?> workSendMessage(String queueName, Object obj, String msg) {
|
||||||
|
//
|
||||||
|
// log.info("【工作模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", queueName, obj, msg);
|
||||||
|
// // 发送简单模型消息
|
||||||
|
// // 第一个参数: 绑定规则 相当于 队列名称
|
||||||
|
// // 第二个参数:消息内容
|
||||||
|
// rabbitTemplate.convertAndSend(queueName, obj, message -> {
|
||||||
|
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
// return message;
|
||||||
|
// } );
|
||||||
|
//
|
||||||
|
// log.info("【工作模型mq】 : method: 【 workSendMessage 】- queue: 【 {} 】 ---> 【 消息发送成功 】", queueName);
|
||||||
|
//
|
||||||
|
// return Result.success("消息发送成功");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Publish/Subscribe 发布订阅者模型
|
||||||
|
// * 多个消费者,多个消费者可以同时接收到消息 有交换机 类型 fanout
|
||||||
|
// *
|
||||||
|
// * @param exchange 交换机名称
|
||||||
|
// * @param obj 发送的消息Object
|
||||||
|
// * @param msg 响应的内容
|
||||||
|
// * @return 结果集
|
||||||
|
// */
|
||||||
|
// public Result<?> publishSubscribeSendMessage(String exchange, Object obj, String msg) {
|
||||||
|
//
|
||||||
|
// log.info("【订阅模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", exchange, obj, msg);
|
||||||
|
// // 发送简单模型消息
|
||||||
|
// // 第一个参数: exchange 交换机的名称
|
||||||
|
// // 第二个参数: 绑定规则 发布订阅者模型 不写 默认 "" 只要绑定就行 不需要规则
|
||||||
|
// // 第三个参数:消息内容
|
||||||
|
// rabbitTemplate.convertAndSend(exchange, "", obj, message -> {
|
||||||
|
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
// return message;
|
||||||
|
// } );
|
||||||
|
//
|
||||||
|
// log.info("【订阅模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
||||||
|
//
|
||||||
|
// return Result.success("消息发送成功");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Routing路由模型
|
||||||
|
// * 使用的是 Direct 类型的交换机,会将接收到的消息根据 规则 路由到指定的Queue(队列),因此称为路由模式
|
||||||
|
// *
|
||||||
|
// * @param exchange 交换机名称
|
||||||
|
// * @param rule 绑定规则 一个字符串即可
|
||||||
|
// * @param obj 发送的消息Object
|
||||||
|
// * @param msg 响应的内容
|
||||||
|
// * @return 结果集
|
||||||
|
// */
|
||||||
|
// public Result<?> routingSendMessage(String exchange, String rule, Object obj, String msg) {
|
||||||
|
//
|
||||||
|
// log.info("【路由模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", exchange, obj, msg);
|
||||||
|
// // 发送简单模型消息
|
||||||
|
// // 第一个参数: 绑定规则 相当于 队列名称
|
||||||
|
// // 第二个参数:消息内容
|
||||||
|
// rabbitTemplate.convertAndSend(exchange, rule, obj, message -> {
|
||||||
|
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
// return message;
|
||||||
|
// } );
|
||||||
|
//
|
||||||
|
// log.info("【路由模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
||||||
|
//
|
||||||
|
// return Result.success("消息发送成功");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Topic主题模型模型
|
||||||
|
// * 使用的是 topic 类型的交换机
|
||||||
|
// *
|
||||||
|
// * @param exchange 交换机名称
|
||||||
|
// * @param rule 绑定规则 可以绑定多个单词以 . 拼接 也可以使用 #(匹配 零个 一个 或 多个 单词) 或 *(匹配 一个 单词) 通配符(例如:name.msg, *.msg, age.# )
|
||||||
|
// * @param obj 发送的消息Object
|
||||||
|
// * @param msg 响应的内容
|
||||||
|
// * @return 结果集
|
||||||
|
// */
|
||||||
|
// public Result<?> topicSendMessage(String exchange, String rule, Object obj) {
|
||||||
|
//
|
||||||
|
// log.info("【主题模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {} 】 ---> 【 消息发送中。。。 】", exchange, obj);
|
||||||
|
// // 发送简单模型消息
|
||||||
|
// // 第一个参数: 绑定规则 相当于 队列名称
|
||||||
|
// // 第二个参数:消息内容
|
||||||
|
// rabbitTemplate.convertAndSend(exchange, rule, obj, message -> {
|
||||||
|
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
// return message;
|
||||||
|
// } );
|
||||||
|
//
|
||||||
|
// log.info("【主题模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
||||||
|
//
|
||||||
|
// return Result.success(obj,"消息发送成功");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 延迟队列模型
|
||||||
|
* @param param 传输内容
|
||||||
|
* @param delayTime 延迟时间
|
||||||
|
* @return 结果集
|
||||||
|
*/
|
||||||
|
// public Result<?> delayedSendMessage(Long delayTime, Object param) {
|
||||||
|
// log.info("【延迟队列模型】 : method: 【 delayedSendMessage 】 消息内容:{}---> 【 消息发送中。。。 】",param);
|
||||||
|
//
|
||||||
|
// rabbitTemplate.convertAndSend(RabbitmqConstants.DELAYED_EXCHANGE_NAME, RabbitmqConstants.DELAYED_ROUTING_KEY,param, message -> {
|
||||||
|
// MessageProperties messageProperties = message.getMessageProperties();
|
||||||
|
// messageProperties.setMessageId(UUID.randomUUID().toString());
|
||||||
|
// messageProperties.setDelayLong(delayTime);
|
||||||
|
// return message;
|
||||||
|
// });
|
||||||
|
// log.info("【延迟队列模型】 : method: 【 delayedSendMessage 】 消息内容:{}---> 【 消息发送成功 】",param);
|
||||||
|
//
|
||||||
|
// return Result.success(param,"消息发送成功");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,5 @@ com.muyu.rabbitmq.producer.RabbitMQProducerUtil
|
||||||
com.muyu.rabbitmq.consumer.RabbitMQConsumerUtil
|
com.muyu.rabbitmq.consumer.RabbitMQConsumerUtil
|
||||||
com.muyu.rabbitmq.config.RabbitmqConfig
|
com.muyu.rabbitmq.config.RabbitmqConfig
|
||||||
com.muyu.rabbitmq.config.MyConfirmCallback
|
com.muyu.rabbitmq.config.MyConfirmCallback
|
||||||
com.muyu.rabbitmq.config.DelayedQueueConfig
|
|
||||||
com.muyu.rabbitmq.config.RabbitAdminConfig
|
com.muyu.rabbitmq.config.RabbitAdminConfig
|
||||||
com.muyu.rabbitmq.config.ReturnCallbackConfig
|
com.muyu.rabbitmq.config.ReturnCallbackConfig
|
||||||
|
|
|
@ -33,9 +33,10 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-security</artifactId>
|
<artifactId>cloud-common-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -5,17 +5,17 @@ import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||||
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
||||||
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
|
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
|
||||||
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
|
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
|
||||||
|
import com.muyu.cloud.common.many.datasource.init.InitDataSource;
|
||||||
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
||||||
|
import com.muyu.cloud.common.saas.domain.Datasource;
|
||||||
import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
||||||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.SpringUtils;
|
import com.muyu.common.core.utils.SpringUtils;
|
||||||
import com.muyu.common.system.domain.Datasource;
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
|
||||||
import com.muyu.common.system.remote.RemoteSaaSService;
|
import com.muyu.common.system.remote.RemoteSaaSService;
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
|
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
|
||||||
|
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.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
@ -35,9 +35,14 @@ import java.util.Map;
|
||||||
@Component
|
@Component
|
||||||
@AutoConfiguration(before = {MybatisPlusAutoConfiguration.class, MybatisAutoConfiguration.class})
|
@AutoConfiguration(before = {MybatisPlusAutoConfiguration.class, MybatisAutoConfiguration.class})
|
||||||
public class ManyDataSource implements ApplicationRunner{
|
public class ManyDataSource implements ApplicationRunner{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InitDataSource initDataSource;
|
||||||
|
|
||||||
|
|
||||||
private List<EntInfo> dataSourceInfoList(){
|
private List<EntInfo> dataSourceInfoList(){
|
||||||
RemoteSaaSService remoteSaaSService = SpringUtils.getBean(RemoteSaaSService.class);
|
RemoteSaaSService remoteSaaSService = SpringUtils.getBean(RemoteSaaSService.class);
|
||||||
Result<List<Datasource>> tableDataInfoResult = remoteSaaSService.findDatabaseList();
|
Result<List<Datasource>> tableDataInfoResult = initDataSource.initDatasource();
|
||||||
if (tableDataInfoResult==null){
|
if (tableDataInfoResult==null){
|
||||||
throw new SaaSException("saas远调数据源错误");
|
throw new SaaSException("saas远调数据源错误");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,4 @@ public class DatasourceContent {
|
||||||
public final static String IP = "47.101.53.251";
|
public final static String IP = "47.101.53.251";
|
||||||
|
|
||||||
public final static Integer PORT = 3306;
|
public final static Integer PORT = 3306;
|
||||||
|
|
||||||
public static String getDatasourceUrl(String databaseName) {
|
|
||||||
return String.format(DATASOURCE_URL,USER_NAME,PASSWORD,IP,PORT, databaseName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.muyu.cloud.common.many.datasource.init;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.cloud.common.saas.domain.Datasource;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class InitDataSource {
|
||||||
|
|
||||||
|
public static final String USER="root";
|
||||||
|
public static final String PASSWORD="Lw030106";
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public Result<List<Datasource>> initDatasource(){
|
||||||
|
ArrayList<Datasource> list = new ArrayList<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
|
||||||
|
Connection connection= DriverManager.getConnection("jdbc:mysql://47.101.53.251:3306/datasource?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&useSSL=false",USER,PASSWORD);
|
||||||
|
String sql="select * from `datasource` ";
|
||||||
|
|
||||||
|
Statement stmt = connection.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery(sql);
|
||||||
|
|
||||||
|
while (rs.next()){
|
||||||
|
Datasource datasource = new Datasource();
|
||||||
|
datasource.setId(rs.getInt("id"));
|
||||||
|
datasource.setFirmName(rs.getString("firm_name"));
|
||||||
|
datasource.setDatabaseName(rs.getString("database_name"));
|
||||||
|
list.add(datasource);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return Result.success(list);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,10 +1,9 @@
|
||||||
package com.muyu.cloud.common.saas.interceptor;
|
package com.muyu.cloud.common.saas.interceptor;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.muyu.cloud.common.saas.contents.SaaSConstant;
|
|
||||||
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
|
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
|
||||||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
|
||||||
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
||||||
|
import com.muyu.cloud.common.saas.contents.SaaSConstant;
|
||||||
|
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||||
import com.muyu.common.core.utils.ServletUtils;
|
import com.muyu.common.core.utils.ServletUtils;
|
||||||
import com.muyu.common.core.utils.SpringUtils;
|
import com.muyu.common.core.utils.SpringUtils;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
com.muyu.cloud.common.saas.interceptor.WebMvcSaaSConfig
|
com.muyu.cloud.common.saas.interceptor.WebMvcSaaSConfig
|
||||||
com.muyu.cloud.common.many.datasource.ManyDataSource
|
com.muyu.cloud.common.many.datasource.ManyDataSource
|
||||||
com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory
|
com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory
|
||||||
|
com.muyu.cloud.common.many.datasource.init.InitDataSource
|
||||||
|
|
|
@ -21,7 +21,7 @@ import lombok.experimental.SuperBuilder;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Enterprise extends BaseEntity {
|
public class Business extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -3,13 +3,12 @@ package com.muyu.common.system.remote;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.system.domain.Business;
|
||||||
import com.muyu.common.system.domain.Enterprise;
|
|
||||||
import com.muyu.common.system.domain.SysFirmUser;
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -53,5 +52,13 @@ public interface RemoteUserService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/enterprise")
|
@PostMapping("/user/enterprise")
|
||||||
Result<Boolean>settlementEnterpriseInfo(@RequestBody Enterprise enterprise, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
Result<Boolean>settlementEnterpriseInfo(@RequestBody Business enterprise, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户添加
|
||||||
|
* @param sysUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/user/addUser")
|
||||||
|
public Result<Integer> addUser(@RequestBody SysUser sysUser,@RequestHeader(SecurityConstants.FROM_SOURCE)String source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.muyu.common.system.remote.factory;
|
package com.muyu.common.system.remote.factory;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.system.domain.Business;
|
||||||
import com.muyu.common.system.domain.Enterprise;
|
|
||||||
import com.muyu.common.system.domain.SysFirmUser;
|
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
@ -43,10 +41,16 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Boolean> settlementEnterpriseInfo(Enterprise enterprise, String source) {
|
public Result<Boolean> settlementEnterpriseInfo(Business enterprise, String source) {
|
||||||
return Result.error("入驻企业失败");
|
return Result.error("入驻企业失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<Integer> addUser(SysUser sysUser, String source) {
|
||||||
|
return Result.error("用户添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: four
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -127,6 +127,12 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>saas-cache</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -28,6 +28,4 @@ public class EventPublisher implements ApplicationEventPublisherAware {
|
||||||
publisher.publishEvent(event);
|
publisher.publishEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,7 @@ public class IoTDBConfig {
|
||||||
measurements.add("car_vin");
|
measurements.add("car_vin");
|
||||||
measurements.add("information");
|
measurements.add("information");
|
||||||
|
|
||||||
|
|
||||||
session.insertRecord(TABLENAME,System.currentTimeMillis(),measurements,list);
|
session.insertRecord(TABLENAME,System.currentTimeMillis(),measurements,list);
|
||||||
|
|
||||||
//关闭连接
|
//关闭连接
|
||||||
session.close();
|
session.close();
|
||||||
} catch (IoTDBConnectionException e) {
|
} catch (IoTDBConnectionException e) {
|
||||||
|
|
|
@ -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,11 +9,14 @@ 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 刘武
|
||||||
* @package:com.muyu.event.consumer
|
* @package:com.muyu.event.consumer
|
||||||
|
@ -31,27 +34,18 @@ public class MessageConsumer implements ApplicationRunner {
|
||||||
|
|
||||||
private final String topic="four_car";
|
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 -> {
|
||||||
String value = record.value();
|
String value = record.value();
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
package com.muyu.event.consumer;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.muyu.cache.ElectronicFenceGroupCacheService;
|
||||||
|
import com.muyu.cache.SysCarCacheService;
|
||||||
|
import com.muyu.common.domain.database.ElectronicFenceGroup;
|
||||||
|
import com.muyu.common.domain.resp.SysCarVo;
|
||||||
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
import com.muyu.rabbitmq.consumer.RabbitMQConsumerUtil;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rabbitmq 监听器
|
||||||
|
* @author 刘武
|
||||||
|
* @package:com.muyu.event.consumer
|
||||||
|
* @name:MqConsumer
|
||||||
|
* @date:2024/10/2 14:17
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class MqConsumer {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysCarCacheService sysCarCacheService;
|
||||||
|
@Autowired
|
||||||
|
private ElectronicFenceGroupCacheService electronicFenceGroupCacheService;
|
||||||
|
|
||||||
|
@RabbitListener(queuesToDeclare = @Queue(name = "basic"))
|
||||||
|
public void rabbitMQBasicConsumer(String data , Message message , Channel channel) {
|
||||||
|
log.info("当前时间:{} :RabbitMQConsumerUtil : {}", new Date(), message);
|
||||||
|
try {
|
||||||
|
// 获取到消息 开始消费
|
||||||
|
log.info("消息消费者接收到消息,消息内容:{}", JSONObject.toJSONString(data));
|
||||||
|
|
||||||
|
Long add = redisService.redisTemplate.opsForSet().add(data, message.getMessageProperties().getMessageId());
|
||||||
|
|
||||||
|
if (add != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------以下为异步业务操作----------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
// 消费消息成功之后需要确认
|
||||||
|
// long deliveryTag 消息投递序号 自增的数字 在整个队列中唯一 拿到这个序号就相当于拿到这条消息
|
||||||
|
// boolean multiple 是否批量确认 true 批量 确认小于等于当前投递序号的消息 false 单个确认
|
||||||
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
log.info("xxx消费者接收到消息,消息内容:{},消费成功...", message);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("xxx消费者接收到消息,消息内容:{},消费消息异常,异常信息:{}", message, e);
|
||||||
|
// 消息回退 拒绝消费消息
|
||||||
|
// long deliveryTag 消息投递序号 自增的数字 在整个队列中唯一 拿到这个序号就相当于拿到这条消息
|
||||||
|
// boolean requeue 是否回到原来的队列
|
||||||
|
try {
|
||||||
|
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||||
|
// channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
log.error("xxx消费者接收到消息,消息内容:{},回退消息异常,异常信息:{}", message, ex);
|
||||||
|
}
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
channel.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("xxx消费者关闭Channel异常,消息内容:{},异常信息:{}", message, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -18,4 +18,6 @@ public class OnlineConsumer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 数据处理
|
||||||
* @author 刘武
|
* @author 刘武
|
||||||
* @package:com.muyu.event.controller
|
* @package:com.muyu.event.controller
|
||||||
* @name:DataController
|
* @name:DataController
|
||||||
* @date:2024/9/29 20:16
|
* @date:2024/9/29 20:16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("data")
|
@RequestMapping("data")
|
||||||
public class DataController {
|
public class DataController {
|
||||||
|
|
|
@ -19,13 +19,12 @@ import java.util.List;
|
||||||
* @name:ItodbController
|
* @name:ItodbController
|
||||||
* @date:2024/9/28 19:17
|
* @date:2024/9/28 19:17
|
||||||
*/
|
*/
|
||||||
@RestController()
|
@RestController
|
||||||
public class IoTDBController {
|
public class IoTDBController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IoTDBService tdbService;
|
private IoTDBService tdbService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询实时车辆信息列表
|
* 查询实时车辆信息列表
|
||||||
* @return list
|
* @return list
|
||||||
|
@ -47,7 +46,6 @@ public class IoTDBController {
|
||||||
return Result.success(carInformation);
|
return Result.success(carInformation);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆添加
|
* 车辆添加
|
||||||
* @param addCarInformation
|
* @param addCarInformation
|
||||||
|
@ -59,16 +57,4 @@ public class IoTDBController {
|
||||||
return Result.success("添加成功");
|
return Result.success("添加成功");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,17 @@ package com.muyu.event.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.muyu.event.service.TestService;
|
import com.muyu.rabbitmq.producer.RabbitMQProducerUtil;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
import org.springframework.amqp.core.AmqpTemplate;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 测试
|
||||||
* @author 刘武
|
* @author 刘武
|
||||||
* @package:com.muyu.event.controller
|
* @package:com.muyu.event.controller
|
||||||
* @name:TestController
|
* @name:TestController
|
||||||
|
@ -26,25 +23,33 @@ public class TestController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private KafkaProducer kafkaProducer;
|
private KafkaProducer kafkaProducer;
|
||||||
|
@Resource
|
||||||
|
private RabbitMQProducerUtil rabbitMQProducerUtil;
|
||||||
|
|
||||||
|
|
||||||
private static final String topic="four_car";
|
private static final String topic="four_car";
|
||||||
|
|
||||||
@GetMapping("send")
|
@GetMapping("sendKafka")
|
||||||
public String sendKafka(){
|
public String sendKafka(){
|
||||||
|
|
||||||
String message="发送一条信息";
|
String message="发送一条信息";
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("cj","sb");
|
jsonObject.put("cj","hh");
|
||||||
|
ProducerRecord<String, String> producerRecord = new ProducerRecord<String, String>(topic,jsonObject.toString());
|
||||||
|
|
||||||
ProducerRecord<String, String> producerRecord = new ProducerRecord<String, String>(topic,jsonObject.toJSONString());
|
|
||||||
kafkaProducer.send(producerRecord);
|
kafkaProducer.send(producerRecord);
|
||||||
|
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("sendMq")
|
||||||
|
public String sendMq(){
|
||||||
|
String message="发送一条信息-mq";
|
||||||
|
rabbitMQProducerUtil.basicSendMessage("basic",message);
|
||||||
|
return "success-mq";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,13 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件实体类
|
||||||
|
* @author 刘武
|
||||||
|
* @package:com.muyu.event.domain
|
||||||
|
* @name:Event
|
||||||
|
* @date:2024/9/28 23:10
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|
|
@ -28,6 +28,10 @@ public class AddDatabaseListener implements EventListener {
|
||||||
keys.add(key);
|
keys.add(key);
|
||||||
values.add((String) value);
|
values.add((String) value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class SysUserController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@InnerAuth
|
@InnerAuth
|
||||||
@PostMapping("/enterprise")
|
@PostMapping("/enterprise")
|
||||||
public Result<Boolean> enterprise (@RequestBody Enterprise enterprise){
|
public Result<Boolean> enterprise (@RequestBody Business enterprise){
|
||||||
|
|
||||||
return Result.success(userService.enterprise(enterprise));
|
return Result.success(userService.enterprise(enterprise));
|
||||||
}
|
}
|
||||||
|
@ -302,4 +302,11 @@ public class SysUserController extends BaseController {
|
||||||
public Result deptTree (SysDept dept) {
|
public Result deptTree (SysDept dept) {
|
||||||
return success(deptService.selectDeptTreeList(dept));
|
return success(deptService.selectDeptTreeList(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/addUser")
|
||||||
|
public Result<Integer> addUser(@RequestBody SysUser sysUser){
|
||||||
|
Integer i = userService.addUser(sysUser);
|
||||||
|
return Result.success(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.muyu.system.mapper;
|
package com.muyu.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.common.system.domain.Enterprise;
|
import com.muyu.common.system.domain.Business;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@ -72,14 +72,14 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||||
* @param enterprise
|
* @param enterprise
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int enterprise(Enterprise enterprise);
|
int enterprise(Business enterprise);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业管理添加
|
* 企业管理添加
|
||||||
* @param enterprise
|
* @param enterprise
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int enterPriseAdd(Enterprise enterprise);
|
int enterPriseAdd(Business enterprise);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
|
@ -158,5 +158,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||||
List<SysUser> selectCompanyList();
|
List<SysUser> selectCompanyList();
|
||||||
|
|
||||||
|
|
||||||
|
Integer addUser(SysUser sysUser);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.muyu.system.service;
|
package com.muyu.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.common.system.domain.Enterprise;
|
import com.muyu.common.system.domain.Business;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -134,7 +134,7 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
*/
|
*/
|
||||||
boolean registerUser(SysUser user);
|
boolean registerUser(SysUser user);
|
||||||
|
|
||||||
boolean enterprise(Enterprise enterprise);
|
boolean enterprise(Business enterprise);
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
*
|
*
|
||||||
|
@ -230,5 +230,6 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
|
|
||||||
List<SysUser> selectCompanyList();
|
List<SysUser> selectCompanyList();
|
||||||
|
|
||||||
|
Integer addUser(SysUser sysUser);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.bean.BeanValidators;
|
import com.muyu.common.core.utils.bean.BeanValidators;
|
||||||
import com.muyu.common.datascope.annotation.DataScope;
|
import com.muyu.common.datascope.annotation.DataScope;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.Enterprise;
|
import com.muyu.common.system.domain.Business;
|
||||||
import com.muyu.common.system.domain.SysRole;
|
import com.muyu.common.system.domain.SysRole;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.system.domain.SysPost;
|
import com.muyu.system.domain.SysPost;
|
||||||
|
@ -264,7 +264,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean enterprise(Enterprise enterprise){
|
public boolean enterprise(Business enterprise){
|
||||||
userMapper.enterPriseAdd(enterprise);
|
userMapper.enterPriseAdd(enterprise);
|
||||||
return userMapper.enterprise(enterprise) > 0;
|
return userMapper.enterprise(enterprise) > 0;
|
||||||
}
|
}
|
||||||
|
@ -518,4 +518,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
return userMapper.selectCompanyList();
|
return userMapper.selectCompanyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer addUser(SysUser sysUser) {
|
||||||
|
return userMapper.addUser(sysUser);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: four
|
||||||
# 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:
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<result property="updateBy" column="update_by"/>
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="updateTime" column="update_time"/>
|
||||||
<result property="remark" column="remark"/>
|
<result property="remark" column="remark"/>
|
||||||
|
<result property="databaseName" column="database_name"/>
|
||||||
<association property="dept" javaType="com.muyu.common.system.domain.SysDept" resultMap="deptResult"/>
|
<association property="dept" javaType="com.muyu.common.system.domain.SysDept" resultMap="deptResult"/>
|
||||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
@ -204,6 +205,7 @@
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="status != null and status != ''">status,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
<if test="databaseName !=null and databaseName!=''">database_name,</if>
|
||||||
create_time
|
create_time
|
||||||
)values(
|
)values(
|
||||||
<if test="userId != null and userId != ''">#{userId},</if>
|
<if test="userId != null and userId != ''">#{userId},</if>
|
||||||
|
@ -218,6 +220,7 @@
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
<if test="databaseName!=null and databaseName!=''">#{databaseName}</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
@ -228,6 +231,11 @@
|
||||||
INSERT INTO `saas`.`tb_enterprise` (`enterprise_id`, `enterprise_name`, `enterprise_car_count`, `enterprise_fence_count`, `enterprise_database_name`)
|
INSERT INTO `saas`.`tb_enterprise` (`enterprise_id`, `enterprise_name`, `enterprise_car_count`, `enterprise_fence_count`, `enterprise_database_name`)
|
||||||
VALUES (NULL, #{firmName}, 0, 0, #{databaseName});
|
VALUES (NULL, #{firmName}, 0, 0, #{databaseName});
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="addUser">
|
||||||
|
INSERT INTO `four`.`sys_user`
|
||||||
|
(`dept_id`, `user_name`, `nick_name`, `user_type`, `email`, `phonenumber`, `sex`, `avatar`, `password`, `status`, `del_flag`, `login_ip`, `login_date`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `database_name`)
|
||||||
|
VALUES ( 105, #{userName}, '若依', '00', 'ry@qq.com', '15666666666', '1', '', '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '47.101.53.251', '2024-05-23 15:08:18', 'admin', #{createTime}, '', NULL, '测试员', #{databaseName});
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
||||||
update sys_user
|
update sys_user
|
||||||
|
|
|
@ -131,6 +131,18 @@
|
||||||
<version>4.2.0</version><!-- 请根据实际情况使用最新的版本 -->
|
<version>4.2.0</version><!-- 请根据实际情况使用最新的版本 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu.server</groupId>
|
||||||
|
<artifactId>saas-server</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Forest HTTP Client -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dtflys.forest</groupId>
|
||||||
|
<artifactId>forest-spring-boot-starter</artifactId>
|
||||||
|
<version>1.5.36</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
|
|
||||||
public class VehicleGatewayApplication {
|
public class VehicleGatewayApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(VehicleGatewayApplication.class,args);
|
SpringApplication.run(VehicleGatewayApplication.class,args);
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package com.muyu.vehicle;
|
package com.muyu.vehicle;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.aliyun.ecs20140526.Client;
|
import com.aliyun.ecs20140526.Client;
|
||||||
import com.aliyun.ecs20140526.models.*;
|
import com.aliyun.ecs20140526.models.*;
|
||||||
import com.aliyun.tea.TeaException;
|
import com.aliyun.tea.TeaException;
|
||||||
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.config.SelectInstance;
|
||||||
import com.muyu.vehicle.domain.InstanceInfo;
|
import com.muyu.vehicle.domain.InstanceInfo;
|
||||||
import com.muyu.vehicle.service.OpenInstance;
|
import com.muyu.vehicle.utils.CreateClient;
|
||||||
import com.muyu.vehicle.service.SelectInstance;
|
|
||||||
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.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
@ -19,25 +19,21 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
|
/**
|
||||||
|
* 项目启动创建实例
|
||||||
|
*/
|
||||||
public class ManageInstance implements ApplicationRunner {
|
public class ManageInstance implements ApplicationRunner {
|
||||||
|
@Autowired
|
||||||
/**
|
private RedisService redisService;
|
||||||
* ACCESS_KEY_ID
|
|
||||||
*/
|
|
||||||
public static final String ALIBABA_CLOUD_ACCESS_KEY_ID="LTAI5tGabdxedjfCh2uXHNrw";
|
|
||||||
|
|
||||||
/**
|
|
||||||
*ACCESS_KEY_SECRET
|
|
||||||
*/
|
|
||||||
public static final String ACCESS_KEY_SECRET="NHb7wHVpesLW6Axc0bFBs6ThhuNR10";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 镜像ID
|
* 镜像ID
|
||||||
*/
|
*/
|
||||||
public static final String IMAGE_ID="m-uf6agr9i6g27gj23om34";
|
public static final String IMAGE_ID = "m-uf6ffgkry85fwu4znr6s";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实例类型
|
* 实例类型
|
||||||
|
@ -60,30 +56,10 @@ 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 {
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用AK&SK初始化账号Client
|
|
||||||
* @return Client
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static Client createClient() throws Exception {
|
|
||||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
|
||||||
Config config = new Config()
|
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
|
||||||
.setAccessKeyId(ALIBABA_CLOUD_ACCESS_KEY_ID)
|
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
|
||||||
.setAccessKeySecret(ACCESS_KEY_SECRET);
|
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
|
||||||
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
|
||||||
return new com.aliyun.ecs20140526.Client(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void generateInstance() throws Exception {
|
|
||||||
// 创建阿里云ECS客户端
|
// 创建阿里云ECS客户端
|
||||||
Client client = ManageInstance.createClient();
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
|
Client client = CreateClient.createClient();
|
||||||
// 配置系统盘参数
|
// 配置系统盘参数
|
||||||
RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk =
|
RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk =
|
||||||
new RunInstancesRequest.RunInstancesRequestSystemDisk()
|
new RunInstancesRequest.RunInstancesRequestSystemDisk()
|
||||||
|
@ -121,6 +97,7 @@ public class ManageInstance implements ApplicationRunner {
|
||||||
list.add(instance);
|
list.add(instance);
|
||||||
}
|
}
|
||||||
log.info("ESC创建成功,实例ID为:" + list);
|
log.info("ESC创建成功,实例ID为:" + list);
|
||||||
|
return list;
|
||||||
} catch (TeaException error) {
|
} catch (TeaException error) {
|
||||||
// 错误 message
|
// 错误 message
|
||||||
log.info(error.getMessage());
|
log.info(error.getMessage());
|
||||||
|
@ -133,41 +110,25 @@ public class ManageInstance implements ApplicationRunner {
|
||||||
// 错误 message
|
// 错误 message
|
||||||
log.info("实例创建失败:" + error.getMessage());
|
log.info("实例创建失败:" + error.getMessage());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<InstanceInfo> selectInstance() throws Exception {
|
|
||||||
Client client = ManageInstance.createClient();
|
|
||||||
ArrayList<InstanceInfo> instanceInfos = new ArrayList<>();// 实例基础信息
|
|
||||||
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
|
||||||
.setRegionId("cn-shanghai")
|
|
||||||
.setInternetChargeType("PayByTraffic")
|
|
||||||
.setInstanceChargeType("PostPaid")
|
|
||||||
.setInstanceName("cloud-MQTT") // 设置实例名称
|
|
||||||
;
|
|
||||||
// 创建运行时选项对象
|
|
||||||
RuntimeOptions runtime = new RuntimeOptions();
|
|
||||||
//实例ID Instances.Instance.InstanceId
|
|
||||||
//实例IP Instances.Instance.PublicIpAddress.IpAddress
|
|
||||||
//状态 Instances.Instance.Status
|
|
||||||
DescribeInstancesResponse resp =client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
|
||||||
DescribeInstancesResponseBody body = resp.getBody();
|
|
||||||
|
|
||||||
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()){
|
|
||||||
InstanceInfo instanceInfo = new InstanceInfo();
|
|
||||||
instanceInfo.setInstanceId(instance.getInstanceId());
|
|
||||||
instanceInfo.setIpAddress(String.valueOf(instance.getPublicIpAddress().getIpAddress()));
|
|
||||||
instanceInfo.setStatus(instance.getStatus());
|
|
||||||
instanceInfos.add(instanceInfo);
|
|
||||||
|
|
||||||
}
|
|
||||||
log.info("实例信息为:"+Common.toJSONString(instanceInfos));
|
|
||||||
return instanceInfos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
generateInstance();
|
List<String> list = generateInstance();
|
||||||
selectInstance();
|
log.info("创建实例成功");
|
||||||
|
log.info("正在加载实例");
|
||||||
|
Thread.sleep(30000);
|
||||||
|
List<InstanceInfo> instanceInfos = SelectInstance.selectInstance(list);
|
||||||
|
log.info("实例信息查询成功");
|
||||||
|
for (InstanceInfo instanceInfo : instanceInfos) {
|
||||||
|
redisService.setCacheObject("FourInstanceIdKey:"+instanceInfo.getInstanceId(),instanceInfo);
|
||||||
|
}
|
||||||
|
System.out.println("实例信息:"+instanceInfos);
|
||||||
|
log.info("实例信息:", JSONObject.toJSONString(instanceInfos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
package com.muyu.vehicle.service;
|
package com.muyu.vehicle.config;
|
||||||
|
|
||||||
|
|
||||||
import com.aliyun.ecs20140526.Client;
|
import com.aliyun.ecs20140526.Client;
|
||||||
import com.aliyun.ecs20140526.models.DeleteInstancesRequest;
|
import com.aliyun.ecs20140526.models.DeleteInstancesRequest;
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
||||||
|
@ -10,42 +8,33 @@ 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.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.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除实例信息
|
||||||
|
*/
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class CloseInstance implements DisposableBean{
|
public class CloseInstance implements DisposableBean{
|
||||||
/**
|
|
||||||
* ACCESS_KEY_ID
|
|
||||||
*/
|
|
||||||
public static final String ALIBABA_CLOUD_ACCESS_KEY_ID="LTAI5tGabdxedjfCh2uXHNrw";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*ACCESS_KEY_SECRET
|
* <b>description</b> :
|
||||||
|
* <p>使用AK&SK初始化账号Client</p>
|
||||||
|
* @return Client
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static final String ACCESS_KEY_SECRET="NHb7wHVpesLW6Axc0bFBs6ThhuNR10";
|
|
||||||
public static Client createClient() throws Exception {
|
|
||||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
|
||||||
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
|
||||||
Config config = new Config()
|
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
|
||||||
.setAccessKeyId(ALIBABA_CLOUD_ACCESS_KEY_ID)
|
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
|
||||||
.setAccessKeySecret(ACCESS_KEY_SECRET);
|
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
|
||||||
config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
|
|
||||||
return new Client(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void delInstance() throws Exception {
|
public static void delInstance() throws Exception {
|
||||||
|
|
||||||
// 创建ECS客户端对象,用于后续调用ECS相关API
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
Client client = CloseInstance.createClient();
|
Client client = CreateClient.createClient();
|
||||||
|
|
||||||
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
||||||
.setRegionId("cn-shanghai");
|
.setRegionId("cn-shanghai");
|
||||||
|
@ -108,3 +97,4 @@ public class CloseInstance implements DisposableBean {
|
||||||
delInstance();
|
delInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.muyu.vehicle.config;
|
||||||
|
|
||||||
|
import com.muyu.vehicle.domain.MqttServerModel;
|
||||||
|
import feign.Client;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 链接fluxMq
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
public class ConnectFluxMq {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void FluxMqConnect(String IP,String vin){
|
||||||
|
String topic = "car";
|
||||||
|
String broker = "tcp://"+IP+":1883";
|
||||||
|
String clientId = vin+"vehicleGateway";
|
||||||
|
MqttClient client;
|
||||||
|
try {
|
||||||
|
//创建
|
||||||
|
client = new MqttClient(broker,clientId);
|
||||||
|
//设置连接参数
|
||||||
|
MqttConnectOptions options = new MqttConnectOptions();
|
||||||
|
options.setCleanSession(true);
|
||||||
|
//连接到Broker
|
||||||
|
client.connect(options);
|
||||||
|
log.info("Connecting to broker: " + broker);
|
||||||
|
//连接
|
||||||
|
client.subscribe(topic,0);
|
||||||
|
client.setCallback(new MqttCallback() {
|
||||||
|
@Override
|
||||||
|
public void connectionLost(Throwable throwable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (MqttException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.muyu.vehicle.config;
|
||||||
|
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.core.*;
|
||||||
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
public class CreateExchange implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConnectionFactory connectionFactory;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
log.info("=====>开始创建交换机");
|
||||||
|
|
||||||
|
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
|
||||||
|
|
||||||
|
// 创建Fanout类型的交换机
|
||||||
|
FanoutExchange exchange = new FanoutExchange("ONLINE_EXCHANGE", true, false);
|
||||||
|
|
||||||
|
rabbitAdmin.declareExchange(exchange);
|
||||||
|
|
||||||
|
// 创建队列
|
||||||
|
Queue queue = new Queue("GO_ONLINE", true, false, false);
|
||||||
|
|
||||||
|
rabbitAdmin.declareQueue(queue);
|
||||||
|
|
||||||
|
// Fanout交换机绑定
|
||||||
|
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange));
|
||||||
|
|
||||||
|
log.info("=====>交换机创建成功");
|
||||||
|
log.info("=====>队列创建成功并绑定到交换机");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.muyu.vehicle.config;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||||
|
import com.aliyun.teautil.Common;
|
||||||
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
import com.muyu.vehicle.domain.InstanceInfo;
|
||||||
|
import com.muyu.vehicle.utils.CreateClient;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询实例信息
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询实例信息
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
public class SelectInstance {
|
||||||
|
public static List<InstanceInfo> selectInstance(List<String> instanceIds) throws Exception {
|
||||||
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
|
Client client = CreateClient.createClient();
|
||||||
|
ArrayList<InstanceInfo> instanceInfos = new ArrayList<>();// 实例基础信息
|
||||||
|
com.aliyun.ecs20140526.models.DescribeInstancesRequest describeInstancesRequest = new com.aliyun.ecs20140526.models.DescribeInstancesRequest()
|
||||||
|
.setInstanceIds(JSON.toJSONString(instanceIds))
|
||||||
|
.setRegionId("cn-shanghai");
|
||||||
|
// 创建运行时选项对象
|
||||||
|
RuntimeOptions runtime = new RuntimeOptions();
|
||||||
|
//实例ID Instances.Instance.InstanceId
|
||||||
|
//实例IP Instances.Instance.PublicIpAddress.IpAddress
|
||||||
|
//状态 Instances.Instance.Status
|
||||||
|
DescribeInstancesResponse resp = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
||||||
|
DescribeInstancesResponseBody body = resp.getBody();
|
||||||
|
|
||||||
|
ArrayList<InstanceInfo> list = new ArrayList<>();
|
||||||
|
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()){
|
||||||
|
InstanceInfo instanceInfo = new InstanceInfo();
|
||||||
|
instanceInfo.setInstanceId(instance.getInstanceId());
|
||||||
|
log.info("实例ID:{}",instanceInfo.getInstanceId());
|
||||||
|
instanceInfo.setStatus(instance.getStatus());
|
||||||
|
log.info("实例状态:{}",instanceInfo.getStatus());
|
||||||
|
instanceInfo.setIpAddress(String.valueOf(instance.getPublicIpAddress().getIpAddress()));
|
||||||
|
log.info("实例IP:{}",instanceInfo.getIpAddress());
|
||||||
|
list.add(instanceInfo);
|
||||||
|
}
|
||||||
|
System.out.println("实例信息:"+list);
|
||||||
|
log.info("实例信息:",list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.vehicle.controller;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.vehicle.domain.MqttServerModel;
|
||||||
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.vehicle.service.VehicleConnectService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/carInstance")
|
||||||
|
public class CarInstanceController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VehicleConnectService vehicleConnectService;
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/receiveMsg")
|
||||||
|
public Result receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
||||||
|
log.info("=======>"+vehicleConnectionReq);
|
||||||
|
Result<MqttServerModel> connect = vehicleConnectService.getConnect(vehicleConnectionReq);
|
||||||
|
return Result.success(connect);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.vehicle.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fluxMq配置
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class FluxMqProperties {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点
|
||||||
|
*/
|
||||||
|
private String broker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主题
|
||||||
|
*/
|
||||||
|
private String topic;
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点ID
|
||||||
|
*/
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,9 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关实例信息
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.muyu.vehicle.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mqtt服务器模型
|
||||||
|
* @author YunFei.Du
|
||||||
|
* @date 22:08 2024/5/29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MqttServerModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MQTT服务节点
|
||||||
|
*/
|
||||||
|
private String broker;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MQTT订阅主题
|
||||||
|
*/
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.muyu.vehicle.domain.req;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆连接信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName(value = "vehicle_connection")
|
||||||
|
public class VehicleConnectionReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆VIN
|
||||||
|
*/
|
||||||
|
private String vehicleVin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间戳
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 随机字符串
|
||||||
|
*/
|
||||||
|
private String nonce;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.muyu.vehicle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface VehicleConnectMapper extends BaseMapper<VehicleConnectionReq> {
|
||||||
|
|
||||||
|
VehicleConnectionReq selectByVehicleVin(String vin);
|
||||||
|
|
||||||
|
}
|
|
@ -1,129 +0,0 @@
|
||||||
package com.muyu.vehicle.service;
|
|
||||||
|
|
||||||
import com.aliyun.ecs20140526.Client;
|
|
||||||
import com.aliyun.ecs20140526.models.RunInstancesRequest;
|
|
||||||
import com.aliyun.ecs20140526.models.RunInstancesResponse;
|
|
||||||
import com.aliyun.ecs20140526.models.RunInstancesResponseBody;
|
|
||||||
import com.aliyun.tea.TeaException;
|
|
||||||
import com.aliyun.teaopenapi.models.Config;
|
|
||||||
import com.aliyun.teautil.Common;
|
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
|
||||||
import com.muyu.vehicle.ManageInstance;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
@Log4j2
|
|
||||||
public class OpenInstance {
|
|
||||||
/**
|
|
||||||
* ACCESS_KEY_ID
|
|
||||||
*/
|
|
||||||
public static final String ALIBABA_CLOUD_ACCESS_KEY_ID="LTAI5tGabdxedjfCh2uXHNrw";
|
|
||||||
|
|
||||||
/**
|
|
||||||
*ACCESS_KEY_SECRET
|
|
||||||
*/
|
|
||||||
public static final String ACCESS_KEY_SECRET="NHb7wHVpesLW6Axc0bFBs6ThhuNR10";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 镜像ID
|
|
||||||
*/
|
|
||||||
public static final String IMAGE_ID="m-uf6agr9i6g27gj23om34";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实例类型
|
|
||||||
*/
|
|
||||||
public static final String INSTANCE_TYPE="ecs.e-c1m1.large";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 安全组ID
|
|
||||||
*/
|
|
||||||
public static final String SECURITY_GROUP_ID="sg-uf6glo8c4k17szhxu7sk";
|
|
||||||
|
|
||||||
/**
|
|
||||||
*交换机ID
|
|
||||||
*/
|
|
||||||
public static final String V_SWITCH_ID="vsw-uf6xy4rbt9ggcz93t6oib";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 实例付费类型
|
|
||||||
*/
|
|
||||||
public static final String INSTANCE_CHARGE_TY="PostPaid";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用AK&SK初始化账号Client
|
|
||||||
* @return Client
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static Client createClient() throws Exception {
|
|
||||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
|
||||||
Config config = new Config()
|
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
|
||||||
.setAccessKeyId(ALIBABA_CLOUD_ACCESS_KEY_ID)
|
|
||||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
|
||||||
.setAccessKeySecret(ACCESS_KEY_SECRET);
|
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
|
||||||
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
|
||||||
return new com.aliyun.ecs20140526.Client(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void generateInstance() throws Exception {
|
|
||||||
// 创建阿里云ECS客户端
|
|
||||||
Client client = OpenInstance.createClient();
|
|
||||||
// 配置系统盘参数
|
|
||||||
RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk=
|
|
||||||
new RunInstancesRequest.RunInstancesRequestSystemDisk()
|
|
||||||
.setSize("40")
|
|
||||||
.setCategory("cloud_essd");
|
|
||||||
|
|
||||||
// 创建创建实例请求对象并设置参数
|
|
||||||
|
|
||||||
RunInstancesRequest runInstancesRequest = new RunInstancesRequest()
|
|
||||||
.setRegionId("cn-shanghai") // 设置地域ID
|
|
||||||
.setImageId(IMAGE_ID) // 设置镜像ID
|
|
||||||
.setInstanceType(INSTANCE_TYPE) // 设置实例类型
|
|
||||||
.setSecurityGroupId(SECURITY_GROUP_ID) // 设置安全组ID
|
|
||||||
.setVSwitchId(V_SWITCH_ID) // 设置虚拟交换机ID
|
|
||||||
.setInstanceName("cloud-MQTT") // 设置实例名称
|
|
||||||
.setInstanceChargeType(INSTANCE_CHARGE_TY) // 设置实例付费类型为后付费按量付费
|
|
||||||
.setSystemDisk(systemDisk) // 设置系统盘配置
|
|
||||||
.setHostName("root") // 设置主机名
|
|
||||||
.setPassword("2112A-four") // 设置实例密码
|
|
||||||
.setAmount(2) // 设置创建实例的数量
|
|
||||||
.setInternetChargeType("PayByTraffic")
|
|
||||||
.setInternetMaxBandwidthOut(1);
|
|
||||||
|
|
||||||
|
|
||||||
//创建运行时选择对象
|
|
||||||
RuntimeOptions runTime=
|
|
||||||
new RuntimeOptions();
|
|
||||||
// 尝试执行创建实例请求
|
|
||||||
try {
|
|
||||||
ArrayList<String> list = new ArrayList<>();
|
|
||||||
// 复制代码运行请自行打印 API 的返回值
|
|
||||||
RunInstancesResponse runInstancesResponse = client.runInstancesWithOptions(runInstancesRequest, runTime);
|
|
||||||
RunInstancesResponseBody body = runInstancesResponse.getBody();
|
|
||||||
for (String instance : body.getInstanceIdSets().getInstanceIdSet()) {
|
|
||||||
list.add(instance);
|
|
||||||
log.info("ESC创建成功,实例ID为:" + list);
|
|
||||||
}
|
|
||||||
} catch (TeaException error) {
|
|
||||||
// 错误 message
|
|
||||||
log.info(error.getMessage());
|
|
||||||
// 诊断地址
|
|
||||||
log.info(error.getData().get("Recommend"));
|
|
||||||
Common.assertAsString(error.message);
|
|
||||||
} catch (Exception _error) {
|
|
||||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
|
||||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
|
||||||
// 错误 message
|
|
||||||
log.info("实例创建失败:"+error.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package com.muyu.vehicle.service;
|
|
||||||
|
|
||||||
import com.aliyun.ecs20140526.Client;
|
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
|
||||||
import com.aliyun.teaopenapi.models.Config;
|
|
||||||
import com.aliyun.teautil.Common;
|
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
|
||||||
import com.muyu.vehicle.domain.InstanceInfo;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
@Log4j2
|
|
||||||
public class SelectInstance {
|
|
||||||
/**
|
|
||||||
* ACCESS_KEY_ID
|
|
||||||
*/
|
|
||||||
public static final String ALIBABA_CLOUD_ACCESS_KEY_ID="LTAI5tGabdxedjfCh2uXHNrw";
|
|
||||||
|
|
||||||
/**
|
|
||||||
*ACCESS_KEY_SECRET
|
|
||||||
*/
|
|
||||||
public static final String ACCESS_KEY_SECRET="NHb7wHVpesLW6Axc0bFBs6ThhuNR10";
|
|
||||||
|
|
||||||
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
|
||||||
Config config = new com.aliyun.teaopenapi.models.Config()
|
|
||||||
// 必填,您的 AccessKey ID
|
|
||||||
.setAccessKeyId(ALIBABA_CLOUD_ACCESS_KEY_ID)
|
|
||||||
// 必填,您的 AccessKey Secret
|
|
||||||
.setAccessKeySecret(ACCESS_KEY_SECRET);
|
|
||||||
// 访问的域名
|
|
||||||
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
|
||||||
return new Client(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args_) throws Exception {
|
|
||||||
java.util.List<String> args = java.util.Arrays.asList(args_);
|
|
||||||
// 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
|
||||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式
|
|
||||||
Client client = SelectInstance.createClient(ALIBABA_CLOUD_ACCESS_KEY_ID, ACCESS_KEY_SECRET);
|
|
||||||
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
|
||||||
.setRegionId("cn-shanghai")
|
|
||||||
.setInternetChargeType("PayByTraffic")
|
|
||||||
.setInstanceChargeType("PostPaid")
|
|
||||||
.setInstanceName("cloud-MQTT") // 设置实例名称
|
|
||||||
;
|
|
||||||
//实例ID Instances.Instance.InstanceId
|
|
||||||
//实例IP Instances.Instance.PublicIpAddress.IpAddress
|
|
||||||
//状态 Instances.Instance.Status
|
|
||||||
RuntimeOptions runtime = new RuntimeOptions();
|
|
||||||
DescribeInstancesResponse resp = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
|
||||||
DescribeInstancesResponseBody body = resp.getBody();
|
|
||||||
ArrayList<InstanceInfo> instanceInfos = new ArrayList<>();// 实例基础信息
|
|
||||||
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()){
|
|
||||||
|
|
||||||
InstanceInfo instanceInfo = new InstanceInfo();
|
|
||||||
instanceInfo.setInstanceId(instance.getInstanceId());
|
|
||||||
instanceInfo.setIpAddress(String.valueOf(instance.getPublicIpAddress().getIpAddress()));
|
|
||||||
instanceInfo.setStatus(instance.getStatus());
|
|
||||||
instanceInfos.add(instanceInfo);
|
|
||||||
}
|
|
||||||
log.info(Common.toJSONString(instanceInfos));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.muyu.vehicle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.vehicle.domain.MqttServerModel;
|
||||||
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
|
||||||
|
public interface VehicleConnectService extends IService<VehicleConnectionReq> {
|
||||||
|
|
||||||
|
Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.vehicle.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.vehicle.domain.MqttServerModel;
|
||||||
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.vehicle.mapper.VehicleConnectMapper;
|
||||||
|
import com.muyu.vehicle.service.VehicleConnectService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
public class VehicleConnectServiceImpl extends ServiceImpl<VehicleConnectMapper, VehicleConnectionReq> implements VehicleConnectService {
|
||||||
|
@Autowired
|
||||||
|
private VehicleConnectMapper vehicleConnectMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq) {
|
||||||
|
log.info("车辆连接信息:{}", vehicleConnectionReq);
|
||||||
|
//生成密码
|
||||||
|
vehicleConnectionReq.setPassword(vehicleConnectionReq.getVehicleVin() + vehicleConnectionReq.getTimestamp()
|
||||||
|
+ vehicleConnectionReq.getNonce());
|
||||||
|
|
||||||
|
VehicleConnectionReq connection = vehicleConnectMapper.selectByVehicleVin(vehicleConnectionReq.getVehicleVin());
|
||||||
|
if (connection==null){
|
||||||
|
vehicleConnectMapper.insert(vehicleConnectionReq);
|
||||||
|
log.info("车辆预上线成功");
|
||||||
|
}else {
|
||||||
|
log.info("车辆已预上线成功,禁止重复");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
package com.muyu.vehicle.utils;
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建ECS客户端对象
|
||||||
|
*/
|
||||||
|
public class CreateClient {
|
||||||
|
/**
|
||||||
|
* ACCESS_KEY_ID
|
||||||
|
*/
|
||||||
|
public static final String ALIBABA_CLOUD_ACCESS_KEY_ID = "LTAI5tGabdxedjfCh2uXHNrw";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*ACCESS_KEY_SECRET
|
||||||
|
*/
|
||||||
|
public static final String ACCESS_KEY_SECRET = "NHb7wHVpesLW6Axc0bFBs6ThhuNR10";
|
||||||
|
|
||||||
|
public static Client createClient() throws Exception {
|
||||||
|
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||||
|
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||||
|
Config config = new Config()
|
||||||
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||||
|
.setAccessKeyId(ALIBABA_CLOUD_ACCESS_KEY_ID)
|
||||||
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||||
|
.setAccessKeySecret(ACCESS_KEY_SECRET);
|
||||||
|
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||||
|
config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
|
||||||
|
return new Client(config);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,10 +7,12 @@ 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: sx
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: cloud-vehicleGateway
|
name: cloud-vehicleGateway
|
||||||
|
|
|
@ -51,6 +51,16 @@
|
||||||
<groupId>org.apache.kafka</groupId>
|
<groupId>org.apache.kafka</groupId>
|
||||||
<artifactId>kafka-clients</artifactId>
|
<artifactId>kafka-clients</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.baomidou</groupId>-->
|
||||||
|
<!-- <artifactId>mybatis-plus-boot-starter</artifactId>-->
|
||||||
|
<!-- <version>3.5.1</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -42,6 +42,11 @@
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-saas</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
@ -101,6 +106,7 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-xxl</artifactId>
|
<artifactId>cloud-common-xxl</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.iotdb</groupId>
|
<groupId>org.apache.iotdb</groupId>
|
||||||
<artifactId>service-rpc</artifactId>
|
<artifactId>service-rpc</artifactId>
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package com.muyu.server;
|
package com.muyu.server;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||||
|
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||||
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* saas模块启动类
|
* saas模块启动类
|
||||||
* @author YuPing
|
* @author YuPing
|
||||||
|
@ -9,7 +16,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
* @Data 2024-09-28 17:34:31
|
* @Data 2024-09-28 17:34:31
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication(exclude = {
|
||||||
|
DataSourceAutoConfiguration.class,
|
||||||
|
DruidDataSourceAutoConfigure.class,
|
||||||
|
DynamicDataSourceAutoConfiguration.class
|
||||||
|
})
|
||||||
|
@EnableCustomConfig
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
public class SaasApplication {
|
public class SaasApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -21,8 +21,6 @@ import java.util.List;
|
||||||
* @Date 2024/9/29 12:06
|
* @Date 2024/9/29 12:06
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/carType")
|
@RequestMapping("/carType")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
package com.muyu.server.controller;
|
package com.muyu.server.controller;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
||||||
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.domain.Enterprise;
|
import com.muyu.common.domain.Enterprise;
|
||||||
|
import com.muyu.common.system.domain.Business;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
import com.muyu.common.util.PageUtils;
|
import com.muyu.common.util.PageUtils;
|
||||||
import com.muyu.server.controller.form.DeleteEnterpriseByIds;
|
import com.muyu.server.controller.form.DeleteEnterpriseByIds;
|
||||||
import com.muyu.server.controller.form.InsertEnterprise;
|
import com.muyu.server.controller.form.InsertEnterprise;
|
||||||
|
@ -14,8 +19,16 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
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.core.io.ClassPathResource;
|
||||||
|
import org.springframework.core.io.support.EncodedResource;
|
||||||
|
import org.springframework.jdbc.datasource.init.ScriptUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -35,6 +48,9 @@ public class EnterpriseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private EnterpriseService enterpriseService;
|
private EnterpriseService enterpriseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询分页企业信息
|
* 查询分页企业信息
|
||||||
|
@ -72,6 +88,56 @@ public class EnterpriseController {
|
||||||
enterprise.setEnterpriseFenceCount(form.getEnterpriseFenceCount());
|
enterprise.setEnterpriseFenceCount(form.getEnterpriseFenceCount());
|
||||||
|
|
||||||
int rows = enterpriseService.insert(enterprise);
|
int rows = enterpriseService.insert(enterprise);
|
||||||
|
if (rows == 0){
|
||||||
|
return Result.error("新增失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
Business business = new Business();
|
||||||
|
business.setFirmName(form.getEnterpriseName());
|
||||||
|
business.setDatabaseName(form.getEnterpriseDatabaseName());
|
||||||
|
remoteUserService.settlementEnterpriseInfo(business, SecurityConstants.INNER);
|
||||||
|
|
||||||
|
SysUser sysUser = new SysUser();
|
||||||
|
sysUser.setDatabaseName(form.getEnterpriseDatabaseName());
|
||||||
|
sysUser.setUserName(form.getEnterpriseName());
|
||||||
|
sysUser.setCreateTime(new Date());
|
||||||
|
remoteUserService.addUser(sysUser, SecurityConstants.INNER);
|
||||||
|
String createDatabaseUrl="jdbc:mysql://"+ DatasourceContent.IP+":"+DatasourceContent.PORT+"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||||
|
String createDatabaseSql = "CREATE DATABASE IF NOT EXISTS " + form.getEnterpriseDatabaseName() + ";";
|
||||||
|
|
||||||
|
try (Connection adminConn = DriverManager.getConnection(createDatabaseUrl, DatasourceContent.USER_NAME, DatasourceContent.PASSWORD);
|
||||||
|
Statement stmt = adminConn.createStatement()) {
|
||||||
|
|
||||||
|
boolean success = stmt.execute(createDatabaseSql);
|
||||||
|
if (success) {
|
||||||
|
log.info("数据库 {} 创建失败", form.getEnterpriseDatabaseName());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.warn("数据库 {} 创建成功", form.getEnterpriseDatabaseName());
|
||||||
|
|
||||||
|
// 切换到新的数据库连接
|
||||||
|
Connection connection = null;
|
||||||
|
try {
|
||||||
|
String url = "jdbc:mysql://47.101.53.251:3306/" + form.getEnterpriseDatabaseName() + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||||
|
String user = "root";
|
||||||
|
String pwd = "Lw030106";
|
||||||
|
String driverClassName = "com.mysql.cj.jdbc.Driver";
|
||||||
|
Class.forName(driverClassName);
|
||||||
|
connection = DriverManager.getConnection(url, user, pwd);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
ClassPathResource rc = new ClassPathResource("static/saas.sql");
|
||||||
|
EncodedResource er = new EncodedResource(rc, "utf-8");
|
||||||
|
ScriptUtils.executeSqlScript(connection, er);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("连接数据库时发生错误或创建数据库失败", e);
|
||||||
|
}
|
||||||
return Result.success(rows);
|
return Result.success(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class SysCarFaultController extends BaseController
|
||||||
@Validated @RequestBody SysCarFault sysCarFault)
|
@Validated @RequestBody SysCarFault sysCarFault)
|
||||||
{
|
{
|
||||||
//判断故障码是否重复
|
//判断故障码是否重复
|
||||||
SysCarFault selectFaultByFaultCode = sysCarFaultService.selectFaultByFaultCode(sysCarFault.getFaultCode());
|
List<SysCarFault> selectFaultByFaultCode = sysCarFaultService.selectFaultByFaultCode(sysCarFault.getFaultCode());
|
||||||
if (selectFaultByFaultCode!=null){
|
if (selectFaultByFaultCode!=null){
|
||||||
return error("新增车辆故障 ,故障码已存在");
|
return error("新增车辆故障 ,故障码已存在");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.muyu.server.controller;
|
package com.muyu.server.controller;
|
||||||
|
|
||||||
import com.muyu.cache.TemplateCacheService;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.domain.Template;
|
import com.muyu.common.domain.Template;
|
||||||
import com.muyu.server.service.TemplateService;
|
import com.muyu.server.service.TemplateService;
|
||||||
|
@ -35,9 +34,6 @@ public class TemplateController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplateService templateService;
|
private TemplateService templateService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TemplateCacheService templateCacheService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报文模版列表
|
* 报文模版列表
|
||||||
* @return
|
* @return
|
||||||
|
@ -45,19 +41,24 @@ public class TemplateController {
|
||||||
@PostMapping("/templateList")
|
@PostMapping("/templateList")
|
||||||
@Operation(summary = "报文模版列表",description = "报文模版列表")
|
@Operation(summary = "报文模版列表",description = "报文模版列表")
|
||||||
public Result<List<Template>> templateList() {
|
public Result<List<Template>> templateList() {
|
||||||
|
return Result.success(templateService.list());
|
||||||
List<Template> list = templateService.list();
|
|
||||||
|
|
||||||
templateCacheService.put("List",list);
|
|
||||||
|
|
||||||
return Result.success(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析报文
|
||||||
|
* @param templateMessage
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/messageParsing")
|
||||||
|
@Operation(summary = "报文解析",description = "报文解析")
|
||||||
|
public Result messageParsing(@RequestParam("templateMessage") String templateMessage) throws SQLException, IoTDBConnectionException, ClassNotFoundException, StatementExecutionException, ExecutionException, InterruptedException {
|
||||||
|
templateService.messageParsing(templateMessage);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报文模版添加
|
* 报文模版添加0002222220
|
||||||
* @param template
|
* @param template
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,6 +5,9 @@ import javax.annotation.Resource;
|
||||||
import com.muyu.common.domain.WarnStrategy;
|
import com.muyu.common.domain.WarnStrategy;
|
||||||
import com.muyu.common.domain.req.WarnStrategyReq;
|
import com.muyu.common.domain.req.WarnStrategyReq;
|
||||||
import com.muyu.server.service.WarnStrategyService;
|
import com.muyu.server.service.WarnStrategyService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
@ -23,6 +26,8 @@ import com.muyu.common.core.domain.Result;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/strategy")
|
@RequestMapping("/strategy")
|
||||||
|
@Log4j2
|
||||||
|
@Tag(name = "预警策略管理",description = "预警策略管理")
|
||||||
public class WarnStrategyController extends BaseController
|
public class WarnStrategyController extends BaseController
|
||||||
{
|
{
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -32,6 +37,7 @@ public class WarnStrategyController extends BaseController
|
||||||
* 查询预警策略列表
|
* 查询预警策略列表
|
||||||
*/
|
*/
|
||||||
@PostMapping("/selectWarnStrategyList")
|
@PostMapping("/selectWarnStrategyList")
|
||||||
|
@Operation(summary = "预警策略列表",description = "预警策略列表")
|
||||||
public Result selectWarnStrategyList(@RequestBody WarnStrategyReq warnStrategyReq)
|
public Result selectWarnStrategyList(@RequestBody WarnStrategyReq warnStrategyReq)
|
||||||
{
|
{
|
||||||
return Result.success(warnStrategyService.selectWarnStrategyList(warnStrategyReq));
|
return Result.success(warnStrategyService.selectWarnStrategyList(warnStrategyReq));
|
||||||
|
@ -42,6 +48,7 @@ public class WarnStrategyController extends BaseController
|
||||||
* 获取预警策略详细信息
|
* 获取预警策略详细信息
|
||||||
*/
|
*/
|
||||||
@GetMapping( "selectById/{id}")
|
@GetMapping( "selectById/{id}")
|
||||||
|
@Operation(summary = "预警策略详细信息",description = "预警策略详细信息")
|
||||||
public Result selectById(@PathVariable("id") Long id)
|
public Result selectById(@PathVariable("id") Long id)
|
||||||
{
|
{
|
||||||
return success(warnStrategyService.selectWarnStrategyById(id));
|
return success(warnStrategyService.selectWarnStrategyById(id));
|
||||||
|
@ -51,6 +58,7 @@ public class WarnStrategyController extends BaseController
|
||||||
* 新增预警策略
|
* 新增预警策略
|
||||||
*/
|
*/
|
||||||
@PostMapping("/addWarnStrategy")
|
@PostMapping("/addWarnStrategy")
|
||||||
|
@Operation(summary = "预警策略添加",description = "预警策略添加")
|
||||||
public Result addWarnStrategy(@RequestBody WarnStrategy warnStrategy)
|
public Result addWarnStrategy(@RequestBody WarnStrategy warnStrategy)
|
||||||
{
|
{
|
||||||
Integer i = warnStrategyService.addWarnStrategy(warnStrategy);
|
Integer i = warnStrategyService.addWarnStrategy(warnStrategy);
|
||||||
|
@ -61,6 +69,7 @@ public class WarnStrategyController extends BaseController
|
||||||
* 修改预警策略
|
* 修改预警策略
|
||||||
*/
|
*/
|
||||||
@PostMapping("/updWarnStrategy")
|
@PostMapping("/updWarnStrategy")
|
||||||
|
@Operation(summary = "预警策略修改",description = "预警策略修改")
|
||||||
public Result updWarnStrategy(@RequestBody WarnStrategy warnStrategy)
|
public Result updWarnStrategy(@RequestBody WarnStrategy warnStrategy)
|
||||||
{
|
{
|
||||||
Integer i = warnStrategyService.updWarnStrategy(warnStrategy);
|
Integer i = warnStrategyService.updWarnStrategy(warnStrategy);
|
||||||
|
@ -71,6 +80,7 @@ public class WarnStrategyController extends BaseController
|
||||||
* 删除预警策略
|
* 删除预警策略
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("deleteWarnStrategy/{id}")
|
@DeleteMapping("deleteWarnStrategy/{id}")
|
||||||
|
@Operation(summary = "预警策略删除",description = "预警策略删除")
|
||||||
public Result deleteWarnStrategy(@PathVariable("id") Long id)
|
public Result deleteWarnStrategy(@PathVariable("id") Long id)
|
||||||
{
|
{
|
||||||
Integer i = warnStrategyService.deleteWarnStrategy(id);
|
Integer i = warnStrategyService.deleteWarnStrategy(id);
|
||||||
|
@ -83,6 +93,7 @@ public class WarnStrategyController extends BaseController
|
||||||
* 根据车辆类型ID查询策略
|
* 根据车辆类型ID查询策略
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectListByCarType/{carTypeId}")
|
@GetMapping("/selectListByCarType/{carTypeId}")
|
||||||
|
@Operation(summary = "根据车辆类型ID查询策略",description = "根据车辆类型ID查询策略")
|
||||||
public Result selectListByCarType(@PathVariable("carTypeId") Long carTypeId) {
|
public Result selectListByCarType(@PathVariable("carTypeId") Long carTypeId) {
|
||||||
return Result.success(warnStrategyService.selectListByCarType(carTypeId));
|
return Result.success(warnStrategyService.selectListByCarType(carTypeId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ import java.util.Map;
|
||||||
* 企业信息Mapper接口
|
* 企业信息Mapper接口
|
||||||
* @author yupnig
|
* @author yupnig
|
||||||
* @package com.muyu.server.mapper
|
* @package com.muyu.server.mapper
|
||||||
* @name EnterpriseDao
|
* @name EnterpriseMapper
|
||||||
* @date 2024-09-29 14:31:06
|
* @date 2024-09-29 14:31:06
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface EnterpriseDao {
|
public interface EnterpriseMapper {
|
||||||
// 查询分页信息
|
// 查询分页信息
|
||||||
public ArrayList<HashMap> selectEnterprise(Map param);
|
public ArrayList<HashMap> selectEnterprise(Map param);
|
||||||
//查询企业记录总数
|
//查询企业记录总数
|
|
@ -17,16 +17,6 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SysCarFaultMapper extends BaseMapper<SysCarFault> {
|
public interface SysCarFaultMapper extends BaseMapper<SysCarFault> {
|
||||||
|
|
||||||
//根据添加的故障码进行查询
|
|
||||||
@Select("select fault_code from sys_car_fault where fault_code=#{faultCode}")
|
|
||||||
SysCarFault selectFaultByFaultCode(String faultCode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询故障码信息
|
|
||||||
* @param ids 故障码信息主键
|
|
||||||
* @return 故障码信息
|
|
||||||
*/
|
|
||||||
public List<SysCarFault> selectSysCarFaultIds(String[] ids);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,8 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SysCarFaultMessageMapper extends BaseMapper<SysCarFaultMessage> {
|
public interface SysCarFaultMessageMapper extends BaseMapper<SysCarFaultMessage> {
|
||||||
|
|
||||||
// 查询状态等于1的记录
|
|
||||||
@Select("select * from sys_car_fault_message where status=1")
|
|
||||||
public List<SysCarFaultMessage>listStatusOnt( );
|
|
||||||
//查询状态等于2的记录
|
|
||||||
@Select("select * from sys_car_fault_message where status=2")
|
|
||||||
public List<SysCarFaultMessage>listStatusTwo( );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,6 @@ public interface SysCarMapper extends BaseMapper<SysCar> {
|
||||||
|
|
||||||
SysCar findCarByVin(@Param("carVin") String carVin);
|
SysCar findCarByVin(@Param("carVin") String carVin);
|
||||||
|
|
||||||
SysCar selectByCarVin(@Param("carVin") String carVin);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TemplateMapper extends BaseMapper<Template> {
|
public interface TemplateMapper extends BaseMapper<Template> {
|
||||||
|
|
||||||
List<MessageTemplateType> findTemplateById(@Param("templateId") Integer templateId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.server.mapper;
|
package com.muyu.server.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.common.domain.MessageTemplateType;
|
import com.muyu.common.domain.MessageTemplateType;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
@ -14,6 +15,6 @@ import java.util.List;
|
||||||
* @date 2024-09-29 14:44:57
|
* @date 2024-09-29 14:44:57
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TemplateNeedMapper {
|
public interface TemplateNeedMapper extends BaseMapper<MessageTemplateType> {
|
||||||
List<MessageTemplateType> selectByTemplateId(@Param("templateId")Long templateId);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预警策略Mapper接口
|
* 预警策略Mapper接口
|
||||||
* @author muyu
|
* @author sx
|
||||||
* @package com.muyu.server.mapper
|
* @package com.muyu.server.mapper
|
||||||
* @name WarnStrategyMapper
|
* @name WarnStrategyMapper
|
||||||
* @date 2024-09-20
|
* @date 2024-09-20
|
||||||
|
|
|
@ -36,7 +36,7 @@ public interface SysCarFaultService extends IService<SysCarFault> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SysCarFault selectFaultByFaultCode(String faultCode);
|
List<SysCarFault> selectFaultByFaultCode(String faultCode);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.server.service;
|
package com.muyu.server.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.common.domain.MessageTemplateType;
|
import com.muyu.common.domain.MessageTemplateType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -12,6 +13,6 @@ import java.util.List;
|
||||||
* @date 2024-09-29 15:31:55
|
* @date 2024-09-29 15:31:55
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface TemplateNeedService {
|
public interface TemplateNeedService extends IService<MessageTemplateType> {
|
||||||
List<MessageTemplateType> selectByTemplateId(Long templateId);
|
List<MessageTemplateType> selectByTemplateId(Long templateId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.muyu.server.service.CarTypeService;
|
||||||
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 javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@ import cn.hutool.core.map.MapUtil;
|
||||||
import com.muyu.cache.EnterpriseCacheService;
|
import com.muyu.cache.EnterpriseCacheService;
|
||||||
import com.muyu.common.domain.Enterprise;
|
import com.muyu.common.domain.Enterprise;
|
||||||
import com.muyu.common.util.PageUtils;
|
import com.muyu.common.util.PageUtils;
|
||||||
import com.muyu.server.mapper.EnterpriseDao;
|
import com.muyu.server.mapper.EnterpriseMapper;
|
||||||
import com.muyu.server.service.EnterpriseService;
|
import com.muyu.server.service.EnterpriseService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -22,7 +22,7 @@ import java.util.*;
|
||||||
public class EnterpriseServiceImpl implements EnterpriseService {
|
public class EnterpriseServiceImpl implements EnterpriseService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EnterpriseDao enterpriseDao;
|
private EnterpriseMapper enterpriseDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EnterpriseCacheService enterpriseCacheService;
|
private EnterpriseCacheService enterpriseCacheService;
|
||||||
|
|
|
@ -50,8 +50,9 @@ public class SysCarFaultMessageServiceImpl extends ServiceImpl<SysCarFaultMessag
|
||||||
@Override
|
@Override
|
||||||
public List<SysCarFaultMessage> listStatusOnt( ) {
|
public List<SysCarFaultMessage> listStatusOnt( ) {
|
||||||
|
|
||||||
List<SysCarFaultMessage> list = baseMapper.listStatusOnt();
|
LambdaQueryWrapper<SysCarFaultMessage> wrapper = new LambdaQueryWrapper<>();
|
||||||
return list;
|
wrapper.eq(SysCarFaultMessage::getStatus,1);
|
||||||
|
return this.list(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +61,9 @@ public class SysCarFaultMessageServiceImpl extends ServiceImpl<SysCarFaultMessag
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysCarFaultMessage> listStatusTwo( ) {
|
public List<SysCarFaultMessage> listStatusTwo( ) {
|
||||||
List<SysCarFaultMessage> list = baseMapper.listStatusTwo();
|
|
||||||
return list;
|
LambdaQueryWrapper<SysCarFaultMessage> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SysCarFaultMessage::getStatus,2);
|
||||||
|
return this.list(wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,12 @@ public class SysCarFaultServiceImpl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysCarFault selectFaultByFaultCode(String faultCode) {
|
public List<SysCarFault> selectFaultByFaultCode(String faultCode) {
|
||||||
return mapper.selectFaultByFaultCode(faultCode);
|
LambdaQueryWrapper<SysCarFault> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SysCarFault::getFaultCode, faultCode);
|
||||||
|
return this.list(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,16 @@ import com.muyu.server.service.SysCarService;
|
||||||
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.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆管理 服务层处理
|
||||||
|
* @author sx
|
||||||
|
* @package com.muyu.server.service.impl
|
||||||
|
* @name SysCarServiceImpl
|
||||||
|
* @date 2024-09-29 14:31:06
|
||||||
|
*/
|
||||||
@DS("lizzDB")
|
@DS("lizzDB")
|
||||||
@Service
|
@Service
|
||||||
public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> implements SysCarService {
|
public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> implements SysCarService {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.cache.MessageTemplateTypeCacheService;
|
import com.muyu.cache.MessageTemplateTypeCacheService;
|
||||||
import com.muyu.common.domain.MessageTemplateType;
|
import com.muyu.common.domain.MessageTemplateType;
|
||||||
import com.muyu.server.mapper.TemplateNeedMapper;
|
import com.muyu.server.mapper.TemplateNeedMapper;
|
||||||
|
@ -17,14 +19,21 @@ import java.util.List;
|
||||||
* @date 2024/9/22 14:36
|
* @date 2024/9/22 14:36
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TemplateNeedServiceImpl implements TemplateNeedService {
|
public class TemplateNeedServiceImpl extends ServiceImpl<TemplateNeedMapper, MessageTemplateType> implements TemplateNeedService {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TemplateNeedMapper templateNeedMapper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MessageTemplateType> selectByTemplateId(Long templateId) {
|
public List<MessageTemplateType> selectByTemplateId(Long templateId) {
|
||||||
List<MessageTemplateType> messageTemplateTypes = templateNeedMapper.selectByTemplateId(templateId);
|
|
||||||
return messageTemplateTypes;
|
LambdaQueryWrapper<MessageTemplateType> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
|
wrapper.eq(MessageTemplateType::getTemplateId, templateId);
|
||||||
|
|
||||||
|
return this.list(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.muyu.server.service.impl;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.cache.SysCarCacheService;
|
|
||||||
import com.muyu.common.domain.MessageTemplateType;
|
import com.muyu.common.domain.MessageTemplateType;
|
||||||
import com.muyu.common.domain.SysCar;
|
import com.muyu.common.domain.SysCar;
|
||||||
import com.muyu.common.domain.Template;
|
import com.muyu.common.domain.Template;
|
||||||
|
@ -21,7 +20,8 @@ import java.sql.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
/**
|
/**
|
||||||
* @Author:liuxinyue
|
* 报文模版 服务层处理
|
||||||
|
* @author liuxinyue
|
||||||
* @Package:com.template.service.impl
|
* @Package:com.template.service.impl
|
||||||
* @Project:cloud-server-c
|
* @Project:cloud-server-c
|
||||||
* @name:TemplateServiceImp
|
* @name:TemplateServiceImp
|
||||||
|
@ -31,8 +31,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
@Service
|
@Service
|
||||||
public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> implements TemplateService {
|
public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> implements TemplateService {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private static TemplateMapper templateMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysCarService sysCarService;
|
private SysCarService sysCarService;
|
||||||
|
|
|
@ -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: four
|
||||||
# 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:
|
||||||
|
|
|
@ -1,9 +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.server.mapper.CarTypeMapper">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
|
|
@ -6,7 +6,7 @@
|
||||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||||
-->
|
-->
|
||||||
<mapper namespace="com.muyu.server.mapper.EnterpriseDao">
|
<mapper namespace="com.muyu.server.mapper.EnterpriseMapper">
|
||||||
|
|
||||||
<!--查询企业信息-->
|
<!--查询企业信息-->
|
||||||
<select id="selectEnterprise" resultType="HashMap" parameterType="Map">
|
<select id="selectEnterprise" resultType="HashMap" parameterType="Map">
|
||||||
|
@ -27,19 +27,18 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--新增企业信息-->
|
<!--新增企业信息-->
|
||||||
<insert id="insert" parameterType="com.muyu.server.mapper.EnterpriseDao">
|
<insert id="insert" parameterType="com.muyu.server.mapper.EnterpriseMapper">
|
||||||
insert into tb_enterprise
|
insert into tb_enterprise
|
||||||
set enterprise_name = #{enterpriseName},
|
set enterprise_name = #{enterpriseName},
|
||||||
enterprise_car_count = #{enterpriseCarCount},
|
enterprise_car_count = #{enterpriseCarCount},
|
||||||
enterprise_fence_count = #{enterpriseFenceCount},
|
enterprise_fence_count = #{enterpriseFenceCount}
|
||||||
enterprise_database_name=#{enterpriseDatabaseName}
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--根据编号查询企业信息-->
|
<!--根据编号查询企业信息-->
|
||||||
<select id="searchById" resultType="java.util.HashMap">
|
<select id="searchById" resultType="java.util.HashMap">
|
||||||
select enterprise_id,enterprise_name,enterprise_car_count,enterprise_fence_count,enterprise_database_name
|
select enterprise_id,enterprise_name,enterprise_car_count,enterprise_fence_count
|
||||||
from tb_enterprise
|
from tb_enterprise
|
||||||
where enterprise_id = #{enterpriseId}
|
where enterprise_id = #{enterpriseId}
|
||||||
</select>
|
</select>
|
||||||
|
@ -48,8 +47,7 @@
|
||||||
update tb_enterprise
|
update tb_enterprise
|
||||||
set enterprise_name = #{enterpriseName},
|
set enterprise_name = #{enterpriseName},
|
||||||
enterprise_car_count = #{enterpriseCarCount},
|
enterprise_car_count = #{enterpriseCarCount},
|
||||||
enterprise_fence_count = #{enterpriseFenceCount},
|
enterprise_fence_count = #{enterpriseFenceCount}
|
||||||
enterprise_database_name=#{enterpriseDatabaseName}
|
|
||||||
where enterprise_id = #{enterpriseId} and enterprise_id != 0
|
where enterprise_id = #{enterpriseId} and enterprise_id != 0
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,374 @@
|
||||||
|
/*
|
||||||
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
|
Source Server : 组
|
||||||
|
Source Server Type : MySQL
|
||||||
|
Source Server Version : 80401
|
||||||
|
Source Host : 47.101.53.251:3306
|
||||||
|
Source Schema : saas
|
||||||
|
|
||||||
|
Target Server Type : MySQL
|
||||||
|
Target Server Version : 80401
|
||||||
|
File Encoding : 65001
|
||||||
|
|
||||||
|
Date: 04/10/2024 16:01:07
|
||||||
|
*/
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for car_type
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `car_type`;
|
||||||
|
CREATE TABLE `car_type` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT COMMENT '车辆类型Id',
|
||||||
|
`type_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆类型',
|
||||||
|
`template_id` int NULL DEFAULT NULL COMMENT '报文模版Id',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆类型' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for data_type
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `data_type`;
|
||||||
|
CREATE TABLE `data_type` (
|
||||||
|
`data_type_id` int NOT NULL AUTO_INCREMENT COMMENT '报文数据类型Id',
|
||||||
|
`data_type_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文数据类型',
|
||||||
|
PRIMARY KEY (`data_type_id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '报文数据类型' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for electronic_fence
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `electronic_fence`;
|
||||||
|
CREATE TABLE `electronic_fence` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT COMMENT '围栏主键',
|
||||||
|
`name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '围栏名称',
|
||||||
|
`fence_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '围栏类型(驶入,驶出)',
|
||||||
|
`longitude_latitude` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '经纬度信息',
|
||||||
|
`status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '电子围栏状态(正常,停用)',
|
||||||
|
`fence_desc` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '描述信息',
|
||||||
|
`create_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '备注',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '电子围栏' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for electronic_fence_group
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `electronic_fence_group`;
|
||||||
|
CREATE TABLE `electronic_fence_group` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
|
||||||
|
`group_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '围栏组名称',
|
||||||
|
`group_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '围栏组类型',
|
||||||
|
`priority` int NULL DEFAULT NULL COMMENT '围栏组优先级(0-99)',
|
||||||
|
`status` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '启用状态',
|
||||||
|
`create_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '备注',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '围栏组' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for fence_group_mid
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `fence_group_mid`;
|
||||||
|
CREATE TABLE `fence_group_mid` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`group_id` int NULL DEFAULT NULL COMMENT '围栏组外键',
|
||||||
|
`fence_id` int NULL DEFAULT NULL COMMENT '电子围栏外键',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 23 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '电子围栏-围栏组(中间表)' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for message_template
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `message_template`;
|
||||||
|
CREATE TABLE `message_template` (
|
||||||
|
`message_id` int(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
|
||||||
|
`vin_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'VIN 码',
|
||||||
|
`time_stamp` datetime NULL DEFAULT NULL COMMENT '时间戳',
|
||||||
|
`long_itude` double NULL DEFAULT NULL COMMENT '经度',
|
||||||
|
`latitude` double NULL DEFAULT NULL COMMENT '纬度',
|
||||||
|
`speed_vehicle` double NULL DEFAULT NULL COMMENT '车速',
|
||||||
|
`total_mileage` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '总里程',
|
||||||
|
`total_voltage` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '总电压',
|
||||||
|
`combined_current` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '总电流',
|
||||||
|
`insulation_resistance` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '绝缘电阻',
|
||||||
|
`gear_position` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '档位',
|
||||||
|
`accelerator_pedal_travel_value` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '加速踏板行程值',
|
||||||
|
`brake_pedal_travel_value` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '制动踏板行程值',
|
||||||
|
`specific_fuel_consumption` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '燃料消耗率',
|
||||||
|
`motor_controller_temperature` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电机控制器温度',
|
||||||
|
`motor_speed` double NULL DEFAULT NULL COMMENT '电机转速',
|
||||||
|
`motor_torque` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电机转矩',
|
||||||
|
`motor_temperature` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电机温度',
|
||||||
|
`motor_voltage` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电机电压',
|
||||||
|
`motor_current` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电机电流',
|
||||||
|
`power_battery_remaining_soc` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '剩余电池电量',
|
||||||
|
`maximum_feedback_power` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最大反馈功率',
|
||||||
|
`maximum_discharge_power` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最大放电功率',
|
||||||
|
`bms_self_check_counter` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'BMS自检计数器',
|
||||||
|
`power_battery` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '动力电池',
|
||||||
|
`total_voltage_load_side` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '总电压负载侧',
|
||||||
|
`maximum_voltage` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最大电压',
|
||||||
|
`minimum_voltage` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最小电压',
|
||||||
|
`maximum_temperature` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最高温度',
|
||||||
|
`minimum_temperature` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最低温度',
|
||||||
|
`available_capacity` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '可用功率',
|
||||||
|
`vehicle_status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆状态',
|
||||||
|
`charging_state` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '充电状态',
|
||||||
|
`operational_status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '行驶状态',
|
||||||
|
`soc` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单芯片系统',
|
||||||
|
`energy_storage_devices` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '能源存储设备',
|
||||||
|
`drive_motor_condition` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '驱动电机转态',
|
||||||
|
`whether_works` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '是否有效',
|
||||||
|
`eas` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电子防窃系统',
|
||||||
|
`ptc` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '正常温度系数',
|
||||||
|
`eps` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '蓄电池',
|
||||||
|
`abs` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '防抱死制动系统',
|
||||||
|
`mcu` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '单片机',
|
||||||
|
`heating_state` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '加热状态',
|
||||||
|
`power_battery_status` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT '' COMMENT '电源电池状态',
|
||||||
|
`state_battery_insulation` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态电池绝缘',
|
||||||
|
`dcdc` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '直流直流变换器',
|
||||||
|
`chg` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '变化',
|
||||||
|
`check_digit` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '校验数位',
|
||||||
|
`cutoff_bit` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '截止点',
|
||||||
|
PRIMARY KEY (`message_id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '报文模版' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for message_template_type
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `message_template_type`;
|
||||||
|
CREATE TABLE `message_template_type` (
|
||||||
|
`message_template_type_id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`message_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '编码',
|
||||||
|
`message_field` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '标签',
|
||||||
|
`start_index` int NULL DEFAULT NULL COMMENT '起始位',
|
||||||
|
`end_index` int NULL DEFAULT NULL COMMENT '终值位',
|
||||||
|
`data_type_id` int NULL DEFAULT NULL COMMENT '报文数据类型Id',
|
||||||
|
`data_type_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文数据类型名称',
|
||||||
|
`fixed_value` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最小值',
|
||||||
|
`range_value` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最大值',
|
||||||
|
`template_id` int NULL DEFAULT NULL COMMENT '模版Id',
|
||||||
|
`message_class` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文类别',
|
||||||
|
PRIMARY KEY (`message_template_type_id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 76 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '报文模版类型' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for message_value
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `message_value`;
|
||||||
|
CREATE TABLE `message_value` (
|
||||||
|
`message_id` bigint NOT NULL AUTO_INCREMENT COMMENT '报文主键',
|
||||||
|
`template_id` bigint NULL DEFAULT NULL COMMENT '模版外键',
|
||||||
|
`message_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '报文编码',
|
||||||
|
`message_label` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '报文标签',
|
||||||
|
`message_start_index` int NULL DEFAULT NULL COMMENT '起始位',
|
||||||
|
`message_end_index` int NULL DEFAULT NULL COMMENT '终止位',
|
||||||
|
`create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||||
|
`message_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`message_id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 61 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '报文' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for sys_car
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `sys_car`;
|
||||||
|
CREATE TABLE `sys_car` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`car_vin` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'VIN码',
|
||||||
|
`car_type_id` int NULL DEFAULT NULL COMMENT '车辆类型Id',
|
||||||
|
`state` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '状态',
|
||||||
|
`fence_id` int NULL DEFAULT NULL COMMENT '电子围栏',
|
||||||
|
`car_motor_manufacturer` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆电机厂商',
|
||||||
|
`car_motor_model` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电机型号',
|
||||||
|
`car_battery_manufacturer` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆电池厂商',
|
||||||
|
`car_battery_model` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '电池型号',
|
||||||
|
`strategy_id` int NULL DEFAULT NULL COMMENT '策略ID',
|
||||||
|
`group_id` int NULL DEFAULT NULL COMMENT '围栏组ID',
|
||||||
|
`create_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '修改人',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
|
||||||
|
`remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
|
||||||
|
`template_id` int NULL DEFAULT NULL COMMENT '报文模版ID',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆基础信息表' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for sys_car_enterprise
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `sys_car_enterprise`;
|
||||||
|
CREATE TABLE `sys_car_enterprise` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`enterprise_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业名称',
|
||||||
|
`name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用户姓名',
|
||||||
|
`position` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用户职位',
|
||||||
|
`province` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '公司所在省',
|
||||||
|
`city` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '公司所在市',
|
||||||
|
`county` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '公司所在县/区',
|
||||||
|
`address` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '公司详细地址',
|
||||||
|
`credit_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '统一社会信用代码',
|
||||||
|
`business_license` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '营业执照',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '企业' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for sys_car_fault
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `sys_car_fault`;
|
||||||
|
CREATE TABLE `sys_car_fault` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '参数主键',
|
||||||
|
`fault_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '故障码编码',
|
||||||
|
`fault_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '故障名',
|
||||||
|
`type_id` int NULL DEFAULT NULL COMMENT '故障类型',
|
||||||
|
`fault_label` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '故障标签',
|
||||||
|
`fault_bit` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '故障位',
|
||||||
|
`fault_value` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '故障值',
|
||||||
|
`fault_rank` int NULL DEFAULT NULL COMMENT '故障级别 (0.低 ,1.中 ,2.高)',
|
||||||
|
`fault_desc` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '故障描述信息',
|
||||||
|
`fault_min_threshold` int NULL DEFAULT NULL COMMENT '故障最小阈值',
|
||||||
|
`fault_max_threshold` int NULL DEFAULT NULL COMMENT '故障最大阈值',
|
||||||
|
`status` int NULL DEFAULT 1 COMMENT '启用状态(1.待处理 2.处理中 3.已处理 4.忽略)',
|
||||||
|
`warn_status` int NULL DEFAULT 0 COMMENT '是否警告(0.开启 1.禁止)',
|
||||||
|
`remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
|
||||||
|
`create_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建者',
|
||||||
|
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新者',
|
||||||
|
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`car_type_id` int NULL DEFAULT NULL COMMENT '车辆类型',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '故障码' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for sys_car_fault_log
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `sys_car_fault_log`;
|
||||||
|
CREATE TABLE `sys_car_fault_log` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`sys_car_fault_id` int NOT NULL COMMENT '故障码编号',
|
||||||
|
`create_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
|
||||||
|
`update_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '修改人',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
|
||||||
|
`vin` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'VIN码',
|
||||||
|
`remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '内容',
|
||||||
|
`status` int NULL DEFAULT 2 COMMENT '1- 解决 2- 处理中 3-忽略',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '故障日志表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for sys_car_fault_message
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `sys_car_fault_message`;
|
||||||
|
CREATE TABLE `sys_car_fault_message` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`content` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '内容',
|
||||||
|
`status` int NULL DEFAULT NULL COMMENT '1-已读 2-未读',
|
||||||
|
`create_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
|
||||||
|
`update_by` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '修改人',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
|
||||||
|
`remark` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '站内信' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for sys_car_log
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `sys_car_log`;
|
||||||
|
CREATE TABLE `sys_car_log` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`car_vin` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'VIN码',
|
||||||
|
`start_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆日志表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for t_template
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `t_template`;
|
||||||
|
CREATE TABLE `t_template` (
|
||||||
|
`template_id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
`house_id` int NULL DEFAULT NULL,
|
||||||
|
`template_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文模版名称',
|
||||||
|
`template_describe` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '报文模版描述',
|
||||||
|
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`template_id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '报文模版表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for tb_enterprise
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `tb_enterprise`;
|
||||||
|
CREATE TABLE `tb_enterprise` (
|
||||||
|
`enterprise_id` int NOT NULL AUTO_INCREMENT COMMENT '企业编号',
|
||||||
|
`enterprise_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业名称',
|
||||||
|
`enterprise_car_count` int NULL DEFAULT 0 COMMENT '企业车辆数量',
|
||||||
|
`enterprise_fence_count` int NULL DEFAULT 0 COMMENT '企业电子围栏数量',
|
||||||
|
`enterprise_database_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '企业数据库',
|
||||||
|
PRIMARY KEY (`enterprise_id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '企业运营' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for warn_logs
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `warn_logs`;
|
||||||
|
CREATE TABLE `warn_logs` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT COMMENT '预警日志id',
|
||||||
|
`vin` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '车辆vin码',
|
||||||
|
`warn_rule_id` int NULL DEFAULT NULL COMMENT '规则id',
|
||||||
|
`start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
|
||||||
|
`end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
|
||||||
|
`max_value` int NULL DEFAULT NULL COMMENT '最大值',
|
||||||
|
`min_value` int NULL DEFAULT NULL COMMENT '最小值',
|
||||||
|
`avg_value` int NULL DEFAULT NULL COMMENT '平均值',
|
||||||
|
`median_value` int NULL DEFAULT NULL COMMENT '中位数',
|
||||||
|
`status` int NULL DEFAULT NULL COMMENT '是否发送预警',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆预警记录表' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for warn_rule
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `warn_rule`;
|
||||||
|
CREATE TABLE `warn_rule` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT COMMENT '规则id',
|
||||||
|
`rule_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '规则名称',
|
||||||
|
`strategy_id` int NULL DEFAULT NULL COMMENT '策略id',
|
||||||
|
`msg_type_id` int NULL DEFAULT NULL COMMENT '报文数据类型id',
|
||||||
|
`slide_time` int NULL DEFAULT NULL COMMENT '滑窗时间',
|
||||||
|
`slide_frequency` int NULL DEFAULT NULL COMMENT '滑窗频率',
|
||||||
|
`growth_rate` int NULL DEFAULT NULL COMMENT '增长率',
|
||||||
|
`volatility_rate` int NULL DEFAULT NULL COMMENT '波动率',
|
||||||
|
`decrease_rate` int NULL DEFAULT NULL COMMENT '下降率',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆预警规则表' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for warn_strategy
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `warn_strategy`;
|
||||||
|
CREATE TABLE `warn_strategy` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT COMMENT '策略id',
|
||||||
|
`car_type_id` int NULL DEFAULT NULL COMMENT '车辆类型id',
|
||||||
|
`strategy_name` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '策略名称',
|
||||||
|
`template_id` int NULL DEFAULT NULL COMMENT '报文模版id',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '车辆预警策略表' ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
Loading…
Reference in New Issue