Compare commits

...

66 Commits

Author SHA1 Message Date
LQS ec41019824 fix(): 解决企业缓存编译错误问题 2024-10-07 22:14:46 +08:00
LQS b491045ebf feat(): 新增企业远程调用模块,重构远程调用代码 2024-10-07 21:58:01 +08:00
LQS 580172aa76 Merge remote-tracking branch 'origin/dev.analysis' into dev
# Conflicts:
#	cloud-common/pom.xml
2024-10-07 20:33:09 +08:00
crj c08a1376d6 fix():整理代码格式 2024-10-07 20:14:44 +08:00
crj 9bb39ec32a fix():解决故障规则报错 2024-10-07 20:12:05 +08:00
crj 6e0ed3b883 Merge remote-tracking branch 'origin/dev.entOperation' into dev
# Conflicts:
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/pom.xml
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/CarMessageController.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/FaultRuleController.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/FaultRuleService.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/FaultRuleServiceImpl.java
#	cloud-modules/cloud-modules-vehicle-gateway/src/main/resources/banner.txt
2024-10-07 20:09:21 +08:00
crj 94d04e3a35 feat():解决冲突 2024-10-07 20:00:27 +08:00
xinzirun a9bfdc1670 Merge remote-tracking branch 'origin/dev' into dev 2024-10-07 19:48:57 +08:00
xinzirun 111129e777 fix(): 修复故障规则 2024-10-07 19:48:11 +08:00
微醺 0bafed3671 1.feat(): 添加:
2.fix(): 修复了: 之前添加的封装的缓存

更新时间10071938
2024-10-07 19:43:07 +08:00
微醺 0db37dc190 Merge branch 'dev.entBusiness' into dev
# Conflicts:
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-cache/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
2024-10-07 19:40:07 +08:00
微醺 293e58809c 1.feat(): 添加:
2.fix(): 修复了: 之前添加的封装的缓存

更新时间10071938
2024-10-07 19:38:31 +08:00
xinzirun 22e068cfc5 Merge branch 'dev' of https://gitea.qinmian.online/six-vehicle/cloud-server into dev 2024-10-07 19:31:57 +08:00
xinzirun 9f0f373594 fix(): 处理事件监听器执行异常问题 2024-10-07 19:31:18 +08:00
crj a2f2d2ec52 fix():故障规则重构 2024-10-07 19:31:18 +08:00
xinzirun 26c0d3d4c8 fix(): 优化上下线监听 2024-10-07 19:31:18 +08:00
xinzirun 7fa71097fd fix(): 解决配置冲突问题 2024-10-07 19:31:18 +08:00
liuyibo e018d60115 build():添加车辆连接获取车辆信息存入数据库中,发送rabbitmq消息队列 2024-10-07 19:31:17 +08:00
xinzirun 20977536e3 fix(): 处理事件监听器执行异常问题 2024-10-07 19:29:12 +08:00
crj 222b2ad30f fix():故障规则重构 2024-10-07 18:53:10 +08:00
微醺 c0a9b1a1dd 1.feat(): 添加: swagger文档
2.fix(): 修复了: 企业表的实体类

更新时间09301928
2024-10-07 14:25:10 +08:00
xinzirun eef7d19aeb fix(): 优化上下线监听 2024-10-07 13:55:46 +08:00
xinzirun 19f67a389c fix(): 解决配置冲突问题 2024-10-07 09:45:59 +08:00
xinzirun f7f54bf0c1 Merge remote-tracking branch 'origin/dev.eventProcess' into dev 2024-10-07 09:16:12 +08:00
xinzirun a1894bb013 feat(): 新增车辆上线消费者和识别故障监听器 2024-10-07 09:02:38 +08:00
xinzirun ca8bd65148 fix(): 优化时间处理流程,修复bug 2024-10-07 09:01:57 +08:00
xinzirun a0c2d916f2 fix(): 修改事件处理基类架构 2024-10-07 09:01:19 +08:00
xinzirun 8888b7430c fix(): 修改故障规则命名 2024-10-07 09:00:43 +08:00
liuyibo a8222a4c88 build():添加车辆连接获取车辆信息存入数据库中,发送rabbitmq消息队列 2024-10-06 11:08:48 +08:00
liuyibo 98fa19923d build():添加车辆连接获取车辆信息存入数据库中,发送rabbitmq消息队列 2024-10-06 10:57:27 +08:00
xinzirun 3378b4c216 feat(): 添加车辆下线监听消费者
fix(): 解决依赖冲突
2024-10-06 09:57:22 +08:00
微醺 688527037d 1.feat(): 添加: 电子围栏的redis
2.fix(): 修复了: 暂无

更新时间10060935
2024-10-06 09:35:54 +08:00
微醺 d896e9b26d Merge branch 'dev.entBusiness' of https://gitea.qinmian.online/six-vehicle/cloud-server into dev
# Conflicts:
#	cloud-common/pom.xml
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/CloudEnterpriseApplication.java
#	cloud-modules/cloud-modules-event-process/src/main/resources/banner.txt
#	pom.xml
2024-10-06 09:22:15 +08:00
微醺 f81d701acb 1.feat(): 添加: redis缓存的的封装
2.fix(): 修复了: 暂无

更新时间09301928
2024-10-06 09:17:03 +08:00
crj 3fb0158cfa feax:()添加企业表的同时将数据同步进去 企业列表展示 2024-10-05 20:41:45 +08:00
xinzirun 5d66ce181f feat(): 新增本地缓存工具类 2024-10-04 20:45:34 +08:00
crj 46689d02e1 feax:()添加企业表的同时将数据同步进去 企业列表展示 2024-10-04 11:09:33 +08:00
xinzirun 576befa0ee fix(): 修改nacos命名空间配置 2024-10-02 16:50:55 +08:00
xinzirun 6f95055a6b feat(): 新增rabbitmq公共模块代码 2024-10-02 16:49:39 +08:00
xinzirun 17245c91b3 fix(): 解决代码冲突问题 2024-09-30 20:09:05 +08:00
xinzirun ff3f1e8ac2 fix(): 解决代码冲突问题 2024-09-30 20:07:32 +08:00
xinzirun 147dbe2c99 fix(): 解决依赖冲突问题 2024-09-30 20:07:17 +08:00
微醺 a229006c89 1.feat(): 添加将pom文件版本号统一管理
2.fix(): 修复了项目运行时的报错:
Error creating bean with name 'com.muyu.common.cache.config.CacheAbsBasic': Failed to instantiate [com.muyu.common.cache.config.CacheAbsBasic]: Is it an abstract class?
更新时间09301928
2024-09-30 19:28:04 +08:00
liuyibo b9529234e9 Merge branch 'dev' of https://gitea.qinmian.online/six-vehicle/cloud-server into dev.vehicleGateway
# Conflicts:
#	pom.xml
2024-09-30 19:06:12 +08:00
liuyibo 0ed0f872e9 build():依赖版本号放到公共层统一管理 2024-09-30 19:05:30 +08:00
xinzirun 7e2ad67a64 fix(): 解决代码冲突问题 2024-09-30 19:00:17 +08:00
xinzirun c67d648a8a Merge branch 'dev.eventProcessing' into dev
# Conflicts:
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/pom.xml
#	cloud-modules/pom.xml
2024-09-30 18:10:51 +08:00
xinzirun 5203c69a90 fix(): 修改nacos命名空间 2024-09-30 18:04:49 +08:00
xinzirun 3ebd1d2c39 fix(): 修复时间处理基础架构 2024-09-30 18:03:48 +08:00
crj 0c7795ea71 feax:()添加企业的时候添加一个单独的库和表 2024-09-30 16:41:06 +08:00
微醺 b9f3cac204 1.feat(): 添加 redis缓存
2.fix(): 更新公共路径
更新时间09301533
2024-09-30 15:33:37 +08:00
liuyibo add31c49fa feat():程序启动时可以通过新创的服务器id查询到ip和状态 2024-09-30 09:22:25 +08:00
xinzirun 7100bf71bf feat(): 添加事件处理业务 2024-09-30 00:52:20 +08:00
微醺 a7b8987be4 1.将MyBatis编写方式更改成MyBatisPlus
2.后台测试成功
更新时间09292247
2024-09-29 22:47:40 +08:00
LQS 497de4ade9 Merge remote-tracking branch 'origin/dev.analysis' into dev 2024-09-29 18:05:15 +08:00
LQS 940e41b297 fix():修复与dev.analysis合并报错(Move or commit them before Merge) 2024-09-29 18:04:46 +08:00
liuyibo 22675757b3 feat():启动创建ECS服务器模块,停止删除ECS服务器模块 2024-09-29 16:33:04 +08:00
xinzirun 6594363a91 fix(): 修复cloud-data-process数据处理微服务模块 ---> cloud-event-process事件处理微服务模块 2024-09-29 16:06:24 +08:00
crj 517c18f215 feax:()删除fault模块 2024-09-29 15:07:11 +08:00
xinzirun 423836afb7 fix(): 修复IoTDB基础类 2024-09-29 11:58:18 +08:00
liuyibo cb79600bc0 style():优化代码 2024-09-29 11:20:00 +08:00
liuyibo 782f31446b feat():项目启动添加ecs实例,停止删除ecs实例 2024-09-29 10:25:30 +08:00
xinzirun 47567ff055 feat(): 新增IoTDB配置类、基础业务类 2024-09-29 00:55:53 +08:00
crj 2d0f557398 feax:()修改代码规范 2024-09-28 22:14:45 +08:00
crj cd46940e70 feax:()修改代码规范(注释) 2024-09-28 20:12:04 +08:00
liuyibo e9a19e94e9 连接MQTT,接收车辆的数据 2024-09-28 12:28:19 +08:00
164 changed files with 5955 additions and 590 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ logs
*.iws *.iws
*.iml *.iml
*.ipr *.ipr
*.yml
### JRebel ### ### JRebel ###
rebel.xml rebel.xml

View File

@ -76,19 +76,18 @@ public class SysLoginService {
if (Result.FAIL == userResult.getCode()) { if (Result.FAIL == userResult.getCode()) {
throw new ServiceException(userResult.getMsg()); throw new ServiceException(userResult.getMsg());
} }
LoginUser userInfo = userResult.getData(); LoginUser userInfo = userResult.getData();
SysUser user = userResult.getData().getSysUser(); SysUser user = userResult.getData().getSysUser();
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { if(UserStatus.DELETED.getCode().equals(user.getDelFlag())){
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); recordLogService.recordLogininfor(username,Constants.LOGIN_FAIL,"对不起,您的账号已被删除");
throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); throw new ServiceException("对不起,您的账号:" + username + " 已被删除 ");
} }
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { if(UserStatus.DISABLE.getCode().equals(user.getStatus())){
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); recordLogService.recordLogininfor(username,Constants.LOGIN_FAIL,"用户已停用,请联系管理官");
throw new ServiceException("对不起,您的账号" + username + " 已停用"); throw new ServiceException("对不起,您的账号:" + username + " 已停用");
} }
passwordService.validate(user, password); passwordService.validate(user,password);
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); recordLogService.recordLogininfor(username,Constants.LOGIN_SUCCESS,"登录成功");
return userInfo; return userInfo;
} }
@ -128,16 +127,16 @@ public class SysLoginService {
throw new ServiceException("密码长度必须在5到20个字符之间"); throw new ServiceException("密码长度必须在5到20个字符之间");
} }
// 注册用户信息 //注册用户信息
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setUserName(username); sysUser.setUserName(username);
sysUser.setNickName(username); sysUser.setNickName(username);
sysUser.setPassword(SecurityUtils.encryptPassword(password)); sysUser.setPassword(SecurityUtils.encryptPassword(password));
Result<?> registerResult = remoteUserService.registerUserInfo(registerBody, SecurityConstants.INNER); Result<Boolean> registerResult = remoteUserService.registerUserInfo(registerBody, SecurityConstants.INNER);
if (Result.FAIL == registerResult.getCode()) { if (Result.FAIL == registerResult.getCode()) {
throw new ServiceException(registerResult.getMsg()); throw new ServiceException(registerResult.getMsg());
} }
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
recordLogService.recordLogininfor(username,Constants.REGISTER,"注册成功");
} }
} }

View File

