package com.ruoyi.ems.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
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.PvSupplyH;
import com.ruoyi.ems.service.IPvSupplyHService;

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

    /**
     * 查询光伏并网计量光伏并网计量-小时列表
     */
    @RequiresPermissions("ems:prod:list")
    @GetMapping("/list")
    public AjaxResult list(PvSupplyH admEmsPvSupplyH) {
        List<PvSupplyH> list = admEmsPvSupplyHService.selectPvSupplyHList(admEmsPvSupplyH);
        return success(list);
    }

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

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

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

    @RequiresPermissions("ems:prod:list")
    @GetMapping("/list/prod/this/day/total")
    public AjaxResult listProdThisDayTotalIndex(PvSupplyH admEmsPvSupplyH) {
        List<Map<String, Object>> list = admEmsPvSupplyHService
            .selectAreaSupplyHByThisDay(admEmsPvSupplyH.getAreaCode());
        return success(list);
    }

    @RequiresPermissions("ems:prod:list")
    @GetMapping("/list/prod/this/month/total")
    public AjaxResult listProdThisMonthTotalIndex(PvSupplyH admEmsPvSupplyH) {
        List<Map<String, Object>> list = admEmsPvSupplyHService
            .selectAreaSupplyHByRefMonth(admEmsPvSupplyH.getAreaCode());
        return success(list);
    }

    @RequiresPermissions("ems:prod:list")
    @GetMapping("/list/prod/this/year/total")
    public AjaxResult listProdThisYearTotalIndex(PvSupplyH admEmsPvSupplyH) {
        List<Map<String, Object>> list = admEmsPvSupplyHService.selectAreaSupplyHByYear(admEmsPvSupplyH.getAreaCode());
        return success(list);
    }

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