package cn.iocoder.yudao.module.mes.controller.admin.em.alert;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.module.mes.controller.admin.em.alert.vo.MesEmAlertHandleReqVO;
|
import cn.iocoder.yudao.module.mes.controller.admin.em.alert.vo.MesEmAlertPageReqVO;
|
import cn.iocoder.yudao.module.mes.controller.admin.em.alert.vo.MesEmAlertRespVO;
|
import cn.iocoder.yudao.module.mes.dal.dataobject.em.alert.MesEmAlertDO;
|
import cn.iocoder.yudao.module.mes.service.em.alert.MesEmAlertService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.annotation.Resource;
|
import jakarta.validation.Valid;
|
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.time.LocalDate;
|
import java.util.Collections;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@Tag(name = "管理后台 - MES 能耗预警")
|
@RestController
|
@RequestMapping("/mes/em/alert")
|
@Validated
|
public class MesEmAlertController {
|
|
@Resource
|
private MesEmAlertService alertService;
|
|
@GetMapping("/page")
|
@Operation(summary = "获得能耗预警分页")
|
public CommonResult<PageResult<MesEmAlertRespVO>> getAlertPage(@Valid MesEmAlertPageReqVO pageReqVO) {
|
PageResult<MesEmAlertDO> pageResult = alertService.getAlertPage(pageReqVO);
|
return success(new PageResult<>(alertService.getAlertRespVOList(pageResult.getList()),
|
pageResult.getTotal()));
|
}
|
|
@GetMapping("/get")
|
@Operation(summary = "获得能耗预警")
|
@Parameter(name = "id", description = "编号", required = true)
|
public CommonResult<MesEmAlertRespVO> getAlert(@RequestParam("id") Long id) {
|
MesEmAlertDO alert = alertService.getAlert(id);
|
if (alert == null) {
|
return success(null);
|
}
|
return success(alertService.getAlertRespVOList(Collections.singletonList(alert)).get(0));
|
}
|
|
@PutMapping("/handle")
|
@Operation(summary = "处理能耗预警")
|
@PreAuthorize("@ss.hasPermission('mes:em-alert:handle')")
|
public CommonResult<Boolean> handleAlert(@Valid @RequestBody MesEmAlertHandleReqVO handleReqVO) {
|
alertService.handleAlert(handleReqVO);
|
return success(true);
|
}
|
|
@PostMapping("/check")
|
@Operation(summary = "重新检测指定日期区间的能耗预警")
|
@PreAuthorize("@ss.hasPermission('mes:em-alert:handle')")
|
public CommonResult<Integer> checkAlerts(
|
@RequestParam("beginDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate beginDate,
|
@RequestParam("endDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
|
return success(alertService.checkRange(beginDate, endDate));
|
}
|
|
}
|