package com.ruoyi.web.modules.screen.mapper;

import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.web.modules.screen.domain.dto.HomeScreenAppointmentStatDto;
import com.ruoyi.web.modules.screen.domain.dto.HomeScreenMonthCountDto;
import com.ruoyi.web.modules.screen.domain.dto.HomeScreenSubsidyTypeSumDto;
import com.ruoyi.web.modules.screen.domain.dto.HomeScreenTrainingMonthDto;

/**
 * 大屏首页聚合查询。
 * <p>
 * 牦牛出栏等需传入 {@code allowedPastureIds} 限定有效牧场；补贴按 {@code grant_date} 落在统计年内。
 */
public interface HomeScreenStatsMapper
{
    /** 入驻供应商数（与交易销售总览同源） */
    int countSupplierForScreen();

    int countDistributorForScreen();

    int countTradeMarketForScreen();

    /** 按月出栏头数；{@code asset_status=4}，按 {@code status_change_date} */
    List<HomeScreenMonthCountDto> selectOutboundCountByMonth(
            @Param("allowedPastureIds") List<Long> allowedPastureIds,
            @Param("yearStart") Date yearStart,
            @Param("yearEnd") Date yearEnd);

    /** 当年预约总量，按 provider_type 分组 */
    List<HomeScreenAppointmentStatDto> selectAppointmentAnnualByYear(@Param("statYear") int statYear);

    /** 当年预约按月+provider_type 分组 */
    List<HomeScreenAppointmentStatDto> selectAppointmentMonthlyByYear(@Param("statYear") int statYear);

    /** 惠农补贴按类型汇总金额（元） */
    List<HomeScreenSubsidyTypeSumDto> sumSubsidyAmountByTypeForYear(
            @Param("yearStart") Date yearStart,
            @Param("yearEnd") Date yearEnd);

    /** 统计年内是否有补贴发放记录 */
    int countSubsidyGrantInYear(@Param("yearStart") Date yearStart, @Param("yearEnd") Date yearEnd);

    int countVideoCoursesPublishedInYear(@Param("yearStart") Date yearStart, @Param("yearEnd") Date yearEnd);

    int countTrainingsPublishedInYear(@Param("yearStart") Date yearStart, @Param("yearEnd") Date yearEnd);

    /** 培训趋势：按培训举办时间所在月统计 */
    List<HomeScreenTrainingMonthDto> selectTrainingTrendByTrainingYear(@Param("statYear") int statYear);

    int countPublishedTrainingsWithTrainingTimeInYear(@Param("statYear") int statYear);

    List<Integer> selectDistinctOutboundYears();

    List<Integer> selectDistinctAppointmentYears();

    List<Integer> selectDistinctSubsidyYears();

    List<Integer> selectDistinctStandardCreateYears();

    List<Integer> selectDistinctTechPublishYears();

    List<Integer> selectDistinctTrainingYears();
}
