package com.ruoyi.ems.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
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 com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.ems.domain.AdmEmsPvSupplyH;
import com.ruoyi.ems.service.IAdmEmsPvSupplyHService;

/**
 * 光伏并网计量光伏并网计量-小时Controller
 *
 * @author ruoyi
 * @date 2024-08-02
 */
@RestController
@RequestMapping("/prod")
public class AdmEmsPvSupplyHController extends BaseController {
    @Autowired
    private IAdmEmsPvSupplyHService admEmsPvSupplyHService;
    /**
     * 查询光伏并网计量光伏并网计量-小时列表
     */
    @RequiresPermissions("ems:prod:list")
    @GetMapping("/list")
    public AjaxResult list(AdmEmsPvSupplyH admEmsPvSupplyH) {
        List<AdmEmsPvSupplyH> list = admEmsPvSupplyHService.selectAdmEmsPvSupplyHList(admEmsPvSupplyH);
        return success(list);
    }

    @RequiresPermissions("ems:prod:list")
    @GetMapping("/list/prod/this/day/index")
    public AjaxResult listProdIndex(AdmEmsPvSupplyH admEmsPvSupplyH) {
        admEmsPvSupplyH.setDate(DateUtils.getNowDate());
        List<AdmEmsPvSupplyH> list = admEmsPvSupplyHService.selectAreaSupplyH(admEmsPvSupplyH);
        return success(list);
    }

    @RequiresPermissions("ems:prod:list")
    @GetMapping("/list/prod/this/month/index")
    public AjaxResult listProdMonthIndex(AdmEmsPvSupplyH admEmsPvSupplyH) {
        List<AdmEmsPvSupplyH> list = admEmsPvSupplyHService.selectAreaSupplyH(admEmsPvSupplyH);
        return success(list);
    }

    @RequiresPermissions("ems:prod:list")
    @GetMapping("/list/prod/this/year/index")
    public AjaxResult listProdYearIndex(AdmEmsPvSupplyH admEmsPvSupplyH) {
        List<AdmEmsPvSupplyH> list = admEmsPvSupplyHService.selectAreaSupplyH(admEmsPvSupplyH);
        return success(list);
    }

    /**
     * 导出光伏并网计量光伏并网计量-小时列表
     */
    @RequiresPermissions("ems:prod:export")
    @Log(title = "光伏并网计量光伏并网计量-小时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdmEmsPvSupplyH admEmsPvSupplyH) {
        List<AdmEmsPvSupplyH> list = admEmsPvSupplyHService.selectAdmEmsPvSupplyHList(admEmsPvSupplyH);
        ExcelUtil<AdmEmsPvSupplyH> util = new ExcelUtil<AdmEmsPvSupplyH>(AdmEmsPvSupplyH.class);
        util.exportExcel(response, list, "光伏并网计量光伏并网计量-小时数据");
    }
}
