package com.njcn.device.pms.controller.ledgerManger;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pms.pojo.po.StatationStat;
import com.njcn.device.pms.pojo.vo.StatationStatVO;
import com.njcn.device.pms.service.majornetwork.IStatationStatService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wr
 * @since 2023-08-08
 */
@Slf4j
@Api(tags = "冀北变电站统计")
@RestController
@RequestMapping("/pms/substationStatistics")
@RequiredArgsConstructor
public class SubstationController extends BaseController {

    private final IStatationStatService statationStatService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getStatistics")
    @ApiOperation("获取在运变电站数量")
    public HttpResult<List<Integer>> getStatisticsMotion(String orgID) {
        String methodDescribe = getMethodDescribe("getStatisticsMotion");
        List<Integer> integers = statationStatService.statisticsMotion(orgID);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, integers, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getOrgStatistics")
    @ApiOperation("获取部门各个部门变电站数量（按电压等级区分）")
    public HttpResult<List<List<StatationStatVO.StatationParam>>> getOrgStatisticsMotion(String orgID) {
        String methodDescribe = getMethodDescribe("getOrgStatisticsMotion");
        List<List<StatationStatVO.StatationParam>> lists = statationStatService.orgStatisticsMotion(orgID);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lists, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getStatationStat")
    @ApiOperation("获取变压器列表")
    public HttpResult<List<StatationStat>> getStatationStat(String orgID) {
        String methodDescribe = getMethodDescribe("getStatationStat");
        List<StatationStat> statationStatList = statationStatService.getStatationStatList(orgID);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, statationStatList, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @GetMapping("/getHarmonicCurve")
    @ApiOperation("获取变压器谐波日曲线")
    public HttpResult<List<StatationStatVO.Curve>> getHarmonicCurve(String subID,String voltageLevel) {
        String methodDescribe = getMethodDescribe("getHarmonicCurve");
        List<StatationStatVO.Curve> curves = statationStatService.getStatationStatCurve(subID, voltageLevel,0);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, curves, methodDescribe);
    }
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @GetMapping("/getActiveCurve")
    @ApiOperation("获取变压器功率日曲线")
    public HttpResult<List<StatationStatVO.Curve>> getActiveCurve(String subID,String voltageLevel) {
        String methodDescribe = getMethodDescribe("getActiveCurve");
        List<StatationStatVO.Curve> curves = statationStatService.getStatationStatCurve(subID, voltageLevel,1);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, curves, methodDescribe);
    }

}

