package cn.iocoder.yudao.module.base.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.base.service.RepairStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Tag(name = "维修数据统计")
@RestController
@RequestMapping("/repair/statistics")
@Validated
public class RepairStatisticsController {
    @Resource
    private RepairStatisticsService statisticsService;

    /**
     * 客户来源分析饼图
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/customerSource")
    @Operation(summary = "客户来源分析饼图")
    public CommonResult<?> customerSource() {
        return CommonResult.success(statisticsService.customerSource());
    }

    /**
     * 月工单金额走势折线图
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/ticketMainAmount")
    @Operation(summary = "月工单金额走势")
    public CommonResult<?> ticketMainAmount() {
        return CommonResult.success(statisticsService.ticketMain("amount"));
    }

    /**
     * 月工单数量走势折线图
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/ticketMainCount")
    @Operation(summary = "月工单数量走势")
    public CommonResult<?> ticketMainCount() {
        return CommonResult.success(statisticsService.ticketMain("count"));
    }

    /**
     * 支付渠道统计柱状图
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/ticketMainPayWay")
    @Operation(summary = "支付渠道统计")
    public CommonResult<?> ticketMainPayWay() {
        return CommonResult.success(statisticsService.ticketMain("payWay"));
    }

    /**
     * 维修类型相关统计分析饼图
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/repairTypeStatistics")
    @Operation(summary = "维修类型相关统计分析饼图")
    public CommonResult<?> repairTypeStatistics() {
        return CommonResult.success(statisticsService.repairTypeStatistics());
    }

    /**
     * 工单总数、今日工单、工单总金额、今日工单金额
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/ticketStatistics")
    @Operation(summary = "工单总数、今日工单、工单总金额、今日工单金额")
    public CommonResult<?> ticketStatistics() {
        return CommonResult.success(statisticsService.ticketStatistics());
    }

    /**
     * 工单状态数量统计
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/ticketStatusCount")
    @Operation(summary = "工单状态数量统计")
    public CommonResult<?> ticketStatusCount() {
        return CommonResult.success(statisticsService.ticketStatusCount());
    }

    /**
     * 今日工单
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/listTicketToday")
    @Operation(summary = "今日工单")
    public CommonResult<?> listTicketToday() {
        return CommonResult.success(statisticsService.listTicketToday());
    }

    /**
     * 维修工人排行
     *
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 16:15 2024/10/21
     **/
    @GetMapping("/listWorks")
    @Operation(summary = "维修工人排行")
    public CommonResult<?> listWorks() {
        return CommonResult.success(statisticsService.listWorks());
    }

}