作者 钟来

修改bug

正在显示 24 个修改的文件 包含 1537 行增加75 行删除
  1 +package com.zhonglai.luhui.admin.controller.iot;
  2 +
  3 +import com.ruoyi.common.annotation.Log;
  4 +import com.ruoyi.common.core.controller.BaseController;
  5 +import com.ruoyi.common.core.domain.AjaxResult;
  6 +import com.ruoyi.common.core.page.TableDataInfo;
  7 +import com.ruoyi.common.enums.BusinessType;
  8 +import com.ruoyi.common.utils.poi.ExcelUtil;
  9 +import com.ruoyi.system.domain.IotAlert;
  10 +import com.ruoyi.system.service.IIotAlertService;
  11 +import io.swagger.annotations.Api;
  12 +import io.swagger.annotations.ApiImplicitParam;
  13 +import io.swagger.annotations.ApiImplicitParams;
  14 +import io.swagger.annotations.ApiOperation;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.security.access.prepost.PreAuthorize;
  17 +import org.springframework.web.bind.annotation.*;
  18 +
  19 +import javax.servlet.http.HttpServletResponse;
  20 +import java.util.List;
  21 +
  22 +/**
  23 + * 设备告警Controller
  24 + *
  25 + * @author kerwincui
  26 + * @date 2022-01-13
  27 + */
  28 +@Api(tags = "设备告警")
  29 +@RestController
  30 +@RequestMapping("/iot/alert")
  31 +public class IotAlertController extends BaseController
  32 +{
  33 + @Autowired
  34 + private IIotAlertService alertService;
  35 +
  36 + /**
  37 + * 查询设备告警列表
  38 + */
  39 + @ApiOperation("查询设备告警列表")
  40 + @PreAuthorize("@ss.hasPermi('iot:alert:list')")
  41 + @GetMapping("/list")
  42 + public TableDataInfo list(IotAlert alert)
  43 + {
  44 + startPage();
  45 + List<IotAlert> list = alertService.selectAlertList(alert);
  46 + return getDataTable(list);
  47 + }
  48 +
  49 + /**
  50 + * 导出设备告警列表
  51 + */
  52 + @ApiOperation("导出设备告警列表")
  53 + @PreAuthorize("@ss.hasPermi('iot:alert:export')")
  54 + @Log(title = "设备告警", businessType = BusinessType.EXPORT)
  55 + @PostMapping("/export")
  56 + public void export(HttpServletResponse response, IotAlert alert)
  57 + {
  58 + List<IotAlert> list = alertService.selectAlertList(alert);
  59 + ExcelUtil<IotAlert> util = new ExcelUtil<IotAlert>(IotAlert.class);
  60 + util.exportExcel(response, list, "设备告警数据");
  61 + }
  62 +
  63 + /**
  64 + * 获取设备告警详细信息
  65 + */
  66 + @ApiOperation("获取设备告警详细信息")
  67 + @PreAuthorize("@ss.hasPermi('iot:alert:query')")
  68 + @GetMapping(value = "/{alertId}")
  69 + public AjaxResult getInfo(@PathVariable("alertId") Long alertId)
  70 + {
  71 + return AjaxResult.success(alertService.selectAlertByAlertId(alertId));
  72 + }
  73 +
  74 + /**
  75 + * 新增设备告警
  76 + */
  77 + @ApiOperation("新增设备告警")
  78 + @PreAuthorize("@ss.hasPermi('iot:alert:add')")
  79 + @Log(title = "设备告警", businessType = BusinessType.INSERT)
  80 + @PostMapping
  81 + public AjaxResult add(@RequestBody IotAlert alert)
  82 + {
  83 + return toAjax(alertService.insertAlert(alert));
  84 + }
  85 +
  86 + /**
  87 + * 修改设备告警
  88 + */
  89 + @ApiOperation("修改设备告警")
  90 + @PreAuthorize("@ss.hasPermi('iot:alert:edit')")
  91 + @Log(title = "设备告警", businessType = BusinessType.UPDATE)
  92 + @PutMapping
  93 + public AjaxResult edit(@RequestBody IotAlert alert)
  94 + {
  95 + return toAjax(alertService.updateAlert(alert));
  96 + }
  97 +
  98 + /**
  99 + * 删除设备告警
  100 + */
  101 + @ApiOperation("删除设备告警")
  102 + @PreAuthorize("@ss.hasPermi('iot:alert:remove')")
  103 + @Log(title = "设备告警", businessType = BusinessType.DELETE)
  104 + @DeleteMapping("/{alertIds}")
  105 + public AjaxResult remove(@PathVariable Long[] alertIds)
  106 + {
  107 + return toAjax(alertService.deleteAlertByAlertIds(alertIds));
  108 + }
  109 +}
  1 +package com.zhonglai.luhui.admin.controller.iot;
  2 +
  3 +import com.ruoyi.common.annotation.Log;
  4 +import com.ruoyi.common.core.controller.BaseController;
  5 +import com.ruoyi.common.core.domain.AjaxResult;
  6 +import com.ruoyi.common.core.page.TableDataInfo;
  7 +import com.ruoyi.common.enums.BusinessType;
  8 +import com.ruoyi.common.utils.poi.ExcelUtil;
  9 +import com.ruoyi.system.domain.IotAlertLog;
  10 +import com.ruoyi.system.service.IIotAlertLogService;
  11 +import io.swagger.annotations.Api;
  12 +import io.swagger.annotations.ApiOperation;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.security.access.prepost.PreAuthorize;
  15 +import org.springframework.web.bind.annotation.*;
  16 +
  17 +import javax.servlet.http.HttpServletResponse;
  18 +import java.util.List;
  19 +
  20 +/**
  21 + * 设备告警Controller
  22 + *
  23 + * @author kerwincui
  24 + * @date 2022-01-13
  25 + */
  26 +@Api(tags = "设备告警日志")
  27 +@RestController
  28 +@RequestMapping("/iot/alertLog")
  29 +public class IotAlertLogController extends BaseController
  30 +{
  31 + @Autowired
  32 + private IIotAlertLogService alertLogService;
  33 +
  34 + /**
  35 + * 查询设备告警列表
  36 + */
  37 + @ApiOperation("查询设备告警列表")
  38 + @PreAuthorize("@ss.hasPermi('iot:alert:list')")
  39 + @GetMapping("/list")
  40 + public TableDataInfo list(IotAlertLog alertLog)
  41 + {
  42 + startPage();
  43 + List<IotAlertLog> list = alertLogService.selectAlertLogList(alertLog);
  44 + return getDataTable(list);
  45 + }
  46 +
  47 + /**
  48 + * 导出设备告警列表
  49 + */
  50 + @ApiOperation("导出设备告警列表")
  51 + @PreAuthorize("@ss.hasPermi('iot:alert:export')")
  52 + @Log(title = "设备告警", businessType = BusinessType.EXPORT)
  53 + @PostMapping("/export")
  54 + public void export(HttpServletResponse response, IotAlertLog alertLog)
  55 + {
  56 + List<IotAlertLog> list = alertLogService.selectAlertLogList(alertLog);
  57 + ExcelUtil<IotAlertLog> util = new ExcelUtil<IotAlertLog>(IotAlertLog.class);
  58 + util.exportExcel(response, list, "设备告警数据");
  59 + }
  60 +
  61 + /**
  62 + * 获取设备告警详细信息
  63 + */
  64 + @ApiOperation("获取设备告警详细信息")
  65 + @PreAuthorize("@ss.hasPermi('iot:alert:query')")
  66 + @GetMapping(value = "/{alertLogId}")
  67 + public AjaxResult getInfo(@PathVariable("alertLogId") Long alertLogId)
  68 + {
  69 + return AjaxResult.success(alertLogService.selectAlertLogByAlertLogId(alertLogId));
  70 + }
  71 +
  72 + /**
  73 + * 新增设备告警
  74 + */
  75 + @ApiOperation("新增设备告警")
  76 + @PreAuthorize("@ss.hasPermi('iot:alert:add')")
  77 + @Log(title = "设备告警", businessType = BusinessType.INSERT)
  78 + @PostMapping
  79 + public AjaxResult add(@RequestBody IotAlertLog alertLog)
  80 + {
  81 + return toAjax(alertLogService.insertAlertLog(alertLog));
  82 + }
  83 +
  84 + /**
  85 + * 修改设备告警
  86 + */
  87 + @ApiOperation("修改设备告警")
  88 + @PreAuthorize("@ss.hasPermi('iot:alert:edit')")
  89 + @Log(title = "设备告警", businessType = BusinessType.UPDATE)
  90 + @PutMapping
  91 + public AjaxResult edit(@RequestBody IotAlertLog alertLog)
  92 + {
  93 + return toAjax(alertLogService.updateAlertLog(alertLog));
  94 + }
  95 +
  96 + /**
  97 + * 删除设备告警
  98 + */
  99 + @ApiOperation("删除设备告警")
  100 + @PreAuthorize("@ss.hasPermi('iot:alert:remove')")
  101 + @Log(title = "设备告警", businessType = BusinessType.DELETE)
  102 + @DeleteMapping("/{alertLogIds}")
  103 + public AjaxResult remove(@PathVariable Long[] alertLogIds)
  104 + {
  105 + return toAjax(alertLogService.deleteAlertLogByAlertLogIds(alertLogIds));
  106 + }
  107 +}
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
  3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5 + <parent>
  6 + <artifactId>Luhui</artifactId>
  7 + <groupId>com.zhonglai.luhui</groupId>
  8 + <version>1.0-SNAPSHOT</version>
  9 + </parent>
  10 + <modelVersion>4.0.0</modelVersion>
  11 +
  12 + <artifactId>lh-alarm</artifactId>
  13 +
  14 + <dependencies>
  15 + <!-- spring-boot-devtools -->
  16 + <dependency>
  17 + <groupId>org.springframework.boot</groupId>
  18 + <artifactId>spring-boot-devtools</artifactId>
  19 + <optional>true</optional> <!-- 表示依赖不会传递 -->
  20 + </dependency>
  21 +
  22 + <!-- Mysql驱动包 -->
  23 + <dependency>
  24 + <groupId>mysql</groupId>
  25 + <artifactId>mysql-connector-java</artifactId>
  26 + </dependency>
  27 +
  28 + <!-- 核心模块-->
  29 + <dependency>
  30 + <groupId>com.zhonglai.luhui</groupId>
  31 + <artifactId>ruoyi-framework</artifactId>
  32 + </dependency>
  33 + <!-- 文档 -->
  34 + <dependency >
  35 + <groupId>io.springfox</groupId>
  36 + <artifactId>springfox-swagger2</artifactId>
  37 + <version>${swagger.version}</version>
  38 + <exclusions>
  39 + <exclusion>
  40 + <groupId>io.swagger</groupId>
  41 + <artifactId>swagger-models</artifactId>
  42 + </exclusion>
  43 + <exclusion>
  44 + <groupId>com.google.guava</groupId>
  45 + <artifactId>guava</artifactId>
  46 + </exclusion>
  47 + </exclusions>
  48 + </dependency>
  49 + <!--https://mvnrepository.com/artifact/io.swagger/swagger-models-->
  50 + <dependency>
  51 + <groupId>io.swagger</groupId>
  52 + <artifactId>swagger-models</artifactId>
  53 + <version>${swagger-models.version}</version>
  54 + </dependency>
  55 + <dependency>
  56 + <groupId>io.springfox</groupId>
  57 + <artifactId>springfox-swagger-ui</artifactId>
  58 + <version>${swagger.version}</version>
  59 + </dependency>
  60 + <!--&lt;!&ndash; https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui &ndash;&gt;-->
  61 + <dependency>
  62 + <groupId>com.github.xiaoymin</groupId>
  63 + <artifactId>swagger-bootstrap-ui</artifactId>
  64 + <version>${swagger-ui.version}</version>
  65 + </dependency>
  66 + </dependencies>
  67 +
  68 + <build>
  69 + <finalName>lh-alarm</finalName>
  70 + <plugins>
  71 + <plugin>
  72 + <groupId>org.apache.maven.plugins</groupId>
  73 + <artifactId>maven-jar-plugin</artifactId>
  74 + <version>2.4</version>
  75 + <configuration>
  76 + <archive>
  77 + <!--
  78 + 生成的jar中,不要包含pom.xml和pom.properties这两个文件
  79 + -->
  80 + <addMavenDescriptor>false</addMavenDescriptor>
  81 + <manifest>
  82 + <!--
  83 + 是否要把第三方jar放到manifest的classpath中
  84 + -->
  85 + <addClasspath>true</addClasspath>
  86 +
  87 + <!--
  88 + 生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/
  89 + -->
  90 + <classpathPrefix>lib/</classpathPrefix>
  91 + <mainClass>com.zhonglai.luhui.alarm.AlarmApplication</mainClass>
  92 + </manifest>
  93 + </archive>
  94 + </configuration>
  95 + </plugin>
  96 +
  97 + <!-- The configuration of maven-assembly-plugin -->
  98 + <plugin>
  99 + <groupId>org.apache.maven.plugins</groupId>
  100 + <artifactId>maven-assembly-plugin</artifactId>
  101 + <version>2.4</version>
  102 + <configuration>
  103 + <descriptors>
  104 + <descriptor>src/main/resources/package.xml</descriptor>
  105 + </descriptors>
  106 + </configuration>
  107 + <executions>
  108 + <execution>
  109 + <id>make-assembly</id>
  110 + <phase>package</phase>
  111 + <goals>
  112 + <goal>single</goal>
  113 + </goals>
  114 + </execution>
  115 + </executions>
  116 + </plugin>
  117 + </plugins>
  118 + </build>
  119 +</project>
  1 +package com.zhonglai.luhui.alarm;
  2 +
  3 +import com.ruoyi.framework.aspectj.LogAspect;
  4 +import com.ruoyi.framework.aspectj.RateLimiterAspect;
  5 +import com.ruoyi.framework.config.*;
  6 +import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
  7 +import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
  8 +import com.ruoyi.system.login.service.LoginService;
  9 +import com.ruoyi.system.login.service.TokenService;
  10 +import com.ruoyi.system.service.impl.SysConfigServiceImpl;
  11 +import com.ruoyi.system.service.impl.SysDictTypeServiceImpl;
  12 +import com.ruoyi.system.service.impl.SysUserServiceImpl;
  13 +import org.springframework.boot.SpringApplication;
  14 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  15 +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  16 +import org.springframework.context.annotation.ComponentScan;
  17 +import org.springframework.context.annotation.FilterType;
  18 +
  19 +@ComponentScan(basePackages = {
  20 + "com.ruoyi.common",
  21 + "com.ruoyi.system",
  22 + "com.ruoyi.framework",
  23 +},
  24 + excludeFilters = {@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE,classes = {LogAspect.class,
  25 + RateLimiterAspect.class, LoginService.class, TokenService.class, FilterConfig.class, JwtAuthenticationTokenFilter.class,
  26 + SysConfigServiceImpl.class, SysDictTypeServiceImpl.class, SysUserServiceImpl.class,SecurityConfig.class, LogoutSuccessHandlerImpl.class
  27 + })}
  28 +
  29 +)
  30 +@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
  31 +public class AlarmApplication {
  32 + public static void main(String[] args) {
  33 + SpringApplication.run(AlarmApplication.class,args);
  34 + System.out.println("启动成功");
  35 + }
  36 +}
  1 +# 数据源配置
  2 +spring:
  3 + datasource:
  4 + type: com.alibaba.druid.pool.DruidDataSource
  5 + driverClassName: com.mysql.cj.jdbc.Driver
  6 + druid:
  7 + # 主库数据源
  8 + master:
  9 + url: jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
  10 + username: luhui
  11 + password: Luhui586
  12 + # 从库数据源
  13 + slave:
  14 + # 从数据源开关/默认关闭
  15 + enabled: false
  16 + url:
  17 + username:
  18 + password:
  19 + # 初始连接数
  20 + initialSize: 5
  21 + # 最小连接池数量
  22 + minIdle: 10
  23 + # 最大连接池数量
  24 + maxActive: 20
  25 + # 配置获取连接等待超时的时间
  26 + maxWait: 60000
  27 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
  28 + timeBetweenEvictionRunsMillis: 60000
  29 + # 配置一个连接在池中最小生存的时间,单位是毫秒
  30 + minEvictableIdleTimeMillis: 300000
  31 + # 配置一个连接在池中最大生存的时间,单位是毫秒
  32 + maxEvictableIdleTimeMillis: 900000
  33 + # 配置检测连接是否有效
  34 + validationQuery: SELECT 1 FROM DUAL
  35 + testWhileIdle: true
  36 + testOnBorrow: false
  37 + testOnReturn: false
  38 + webStatFilter:
  39 + enabled: true
  40 + statViewServlet:
  41 + enabled: true
  42 + # 设置白名单,不填则允许所有访问
  43 + allow:
  44 + url-pattern: /druid/*
  45 + # 控制台管理用户名和密码
  46 + login-username: ruoyi
  47 + login-password: 123456
  48 + filter:
  49 + stat:
  50 + enabled: true
  51 + # 慢SQL记录
  52 + log-slow-sql: true
  53 + slow-sql-millis: 1000
  54 + merge-sql: true
  55 + wall:
  56 + config:
  57 + multi-statement-allow: true
  1 +# 项目相关配置 jhlt: # 名称 name: zhonglai # 版本 version: 3.8.2 # 版权年份 copyrightYear: 2022 # 获取ip地址开关 addressEnabled: false # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8081 servlet: # 应用的访问路径 context-path: / tomcat: # tomcat的URI编码 uri-encoding: UTF-8 # 连接数满后的排队数,默认为100 accept-count: 1000 threads: # tomcat最大线程数,默认为200 max: 800 # Tomcat启动初始化的线程数,默认值10 min-spare: 100 # 日志配置 logging: level: com.ruoyi: debug org.springframework: warn # Spring配置 spring: # 资源信息 messages: # 国际化资源文件路径 basename: i18n/messages profiles: active: druid # 文件上传 servlet: multipart: # 单个文件大小 max-file-size: 10MB # 设置总上传的文件大小 max-request-size: 20MB # 服务模块 devtools: restart: # 热部署开关 enabled: true # token配置 token: # 令牌自定义标识 header: Authorization # MyBatis配置 mybatis: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 pagehelper: helperDialect: mysql supportMethodsArguments: true params: count=countSql # Swagger配置 swagger: # 是否开启swagger enabled: true # 请求前缀 pathMapping: /dev-api # NameServer地址 rocketmq: name-server: 47.115.144.179:9876 # 默认的消息组 producer: group: deviceCommand send-message-timeout: 30000 send-topic: lh-alarm-test send-tags: 1
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE configuration
  3 +PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  4 +"http://mybatis.org/dtd/mybatis-3-config.dtd">
  5 +<configuration>
  6 + <!-- 全局参数 -->
  7 + <settings>
  8 + <!-- 使全局的映射器启用或禁用缓存 -->
  9 + <setting name="cacheEnabled" value="true" />
  10 + <!-- 允许JDBC 支持自动生成主键 -->
  11 + <setting name="useGeneratedKeys" value="true" />
  12 + <!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
  13 + <setting name="defaultExecutorType" value="SIMPLE" />
  14 + <!-- 指定 MyBatis 所用日志的具体实现 -->
  15 + <setting name="logImpl" value="SLF4J" />
  16 + <!-- 使用驼峰命名法转换字段 -->
  17 + <!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
  18 + </settings>
  19 +
  20 +</configuration>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +
  3 +<assembly>
  4 + <id>bin</id>
  5 + <!-- 最终打包成一个用于发布的zip文件 -->
  6 + <formats>
  7 + <format>zip</format>
  8 + </formats>
  9 +
  10 + <!-- Adds dependencies to zip package under lib directory -->
  11 + <dependencySets>
  12 + <dependencySet>
  13 + <!--
  14 + 不使用项目的artifact,第三方jar不要解压,打包进zip文件的lib目录
  15 + -->
  16 + <useProjectArtifact>false</useProjectArtifact>
  17 + <outputDirectory>lib</outputDirectory>
  18 + <unpack>false</unpack>
  19 + </dependencySet>
  20 + </dependencySets>
  21 +
  22 + <fileSets>
  23 + <!-- 把项目相关的说明文件,打包进zip文件的根目录 -->
  24 + <fileSet>
  25 + <directory>${project.basedir}</directory>
  26 + <outputDirectory>/</outputDirectory>
  27 + <includes>
  28 + <include>README*</include>
  29 + <include>LICENSE*</include>
  30 + <include>NOTICE*</include>
  31 + </includes>
  32 + </fileSet>
  33 +
  34 + <!-- 把项目的配置文件,打包进zip文件的config目录 -->
  35 + <fileSet>
  36 + <directory>${project.basedir}\src\main\resources\configs</directory>
  37 + <outputDirectory>../configs</outputDirectory>
  38 + <includes>
  39 + <include>*.properties</include>
  40 + </includes>
  41 + </fileSet>
  42 +
  43 + <!-- 把项目的配置文件,提出来 -->
  44 + <fileSet>
  45 + <directory>${project.basedir}\src\main\resources</directory>
  46 + <outputDirectory>/</outputDirectory>
  47 + <includes>
  48 + <include>*.properties</include>
  49 + <include>*.yml</include>
  50 + </includes>
  51 + </fileSet>
  52 +
  53 + <!-- 把项目的脚本文件目录( src/main/scripts )中的启动脚本文件,打包进zip文件的跟目录 -->
  54 + <fileSet>
  55 + <directory>${project.basedir}\bin</directory>
  56 + <outputDirectory></outputDirectory>
  57 + <includes>
  58 + <include>start.*</include>
  59 + <include>stop.*</include>
  60 + </includes>
  61 + </fileSet>
  62 +
  63 + <!-- 把项目自己编译出来的jar文件,打包进zip文件的根目录 -->
  64 + <fileSet>
  65 + <directory>${project.build.directory}</directory>
  66 + <outputDirectory></outputDirectory>
  67 + <includes>
  68 + <include>*.jar</include>
  69 + </includes>
  70 + </fileSet>
  71 + </fileSets>
  72 +</assembly>
  1 +package com.ruoyi.system.domain;
  2 +
  3 +import com.ruoyi.system.domain.tool.BaseEntity;
  4 +import org.apache.commons.lang3.builder.ToStringBuilder;
  5 +import org.apache.commons.lang3.builder.ToStringStyle;
  6 +
  7 +import java.io.Serializable;
  8 +
  9 +/**
  10 + * 设备告警对象 iot_alert
  11 + *
  12 + * @author kerwincui
  13 + * @date 2022-01-13
  14 + */
  15 +public class IotAlert extends BaseEntity
  16 +{
  17 + private static final long serialVersionUID = 1L;
  18 +
  19 + /** 告警ID */
  20 + private Long alertId;
  21 +
  22 + /** 告警名称 */
  23 + private String alertName;
  24 +
  25 + /** 告警级别(1=提醒通知,2=轻微问题,3=严重警告) */
  26 + private Long alertLevel;
  27 +
  28 + /** 产品ID */
  29 + private Long productId;
  30 +
  31 + /** 产品名称 */
  32 + private String productName;
  33 +
  34 + /** 触发器 */
  35 + private String triggers;
  36 +
  37 + /** 执行动作 */
  38 + private String actions;
  39 +
  40 + /** 告警状态 (1-启动,2-停止)**/
  41 + private Integer status;
  42 +
  43 + public Integer getStatus() {
  44 + return status;
  45 + }
  46 +
  47 + public void setStatus(Integer status) {
  48 + this.status = status;
  49 + }
  50 +
  51 + public void setAlertId(Long alertId)
  52 + {
  53 + this.alertId = alertId;
  54 + }
  55 +
  56 + public Long getAlertId()
  57 + {
  58 + return alertId;
  59 + }
  60 + public void setAlertName(String alertName)
  61 + {
  62 + this.alertName = alertName;
  63 + }
  64 +
  65 + public String getAlertName()
  66 + {
  67 + return alertName;
  68 + }
  69 + public void setAlertLevel(Long alertLevel)
  70 + {
  71 + this.alertLevel = alertLevel;
  72 + }
  73 +
  74 + public Long getAlertLevel()
  75 + {
  76 + return alertLevel;
  77 + }
  78 + public void setProductId(Long productId)
  79 + {
  80 + this.productId = productId;
  81 + }
  82 +
  83 + public Long getProductId()
  84 + {
  85 + return productId;
  86 + }
  87 + public void setProductName(String productName)
  88 + {
  89 + this.productName = productName;
  90 + }
  91 +
  92 + public String getProductName()
  93 + {
  94 + return productName;
  95 + }
  96 + public void setTriggers(String triggers)
  97 + {
  98 + this.triggers = triggers;
  99 + }
  100 +
  101 + public String getTriggers()
  102 + {
  103 + return triggers;
  104 + }
  105 + public void setActions(String actions)
  106 + {
  107 + this.actions = actions;
  108 + }
  109 +
  110 + public String getActions()
  111 + {
  112 + return actions;
  113 + }
  114 +
  115 + @Override
  116 + public String toString() {
  117 + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
  118 + .append("alertId", getAlertId())
  119 + .append("alertName", getAlertName())
  120 + .append("alertLevel", getAlertLevel())
  121 + .append("productId", getProductId())
  122 + .append("productName", getProductName())
  123 + .append("triggers", getTriggers())
  124 + .append("actions", getActions())
  125 + .toString();
  126 + }
  127 +}
  1 +package com.ruoyi.system.domain;
  2 +
  3 +import com.ruoyi.system.domain.tool.BaseEntity;
  4 +import org.apache.commons.lang3.builder.ToStringBuilder;
  5 +import org.apache.commons.lang3.builder.ToStringStyle;
  6 +
  7 +/**
  8 + * 设备告警对象 iot_alert_log
  9 + *
  10 + * @author kerwincui
  11 + * @date 2022-01-13
  12 + */
  13 +public class IotAlertLog extends BaseEntity
  14 +{
  15 + private static final long serialVersionUID = 1L;
  16 +
  17 + /** 告警ID */
  18 + private Long alertLogId;
  19 +
  20 + /** 告警名称 */
  21 + private String alertName;
  22 +
  23 + /** 告警级别(1=提醒通知,2=轻微问题,3=严重警告,4=场景联动) */
  24 + private Long alertLevel;
  25 +
  26 + /** 处理状态(0=不需要处理,1=未处理,2=已处理) */
  27 + private Long status;
  28 +
  29 + /** 产品ID */
  30 + private Long productId;
  31 +
  32 + /** 产品名称 */
  33 + private String productName;
  34 +
  35 + /** 设备ID */
  36 + private Long deviceId;
  37 +
  38 + /** 设备名称 */
  39 + private String deviceName;
  40 +
  41 + /** 用户ID */
  42 + private Long userId;
  43 +
  44 + /** 用户昵称 */
  45 + private String userName;
  46 +
  47 + /** 租户ID */
  48 + private Long tenantId;
  49 +
  50 + /** 租户名称 */
  51 + private String tenantName;
  52 +
  53 + public Long getUserId() {
  54 + return userId;
  55 + }
  56 +
  57 + public void setUserId(Long userId) {
  58 + this.userId = userId;
  59 + }
  60 +
  61 + public String getUserName() {
  62 + return userName;
  63 + }
  64 +
  65 + public void setUserName(String userName) {
  66 + this.userName = userName;
  67 + }
  68 +
  69 + public Long getTenantId() {
  70 + return tenantId;
  71 + }
  72 +
  73 + public void setTenantId(Long tenantId) {
  74 + this.tenantId = tenantId;
  75 + }
  76 +
  77 + public String getTenantName() {
  78 + return tenantName;
  79 + }
  80 +
  81 + public void setTenantName(String tenantName) {
  82 + this.tenantName = tenantName;
  83 + }
  84 +
  85 + public void setAlertLogId(Long alertLogId)
  86 + {
  87 + this.alertLogId = alertLogId;
  88 + }
  89 +
  90 + public Long getAlertLogId()
  91 + {
  92 + return alertLogId;
  93 + }
  94 + public void setAlertName(String alertLogName)
  95 + {
  96 + this.alertName = alertLogName;
  97 + }
  98 +
  99 + public String getAlertName()
  100 + {
  101 + return alertName;
  102 + }
  103 + public void setAlertLevel(Long alertLevel)
  104 + {
  105 + this.alertLevel = alertLevel;
  106 + }
  107 +
  108 + public Long getAlertLevel()
  109 + {
  110 + return alertLevel;
  111 + }
  112 + public void setStatus(Long status)
  113 + {
  114 + this.status = status;
  115 + }
  116 +
  117 + public Long getStatus()
  118 + {
  119 + return status;
  120 + }
  121 + public void setProductId(Long productId)
  122 + {
  123 + this.productId = productId;
  124 + }
  125 +
  126 + public Long getProductId()
  127 + {
  128 + return productId;
  129 + }
  130 + public void setProductName(String productName)
  131 + {
  132 + this.productName = productName;
  133 + }
  134 +
  135 + public String getProductName()
  136 + {
  137 + return productName;
  138 + }
  139 + public void setDeviceId(Long deviceId)
  140 + {
  141 + this.deviceId = deviceId;
  142 + }
  143 +
  144 + public Long getDeviceId()
  145 + {
  146 + return deviceId;
  147 + }
  148 + public void setDeviceName(String deviceName)
  149 + {
  150 + this.deviceName = deviceName;
  151 + }
  152 +
  153 + public String getDeviceName()
  154 + {
  155 + return deviceName;
  156 + }
  157 +
  158 + @Override
  159 + public String toString() {
  160 + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
  161 + .append("alertLogId", getAlertLogId())
  162 + .append("alertName", getAlertName())
  163 + .append("alertLevel", getAlertLevel())
  164 + .append("status", getStatus())
  165 + .append("productId", getProductId())
  166 + .append("productName", getProductName())
  167 + .append("deviceId", getDeviceId())
  168 + .append("deviceName", getDeviceName())
  169 + .append("createBy", getCreateBy())
  170 + .append("createTime", getCreateTime())
  171 + .append("updateBy", getUpdateBy())
  172 + .append("updateTime", getUpdateTime())
  173 + .append("remark", getRemark())
  174 + .toString();
  175 + }
  176 +}
