package com.hdkj.lt.mq.controller;

import com.hdkj.lt.modle.dto.abnormal.AbnormalMessageDataDTO;
import com.hdkj.lt.modle.dto.abnormal.AbnormalOperationDTO;
import com.hdkj.lt.mq.listener.RocketConsumerOutageOperationAbnormalityListener;
import com.hdkj.lt.mq.listener.RocketConsumerSimulationPlatformListener;
import com.hdkj.lt.mq.service.abnormal.FhzgGridOperationAbnormalityService;
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;

@Slf4j
@RestController
@RequestMapping("test/abNormal")
@RequiredArgsConstructor
public class AbnormalController {

    private final FhzgGridOperationAbnormalityService service;

    private final RocketConsumerOutageOperationAbnormalityListener rocketConsumerOutageOperationAbnormalityListener;
    private final RocketConsumerSimulationPlatformListener rocketConsumerSimulationPlatformListener;

    /**
     * 解析运行调优数据（测试）
     **/
    @PostMapping("/getResult")
    @ApiOperation(value = "获取调优数据")
    public ApiResponse<Boolean> analysisAbnormalData(@RequestBody Long id) {
        rocketConsumerSimulationPlatformListener.executeFunc(id, "3");
        return ApiResponse.success();
    }

    /**
     * 接收运行调优消息（手动）
     */
    @PostMapping("/acceptAbnormalData")
    @ApiOperation(value = "根据运行调优id解析运行调优数据")
    public ApiResponse<Boolean> acceptAbnormalData(@RequestBody String id) {
        rocketConsumerOutageOperationAbnormalityListener.executeFunc(id, "3");
        return ApiResponse.success();
    }

    /**
     * 接收运行调优消息（手动）
     */
    @PostMapping("/acceptAbnormalDataTest")
    @ApiOperation(value = "解析运行调优数据")
    public ApiResponse<Boolean> acceptAbnormalData(@RequestBody AbnormalMessageDataDTO dataDTO) {
        service.AcceptOperationAbnormalMessage(dataDTO);
        return ApiResponse.success();
    }

    /**
     * 解析运行调优数据（测试）
     **/
    @PostMapping("/analysisAbnormalData")
    @ApiOperation(value = "解析运行调优数据")
    public ApiResponse<Boolean> analysisAbnormalData(@RequestBody AbnormalOperationDTO abnormalOperationDTO) {
        service.dealOperationAbnormalDataForTest(abnormalOperationDTO);
        return ApiResponse.success();
    }

    /**
     * 解析运行调优数据
     **/
    @PostMapping("/analysisAbnormalDataByid")
    @ApiOperation(value = "根据运行调优id解析运行调优数据")
    public ApiResponse<Boolean> analysisAbnormalDataByid(@RequestBody Long oaId) {
        service.dealOperationAbnormalData(oaId);
        return ApiResponse.success();
    }


}
