package com.nantian.cloud.dbcapp.controller;


import com.nantian.cloud.dbcapp.service.ElectricityService;
import com.nantian.sc.cloud.common.core.util.R;
import com.nantian.sc.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;


/**
* @Description: 电力controller
* @Param: 
* @return: 
* @Author: zfw
* @Date: 2020/12/22
* @Date: 20:05
*/
@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/electricity")
@Api(value = "electricity", tags = "电力")

public class ElectricityController {

    private final ElectricityService electricityService;


    /**
     * 用能单位接入数量
     *
     * @param
     * @return R
     */
    @RequestMapping("/total")
    @SysLog("电力-用能单位接入数量")
    @ApiOperation(value = "用能单位接入数量", notes = "用能单位接入数量")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "周期", required = false, dataType = "string", paramType = "path")
                })
    public R getTotal( String area ,String industry,String time) {
        return R.ok(electricityService.getTotal(area,industry,time),"查询成功");
    }


    /**
     * 电力企业数量
     *
     * @param
     * @return R
     */
    @GetMapping("/info")
    @SysLog("电力-电力企业数量")
    @ApiOperation(value = "电力企业数量", notes = "电力企业数量")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "周期", required = false, dataType = "string", paramType = "path")
    })
    public R getInfo( String area ,String industry,String time) {
        return R.ok(electricityService.getInfo(area,industry,time),"查询成功");
    }

    /**
     * 查询电力数据
     *
     * @param
     * @return R
     */
    @RequestMapping("/infoData")
    @SysLog("电力-查询电力数据")
    @ApiOperation(value = "电力数据", notes = "电力数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "周期", required = false, dataType = "string", paramType = "path")
    })
    public R getInfoData( String area ,String industry,String time) {
        return R.ok(electricityService.getInfoData(area,industry,time));
    }

    /**
    * @Description: 电力数据按月查询
    * @Param: 
    * @return: 
    * @Author: zfw
    * @Date: 2021/2/18
    * @Date: 14:33
    */
    @GetMapping("/EnterpriseInfoData")
    @SysLog("电力-电力数据按月查询")
    @ApiOperation(value = "电力数据", notes = "电力数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "周期", required = false, dataType = "string", paramType = "path")
    })
    public R getInfoData( String enterpriseCode,String time) throws ParseException {
        return R.ok(electricityService.getEnterpriseInfoData(enterpriseCode,time));
    }
    /**
    * @Description: 按天查询电力数据
    * @Param: [enterpriseCode, time]
    * @return: com.nantian.sc.cloud.common.core.util.R
    * @Author: zfw
    * @Date: 2021/2/18
    * @Date: 15:37
    */
    @SysLog("电力-按天查询电力数据")
    @GetMapping("/EnterpriseInfoDataDetail")
    @ApiOperation(value = "电力数据", notes = "电力数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "周期", required = false, dataType = "string", paramType = "path")
    })
    public R getInfoDataDetail( String enterpriseCode,String time) {
        return R.ok(electricityService.getEnterpriseInfoDataDetail(enterpriseCode,time));
    }


    @GetMapping("/getCollectData")
    @SysLog("电力-335家在线电力")
    @ApiOperation(value = "335家在线电力", notes = "335家在线电力")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "area", value = "地区", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "industry", value = "行业", required = false, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "time", value = "周期", required = false, dataType = "string", paramType = "path")
    })
    public R getInfoDataByArea( String area,String industry,String time) throws ParseException {
        return R.ok(electricityService.getCollectData(area,industry,time));
    }
}
