package com.hdkj.lt.bf.controller;

import com.hdkj.lt.bf.entity.dto.*;
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.plan.FhzgPlanTransferScheme;
import com.hdkj.lt.core.bizms.modle.po.plan.FhzgPlanTransferSchemeOppositeLineLoadFactor;
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("/fhzgPlanTransferSchemeEvaluation")
@RequiredArgsConstructor
public class FhzgPlanTransferSchemeEvaluationController {

    @Autowired
    IFhzgPlanTransferSchemeEvaluationIndexService fhzgPlanTransferSchemeEvaluationIndexService;

    @Autowired
    IFhzgPlanTransferSchemeStrategyScoreService fhzgPlanTransferSchemeStrategyScoreService;

    @Autowired
    IFhzgPlanTransferSchemeTransferSituationService fhzgPlanTransferSchemeTransferSituationService;

    @Autowired
    FhzgPlanTransferSchemeOppositeLineLoadFactorService fhzgPlanTransferSchemeOppositeLineLoadFactorService;

    @Autowired
    FhzgPlanTransferSchemePathDetailService fhzgPlanTransferSchemePathDetailService;

    @Autowired
    FhzgPlanTransferSchemeService fhzgPlanTransferSchemeService;


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

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

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


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

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

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

    /**
     * 查询对侧负载率情况
     * @param transferSchemeEvaluationReqDTO
     * @return
     */
    @PostMapping("/getTransferSchemeOppositeLineLoadFactorBySchemeId")
    @ApiOperation(value = "查询对侧负载率情况")
    public ApiResponse<List<FhzgPlanTransferSchemeOppositeLineLoadFactorDTO>> getTransferSchemeOppositeLineLoadFactorBySchemeId(@RequestBody TransferSchemeEvaluationReqDTO transferSchemeEvaluationReqDTO) {
        FhzgPlanTransferSchemeOppositeLineLoadFactor fhzgPlanTransferSchemeOppositeLineLoadFactor = new FhzgPlanTransferSchemeOppositeLineLoadFactor();
        fhzgPlanTransferSchemeOppositeLineLoadFactor.setSchemeId(transferSchemeEvaluationReqDTO.getSchemeId());
        List<FhzgPlanTransferSchemeOppositeLineLoadFactorDTO> stringList = fhzgPlanTransferSchemeOppositeLineLoadFactorService.getTransferSchemeOppositeLineLoadFactorBySchemeId(fhzgPlanTransferSchemeOppositeLineLoadFactor);
        return ApiResponse.success(stringList);
    }
}
