package cn.iocoder.yudao.module.mes.controller.admin.energydevice;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.mes.controller.admin.energydevice.vo.*;
import cn.iocoder.yudao.module.mes.controller.admin.energytype.vo.EnergyTypePageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.energytype.vo.EnergyTypeRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.energydevice.EnergyDeviceCheckRecordDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.energydevice.EnergyDeviceReportDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.energytype.EnergyTypeDO;
import cn.iocoder.yudao.module.mes.service.energydevice.EnergyDeviceReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 能耗报表")
@RestController
@RequestMapping("/mes/energy-report")
@Validated
public class EnergyDeviceReportController {

    @Resource
    private EnergyDeviceReportService energyDeviceReportService;

//    @PostMapping("/create")
//    @Operation(summary = "创建能源报表")
//    @PreAuthorize("@ss.hasPermission('mes:energy-device-report:create')")
//    public CommonResult<Long> createEnergyDeviceReport(@Valid @RequestBody EnergyDeviceReportSaveReqVO createReqVO) {
//        return success(energyDeviceReportService.createEnergyReportRecord(createReqVO));
//    }

    @GetMapping("/page")
    @Operation(summary = "获得抄表记录分页")
    @PreAuthorize("@ss.hasPermission('mes:energy-device-report:query')")
    public CommonResult<PageResult<EnergyDeviceReportRespVO>> getEnergyDeviceReportPage(@Valid EnergyDeviceReportPageReqVO pageReqVO) {
        PageResult<EnergyDeviceReportDO> pageResult = energyDeviceReportService.getEnergyDeviceReportPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, EnergyDeviceReportRespVO.class));
    }
}