Compare commits

...

29 Commits

Author SHA1 Message Date
crj c08a1376d6 fix():整理代码格式 2024-10-07 20:14:44 +08:00
crj 9bb39ec32a fix():解决故障规则报错 2024-10-07 20:12:05 +08:00
crj 6e0ed3b883 Merge remote-tracking branch 'origin/dev.entOperation' into dev
# Conflicts:
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/pom.xml
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/CarMessageController.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/FaultRuleController.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/FaultRuleService.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/FaultRuleServiceImpl.java
#	cloud-modules/cloud-modules-vehicle-gateway/src/main/resources/banner.txt
2024-10-07 20:09:21 +08:00
crj 94d04e3a35 feat():解决冲突 2024-10-07 20:00:27 +08:00
xinzirun a9bfdc1670 Merge remote-tracking branch 'origin/dev' into dev 2024-10-07 19:48:57 +08:00
xinzirun 111129e777 fix(): 修复故障规则 2024-10-07 19:48:11 +08:00
微醺 0bafed3671 1.feat(): 添加:
2.fix(): 修复了: 之前添加的封装的缓存

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

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

更新时间09301928
2024-10-07 14:25:10 +08:00
xinzirun eef7d19aeb fix(): 优化上下线监听 2024-10-07 13:55:46 +08:00
xinzirun 19f67a389c fix(): 解决配置冲突问题 2024-10-07 09:45:59 +08:00
xinzirun f7f54bf0c1 Merge remote-tracking branch 'origin/dev.eventProcess' into dev 2024-10-07 09:16:12 +08:00
liuyibo a8222a4c88 build():添加车辆连接获取车辆信息存入数据库中,发送rabbitmq消息队列 2024-10-06 11:08:48 +08:00
liuyibo 98fa19923d build():添加车辆连接获取车辆信息存入数据库中,发送rabbitmq消息队列 2024-10-06 10:57:27 +08:00
crj 3fb0158cfa feax:()添加企业表的同时将数据同步进去 企业列表展示 2024-10-05 20:41:45 +08:00
crj 46689d02e1 feax:()添加企业表的同时将数据同步进去 企业列表展示 2024-10-04 11:09:33 +08:00
crj 0c7795ea71 feax:()添加企业的时候添加一个单独的库和表 2024-09-30 16:41:06 +08:00
crj 517c18f215 feax:()删除fault模块 2024-09-29 15:07:11 +08:00
crj 2d0f557398 feax:()修改代码规范 2024-09-28 22:14:45 +08:00
crj cd46940e70 feax:()修改代码规范(注释) 2024-09-28 20:12:04 +08:00
66 changed files with 1281 additions and 213 deletions

1
.gitignore vendored
View File

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

View File

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

View File

