package com.hw.ems.report.controller;

import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.page.TableDataInfo;
import com.hw.ems.report.service.IEnergyPreviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

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

/**
 * 能源预览Controller
 *
 * @author YinQ
 * @date 2023-04-05
 */
@Controller
@RequestMapping("/report/preview")
public class energyPreviewController extends BaseController {
    private String prefix = "report/preview";

    @Autowired
    private IEnergyPreviewService energyPreviewService;


    /**
     * 电能源预览
     *
     * @return
     */
    @GetMapping("/dnbIndex/{energyType}")
    public String dnbIndex(@PathVariable("energyType") Long energyType, ModelMap mmap) {
        mmap.put("energyType", energyType);
        return prefix + "/dnbIndex";
    }


    /**
     * 能源预览返回数据
     *
     * @param map
     * @return
     */
    @PostMapping("/consumptionReport/{monitorType}")
    @ResponseBody
    public TableDataInfo indexDataReport(@RequestBody Map map, @PathVariable("monitorType") Long energyType) {
        List<Map<String, String>> list = energyPreviewService.indexDataReport(map, energyType);
        return getDataTable(list);
    }


    /**
     * 水能源预览
     *
     * @return
     */
    @GetMapping("/waterIndex/{energyType}")
    public String energyPreview(@PathVariable("energyType") Long energyType, ModelMap mmap) {
        mmap.put("energyType", energyType);
        return prefix + "/waterIndex";
    }


}
