package com.njcn.device.pq.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.pq.pojo.param.DevRunEvaluateParam;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.vo.DeviceRunEvaluateVO;
import com.njcn.device.pq.pojo.vo.TerminalEvaluateAreaVO;
import com.njcn.device.pq.service.DeviceRunEvaluateService;
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.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 java.util.List;

/**
 * @author 终端运行评价
 * @description
 * @date 2025/5/8 13:57
 */
@Slf4j
@Api(tags = "终端运行评价")
@RestController
@RequestMapping("/deviceRunEvaluate")
@RequiredArgsConstructor
public class DeviceRunEvaluateController extends BaseController {

    private final DeviceRunEvaluateService deviceRunEvaluateService;

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/getRunEvaluate")
    @ApiOperation("终端运行评价")
    public HttpResult<List<DeviceRunEvaluateVO.Info>> getRunEvaluate(@RequestBody @Validated DeviceInfoParam.CompareBusinessParam param) {
        String methodDescribe = getMethodDescribe("getRunEvaluate");
        List<DeviceRunEvaluateVO.Info> runEvaluate = deviceRunEvaluateService.getRunEvaluate(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, runEvaluate, methodDescribe);
    }

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/getRunEvaluateDetail")
    @ApiOperation("异常终端详情")
    public HttpResult<List<DeviceRunEvaluateVO>> getRunEvaluateDetail(@RequestBody @Validated DevRunEvaluateParam param) {
        String methodDescribe = getMethodDescribe("getRunEvaluateDetail");
        List<DeviceRunEvaluateVO> runEvaluate = deviceRunEvaluateService.getRunEvaluateDetail(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, runEvaluate, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/areaTerminalStatistic")
    @ApiOperation("根据部门获取不同层级的终端信息")
    public HttpResult<List<TerminalEvaluateAreaVO>> areaTerminalStatistic(@RequestBody DeviceInfoParam.BusinessParam businessParam) {
        String methodDescribe = getMethodDescribe("areaTerminalStatistic");
        List<TerminalEvaluateAreaVO> result = deviceRunEvaluateService.areaTerminalStatistic(businessParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/lastWeekTrend")
    @ApiOperation("最近一周终端评价趋势")
    public HttpResult<TerminalEvaluateAreaVO.lastWeekTrendVO> lastWeekTrend(@RequestBody DeviceInfoParam.BusinessParam businessParam) {
        String methodDescribe = getMethodDescribe("lastWeekTrend");
        TerminalEvaluateAreaVO.lastWeekTrendVO result = deviceRunEvaluateService.lastWeekTrend(businessParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/getRunEvaluateInfo")
    @ApiOperation("终端评价列表(冀北)")
    public HttpResult<List<DeviceRunEvaluateVO.Detail>> getRunEvaluateInfo(@RequestBody DeviceInfoParam.BusinessParam businessParam) {
        String methodDescribe = getMethodDescribe("getRunEvaluateInfo");
        businessParam.setLineOrDevice(1);
        List<DeviceRunEvaluateVO.Detail> runEvaluate = deviceRunEvaluateService.getRunEvaluate(businessParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, runEvaluate, methodDescribe);
    }


}