@ -2,6 +2,7 @@
server: server:
port: 9500 port: 9500
# nacos线上地址
nacos: nacos:
addr: 106.15.136.7:8848 addr: 106.15.136.7:8848
user-name: nacos user-name: nacos

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-common</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-common-cache</artifactId>
<description>
cloud-common-cache redis缓存架构
</description>
<dependencies>
<!-- redis 缓存模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-redis</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,36 @@
package com.muyu.common.cache.config;
/**
*
* @ClassName CacheAbsBasic
* @Description CacheAbsBasic:
* @Date 2024/9/30 1:39
* @author MingWei.Zong
*/
import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
public abstract class CacheAbsBasic<K,V> implements CacheBasic<K,V> {
@Autowired
private RedisService redisService;
@Override
public void put(K key, V value) {
redisService.setCacheObject(encode(key),value);
}
@Override
public V get(K key) {
return redisService.getCacheObject(encode(key));
}
@Override
public void remove(K key) {
redisService.deleteObject(encode(key));
}
}

View File

@ -0,0 +1,22 @@
package com.muyu.common.cache.config;
import java.awt.image.Kernel;
/**
*
* @ClassName CacheBasic
* @Description CacheBasic:
* @Date 2024/9/30 1:36
* @author MingWei.Zong
*/
public interface CacheBasic<K,V> extends PrimaryKeyBasic<K>{
void put(K key,V value);
V get(K key);
void remove(K key);
}

View File

@ -0,0 +1,45 @@
package com.muyu.common.cache.config;
/**
*
* @ClassName PrimaryKeyBasic
* @Description PrimaryKeyBasic:
* @Date 2024/9/30 0:15
* @author MingWei.Zong
*/
public interface PrimaryKeyBasic <K>{
/**
* key
*/
public String keyPre();
/**
*
* @param key
* @return
*/
public default String encode(K key){
return keyPre() + key.toString();
}
/**
* Key
* @param key key
* @return
*/
public K decode(String key);
}

View File

@ -0,0 +1,44 @@
package com.muyu.common.rabbit.callback;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
/**
* @Author: zi run
* @Date 2024/10/2 9:26
* @Description broker
*/
@Slf4j
@Component
public class ConfirmCallback implements RabbitTemplate.ConfirmCallback {
@Resource
private RabbitTemplate rabbitTemplate;
/**
*
*/
@PostConstruct
public void init() {
this.rabbitTemplate.setConfirmCallback(this);
}
/**
*
* @param correlationData
* @param ack truebrokerfalsebroker
* @param cause ackfalseacktrue
*/
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
if (ack) {
log.info("消息发送到broker成功");
} else {
log.info("消息发送到broker失败失败原因{}", cause);
}
}
}

View File

@ -0,0 +1,39 @@
package com.muyu.common.rabbit.callback;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
/**
* @Author: zi run
* @Date 2024/10/2 9:33
* @Description
*/
@Slf4j
@Component
public class ReturnsCallback implements RabbitTemplate.ReturnsCallback {
@Resource
private RabbitTemplate rabbitTemplate;
/**
*
*/
@PostConstruct
public void init() {
rabbitTemplate.setReturnsCallback(this);
}
/**
*
* @param returnedMessage
*/
@Override
public void returnedMessage(ReturnedMessage returnedMessage) {
log.info("消息:{}被交换机:{}回退!回退原因:{}", returnedMessage.getMessage().toString(),
returnedMessage.getExchange(), returnedMessage.getReplyText());
}
}

View File

@ -0,0 +1,72 @@
package com.muyu.common.rabbit.config;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Author: zi run
* @Date 2024/10/2 16:41
* @Description RabbitMQ
*/
@Configuration
public class RabbitAdminConfig {
/**
* RabbitMQ
*/
@Value("${spring.rabbitmq.host}")
private String host;
/**
* RabbitMQ
*/
@Value("${spring.rabbitmq.username}")
private String username;
/**
* RabbitMQ
*/
@Value("${spring.rabbitmq.password}")
private String password;
/**
* RabbitMQ
*/
@Value("${spring.rabbitmq.virtualhost}")
private String virtualhost;
/**
* RabbitAdmin
*
* @return RabbitAdmin
*/
@Bean
public RabbitAdmin rabbitAdmin() {
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory());
rabbitAdmin.setAutoStartup(true);
return rabbitAdmin;
}
/**
* RabbitMQ
*
* @return ConnectionFactory
*/
@Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setAddresses(host);
connectionFactory.setUsername(username);
connectionFactory.setPassword(password);
connectionFactory.setVirtualHost(virtualhost);
// 配置发送确认回调时次配置必须配置否则即使在RabbitTemplate配置了ConfirmCallback也不会生效
connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
connectionFactory.setPublisherReturns(true);
return connectionFactory;
}
}

View File

@ -1,28 +1,41 @@
package com.muyu.common.rabbit; package com.muyu.common.rabbit.config;
import org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer;
import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar; import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.messaging.converter.MappingJackson2MessageConverter;
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory;
/**
* @Author: zi run
* @Date 2024/10/2 10:06
* @Description rabbitMQ
*/
@Configuration @Configuration
public class RabbitListenerConfigurer implements org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer { public class RabbitListenerConfig implements RabbitListenerConfigurer {
static { static {
// 设置为信任所有类型的反序列化,确保消息能够正确反序列化
System.setProperty("spring.amqp.deserialization.trust.all", "true"); System.setProperty("spring.amqp.deserialization.trust.all", "true");
} }
//以下配置RabbitMQ消息服务 /**
* RabbitMQ
*/
@Autowired @Autowired
public ConnectionFactory connectionFactory; public ConnectionFactory connectionFactory;
@Autowired
private MessageConverter jsonMessageConverter;
/** /**
* * bean
* @return *
* @return DefaultMessageHandlerMethodFactory
*/ */
@Bean @Bean
public DefaultMessageHandlerMethodFactory handlerMethodFactory() { public DefaultMessageHandlerMethodFactory handlerMethodFactory() {
@ -32,8 +45,14 @@ public class RabbitListenerConfigurer implements org.springframework.amqp.rabbit
return factory; return factory;
} }
/**
* RabbitMQ
*
* @param rabbitListenerEndpointRegistrar
*/
@Override @Override
public void configureRabbitListeners(RabbitListenerEndpointRegistrar rabbitListenerEndpointRegistrar) { public void configureRabbitListeners(RabbitListenerEndpointRegistrar rabbitListenerEndpointRegistrar) {
// 注册自定义的消息处理方法工厂
rabbitListenerEndpointRegistrar.setMessageHandlerMethodFactory(handlerMethodFactory()); rabbitListenerEndpointRegistrar.setMessageHandlerMethodFactory(handlerMethodFactory());
} }

View File

@ -0,0 +1,26 @@
package com.muyu.common.rabbit.config;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Author: zi run
* @Date 2024/10/2 9:17
* @Description rabbitMQ
*/
@Configuration
public class RabbitMQMessageConverterConfig {
/**
*
*
* @return
*/
@Bean
public MessageConverter jsonMessageConverter() {
return new Jackson2JsonMessageConverter();
}
}

View File

@ -1 +1,3 @@
com.muyu.common.rabbit.RabbitListenerConfigurer com.muyu.common.rabbit.config.RabbitAdminConfig
com.muyu.common.rabbit.config.RabbitListenerConfig
com.muyu.common.rabbit.config.RabbitMQMessageConverterConfig

View File

@ -91,21 +91,19 @@ public class ManyDataSource implements ApplicationRunner {
@Bean @Bean
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) { public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
List<EntInfo> entInfoList = dataSourceInfoList(); List<EntInfo> entInfoList = dataSourceInfoList();
if(StringUtils.isEmpty(entInfoList)){ if (StringUtils.isNotEmpty(entInfoList)) {
throw new SaaSException("数据信息列表为空或为null"); throw new SaaSException("数据信息列表为空或为null");
} }
Map<Object, Object> dataSourceMap = dataSourceInfoList().stream() Map<Object,Object> dataSourceMap = dataSourceInfoList().stream()
.map(entInfo -> DataSourceInfo.hostAndPortBuild( .map(entInfo -> DataSourceInfo.hostAndPortBuild(
entInfo.getEntCode(), entInfo.getEntCode(),
entInfo.getIp(), entInfo.getIp(),
entInfo.getPort() entInfo.getPort()
) )
) ).collect(Collectors.toMap(
.collect(Collectors.toMap(
dataSourceInfo -> dataSourceInfo.getKey(), dataSourceInfo -> dataSourceInfo.getKey(),
dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo) dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo)
)); ));
//设置动态数据源 //设置动态数据源
DynamicDataSource dynamicDataSource = new DynamicDataSource(); DynamicDataSource dynamicDataSource = new DynamicDataSource();
dynamicDataSource.setTargetDataSources(dataSourceMap); dynamicDataSource.setTargetDataSources(dataSourceMap);

View File

@ -1,8 +1,9 @@
package com.muyu.cloud.common.many.datasource.constents; package com.muyu.cloud.common.many.datasource.constents;
/** /**
* @Author: zi run *
* @Date 2024/9/20 14:52 * @Author chenruijia
* @Date 2024/9/29 17:52
* @Description * @Description
*/ */
public class DatasourceContent { public class DatasourceContent {

View File

@ -8,6 +8,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
*
* @Author: zi run * @Author: zi run
* @Date 2024/9/20 14:52 * @Date 2024/9/20 14:52
* @Description * @Description

View File

@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
import java.sql.SQLException; import java.sql.SQLException;
/** /**
* Druid
* @Author: zi run * @Author: zi run
* @Date 2024/9/20 14:52 * @Date 2024/9/20 14:52
* @Description Druid * @Description Druid

View File

@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
*
* @Author: zi run * @Author: zi run
* @Date 2024/9/20 14:52 * @Date 2024/9/20 14:52
* @Description * @Description

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-common</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-common-swagger</artifactId>
<description>
cloud-common-swagger api接口文档
</description>
<dependencies>
<!-- SpringBoot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,22 @@
package com.muyu.common.swagger.annotation;
import com.muyu.common.swagger.config.SwaggerAutoConfiguration;
import org.springframework.context.annotation.Import;
import java.lang.annotation.*;
/**
* @ClassName EnableCustomSwagger2
* @Description EnableCustomSwagger2:
* @Date 2024/10/6 22:16
* @author MingWei.Zong
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Import({SwaggerAutoConfiguration.class})
public @interface EnableCustomSwagger2 {
}

View File

@ -0,0 +1,118 @@
package com.muyu.common.swagger.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
/**
* @ClassName SwaggerAutoConfiguration
* @Description SwaggerAutoConfiguration:
* @Date 2024/10/6 22:16
* @author MingWei.Zong
*/
@Configuration
@EnableSwagger2
@EnableConfigurationProperties(SwaggerProperties.class)
@ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true)
@Import({SwaggerBeanPostProcessor.class, SwaggerWebConfiguration.class})
public class SwaggerAutoConfiguration {
/**
* Spring Boot
*/
private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error", "/actuator/**");
private static final String BASE_PATH = "/**";
@Bean
public Docket api (SwaggerProperties swaggerProperties) {
// base-path处理
if (swaggerProperties.getBasePath().isEmpty()) {
swaggerProperties.getBasePath().add(BASE_PATH);
}
// noinspection unchecked
List<Predicate<String>> basePath = new ArrayList<Predicate<String>>();
swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path)));
// exclude-path处理
if (swaggerProperties.getExcludePath().isEmpty()) {
swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH);
}
List<Predicate<String>> excludePath = new ArrayList<>();
swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path)));
ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2).host(swaggerProperties.getHost())
.apiInfo(apiInfo(swaggerProperties)).select()
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()));
swaggerProperties.getBasePath().forEach(p -> builder.paths(PathSelectors.ant(p)));
swaggerProperties.getExcludePath().forEach(p -> builder.paths(PathSelectors.ant(p).negate()));
return builder.build().securitySchemes(securitySchemes()).securityContexts(securityContexts()).pathMapping("/");
}
/**
* tokenAuthorization
*/
private List<SecurityScheme> securitySchemes () {
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
return apiKeyList;
}
/**
*
*/
private List<SecurityContext> securityContexts () {
List<SecurityContext> securityContexts = new ArrayList<>();
securityContexts.add(
SecurityContext.builder()
.securityReferences(defaultAuth())
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
.build());
return securityContexts;
}
/**
*
*
* @return
*/
private List<SecurityReference> defaultAuth () {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
List<SecurityReference> securityReferences = new ArrayList<>();
securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
return securityReferences;
}
private ApiInfo apiInfo (SwaggerProperties swaggerProperties) {
return new ApiInfoBuilder()
.title(swaggerProperties.getTitle())
.description(swaggerProperties.getDescription())
.license(swaggerProperties.getLicense())
.licenseUrl(swaggerProperties.getLicenseUrl())
.termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl())
.contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail()))
.version(swaggerProperties.getVersion())
.build();
}
}

