using DataSharing.CityStateDataExchange;
using DataSharing.LuZhou.LZCityPortal;
using DataSharing.SendTask;
using DataSharing.SendTask.OtherPlatforms;
using Hotline.Share.Dtos.Order;
using Hotline.Share.Enums.Order;
using Microsoft.Extensions.Logging;

namespace DataSharing.LuZhou
{
    public class LuZhouSendTaskDataService : ISendTaskDataService
    {
        private readonly ILogger<LuZhouSendTaskDataService> _logger;
        private readonly ICityStateDataExchangePusherProviderService _dataExchangePusherProviderService;
        private readonly ISharingConfigurationManager _sharingConfigurationManager;
        private readonly ICityStateDataExchangeService _cityStateDataExchangeService;
        private readonly ILZCityPortalSiteService _lzCityPortalSiteService;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="dataExchangePusherProviderService"></param>
        /// <param name="sharingConfigurationManager"></param>
        /// <param name="dcjtService"></param>
        public LuZhouSendTaskDataService(ILogger<LuZhouSendTaskDataService> logger,
         ICityStateDataExchangePusherProviderService dataExchangePusherProviderService,
         ISharingConfigurationManager sharingConfigurationManager,
         ICityStateDataExchangeService cityStateDataExchangeService,
         ILZCityPortalSiteService lzCityPortalSiteService)
        {
            _logger = logger;
            _dataExchangePusherProviderService = dataExchangePusherProviderService;
            _sharingConfigurationManager = sharingConfigurationManager;
            _cityStateDataExchangeService = cityStateDataExchangeService;
            _lzCityPortalSiteService = lzCityPortalSiteService;
        }

        /// <summary>
        /// 执行推送任务
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task SendTask(DsWaitSendTaskOtherPlatforms dto, CancellationToken cancellationToken)
        {
            if (dto is null)
                return;
            _logger.LogInformation("这里是泸州的服务--------------------------------------");

            switch (dto.PlatformSource)
            {
                case Share.Enums.EPlatformSource.Police110:
                    //调用推送服务
                    break;
                //case Share.Enums.EPlatformSource.CityDataExchange:
                //    await _dataExchangePusherProviderService.SendDataExchangeDataPusher(dto, cancellationToken);
                //    break;
                default:
                    break;
            }
        }

        /// <summary>
        ///泸州其他推送
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="order"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task OtherSendTask(string Key, OrderDto order, CancellationToken cancellationToken)
        {
            return Task.CompletedTask;
        }

        /// <summary>
        ///撤单操作
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task RevokeOrderAsync(PublishSpecialDto dto, CancellationToken cancellationToken)
        {
            return Task.CompletedTask;
        }

        /// <summary>
        /// 推送办理结果
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task AddHandleOpinion(OrderFlowDto dto, CancellationToken cancellationToken)
        {
            //市州互转推送办结结果
            if (dto.Order.Source == ESource.CityDataExchangeZG || dto.Order.Source == ESource.CityDataExchangeYB)
                await _cityStateDataExchangeService.UndertakAdviceAsync(dto.Order, cancellationToken);
        }

        /// <summary>
        /// 市州互转
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task TranspondCityAsync(OrderDto dto, CancellationToken cancellationToken)
        {
            //数据推送
            await _cityStateDataExchangeService.InitCityDataAsync(dto, cancellationToken);
        }

        /// <summary>
        /// 推送办理结果（泸州市政府门户网站）
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task AddHandleOpinionByCityPortal(OrderFlowDto dto, CancellationToken cancellationToken)
        {
            // 泸州市政府门户网站
            if (dto.Order.Source == ESource.LZCityPortalSite)
                await _lzCityPortalSiteService.SendOpinionAsync(dto.Order, cancellationToken);
        }
    }
}
