using Hotline.FlowEngine.Workflows; using Hotline.Settings.Hotspots; using Hotline.Share.Enums.Order; using Hotline.Users; using SqlSugar; using XF.Domain.Extensions; using XF.Domain.Repository; namespace Hotline.Orders { /// /// 工单 /// public partial class Order : PositionWorkflowEntity { #region 来电信息 /// /// 来源渠道(电话、网站、APP等) /// [SugarColumn(DefaultValue = "其他")] public string SourceChannel { get; set; } [SugarColumn(DefaultValue = "QT")] public string SourceChannelCode { get; set; } /// /// 渠道为电话时,此字段存在(Call.Id) /// [SugarColumn(IsNullable = true)] public string? CallId { get; set; } /// /// 接线员工(userId) /// public string EmployeeId { get; set; } /// /// 来电号码 /// [SugarColumn(IsNullable = true)] public string? FromPhone { get; set; } /// /// 转接号码(转接来源) /// [SugarColumn(IsNullable = true)] public string? TransferPhone { get; set; } /// /// 来电/信人姓名 /// public string FromName { get; set; } /// /// 来电/信人性别 /// public EGender FromGender { get; set; } /// /// 来电/信人身份 /// public EIdentityType IdentityType { get; set; } /// /// 证件类型 /// [SugarColumn(IsNullable = true)] public string? LicenceTypeCode { get; set; } [SugarColumn(IsNullable = true)] public string? LicenceType { get; set; } /// /// 证件号码 /// [SugarColumn(IsNullable = true)] public string? LicenceNo { get; set; } /// /// 年龄段 /// [SugarColumn(IsNullable = true)] public string? AgeRangeCode { get; set; } [SugarColumn(IsNullable = true)] public string? AgeRange { get; set; } /// /// 联系电话 /// [SugarColumn(ColumnDescription = "联系电话", IsNullable = true)] public string? Contact { get; set; } [SugarColumn(ColumnDescription = "联系电话脱敏", IsNullable = true)] public string? ContactMask { get; set; } /// /// 是否接受短信,勾选校验手机号 /// public bool AcceptSms { get; set; } /// /// 是否已发送短信 /// public bool SmsSended { get; set; } /// /// 是否保密 /// [SugarColumn(DefaultValue = "t")] public bool IsSecret { get; set; } /// /// 工作单位(当“来电/信人身份”为“企业”时必填,其他情况非必填) /// [SugarColumn(ColumnDescription = "工作单位", IsNullable = true)] public string? Company { get; set; } #endregion #region 诉求信息 /// /// 工单类型 /// public EOrderType OrderType { get; set; } /// /// 受理类型 /// public EAcceptType AcceptType { get; set; } /// /// 紧急程度 /// public EEmergencyLevel EmergencyLevel { get; set; } = EEmergencyLevel.Normal; public string Title { get; set; } #region 热点 /// /// 热点 /// public string HotspotId { get; set; } public string HotspotName { get; set; } public string HotspotSpliceName { get; set; } /// /// 外部数据(为前端提供级联功能) /// [SugarColumn(IsNullable = true)] public string? HotspotExternal { get; set; } #endregion /// /// 事发时间 /// public DateTime? IncidentTime { get; set; } /// /// 重复工单 /// //todo 1vN [SugarColumn(ColumnDescription = "重复工单Id", IsNullable = true)] public string? DuplicateId { get; set; } [SugarColumn(ColumnDescription = "重复工单标题", IsNullable = true)] public string? DuplicateTitle { get; set; } /// /// 推送分类 /// [SugarColumn(IsNullable = true)] public string? PushTypeCode { get; set; } [SugarColumn(IsNullable = true)] public string? PushType { get; set; } /// /// 附件 /// [SugarColumn(ColumnDataType = "json", IsJson = true)] public List Additions { get; set; } = new(); /// /// 诉求内容 /// [SugarColumn(ColumnDataType = "varchar(2000)")] public string Content { get; set; } #endregion #region 工单属性 /// /// 工单状态 /// public EOrderStatus Status { get; set; } /// /// 过期状态 //todo 延迟消息更新此字段 /// public EExpiredStatus ExpiredStatus { get; set; } /// /// 来源,区分省平台或110等其他平台同步过来的工单 /// public ESource Source { get; set; } /// /// 处理方式(直办、交办) /// [SugarColumn(DefaultValue = "10")] public EProcessType ProcessType { get; set; } = EProcessType.Zhiban; /// /// 进展情况 /// [SugarColumn(DefaultValue = "0")] public EProgress Progress { get; set; } /// /// 是否公开 /// [SugarColumn(DefaultValue = "f")] public bool IsPublicity { get; set; } /// /// 是否为省工单 /// [SugarColumn(DefaultValue = "f")] public bool IsProvince { get; set; } /// /// 工单编码(20220101000001) /// public string No { get; set; } /// /// 省工单编号(冗余) /// [SugarColumn(IsNullable = true)] public string? FromProvinceNo { get; set; } /// /// 同步省工单编号(按省工单要求生成的编号,冗余) /// [SugarColumn(IsNullable = true)] public string? ToProvinceNo { get; set; } #endregion #region 流程信息 /// /// 工单开始时间(受理/接办时间=流程开启时间) /// public DateTime? StartTime { get; set; } /// /// 过期时间 /// public DateTime? ExpiredTime { get; set; } ///// ///// 工单办理完成时间,实际办理部门的办理时间(汇总节点的上一个非汇总节点办理完成时间,开启会签时清空该字段) ///// //public DateTime? CompleteTime { get; set; } /// /// 归档时间(暂为流程结束时间,因流程结束自动归档) /// public DateTime? FiledTime { get; set; } #region 实际办理信息(节点,部门,意见) /// /// 实际办理节点code(会签状态此字段保存最外层会签发起节点code) /// [SugarColumn(IsNullable = true)] public string? ActualHandleStepCode { get; set; } /// /// 实际办理节点名称(会签状态此字段保存最外层会签发起节点名称) /// [SugarColumn(IsNullable = true)] public string? ActualHandleStepName { get; set; } /// /// 到达实际办理节点时间(stepBox创建时间) /// public DateTime? ActualHandleStepCreateTime { get; set; } /// /// 实际办理时间 /// public DateTime? ActualHandleTime { get; set; } /// /// 实际办理人id /// [SugarColumn(IsNullable = true)] public string? ActualHandlerId { get; set; } /// /// 实际办理人名称 /// [SugarColumn(IsNullable = true)] public string? ActualHandlerName { get; set; } /// /// 实际办理部门名称 /// [SugarColumn(IsNullable = true)] public string? ActualHandleOrgName { get; set; } /// /// 实际办理部门编码 /// [SugarColumn(IsNullable = true)] public string? ActualHandleOrgCode { get; set; } /// /// 实际办理意见(办理中...or 最终办理意见) /// [SugarColumn(Length = 2000)] public string ActualOpinion { get; set; } = "办理中..."; #endregion #region 当前办理节点信息 /// /// 当前办理节点code(非会签:当前被指派节点,会签:会签发起节点) /// [SugarColumn(IsNullable = true)] public string? CurrentStepCode { get; set; } /// /// 当前节点名称 /// [SugarColumn(IsNullable = true)] public string? CurrentStepName { get; set; } /// /// 到达当前节点时间(stepBox创建时间) /// public DateTime? CurrentStepCreateTime { get; set; } #endregion #region 一级部门 /// /// 一级部门code /// [SugarColumn(IsNullable = true)] public string? OrgLevelOneCode { get; set; } /// /// 一级部门名称 /// [SugarColumn(IsNullable = true)] public string? OrgLevelOneName { get; set; } #endregion #region 受理人(开启流程的话务员) /// /// 受理人id /// [SugarColumn(IsNullable = true)] public string? AcceptorId { get; set; } /// /// 受理人名称 /// [SugarColumn(IsNullable = true)] public string? AcceptorName { get; set; } #endregion #endregion } public partial class Order { /// /// 接线员(服务人) /// [Navigate(NavigateType.OneToOne, nameof(EmployeeId))] public User Employee { get; set; } /// /// 热点 /// [Navigate(NavigateType.OneToOne, nameof(HotspotId))] public Hotspot Hotspot { get; set; } /// /// 办理流程 /// [Navigate(NavigateType.OneToOne, nameof(WorkflowId))] public Workflow? Workflow { get; set; } /// /// 工单扩展信息(12315-投诉) /// [Navigate(NavigateType.OneToOne, nameof(Id))] public OrderComplain? OrderComplain { get; set; } /// /// 工单扩展信息(12315-举报) /// [Navigate(NavigateType.OneToOne, nameof(Id))] public OrderReport? OrderReport { get; set; } /// /// 已发布工单 /// [Navigate(NavigateType.OneToOne, nameof(Id))] public OrderPublish? OrderPublished { get; set; } /// /// 已回访工单 /// [Navigate(NavigateType.OneToOne, nameof(Id))] public OrderVisit? OrderVisited { get; set; } #region Method public void Init(string employeeId) { EmployeeId = employeeId; if (!string.IsNullOrEmpty(Contact)) ContactMask = Contact.MaskPhoneNumber(); Status = EOrderStatus.WaitForAccept; ExpiredStatus = EExpiredStatus.Normal; } /// /// 开始工单办理流程 /// public void StartManageFlow() => Status = EOrderStatus.Handling; /// /// 更新工单办理中状态 /// public void UpdateHandlingStatus(bool isInCountersign) => Status = isInCountersign ? EOrderStatus.Countersigning : EOrderStatus.Handling; /// /// 接办 /// public void Accept() { if (Status is EOrderStatus.Countersigning) return; Status = EOrderStatus.Handling; } ///// ///// 最终办理 ///// //public void FinalManage() //{ // Status = EOrderStatus.Completed; //} ///// ///// 撤回最终办理 ///// //public void RecallFinalManage() //{ // Status = EOrderStatus.WaitForSign; //} /// /// 归档 /// public void Filed() { Status = EOrderStatus.Filed; FiledTime = DateTime.Now; } //public void Jump() //{ // Status = EOrderStatus.WaitForSign; //} /// /// 工单从中心派往部门办理 /// public void FlowFromCenterToOrg() => ProcessType = EProcessType.Jiaoban; /// /// 发布 /// /// public void Publish(bool isPublicity) { Progress = EProgress.Published; IsPublicity = isPublicity; //IsPub = true; } #endregion } }