package com.njcn.device.pms.controller.majornetwork;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.pms.pojo.dto.MonitorIntegrityDataDTO;
import com.njcn.device.pms.pojo.param.DataQualityDetailsParam;
import com.njcn.device.pms.service.majornetwork.IRStatIntegrityDService;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.LineIntegrityDataParam;
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import com.njcn.device.pq.pojo.vo.LineIntegrityDataVO;
import com.njcn.harmonic.pojo.vo.IntegrityIconVO;
import com.njcn.web.controller.BaseController;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 监测点数据完整性列表
 * @author yzh
 * @date 2022/9/9
 */

@Slf4j
@Api(tags = "监测点数据完整性列表")
@RestController
@RequestMapping("/monitorIntegrity")
@RequiredArgsConstructor
public class LineIntegrityDataController extends BaseController {

    private final IRStatIntegrityDService irStatIntegrityDService;


    /**
     * 监测点数据完整性
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getMonitorIntegrityData")
    @ApiOperation("监测点数据完整性")
    @ApiImplicitParam(name = "monitorIntegrityDataDTO", value = "参数实体", required = true)
    public HttpResult<Page<MonitorIntegrityDataDTO>> getIntegrityData(@RequestBody MonitorIntegrityDataDTO monitorIntegrityDataDTO) {
        String methodDescribe = getMethodDescribe("getMonitorIntegrityData");
        Page<MonitorIntegrityDataDTO> monitorIntegrityDataDTOList = irStatIntegrityDService.getMonitorIntegrityData(monitorIntegrityDataDTO);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,monitorIntegrityDataDTOList,methodDescribe);
    }

    /**
     * 监测点数据完整性
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getIntegrityData")
    @ApiOperation("监测点数据完整性")
    @ApiImplicitParam(name = "param", value = "参数实体", required = true)
    public HttpResult<List<RStatIntegrityD>> getIntegrityData(@RequestBody DataQualityDetailsParam param) {
        String methodDescribe = getMethodDescribe("getIntegrityData");
        List<RStatIntegrityD> integrityDS = irStatIntegrityDService.list(new LambdaQueryWrapper<RStatIntegrityD>()
                .in(RStatIntegrityD::getLineIndex, param.getCheckRules())
                .ge(RStatIntegrityD::getTimeId,param.getStartTime())
                .le(RStatIntegrityD::getTimeId, param.getEndTime())
        );
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,integrityDS,methodDescribe);
    }
}
