package com.njcn.harmonic.controller.majornetwork;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.BizParamConstant;
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.harmonic.pojo.param.RMpBenchmarkLevelParam;
import com.njcn.harmonic.pojo.vo.RMpBenchmarkLevelVO;
import com.njcn.harmonic.service.majornetwork.RMpBenchmarkLevelMService;
import com.njcn.harmonic.service.majornetwork.RMpBenchmarkLevelQService;
import com.njcn.harmonic.service.majornetwork.RMpBenchmarkLevelYService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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 jianghaifei
 * @Date 2022-10-11 10:34
 * @Version V1.0
 */
@RestController
@Api(tags = "主网-基准水平评估")
@RequiredArgsConstructor
@RequestMapping("/rMpBenchmarkLevel")
public class RMpBenchmarkLevelController extends BaseController {

    /**
     * 基准水平-月
     */
    private final RMpBenchmarkLevelMService rMpBenchmarkLevelMService;

    /**
     * 基准水平-季
     */
    private final RMpBenchmarkLevelQService rMpBenchmarkLevelQService;

    /**
     * 基准水平-年
     */
    private final RMpBenchmarkLevelYService rMpBenchmarkLevelYService;


    @PostMapping("getAllRMpBenchmarkLevelList")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("主网-区域稳态电能质量水平评估")
    public HttpResult<List<RMpBenchmarkLevelVO>> getAllRMpBenchmarkLevelList(@RequestBody RMpBenchmarkLevelParam rMpBenchmarkLevelParam) {
        String methodDescribe = getMethodDescribe("getAllRMpBenchmarkLevelList");
        //获取查询条件-时间类型
        String type = rMpBenchmarkLevelParam.getType().toString();
        List<RMpBenchmarkLevelVO> rMpBenchmarkLevelList;
        switch (type) {
            case BizParamConstant.STAT_BIZ_YEAR:
                //查询基准水平-年数据
                rMpBenchmarkLevelList = rMpBenchmarkLevelYService.getRMpBenchmarkLevelList(rMpBenchmarkLevelParam);
                break;
            case BizParamConstant.STAT_BIZ_QUARTER:
                //查询基准水平-季数据
                rMpBenchmarkLevelList = rMpBenchmarkLevelQService.getRMpBenchmarkLevelList(rMpBenchmarkLevelParam);
                break;
            default:
                //查询月数据
                rMpBenchmarkLevelList = rMpBenchmarkLevelMService.getRMpBenchmarkLevelList(rMpBenchmarkLevelParam);
                break;
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rMpBenchmarkLevelList, methodDescribe);
    }

}
