using Hotline.FlowEngine.Definitions; using Hotline.FlowEngine.WorkflowModules; using Hotline.Settings; using Hotline.Share.Dtos; using Hotline.Share.Dtos.File; using Hotline.Share.Dtos.FlowEngine; using Hotline.Share.Dtos.FlowEngine.Workflow; using Hotline.Share.Enums.FlowEngine; using Hotline.Share.Enums.Settings; using Hotline.Users; using XF.Domain.Authentications; using XF.Domain.Entities; namespace Hotline.FlowEngine.Workflows { public interface IWorkflowDomainService { /// /// 创建流程 /// Task CreateWorkflowAsync(WorkflowModule wfModule, string title, string userId, string orgId, string? externalId = null, CancellationToken cancellationToken = default); // /// // /// 进行流程的开始节点 // /// // Task StartAsync(Workflow workflow, WorkflowStep startStep, BasicWorkflowDto dto, StepDefine firstStepDefine, // bool isNextDynamic, FlowAssignInfo flowAssignInfo, ECounterSignType? counterSignType, DateTime? expiredTime, // CancellationToken cancellationToken); /// /// new /// Task<(Workflow, WorkflowStep)> StartAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null, Action? newStepConfig = null, CancellationToken cancellationToken = default); /// /// new /// Task<(Workflow, WorkflowStep, StepDefine, List)> NextAsync( NextWorkflowDto dto, EHandleMode handleMode = EHandleMode.Normal, DateTime? expiredTime = null, bool isAutoFillSummaryOpinion = false, Action? currentStepConfig = null, Action? newStepConfig = null, CancellationToken cancellationToken = default); Task<(Workflow, WorkflowStep, StepDefine, List)> NextAsync( Workflow workflow, NextWorkflowDto dto, EHandleMode handleMode = EHandleMode.Normal, DateTime? expiredTime = null, bool isAutoFillSummaryOpinion = false, Action? currentStepConfig = null, Action? newStepConfig = null, CancellationToken cancellationToken = default); /// /// 开启流程并办理至第一个节点 /// Task> StartToFirstStepAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null, Action? newStepConfig = null, CancellationToken cancellationToken = default); /// /// 开启流程直接归档 /// Task StartToEndAsync(StartWorkflowDto dto, string externalId, DateTime? expiredTime = null, CancellationToken cancellationToken = default); /// /// 查询工作流 /// Task GetWorkflowAsync(string workflowId, bool withDefine = false, bool withSteps = false, bool withTraces = false, bool withTracesTree = false, bool withSupplements = false, bool withCountersigns = false, CancellationToken cancellationToken = default); /// /// 查询工作流包含当前用户办理权限(是否可办理) /// Task<(Workflow Workflow, string? CountersignId, bool CanHandle, bool CanPrevious, WorkflowTrace? Trace)> GetWorkflowHandlePermissionAsync( string workflowId, string userId, string orgId, string[] roleIds, CancellationToken cancellationToken = default); /// /// 受理,接办 /// Task AcceptAsync(Workflow workflow, string userId, string? userName, string orgId, string? orgName, string? orgAreaCode, string? orgAreaName, CancellationToken cancellationToken); ///// ///// 办理(流转至下一节点) ///// //Task NextAsync(Workflow workflow, WorkflowStep currentStep, NextWorkflowDto dto, StepDefine nextStepDefine, // bool isNextDynamic, FlowAssignInfo flowAssignInfo, DateTime? expiredTime, CancellationToken cancellationToken); // /// // /// 退回(返回前一节点) // /// // /// // Task PreviousAsync(Workflow workflow, PreviousWorkflowDto dto, // string applicantId, string applicantName, // string applicantOrgId, string applicantOrgName, // string applicantOrgAreaCode, string applicantOrgAreaName, // bool applicantIsCenter, string[] applicantRoleIds, // CancellationToken cancellationToken); /// /// 退回(new) /// Task<(Workflow workflow, WorkflowStep currentStep, StepDefine prevDefine, WorkflowStep prevStep, WorkflowStep newStep, EFlowDirection flowDirection)> PreviousAsync (Workflow workflow, PreviousWorkflowDto dto, OperatorInfo operatorInfo, EHandleMode handleMode = EHandleMode.Previous, Action? newStepConfig = null, CancellationToken cancellationToken = default); /// /// 退回 /// Task<(Workflow workflow, WorkflowStep currentStep, StepDefine prevDefine, WorkflowStep prevStep, WorkflowStep newStep, EFlowDirection flowDirection)> PreviousAsync(PreviousWorkflowDto dto, EHandleMode handleMode = EHandleMode.Previous, Action? newStepConfig = null, CancellationToken cancellationToken = default); /// /// 撤回(返回到之前任意节点) /// Task<(Workflow, StepDefine, WorkflowStep, WorkflowStep, WorkflowStep, bool)> RecallAsync( RecallDto dto, StepAssignInfo stepAssignInfo, EWorkflowTraceType traceType, DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, Action? newStepConfig = null, CancellationToken cancellationToken = default); Task<(Workflow, StepDefine, WorkflowStep, WorkflowStep, WorkflowStep, bool)> RecallAsync( Workflow workflow, BasicWorkflowDto dto, StepAssignInfo stepAssignInfo, StepDefine targetStepDefine, EWorkflowTraceType traceType, DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, Action? newStepConfig = null, CancellationToken cancellationToken = default); Task<(Workflow, StepDefine, WorkflowStep, WorkflowStep, WorkflowStep, bool)> RecallAsync( Workflow workflow, BasicWorkflowDto dto, StepAssignInfo stepAssignInfo, WorkflowStep targetStep, EWorkflowTraceType traceType, DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, Action? newStepConfig = null, CancellationToken cancellationToken = default); /// /// 撤回至开始节点 /// Task RecallToStartStepAsync(string workflowId, string opinion, DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, EFlowAssignType? flowAssignType = EFlowAssignType.Role, CancellationToken cancellationToken = default); Task RecallToStartStepAsync(Workflow workflow, string opinion, DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, EFlowAssignType? flowAssignType = EFlowAssignType.Role, CancellationToken cancellationToken = default); /// /// 特提至派单节点(无派单节点会抛异常) /// Task RecallToSendStepAsync(Workflow workflow, string opinion, DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, EFlowAssignType? flowAssignType = EFlowAssignType.Role, CancellationToken cancellationToken = default); /// /// 特提至中心(优先派单组其次坐席) /// /// Task<(bool, Workflow workflow)> RecallToCenterFirstToSendAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime, EHandleMode handleMode, EFlowAssignType? flowAssignType = EFlowAssignType.User, CancellationToken cancellationToken = default); ///// ///// 否决(审批流程不通过) ///// ///// //Task RejectAsync(Workflow workflow, BasicWorkflowDto dto, CancellationToken cancellationToken); Task RejectAsync(RejectDto dto, CancellationToken cancellationToken); /// /// 补充 /// /// Task SupplementAsync(Workflow workflow, EndWorkflowDto dto, CancellationToken cancellationToken); /// /// 终止流程 /// Task TerminateAsync(TerminateDto dto, CancellationToken cancellationToken); /// /// 结束流程(流程直接流转至结束节点) /// Task<(WorkflowStep, WorkflowTrace)> EndAsync(ISessionContext current, Workflow workflow, BasicWorkflowDto dto, StepDefine endStepDefine, WorkflowStep currentStep, DateTime? expiredTime, CancellationToken cancellationToken); StepDefine GetStepDefine(WorkflowDefinition workflowDefinition, string stepCode); /// /// 查询当前待办理节点 /// WorkflowStep FindCurrentStepWaitForHandle(Workflow workflow, string userId, string orgId, string[] roleIds); /// /// 查询当前节点中最后一个节点 /// Task FindLastStepAsync(string workflowId, CancellationToken cancellationToken); /// /// 查询所有办理部门及实际办理部门 /// Task<(Kv, IReadOnlyList)> GetHandleOrgsAsync(string workflowId, CancellationToken cancellationToken); /// /// 新增流程流转记录 /// Task AddStepsAsync(string workflowId, List steps, CancellationToken cancellationToken); /// /// 创建开始节点 /// WorkflowStep CreateStartStep(Workflow workflow, StepDefine startStepDefine, BasicWorkflowDto dto, UserInfo assigner, StepAssignInfo handler, DateTime? expiredTime, //EFlowAssignType? flowAssignType = EFlowAssignType.User, Action? newStepConfig = null); /// /// 查询未完成节点 /// /// /// /// /// WorkflowStep GetUnHandleStep(List steps, string orgId, string userId, string[] roleIds); /// /// 检查当前办理节点是否为开始节点 /// /// /// 当前办理人Id /// 当前办理人orgId /// /// Task CheckCurrentIsStartStepAsync(string workflowId, string userId, string orgId, CancellationToken cancellationToken); /// /// 检查动态节点是否该终止 /// bool DynamicShouldTerminal(StepDefine currentStepDefine, int currentOrgLevel); /// /// 终止会签 /// /// /// /// Task TerminalCountersignAsync(string countersignId, DateTime expireTime, CancellationToken cancellationToken); Task TerminalCountersignAsync(WorkflowCountersign countersign, DateTime expireTime, CancellationToken cancellationToken); /// /// 办理节点 /// Task HandleStepAsync(WorkflowStep step, Workflow workflow, BasicWorkflowDto dto, ECounterSignType? counterSignType, DateTime? expiredTime, EHandleMode handleMode, CancellationToken cancellationToken); /// /// 获取会签类型 /// ECounterSignType? GetCounterSignType(bool isStartCountersign, EBusinessType currentStepBusinessType); /// /// 查询退回节点信息 /// (WorkflowStep currentStep, WorkflowStep prevStep, WorkflowStep? countersignStartStep) GetPreviousStep( Workflow workflow, string operaterId, string operaterOrgId, string[] roleIds); /// /// 查询派单池中流程节点id /// Task> GetUnhandleStepIdsFromSendPoolAsync(string sendPoolId, CancellationToken cancellationToken); /// /// 查询归属某用户的所有流程节点 /// Task> GetStepsBelongsToAsync(string userId, CancellationToken cancellationToken); /// /// 查询归属多个用户的所有流程节点 当天 /// /// Task> GetStepsBelongsDayToAsync(List userIds, DateTime time, CancellationToken cancellationToken); /// /// 批量修改工单办理对象 /// Task ChangeHandlerBatchAsync( IReadOnlyList<(string userId, string username, string orgId, string orgName, string? roleId, string? roleName, ICollection steps)> handlers, CancellationToken cancellationToken); /// /// 查询工单办理中的一级部门 /// Task> GetLevelOneOrgsAsync(string workflowId, CancellationToken cancellation); /// /// 更新未办理节点的期满时间 /// Task UpdateUnhandleExpiredTimeAsync(string workflowId, DateTime? expiredTime, CancellationToken cancellation); /// /// 查询该部门最后办理节点 /// /// Task FindLastHandleStepAsync(string workflowId, string orgId, CancellationToken cancellation); /// /// 部门会签工单获取流程最顶级办理节点 /// /// Task FindTopHandleStepAsync(string workflowId, CancellationToken cancellation); /// /// 查询流转方向 /// EFlowDirection GetFlowDirection(EBusinessType sourceStepBusinessType, EBusinessType directionStepBusinessType); /// /// 流程被签收至某个用户(更新流转对象,办理对象,节点办理对象以及stepHandlers) /// Task SignToSomebodyAsync(string workflowId, string userId, string username, string orgId, string orgName, CancellationToken cancellationToken); /// /// 非节点办理人员查询待办节点 /// /// Task> GetUnhandleStepsByOthersAsync(string workflowId, CancellationToken cancellationToken); /// /// 根据汇总对象id找到被汇总节点,生成指派到用户的办理对象 /// StepAssignInfo GetSummaryTargetFlowStepHandler(Workflow workflow, string summaryTargetStepCode); /// /// 追加归档信息(接收ds推送12315归档信息) /// Task AppendFileOpinionAsync(string workflowId, string opinion, List files, CancellationToken cancellationToken); /// /// 跳转至结束节点(无视流程模板配置以及当前办理对象,直接跳至结束节点) /// Task JumpToEndAsync(ISessionContext current, string workflowId, string opinion, List files, DateTime? expiredTime, EReviewResult reviewResult = EReviewResult.Unknown, CancellationToken cancellationToken = default); Task JumpToEndAsync(ISessionContext current, Workflow workflow, string opinion, List files, DateTime? expiredTime, EReviewResult reviewResult = EReviewResult.Unknown, CancellationToken cancellationToken = default); /// /// 查找会签循环的初始会签发起节点 /// WorkflowStep GetCsLoopStartStep(List steps, WorkflowStep currentStep); Task HandlePublishTraceAsync(string workflowId, string orderPublishId, UserInfo acceptor, UserInfo handler, DateTime handleTime, UserInfo visitAcceptor, string orderVisitId, CancellationToken cancellation); Task HandleVisitTraceAsync(string orderVisitId, UserInfo visitor, DateTime visitTime, CancellationToken cancellation); Task GetNextStepFlowAssignInfoByDefineAsync(StepDefine nextStepDefine, EHandlerType handlerType, bool isStartCountersign, List handlers, CancellationToken cancellationToken); } }