src/main/java/com/whyc/controller/AlarmRuleController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/mapper/AlarmRuleMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/AlarmRule.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/AlarmRuleService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/AlarmRuleController.java
New file @@ -0,0 +1,59 @@ package com.whyc.controller; import com.github.pagehelper.PageInfo; import com.whyc.dto.Response; import com.whyc.pojo.AlarmRule; import com.whyc.service.AlarmRuleService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("alarmRule") @Api(tags = "告警规则") public class AlarmRuleController { @Autowired private AlarmRuleService service; @GetMapping("byDeviceFlag") @ApiOperation(value = "查询告警规则-根据id",notes ="主要设备:\n" + " 101-电源,102-主流配电板,103-受势电机,104测功电机\n" + "辅助设备:\n" + " 201-进线屏,205-直流调速柜,206-振动测试系统,207-AFE变频驱动柜,\n" + " 208-升压变压器,209-油站,210-水站,211-UPS\n" + "环境设备:\n" + " 301-水质监测,302-漏水监测,303-绝缘监测" ) public Response<List<AlarmRule>> getRuleByDeviceFlag( @RequestParam int deviceFlag){ return service.getRuleByDeviceFlag(deviceFlag); } /** * 新增规则,TODO 必须考虑阈值和级别的关系 * @param alarmRule * @return */ @PostMapping @ApiOperation(value = "新增规则") public Response add(@RequestBody AlarmRule alarmRule){ return service.add(alarmRule); } @PutMapping @ApiOperation(value = "更新规则") public Response update(@RequestBody AlarmRule alarmRule){ return service.update(alarmRule); } @DeleteMapping @ApiOperation(value = "删除规则") public Response delete(@RequestParam int id){ return service.delete(id); } } src/main/java/com/whyc/mapper/AlarmRuleMapper.java
New file @@ -0,0 +1,7 @@ package com.whyc.mapper; import com.whyc.pojo.AlarmRule; public interface AlarmRuleMapper extends CustomMapper<AlarmRule> { } src/main/java/com/whyc/pojo/AlarmRule.java
@@ -1,5 +1,6 @@ package com.whyc.pojo; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,15 +11,37 @@ @ApiModel public class AlarmRule { @TableId private Integer id; /** * 主要设备: * 101-电源,102-主流配电板,103-受势电机,104测功电机 * 辅助设备: * 201-进线屏,205-直流调速柜,206-振动测试系统,207-AFE变频驱动柜, * 208-升压变压器,209-油站,210-水站,211-UPS * 环境设备: * 301-水质监测,302-漏水监测,303-绝缘监测 */ @ApiModelProperty("主要设备:\n" + " 101-电源,102-主流配电板,103-受势电机,104测功电机\n" + "辅助设备:\n" + " 201-进线屏,205-直流调速柜,206-振动测试系统,207-AFE变频驱动柜,\n" + " 208-升压变压器,209-油站,210-水站,211-UPS\n" + "环境设备:\n" + " 301-水质监测,302-漏水监测,303-绝缘监测") private Integer deviceFlag; @ApiModelProperty("设备字段") private String field; @ApiModelProperty("设备字段") private String name; @ApiModelProperty("告警名称") private String name; @ApiModelProperty("故障描述") private String description; @ApiModelProperty("阈值标识:under对应1,over对应2") private Integer thresholdFlag; @ApiModelProperty("告警阈值") private Float threshold; private Float thresholdValue; @ApiModelProperty("告警阈值时间") private Integer thresholdDuration; @ApiModelProperty("告警级别") private Integer level; @ApiModelProperty("启用状态") @@ -56,12 +79,36 @@ this.description = description; } public Float getThreshold() { return threshold; public Integer getDeviceFlag() { return deviceFlag; } public void setThreshold(Float threshold) { this.threshold = threshold; public void setDeviceFlag(Integer deviceFlag) { this.deviceFlag = deviceFlag; } public Integer getThresholdFlag() { return thresholdFlag; } public void setThresholdFlag(Integer thresholdFlag) { this.thresholdFlag = thresholdFlag; } public Float getThresholdValue() { return thresholdValue; } public void setThresholdValue(Float thresholdValue) { this.thresholdValue = thresholdValue; } public Integer getThresholdDuration() { return thresholdDuration; } public void setThresholdDuration(Integer thresholdDuration) { this.thresholdDuration = thresholdDuration; } public Integer getLevel() { src/main/java/com/whyc/service/AlarmRuleService.java
New file @@ -0,0 +1,41 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.PageInfo; import com.whyc.dto.Response; import com.whyc.mapper.AlarmRuleMapper; import com.whyc.pojo.AlarmRule; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; @Service public class AlarmRuleService { @Resource private AlarmRuleMapper mapper; public Response<List<AlarmRule>> getRuleByDeviceFlag(int deviceFlag) { QueryWrapper<AlarmRule> wrapper = Wrappers.query(); wrapper.eq("device_flag",deviceFlag); List<AlarmRule> alarmRules = mapper.selectList(wrapper); return new Response<List<AlarmRule>>().set(1,alarmRules); } public Response add(AlarmRule alarmRule) { mapper.insert(alarmRule); return new Response().setMsg(1,"新增成功"); } public Response update(AlarmRule alarmRule) { mapper.updateById(alarmRule); return new Response().setMsg(1,"更新成功"); } public Response delete(int id) { mapper.deleteById(id); return new Response().set(1,"删除成功"); } }