package com.ruoyi.web.controller.ems;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.huashe.common.domain.AjaxResult;
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.ElecUseH;
import com.ruoyi.ems.model.ElecUseSta;
import com.ruoyi.ems.model.QueryIndex;
import com.ruoyi.ems.service.IElecUseHService;
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.PathVariable;
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-15
 */
@Deprecated
@RestController
@RequestMapping("/ems/elec/use")
@Api(value = "ElecUseHController", description = "用电计量数据接口")
public class ElecUseHController extends BaseController {
    @Autowired
    private IElecUseHService elecUseHService;

    /**
     * 查询用能计量-小时列表
     */
    @GetMapping("/hour/list")
    public TableDataInfo hourList(ElecUseH elecUseH) {
        startPage();
        List<ElecUseH> list = elecUseHService.getElecUseHList(elecUseH);
        return getDataTable(list);
    }

    @GetMapping("/day/list")
    public TableDataInfo dayList(QueryIndex queryIndex) {
        List<ElecUseH> list = elecUseHService.getElecUseDayList(queryIndex);
        return getDataTable(list);
    }

    @GetMapping("/hour/sumBySubCategory")
    public AjaxResult sumBySubCategory(ElecUseH elecUseH) {
        List<ElecUseSta> list = elecUseHService.getSumBySubCategory(elecUseH);
        return success(list);
    }

    @GetMapping("/hour/sumByFacs")
    public AjaxResult sumByFacs(ElecUseH elecUseH) {
        List<ElecUseSta> list = elecUseHService.getSumByFacs(elecUseH);
        return success(list);
    }

    @GetMapping("/hour/listSum")
    public TableDataInfo listSum(ElecUseH elecUseH) {
        startPage();
        List<ElecUseH> list = elecUseHService.getElecUseHListSum(elecUseH);
        return getDataTable(list);
    }

    /**
     * 导出用能计量-小时列表
     */
    @Log(title = "用能计量-小时", businessType = BusinessType.EXPORT)
    @PostMapping("/hour/export")
    public void export(HttpServletResponse response, ElecUseH elecUseH) {
        List<ElecUseH> list = elecUseHService.getElecUseHList(elecUseH);
        ExcelUtil<ElecUseH> util = new ExcelUtil<ElecUseH>(ElecUseH.class);
        util.exportExcel(response, list, "用能计量-小时数据");
    }

    /**
     * 获取用能计量-小时详细信息
     */
    @GetMapping(value = "/hour/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(elecUseHService.getElecUseHById(id));
    }
}
