using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hotline.FlowEngine.Workflows;
using Hotline.Orders;
using Hotline.Settings;
using Hotline.Share.Dtos;
using Hotline.Share.Dtos.Bi;
using Hotline.Share.Dtos.DataSharing.PusherHotlineDto;
using Hotline.Share.Dtos.FlowEngine.Workflow;
using Hotline.Share.Dtos.Order;
using Hotline.Share.Enums.Order;
using Hotline.Share.Enums.Settings;
using Hotline.Share.Requests;
using MediatR;
using SqlSugar;
using XF.Domain.Authentications;
using XF.Domain.Entities;

namespace Hotline.Application.Orders
{
    public interface IOrderApplication
    {

        /// <summary>
        /// 派单量统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<List<SendOrderReportOutDto>> SendOrderReportAsync(QuerySendOrderRequest dto);

        /// <summary>
        /// 更新工单办理期满时间
        /// 1.更新工单 2.更新流程
        /// </summary>
        /// <returns></returns>
        Task DelayOrderExpiredTimeAsync(string orderId, int timeCount, ETimeType timeType, bool IsProDelay, CancellationToken cancellationToken);

        /// <summary>
        /// 新增工单办理流程记录
        /// </summary>
        Task AddOrderTracesAsync(string orderId, ICollection<WorkflowTraceDto> traces, CancellationToken cancellationToken);

        /// <summary>
        /// 撤销工单
        /// </summary>
        Task CancelOrderAsync(string orderId, string opinion, CancellationToken cancellationToken);

        ISugarQueryable<Order> GetToExpireAsync(AboutToExpireListDto dto);
        //Task<PagedDto<WorkflowOrderDto>> GetToExpireNodeAsync(AboutToExpireListDto dto, CancellationToken cancellationToken);
        ISugarQueryable<Order> GetAboutToExpireAsync(AboutToExpireListDto dto);
        //Task<PagedDto<WorkflowOrderDto>> GetAboutToExpireNodeAsync(AboutToExpireListDto dto, CancellationToken cancellationToken);
        Task OrderParticiple(string inputStr, string orderId, DateTime time, CancellationToken cancellationToken);
        Task OrderSensitiveParticiple(string inputStr, string orderId, CancellationToken cancellationToken);
        /// <summary>
        /// 接收外部平台工单
        /// </summary>
        Task<AddOrderResponse> ReceiveOrderFromExternalAsync(AddOrderDto dto, ISessionContext current, CancellationToken cancellationToken);

        /// <summary>
        /// 接收外部平台修改工单附件
        /// </summary>
        Task UpdateOrderFilesAnonymousAsync(UpdateOrderFilesDto dto, CancellationToken cancellationToken);

        /// <summary>
        /// 工单回访
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task OrderVisitWeb(OrderVisitWebDto dto, CancellationToken cancellationToken);

        #region 工单办理

        ISugarQueryable<Order> QueryOrders(QueryOrderDto dto);

        #endregion

        /// <summary>
        /// 未签收统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<Order, WorkflowStep> QueryUnsignedOrders(QueryUnsignedOrdersRequest dto);

        /// <summary>
        /// 信件来源统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<Order> QueryOrderSource(QueryOrderSourceRequest dto);

        /// <summary>
        /// 信件来源统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<Order> QueryOrderSourceDetail(QueryOrderSourceDetailRequest dto);

        /// <summary>
        /// 部门超期统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderBiOrgDataListVo> QueryOrgDataList(ReportPagedRequest dto);

        /// <summary>
        /// 部门超期统计明细
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
		ISugarQueryable<Order> QueryOrgDataListDetail(OrgDataListDetailRequest dto);

        /// <summary>
        /// 部门全量超期统计明细
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<Order> QueryOrgDataListDetail(OrgDataListAllDetailRequest dto);

        /// <summary>
        /// 回退错件统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderReTransactVo> OrderReTransact(QueryOrderReTransactRequest dto);

        /// <summary>
        /// 回退错件明细统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderSpecialDetail> QueryOrderSourceDetail(QueryOrderReTransactDetailRequest dto);

        /// <summary>
        /// 部门满意度统计
        /// </summary>
        /// <returns></returns>
        Task<List<VisitAndOrgSatisfactionStatisticsDto>> VisitAndOrgSatisfactionStatistics(PagedKeywordSonRequest dto);

        /// <summary>
        /// 子部门满意度
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<List<VisitAndOrgSatisfactionStatisticsDto>> VisitAndOrgStatisfactionOrgDetail(PagedKeywordSonRequest dto);

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

        /// <summary>
        /// 热点-区域统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<(List<SystemArea> area, object items)> HotspotAndAreaStatistics(HotspotAndAreaStatisticsReq dto);


        /// <summary>
        /// 热点-区域统计导出
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<DataTable> HotspotAndAreaStatisticsExport(HotspotAndAreaStatisticsReq dto);

        /// <summary>
        /// 热点-区域统计
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="AddColumnName"></param>
        /// <param name="HotspotLevel"></param>
        /// <returns></returns>
        DataTable InitHotspotTable(DataTable dt, List<string> AddColumnName, int HotspotLevel);


        /// <summary>
        /// 热点类型满意度统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<List<VisitAndHotspotSatisfactionStatisticsDto>> VisitAndHotspotSatisfactionStatistics(VisitAndHotspotPagedKeywordRequest dto);

        /// <summary>
        /// 热点满意度明细统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderVisitDetail> VisitAndHotspotSatisfactionDetail(VisitAndHotspotPagedKeywordRequest dto);

        /// <summary>
        /// 话务员办件统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderBiCentreDataListVo> CentreDataList(ReportPagedRequest dto);

		/// <summary>
		/// 热点受理类型统计
        /// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		Task<(List<SystemDicData> acceptTypes, object items)> HotspotAndAcceptTypeStatistics(HotspotAndAcceptTypeStatisticsReq dto);


		/// <summary>
		/// 热点受理类型统计--导出
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		Task<DataTable> HotspotAndAcceptTypeStatisticsExport(HotspotAndAcceptTypeStatisticsReq dto);

        /// <summary>
        /// 热点受理类型明细
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<Order> HotspotAndAcceptTypeStatisticsDetail(HotspotAndAcceptTypeStatisticsDetailReq dto);

        /// <summary>
        /// 甄别申请统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderScreenApplyVo> OrderScreenApply(OrderScreenApplyPagedRequest dto);

        /// <summary>
        /// 甄别审批统计
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        ISugarQueryable<OrderScreenAuditVo> OrderScreenAudit(OrderScreenAuditPagedRequest dto);

	}
}