package com.tofly.callcenter.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.callcenter.entity.custom.CallSearch;
import com.tofly.callcenter.service.PltCalllist1000Service;
import com.tofly.common.core.entity.ResultRespone;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

/**
 * @author FlashWJL
 * @date 2021/6/21 10:17
 */
@RestController
@AllArgsConstructor
@RequestMapping("/statis")
@Api(tags = "统计接口")
public class StatisController {
    private final PltCalllist1000Service pltCalllist1000Service;

    @GetMapping("/telephoneSta")
    @ApiOperation(value = "坐席话务统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = true, dataType = "String"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = true, dataType = "String"),
            @ApiImplicitParam(name = "empcode", value = "坐席号", dataType = "string")
    })
    public ResultRespone getTelephoneSta(HttpServletResponse response, Page page, CallSearch search) {
        return ResultRespone.success(pltCalllist1000Service.getTelephoneSta(response, page, search));
    }

    @GetMapping("/satisfactionStatis")
    @ApiOperation(value = "满意度统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = true, dataType = "String"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = true, dataType = "String")
    })
    public ResultRespone getSatisfactionStatis(HttpServletResponse response, Page page, CallSearch search) {
        return ResultRespone.success(pltCalllist1000Service.getSatisfactionStatis(response, page, search));
    }

    @GetMapping("/getUserScoreInfo")
    @ApiOperation(value = "获取对应用户满意度信息及排名")
    public Map<String, BigDecimal> getUserScoreInfo(Date start, Date end, String userName) {
        return pltCalllist1000Service.getUserScoreInfo(start, end, userName);
    }

    @GetMapping("/getSatisfactionStatisInfo")
    @ApiOperation("满意度详情查看")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = true, dataType = "String"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = true, dataType = "String"),
            @ApiImplicitParam(name = "empcode", value = "坐席员工工号", dataType = "String"),
            @ApiImplicitParam(name = "score", value = "满意度，不传查询全部", dataType = "long"),
            @ApiImplicitParam(name = "export", value = "暂时传0，导出未做", required = true, dataType = "long"),
    })
    public ResultRespone getSatisfactionStatisInfo(HttpServletResponse response, Page page, CallSearch search) {
        return ResultRespone.success(pltCalllist1000Service.getSatisfactionStatisInfo(response, page, search));
    }

    @GetMapping("/stateStatis")
    @ApiOperation(value = "坐席状态统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始时间", required = true, dataType = "String"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", required = true, dataType = "String"),
            @ApiImplicitParam(name = "empcode", value = "坐席员工工号", dataType = "String")
    })
    public ResultRespone getStateStatis(HttpServletResponse response, Page page, CallSearch search) {
        return ResultRespone.success(pltCalllist1000Service.getStateStatis(response, page, search));
    }

    @GetMapping("/getTodayFlow")
    @ApiOperation("获取今日话务呼入、呼出量")
    public ResultRespone getTodayFlow() {
        return ResultRespone.success(pltCalllist1000Service.getTodayFlow());
    }

    @GetMapping("/incomingCallCount")
    @ApiOperation("获取本月呼入统计")
    public Map<String, BigDecimal> incomingCallCount() {
        return pltCalllist1000Service.incomingCallCount();
    }

    @GetMapping("/exhalationCount")
    @ApiOperation("获取本月呼出统计")
    public Map<String, BigDecimal> exhalationCount() {
        return pltCalllist1000Service.exhalationCount();
    }

    @GetMapping("/callCount")
    @ApiOperation("当月呼入呼出总数统计")
    public Map<String, BigDecimal> getCallCount(String userName) {
        return pltCalllist1000Service.getCallCount(userName);
    }

}
