package com.njcn.harmonic.controller.distribution;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.PwRMpBenchmarkLevelVO;
import com.njcn.harmonic.service.distribution.PwRMpBenchmarkLevelMService;
import com.njcn.harmonic.service.distribution.PwRMpBenchmarkLevelQService;
import com.njcn.harmonic.service.distribution.PwRMpBenchmarkLevelYService;
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;


/**
 * @author jianghaifei
 * @date 2022-10-11 10:34
 * @version V1.0
 */
@RestController
@Api(tags = "配网-基准水平评估")
@RequiredArgsConstructor
@RequestMapping("/pwRMpBenchmarkLevel")
public class PwRMpBenchmarkLevelController extends BaseController {

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

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

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

    @PostMapping("getPwRMpBenchmarkLevelList")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("配网-全网基准水平")
    public HttpResult<Page<PwRMpBenchmarkLevelVO>> getPwRMpBenchmarkLevelList(@RequestBody RMpBenchmarkLevelParam rMpBenchmarkLevelParam) {
        String methodDescribe = getMethodDescribe("getPwRMpBenchmarkLevelList");
        if (rMpBenchmarkLevelParam.getType() == null) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, null, methodDescribe);
        }
        //获取查询条件-时间类型
        String type = rMpBenchmarkLevelParam.getType().toString();
        Page<PwRMpBenchmarkLevelVO> rMpBenchmarkLevelList;
        switch (type) {
            case BizParamConstant.STAT_BIZ_YEAR:
                //查询基准水平-年数据
                rMpBenchmarkLevelList = rMpBenchmarkLevelYService.getPwRMpBenchmarkLevelList(rMpBenchmarkLevelParam);
                break;
            case BizParamConstant.STAT_BIZ_QUARTER:
                //查询基准水平-季数据
                rMpBenchmarkLevelList = rMpBenchmarkLevelQService.getPwRMpBenchmarkLevelList(rMpBenchmarkLevelParam);
                break;
            default:
                //查询月数据
                rMpBenchmarkLevelList = rMpBenchmarkLevelMService.getPwRMpBenchmarkLevelList(rMpBenchmarkLevelParam);
                break;
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rMpBenchmarkLevelList, methodDescribe);
    }
}