@ -24,48 +24,6 @@ public abstract class CacheAbsBasic<K,V> implements CacheBasic<K,V> {
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
public V get(K key) {
return redisService.getCacheObject(encode(key));

View File

@ -12,35 +12,6 @@ import java.awt.image.Kernel;
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);
V get(K key);

View File

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

View File

@ -1,8 +1,9 @@
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
*/
public class DatasourceContent {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,6 +23,7 @@
<module>cloud-common-rabbit</module>
<module>cloud-common-kafka</module>
<module>cloud-common-cache</module>
<module>cloud-common-swagger</module>
</modules>
<artifactId>cloud-common</artifactId>

View File

@ -1,7 +1,6 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.config.CacheAbsBasic;
import com.muyu.enterprise.domain.CarManage;
import com.muyu.enterprise.domain.CarMessage;
/**
@ -11,7 +10,6 @@ import com.muyu.enterprise.domain.CarMessage;
* @Date 2024/9/30 11:42
* @author MingWei.Zong
*/
public class CarMessageCacheService extends CacheAbsBasic<String, CarMessage> {
@Override
public String keyPre() {

View File

@ -3,7 +3,5 @@ com.muyu.enterprise.cache.CarFaultCacheService
com.muyu.enterprise.cache.CarManageCacheService
com.muyu.enterprise.cache.CarMessageCacheService
com.muyu.enterprise.cache.CarTemplateCacheService
com.muyu.enterprise.cache.CarWarnCacheService
com.muyu.enterprise.cache.CarWarnCacheServic
com.muyu.enterprise.cache.ElectronicFenceCacheService

View File

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

View File

@ -105,7 +105,7 @@ public class CarManage {
/**
* id
*/
private Long companyId;
private Long enterpriseId;
}

View File

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

View File

@ -12,7 +12,7 @@ import lombok.experimental.SuperBuilder;
*
* @Author: chenruijia
* @Date 2024/9/28 12.23
* @Description FaultrRule:
* @Description FaultRule:
*/
@Data
@SuperBuilder
@ -29,18 +29,40 @@ public class FaultRule extends BaseEntity {
@Schema(defaultValue = "故障规则ID",type = "Long",description = "故障规则ID")
private Long faultRuleId;
/**
*
* ID
*/
@Schema(defaultValue = "故障规则名称",type = "String",description = "故障规则名称")
private String faultRuleName;
@Schema(defaultValue = "车辆类型ID",type = "Integer",description = "车辆类型ID")
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 = "故障规则参数")
private String faultRuleParameter;
private String ruleParameters;
/**
*
*
*/
@Schema(defaultValue = "故障规则描述",type = "String",description = "故障规则描述")
private String faultRuleDescription;
@Schema(defaultValue = "车辆类型名称",type = "String",description = "车辆类型名称")
private String carTypeName;
/**
*
*/
@Schema(defaultValue = "故障名称",type = "String",description = "故障名称")
private String faultName;
/**
* VIN
*/
@Schema(defaultValue = "车辆VIN",type = "String",description = "车辆VIN")
private String carVin;
}

View File

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

View File

@ -22,7 +22,7 @@ public class CarDTO {
/**
*
*/
private Long companyId;
private Long enterpriseId;
/**
*
*/

View File

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

View File

@ -94,7 +94,7 @@ public class CarVO {
/** 所属企业 */
private Long companyId;
private Long enterpriseId;

View File

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

View File

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

View File

@ -33,15 +33,19 @@ public class CarCompanyController extends BaseController {
@PostMapping("selectCompany")
public Result<List<CarCompany>> selectCompany(){
startPage();
return Result.success(sysCarCompanyService.list());
List<CarCompany> list = sysCarCompanyService.list();
list.forEach(carCompany -> {
});
return Result.success(list);
}
/**
* ID
*/
@PostMapping("selectCompanyByCompanyId")
public Result<CarCompany> selectCompanyByCompanyId(@RequestParam("companyId") Long companyId){
return Result.success(sysCarCompanyService.selectCompanyByCompanyId(companyId));
public Result<CarCompany> selectCompanyByCompanyId(@RequestParam("enterpriseId") Long enterpriseId){
return Result.success(sysCarCompanyService.selectCompanyByCompanyId(enterpriseId));
}
}

View File

@ -50,6 +50,7 @@ public class CarManageController extends BaseController {
@PostMapping("/carListShow2")
public Result<List<CarVO>> carListShow2(@RequestBody CarDTO carDTO){
startPage();
// 存到缓存中去
return Result.success(sysCarService.carListShow2(carDTO));
}
@ -87,10 +88,8 @@ public class CarManageController extends BaseController {
// 随机生成VIN码
String key2 = RandomUtil.randomNumbers(17);
carVO.setCarVin(key2);
sysCarService.save(carVO);
// 存到缓存中去
carManageCacheService.putManage(carVO.getCarVin(),new CarManage());
return Result.success("车辆添加成功");
sysCarService.insertCar(carVO);
return Result.success("添加成功");
}

View File

@ -30,6 +30,8 @@ public class CarMessageController extends BaseController {
private final CarMessageCacheService carMessageCacheService;
private final CarMessageService sysCarMessageService;
@Autowired
private CarMessageService carMessageService;
/**
*

View File

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

View File

@ -8,8 +8,8 @@ import org.apache.ibatis.annotations.Mapper;
*
* @Author: chenruijia
* @Date 2024/9/28 12.17
* @Description FaultrRuleMapper:
* @Description FaultRuleMapper:
*/
@Mapper
public interface FaultrRuleMapper extends BaseMapper<FaultRule> {
public interface FaultRuleMapper extends BaseMapper<FaultRule> {
}

View File

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

View File

@ -11,11 +11,10 @@ import com.muyu.enterprise.domain.CarCompany;
*/
public interface CarCompanyService extends IService<CarCompany> {
/**
*
* @param companyId
* @param enterpriseId
* @return
*/
CarCompany selectCompanyByCompanyId(Long companyId);
CarCompany selectCompanyByCompanyId(Long enterpriseId);

View File

@ -28,8 +28,10 @@ public interface CarManageService extends IService<CarManage> {
*/
List<CarVO> CarListShow(CarDTO carDTO);
/**
*
* @param carVO
* @return
*/
void insertCar(CarManage carVO);
}

View File

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

View File

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

View File

@ -10,7 +10,7 @@ import java.util.List;
* @Date 2024/9/28 12.19
* @Description FaultrRuleService:
*/
public interface FaultrRuleService extends IService<FaultRule> {
public interface FaultRuleService extends IService<FaultRule> {
List<FaultRule> faultRuleList(FaultRule faultrRule);
FaultRule byidRuleId(Long faultRuleId);

View File

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

View File

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

View File

@ -33,12 +33,12 @@ public class CarCompanyServiceImpl extends ServiceImpl<CarCompanyMapper, CarComp
/**
*
* @param companyId
* @param enterpriseId
* @return
*/
@Override
public CarCompany selectCompanyByCompanyId(Long companyId) {
return carCompanyMapper.selectById(companyId);
public CarCompany selectCompanyByCompanyId(Long enterpriseId) {
return carCompanyMapper.selectById(enterpriseId);
}

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.enterprise.cache.CarManageCacheService;
import com.muyu.enterprise.controller.CarCompanyController;
import com.muyu.enterprise.domain.CarCompany;
import com.muyu.enterprise.domain.CarConfig;
@ -39,6 +40,8 @@ public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage
@Autowired
private CarConfigService carConfigService;
@Autowired
private CarManageCacheService carManageCacheService;
@Autowired
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.getCarBrand() != null && carManage.getCarBrand() != "", CarManage::getCarBrand, carManage.getCarBrand())
.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<CarManage> list = list();
@ -69,9 +72,13 @@ public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage
carVO.setEnergyType(carConfig.getEnergyType());
carVO.setGearType(carConfig.getGearType());
// 查询出对象,用于赋值
CarCompany carCompany = carCompanyService.selectCompanyByCompanyId(carVO.getCompanyId());
CarCompany carCompany = carCompanyService.selectCompanyByCompanyId(carVO.getEnterpriseId());
carVO.setCompanyName(carCompany.getCompanyName());
// 存到 redis
carManageCacheService.put(carVO.getCarVin(),new CarManage());
});
return carVOS;
}
@Override
@ -85,16 +92,23 @@ public class CarManageServiceImpl extends ServiceImpl<CarManageMapper, CarManage
.select(CarConfig::getGearType)
.select(CarConfig::getEnergyType)
.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.getCarModel() != null && carManage.getCarModel() != "", CarManage::getCarModel, carManage.getCarModel())
.eq(carManage.getCarBrand() != null && carManage.getCarBrand() != "", CarManage::getCarBrand, carManage.getCarBrand())
.eq(carManage.getCarStatus() != null && carManage.getCarStatus() > 0, CarManage::getCarStatus, carManage.getCarStatus())
.eq(carManage.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());
}
}

View File

@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.enterprise.domain.FaultRule;
import com.muyu.enterprise.mapper.FaultrRuleMapper;
import com.muyu.enterprise.service.FaultrRuleService;
import com.muyu.enterprise.mapper.FaultRuleMapper;
import com.muyu.enterprise.service.FaultRuleService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@ -17,16 +17,16 @@ import java.util.List;
* @Description FaultrRuleServiceImpl:
*/
@Service
public class FaultrRuleServiceImpl extends ServiceImpl<FaultrRuleMapper, FaultRule> implements FaultrRuleService {
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, FaultRule> implements FaultRuleService {
@Override
public List<FaultRule> faultRuleList(FaultRule faultrRule) {
public List<FaultRule> faultRuleList(FaultRule faultRule) {
LambdaQueryWrapper<FaultRule> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleName())) {
queryWrapper.eq(FaultRule::getFaultRuleName,faultrRule.getFaultRuleName());
if (StringUtils.isNotEmpty(faultRule.getFaultName())) {
queryWrapper.eq(FaultRule::getFaultName,faultRule.getFaultName());
}
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleParameter())) {
queryWrapper.eq(FaultRule::getFaultRuleParameter,faultrRule.getFaultRuleParameter());
if (StringUtils.isNotEmpty(faultRule.getRuleParameters())) {
queryWrapper.eq(FaultRule::getRuleParameters,faultRule.getRuleParameters());
}
return this.list(queryWrapper);
}

View File

@ -1,5 +1,6 @@
package com.muyu.event.process.basic;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
@ -10,6 +11,7 @@ import java.util.List;
* @Date 2024/9/30 15:37
* @Description
*/
@Slf4j
@Component
public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>> {
@ -34,6 +36,12 @@ public class BasicEventHandler<T> implements ApplicationListener<BasicEvent<T>>
*/
@Override
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());
}
});
}
}

View File

@ -3,6 +3,7 @@ package com.muyu.event.process.consumer;
import com.muyu.event.process.util.CacheUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
@ -32,7 +33,7 @@ public class GoOfflineConsumer {
@RabbitListener(
bindings = @QueueBinding(
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) {

View File

@ -8,6 +8,7 @@ import com.muyu.event.process.constant.CacheHandlerConstants;
import com.muyu.event.process.util.CacheUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
@ -19,7 +20,7 @@ import java.util.HashMap;
/**
* @Author: zi run
* @Date 2024/10/6 10:01
* @Description 线
* @Description 线
*/
@Slf4j
@Component
@ -53,12 +54,13 @@ public class GoOnlineConsumer {
/**
* 线
*
* @param vin
*/
@RabbitListener(
bindings = @QueueBinding(
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) {

View File

@ -1,6 +1,7 @@
package com.muyu.event.process.listener;
import com.alibaba.fastjson2.JSONObject;
import com.muyu.common.core.exception.ServiceException;
import com.muyu.enterprise.domain.FaultRule;
import com.muyu.event.process.basic.BasicEvent;
import com.muyu.event.process.basic.BasicEventListener;
@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Optional;
/**
* @Author: zi run
@ -31,8 +33,10 @@ public class IdentifyingFailuresEventListener implements BasicEventListener<Stri
public void onEvent(BasicEvent<String> event) {
log.info("触发识别故障时间监听器……");
JSONObject data = JSONObject.parseObject(event.getData());
Map<String, Object> dataMap = (Map<String, Object>) cacheUtil.get((String) data.get("vin"));
FaultRule faultRule = (FaultRule) dataMap.get(CacheHandlerConstants.FAULT_RULE_KEY);
Optional<Map<String, Object>> optionalDataMap =
Optional.ofNullable((Map<String, Object>) cacheUtil.get((String) data.get("vin")));
optionalDataMap
.map(dataMap -> (FaultRule) dataMap.get(CacheHandlerConstants.FAULT_RULE_KEY))
.orElseThrow(() -> new ServiceException("故障规则未找到"));
}
}

View File

@ -1,2 +1,22 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// 佛祖保佑 永不宕机 永无BUG //

View File

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

View File

@ -21,14 +21,14 @@ import java.util.List;
/**
*
* @Author: chenruijia
* @author chenruijia
* @Date 2024/9/26 0:21
* @Description
*/
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/ent")
@Tag(name = "SysEntController",description = "企业管理")
@Tag(name = "企业信息",description = "企业管理")
public class SysEntController extends BaseController {
/**
@ -40,7 +40,7 @@ public class SysEntController extends BaseController {
*
* @return
*/
@GetMapping(value = "/getInfo")
@RequestMapping(value = "/selectList",method = RequestMethod.GET)
@Operation(summary = "获取企业信息", description = "现有的基础企业信息")
public Result<List<EntResp>> getInfo() {
return Result.success(
@ -48,25 +48,25 @@ public class SysEntController extends BaseController {
);
}
/**
*
* @param entListReq
* @return
*/
@PostMapping(value = "/selectList")
@Operation(summary = "查询企业信息列表", description = "分页展示企业信息")
public Result<TableDataInfo<EntResp>> selectList(@RequestBody EntListReq entListReq) {
startPage();
List<EntResp> entRespList = sysEntService.selectList(entListReq);
return getDataTable(entRespList);
}
// /**
// * 查询企业信息列表
// * @param entListReq 企业列表请求对象
// * @return 响应结果
// */
// @PostMapping(value = "/selectList")
// @Operation(summary = "查询企业信息列表", description = "分页展示企业信息")
// public Result<TableDataInfo<EntResp>> selectList(@RequestBody EntListReq entListReq) {
// startPage();
// List<EntResp> entRespList = sysEntService.selectList(entListReq);
// return getDataTable(entRespList);
// }
/**
* ID
* @param entId ID
* @return
*/
@GetMapping(value = "/{entId}")
@GetMapping(value = "/getById/{entId}")
@Operation(summary = "根据ID获取企业信息", description = "根据企业唯一标识获取单体企业信息")
public Result<EntResp> getById(
@Schema(title = "企业ID", type = "Long", defaultValue = "1", description = "企业唯一标识")
@ -79,7 +79,7 @@ public class SysEntController extends BaseController {
* @param entAddReq
* @return
*/
@PostMapping
@PostMapping(value = "/save")
@Operation(summary = "添加企业信息", description = "将企业信息添加到系统中")
public Result<String> save(@Validated @RequestBody EntAddReq entAddReq) {
sysEntService.save(EntAddReq.addBuild(entAddReq));
@ -92,7 +92,7 @@ public class SysEntController extends BaseController {
* @param entUpdateReq
* @return
*/
@PutMapping(value = "/{entId}")
@PutMapping(value = "/update/{entId}")
@Operation(summary = "修改企业信息",description = "根据企业唯一标识修改企业信息")
public Result<String> update(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识")
@NotNull(message = "企业ID不能为空") @PathVariable(value = "entId") Long entId,
@ -106,7 +106,7 @@ public class SysEntController extends BaseController {
* @param entId ID
* @return
*/
@RequestMapping(value = "/entId",method = RequestMethod.DELETE)
@RequestMapping(value = "/remove/{entId}",method = RequestMethod.DELETE)
@Operation(summary = "删除企业信息",description = "根据企业唯一标识删除企业记录")
public Result<String> remove(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识")
@NotNull(message = "企业ID不能为空") @PathVariable(value = "entId")Long entId){

View File

@ -16,6 +16,7 @@ import com.muyu.system.domain.resp.AuthRoleResp;
import com.muyu.system.domain.resp.UserDetailInfoResp;
import com.muyu.system.domain.resp.UserInfoResp;
import com.muyu.system.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -23,6 +24,8 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.*;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@ -32,6 +35,7 @@ import java.util.stream.Collectors;
*
* @author muyu
*/
@Slf4j
@RestController
@RequestMapping("/user")
public class SysUserController extends BaseController {
@ -120,20 +124,24 @@ public class SysUserController extends BaseController {
@PostMapping("/register")
public Result<Boolean> register (@RequestBody RegisterBody registerBody) {
String username = registerBody.getUsername();
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
return Result.error("当前系统没有开启注册功能!");
}
SysUser sysUser = SysUser.builder().userName(username).build();
SysUser sysUser = new SysUser();
sysUser.setUserName(username);
if (!userService.checkUserNameUnique(sysUser)) {
return Result.error("保存用户'" + username + "'失败,注册账号已存在");
}
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
return Result.error("当前系统没有开启注册功能!");
}
if (!userService.checkUserNameUnique(sysUser)) {
return Result.error("保存用户'" + username + "'失败,注册账号已存在");
}
//添加企业
SysEnt sysEnt = SysEnt.builder()
.name(registerBody.getEntName())
.leader(registerBody.getLeader())
.phone(registerBody.getPhone())
.email(registerBody.getEmail())
.entCode(registerBody.getUsername())
.build();
entService.save(sysEnt);
@ -151,7 +159,78 @@ public class SysUserController extends BaseController {
sysUser.setDeptId(sysDept.getDeptId());
sysUser.setNickName(registerBody.getUsername());
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));
}

View File

@ -107,6 +107,12 @@
<groupId>com.aliyun</groupId>
<artifactId>cloudapi20160714</artifactId>
</dependency>
<!-- rabbitmq模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-rabbit</artifactId>
</dependency>
</dependencies>
<repositories>

View File

@ -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("创建实例成功");
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -9,13 +9,12 @@ import com.aliyun.tea.TeaException;
import com.aliyun.teautil.Common;
import com.aliyun.teautil.models.RuntimeOptions;
import com.muyu.common.redis.service.RedisService;
import com.muyu.vehiclegateway.domain.Instance;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
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 java.util.ArrayList;
@ -23,7 +22,7 @@ import java.util.List;
/**
* @ClassName GenerateInstance
* @Description
* @Description ECS
* @Author YiBo.Liu
* @Date 2024/9/28 19:39
*/
@ -40,7 +39,7 @@ public class GenerateInstance implements ApplicationRunner {
*
* @throws Exception
*/
public List<String> generateInstance() throws Exception {
public List<Instance> generateInstance() throws Exception {
// 创建ECS客户端对象用于后续调用ECS相关API
Client client = CreateClient.createClient();
@ -52,7 +51,7 @@ public class GenerateInstance implements ApplicationRunner {
// 设置地域ID
.setRegionId("cn-shanghai")
// 设置镜像ID
.setImageId("m-uf63thq7h50ng72jpoq2")
.setImageId("m-uf6f7atj16s3cjn9q5l8")
// 设置实例类型
.setInstanceType("ecs.t6-c1m1.large")
// 设置安全组ID
@ -105,27 +104,29 @@ public class GenerateInstance implements ApplicationRunner {
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions);
//提取实例ID集合
ArrayList<String> list = new ArrayList<>();
List<Instance> list = new ArrayList<>();
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
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("实例ip为:"+instance.getPublicIpAddress().ipAddress.get(0));
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;
}
@Override
public void run(ApplicationArguments args) throws Exception {
generateInstance();

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -40,6 +40,8 @@ spring:
file-extension: yml
# 共享配置
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}
# 系统环境Config共享配置

View File

@ -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>

View File

@ -298,6 +298,13 @@
<version>${muyu.version}</version>
</dependency>
<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- 多数据源 -->
<dependency>
<groupId>com.muyu</groupId>