package com.njcn.csdevice.controller.data;


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.csdevice.param.IcdBzParam;
import com.njcn.csdevice.pojo.po.RStatIntegrityD;
import com.njcn.csdevice.service.IRStatIntegrityDService;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 数据完整性日表 前端控制器
 * </p>
 *
 * @author xy
 * @since 2025-06-23
 */
@Slf4j
@RestController
@RequestMapping("/rStatIntegrityD")
@Api(tags = "数据完整性接口")
@AllArgsConstructor
public class RStatIntegrityDController extends BaseController {

    private final IRStatIntegrityDService irStatIntegrityDService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/add")
    @ApiOperation("新增数据完整性(可根据时间段进行补召)")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<String> addData(@RequestBody @Validated StatisticsDataParam param){
        String methodDescribe = getMethodDescribe("addData");
        irStatIntegrityDService.addData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/list")
    @ApiOperation("获取数据")
    public HttpResult<List<RStatIntegrityD>> list(@RequestBody @Validated IcdBzParam param){
        String methodDescribe = getMethodDescribe("list");
        List<RStatIntegrityD> result = irStatIntegrityDService.getData(param.getLineList(),param.getStartTime(),param.getEndTime());
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

}

