package com.hdkj.lt.bf.controller;
import com.hdkj.lt.bf.entity.dto.FaultTransferSchemeOppositeLineLoadFactorDTO;
import com.hdkj.lt.bf.entity.dto.FaultTransferSchemeSwitchingSequenceAndPathDTO;
import com.hdkj.lt.bf.entity.dto.FhzgFaultTransferSchemeDTO;
import com.hdkj.lt.bf.entity.dto.FhzgFaultTransferSchemeTransferSituationDTO;
import com.hdkj.lt.bf.entity.vo.SectionTransferPage;
import com.hdkj.lt.bf.entity.vo.TransferSchemeEvaluationIndexVO;
import com.hdkj.lt.bf.entity.vo.TransferSchemeStrategyScoreVO;
import com.hdkj.lt.bf.service.*;
import com.hdkj.lt.core.bizms.modle.dto.TransferSchemeEvaluationReqDTO;

import com.hdkj.lt.core.bizms.modle.po.fault.FaultTransferScheme;
import com.hdkj.lt.core.bizms.modle.po.fault.FaultTransferSchemeOppositeLineLoadFactor;
import com.hdkj.hussar.ApiResponse;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;

/**
 * @author luorui
 * @date 2025/5/14 15:18
 *
 * 故障停电转供方案评分控制器
 */
@RestController
@RequestMapping("/fhzgFaultTransferSchemeEvaluation")
@RequiredArgsConstructor
public class FhzgFaultTransferSchemeEvaluationController {

    @Autowired
    IFaultTransferSchemeEvaluationIndexService fhzgFaultTransferSchemeEvaluationIndexService;

    @Autowired
    IFaultTransferSchemeStrategyScoreService fhzgFaultTransferSchemeStrategyScoreService;

    @Autowired
    IFaultTransferSchemeTransferSituationService fhzgFaultTransferSchemeTransferSituationService;

    @Autowired
    IFaultTransferSchemeOppositeLineLoadFactorService fhzgFaultTransferSchemeOppositeLineLoadFactorService;

    @Autowired
    IFaultTransferSchemePathDetailService fhzgFaultTransferSchemePathDetailService;

    @Autowired
   IFaultTransferSchemeService fhzgFaultTransferSchemeService;


    /**
     * 摘要模式 评比指标查询
     * @param transferSchemeEvaluationReqDTO
     * @return
     */
    @PostMapping("/getTransferSchemeEvaluationIndexByFaultId")
    @ApiOperation(value = "故障停电摘要模式评比指标查询")
    public ApiResponse<TransferSchemeEvaluationIndexVO> getTransferSchemeEvaluationIndexByFaultId(@RequestBody TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        TransferSchemeEvaluationIndexVO result = fhzgFaultTransferSchemeEvaluationIndexService.getTransferSchemeEvaluationIndexByFaultId(transferSchemeEvaluationReqDTO);
        return ApiResponse.success(result);
    }

    /**
     * 摘要模式查询方案得分详情
     * @param transferSchemeEvaluationReqDTO
     * @return
     */
    @PostMapping("/getTransferSchemeStrategyScoreByFaultId")
    @ApiOperation(value = "故障停电摘要模式查询方案得分详情")
    public ApiResponse<TransferSchemeStrategyScoreVO> getTransferSchemeStrategyScoreByFaultId(@RequestBody TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        TransferSchemeStrategyScoreVO result = fhzgFaultTransferSchemeStrategyScoreService.getTransferSchemeStrategyScoreByFaultId(transferSchemeEvaluationReqDTO);
        return ApiResponse.success(result);
    }

    /**
     * 查询方案列表 打上标签，并排序
     * @param transferSchemeEvaluationReqDTO
     * @return
     */
    @PostMapping("/getTransferSchemeEvaluationListByFaultId")
    @ApiOperation(value = "查询方案列表 打上标签，并排序")
    public ApiResponse<List<FhzgFaultTransferSchemeDTO>> getTransferSchemeEvaluationListByFaultId(@RequestBody TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        List<FhzgFaultTransferSchemeDTO> fhzgFaultTransferSchemeDTOList = fhzgFaultTransferSchemeStrategyScoreService.getTransferSchemeEvaluationListByFaultId(transferSchemeEvaluationReqDTO);
        return ApiResponse.success(fhzgFaultTransferSchemeDTOList);
    }


