告警设置
parent
5497a43e5c
commit
eb97c55199
|
|
@ -0,0 +1,81 @@
|
|||
package com.gunshi.project.hsz.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.hsz.entity.so.AlarmSetPageSo;
|
||||
import com.gunshi.project.hsz.entity.so.OsmoticQueryPageSo;
|
||||
import com.gunshi.project.hsz.model.AlarmSet;
|
||||
import com.gunshi.project.hsz.model.ForecastProject;
|
||||
import com.gunshi.project.hsz.model.ForecastResults;
|
||||
import com.gunshi.project.hsz.model.OsmoticFlowR;
|
||||
import com.gunshi.project.hsz.service.AlarmSetService;
|
||||
import com.gunshi.project.hsz.timetask.AlarmTask;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "告警设置")
|
||||
@RestController
|
||||
@RequestMapping(value="/alarmSet")
|
||||
public class AlarmSetController {
|
||||
|
||||
@Autowired
|
||||
private AlarmSetService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<AlarmSet> insert(@Validated(Insert.class) @RequestBody AlarmSet dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setCreateDate(new Date());
|
||||
boolean result = service.save(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<AlarmSet> update(@Validated(Update.class) @RequestBody AlarmSet dto) {
|
||||
boolean result = service.updateById(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
boolean b = service.removeById(id);
|
||||
return R.ok(b);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<AlarmSet>> page(@RequestBody AlarmSetPageSo pageSo) {
|
||||
return R.ok(service.queryPage(pageSo));
|
||||
}
|
||||
|
||||
@Operation(summary = "列表")
|
||||
@PostMapping("/list")
|
||||
public List<AlarmSet> list(@RequestBody AlarmSetPageSo pageSo) {
|
||||
List<AlarmSet> list = service.lambdaQuery().list();
|
||||
return list;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AlarmTask alarmTask;
|
||||
|
||||
@GetMapping("/test")
|
||||
public void test(){
|
||||
alarmTask.updateAlarmSet();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
package com.gunshi.project.hsz.entity.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 防汛预警类型枚举
|
||||
* Created by wanyan on 2024/2/20
|
||||
*
|
||||
* @author wanyan
|
||||
* @version 1.0
|
||||
*/
|
||||
@Getter
|
||||
public enum AlarmTypeEnum {
|
||||
|
||||
/**
|
||||
* 水库超汛限
|
||||
*/
|
||||
RESERVOIR_OVER_FLOOD_LIMIT("RESERVOIR_OVER_FLOOD_LIMIT", "水库超汛限", "水库水位超过汛限水位", 1, "水库"),
|
||||
|
||||
/**
|
||||
* 水库超设计
|
||||
*/
|
||||
RESERVOIR_OVER_DESIGN("RESERVOIR_OVER_DESIGN", "水库超设计", "水库水位超过设计洪水位", 2, "水库"),
|
||||
|
||||
/**
|
||||
* 水库超校核
|
||||
*/
|
||||
RESERVOIR_OVER_CHECK("RESERVOIR_OVER_CHECK", "水库超校核", "水库水位超过校核洪水位", 3, "水库"),
|
||||
|
||||
/**
|
||||
* 河道超警戒
|
||||
*/
|
||||
RIVER_OVER_WARNING("RIVER_OVER_WARNING", "河道超警戒", "河道水位超过警戒水位", 4, "河道"),
|
||||
|
||||
/**
|
||||
* 河道超保证
|
||||
*/
|
||||
RIVER_OVER_GUARANTEE("RIVER_OVER_GUARANTEE", "河道超保证", "河道水位超过保证水位", 5, "河道");
|
||||
|
||||
/**
|
||||
* 枚举编码
|
||||
*/
|
||||
private final String code;
|
||||
|
||||
/**
|
||||
* 枚举名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* 描述信息
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* 预警等级
|
||||
*/
|
||||
private final Integer level;
|
||||
|
||||
/**
|
||||
* 预警类型(水库/河道)
|
||||
*/
|
||||
private final String category;
|
||||
|
||||
AlarmTypeEnum(String code, String name, String description, Integer level, String category) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.level = level;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编码获取枚举
|
||||
*/
|
||||
public static AlarmTypeEnum getByCode(String code) {
|
||||
for (AlarmTypeEnum value : values()) {
|
||||
if (value.getCode().equals(code)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称获取枚举
|
||||
*/
|
||||
public static AlarmTypeEnum getByName(String name) {
|
||||
for (AlarmTypeEnum value : values()) {
|
||||
if (value.getName().equals(name)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为水库相关预警
|
||||
*/
|
||||
public boolean isReservoirWarning() {
|
||||
return "水库".equals(this.category);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为河道相关预警
|
||||
*/
|
||||
public boolean isRiverWarning() {
|
||||
return "河道".equals(this.category);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有水库预警类型
|
||||
*/
|
||||
public static AlarmTypeEnum[] getReservoirWarnings() {
|
||||
return new AlarmTypeEnum[]{
|
||||
RESERVOIR_OVER_FLOOD_LIMIT,
|
||||
RESERVOIR_OVER_DESIGN,
|
||||
RESERVOIR_OVER_CHECK
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有河道预警类型
|
||||
*/
|
||||
public static AlarmTypeEnum[] getRiverWarnings() {
|
||||
return new AlarmTypeEnum[]{
|
||||
RIVER_OVER_WARNING,
|
||||
RIVER_OVER_GUARANTEE
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + "(" + this.code + ") - " + this.description;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AlarmSetPageSo {
|
||||
|
||||
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description = "测点名称")
|
||||
private String name;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.hsz.model.AlarmSet;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface AlarmSetMapper extends BaseMapper<AlarmSet> {
|
||||
|
||||
@Select(
|
||||
"""
|
||||
<script>
|
||||
select * from alarm_set t
|
||||
where t.stcd = #{stcd}
|
||||
</script>
|
||||
"""
|
||||
)
|
||||
AlarmSet queryByStcd(@Param("stcd") String stcd);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.gunshi.project.hsz.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.checkerframework.checker.units.qual.N;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName(value ="alarm_set")
|
||||
public class AlarmSet implements Serializable{
|
||||
/**
|
||||
* 报警设置实体类
|
||||
*
|
||||
* @author
|
||||
* @TableName alarm_set
|
||||
*/
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
@Schema(description = "主键")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 站点编码
|
||||
*/
|
||||
@TableField(value = "stcd")
|
||||
@Schema(description = "站点编码")
|
||||
@NotNull(message = "站点编码不能为空",groups = {Insert.class, Update.class})
|
||||
private String stcd;
|
||||
|
||||
|
||||
/**
|
||||
* 站点编码
|
||||
*/
|
||||
@TableField(value = "stnm")
|
||||
@Schema(description = "站点编码")
|
||||
private String stnm;
|
||||
|
||||
/**
|
||||
* 警戒水位
|
||||
*/
|
||||
@TableField(value = "warn_water_level")
|
||||
@Schema(description = "警戒水位")
|
||||
@NotNull(message = "警戒水位",groups = {Insert.class, Update.class})
|
||||
private BigDecimal warnWaterLevel;
|
||||
|
||||
/**
|
||||
* 保证水位
|
||||
*/
|
||||
@TableField(value = "promise_water_level")
|
||||
@Schema(description = "保证水位")
|
||||
@NotNull(message = "保证水位",groups = {Insert.class, Update.class})
|
||||
private BigDecimal promiseWaterLevel;
|
||||
|
||||
/**
|
||||
* 调查最高水位
|
||||
*/
|
||||
@TableField(value = "max_level")
|
||||
@Schema(description = "调查最高水位")
|
||||
private BigDecimal maxLevel;
|
||||
|
||||
/**
|
||||
* 调查最高水位出现时间
|
||||
*/
|
||||
@TableField(value = "max_level_time")
|
||||
@Schema(description = "调查最高水位出现时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date maxLevelTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_date")
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createDate;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.AlarmSetPageSo;
|
||||
import com.gunshi.project.hsz.mapper.AlarmSetMapper;
|
||||
import com.gunshi.project.hsz.model.AlarmSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class AlarmSetService extends ServiceImpl<AlarmSetMapper, AlarmSet> {
|
||||
public Page<AlarmSet> queryPage(AlarmSetPageSo page) {
|
||||
LambdaQueryWrapper<AlarmSet> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (page.getName() != null) {
|
||||
queryWrapper.like(AlarmSet::getStcd, page.getName());
|
||||
}
|
||||
queryWrapper.orderByDesc(AlarmSet::getCreateDate);
|
||||
Page<AlarmSet> alarmSetPage = this.baseMapper.selectPage(page.getPageSo().toPage(), queryWrapper);
|
||||
return alarmSetPage;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue