package com.hdkj.lt.bf.controller;

import com.hdkj.lt.bf.aspect.RequiresCountryPermissions;
import com.hdkj.lt.bf.entity.dto.BeakerStatusDTO;
import com.hdkj.lt.bf.entity.dto.SwitchOrTransformerDTO;
import com.hdkj.lt.bf.entity.vo.*;
import com.hdkj.lt.bf.service.FhzgSvgBreakersService;
import com.hdkj.lt.core.bizms.modle.request.StateEstimationEquipRequest;
import com.hdkj.lt.core.mvc.BaseController;
import com.hdkj.hussar.ApiResponse;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/fhzgSvg")
@RequiredArgsConstructor
public class FhzgSvgBreakerController extends BaseController {

    private final FhzgSvgBreakersService fhzgSvgBreakersService;

    @PostMapping("/getBreakerStatusInfo")
    @ApiOperation(value = "通过通过线路id查询SVG开关状态信息")
    public ApiResponse<List<BeakerSvgInfoVO>> getBreakerStatusInfo(@RequestBody BeakerStatusDTO dto) {
        List<BeakerSvgInfoVO> breakerList = fhzgSvgBreakersService.getBreakerStatusInfo(dto);
        return ApiResponse.success(breakerList);
    }

    @PostMapping("/getCurveInfo")
    @ApiOperation(value = "通过获取曲线信息信息")
    public ApiResponse<PqiuCurveInfoVO> getPqiuCurveInfo(@Valid @RequestBody StateEstimationEquipRequest dto) {
        PqiuCurveInfoVO pqiuCurveInfo = fhzgSvgBreakersService.getPqiuCurveInfo(dto);
        return ApiResponse.success(pqiuCurveInfo);
    }

    @PostMapping("/getBreakerStatusInfoLc")
    @ApiOperation(value = "通过通过线路id查询SVG开关状态信息量测")
    public ApiResponse<List<BeakerStatusInfoVO>> getBreakerStatusInfoLc(@RequestBody BeakerStatusDTO dto) {
        List<BeakerStatusInfoVO> breakerList = fhzgSvgBreakersService.getBeakerStatusInfoLc(dto);
        return ApiResponse.success(breakerList);
    }

    @PostMapping("/getBreakerStatusInfoZg")
    @ApiOperation(value = "通过通过线路id查询SVG开关状态信息状估")
    @RequiresCountryPermissions(lineFields = "linePsrId")
    public ApiResponse<List<BeakerStatusInfoVO>> getBreakerStatusInfoZg(@RequestBody BeakerStatusDTO dto) {
        List<BeakerStatusInfoVO> breakerList = fhzgSvgBreakersService.getBeakerStatusInfoZg(dto);
        return ApiResponse.success(breakerList);
    }

    @PostMapping("/getBreakerStatusInfoZgh")
    @ApiOperation(value = "通过通过线路id查询SVG开关状态信息转供后")
    public ApiResponse<List<BeakerStatusInfoVO>> getBreakerStatusInfoZgh(@RequestBody BeakerStatusDTO dto) {
        List<BeakerStatusInfoVO> breakerList = fhzgSvgBreakersService.getBeakerStatusInfoZgh(dto);
        return ApiResponse.success(breakerList);
    }

    @PostMapping("/getBreakerStatusInfoBg")
    @ApiOperation(value = "通过通过线路id查询SVG开关状态信息保护定值")
    public ApiResponse<List<BeakerBreakerProtectionInfoVO>> getBreakerStatusInfoBg(@RequestBody BeakerStatusDTO dto) {
        List<BeakerBreakerProtectionInfoVO> breakerList = fhzgSvgBreakersService.getBeakerStatusInfoBg(dto);
        return ApiResponse.success(breakerList);
    }


    @PostMapping("/getBeakerSvgInfoVOByPsrId")
    @ApiOperation(value = "通过通过开关id查询SVG开关状态信息")
    @RequiresCountryPermissions(lineFields = "linePsrId")
    public ApiResponse<BeakerSvgInfoVO> getBeakerSvgInfoVOByPsrId(@RequestBody BeakerStatusDTO dto) {
        BeakerSvgInfoVO beakerSvgInfoVO = fhzgSvgBreakersService.getBeakerSvgInfoVOByPsrId(dto);
        return ApiResponse.success(beakerSvgInfoVO);
    }

    @PostMapping("/saveStatusInfoZgList")
    @ApiOperation(value = "批量调用状估接口保存线路pqui数据")
    public ApiResponse<List<BeakerStatusInfoVO>> saveStatusInfoZgList(@RequestBody BeakerStatusDTO dto) {
        List<BeakerStatusInfoVO> breakerList = fhzgSvgBreakersService.saveStatusInfoZgList(dto);
        return ApiResponse.success(breakerList);
    }

    @PostMapping("/deleteSvgPqui")
    @ApiOperation(value = "删除指定区县下所有线路pqui数据缓存")
    public ApiResponse<List<BeakerStatusInfoVO>> deleteSvgPqui(@RequestBody BeakerStatusDTO dto) {
        fhzgSvgBreakersService.deleteSvgPqui(dto);
        return ApiResponse.success();
    }


    @PostMapping("/getSwitchAndTransformerList")
    @ApiOperation(value = "获取开关配变列表")
    @RequiresCountryPermissions(lineFields = "feederId")
    public ApiResponse<List<SwitchOrTransformerVO>> getSwitchAndTransformerList(@RequestBody SwitchOrTransformerDTO dto) {
        return ApiResponse.success(fhzgSvgBreakersService.getSwitchAndTransformerList(dto));
    }

    @PostMapping("/getSwitchOrTransformerInfo")
    @ApiOperation(value = "获取开关配变对应定位id")
    public ApiResponse<SwitchOrTransformerVO> getSwitchOrTransformerInfo(@RequestBody SwitchOrTransformerDTO dto) {
        return ApiResponse.success(fhzgSvgBreakersService.getSwitchOrTransformerInfo(dto));
    }

}
