package com.njcn.device.pq.controller;

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.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.dto.SubstationDTO;
import com.njcn.device.pq.pojo.param.AlarmStrategyParam;
import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.device.pq.pojo.vo.AlarmStrategyVO;
import com.njcn.device.pq.pojo.vo.LedgerSelectVO;
import com.njcn.device.pq.service.AlarmStrategyService;
import com.njcn.device.pq.service.ISubstationService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hongawen
 * @version 1.0.0
 * @date 2022年10月13日 19:54
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/substation")
@Api(tags = "变电站管理")
@AllArgsConstructor
public class SubstationController extends BaseController {

    private final ISubstationService substationService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("获取变电站详情")
    @PostMapping("getSubstationById")
    HttpResult<List<SubstationDTO>> getSubstationById(@RequestBody List<String> subId){
        String methodDescribe = getMethodDescribe("getSubstationById");
        List<SubstationDTO> substationDTOList = substationService.getSubstationById(subId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, substationDTOList, methodDescribe);
    }



    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("获取变电站列表")
    @GetMapping("getSubstationSelect")
    HttpResult<List<LedgerSelectVO>> getSubstationSelect(){
        String methodDescribe = getMethodDescribe("getSubstationSelect");
        List<LedgerSelectVO> substationDTOList = substationService.getSubstationSelect();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, substationDTOList, methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("获取变电站下面监测点")
    @GetMapping("getMonitorSelect")
    HttpResult<List<Line>> getMonitorSelect(@RequestParam("stationId")String stationId){
        String methodDescribe = getMethodDescribe("getMonitorSelect");
        List<Line> substationDTOList = substationService.getMonitorSelect(stationId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, substationDTOList, methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("获取变电站下面的母线列表")
    @GetMapping("getBusBarSelect")
    HttpResult<List<LedgerSelectVO>> getBusBarSelect(@RequestParam("stationId")String stationId){
        String methodDescribe = getMethodDescribe("getBusBarSelect");
        List<LedgerSelectVO> substationDTOList = substationService.getBusBarSelect(stationId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, substationDTOList, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("根据电站下面的电网侧测点")
    @GetMapping("getMonitorByStationId")
    HttpResult<List<LineDetail>> getMonitorByStationId(@RequestParam("stationId") String stationId,@RequestParam("powerFlag") Integer powerFlag){
        String methodDescribe = getMethodDescribe("getMonitorByStationId");
        List<LineDetail> lineDetailList = substationService.getPowerByStationId(stationId,powerFlag);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineDetailList, methodDescribe);
    }

}
