using Hotline.Settings;
using Hotline.Share.Requests;
using SqlSugar;
using System.Data;
using Hotline.Share.Dtos;
using Hotline.Share.Dtos.Order;
using XF.Domain.Repository;
using Hotline.Share.Dtos.Bi;
using Hotline.Settings.Hotspots;

namespace Hotline.Orders
{
    public interface IOrderRepository : IRepositoryWorkflow<Order>
    {
        Task<string> AddOrderNavAsync(Order order, CancellationToken cancellationToken);
        Task RemoveOrderWrodBatchAsync(List<string> ids, CancellationToken cancellationToken);
        Task RemoveOrderObserveBatchAsync(List<string> ids, CancellationToken cancellationToken);
        Task RemoveOrderFinalityBatchAsync(List<string> ids, CancellationToken cancellationToken);
        Task OrderScreenRevisionVisit(string VisitId, bool canHandle, CancellationToken cancellationToken);
        Task FileAsync(Order order, CancellationToken cancellationToken);

        Task<(IReadOnlyList<Hotspot> hotSpotList, List<dynamic>? list)> HotPortJoinOrgStatistics(DateTime StartTime, DateTime EndTime, bool IsCenter, string? OrgCode);
        ISugarQueryable<Order> HotPortJoinOrgStatisticsDetail(HotPortJoinOrgStatisticsRequestDetail dto);

        ISugarQueryable<OrderWord> QueryOrderWordList(OrderWordListDto dto);

        ISugarQueryable<DepartmentalProcessingStatisticsDataDto> OrderUnionAll(ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t1,
         ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t2,
         ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t3,
         ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t4,
         ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t5,
         ISugarQueryable<DepartmentalProcessingStatisticsDataDto> t6);

        ISugarQueryable<SelectOrderId> OrderListUnionAll(ISugarQueryable<SelectOrderId> t1, ISugarQueryable<SelectOrderId> t2);

        /// <summary>
        /// 区域分时统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<object> OrderAreaTime(TimeSharingPagedKeywordRequest dto);

        /// <summary>
        /// 区域分时统计--导出
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<DataTable> OrderAreaTimeExport(TimeSharingPagedKeywordRequest dto);

        /// <summary>
        /// 热点类型分时统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<object> OrderHotspotTime(TimeSharingPagedKeywordRequest dto);

        /// <summary>
        /// 热点类型分时统计---导出
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<DataTable> OrderHotspotTimeExport(TimeSharingPagedKeywordRequest dto);

        /// <summary>
        /// 受理类型分时统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<object> OrderAcceptanceTime(TimeSharingPagedKeywordRequest dto);

        /// <summary>
        /// 中心报表统计
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <returns></returns>
        Task<DataTable> CenterReportFormsStatistics(DateTime StartTime, DateTime EndTime);

        /// <summary>
        /// 中心报表统计（受理类型）
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <returns></returns>
        Task<DataTable> CenterReportPurTypeStatistics(DateTime StartTime, DateTime EndTime);

        /// <summary>
        /// 中心报表统计（部门统计）
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <param name="Type"></param>
        /// <returns></returns>
        Task<DataTable> CenterReportDepartStatistics(DateTime StartTime, DateTime EndTime, string Type);

        /// <summary>
        /// 中心报表统计（新增加的）
        /// </summary>
        /// <param name="StartTime"></param>
        /// <param name="EndTime"></param>
        /// <param name="Type"></param>
        /// <returns></returns>
        Task<DataTable> CenterReportNewStatistics(DateTime StartTime, DateTime EndTime);

        /// <summary>
        /// 受理类型分时统计---导出
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<DataTable> OrderAcceptanceTimeExport(TimeSharingPagedKeywordRequest dto, List<Kv> title);

        /// <summary>
        /// 信件来源分时统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<object> OrderSourceTime(TimeSharingPagedKeywordRequest dto);

        /// <summary>
        /// 信件来源分时统计---导出
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<DataTable> OrderSourceTimeExport(TimeSharingPagedKeywordRequest dto);


        /// <summary>
        /// 信件来源统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<object> OrderSource(QueryOrderSourceRequest dto);

        /// <summary>
        /// 信件来源统计 -- 导出
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
		Task<DataTable> OrderSourceExport(QueryOrderSourceRequest dto);

        ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class;

        /// <summary>
        /// 部门办件统计
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        List<DepartmentalProcessingStatisticsDataDto> DepartmentalProcessingStatisticsNew(string sql);


        /// <summary>
        ///  热点区域明细
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<HotspotAndAreaStatisticsDetailDto> HotspotAndAreaStatisticsDetail(HotspotAndAreaStatisticsDetailReq dto);

        /// <summary>
        /// 根据时间查询受理类型统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<(List<SystemDicData> acceptType, object items)> AcceptTypeStatisticsByDate(AcceptTypeStatisticsByDateReq dto);

        /// <summary>
        /// 根据时间查询受理类型统计-导出
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<DataTable> AcceptTypeStatisticsByDateExport(AcceptTypeStatisticsByDateReq dto);

        /// <summary>
        /// 受理类型导出表处理
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="AddColumnName"></param>
        /// <returns></returns>
        DataTable InitAcceptTypeTable(DataTable dt, List<string> AddColumnName);

        /// <summary>
        /// 受理类型明细
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<HotspotAndAreaStatisticsDetailDto> AcceptTypeStatisticsByDateDetail(AcceptTypeStatisticsByDateDetailReq dto);

        /// <summary>
        /// 中心受理统计（时间段）
        /// </summary>
        /// <returns></returns>
		ISugarQueryable<OrderCenterAcceptHourVo> OrderCenterAcceptHour(OrderCenterAcceptPagedRequest dto);

        /// <summary>
        /// 数据清单
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderDataInventoryRep> OrderDataInventory(OrderDataInventoryReq dto);

        /// <summary>
        /// 扭转列表
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderVisit> VisitJudgeQuery(VisitJudgeQueryReq dto);

        /// <summary>
        /// 满意度明细
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrgVisitDetailListResp> OrgVisitDetailList(OrgVisitDetailListReq dto);

        /// <summary>
        /// 部门满意度明细统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrgVisitDetailListResp> VisitAndOrgSatisfactionDetail(VisitAndOrgSatisfactionDetailDto dto);

        /// <summary>
        /// 部门满意度明细 排除不满意 非常不满意 未作评价
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrgVisitDetailListResp> OrgVisitDetailFiltrationList(OrgVisitDetailListReq dto, string orgId);

        /// <summary>
        /// 智能回访数据统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<QueryAiVisitStatisticsResp> QueryAiVisitStatistics(QueryAiVisitStatisticsRequest dto);

        /// <summary>
        /// 智能回访有效性分析
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<QueryAiVisitEffectiveAnalysisResp> QueryAiVisitEffectiveAnalysis(QueryAiVisitStatisticsRequest dto);

    }

    public interface IOrderScreenRepository : IRepositoryWorkflow<OrderScreen>
    {

    }

    public interface IOrderTerminateRepository : IRepositoryWorkflow<OrderTerminate>
    {

    }

    public interface IOrderDelayRepository : IRepositoryWorkflow<OrderDelay>
    {

    }
}
