package cn.cecep.talroad.controller.analysis;

import cn.cecep.talroad.common.core.utils.poi.ExcelUtil;
import cn.cecep.talroad.common.core.web.controller.BasesController;
import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.service.analysis.ISRaGasFlagService;
import cn.cecep.talroad.vo.analysis.SRaGasFlagVo;
import cn.cecep.talroad.vo.query.analysis.SRaGasFlagQuery;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


@Api(tags = "废气在线监测标记汇总")
@RestController
@RequestMapping("/sraGasFlag")
public class SRaGasFlagController extends BasesController {
    @Autowired
    private ISRaGasFlagService gasFlagService;

    @ApiOperation(value = "废气在线监测标记汇总")
    @GetMapping("/list")
    public AjaxResults<IPage<SRaGasFlagVo.Row>> list(SRaGasFlagQuery query) {
        Page<SRaGasFlagVo.Row> page = new Page<>(query.getPageNum(), query.getPageSize());
        List<SRaGasFlagVo.Row> list = gasFlagService.getGasFlagList(page, query);
        page.setRecords(list);
        return AjaxResults.success(page);
    }

    @ApiOperation(value = "导出废气在线监测标记汇总")
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody SRaGasFlagQuery query) {
        Page<SRaGasFlagVo.Row> page = new Page<>(query.getPageNum(), query.getPageSize());
        List<SRaGasFlagVo.Row> list = gasFlagService.getGasFlagList(page, query);
        ExcelUtil<SRaGasFlagVo.Row> util = new ExcelUtil<>(SRaGasFlagVo.Row.class);
        util.exportExcel(response, list, "废气在线监测标记汇总数据");
    }

    @ApiOperation(value = "废气在线监测标记明细")
    @GetMapping("/detail/list")
    public AjaxResults<IPage<SRaGasFlagVo.DetailRow>> detailList(SRaGasFlagQuery query) {
        Page<SRaGasFlagVo.DetailRow> page = new Page<>(query.getPageNum(), query.getPageSize());
        List<SRaGasFlagVo.DetailRow> list = gasFlagService.getGasFlagDetailList(page, query);
        page.setRecords(list);
        return AjaxResults.success(page);
    }

    @ApiOperation(value = "导出废气在线监测标记明细")
    @PostMapping("/detail/export")
    public void detailExport(HttpServletResponse response, @RequestBody SRaGasFlagQuery query) {
        Page<SRaGasFlagVo.DetailRow> page = new Page<>(query.getPageNum(), query.getPageSize());
        List<SRaGasFlagVo.DetailRow> list = gasFlagService.getGasFlagDetailList(page, query);
        ExcelUtil<SRaGasFlagVo.DetailRow> util = new ExcelUtil<>(SRaGasFlagVo.DetailRow.class);
        util.exportExcel(response, list, "废气在线监测标记明细数据");
    }

}
