package com.njcn.device.device.controller;


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.device.service.OnLineRateService;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.vo.RStatOnlineRateVO;
import com.njcn.device.pq.pojo.vo.common.DeviceOnlineRate;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Description: 终端在线率
 * @Author: wr
 * @Date: 2025/11/26 10:28
 */
@Slf4j
@Api(tags = "终端在线率")
@RestController
@RequestMapping("/onLineRate")
@RequiredArgsConstructor
public class OnLineRateController extends BaseController {

    private final OnLineRateService onLineRateService;


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/deviceOnlineRateInfo")
    @ApiOperation("终端在线率列表(冀北)")
    public HttpResult<DeviceOnlineRate> deviceOnlineRateInfo(@RequestBody DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("deviceOnlineRateInfo");
        deviceInfoParam.setLineOrDevice(1);
        DeviceOnlineRate rate = onLineRateService.deviceOnlineRateInfo(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rate, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getOnlineRateByDevIds")
    @ApiOperation("通用终端在线率(冀北)")
    public HttpResult<List<RStatOnlineRateVO>> getOnlineRateByDevIds(@RequestBody OnlineRateParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("deviceOnlineRateInfo");
        List<RStatOnlineRateVO> rate = onLineRateService.getOnlineRateByDevIds(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rate, methodDescribe);
    }

}

