package com.hdkj.lt.mq.feign;

import com.hdkj.lt.feign.IPlanCreateClient;
import com.hdkj.lt.modle.dto.plan.AcceptPlanPowerCutListRequest;
import com.hdkj.lt.modle.dto.plan.PlanCreateSwitchDTO;
import com.hdkj.lt.mq.entity.dto.AcceptPlanPowerCutListDTO;
import com.hdkj.lt.mq.service.plan.AcceptPlanPowerCutService;
import com.hdkj.lt.mq.service.plan.impl.FhzgReasoningPlatformServiceImpl;
import com.hdkj.hussar.ApiResponse;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author rj
 * @date 2025/9/1 16:39
 * @description
 */
@RequiredArgsConstructor
@Slf4j
@RestController
public class PlanCreateClient implements IPlanCreateClient {

    private final AcceptPlanPowerCutService acceptPlanPowerCutService;

    private final FhzgReasoningPlatformServiceImpl fhzgReasoningPlatformService;


    @Override
    public Boolean checkPowerOutArea(@RequestBody PlanCreateSwitchDTO planCreateSwitchDTO) {
        return fhzgReasoningPlatformService.checkPowerOutArea(planCreateSwitchDTO);
    }

    @Override
    public ApiResponse<Boolean> createPlanPowerCut(@RequestBody PlanCreateSwitchDTO planCreateSwitchDTO) {
        boolean result = acceptPlanPowerCutService.createPlanPowerCut(planCreateSwitchDTO);
        return ApiResponse.success(result);
    }

    @Override
    public ApiResponse<String> acceptPlanPowerCut(@RequestBody AcceptPlanPowerCutListRequest request) {
        AcceptPlanPowerCutListDTO dto = AcceptPlanPowerCutListDTO.builder()
                .startTime(request.getStartTime())
                .endTime(request.getEndTime())
                .feederList(request.getFeederList()).build();
        String planNo = acceptPlanPowerCutService.autoTaskCreatePlan(dto);
        return ApiResponse.success(planNo);
    }
}
