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

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
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.prepare.harmonic.pojo.param.LineParam;
import com.njcn.prepare.harmonic.service.mysql.line.*;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2023/4/20 16:05
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/harmonicOverLimit")
@Api(tags = "监测点稳态指标统计")
@AllArgsConstructor
public class HarmonicOverLimitController extends BaseController {

    private final IRMpPartHarmonicDetailDService mpPartHarmonicDetailDService;

    private final IRMpSurplusHarmonicDetailDService mpSurplusHarmonicDetailDService;

    private final IRMpPartHarmonicDetailMService mpPartHarmonicDetailMService;

    private final IRMpSurplusHarmonicDetailMService mpSurplusHarmonicDetailMService;

    private final IRMpVThdService mpVThdService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/harmonicDetailDay1")
    @ApiOperation("监测点稳态指标超标明细日表1")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> harmonicDetailDay1(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("harmonicDetailDay1");
        mpPartHarmonicDetailDService.insertHarmonicDetailDayOne(lineParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/harmonicDetailDay2")
    @ApiOperation("监测点稳态指标超标明细日表2")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> harmonicDetailDay2(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("harmonicDetailDay2");
        mpSurplusHarmonicDetailDService.insertHarmonicDetailDayTwo(lineParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/harmonicDetailMonth1")
    @ApiOperation("监测点稳态指标超标明细月表1")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> harmonicDetailMonth1(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("harmonicDetailMonth1");
        mpPartHarmonicDetailMService.insertHarmonicDetailMonthOne(lineParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/harmonicDetailMonth2")
    @ApiOperation("监测点稳态指标超标明细月表2")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> harmonicDetailMonth2(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("harmonicDetailMonth2");
        mpSurplusHarmonicDetailMService.insertHarmonicDetailMonthTwo(lineParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/harmonicThdDay")
    @ApiOperation("谐波畸变率日表")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> harmonicThdDay(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("harmonicThdDay");
        mpVThdService.insertHarmonicVThdDay(lineParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

}
