package com.ruoyi.web.controller.app;

import com.ruoyi.app.model.request.SearchTimeRangeParam;
import com.ruoyi.app.model.request.TimeRangeParam;
import com.ruoyi.app.service.IDataStatisticsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 数据分析Controller
 *
 * @author coede
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/app/statistics")
public class DataStatisticsController extends BaseController
{
    @Autowired
    private IDataStatisticsService dataStatisticsService;

    /**
     * 获取生产指标信息
     */
//    // @PreAuthorize("@ss.hasPermi('app:statistics:entrance')")
    @GetMapping(value = "/getGrodIndicator")
    public AjaxResult getProdIndicator(@Validated TimeRangeParam timeRangeParam)
    {

        return success(dataStatisticsService.getProdIndicator(timeRangeParam));
    }

    /**
     * 获取供应商供应数量前五排名
     */
//    // @PreAuthorize("@ss.hasPermi('app:statistics:entrance')")
    @GetMapping(value = "/getSupplierRank")
    public AjaxResult getSupplierRank(@Validated TimeRangeParam timeRangeParam)
    {

        return success(dataStatisticsService.selectAmountRankByTime(timeRangeParam));
    }

    /**
     * 获取肉商接收数量前五排名
     */
//    // @PreAuthorize("@ss.hasPermi('app:statistics:entrance')")
    @GetMapping(value = "/getPurchaserRank")
    public AjaxResult getPurchaserRank(@Validated TimeRangeParam timeRangeParam)
    {

        return success(dataStatisticsService.selectSaleAmountRankByTime(timeRangeParam));
    }

    /**
     * 根据时间范围获取不同产地供应商供应数量
     */
//    // @PreAuthorize("@ss.hasPermi('app:statistics:entrance')")
    @GetMapping(value = "/getOriginAmount")
    public AjaxResult getOriginAmount(@Validated TimeRangeParam timeRangeParam)
    {

        return success(dataStatisticsService.selectOriginAmountByTime(timeRangeParam));
    }

    /**
     * 根据时间范围获取不同去向肉商销售数量
     */
//    // @PreAuthorize("@ss.hasPermi('app:statistics:entrance')")
    @GetMapping(value = "/getSaleAmount")
    public AjaxResult getSaleAmount(@Validated TimeRangeParam timeRangeParam)
    {

        return success(dataStatisticsService.selectSaleAmountByTime(timeRangeParam));
    }

    /**
     * 根据时间范围获取入场检验统计数量
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:entrance')")
    @GetMapping(value = "/getHarmlessAmount")
    public AjaxResult getHarmlessAmount(@Validated TimeRangeParam timeRangeParam)
    {

        return success(dataStatisticsService.selectHarmlessSumByTime(timeRangeParam));
    }

    /**
     * 根据获取指定时间范围内每日累计计划屠宰
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:entrance')")
    @GetMapping(value = "/getEntranceAmountWithTime")
    public AjaxResult getEntranceAmountWithTime(@Validated TimeRangeParam timeRangeParam)
    {
        return success(dataStatisticsService.selectEntranceAmountByTime(timeRangeParam));
    }

    /**
     * 获取产出指标信息
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:output')")
    @GetMapping(value = "/getOutputIndicator")
    public AjaxResult getOutputIndicator(@Validated TimeRangeParam timeRangeParam)
    {
        return success(dataStatisticsService.getOutputIndicator(timeRangeParam));
    }

    /**
     * 获取白条重量统计
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:output')")
    @GetMapping(value = "/getSideWeight")
    public AjaxResult getSideWeight(@Validated TimeRangeParam timeRangeParam)
    {
        return success(dataStatisticsService.selectSideWeightByTime(timeRangeParam));
    }

    /**
     * 获取其他产品重量统计
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:output')")
    @GetMapping(value = "/getOtherProductWeight")
    public AjaxResult getOtherProductWeight(@Validated SearchTimeRangeParam searchTimeRangeParam)
    {
        return success(dataStatisticsService.selectOtherProductWeightByTime(searchTimeRangeParam));
    }

    /**
     * 获取今日昨日统计
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:output')")
    @GetMapping(value = "/getLastestIndicator")
    public AjaxResult getLatelyIndicator()
    {
        return success(dataStatisticsService.getLatelyIndicator());
    }

    /**
     * 获取近七天每日分销订单量
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:output')")
    @GetMapping(value = "/getWeekEntranceCount")
    public AjaxResult getWeekEntranceCount()
    {
        return success(dataStatisticsService.getWeekEntranceCount());
    }

    /**
     * 获取近七天每日分销订单量
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:output')")
    @GetMapping(value = "/getWeekDistributeCount")
    public AjaxResult getWeekDistributeCount()
    {
        return success(dataStatisticsService.getWeekDistributeCount());
    }

    /**
     * 获取各部位重量对比情况
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:output')")
    @GetMapping(value = "/getPorkPartWeight")
    public AjaxResult getPorkPartWeight()
    {
        return success(dataStatisticsService.getPorkPartWeight());
    }

    /**
     * 获取产地/去向对比情况
     */
    // @PreAuthorize("@ss.hasPermi('app:statistics:output')")
    @GetMapping(value = "/getPlaceAmount")
    public AjaxResult getPlaceAmount()
    {
        return success(dataStatisticsService.getPlaceAmount());
    }
}
