作者 钟来

修改bug

正在显示 24 个修改的文件 包含 1537 行增加75 行删除
package com.zhonglai.luhui.admin.controller.iot;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.IotAlert;
import com.ruoyi.system.service.IIotAlertService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 设备告警Controller
*
* @author kerwincui
* @date 2022-01-13
*/
@Api(tags = "设备告警")
@RestController
@RequestMapping("/iot/alert")
public class IotAlertController extends BaseController
{
@Autowired
private IIotAlertService alertService;
/**
* 查询设备告警列表
*/
@ApiOperation("查询设备告警列表")
@PreAuthorize("@ss.hasPermi('iot:alert:list')")
@GetMapping("/list")
public TableDataInfo list(IotAlert alert)
{
startPage();
List<IotAlert> list = alertService.selectAlertList(alert);
return getDataTable(list);
}
/**
* 导出设备告警列表
*/
@ApiOperation("导出设备告警列表")
@PreAuthorize("@ss.hasPermi('iot:alert:export')")
@Log(title = "设备告警", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IotAlert alert)
{
List<IotAlert> list = alertService.selectAlertList(alert);
ExcelUtil<IotAlert> util = new ExcelUtil<IotAlert>(IotAlert.class);
util.exportExcel(response, list, "设备告警数据");
}
/**
* 获取设备告警详细信息
*/
@ApiOperation("获取设备告警详细信息")
@PreAuthorize("@ss.hasPermi('iot:alert:query')")
@GetMapping(value = "/{alertId}")
public AjaxResult getInfo(@PathVariable("alertId") Long alertId)
{
return AjaxResult.success(alertService.selectAlertByAlertId(alertId));
}
/**
* 新增设备告警
*/
@ApiOperation("新增设备告警")
@PreAuthorize("@ss.hasPermi('iot:alert:add')")
@Log(title = "设备告警", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody IotAlert alert)
{
return toAjax(alertService.insertAlert(alert));
}
/**
* 修改设备告警
*/
@ApiOperation("修改设备告警")
@PreAuthorize("@ss.hasPermi('iot:alert:edit')")
@Log(title = "设备告警", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody IotAlert alert)
{
return toAjax(alertService.updateAlert(alert));
}
/**
* 删除设备告警
*/
@ApiOperation("删除设备告警")
@PreAuthorize("@ss.hasPermi('iot:alert:remove')")
@Log(title = "设备告警", businessType = BusinessType.DELETE)
@DeleteMapping("/{alertIds}")
public AjaxResult remove(@PathVariable Long[] alertIds)
{
return toAjax(alertService.deleteAlertByAlertIds(alertIds));
}
}
... ...
package com.zhonglai.luhui.admin.controller.iot;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.IotAlertLog;
import com.ruoyi.system.service.IIotAlertLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 设备告警Controller
*
* @author kerwincui
* @date 2022-01-13
*/
@Api(tags = "设备告警日志")
@RestController
@RequestMapping("/iot/alertLog")
public class IotAlertLogController extends BaseController
{
@Autowired
private IIotAlertLogService alertLogService;
/**
* 查询设备告警列表
*/
@ApiOperation("查询设备告警列表")
@PreAuthorize("@ss.hasPermi('iot:alert:list')")
@GetMapping("/list")
public TableDataInfo list(IotAlertLog alertLog)
{
startPage();
List<IotAlertLog> list = alertLogService.selectAlertLogList(alertLog);
return getDataTable(list);
}
/**
* 导出设备告警列表
*/
@ApiOperation("导出设备告警列表")
@PreAuthorize("@ss.hasPermi('iot:alert:export')")
@Log(title = "设备告警", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IotAlertLog alertLog)
{
List<IotAlertLog> list = alertLogService.selectAlertLogList(alertLog);
ExcelUtil<IotAlertLog> util = new ExcelUtil<IotAlertLog>(IotAlertLog.class);
util.exportExcel(response, list, "设备告警数据");
}
/**
* 获取设备告警详细信息
*/
@ApiOperation("获取设备告警详细信息")
@PreAuthorize("@ss.hasPermi('iot:alert:query')")
@GetMapping(value = "/{alertLogId}")
public AjaxResult getInfo(@PathVariable("alertLogId") Long alertLogId)
{
return AjaxResult.success(alertLogService.selectAlertLogByAlertLogId(alertLogId));
}
/**
* 新增设备告警
*/
@ApiOperation("新增设备告警")
@PreAuthorize("@ss.hasPermi('iot:alert:add')")
@Log(title = "设备告警", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody IotAlertLog alertLog)
{
return toAjax(alertLogService.insertAlertLog(alertLog));
}
/**
* 修改设备告警
*/
@ApiOperation("修改设备告警")
@PreAuthorize("@ss.hasPermi('iot:alert:edit')")
@Log(title = "设备告警", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody IotAlertLog alertLog)
{
return toAjax(alertLogService.updateAlertLog(alertLog));
}
/**
* 删除设备告警
*/
@ApiOperation("删除设备告警")
@PreAuthorize("@ss.hasPermi('iot:alert:remove')")
@Log(title = "设备告警", businessType = BusinessType.DELETE)
@DeleteMapping("/{alertLogIds}")
public AjaxResult remove(@PathVariable Long[] alertLogIds)
{
return toAjax(alertLogService.deleteAlertLogByAlertLogIds(alertLogIds));
}
}
... ...
<?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">
<parent>
<artifactId>Luhui</artifactId>
<groupId>com.zhonglai.luhui</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lh-alarm</artifactId>
<dependencies>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 核心模块-->
<dependency>
<groupId>com.zhonglai.luhui</groupId>
<artifactId>ruoyi-framework</artifactId>
</dependency>
<!-- 文档 -->
<dependency >
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--https://mvnrepository.com/artifact/io.swagger/swagger-models-->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger-models.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!--&lt;!&ndash; https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui &ndash;&gt;-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-ui.version}</version>
</dependency>
</dependencies>
<build>
<finalName>lh-alarm</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<!--
生成的jar中,不要包含pom.xml和pom.properties这两个文件
-->
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<!--
是否要把第三方jar放到manifest的classpath中
-->
<addClasspath>true</addClasspath>
<!--
生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/
-->
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.zhonglai.luhui.alarm.AlarmApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- The configuration of maven-assembly-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptors>
<descriptor>src/main/resources/package.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
... ...
package com.zhonglai.luhui.alarm;
import com.ruoyi.framework.aspectj.LogAspect;
import com.ruoyi.framework.aspectj.RateLimiterAspect;
import com.ruoyi.framework.config.*;
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
import com.ruoyi.system.login.service.LoginService;
import com.ruoyi.system.login.service.TokenService;
import com.ruoyi.system.service.impl.SysConfigServiceImpl;
import com.ruoyi.system.service.impl.SysDictTypeServiceImpl;
import com.ruoyi.system.service.impl.SysUserServiceImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
@ComponentScan(basePackages = {
"com.ruoyi.common",
"com.ruoyi.system",
"com.ruoyi.framework",
},
excludeFilters = {@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE,classes = {LogAspect.class,
RateLimiterAspect.class, LoginService.class, TokenService.class, FilterConfig.class, JwtAuthenticationTokenFilter.class,
SysConfigServiceImpl.class, SysDictTypeServiceImpl.class, SysUserServiceImpl.class,SecurityConfig.class, LogoutSuccessHandlerImpl.class
})}
)
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class AlarmApplication {
public static void main(String[] args) {
SpringApplication.run(AlarmApplication.class,args);
System.out.println("启动成功");
}
}
... ...
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: luhui
password: Luhui586
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
\ No newline at end of file
... ...
# 项目相关配置 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
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 全局参数 -->
<settings>
<!-- 使全局的映射器启用或禁用缓存 -->
<setting name="cacheEnabled" value="true" />
<!-- 允许JDBC 支持自动生成主键 -->
<setting name="useGeneratedKeys" value="true" />
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings>
</configuration>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>bin</id>
<!-- 最终打包成一个用于发布的zip文件 -->
<formats>
<format>zip</format>
</formats>
<!-- Adds dependencies to zip package under lib directory -->
<dependencySets>
<dependencySet>
<!--
不使用项目的artifact,第三方jar不要解压,打包进zip文件的lib目录
-->
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
<fileSets>
<!-- 把项目相关的说明文件,打包进zip文件的根目录 -->
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
</includes>
</fileSet>
<!-- 把项目的配置文件,打包进zip文件的config目录 -->
<fileSet>
<directory>${project.basedir}\src\main\resources\configs</directory>
<outputDirectory>../configs</outputDirectory>
<includes>
<include>*.properties</include>
</includes>
</fileSet>
<!-- 把项目的配置文件,提出来 -->
<fileSet>
<directory>${project.basedir}\src\main\resources</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.properties</include>
<include>*.yml</include>
</includes>
</fileSet>
<!-- 把项目的脚本文件目录( src/main/scripts )中的启动脚本文件,打包进zip文件的跟目录 -->
<fileSet>
<directory>${project.basedir}\bin</directory>
<outputDirectory></outputDirectory>
<includes>
<include>start.*</include>
<include>stop.*</include>
</includes>
</fileSet>
<!-- 把项目自己编译出来的jar文件,打包进zip文件的根目录 -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
... ...
package com.ruoyi.system.domain;
import com.ruoyi.system.domain.tool.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serializable;
/**
* 设备告警对象 iot_alert
*
* @author kerwincui
* @date 2022-01-13
*/
public class IotAlert extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 告警ID */
private Long alertId;
/** 告警名称 */
private String alertName;
/** 告警级别(1=提醒通知,2=轻微问题,3=严重警告) */
private Long alertLevel;
/** 产品ID */
private Long productId;
/** 产品名称 */
private String productName;
/** 触发器 */
private String triggers;
/** 执行动作 */
private String actions;
/** 告警状态 (1-启动,2-停止)**/
private Integer status;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public void setAlertId(Long alertId)
{
this.alertId = alertId;
}
public Long getAlertId()
{
return alertId;
}
public void setAlertName(String alertName)
{
this.alertName = alertName;
}
public String getAlertName()
{
return alertName;
}
public void setAlertLevel(Long alertLevel)
{
this.alertLevel = alertLevel;
}
public Long getAlertLevel()
{
return alertLevel;
}
public void setProductId(Long productId)
{
this.productId = productId;
}
public Long getProductId()
{
return productId;
}
public void setProductName(String productName)
{
this.productName = productName;
}
public String getProductName()
{
return productName;
}
public void setTriggers(String triggers)
{
this.triggers = triggers;
}
public String getTriggers()
{
return triggers;
}
public void setActions(String actions)
{
this.actions = actions;
}
public String getActions()
{
return actions;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("alertId", getAlertId())
.append("alertName", getAlertName())
.append("alertLevel", getAlertLevel())
.append("productId", getProductId())
.append("productName", getProductName())
.append("triggers", getTriggers())
.append("actions", getActions())
.toString();
}
}
... ...
package com.ruoyi.system.domain;
import com.ruoyi.system.domain.tool.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 设备告警对象 iot_alert_log
*
* @author kerwincui
* @date 2022-01-13
*/
public class IotAlertLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 告警ID */
private Long alertLogId;
/** 告警名称 */
private String alertName;
/** 告警级别(1=提醒通知,2=轻微问题,3=严重警告,4=场景联动) */
private Long alertLevel;
/** 处理状态(0=不需要处理,1=未处理,2=已处理) */
private Long status;
/** 产品ID */
private Long productId;
/** 产品名称 */
private String productName;
/** 设备ID */
private Long deviceId;
/** 设备名称 */
private String deviceName;
/** 用户ID */
private Long userId;
/** 用户昵称 */
private String userName;
/** 租户ID */
private Long tenantId;
/** 租户名称 */
private String tenantName;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public String getTenantName() {
return tenantName;
}
public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
public void setAlertLogId(Long alertLogId)
{
this.alertLogId = alertLogId;
}
public Long getAlertLogId()
{
return alertLogId;
}
public void setAlertName(String alertLogName)
{
this.alertName = alertLogName;
}
public String getAlertName()
{
return alertName;
}
public void setAlertLevel(Long alertLevel)
{
this.alertLevel = alertLevel;
}
public Long getAlertLevel()
{
return alertLevel;
}
public void setStatus(Long status)
{
this.status = status;
}
public Long getStatus()
{
return status;
}
public void setProductId(Long productId)
{
this.productId = productId;
}
public Long getProductId()
{
return productId;
}
public void setProductName(String productName)
{
this.productName = productName;
}
public String getProductName()
{
return productName;
}
public void setDeviceId(Long deviceId)
{
this.deviceId = deviceId;
}
public Long getDeviceId()
{
return deviceId;
}
public void setDeviceName(String deviceName)
{
this.deviceName = deviceName;
}
public String getDeviceName()
{
return deviceName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("alertLogId", getAlertLogId())
.append("alertName", getAlertName())
.append("alertLevel", getAlertLevel())
.append("status", getStatus())
.append("productId", getProductId())
.append("productName", getProductName())
.append("deviceId", getDeviceId())
.append("deviceName", getDeviceName())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
... ...
... ... @@ -172,19 +172,6 @@
<artifactId>rocketmq-spring-boot-starter</artifactId>
</dependency>
<!-- 日志 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
</dependencies>
<build>
... ...
package com.zhonglai.luhui.mqtt.comm.service;
import com.alibaba.fastjson.JSON;
import com.ruoyi.system.domain.IotDevice;
import com.zhonglai.luhui.mqtt.comm.dto.ServerDto;
import com.zhonglai.luhui.mqtt.comm.dto.business.BusinessDto;
... ... @@ -9,12 +8,8 @@ import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreement;
import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreementFactory;
import com.zhonglai.luhui.mqtt.comm.factory.Topic;
import com.zhonglai.luhui.mqtt.comm.util.ByteUtil;
import com.zhonglai.luhui.mqtt.comm.util.DateUtils;
import com.zhonglai.luhui.mqtt.service.db.DeviceService;
import lombok.SneakyThrows;
import org.apache.log4j.FileAppender;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallbackExtended;
import org.eclipse.paho.client.mqttv3.MqttException;
... ... @@ -24,8 +19,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class MqttCallback implements MqttCallbackExtended {
private static final Logger log = LoggerFactory.getLogger(MqttCallback.class);
... ... @@ -76,12 +69,12 @@ public class MqttCallback implements MqttCallbackExtended {
if(null == topic)
{
log.error("消息{},topic为空,不做解析");
getLoggerByName("error").error("消息《"+s+"》解析为空 》》》内容:\r\n"+buffer.toString());
// getLoggerByName("error").error("消息《"+s+"》解析为空 》》》内容:\r\n"+buffer.toString());
return;
}
//日志记录
getLoggerByName(topic.getClientid()).info(buffer.toString());
// getLoggerByName(topic.getClientid()).info(buffer.toString());
//准备数据
byte[] data = mqttMessage.getPayload();
... ... @@ -128,37 +121,37 @@ public class MqttCallback implements MqttCallbackExtended {
}
}
public static org.apache.log4j.Logger getLoggerByName(String name) {
// 生成新的Logger
// 如果已經有了一個Logger實例返回現有的
org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(name);
// 清空Appender。特別是不想使用現存實例時一定要初期化
logger.removeAllAppenders();
// 設定Logger級別。
// logger.setLevel(Level.DEBUG);
// 設定是否繼承父Logger。
// 默認為true。繼承root輸出。
// 設定false後將不輸出root。
logger.setAdditivity(true);
// 生成新的Appender
FileAppender appender = new RollingFileAppender();
PatternLayout layout = new PatternLayout();
// log的输出形式
String conversionPattern = "%d{HH:mm:ss} [%p] -%m%n";
layout.setConversionPattern(conversionPattern);
appender.setLayout(layout);
// log输出路径
// 这里使用了环境变量[catalina.home],只有在tomcat环境下才可以取到
// String tomcatPath = java.lang.System.getProperty("catalina.home");
appender.setFile( "logs/" + name+"_"+ DateUtils.parseDateToStr("yyyyMMdd",new Date()) + ".log");
// log的文字码
appender.setEncoding("UTF-8");
// true:在已存在log文件后面追加 false:新log覆盖以前的log
appender.setAppend(true);
// 适用当前配置
appender.activateOptions();
// 将新的Appender加到Logger中
logger.addAppender(appender);
return logger;
}
// public static org.apache.log4j.Logger getLoggerByName(String name) {
// // 生成新的Logger
// // 如果已經有了一個Logger實例返回現有的
// org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(name);
// // 清空Appender。特別是不想使用現存實例時一定要初期化
// logger.removeAllAppenders();
// // 設定Logger級別。
//// logger.setLevel(Level.DEBUG);
// // 設定是否繼承父Logger。
// // 默認為true。繼承root輸出。
// // 設定false後將不輸出root。
// logger.setAdditivity(true);
// // 生成新的Appender
// FileAppender appender = new RollingFileAppender();
// PatternLayout layout = new PatternLayout();
// // log的输出形式
// String conversionPattern = "%d{HH:mm:ss} [%p] -%m%n";
// layout.setConversionPattern(conversionPattern);
// appender.setLayout(layout);
// // log输出路径
// // 这里使用了环境变量[catalina.home],只有在tomcat环境下才可以取到
//// String tomcatPath = java.lang.System.getProperty("catalina.home");
// appender.setFile( "logs/" + name+"_"+ DateUtils.parseDateToStr("yyyyMMdd",new Date()) + ".log");
// // log的文字码
// appender.setEncoding("UTF-8");
// // true:在已存在log文件后面追加 false:新log覆盖以前的log
// appender.setAppend(true);
// // 适用当前配置
// appender.activateOptions();
// // 将新的Appender加到Logger中
// logger.addAppender(appender);
// return logger;
// }
}
... ...
... ... @@ -29,7 +29,6 @@ public class DeviceCommandApi {
case delIotTerminal:
return deviceService.delIotTerminal(deviceCommandApiParameter.getClient_id(),deviceCommandApiParameter.getNumber());
case getFirmwareVersion:
deviceCommandApiParameter.setClient_id(deviceCommandApiParameter.getData());
return deviceService.getFirmwareVersion(deviceCommandApiParameter.getData());
case updateIotDevice:
IotDevice iotDevice = JSONObject.parseObject(JSONObject.toJSONString(deviceCommandApiParameter.getMap()), IotDevice.class);
... ...
... ... @@ -65,5 +65,5 @@ sys:
rocketmq:
#nameservice服务器地址(多个以英文逗号隔开)
name-server: 47.115.144.179:9876
send-topic: lh-mqtt-service-deviceCommand-test
send-topic: lh-mqtt-service-deviceCommand-test1
send-tag: 1
\ No newline at end of file
... ...
... ... @@ -18,6 +18,7 @@
<module>lh-api</module>
<module>lh-central-control</module>
<module>lh-backups</module>
<module>lh-alarm</module>
</modules>
<packaging>pom</packaging>
... ... @@ -339,23 +340,6 @@
<version>2.1.1</version>
</dependency>
<!-- 日志 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.24</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.24</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
... ...
package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.IotAlertLog;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 设备告警Mapper接口
*
* @author kerwincui
* @date 2022-01-13
*/
@Repository
public interface IotAlertLogMapper
{
/**
* 查询设备告警
*
* @param alertLogId 设备告警主键
* @return 设备告警
*/
public IotAlertLog selectAlertLogByAlertLogId(Long alertLogId);
/**
* 查询设备告警列表
*
* @param alertLog 设备告警
* @return 设备告警集合
*/
public List<IotAlertLog> selectAlertLogList(IotAlertLog alertLog);
/**
* 新增设备告警
*
* @param alertLog 设备告警
* @return 结果
*/
public int insertAlertLog(IotAlertLog alertLog);
/**
* 修改设备告警
*
* @param alertLog 设备告警
* @return 结果
*/
public int updateAlertLog(IotAlertLog alertLog);
/**
* 删除设备告警
*
* @param alertLogId 设备告警主键
* @return 结果
*/
public int deleteAlertLogByAlertLogId(Long alertLogId);
/**
* 批量删除设备告警
*
* @param alertLogIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteAlertLogByAlertLogIds(Long[] alertLogIds);
}
... ...
package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.IotAlert;
import com.ruoyi.system.domain.IotDevice;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 设备告警Mapper接口
*
* @author kerwincui
* @date 2022-01-13
*/
@Repository
public interface IotAlertMapper
{
/**
* 查询设备告警
*
* @param alertId 设备告警主键
* @return 设备告警
*/
public IotAlert selectAlertByAlertId(Long alertId);
/**
* 查询设备告警列表
*
* @param alert 设备告警
* @return 设备告警集合
*/
public List<IotAlert> selectAlertList(IotAlert alert);
/**
* 新增设备告警
*
* @param alert 设备告警
* @return 结果
*/
public int insertAlert(IotAlert alert);
/**
* 修改设备告警
*
* @param alert 设备告警
* @return 结果
*/
public int updateAlert(IotAlert alert);
/**
* 删除设备告警
*
* @param alertId 设备告警主键
* @return 结果
*/
public int deleteAlertByAlertId(Long alertId);
/**
* 批量删除设备告警
*
* @param alertIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteAlertByAlertIds(Long[] alertIds);
}
... ...
package com.ruoyi.system.service;
import com.ruoyi.system.domain.IotAlertLog;
import java.util.List;
/**
* 设备告警Service接口
*
* @author kerwincui
* @date 2022-01-13
*/
public interface IIotAlertLogService
{
/**
* 查询设备告警
*
* @param alertLogId 设备告警主键
* @return 设备告警
*/
public IotAlertLog selectAlertLogByAlertLogId(Long alertLogId);
/**
* 查询设备告警列表
*
* @param alertLog 设备告警
* @return 设备告警集合
*/
public List<IotAlertLog> selectAlertLogList(IotAlertLog alertLog);
/**
* 新增设备告警
*
* @param alertLog 设备告警
* @return 结果
*/
public int insertAlertLog(IotAlertLog alertLog);
/**
* 修改设备告警
*
* @param alertLog 设备告警
* @return 结果
*/
public int updateAlertLog(IotAlertLog alertLog);
/**
* 批量删除设备告警
*
* @param alertLogIds 需要删除的设备告警主键集合
* @return 结果
*/
public int deleteAlertLogByAlertLogIds(Long[] alertLogIds);
/**
* 删除设备告警信息
*
* @param alertLogId 设备告警主键
* @return 结果
*/
public int deleteAlertLogByAlertLogId(Long alertLogId);
}
... ...
package com.ruoyi.system.service;
import com.ruoyi.system.domain.IotAlert;
import java.util.List;
/**
* 设备告警Service接口
*
* @author kerwincui
* @date 2022-01-13
*/
public interface IIotAlertService
{
/**
* 查询设备告警
*
* @param alertId 设备告警主键
* @return 设备告警
*/
public IotAlert selectAlertByAlertId(Long alertId);
/**
* 查询设备告警列表
*
* @param alert 设备告警
* @return 设备告警集合
*/
public List<IotAlert> selectAlertList(IotAlert alert);
/**
* 新增设备告警
*
* @param alert 设备告警
* @return 结果
*/
public int insertAlert(IotAlert alert);
/**
* 修改设备告警
*
* @param alert 设备告警
* @return 结果
*/
public int updateAlert(IotAlert alert);
/**
* 批量删除设备告警
*
* @param alertIds 需要删除的设备告警主键集合
* @return 结果
*/
public int deleteAlertByAlertIds(Long[] alertIds);
/**
* 删除设备告警信息
*
* @param alertId 设备告警主键
* @return 结果
*/
public int deleteAlertByAlertId(Long alertId);
}
... ...
package com.ruoyi.system.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.IotAlertLog;
import com.ruoyi.system.mapper.IotAlertLogMapper;
import com.ruoyi.system.service.IIotAlertLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 设备告警Service业务层处理
*
* @author kerwincui
* @date 2022-01-13
*/
@Service
public class IotAlertLogServiceImpl implements IIotAlertLogService
{
@Autowired
private IotAlertLogMapper alertLogMapper;
/**
* 查询设备告警
*
* @param alertLogId 设备告警主键
* @return 设备告警
*/
@Override
public IotAlertLog selectAlertLogByAlertLogId(Long alertLogId)
{
return alertLogMapper.selectAlertLogByAlertLogId(alertLogId);
}
/**
* 查询设备告警列表
*
* @param alertLog 设备告警
* @return 设备告警
*/
@Override
public List<IotAlertLog> selectAlertLogList(IotAlertLog alertLog)
{
return alertLogMapper.selectAlertLogList(alertLog);
}
/**
* 新增设备告警
*
* @param alertLog 设备告警
* @return 结果
*/
@Override
public int insertAlertLog(IotAlertLog alertLog)
{
alertLog.setCreateTime(DateUtils.getNowDate());
return alertLogMapper.insertAlertLog(alertLog);
}
/**
* 修改设备告警
*
* @param alertLog 设备告警
* @return 结果
*/
@Override
public int updateAlertLog(IotAlertLog alertLog)
{
alertLog.setUpdateTime(DateUtils.getNowDate());
return alertLogMapper.updateAlertLog(alertLog);
}
/**
* 批量删除设备告警
*
* @param alertLogIds 需要删除的设备告警主键
* @return 结果
*/
@Override
public int deleteAlertLogByAlertLogIds(Long[] alertLogIds)
{
return alertLogMapper.deleteAlertLogByAlertLogIds(alertLogIds);
}
/**
* 删除设备告警信息
*
* @param alertLogId 设备告警主键
* @return 结果
*/
@Override
public int deleteAlertLogByAlertLogId(Long alertLogId)
{
return alertLogMapper.deleteAlertLogByAlertLogId(alertLogId);
}
}
... ...
package com.ruoyi.system.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.IotAlert;
import com.ruoyi.system.mapper.IotAlertMapper;
import com.ruoyi.system.service.IIotAlertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 设备告警Service业务层处理
*
* @author kerwincui
* @date 2022-01-13
*/
@Service
public class IotAlertServiceImpl implements IIotAlertService
{
@Autowired
private IotAlertMapper alertMapper;
/**
* 查询设备告警
*
* @param alertId 设备告警主键
* @return 设备告警
*/
@Override
public IotAlert selectAlertByAlertId(Long alertId)
{
return alertMapper.selectAlertByAlertId(alertId);
}
/**
* 查询设备告警列表
*
* @param alert 设备告警
* @return 设备告警
*/
@Override
public List<IotAlert> selectAlertList(IotAlert alert)
{
return alertMapper.selectAlertList(alert);
}
/**
* 新增设备告警
*
* @param alert 设备告警
* @return 结果
*/
@Override
public int insertAlert(IotAlert alert)
{
alert.setCreateTime(DateUtils.getNowDate());
return alertMapper.insertAlert(alert);
}
/**
* 修改设备告警
*
* @param alert 设备告警
* @return 结果
*/
@Override
public int updateAlert(IotAlert alert)
{
alert.setUpdateTime(DateUtils.getNowDate());
return alertMapper.updateAlert(alert);
}
/**
* 批量删除设备告警
*
* @param alertIds 需要删除的设备告警主键
* @return 结果
*/
@Override
public int deleteAlertByAlertIds(Long[] alertIds)
{
return alertMapper.deleteAlertByAlertIds(alertIds);
}
/**
* 删除设备告警信息
*
* @param alertId 设备告警主键
* @return 结果
*/
@Override
public int deleteAlertByAlertId(Long alertId)
{
return alertMapper.deleteAlertByAlertId(alertId);
}
}
... ...
<?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.ruoyi.system.mapper.IotAlertLogMapper">
<resultMap type="com.ruoyi.system.domain.IotAlertLog" id="AlertLogResult">
<result property="alertLogId" column="alert_log__id" />
<result property="alertName" column="alert_name" />
<result property="alertLevel" column="alert_level" />
<result property="status" column="status" />
<result property="productId" column="product_id" />
<result property="productName" column="product_name" />
<result property="deviceId" column="device_id" />
<result property="deviceName" column="device_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
</resultMap>
<sql id="selectAlertLogVo">
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
</sql>
<select id="selectAlertLogList" parameterType="com.ruoyi.system.domain.IotAlertLog" resultMap="AlertLogResult">
<include refid="selectAlertLogVo"/>
<where>
<if test="userId != null and userId != 0"> and user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
<if test="alertName != null and alertName != ''"> and alert_name like concat('%', #{alertName}, '%')</if>
<if test="alertLevel != null "> and alert_level = #{alertLevel}</if>
<if test="status != null "> and status = #{status}</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
</where>
</select>
<select id="selectAlertLogByAlertLogId" parameterType="Long" resultMap="AlertLogResult">
<include refid="selectAlertLogVo"/>
where alert_log__id = #{alertLogId}
</select>
<insert id="insertAlertLog" parameterType="com.ruoyi.system.domain.IotAlertLog" useGeneratedKeys="true" keyProperty="alertLogId">
insert into iot_alert_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alertName != null and alertName != ''">alert_name,</if>
<if test="alertLevel != null">alert_level,</if>
<if test="status != null">status,</if>
<if test="productId != null">product_id,</if>
<if test="productName != null and productName != ''">product_name,</if>
<if test="deviceId != null">device_id,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="userId != null">user_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alertName != null and alertName != ''">#{alertName},</if>
<if test="alertLevel != null">#{alertLevel},</if>
<if test="status != null">#{status},</if>
<if test="productId != null">#{productId},</if>
<if test="productName != null and productName != ''">#{productName},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="userId != null">#{userId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
</trim>
</insert>
<update id="updateAlertLog" parameterType="com.ruoyi.system.domain.IotAlertLog">
update iot_alert_log
<trim prefix="SET" suffixOverrides=",">
<if test="alertName != null and alertName != ''">alert_name = #{alertName},</if>
<if test="alertLevel != null">alert_level = #{alertLevel},</if>
<if test="status != null">status = #{status},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="productName != null and productName != ''">product_name = #{productName},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
</trim>
where alert_log__id = #{alertLogId}
</update>
<delete id="deleteAlertLogByAlertLogId" parameterType="Long">
delete from iot_alert_log where alert_log__id = #{alertLogId}
</delete>
<delete id="deleteAlertLogByAlertLogIds" parameterType="String">
delete from iot_alert_log where alert_log__id in
<foreach item="alertLogId" collection="array" open="(" separator="," close=")">
#{alertLogId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
... ...
<?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.ruoyi.system.mapper.IotAlertMapper">
<resultMap type="com.ruoyi.system.domain.IotAlert" id="AlertResult">
<result property="alertId" column="alert_id" />
<result property="alertName" column="alert_name" />
<result property="alertLevel" column="alert_level" />
<result property="status" column="status" />
<result property="productId" column="product_id" />
<result property="productName" column="product_name" />
<result property="triggers" column="triggers" />
<result property="actions" column="actions" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectAlertVo">
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
</sql>
<select id="selectAlertList" parameterType="com.ruoyi.system.domain.IotAlert" resultMap="AlertResult">
<include refid="selectAlertVo"/>
<where>
<if test="alertName != null and alertName != ''"> and alert_name like concat('%', #{alertName}, '%')</if>
<if test="alertLevel != null "> and alert_level = #{alertLevel}</if>
<if test="status != null "> and status = #{status}</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
</where>
</select>
<select id="selectAlertByAlertId" parameterType="Long" resultMap="AlertResult">
<include refid="selectAlertVo"/>
where alert_id = #{alertId}
</select>
<insert id="insertAlert" parameterType="com.ruoyi.system.domain.IotAlert" useGeneratedKeys="true" keyProperty="alertId">
insert into iot_alert
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alertName != null and alertName != ''">alert_name,</if>
<if test="alertLevel != null">alert_level,</if>
<if test="status != null">status,</if>
<if test="productId != null">product_id,</if>
<if test="productName != null and productName != ''">product_name,</if>
<if test="triggers != null and triggers != ''">triggers,</if>
<if test="actions != null and actions != ''">actions,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alertName != null and alertName != ''">#{alertName},</if>
<if test="alertLevel != null">#{alertLevel},</if>
<if test="status != null">#{status},</if>
<if test="productId != null">#{productId},</if>
<if test="productName != null and productName != ''">#{productName},</if>
<if test="triggers != null and triggers != ''">#{triggers},</if>
<if test="actions != null and actions != ''">#{actions},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateAlert" parameterType="com.ruoyi.system.domain.IotAlert">
update iot_alert
<trim prefix="SET" suffixOverrides=",">
<if test="alertName != null and alertName != ''">alert_name = #{alertName},</if>
<if test="alertLevel != null">alert_level = #{alertLevel},</if>
<if test="status != null">status = #{status},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="productName != null and productName != ''">product_name = #{productName},</if>
<if test="triggers != null and triggers != ''">triggers = #{triggers},</if>
<if test="actions != null and actions != ''">actions = #{actions},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where alert_id = #{alertId}
</update>
<delete id="deleteAlertByAlertId" parameterType="Long">
delete from iot_alert where alert_id = #{alertId}
</delete>
<delete id="deleteAlertByAlertIds" parameterType="String">
delete from iot_alert where alert_id in
<foreach item="alertId" collection="array" open="(" separator="," close=")">
#{alertId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
... ...
... ... @@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectIotDeviceVo">
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
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
</sql>
<select id="selectIotDeviceList" parameterType="IotDevice" resultMap="IotDeviceResult">
... ...