package com.ruoyi.web.controller.ems;

import com.huashe.common.domain.AjaxResult;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ems.domain.ElecPvSupplyH;
import com.ruoyi.ems.model.QueryMeter;
import com.ruoyi.ems.service.IElecPvSupplyHService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 光伏并网计量-小时Controller
 *
 * @author ruoyi
 * @date 2024-08-02
 */
@RestController
@RequestMapping("/ems/prod/pv")
@Api(value = "ElecPvSupplyHController", description = "光伏并网计量数据接口")
public class ElecPvSupplyHController extends BaseController {
    @Autowired
    private IElecPvSupplyHService pvSupplyHService;

    /**
     * 查询光伏并网计量光伏并网计量-小时列表
     */
    @PreAuthorize("@ss.hasPermi('ems:prod:list')")
    @GetMapping("/hour/list")
    public TableDataInfo list(ElecPvSupplyH pvSupplyH) {
        startPage();
        List<ElecPvSupplyH> list = pvSupplyHService.selectPvSupplyHList(pvSupplyH);
        return getDataTable(list);
    }

    /**
     * 查询光伏并网计量光伏并网计量-小时列表
     */
    @PreAuthorize("@ss.hasPermi('ems:prod:list')")
    @GetMapping("/day/list")
    public AjaxResult listByDay(QueryMeter param) {
        List<ElecPvSupplyH> list = pvSupplyHService.selectPvSupplyDayList(param);
        return success(list);
    }

    /**
     * 导出光伏并网计量光伏并网计量-小时列表
     */
    @Log(title = "光伏并网计量光伏并网计量-小时", businessType = BusinessType.EXPORT)
    @PostMapping("/hour/export")
    public void export(HttpServletResponse response, ElecPvSupplyH pvSupplyH) {
        List<ElecPvSupplyH> list = pvSupplyHService.selectPvSupplyHList(pvSupplyH);
        ExcelUtil<ElecPvSupplyH> util = new ExcelUtil<ElecPvSupplyH>(ElecPvSupplyH.class);
        util.exportExcel(response, list, "光伏并网计量光伏并网计量-小时数据");
    }
}