View File

@ -0,0 +1,47 @@
package com.muyu.common.swagger.config;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
import java.lang.reflect.Field;
import java.util.List;
import java.util.stream.Collectors;
/**
* @ClassName SwaggerBeanPostProcessor
* @Description SwaggerBeanPostProcessor:
* @Date 2024/10/6 22:16
* @author MingWei.Zong
*/
public class SwaggerBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization (Object bean, String beanName) throws BeansException {
if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
}
return bean;
}
private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings (List<T> mappings) {
List<T> copy = mappings.stream().filter(mapping -> mapping.getPatternParser() == null)
.collect(Collectors.toList());
mappings.clear();
mappings.addAll(copy);
}
@SuppressWarnings("unchecked")
private List<RequestMappingInfoHandlerMapping> getHandlerMappings (Object bean) {
try {
Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
field.setAccessible(true);
return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
}
}

View File

@ -0,0 +1,303 @@
package com.muyu.common.swagger.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName SwaggerProperties
* @Description SwaggerProperties:
* @Date 2024/10/6 22:16
* @author MingWei.Zong
*/
@ConfigurationProperties("swagger")
public class SwaggerProperties {
/**
* swagger
*/
private Boolean enabled;
/**
* swagger
**/
private String basePackage = "";
/**
* swaggerurl
**/
private List<String> basePath = new ArrayList<>();
/**
* basePathurl
**/
private List<String> excludePath = new ArrayList<>();
/**
*
**/
private String title = "";
/**
*
**/
private String description = "";
/**
*
**/
private String version = "";
/**
*
**/
private String license = "";
/**
* URL
**/
private String licenseUrl = "";
/**
* URL
**/
private String termsOfServiceUrl = "";
/**
* host
**/
private String host = "";
/**
*
*/
private Contact contact = new Contact();
/**
*
**/
private Authorization authorization = new Authorization();
public Boolean getEnabled () {
return enabled;
}
public void setEnabled (Boolean enabled) {
this.enabled = enabled;
}
public String getBasePackage () {
return basePackage;
}
public void setBasePackage (String basePackage) {
this.basePackage = basePackage;
}
public List<String> getBasePath () {
return basePath;
}
public void setBasePath (List<String> basePath) {
this.basePath = basePath;
}
public List<String> getExcludePath () {
return excludePath;
}
public void setExcludePath (List<String> excludePath) {
this.excludePath = excludePath;
}
public String getTitle () {
return title;
}
public void setTitle (String title) {
this.title = title;
}
public String getDescription () {
return description;
}
public void setDescription (String description) {
this.description = description;
}
public String getVersion () {
return version;
}
public void setVersion (String version) {
this.version = version;
}
public String getLicense () {
return license;
}
public void setLicense (String license) {
this.license = license;
}
public String getLicenseUrl () {
return licenseUrl;
}
public void setLicenseUrl (String licenseUrl) {
this.licenseUrl = licenseUrl;
}
public String getTermsOfServiceUrl () {
return termsOfServiceUrl;
}
public void setTermsOfServiceUrl (String termsOfServiceUrl) {
this.termsOfServiceUrl = termsOfServiceUrl;
}
public String getHost () {
return host;
}
public void setHost (String host) {
this.host = host;
}
public Contact getContact () {
return contact;
}
public void setContact (Contact contact) {
this.contact = contact;
}
public Authorization getAuthorization () {
return authorization;
}
public void setAuthorization (Authorization authorization) {
this.authorization = authorization;
}
public static class Contact {
/**
*
**/
private String name = "";
/**
* url
**/
private String url = "";
/**
* email
**/
private String email = "";
public String getName () {
return name;
}
public void setName (String name) {
this.name = name;
}
public String getUrl () {
return url;
}
public void setUrl (String url) {
this.url = url;
}
public String getEmail () {
return email;
}
public void setEmail (String email) {
this.email = email;
}
}
public static class Authorization {
/**
* IDSecurityReferences ID
*/
private String name = "";
/**
* URL
*/
private String authRegex = "^.*$";
/**
*
*/
private List<AuthorizationScope> authorizationScopeList = new ArrayList<>();
private List<String> tokenUrlList = new ArrayList<>();
public String getName () {
return name;
}
public void setName (String name) {
this.name = name;
}
public String getAuthRegex () {
return authRegex;
}
public void setAuthRegex (String authRegex) {
this.authRegex = authRegex;
}
public List<AuthorizationScope> getAuthorizationScopeList () {
return authorizationScopeList;
}
public void setAuthorizationScopeList (List<AuthorizationScope> authorizationScopeList) {
this.authorizationScopeList = authorizationScopeList;
}
public List<String> getTokenUrlList () {
return tokenUrlList;
}
public void setTokenUrlList (List<String> tokenUrlList) {
this.tokenUrlList = tokenUrlList;
}
}
public static class AuthorizationScope {
/**
*
*/
private String scope = "";
/**
*
*/
private String description = "";
public String getScope () {
return scope;
}
public void setScope (String scope) {
this.scope = scope;
}
public String getDescription () {
return description;
}
public void setDescription (String description) {
this.description = description;
}
}
}

View File

@ -0,0 +1,20 @@
package com.muyu.common.swagger.config;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @ClassName SwaggerWebConfiguration
* @Description SwaggerWebConfiguration:
* @Date 2024/10/6 22:16
* @author MingWei.Zong
*/
public class SwaggerWebConfiguration implements WebMvcConfigurer {
@Override
public void addResourceHandlers (ResourceHandlerRegistry registry) {
/** swagger-ui 地址 */
registry.addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
}
}

View File

@ -22,6 +22,8 @@
<module>cloud-common-xxl</module> <module>cloud-common-xxl</module>
<module>cloud-common-rabbit</module> <module>cloud-common-rabbit</module>
<module>cloud-common-kafka</module> <module>cloud-common-kafka</module>
<module>cloud-common-cache</module>
<module>cloud-common-swagger</module>
<module>cloud-common-mqtt</module> <module>cloud-common-mqtt</module>
</modules> </modules>

View File

@ -2,6 +2,7 @@
server: server:
port: 8080 port: 8080
# nacos线上地址
nacos: nacos:
addr: 106.15.136.7:8848 addr: 106.15.136.7:8848
user-name: nacos user-name: nacos

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-modules-enterprise</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>cloud-modules-enterprise-cache</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<description>
cloud-modules-enterprise-cache redis 缓存平台
</description>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-cache</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-modules-enterprise-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,29 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.config.CacheAbsBasic;
import com.muyu.enterprise.domain.CarCompany;
import com.muyu.enterprise.domain.CarManage;
/**
* redis
* @ClassName CarCompanyCacheService
* @Description CarCompanyCacheService:
* @Date 2024/10/3 15:22
* @author MingWei.Zong
*/
public class CarCompanyCacheService extends CacheAbsBasic<String, CarCompany> {
@Override
public String keyPre() {
return "CarCompany:info:";
}
@Override
public String decode(String key) {
return key.replace("CarCompany:info:","");
}
}

View File

@ -0,0 +1,27 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.config.CacheAbsBasic;
import com.muyu.enterprise.domain.FaultRule;
import org.springframework.stereotype.Component;
/**
* redis
* @ClassName CarFaultCacheService
* @Description CarFaultCacheService:
* @Date 2024/10/3 15:22
* @author MingWei.Zong
*/
public class CarFaultCacheService extends CacheAbsBasic<String, FaultRule> {
@Override
public String keyPre() {
return "faultRule:info:";
}
@Override
public String decode(String key) {
return key.replace("faultRule:info:","");
}
}

View File

@ -0,0 +1,28 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.config.CacheAbsBasic;
import com.muyu.enterprise.domain.CarManage;
/**
* redis
* @ClassName CarManageCacheService
* @Description CarManageCacheService:
* @Date 2024/10/3 15:22
* @author MingWei.Zong
*/
public class CarManageCacheService extends CacheAbsBasic<String, CarManage> {
@Override
public String keyPre() {
return "carManage:info:";
}
@Override
public String decode(String key) {
return key.replace("carManage:info:","");
}
}

View File

@ -0,0 +1,30 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.config.CacheAbsBasic;
import com.muyu.enterprise.domain.CarMessage;
/**
* redis
* @ClassName CarMessageCacheService
* @Description CarMessageCacheService:
* @Date 2024/9/30 11:42
* @author MingWei.Zong
*/
public class CarMessageCacheService extends CacheAbsBasic<String, CarMessage> {
@Override
public String keyPre() {
return "carMessage:info:";
}
// @Override
// public String encode(String key) {
// return super.encode(key);
// }
@Override
public String decode(String key) {
return key.replace("carMessage:info:","");
}
}

View File

@ -0,0 +1,29 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.config.CacheAbsBasic;
import com.muyu.enterprise.domain.CarCompany;
import com.muyu.enterprise.domain.CarTemplate;
/**
* redis
* @ClassName CarTemplateCacheService
* @Description CarTemplateCacheService:
* @Date 2024/10/3 15:22
* @author MingWei.Zong
*/
public class CarTemplateCacheService extends CacheAbsBasic<String, CarTemplate> {
@Override
public String keyPre() {
return "carTemplate:info:";
}
@Override
public String decode(String key) {
return key.replace("carTemplate:info:","");
}
}

View File

@ -0,0 +1,27 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.config.CacheAbsBasic;
import com.muyu.enterprise.domain.WarnRule;
/**
* redis
* @ClassName CarWarnCacheService
* @Description CarWarnCacheService:
* @Date 2024/10/3 15:22
* @author MingWei.Zong
*/
public class CarWarnCacheService extends CacheAbsBasic<String, WarnRule> {
@Override
public String keyPre() {
return "warnRule:info:";
}
@Override
public String decode(String key) {
return key.replace("warnRule:info:","");
}
}

View File

@ -0,0 +1,29 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.config.CacheAbsBasic;
import com.muyu.enterprise.domain.CarCompany;
import com.muyu.enterprise.domain.dateBase.ElectronicFence;
/**
* redis
* @ClassName ElectronicFenceCacheService
* @Description ElectronicFenceCacheService:
* @Date 2024/10/3 15:22
* @author MingWei.Zong
*/
public class ElectronicFenceCacheService extends CacheAbsBasic<String, ElectronicFence> {
@Override
public String keyPre() {
return "electronicFence:info:";
}
@Override
public String decode(String key) {
return key.replace("electronicFence:info:","");
}
}

View File

@ -0,0 +1,7 @@
com.muyu.enterprise.cache.CarCompanyCacheService
com.muyu.enterprise.cache.CarFaultCacheService
com.muyu.enterprise.cache.CarManageCacheService
com.muyu.enterprise.cache.CarMessageCacheService
com.muyu.enterprise.cache.CarTemplateCacheService
com.muyu.enterprise.cache.CarWarnCacheService
com.muyu.enterprise.cache.ElectronicFenceCacheService

View File

@ -28,22 +28,11 @@
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>cloud-common-core</artifactId> <artifactId>cloud-common-core</artifactId>
</dependency> </dependency>
<!--swagger3maven依赖-->
<!--swagger3依赖-->
<dependency> <dependency>
<groupId>io.swagger.core.v3</groupId> <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations-jakarta</artifactId> <artifactId>swagger-annotations-jakarta</artifactId>
</dependency> </dependency>
<!--mqttv3依赖-->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.2</version>
</dependency>
<!--mqtt依赖-->
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mqtt</artifactId>
<version>6.2.5</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -25,10 +25,11 @@ public class CarCompany {
/** /**
* *
*/ */
@TableId(value = "company_id",type = IdType.AUTO) @TableId(value = "enterprise_id",type = IdType.AUTO)
private Long companyId; private Long enterpriseId;
/** /**
* *
*/ */
private String companyName; private String companyName;
} }

View File

@ -29,20 +29,17 @@ public class CarConfig {
@TableId(value = "config_id",type = IdType.AUTO) @TableId(value = "config_id",type = IdType.AUTO)
private Long configId; private Long configId;
/** /**
* 1. 2. 3. *
*/ */
private String configName; private String configName;
/** /**
* * 1. 2. 3.
*/ */
private String energyType; private Integer energyType;
/** /**
* 1. 2. * 1. 2.
*/ */
private Integer gearType; private Integer gearType;
/**
* id
*/
private Integer companyId;
} }

View File

@ -73,7 +73,7 @@ public class CarManage {
/** /**
* 线 1. 2. 3. * 线 1. 2. 3.
*/ */
private Integer carStayus; private Integer carStatus;
/** /**
* *
*/ */
@ -90,7 +90,7 @@ public class CarManage {
/** /**
* *
*/ */
private String cardDrand; private String carBrand;
/** 最后一次连线时间 */ /** 最后一次连线时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ -105,10 +105,7 @@ public class CarManage {
/** /**
* id * id
*/ */
private Long companyId; private Long enterpriseId;
/**
* 1.轿 2. 3. 4. 5. 6.
*/
private Integer carType;
} }

View File

@ -8,12 +8,12 @@ import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* -- *
* @ClassName CarTemplate * @Author: chenruijia
* @Description * @Date 2024/9/28 12.23
* @author MingWei.Zong * @Description FaultRule:
* @Date 2024/9/28 16:52
*/ */
@Data @Data
@NoArgsConstructor @NoArgsConstructor

View File

@ -12,7 +12,7 @@ import lombok.experimental.SuperBuilder;
* *
* @Author: chenruijia * @Author: chenruijia
* @Date 2024/9/28 12.23 * @Date 2024/9/28 12.23
* @Description FaultrRule: * @Description FaultRule:
*/ */
@Data @Data
@SuperBuilder @SuperBuilder
@ -21,7 +21,7 @@ import lombok.experimental.SuperBuilder;
@TableName(value = "fault_rule",autoResultMap = true) @TableName(value = "fault_rule",autoResultMap = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Tag(name = "故障规则") @Tag(name = "故障规则")
public class FaultrRule extends BaseEntity { public class FaultRule extends BaseEntity {
/** /**
* ID * ID
*/ */
@ -29,18 +29,40 @@ public class FaultrRule extends BaseEntity {
@Schema(defaultValue = "故障规则ID",type = "Long",description = "故障规则ID") @Schema(defaultValue = "故障规则ID",type = "Long",description = "故障规则ID")
private Long faultRuleId; private Long faultRuleId;
/** /**
* * ID
*/ */
@Schema(defaultValue = "故障规则名称",type = "String",description = "故障规则名称") @Schema(defaultValue = "车辆类型ID",type = "Integer",description = "车辆类型ID")
private String faultRuleName; private Integer carTypeId;
/**
* ID
*/
@Schema(defaultValue = "故障名称ID",type = "Integer",description = "故障名称ID")
private Integer faultId;
/**
*
*/
@Schema(defaultValue = "故障条件",type = "String",description = "故障条件")
private String faultConditions;
/** /**
* *
*/ */
@Schema(defaultValue = "故障规则参数",type = "String",description = "故障规则参数") @Schema(defaultValue = "故障规则参数",type = "String",description = "故障规则参数")
private String faultRuleParameter; private String ruleParameters;
/** /**
* *
*/ */
@Schema(defaultValue = "故障规则描述",type = "String",description = "故障规则描述") @Schema(defaultValue = "车辆类型名称",type = "String",description = "车辆类型名称")
private String faultRuleDescription; private String carTypeName;
/**
*
*/
@Schema(defaultValue = "故障名称",type = "String",description = "故障名称")
private String faultName;
/**
* VIN
*/
@Schema(defaultValue = "车辆VIN",type = "String",description = "车辆VIN")
private String carVin;
} }

View File

@ -3,6 +3,7 @@ package com.muyu.enterprise.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -42,6 +43,11 @@ public class SysCarFault extends BaseEntity {
*/ */
@Schema(defaultValue = "车辆故障类型ID",type = "Integer",description = "车辆故障类型ID") @Schema(defaultValue = "车辆故障类型ID",type = "Integer",description = "车辆故障类型ID")
private Integer faultTypeId; private Integer faultTypeId;
/**
* ID
*/
@Schema(defaultValue = "车辆故障规则ID",type = "Integer",description = "车辆故障规则ID")
public Integer faultRuleId;
/** /**
* VIN * VIN
*/ */

View File

@ -19,42 +19,27 @@ public class CarDTO {
* VIN * VIN
*/ */
private String carVin; private String carVin;
/** /**
* *
*/ */
private String typeName; private Long enterpriseId;
/** /**
* 1. 2. 3. *
*/ */
@TableField(exist = false) private Long configId;
private Integer energyType;
/**
* 1. 2.
*/
@TableField(exist = false)
private Integer gearType;
private Integer pageNum = 1;
private Integer pageSize = 3;
/** 最后一次连线时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date carLastJoinTime;
/** 最后一次离线时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date carLastOfflineTime;
/** /**
* 线 1. 2. 3. * 线 1. 2. 3.
*/ */
private Integer carStatus; private Integer carStatus;
/** /**
* *
*/ */
@TableField(exist = false) private String carModel;
private String companyName; /**
*
*/
private String carBrand;
} }

View File

@ -0,0 +1,96 @@
package com.muyu.enterprise.domain.resp;
import com.muyu.common.core.annotation.Excel;
import com.muyu.enterprise.domain.SysCarFault;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.function.Supplier;
/**
*
* @author chenruijia
* @Date 2024/9/28 21:11
* @Description FaultResp:
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Tag(name = "故障返回")
public class FaultResp {
/**
*
*/
@Schema(defaultValue = "车辆故障码",type = "String",description = "车辆故障码")
private String faultCode;
/**
* ID
*/
@Schema(defaultValue = "车辆故障那类型ID",type = "Integer",description = "车辆故障类型ID")
private Integer faultTypeId;
/**
* ID
*/
@Schema(defaultValue = "车辆故障规则ID",type = "Integer",description = "车辆故障规则ID")
public Integer faultRuleId;
/**
* VIN
*/
@Schema(defaultValue = "故障VIN编码",type = "String",description = "故障VIN编码")
public String carVin;
/**
*
*/
@Schema(defaultValue = "车辆故障标签",type = "String",description = "车辆故障标签")
public String faultLabel;
/**
*
*/
@Schema(defaultValue = "车辆故障位",type = "String",description = "车辆故障位")
public String faultBit;
/**
*
*/
@Schema(defaultValue = "车辆故障值",type = "String",description = "车辆故障值")
public String faultValue;
/**
* v
*/
@Schema(defaultValue = "故障级别",type = "String",description = "故障级别")
public String faultWarn;
/**
*
*/
@Schema(defaultValue = "报警状态",type = "String",description = "报警状态")
public String warnStatus;
/**
*
*/
@Schema(defaultValue = "故障描述信息",type = "String",description = "故障描述信息")
public String faultDesc;
/**
*
*/
@Schema(defaultValue = "启用状态",type = "Integer",description = "启用状态")
public Integer state;
/**
*
*/
@Schema(defaultValue = "故障规则名称",type = "String",description = "故障规则名称")
public String faultRuleName;
/**
*
*/
@Schema(defaultValue = "故障规则参数",type = "String",description = "故障规则参数")
public String faultRuleParameter;
/**
*
*/
@Schema(defaultValue = "故障规则描述",type = "String",description = "故障规则描述")
public String faultRuleDescription;
}

View File

@ -31,7 +31,7 @@ public class CarVO {
/** /**
* *
*/ */
private String carCoed; private String carCode;
/** /**
* 1. 2.绿 3. 4. 5. * 1. 2.绿 3. 4. 5.
*/ */
@ -47,7 +47,7 @@ public class CarVO {
/** /**
* *
*/ */
private Integer typeId; private Long configId;
/** /**
* *
*/ */
@ -94,16 +94,18 @@ public class CarVO {
/** 所属企业 */ /** 所属企业 */
private Long companyId; private Long enterpriseId;
/** 车辆车型(如客车,卡车,公交车等) */
private String carType;
// /** 车辆车型(如客车,卡车,公交车等) */
// private String carType;
/** /**
* *
*/ */
@TableField(exist = false) @TableField(exist = false)
private String typeName; private String configName;
/** /**
* 1. 2. 3. * 1. 2. 3.

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-modules-enterprise</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>cloud-modules-enterprise-remote</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<description>
cloud-modules-enterprise-remote 企业远程调用模块
</description>
<dependencies>
<!-- 企业公共模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-modules-enterprise-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,10 +1,9 @@
package com.muyu.analysis.parsing.remote; package com.muyu.enterprise.remote;
import com.muyu.analysis.parsing.remote.factory.RemoteClientServiceFactory; import com.muyu.enterprise.remote.factory.RemoteMessageValueServiceFactory;
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.enterprise.domain.resp.car.MessageValueListResp; import com.muyu.enterprise.domain.resp.car.MessageValueListResp;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -12,34 +11,27 @@ import org.springframework.web.bind.annotation.PathVariable;
import java.util.List; import java.util.List;
/** /**
* *
* @Author * @Author
* @Packagecom.muyu.analysis.parsing.feign * @Packagecom.muyu.analysis.parsing.feign
* @Projectcloud-server * @Projectcloud-server
* @nameRemoteServiceClient * @nameRemoteServiceClient
* @Date2024/9/28 20:38 * @Date2024/9/28 20:38
* ,,value = ServiceNameConstants.ENTERPRISE_SERVICE
* ,fallbackFactory= RemoteClientServiceFactory.class
*/ */
@FeignClient(name = "cloud-enterprise",value = ServiceNameConstants.ENTERPRISE_SERVICE @FeignClient(
,fallbackFactory= RemoteClientServiceFactory.class path = "/messageValue",
contextId = "remoteMessageValueService",
value = ServiceNameConstants.ENTERPRISE_SERVICE,
fallbackFactory= RemoteMessageValueServiceFactory.class
) )
public interface RemoteClientService { public interface RemoteMessageValueService {
/**
* id
* @param vehicleVin
* @return
*/
@GetMapping("/vehicleManage/findByVehicleVin/{vehicleVin}")
// @Operation(description = "通过车辆vin码查询模板id")
public Result<Long> findByVehicleVin(@PathVariable("vehicleVin") String vehicleVin);
/** /**
* id * id
* @param templateId * @param templateId
* @return * @return
*/ */
@GetMapping("/messageValue/findByTemplateId/{templateId}") @GetMapping("/findByTemplateId/{templateId}")
// @Operation(summary = "根据报文模版id查询报文数据", description = "根据报文模版id查询报文数据") // @Operation(summary = "根据报文模版id查询报文数据", description = "根据报文模版id查询报文数据")
public Result<List<MessageValueListResp>> findByTemplateId(@PathVariable("templateId") Long templateId); public Result<List<MessageValueListResp>> findByTemplateId(@PathVariable("templateId") Long templateId);

View File

@ -0,0 +1,33 @@
package com.muyu.enterprise.remote;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.remote.factory.RemoteVehicleServiceFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
*
* @Author
* @Packagecom.muyu.enterprise.remote
* @Projectcloud-server
* @nameRemoteVehicleService
* @Date2024/10/7 20:53
*/
@FeignClient(
path = "/vehicleManage",
contextId = "remoteVehicleService",
value = ServiceNameConstants.ENTERPRISE_SERVICE,
fallbackFactory= RemoteVehicleServiceFactory.class
)
public interface RemoteVehicleService {
/**
* vinid
* @param vehicleVin
* @return
*/
@GetMapping("/findByVehicleVin/{vehicleVin}")
public Result<Long> findByVehicleVin(@PathVariable("vehicleVin") String vehicleVin);
}

View File

@ -1,6 +1,6 @@
package com.muyu.analysis.parsing.remote.factory; package com.muyu.enterprise.remote.factory;
import com.muyu.analysis.parsing.remote.RemoteClientService; import com.muyu.enterprise.remote.RemoteMessageValueService;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.domain.resp.car.MessageValueListResp; import com.muyu.enterprise.domain.resp.car.MessageValueListResp;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
/** /**
* *
* @Author * @Author
* @Packagecom.muyu.analysis.parsing.remote.factory * @Packagecom.muyu.analysis.parsing.remote.factory
* @Projectcloud-server * @Projectcloud-server
@ -19,21 +19,15 @@ import java.util.List;
* @Date2024/9/28 21:16 * @Date2024/9/28 21:16
*/ */
@Component @Component
public class RemoteClientServiceFactory public class RemoteMessageValueServiceFactory
implements FallbackFactory<RemoteClientService> implements FallbackFactory<RemoteMessageValueService>
{ {
private static final Logger log = LoggerFactory.getLogger(RemoteClientServiceFactory.class); private static final Logger log = LoggerFactory.getLogger(RemoteMessageValueServiceFactory.class);
@Override @Override
public RemoteClientService create(Throwable throwable) { public RemoteMessageValueService create(Throwable throwable) {
log.error("报文模版传参调用失败:{}", throwable.getMessage()); log.error("报文模版传参调用失败:{}", throwable.getMessage());
return new RemoteClientService(){ return new RemoteMessageValueService(){
@Override
public Result<Long> findByVehicleVin(String vehicleVin) {
return Result.error("报文模版传参调用失败" + throwable.getMessage());
}
@Override @Override
public Result<List<MessageValueListResp>> findByTemplateId(Long templateId) { public Result<List<MessageValueListResp>> findByTemplateId(Long templateId) {
return Result.error("报文模版传参调用失败" + throwable.getMessage()); return Result.error("报文模版传参调用失败" + throwable.getMessage());

View File

@ -0,0 +1,34 @@
package com.muyu.enterprise.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.domain.resp.car.MessageValueListResp;
import com.muyu.enterprise.remote.RemoteVehicleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* @Author
* @Packagecom.muyu.enterprise.remote.factory
* @Projectcloud-server
* @nameRemoteVehicleServiceFactory
* @Date2024/10/7 20:57
*/
@Component
public class RemoteVehicleServiceFactory implements FallbackFactory<RemoteVehicleService> {
private static final Logger log = LoggerFactory.getLogger(RemoteVehicleServiceFactory.class);
@Override
public RemoteVehicleService create(Throwable throwable) {
return new RemoteVehicleService() {
@Override
public Result<Long> findByVehicleVin(String vehicleVin) {
return Result.error("报文模版传参调用失败" + throwable.getMessage());
}
};
}
}

View File

@ -0,0 +1,2 @@
com.muyu.enterprise.remote.factory.RemoteVehicleServiceFactory
com.muyu.enterprise.remote.factory.RemoteMessageValueServiceFactory

View File

@ -83,6 +83,18 @@
<artifactId>cloud-common-api-doc</artifactId> <artifactId>cloud-common-api-doc</artifactId>
</dependency> </dependency>
<!-- 企业缓存 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-modules-enterprise-cache</artifactId>
</dependency>
<!-- 远程调用 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- 企业业务平台 - 公共依赖 --> <!-- 企业业务平台 - 公共依赖 -->
<dependency> <dependency>
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>

View File

@ -6,7 +6,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
/** /**
* *
* *
* @author muyu * @author muyu
*/ */

View File

@ -0,0 +1,17 @@
package com.muyu.enterprise.OpenFen;
import org.springframework.stereotype.Component;
/**
*
* @ClassName SysEntOpenFen
* @Description SysEntOpenFen:
* @Date 2024/10/7 11:52
* @author MingWei.Zong()
*/
@Component
public class SysEntFallbackFactory {
}

View File

@ -5,6 +5,7 @@ import com.muyu.enterprise.service.CarCompanyService;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -18,27 +19,33 @@ import java.util.List;
* @Date 2024/9/28 16:52 * @Date 2024/9/28 16:52
*/ */
@RestController @RestController
@RequestMapping("/company") @RequestMapping("/carCompany")
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
@Tag(name = "CarCompanyController", description = "企业表") @Tag(name = "CarCompanyController", description = "企业表")
public class CarCompanyController extends BaseController { public class CarCompanyController extends BaseController {
@Autowired private final CarCompanyService sysCarCompanyService;
private CarCompanyService sysCarCompanyService;
/** /**
* *
*/ */
@PostMapping("selectCompany") @PostMapping("selectCompany")
public Result<List<CarCompany>> selectCompany(){ public Result<List<CarCompany>> selectCompany(){
return Result.success(sysCarCompanyService.list()); startPage();
List<CarCompany> list = sysCarCompanyService.list();
list.forEach(carCompany -> {
});
return Result.success(list);
} }
/** /**
* ID * ID
*/ */
@PostMapping("selectCompanyByCompanyId") @PostMapping("selectCompanyByCompanyId")
public Result<CarCompany> selectCompanyByCompanyId(@RequestParam("companyId") Long companyId){ public Result<CarCompany> selectCompanyByCompanyId(@RequestParam("enterpriseId") Long enterpriseId){
return Result.success(sysCarCompanyService.getById(companyId)); return Result.success(sysCarCompanyService.selectCompanyByCompanyId(enterpriseId));
} }
} }

View File

@ -0,0 +1,47 @@
package com.muyu.enterprise.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.enterprise.domain.CarCompany;
import com.muyu.enterprise.service.CarCompanyService;
import com.muyu.enterprise.service.CarConfigService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* --
* @ClassName CarCompanyController
* @Description Controller
* @author MingWei.Zong
* @Date 2024/9/28 16:52
*/
@RestController
@RequestMapping("/carConfig")
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
@Tag(name = "CarConfigController", description = "车辆配置")
public class CarConfigController extends BaseController {
private final CarConfigService carConfigService;
/**
* configId
* @param configId
* @return
*/
@PostMapping("selectByConfigId")
public Result selectByConfigId(@RequestParam("configId") Long configId){
startPage();
return Result.success(carConfigService.selectByConfigId(configId));
}
}

View File

@ -3,6 +3,7 @@ package com.muyu.enterprise.controller;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.StringUtils;
import com.muyu.enterprise.cache.CarManageCacheService;
import com.muyu.enterprise.domain.CarManage; import com.muyu.enterprise.domain.CarManage;
import com.muyu.enterprise.domain.dto.CarDTO; import com.muyu.enterprise.domain.dto.CarDTO;
import com.muyu.enterprise.domain.vo.CarVO; import com.muyu.enterprise.domain.vo.CarVO;
@ -14,6 +15,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -28,22 +30,37 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/carManage") @RequestMapping("/carManage")
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
@Tag(name = "CarManageController", description = "车辆管理") @Tag(name = "CarManageController", description = "车辆管理")
public class CarManageController extends BaseController { public class CarManageController extends BaseController {
@Autowired private final CarManageCacheService carManageCacheService;
private CarCompanyService sysCarCompanyService;
@Autowired private final CarCompanyService sysCarCompanyService;
private CarManageService sysCarService;
private final CarManageService sysCarService;
/** /**
* 2 *
* @param carDTO * @param carDTO
* @return * @return
*/ */
@PostMapping("CarListShow") @PostMapping("/carListShow2")
public Result<List<CarManage>> CarListShow(@RequestBody CarDTO carDTO){ public Result<List<CarVO>> carListShow2(@RequestBody CarDTO carDTO){
startPage();
// 存到缓存中去
return Result.success(sysCarService.carListShow2(carDTO));
}
/**
*
* @param carDTO
* @return
*/
@PostMapping("/carListShow")
public Result<List<CarVO>> carListShow(@RequestBody CarDTO carDTO){
return Result.success(sysCarService.CarListShow(carDTO)); return Result.success(sysCarService.CarListShow(carDTO));
} }
@ -52,23 +69,11 @@ public class CarManageController extends BaseController {
* @param carId * @param carId
* @return * @return
*/ */
@PostMapping("CarManageShowByCarId") @PostMapping("carManageShowByCarId")
public Result CarManageShowByCarId(@RequestParam("carId") Long carId){ public Result carManageShowByCarId(@RequestParam("carId") Long carId){
return Result.success(sysCarService.getById(carId)); return Result.success(sysCarService.getById(carId));
} }
// /**
// * 车辆列表1
// * @param carVO
// * @return
// */
// @PostMapping("CarList")
// @Operation(summary = "查询列表",description = "车辆管理列表")
// public Result<TableDataInfo<CarManage>> CarList(@RequestBody CarVO carVO){
// startPage();
// return getDataTable(sysCarService.carList(carVO));
// }
/** /**
* *
@ -83,8 +88,8 @@ public class CarManageController extends BaseController {
// 随机生成VIN码 // 随机生成VIN码
String key2 = RandomUtil.randomNumbers(17); String key2 = RandomUtil.randomNumbers(17);
carVO.setCarVin(key2); carVO.setCarVin(key2);
sysCarService.save(carVO); sysCarService.insertCar(carVO);
return Result.success("车辆添加成功"); return Result.success("添加成功");
} }

View File

@ -3,9 +3,12 @@ package com.muyu.enterprise.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;
import com.muyu.enterprise.cache.CarManageCacheService;
import com.muyu.enterprise.cache.CarMessageCacheService;
import com.muyu.enterprise.domain.CarMessage; import com.muyu.enterprise.domain.CarMessage;
import com.muyu.enterprise.service.CarMessageService; import com.muyu.enterprise.service.CarMessageService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -20,10 +23,15 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/carMessage") @RequestMapping("/carMessage")
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
@Tag(name = "报文",description = "报文模块") @Tag(name = "报文",description = "报文模块")
public class CarMessageController extends BaseController { public class CarMessageController extends BaseController {
private final CarMessageCacheService carMessageCacheService;
private final CarMessageService sysCarMessageService;
@Autowired @Autowired
private CarMessageService sysCarMessageService; private CarMessageService carMessageService;
/** /**
* *
@ -31,6 +39,7 @@ public class CarMessageController extends BaseController {
*/ */
@PostMapping("selectMessageShow") @PostMapping("selectMessageShow")
public List<CarMessage> selectMessageShow(@RequestParam("templateId") Long templateId){ public List<CarMessage> selectMessageShow(@RequestParam("templateId") Long templateId){
startPage();
return sysCarMessageService.selectMessageShow(templateId); return sysCarMessageService.selectMessageShow(templateId);
} }
@ -41,8 +50,7 @@ public class CarMessageController extends BaseController {
*/ */
@GetMapping("/selectByTemplateId") @GetMapping("/selectByTemplateId")
private Result<List<CarMessage>> selectByTemplateId(@RequestParam("templateId") Integer templateId) { private Result<List<CarMessage>> selectByTemplateId(@RequestParam("templateId") Integer templateId) {
return Result.success(sysCarMessageService.list return Result.success(sysCarMessageService.list(new LambdaQueryWrapper<CarMessage>().eq(CarMessage::getTemplateId, templateId)));
(new LambdaQueryWrapper<CarMessage>().eq(CarMessage::getTemplateId, templateId)));
} }
/** /**
@ -61,6 +69,8 @@ public class CarMessageController extends BaseController {
@PostMapping("insertMessage") @PostMapping("insertMessage")
public Result insertMessage(@RequestBody CarMessage carMessage){ public Result insertMessage(@RequestBody CarMessage carMessage){
sysCarMessageService.save(carMessage); sysCarMessageService.save(carMessage);
//报文 redis
carMessageCacheService.put(carMessage.getMessageType(),new CarMessage());
return Result.success("添加成功"); return Result.success("添加成功");
} }
/** /**

View File

@ -7,6 +7,7 @@ import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.enterprise.domain.CarMessageType; import com.muyu.enterprise.domain.CarMessageType;
import com.muyu.enterprise.service.CarMessageTypeService; import com.muyu.enterprise.service.CarMessageTypeService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -20,11 +21,13 @@ import java.util.List;
* @Date 2024/9/28 16:52 * @Date 2024/9/28 16:52
*/ */
@RestController @RestController
@RequestMapping("carMessageType") @RequestMapping("/carMessageType")
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
@Tag(name = "报文类型" ,description = "报文类型") @Tag(name = "报文类型" ,description = "报文类型")
public class CarMessageTypeController extends BaseController { public class CarMessageTypeController extends BaseController {
@Autowired
private CarMessageTypeService sysCarMessageTypeService; private final CarMessageTypeService sysCarMessageTypeService;
/** /**
* *
@ -32,21 +35,18 @@ public class CarMessageTypeController extends BaseController {
*/ */
@PostMapping("messageTypeList") @PostMapping("messageTypeList")
public Result messageTypeList(){ public Result messageTypeList(){
sysCarMessageTypeService.messageTypeList(); startPage();
List<CarMessageType> list = sysCarMessageTypeService.list(); List<CarMessageType> list = sysCarMessageTypeService.list();
return Result.success(list); return Result.success(list);
} }
/**
*
* @param carMessageType
* @return
*/
@PostMapping("inserMessageType") @PostMapping("inserMessageType")
public Result inserMessageType(@RequestBody CarMessageType carMessageType){ public Result inserMessageType(@RequestBody CarMessageType carMessageType){
/** id 检验 */
if(carMessageType.getMessageTypeId()>0){
return Result.error("添加要什么id");
}
/** token 检验 */
if(SecurityUtils.getToken().isEmpty()){
return Result.error("token不为空");
}
/** 报文类型 */ /** 报文类型 */
if(StringUtils.isEmpty(carMessageType.getMessageType())){ if(StringUtils.isEmpty(carMessageType.getMessageType())){
return Result.error("报文类型不能为空"); return Result.error("报文类型不能为空");
@ -74,13 +74,21 @@ public class CarMessageTypeController extends BaseController {
*/ */
@PostMapping("updateMessageType") @PostMapping("updateMessageType")
public Result updateMessageType(@RequestBody CarMessageType carMessageType){ public Result updateMessageType(@RequestBody CarMessageType carMessageType){
/** id */ /** 报文类型 */
if(carMessageType.getMessageTypeId() < 0 ){ if(StringUtils.isEmpty(carMessageType.getMessageType())){
return Result.error("修改需要id"); return Result.error("报文类型不能为空");
} }
/** 报文编号 */ /** 报文 */
if(StringUtils.isEmpty(carMessageType.getMessageName())){
return Result.error("报文不能为空");
}
/** 报文编码 */
if(StringUtils.isEmpty(carMessageType.getMessageCode())){ if(StringUtils.isEmpty(carMessageType.getMessageCode())){
return Result.error(""); return Result.error("报文编码不能为空");
}
/** 报文字段类型 */
if(StringUtils.isEmpty(carMessageType.getMessageClass())){
return Result.error("报文字段类型不能为空");
} }
sysCarMessageTypeService.updateById(carMessageType); sysCarMessageTypeService.updateById(carMessageType);
return Result.success("修改成功"); return Result.success("修改成功");

View File

@ -5,6 +5,7 @@ import com.muyu.enterprise.service.CarTemplateService;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -18,10 +19,12 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/carTemplate") // 报文模版 @RequestMapping("/carTemplate") // 报文模版
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
@Tag(name = "模版模块",description = "报文模版模块") @Tag(name = "模版模块",description = "报文模版模块")
public class CarTemplateController extends BaseController { public class CarTemplateController extends BaseController {
@Autowired
private CarTemplateService sysCarTemplateService; private final CarTemplateService sysCarTemplateService;
/** /**
* *
@ -29,6 +32,7 @@ public class CarTemplateController extends BaseController {
*/ */
@PostMapping("selectTemplateShow") @PostMapping("selectTemplateShow")
public List<CarTemplate> selectTemplateShow(){ public List<CarTemplate> selectTemplateShow(){
startPage();
return sysCarTemplateService.selectTemplateShow(); return sysCarTemplateService.selectTemplateShow();
} }
/** /**

View File

@ -4,11 +4,14 @@ import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.domain.CarType; import com.muyu.enterprise.domain.CarType;
import com.muyu.enterprise.service.CarTypeService; import com.muyu.enterprise.service.CarTypeService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import static com.muyu.common.core.utils.PageUtils.startPage;
/** /**
* *
* @ClassName CarController * @ClassName CarController
@ -18,11 +21,12 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/carType") @RequestMapping("/carType")
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
@Tag(name = "CarTypeController",description = "车辆类型") @Tag(name = "CarTypeController",description = "车辆类型")
public class CarTypeController { public class CarTypeController {
@Autowired private final CarTypeService carTypeService;
private CarTypeService carTypeService;
/** /**
* *
@ -30,6 +34,7 @@ public class CarTypeController {
*/ */
@GetMapping("/carTypeList") @GetMapping("/carTypeList")
private Result<List<CarType>> carTypeList() { private Result<List<CarType>> carTypeList() {
startPage();
List<CarType> carTypeList = carTypeService.list(); List<CarType> carTypeList = carTypeService.list();
return Result.success(carTypeList); return Result.success(carTypeList);
} }

View File

@ -2,8 +2,8 @@ package com.muyu.enterprise.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.domain.FaultrRule; import com.muyu.enterprise.domain.FaultRule;
import com.muyu.enterprise.service.FaultrRuleService; import com.muyu.enterprise.service.FaultRuleService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -14,42 +14,44 @@ import java.util.List;
* *
* @author chenruijia * @author chenruijia
* @Date 2024/9/28 11:58 * @Date 2024/9/28 11:58
* @Description FaultrRuleController: * @Description FaultRuleController:
*/ */
@RestController @RestController
@RequestMapping("/rule") @RequestMapping("/rule")
@Tag(name = "故障的规则",description = "对故障数据规则的判断") @Tag(name = "故障的规则",description = "对故障数据规则的判断")
public class FaultrRuleController { public class FaultRuleController {
@Autowired @Autowired
private FaultrRuleService faultrRuleService; private FaultRuleService faultRuleList;
/** /**
* *
*/ */
@RequestMapping(value = "/faultRuleList", method = RequestMethod.GET) @RequestMapping(value = "/faultRuleList", method = RequestMethod.GET)
public Result<List<FaultrRule>> faultRuleList(FaultrRule faultrRule) public Result<List<FaultRule>> faultRuleList(FaultRule faultRule)
{ {
List<FaultrRule> list = faultrRuleService.faultRuleList(faultrRule); List<FaultRule> list = faultRuleList.faultRuleList(faultRule);
return Result.success(list); return Result.success(list);
} }
/** /**
* *
* @param faultrRule * @param faultRule
* @return * @return
*/ */
@RequestMapping(value = "/insertRule",method = RequestMethod.POST) @RequestMapping(value = "/insertRule",method = RequestMethod.POST)
public Result insertRule(@RequestBody FaultrRule faultrRule){ public Result insertRule(@RequestBody FaultRule faultRule){
return Result.success(faultrRuleService.save(faultrRule)); return Result.success(faultRuleList.save(faultRule));
} }
/** /**
* *
* @param faultrRule * @param faultRule
* @return * @return
*/ */
@RequestMapping(value = "/updateRule",method = RequestMethod.POST) @RequestMapping(value = "/updateRule",method = RequestMethod.POST)
public Result updateRule(@RequestBody FaultrRule faultrRule){ public Result updateRule(@RequestBody FaultRule faultRule){
return Result.success(faultrRuleService.updateById(faultrRule)); return Result.success(faultRuleList.updateById(faultRule));
} }
/** /**
@ -59,7 +61,7 @@ public class FaultrRuleController {
*/ */
@RequestMapping(value = "/byidRuleId/{faultRuleId}",method = RequestMethod.GET) @RequestMapping(value = "/byidRuleId/{faultRuleId}",method = RequestMethod.GET)
public Result byidRuleId(@PathVariable Long faultRuleId){ public Result byidRuleId(@PathVariable Long faultRuleId){
FaultrRule byid = faultrRuleService.byidRuleId(faultRuleId); FaultRule byid = faultRuleList.byidRuleId(faultRuleId);
return Result.success(byid); return Result.success(byid);
} }
@ -69,7 +71,7 @@ public class FaultrRuleController {
@RequestMapping(value = "/remove/{ids}",method = RequestMethod.DELETE) @RequestMapping(value = "/remove/{ids}",method = RequestMethod.DELETE)
public Result<Integer> remove(@PathVariable("ids") Long[] ids) public Result<Integer> remove(@PathVariable("ids") Long[] ids)
{ {
faultrRuleService.removeBatchByIds(Arrays.asList(ids)); faultRuleList.removeBatchByIds(Arrays.asList(ids));
return Result.success(); return Result.success();
} }

View File

@ -1,6 +1,7 @@
package com.muyu.enterprise.controller; package com.muyu.enterprise.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.cache.CarFaultCacheService;
import com.muyu.enterprise.domain.FaultType; import com.muyu.enterprise.domain.FaultType;
import com.muyu.enterprise.service.FaultTypeService; import com.muyu.enterprise.service.FaultTypeService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -19,6 +20,8 @@ import java.util.List;
@RequestMapping("/type") @RequestMapping("/type")
@Tag(name = "故障类型",description = "对故障类型的定义") @Tag(name = "故障类型",description = "对故障类型的定义")
public class FaultTypeController { public class FaultTypeController {
@Autowired
private CarFaultCacheService carFaultCacheService;
@Autowired @Autowired
private FaultTypeService faultTypeService; private FaultTypeService faultTypeService;

View File

@ -7,6 +7,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.enterprise.domain.WarnLogs; import com.muyu.enterprise.domain.WarnLogs;
import com.muyu.enterprise.service.IWarnLogsService; import com.muyu.enterprise.service.IWarnLogsService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,6 +24,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/logs") @RequestMapping("/logs")
@Tag(name = "车辆预警日志",description = "用来记录车辆预警的日志")
public class WarnLogsController extends BaseController public class WarnLogsController extends BaseController
{ {
@Resource @Resource

View File

@ -8,6 +8,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.enterprise.domain.WarnRule; import com.muyu.enterprise.domain.WarnRule;
import com.muyu.enterprise.service.IWarnRuleService; import com.muyu.enterprise.service.IWarnRuleService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -24,6 +25,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/rule") @RequestMapping("/rule")
@Tag(name = "车辆预警规则",description = "用来客户添加或者修改规则")
public class WarnRuleController extends BaseController public class WarnRuleController extends BaseController
{ {
@Resource @Resource

View File

@ -7,6 +7,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.enterprise.domain.resp.WarnStrategy; import com.muyu.enterprise.domain.resp.WarnStrategy;
import com.muyu.enterprise.service.IWarnStrategyService; import com.muyu.enterprise.service.IWarnStrategyService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,6 +24,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/strategy") @RequestMapping("/strategy")
@Tag(name = "故障策略",description = "故障策略对应车辆类型用来客户选择")
public class WarnStrategyController extends BaseController public class WarnStrategyController extends BaseController
{ {
@Resource @Resource

View File

@ -0,0 +1,22 @@
package com.muyu.enterprise.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.muyu.enterprise.domain.CarConfig;
import com.muyu.enterprise.domain.CarManage;
import com.muyu.enterprise.domain.vo.CarVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* --
* @ClassName CarManageMapper
* @Description Mapper
* @author MingWei.Zong
* @Date 2024/9/28 16:52
*/
public interface CarConfigMapper extends MPJBaseMapper<CarConfig> {
}

View File

@ -2,9 +2,12 @@ package com.muyu.enterprise.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.muyu.enterprise.domain.CarManage; import com.muyu.enterprise.domain.CarManage;
import com.muyu.enterprise.domain.dto.CarDTO; import com.muyu.enterprise.domain.dto.CarDTO;
import com.muyu.enterprise.domain.vo.CarVO; import com.muyu.enterprise.domain.vo.CarVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -16,26 +19,7 @@ import java.util.List;
* @author MingWei.Zong * @author MingWei.Zong
* @Date 2024/9/28 16:52 * @Date 2024/9/28 16:52
*/ */
@Mapper
public interface CarManageMapper extends MPJBaseMapper<CarManage> {
public interface CarManageMapper extends BaseMapper<CarManage> {
/**
*
* @param queryWrapper
* @return
*/
List<CarVO> carList(LambdaQueryWrapper<CarVO> queryWrapper);
/**
* 2
* @param carDTO
* @return
*/
List<CarVO> CarListShow(CarDTO carDTO);
/**
* id
* @param carId
* @return
*/
List<CarVO> CarListShowByCarId(@Param("carId") Long carId);
} }

View File

@ -14,10 +14,5 @@ import java.util.List;
*/ */
@Mapper @Mapper
public interface CarMessageMapper extends BaseMapper<CarMessage> { public interface CarMessageMapper extends BaseMapper<CarMessage> {
/**
*
* @param templateId
* @return
*/
List<CarMessage> selectMessageShow(Long templateId);
} }

View File

@ -14,9 +14,5 @@ import java.util.List;
*/ */
@Mapper @Mapper
public interface CarTemplateMapper extends BaseMapper<CarTemplate> { public interface CarTemplateMapper extends BaseMapper<CarTemplate> {
/**
*
* @return
*/
List<CarTemplate> selectTemplateShow();
} }

View File

@ -1,15 +1,15 @@
package com.muyu.enterprise.mapper; package com.muyu.enterprise.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.enterprise.domain.FaultrRule; import com.muyu.enterprise.domain.FaultRule;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
* *
* @Author: chenruijia * @Author: chenruijia
* @Date 2024/9/28 12.17 * @Date 2024/9/28 12.17
* @Description FaultrRuleMapper: * @Description FaultRuleMapper:
*/ */
@Mapper @Mapper
public interface FaultrRuleMapper extends BaseMapper<FaultrRule> { public interface FaultRuleMapper extends BaseMapper<FaultRule> {
} }

View File

@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
* @Description SysCarFaultMapper: * @Description SysCarFaultMapper:
*/ */
@Mapper @Mapper
public interface SysCarFaultMapper extends BaseMapper<SysCarFault>{ public interface SysCarFaultMapper extends BaseMapper<SysCarFault> {
} }

View File

@ -10,11 +10,12 @@ import com.muyu.enterprise.domain.CarCompany;
* @Date 2024/9/28 16:52 * @Date 2024/9/28 16:52
*/ */
public interface CarCompanyService extends IService<CarCompany> { public interface CarCompanyService extends IService<CarCompany> {
/** /**
* * @param enterpriseId
* @return * @return
*/ */
//List<CarCompany> selectCompany(); CarCompany selectCompanyByCompanyId(Long enterpriseId);
} }

View File

@ -0,0 +1,25 @@
package com.muyu.enterprise.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.enterprise.domain.CarConfig;
import com.muyu.enterprise.domain.CarManage;
import com.muyu.enterprise.domain.dto.CarDTO;
import com.muyu.enterprise.domain.vo.CarVO;
import java.util.List;
/**
* --
* @ClassName CarConfigService
* @Description Service
* @author MingWei.Zong
* @Date 2024/9/28 16:52
*/
public interface CarConfigService extends IService<CarConfig> {
/**
* configId
* @param configId
* @return
*/
CarConfig selectByConfigId(Long configId);
}

View File

@ -14,37 +14,24 @@ import java.util.List;
* @Date 2024/9/28 16:52 * @Date 2024/9/28 16:52
*/ */
public interface CarManageService extends IService<CarManage> { public interface CarManageService extends IService<CarManage> {
// /**
// * 车辆列表
// * @param carVO
// * @return
// */
// List<CarManage> carList(CarVO carVO);
//
// /**
// * 车辆添加
// * @param carVO
// */
// void insertCar(CarVO carVO);
//
// /**
// * 车辆删除
// * @param ids
// */
// void deleteCar(List<Long> ids);
//
//
/** /**
* 2 * 2
* @param carDTO * @param carDTO
* @return * @return
*/ */
List<CarManage> CarListShow(CarDTO carDTO); List<CarVO> carListShow2(CarDTO carDTO);
//
// /** /**
// * 通过id查询 *
// * @param carId * @param carDTO
// * @return * @return
// */ */
// List<CarVO> CarListShowByCarId(Long carId); List<CarVO> CarListShow(CarDTO carDTO);
/**
*
* @param carVO
* @return
*/
void insertCar(CarManage carVO);
} }

View File

@ -12,5 +12,5 @@ import java.util.List;
* @Date 2024/9/28 16:52 * @Date 2024/9/28 16:52
*/ */
public interface CarMessageTypeService extends IService<CarMessageType> { public interface CarMessageTypeService extends IService<CarMessageType> {
List<CarMessageType> messageTypeList();
} }

View File

@ -7,14 +7,13 @@ import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description FaultLogService: * @Description FaultLogService:
*/ */
public interface FaultLogService extends IService<FaultLog> { public interface FaultLogService extends IService<FaultLog> {
List<FaultLog> faultLogList(FaultLog faultLog); List<FaultLog> faultLogList(FaultLog faultLog);
FaultLog byidId(Long faultLogId); FaultLog byidId(Long faultLogId);
} }

View File

@ -6,7 +6,7 @@ import com.muyu.enterprise.domain.FaultMessage;
import java.util.List; import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description FaultMessageService: * @Description FaultMessageService:
*/ */

View File

@ -1,7 +1,7 @@
package com.muyu.enterprise.service; package com.muyu.enterprise.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.enterprise.domain.FaultrRule; import com.muyu.enterprise.domain.FaultRule;
import java.util.List; import java.util.List;
/** /**
@ -10,8 +10,8 @@ import java.util.List;
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description FaultrRuleService: * @Description FaultrRuleService:
*/ */
public interface FaultrRuleService extends IService<FaultrRule> { public interface FaultRuleService extends IService<FaultRule> {
List<FaultrRule> faultRuleList(FaultrRule faultrRule); List<FaultRule> faultRuleList(FaultRule faultrRule);
FaultrRule byidRuleId(Long faultRuleId); FaultRule byidRuleId(Long faultRuleId);
} }

View File

@ -6,7 +6,7 @@ import com.muyu.enterprise.domain.FaultType;
import java.util.List; import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description FaultTypeService: * @Description FaultTypeService:
*/ */

View File

@ -6,7 +6,7 @@ import com.muyu.enterprise.domain.SysCarFault;
import java.util.List; import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description SysCarFaultService: * @Description SysCarFaultService:
*/ */

View File

@ -29,11 +29,17 @@ public class CarCompanyServiceImpl extends ServiceImpl<CarCompanyMapper, CarComp
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
@Autowired @Autowired
private CarCompanyMapper sysCarCompanyMapper; private CarCompanyMapper carCompanyMapper;
/**
*
* @param enterpriseId
* @return
*/
@Override
public CarCompany selectCompanyByCompanyId(Long enterpriseId) {
return carCompanyMapper.selectById(enterpriseId);
}
// @Override
// public List<CarCompany> selectCompany() {
// return sysCarCompanyMapper.;
// }
} }

View File

@ -0,0 +1,45 @@
package com.muyu.enterprise.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.muyu.enterprise.domain.CarCompany;
import com.muyu.enterprise.domain.CarConfig;
import com.muyu.enterprise.domain.CarManage;
import com.muyu.enterprise.domain.dto.CarDTO;
import com.muyu.enterprise.domain.vo.CarVO;
import com.muyu.enterprise.mapper.CarConfigMapper;
import com.muyu.enterprise.mapper.CarManageMapper;
import com.muyu.enterprise.service.CarCompanyService;
import com.muyu.enterprise.service.CarConfigService;
import com.muyu.enterprise.service.CarManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* --
* @ClassName CarConfigServiceImpl
* @Description ServiceImpl
* @author MingWei.Zong
* @Date 2024/9/28 16:52
*/
@Service
public class CarConfigServiceImpl extends ServiceImpl<CarConfigMapper, CarConfig>
implements CarConfigService {
@Autowired
private CarConfigMapper carConfigMapper;
/**
* configId
* @param configId
* @return
*/
@Override
public CarConfig selectByConfigId(Long configId) {
CarConfig carConfig = carConfigMapper.selectById(configId);
return carConfig;
}
}

View File

@ -2,21 +2,26 @@ package com.muyu.enterprise.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.StringUtils;
import com.muyu.enterprise.cache.CarManageCacheService;
import com.muyu.enterprise.controller.CarCompanyController; import com.muyu.enterprise.controller.CarCompanyController;
import com.muyu.enterprise.domain.CarCompany; import com.muyu.enterprise.domain.CarCompany;
import com.muyu.enterprise.domain.CarConfig;
import com.muyu.enterprise.domain.CarManage; import com.muyu.enterprise.domain.CarManage;
import com.muyu.enterprise.domain.dto.CarDTO; import com.muyu.enterprise.domain.dto.CarDTO;
import com.muyu.enterprise.domain.vo.CarVO; import com.muyu.enterprise.domain.vo.CarVO;
import com.muyu.enterprise.mapper.CarManageMapper; import com.muyu.enterprise.mapper.CarManageMapper;
import com.muyu.enterprise.service.CarCompanyService; import com.muyu.enterprise.service.CarCompanyService;
import com.muyu.enterprise.service.CarConfigService;
import com.muyu.enterprise.service.CarManageService; import com.muyu.enterprise.service.CarManageService;
import com.muyu.common.redis.service.RedisService; import com.muyu.common.redis.service.RedisService;
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.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -30,122 +35,80 @@ import java.util.List;
public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage> public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage>
implements CarManageService { implements CarManageService {
// @Autowired @Autowired
// private RedisService redisService; private CarCompanyService carCompanyService;
// @Autowired @Autowired
// private CarManageMapper carMapper; private CarConfigService carConfigService;
// // 企业 service @Autowired
// @Autowired private CarManageCacheService carManageCacheService;
// private CarCompanyService carCompanyService; @Autowired
// /** private CarManageMapper carManageMapper;
// * 车辆列表
// * @param carVO
// * @return
// */
// @Override
// public List<CarVO> carList(CarVO carVO) {
//
//// MPJLambdaWrapper<CarVO> queryWrapper = new MPJLambdaWrapper<>();
//// carMapper.selectJoinList(CarVO.class,
//// queryWrapper.selectAll(CarVO.class)// 主表查询所有
//// .select(Type::getTypeName)// 获取附表的字段
//// .select(Type::getEnergyType)
//// .select(Type::getGearType)
//// .leftJoin(Type.class,Type::getTypeId,Car::getTypeId)// 左链接
//// );
//// // vin码--精确
//// if(StringUtils.isNotEmpty(carVO.getCarVin())){
//// queryWrapper.eq(CarVO::getCarVin,carVO.getCarVin());
//// }
//// // 车辆型号
//// if(StringUtils.isNotEmpty(carVO.getTypeName())){
//// queryWrapper.like(CarVO::getTypeName,carVO.getTypeName());
//// }
//// // 能源类型 1.电动 2.纯油 3.混动
//// if(carVO.getEnergyType()>0){
//// queryWrapper.eq(CarVO::getEnergyType,carVO.getEnergyType());
//// }
//// // 档的类型 1.手动 2.自动
//// if(carVO.getGearType()>0){
//// queryWrapper.eq(CarVO::getGearType,carVO.getGearType());
//// }
//// // 自定义列表查询
////// @Select("")
////// this.list(queryWrapper);
//// // mybatis列表查询
//// //return carMapper.carList(queryWrapper);
//// // 单表的列表查询
//// this.list(
//// new LambdaQueryWrapper<CarVO>()
//// .eq(StringUtils.isNotEmpty(carVO.getCarVin()),CarVO::getCarVin,carVO.getCarVin())
//// .eq(carVO.getEnergyType()>0,CarVO::getEnergyType,carVO.getEnergyType())
//// .eq(carVO.getGearType()>0,CarVO::getGearType,carVO.getGearType())
//// .like(StringUtils.isNotEmpty(carVO.getTypeName()),CarVO::getTypeName,carVO.getTypeName())
//// );
//// return this.list(queryWrapper);
// return null;
// }
//
// /**
// * 车辆添加
// * @param carVO
// */
// @Override
// public void insertCar(CarVO carVO) {
// carMapper.insert(carVO);
// }
//
//// /**
//// * 车辆修改
//// * @param carVO
//// */
//// @Override
//// public void updataCar(CarVO carVO) {
//// carMapper.updateById(carVO);
//// }
//
/** /**
* 2 * 2
* @param carDTO * @param carDTO
* @return * @return
*/ */
@Override @Override
public List<CarManage> CarListShow(CarDTO carDTO) { public List<CarVO> carListShow2(CarDTO carDTO) {
// 获取 企业 // 获取 企业
// CarCompanyController carCompanyController = new CarCompanyController();
CarManage carManage = BeanUtil.copyProperties(carDTO, CarManage.class); CarManage carManage = BeanUtil.copyProperties(carDTO, CarManage.class);
return lambdaQuery() List<CarManage> list = lambdaQuery()
.eq(StringUtils.isNotEmpty(carManage.getCarVin()), CarManage::getCarVin, carManage.getCarVin()) .eq(carManage.getCarVin() != null && carManage.getCarVin() != "", CarManage::getCarVin, carManage.getCarVin())
.eq(carManage.getConfigId() > 0, CarManage::getCarVin, carManage.getConfigId()) .eq(carManage.getCarModel() != null && carManage.getCarModel() != "", CarManage::getCarModel, carManage.getCarModel())
.eq(carManage.getCarBrand() != null && carManage.getCarBrand() != "", CarManage::getCarBrand, carManage.getCarBrand())
.eq(carManage.getCarStatus() != null && carManage.getCarStatus() > 0, CarManage::getCarStatus, carManage.getCarStatus())
.eq(carManage.getEnterpriseId() != null && carManage.getEnterpriseId() > 0, CarManage::getEnterpriseId, carManage.getEnterpriseId())
.list(); .list();
// list.forEach(carManage1 -> { // List<CarManage> list = list();
// // 获取 企业 id
// carCompanyController.selectCompanyByCompanyId(carManage1.getCompanyId()); // 把 查询出来的车辆数据 copy 到 CarVO
// }); List<CarVO> carVOS = BeanUtil.copyToList(list, CarVO.class);
// // 遍历赋值
// List<CarCompany> data = carCompanyController.selectCompany().getData(); carVOS.forEach(carVO -> {
// getById() // 查询出对象,用于赋值
CarConfig carConfig = carConfigService.selectByConfigId(carVO.getConfigId());
carVO.setConfigName(carConfig.getConfigName());
carVO.setEnergyType(carConfig.getEnergyType());
carVO.setGearType(carConfig.getGearType());
// 查询出对象,用于赋值
CarCompany carCompany = carCompanyService.selectCompanyByCompanyId(carVO.getEnterpriseId());
carVO.setCompanyName(carCompany.getCompanyName());
// 存到 redis
carManageCacheService.put(carVO.getCarVin(),new CarManage());
});
return carVOS;
}
@Override
public List<CarVO> CarListShow(CarDTO carDTO) {
// 获取 企业
CarManage carManage = BeanUtil.copyProperties(carDTO, CarManage.class);
return carManageMapper.selectJoinList(CarVO.class, new MPJLambdaWrapper<CarManage>()
.selectAll(CarManage.class) // 查询所有车辆表
.select(CarCompany::getCompanyName)
.select(CarConfig::getConfigName)
.select(CarConfig::getGearType)
.select(CarConfig::getEnergyType)
.leftJoin(CarConfig.class, CarConfig::getConfigId, CarManage::getConfigId)
.leftJoin(CarCompany.class, CarCompany::getEnterpriseId, CarManage::getEnterpriseId)
.eq(carManage.getCarVin() != null && carManage.getCarVin() != "", CarManage::getCarVin, carManage.getCarVin())
.eq(carManage.getCarModel() != null && carManage.getCarModel() != "", CarManage::getCarModel, carManage.getCarModel())
.eq(carManage.getCarBrand() != null && carManage.getCarBrand() != "", CarManage::getCarBrand, carManage.getCarBrand())
.eq(carManage.getCarStatus() != null && carManage.getCarStatus() > 0, CarManage::getCarStatus, carManage.getCarStatus())
.eq(carManage.getEnterpriseId() != null && carManage.getEnterpriseId() > 0, CarManage::getEnterpriseId, carManage.getEnterpriseId())
);
} }
//
// /** @Override
// * 通过id查询 public void insertCar(CarManage carVO) {
// * @param carId save(carVO);
// * @return // 存到缓存中去
// */ carManageCacheService.put(carVO.getCarVin(),new CarManage());
// @Override }
// public CarManage CarListShowByCarId(Long carId) {
// return carMapper.CarListShowByCarId(carId);
// }
//
//
// /**
// * 车辆删除
// * @param ids
// */
// @Override
// public void deleteCar(List<Long> ids) {
// carMapper.deleteBatchIds(ids);
// }
} }

View File

@ -1,5 +1,6 @@
package com.muyu.enterprise.service.impl; package com.muyu.enterprise.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.enterprise.domain.CarMessage; import com.muyu.enterprise.domain.CarMessage;
import com.muyu.enterprise.mapper.CarMessageMapper; import com.muyu.enterprise.mapper.CarMessageMapper;
@ -7,6 +8,7 @@ import com.muyu.enterprise.service.CarMessageService;
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;
/** /**
* -- * --
@ -27,7 +29,8 @@ public class CarMessageServiceImpl extends ServiceImpl<CarMessageMapper, CarMess
*/ */
@Override @Override
public List<CarMessage> selectMessageShow(Long templateId) { public List<CarMessage> selectMessageShow(Long templateId) {
return sysCarMessageMapper.selectMessageShow(templateId); return list(new LambdaQueryWrapper<CarMessage>()
.eq(CarMessage::getTemplateId,templateId));
} }
/** /**

View File

@ -18,8 +18,5 @@ import java.util.List;
@Service @Service
public class CarMessageTypeServiceImpl extends ServiceImpl<CarMessageTypeMapper, CarMessageType> implements CarMessageTypeService { public class CarMessageTypeServiceImpl extends ServiceImpl<CarMessageTypeMapper, CarMessageType> implements CarMessageTypeService {
@Override
public List<CarMessageType> messageTypeList() {
return null;
}
} }

View File

@ -26,7 +26,7 @@ public class CarTemplateServiceImpl extends ServiceImpl<CarTemplateMapper, CarTe
*/ */
@Override @Override
public List<CarTemplate> selectTemplateShow() { public List<CarTemplate> selectTemplateShow() {
return sysCarTemplateMapper.selectTemplateShow(); return list();
} }
/** /**

View File

@ -0,0 +1,41 @@
package com.muyu.enterprise.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.enterprise.domain.FaultRule;
import com.muyu.enterprise.mapper.FaultRuleMapper;
import com.muyu.enterprise.service.FaultRuleService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.List;
/**
*
* @Author: chenruijia
* @Date 2024/9/28 12.19
* @Description FaultrRuleServiceImpl:
*/
@Service
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, FaultRule> implements FaultRuleService {
@Override
public List<FaultRule> faultRuleList(FaultRule faultRule) {
LambdaQueryWrapper<FaultRule> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(faultRule.getFaultName())) {
queryWrapper.eq(FaultRule::getFaultName,faultRule.getFaultName());
}
if (StringUtils.isNotEmpty(faultRule.getRuleParameters())) {
queryWrapper.eq(FaultRule::getRuleParameters,faultRule.getRuleParameters());
}
return this.list(queryWrapper);
}
@Override
public FaultRule byidRuleId(Long faultRuleId) {
LambdaQueryWrapper<FaultRule> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(faultRuleId, "规则ID不可为空");
queryWrapper.eq(FaultRule::getFaultRuleId, faultRuleId);
return this.getOne(queryWrapper);
}
}

View File

@ -1,41 +0,0 @@
package com.muyu.enterprise.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.enterprise.domain.FaultrRule;
import com.muyu.enterprise.mapper.FaultrRuleMapper;
import com.muyu.enterprise.service.FaultrRuleService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.List;
/**
*
* @Author: chenruijia
* @Date 2024/9/28 12.19
* @Description FaultrRuleServiceImpl:
*/
@Service
public class FaultrRuleServiceImpl extends ServiceImpl<FaultrRuleMapper, FaultrRule> implements FaultrRuleService {
@Override
public List<FaultrRule> faultRuleList(FaultrRule faultrRule) {
LambdaQueryWrapper<FaultrRule> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleName())) {
queryWrapper.eq(FaultrRule::getFaultRuleName,faultrRule.getFaultRuleName());
}
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleParameter())) {
queryWrapper.eq(FaultrRule::getFaultRuleParameter,faultrRule.getFaultRuleParameter());
}
return this.list(queryWrapper);
}
@Override
public FaultrRule byidRuleId(Long faultRuleId) {
LambdaQueryWrapper<FaultrRule> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(faultRuleId, "规则ID不可为空");
queryWrapper.eq(FaultrRule::getFaultRuleId, faultRuleId);
return this.getOne(queryWrapper);
}
}

View File

@ -2,6 +2,7 @@
server: server:
port: 10066 port: 10066
# nacos线上地址
nacos: nacos:
addr: 106.15.136.7:8848 addr: 106.15.136.7:8848
user-name: nacos user-name: nacos

View File

@ -4,75 +4,5 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.enterprise.mapper.CarManageMapper"> <mapper namespace="com.muyu.enterprise.mapper.CarManageMapper">
<!-- 车辆列表 -->
<select id="carList" resultType="com.muyu.enterprise.domain.vo.CarVO">
SELECT
cman.*,
cc.config_name,
cc.energy_type,
cc.gear_type
FROM
`car_manage` cman
LEFT JOIN `car_config` cc ON cman.config_id = cc.config_id
<where>
<if test="carVin != null and carVin != ''">
and cman.car_vin = #{carVin}
</if>
<if test="typeName != null and typeName != ''">
and cc.config_name like concat('%',#{typeName},'%')
</if>
<if test="energyType != null and energyType > 0 ">
and cc.energy_type = #{energyType}
</if>
<if test="gearType != null and gearType > 0 ">
and cc.gear_type = #{gearType}
</if>
</where>
</select>
<select id="CarListShow" resultType="com.muyu.enterprise.domain.vo.CarVO">
SELECT
tc.*,
tt.energy_type,
tt.gear_type,
tt.type_name
FROM
`t_car` tc
LEFT JOIN `t_type` tt ON tc.type_id = tt.type_id
<where>
<if test="carVin != null and carVin != ''">
and tc.car_vin = #{carVin}
</if>
<if test="carLastJoinTime != null and carLastJoinTime != ''">
and tc.car_last_join_time = #{carLastJoinTime}
</if>
<if test="carLastOfflineTime != null and carLastOfflineTime != ''">
and tc.car_last_offline_time = #{carVin}
</if>
<if test="typeName != null and typeName != ''">
and tt.type_name like concat('%',#{typeName},'%')
</if>
<if test="energyType != null and energyType > 0 ">
and tt.energy_type = #{energyType}
</if>
<if test="gearType != null and gearType > 0 ">
and tt.gear_type = #{gearType}
</if>
</where>
</select>
<!-- 通过id查询 -->
<select id="CarListShowByCarId" resultType="com.muyu.enterprise.domain.vo.CarVO">
SELECT
tc.*,
tt.energy_type,
tt.gear_type,
tt.type_name
FROM
`t_car` tc
LEFT JOIN `t_type` tt ON tc.type_id = tt.type_id
where tc.car_id = #{carId}
</select>
</mapper> </mapper>

View File

@ -4,17 +4,4 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.enterprise.mapper.CarMessageMapper"> <mapper namespace="com.muyu.enterprise.mapper.CarMessageMapper">
<!-- 查询所有报文信息 -->
<!-- 查询所有报文信息 -->
<select id="selectMessageShow" resultType="com.muyu.enterprise.domain.CarMessage">
SELECT
tcm.*
FROM
`t_car_message` tcm
WHERE
tcm.template_id = #{templateId}
</select>
</mapper> </mapper>

View File

@ -4,10 +4,4 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.enterprise.mapper.CarTemplateMapper"> <mapper namespace="com.muyu.enterprise.mapper.CarTemplateMapper">
<!-- 查询所有报文信息 -->
<select id="selectTemplateShow" resultType="com.muyu.enterprise.domain.CarTemplate">
select * from `t_template`
</select>
</mapper> </mapper>

View File

@ -15,6 +15,8 @@
<modules> <modules>
<module>cloud-modules-enterprise-server</module> <module>cloud-modules-enterprise-server</module>
<module>cloud-modules-enterprise-common</module> <module>cloud-modules-enterprise-common</module>
<module>cloud-modules-enterprise-cache</module>
<module>cloud-modules-enterprise-remote</module>
</modules> </modules>
<description> <description>

View File

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-modules</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>cloud-modules-event-process</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<description>
cloud-modules-event-process 事件处理
</description>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- IotDB会话 -->
<dependency>
<groupId>org.apache.iotdb</groupId>
<artifactId>iotdb-session</artifactId>
</dependency>
<!-- Caffeine本地缓存 -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<!-- MuYu Common DataScope -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-datascope</artifactId>
</dependency>
<!-- MuYu Common Log -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-log</artifactId>
</dependency>
<!-- 接口模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-api-doc</artifactId>
</dependency>
<!-- 公共核心模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-core</artifactId>
</dependency>
<!-- kafka模块-->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-kafka</artifactId>
</dependency>
<!-- rabbit模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-rabbit</artifactId>
</dependency>
<!-- 企业缓存模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-modules-enterprise-cache</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,21 @@
package com.muyu.event.process;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* @Author: zi run
* @Date 2024/9/28 22:31
* @Description
*/
@EnableCustomConfig
@EnableMyFeignClients
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class CloudEventProcessApplication {
public static void main(String[] args) {
SpringApplication.run(CloudEventProcessApplication.class, args);
}
}

View File

@ -0,0 +1,37 @@
package com.muyu.event.process.basic;
import org.springframework.context.ApplicationEvent;
/**
* @Author: zi run
* @Date 2024/9/30 15:11
* @Description
*/
public class BasicEvent<T> extends ApplicationEvent {
/**
*
*/
private final T data;
/**
*
*
* @param source
* @param data
*/
public BasicEvent(Object source, T data) {
super(source);
this.data = data;
}
/**
*
*
* @return
*/
public T getData() {
return data;
}
}

View File

@ -0,0 +1,47 @@
package com.muyu.event.process.basic;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Author: zi run
* @Date 2024/9/30 15:37
* @Description
*/
@Slf4j
@Component
public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>> {
/**
*
*/
private final List<BasicEventListener<T>> listeners;
/**
*
*
* @param listeners
*/
public BasicEventHandler(List<BasicEventListener<T>> listeners) {
this.listeners = listeners;
}
/**
*
*
* @param event
*/
@Override
public void onApplicationEvent(BasicEvent<T> event) {
listeners.forEach(l -> {
try {
l.onEvent(event);
} catch (Exception e) {
log.error("{}监听器处理事件时发生异常:{}", l, e.getMessage());
}
});
}
}

Some files were not shown because too many files have changed in this diff Show More