package com.zksy.web.controller.gasbasic;

import com.zksy.base.service.PressureMonitorService;
import com.zksy.common.annotation.Anonymous;
import com.zksy.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 管线压力监测
 */
@Api(tags = "燃气监测-管线压力")
@RestController
@RequestMapping("/api/pressure-monitor")
@Anonymous
public class PressureMonitorController {

    @Autowired
    private PressureMonitorService pressureMonitorService;

    @GetMapping("/points")
    @ApiOperation("获取压力监测点列表(含最新压力数据)")
    public AjaxResult getPoints() {
        return AjaxResult.success(pressureMonitorService.getPoints());
    }

    @GetMapping("/point/{pointId}/trend")
    @ApiOperation("获取压力趋势(近N天, 每天6时段)")
    public AjaxResult getTrend(@PathVariable String pointId,
                               @RequestParam(defaultValue = "10") int days) {
        return AjaxResult.success(pressureMonitorService.getTrend(pointId, days));
    }

    @GetMapping("/point/{pointId}/history")
    @ApiOperation("分页获取压力历史记录")
    public AjaxResult getHistory(@PathVariable String pointId,
                                 @RequestParam(defaultValue = "1") int pageNum,
                                 @RequestParam(defaultValue = "10") int pageSize) {
        return AjaxResult.success(pressureMonitorService.getHistory(pointId, pageNum, pageSize));
    }
}
