diff --git a/.gitignore b/.gitignore index 4c53a6f..196e0b5 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/xiuosiot-backend/pom.xml b/xiuosiot-backend/pom.xml index bde2077..d90d422 100644 --- a/xiuosiot-backend/pom.xml +++ b/xiuosiot-backend/pom.xml @@ -69,6 +69,12 @@ 1.2.32 + + com.taosdata.jdbc + taos-jdbcdriver + 3.0.0 + + diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/AlarmInfoController.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/AlarmInfoController.java new file mode 100644 index 0000000..0a98160 --- /dev/null +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/AlarmInfoController.java @@ -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 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,"更新告警信息失败!"); + } +} diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/ProtocolProductInfoController.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/ProtocolProductInfoController.java index aba6764..a4345cb 100644 --- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/ProtocolProductInfoController.java +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/ProtocolProductInfoController.java @@ -70,8 +70,8 @@ public class ProtocolProductInfoController { } @GetMapping("/selectOne") - public ResultRespons selectProtocolProduct(@RequestBody Map 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) { diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/AlarmInfoMapper.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/AlarmInfoMapper.java new file mode 100644 index 0000000..23dd8af --- /dev/null +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/dao/mappers/AlarmInfoMapper.java @@ -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 selectAll(); + + @Select("select * from alarm_info where alarm_level =#{level} order by alarm_time desc") + List selectByLevel(@Param("level") int level); + + List selectByParam(AlarmInfo alarmInfo); + + +} \ No newline at end of file diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/AlarmInfo.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/AlarmInfo.java new file mode 100644 index 0000000..427cfa4 --- /dev/null +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/AlarmInfo.java @@ -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(); + } +} \ No newline at end of file diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/AlarmInfoService.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/AlarmInfoService.java new file mode 100644 index 0000000..466ffe2 --- /dev/null +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/AlarmInfoService.java @@ -0,0 +1,12 @@ +package com.aiit.xiuos.service; + +import com.aiit.xiuos.model.AlarmInfo; + +import java.util.List; + +public interface AlarmInfoService { + List selectAll(); + List selectByLevel(int level); + int updateAlarmInfo(AlarmInfo alarmInfo); + List selectByParam(AlarmInfo alarmInfo); +} diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/AlarmInfoServiceImpl.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/AlarmInfoServiceImpl.java new file mode 100644 index 0000000..159207d --- /dev/null +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/AlarmInfoServiceImpl.java @@ -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 selectAll() { + return alarmInfoMapper.selectAll(); + } + + @Override + public List selectByLevel(int level) { + return alarmInfoMapper.selectByLevel(level); + } + + @Override + public int updateAlarmInfo(AlarmInfo alarmInfo) { + return alarmInfoMapper.updateByPrimaryKeySelective(alarmInfo); + } + + @Override + public List selectByParam(AlarmInfo alarmInfo) { + return alarmInfoMapper.selectByParam(alarmInfo); + } + +} diff --git a/xiuosiot-backend/src/main/resources/generatorConfig.xml b/xiuosiot-backend/src/main/resources/generatorConfig.xml deleted file mode 100644 index d50d61a..0000000 --- a/xiuosiot-backend/src/main/resources/generatorConfig.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xiuosiot-backend/src/main/resources/mappers/AlarmInfoMapper.xml b/xiuosiot-backend/src/main/resources/mappers/AlarmInfoMapper.xml new file mode 100644 index 0000000..c15ac5f --- /dev/null +++ b/xiuosiot-backend/src/main/resources/mappers/AlarmInfoMapper.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + device_no, alarm_name, alarm_time, device_type, alarm_status, alarm_level, alarm_res + + + + delete from alarm_info + where device_no = #{deviceNo,jdbcType=VARCHAR} + and alarm_name = #{alarmName,jdbcType=VARCHAR} + + + 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 into alarm_info + + + device_no, + + + alarm_name, + + + alarm_time, + + + device_type, + + + alarm_status, + + + alarm_level, + + + alarm_res, + + + + + #{deviceNo,jdbcType=VARCHAR}, + + + #{alarmName,jdbcType=VARCHAR}, + + + #{alarmTime,jdbcType=TIMESTAMP}, + + + #{deviceType,jdbcType=VARCHAR}, + + + #{alarmStatus,jdbcType=INTEGER}, + + + #{alarmLevel,jdbcType=INTEGER}, + + + #{alarmRes,jdbcType=VARCHAR}, + + + + + update alarm_info + + + 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 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} + + + + \ No newline at end of file diff --git a/xiuosiot-backend/src/main/resources/mybatisGenerate/generatormapper/AvgDayDataMapper.java b/xiuosiot-backend/src/main/resources/mybatisGenerate/generatormapper/AvgDayDataMapper.java deleted file mode 100644 index a10b6aa..0000000 --- a/xiuosiot-backend/src/main/resources/mybatisGenerate/generatormapper/AvgDayDataMapper.java +++ /dev/null @@ -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); -} \ No newline at end of file