using Hotline.Share.Dtos.CallCenter;
using Hotline.Share.Dtos.File;
using Hotline.Share.Dtos.FlowEngine.Workflow;
using Hotline.Share.Dtos.Hotspots;
using Hotline.Share.Dtos.Order.OrderDelay;
using Hotline.Share.Dtos.Settings;
using Hotline.Share.Enums.FlowEngine;
using Hotline.Share.Enums.Order;
using Hotline.Share.Enums.Settings;
using Hotline.Share.Requests;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.Order
{
    public class OrderHistoryOutDto
    {
        public string Id { get; set; }
        public string Title { get; set; }

        /// <summary>
        /// 是否甄别
        /// </summary>
        public bool IsScreen { get; set; }

        public string No { get; set; }

        /// <summary>
        /// 当前节点名称
        /// </summary>
        public string CurrentStepName { get; set; }

        public DateTime CreationTime { get; set; }

        public string ActualHandleOrgName { get; set; }

        /// <summary>
        /// 工单状态
        /// </summary>
        public EOrderStatus Status { get; set; }

        public string StatusText => Status.GetDescription();

        public string? TerminateStatusText => IsTerminate == true ? "终止同意" : "";

        public bool IsTerminate { get; set; }
    }

    public class OrderDto : UpdateOrderDto
    {
        #region 工单属性

        /// <summary>
        /// 工单状态
        /// </summary>
        public EOrderStatus Status { get; set; }

        public string StatusText => Status.GetDescription();

        /// <summary>
        /// 过期状态
        /// </summary>
        public EExpiredStatus? ExpiredStatus => CalculateExpiredState();

        /// <summary>
        /// 过期状态
        /// </summary>
        public string ExpiredStatusText => ExpiredStatus?.GetDescription() ?? string.Empty;

        /// <summary>
        /// 处理方式（直办、交办）
        /// </summary>
        public EProcessType ProcessType { get; set; }

        ///// <summary>
        ///// 进展情况
        ///// </summary>
        //public EProgress Progress { get; set; }

        /// <summary>
        /// 是否公开
        /// </summary>
        public bool IsPublicity { get; set; }

        /// <summary>
        /// 工单编码（20220101000001）
        /// </summary>
        public string No { get; set; }

        /// <summary>
        /// 是否110来的工单
        /// </summary>
        public bool IsNo110 { get; set; }

        public string? TagNames { get; set; }

        /// <summary>
        /// 工单标签（自贡）
        /// </summary>
        public string? OrderTag => OrderTags != null && OrderTags.Any() ? string.Join(",", OrderTags.Select(x => x.DicDataName)) : string.Empty;

        // public string? OrderTagCode => OrderTags != null && OrderTags.Any() ? string.Join(",", OrderTags.Select(x => x.DicDataValue)) : string.Empty; 
        public string? OrderTagCode { get; set; }

        public List<SystemDicDataOutDto>? OrderTags { get; set; }

        /// <summary>
        /// 一级标签
        /// </summary>
        public string? OrderTagsOneName => GetOrderTagsOne(1);

        /// <summary>
        /// 二级标签
        /// </summary>
        public string? OrderTagsTwoName => GetOrderTagsOne(2);

        private string? GetOrderTagsOne(int level)
        {
            if (OrderTags != null && OrderTags.Any())
            {
                List<SystemDicDataOutDto> tagsData = [];
                if (level == 1)
                    tagsData = OrderTags.Where(p => p.ParentId == null || p.ParentId == "").ToList();
                if (level == 2)
                    tagsData = OrderTags.Where(p => p.ParentId != null && p.ParentId != "").ToList();
                if (tagsData != null && tagsData.Any())
                {
                    return string.Join(",", tagsData.Select(x => x.DicDataName));
                }
            }
            return string.Empty;
        }

        #region 流程信息

        /// <summary>
        /// 工单开始时间(受理/接办时间=流程开启时间)
        /// </summary>
        public DateTime? StartTime { get; set; }

        /// <summary>
        /// 交办时间(中心交部门办理时间)
        /// </summary>
        public DateTime? CenterToOrgTime { get; set; }

        /// <summary>
        /// 归档时间（暂为流程结束时间，因流程结束自动归档）
        /// </summary>
        public DateTime? FiledTime { get; set; }


        ///// <summary>
        ///// 归档意见
        ///// </summary>
        //public string? FileOpinion { get; set; }

        /// <summary>
        /// 办结时长（分钟）
        /// 办结时间-交办时间
        /// </summary>
        public double HandleDuration { get; set; }

        /// <summary>
        /// 办结工作日时长(分钟)
        /// </summary>
        public double HandleDurationWorkday { get; set; }

        /// <summary>
        /// 全流程时长（秒）
        /// 归档时间-受理时间
        /// </summary>
        public double AllDuration { get; set; }

        /// <summary>
        /// 全流程时长小时
        /// </summary>
        public string AllDurationHour => GetAllDurationHour();

        public string GetAllDurationHour()
        {
            if (CreationTimeHandleDurationWorkday != null && CreationTimeHandleDurationWorkday > 0)
            {
                return Math.Round(Math.Round(CreationTimeHandleDurationWorkday.Value) / 60 / 60, 2).ToString() + "";
            }
            return "0.00";
        }

        /// <summary>
        /// 办结时长（秒） 归档时间-受理时间（工单创建时间）
        /// </summary>
        public double? CreationTimeHandleDuration { get; set; }

        /// <summary>
        /// 办结工作日时长（秒）归档时间-受理时间（工单创建时间）
        /// </summary>
        public double? CreationTimeHandleDurationWorkday { get; set; }

        /// <summary>
        /// 办结时长（秒） 归档时间-派单时间（中心到部门时间）
        /// </summary>
        public double? CenterToOrgHandleDuration { get; set; }

        /// <summary>
        /// 办结工作日时长（秒）归档时间-派单时间（中心到部门时间）
        /// </summary>
        public double? CenterToOrgHandleDurationWorkday { get; set; }

        /// <summary>
        /// 第一次评价结果代码
        /// </summary>
        public string? FirstVisitResultCode { get; set; }

        #region 实际办理信息（节点，部门，意见）

        /// <summary>
        /// 实际办理节点code（会签状态此字段保存最外层会签发起节点code）
        /// </summary>
        public string? ActualHandleStepCode { get; set; }

        /// <summary>
        /// 实际办理节点名称（会签状态此字段保存最外层会签发起节点名称）
        /// </summary>
        public string? ActualHandleStepName { get; set; }

        /// <summary>
        /// 到达实际办理节点时间（stepBox创建时间）
        /// </summary>
        public DateTime? ActualHandleStepCreateTime { get; set; }

        /// <summary>
        /// 实际办理节点签收时间
        /// </summary>
        public DateTime? ActualHandleStepAcceptTime { get; set; }

        public string ActualStepAcceptText => ActualHandleStepAcceptTime.HasValue ? "已签收" : "未签收";

        /// <summary>
        /// 实际办理时间
        /// </summary>
        public DateTime? ActualHandleTime { get; set; }

        /// <summary>
        /// 实际办理人id
        /// </summary>
        public string? ActualHandlerId { get; set; }

        /// <summary>
        /// 实际办理人名称
        /// </summary>
        public string? ActualHandlerName { get; set; }

        /// <summary>
        /// 实际办理部门名称
        /// </summary>
        public string? ActualHandleOrgName { get; set; }

        /// <summary>
        /// 实际办理部门编码
        /// </summary>
        public string? ActualHandleOrgCode { get; set; }

        /// <summary>
        /// 实际办理部门行政区划编码
        /// </summary>
        public string? ActualHandleOrgAreaCode { get; set; }

        /// <summary>
        /// 实际办理部门行政区划名称
        /// </summary>
        public string? ActualHandleOrgAreaName { get; set; }

        /// <summary>
        /// 实际办理对象(会签停留在顶级发起节点)
        /// 办理时选择的办理对象，可能是部门也可能是用户
        /// </summary>
        public string? ActualHandlerValue { get; set; }

        public string? ActualHandlerKey { get; set; }
        public EHandlerType? ActualHandlerType { get; set; }

        /// <summary>
        /// 实际办理意见（办理中...or 最终办理意见）
        /// </summary>
        public string ActualOpinion { get; set; } = "办理中...";

        /// <summary>
        /// 真实办理人姓名（手动填写）
        /// </summary>
        public string? RealHandlerName { get; set; }

        /// <summary>
        /// 真实办理人电话（手动填写）
        /// </summary>
        public string? RealHandlerPhone { get; set; }

        /// <summary>
        /// 沟通方式（手动填写）
        /// </summary>
        public ERealCommunicationMode? RealCommunicationMode { get; set; }

        /// <summary>
        /// 沟通时间（手动填写）
        /// </summary>
        public DateTime? RealCommunicationTime { get; set; }

        /// <summary>
        /// 沟通地点（手动填写）
        /// </summary>
        public string? RealCommunicationAddress { get; set; }

        /// <summary>
        /// 已与市民沟通
        /// </summary>
        public bool? RealIsContacted { get; set; }

        /// <summary>
        /// 已与市民沟通
        /// </summary>
        public string RealIsContactedTxt => RealIsContacted.HasValue && RealIsContacted.Value ? "已与市民沟通" : string.Empty;

        /// <summary>
        /// 已与市民现场沟通
        /// </summary>
        public bool? RealContactLocale { get; set; }

        /// <summary>
        /// 其它
        /// </summary>
        public bool? IsOther { get; set; }

        /// <summary>
        /// 其它的备注
        /// </summary>
        public string? OtherRemark { get; set; }

        /// <summary>
        /// 已与市民现场沟通
        /// </summary>
        public string RealContactLocaleTxt => RealContactLocale.HasValue && RealContactLocale.Value ? "已与市民现场沟通" : string.Empty;

        #endregion

        #region 当前办理节点信息(指派时赋值)

        public string? CurrentStepId { get; set; }

        /// <summary>
        /// 当前办理节点code（非会签：当前被指派节点，会签：会签发起节点）
        /// </summary>
        public string? CurrentStepCode { get; set; }

        /// <summary>
        /// 当前节点名称
        /// </summary>
        public string? CurrentStepName { get; set; }

        /// <summary>
        /// 到达当前节点时间
        /// </summary>
        public DateTime? CurrentStepCreateTime { get; set; }

        /// <summary>
        /// 当前办理节点签收时间
        /// </summary>
        public DateTime? CurrentStepAcceptTime { get; set; }

        public string CurrentStepAcceptText => CurrentStepAcceptTime.HasValue ? "已签收" : "未签收";

        /// <summary>
        /// 当前办理时间
        /// </summary>
        public DateTime? CurrentHandleTime { get; set; }

        /// <summary>
        /// 当前办理人id
        /// </summary>
        public string? CurrentHandlerId { get; set; }

        /// <summary>
        /// 当前办理人名称
        /// </summary>
        public string? CurrentHandlerName { get; set; }

        /// <summary>
        /// 当前办理部门名称
        /// </summary>
        public string? CurrentHandleOrgName { get; set; }

        /// <summary>
        /// 当前办理部门编码
        /// </summary>
        public string? CurrentHandleOrgId { get; set; }

        /// <summary>
        /// 当前办理部门等级
        /// </summary>
        public int? CurrentHandleOrgLevel { get; set; }

        /// <summary>
        /// 当前办理部门行政区划编码
        /// </summary>
        public string? CurrentHandleOrgAreaCode { get; set; }

        /// <summary>
        /// 当前办理部门行政区划名称
        /// </summary>
        public string? CurrentHandleOrgAreaName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string? FocusOnEventsName { get; set; }

        #endregion

        #region 一级部门

        /// <summary>
        /// 一级部门code
        /// </summary>
        public string? OrgLevelOneCode { get; set; }

        /// <summary>
        /// 一级部门名称
        /// </summary>
        public string? OrgLevelOneName { get; set; }

        #endregion

        #region 受理人(开启流程的话务员)

        /// <summary>
        /// 受理人id
        /// </summary>
        public string? AcceptorId { get; set; }

        /// <summary>
        /// 受理人名称
        /// </summary>
        public string? AcceptorName { get; set; }

        /// <summary>
        /// 受理人工号
        /// </summary>
        public string? AcceptorStaffNo { get; set; }

        /// <summary>
        /// 受理人部门编码
        /// </summary>
        public string? AcceptorOrgCode { get; set; }

        /// <summary>
        /// 受理人部门名称
        /// </summary>
        public string? AcceptorOrgName { get; set; }

        #endregion

        /// <summary>
        /// 会签类型
        /// </summary>
        public ECounterSignType? CounterSignType { get; set; }

        public string? CounterSignTypeText => CounterSignType?.GetDescription() ?? "未会签";

        #region 签收

        /// <summary>
        /// 签收人id
        /// </summary>
        public string? SignerId { get; set; }

        /// <summary>
        /// 签收人名称
        /// </summary>
        public string? SignerName { get; set; }

        #endregion

        #endregion

        #endregion

        public DateTime CreationTime { get; set; }


        public string? ContactMask { get; set; }

        public string SmsSendedText => SmsSended ? "已发送" : "未发送";

        /// <summary>
        /// 市民查询密码
        /// </summary>
        public string? Password { get; set; }

        //public string? HotspotCodeLv1 { get; set; }

        public string WorkflowId { get; set; }
        public WorkflowDto Workflow { get; set; }

        /// <summary>
        /// 来电/信人性别
        /// </summary>
        public string FromGenderText => FromGender.GetDescription();

        /// <summary>
        /// 来电/信人身份
        /// </summary>
        public string IdentityTypeText => IdentityType?.GetDescription();

        ///// <summary>
        ///// 受理类型
        ///// </summary>
        ////public string AcceptTypeText => AcceptType.GetDescription();

        ///// <summary>
        ///// 紧急程度
        ///// </summary>
        //public string EmergencyLevelText => EmergencyLevel.GetDescription();
        /// <summary>
        /// 紧急程度
        /// </summary>
        //public EEmergencyLevel EmergencyLevel { get; set; }
        public EEmergencyLevel EmergencyLevel => IsUrgent
            ? EEmergencyLevel.Emergency
            : EEmergencyLevel.UnEmergency;

        ///// <summary>
        ///// 超期时间描述（需求：超期3天、0.5天后超期）
        ///// </summary>
        //public string ExpiredText => CalculateExpiredText();

        /// <summary>
        /// 是否可编辑
        /// </summary>
        public bool CanEdit => !string.IsNullOrEmpty(SignerId) &&
                               (Status is EOrderStatus.WaitForAccept or EOrderStatus.BackToUnAccept or EOrderStatus.SpecialToUnAccept
                                   or EOrderStatus.HandOverToUnAccept);

        /// <summary>
        /// 是否可签收
        /// </summary>
        public bool CanSign => string.IsNullOrEmpty(SignerId);

        /// <summary>
        /// 是否显示为红色
        /// </summary>
        public bool IsRed { get; set; }

        /// <summary>
        /// 待结束会签编号
        /// </summary>
        public string? CountersignId { get; set; }

        /// <summary>
        /// 是否可以延期
        /// </summary>
        public bool IsCanDelay { get; set; }

        /// <summary>
        /// 是否可以取消延期
        /// </summary>
        public bool IsCanCancelDelay { get; set; }

        /// <summary>
        /// 最后一次延期天数
        /// </summary>
        public string? DelayString { get; set; }

        /// <summary>
        /// 是否可退回
        /// </summary>
        public bool CanPrevious { get; set; }

        /// <summary>
        /// 是否可办理
        /// </summary>
        public bool CanHandle { get; set; }

        /// <summary>
        /// 退回意见
        /// </summary>
        public string? PreviousOpinion { get; set; }

        /// <summary>
        /// 是否可代办
        /// </summary>
        public bool CanInsteadHandle { get; set; }

        /// <summary>
        /// 延期申请数量
        /// </summary>
        public int DelayingCount => OrderDelays?.Count ?? 0;

        /// <summary>
        /// 是否紧急
        /// </summary>
        public bool IsUrgent { get; set; }

        public string IsUrgentText => IsUrgent ? "紧急" : "";

        /// <summary>
        /// 工单办理时 勾选的 是否紧急
        /// </summary>
        public string IsStepUrgenText => IsStepUrgent ? "紧急" : "";

        /// <summary>
        /// 工单办理时勾选的 是否紧急
        /// </summary>
        public bool IsStepUrgent { get; set; }

        /// <summary>
        /// 是否推诿
        /// </summary>
        public bool IsEvasive { get; set; }

        /// <summary>
        /// 是否推诿
        /// </summary>
        public string IsEvasiveTxt => IsEvasive ? "推诿" : "";

        /// <summary>
        /// 是否不积极
        /// </summary>
        public bool IsInactively { get; set; }

        /// <summary>
        /// 是否不积极
        /// </summary>
        public string IsInactivelyTxt => IsInactively ? "不积极" : "";

        /// <summary>
        /// 发布范围
        /// </summary>
        public bool? PublishState { get; set; }

        /// <summary>
        /// 是否延期 
        /// </summary>
        public string? DelayText => DelayingCount > 0 ? "是" : "否";

        /// <summary>
        /// 一级热点
        /// </summary>
        public string OneHotspotName => !string.IsNullOrEmpty(HotspotSpliceName) && HotspotSpliceName.Split("-").Length >= 1 ? HotspotSpliceName.Split("-")[0] : string.Empty;

        /// <summary>
        /// 二级热点
        /// </summary>
		public string TwoHotspotName => !string.IsNullOrEmpty(HotspotSpliceName) && HotspotSpliceName.Split("-").Length >= 2 ? HotspotSpliceName.Split("-")[1] : string.Empty;

        /// <summary>
        /// 三级热点
        /// </summary>
		public string ThreeHotspotName => !string.IsNullOrEmpty(HotspotSpliceName) && HotspotSpliceName.Split("-").Length >= 3 ? HotspotSpliceName.Split("-")[2] : string.Empty;

        /// <summary>
        /// 四级热点
        /// </summary>
        public string FourHotspotName => !string.IsNullOrEmpty(HotspotSpliceName) && HotspotSpliceName.Split("-").Length >= 4 ? HotspotSpliceName.Split("-")[3] : string.Empty;

        /// <summary>
        /// 五级热点
        /// </summary>
        public string FiveHotspotName => !string.IsNullOrEmpty(HotspotSpliceName) && HotspotSpliceName.Split("-").Length >= 5 ? HotspotSpliceName.Split("-")[4] : string.Empty;

        /// <summary>
        /// 特提次数
        /// </summary>
        public int SpecialNum { get; set; }

        private string CalculateExpiredText()
        {
            //todo 完整处理方案：1.创建待过期表，Id,过期时间，即将过期时间等字段。2.延迟消息通知处理过期，删除子表数据，处理order过期状态字段。3.此处即可采用expiredStatus进行判断
            //todo 目前暂时采用过期时间计算
            if (!ExpiredTime.HasValue)
                return string.Empty;
            var days = (DateTime.Now - ExpiredTime.Value).TotalDays;
            switch (days)
            {
                case > 0:
                    return $"超期{days:N1}天";
                case < 0:
                    return $"{days:N1}天后超期";
                default:
                    return "超期不到1天";
            }
        }

        /// <summary>
        /// 超期天数
        /// </summary>
        public string DaysOverdue => DaysOverdueText();

        private string DaysOverdueText()
        {
            DateTime? dateTime = DateTime.Now;
            if (Status >= EOrderStatus.Filed && ExpiredTime.HasValue && FiledTime.HasValue)
            {
                var days = (FiledTime.Value - ExpiredTime.Value).TotalDays;
                return $"超期{days:N1}天";
            }

            if (ExpiredTime.HasValue)
            {
                var days = (dateTime.Value - ExpiredTime.Value).TotalDays;
                return $"超期{days:N1}天";
            }

            return string.Empty;
        }

        /// <summary>
        /// 剩余办理时长
        /// </summary>
        public string RemainingTime => RemainingTimeTextVoid();

        public string RemainingTimeTextVoid()
        {
            try
            {
                if (Status >= EOrderStatus.Filed && FiledTime != null && ExpiredTime != null)
                {
                    return Math.Round((ExpiredTime.Value - FiledTime.Value).TotalDays, 1) + "天";
                }
                else if (Status < EOrderStatus.Filed && ExpiredTime != null)
                {
                    return Math.Round((ExpiredTime.Value - DateTime.Now).TotalDays, 1) + "天";
                }
                else
                {
                    return "-";
                }
            }
            catch
            {
                return "-";
            }
        }


        /// <summary>
        /// 超期部门
        /// </summary>
        public string DaysOverdueOrgName { get; set; }

        public EExpiredStatus? CalculateExpiredState()
        {
            DateTime? dateTime = DateTime.Now;
            if (Status >= EOrderStatus.Filed)
            {
                dateTime = FiledTime;
            }

            //ExpiredStatus
            if (ExpiredTime.HasValue)
            {
                if (NearlyExpiredTimeOne.HasValue && dateTime < NearlyExpiredTimeOne)
                {
                    return EExpiredStatus.Normal;
                }
                else if (!NearlyExpiredTimeOne.HasValue && dateTime < NearlyExpiredTime)
                {
                    return EExpiredStatus.Normal;
                }
                else if (NearlyExpiredTimeOne.HasValue && dateTime > NearlyExpiredTimeOne && dateTime < NearlyExpiredTime)
                {
                    return EExpiredStatus.GoingToExpiredOne;
                }
                else if (dateTime > NearlyExpiredTime && dateTime < ExpiredTime)
                {
                    return EExpiredStatus.GoingToExpired;
                }
                else
                {
                    return EExpiredStatus.Expired;
                }
            }

            return null;
        }

        public OrderExtensionDto OrderExtension { get; set; }

        public HotspotDto? Hotspot { get; set; }

        /// <summary>
        /// 延期
        /// </summary>
        public List<OrderDelayDto> OrderDelays { get; set; }

        /// <summary>
        /// 甄别
        /// </summary>
        public List<OrderScreenListDto> OrderScreens { get; set; }

        public List<RepeatableEventDetailOpDto> RepeatableEventDetails { get; set; } = new();

        public List<OrderVisitDto>? OrderVisits { get; set; }

        public CallNativeDto? FwCallRecord { get; set; }

        public List<FileJson>? FileJson { get; set; }

        /// <summary>
        /// 可直接访问的通话录音地址
        /// </summary>
        public string? RecordingBaseAddress { get; set; }

        public string? RecordingAbsolutePath { get; set; }

        public int ReTransactNum { get; set; }

        /// <summary>
        /// 回访重办次数
        /// </summary>
        public int? VisitReTransactNum { get; set; }

        /// <summary>
        /// 省重办次数
        /// </summary>
        public int? ProvinceReTransactNum { get; set; }

        /// <summary>
        /// 工单交办处理方式 10：直接办结，20：交办，30：派单员重派，40：结果审核重派，50：回访不满意重派
        /// </summary>
        public string? CaseProcessTypeText => GetCaseProcessTypeText();
        public string GetCaseProcessTypeText()
        {
            var text = "";
            if (!string.IsNullOrEmpty(CaseProcessType))
            {
                switch (CaseProcessType)
                {
                    case "10":
                    case "20":
                        break;
                    case "30":
                        text = "派单员重派";
                        break;
                    case "40":
                        text = "结果审核重派";
                        break;
                    case "50":
                        text = "回访不满意重派";
                        break;
                    default:
                        break;
                }
            }
            return text;
        }

        /// <summary>
        /// 敏感标签
        /// </summary>
        public List<string>? Sensitive { get; set; }

        public string? SensitiveText => (Sensitive != null && Sensitive.Any()) ? string.Join(',', Sensitive) : "";

        public string IsProvinceText => IsProvince ? "省工单" : "市工单";

        /// <summary>
        /// 部门是否解决
        /// </summary>
        public bool IsResolved { get; set; }

        public string IsResolvedText => IsResolved ? "已解决" : "未解决";

        #region 副本工单

        /// <summary>
        /// 修改人	
        /// </summary>
        public string AuditUserName { get; set; }

        public string AuditUserId { get; set; }

        /// <summary>
        ///  修改时间
        /// </summary>
        public DateTime AuditTime { get; set; }

        /// <summary>
        /// 副本工单id
        /// </summary>
        public string CopyId { get; set; }

        #endregion

        public string OverDays => GetOverDays();


        public string GetOverDays()
        {
            var overDays = "0天";
            if (ExpiredTime.HasValue)
            {
                if (FiledTime.HasValue && ExpiredTime < FiledTime)
                {
                    overDays = (FiledTime - ExpiredTime).Value.Days + "天";
                }
                else if (FiledTime.HasValue == false && ExpiredTime < DateTime.Now)
                {
                    overDays = (DateTime.Now - ExpiredTime).Value.Days + "天";
                }
            }

            return overDays;
        }

        /// <summary>
        /// 自贡需求584，保密工单的事发地址需开放给承办部门
        /// </summary>
        /// <param name="isShow"></param>
        /// <returns></returns>
        public OrderDto DataMask(bool isShow)
        {
            if (this.IsSecret == false) return this;
            var maskString = "***";
            this.Contact = maskString;
            this.FromName = maskString;
            this.FromGender = EGender.Unknown;
            this.FromPhone = maskString;
            if (isShow == false)
            {
                this.FullAddress = maskString;
                this.Address = maskString;
                this.City = maskString;
                this.Street = maskString;
            }
            this.ContactMask = maskString;
            return this;
        }

        ///// <summary>
        ///// 中心意见
        ///// </summary>
        //public string CenterOpinion { get; set; }

        /// <summary>
        /// 退回原因
        /// </summary>
        public string SendBackOpinion { get; set; }

        /// <summary>
        /// 重办意见
        /// </summary>
        public string? ReTransactOpinion { get; set; }

        /// <summary>
        /// 退回原因
        /// </summary>
        public string SendBackRefuseOpinion { get; set; }

        /// <summary>
        /// 审批时间
        /// </summary>
        public DateTime? SendBackAuditTime { get; set; }

        /// <summary>
        /// 退回意见
        /// </summary>
        public List<OrderRemarksDto> OrderRemarks { get; set; }

        /// <summary>
        /// 交办人(派单员)
        /// </summary>
        public string? CenterToOrgHandlerId { get; set; }

        /// <summary>
        /// 交办人(派单员)
        /// </summary>
        public string? CenterToOrgHandlerName { get; set; }

        /// <summary>
        /// 是否退回审批中
        /// </summary>
        public bool IsReturnUnderApproval { get; set; }

        /// <summary>
        /// 退回截至时间
        /// </summary>
        public DateTime? SendBackAuditEndTime { get; set; }

        /// <summary>
        /// 省退回信息
        /// </summary>
        public string ProvinceSendBackString { get; set; }

        /// <summary>
        /// 省撤单信息
        /// </summary>
        public string ProvinceRevokeString { get; set; }

        /// <summary>
        /// 省甄别
        /// </summary>
        public string ProvinceScreenString { get; set; }

        /// <summary>
        /// 省延期
        /// </summary>
        public string? ProvinceDelayString { get; set; }

        /// <summary>
        /// 省工单退回
        /// </summary>
        public bool? ProvinceSendBack { get; set; }

        /// <summary>
        /// 终止
        /// </summary>
        public List<OrderTerminateDto> OrderTerminates { get; set; }

        /// <summary>
        /// 终止状态
        /// </summary>
        public string? OrderTerminateStatus { get; set; }

        #region 回访信息

        ///// <summary>
        ///// 部门满意度
        ///// </summary>
        //public Kv? OrgEvaluate { get; set; }
        //{
        //    get
        //    {
        //        if (this.OrderVisits == null) return null;
        //        var visitEntity = this.OrderVisits
        //            .OrderByDescending(m => m.CreationTime)
        //            .FirstOrDefault();
        //        if (visitEntity == null) return null;
        //        return visitEntity.NowEvaluate;
        //    }
        //}

        /// <summary>
        /// 部门满意度
        /// </summary>
        public Kv? OrgProcessingResults { get; set; }

        /// <summary>
        /// 部门满意度
        /// </summary>
        public string? OrgEvaluateValue => OrgProcessingResults != null ? OrgProcessingResults.Value : "";
        //{
        //    get
        //    {
        //        if (this.OrderVisits == null) return null;
        //        var visitEntity = this.OrderVisits
        //            .OrderByDescending(m => m.CreationTime)
        //            .FirstOrDefault();
        //        if (visitEntity == null) return null;
        //        var now = visitEntity.NowEvaluate;
        //        if (now == null) return null;
        //        return now.Value;
        //    }
        //}

        /// <summary>
        /// 坐席满意度
        /// </summary>
        public ESeatEvaluate? SeatEvaluate { get; set; }
        //{
        //    get
        //    {
        //        if (this.OrderVisits == null) return null;
        //        var visitEntity = this.OrderVisits
        //            .OrderByDescending(m => m.CreationTime)
        //            .FirstOrDefault();
        //        if (visitEntity == null) return null;
        //        return visitEntity.OrderVisitDetails.Where(m => m.VisitTarget == EVisitTarget.Seat)
        //            .FirstOrDefault()?.SeatEvaluate;
        //    }
        //}

        public string? SeatEvaluateTxt => SeatEvaluate?.GetDescription();

        #endregion

        /// <summary>
        /// 工单补充
        /// </summary>
        public List<OrderComplementDto> OrderComplements { get; set; }

        #region 随手拍
        /// <summary>
        /// 行业Id
        /// <inheritdoc cref="Industry"/> 表的Id
        /// </summary>
        public string? IndustryId { get; set; }

        /// <summary>
        /// 行业名称
        /// <inheritdoc cref="Industry"/> 表的Name
        /// </summary>
        public string? IndustryName { get; set; }

        /// <summary>
        /// 部门-是否整改
        /// </summary>
        public bool? IsRectifyDepartment { get; set; }

        /// <summary>
        /// 部门-是否存在安全隐患
        /// </summary>
        public bool? IsDangerDepartment { get; set; }

        /// <summary>
        /// 标记-部门标记是否安全生产
        /// </summary>
        public bool? IsSafetyDepartment { get; set; }

        /// <summary>
        /// 标记-标记人
        /// </summary>
        public string? SignUserId { get; set; }

        /// <summary>
        /// 标记-标记人
        /// </summary>
        public string? SignUserName { get; set; }

        /// <summary>
        /// 标记-标记时间
        /// </summary>
        public DateTime? SignTime { get; set; }

        /// <summary>
        /// 标记-标记备注
        /// </summary>
        public string? SignRemark { get; set; }

        #endregion

        public bool? IsReTransact { get; set; }

        /// <summary>
        /// 重办时长,最新二次办理审批通过后的归档时间-最新二次办理审批通过时间（秒）
        /// </summary>
        public double? SecondaryHandlingDuration { get; set; }

        public double? SecondaryHandlingDurationWorkday { get; set; }
        public string? SecondaryHandlingDurationWorkdayDayText => SecondaryHandlingDurationDay();

        public string SecondaryHandlingDurationDay()
        {
            var overDays = "";
            if (SecondaryHandlingDurationWorkday.HasValue && SecondaryHandlingDurationWorkday.Value > 0)
            {
                var totalDays = Math.Round(((double)SecondaryHandlingDurationWorkday / 3600 / 8), 2);
                overDays = totalDays > 0 ? totalDays + "" : "0.01";
            }

            return overDays;
        }

        /// <summary>
        /// 工单督办
        /// </summary>
        public List<OrderSuperviseDto> OrderSupervises { get; set; }

        /// <summary>
        /// 督办情况1
        /// </summary>
        public string? SuperviseInfo1 => OrderSupervises != null && OrderSupervises.Count > 0 ? OrderSupervises[0].CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "已通知" + OrderSupervises[0].OrgName : "";

        /// <summary>
        /// 督办情况2
        /// </summary>
        public string? SuperviseInfo2 => OrderSupervises != null && OrderSupervises.Count > 1 ? OrderSupervises[1].CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "已通知" + OrderSupervises[1].OrgName : "";

        /// <summary>
        /// 不满意原因
        /// </summary>
        public string? orgNoSatisfiedReasonText =>
            OrderVisits != null && OrderVisits.Count > 0 ?
            OrderVisits.FirstOrDefault().OrderVisitDetails != null && OrderVisits.FirstOrDefault().OrderVisitDetails.Count > 0 ?
            OrderVisits.FirstOrDefault().OrderVisitDetails.FirstOrDefault().OrgNoSatisfiedReasonText : "" : "";
    }


    public class OrderEarlyInfo
    {
        public string KeyWord { get; set; }

        public int WeekNum { get; set; } = 0;

        public int MonthNum { get; set; } = 0;
    }

    public class UpdateOrderDto : AddOrderDto
    {
        public string Id { get; set; }

        /// <summary>
        /// 中心意见
        /// </summary>
        public string CenterOpinion { get; set; }

        /// <summary>
        /// 归档意见
        /// </summary>
        public string? FileOpinion { get; set; }

        /// <summary>
        /// 能否编辑,true:任何节点可以编辑；false：未发起流程可以编辑
        /// </summary>
        public bool IsEdit { get; set; }

    }

    public class OrderUploadFiles
    {

        public string Id { get; set; }

        /// <summary>
        /// 附件列表
        /// </summary>
        public List<FileDto> Files { get; set; } = new();


    }


    public class AddOrderDto : Position
    {
        #region 来电信息
        /// <summary>
        /// 政治身份
        /// </summary>
        public string? PoliticalIdentityValue { get; set; }

        /// <summary>
        /// 政治身份
        /// </summary>
        public string? PoliticalIdentityName { get; set; }

        /// <summary>
        /// 来源渠道
        /// </summary>
        public string? SourceChannel { get; set; }

        public string? SourceChannelCode { get; set; }

        /// <summary>
        /// 渠道为电话时，此字段存在
        /// </summary>
        public string? CallId { get; set; }

        /// <summary>
        /// 来电归属地
        /// </summary>
        public string? CallAddress { get; set; }

        /// <summary>
        /// 来电号码
        /// </summary>
        public string? FromPhone { get; set; }

        /// <summary>
        /// 转接号码（转接来源）
        /// </summary>
        public string? TransferPhone { get; set; }

        /// <summary>
        /// 来电/信人姓名
        /// </summary>
        public string? FromName { get; set; }

        /// <summary>
        /// 来电/信人性别
        /// </summary>
        public EGender FromGender { get; set; }

        /// <summary>
        /// 来电/信人身份
        /// </summary>
        public EIdentityType? IdentityType { get; set; }

        /// <summary>
        /// 证件类型
        /// </summary>
        public string? LicenceTypeCode { get; set; }

        public string? LicenceType { get; set; }

        /// <summary>
        /// 证件号码
        /// </summary>
        public string? LicenceNo { get; set; }

        /// <summary>
        /// 年龄段
        /// </summary>
        public string? AgeRangeCode { get; set; }

        public string? AgeRange { get; set; }

        /// <summary>
        /// 联系电话
        /// </summary>
        public string? Contact { get; set; }

        /// <summary>
        /// 是否接受短信，勾选校验手机号
        /// </summary>
        public bool AcceptSms { get; set; }

        /// <summary>
        /// 是否已发送短信
        /// </summary>
        public bool SmsSended { get; set; }

        /// <summary>
        /// 是否保密
        /// </summary>
        public bool IsSecret { get; set; }

        public string IsSecretText => IsSecret ? "保密" : "";

        /// <summary>
        /// 工作单位(当“来电/信人身份”为“企业”时必填，其他情况非必填)
        /// </summary>
        public string? Company { get; set; }

        #endregion

        #region 诉求信息

        /// <summary>
        /// 受理类型
        /// </summary>
        public string? AcceptType { get; set; }

        public string? AcceptTypeCode { get; set; }

        public string Title { get; set; }

        //      /// <summary>
        //      /// 工单标签（自贡）
        //      /// </summary>
        //      public string? OrderTag => OrderTags != null && OrderTags.Any() ? string.Join(",", OrderTags.Select(x => x.DicDataName)) : string.Empty;


        //public string? OrderTagCode { get; set; }

        #region 热点

        /// <summary>
        /// 热点
        /// </summary>
        public string? HotspotId { get; set; }

        //public string? HotspotCode { get; set; }
        public string? HotspotName { get; set; }
        public string? HotspotSpliceName { get; set; }

        /// <summary>
        /// 外部数据（为前端提供级联功能）
        /// </summary>
        public string? HotspotExternal { get; set; }

        #endregion

        #region 事件分类

        public string? EventCategoryId { get; set; }
        public string? EventCategoryName { get; set; }
        public string? EventCategorySpliceName { get; set; }
        public string? EventCategoryExternal { get; set; }

        #endregion

        /// <summary>
        /// 事发时间
        /// </summary>
        public DateTime? IncidentTime { get; set; }

        /// <summary>
        /// 事件目的
        /// </summary>
        public string? IncidentPurpose { get; set; }

        /// <summary>
        /// 重复工单Id
        /// </summary>
        public List<string>? DuplicateIds { get; set; }


        /// <summary>
        /// 推送分类 -- 弃用 转为表存储
        /// </summary>
        public string? PushTypeCode { get; set; }


        /// <summary>
        /// 推送分类 -- 弃用 转为表存储
        /// </summary>
        public string? PushType { get; set; }

        /// <summary>
        /// 附件
        /// </summary>
        public List<string> Additions { get; set; } = new();

        /// <summary>
        /// 诉求内容
        /// </summary>
        public string Content { get; set; }

        #endregion

        /// <summary>
        /// 来源，区分省平台或110等其他平台同步过来的工单
        /// </summary>
        public ESource Source { get; set; } = ESource.Hotline;

        /// <summary>
        /// 扩展信息
        /// </summary>
        public OrderExtensionDto? OrderExtension { get; set; }

        /// <summary>
        /// 附件列表
        /// </summary>
        public List<FileDto> Files { get; set; } = new();

        /// <summary>
        /// 企业名称
        /// </summary>
        public string? EnterpriseName { get; set; }

        /// <summary>
        /// 企业Code
        /// </summary>
        public string? EnterpriseCode { get; set; }

        /// <summary>
        /// 专班名称
        /// </summary>
        public string? ZhuanBanMingCheng { get; set; }

        /// <summary>
        /// 专班Code
        /// </summary>
        public string? ZhuanBanCode { get; set; }

        #region 重复性事件

        public List<RepeatableEventDetailOpDto> RepeatableEventDetails { get; set; } = new();

        #endregion

        /// <summary>
        /// 是否为省工单
        /// </summary>
        public bool IsProvince { get; set; }

        /// <summary>
        /// 省本地编号
        /// </summary>
        public string? ProvinceNo { get; set; }

        /// <summary>
        /// 省交办编号
        /// </summary>
        public string? ReceiveProvinceNo { get; set; }

        /// <summary>
        /// 省是否公开（省政府网站、省政务服务网、天府通办App）
        /// </summary>
        public bool? IsPublic { get; set; }

        /// <summary>
        /// 省过期时间（省工单才有）
        /// </summary>
        public DateTime? ExpiredTimeProvince { get; set; }

        /// <summary>
        /// 工单交办处理方式 10：直接办结，20：交办，30：派单员重派，40：结果审核重派，50：回访不满意重派
        /// 处理方式为结果审核重派时禁止退单
        /// 处理方式为回访不满意重派时禁止退单
        /// </summary>
        public string? CaseProcessType { get; set; }

        /// <summary>
        /// 外部工单唯一标识
        /// </summary>
        public string? ExternalId { get; set; }

        #region 期满时间

        /// <summary>
        /// 过期时间
        /// </summary>
        public DateTime? ExpiredTime { get; set; }

        /// <summary>
        /// 即将超期时间
        /// </summary>
        public DateTime? NearlyExpiredTime { get; set; }

        /// <summary>
        /// 即将超期第一级
        /// </summary>
        public DateTime? NearlyExpiredTimeOne { get; set; }

        /// <summary>
        /// 办理时间限制(如：24小时、7个工作日)
        /// </summary>
        public string? TimeLimit { get; set; }

        public int? TimeLimitCount { get; set; }

        public ETimeType? TimeLimitUnit { get; set; }

        #endregion

        #region 市州工单互转

        /// <summary>
        /// 是否转发
        /// </summary>
        public bool? Transpond { get; set; }

        /// <summary>
        /// 转发市州Id
        /// </summary>
        public string? TranspondCityId { get; set; }

        /// <summary>
        /// 转发市州名称
        /// </summary>
        public string? TranspondCityName { get; set; }

        /// <summary>
        /// 转发市州Value
        /// </summary>
        public string? TranspondCityValue { get; set; }

        #endregion

        /// <summary>
        /// 是否行政执法类
        /// </summary>
        public bool? IsEnforcementOrder { get; set; }

        /// <summary>
        /// 形式主义工单
        /// </summary>
        public bool IsFormalistWorkOrder { get; set; }

        /// <summary>
        /// 敏感类工单
        /// </summary>
        public bool IsSensitiveWorkOrders { get; set; }

        /// <summary>
        /// 24小时办结
        /// </summary>
        public bool Is24HoursComplete { get; set; }

        /// <summary>
        /// 重点关注事件,保存前端选择，用于返回前端数据
        /// </summary>
        public string? FocusOnEvents { get; set; }

        /// <summary>
        /// 重点关注事件，保存前端选择文字，用于返回前端数据
        /// </summary>
        public string? FocusOnEventsName { get; set; }

        /// <summary>
        /// 是否紧急
        /// </summary>
        public bool IsUrgent { get; set; }

        /// <summary>
        /// 是否三方通话
        /// </summary>
        public bool IsThreePartyConference { get; set; }

        /// <summary>
        /// 是否政民互动公开
        /// </summary>
        public bool IsProvinceZmhd { get; set; }

        /// <summary>
        /// 初审人姓名
        /// </summary>
        public string? AuditFirstName { get; set; }

        /// <summary>
        /// 初审时间
        /// </summary>
        public DateTime? AuditFirstTime { get; set; }

        /// <summary>
        /// 政民互动公开ID
        /// </summary>
        public string? OrderProvinceZmhdId { get; set; }

        /// <summary>
        /// 工单推送分类
        /// </summary>
        public List<OrderPushTypeDto>? OrderPushTypes { get; set; }

        #region 随手拍
        /// <summary>
        /// 行业Id
        /// <inheritdoc cref="Industry"/> 表的Id
        /// </summary>
        public string? IndustryId { get; set; }

        /// <summary>
        /// 行业名称
        /// <inheritdoc cref="Industry"/> 表的Name
        /// </summary>
        public string? IndustryName { get; set; }

        #endregion

        /// <summary>
        ///知识库引用
        /// </summary>
        public List<Kv>? KnowledgeQuote { get; set; }

        /// <summary>
        /// 工单标签
        /// </summary>
        public List<string>? Tags { get; set; }

        #region 预警信息

        /// <summary>
        /// 坐席预警级别值
        /// </summary>
        public string? SeatEarlyWarningLevelValue { get; set; }

        /// <summary>
        /// 坐席预警级别名称
        /// </summary>
        public string? SeatEarlyWarningLevelName { get; set; }

        /// <summary>
        /// 坐席预警类型值
        /// </summary>
        public string? SeatEarlyWarningTypeValue { get; set; }

        /// <summary>
        /// 坐席预警类型名称
        /// </summary>
        public string? SeatEarlyWarningTypeName { get; set; }

        #endregion

    }

    public record CanLinkCallRecordOrderDto : PagedKeywordRequest
    {
    }

    /// <summary>
    /// 修改工单受理附件
    /// </summary>
    public class UpdateOrderFilesDto
    {
        public string Id { get; set; }

        public string OrderNo { get; set; }

        /// <summary>
        /// 附件
        /// </summary>
        public List<FileDto> Files { get; set; } = new List<FileDto>();
    }


    public record OrderCopyListDto : PagedKeywordRequest
    {
        public string OrderId { get; set; }
    }

    public class UnsignedOrderDto
    {
        public OrderDto Order { get; set; }

        public WorkflowStepDto WorkflowStep { get; set; }

        public decimal UnsignedTime { get; set; }
    }

    public class OrderRemarksDto
    {
        /// <summary>
        /// 备注信息
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 备注人
        /// </summary>
        public string? RemarkUser { get; set; }

        /// <summary>
        /// 备注时间
        /// </summary>
        public DateTime? RemarkTime { get; set; }
    }

    public class PublishNearlyExpiredTimeSmsDto
    {
        public string OrderId { get; set; }
    }

    public class OverTimeOrderDto
    {
        public string OrgId { get; set; }

        public int NearlyOrderCount { get; set; }

        public int ExpiredTimeOrderCount { get; set; }
    }

    public class PublishAutomaticDelayDto
    {
        public string OrderId { get; set; }
    }

    public class PublishCancelInDto
    {
        /// <summary>
        /// Id
        /// </summary>
        public string OrderPublishId { get; set; }
    }

    public class OrderListOutDto
    {
        /// <summary>
        /// Id
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 工单状态
        /// </summary>
        public EOrderStatus Status { get; set; }

        public string StatusText => Status.GetDescription();

        /// <summary>
        /// 过期状态
        /// </summary>
        public EExpiredStatus? ExpiredStatus => CalculateExpiredState();

        /// <summary>
        /// 归档时间（暂为流程结束时间，因流程结束自动归档）
        /// </summary>
        public DateTime? FiledTime { get; set; }

        /// <summary>
        /// 过期时间
        /// </summary>
        public DateTime? ExpiredTime { get; set; }

        /// <summary>
        /// 即将超期时间
        /// </summary>
        public DateTime? NearlyExpiredTime { get; set; }

        /// <summary>
        /// 即将超期第一级
        /// </summary>
        public DateTime? NearlyExpiredTimeOne { get; set; }


        public EExpiredStatus? CalculateExpiredState()
        {
            DateTime? dateTime = DateTime.Now;
            if (Status >= EOrderStatus.Filed)
            {
                dateTime = FiledTime;
            }

            //ExpiredStatus
            if (ExpiredTime.HasValue)
            {
                if (NearlyExpiredTimeOne.HasValue && dateTime < NearlyExpiredTimeOne)
                {
                    return EExpiredStatus.Normal;
                }
                else if (!NearlyExpiredTimeOne.HasValue && dateTime < NearlyExpiredTime)
                {
                    return EExpiredStatus.Normal;
                }
                else if (NearlyExpiredTimeOne.HasValue && dateTime > NearlyExpiredTimeOne && dateTime < NearlyExpiredTime)
                {
                    return EExpiredStatus.GoingToExpiredOne;
                }
                else if (dateTime > NearlyExpiredTime && dateTime < ExpiredTime)
                {
                    return EExpiredStatus.GoingToExpired;
                }
                else
                {
                    return EExpiredStatus.Expired;
                }
            }

            return null;
        }

        /// <summary>
        /// 过期状态
        /// </summary>
        public string ExpiredStatusText => ExpiredStatus?.GetDescription() ?? string.Empty;

        /// <summary>
        /// 工单编码（20220101000001）
        /// </summary>
        public string No { get; set; }


        /// <summary>
        /// 会签类型
        /// </summary>
        public ECounterSignType? CounterSignType { get; set; }

        public string? CounterSignTypeText => CounterSignType?.GetDescription() ?? "未会签";

        /// <summary>
        /// 签收人id
        /// </summary>
        public string? SignerId { get; set; }

        /// <summary>
        /// 签收人名称
        /// </summary>
        public string? SignerName { get; set; }

        public DateTime CreationTime { get; set; }

        public string? ContactMask { get; set; }


        /// <summary>
        /// 紧急程度
        /// </summary>
        public EEmergencyLevel EmergencyLevel => IsUrgent
            ? EEmergencyLevel.Emergency
            : EEmergencyLevel.UnEmergency;

        /// <summary>
        /// 是否可签收
        /// </summary>
        public bool CanSign => string.IsNullOrEmpty(SignerId);

        /// <summary>
        /// 待结束会签编号
        /// </summary>
        public string? CountersignId { get; set; }

        /// <summary>
        /// 是否可以延期
        /// </summary>
        public bool IsCanDelay { get; set; }

        /// <summary>
        /// 是否可以取消延期
        /// </summary>
        public bool IsCanCancelDelay { get; set; }

        /// <summary>
        /// 最后一次延期天数
        /// </summary>
        public string? DelayString { get; set; }

        /// <summary>
        /// 是否可退回
        /// </summary>
        public bool CanPrevious { get; set; }

        /// <summary>
        /// 是否可办理
        /// </summary>
        public bool CanHandle { get; set; }

        /// <summary>
        /// 退回意见
        /// </summary>
        public string? PreviousOpinion { get; set; }

        /// <summary>
        /// 是否可代办
        /// </summary>
        public bool CanInsteadHandle { get; set; }

        /// <summary>
        /// 是否紧急
        /// </summary>
        public bool IsUrgent { get; set; }

        public string IsUrgentText => IsUrgent ? "紧急" : "";

        /// <summary>
        /// 是否显示为红色
        /// </summary>
        public bool IsRed { get; set; }

        /// <summary>
        /// 发布范围
        /// </summary>
        public bool? PublishState { get; set; }

        /// <summary>
        /// 实际办理节点code（会签状态此字段保存最外层会签发起节点code）
        /// </summary>
        public string? ActualHandleStepCode { get; set; }

        /// <summary>
        /// 实际办理节点名称（会签状态此字段保存最外层会签发起节点名称）
        /// </summary>
        public string? ActualHandleStepName { get; set; }

        /// <summary>
        /// 重办次数
        /// </summary>
        public int ReTransactNum { get; set; }

        /// <summary>
        /// 热点分类
        /// </summary>
        public string HotspotName { get; set; }

        /// <summary>
        /// 来源渠道
        /// </summary>
        public string SourceChannel { get; set; }

        public string SourceChannelCode { get; set; }

        /// <summary>
        /// 受理类型
        /// </summary>
        public string AcceptType { get; set; }

        public string AcceptTypeCode { get; set; }

        /// <summary>
        /// 是否为省工单
        /// </summary>
        public bool IsProvince { get; set; }

        public string IsProvinceText => IsProvince ? "省工单" : "市工单";

        /// <summary>
        /// 工单标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 工单开始时间(受理/接办时间=流程开启时间)
        /// </summary>
        public DateTime? StartTime { get; set; }

        /// <summary>
        /// 受理人id
        /// </summary>
        public string AcceptorId { get; set; }

        /// <summary>
        /// 受理人名称
        /// </summary>
        public string AcceptorName { get; set; }

        /// <summary>
        /// 是否可编辑
        /// </summary>
        public bool CanEdit => !string.IsNullOrEmpty(SignerId) &&
                               (Status is EOrderStatus.WaitForAccept or EOrderStatus.BackToUnAccept or EOrderStatus.SpecialToUnAccept
                                   or EOrderStatus.HandOverToUnAccept);

        /// <summary>
        /// 敏感标签
        /// </summary>
        public List<string>? Sensitive { get; set; }

        public string? SensitiveText => (Sensitive != null && Sensitive.Any()) ? string.Join(',', Sensitive) : "";
    }

    public class OrderStepUploadFilesDto
    {
        public string OrderId { get; set; }
        public string StepId { get; set; }
        public List<FileDto> Files { get; set; } = new();
    }
}
