package com.hw.ems.report.controller;

import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.ems.report.service.IBoardService;
import com.hw.ems.report.service.IDataAnalysisService;
import com.hw.ems.report.service.IEnergyPreviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * 首页看板数据接口Controller
 *
 * @author YinQ
 * @date 2023-04-05
 */
@Controller
@RequestMapping("/report/board")
public class BoardController extends BaseController
{
    private String prefix = "report/board";

    @Autowired
    private IEnergyPreviewService energyPreviewService;

    @Autowired
    private IDataAnalysisService dataAnalysisService;

    @Autowired
    private IBoardService boardService;

    /**
     * 首页看板
     * @return
     */
    @GetMapping("/index")
    public String index()
    {
        return prefix + "/index";
    }


    /**
     * 能耗预览看板
     * @return
     */
    @GetMapping("/energyPreview")
    public String energyPreview()
    {
        return prefix + "/energyPreview";
    }

    /**
     * 表具状态看板
     * @return
     */
    @GetMapping("/tablewareState")
    public String tablewareState()
    {
        return prefix + "/tablewareState";
    }
    /**
     * 园区看板
     * @return
     */
    @GetMapping("/parkPage")
    public String parkPage()
    {
        return prefix + "/page";
    }


    /**
     * 首页能耗曲线图
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/indexCurveChart")
    public AjaxResult indexCurveChart(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = energyPreviewService.indexBarChart(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 首页今日、本周、当月、当年耗量
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/fourEnergy")
    public AjaxResult fourEnergy(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = energyPreviewService.fourEnergy(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 首页建筑、业态、分项饼图
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/threePieChart")
    public AjaxResult threePieChart(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = energyPreviewService.threePieChart(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 首页建筑、业态、分项柱图
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/columnarChart")
    public AjaxResult columnarChart(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = energyPreviewService.columnarChart(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 点抄数据柱状图
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/dnbCountingData")
    public AjaxResult dnbCountingData(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = energyPreviewService.dnbCountingData(paramMap);
        return AjaxResult.success(result);
    }


    /**
     * 预览看板耗量折线
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/previewPolyline")
    public AjaxResult previewPolyline(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = dataAnalysisService.previewPolyline(paramMap);
        return AjaxResult.success(result);
    }


    /**
     * 能耗排名
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/energyRanking")
    public AjaxResult energyRanking(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = energyPreviewService.energyRanking(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 线损排名
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/lineLossRanking")
    public AjaxResult lineLossRanking(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = dataAnalysisService.lineLossRanking(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 预览看板线损折线
     * 传参：monitorId
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/previewLineLossLine")
    public AjaxResult previewLineLossLine(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = dataAnalysisService.previewLineLossLine(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 表具状态信息
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/tablewareInfo")
    public AjaxResult tablewareInfo(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = boardService.tablewareInfo(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 园区概览
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/parkHomepageOverview")
    public AjaxResult parkHomepageOverview(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = boardService.parkHomepageOverview(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 分项业态占比图
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/categoryBusinessChart")
    public AjaxResult categoryBusinessChart(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = boardService.categoryBusinessChart(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 接入园区、设备数量
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/parkEquipmentNumber")
    public AjaxResult parkEquipmentNumber(@RequestParam(required = false) Map paramMap){
        Map<String, Object> result = boardService.parkEquipmentNumber(paramMap);
        return AjaxResult.success(result);
    }

    /**
     * 各园区能耗排名
     * @param paramMap
     * @return
     */
    @ResponseBody
    @GetMapping("/parkEnergyRanking")
    public AjaxResult parkEnergyRanking(@RequestParam(required = false) Map paramMap){
        ArrayList<HashMap<String, Object>> result = boardService.parkEnergyRanking(paramMap);
        return AjaxResult.success(result);
    }

}
