forked from floraachy/xiuos_IoT
add alarm management function
This commit is contained in:
parent
4eb4b00afe
commit
561ffe67b2
|
@ -5,3 +5,4 @@ xiuosiot-backend/src/resources/mybatisGenerate/
|
|||
xiuosiot-frontend/dist/
|
||||
xiuosiot-frontend/node_modules/
|
||||
xiuosiot-backend/src/main/resources/mybatisGenerate/generatormapper/ProtocolProductInfoMapper.java
|
||||
xiuosiot-backend/src/main/resources/generatorConfig.xml
|
||||
|
|
|
@ -69,6 +69,12 @@
|
|||
<version>1.2.32</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.aiit.xiuos.controller;
|
||||
|
||||
import com.aiit.xiuos.Utils.Constant;
|
||||
import com.aiit.xiuos.Utils.ResultRespons;
|
||||
import com.aiit.xiuos.model.AlarmInfo;
|
||||
import com.aiit.xiuos.service.AlarmInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/alarmInfo")
|
||||
public class AlarmInfoController {
|
||||
@Autowired
|
||||
AlarmInfoService alarmInfoService;
|
||||
@GetMapping("/select")
|
||||
public ResultRespons getAllInfo(AlarmInfo alarmInfo,HttpServletRequest request){
|
||||
List<AlarmInfo> lists = alarmInfoService.selectByParam(alarmInfo);
|
||||
|
||||
if(lists!=null && lists.size()>=0){
|
||||
return new ResultRespons(Constant.SUCCESS_CODE,"查询告警信息成功!",lists);
|
||||
}
|
||||
return new ResultRespons(Constant.ERROR_CODE,"查询告警信息失败!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/update")
|
||||
public ResultRespons updateAlarmInfo(@RequestBody AlarmInfo alarmInfo){
|
||||
int res =alarmInfoService.updateAlarmInfo(alarmInfo);
|
||||
if(res==1){
|
||||
return new ResultRespons(Constant.SUCCESS_CODE,"更新告警信息成功!");
|
||||
}
|
||||
return new ResultRespons(Constant.ERROR_CODE,"更新告警信息失败!");
|
||||
}
|
||||
}
|
|
@ -70,8 +70,8 @@ public class ProtocolProductInfoController {
|
|||
}
|
||||
|
||||
@GetMapping("/selectOne")
|
||||
public ResultRespons selectProtocolProduct(@RequestBody Map<String, Object> jsonMap, HttpServletRequest request) throws ParseException {
|
||||
String productName= jsonMap.get("productName").toString();
|
||||
public ResultRespons selectProtocolProduct(@RequestParam String productName, HttpServletRequest request) throws ParseException {
|
||||
|
||||
ProtocolProductInfo protocolProductInfo = protocolService.getProtocolByName(productName);
|
||||
|
||||
if (protocolProductInfo != null) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.aiit.xiuos.dao.mappers;
|
||||
|
||||
import com.aiit.xiuos.model.AlarmInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface AlarmInfoMapper {
|
||||
int deleteByPrimaryKey(@Param("deviceNo") String deviceNo, @Param("alarmName") String alarmName);
|
||||
|
||||
int insert(AlarmInfo record);
|
||||
|
||||
int insertSelective(AlarmInfo record);
|
||||
|
||||
AlarmInfo selectByPrimaryKey(@Param("deviceNo") String deviceNo, @Param("alarmName") String alarmName);
|
||||
|
||||
int updateByPrimaryKeySelective(AlarmInfo record);
|
||||
|
||||
int updateByPrimaryKey(AlarmInfo record);
|
||||
|
||||
@Select("select * from alarm_info order by alarm_time desc")
|
||||
List<AlarmInfo> selectAll();
|
||||
|
||||
@Select("select * from alarm_info where alarm_level =#{level} order by alarm_time desc")
|
||||
List<AlarmInfo> selectByLevel(@Param("level") int level);
|
||||
|
||||
List<AlarmInfo> selectByParam(AlarmInfo alarmInfo);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.aiit.xiuos.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class AlarmInfo {
|
||||
private String deviceNo;
|
||||
|
||||
private String alarmName;
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date alarmTime;
|
||||
|
||||
private String deviceType;
|
||||
|
||||
private Integer alarmStatus;
|
||||
|
||||
private Integer alarmLevel;
|
||||
|
||||
private String alarmRes;
|
||||
|
||||
public AlarmInfo(String deviceNo, String alarmName, Date alarmTime, String deviceType, Integer alarmStatus, Integer alarmLevel, String alarmRes) {
|
||||
this.deviceNo = deviceNo;
|
||||
this.alarmName = alarmName;
|
||||
this.alarmTime = alarmTime;
|
||||
this.deviceType = deviceType;
|
||||
this.alarmStatus = alarmStatus;
|
||||
this.alarmLevel = alarmLevel;
|
||||
this.alarmRes = alarmRes;
|
||||
}
|
||||
|
||||
public AlarmInfo() {
|
||||
super();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.aiit.xiuos.service;
|
||||
|
||||
import com.aiit.xiuos.model.AlarmInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AlarmInfoService {
|
||||
List<AlarmInfo> selectAll();
|
||||
List<AlarmInfo> selectByLevel(int level);
|
||||
int updateAlarmInfo(AlarmInfo alarmInfo);
|
||||
List<AlarmInfo> selectByParam(AlarmInfo alarmInfo);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.aiit.xiuos.service.impl;
|
||||
|
||||
import com.aiit.xiuos.dao.mappers.AlarmInfoMapper;
|
||||
import com.aiit.xiuos.model.AlarmInfo;
|
||||
import com.aiit.xiuos.service.AlarmInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@Service
|
||||
public class AlarmInfoServiceImpl implements AlarmInfoService {
|
||||
@Autowired
|
||||
AlarmInfoMapper alarmInfoMapper;
|
||||
|
||||
@Override
|
||||
public List<AlarmInfo> selectAll() {
|
||||
return alarmInfoMapper.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AlarmInfo> selectByLevel(int level) {
|
||||
return alarmInfoMapper.selectByLevel(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateAlarmInfo(AlarmInfo alarmInfo) {
|
||||
return alarmInfoMapper.updateByPrimaryKeySelective(alarmInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AlarmInfo> selectByParam(AlarmInfo alarmInfo) {
|
||||
return alarmInfoMapper.selectByParam(alarmInfo);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE generatorConfiguration
|
||||
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||
<!-- 配置生成器 -->
|
||||
<generatorConfiguration>
|
||||
|
||||
<!--id:必选,上下文id,用于在生成错误时提示-->
|
||||
<context id="xiousiot" targetRuntime="MyBatis3" defaultModelType="flat">
|
||||
|
||||
<!-- 生成的Java文件的编码 -->
|
||||
<property name="javaFileEncoding" value="UTF-8"/>
|
||||
<plugin type="com.softwareloop.mybatis.generator.plugins.LombokPlugin">
|
||||
<!-- enable annotations -->
|
||||
<property name="builder" value="true"/>
|
||||
<!-- annotation's option(boolean) -->
|
||||
<property name="builder.fluent" value="true"/>
|
||||
<!-- annotation's option(String) -->
|
||||
<property name="builder.builderMethodName" value="myBuilder"/>
|
||||
<property name="accessors" value="true"/>
|
||||
<!-- annotation's option(array of String) -->
|
||||
<property name="accessors.prefix" value="m_, _"/>
|
||||
<!-- disable annotations -->
|
||||
<property name="allArgsConstructor" value="false"/>
|
||||
</plugin>
|
||||
|
||||
<!-- 对注释进行控制 -->
|
||||
<commentGenerator>
|
||||
<!-- suppressDate是去掉生成日期那行注释 -->
|
||||
<property name="suppressDate" value="true"/>
|
||||
<!-- suppressAllComments是去掉所有的注解 -->
|
||||
<property name="suppressAllComments" value="true"/>
|
||||
</commentGenerator>
|
||||
|
||||
|
||||
<!--jdbc的数据库连接 -->
|
||||
<jdbcConnection
|
||||
driverClass="org.postgresql.Driver"
|
||||
connectionURL="jdbc:postgresql://localhost:5432/xiuosiot"
|
||||
userId="xiuosiot"
|
||||
password="123456">
|
||||
</jdbcConnection>
|
||||
|
||||
<!-- java类型处理器
|
||||
用于处理DB中的类型到Java中的类型,默认使用JavaTypeResolverDefaultImpl;
|
||||
注意一点,默认会先尝试使用Integer,Long,Short等来对应DECIMAL和 NUMERIC数据类型;
|
||||
-->
|
||||
<javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
|
||||
<property name="forceBigDecimals" value="false"/>
|
||||
</javaTypeResolver>
|
||||
|
||||
|
||||
<javaModelGenerator targetPackage="com.aiit.xiuos.model" targetProject="src/main/java">
|
||||
<!-- 是否允许子包,即targetPackage.schemaName.tableName -->
|
||||
<property name="enableSubPackages" value="false"/>
|
||||
<!-- 是否对model添加 构造函数 -->
|
||||
<property name="constructorBased" value="true"/>
|
||||
<!-- 是否对类CHAR类型的列的数据进行trim操作 -->
|
||||
<property name="trimStrings" value="true"/>
|
||||
<!-- 建立的Model对象是否 不可改变 即生成的Model对象不会有 setter方法,只有构造方法 -->
|
||||
<property name="immutable" value="false"/>
|
||||
</javaModelGenerator>
|
||||
|
||||
|
||||
<sqlMapGenerator targetPackage="mybatisGenerate/generatorXML" targetProject="src/main/resources">
|
||||
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
|
||||
<property name="enableSubPackages" value="false"/>
|
||||
</sqlMapGenerator>
|
||||
|
||||
<javaClientGenerator targetPackage="mybatisGenerate/generatormapper" type="XMLMAPPER"
|
||||
targetProject="src/main/resources">
|
||||
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
|
||||
<property name="enableSubPackages" value="false"/>
|
||||
</javaClientGenerator>
|
||||
|
||||
<!-- 选择一个table来生成相关文件,可以有一个或多个table,必须要有table元素
|
||||
tableName(必要):要生成对象的表名;
|
||||
domainObjectName 给表对应的 model 起名字
|
||||
注意:大小写敏感问题。
|
||||
-->
|
||||
<!-- <table tableName="user_info" domainObjectName="UserInfo"-->
|
||||
<!-- enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"-->
|
||||
<!-- enableSelectByExample="false" selectByExampleQueryId="false"/>-->
|
||||
|
||||
<table tableName="protocol_product_info" domainObjectName="ProtocolProductInfo"
|
||||
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
||||
enableSelectByExample="false" selectByExampleQueryId="false"/>
|
||||
|
||||
</context>
|
||||
|
||||
</generatorConfiguration>
|
|
@ -0,0 +1,142 @@
|
|||
<?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.aiit.xiuos.dao.mappers.AlarmInfoMapper">
|
||||
<resultMap id="BaseResultMap" type="com.aiit.xiuos.model.AlarmInfo">
|
||||
<constructor>
|
||||
<idArg column="device_no" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<idArg column="alarm_name" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="alarm_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
|
||||
<arg column="device_type" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
<arg column="alarm_status" javaType="java.lang.Integer" jdbcType="INTEGER" />
|
||||
<arg column="alarm_level" javaType="java.lang.Integer" jdbcType="INTEGER" />
|
||||
<arg column="alarm_res" javaType="java.lang.String" jdbcType="VARCHAR" />
|
||||
</constructor>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
device_no, alarm_name, alarm_time, device_type, alarm_status, alarm_level, alarm_res
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="map" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from alarm_info
|
||||
where device_no = #{deviceNo,jdbcType=VARCHAR}
|
||||
and alarm_name = #{alarmName,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="map">
|
||||
delete from alarm_info
|
||||
where device_no = #{deviceNo,jdbcType=VARCHAR}
|
||||
and alarm_name = #{alarmName,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.aiit.xiuos.model.AlarmInfo">
|
||||
insert into alarm_info (device_no, alarm_name, alarm_time,
|
||||
device_type, alarm_status, alarm_level,
|
||||
alarm_res)
|
||||
values (#{deviceNo,jdbcType=VARCHAR}, #{alarmName,jdbcType=VARCHAR}, #{alarmTime,jdbcType=TIMESTAMP},
|
||||
#{deviceType,jdbcType=VARCHAR}, #{alarmStatus,jdbcType=INTEGER}, #{alarmLevel,jdbcType=INTEGER},
|
||||
#{alarmRes,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.aiit.xiuos.model.AlarmInfo">
|
||||
insert into alarm_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceNo != null">
|
||||
device_no,
|
||||
</if>
|
||||
<if test="alarmName != null">
|
||||
alarm_name,
|
||||
</if>
|
||||
<if test="alarmTime != null">
|
||||
alarm_time,
|
||||
</if>
|
||||
<if test="deviceType != null">
|
||||
device_type,
|
||||
</if>
|
||||
<if test="alarmStatus != null">
|
||||
alarm_status,
|
||||
</if>
|
||||
<if test="alarmLevel != null">
|
||||
alarm_level,
|
||||
</if>
|
||||
<if test="alarmRes != null">
|
||||
alarm_res,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceNo != null">
|
||||
#{deviceNo,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="alarmName != null">
|
||||
#{alarmName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="alarmTime != null">
|
||||
#{alarmTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="deviceType != null">
|
||||
#{deviceType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="alarmStatus != null">
|
||||
#{alarmStatus,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="alarmLevel != null">
|
||||
#{alarmLevel,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="alarmRes != null">
|
||||
#{alarmRes,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.aiit.xiuos.model.AlarmInfo">
|
||||
update alarm_info
|
||||
<set>
|
||||
<if test="alarmTime != null">
|
||||
alarm_time = #{alarmTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="deviceType != null">
|
||||
device_type = #{deviceType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="alarmStatus != null">
|
||||
alarm_status = #{alarmStatus,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="alarmLevel != null">
|
||||
alarm_level = #{alarmLevel,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="alarmRes != null">
|
||||
alarm_res = #{alarmRes,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where device_no = #{deviceNo,jdbcType=VARCHAR}
|
||||
and alarm_name = #{alarmName,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.aiit.xiuos.model.AlarmInfo">
|
||||
update alarm_info
|
||||
set alarm_time = #{alarmTime,jdbcType=TIMESTAMP},
|
||||
device_type = #{deviceType,jdbcType=VARCHAR},
|
||||
alarm_status = #{alarmStatus,jdbcType=INTEGER},
|
||||
alarm_level = #{alarmLevel,jdbcType=INTEGER},
|
||||
alarm_res = #{alarmRes,jdbcType=VARCHAR}
|
||||
where device_no = #{deviceNo,jdbcType=VARCHAR}
|
||||
and alarm_name = #{alarmName,jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
||||
<select id="selectByParam" parameterType="com.aiit.xiuos.model.AlarmInfo" resultMap="BaseResultMap">
|
||||
select * from alarm_info where 1=1
|
||||
<if test="deviceNo != null">
|
||||
and device_no = #{deviceNo,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="alarmName != null">
|
||||
and alarm_name = #{alarmName,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="alarmTime != null">
|
||||
and alarm_time = #{alarmTime,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="deviceType != null">
|
||||
and device_type = #{deviceType,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="alarmStatus != null">
|
||||
and alarm_status = #{alarmStatus,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="alarmLevel != null">
|
||||
and alarm_level = #{alarmLevel,jdbcType=INTEGER}
|
||||
</if>
|
||||
order by alarm_time desc;
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,17 +0,0 @@
|
|||
package mybatisGenerate/generatormapper;
|
||||
|
||||
import com.aiit.xiuos.model.AvgDayData;
|
||||
|
||||
public interface AvgDayDataMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(AvgDayData record);
|
||||
|
||||
int insertSelective(AvgDayData record);
|
||||
|
||||
AvgDayData selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(AvgDayData record);
|
||||
|
||||
int updateByPrimaryKey(AvgDayData record);
|
||||
}
|
Loading…
Reference in New Issue