    /**
     * 查询风险提示信息
     * @param transferSchemeEvaluationReqDTO
     * @return
     */
    @PostMapping("/getTransferSchemeRiskWarningFaultById")
    @ApiOperation(value = "查询风险提示信息")
    public ApiResponse<List<String>> getTransferSchemeRiskWarningByFaultId(@RequestBody TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        List<String> stringList = fhzgFaultTransferSchemeEvaluationIndexService.getTransferSchemeRiskWarningById(transferSchemeEvaluationReqDTO);
        return ApiResponse.success(stringList);
    }

    /**
     * 转供路径以及开关动作顺序概述
     * @param transferSchemeEvaluationReqDTO
     * @return
     */
    @PostMapping("/getTransferSchemePathAndSwitchById")
    @ApiOperation(value = "转供路径以及开关动作顺序概述")
    public ApiResponse<SectionTransferPage<FaultTransferSchemeSwitchingSequenceAndPathDTO>> getTransferSchemePathAndSwitchById(@RequestBody TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        FaultTransferScheme fhzgFaultTransferScheme = new FaultTransferScheme();
        fhzgFaultTransferScheme.setId(transferSchemeEvaluationReqDTO.getSchemeId());
        fhzgFaultTransferScheme.setPageSize(transferSchemeEvaluationReqDTO.getPageSize());
        fhzgFaultTransferScheme.setPageNum(transferSchemeEvaluationReqDTO.getPageNum());
        fhzgFaultTransferScheme.setSwitchType(transferSchemeEvaluationReqDTO.getSwitchType());
        SectionTransferPage<FaultTransferSchemeSwitchingSequenceAndPathDTO> result = fhzgFaultTransferSchemePathDetailService.getTransferSchemePathAndSwitchById(fhzgFaultTransferScheme);
        return ApiResponse.success(result);
    }

    /**
     * 转供情况查询
     * @param transferSchemeEvaluationReqDTO
     * @return
     */
    @PostMapping("/getTransferSchemeSituationById")
    @ApiOperation(value = "转供情况查询")
    public ApiResponse<FhzgFaultTransferSchemeTransferSituationDTO> getTransferSchemeSituationById(@RequestBody TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        //转供情况、查询待转供用户信息和 损失用户信息统计得来
        FhzgFaultTransferSchemeTransferSituationDTO fhzgFaultTransferSchemeTransferSituationDTO = fhzgFaultTransferSchemeService.getTransferSchemeSituationById(transferSchemeEvaluationReqDTO);
        return ApiResponse.success(fhzgFaultTransferSchemeTransferSituationDTO);
    }

    /**
     * 查询对侧负载率情况
     * @param transferSchemeEvaluationReqDTO
     * @return
     */
    @PostMapping("/getTransferSchemeOppositeLineLoadFactorBySchemeId")
    @ApiOperation(value = "查询对侧负载率情况")
    public ApiResponse<List<FaultTransferSchemeOppositeLineLoadFactorDTO>> getTransferSchemeOppositeLineLoadFactorBySchemeId(@RequestBody TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        FaultTransferSchemeOppositeLineLoadFactor fhzgFaultTransferSchemeOppositeLineLoadFactor = new FaultTransferSchemeOppositeLineLoadFactor();
        fhzgFaultTransferSchemeOppositeLineLoadFactor.setSchemeId(transferSchemeEvaluationReqDTO.getSchemeId());
        List<FaultTransferSchemeOppositeLineLoadFactorDTO> faultTransferSchemeOppositeLineLoadFactorDTOList = fhzgFaultTransferSchemeOppositeLineLoadFactorService.getTransferSchemeOppositeLineLoadFactorBySchemeId(fhzgFaultTransferSchemeOppositeLineLoadFactor);
        return ApiResponse.success(faultTransferSchemeOppositeLineLoadFactorDTOList);
    }
}
