Compare commits
2 Commits
dev.entOpe
...
master
Author | SHA1 | Date |
---|---|---|
|
df2e675685 | |
|
ebc0a534a3 |
|
@ -26,7 +26,6 @@ logs
|
|||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
*.yml
|
||||
|
||||
### JRebel ###
|
||||
rebel.xml
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.muyu.auth.controller;
|
||||
|
||||
import com.muyu.common.system.domain.form.LoginBody;
|
||||
import com.muyu.common.system.domain.form.RegisterBody;
|
||||
import com.muyu.auth.form.LoginBody;
|
||||
import com.muyu.auth.form.RegisterBody;
|
||||
import com.muyu.auth.service.SysLoginService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.JwtUtils;
|
||||
|
@ -66,7 +66,7 @@ public class TokenController {
|
|||
@PostMapping("register")
|
||||
public Result<?> register (@RequestBody RegisterBody registerBody) {
|
||||
// 用户注册
|
||||
sysLoginService.register(registerBody);
|
||||
sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.common.system.domain.form;
|
||||
package com.muyu.auth.form;
|
||||
|
||||
/**
|
||||
* 用户登录对象
|
|
@ -0,0 +1,10 @@
|
|||
package com.muyu.auth.form;
|
||||
|
||||
/**
|
||||
* 用户注册对象
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class RegisterBody extends LoginBody {
|
||||
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.muyu.auth.service;
|
||||
|
||||
import com.muyu.common.system.domain.form.RegisterBody;
|
||||
import com.muyu.common.core.constant.CacheConstants;
|
||||
import com.muyu.common.core.constant.Constants;
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
|
@ -76,6 +75,7 @@ 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())) {
|
||||
|
@ -83,8 +83,8 @@ public class SysLoginService {
|
|||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||
}
|
||||
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
recordLogService.recordLogininfor(username,Constants.LOGIN_FAIL,"用户已停用,请联系管理官");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||
}
|
||||
passwordService.validate(user, password);
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||
|
@ -98,22 +98,7 @@ public class SysLoginService {
|
|||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register (RegisterBody registerBody) {
|
||||
//获取用户名密码
|
||||
String username = registerBody.getUsername();
|
||||
String password = registerBody.getPassword();
|
||||
if(StringUtils.isEmpty(registerBody.getEntName())) {
|
||||
throw new ServiceException("企业名称不能为空");
|
||||
}
|
||||
if(StringUtils.isEmpty(registerBody.getLeader())) {
|
||||
throw new ServiceException("负责人不能为空");
|
||||
}
|
||||
if(StringUtils.isBlank(registerBody.getPhone())) {
|
||||
throw new ServiceException("手机号不能为空");
|
||||
}
|
||||
if(StringUtils.isBlank(registerBody.getEmail())) {
|
||||
throw new ServiceException("邮箱不能为空");
|
||||
}
|
||||
public void register (String username, String password) {
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password)) {
|
||||
throw new ServiceException("用户/密码必须填写");
|
||||
|
@ -132,11 +117,11 @@ public class SysLoginService {
|
|||
sysUser.setUserName(username);
|
||||
sysUser.setNickName(username);
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
||||
Result<Boolean> registerResult = remoteUserService.registerUserInfo(registerBody, SecurityConstants.INNER);
|
||||
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||
|
||||
if (Result.FAIL == registerResult.getCode()) {
|
||||
throw new ServiceException(registerResult.getMsg());
|
||||
}
|
||||
|
||||
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: dev
|
||||
namespace: xzr
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloud-common-cache</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-common-cache redis缓存架构
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- redis 缓存模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,36 +0,0 @@
|
|||
package com.muyu.common.cache.config;
|
||||
/**
|
||||
* 抽象缓存层
|
||||
* @ClassName CacheAbsBasic
|
||||
* @Description CacheAbsBasic:类的描述
|
||||
* @Date 2024/9/30 1:39
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
public abstract class CacheAbsBasic<K,V> implements CacheBasic<K,V> {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public void put(K key, V value) {
|
||||
redisService.setCacheObject(encode(key),value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(K key) {
|
||||
return redisService.getCacheObject(encode(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(K key) {
|
||||
redisService.deleteObject(encode(key));
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package com.muyu.common.cache.config;
|
||||
|
||||
import java.awt.image.Kernel;
|
||||
|
||||
/**
|
||||
* 缓存基础
|
||||
* @ClassName CacheBasic
|
||||
* @Description CacheBasic:类的描述
|
||||
* @Date 2024/9/30 1:36
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
|
||||
public interface CacheBasic<K,V> extends PrimaryKeyBasic<K>{
|
||||
|
||||
void put(K key,V value);
|
||||
|
||||
V get(K key);
|
||||
|
||||
void remove(K key);
|
||||
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package com.muyu.common.cache.config;
|
||||
|
||||
/**
|
||||
* 主键基础
|
||||
* @ClassName PrimaryKeyBasic
|
||||
* @Description PrimaryKeyBasic:类的描述
|
||||
* @Date 2024/9/30 0:15
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
public interface PrimaryKeyBasic <K>{
|
||||
/**
|
||||
* key 前缀
|
||||
*/
|
||||
public String keyPre();
|
||||
|
||||
/**
|
||||
* 编码
|
||||
* @param key 缓存键
|
||||
* @return 装修键
|
||||
*/
|
||||
public default String encode(K key){
|
||||
return keyPre() + key.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码 Key
|
||||
* @param key 解码后的key
|
||||
* @return
|
||||
*/
|
||||
public K decode(String key);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* kafka常量信息
|
||||
* @Author:李庆帅
|
||||
* @Package:com.muyu.common.core.constant
|
||||
* @Project:cloud-server
|
||||
* @name:KafkaConstants
|
||||
* @Date:2024/9/29 16:41
|
||||
*/
|
||||
public class KafkaConstants {
|
||||
|
||||
/**
|
||||
* 协议解析报文传递数据(队列名称)
|
||||
*/
|
||||
public final static String MESSAGE_PARSING = "MessageParsing";
|
||||
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
/**
|
||||
* redis常量信息
|
||||
* @Author:李庆帅
|
||||
* @Package:com.muyu.common.core.constant
|
||||
* @Project:cloud-server
|
||||
* @name:RedisConstants
|
||||
* @Date:2024/9/29 17:28
|
||||
*/
|
||||
public class RedisConstants {
|
||||
|
||||
/**
|
||||
* redisKey(协议解析报文传递)
|
||||
*/
|
||||
public final static String MESSAGE_TEMPLATE = "messageTemplate";
|
||||
}
|
|
@ -20,8 +20,4 @@ public class ServiceNameConstants {
|
|||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "cloud-file";
|
||||
/**
|
||||
* 企业平台服务的serviceid
|
||||
*/
|
||||
public static final String ENTERPRISE_SERVICE = "cloud-enterprise";
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package com.muyu.common.core.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.muyu.common.core.context.SecurityContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/26 16:43
|
||||
* @Description 填充公共字段
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
|
||||
public MyMetaObjectHandler () {
|
||||
log.info("元数据填充初始化成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加时触发
|
||||
* @param metaObject 元数据对象
|
||||
*/
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
String[] setterNames = metaObject.getSetterNames();
|
||||
Set<String> setterNamesSet = Arrays.stream(setterNames).collect(Collectors.toSet());
|
||||
if (setterNamesSet.contains("createBy")){
|
||||
if (metaObject.getValue("createBy") == null) {
|
||||
this.setFieldValByName("createBy", SecurityContextHolder.getUserName(), metaObject);
|
||||
}
|
||||
}
|
||||
if (setterNamesSet.contains("createTime")){
|
||||
if (metaObject.getValue("createTime") == null) {
|
||||
this.setFieldValByName("createTime", new Date(), metaObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改时触发
|
||||
* @param metaObject 元数据对象
|
||||
*/
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
String[] setterNames = metaObject.getSetterNames();
|
||||
Set<String> setterNamesSet = Arrays.stream(setterNames).collect(Collectors.toSet());
|
||||
if (setterNamesSet.contains("updateBy")){
|
||||
if (metaObject.getValue("updateBy") == null) {
|
||||
this.setFieldValByName("updateBy", SecurityContextHolder.getUserName(), metaObject);
|
||||
}
|
||||
}
|
||||
if (setterNamesSet.contains("updateTime")){
|
||||
if (metaObject.getValue("updateTime") == null) {
|
||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?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-datascope</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-common-datascope权限范围
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- MuYu Common Security -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,28 +0,0 @@
|
|||
package com.muyu.common.datascope.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 数据权限过滤注解
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface DataScope {
|
||||
/**
|
||||
* 部门表的别名
|
||||
*/
|
||||
public String deptAlias () default "";
|
||||
|
||||
/**
|
||||
* 用户表的别名
|
||||
*/
|
||||
public String userAlias () default "";
|
||||
|
||||
/**
|
||||
* 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@RequiresPermissions获取,多个权限用逗号分隔开来
|
||||
*/
|
||||
public String permission () default "";
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
package com.muyu.common.datascope.aspect;
|
||||
|
||||
import com.muyu.common.core.context.SecurityContextHolder;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.datascope.annotation.DataScope;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据过滤处理
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class DataScopeAspect {
|
||||
/**
|
||||
* 全部数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_ALL = "1";
|
||||
|
||||
/**
|
||||
* 自定数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_CUSTOM = "2";
|
||||
|
||||
/**
|
||||
* 部门数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT = "3";
|
||||
|
||||
/**
|
||||
* 部门及以下数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
|
||||
|
||||
/**
|
||||
* 仅本人数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_SELF = "5";
|
||||
|
||||
/**
|
||||
* 数据权限过滤关键字
|
||||
*/
|
||||
public static final String DATA_SCOPE = "dataScope";
|
||||
|
||||
/**
|
||||
* 数据范围过滤
|
||||
*
|
||||
* @param joinPoint 切点
|
||||
* @param user 用户
|
||||
* @param deptAlias 部门别名
|
||||
* @param userAlias 用户别名
|
||||
* @param permission 权限字符
|
||||
*/
|
||||
public static void dataScopeFilter (JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, String permission) {
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
List<String> conditions = new ArrayList<String>();
|
||||
|
||||
for (SysRole role : user.getRoles()) {
|
||||
String dataScope = role.getDataScope();
|
||||
if (!DATA_SCOPE_CUSTOM.equals(dataScope) && conditions.contains(dataScope)) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(permission) && StringUtils.isNotEmpty(role.getPermissions())
|
||||
&& !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission))) {
|
||||
continue;
|
||||
}
|
||||
if (DATA_SCOPE_ALL.equals(dataScope)) {
|
||||
sqlString = new StringBuilder();
|
||||
conditions.add(dataScope);
|
||||
break;
|
||||
} else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
|
||||
role.getRoleId()));
|
||||
} else if (DATA_SCOPE_DEPT.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
|
||||
} else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
|
||||
deptAlias, user.getDeptId(), user.getDeptId()));
|
||||
} else if (DATA_SCOPE_SELF.equals(dataScope)) {
|
||||
if (StringUtils.isNotBlank(userAlias)) {
|
||||
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
|
||||
} else {
|
||||
// 数据权限为仅本人且没有userAlias别名不查询任何数据
|
||||
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
||||
}
|
||||
}
|
||||
conditions.add(dataScope);
|
||||
}
|
||||
|
||||
// 多角色情况下,所有角色都不包含传递过来的权限字符,这个时候sqlString也会为空,所以要限制一下,不查询任何数据
|
||||
if (StringUtils.isEmpty(conditions)) {
|
||||
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(sqlString.toString())) {
|
||||
Object params = joinPoint.getArgs()[0];
|
||||
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
|
||||
BaseEntity baseEntity = (BaseEntity) params;
|
||||
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Before("@annotation(controllerDataScope)")
|
||||
public void doBefore (JoinPoint point, DataScope controllerDataScope) throws Throwable {
|
||||
clearDataScope(point);
|
||||
handleDataScope(point, controllerDataScope);
|
||||
}
|
||||
|
||||
protected void handleDataScope (final JoinPoint joinPoint, DataScope controllerDataScope) {
|
||||
// 获取当前的用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (StringUtils.isNotNull(loginUser)) {
|
||||
SysUser currentUser = loginUser.getSysUser();
|
||||
// 如果是超级管理员,则不过滤数据
|
||||
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) {
|
||||
String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), SecurityContextHolder.getPermission());
|
||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
||||
controllerDataScope.userAlias(), permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接权限sql前先清空params.dataScope参数防止注入
|
||||
*/
|
||||
private void clearDataScope (final JoinPoint joinPoint) {
|
||||
Object params = joinPoint.getArgs()[0];
|
||||
if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
|
||||
BaseEntity baseEntity = (BaseEntity) params;
|
||||
baseEntity.getParams().put(DATA_SCOPE, "");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
com.muyu.common.datascope.aspect.DataScopeAspect
|
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-common-kafka</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-common-kafka
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 项目公共核心模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- kafka客户端 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,102 +0,0 @@
|
|||
package com.muyu.common.kafka.config;
|
||||
|
||||
import com.muyu.common.core.text.StrFormatter;
|
||||
import com.muyu.common.kafka.constant.KafkaConfigConstants;
|
||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||
import org.apache.kafka.common.serialization.Deserializer;
|
||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/28 20:32
|
||||
* @Description Kafka消费者配置
|
||||
*/
|
||||
@Configuration
|
||||
public class KafkaConsumerConfig {
|
||||
|
||||
/**
|
||||
* 服务端IP
|
||||
*/
|
||||
@Value("${kafka.consumer.bootstrap-servers-ip}")
|
||||
private String bootstrapServersIP;
|
||||
|
||||
/**
|
||||
* 服务端口号
|
||||
*/
|
||||
@Value("${kafka.consumer.bootstrap-servers-port}")
|
||||
private String bootstrapServersPort;
|
||||
|
||||
/**
|
||||
* 开启消费者偏移量
|
||||
*/
|
||||
@Value("${kafka.consumer.enable-auto-commit}")
|
||||
private Boolean enableAutoCommit;
|
||||
|
||||
/**
|
||||
* 自动提交时间间隔
|
||||
*/
|
||||
@Value("${kafka.consumer.auto-commit-interval}")
|
||||
private Integer autoCommitInterval;
|
||||
|
||||
/**
|
||||
* 自动重置偏移量
|
||||
*/
|
||||
@Value("${kafka.consumer.auto-offset-reset}")
|
||||
private String autoOffsetReset;
|
||||
|
||||
/**
|
||||
* 请求阻塞的最大时间
|
||||
*/
|
||||
@Value("${kafka.consumer.fetch-max-wait}")
|
||||
private Integer fetchMaxWait;
|
||||
|
||||
/**
|
||||
* 请求应答的最小字节数
|
||||
*/
|
||||
@Value("${kafka.consumer.fetch-min-size}")
|
||||
private Integer fetchMinSize;
|
||||
|
||||
/**
|
||||
* 心跳间隔时间
|
||||
*/
|
||||
@Value("${kafka.consumer.heartbeat-interval}")
|
||||
private Integer heartbeatInterval;
|
||||
|
||||
/**
|
||||
* 一次调用poll返回的最大记录条数
|
||||
*/
|
||||
@Value("${kafka.consumer.max-poll-records}")
|
||||
private Integer maxPollRecords;
|
||||
|
||||
/**
|
||||
* 指定消费组
|
||||
*/
|
||||
@Value("${kafka.consumer.group-id}")
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
* Kafka消费者初始化配置
|
||||
* @return Kafka消费者实例
|
||||
*/
|
||||
@Bean
|
||||
public KafkaConsumer<String, String> kafkaConsumer() {
|
||||
HashMap<String, Object> configs = new HashMap<>();
|
||||
configs.put(KafkaConfigConstants.BOOTSTRAP_SERVERS,
|
||||
StrFormatter.format("{}:{}", bootstrapServersIP, bootstrapServersPort));
|
||||
configs.put(KafkaConfigConstants.ENABLE_AUTO_COMMIT, enableAutoCommit);
|
||||
configs.put(KafkaConfigConstants.AUTO_COMMIT_INTERVAL, autoCommitInterval);
|
||||
configs.put(KafkaConfigConstants.AUTO_OFFSET_RESET, autoOffsetReset);
|
||||
configs.put(KafkaConfigConstants.FETCH_MAX_WAIT, fetchMaxWait);
|
||||
configs.put(KafkaConfigConstants.FETCH_MIN_SIZE, fetchMinSize);
|
||||
configs.put(KafkaConfigConstants.HEARTBEAT_INTERVAL, heartbeatInterval);
|
||||
configs.put(KafkaConfigConstants.MAX_POLL_RECORDS, maxPollRecords);
|
||||
configs.put(KafkaConfigConstants.GROUP_ID, groupId);
|
||||
Deserializer<String> keyDeserializer = new StringDeserializer();
|
||||
Deserializer<String> valueDeserializer = new StringDeserializer();
|
||||
return new KafkaConsumer<>(configs, keyDeserializer, valueDeserializer);
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package com.muyu.common.kafka.config;
|
||||
|
||||
import com.muyu.common.core.text.StrFormatter;
|
||||
import com.muyu.common.kafka.constant.KafkaConfigConstants;
|
||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.common.serialization.Serializer;
|
||||
import org.apache.kafka.common.serialization.StringSerializer;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/28 16:35
|
||||
* @Description Kafka生产者配置
|
||||
*/
|
||||
@Configuration
|
||||
public class KafkaProducerConfig {
|
||||
|
||||
/**
|
||||
* 服务端IP
|
||||
*/
|
||||
@Value("${kafka.producer.bootstrap-servers-ip}")
|
||||
private String bootstrapServersIP;
|
||||
|
||||
/**
|
||||
* 服务端口号
|
||||
*/
|
||||
@Value("${kafka.producer.bootstrap-servers-port}")
|
||||
private String bootstrapServersPort;
|
||||
|
||||
/**
|
||||
* 重试次数
|
||||
*/
|
||||
@Value("${kafka.producer.retries}")
|
||||
private Integer retries;
|
||||
|
||||
/**
|
||||
* 默认批量大小
|
||||
*/
|
||||
@Value("${kafka.producer.batch-size}")
|
||||
private Integer batchSize;
|
||||
|
||||
/**
|
||||
* 总内存字节数
|
||||
*/
|
||||
@Value("${kafka.producer.buffer-memory}")
|
||||
private Integer bufferMemory;
|
||||
|
||||
/**
|
||||
* 偏移量
|
||||
*/
|
||||
@Value("${kafka.producer.acks}")
|
||||
private String acks;
|
||||
|
||||
/**
|
||||
* Kafka生产者初始化配置
|
||||
* @return kafka生产者实例
|
||||
*/
|
||||
@Bean
|
||||
public KafkaProducer<String, String> kafkaProducer() {
|
||||
HashMap<String, Object> configs = new HashMap<>();
|
||||
configs.put(KafkaConfigConstants.BOOTSTRAP_SERVERS,
|
||||
StrFormatter.format("{}:{}", bootstrapServersIP, bootstrapServersPort));
|
||||
configs.put(KafkaConfigConstants.RETRIES, retries);
|
||||
configs.put(KafkaConfigConstants.BATCH_SIZE, batchSize);
|
||||
configs.put(KafkaConfigConstants.BUFFER_MEMORY, bufferMemory);
|
||||
configs.put(KafkaConfigConstants.ACKS, acks);
|
||||
Serializer<String> keySerializer = new StringSerializer();
|
||||
Serializer<String> valueSerializer = new StringSerializer();
|
||||
return new KafkaProducer<>(configs, keySerializer, valueSerializer);
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package com.muyu.common.kafka.constant;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/28 20:07
|
||||
* @Description Kafka配置通用常量
|
||||
*/
|
||||
public class KafkaConfigConstants {
|
||||
|
||||
/**
|
||||
* 服务端ip+端口号
|
||||
*/
|
||||
public static final String BOOTSTRAP_SERVERS = "bootstrap.servers";
|
||||
|
||||
/**
|
||||
* 重试次数
|
||||
*/
|
||||
public static final String RETRIES = "retries";
|
||||
|
||||
/**
|
||||
* 默认批量大小
|
||||
*/
|
||||
public static final String BATCH_SIZE = "batch.size";
|
||||
|
||||
/**
|
||||
* 总内存字节数
|
||||
*/
|
||||
public static final String BUFFER_MEMORY = "buffer-memory";
|
||||
|
||||
/**
|
||||
* 偏移量
|
||||
*/
|
||||
public static final String ACKS = "acks";
|
||||
|
||||
/**
|
||||
* 开启消费者偏移量
|
||||
*/
|
||||
public static final String ENABLE_AUTO_COMMIT = "enable.auto.commit";
|
||||
|
||||
/**
|
||||
* 自动提交时间间隔
|
||||
*/
|
||||
public static final String AUTO_COMMIT_INTERVAL = "auto.commit.interval";
|
||||
|
||||
/**
|
||||
* 自动重置偏移量
|
||||
*/
|
||||
public static final String AUTO_OFFSET_RESET = "auto.offset.reset";
|
||||
|
||||
/**
|
||||
* 请求阻塞的最大时间
|
||||
*/
|
||||
public static final String FETCH_MAX_WAIT = "fetch.max.wait";
|
||||
|
||||
/**
|
||||
* 请求应答的最小字节数
|
||||
*/
|
||||
public static final String FETCH_MIN_SIZE = "fetch.min.size";
|
||||
|
||||
/**
|
||||
* 心跳间隔时间
|
||||
*/
|
||||
public static final String HEARTBEAT_INTERVAL = "heartbeat-interval";
|
||||
|
||||
/**
|
||||
* 一次调用poll返回的最大记录条数
|
||||
*/
|
||||
public static final String MAX_POLL_RECORDS = "max.poll.records";
|
||||
|
||||
/**
|
||||
* 指定消费组
|
||||
*/
|
||||
public static final String GROUP_ID = "group.id";
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
com.muyu.common.kafka.config.KafkaProducerConfig
|
||||
com.muyu.common.kafka.config.KafkaConsumerConfig
|
|
@ -1,41 +1,28 @@
|
|||
package com.muyu.common.rabbit.config;
|
||||
package com.muyu.common.rabbit;
|
||||
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
||||
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/10/2 10:06
|
||||
* @Description rabbitMQ的监听器配置
|
||||
*/
|
||||
@Configuration
|
||||
public class RabbitListenerConfig implements RabbitListenerConfigurer {
|
||||
public class RabbitListenerConfigurer implements org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer {
|
||||
|
||||
static {
|
||||
// 设置为信任所有类型的反序列化,确保消息能够正确反序列化
|
||||
System.setProperty("spring.amqp.deserialization.trust.all", "true");
|
||||
}
|
||||
|
||||
/**
|
||||
* RabbitMQ连接工厂,用于创建连接
|
||||
*/
|
||||
//以下配置RabbitMQ消息服务
|
||||
@Autowired
|
||||
public ConnectionFactory connectionFactory;
|
||||
|
||||
@Autowired
|
||||
private MessageConverter jsonMessageConverter;
|
||||
|
||||
/**
|
||||
* 创建处理器方法工厂的bean
|
||||
*
|
||||
* @return DefaultMessageHandlerMethodFactory 实例,用于处理消息的转换和方法调用
|
||||
* 处理器方法工厂
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public DefaultMessageHandlerMethodFactory handlerMethodFactory() {
|
||||
|
@ -45,14 +32,8 @@ public class RabbitListenerConfig implements RabbitListenerConfigurer {
|
|||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置RabbitMQ监听器的消息处理方法工厂。
|
||||
*
|
||||
* @param rabbitListenerEndpointRegistrar 实例,用于注册监听器的配置
|
||||
*/
|
||||
@Override
|
||||
public void configureRabbitListeners(RabbitListenerEndpointRegistrar rabbitListenerEndpointRegistrar) {
|
||||
// 注册自定义的消息处理方法工厂
|
||||
rabbitListenerEndpointRegistrar.setMessageHandlerMethodFactory(handlerMethodFactory());
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package com.muyu.common.rabbit.callback;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/10/2 9:26
|
||||
* @Description 消息发送到broker确认回调
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ConfirmCallback implements RabbitTemplate.ConfirmCallback {
|
||||
|
||||
@Resource
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.rabbitTemplate.setConfirmCallback(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调确认方法(消息发送之后 消息无论发送成功还是失败都会执行这个回调方法)
|
||||
* @param correlationData 回调的相关数据
|
||||
* @param ack 确认结果(true表示消息已经被broker接收,false表示消息未被broker接收)
|
||||
* @param cause 失败原因(当ack为false时,表示拒绝接收消息的原因;当ack为true时,该值为空)
|
||||
*/
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||
if (ack) {
|
||||
log.info("消息发送到broker成功!");
|
||||
} else {
|
||||
log.info("消息发送到broker失败,失败原因:{}", cause);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package com.muyu.common.rabbit.callback;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.ReturnedMessage;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/10/2 9:33
|
||||
* @Description 消息发送失败时回调
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ReturnsCallback implements RabbitTemplate.ReturnsCallback {
|
||||
|
||||
@Resource
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
rabbitTemplate.setReturnsCallback(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息发送到队列失败时执行
|
||||
* @param returnedMessage 返回的消息和元数据
|
||||
*/
|
||||
@Override
|
||||
public void returnedMessage(ReturnedMessage returnedMessage) {
|
||||
log.info("消息:{}被交换机:{}回退!回退原因:{}", returnedMessage.getMessage().toString(),
|
||||
returnedMessage.getExchange(), returnedMessage.getReplyText());
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package com.muyu.common.rabbit.config;
|
||||
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/10/2 16:41
|
||||
* @Description RabbitMQ连接和管理功能配置
|
||||
*/
|
||||
@Configuration
|
||||
public class RabbitAdminConfig {
|
||||
|
||||
/**
|
||||
* RabbitMQ服务器的主机地址
|
||||
*/
|
||||
@Value("${spring.rabbitmq.host}")
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* RabbitMQ的用户名
|
||||
*/
|
||||
@Value("${spring.rabbitmq.username}")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* RabbitMQ的密码
|
||||
*/
|
||||
@Value("${spring.rabbitmq.password}")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* RabbitMQ的虚拟主机
|
||||
*/
|
||||
@Value("${spring.rabbitmq.virtualhost}")
|
||||
private String virtualhost;
|
||||
|
||||
/**
|
||||
* 创建并初始化RabbitAdmin实例
|
||||
*
|
||||
* @return RabbitAdmin 实例
|
||||
*/
|
||||
@Bean
|
||||
public RabbitAdmin rabbitAdmin() {
|
||||
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory());
|
||||
rabbitAdmin.setAutoStartup(true);
|
||||
return rabbitAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建RabbitMQ连接工厂
|
||||
*
|
||||
* @return ConnectionFactory 实例
|
||||
*/
|
||||
@Bean
|
||||
public ConnectionFactory connectionFactory() {
|
||||
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
|
||||
connectionFactory.setAddresses(host);
|
||||
connectionFactory.setUsername(username);
|
||||
connectionFactory.setPassword(password);
|
||||
connectionFactory.setVirtualHost(virtualhost);
|
||||
|
||||
// 配置发送确认回调时,次配置必须配置,否则即使在RabbitTemplate配置了ConfirmCallback也不会生效
|
||||
connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
|
||||
connectionFactory.setPublisherReturns(true);
|
||||
return connectionFactory;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
|
||||
package com.muyu.common.rabbit.config;
|
||||
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author: zi run
|
||||
* @Date 2024/10/2 9:17
|
||||
* @Description rabbitMQ消息转换器配置
|
||||
*/
|
||||
@Configuration
|
||||
public class RabbitMQMessageConverterConfig {
|
||||
|
||||
/**
|
||||
* 消息转换配置
|
||||
*
|
||||
* @return 消息转换器
|
||||
*/
|
||||
@Bean
|
||||
public MessageConverter jsonMessageConverter() {
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
}
|
|
@ -1,3 +1 @@
|
|||
com.muyu.common.rabbit.config.RabbitAdminConfig
|
||||
com.muyu.common.rabbit.config.RabbitListenerConfig
|
||||
com.muyu.common.rabbit.config.RabbitMQMessageConverterConfig
|
||||
com.muyu.common.rabbit.RabbitListenerConfigurer
|
|
@ -64,7 +64,7 @@ public class ManyDataSource implements ApplicationRunner {
|
|||
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
||||
Result<List<SysUser>> entListResult = remoteUserService.entList();
|
||||
if (entListResult==null){
|
||||
throw new SaaSException("saas远调数据源异常");
|
||||
throw new SaaSException("saas远调数据源错误");
|
||||
}
|
||||
List<SysUser> data = entListResult.getData();
|
||||
if (entListResult.getCode() == Result.SUCCESS && data != null){
|
||||
|
@ -91,8 +91,8 @@ public class ManyDataSource implements ApplicationRunner {
|
|||
@Bean
|
||||
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
||||
List<EntInfo> entInfoList = dataSourceInfoList();
|
||||
if (StringUtils.isNotEmpty(entInfoList)) {
|
||||
throw new SaaSException("数据元信息列表为空或为null");
|
||||
if(StringUtils.isEmpty(entInfoList)){
|
||||
throw new SaaSException("数据源信息列表为空或为null");
|
||||
}
|
||||
Map<Object, Object> dataSourceMap = dataSourceInfoList().stream()
|
||||
.map(entInfo -> DataSourceInfo.hostAndPortBuild(
|
||||
|
@ -100,10 +100,12 @@ public class ManyDataSource implements ApplicationRunner {
|
|||
entInfo.getIp(),
|
||||
entInfo.getPort()
|
||||
)
|
||||
).collect(Collectors.toMap(
|
||||
)
|
||||
.collect(Collectors.toMap(
|
||||
dataSourceInfo -> dataSourceInfo.getKey(),
|
||||
dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo)
|
||||
));
|
||||
|
||||
//设置动态数据源
|
||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||
dynamicDataSource.setTargetDataSources(dataSourceMap);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package com.muyu.cloud.common.many.datasource.constents;
|
||||
|
||||
/**
|
||||
* 数据源常量
|
||||
* @Author chenruijia
|
||||
* @Date 2024/9/29 17:52
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/20 14:52
|
||||
* @Description 数据源常量
|
||||
*/
|
||||
public class DatasourceContent {
|
||||
|
|
|
@ -8,7 +8,6 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据源实体类
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/20 14:52
|
||||
* @Description 数据源实体类
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.springframework.stereotype.Component;
|
|||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Druid工厂
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/20 14:52
|
||||
* @Description Druid工厂
|
||||
|
|
|
@ -4,7 +4,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* 数据源切换处理
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/20 14:52
|
||||
* @Description 数据源切换处理
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.muyu.common.security.utils.SecurityUtils;
|
|||
import com.muyu.common.system.domain.LoginUser;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<?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>
|
|
@ -1,22 +0,0 @@
|
|||
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 {
|
||||
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
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();
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,303 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
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/");
|
||||
}
|
||||
}
|
|
@ -64,11 +64,6 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
private Long entId;
|
||||
|
||||
/**
|
||||
* 部门状态:0正常,1停用
|
||||
*/
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 企业表
|
||||
* @Author: zi run
|
||||
* @Date 2024/9/25 22:38
|
||||
* @Description 企业表
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "sys_ent", autoResultMap = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysEnt extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private String leader;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 企业编码
|
||||
*/
|
||||
private String entCode;
|
||||
/**
|
||||
* 企业状态
|
||||
*/
|
||||
private Integer entStatus;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package com.muyu.common.system.domain.form;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 用户注册对象
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RegisterBody extends LoginBody {
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String entName;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private String leader;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
}
|
|
@ -4,7 +4,6 @@ import com.muyu.common.core.constant.SecurityConstants;
|
|||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.form.RegisterBody;
|
||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
@ -39,7 +38,7 @@ public interface RemoteUserService {
|
|||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/user/register")
|
||||
public Result<Boolean> registerUserInfo (@RequestBody RegisterBody registerBody, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 获取企业信息
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.muyu.common.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.form.RegisterBody;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
|
@ -31,7 +30,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> registerUserInfo (RegisterBody registerBody, String source) {
|
||||
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
<module>cloud-common-system</module>
|
||||
<module>cloud-common-xxl</module>
|
||||
<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>
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: dev
|
||||
namespace: xzr
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
<artifactId>cloud-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<version>3.6.3</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cloud-modules-vehicle-gateway</artifactId>
|
||||
<artifactId>cloud-modules-car</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-modules-vehicle-gateway系统模块
|
||||
cloud-modules-car车辆模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
@ -60,12 +59,6 @@
|
|||
<artifactId>cloud-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Mqtt3包 -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
|
@ -77,53 +70,8 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-openapi</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-console</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-util</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云创建ecs实例 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>cloudapi20160714</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- rabbitmq模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-rabbit</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>aliyun-repo</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
|
@ -1,21 +1,23 @@
|
|||
package com.muyu.enterprise;
|
||||
package com.muyu;
|
||||
|
||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 企业平台微服务启动类
|
||||
* 系统模块
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class CloudEnterpriseApplication {
|
||||
public class CloudCarApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CloudEnterpriseApplication.class, args);
|
||||
SpringApplication.run(CloudCarApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.muyu.car.controller;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.muyu.car.domain.dto.CarDTO;
|
||||
import com.muyu.car.domain.vo.CarVO;
|
||||
import com.muyu.car.service.SysCarCompanyService;
|
||||
import com.muyu.car.service.SysCarService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 信息操作处理
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/company")
|
||||
@Tag(name = "SysCarCompanyController", description = "系统参数配置")
|
||||
public class SysCarCompanyController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private SysCarCompanyService sysCarCompanyService;
|
||||
|
||||
/**
|
||||
* 查询企业表
|
||||
*/
|
||||
@PostMapping("selectCompany")
|
||||
public Result selectCompany(){
|
||||
return Result.success(sysCarCompanyService.list());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.muyu.car.controller;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.muyu.car.domain.dto.CarDTO;
|
||||
import com.muyu.car.domain.vo.CarVO;
|
||||
import com.muyu.car.service.SysCarCompanyService;
|
||||
import com.muyu.car.service.SysCarService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.catalina.security.SecurityUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 信息操作处理
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/manage")
|
||||
@Tag(name = "SysCarController", description = "系统参数配置")
|
||||
public class SysCarController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private SysCarCompanyService sysCarCompanyService;
|
||||
@Autowired
|
||||
private SysCarService sysCarService;
|
||||
|
||||
/**
|
||||
* 车辆列表2
|
||||
* @param carDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("CarListShow")
|
||||
public Result<List<CarVO>> CarListShow(@RequestBody CarDTO carDTO){
|
||||
return Result.success(sysCarService.CarListShow(carDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param carId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("CarListShowByCarId")
|
||||
public Result<List<CarVO>> CarListShowByCarId(@RequestParam("carId") Long carId){
|
||||
return Result.success(sysCarService.CarListShowByCarId(carId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆列表1
|
||||
* @param carVO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("CarList")
|
||||
@Operation(summary = "查询列表",description = "车辆管理列表")
|
||||
public Result<TableDataInfo<CarVO>> CarList(@RequestBody CarVO carVO){
|
||||
startPage();
|
||||
return getDataTable(sysCarService.carList(carVO));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车辆添加
|
||||
* @param carVO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("insertCar")
|
||||
public Result insertCar(@RequestBody CarVO carVO){
|
||||
String key = RandomUtil.randomNumbers(9);
|
||||
// 随机生成车架号
|
||||
carVO.setCarFrame(key);
|
||||
// 随机生成VIN码
|
||||
String key2 = RandomUtil.randomNumbers(17);
|
||||
carVO.setCarVin(key2);
|
||||
sysCarService.insertCar(carVO);
|
||||
return Result.success("车辆添加成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车辆修改
|
||||
* @param carVO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("updataCar")
|
||||
public Result updataCar(@RequestBody CarVO carVO){
|
||||
//
|
||||
carVO.setUserId(SecurityUtils.getUserId());
|
||||
sysCarService.updateById(carVO);
|
||||
return Result.success("车辆修改成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("deleteCar")
|
||||
public Result deleteCar(@RequestParam("ids") List<Long> ids){
|
||||
sysCarService.deleteCar(ids);
|
||||
return Result.success("车辆删除成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,37 +1,21 @@
|
|||
package com.muyu.enterprise.controller;
|
||||
package com.muyu.car.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.service.SysCarMessageService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.enterprise.cache.CarManageCacheService;
|
||||
import com.muyu.enterprise.cache.CarMessageCacheService;
|
||||
import com.muyu.enterprise.domain.CarMessage;
|
||||
import com.muyu.enterprise.service.CarMessageService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆报文--控制层
|
||||
* @ClassName carMessageController
|
||||
* @Description 车辆类型 Controller 层
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/carMessage")
|
||||
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
|
||||
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
|
||||
@RequestMapping("/message") // 报文
|
||||
@Tag(name = "报文",description = "报文模块")
|
||||
public class CarMessageController extends BaseController {
|
||||
|
||||
private final CarMessageCacheService carMessageCacheService;
|
||||
private final CarMessageService sysCarMessageService;
|
||||
public class SysCarMessageController extends BaseController {
|
||||
@Autowired
|
||||
private CarMessageService carMessageService;
|
||||
private SysCarMessageService sysCarMessageService;
|
||||
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
|
@ -39,20 +23,8 @@ public class CarMessageController extends BaseController {
|
|||
*/
|
||||
@PostMapping("selectMessageShow")
|
||||
public List<CarMessage> selectMessageShow(@RequestParam("templateId") Long templateId){
|
||||
startPage();
|
||||
return sysCarMessageService.selectMessageShow(templateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据报文模板id查询报文
|
||||
* @param templateId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/selectByTemplateId")
|
||||
private Result<List<CarMessage>> selectByTemplateId(@RequestParam("templateId") Integer templateId) {
|
||||
return Result.success(sysCarMessageService.list(new LambdaQueryWrapper<CarMessage>().eq(CarMessage::getTemplateId, templateId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询报文信息
|
||||
* @return
|
||||
|
@ -69,8 +41,6 @@ public class CarMessageController extends BaseController {
|
|||
@PostMapping("insertMessage")
|
||||
public Result insertMessage(@RequestBody CarMessage carMessage){
|
||||
sysCarMessageService.save(carMessage);
|
||||
//报文 redis
|
||||
carMessageCacheService.put(carMessage.getMessageType(),new CarMessage());
|
||||
return Result.success("添加成功");
|
||||
}
|
||||
/**
|
|
@ -1,30 +1,23 @@
|
|||
package com.muyu.enterprise.controller;
|
||||
package com.muyu.car.controller;
|
||||
|
||||
import com.muyu.enterprise.domain.CarTemplate;
|
||||
import com.muyu.enterprise.service.CarTemplateService;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarTemplate;
|
||||
import com.muyu.car.service.SysCarMessageService;
|
||||
import com.muyu.car.service.SysCarTemplateService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 报文模版--控制层
|
||||
* @ClassName CarTemplateController
|
||||
* @Description 报文模版 Controller 层
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/carTemplate") // 报文模版
|
||||
/** 构造必备注解 只有用 final 修饰 才会被构造注入 */
|
||||
@RequiredArgsConstructor //制动构造注入 默认无参 Lombook包下
|
||||
@Tag(name = "模版模块",description = "报文模版模块")
|
||||
public class CarTemplateController extends BaseController {
|
||||
|
||||
private final CarTemplateService sysCarTemplateService;
|
||||
@RestController
|
||||
@RequestMapping("/template") // 报文
|
||||
@Tag(name = "模版模块",description = "报文模版模块")
|
||||
public class SysCarTemplateController extends BaseController {
|
||||
@Autowired
|
||||
private SysCarTemplateService sysCarTemplateService;
|
||||
|
||||
/**
|
||||
* 查询所有模版信息
|
||||
|
@ -32,7 +25,6 @@ public class CarTemplateController extends BaseController {
|
|||
*/
|
||||
@PostMapping("selectTemplateShow")
|
||||
public List<CarTemplate> selectTemplateShow(){
|
||||
startPage();
|
||||
return sysCarTemplateService.selectTemplateShow();
|
||||
}
|
||||
/**
|
|
@ -1,35 +1,26 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
package com.muyu.car.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
/**
|
||||
* 企业表--实体类
|
||||
* @ClassName CarCompany
|
||||
* @Description 企业表
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@TableName(value = "car_company")
|
||||
@Tag(name = "企业表")
|
||||
@TableName(value = "t_company")
|
||||
public class CarCompany {
|
||||
/**
|
||||
* 企业表
|
||||
*/
|
||||
@TableId(value = "enterprise_id",type = IdType.AUTO)
|
||||
private Long enterpriseId;
|
||||
@TableId(value = "company_id",type = IdType.AUTO)
|
||||
private Long companyId;
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String companyName;
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.car.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@TableName(value = "t_car_message")
|
||||
public class CarMessage {
|
||||
/**
|
||||
* 报文表
|
||||
*/
|
||||
@TableId(value = "message_id",type = IdType.AUTO)
|
||||
private Long messageId;
|
||||
/**
|
||||
* 车辆报文类别
|
||||
*/
|
||||
private String messageType;
|
||||
/**
|
||||
* 开始位下标
|
||||
*/
|
||||
private Integer messageStartIndex;
|
||||
/**
|
||||
* 结束位下标
|
||||
*/
|
||||
private Integer messageEndIndex;
|
||||
|
||||
/**
|
||||
* 模版id
|
||||
*/
|
||||
private Long templateId;
|
||||
/**
|
||||
* 报文标签
|
||||
*/
|
||||
private String messageLabel;
|
||||
|
||||
}
|
|
@ -1,26 +1,18 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
package com.muyu.car.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
/**
|
||||
* 报文类型表--实体类
|
||||
* @ClassName CarMessageType
|
||||
* @Description 报文类型表
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@TableName(value = "car_message_type")
|
||||
@Tag(name = "报文类型表")
|
||||
@TableName(value = "t_message_type")
|
||||
public class CarMessageType {
|
||||
/**
|
||||
* 报文
|
|
@ -1,26 +1,18 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
package com.muyu.car.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 报文模版表
|
||||
* @Author: chenruijia
|
||||
* @Date 2024/9/28 12.23
|
||||
* @Description CarTemplate:报文模版表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@TableName(value = "car_template")
|
||||
@Tag(name = "报文模版表")
|
||||
@TableName(value = "t_template")
|
||||
public class CarTemplate {
|
||||
|
||||
/**
|
|
@ -1,31 +1,23 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
package com.muyu.car.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
/**
|
||||
* 车辆表--实体类
|
||||
* @ClassName CarManage
|
||||
* @Description 车辆表
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "车辆表")
|
||||
@Builder
|
||||
@TableName(value = "car_manage",autoResultMap = true)
|
||||
public class CarManage {
|
||||
@TableName(value = "t_car")
|
||||
public class SysCar {
|
||||
/**
|
||||
* 车辆表
|
||||
*/
|
||||
|
@ -38,7 +30,7 @@ public class CarManage {
|
|||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
private String carCode;
|
||||
private String carCoed;
|
||||
/**
|
||||
* 车牌颜色 1.白色 2.绿色 3.黑色 4.银色 5.红色
|
||||
*/
|
||||
|
@ -48,13 +40,21 @@ public class CarManage {
|
|||
*/
|
||||
private String carVin;
|
||||
/**
|
||||
* 驾驶员
|
||||
* 车主
|
||||
*/
|
||||
private long userId;
|
||||
private Long userId;
|
||||
/**
|
||||
* 车辆配置
|
||||
*/
|
||||
private long configId;
|
||||
private Long typeId;
|
||||
|
||||
/** 车辆品牌 */
|
||||
@Excel(name = "车辆品牌")
|
||||
private String carBrand;
|
||||
|
||||
/** 车辆型号 */
|
||||
@Excel(name = "车辆型号")
|
||||
private String carModel;
|
||||
/**
|
||||
* 年审日期
|
||||
*/
|
||||
|
@ -83,34 +83,16 @@ public class CarManage {
|
|||
* 当前档位
|
||||
*/
|
||||
private Integer carGears;
|
||||
/**
|
||||
* 车辆品牌
|
||||
*/
|
||||
private String carModel;
|
||||
/**
|
||||
* 车辆型号
|
||||
*/
|
||||
private String carBrand;
|
||||
|
||||
|
||||
/** 最后一次连线时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "最后一次连线时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "最后一次连线时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date carLastJoinTime;
|
||||
|
||||
/** 最后一次离线时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "最后一次离线时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "最后一次离线时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date carLastOfflineTime;
|
||||
|
||||
/**
|
||||
* 汽车所属企业id
|
||||
*/
|
||||
private Long enterpriseId;
|
||||
|
||||
/**
|
||||
* 车辆类型ID
|
||||
*/
|
||||
private Long carTypeId;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.muyu.car.domain.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class CarDTO {
|
||||
|
||||
/**
|
||||
* VIN码
|
||||
*/
|
||||
private String carVin;
|
||||
|
||||
|
||||
/**
|
||||
* 车辆型号
|
||||
*/
|
||||
private String typeName;
|
||||
/**
|
||||
* 能源类型 1.电动 2.纯油 3.混动
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Integer energyType;
|
||||
/**
|
||||
* 档的类型 1.手动 2.自动
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Integer gearType;
|
||||
|
||||
private Integer pageNum = 1;
|
||||
private Integer pageSize = 3;
|
||||
|
||||
/** 最后一次连线时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date carLastJoinTime;
|
||||
|
||||
/** 最后一次离线时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date carLastOfflineTime;
|
||||
/**
|
||||
* 在线状态 1.无信号 2.行驶中 3.已停止
|
||||
*/
|
||||
private Integer carStatus;
|
||||
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String companyName;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.enterprise.domain.vo;
|
||||
package com.muyu.car.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
@ -31,7 +31,7 @@ public class CarVO {
|
|||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
private String carCode;
|
||||
private String carCoed;
|
||||
/**
|
||||
* 车牌颜色 1.白色 2.绿色 3.黑色 4.银色 5.红色
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ public class CarVO {
|
|||
/**
|
||||
* 车辆配置
|
||||
*/
|
||||
private Long configId;
|
||||
private Integer typeId;
|
||||
/**
|
||||
* 年审日期
|
||||
*/
|
||||
|
@ -94,18 +94,16 @@ public class CarVO {
|
|||
|
||||
|
||||
/** 所属企业 */
|
||||
private Long enterpriseId;
|
||||
private Long companyId;
|
||||
|
||||
|
||||
|
||||
// /** 车辆车型(如客车,卡车,公交车等) */
|
||||
// private String carType;
|
||||
/** 车辆车型(如客车,卡车,公交车等) */
|
||||
private String carType;
|
||||
|
||||
/**
|
||||
* 车辆配置
|
||||
* 车辆型号
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String configName;
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 能源类型 1.电动 2.纯油 3.混动
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.car.domain.CarCompany;
|
||||
import com.muyu.car.domain.dto.CarDTO;
|
||||
import com.muyu.car.domain.vo.CarVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author zmw
|
||||
* @description: 配置mybatis配置
|
||||
* @Date 2023-11-13 上午 10:05
|
||||
*/
|
||||
public interface SysCarCompanyMapper extends BaseMapper<CarCompany> {
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.car.domain.SysCar;
|
||||
import com.muyu.car.domain.dto.CarDTO;
|
||||
import com.muyu.car.domain.vo.CarVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author zmw
|
||||
* @description: 配置mybatis配置
|
||||
* @Date 2023-11-13 上午 10:05
|
||||
*/
|
||||
public interface SysCarMapper extends BaseMapper<CarVO> {
|
||||
/**
|
||||
* 车辆列表
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
List<CarVO> carList(LambdaQueryWrapper<CarVO> queryWrapper);
|
||||
|
||||
/**
|
||||
* 车辆列表2
|
||||
* @param carDTO
|
||||
* @return
|
||||
*/
|
||||
List<CarVO> CarListShow(CarDTO carDTO);
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param carId
|
||||
* @return
|
||||
*/
|
||||
List<CarVO> CarListShowByCarId(@Param("carId") Long carId);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysCarMessageMapper extends BaseMapper<CarMessage> {
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @param templateId
|
||||
* @return
|
||||
*/
|
||||
List<CarMessage> selectMessageShow(Long templateId);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarTemplate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysCarTemplateMapper extends BaseMapper<CarTemplate> {
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @return
|
||||
*/
|
||||
List<CarTemplate> selectTemplateShow();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.car.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.car.domain.CarCompany;
|
||||
import com.muyu.car.domain.dto.CarDTO;
|
||||
import com.muyu.car.domain.vo.CarVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zmw
|
||||
* @description: 配置plus业务层
|
||||
* @Date 2023-11-13 上午 10:06
|
||||
*/
|
||||
public interface SysCarCompanyService extends IService<CarCompany> {
|
||||
|
||||
/**
|
||||
* 查询企业表
|
||||
* @return
|
||||
*/
|
||||
//List<CarCompany> selectCompany();
|
||||
|
||||
}
|
|
@ -1,17 +1,11 @@
|
|||
package com.muyu.enterprise.service;
|
||||
package com.muyu.car.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.enterprise.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 车辆报文--业务层
|
||||
* @ClassName CarMessageService
|
||||
* @Description 车辆类型 Service 层
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
public interface CarMessageService extends IService<CarMessage> {
|
||||
|
||||
public interface SysCarMessageService extends IService<CarMessage> {
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @param templateId
|
|
@ -0,0 +1,54 @@
|
|||
package com.muyu.car.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.car.domain.CarCompany;
|
||||
import com.muyu.car.domain.SysCar;
|
||||
import com.muyu.car.domain.dto.CarDTO;
|
||||
import com.muyu.car.domain.vo.CarVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zmw
|
||||
* @description: 配置plus业务层
|
||||
* @Date 2023-11-13 上午 10:06
|
||||
*/
|
||||
public interface SysCarService extends IService<CarVO> {
|
||||
/**
|
||||
* 车辆列表
|
||||
* @param carVO
|
||||
* @return
|
||||
*/
|
||||
List<CarVO> carList(CarVO carVO);
|
||||
|
||||
/**
|
||||
* 车辆添加
|
||||
* @param carVO
|
||||
*/
|
||||
void insertCar(CarVO carVO);
|
||||
|
||||
/**
|
||||
* 车辆删除
|
||||
* @param ids
|
||||
*/
|
||||
void deleteCar(List<Long> ids);
|
||||
|
||||
// /**
|
||||
// * 车辆修改
|
||||
// * @param carVO
|
||||
// */
|
||||
// void updataCar(CarVO carVO);
|
||||
|
||||
/**
|
||||
* 车辆列表2
|
||||
* @param carDTO
|
||||
* @return
|
||||
*/
|
||||
List<CarVO> CarListShow(CarDTO carDTO);
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param carId
|
||||
* @return
|
||||
*/
|
||||
List<CarVO> CarListShowByCarId(Long carId);
|
||||
}
|
|
@ -1,17 +1,12 @@
|
|||
package com.muyu.enterprise.service;
|
||||
package com.muyu.car.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.enterprise.domain.CarTemplate;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarTemplate;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 报文模版--业务层
|
||||
* @ClassName CarTemplateService
|
||||
* @Description 报文模版 Service 层
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
public interface CarTemplateService extends IService<CarTemplate> {
|
||||
|
||||
public interface SysCarTemplateService extends IService<CarTemplate> {
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @return
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.car.domain.CarCompany;
|
||||
import com.muyu.car.mapper.SysCarCompanyMapper;
|
||||
import com.muyu.car.service.SysCarCompanyService;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author zmw
|
||||
* @description: 配置plus业务实现层
|
||||
* @Date 2023-11-13 上午 10:06
|
||||
*/
|
||||
@Service
|
||||
public class SysCarCompanyServiceImpl extends ServiceImpl<SysCarCompanyMapper, CarCompany>
|
||||
implements SysCarCompanyService {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private SysCarCompanyMapper sysCarCompanyMapper;
|
||||
|
||||
|
||||
// @Override
|
||||
// public List<CarCompany> selectCompany() {
|
||||
// return sysCarCompanyMapper.;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.mapper.SysCarMessageMapper;
|
||||
import com.muyu.car.service.SysCarMessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysCarMessageServiceImpl extends ServiceImpl<SysCarMessageMapper, CarMessage> implements SysCarMessageService {
|
||||
|
||||
@Autowired
|
||||
private SysCarMessageMapper sysCarMessageMapper;
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @param templateId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CarMessage> selectMessageShow(Long templateId) {
|
||||
return sysCarMessageMapper.selectMessageShow(templateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询报文信息
|
||||
* @param messageId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CarMessage selectMessageByMessageId(Long messageId) {
|
||||
return sysCarMessageMapper.selectById(messageId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
package com.muyu.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.car.domain.CarCompany;
|
||||
import com.muyu.car.domain.SysCar;
|
||||
import com.muyu.car.domain.dto.CarDTO;
|
||||
import com.muyu.car.domain.vo.CarVO;
|
||||
import com.muyu.car.mapper.SysCarMapper;
|
||||
import com.muyu.car.service.SysCarService;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zmw
|
||||
* @description: 配置plus业务实现层
|
||||
* @Date 2023-11-13 上午 10:06
|
||||
*/
|
||||
@Service
|
||||
public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, CarVO>
|
||||
implements SysCarService {
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private SysCarMapper carMapper;
|
||||
|
||||
/**
|
||||
* 车辆列表
|
||||
* @param carVO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CarVO> carList(CarVO carVO) {
|
||||
|
||||
// MPJLambdaWrapper<CarVO> queryWrapper = new MPJLambdaWrapper<>();
|
||||
// carMapper.selectJoinList(CarVO.class,
|
||||
// queryWrapper.selectAll(CarVO.class)// 主表查询所有
|
||||
// .select(Type::getTypeName)// 获取附表的字段
|
||||
// .select(Type::getEnergyType)
|
||||
// .select(Type::getGearType)
|
||||
// .leftJoin(Type.class,Type::getTypeId,Car::getTypeId)// 左链接
|
||||
// );
|
||||
// // vin码--精确
|
||||
// if(StringUtils.isNotEmpty(carVO.getCarVin())){
|
||||
// queryWrapper.eq(CarVO::getCarVin,carVO.getCarVin());
|
||||
// }
|
||||
// // 车辆型号
|
||||
// if(StringUtils.isNotEmpty(carVO.getTypeName())){
|
||||
// queryWrapper.like(CarVO::getTypeName,carVO.getTypeName());
|
||||
// }
|
||||
// // 能源类型 1.电动 2.纯油 3.混动
|
||||
// if(carVO.getEnergyType()>0){
|
||||
// queryWrapper.eq(CarVO::getEnergyType,carVO.getEnergyType());
|
||||
// }
|
||||
// // 档的类型 1.手动 2.自动
|
||||
// if(carVO.getGearType()>0){
|
||||
// queryWrapper.eq(CarVO::getGearType,carVO.getGearType());
|
||||
// }
|
||||
// // 自定义列表查询
|
||||
//// @Select("")
|
||||
//// this.list(queryWrapper);
|
||||
// // mybatis列表查询
|
||||
// //return carMapper.carList(queryWrapper);
|
||||
// // 单表的列表查询
|
||||
// this.list(
|
||||
// new LambdaQueryWrapper<CarVO>()
|
||||
// .eq(StringUtils.isNotEmpty(carVO.getCarVin()),CarVO::getCarVin,carVO.getCarVin())
|
||||
// .eq(carVO.getEnergyType()>0,CarVO::getEnergyType,carVO.getEnergyType())
|
||||
// .eq(carVO.getGearType()>0,CarVO::getGearType,carVO.getGearType())
|
||||
// .like(StringUtils.isNotEmpty(carVO.getTypeName()),CarVO::getTypeName,carVO.getTypeName())
|
||||
// );
|
||||
// return this.list(queryWrapper);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆添加
|
||||
* @param carVO
|
||||
*/
|
||||
@Override
|
||||
public void insertCar(CarVO carVO) {
|
||||
carMapper.insert(carVO);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 车辆修改
|
||||
// * @param carVO
|
||||
// */
|
||||
// @Override
|
||||
// public void updataCar(CarVO carVO) {
|
||||
// carMapper.updateById(carVO);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 车辆列表2
|
||||
* @param carDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CarVO> CarListShow(CarDTO carDTO) {
|
||||
return carMapper.CarListShow(carDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param carId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CarVO> CarListShowByCarId(Long carId) {
|
||||
return carMapper.CarListShowByCarId(carId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车辆删除
|
||||
* @param ids
|
||||
*/
|
||||
@Override
|
||||
public void deleteCar(List<Long> ids) {
|
||||
carMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +1,29 @@
|
|||
package com.muyu.enterprise.service.impl;
|
||||
package com.muyu.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.enterprise.domain.CarTemplate;
|
||||
import com.muyu.enterprise.mapper.CarTemplateMapper;
|
||||
import com.muyu.enterprise.service.CarTemplateService;
|
||||
import com.muyu.car.domain.CarMessage;
|
||||
import com.muyu.car.domain.CarTemplate;
|
||||
import com.muyu.car.mapper.SysCarMessageMapper;
|
||||
import com.muyu.car.mapper.SysCarTemplateMapper;
|
||||
import com.muyu.car.service.SysCarMessageService;
|
||||
import com.muyu.car.service.SysCarTemplateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 报文模版--业务实现层
|
||||
* @ClassName CarTemplateServiceImpl
|
||||
* @Description 报文模版 ServiceImpl 层
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class CarTemplateServiceImpl extends ServiceImpl<CarTemplateMapper, CarTemplate> implements CarTemplateService {
|
||||
public class SysCarTemplateServiceImpl extends ServiceImpl<SysCarTemplateMapper, CarTemplate> implements SysCarTemplateService {
|
||||
|
||||
@Autowired
|
||||
private CarTemplateMapper sysCarTemplateMapper;
|
||||
private SysCarTemplateMapper sysCarTemplateMapper;
|
||||
/**
|
||||
* 查询所有报文信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CarTemplate> selectTemplateShow() {
|
||||
return list();
|
||||
return sysCarTemplateMapper.selectTemplateShow();
|
||||
}
|
||||
|
||||
/**
|
|
@ -7,12 +7,12 @@ nacos:
|
|||
addr: 106.15.136.7:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: dev
|
||||
namespace: xzr
|
||||
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: cloud-enterprise
|
||||
name: cloud-car
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
|
@ -0,0 +1,78 @@
|
|||
<?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.car.mapper.SysCarMapper">
|
||||
|
||||
<!-- 车辆列表 -->
|
||||
<select id="carList" resultType="com.muyu.car.domain.vo.CarVO">
|
||||
SELECT
|
||||
tc.*,
|
||||
tt.energy_type,
|
||||
tt.gear_type,
|
||||
tt.type_name
|
||||
FROM
|
||||
`t_car` tc
|
||||
LEFT JOIN `t_type` tt ON tc.type_id = tt.type_id
|
||||
<where>
|
||||
<if test="carVin != null and carVin != ''">
|
||||
and tc.car_vin = #{carVin}
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
and tt.type_name like concat('%',#{typeName},'%')
|
||||
</if>
|
||||
<if test="energyType != null and energyType > 0 ">
|
||||
and tt.energy_type = #{energyType}
|
||||
</if>
|
||||
<if test="gearType != null and gearType > 0 ">
|
||||
and tt.gear_type = #{gearType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="CarListShow" resultType="com.muyu.car.domain.vo.CarVO">
|
||||
SELECT
|
||||
tc.*,
|
||||
tt.energy_type,
|
||||
tt.gear_type,
|
||||
tt.type_name
|
||||
FROM
|
||||
`t_car` tc
|
||||
LEFT JOIN `t_type` tt ON tc.type_id = tt.type_id
|
||||
<where>
|
||||
<if test="carVin != null and carVin != ''">
|
||||
and tc.car_vin = #{carVin}
|
||||
</if>
|
||||
<if test="carLastJoinTime != null and carLastJoinTime != ''">
|
||||
and tc.car_last_join_time = #{carLastJoinTime}
|
||||
</if>
|
||||
<if test="carLastOfflineTime != null and carLastOfflineTime != ''">
|
||||
and tc.car_last_offline_time = #{carVin}
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
and tt.type_name like concat('%',#{typeName},'%')
|
||||
</if>
|
||||
<if test="energyType != null and energyType > 0 ">
|
||||
and tt.energy_type = #{energyType}
|
||||
</if>
|
||||
<if test="gearType != null and gearType > 0 ">
|
||||
and tt.gear_type = #{gearType}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 通过id查询 -->
|
||||
<select id="CarListShowByCarId" resultType="com.muyu.car.domain.vo.CarVO">
|
||||
SELECT
|
||||
tc.*,
|
||||
tt.energy_type,
|
||||
tt.gear_type,
|
||||
tt.type_name
|
||||
FROM
|
||||
`t_car` tc
|
||||
LEFT JOIN `t_type` tt ON tc.type_id = tt.type_id
|
||||
where tc.car_id = #{carId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,20 @@
|
|||
<?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.car.mapper.SysCarMessageMapper">
|
||||
|
||||
<!-- 查询所有报文信息 -->
|
||||
|
||||
|
||||
<!-- 查询所有报文信息 -->
|
||||
<select id="selectMessageShow" resultType="com.muyu.car.domain.CarMessage">
|
||||
SELECT
|
||||
tcm.*
|
||||
FROM
|
||||
`t_car_message` tcm
|
||||
WHERE
|
||||
tcm.template_id = #{templateId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,13 @@
|
|||
<?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.car.mapper.SysCarTemplateMapper">
|
||||
|
||||
<!-- 查询所有报文信息 -->
|
||||
|
||||
|
||||
<select id="selectTemplateShow" resultType="com.muyu.car.domain.CarTemplate">
|
||||
select * from `t_template`
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<description>
|
||||
cloud-modules-enterprise-cache redis 缓存平台
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-cache</artifactId>
|
||||
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
|
@ -1,29 +0,0 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.config.CacheAbsBasic;
|
||||
import com.muyu.enterprise.domain.CarCompany;
|
||||
import com.muyu.enterprise.domain.CarManage;
|
||||
|
||||
/**
|
||||
* redis企业业务层
|
||||
* @ClassName CarCompanyCacheService
|
||||
* @Description CarCompanyCacheService:类的描述
|
||||
* @Date 2024/10/3 15:22
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
|
||||
public class CarCompanyCacheService extends CacheAbsBasic<String, CarCompany> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarCompany:info:";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("CarCompany:info:","");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.config.CacheAbsBasic;
|
||||
import com.muyu.enterprise.domain.CarFaultRule;
|
||||
|
||||
/**
|
||||
* redis故障业务层
|
||||
* @ClassName CarFaultCacheService
|
||||
* @Description CarFaultCacheService:类的描述
|
||||
* @Date 2024/10/3 15:22
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
public class CarFaultCacheService extends CacheAbsBasic<String, CarFaultRule> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "carFaultRule:info:";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("carFaultRule:info:","");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.config.CacheAbsBasic;
|
||||
import com.muyu.enterprise.domain.CarManage;
|
||||
|
||||
/**
|
||||
* redis报文业务层
|
||||
* @ClassName CarManageCacheService
|
||||
* @Description CarManageCacheService:类的描述
|
||||
* @Date 2024/10/3 15:22
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
|
||||
public class CarManageCacheService extends CacheAbsBasic<String, CarManage> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarManage:info:";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("CarManage:info:","");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.config.CacheAbsBasic;
|
||||
import com.muyu.enterprise.domain.CarMessage;
|
||||
|
||||
/**
|
||||
* redis车辆管理业务层
|
||||
* @ClassName CarMessageCacheService
|
||||
* @Description CarMessageCacheService:类的描述
|
||||
* @Date 2024/9/30 11:42
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
public class CarMessageCacheService extends CacheAbsBasic<String, CarMessage> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "carMessage:info:";
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String encode(String key) {
|
||||
// return super.encode(key);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("carMessage:info:","");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.config.CacheAbsBasic;
|
||||
import com.muyu.enterprise.domain.CarCompany;
|
||||
import com.muyu.enterprise.domain.CarTemplate;
|
||||
|
||||
/**
|
||||
* redis报文模版业务层
|
||||
* @ClassName CarTemplateCacheService
|
||||
* @Description CarTemplateCacheService:类的描述
|
||||
* @Date 2024/10/3 15:22
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
|
||||
public class CarTemplateCacheService extends CacheAbsBasic<String, CarTemplate> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "carTemplate:info:";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("carTemplate:info:","");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.config.CacheAbsBasic;
|
||||
import com.muyu.enterprise.domain.CarCompany;
|
||||
import com.muyu.enterprise.domain.WarnRule;
|
||||
|
||||
/**
|
||||
* redis车辆预警业务层
|
||||
* @ClassName CarWarnCacheService
|
||||
* @Description CarWarnCacheService:类的描述
|
||||
* @Date 2024/10/3 15:22
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
|
||||
public class CarWarnCacheService extends CacheAbsBasic<String, WarnRule> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "warnRule:info:";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("warnRule:info:","");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.muyu.enterprise.cache;
|
||||
|
||||
import com.muyu.common.cache.config.CacheAbsBasic;
|
||||
import com.muyu.enterprise.domain.CarCompany;
|
||||
import com.muyu.enterprise.domain.dateBase.ElectronicFence;
|
||||
|
||||
/**
|
||||
* redis电子围栏业务层
|
||||
* @ClassName ElectronicFenceCacheService
|
||||
* @Description ElectronicFenceCacheService:类的描述
|
||||
* @Date 2024/10/3 15:22
|
||||
* @author MingWei.Zong
|
||||
*/
|
||||
|
||||
public class ElectronicFenceCacheService extends CacheAbsBasic<String, ElectronicFence> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "electronicFence:info:";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("electronicFence:info:","");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
com.muyu.enterprise.cache.CarCompanyCacheService
|
||||
com.muyu.enterprise.cache.CarFaultCacheService
|
||||
com.muyu.enterprise.cache.CarManageCacheService
|
||||
com.muyu.enterprise.cache.CarMessageCacheService
|
||||
com.muyu.enterprise.cache.CarTemplateCacheService
|
||||
com.muyu.enterprise.cache.CarWarnCacheService
|
||||
com.muyu.enterprise.cache.ElectronicFenceCacheService
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-modules-enterprise-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 公共依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--swagger3依赖-->
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,45 +0,0 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 车辆配置表--实体类
|
||||
* @ClassName CarConfig
|
||||
* @Description 车辆配置表
|
||||
* @author MingWei.Zong
|
||||
* @Date 2024/9/28 16:52
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Tag(name = "车辆配置表")
|
||||
@TableName(value = "car_config")
|
||||
public class CarConfig {
|
||||
/**
|
||||
* 车辆配置类
|
||||
*/
|
||||
@TableId(value = "config_id",type = IdType.AUTO)
|
||||
private Long configId;
|
||||
/**
|
||||
* 车辆配置
|
||||
*/
|
||||
private String configName;
|
||||
/**
|
||||
* 能源类型 1.电动 2.纯油 3.混动
|
||||
*/
|
||||
private Integer energyType;
|
||||
/**
|
||||
* 档的类型 1.手动 2.自动
|
||||
*/
|
||||
private Integer gearType;
|
||||
|
||||
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
/**
|
||||
*
|
||||
* 故障规则测试类(故障)
|
||||
* @Author:chenruijia
|
||||
* @Package:com.muyu.cloud.faultmanage.domain.faultrule
|
||||
* @Project:cloud-server
|
||||
* @name:PureElectricCar
|
||||
* @Date:2024/9/20 20:22
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@Tag(name = "故障规则测试类")
|
||||
public class CarFaultRule {
|
||||
/**
|
||||
* VIN码
|
||||
*/
|
||||
private String vin;
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private long timestamp;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private double longitude;
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private double latitude;
|
||||
/**
|
||||
* 车速
|
||||
*/
|
||||
private double speed;
|
||||
/**
|
||||
* 总里程
|
||||
*/
|
||||
private long TM;
|
||||
/**
|
||||
* 总电压
|
||||
*/
|
||||
private double TV;
|
||||
/**
|
||||
* 总电流
|
||||
*/
|
||||
private double CC;
|
||||
/**
|
||||
* 绝缘电阻
|
||||
*/
|
||||
private double IR;
|
||||
/**
|
||||
* 档位
|
||||
*/
|
||||
private String GP;
|
||||
/**
|
||||
* 加速踏板行程值
|
||||
*/
|
||||
private double APTV;
|
||||
/**
|
||||
* 制动踏板行程值
|
||||
*/
|
||||
private double BPTV;
|
||||
/**
|
||||
* 燃料消耗率
|
||||
*/
|
||||
private double SFC;
|
||||
/**
|
||||
* 电机控制器温度
|
||||
*/
|
||||
private double MCT;
|
||||
/**
|
||||
* 电机转速
|
||||
*/
|
||||
private int MS;
|
||||
/**
|
||||
* 电机转矩
|
||||
*/
|
||||
private double MTO;
|
||||
/**
|
||||
* 电机温度
|
||||
*/
|
||||
private double MTE;
|
||||
/**
|
||||
* 电机电压
|
||||
*/
|
||||
private double MV;
|
||||
/**
|
||||
* 电机电流
|
||||
*/
|
||||
private double MC;
|
||||
/**
|
||||
* 动力电池剩余电量SOC
|
||||
*/
|
||||
private double PBRSOC;
|
||||
/**
|
||||
* 当前状态允许的最大反馈功率
|
||||
*/
|
||||
private double MACSFP;
|
||||
/**
|
||||
* 当前状态允许最大放电功率
|
||||
*/
|
||||
private double CSATMDP;
|
||||
/**
|
||||
* BMS自检计数器
|
||||
*/
|
||||
private int BMS;
|
||||
/**
|
||||
* 动力电池充放电电流
|
||||
*/
|
||||
private double CADC;
|
||||
/**
|
||||
* 动力电池负载端总电压V3
|
||||
*/
|
||||
private double PBLETVV3;
|
||||
/**
|
||||
* 单次最大电压
|
||||
*/
|
||||
private double SMV;
|
||||
/**
|
||||
* 单体电池最低电压
|
||||
*/
|
||||
private double MVOAB;
|
||||
/**
|
||||
* 单体电池最高温度
|
||||
*/
|
||||
private double MAXBT;
|
||||
/**
|
||||
* 单体电池最低温度
|
||||
*/
|
||||
private double MINBT;
|
||||
/**
|
||||
* 动力电池可用容量
|
||||
*/
|
||||
private double PBAC;
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
private String VS;
|
||||
/**
|
||||
* 充电状态
|
||||
*/
|
||||
private String CS;
|
||||
/**
|
||||
* 运行状态
|
||||
*/
|
||||
private String RS;
|
||||
/**
|
||||
* SOC
|
||||
*/
|
||||
private double SOC;
|
||||
/**
|
||||
* 可充电储能装置工作状态
|
||||
*/
|
||||
private String RESDWC;
|
||||
/**
|
||||
* EAS
|
||||
*/
|
||||
private String EAS;
|
||||
/**
|
||||
* PTC
|
||||
*/
|
||||
private String PTC;
|
||||
/**
|
||||
* EPS
|
||||
*/
|
||||
private String EPS;
|
||||
/**
|
||||
* ABS
|
||||
*/
|
||||
private String ABS;
|
||||
/**
|
||||
* MCU
|
||||
*/
|
||||
private String MCU;
|
||||
/**
|
||||
* 动力电池加热状态
|
||||
*/
|
||||
private String PBHS;
|
||||
/**
|
||||
* 动力电池当前状态
|
||||
*/
|
||||
private String PBCS;
|
||||
/**
|
||||
* 动力电池保温状态
|
||||
*/
|
||||
private String PBIS;
|
||||
/**
|
||||
* DCDC
|
||||
*/
|
||||
private String DCDC;
|
||||
/**
|
||||
* CHG
|
||||
*/
|
||||
private String CHG;
|
||||
/**
|
||||
* 校验位
|
||||
*/
|
||||
private byte CHB;
|
||||
/**
|
||||
* 截止位
|
||||
*/
|
||||
private byte CUB;
|
||||
/**
|
||||
* 起始位
|
||||
*/
|
||||
private byte SOH;
|
||||
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 故障查询信息结果返回对象
|
||||
* @Author:chenruijia
|
||||
* @Package:com.muyu.cloud.faultmanage.domain
|
||||
* @Project:cloud-server
|
||||
* @name:Vehicle
|
||||
* @Date:2024/9/20 20:44
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@Tag(name = "故障查询信息结果返回对象")
|
||||
public class Cheak {
|
||||
/**
|
||||
* 车辆VIN 唯一标识
|
||||
*/
|
||||
private String VIN;
|
||||
/**
|
||||
* 故障信息
|
||||
*/
|
||||
private String faultmessage;
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.enterprise.domain.req.FaultConditionAddReq;
|
||||
import com.muyu.enterprise.domain.req.FaultConditionUpdReq;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 故障规则
|
||||
* @Author:chenruijia
|
||||
* @Package:com.muyu.cloud.faultmanage.domain
|
||||
* @Project:cloud-server
|
||||
* @name:FaultCondition
|
||||
* @Date:2024/9/21 19:51
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@TableName(value = "fault_condition",autoResultMap = true)
|
||||
@Tag(name = "故障规则")
|
||||
public class FaultCondition {
|
||||
/**
|
||||
* 故障规则表Id
|
||||
*/
|
||||
@TableId(value = "fault_condition_id",type = IdType.AUTO)
|
||||
private long faultConditionId;
|
||||
/**
|
||||
* 车辆类型Id
|
||||
*/
|
||||
private long carTypeId;
|
||||
/**
|
||||
*故障名称Id
|
||||
*/
|
||||
private long messageId;
|
||||
/**
|
||||
* 故障条件
|
||||
*/
|
||||
private String faultConditionIdentification;
|
||||
/**
|
||||
* 故障规则参数
|
||||
*/
|
||||
private BigDecimal faultConditionParameter;
|
||||
|
||||
|
||||
public static FaultCondition faultConditionadd(FaultConditionAddReq faultConditionAddReq){
|
||||
return FaultCondition.builder()
|
||||
.carTypeId(faultConditionAddReq.getCarTypeId())
|
||||
.messageId(faultConditionAddReq.getMessageId())
|
||||
.faultConditionIdentification(faultConditionAddReq.getFaultConditionIdentification())
|
||||
.faultConditionParameter(faultConditionAddReq.getFaultConditionParameter())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static FaultCondition faultConditionupd(FaultConditionUpdReq faultConditionUpdReq, Supplier<Long> idSupplier){
|
||||
return FaultCondition.builder()
|
||||
.faultConditionId(faultConditionUpdReq.getFaultConditionId())
|
||||
.carTypeId(faultConditionUpdReq.getCarTypeId())
|
||||
.messageId(faultConditionUpdReq.getMessageId())
|
||||
.faultConditionIdentification(faultConditionUpdReq.getFaultConditionIdentification())
|
||||
.faultConditionParameter(faultConditionUpdReq.getFaultConditionParameter())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 故障标签
|
||||
* @Author:chenruijia
|
||||
* @Package:com.muyu.cloud.faultmanage.domain
|
||||
* @Project:cloud-faultmanage
|
||||
* @name:FaultLabel
|
||||
* @Date:2024/9/17 15:06
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@TableName(value = "car_message_type",autoResultMap = true)
|
||||
@Tag(name = "故障标签")
|
||||
public class FaultLabel {
|
||||
/**
|
||||
*自增主键
|
||||
*/
|
||||
@TableId(value = "message_type_id",type = IdType.AUTO)
|
||||
private long messageTypeId;
|
||||
/**
|
||||
*报文编码
|
||||
*/
|
||||
@TableField(value = "message_code")
|
||||
private String messageTypeCode;
|
||||
/**
|
||||
*报文名称
|
||||
*/
|
||||
@TableField(value = "message_name")
|
||||
private String messageTypeName;
|
||||
/**
|
||||
*报文所属类别
|
||||
*/
|
||||
@TableField(value = "message_type")
|
||||
private String messageTypeBelongs;
|
||||
|
||||
private String messageClass;
|
||||
|
||||
|
||||
public static FaultLabel addfaultLabel(FaultLabel faultLabel){
|
||||
return FaultLabel.builder()
|
||||
.messageTypeId(0)
|
||||
.messageTypeId(faultLabel.getMessageTypeId())
|
||||
.messageTypeCode(faultLabel.getMessageTypeCode())
|
||||
.messageTypeName(faultLabel.getMessageTypeName())
|
||||
.messageTypeBelongs(faultLabel.getMessageTypeBelongs())
|
||||
.messageClass(faultLabel.getMessageClass())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
public static FaultLabel selectFaultLabel(FaultLabel faultLabel) {
|
||||
return FaultLabel.builder()
|
||||
.messageTypeId(faultLabel.messageTypeId)
|
||||
.messageTypeCode(faultLabel.messageTypeCode)
|
||||
.messageTypeName(faultLabel.messageTypeName)
|
||||
.messageTypeBelongs(faultLabel.messageTypeBelongs)
|
||||
.messageClass(faultLabel.messageClass)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
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.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
/**
|
||||
* 故障日志
|
||||
* @Author: chenruijia
|
||||
* @Date 2024/9/28 12.23
|
||||
* @Description FaultLog:故障日志
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "fault_log",autoResultMap = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Tag(name = "故障日志")
|
||||
public class FaultLog extends BaseEntity {
|
||||
/**
|
||||
* 日志ID
|
||||
*/
|
||||
@TableId(value = "fault_log_id", type= IdType.AUTO)
|
||||
@Schema(defaultValue = "日志ID",type = "Long",description = "日志ID")
|
||||
private Long faultLogId;
|
||||
/**
|
||||
* 故障码
|
||||
*/
|
||||
@Schema(defaultValue = "故障码",type = "String",description = "故障码")
|
||||
private String faultLogCodes;
|
||||
/**
|
||||
* 车辆VIN
|
||||
*/
|
||||
@Schema(defaultValue = "车辆VIN",type = "String",description = "车辆VIN")
|
||||
private String faultLogVin;
|
||||
/**
|
||||
* 开始报警时间
|
||||
*/
|
||||
@Schema(defaultValue = "开始报警时间",type = "Date",description = "开始报警时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date faultLogStartTime;
|
||||
/**
|
||||
* 结束报警时间
|
||||
*/
|
||||
@Schema(defaultValue = "结束报警时间",type = "Date",description = "结束报警时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date faultLogEndTime;
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package com.muyu.enterprise.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 站内信
|
||||
* @Author: chenruijia
|
||||
* @Date 2024/9/28 12.23
|
||||
* @Description FaultMessage:站内信
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "fault_message",autoResultMap = true)
|
||||
@Tag(name = "站内信")
|
||||
public class FaultMessage {
|
||||
/**
|
||||
* 站内信ID
|
||||
*/
|
||||
@TableId(value = "fault_message_id", type= IdType.AUTO)
|
||||
@Schema(defaultValue = "站内信ID",type = "Long",description = "站内信ID")
|
||||
private Long faultMessageId;
|
||||
/**
|
||||
* 消息发送人
|
||||
*/
|
||||
@Schema(defaultValue = "消息发送人",type = "String",description = "消息发送人")
|
||||
private String faultMessageSendName;
|
||||
/**
|
||||
* 消息接收人
|
||||
*/
|
||||
@Schema(defaultValue = "消息接收人",type = "String",description = "消息发送人")
|
||||
private String faultMessageRemoveName;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
@Schema(defaultValue = "消息内容",type = "String",description = "消息内容")
|
||||
private String faultMessageContent;
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@Schema(defaultValue = "发送时间",type = "Date",description = "发送时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date faultMessageSendTime;
|
||||
/**
|
||||
* 消息状态(1:未读,2:已读)
|
||||
*/
|
||||
@Schema(defaultValue = "消息状态",type = "Integer",description = "消息状态(1:未读,2:已读)")
|
||||
private Integer faultMessageState;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package com.muyu.enterprise.domain.car;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.enterprise.domain.req.car.MessageTemplateAddReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 报文模版实体类
|
||||
* @Author:李庆帅
|
||||
* @Package:com.muyu.car.domain
|
||||
* @Project:cloud-server
|
||||
* @name:MessageTemplate
|
||||
* @Date:2024/9/26 20:27
|
||||
* @Description: 报文模版
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "message_template", autoResultMap = true)
|
||||
public class MessageTemplate extends BaseEntity
|
||||
{
|
||||
/**
|
||||
* 报文模版主键
|
||||
*/
|
||||
@TableId(value = "message_template_id", type = IdType.AUTO)
|
||||
private String messageTemplateId;
|
||||
|
||||
/**
|
||||
* 报文模版名称
|
||||
*/
|
||||
private String messageTemplateName;
|
||||
|
||||
/**
|
||||
* 报文模版描述
|
||||
*/
|
||||
private String messageTemplateDescribe;
|
||||
|
||||
/**
|
||||
* 报文模版添加数据转换
|
||||
* @param messageTemplateAddReq
|
||||
* @return
|
||||
*/
|
||||
public static MessageTemplate addBuild(MessageTemplateAddReq messageTemplateAddReq){
|
||||
return MessageTemplate.builder()
|
||||
.messageTemplateName(messageTemplateAddReq.getMessageTemplateName())
|
||||
.messageTemplateDescribe(messageTemplateAddReq.getMessageTemplateDescribe())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
package com.muyu.enterprise.domain.car;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.enterprise.domain.req.car.MessageValueAddReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Author:李庆帅
|
||||
* @Package:com.muyu.car.domain
|
||||
* @Project:cloud-server
|
||||
* @name:MessageValue
|
||||
* @Date:2024/9/26 20:29
|
||||
*
|
||||
* 报文类型对象 message_type
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 报文类型实体类
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "message_value", autoResultMap = true)
|
||||
public class MessageValue extends BaseEntity
|
||||
{
|
||||
/**
|
||||
* 报文数据主键
|
||||
*/
|
||||
@TableId(value = "message_id", type = IdType.AUTO)
|
||||
private Long messageId;
|
||||
|
||||
/**
|
||||
* 模版主键
|
||||
*/
|
||||
private Long templateId;
|
||||
|
||||
/**
|
||||
* 报文类别
|
||||
*/
|
||||
private String messageType;
|
||||
|
||||
/**
|
||||
* 报文编码
|
||||
*/
|
||||
private String messageCode;
|
||||
|
||||
/**
|
||||
* 报文标签
|
||||
*/
|
||||
private String messageLabel;
|
||||
|
||||
/**
|
||||
* 起始下标
|
||||
*/
|
||||
private Integer messageStartIndex;
|
||||
|
||||
/**
|
||||
* 终止下标
|
||||
*/
|
||||
private Integer messageEndIndex;
|
||||
|
||||
public static MessageValue addBuild(MessageValueAddReq messageValueAddReq){
|
||||
return MessageValue.builder()
|
||||
.templateId(messageValueAddReq.getTemplateId())
|
||||
.messageType(messageValueAddReq.getMessageType())
|
||||
.messageCode(messageValueAddReq.getMessageCode())
|
||||
.messageLabel(messageValueAddReq.getMessageLabel())
|
||||
.messageStartIndex(messageValueAddReq.getMessageStartIndex())
|
||||
.messageEndIndex(messageValueAddReq.getMessageEndIndex())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue