Compare commits
12 Commits
be2fc79d49
...
c9ec3f3b01
Author | SHA1 | Date |
---|---|---|
|
c9ec3f3b01 | |
|
dd30d17c40 | |
|
68f94b0f26 | |
|
c470ef9787 | |
|
50a58d2470 | |
|
17c891ff02 | |
|
934367b1ea | |
|
b5757fdead | |
|
7c49fee992 | |
|
0b97b1e2ed | |
|
d81b53910e | |
|
6a55491e45 |
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 106.15.136.7:8848
|
addr: 106.15.136.7:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: crj
|
namespace: xzr
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
|
|
@ -21,132 +21,132 @@ public @interface Excel {
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中排序
|
* 导出时在excel中排序
|
||||||
*/
|
*/
|
||||||
public int sort () default Integer.MAX_VALUE;
|
public int sort() default Integer.MAX_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出到Excel中的名字.
|
* 导出到Excel中的名字.
|
||||||
*/
|
*/
|
||||||
public String name () default "";
|
public String name() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式, 如: yyyy-MM-dd
|
* 日期格式, 如: yyyy-MM-dd
|
||||||
*/
|
*/
|
||||||
public String dateFormat () default "";
|
public String dateFormat() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||||
*/
|
*/
|
||||||
public String readConverterExp () default "";
|
public String readConverterExp() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分隔符,读取字符串组内容
|
* 分隔符,读取字符串组内容
|
||||||
*/
|
*/
|
||||||
public String separator () default ",";
|
public String separator() default ",";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||||
*/
|
*/
|
||||||
public int scale () default -1;
|
public int scale() default -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||||
*/
|
*/
|
||||||
public int roundingMode () default BigDecimal.ROUND_HALF_EVEN;
|
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的高度
|
* 导出时在excel中每个列的高度
|
||||||
*/
|
*/
|
||||||
public double height () default 14;
|
public double height() default 14;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的宽度
|
* 导出时在excel中每个列的宽度
|
||||||
*/
|
*/
|
||||||
public double width () default 16;
|
public double width() default 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文字后缀,如% 90 变成90%
|
* 文字后缀,如% 90 变成90%
|
||||||
*/
|
*/
|
||||||
public String suffix () default "";
|
public String suffix() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当值为空时,字段的默认值
|
* 当值为空时,字段的默认值
|
||||||
*/
|
*/
|
||||||
public String defaultValue () default "";
|
public String defaultValue() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提示信息
|
* 提示信息
|
||||||
*/
|
*/
|
||||||
public String prompt () default "";
|
public String prompt() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置只能选择不能输入的列内容.
|
* 设置只能选择不能输入的列内容.
|
||||||
*/
|
*/
|
||||||
public String[] combo () default {};
|
public String[] combo() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
||||||
*/
|
*/
|
||||||
public boolean needMerge () default false;
|
public boolean needMerge() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||||
*/
|
*/
|
||||||
public boolean isExport () default true;
|
public boolean isExport() default true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
||||||
*/
|
*/
|
||||||
public String targetAttr () default "";
|
public String targetAttr() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否自动统计数据,在最后追加一行统计数据总和
|
* 是否自动统计数据,在最后追加一行统计数据总和
|
||||||
*/
|
*/
|
||||||
public boolean isStatistics () default false;
|
public boolean isStatistics() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出类型(0数字 1字符串)
|
* 导出类型(0数字 1字符串)
|
||||||
*/
|
*/
|
||||||
public ColumnType cellType () default ColumnType.STRING;
|
public ColumnType cellType() default ColumnType.STRING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出列头背景颜色
|
* 导出列头背景颜色
|
||||||
*/
|
*/
|
||||||
public IndexedColors headerBackgroundColor () default IndexedColors.GREY_50_PERCENT;
|
public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出列头字体颜色
|
* 导出列头字体颜色
|
||||||
*/
|
*/
|
||||||
public IndexedColors headerColor () default IndexedColors.WHITE;
|
public IndexedColors headerColor() default IndexedColors.WHITE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出单元格背景颜色
|
* 导出单元格背景颜色
|
||||||
*/
|
*/
|
||||||
public IndexedColors backgroundColor () default IndexedColors.WHITE;
|
public IndexedColors backgroundColor() default IndexedColors.WHITE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出单元格字体颜色
|
* 导出单元格字体颜色
|
||||||
*/
|
*/
|
||||||
public IndexedColors color () default IndexedColors.BLACK;
|
public IndexedColors color() default IndexedColors.BLACK;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出字段对齐方式
|
* 导出字段对齐方式
|
||||||
*/
|
*/
|
||||||
public HorizontalAlignment align () default HorizontalAlignment.CENTER;
|
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义数据处理器
|
* 自定义数据处理器
|
||||||
*/
|
*/
|
||||||
public Class<?> handler () default ExcelHandlerAdapter.class;
|
public Class<?> handler() default ExcelHandlerAdapter.class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义数据处理器参数
|
* 自定义数据处理器参数
|
||||||
*/
|
*/
|
||||||
public String[] args () default {};
|
public String[] args() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||||
*/
|
*/
|
||||||
Type type () default Type.ALL;
|
Type type() default Type.ALL;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
ALL(0), EXPORT(1), IMPORT(2);
|
ALL(0), EXPORT(1), IMPORT(2);
|
||||||
|
|
|
@ -13,5 +13,5 @@ import java.lang.annotation.Target;
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface Excels {
|
public @interface Excels {
|
||||||
Excel[] value ();
|
Excel[] value();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,4 +45,9 @@ public class SecurityConstants {
|
||||||
* 角色权限
|
* 角色权限
|
||||||
*/
|
*/
|
||||||
public static final String ROLE_PERMISSION = "role_permission";
|
public static final String ROLE_PERMISSION = "role_permission";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SaaS标识
|
||||||
|
*/
|
||||||
|
public static final String SAAS_KEY = "ent-code";
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,4 +162,13 @@ public class JwtUtils {
|
||||||
public static String getValue (Claims claims, String key) {
|
public static String getValue (Claims claims, String key) {
|
||||||
return Convert.toStr(claims.get(key), "");
|
return Convert.toStr(claims.get(key), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据身份信息获取SaaS标识
|
||||||
|
* @param claims 身份信息
|
||||||
|
* @return Saas标识
|
||||||
|
*/
|
||||||
|
public static String getSaaSKey (Claims claims) {
|
||||||
|
return getValue(claims, SecurityConstants.SAAS_KEY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return Object 一个以所给名字注册的bean的实例
|
* @return Object 一个以所给名字注册的bean的实例
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.BeansException
|
* @throws BeansException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T getBean (String name) throws BeansException {
|
public static <T> T getBean (String name) throws BeansException {
|
||||||
|
@ -40,7 +40,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.BeansException
|
* @throws BeansException
|
||||||
*/
|
*/
|
||||||
public static <T> T getBean (Class<T> clz) throws BeansException {
|
public static <T> T getBean (Class<T> clz) throws BeansException {
|
||||||
T result = (T) beanFactory.getBean(clz);
|
T result = (T) beanFactory.getBean(clz);
|
||||||
|
@ -65,7 +65,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
* @throws NoSuchBeanDefinitionException
|
||||||
*/
|
*/
|
||||||
public static boolean isSingleton (String name) throws NoSuchBeanDefinitionException {
|
public static boolean isSingleton (String name) throws NoSuchBeanDefinitionException {
|
||||||
return beanFactory.isSingleton(name);
|
return beanFactory.isSingleton(name);
|
||||||
|
@ -76,7 +76,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return Class 注册对象的类型
|
* @return Class 注册对象的类型
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
* @throws NoSuchBeanDefinitionException
|
||||||
*/
|
*/
|
||||||
public static Class<?> getType (String name) throws NoSuchBeanDefinitionException {
|
public static Class<?> getType (String name) throws NoSuchBeanDefinitionException {
|
||||||
return beanFactory.getType(name);
|
return beanFactory.getType(name);
|
||||||
|
@ -89,7 +89,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*
|
*
|
||||||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
|
* @throws NoSuchBeanDefinitionException
|
||||||
*/
|
*/
|
||||||
public static String[] getAliases (String name) throws NoSuchBeanDefinitionException {
|
public static String[] getAliases (String name) throws NoSuchBeanDefinitionException {
|
||||||
return beanFactory.getAliases(name);
|
return beanFactory.getAliases(name);
|
||||||
|
|
|
@ -17,11 +17,11 @@ import java.lang.annotation.Target;
|
||||||
@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
|
@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
|
||||||
@Constraint(validatedBy = {XssValidator.class})
|
@Constraint(validatedBy = {XssValidator.class})
|
||||||
public @interface Xss {
|
public @interface Xss {
|
||||||
String message ()
|
String message()
|
||||||
|
|
||||||
default "不允许任何脚本运行";
|
default "不允许任何脚本运行";
|
||||||
|
|
||||||
Class<?>[] groups () default {};
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
Class<? extends Payload>[] payload () default {};
|
Class<? extends Payload>[] payload() default {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?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>
|
|
@ -0,0 +1,28 @@
|
||||||
|
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 "";
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
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, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
com.muyu.common.datascope.aspect.DataScopeAspect
|
|
@ -11,11 +11,10 @@ import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
||||||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.SpringUtils;
|
import com.muyu.common.core.utils.SpringUtils;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
|
||||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
@ -78,7 +77,7 @@ public class ManyDataSource implements ApplicationRunner {
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
}else {
|
}else {
|
||||||
log.error("远调数据源错误,远调数据为:{}", JSON.toJSONString(data));
|
log.error("远调数据源异常,异常信息:{}", JSON.toJSONString(entListResult.getMsg()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,29 +90,21 @@ public class ManyDataSource implements ApplicationRunner {
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
||||||
List<DataSourceInfo> sourceInfoList = dataSourceInfoList().stream()
|
List<EntInfo> entInfoList = dataSourceInfoList();
|
||||||
|
if(StringUtils.isEmpty(entInfoList)){
|
||||||
|
throw new SaaSException("数据源信息列表为空或为null");
|
||||||
|
}
|
||||||
|
Map<Object, Object> dataSourceMap = dataSourceInfoList().stream()
|
||||||
.map(entInfo -> DataSourceInfo.hostAndPortBuild(
|
.map(entInfo -> DataSourceInfo.hostAndPortBuild(
|
||||||
entInfo.getEntCode(),
|
entInfo.getEntCode(),
|
||||||
entInfo.getIp(),
|
entInfo.getIp(),
|
||||||
entInfo.getPort()
|
entInfo.getPort()
|
||||||
)
|
)
|
||||||
).toList();
|
)
|
||||||
|
.collect(Collectors.toMap(
|
||||||
Map<Object, Object> dataSourceMap = sourceInfoList.stream().collect(Collectors.toMap(
|
dataSourceInfo -> dataSourceInfo.getKey(),
|
||||||
dataSourceInfo -> dataSourceInfo.getKey(),
|
dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo)
|
||||||
dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo)
|
));
|
||||||
));
|
|
||||||
// Map<Object, Object> dataSourceMap = dataSourceInfoList().stream()
|
|
||||||
// .map(entInfo -> DataSourceInfo.hostAndPortBuild(
|
|
||||||
// entInfo.getEntCode(),
|
|
||||||
// entInfo.getIp(),
|
|
||||||
// entInfo.getPort()
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// .collect(Collectors.toMap(
|
|
||||||
// dataSourceInfo -> dataSourceInfo.getKey(),
|
|
||||||
// dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo)
|
|
||||||
// ));
|
|
||||||
|
|
||||||
//设置动态数据源
|
//设置动态数据源
|
||||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||||
|
@ -121,19 +112,4 @@ public class ManyDataSource implements ApplicationRunner {
|
||||||
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||||
return dynamicDataSource;
|
return dynamicDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建 SqlSessionFactory Bean,用于 MyBatis 数据库操作。
|
|
||||||
* 该方法接收动态数据源并配置 SqlSessionFactory,返回
|
|
||||||
* 用于与数据库交互的 SqlSessionFactory 实例。
|
|
||||||
* @param dataSource 动态数据源
|
|
||||||
* @return 配置好的 SqlSessionFactory 实例
|
|
||||||
* @throws Exception 可能抛出的异常
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public SqlSessionFactory sqlSessionFactory(DynamicDataSource dataSource) throws Exception {
|
|
||||||
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
|
||||||
sessionFactory.setDataSource(dataSource);
|
|
||||||
return sessionFactory.getObject();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class TokenService {
|
||||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||||
|
claimsMap.put(SecurityConstants.SAAS_KEY, loginUser.getSysUser().getDatabaseName());
|
||||||
|
|
||||||
// 接口返回信息
|
// 接口返回信息
|
||||||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<module>cloud-common-log</module>
|
<module>cloud-common-log</module>
|
||||||
<module>cloud-common-core</module>
|
<module>cloud-common-core</module>
|
||||||
<module>cloud-common-redis</module>
|
<module>cloud-common-redis</module>
|
||||||
|
<module>cloud-common-saas</module>
|
||||||
<module>cloud-common-seata</module>
|
<module>cloud-common-seata</module>
|
||||||
<module>cloud-common-api-doc</module>
|
<module>cloud-common-api-doc</module>
|
||||||
<module>cloud-common-security</module>
|
<module>cloud-common-security</module>
|
||||||
|
@ -20,7 +21,6 @@
|
||||||
<module>cloud-common-system</module>
|
<module>cloud-common-system</module>
|
||||||
<module>cloud-common-xxl</module>
|
<module>cloud-common-xxl</module>
|
||||||
<module>cloud-common-rabbit</module>
|
<module>cloud-common-rabbit</module>
|
||||||
<module>cloud-common-saas</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>cloud-common</artifactId>
|
<artifactId>cloud-common</artifactId>
|
||||||
|
|
|
@ -56,9 +56,9 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
if (claims == null) {
|
if (claims == null) {
|
||||||
return unauthorizedResponse(exchange, "令牌已过期或验证不正确!");
|
return unauthorizedResponse(exchange, "令牌已过期或验证不正确!");
|
||||||
}
|
}
|
||||||
String userkey = JwtUtils.getUserKey(claims);
|
String userKey = JwtUtils.getUserKey(claims);
|
||||||
boolean islogin = redisService.hasKey(getTokenKey(userkey));
|
boolean isLogin = redisService.hasKey(getTokenKey(userKey));
|
||||||
if (!islogin) {
|
if (!isLogin) {
|
||||||
return unauthorizedResponse(exchange, "登录状态已过期");
|
return unauthorizedResponse(exchange, "登录状态已过期");
|
||||||
}
|
}
|
||||||
String userid = JwtUtils.getUserId(claims);
|
String userid = JwtUtils.getUserId(claims);
|
||||||
|
@ -66,11 +66,14 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
|
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
|
||||||
return unauthorizedResponse(exchange, "令牌验证失败");
|
return unauthorizedResponse(exchange, "令牌验证失败");
|
||||||
}
|
}
|
||||||
|
String saaSKey = JwtUtils.getSaaSKey(claims);
|
||||||
|
|
||||||
// 设置用户信息到请求
|
// 设置用户信息到请求
|
||||||
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
|
addHeader(mutate, SecurityConstants.USER_KEY, userKey);
|
||||||
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
||||||
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
||||||
|
addHeader(mutate, SecurityConstants.SAAS_KEY, saaSKey);
|
||||||
|
|
||||||
// 内部请求来源参数清除
|
// 内部请求来源参数清除
|
||||||
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
||||||
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 106.15.136.7:8848
|
addr: 106.15.136.7:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: crj
|
namespace: xzr
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.muyu;
|
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.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统模块
|
* 系统模块
|
||||||
|
|
|
@ -78,8 +78,6 @@ public class SysCarController extends BaseController {
|
||||||
// 随机生成VIN码
|
// 随机生成VIN码
|
||||||
String key2 = RandomUtil.randomNumbers(17);
|
String key2 = RandomUtil.randomNumbers(17);
|
||||||
carVO.setCarVin(key2);
|
carVO.setCarVin(key2);
|
||||||
//
|
|
||||||
carVO.setUserId(SecurityUtils.getUserId());
|
|
||||||
sysCarService.insertCar(carVO);
|
sysCarService.insertCar(carVO);
|
||||||
return Result.success("车辆添加成功");
|
return Result.success("车辆添加成功");
|
||||||
}
|
}
|
||||||
|
@ -92,6 +90,8 @@ public class SysCarController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("updataCar")
|
@PostMapping("updataCar")
|
||||||
public Result updataCar(@RequestBody CarVO carVO){
|
public Result updataCar(@RequestBody CarVO carVO){
|
||||||
|
//
|
||||||
|
carVO.setUserId(SecurityUtils.getUserId());
|
||||||
sysCarService.updateById(carVO);
|
sysCarService.updateById(carVO);
|
||||||
return Result.success("车辆修改成功");
|
return Result.success("车辆修改成功");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.muyu.car.controller;
|
||||||
|
|
||||||
|
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 io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/message") // 报文
|
||||||
|
@Tag(name = "报文",description = "报文模块")
|
||||||
|
public class SysCarMessageController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SysCarMessageService sysCarMessageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有报文信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("selectMessageShow")
|
||||||
|
public List<CarMessage> selectMessageShow(@RequestParam("templateId") Long templateId){
|
||||||
|
return sysCarMessageService.selectMessageShow(templateId);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 通过id查询报文信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("selectMessageByMessageId")
|
||||||
|
public CarMessage selectMessageByMessageId(@RequestParam("messageId") Long messageId){
|
||||||
|
return sysCarMessageService.selectMessageByMessageId(messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加报文信息
|
||||||
|
* @return carMessage
|
||||||
|
*/
|
||||||
|
@PostMapping("insertMessage")
|
||||||
|
public Result insertMessage(@RequestBody CarMessage carMessage){
|
||||||
|
sysCarMessageService.save(carMessage);
|
||||||
|
return Result.success("添加成功");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改报文信息
|
||||||
|
* @return carMessage
|
||||||
|
*/
|
||||||
|
@PostMapping("updataMessage")
|
||||||
|
public Result updataMessage(@RequestBody CarMessage carMessage){
|
||||||
|
sysCarMessageService.updateById(carMessage);
|
||||||
|
return Result.success("修改成功");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除报文信息
|
||||||
|
* @return carMessage
|
||||||
|
*/
|
||||||
|
@PostMapping("deleteMessage")
|
||||||
|
public Result deleteMessage(@RequestParam("ids") List<Long> ids){
|
||||||
|
sysCarMessageService.removeBatchByIds(ids);
|
||||||
|
return Result.success("删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.muyu.car.controller;
|
||||||
|
|
||||||
|
import com.github.pagehelper.util.StringUtil;
|
||||||
|
import com.muyu.car.domain.CarMessageType;
|
||||||
|
import com.muyu.car.domain.CarTemplate;
|
||||||
|
import com.muyu.car.service.SysCarMessageTypeService;
|
||||||
|
import com.muyu.car.service.SysCarTemplateService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/type") // 报文类型
|
||||||
|
@Tag(name = "报文类型",description = "报文类型")
|
||||||
|
public class SysCarMessageTypeController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SysCarMessageTypeService sysCarMessageTypeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文类型列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("messageTypeList")
|
||||||
|
public List<CarMessageType> messageTypeList(){
|
||||||
|
List<CarMessageType> list = sysCarMessageTypeService.list();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文类型添加成功
|
||||||
|
* @param carMessageType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("insertMessageType")
|
||||||
|
public Result insertMessageType(@RequestBody CarMessageType carMessageType){
|
||||||
|
// // token 校验
|
||||||
|
// if(SecurityUtils.getToken().equals("")){
|
||||||
|
// return Result.error("token不存在");
|
||||||
|
// }
|
||||||
|
// id不能传
|
||||||
|
// if(carMessageType.getMessageTypeId() > 0 || carMessageType.getMessageTypeId() != null){
|
||||||
|
// return Result.error("添加要什么ID");
|
||||||
|
// }
|
||||||
|
// 报文编码校验
|
||||||
|
if(StringUtils.isEmpty(carMessageType.getMessageCode())){
|
||||||
|
return Result.error("报文编码不能为空");
|
||||||
|
}
|
||||||
|
// 报文名称校验
|
||||||
|
if(StringUtils.isEmpty(carMessageType.getMessageName())){
|
||||||
|
return Result.error("报文名称不能为空");
|
||||||
|
}
|
||||||
|
// 报文分类不能为空
|
||||||
|
if(StringUtils.isEmpty(carMessageType.getMessageClass())){
|
||||||
|
return Result.error("报文字段类型不能为空");
|
||||||
|
}
|
||||||
|
// 执行添加的操作
|
||||||
|
sysCarMessageTypeService.save(carMessageType);
|
||||||
|
return Result.success("添加成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改报文类型
|
||||||
|
* @param carMessageType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("updateMessageType")
|
||||||
|
public Result updateMessageType(@RequestBody CarMessageType carMessageType){
|
||||||
|
// 报文id
|
||||||
|
if(carMessageType.getMessageTypeId() <= 0){
|
||||||
|
return Result.error("报文类型id不能为空,这是修改啊哥们");
|
||||||
|
}
|
||||||
|
// 报文分类判断
|
||||||
|
if(StringUtils.isEmpty(carMessageType.getMessageType())){
|
||||||
|
return Result.error("报文分类不为空");
|
||||||
|
}
|
||||||
|
// 报文编码
|
||||||
|
if(StringUtils.isEmpty(carMessageType.getMessageCode())){
|
||||||
|
return Result.error("报文编码不能为空");
|
||||||
|
}
|
||||||
|
// 报文名称
|
||||||
|
if(StringUtils.isEmpty(carMessageType.getMessageName())){
|
||||||
|
return Result.error("报文名称不能为空");
|
||||||
|
}
|
||||||
|
// 报文字段类型
|
||||||
|
if(StringUtils.isEmpty(carMessageType.getMessageClass())){
|
||||||
|
return Result.error("报文字段类型不能为空");
|
||||||
|
}
|
||||||
|
sysCarMessageTypeService.updateById(carMessageType);
|
||||||
|
return Result.success("报文类型修改成功");
|
||||||
|
}
|
||||||
|
@PostMapping("deleteMessageType")
|
||||||
|
public Result deleteMessageType
|
||||||
|
(@RequestParam("ids") List<Long> ids){
|
||||||
|
if(ids.size()<1){
|
||||||
|
return Result.error("请先选择要删除的数据行");
|
||||||
|
}
|
||||||
|
sysCarMessageTypeService.removeBatchByIds(ids);
|
||||||
|
if(ids.size()==1){
|
||||||
|
return Result.success("删除成功");
|
||||||
|
}
|
||||||
|
if(ids.size()>1){
|
||||||
|
return Result.success("批量删除成功");
|
||||||
|
}
|
||||||
|
return Result.success("删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.muyu.car.controller;
|
||||||
|
|
||||||
|
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 org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/template") // 报文
|
||||||
|
@Tag(name = "模版模块",description = "报文模版模块")
|
||||||
|
public class SysCarTemplateController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SysCarTemplateService sysCarTemplateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有模版信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("selectTemplateShow")
|
||||||
|
public List<CarTemplate> selectTemplateShow(){
|
||||||
|
return sysCarTemplateService.selectTemplateShow();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 通过id查询模版信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("selectTemplateByTemplateId")
|
||||||
|
public CarTemplate selectTemplateByTemplateId(@RequestParam("templateId") Long templateId){
|
||||||
|
return sysCarTemplateService.selectTemplateByTemplateId(templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加模版信息
|
||||||
|
* @return carMessage
|
||||||
|
*/
|
||||||
|
@PostMapping("insertTemplate")
|
||||||
|
public Result insertTemplate(@RequestBody CarTemplate carTemplate){
|
||||||
|
sysCarTemplateService.save(carTemplate);
|
||||||
|
return Result.success("添加成功");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改模版信息
|
||||||
|
* @return carMessage
|
||||||
|
*/
|
||||||
|
@PostMapping("updataTemplate")
|
||||||
|
public Result updataTemplate(@RequestBody CarTemplate carTemplate){
|
||||||
|
sysCarTemplateService.updateById(carTemplate);
|
||||||
|
return Result.success("修改成功");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除模版信息
|
||||||
|
* @return carMessage
|
||||||
|
*/
|
||||||
|
@PostMapping("deleteTemplate")
|
||||||
|
public Result deleteTemplate(@RequestParam("ids") List<Long> ids){
|
||||||
|
sysCarTemplateService.removeBatchByIds(ids);
|
||||||
|
return Result.success("删除成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.muyu.car.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Car {
|
||||||
|
/**
|
||||||
|
* 车辆表
|
||||||
|
*/
|
||||||
|
private Integer CarId;
|
||||||
|
/**
|
||||||
|
* 车架号
|
||||||
|
*/
|
||||||
|
private String CarFrame;
|
||||||
|
/**
|
||||||
|
* 车牌号
|
||||||
|
*/
|
||||||
|
private String CarCoed;
|
||||||
|
/**
|
||||||
|
* 颜色
|
||||||
|
*/
|
||||||
|
private Integer CarColor;
|
||||||
|
/**
|
||||||
|
* VIN
|
||||||
|
*/
|
||||||
|
private String CarVin;
|
||||||
|
/**
|
||||||
|
* 驾驶员
|
||||||
|
*/
|
||||||
|
private Integer UserId;
|
||||||
|
/**
|
||||||
|
* 类型
|
||||||
|
*/
|
||||||
|
private Integer TypeId;
|
||||||
|
/**
|
||||||
|
* 年审日期
|
||||||
|
*/
|
||||||
|
private Date AudditTime;
|
||||||
|
/**
|
||||||
|
* 行驶证到期时间
|
||||||
|
*/
|
||||||
|
private Date LiceseTime;
|
||||||
|
/**
|
||||||
|
* 保险到期日期
|
||||||
|
*/
|
||||||
|
private Date LinsuranceTime;
|
||||||
|
/**
|
||||||
|
* 在线状态
|
||||||
|
*/
|
||||||
|
private Integer CarStatus;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date CreatedTime;
|
||||||
|
/**
|
||||||
|
* 当前档位
|
||||||
|
*/
|
||||||
|
private Integer CarGears;
|
||||||
|
/**
|
||||||
|
* 品牌
|
||||||
|
*/
|
||||||
|
private String CarModel;
|
||||||
|
/**
|
||||||
|
* 车辆型号
|
||||||
|
*/
|
||||||
|
private String CarBrand;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -19,10 +19,6 @@ public class CarMessage {
|
||||||
*/
|
*/
|
||||||
@TableId(value = "message_id",type = IdType.AUTO)
|
@TableId(value = "message_id",type = IdType.AUTO)
|
||||||
private Long messageId;
|
private Long messageId;
|
||||||
/**
|
|
||||||
* 车辆编码
|
|
||||||
*/
|
|
||||||
private String messageCode;
|
|
||||||
/**
|
/**
|
||||||
* 车辆报文类别
|
* 车辆报文类别
|
||||||
*/
|
*/
|
||||||
|
@ -35,22 +31,7 @@ public class CarMessage {
|
||||||
* 结束位下标
|
* 结束位下标
|
||||||
*/
|
*/
|
||||||
private Integer messageEndIndex;
|
private Integer messageEndIndex;
|
||||||
/**
|
|
||||||
* 数据类型
|
|
||||||
*/
|
|
||||||
private String messageDataType;
|
|
||||||
/**
|
|
||||||
* 固定值
|
|
||||||
*/
|
|
||||||
private double fixedValue;
|
|
||||||
/**
|
|
||||||
* 最小值
|
|
||||||
*/
|
|
||||||
private double minimumValue;
|
|
||||||
/**
|
|
||||||
* 最大值
|
|
||||||
*/
|
|
||||||
private double maximumValue;
|
|
||||||
/**
|
/**
|
||||||
* 模版id
|
* 模版id
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class CarMessageType {
|
||||||
* 报文
|
* 报文
|
||||||
*/
|
*/
|
||||||
@TableId(value = "message_type_id",type = IdType.AUTO)
|
@TableId(value = "message_type_id",type = IdType.AUTO)
|
||||||
private Integer messageTypeId;
|
private Long messageTypeId;
|
||||||
/**
|
/**
|
||||||
* 报文编码
|
* 报文编码
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class CarTemplate {
|
||||||
* 报文模版表
|
* 报文模版表
|
||||||
*/
|
*/
|
||||||
@TableId(value = "template_id",type = IdType.AUTO)
|
@TableId(value = "template_id",type = IdType.AUTO)
|
||||||
private Integer templateId;
|
private Long templateId;
|
||||||
/**
|
/**
|
||||||
* 报文模版名称
|
* 报文模版名称
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,10 +39,6 @@ public class SysCar {
|
||||||
* VIN码
|
* VIN码
|
||||||
*/
|
*/
|
||||||
private String carVin;
|
private String carVin;
|
||||||
/**
|
|
||||||
* 驾车人
|
|
||||||
*/
|
|
||||||
private Long carUserId;
|
|
||||||
/**
|
/**
|
||||||
* 车主
|
* 车主
|
||||||
*/
|
*/
|
||||||
|
@ -98,5 +94,13 @@ public class SysCar {
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "最后一次离线时间", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "最后一次离线时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date carLastOfflineTime;
|
private Date carLastOfflineTime;
|
||||||
|
private Integer Car_id;
|
||||||
|
private Integer car_deman;
|
||||||
|
private Integer cae_color;
|
||||||
|
private Integer vin;
|
||||||
|
private Integer user_id;
|
||||||
|
private Integer type_id;
|
||||||
|
private Integer stete;
|
||||||
|
private Integer auddit;
|
||||||
|
private String brand;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,11 @@ public class CarDTO {
|
||||||
* 在线状态 1.无信号 2.行驶中 3.已停止
|
* 在线状态 1.无信号 2.行驶中 3.已停止
|
||||||
*/
|
*/
|
||||||
private Integer carStatus;
|
private Integer carStatus;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String companyName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,6 @@ public class CarVO {
|
||||||
* VIN码
|
* VIN码
|
||||||
*/
|
*/
|
||||||
private String carVin;
|
private String carVin;
|
||||||
/**
|
|
||||||
* 驾车人
|
|
||||||
*/
|
|
||||||
private Long carUserId;
|
|
||||||
/**
|
/**
|
||||||
* 车主
|
* 车主
|
||||||
*/
|
*/
|
||||||
|
@ -120,4 +116,10 @@ public class CarVO {
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Integer gearType;
|
private Integer gearType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业名称
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,13 @@
|
||||||
|
package com.muyu.car.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.car.domain.CarMessageType;
|
||||||
|
import com.muyu.car.domain.CarTemplate;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface SysCarMessageTypeMapper extends BaseMapper<CarMessageType> {
|
||||||
|
|
||||||
|
}
|
|
@ -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,15 @@
|
||||||
|
package com.muyu.car.mq.consumer;
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component //消费者
|
||||||
|
public class TextConsumer {
|
||||||
|
// @RabbitListener(bindings = @QueueBinding(value = @Queue("aaaa"),
|
||||||
|
// exchange = @Exchange(value = "aaaaa")))
|
||||||
|
// @RabbitListener(bindings = )
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.car.mq.producer;
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.annotation.AccessType;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Component // 生产者
|
||||||
|
public class TextProducer {
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
@GetMapping("aaa")
|
||||||
|
public String aaa(){
|
||||||
|
rabbitTemplate.convertAndSend("aaaa","abc","jsijx");
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.car.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.car.domain.CarMessage;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SysCarMessageService extends IService<CarMessage> {
|
||||||
|
/**
|
||||||
|
* 查询所有报文信息
|
||||||
|
* @param templateId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CarMessage> selectMessageShow(Long templateId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询报文信息
|
||||||
|
* @param messageId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CarMessage selectMessageByMessageId(Long messageId);
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.car.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.car.domain.CarMessageType;
|
||||||
|
import com.muyu.car.domain.CarTemplate;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SysCarMessageTypeService extends IService<CarMessageType> {
|
||||||
|
/**
|
||||||
|
* 添加报文类型表
|
||||||
|
* @param carMessageType
|
||||||
|
*/
|
||||||
|
void insertMessageType(CarMessageType carMessageType);
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 报文类型列表
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// List<CarMessageType> messageTypeList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改报文类型列表
|
||||||
|
* @param carMessageType
|
||||||
|
*/
|
||||||
|
void updateMessageType(CarMessageType carMessageType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除碑文类型表
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
void deleteMessageType(@Param("ids") List<Long> ids);
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.car.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.car.domain.CarMessage;
|
||||||
|
import com.muyu.car.domain.CarTemplate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SysCarTemplateService extends IService<CarTemplate> {
|
||||||
|
/**
|
||||||
|
* 查询所有报文信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CarTemplate> selectTemplateShow();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询报文信息
|
||||||
|
* @param messageId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CarTemplate selectTemplateByTemplateId(Long messageId);
|
||||||
|
}
|
|
@ -2,18 +2,12 @@ package com.muyu.car.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.car.domain.CarCompany;
|
import com.muyu.car.domain.CarCompany;
|
||||||
import com.muyu.car.domain.dto.CarDTO;
|
|
||||||
import com.muyu.car.domain.vo.CarVO;
|
|
||||||
import com.muyu.car.mapper.SysCarCompanyMapper;
|
import com.muyu.car.mapper.SysCarCompanyMapper;
|
||||||
import com.muyu.car.mapper.SysCarMapper;
|
|
||||||
import com.muyu.car.service.SysCarCompanyService;
|
import com.muyu.car.service.SysCarCompanyService;
|
||||||
import com.muyu.car.service.SysCarService;
|
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zmw
|
* @author zmw
|
||||||
* @description: 配置plus业务实现层
|
* @description: 配置plus业务实现层
|
||||||
|
|
|
@ -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,58 @@
|
||||||
|
package com.muyu.car.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.car.domain.CarMessageType;
|
||||||
|
import com.muyu.car.domain.CarTemplate;
|
||||||
|
import com.muyu.car.mapper.SysCarMessageTypeMapper;
|
||||||
|
import com.muyu.car.mapper.SysCarTemplateMapper;
|
||||||
|
import com.muyu.car.service.SysCarMessageTypeService;
|
||||||
|
import com.muyu.car.service.SysCarTemplateService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SysCarMessageTypeServiceImpl extends ServiceImpl<SysCarMessageTypeMapper, CarMessageType> implements SysCarMessageTypeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysCarMessageTypeMapper sysCarMessageTypeMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加 报文类型
|
||||||
|
* @param carMessageType
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertMessageType(CarMessageType carMessageType) {
|
||||||
|
sysCarMessageTypeMapper.insert(carMessageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 类型列表
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// @Override
|
||||||
|
// public List<CarMessageType> messageTypeList() {
|
||||||
|
// return sysCarMessageTypeMapper.;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改报文类型
|
||||||
|
* @param carMessageType
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateMessageType(CarMessageType carMessageType) {
|
||||||
|
sysCarMessageTypeMapper.updateById(carMessageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除报文类型表
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteMessageType(List<Long> ids) {
|
||||||
|
sysCarMessageTypeMapper.deleteBatchIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.car.service.impl;
|
package com.muyu.car.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.car.domain.CarCompany;
|
import com.muyu.car.domain.CarCompany;
|
||||||
import com.muyu.car.domain.SysCar;
|
import com.muyu.car.domain.SysCar;
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.car.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SysCarTemplateServiceImpl extends ServiceImpl<SysCarTemplateMapper, CarTemplate> implements SysCarTemplateService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysCarTemplateMapper sysCarTemplateMapper;
|
||||||
|
/**
|
||||||
|
* 查询所有报文信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<CarTemplate> selectTemplateShow() {
|
||||||
|
return sysCarTemplateMapper.selectTemplateShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询报文信息
|
||||||
|
* @param templateId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CarTemplate selectTemplateByTemplateId(Long templateId) {
|
||||||
|
return sysCarTemplateMapper.selectById(templateId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.car.text;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CarText {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 10066
|
||||||
|
|
||||||
|
# nacos线上地址
|
||||||
|
nacos:
|
||||||
|
addr: 106.15.136.7:8848
|
||||||
|
user-name: nacos
|
||||||
|
password: nacos
|
||||||
|
namespace: zmw
|
||||||
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
amqp:
|
||||||
|
deserialization:
|
||||||
|
trust:
|
||||||
|
all: true
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: cloud-car
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# nacos用户名
|
||||||
|
username: ${nacos.user-name}
|
||||||
|
# nacos密码
|
||||||
|
password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
config:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# nacos用户名
|
||||||
|
username: ${nacos.user-name}
|
||||||
|
# nacos密码
|
||||||
|
password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
# 系统共享配置
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# xxl-job 配置文件
|
||||||
|
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# rabbit 配置文件
|
||||||
|
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.muyu.system.mapper: DEBUG
|
|
@ -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>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?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.SysCarMessageTypeMapper">
|
||||||
|
|
||||||
|
<!-- 查询所有报文信息 -->
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -72,6 +72,12 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-api-doc</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SaaS-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-saas</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
package com.muyu;
|
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.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication(exclude = {
|
||||||
|
DataSourceAutoConfiguration.class,
|
||||||
|
DruidDataSourceAutoConfigure.class,
|
||||||
|
DynamicDataSourceAutoConfiguration.class
|
||||||
|
})
|
||||||
public class CloudFaultApplication {
|
public class CloudFaultApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(CloudFaultApplication.class,args);
|
SpringApplication.run(CloudFaultApplication.class,args);
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 106.15.136.7:8848
|
addr: 106.15.136.7:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: crj
|
namespace: xzr
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 106.15.136.7:8848
|
addr: 106.15.136.7:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: crj
|
namespace: xzr
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 106.15.136.7:8848
|
addr: 106.15.136.7:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: crj
|
namespace: xzr
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 106.15.136.7:8848
|
addr: 106.15.136.7:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: crj
|
namespace: xzr
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
amqp:
|
amqp:
|
||||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
||||||
addr: 106.15.136.7:8848
|
addr: 106.15.136.7:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: crj
|
namespace: xzr
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
<?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-server</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-warn</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>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 接口模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统模块
|
||||||
|
* @author muyu
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
//@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CloudWarnApplication {
|
||||||
|
public static void main (String[] args) {
|
||||||
|
SpringApplication.run(CloudWarnApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.warn.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.warn.domain.CarMessage;
|
||||||
|
import com.muyu.warn.service.CarMessageService;
|
||||||
|
import com.muyu.warn.service.CarTypeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName CarMessageController
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 22:28
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/carMessage")
|
||||||
|
public class CarMessageController {
|
||||||
|
@Autowired
|
||||||
|
private CarMessageService carMessageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据报文模板id查询报文
|
||||||
|
* @param templateId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/selectByTemplateId")
|
||||||
|
private Result<List<CarMessage>> selectByTemplateId(@RequestParam("templateId") Integer templateId) {
|
||||||
|
return Result.success(carMessageService.list
|
||||||
|
(new LambdaQueryWrapper<CarMessage>().eq(CarMessage::getTemplateId, templateId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.muyu.warn.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.warn.domain.CarType;
|
||||||
|
import com.muyu.warn.service.CarTypeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName CarController
|
||||||
|
* @Description 车辆类型Controller层
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 16:52
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/carType")
|
||||||
|
public class CarTypeController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarTypeService carTypeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有规则
|
||||||
|
* @return carTypeList
|
||||||
|
*/
|
||||||
|
@GetMapping("/carTypeList")
|
||||||
|
private Result<List<CarType>> carTypeList() {
|
||||||
|
List<CarType> carTypeList = carTypeService.list();
|
||||||
|
return Result.success(carTypeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询类型对象
|
||||||
|
* @param catTypeId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/catTypeId")
|
||||||
|
private Result<CarType> catTypeId(@RequestParam("catTypeId") Integer catTypeId) {
|
||||||
|
CarType carType = carTypeService.findById(catTypeId);
|
||||||
|
return Result.success(carType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.warn.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.warn.domain.Template;
|
||||||
|
import com.muyu.warn.service.TemplateService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName Template
|
||||||
|
* @Description 报文模板
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 18:37
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/template")
|
||||||
|
public class TemplateController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过报文id查询
|
||||||
|
* @param templateId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/findByTemplateId")
|
||||||
|
private Result findByTemplateId(@RequestParam("templateId") Integer templateId) {
|
||||||
|
return Result.success(templateService.getOne(
|
||||||
|
new LambdaQueryWrapper<Template>().eq(Template::getTemplateId, templateId)));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
package com.muyu.warn.controller;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.warn.domain.WarnLogs;
|
||||||
|
import com.muyu.warn.service.IWarnLogsService;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警日志Controller
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/logs")
|
||||||
|
public class WarnLogsController extends BaseController
|
||||||
|
{
|
||||||
|
@Resource
|
||||||
|
private IWarnLogsService warnLogsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警日志列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:logs:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<WarnLogs>> list(WarnLogs warnLogs)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<WarnLogs> list = warnLogsService.selectWarnLogsList(warnLogs);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出预警日志列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:logs:export")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, WarnLogs warnLogs)
|
||||||
|
{
|
||||||
|
List<WarnLogs> list = warnLogsService.selectWarnLogsList(warnLogs);
|
||||||
|
ExcelUtil<WarnLogs> util = new ExcelUtil<WarnLogs>(WarnLogs.class);
|
||||||
|
util.exportExcel(response, list, "预警日志数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预警日志详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:logs:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result<List<WarnLogs>> getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(warnLogsService.selectWarnLogsById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增预警日志
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:logs:add")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Integer> add(
|
||||||
|
@Validated @RequestBody WarnLogs warnLogs)
|
||||||
|
{
|
||||||
|
if (warnLogsService.checkIdUnique(warnLogs)) {
|
||||||
|
return error("新增 预警日志 '" + warnLogs + "'失败,预警日志已存在");
|
||||||
|
}
|
||||||
|
return toAjax(warnLogsService.save(warnLogs));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改预警日志
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:logs:edit")
|
||||||
|
@PutMapping
|
||||||
|
public Result<Integer> edit(
|
||||||
|
@Validated @RequestBody WarnLogs warnLogs)
|
||||||
|
{
|
||||||
|
if (!warnLogsService.checkIdUnique(warnLogs)) {
|
||||||
|
return error("修改 预警日志 '" + warnLogs + "'失败,预警日志不存在");
|
||||||
|
}
|
||||||
|
return toAjax(warnLogsService.updateById(warnLogs));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除预警日志
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:logs:remove")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||||
|
{
|
||||||
|
warnLogsService.removeBatchByIds(Arrays.asList(ids));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
package com.muyu.warn.controller;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.warn.domain.WarnRule;
|
||||||
|
import com.muyu.warn.service.IWarnRuleService;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警规则Controller
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/rule")
|
||||||
|
public class WarnRuleController extends BaseController
|
||||||
|
{
|
||||||
|
@Resource
|
||||||
|
private IWarnRuleService warnRuleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警规则列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:rule:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<WarnRule>> list(WarnRule warnRule)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出预警规则列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:rule:export")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, WarnRule warnRule)
|
||||||
|
{
|
||||||
|
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
|
||||||
|
ExcelUtil<WarnRule> util = new ExcelUtil<WarnRule>(WarnRule.class);
|
||||||
|
util.exportExcel(response, list, "预警规则数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预警规则详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:rule:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result<List<WarnRule>> getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(warnRuleService.selectWarnRuleById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增预警规则
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:rule:add")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Integer> add(
|
||||||
|
@Validated @RequestBody WarnRule warnRule)
|
||||||
|
{
|
||||||
|
if (warnRuleService.checkIdUnique(warnRule)) {
|
||||||
|
return error("新增 预警规则 '" + warnRule + "'失败,预警规则已存在");
|
||||||
|
}
|
||||||
|
return toAjax(warnRuleService.save(warnRule));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改预警规则
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:rule:edit")
|
||||||
|
@PutMapping
|
||||||
|
public Result<Integer> edit(
|
||||||
|
@Validated @RequestBody WarnRule warnRule)
|
||||||
|
{
|
||||||
|
if (!warnRuleService.checkIdUnique(warnRule)) {
|
||||||
|
return error("修改 预警规则 '" + warnRule + "'失败,预警规则不存在");
|
||||||
|
}
|
||||||
|
return toAjax(warnRuleService.updateById(warnRule));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除预警规则
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:rule:remove")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||||
|
{
|
||||||
|
warnRuleService.removeBatchByIds(Arrays.asList(ids));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据策略id查询规则
|
||||||
|
* @param strategyId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/selectByStrategyId")
|
||||||
|
public Result<List<WarnRule>> selectByStrategyId
|
||||||
|
(@RequestParam("strategyId") Long strategyId){
|
||||||
|
List<WarnRule> list = warnRuleService.list
|
||||||
|
(new LambdaQueryWrapper<WarnRule>().eq(WarnRule::getStrategyId, strategyId));
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
package com.muyu.warn.controller;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.warn.domain.Resp.WarnStrategyList;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.warn.domain.WarnStrategy;
|
||||||
|
import com.muyu.warn.service.IWarnStrategyService;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警策略Controller
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/strategy")
|
||||||
|
public class WarnStrategyController extends BaseController
|
||||||
|
{
|
||||||
|
@Resource
|
||||||
|
private IWarnStrategyService warnStrategyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警策略列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:strategy:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<WarnStrategy>> list(WarnStrategy warnStrategy)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出预警策略列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:strategy:export")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, WarnStrategy warnStrategy)
|
||||||
|
{
|
||||||
|
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy);
|
||||||
|
ExcelUtil<WarnStrategy> util = new ExcelUtil<WarnStrategy>(WarnStrategy.class);
|
||||||
|
util.exportExcel(response, list, "预警策略数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预警策略详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:strategy:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result<List<WarnStrategy>> getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(warnStrategyService.selectWarnStrategyById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增预警策略
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:strategy:add")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Integer> add(
|
||||||
|
@Validated @RequestBody WarnStrategy warnStrategy)
|
||||||
|
{
|
||||||
|
if (warnStrategyService.checkIdUnique(warnStrategy)) {
|
||||||
|
return error("新增 预警策略 '" + warnStrategy + "'失败,预警策略已存在");
|
||||||
|
}
|
||||||
|
return toAjax(warnStrategyService.save(warnStrategy));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改预警策略
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:strategy:edit")
|
||||||
|
@PutMapping
|
||||||
|
public Result<Integer> edit(
|
||||||
|
@Validated @RequestBody WarnStrategy warnStrategy)
|
||||||
|
{
|
||||||
|
if (!warnStrategyService.checkIdUnique(warnStrategy)) {
|
||||||
|
return error("修改 预警策略 '" + warnStrategy + "'失败,预警策略不存在");
|
||||||
|
}
|
||||||
|
return toAjax(warnStrategyService.updateById(warnStrategy));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除预警策略
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("warn:strategy:remove")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||||
|
{
|
||||||
|
warnStrategyService.removeBatchByIds(Arrays.asList(ids));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 双表联查
|
||||||
|
* @param warnStrategy
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/strategyRuleList")
|
||||||
|
public Result<List<WarnStrategyList>> StrategyRuleList(@RequestBody WarnStrategy warnStrategy){
|
||||||
|
List<WarnStrategyList> list = warnStrategyService.strategyList(warnStrategy);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.muyu.warn.domain;
|
||||||
|
|
||||||
|
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 CarMessage
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 22:24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Tag(name = "报文表")
|
||||||
|
@TableName(value = "t_car_message")
|
||||||
|
public class CarMessage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文表
|
||||||
|
*/
|
||||||
|
private Long messageId;
|
||||||
|
/**
|
||||||
|
* 车辆报文类别
|
||||||
|
*/
|
||||||
|
private String messageType;
|
||||||
|
/**
|
||||||
|
* 开始位下标
|
||||||
|
*/
|
||||||
|
private Integer messageStartIndex;
|
||||||
|
/**
|
||||||
|
* 结束位下标
|
||||||
|
*/
|
||||||
|
private Integer messageEndIndex;
|
||||||
|
/**
|
||||||
|
* 模版id
|
||||||
|
*/
|
||||||
|
private Long templateId;
|
||||||
|
/**
|
||||||
|
* 报文标签
|
||||||
|
*/
|
||||||
|
private String messageLabel;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.warn.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 CarType
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 16:53
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Tag(name = "车辆类型表")
|
||||||
|
@TableName(value = "t_car_type")
|
||||||
|
public class CarType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆类型id
|
||||||
|
*/
|
||||||
|
private Integer carTypeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆类型名称
|
||||||
|
*/
|
||||||
|
private String carTypeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
private Integer templateId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.muyu.warn.domain.Resp;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.warn.domain.WarnRule;
|
||||||
|
import com.muyu.warn.domain.WarnStrategy;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName StrategyRuleList
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 15:07
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Tag(name = "策略规则一对多")
|
||||||
|
public class StrategyRuleList {
|
||||||
|
|
||||||
|
|
||||||
|
/** 策略id */
|
||||||
|
@TableId( type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 车辆类型id */
|
||||||
|
@Excel(name = "车辆类型id")
|
||||||
|
private Long carTypeId;
|
||||||
|
|
||||||
|
/** 策略名称 */
|
||||||
|
@Excel(name = "策略名称")
|
||||||
|
private String strategyName;
|
||||||
|
|
||||||
|
/** 报文模版id */
|
||||||
|
@Excel(name = "报文模版id")
|
||||||
|
private Long msgId;
|
||||||
|
|
||||||
|
private List<WarnRule> warnRuleList;
|
||||||
|
|
||||||
|
// private static StrategyRuleList strategyRuleList
|
||||||
|
// (WarnStrategy warnStrategy, Supplier<Long> supplierId) {
|
||||||
|
// return StrategyRuleList.builder()
|
||||||
|
// .id(warnStrategy.getId())
|
||||||
|
// .carTypeId(warnStrategy.getCarTypeId())
|
||||||
|
// .strategyName(warnStrategy.getStrategyName())
|
||||||
|
// .msgId(warnStrategy.getMsgId())
|
||||||
|
// .warnRuleList(supplierId)
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.muyu.warn.domain.Resp;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.warn.domain.WarnRule;
|
||||||
|
import com.muyu.warn.domain.WarnStrategy;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName WarnStrategyList
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/21 18:45
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Tag(name = "策略规则双表联查")
|
||||||
|
public class WarnStrategyList {
|
||||||
|
|
||||||
|
/** 策略id */
|
||||||
|
private Long strategyId;
|
||||||
|
|
||||||
|
/** 车辆类型id */
|
||||||
|
private Long carTypeId;
|
||||||
|
|
||||||
|
/** 策略名称 */
|
||||||
|
private String strategyName;
|
||||||
|
|
||||||
|
|
||||||
|
/** 报文模版id */
|
||||||
|
private Long msgId;
|
||||||
|
|
||||||
|
/** 规则id */
|
||||||
|
private Long ruleId;
|
||||||
|
|
||||||
|
/** 规则名称 */
|
||||||
|
private String ruleName;
|
||||||
|
|
||||||
|
|
||||||
|
/** 报文数据类型id */
|
||||||
|
private Long msgTypeId;
|
||||||
|
|
||||||
|
/** 滑窗时间 */
|
||||||
|
private Long slideTime;
|
||||||
|
|
||||||
|
/** 滑窗频率 */
|
||||||
|
private Long slideFrequency;
|
||||||
|
|
||||||
|
/** 最大值 */
|
||||||
|
private Long maxValue;
|
||||||
|
|
||||||
|
/** 最小值 */
|
||||||
|
private Long minValue;
|
||||||
|
|
||||||
|
/** 报文数据名称 */
|
||||||
|
private String messageName;;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.warn.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.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName Template
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 16:54
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Tag(name = "模板表")
|
||||||
|
@TableName(value = "t_template")
|
||||||
|
public class Template {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
private Integer templateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板名称
|
||||||
|
*/
|
||||||
|
private String templateName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板描述
|
||||||
|
*/
|
||||||
|
private String templateDescribe;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
package com.muyu.warn.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警日志对象 warn_logs
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("warn_logs")
|
||||||
|
public class WarnLogs{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 预警日志id */
|
||||||
|
@TableId( type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 车辆vin码 */
|
||||||
|
@Excel(name = "车辆vin码")
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/** 规则id */
|
||||||
|
@Excel(name = "规则id")
|
||||||
|
private Long warnRuleId;
|
||||||
|
|
||||||
|
/** 开始时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
/** 结束时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
/** 最大值 */
|
||||||
|
@Excel(name = "最大值")
|
||||||
|
private Long maxValue;
|
||||||
|
|
||||||
|
/** 最小值 */
|
||||||
|
@Excel(name = "最小值")
|
||||||
|
private Long minValue;
|
||||||
|
|
||||||
|
/** 平均值 */
|
||||||
|
@Excel(name = "平均值")
|
||||||
|
private Long avgValue;
|
||||||
|
|
||||||
|
/** 中位数 */
|
||||||
|
@Excel(name = "中位数")
|
||||||
|
private Long medianValue;
|
||||||
|
|
||||||
|
/** 是否发送预警 */
|
||||||
|
@Excel(name = "是否发送预警")
|
||||||
|
private Long status;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("vin", getVin())
|
||||||
|
.append("warnRuleId", getWarnRuleId())
|
||||||
|
.append("startTime", getStartTime())
|
||||||
|
.append("endTime", getEndTime())
|
||||||
|
.append("maxValue", getMaxValue())
|
||||||
|
.append("minValue", getMinValue())
|
||||||
|
.append("avgValue", getAvgValue())
|
||||||
|
.append("medianValue", getMedianValue())
|
||||||
|
.append("status", getStatus())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.muyu.warn.domain;
|
||||||
|
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警规则对象 warn_rule
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("warn_rule")
|
||||||
|
public class WarnRule{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 规则id */
|
||||||
|
@TableId( type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 规则名称 */
|
||||||
|
@Excel(name = "规则名称")
|
||||||
|
private String ruleName;
|
||||||
|
|
||||||
|
/** 策略id */
|
||||||
|
@Excel(name = "策略id")
|
||||||
|
private Long strategyId;
|
||||||
|
|
||||||
|
/** 报文数据类型id */
|
||||||
|
@Excel(name = "报文数据类型id")
|
||||||
|
private Long msgTypeId;
|
||||||
|
|
||||||
|
/** 滑窗时间 */
|
||||||
|
@Excel(name = "滑窗时间")
|
||||||
|
private Long slideTime;
|
||||||
|
|
||||||
|
/** 滑窗频率 */
|
||||||
|
@Excel(name = "滑窗频率")
|
||||||
|
private Long slideFrequency;
|
||||||
|
|
||||||
|
/** 最大值 */
|
||||||
|
@Excel(name = "最大值")
|
||||||
|
private Long maxValue;
|
||||||
|
|
||||||
|
/** 最小值 */
|
||||||
|
@Excel(name = "最小值")
|
||||||
|
private Long minValue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("ruleName", getRuleName())
|
||||||
|
.append("strategyId", getStrategyId())
|
||||||
|
.append("msgTypeId", getMsgTypeId())
|
||||||
|
.append("slideTime", getSlideTime())
|
||||||
|
.append("slideFrequency", getSlideFrequency())
|
||||||
|
.append("maxValue", getMaxValue())
|
||||||
|
.append("minValue", getMinValue())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.muyu.warn.domain;
|
||||||
|
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警策略对象 warn_strategy
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("warn_strategy")
|
||||||
|
public class WarnStrategy{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 策略id */
|
||||||
|
@TableId( type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 车辆类型id */
|
||||||
|
@Excel(name = "车辆类型id")
|
||||||
|
private Long carTypeId;
|
||||||
|
|
||||||
|
/** 策略名称 */
|
||||||
|
@Excel(name = "策略名称")
|
||||||
|
private String strategyName;
|
||||||
|
|
||||||
|
/** 报文模版id */
|
||||||
|
@Excel(name = "报文模版id")
|
||||||
|
private Long templateId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("carTypeId", getCarTypeId())
|
||||||
|
.append("strategyName", getStrategyName())
|
||||||
|
.append("msgId", getTemplateId())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.muyu.warn.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.warn.domain.CarMessage;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CarMessageMapper extends BaseMapper<CarMessage> {
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.muyu.warn.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.warn.domain.CarType;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CarTypeMapper extends BaseMapper<CarType> {
|
||||||
|
CarType findById(@Param("catTypeId") Integer catTypeId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.muyu.warn.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.warn.domain.Template;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface TemplateMapper extends BaseMapper<Template> {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.muyu.warn.mapper;
|
||||||
|
|
||||||
|
import com.muyu.warn.domain.WarnLogs;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警日志Mapper接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface WarnLogsMapper extends BaseMapper<WarnLogs>{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.muyu.warn.mapper;
|
||||||
|
|
||||||
|
import com.muyu.warn.domain.WarnRule;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警规则Mapper接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface WarnRuleMapper extends BaseMapper<WarnRule>{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.warn.mapper;
|
||||||
|
|
||||||
|
import com.muyu.warn.domain.Resp.WarnStrategyList;
|
||||||
|
import com.muyu.warn.domain.WarnStrategy;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警策略Mapper接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface WarnStrategyMapper extends BaseMapper<WarnStrategy>{
|
||||||
|
|
||||||
|
List<WarnStrategyList> strategyList(WarnStrategy warnStrategy);
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.muyu.warn.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.warn.domain.CarMessage;
|
||||||
|
|
||||||
|
public interface CarMessageService extends IService<CarMessage> {
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.muyu.warn.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.warn.domain.CarType;
|
||||||
|
|
||||||
|
public interface CarTypeService extends IService<CarType> {
|
||||||
|
CarType findById(Integer catTypeId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.warn.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.muyu.warn.domain.WarnLogs;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警日志Service接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
public interface IWarnLogsService extends IService<WarnLogs> {
|
||||||
|
/**
|
||||||
|
* 精确查询预警日志
|
||||||
|
*
|
||||||
|
* @param id 预警日志主键
|
||||||
|
* @return 预警日志
|
||||||
|
*/
|
||||||
|
public WarnLogs selectWarnLogsById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警日志列表
|
||||||
|
*
|
||||||
|
* @param warnLogs 预警日志
|
||||||
|
* @return 预警日志集合
|
||||||
|
*/
|
||||||
|
public List<WarnLogs> selectWarnLogsList(WarnLogs warnLogs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 预警日志 id是否唯一
|
||||||
|
* @param warnLogs 预警日志
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Boolean checkIdUnique(WarnLogs warnLogs);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.warn.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.muyu.warn.domain.WarnRule;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警规则Service接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
public interface IWarnRuleService extends IService<WarnRule> {
|
||||||
|
/**
|
||||||
|
* 精确查询预警规则
|
||||||
|
*
|
||||||
|
* @param id 预警规则主键
|
||||||
|
* @return 预警规则
|
||||||
|
*/
|
||||||
|
public WarnRule selectWarnRuleById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警规则列表
|
||||||
|
*
|
||||||
|
* @param warnRule 预警规则
|
||||||
|
* @return 预警规则集合
|
||||||
|
*/
|
||||||
|
public List<WarnRule> selectWarnRuleList(WarnRule warnRule);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 预警规则 id是否唯一
|
||||||
|
* @param warnRule 预警规则
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Boolean checkIdUnique(WarnRule warnRule);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.warn.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.warn.domain.Resp.WarnStrategyList;
|
||||||
|
import com.muyu.warn.domain.WarnStrategy;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警策略Service接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
public interface IWarnStrategyService extends IService<WarnStrategy> {
|
||||||
|
/**
|
||||||
|
* 精确查询预警策略
|
||||||
|
*
|
||||||
|
* @param id 预警策略主键
|
||||||
|
* @return 预警策略
|
||||||
|
*/
|
||||||
|
public WarnStrategy selectWarnStrategyById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警策略列表
|
||||||
|
*
|
||||||
|
* @param warnStrategy 预警策略
|
||||||
|
* @return 预警策略集合
|
||||||
|
*/
|
||||||
|
public List<WarnStrategy> selectWarnStrategyList(WarnStrategy warnStrategy);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 预警策略 id是否唯一
|
||||||
|
* @param warnStrategy 预警策略
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Boolean checkIdUnique(WarnStrategy warnStrategy);
|
||||||
|
|
||||||
|
|
||||||
|
List<WarnStrategyList> strategyList(WarnStrategy warnStrategy);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.muyu.warn.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.warn.domain.Template;
|
||||||
|
|
||||||
|
public interface TemplateService extends IService<Template> {
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.warn.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.warn.domain.CarMessage;
|
||||||
|
import com.muyu.warn.mapper.CarMessageMapper;
|
||||||
|
import com.muyu.warn.service.CarMessageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName CarMessageServiceImpl
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 22:29
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CarMessageServiceImpl
|
||||||
|
extends ServiceImpl<CarMessageMapper, CarMessage>
|
||||||
|
implements CarMessageService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarMessageMapper carMessageMapper;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.warn.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.warn.domain.CarType;
|
||||||
|
import com.muyu.warn.mapper.CarTypeMapper;
|
||||||
|
import com.muyu.warn.service.CarTypeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName CarServiceImpl
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 16:52
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CarTypeTypeServiceImpl
|
||||||
|
extends ServiceImpl<CarTypeMapper, CarType>
|
||||||
|
implements CarTypeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarTypeMapper carTypeMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CarType findById(Integer catTypeId) {
|
||||||
|
CarType carType= carTypeMapper.findById(catTypeId);
|
||||||
|
return carType;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.warn.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.warn.domain.Template;
|
||||||
|
import com.muyu.warn.mapper.TemplateMapper;
|
||||||
|
import com.muyu.warn.service.TemplateService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName TemplateServiceImpl
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/22 18:38
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TemplateServiceImpl
|
||||||
|
extends ServiceImpl<TemplateMapper, Template>
|
||||||
|
implements TemplateService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateMapper templateMapper;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
package com.muyu.warn.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.muyu.warn.mapper.WarnLogsMapper;
|
||||||
|
import com.muyu.warn.domain.WarnLogs;
|
||||||
|
import com.muyu.warn.service.IWarnLogsService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警日志Service业务层处理
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WarnLogsServiceImpl
|
||||||
|
extends ServiceImpl<WarnLogsMapper, WarnLogs>
|
||||||
|
implements IWarnLogsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精确查询预警日志
|
||||||
|
*
|
||||||
|
* @param id 预警日志主键
|
||||||
|
* @return 预警日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public WarnLogs selectWarnLogsById(Long id)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<WarnLogs> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
Assert.notNull(id, "id不可为空");
|
||||||
|
queryWrapper.eq(WarnLogs::getId, id);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警日志列表
|
||||||
|
*
|
||||||
|
* @param warnLogs 预警日志
|
||||||
|
* @return 预警日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<WarnLogs> selectWarnLogsList(WarnLogs warnLogs)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<WarnLogs> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(warnLogs.getVin())){
|
||||||
|
queryWrapper.eq(WarnLogs::getVin, warnLogs.getVin());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnLogs.getWarnRuleId())){
|
||||||
|
queryWrapper.eq(WarnLogs::getWarnRuleId, warnLogs.getWarnRuleId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnLogs.getStartTime())){
|
||||||
|
queryWrapper.eq(WarnLogs::getStartTime, warnLogs.getStartTime());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnLogs.getEndTime())){
|
||||||
|
queryWrapper.eq(WarnLogs::getEndTime, warnLogs.getEndTime());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnLogs.getMaxValue())){
|
||||||
|
queryWrapper.eq(WarnLogs::getMaxValue, warnLogs.getMaxValue());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnLogs.getMinValue())){
|
||||||
|
queryWrapper.eq(WarnLogs::getMinValue, warnLogs.getMinValue());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnLogs.getAvgValue())){
|
||||||
|
queryWrapper.eq(WarnLogs::getAvgValue, warnLogs.getAvgValue());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnLogs.getMedianValue())){
|
||||||
|
queryWrapper.eq(WarnLogs::getMedianValue, warnLogs.getMedianValue());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnLogs.getStatus())){
|
||||||
|
queryWrapper.eq(WarnLogs::getStatus, warnLogs.getStatus());
|
||||||
|
}
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一 判断
|
||||||
|
* @param warnLogs 预警日志
|
||||||
|
* @return 预警日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean checkIdUnique(WarnLogs warnLogs) {
|
||||||
|
LambdaQueryWrapper<WarnLogs> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(WarnLogs::getId, warnLogs.getId());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.muyu.warn.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.muyu.warn.mapper.WarnRuleMapper;
|
||||||
|
import com.muyu.warn.domain.WarnRule;
|
||||||
|
import com.muyu.warn.service.IWarnRuleService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警规则Service业务层处理
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WarnRuleServiceImpl
|
||||||
|
extends ServiceImpl<WarnRuleMapper, WarnRule>
|
||||||
|
implements IWarnRuleService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精确查询预警规则
|
||||||
|
*
|
||||||
|
* @param id 预警规则主键
|
||||||
|
* @return 预警规则
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public WarnRule selectWarnRuleById(Long id)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
Assert.notNull(id, "id不可为空");
|
||||||
|
queryWrapper.eq(WarnRule::getId, id);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警规则列表
|
||||||
|
*
|
||||||
|
* @param warnRule 预警规则
|
||||||
|
* @return 预警规则
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<WarnRule> selectWarnRuleList(WarnRule warnRule)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotNull(warnRule.getRuleName())){
|
||||||
|
queryWrapper.like(WarnRule::getRuleName, warnRule.getRuleName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnRule.getStrategyId())){
|
||||||
|
queryWrapper.eq(WarnRule::getStrategyId, warnRule.getStrategyId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnRule.getMsgTypeId())){
|
||||||
|
queryWrapper.eq(WarnRule::getMsgTypeId, warnRule.getMsgTypeId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnRule.getSlideTime())){
|
||||||
|
queryWrapper.eq(WarnRule::getSlideTime, warnRule.getSlideTime());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnRule.getSlideFrequency())){
|
||||||
|
queryWrapper.eq(WarnRule::getSlideFrequency, warnRule.getSlideFrequency());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnRule.getMaxValue())){
|
||||||
|
queryWrapper.eq(WarnRule::getMaxValue, warnRule.getMaxValue());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnRule.getMinValue())){
|
||||||
|
queryWrapper.eq(WarnRule::getMinValue, warnRule.getMinValue());
|
||||||
|
}
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一 判断
|
||||||
|
* @param warnRule 预警规则
|
||||||
|
* @return 预警规则
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean checkIdUnique(WarnRule warnRule) {
|
||||||
|
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(WarnRule::getId, warnRule.getId());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.muyu.warn.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.warn.domain.Resp.WarnStrategyList;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.muyu.warn.mapper.WarnStrategyMapper;
|
||||||
|
import com.muyu.warn.domain.WarnStrategy;
|
||||||
|
import com.muyu.warn.service.IWarnStrategyService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警策略Service业务层处理
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WarnStrategyServiceImpl
|
||||||
|
extends ServiceImpl<WarnStrategyMapper, WarnStrategy>
|
||||||
|
implements IWarnStrategyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WarnStrategyMapper warnStrategyMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精确查询预警策略
|
||||||
|
*
|
||||||
|
* @param id 预警策略主键
|
||||||
|
* @return 预警策略
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public WarnStrategy selectWarnStrategyById(Long id)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<WarnStrategy> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
Assert.notNull(id, "id不可为空");
|
||||||
|
queryWrapper.eq(WarnStrategy::getId, id);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预警策略列表
|
||||||
|
*
|
||||||
|
* @param warnStrategy 预警策略
|
||||||
|
* @return 预警策略
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<WarnStrategy> selectWarnStrategyList(WarnStrategy warnStrategy)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<WarnStrategy> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotNull(warnStrategy.getCarTypeId())){
|
||||||
|
queryWrapper.eq(WarnStrategy::getCarTypeId, warnStrategy.getCarTypeId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnStrategy.getStrategyName())){
|
||||||
|
queryWrapper.like(WarnStrategy::getStrategyName, warnStrategy.getStrategyName());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotNull(warnStrategy.getTemplateId())){
|
||||||
|
queryWrapper.eq(WarnStrategy::getTemplateId, warnStrategy.getTemplateId());
|
||||||
|
}
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一 判断
|
||||||
|
* @param warnStrategy 预警策略
|
||||||
|
* @return 预警策略
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean checkIdUnique(WarnStrategy warnStrategy) {
|
||||||
|
LambdaQueryWrapper<WarnStrategy> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(WarnStrategy::getId, warnStrategy.getId());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<WarnStrategyList> strategyList(WarnStrategy warnStrategy) {
|
||||||
|
return warnStrategyMapper.strategyList(warnStrategy);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9710
|
||||||
|
|
||||||
|
# nacos线上地址
|
||||||
|
nacos:
|
||||||
|
addr: 106.15.136.7:8848
|
||||||
|
user-name: nacos
|
||||||
|
password: nacos
|
||||||
|
namespace: lyb
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: cloud-warn
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# nacos用户名89
|
||||||
|
username: ${nacos.user-name}
|
||||||
|
# nacos密码
|
||||||
|
password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
config:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# nacos用户名
|
||||||
|
username: ${nacos.user-name}
|
||||||
|
# nacos密码
|
||||||
|
password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
# 系统共享配置
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.muyu.system.mapper: DEBUG
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?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.warn.mapper.CarTypeMapper">
|
||||||
|
|
||||||
|
<select id="findById" resultType="com.muyu.warn.domain.CarType">
|
||||||
|
select * from t_car_type where t_car_type.car_type_id = #{catTypeId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?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.warn.mapper.WarnStrategyMapper">
|
||||||
|
|
||||||
|
<select id="strategyList" resultType="com.muyu.warn.domain.Resp.WarnStrategyList">
|
||||||
|
SELECT
|
||||||
|
s.id AS strategy_id,
|
||||||
|
s.msg_id,
|
||||||
|
s.car_type_id,
|
||||||
|
s.strategy_name,
|
||||||
|
r.id AS rule_id,
|
||||||
|
r.max_value,
|
||||||
|
r.min_value,
|
||||||
|
r.msg_type_id,
|
||||||
|
r.rule_name,
|
||||||
|
r.slide_frequency,
|
||||||
|
r.slide_time,
|
||||||
|
r.strategy_id,
|
||||||
|
t_message_type.message_name
|
||||||
|
FROM
|
||||||
|
warn_strategy s
|
||||||
|
LEFT JOIN warn_rule r ON s.id = r.strategy_id
|
||||||
|
LEFT JOIN t_message_type on r.msg_type_id = t_message_type.message_type_id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?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-server</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
|
<artifactId>cloud-weixin-mp</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<!-- SpringBoot Web-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- test -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.dom4j</groupId>
|
||||||
|
<artifactId>dom4j</artifactId>
|
||||||
|
<version>2.1.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
<version>1.4.20</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
<version>2.0.43</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-core</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.muyu;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@ClassName SpringBoot
|
||||||
|
*@Description 描述
|
||||||
|
*@Author YiBo.Liu
|
||||||
|
*@Date 2024/9/17 17:01
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
public class SpringBoot {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(SpringBoot.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.message;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
/**
|
||||||
|
* @ClassName TextMessage
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/17 21:06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@XStreamAlias("item")
|
||||||
|
public class Article {
|
||||||
|
@XStreamAlias("Title")
|
||||||
|
private String title;
|
||||||
|
@XStreamAlias("Description")
|
||||||
|
private String description;
|
||||||
|
@XStreamAlias("PicUrl")
|
||||||
|
private String picUrl;
|
||||||
|
@XStreamAlias("Url")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.muyu.message;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName TextMessage
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/17 21:06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@XStreamAlias("xml")
|
||||||
|
public class NewMessage {
|
||||||
|
@XStreamAlias("ToUserName")
|
||||||
|
private String toUserName;
|
||||||
|
@XStreamAlias("FromUserName")
|
||||||
|
private String fromUserName;
|
||||||
|
@XStreamAlias("CreateTime")
|
||||||
|
private long createTime;
|
||||||
|
@XStreamAlias("MsgType")
|
||||||
|
private String msgType;
|
||||||
|
@XStreamAlias("ArticleCount")
|
||||||
|
private int articleCount;
|
||||||
|
@XStreamAlias("Articles")
|
||||||
|
private List<Article> articles;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.muyu.message;
|
||||||
|
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName TextMessage
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/17 21:06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@XStreamAlias("xml")
|
||||||
|
public class TextMessage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收方账号
|
||||||
|
*/
|
||||||
|
@XStreamAlias("ToUserName")
|
||||||
|
private String toUserName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开发者微信号
|
||||||
|
*/
|
||||||
|
@XStreamAlias("FromUserName")
|
||||||
|
private String fromUserName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@XStreamAlias("CreateTime")
|
||||||
|
private long createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型
|
||||||
|
*/
|
||||||
|
@XStreamAlias("MsgType")
|
||||||
|
private String msgType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息内容
|
||||||
|
*/
|
||||||
|
@XStreamAlias("Content")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.token;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName AccessToken
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/18 15:48
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AccessToken {
|
||||||
|
|
||||||
|
private String access_token;
|
||||||
|
|
||||||
|
private long expires_in;
|
||||||
|
|
||||||
|
public void setExpiresTime(long expiresIn) {
|
||||||
|
this.expires_in = System.currentTimeMillis()+expiresIn*1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否超时
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isExpired() {
|
||||||
|
return System.currentTimeMillis()>this.expires_in;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.util;
|
||||||
|
|
||||||
|
import okhttp3.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class OkHttpUtils {
|
||||||
|
|
||||||
|
private static final OkHttpClient client = new OkHttpClient();
|
||||||
|
|
||||||
|
public static String sendGetRequest(String urlString) {
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(urlString)
|
||||||
|
.build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
return response.body().string();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String sendPostRequest(String urlString, String params) {
|
||||||
|
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), params);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(urlString)
|
||||||
|
.post(requestBody)
|
||||||
|
.build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
return response.body().string();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.muyu.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.muyu.token.AccessToken;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName AccessToken
|
||||||
|
* @Description 描述
|
||||||
|
* @Author YiBo.Liu
|
||||||
|
* @Date 2024/9/18 15:48
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class TokenUtil {
|
||||||
|
private final static String APP_ID = "wx74741af76decd078";
|
||||||
|
|
||||||
|
private final static String APP_SECRET ="540af183133e701051b726f936ebbfe9";
|
||||||
|
|
||||||
|
private static AccessToken accessToken = new AccessToken();
|
||||||
|
|
||||||
|
|
||||||
|
public static void getToken(){
|
||||||
|
String url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s",APP_ID,APP_SECRET);
|
||||||
|
String request = OkHttpUtils.sendGetRequest(url);
|
||||||
|
AccessToken wechatToken = JSON.parseObject(request, AccessToken.class);
|
||||||
|
if (wechatToken != null) {
|
||||||
|
accessToken.setExpiresTime(wechatToken.getExpires_in());
|
||||||
|
accessToken.setAccess_token(wechatToken.getAccess_token());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取AccessToken
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getAccessToken(){
|
||||||
|
getToken();
|
||||||
|
return accessToken.getAccess_token();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.util;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import okhttp3.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class WechatUtil {
|
||||||
|
|
||||||
|
public static void send(String toUser,String content) {
|
||||||
|
String accessToken = TokenUtil.getAccessToken();
|
||||||
|
if (!accessToken.equals("")) {
|
||||||
|
String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + accessToken;
|
||||||
|
String jsonStr = "{\"touser\":\"" + toUser + "\",\"msgtype\":\"text\",\"text\":{\"content\":\"" + content + "\"}}";
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
|
||||||
|
// 构建请求
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonStr, MediaType.get("application/json; charset=utf-8"));
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.post(requestBody)
|
||||||
|
.addHeader("Content-Type", "application/json; charset=utf-8")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
throw new IOException("Unexpected code " + response);
|
||||||
|
}
|
||||||
|
// 输出响应
|
||||||
|
System.out.println(response.body().string());
|
||||||
|
}catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue