Compare commits
29 Commits
a1894bb013
...
c08a1376d6
Author | SHA1 | Date |
---|---|---|
|
c08a1376d6 | |
|
9bb39ec32a | |
|
6e0ed3b883 | |
|
94d04e3a35 | |
|
a9bfdc1670 | |
|
111129e777 | |
|
0bafed3671 | |
|
0db37dc190 | |
|
293e58809c | |
|
22e068cfc5 | |
|
9f0f373594 | |
|
a2f2d2ec52 | |
|
26c0d3d4c8 | |
|
7fa71097fd | |
|
e018d60115 | |
|
20977536e3 | |
|
222b2ad30f | |
|
c0a9b1a1dd | |
|
eef7d19aeb | |
|
19f67a389c | |
|
f7f54bf0c1 | |
|
a8222a4c88 | |
|
98fa19923d | |
|
3fb0158cfa | |
|
46689d02e1 | |
|
0c7795ea71 | |
|
517c18f215 | |
|
2d0f557398 | |
|
cd46940e70 |
|
@ -26,6 +26,7 @@ logs
|
||||||
*.iws
|
*.iws
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
*.yml
|
||||||
|
|
||||||
### JRebel ###
|
### JRebel ###
|
||||||
rebel.xml
|
rebel.xml
|
||||||
|
|
|
@ -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,"注册成功");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,48 +24,6 @@ public abstract class CacheAbsBasic<K,V> implements CacheBasic<K,V> {
|
||||||
redisService.setCacheObject(encode(key),value);
|
redisService.setCacheObject(encode(key),value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取缓存中车辆的数据
|
|
||||||
* @param key
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public V getManage(K key) {
|
|
||||||
return redisService.getCacheObject(encode(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将数据存入缓存
|
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void putManage(K key, V value) {
|
|
||||||
redisService.setCacheObject(encode(key),value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取缓存中故障的数据
|
|
||||||
* @param key
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public V getFault(K key) {
|
|
||||||
return redisService.getCacheObject(encode(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将数据存入故障缓存
|
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void putFault(K key, V value) {
|
|
||||||
redisService.setCacheObject(encode(key),value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public V get(K key) {
|
public V get(K key) {
|
||||||
return redisService.getCacheObject(encode(key));
|
return redisService.getCacheObject(encode(key));
|
||||||
|
|
|
@ -12,35 +12,6 @@ import java.awt.image.Kernel;
|
||||||
|
|
||||||
public interface CacheBasic<K,V> extends PrimaryKeyBasic<K>{
|
public interface CacheBasic<K,V> extends PrimaryKeyBasic<K>{
|
||||||
|
|
||||||
/**
|
|
||||||
* 将数据存入车辆缓存
|
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
void putManage(K key,V value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取缓存中故障的数据
|
|
||||||
* @param key
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
V getFault(K key);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将数据存入故障缓存
|
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
void putFault(K key,V value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取缓存中车辆的数据
|
|
||||||
* @param key
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
V getManage(K key);
|
|
||||||
|
|
||||||
|
|
||||||
void put(K key,V value);
|
void put(K key,V value);
|
||||||
|
|
||||||
V get(K key);
|
V get(K key);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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 数据源实体类
|
||||||
|
|
|
@ -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工厂
|
||||||
|
|
|
@ -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 数据源切换处理
|
||||||
|
|
|
@ -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>
|
|
@ -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 {
|
||||||
|
|
||||||
|
}
|
|
@ -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("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* swagger会解析的url规则
|
||||||
|
**/
|
||||||
|
private List<String> basePath = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在basePath基础上需要排除的url规则
|
||||||
|
**/
|
||||||
|
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 {
|
||||||
|
/**
|
||||||
|
* 鉴权策略ID,需要和SecurityReferences 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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/");
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,7 @@
|
||||||
<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-cache</module>
|
||||||
|
<module>cloud-common-swagger</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>cloud-common</artifactId>
|
<artifactId>cloud-common</artifactId>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- SpringCloud Gateway -->
|
<!-- SpringCloud Gateway -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.muyu.enterprise.cache;
|
package com.muyu.enterprise.cache;
|
||||||
|
|
||||||
import com.muyu.common.cache.config.CacheAbsBasic;
|
import com.muyu.common.cache.config.CacheAbsBasic;
|
||||||
import com.muyu.enterprise.domain.CarManage;
|
|
||||||
import com.muyu.enterprise.domain.CarMessage;
|
import com.muyu.enterprise.domain.CarMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +10,6 @@ import com.muyu.enterprise.domain.CarMessage;
|
||||||
* @Date 2024/9/30 11:42
|
* @Date 2024/9/30 11:42
|
||||||
* @author MingWei.Zong
|
* @author MingWei.Zong
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CarMessageCacheService extends CacheAbsBasic<String, CarMessage> {
|
public class CarMessageCacheService extends CacheAbsBasic<String, CarMessage> {
|
||||||
@Override
|
@Override
|
||||||
public String keyPre() {
|
public String keyPre() {
|
||||||
|
|
|
@ -3,7 +3,5 @@ com.muyu.enterprise.cache.CarFaultCacheService
|
||||||
com.muyu.enterprise.cache.CarManageCacheService
|
com.muyu.enterprise.cache.CarManageCacheService
|
||||||
com.muyu.enterprise.cache.CarMessageCacheService
|
com.muyu.enterprise.cache.CarMessageCacheService
|
||||||
com.muyu.enterprise.cache.CarTemplateCacheService
|
com.muyu.enterprise.cache.CarTemplateCacheService
|
||||||
com.muyu.enterprise.cache.CarWarnCacheService
|
com.muyu.enterprise.cache.CarWarnCacheServic
|
||||||
com.muyu.enterprise.cache.ElectronicFenceCacheService
|
com.muyu.enterprise.cache.ElectronicFenceCacheService
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ public class CarCompany {
|
||||||
/**
|
/**
|
||||||
* 企业表
|
* 企业表
|
||||||
*/
|
*/
|
||||||
@TableId(value = "company_id",type = IdType.AUTO)
|
@TableId(value = "enterprise_id",type = IdType.AUTO)
|
||||||
private Long companyId;
|
private Long enterpriseId;
|
||||||
/**
|
/**
|
||||||
* 企业名称
|
* 企业名称
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class CarManage {
|
||||||
/**
|
/**
|
||||||
* 汽车所属企业id
|
* 汽车所属企业id
|
||||||
*/
|
*/
|
||||||
private Long companyId;
|
private Long enterpriseId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
@ -29,18 +29,40 @@ public class FaultRule 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;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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编码
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class CarDTO {
|
||||||
/**
|
/**
|
||||||
* 车辆企业
|
* 车辆企业
|
||||||
*/
|
*/
|
||||||
private Long companyId;
|
private Long enterpriseId;
|
||||||
/**
|
/**
|
||||||
* 车辆配置
|
* 车辆配置
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -94,7 +94,7 @@ public class CarVO {
|
||||||
|
|
||||||
|
|
||||||
/** 所属企业 */
|
/** 所属企业 */
|
||||||
private Long companyId;
|
private Long enterpriseId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,12 @@
|
||||||
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 远程调用 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 企业业务平台 - 公共依赖 -->
|
<!-- 企业业务平台 - 公共依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
@ -120,4 +126,4 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
}
|
|
@ -33,15 +33,19 @@ public class CarCompanyController extends BaseController {
|
||||||
@PostMapping("selectCompany")
|
@PostMapping("selectCompany")
|
||||||
public Result<List<CarCompany>> selectCompany(){
|
public Result<List<CarCompany>> selectCompany(){
|
||||||
startPage();
|
startPage();
|
||||||
return Result.success(sysCarCompanyService.list());
|
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.selectCompanyByCompanyId(companyId));
|
return Result.success(sysCarCompanyService.selectCompanyByCompanyId(enterpriseId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class CarManageController extends BaseController {
|
||||||
@PostMapping("/carListShow2")
|
@PostMapping("/carListShow2")
|
||||||
public Result<List<CarVO>> carListShow2(@RequestBody CarDTO carDTO){
|
public Result<List<CarVO>> carListShow2(@RequestBody CarDTO carDTO){
|
||||||
startPage();
|
startPage();
|
||||||
|
// 存到缓存中去
|
||||||
return Result.success(sysCarService.carListShow2(carDTO));
|
return Result.success(sysCarService.carListShow2(carDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,10 +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("添加成功");
|
||||||
carManageCacheService.putManage(carVO.getCarVin(),new CarManage());
|
|
||||||
return Result.success("车辆添加成功");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ public class CarMessageController extends BaseController {
|
||||||
|
|
||||||
private final CarMessageCacheService carMessageCacheService;
|
private final CarMessageCacheService carMessageCacheService;
|
||||||
private final CarMessageService sysCarMessageService;
|
private final CarMessageService sysCarMessageService;
|
||||||
|
@Autowired
|
||||||
|
private CarMessageService carMessageService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有报文信息
|
* 查询所有报文信息
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.enterprise.controller;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.enterprise.domain.FaultRule;
|
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<FaultRule>> faultRuleList(FaultRule faultrRule)
|
public Result<List<FaultRule>> faultRuleList(FaultRule faultRule)
|
||||||
{
|
{
|
||||||
List<FaultRule> 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 FaultRule 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 FaultRule 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){
|
||||||
FaultRule 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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ 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<FaultRule> {
|
public interface FaultRuleMapper extends BaseMapper<FaultRule> {
|
||||||
}
|
}
|
|
@ -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> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,10 @@ import com.muyu.enterprise.domain.CarCompany;
|
||||||
*/
|
*/
|
||||||
public interface CarCompanyService extends IService<CarCompany> {
|
public interface CarCompanyService extends IService<CarCompany> {
|
||||||
/**
|
/**
|
||||||
*
|
* @param enterpriseId
|
||||||
* @param companyId
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
CarCompany selectCompanyByCompanyId(Long companyId);
|
CarCompany selectCompanyByCompanyId(Long enterpriseId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,10 @@ public interface CarManageService extends IService<CarManage> {
|
||||||
*/
|
*/
|
||||||
List<CarVO> CarListShow(CarDTO carDTO);
|
List<CarVO> CarListShow(CarDTO carDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆添加
|
||||||
|
* @param carVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void insertCar(CarManage carVO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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:站内信业务层
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,7 +10,7 @@ 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<FaultRule> {
|
public interface FaultRuleService extends IService<FaultRule> {
|
||||||
List<FaultRule> faultRuleList(FaultRule faultrRule);
|
List<FaultRule> faultRuleList(FaultRule faultrRule);
|
||||||
|
|
||||||
FaultRule byidRuleId(Long faultRuleId);
|
FaultRule byidRuleId(Long faultRuleId);
|
|
@ -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:故障类型业务层
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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:故障管理业务层
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,12 +33,12 @@ public class CarCompanyServiceImpl extends ServiceImpl<CarCompanyMapper, CarComp
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param companyId
|
* @param enterpriseId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CarCompany selectCompanyByCompanyId(Long companyId) {
|
public CarCompany selectCompanyByCompanyId(Long enterpriseId) {
|
||||||
return carCompanyMapper.selectById(companyId);
|
return carCompanyMapper.selectById(enterpriseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
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.CarConfig;
|
||||||
|
@ -39,6 +40,8 @@ public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage
|
||||||
@Autowired
|
@Autowired
|
||||||
private CarConfigService carConfigService;
|
private CarConfigService carConfigService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private CarManageCacheService carManageCacheService;
|
||||||
|
@Autowired
|
||||||
private CarManageMapper carManageMapper;
|
private CarManageMapper carManageMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +58,7 @@ public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage
|
||||||
.eq(carManage.getCarModel() != null && carManage.getCarModel() != "", CarManage::getCarModel, carManage.getCarModel())
|
.eq(carManage.getCarModel() != null && carManage.getCarModel() != "", CarManage::getCarModel, carManage.getCarModel())
|
||||||
.eq(carManage.getCarBrand() != null && carManage.getCarBrand() != "", CarManage::getCarBrand, carManage.getCarBrand())
|
.eq(carManage.getCarBrand() != null && carManage.getCarBrand() != "", CarManage::getCarBrand, carManage.getCarBrand())
|
||||||
.eq(carManage.getCarStatus() != null && carManage.getCarStatus() > 0, CarManage::getCarStatus, carManage.getCarStatus())
|
.eq(carManage.getCarStatus() != null && carManage.getCarStatus() > 0, CarManage::getCarStatus, carManage.getCarStatus())
|
||||||
.eq(carManage.getCompanyId() != null && carManage.getCompanyId() > 0, CarManage::getCompanyId, carManage.getCompanyId())
|
.eq(carManage.getEnterpriseId() != null && carManage.getEnterpriseId() > 0, CarManage::getEnterpriseId, carManage.getEnterpriseId())
|
||||||
.list();
|
.list();
|
||||||
// List<CarManage> list = list();
|
// List<CarManage> list = list();
|
||||||
|
|
||||||
|
@ -69,9 +72,13 @@ public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage
|
||||||
carVO.setEnergyType(carConfig.getEnergyType());
|
carVO.setEnergyType(carConfig.getEnergyType());
|
||||||
carVO.setGearType(carConfig.getGearType());
|
carVO.setGearType(carConfig.getGearType());
|
||||||
// 查询出对象,用于赋值
|
// 查询出对象,用于赋值
|
||||||
CarCompany carCompany = carCompanyService.selectCompanyByCompanyId(carVO.getCompanyId());
|
CarCompany carCompany = carCompanyService.selectCompanyByCompanyId(carVO.getEnterpriseId());
|
||||||
carVO.setCompanyName(carCompany.getCompanyName());
|
carVO.setCompanyName(carCompany.getCompanyName());
|
||||||
|
// 存到 redis
|
||||||
|
carManageCacheService.put(carVO.getCarVin(),new CarManage());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return carVOS;
|
return carVOS;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,16 +92,23 @@ public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage
|
||||||
.select(CarConfig::getGearType)
|
.select(CarConfig::getGearType)
|
||||||
.select(CarConfig::getEnergyType)
|
.select(CarConfig::getEnergyType)
|
||||||
.leftJoin(CarConfig.class, CarConfig::getConfigId, CarManage::getConfigId)
|
.leftJoin(CarConfig.class, CarConfig::getConfigId, CarManage::getConfigId)
|
||||||
.leftJoin(CarCompany.class, CarCompany::getCompanyId, CarManage::getCompanyId)
|
.leftJoin(CarCompany.class, CarCompany::getEnterpriseId, CarManage::getEnterpriseId)
|
||||||
.eq(carManage.getCarVin() != null && carManage.getCarVin() != "", CarManage::getCarVin, carManage.getCarVin())
|
.eq(carManage.getCarVin() != null && carManage.getCarVin() != "", CarManage::getCarVin, carManage.getCarVin())
|
||||||
.eq(carManage.getCarModel() != null && carManage.getCarModel() != "", CarManage::getCarModel, carManage.getCarModel())
|
.eq(carManage.getCarModel() != null && carManage.getCarModel() != "", CarManage::getCarModel, carManage.getCarModel())
|
||||||
.eq(carManage.getCarBrand() != null && carManage.getCarBrand() != "", CarManage::getCarBrand, carManage.getCarBrand())
|
.eq(carManage.getCarBrand() != null && carManage.getCarBrand() != "", CarManage::getCarBrand, carManage.getCarBrand())
|
||||||
.eq(carManage.getCarStatus() != null && carManage.getCarStatus() > 0, CarManage::getCarStatus, carManage.getCarStatus())
|
.eq(carManage.getCarStatus() != null && carManage.getCarStatus() > 0, CarManage::getCarStatus, carManage.getCarStatus())
|
||||||
.eq(carManage.getCompanyId() != null && carManage.getCompanyId() > 0, CarManage::getCompanyId, carManage.getCompanyId())
|
.eq(carManage.getEnterpriseId() != null && carManage.getEnterpriseId() > 0, CarManage::getEnterpriseId, carManage.getEnterpriseId())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertCar(CarManage carVO) {
|
||||||
|
save(carVO);
|
||||||
|
// 存到缓存中去
|
||||||
|
carManageCacheService.put(carVO.getCarVin(),new CarManage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ 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.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.enterprise.domain.FaultRule;
|
import com.muyu.enterprise.domain.FaultRule;
|
||||||
import com.muyu.enterprise.mapper.FaultrRuleMapper;
|
import com.muyu.enterprise.mapper.FaultRuleMapper;
|
||||||
import com.muyu.enterprise.service.FaultrRuleService;
|
import com.muyu.enterprise.service.FaultRuleService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
@ -17,16 +17,16 @@ import java.util.List;
|
||||||
* @Description FaultrRuleServiceImpl:故障规则业务实现层
|
* @Description FaultrRuleServiceImpl:故障规则业务实现层
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class FaultrRuleServiceImpl extends ServiceImpl<FaultrRuleMapper, FaultRule> implements FaultrRuleService {
|
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, FaultRule> implements FaultRuleService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FaultRule> faultRuleList(FaultRule faultrRule) {
|
public List<FaultRule> faultRuleList(FaultRule faultRule) {
|
||||||
LambdaQueryWrapper<FaultRule> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<FaultRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleName())) {
|
if (StringUtils.isNotEmpty(faultRule.getFaultName())) {
|
||||||
queryWrapper.eq(FaultRule::getFaultRuleName,faultrRule.getFaultRuleName());
|
queryWrapper.eq(FaultRule::getFaultName,faultRule.getFaultName());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleParameter())) {
|
if (StringUtils.isNotEmpty(faultRule.getRuleParameters())) {
|
||||||
queryWrapper.eq(FaultRule::getFaultRuleParameter,faultrRule.getFaultRuleParameter());
|
queryWrapper.eq(FaultRule::getRuleParameters,faultRule.getRuleParameters());
|
||||||
}
|
}
|
||||||
return this.list(queryWrapper);
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.event.process.basic;
|
package com.muyu.event.process.basic;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
||||||
* @Date 2024/9/30 15:37
|
* @Date 2024/9/30 15:37
|
||||||
* @Description 基础事件处理器
|
* @Description 基础事件处理器
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>> {
|
public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>> {
|
||||||
|
|
||||||
|
@ -34,6 +36,12 @@ public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(BasicEvent<T> event) {
|
public void onApplicationEvent(BasicEvent<T> event) {
|
||||||
listeners.forEach(l -> l.onEvent(event));
|
listeners.forEach(l -> {
|
||||||
|
try {
|
||||||
|
l.onEvent(event);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("{}监听器处理事件时发生异常:{}", l, e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@ package com.muyu.event.process.consumer;
|
||||||
import com.muyu.event.process.util.CacheUtil;
|
import com.muyu.event.process.util.CacheUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.core.ExchangeTypes;
|
||||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||||
|
@ -32,7 +33,7 @@ public class GoOfflineConsumer {
|
||||||
@RabbitListener(
|
@RabbitListener(
|
||||||
bindings = @QueueBinding(
|
bindings = @QueueBinding(
|
||||||
value = @Queue(value = "GO_OFFLINE", durable = "true"),
|
value = @Queue(value = "GO_OFFLINE", durable = "true"),
|
||||||
exchange = @Exchange(value = "OFFLINE_EXCHANGE", type = "fanout")
|
exchange = @Exchange(value = "OFFLINE_EXCHANGE", type = ExchangeTypes.FANOUT)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
public void offline(String vin) {
|
public void offline(String vin) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.muyu.event.process.constant.CacheHandlerConstants;
|
||||||
import com.muyu.event.process.util.CacheUtil;
|
import com.muyu.event.process.util.CacheUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.core.ExchangeTypes;
|
||||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||||
|
@ -19,7 +20,7 @@ import java.util.HashMap;
|
||||||
/**
|
/**
|
||||||
* @Author: zi run
|
* @Author: zi run
|
||||||
* @Date 2024/10/6 10:01
|
* @Date 2024/10/6 10:01
|
||||||
* @Description 商量上线消费者
|
* @Description 车辆上线消费者
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
|
@ -53,12 +54,13 @@ public class GoOnlineConsumer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理车辆上线事件
|
* 处理车辆上线事件
|
||||||
|
*
|
||||||
* @param vin 车辆的识别码,根据识别码从缓存中存入对应的数据
|
* @param vin 车辆的识别码,根据识别码从缓存中存入对应的数据
|
||||||
*/
|
*/
|
||||||
@RabbitListener(
|
@RabbitListener(
|
||||||
bindings = @QueueBinding(
|
bindings = @QueueBinding(
|
||||||
value = @Queue(value = "GO_ONLINE", durable = "true"),
|
value = @Queue(value = "GO_ONLINE", durable = "true"),
|
||||||
exchange = @Exchange(value = "ONLINE_EXCHANGE", type = "fanout")
|
exchange = @Exchange(value = "ONLINE_EXCHANGE", type = ExchangeTypes.FANOUT)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
public void online(String vin) {
|
public void online(String vin) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.event.process.listener;
|
package com.muyu.event.process.listener;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
import com.muyu.enterprise.domain.FaultRule;
|
import com.muyu.enterprise.domain.FaultRule;
|
||||||
import com.muyu.event.process.basic.BasicEvent;
|
import com.muyu.event.process.basic.BasicEvent;
|
||||||
import com.muyu.event.process.basic.BasicEventListener;
|
import com.muyu.event.process.basic.BasicEventListener;
|
||||||
|
@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: zi run
|
* @Author: zi run
|
||||||
|
@ -31,8 +33,10 @@ public class IdentifyingFailuresEventListener implements BasicEventListener<Stri
|
||||||
public void onEvent(BasicEvent<String> event) {
|
public void onEvent(BasicEvent<String> event) {
|
||||||
log.info("触发识别故障时间监听器……");
|
log.info("触发识别故障时间监听器……");
|
||||||
JSONObject data = JSONObject.parseObject(event.getData());
|
JSONObject data = JSONObject.parseObject(event.getData());
|
||||||
Map<String, Object> dataMap = (Map<String, Object>) cacheUtil.get((String) data.get("vin"));
|
Optional<Map<String, Object>> optionalDataMap =
|
||||||
FaultRule faultRule = (FaultRule) dataMap.get(CacheHandlerConstants.FAULT_RULE_KEY);
|
Optional.ofNullable((Map<String, Object>) cacheUtil.get((String) data.get("vin")));
|
||||||
|
optionalDataMap
|
||||||
|
.map(dataMap -> (FaultRule) dataMap.get(CacheHandlerConstants.FAULT_RULE_KEY))
|
||||||
|
.orElseThrow(() -> new ServiceException("故障规则未找到"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,22 @@
|
||||||
Spring Boot Version: ${spring-boot.version}
|
Spring Boot Version: ${spring-boot.version}
|
||||||
Spring Application Name: ${spring.application.name}
|
Spring Application Name: ${spring.application.name}
|
||||||
|
_ooOoo_
|
||||||
|
o8888888o
|
||||||
|
88" . "88
|
||||||
|
(| -_- |)
|
||||||
|
O\ = /O
|
||||||
|
____/`---'\____
|
||||||
|
.' \\| |// `.
|
||||||
|
/ \\||| : |||// \
|
||||||
|
/ _||||| -:- |||||- \
|
||||||
|
| | \\\ - /// | |
|
||||||
|
| \_| ''\---/'' | |
|
||||||
|
\ .-\__ `-` ___/-. /
|
||||||
|
___`. .' /--.--\ `. . __
|
||||||
|
."" '< `.___\_<|>_/___.' >'"".
|
||||||
|
| | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||||
|
\ \ `-. \_ __\ /__ _/ .-` / /
|
||||||
|
======`-.____`-.___\_____/___.-`____.-'======
|
||||||
|
`=---='
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
// 佛祖保佑 永不宕机 永无BUG //
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
server:
|
server:
|
||||||
port: 11000
|
port: 11000
|
||||||
|
|
||||||
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 106.15.136.7:8848
|
addr: 106.15.136.7:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
|
|
|
@ -21,14 +21,14 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业管理控制层
|
* 企业管理控制层
|
||||||
* @Author: chenruijia
|
* @author chenruijia
|
||||||
* @Date 2024/9/26 0:21
|
* @Date 2024/9/26 0:21
|
||||||
* @Description 企业管理控制层
|
* @Description 企业管理控制层
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping(value = "/ent")
|
@RequestMapping(value = "/ent")
|
||||||
@Tag(name = "SysEntController",description = "企业管理")
|
@Tag(name = "企业信息",description = "企业管理")
|
||||||
public class SysEntController extends BaseController {
|
public class SysEntController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +40,7 @@ public class SysEntController extends BaseController {
|
||||||
* 获取企业信息
|
* 获取企业信息
|
||||||
* @return 响应结果
|
* @return 响应结果
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/getInfo")
|
@RequestMapping(value = "/selectList",method = RequestMethod.GET)
|
||||||
@Operation(summary = "获取企业信息", description = "现有的基础企业信息")
|
@Operation(summary = "获取企业信息", description = "现有的基础企业信息")
|
||||||
public Result<List<EntResp>> getInfo() {
|
public Result<List<EntResp>> getInfo() {
|
||||||
return Result.success(
|
return Result.success(
|
||||||
|
@ -48,25 +48,25 @@ public class SysEntController extends BaseController {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 查询企业信息列表
|
// * 查询企业信息列表
|
||||||
* @param entListReq 企业列表请求对象
|
// * @param entListReq 企业列表请求对象
|
||||||
* @return 响应结果
|
// * @return 响应结果
|
||||||
*/
|
// */
|
||||||
@PostMapping(value = "/selectList")
|
// @PostMapping(value = "/selectList")
|
||||||
@Operation(summary = "查询企业信息列表", description = "分页展示企业信息")
|
// @Operation(summary = "查询企业信息列表", description = "分页展示企业信息")
|
||||||
public Result<TableDataInfo<EntResp>> selectList(@RequestBody EntListReq entListReq) {
|
// public Result<TableDataInfo<EntResp>> selectList(@RequestBody EntListReq entListReq) {
|
||||||
startPage();
|
// startPage();
|
||||||
List<EntResp> entRespList = sysEntService.selectList(entListReq);
|
// List<EntResp> entRespList = sysEntService.selectList(entListReq);
|
||||||
return getDataTable(entRespList);
|
// return getDataTable(entRespList);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID获取企业信息
|
* 根据ID获取企业信息
|
||||||
* @param entId 企业ID
|
* @param entId 企业ID
|
||||||
* @return 响应结果
|
* @return 响应结果
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/{entId}")
|
@GetMapping(value = "/getById/{entId}")
|
||||||
@Operation(summary = "根据ID获取企业信息", description = "根据企业唯一标识获取单体企业信息")
|
@Operation(summary = "根据ID获取企业信息", description = "根据企业唯一标识获取单体企业信息")
|
||||||
public Result<EntResp> getById(
|
public Result<EntResp> getById(
|
||||||
@Schema(title = "企业ID", type = "Long", defaultValue = "1", description = "企业唯一标识")
|
@Schema(title = "企业ID", type = "Long", defaultValue = "1", description = "企业唯一标识")
|
||||||
|
@ -79,7 +79,7 @@ public class SysEntController extends BaseController {
|
||||||
* @param entAddReq 企业添加请求对象
|
* @param entAddReq 企业添加请求对象
|
||||||
* @return 响应结果
|
* @return 响应结果
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping(value = "/save")
|
||||||
@Operation(summary = "添加企业信息", description = "将企业信息添加到系统中")
|
@Operation(summary = "添加企业信息", description = "将企业信息添加到系统中")
|
||||||
public Result<String> save(@Validated @RequestBody EntAddReq entAddReq) {
|
public Result<String> save(@Validated @RequestBody EntAddReq entAddReq) {
|
||||||
sysEntService.save(EntAddReq.addBuild(entAddReq));
|
sysEntService.save(EntAddReq.addBuild(entAddReq));
|
||||||
|
@ -92,7 +92,7 @@ public class SysEntController extends BaseController {
|
||||||
* @param entUpdateReq 企业修改请求对象
|
* @param entUpdateReq 企业修改请求对象
|
||||||
* @return 响应结果
|
* @return 响应结果
|
||||||
*/
|
*/
|
||||||
@PutMapping(value = "/{entId}")
|
@PutMapping(value = "/update/{entId}")
|
||||||
@Operation(summary = "修改企业信息",description = "根据企业唯一标识修改企业信息")
|
@Operation(summary = "修改企业信息",description = "根据企业唯一标识修改企业信息")
|
||||||
public Result<String> update(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识")
|
public Result<String> update(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识")
|
||||||
@NotNull(message = "企业ID不能为空") @PathVariable(value = "entId") Long entId,
|
@NotNull(message = "企业ID不能为空") @PathVariable(value = "entId") Long entId,
|
||||||
|
@ -106,7 +106,7 @@ public class SysEntController extends BaseController {
|
||||||
* @param entId 企业ID
|
* @param entId 企业ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/entId",method = RequestMethod.DELETE)
|
@RequestMapping(value = "/remove/{entId}",method = RequestMethod.DELETE)
|
||||||
@Operation(summary = "删除企业信息",description = "根据企业唯一标识删除企业记录")
|
@Operation(summary = "删除企业信息",description = "根据企业唯一标识删除企业记录")
|
||||||
public Result<String> remove(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识")
|
public Result<String> remove(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识")
|
||||||
@NotNull(message = "企业ID不能为空") @PathVariable(value = "entId")Long entId){
|
@NotNull(message = "企业ID不能为空") @PathVariable(value = "entId")Long entId){
|
||||||
|
|
|
@ -16,6 +16,7 @@ import com.muyu.system.domain.resp.AuthRoleResp;
|
||||||
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
||||||
import com.muyu.system.domain.resp.UserInfoResp;
|
import com.muyu.system.domain.resp.UserInfoResp;
|
||||||
import com.muyu.system.service.*;
|
import com.muyu.system.service.*;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -23,6 +24,8 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -32,6 +35,7 @@ import java.util.stream.Collectors;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
public class SysUserController extends BaseController {
|
public class SysUserController extends BaseController {
|
||||||
|
@ -120,20 +124,24 @@ public class SysUserController extends BaseController {
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public Result<Boolean> register (@RequestBody RegisterBody registerBody) {
|
public Result<Boolean> register (@RequestBody RegisterBody registerBody) {
|
||||||
String username = registerBody.getUsername();
|
String username = registerBody.getUsername();
|
||||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
SysUser sysUser = new SysUser();
|
||||||
return Result.error("当前系统没有开启注册功能!");
|
sysUser.setUserName(username);
|
||||||
}
|
if (!userService.checkUserNameUnique(sysUser)) {
|
||||||
SysUser sysUser = SysUser.builder().userName(username).build();
|
return Result.error("保存用户'" + username + "'失败,注册账号已存在");
|
||||||
|
}
|
||||||
|
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||||
|
return Result.error("当前系统没有开启注册功能!");
|
||||||
|
}
|
||||||
if (!userService.checkUserNameUnique(sysUser)) {
|
if (!userService.checkUserNameUnique(sysUser)) {
|
||||||
return Result.error("保存用户'" + username + "'失败,注册账号已存在");
|
return Result.error("保存用户'" + username + "'失败,注册账号已存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加企业
|
//添加企业
|
||||||
SysEnt sysEnt = SysEnt.builder()
|
SysEnt sysEnt = SysEnt.builder()
|
||||||
.name(registerBody.getEntName())
|
.name(registerBody.getEntName())
|
||||||
.leader(registerBody.getLeader())
|
.leader(registerBody.getLeader())
|
||||||
.phone(registerBody.getPhone())
|
.phone(registerBody.getPhone())
|
||||||
.email(registerBody.getEmail())
|
.email(registerBody.getEmail())
|
||||||
|
.entCode(registerBody.getUsername())
|
||||||
.build();
|
.build();
|
||||||
entService.save(sysEnt);
|
entService.save(sysEnt);
|
||||||
|
|
||||||
|
@ -151,7 +159,78 @@ public class SysUserController extends BaseController {
|
||||||
sysUser.setDeptId(sysDept.getDeptId());
|
sysUser.setDeptId(sysDept.getDeptId());
|
||||||
sysUser.setNickName(registerBody.getUsername());
|
sysUser.setNickName(registerBody.getUsername());
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
||||||
|
sysUser.setNickName("注册");
|
||||||
|
boolean b = userService.registerUser(sysUser);
|
||||||
|
if (b == true) {
|
||||||
|
//数据库驱动
|
||||||
|
String mysqlDriver = "com.mysql.jdbc.Driver";
|
||||||
|
//数据库地址
|
||||||
|
String url = "jdbc:mysql://106.15.136.7:3306/";
|
||||||
|
//数据库用户名
|
||||||
|
String name = "root";
|
||||||
|
//数据库密码
|
||||||
|
String password = "Six@211206";
|
||||||
|
Collection collection = null;
|
||||||
|
Collection stmt = null;
|
||||||
|
//创建数据库SQL
|
||||||
|
try {
|
||||||
|
Class.forName(mysqlDriver);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
String databaseSQL = "create database "+username ;
|
||||||
|
|
||||||
|
//添加企业信息
|
||||||
|
String tableSQL = "create table sys_ent (id int auto_increment primary key comment '主键id'," +
|
||||||
|
"name varchar(16) comment '企业名称'," +
|
||||||
|
"leader varchar(16) comment '负责人'," +
|
||||||
|
"phone varchar(11) comment '联系电话'," +
|
||||||
|
"email varchar(32) comment '邮箱'," +
|
||||||
|
"ent_code varchar(64) comment '企业编码'," +
|
||||||
|
"ent_status varchar(64) comment '企业状态'," +
|
||||||
|
"create_by varchar(32) comment '创建人'," +
|
||||||
|
"update_by varchar(32) comment '创建时间'," +
|
||||||
|
"create_time datetime comment '修改人'," +
|
||||||
|
"update_time datetime comment '修改时间'," +
|
||||||
|
"remark varchar(32) comment '备注')";
|
||||||
|
//连接数据库
|
||||||
|
try {
|
||||||
|
Connection connection = DriverManager.getConnection(url, name, password);
|
||||||
|
//用于执行编译sql语句的对象
|
||||||
|
Statement connStatement = connection.createStatement();
|
||||||
|
if (connection != null) {
|
||||||
|
//执行建库语句
|
||||||
|
connStatement.executeUpdate(databaseSQL);
|
||||||
|
log.info("创建数据库成功");
|
||||||
|
//连接新建数据库
|
||||||
|
Connection connection1 = DriverManager.getConnection(url + username, name, password);
|
||||||
|
if (connection1 != null) {
|
||||||
|
log.info("连接数据库成功"+username);
|
||||||
|
Statement statement = connection1.createStatement();
|
||||||
|
//执行建表语句
|
||||||
|
statement.executeUpdate(tableSQL);
|
||||||
|
log.info("创建表成功");
|
||||||
|
String insertSQL="INSERT INTO sys_ent (name, leader, phone, email, ent_code, ent_status, create_by, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
try(PreparedStatement preparedStatement = connection1.prepareStatement(insertSQL)) {
|
||||||
|
//设置插入的值
|
||||||
|
preparedStatement.setString(1,registerBody.getEntName());
|
||||||
|
preparedStatement.setString(2,registerBody.getLeader());
|
||||||
|
preparedStatement.setString(3,registerBody.getPhone());
|
||||||
|
preparedStatement.setString(4,registerBody.getEmail());
|
||||||
|
preparedStatement.setString(5,username);
|
||||||
|
preparedStatement.setInt(6,0);
|
||||||
|
preparedStatement.setString(7, sysUser.getCreateBy());
|
||||||
|
preparedStatement.setTimestamp(8, new Timestamp(System.currentTimeMillis())); // 当前时间
|
||||||
|
preparedStatement.executeUpdate();
|
||||||
|
log.info("插入企业信息成功");
|
||||||
|
}
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
return Result.success(userService.registerUser(sysUser));
|
return Result.success(userService.registerUser(sysUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,12 @@
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>cloudapi20160714</artifactId>
|
<artifactId>cloudapi20160714</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- rabbitmq模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-rabbit</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.muyu.vehiclegateway.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.vehiclegateway.domain.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.vehiclegateway.service.ConnectService;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ConnectController
|
||||||
|
* @Description 连接车辆
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/10/2 16:25
|
||||||
|
*/
|
||||||
|
@RequestMapping("/vehicleGateway")
|
||||||
|
@RestController
|
||||||
|
@Log4j2
|
||||||
|
@Tag(name = "连接车辆控制层")
|
||||||
|
public class ConnectController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConnectService connectService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆信息
|
||||||
|
* @param vehicleConnectionReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/receiveMsg/connect")
|
||||||
|
private Result receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
||||||
|
log.info("=======>" + vehicleConnectionReq);
|
||||||
|
connectService.receiveMsg(vehicleConnectionReq);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建ECS实例
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@GetMapping("/createConnect")
|
||||||
|
private void createConnect() throws Exception {
|
||||||
|
connectService.createConnect();
|
||||||
|
log.info("创建实例成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.vehiclegateway.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ConnectMemory
|
||||||
|
* @Description 内存使用情况
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/10/4 11:02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Tag(name = "服务器内存使用情况")
|
||||||
|
public class ConnectMemory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点ID
|
||||||
|
*/
|
||||||
|
private String clusterId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属IP
|
||||||
|
*/
|
||||||
|
private String ipAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 剩余连接数
|
||||||
|
*/
|
||||||
|
private String remainingNum;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.vehiclegateway.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName Instance
|
||||||
|
* @Description 服务器数据
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/30 20:42
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Tag(name = "服务器数据")
|
||||||
|
public class Instance {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器ID
|
||||||
|
*/
|
||||||
|
private String instanceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器IP
|
||||||
|
*/
|
||||||
|
private String ipAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.vehiclegateway.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName MqttServerModel
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/10/4 14:49
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Tag(name = "mqtt服务器模型")
|
||||||
|
public class MqttServerModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MQTT服务节点
|
||||||
|
*/
|
||||||
|
private String broker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MQTT订阅主题
|
||||||
|
*/
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.muyu.vehiclegateway.domain.req;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName VehicleConnectionReq
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/10/2 16:10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class VehicleConnectionReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆vin码
|
||||||
|
*/
|
||||||
|
@JSONField(name = "vehicleVin")
|
||||||
|
private String vehicleVin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*时间戳
|
||||||
|
*/
|
||||||
|
private String timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 随机字符串
|
||||||
|
*/
|
||||||
|
private String nonce;
|
||||||
|
|
||||||
|
}
|
|
@ -9,13 +9,12 @@ import com.aliyun.tea.TeaException;
|
||||||
import com.aliyun.teautil.Common;
|
import com.aliyun.teautil.Common;
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
import com.muyu.vehiclegateway.domain.Instance;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -23,7 +22,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName GenerateInstance
|
* @ClassName GenerateInstance
|
||||||
* @Description 描述
|
* @Description 程序启动创建ECS服务器实例
|
||||||
* @Author YiBo.Liu
|
* @Author YiBo.Liu
|
||||||
* @Date 2024/9/28 19:39
|
* @Date 2024/9/28 19:39
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +39,7 @@ public class GenerateInstance implements ApplicationRunner {
|
||||||
* 启动自动创建实例
|
* 启动自动创建实例
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public List<String> generateInstance() throws Exception {
|
public List<Instance> generateInstance() throws Exception {
|
||||||
|
|
||||||
// 创建ECS客户端对象,用于后续调用ECS相关API
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
Client client = CreateClient.createClient();
|
Client client = CreateClient.createClient();
|
||||||
|
@ -52,7 +51,7 @@ public class GenerateInstance implements ApplicationRunner {
|
||||||
// 设置地域ID
|
// 设置地域ID
|
||||||
.setRegionId("cn-shanghai")
|
.setRegionId("cn-shanghai")
|
||||||
// 设置镜像ID
|
// 设置镜像ID
|
||||||
.setImageId("m-uf63thq7h50ng72jpoq2")
|
.setImageId("m-uf6f7atj16s3cjn9q5l8")
|
||||||
// 设置实例类型
|
// 设置实例类型
|
||||||
.setInstanceType("ecs.t6-c1m1.large")
|
.setInstanceType("ecs.t6-c1m1.large")
|
||||||
// 设置安全组ID
|
// 设置安全组ID
|
||||||
|
@ -105,27 +104,29 @@ public class GenerateInstance implements ApplicationRunner {
|
||||||
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions);
|
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions);
|
||||||
|
|
||||||
//提取实例ID集合
|
//提取实例ID集合
|
||||||
ArrayList<String> list = new ArrayList<>();
|
List<Instance> list = new ArrayList<>();
|
||||||
|
|
||||||
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
||||||
|
|
||||||
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()) {
|
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()) {
|
||||||
list.add(instance.getInstanceId());
|
|
||||||
list.add(instance.getPublicIpAddress().ipAddress.get(0));
|
|
||||||
list.add(instance.getStatus());
|
|
||||||
|
|
||||||
log.info("实例id为:"+instance.getInstanceId());
|
log.info("实例id为:"+instance.getInstanceId());
|
||||||
log.info("实例ip为:"+instance.getPublicIpAddress().ipAddress.get(0));
|
log.info("实例ip为:"+instance.getPublicIpAddress().ipAddress.get(0));
|
||||||
log.info("实例状态为:"+instance.getStatus());
|
log.info("实例状态为:"+instance.getStatus());
|
||||||
|
|
||||||
|
Instance instance1 = new Instance(instance.getInstanceId(), instance.getPublicIpAddress().ipAddress.get(0), instance.getStatus());
|
||||||
|
|
||||||
|
list.add(instance1);
|
||||||
}
|
}
|
||||||
|
|
||||||
redisService.setCacheList("shili",list);
|
// Thread.sleep(20000);
|
||||||
|
// redisService.setCacheList("aaa",list);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
generateInstance();
|
generateInstance();
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.vehiclegateway.mapper;
|
||||||
|
|
||||||
|
import com.muyu.vehiclegateway.domain.req.VehicleConnectionReq;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ConnectMapper {
|
||||||
|
void addVehicle(VehicleConnectionReq vehicleConnectionReq);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.muyu.vehiclegateway.service;
|
||||||
|
|
||||||
|
import com.muyu.vehiclegateway.domain.req.VehicleConnectionReq;
|
||||||
|
|
||||||
|
public interface ConnectService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建实例
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
void createConnect() throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆信息
|
||||||
|
* @param vehicleConnectionReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void receiveMsg(VehicleConnectionReq vehicleConnectionReq);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.muyu.vehiclegateway.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.muyu.common.core.constant.GenConstants;
|
||||||
|
import com.muyu.common.core.utils.uuid.UUID;
|
||||||
|
import com.muyu.vehiclegateway.domain.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.vehiclegateway.instance.GenerateInstance;
|
||||||
|
import com.muyu.vehiclegateway.mapper.ConnectMapper;
|
||||||
|
import com.muyu.vehiclegateway.service.ConnectService;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import static io.lettuce.core.pubsub.PubSubOutput.Type.message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName ConnectServiceImpl
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/10/2 16:25
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ConnectServiceImpl implements ConnectService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConnectMapper connectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建实例
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void createConnect() throws Exception {
|
||||||
|
GenerateInstance generateInstance = new GenerateInstance();
|
||||||
|
generateInstance.generateInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆信息
|
||||||
|
* @param vehicleConnectionReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void receiveMsg(VehicleConnectionReq vehicleConnectionReq) {
|
||||||
|
rabbitTemplate.convertAndSend("GO_OFFLINE", vehicleConnectionReq.getVehicleVin(),message1 -> {
|
||||||
|
message1.getMessageProperties().setMessageId(UUID.fastUUID().toString());
|
||||||
|
return message1;
|
||||||
|
});
|
||||||
|
connectMapper.addVehicle(vehicleConnectionReq);
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,6 +40,8 @@ spring:
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
|
# rabbitmq配置
|
||||||
|
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
# 系统共享配置
|
# 系统共享配置
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
# 系统环境Config共享配置
|
# 系统环境Config共享配置
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.muyu.vehiclegateway.mapper.ConnectMapper">
|
||||||
|
|
||||||
|
<insert id="addVehicle">
|
||||||
|
insert into connect(id,vehicle_vin,timestamp,nonce)
|
||||||
|
values (#{id},#{vehicleVin},#{timestamp},#{nonce})
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
7
pom.xml
7
pom.xml
|
@ -298,6 +298,13 @@
|
||||||
<version>${muyu.version}</version>
|
<version>${muyu.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 多数据源 -->
|
<!-- 多数据源 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
|
Loading…
Reference in New Issue