using Hotline.FlowEngine.Definitions;
using Hotline.FlowEngine.WorkflowModules;
using Hotline.Settings;
using Hotline.Share.Dtos;
using Hotline.Share.Dtos.FlowEngine;
using Hotline.Share.Enums.FlowEngine;
using Hotline.Share.Enums.Settings;
using Hotline.Users;
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);
///
/// 查询工作流
///
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 canPrevious)> GetWorkflowHandlePermissionAsync(
string workflowId, string userId, string orgId, 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, User operater,
CancellationToken cancellationToken);
///
/// 撤回(返回到之前任意节点)
///
Task RecallAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine, FlowAssignInfo flowAssignInfo,
DateTime? expiredTime, CancellationToken cancellationToken);
///
/// 撤回至开始节点
///
Task RecallToStartStepAsync(string workflowId, string opinion, CancellationToken cancellationToken);
/////
///// 跳转(直接将流程跳转至任意节点)
/////
//Task JumpAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine, FlowAssignInfo flowAssignInfo,
// CancellationToken cancellationToken);
/////
///// 重办
/////
//Task RedoAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine, FlowAssignInfo flowAssignInfo,
// CancellationToken cancellationToken);
///
/// 否决(审批流程不通过)
///
///
Task RejectAsync(Workflow workflow, BasicWorkflowDto dto, CancellationToken cancellationToken);
///
/// 补充
///
///
Task SupplementAsync(Workflow workflow, EndWorkflowDto dto, CancellationToken cancellationToken);
///
/// 终止流程
///
Task TerminateAsync(TerminateDto dto, CancellationToken cancellationToken);
///
/// 结束流程(流程直接流转至结束节点)
///
Task EndAsync(Workflow workflow, BasicWorkflowDto dto, StepDefine endStepDefine,
WorkflowStep currentStep, EReviewResult? reviewResult = EReviewResult.Unknown,
CancellationToken cancellationToken = default);
StepDefine GetStepDefine(WorkflowDefinition workflowDefinition, string stepCode);
///
/// 查询当前待办理节点
///
WorkflowStep FindCurrentStepWaitForHandle(Workflow workflow, string userId, string orgId);
///
/// 查询当前节点中最后一个节点
///
Task FindLastStepAsync(string workflowId, CancellationToken cancellationToken);
///
/// 查询待回访部门
///
Task<(Kv, IReadOnlyList)> GetUnvisitOrgsAsync(string workflowId, CancellationToken cancellationToken);
///
/// 依据配置过滤下一节点
///
List NextStepDefineFilter(EPathPolicy pathPolicy, List nextStepDefines);
///
/// 撤销流程
///
Task CancelAsync(CancelDto dto, CancellationToken cancellationToken);
/////
///// 更新期满时间
/////
//Task UpdateExpiredTimeAsync(Workflow workflow, DateTime expiredTime, string timelimit, int? timelimiteCount,
// ETimeType? timelimitUnit, DateTime nearlyExpiredTime, CancellationToken cancellationToken);
///
/// 新增流程流转记录
///
Task AddTracesAsync(string workflowId, List traces, CancellationToken cancellationToken);
///
/// 创建开始节点
///
WorkflowStep CreateStartStep(Workflow workflow, StepDefine startStepDefine, BasicWorkflowDto dto,
List handlers, DateTime? expiredTime);
///
/// 查询未完成节点
///
///
///
///
///
WorkflowStep GetUnHandleStep(List steps, string orgCode, string userId);
///
/// 检查当前办理节点是否为开始节点
///
///
/// 当前办理人Id
/// 当前办理人orgId
///
///
Task CheckCurrentIsStartStepAsync(string workflowId, string userId, string orgId,
CancellationToken cancellationToken);
///
/// 检查动态节点是否该终止
///
bool DynamicShouldTerminal(StepDefine currentStepDefine, int currentOrgLevel);
///
/// 终止会签
///
///
///
///
Task TerminalCountersignAsync(string countersignId, CancellationToken cancellationToken);
///
/// 查询实际办理对象信息
///
///
///
///
Task FindActualHandlerAsync(string workflowId, CancellationToken cancellationToken);
///
/// 办理节点
///
Task HandleStepAsync(WorkflowStep step, Workflow workflow, BasicWorkflowDto dto,
EFlowAssignType? flowAssignType, ECounterSignType? counterSignType, DateTime? expiredTime,
CancellationToken cancellationToken);
///
/// 获取会签类型
///
ECounterSignType GetCounterSignType(EBusinessType businessType);
///
/// 查询退回节点信息
///
(WorkflowStep currentStep, WorkflowStep prevStep, WorkflowStep? countersignStartStep) GetPreviousStep(
Workflow workflow, string operaterId, string operaterOrgId);
///
/// 查询派单池中流程节点id
///
Task> GetUnhandleStepIdsFromSendPoolAsync(string sendPoolId, CancellationToken cancellationToken);
///
/// 批量改派工单至指定用户
///
Task ChangeHandlerRangeAsync(string sendPoolId,
IReadOnlyList<(string userId, string username, IReadOnlyList stepIds)> handlers,
CancellationToken cancellationToken);
}
}