feat(预警计划后端代码):
This commit is contained in:
parent
d09153864d
commit
8bd931ea6e
|
@ -1,7 +1,7 @@
|
|||
package com.ruoyi.web.controller.board;
|
||||
|
||||
import com.ruoyi.board.domain.AlertPlan;
|
||||
import com.ruoyi.board.service.AlertPlanService;
|
||||
import com.ruoyi.board.service.IAlertPlanService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
@ -22,10 +22,10 @@ import java.util.List;
|
|||
* @Date 2024-08-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/alertPlan")
|
||||
@RequestMapping("/board/plan")
|
||||
public class AlertPlanController extends BaseController {
|
||||
@Autowired
|
||||
private AlertPlanService alertPlanService;
|
||||
private IAlertPlanService alertPlanService;
|
||||
|
||||
/**
|
||||
* 查询预警计划列表
|
||||
|
@ -34,7 +34,7 @@ public class AlertPlanController extends BaseController {
|
|||
@GetMapping("/list")
|
||||
public TableDataInfo list(AlertPlan alertPlan) {
|
||||
startPage();
|
||||
List<AlertPlan> list = alertPlanService.list();
|
||||
List<AlertPlan> list = alertPlanService.selectList(alertPlan);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -12,7 +13,7 @@ import lombok.EqualsAndHashCode;
|
|||
* 警报计划表
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "pub_alert_plan")
|
||||
public class AlertPlan extends BaseEntity {
|
||||
/**
|
||||
|
@ -37,13 +38,13 @@ public class AlertPlan extends BaseEntity {
|
|||
* 最大值
|
||||
*/
|
||||
@TableField(value = "max_value")
|
||||
private Integer maxValue;
|
||||
private BigDecimal maxValue;
|
||||
|
||||
/**
|
||||
* 最小值
|
||||
*/
|
||||
@TableField(value = "min_value")
|
||||
private Integer minValue;
|
||||
private BigDecimal minValue;
|
||||
|
||||
/**
|
||||
* 显示内容
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.ruoyi.board.domain.enums;
|
||||
|
||||
public class AlertPlanType {
|
||||
|
||||
public static int getPlanTypeByName(String planTypeName) {
|
||||
// 0:雾,1:雨,2:雪
|
||||
switch (planTypeName) {
|
||||
case "雾":
|
||||
return 0;
|
||||
case "雨":
|
||||
return 1;
|
||||
case "雪":
|
||||
return 2;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.ruoyi.board.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.ruoyi.board.domain.AlertPlan;
|
||||
|
||||
public interface AlertPlanMapper extends BaseMapper<AlertPlan> {
|
||||
public interface AlertPlanMapper extends MPJBaseMapper<AlertPlan> {
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
package com.ruoyi.board.service;
|
||||
|
||||
import com.ruoyi.board.domain.AlertPlan;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface AlertPlanService extends IService<AlertPlan>{
|
||||
}
|
|
@ -1,11 +1,36 @@
|
|||
package com.ruoyi.board.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.board.domain.AlertPlan;
|
||||
import com.ruoyi.board.mapper.AlertPlanMapper;
|
||||
import com.ruoyi.board.service.AlertPlanService;
|
||||
@Service
|
||||
public class AlertPlanServiceImpl extends ServiceImpl<AlertPlanMapper, AlertPlan> implements AlertPlanService{
|
||||
import com.ruoyi.board.service.IAlertPlanService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AlertPlanServiceImpl extends MPJBaseServiceImpl<AlertPlanMapper, AlertPlan> implements IAlertPlanService {
|
||||
|
||||
@Override
|
||||
public List<AlertPlan> selectList(AlertPlan alertPlan) {
|
||||
LambdaQueryWrapper<AlertPlan> alertPlanLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
alertPlanLambdaQueryWrapper.eq(ObjectUtils.isNotEmpty(alertPlan.getType()), AlertPlan::getType, alertPlan.getType());
|
||||
alertPlanLambdaQueryWrapper.eq(ObjectUtils.isNotEmpty(alertPlan.getLevel()), AlertPlan::getLevel, alertPlan.getLevel());
|
||||
return list(alertPlanLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertPlan getOneByTypeAndValue(Integer planType, Double value) {
|
||||
if (planType < 0) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<AlertPlan> alertPlanLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
alertPlanLambdaQueryWrapper
|
||||
.eq(AlertPlan::getType, planType)
|
||||
.le(AlertPlan::getMinValue, value)
|
||||
.ge(AlertPlan::getMaxValue, value);
|
||||
return getOne(alertPlanLambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue