package com.njcn.prepare.harmonic.controller.newalgorithm;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailService;
import com.njcn.web.controller.BaseController;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
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.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2022/12/28  13:47【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@Api(tags = "监测点暂态指标超标明细")
@RestController
@RequestMapping("/rmpeventdetail")
@RequiredArgsConstructor
public class RMpEventdetailController extends BaseController {



    private final CommTerminalGeneralClient commTerminalGeneralClient;

    private final RMpEventDetailService rMpEventDetailService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/eventdetailHandler")
    @ApiOperation("监测点暂态指标处理")
    @ApiImplicitParam(name = "lineParam", value = "参数", required = true)
    public HttpResult<String> eventdetailHandler(@RequestBody @Validated LineParam lineParam) {
        log.info(LocalDateTime.now() + "eventdetailHandler始执行");
        String methodDescribe = getMethodDescribe("eventdetailHandler");
        List<String> indexLists;
        if (CollectionUtils.isEmpty(lineParam.getLineIds())) {
            indexLists = commTerminalGeneralClient.getRunMonitorIds().getData();
        } else {
            indexLists = lineParam.getLineIds();
        }
        lineParam.setLineIds(indexLists);

        rMpEventDetailService.eventdetailHandler(lineParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }
}
