package com.zcxk.evaluation.controller;

import com.zcxk.evaluation.dto.EvaluationReportDto;
import com.zcxk.evaluation.service.EvaluationResultService;
import com.zcxk.evaluation.vo.*;
import com.zcxk.model.AjaxMessage;
import com.zcxk.model.ResultStatus;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;

/**
 * @ClassName EvaluationResultReportController
 * @Description: 绩效报表
 * @Author lihui
 * @Date 2021/5/7
 * @Version V1.0
 **/
@RestController
@RequestMapping("/evaluation/report")
@Api(tags = "绩效考评报表")
public class EvaluationResultReportController {

    @Autowired
    private EvaluationResultService evaluationResultService;

    @ApiOperation(value = "人员绩效排名")
    @RequestMapping(value = "/find/ranking", method = RequestMethod.POST)
    @ResponseBody
    public AjaxMessage<List<EvaluationReportRankingVo>> findRanking(@RequestBody @Valid EvaluationReportDto dto) {
        return new AjaxMessage<>(ResultStatus.OK, evaluationResultService.findRanking(dto));
    }

    @ApiOperation(value = "绩效等级分布")
    @RequestMapping(value = "/find/grade/percentage", method = RequestMethod.POST)
    @ResponseBody
    public AjaxMessage<List<EvaluationGradePercentageVo>> findGradePercentage(@RequestBody @Valid EvaluationReportDto dto) {
        return new AjaxMessage<>(ResultStatus.OK, evaluationResultService.findGradePercentage(dto));
    }

    @ApiOperation(value = "统计绩效合格数")
    @RequestMapping(value = "/count/qualified/number", method = RequestMethod.POST)
    @ResponseBody
    public AjaxMessage<List<EvaluationQualifiedNumberVo>> countQualifiedNumber(@RequestBody @Valid EvaluationReportDto dto) {
        return new AjaxMessage<>(ResultStatus.OK, evaluationResultService.countQualifiedNumber(dto, new BigDecimal("60")));
    }

    @ApiOperation(value = "统计绩效人均值")
    @RequestMapping(value = "/count/performance/avg", method = RequestMethod.POST)
    @ResponseBody
    public AjaxMessage<List<EvaluationPerformanceAvgVo>> countPerformanceAvg(@RequestBody @Valid EvaluationReportDto dto) {
        return new AjaxMessage<>(ResultStatus.OK, evaluationResultService.countPerformanceAvg(dto));
    }

}