@@ -172,19 +172,6 @@ @@ -172,19 +172,6 @@
172 <artifactId>rocketmq-spring-boot-starter</artifactId> 172 <artifactId>rocketmq-spring-boot-starter</artifactId>
173 </dependency> 173 </dependency>
174 174
175 - <!-- 日志 -->  
176 - <dependency>  
177 - <groupId>org.slf4j</groupId>  
178 - <artifactId>slf4j-api</artifactId>  
179 - </dependency>  
180 - <dependency>  
181 - <groupId>org.slf4j</groupId>  
182 - <artifactId>slf4j-log4j12</artifactId>  
183 - </dependency>  
184 - <dependency>  
185 - <groupId>log4j</groupId>  
186 - <artifactId>log4j</artifactId>  
187 - </dependency>  
188 </dependencies> 175 </dependencies>
189 176
190 <build> 177 <build>
1 package com.zhonglai.luhui.mqtt.comm.service; 1 package com.zhonglai.luhui.mqtt.comm.service;
2 2
3 -import com.alibaba.fastjson.JSON;  
4 import com.ruoyi.system.domain.IotDevice; 3 import com.ruoyi.system.domain.IotDevice;
5 import com.zhonglai.luhui.mqtt.comm.dto.ServerDto; 4 import com.zhonglai.luhui.mqtt.comm.dto.ServerDto;
6 import com.zhonglai.luhui.mqtt.comm.dto.business.BusinessDto; 5 import com.zhonglai.luhui.mqtt.comm.dto.business.BusinessDto;
@@ -9,12 +8,8 @@ import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreement; @@ -9,12 +8,8 @@ import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreement;
9 import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreementFactory; 8 import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreementFactory;
10 import com.zhonglai.luhui.mqtt.comm.factory.Topic; 9 import com.zhonglai.luhui.mqtt.comm.factory.Topic;
11 import com.zhonglai.luhui.mqtt.comm.util.ByteUtil; 10 import com.zhonglai.luhui.mqtt.comm.util.ByteUtil;
12 -import com.zhonglai.luhui.mqtt.comm.util.DateUtils;  
13 import com.zhonglai.luhui.mqtt.service.db.DeviceService; 11 import com.zhonglai.luhui.mqtt.service.db.DeviceService;
14 import lombok.SneakyThrows; 12 import lombok.SneakyThrows;
15 -import org.apache.log4j.FileAppender;  
16 -import org.apache.log4j.PatternLayout;  
17 -import org.apache.log4j.RollingFileAppender;  
18 import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; 13 import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
19 import org.eclipse.paho.client.mqttv3.MqttCallbackExtended; 14 import org.eclipse.paho.client.mqttv3.MqttCallbackExtended;
20 import org.eclipse.paho.client.mqttv3.MqttException; 15 import org.eclipse.paho.client.mqttv3.MqttException;
@@ -24,8 +19,6 @@ import org.slf4j.LoggerFactory; @@ -24,8 +19,6 @@ import org.slf4j.LoggerFactory;
24 import org.springframework.beans.factory.annotation.Autowired; 19 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.stereotype.Component; 20 import org.springframework.stereotype.Component;
26 21
27 -import java.util.Date;  
28 -  
29 @Component 22 @Component
30 public class MqttCallback implements MqttCallbackExtended { 23 public class MqttCallback implements MqttCallbackExtended {
31 private static final Logger log = LoggerFactory.getLogger(MqttCallback.class); 24 private static final Logger log = LoggerFactory.getLogger(MqttCallback.class);
@@ -76,12 +69,12 @@ public class MqttCallback implements MqttCallbackExtended { @@ -76,12 +69,12 @@ public class MqttCallback implements MqttCallbackExtended {
76 if(null == topic) 69 if(null == topic)
77 { 70 {
78 log.error("消息{},topic为空,不做解析"); 71 log.error("消息{},topic为空,不做解析");
79 - getLoggerByName("error").error("消息《"+s+"》解析为空 》》》内容:\r\n"+buffer.toString()); 72 +// getLoggerByName("error").error("消息《"+s+"》解析为空 》》》内容:\r\n"+buffer.toString());
80 return; 73 return;
81 } 74 }
82 75
83 //日志记录 76 //日志记录
84 - getLoggerByName(topic.getClientid()).info(buffer.toString()); 77 +// getLoggerByName(topic.getClientid()).info(buffer.toString());
85 78
86 //准备数据 79 //准备数据
87 byte[] data = mqttMessage.getPayload(); 80 byte[] data = mqttMessage.getPayload();
@@ -128,37 +121,37 @@ public class MqttCallback implements MqttCallbackExtended { @@ -128,37 +121,37 @@ public class MqttCallback implements MqttCallbackExtended {
128 } 121 }
129 } 122 }
130 123
131 - public static org.apache.log4j.Logger getLoggerByName(String name) {  
132 - // 生成新的Logger  
133 - // 如果已經有了一個Logger實例返回現有的  
134 - org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(name);  
135 - // 清空Appender。特別是不想使用現存實例時一定要初期化  
136 - logger.removeAllAppenders();  
137 - // 設定Logger級別。  
138 -// logger.setLevel(Level.DEBUG);  
139 - // 設定是否繼承父Logger。  
140 - // 默認為true。繼承root輸出。  
141 - // 設定false後將不輸出root。  
142 - logger.setAdditivity(true);  
143 - // 生成新的Appender  
144 - FileAppender appender = new RollingFileAppender();  
145 - PatternLayout layout = new PatternLayout();  
146 - // log的输出形式  
147 - String conversionPattern = "%d{HH:mm:ss} [%p] -%m%n";  
148 - layout.setConversionPattern(conversionPattern);  
149 - appender.setLayout(layout);  
150 - // log输出路径  
151 - // 这里使用了环境变量[catalina.home],只有在tomcat环境下才可以取到  
152 -// String tomcatPath = java.lang.System.getProperty("catalina.home");  
153 - appender.setFile( "logs/" + name+"_"+ DateUtils.parseDateToStr("yyyyMMdd",new Date()) + ".log");  
154 - // log的文字码  
155 - appender.setEncoding("UTF-8");  
156 - // true:在已存在log文件后面追加 false:新log覆盖以前的log  
157 - appender.setAppend(true);  
158 - // 适用当前配置  
159 - appender.activateOptions();  
160 - // 将新的Appender加到Logger中  
161 - logger.addAppender(appender);  
162 - return logger;  
163 - } 124 +// public static org.apache.log4j.Logger getLoggerByName(String name) {
  125 +// // 生成新的Logger
  126 +// // 如果已經有了一個Logger實例返回現有的
  127 +// org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(name);
  128 +// // 清空Appender。特別是不想使用現存實例時一定要初期化
  129 +// logger.removeAllAppenders();
  130 +// // 設定Logger級別。
  131 +//// logger.setLevel(Level.DEBUG);
  132 +// // 設定是否繼承父Logger。
  133 +// // 默認為true。繼承root輸出。
  134 +// // 設定false後將不輸出root。
  135 +// logger.setAdditivity(true);
  136 +// // 生成新的Appender
  137 +// FileAppender appender = new RollingFileAppender();
  138 +// PatternLayout layout = new PatternLayout();
  139 +// // log的输出形式
  140 +// String conversionPattern = "%d{HH:mm:ss} [%p] -%m%n";
  141 +// layout.setConversionPattern(conversionPattern);
  142 +// appender.setLayout(layout);
  143 +// // log输出路径
  144 +// // 这里使用了环境变量[catalina.home],只有在tomcat环境下才可以取到
  145 +//// String tomcatPath = java.lang.System.getProperty("catalina.home");
  146 +// appender.setFile( "logs/" + name+"_"+ DateUtils.parseDateToStr("yyyyMMdd",new Date()) + ".log");
  147 +// // log的文字码
  148 +// appender.setEncoding("UTF-8");
  149 +// // true:在已存在log文件后面追加 false:新log覆盖以前的log
  150 +// appender.setAppend(true);
  151 +// // 适用当前配置
  152 +// appender.activateOptions();
  153 +// // 将新的Appender加到Logger中
  154 +// logger.addAppender(appender);
  155 +// return logger;
  156 +// }
164 } 157 }
@@ -29,7 +29,6 @@ public class DeviceCommandApi { @@ -29,7 +29,6 @@ public class DeviceCommandApi {
29 case delIotTerminal: 29 case delIotTerminal:
30 return deviceService.delIotTerminal(deviceCommandApiParameter.getClient_id(),deviceCommandApiParameter.getNumber()); 30 return deviceService.delIotTerminal(deviceCommandApiParameter.getClient_id(),deviceCommandApiParameter.getNumber());
31 case getFirmwareVersion: 31 case getFirmwareVersion:
32 - deviceCommandApiParameter.setClient_id(deviceCommandApiParameter.getData());  
33 return deviceService.getFirmwareVersion(deviceCommandApiParameter.getData()); 32 return deviceService.getFirmwareVersion(deviceCommandApiParameter.getData());
34 case updateIotDevice: 33 case updateIotDevice:
35 IotDevice iotDevice = JSONObject.parseObject(JSONObject.toJSONString(deviceCommandApiParameter.getMap()), IotDevice.class); 34 IotDevice iotDevice = JSONObject.parseObject(JSONObject.toJSONString(deviceCommandApiParameter.getMap()), IotDevice.class);
@@ -65,5 +65,5 @@ sys: @@ -65,5 +65,5 @@ sys:
65 rocketmq: 65 rocketmq:
66 #nameservice服务器地址(多个以英文逗号隔开) 66 #nameservice服务器地址(多个以英文逗号隔开)
67 name-server: 47.115.144.179:9876 67 name-server: 47.115.144.179:9876
68 - send-topic: lh-mqtt-service-deviceCommand-test 68 + send-topic: lh-mqtt-service-deviceCommand-test1
69 send-tag: 1 69 send-tag: 1
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 <module>lh-api</module> 18 <module>lh-api</module>
19 <module>lh-central-control</module> 19 <module>lh-central-control</module>
20 <module>lh-backups</module> 20 <module>lh-backups</module>
  21 + <module>lh-alarm</module>
21 </modules> 22 </modules>
22 23
23 <packaging>pom</packaging> 24 <packaging>pom</packaging>
@@ -339,23 +340,6 @@ @@ -339,23 +340,6 @@
339 <version>2.1.1</version> 340 <version>2.1.1</version>
340 </dependency> 341 </dependency>
341 342
342 - <!-- 日志 -->  
343 - <dependency>  
344 - <groupId>org.slf4j</groupId>  
345 - <artifactId>slf4j-api</artifactId>  
346 - <version>1.7.24</version>  
347 - </dependency>  
348 - <dependency>  
349 - <groupId>org.slf4j</groupId>  
350 - <artifactId>slf4j-log4j12</artifactId>  
351 - <version>1.7.24</version>  
352 - </dependency>  
353 - <dependency>  
354 - <groupId>log4j</groupId>  
355 - <artifactId>log4j</artifactId>  
356 - <version>1.2.17</version>  
357 - </dependency>  
358 -  
359 </dependencies> 343 </dependencies>
360 344
361 345
  1 +package com.ruoyi.system.mapper;
  2 +
  3 +import com.ruoyi.system.domain.IotAlertLog;
  4 +import org.springframework.stereotype.Repository;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * 设备告警Mapper接口
  10 + *
  11 + * @author kerwincui
  12 + * @date 2022-01-13
  13 + */
  14 +@Repository
  15 +public interface IotAlertLogMapper
  16 +{
  17 + /**
  18 + * 查询设备告警
  19 + *
  20 + * @param alertLogId 设备告警主键
  21 + * @return 设备告警
  22 + */
  23 + public IotAlertLog selectAlertLogByAlertLogId(Long alertLogId);
  24 +
  25 + /**
  26 + * 查询设备告警列表
  27 + *
  28 + * @param alertLog 设备告警
  29 + * @return 设备告警集合
  30 + */
  31 + public List<IotAlertLog> selectAlertLogList(IotAlertLog alertLog);
  32 +
  33 + /**
  34 + * 新增设备告警
  35 + *
  36 + * @param alertLog 设备告警
  37 + * @return 结果
  38 + */
  39 + public int insertAlertLog(IotAlertLog alertLog);
  40 +
  41 + /**
  42 + * 修改设备告警
  43 + *
  44 + * @param alertLog 设备告警
  45 + * @return 结果
  46 + */
  47 + public int updateAlertLog(IotAlertLog alertLog);
  48 +
  49 + /**
  50 + * 删除设备告警
  51 + *
  52 + * @param alertLogId 设备告警主键
  53 + * @return 结果
  54 + */
  55 + public int deleteAlertLogByAlertLogId(Long alertLogId);
  56 +
  57 + /**
  58 + * 批量删除设备告警
  59 + *
  60 + * @param alertLogIds 需要删除的数据主键集合
  61 + * @return 结果
  62 + */
  63 + public int deleteAlertLogByAlertLogIds(Long[] alertLogIds);
  64 +}
  1 +package com.ruoyi.system.mapper;
  2 +
  3 +import com.ruoyi.system.domain.IotAlert;
  4 +import com.ruoyi.system.domain.IotDevice;
  5 +import org.springframework.stereotype.Repository;
  6 +
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * 设备告警Mapper接口
  11 + *
  12 + * @author kerwincui
  13 + * @date 2022-01-13
  14 + */
  15 +@Repository
  16 +public interface IotAlertMapper
  17 +{
  18 + /**
  19 + * 查询设备告警
  20 + *
  21 + * @param alertId 设备告警主键
  22 + * @return 设备告警
  23 + */
  24 + public IotAlert selectAlertByAlertId(Long alertId);
  25 +
  26 + /**
  27 + * 查询设备告警列表
  28 + *
  29 + * @param alert 设备告警
  30 + * @return 设备告警集合
  31 + */
  32 + public List<IotAlert> selectAlertList(IotAlert alert);
  33 +
  34 + /**
  35 + * 新增设备告警
  36 + *
  37 + * @param alert 设备告警
  38 + * @return 结果
  39 + */
  40 + public int insertAlert(IotAlert alert);
  41 +
  42 + /**
  43 + * 修改设备告警
  44 + *
  45 + * @param alert 设备告警
  46 + * @return 结果
  47 + */
  48 + public int updateAlert(IotAlert alert);
  49 +
  50 + /**
  51 + * 删除设备告警
  52 + *
  53 + * @param alertId 设备告警主键
  54 + * @return 结果
  55 + */
  56 + public int deleteAlertByAlertId(Long alertId);
  57 +
  58 + /**
  59 + * 批量删除设备告警
  60 + *
  61 + * @param alertIds 需要删除的数据主键集合
  62 + * @return 结果
  63 + */
  64 + public int deleteAlertByAlertIds(Long[] alertIds);
  65 +}
  1 +package com.ruoyi.system.service;
  2 +
  3 +import com.ruoyi.system.domain.IotAlertLog;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 设备告警Service接口
  9 + *
  10 + * @author kerwincui
  11 + * @date 2022-01-13
  12 + */
  13 +public interface IIotAlertLogService
  14 +{
  15 + /**
  16 + * 查询设备告警
  17 + *
  18 + * @param alertLogId 设备告警主键
  19 + * @return 设备告警
  20 + */
  21 + public IotAlertLog selectAlertLogByAlertLogId(Long alertLogId);
  22 +
  23 + /**
  24 + * 查询设备告警列表
  25 + *
  26 + * @param alertLog 设备告警
  27 + * @return 设备告警集合
  28 + */
  29 + public List<IotAlertLog> selectAlertLogList(IotAlertLog alertLog);
  30 +
  31 + /**
  32 + * 新增设备告警
  33 + *
  34 + * @param alertLog 设备告警
  35 + * @return 结果
  36 + */
  37 + public int insertAlertLog(IotAlertLog alertLog);
  38 +
  39 + /**
  40 + * 修改设备告警
  41 + *
  42 + * @param alertLog 设备告警
  43 + * @return 结果
  44 + */
  45 + public int updateAlertLog(IotAlertLog alertLog);
  46 +
  47 + /**
  48 + * 批量删除设备告警
  49 + *
  50 + * @param alertLogIds 需要删除的设备告警主键集合
  51 + * @return 结果
  52 + */
  53 + public int deleteAlertLogByAlertLogIds(Long[] alertLogIds);
  54 +
  55 + /**
  56 + * 删除设备告警信息
  57 + *
  58 + * @param alertLogId 设备告警主键
  59 + * @return 结果
  60 + */
  61 + public int deleteAlertLogByAlertLogId(Long alertLogId);
  62 +}
  1 +package com.ruoyi.system.service;
  2 +
  3 +import com.ruoyi.system.domain.IotAlert;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 设备告警Service接口
  9 + *
  10 + * @author kerwincui
  11 + * @date 2022-01-13
  12 + */
  13 +public interface IIotAlertService
  14 +{
  15 + /**
  16 + * 查询设备告警
  17 + *
  18 + * @param alertId 设备告警主键
  19 + * @return 设备告警
  20 + */
  21 + public IotAlert selectAlertByAlertId(Long alertId);
  22 +
  23 + /**
  24 + * 查询设备告警列表
  25 + *
  26 + * @param alert 设备告警
  27 + * @return 设备告警集合
  28 + */
  29 + public List<IotAlert> selectAlertList(IotAlert alert);
  30 +
  31 + /**
  32 + * 新增设备告警
  33 + *
  34 + * @param alert 设备告警
  35 + * @return 结果
  36 + */
  37 + public int insertAlert(IotAlert alert);
  38 +
  39 + /**
  40 + * 修改设备告警
  41 + *
  42 + * @param alert 设备告警
  43 + * @return 结果
  44 + */
  45 + public int updateAlert(IotAlert alert);
  46 +
  47 + /**
  48 + * 批量删除设备告警
  49 + *
  50 + * @param alertIds 需要删除的设备告警主键集合
  51 + * @return 结果
  52 + */
  53 + public int deleteAlertByAlertIds(Long[] alertIds);
  54 +
  55 + /**
  56 + * 删除设备告警信息
  57 + *
  58 + * @param alertId 设备告警主键
  59 + * @return 结果
  60 + */
  61 + public int deleteAlertByAlertId(Long alertId);
  62 +}
  1 +package com.ruoyi.system.service.impl;
  2 +
  3 +import com.ruoyi.common.utils.DateUtils;
  4 +import com.ruoyi.system.domain.IotAlertLog;
  5 +import com.ruoyi.system.mapper.IotAlertLogMapper;
  6 +import com.ruoyi.system.service.IIotAlertLogService;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * 设备告警Service业务层处理
  14 + *
  15 + * @author kerwincui
  16 + * @date 2022-01-13
  17 + */
  18 +@Service
  19 +public class IotAlertLogServiceImpl implements IIotAlertLogService
  20 +{
  21 + @Autowired
  22 + private IotAlertLogMapper alertLogMapper;
  23 +
  24 + /**
  25 + * 查询设备告警
  26 + *
  27 + * @param alertLogId 设备告警主键
  28 + * @return 设备告警
  29 + */
  30 + @Override
  31 + public IotAlertLog selectAlertLogByAlertLogId(Long alertLogId)
  32 + {
  33 + return alertLogMapper.selectAlertLogByAlertLogId(alertLogId);
  34 + }
  35 +
  36 + /**
  37 + * 查询设备告警列表
  38 + *
  39 + * @param alertLog 设备告警
  40 + * @return 设备告警
  41 + */
  42 + @Override
  43 + public List<IotAlertLog> selectAlertLogList(IotAlertLog alertLog)
  44 + {
  45 + return alertLogMapper.selectAlertLogList(alertLog);
  46 + }
  47 +
  48 + /**
  49 + * 新增设备告警
  50 + *
  51 + * @param alertLog 设备告警
  52 + * @return 结果
  53 + */
  54 + @Override
  55 + public int insertAlertLog(IotAlertLog alertLog)
  56 + {
  57 + alertLog.setCreateTime(DateUtils.getNowDate());
  58 + return alertLogMapper.insertAlertLog(alertLog);
  59 + }
  60 +
  61 + /**
  62 + * 修改设备告警
  63 + *
  64 + * @param alertLog 设备告警
  65 + * @return 结果
  66 + */
  67 + @Override
  68 + public int updateAlertLog(IotAlertLog alertLog)
  69 + {
  70 + alertLog.setUpdateTime(DateUtils.getNowDate());
  71 + return alertLogMapper.updateAlertLog(alertLog);
  72 + }
  73 +
  74 + /**
  75 + * 批量删除设备告警
  76 + *
  77 + * @param alertLogIds 需要删除的设备告警主键
  78 + * @return 结果
  79 + */
  80 + @Override
  81 + public int deleteAlertLogByAlertLogIds(Long[] alertLogIds)
  82 + {
  83 + return alertLogMapper.deleteAlertLogByAlertLogIds(alertLogIds);
  84 + }
  85 +
  86 + /**
  87 + * 删除设备告警信息
  88 + *
  89 + * @param alertLogId 设备告警主键
  90 + * @return 结果
  91 + */
  92 + @Override
  93 + public int deleteAlertLogByAlertLogId(Long alertLogId)
  94 + {
  95 + return alertLogMapper.deleteAlertLogByAlertLogId(alertLogId);
  96 + }
  97 +}
  1 +package com.ruoyi.system.service.impl;
  2 +
  3 +import com.ruoyi.common.utils.DateUtils;
  4 +import com.ruoyi.system.domain.IotAlert;
  5 +import com.ruoyi.system.mapper.IotAlertMapper;
  6 +import com.ruoyi.system.service.IIotAlertService;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * 设备告警Service业务层处理
  14 + *
  15 + * @author kerwincui
  16 + * @date 2022-01-13
  17 + */
  18 +@Service
  19 +public class IotAlertServiceImpl implements IIotAlertService
  20 +{
  21 + @Autowired
  22 + private IotAlertMapper alertMapper;
  23 +
  24 + /**
  25 + * 查询设备告警
  26 + *
  27 + * @param alertId 设备告警主键
  28 + * @return 设备告警
  29 + */
  30 + @Override
  31 + public IotAlert selectAlertByAlertId(Long alertId)
  32 + {
  33 + return alertMapper.selectAlertByAlertId(alertId);
  34 + }
  35 +
  36 + /**
  37 + * 查询设备告警列表
  38 + *
  39 + * @param alert 设备告警
  40 + * @return 设备告警
  41 + */
  42 + @Override
  43 + public List<IotAlert> selectAlertList(IotAlert alert)
  44 + {
  45 + return alertMapper.selectAlertList(alert);
  46 + }
  47 +
  48 + /**
  49 + * 新增设备告警
  50 + *
  51 + * @param alert 设备告警
  52 + * @return 结果
  53 + */
  54 + @Override
  55 + public int insertAlert(IotAlert alert)
  56 + {
  57 + alert.setCreateTime(DateUtils.getNowDate());
  58 + return alertMapper.insertAlert(alert);
  59 + }
  60 +
  61 + /**
  62 + * 修改设备告警
  63 + *
  64 + * @param alert 设备告警
  65 + * @return 结果
  66 + */
  67 + @Override
  68 + public int updateAlert(IotAlert alert)
  69 + {
  70 + alert.setUpdateTime(DateUtils.getNowDate());
  71 + return alertMapper.updateAlert(alert);
  72 + }
  73 +
  74 + /**
  75 + * 批量删除设备告警
  76 + *
  77 + * @param alertIds 需要删除的设备告警主键
  78 + * @return 结果
  79 + */
  80 + @Override
  81 + public int deleteAlertByAlertIds(Long[] alertIds)
  82 + {
  83 + return alertMapper.deleteAlertByAlertIds(alertIds);
  84 + }
  85 +
  86 + /**
  87 + * 删除设备告警信息
  88 + *
  89 + * @param alertId 设备告警主键
  90 + * @return 结果
  91 + */
  92 + @Override
  93 + public int deleteAlertByAlertId(Long alertId)
  94 + {
  95 + return alertMapper.deleteAlertByAlertId(alertId);
  96 + }
  97 +}
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper
  3 +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 +"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.ruoyi.system.mapper.IotAlertLogMapper">
  6 +
  7 + <resultMap type="com.ruoyi.system.domain.IotAlertLog" id="AlertLogResult">
  8 + <result property="alertLogId" column="alert_log__id" />
  9 + <result property="alertName" column="alert_name" />
  10 + <result property="alertLevel" column="alert_level" />
  11 + <result property="status" column="status" />
  12 + <result property="productId" column="product_id" />
  13 + <result property="productName" column="product_name" />
  14 + <result property="deviceId" column="device_id" />
  15 + <result property="deviceName" column="device_name" />
  16 + <result property="createBy" column="create_by" />
  17 + <result property="createTime" column="create_time" />
  18 + <result property="updateBy" column="update_by" />
  19 + <result property="updateTime" column="update_time" />
  20 + <result property="remark" column="remark" />
  21 + <result property="userId" column="user_id" />
  22 + <result property="userName" column="user_name" />
  23 + <result property="tenantId" column="tenant_id" />
  24 + <result property="tenantName" column="tenant_name" />
  25 + </resultMap>
  26 +
  27 + <sql id="selectAlertLogVo">
  28 + select alert_log__id, alert_name, alert_level, status, product_id, product_name, device_id, device_name,user_id, user_name, tenant_id, tenant_name, create_by, create_time, update_by, update_time, remark from iot_alert_log
  29 + </sql>
  30 +
  31 + <select id="selectAlertLogList" parameterType="com.ruoyi.system.domain.IotAlertLog" resultMap="AlertLogResult">
  32 + <include refid="selectAlertLogVo"/>
  33 + <where>
  34 + <if test="userId != null and userId != 0"> and user_id = #{userId}</if>
  35 + <if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
  36 + <if test="alertName != null and alertName != ''"> and alert_name like concat('%', #{alertName}, '%')</if>
  37 + <if test="alertLevel != null "> and alert_level = #{alertLevel}</if>
  38 + <if test="status != null "> and status = #{status}</if>
  39 + <if test="productId != null "> and product_id = #{productId}</if>
  40 + <if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
  41 + <if test="deviceId != null "> and device_id = #{deviceId}</if>
  42 + <if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
  43 + </where>
  44 + </select>
  45 +
  46 + <select id="selectAlertLogByAlertLogId" parameterType="Long" resultMap="AlertLogResult">
  47 + <include refid="selectAlertLogVo"/>
  48 + where alert_log__id = #{alertLogId}
  49 + </select>
  50 +
  51 + <insert id="insertAlertLog" parameterType="com.ruoyi.system.domain.IotAlertLog" useGeneratedKeys="true" keyProperty="alertLogId">
  52 + insert into iot_alert_log
  53 + <trim prefix="(" suffix=")" suffixOverrides=",">
  54 + <if test="alertName != null and alertName != ''">alert_name,</if>
  55 + <if test="alertLevel != null">alert_level,</if>
  56 + <if test="status != null">status,</if>
  57 + <if test="productId != null">product_id,</if>
  58 + <if test="productName != null and productName != ''">product_name,</if>
  59 + <if test="deviceId != null">device_id,</if>
  60 + <if test="deviceName != null and deviceName != ''">device_name,</if>
  61 + <if test="createBy != null">create_by,</if>
  62 + <if test="createTime != null">create_time,</if>
  63 + <if test="updateBy != null">update_by,</if>
  64 + <if test="updateTime != null">update_time,</if>
  65 + <if test="remark != null">remark,</if>
  66 + <if test="userId != null">user_id,</if>
  67 + <if test="userName != null and userName != ''">user_name,</if>
  68 + <if test="tenantId != null">tenant_id,</if>
  69 + <if test="tenantName != null and tenantName != ''">tenant_name,</if>
  70 + </trim>
  71 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  72 + <if test="alertName != null and alertName != ''">#{alertName},</if>
  73 + <if test="alertLevel != null">#{alertLevel},</if>
  74 + <if test="status != null">#{status},</if>
  75 + <if test="productId != null">#{productId},</if>
  76 + <if test="productName != null and productName != ''">#{productName},</if>
  77 + <if test="deviceId != null">#{deviceId},</if>
  78 + <if test="deviceName != null and deviceName != ''">#{deviceName},</if>
  79 + <if test="createBy != null">#{createBy},</if>
  80 + <if test="createTime != null">#{createTime},</if>
  81 + <if test="updateBy != null">#{updateBy},</if>
  82 + <if test="updateTime != null">#{updateTime},</if>
  83 + <if test="remark != null">#{remark},</if>
  84 + <if test="userId != null">#{userId},</if>
  85 + <if test="userName != null and userName != ''">#{userName},</if>
  86 + <if test="tenantId != null">#{tenantId},</if>
  87 + <if test="tenantName != null and tenantName != ''">#{tenantName},</if>
  88 + </trim>
  89 + </insert>
  90 +
  91 + <update id="updateAlertLog" parameterType="com.ruoyi.system.domain.IotAlertLog">
  92 + update iot_alert_log
  93 + <trim prefix="SET" suffixOverrides=",">
  94 + <if test="alertName != null and alertName != ''">alert_name = #{alertName},</if>
  95 + <if test="alertLevel != null">alert_level = #{alertLevel},</if>
  96 + <if test="status != null">status = #{status},</if>
  97 + <if test="productId != null">product_id = #{productId},</if>
  98 + <if test="productName != null and productName != ''">product_name = #{productName},</if>
  99 + <if test="deviceId != null">device_id = #{deviceId},</if>
  100 + <if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
  101 + <if test="createBy != null">create_by = #{createBy},</if>
  102 + <if test="createTime != null">create_time = #{createTime},</if>
  103 + <if test="updateBy != null">update_by = #{updateBy},</if>
  104 + <if test="updateTime != null">update_time = #{updateTime},</if>
  105 + <if test="remark != null">remark = #{remark},</if>
  106 + <if test="userId != null">user_id = #{userId},</if>
  107 + <if test="userName != null and userName != ''">user_name = #{userName},</if>
  108 + <if test="tenantId != null">tenant_id = #{tenantId},</if>
  109 + <if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
  110 + </trim>
  111 + where alert_log__id = #{alertLogId}
  112 + </update>
  113 +
  114 + <delete id="deleteAlertLogByAlertLogId" parameterType="Long">
  115 + delete from iot_alert_log where alert_log__id = #{alertLogId}
  116 + </delete>
  117 +
  118 + <delete id="deleteAlertLogByAlertLogIds" parameterType="String">
  119 + delete from iot_alert_log where alert_log__id in
  120 + <foreach item="alertLogId" collection="array" open="(" separator="," close=")">
  121 + #{alertLogId}
  122 + </foreach>
  123 + </delete>
  124 +</mapper>
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper
  3 +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 +"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.ruoyi.system.mapper.IotAlertMapper">
  6 +
  7 + <resultMap type="com.ruoyi.system.domain.IotAlert" id="AlertResult">
  8 + <result property="alertId" column="alert_id" />
  9 + <result property="alertName" column="alert_name" />
  10 + <result property="alertLevel" column="alert_level" />
  11 + <result property="status" column="status" />
  12 + <result property="productId" column="product_id" />
  13 + <result property="productName" column="product_name" />
  14 + <result property="triggers" column="triggers" />
  15 + <result property="actions" column="actions" />
  16 + <result property="createBy" column="create_by" />
  17 + <result property="createTime" column="create_time" />
  18 + <result property="updateBy" column="update_by" />
  19 + <result property="updateTime" column="update_time" />
  20 + <result property="remark" column="remark" />
  21 + </resultMap>
  22 +
  23 + <sql id="selectAlertVo">
  24 + select alert_id, alert_name, alert_level,status, product_id, product_name, triggers, actions, create_by, create_time, update_by, update_time, remark from iot_alert
  25 + </sql>
  26 +
  27 + <select id="selectAlertList" parameterType="com.ruoyi.system.domain.IotAlert" resultMap="AlertResult">
  28 + <include refid="selectAlertVo"/>
  29 + <where>
  30 + <if test="alertName != null and alertName != ''"> and alert_name like concat('%', #{alertName}, '%')</if>
  31 + <if test="alertLevel != null "> and alert_level = #{alertLevel}</if>
  32 + <if test="status != null "> and status = #{status}</if>
  33 + <if test="productId != null "> and product_id = #{productId}</if>
  34 + <if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
  35 + </where>
  36 + </select>
  37 +
  38 + <select id="selectAlertByAlertId" parameterType="Long" resultMap="AlertResult">
  39 + <include refid="selectAlertVo"/>
  40 + where alert_id = #{alertId}
  41 + </select>
  42 +
  43 + <insert id="insertAlert" parameterType="com.ruoyi.system.domain.IotAlert" useGeneratedKeys="true" keyProperty="alertId">
  44 + insert into iot_alert
  45 + <trim prefix="(" suffix=")" suffixOverrides=",">
  46 + <if test="alertName != null and alertName != ''">alert_name,</if>
  47 + <if test="alertLevel != null">alert_level,</if>
  48 + <if test="status != null">status,</if>
  49 + <if test="productId != null">product_id,</if>
  50 + <if test="productName != null and productName != ''">product_name,</if>
  51 + <if test="triggers != null and triggers != ''">triggers,</if>
  52 + <if test="actions != null and actions != ''">actions,</if>
  53 + <if test="createBy != null">create_by,</if>
  54 + <if test="createTime != null">create_time,</if>
  55 + <if test="updateBy != null">update_by,</if>
  56 + <if test="updateTime != null">update_time,</if>
  57 + <if test="remark != null">remark,</if>
  58 + </trim>
  59 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  60 + <if test="alertName != null and alertName != ''">#{alertName},</if>
  61 + <if test="alertLevel != null">#{alertLevel},</if>
  62 + <if test="status != null">#{status},</if>
  63 + <if test="productId != null">#{productId},</if>
  64 + <if test="productName != null and productName != ''">#{productName},</if>
  65 + <if test="triggers != null and triggers != ''">#{triggers},</if>
  66 + <if test="actions != null and actions != ''">#{actions},</if>
  67 + <if test="createBy != null">#{createBy},</if>
  68 + <if test="createTime != null">#{createTime},</if>
  69 + <if test="updateBy != null">#{updateBy},</if>
  70 + <if test="updateTime != null">#{updateTime},</if>
  71 + <if test="remark != null">#{remark},</if>
  72 + </trim>
  73 + </insert>
  74 +
  75 + <update id="updateAlert" parameterType="com.ruoyi.system.domain.IotAlert">
  76 + update iot_alert
  77 + <trim prefix="SET" suffixOverrides=",">
  78 + <if test="alertName != null and alertName != ''">alert_name = #{alertName},</if>
  79 + <if test="alertLevel != null">alert_level = #{alertLevel},</if>
  80 + <if test="status != null">status = #{status},</if>
  81 + <if test="productId != null">product_id = #{productId},</if>
  82 + <if test="productName != null and productName != ''">product_name = #{productName},</if>
  83 + <if test="triggers != null and triggers != ''">triggers = #{triggers},</if>
  84 + <if test="actions != null and actions != ''">actions = #{actions},</if>
  85 + <if test="createBy != null">create_by = #{createBy},</if>
  86 + <if test="createTime != null">create_time = #{createTime},</if>
  87 + <if test="updateBy != null">update_by = #{updateBy},</if>
  88 + <if test="updateTime != null">update_time = #{updateTime},</if>
  89 + <if test="remark != null">remark = #{remark},</if>
  90 + </trim>
  91 + where alert_id = #{alertId}
  92 + </update>
  93 +
  94 + <delete id="deleteAlertByAlertId" parameterType="Long">
  95 + delete from iot_alert where alert_id = #{alertId}
  96 + </delete>
  97 +
  98 + <delete id="deleteAlertByAlertIds" parameterType="String">
  99 + delete from iot_alert where alert_id in
  100 + <foreach item="alertId" collection="array" open="(" separator="," close=")">
  101 + #{alertId}
  102 + </foreach>
  103 + </delete>
  104 +</mapper>
@@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
38 </resultMap> 38 </resultMap>
39 39
40 <sql id="selectIotDeviceVo"> 40 <sql id="selectIotDeviceVo">
41 - select active_time, client_id, completion_auth, create_by, create_time, del_flag, firmware_version, img_url, is_shadow, latitude, location_way, longitude, `name`, network_address, network_ip, remark, rssi, status, summary, things_model_value, update_by, update_time, product_id,mqtt_username,payload_type,things_model_config,listen_service_ip,device_life,data_update_time from iot_device 41 + select active_time, client_id, completion_auth, create_by, create_time, del_flag, firmware_version, img_url, is_shadow, latitude, location_way, longitude, `name`, network_address, network_ip, remark, rssi, status, summary, things_model_value, update_by, update_time, product_id,mqtt_username,payload_type,things_model_config,listen_service_ip,device_life,data_update_time,mqtt_username from iot_device
42 </sql> 42 </sql>
43 43
44 <select id="selectIotDeviceList" parameterType="IotDevice" resultMap="IotDeviceResult"> 44 <select id="selectIotDeviceList" parameterType="IotDevice" resultMap="IotDeviceResult">