using Hotline.CallCenter.BlackLists;
using Hotline.JudicialManagement;
using Hotline.Orders;
using Hotline.Push.FWMessage;
using Hotline.Settings;
using Hotline.Share.Dtos.CallCenter;
using Hotline.Share.Dtos.JudicialManagement;
using Hotline.Share.Dtos.OrderExportWord;
using Hotline.Share.Dtos.Org;
using Hotline.Share.Dtos.Push.FWMessage;
using Hotline.Share.Enums.Order;
using Mapster;
using XF.Domain.Entities;

namespace Hotline.Application.Mappers
{
    public partial class MapperConfigs : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config.ForType<AddBlacklistDto, Blacklist>()
                .Ignore(d => d.Expired)
                .AfterMapping((s, t) => t.InitExpired());

            config.ForType<Message, MessageDataDto>()
               .Map(d => d.SendUser, x => x.CreatorName)
               .Map(d => d.SendOrganize, x => x.CreatorOrgName)
               .IgnoreIf((s, d) => s.Order == null, x => x.OrderId)
               .IgnoreIf((s, d) => s.Order == null, x => x.OrderNo);

            #region org

            config.ForType<UpdateOrgDto, SystemOrganize>()
                .Ignore(d => d.Id)
                .Ignore(d => d.ParentId)
                .Ignore(d => d.ParentName);

            #endregion

            config.ForType<EnforcementOrders, EnforcementOrderListDto>()
                .Map(d => d.Id, x => x.Id)
                .Map(d => d.WorkflowId, x => x.Order.WorkflowId)
                .Map(d => d.Status, x => x.Order.Status)
                .Map(d => d.No, x => x.Order.No)
                .Map(d => d.SourceChannel, x => x.Order.SourceChannel)
                .Map(d => d.SourceChannelCode, x => x.Order.SourceChannelCode)
                .Map(d => d.FromPhone, x => x.Order.FromPhone)
                .Map(d => d.TransferPhone, x => x.Order.TransferPhone)
                .Map(d => d.FromName, x => x.Order.FromName)
                .Map(d => d.Contact, x => x.Order.Contact)
                .Map(d => d.AcceptType, x => x.Order.AcceptType)
                .Map(d => d.AcceptTypeCode, x => x.Order.AcceptTypeCode)
                .Map(d => d.EmergencyLevel, x => x.Order.EmergencyLevel)
                .Map(d => d.Title, x => x.Order.Title)
                .Map(d => d.HotspotId, x => x.Order.HotspotId)
                .Map(d => d.HotspotName, x => x.Order.HotspotName)
                .Map(d => d.HotspotSpliceName, x => x.Order.HotspotSpliceName)
                .Map(d => d.CreationTime, x => x.Order.CreationTime)
                .Map(d => d.IsProvince, x => x.Order.IsProvince)
                .Map(d => d.ProvinceNo, x => x.Order.ProvinceNo)
                .Map(d => d.ActualHandleStepName, x => x.Order.ActualHandleStepName)
                .Map(d => d.ActualHandleTime, x => x.Order.ActualHandleTime)
                .Map(d => d.ExpiredTime, x => x.Order.ExpiredTime)
                .Map(d => d.NearlyExpiredTime, x => x.Order.NearlyExpiredTime)
                .Map(d => d.FiledTime, x => x.Order.FiledTime)
                .Map(d => d.OrgLevelOneCode, x => x.Order.OrgLevelOneCode)
                .Map(d => d.OrgLevelOneName, x => x.Order.OrgLevelOneName)
                .Map(d => d.ActualHandlerName, x => x.Order.ActualHandlerName)
                .Map(d => d.StartTime, x => x.Order.StartTime)
                .Map(d => d.ActualHandleOrgName, x => x.Order.ActualHandleOrgName)
                .Map(d => d.ActualHandleOrgCode, x => x.Order.ActualHandleOrgCode)
                .Map(d => d.IsEnforcementOrder, x => x.IsEnforcementOrder)
                .Map(d => d.IsPassTheBuckOrder, x => x.IsPassTheBuckOrder)
                .Map(d => d.IsTheClueTrue, x => x.IsTheClueTrue)
                .Map(d => d.EventTypeName, x => x.EventTypeName)
                .Map(d => d.EventTypeId, x => x.EventTypeId)
                .Map(d => d.EventTypeSpliceName, x => x.EventTypeSpliceName)
                 ;

            config.ForType<Order, OrderSubmissionForm>()
             .Map(d => d.FromGender, x => x.FromGender == EGender.Male ? "男" : x.FromGender == EGender.Female ? "女" : "未知")
             .Map(d => d.CreationTime, x => x.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"))
             .Map(d => d.CenterToOrgTime, x => x.CenterToOrgTime == null ? "" : x.CenterToOrgTime.Value.ToString("yyyy-MM-dd HH:mm:ss"))
             .Map(d => d.ExpiredTime, x => x.ExpiredTime == null ? "" : x.ExpiredTime.Value.ToString("yyyy-MM-dd HH:mm:ss"))
             ;

        }
    }
}
