diff --git a/ds-wms-service/DS.Module.Core/Enums/TaskPlat/TaskBaseTypeEnum.cs b/ds-wms-service/DS.Module.Core/Enums/TaskPlat/TaskBaseTypeEnum.cs index 645364e2..4be9c0bb 100644 --- a/ds-wms-service/DS.Module.Core/Enums/TaskPlat/TaskBaseTypeEnum.cs +++ b/ds-wms-service/DS.Module.Core/Enums/TaskPlat/TaskBaseTypeEnum.cs @@ -225,6 +225,11 @@ namespace DS.Module.Core [Description("待放单")] WAIT_CHECKOUT_BILL = 208, + /// + /// 审单驳回 + /// + [Description("审单驳回")] + ORDER_AUDIT_REJECTED = 401, #endregion #region 工作流--可选服务项目 diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeServiceBase.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeServiceBase.cs index c4a924b3..45ff3535 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeServiceBase.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeServiceBase.cs @@ -285,7 +285,7 @@ namespace DS.WMS.Core.Fee.Method /// /// 审核类型 /// - protected ISugarQueryable GetCurrentFlowsQuery(AuditType[] auditTypes) + protected internal ISugarQueryable GetCurrentFlowsQuery(AuditType[] auditTypes) { return Db.Queryable().Where(x => x.FlowStatus == FlowStatusEnum.Running && SqlFunc.SplitIn(x.MakerList, User.UserId) && auditTypes.Contains(x.Type.Value)) diff --git a/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowCallback.cs b/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowCallback.cs index 7c96ef86..79a38b5c 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowCallback.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Dtos/FlowCallback.cs @@ -4,7 +4,7 @@ using DS.WMS.Core.Op.Entity; namespace DS.WMS.Core.Flow.Dtos { /// - /// 工作流回调信息 + /// 工作流完成回调信息 /// public class FlowCallback { diff --git a/ds-wms-service/DS.WMS.Core/Flow/Dtos/MakerChangedCallback.cs b/ds-wms-service/DS.WMS.Core/Flow/Dtos/MakerChangedCallback.cs new file mode 100644 index 00000000..8463fec3 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Flow/Dtos/MakerChangedCallback.cs @@ -0,0 +1,36 @@ +using DS.Module.Core; +using DS.WMS.Core.Op.Entity; + +namespace DS.WMS.Core.Flow.Dtos +{ + /// + /// 执行人变更回调信息 + /// + public class MakerChangedCallback + { + /// + /// 工作流实例ID + /// + public long InstanceId { get; set; } + + /// + /// 业务ID + /// + public long BusinessId { get; set; } + + /// + /// 业务类型 + /// + public BusinessType? BusinessType { get; set; } + + /// + /// 工作流类型 + /// + public AuditType? Type { get; set; } + + /// + /// 下一执行人的用户ID + /// + public long? NextUserId { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowInstance.cs b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowInstance.cs index f701bfda..50ffaacd 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowInstance.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowInstance.cs @@ -86,9 +86,15 @@ public class FlowInstance : BaseTenantModel public string Content { get; set; } /// - /// 回调地址 + /// 执行人变更回调地址 /// - [SugarColumn(ColumnDescription = "回调地址", IsNullable = true, Length = 255)] + [SugarColumn(ColumnDescription = "执行人变更回调地址", IsNullable = true, Length = 255)] + public string? MakerNotifyURL { get; set; } + + /// + /// 审批完成回调地址 + /// + [SugarColumn(ColumnDescription = "审批完成回调地址", IsNullable = true, Length = 255)] public string? CallbackURL { get; set; } /// diff --git a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplate.cs b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplate.cs index 43206b3c..a49850b4 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplate.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplate.cs @@ -45,11 +45,17 @@ public class FlowTemplate : BaseModel [SugarColumn(ColumnDescription = "状态")] public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 执行人变更回调地址 + /// + [SugarColumn(ColumnDescription = "执行人变更回调地址", IsNullable = true, Length = 255)] + public string? MakerNotifyURL { get; set; } + /// /// 回调地址 /// [SugarColumn(ColumnDescription = "回调地址", IsNullable = true, Length = 255)] - public string CallbackURL { get; set; } + public string? CallbackURL { get; set; } /// /// 审批类型 diff --git a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplateTenant.cs b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplateTenant.cs index c382ffac..51e4a5a4 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplateTenant.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Entity/FlowTemplateTenant.cs @@ -45,11 +45,17 @@ public class FlowTemplateTenant : BaseTenantModel [SugarColumn(ColumnDescription = "状态")] public StatusEnum? Status { get; set; } = StatusEnum.Enable; + /// + /// 执行人变更回调地址 + /// + [SugarColumn(ColumnDescription = "执行人变更回调地址", IsNullable = true, Length = 255)] + public string? MakerNotifyURL { get; set; } + /// /// 回调地址 /// [SugarColumn(ColumnDescription = "回调地址", IsNullable = true, Length = 255)] - public string CallbackURL { get; set; } + public string? CallbackURL { get; set; } /// /// 审批类型 diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowInstanceService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowInstanceService.cs index 8828daf9..385e8c46 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowInstanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowInstanceService.cs @@ -39,6 +39,7 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc PermissionId = template.PermissionId, ColumnView = template.ColumnView, Content = template.Content, + MakerNotifyURL = template.MakerNotifyURL, CallbackURL = template.CallbackURL, Type = template.AuditType }; diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs index d2adc268..31965269 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs @@ -93,6 +93,7 @@ public class FlowInstanceService : IFlowInstanceService PermissionId = template.PermissionId, ColumnView = template.ColumnView, Content = template.Content, + MakerNotifyURL = template.MakerNotifyURL, CallbackURL = template.CallbackURL, Type = template.AuditType }; @@ -150,7 +151,6 @@ public class FlowInstanceService : IFlowInstanceService if (wfruntime.GetNextNodeType() == 4 && !instance.CallbackURL.IsNullOrEmpty()) { Task.Factory.StartNew(() => RunCallbackAsync(instance)); - //RunCallbackAsync(instance); } var userInfo = db.Queryable().First(x => x.Id == long.Parse(user.UserId)); @@ -202,8 +202,7 @@ public class FlowInstanceService : IFlowInstanceService instance.ActivityId = startNodeId; instance.ActivityType = wfruntime.GetNodeType(startNodeId); instance.ActivityName = wfruntime.ChildNodes.First(x => x.Id == startNodeId).Name; - instance.MakerList = - (wfruntime.GetNextNodeType() != 4 ? GetCurrentMakers(wfruntime) : "1"); + instance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetCurrentMakers(wfruntime) : "1"); instance.FlowStatus = FlowStatusEnum.Draft; wfruntime.FlowInstanceId = instance.Id; @@ -321,9 +320,7 @@ public class FlowInstanceService : IFlowInstanceService var runtime = CreateRuntimeService(instance); if (runtime.CurrentNodeId != instance.ActivityId) - { return DataResult.Failed("该工作流审批节点与当前节点不一致!", MultiLanguageConst.FlowInstanceNodeIdConflict); - } #region 会签 @@ -352,13 +349,18 @@ public class FlowInstanceService : IFlowInstanceService instance.FlowStatus = runtime.NextNodeType == 4 ? FlowStatusEnum.Approve : FlowStatusEnum.Running; instance.MakerList = runtime.NextNodeType == 4 ? "1" : GetNextMakers(runtime); } - // AddTransHistory(wfruntime); } else { //会签过程中,需要更新用户 instance.MakerList = GetForkNodeMakers(runtime, runtime.CurrentNodeId); - // AddTransHistory(wfruntime); + } + + string marker = GetNextMarker(instance); + //获取会签下一执行人,进行通知 + if (!marker.IsNullOrEmpty() && marker != "-1" && !instance.MakerNotifyURL.IsNullOrEmpty()) + { + Task.Factory.StartNew(() => NotifyMakerChangedAsync(instance, long.Parse(marker))); } } @@ -422,6 +424,47 @@ public class FlowInstanceService : IFlowInstanceService return DataResult.Successed("审批成功!", MultiLanguageConst.FlowInstanceAuditSuccess); } + /// + /// 获取会签下一执行人 + /// + /// 运行实例 + /// + public static string GetNextMarker(FlowInstance instance) + { + //if (instance.ActivityType != 0) + // return string.Empty; + + if (instance.MakerList.IsNullOrEmpty() || instance.MakerList == "-1") + return instance.MakerList; + + string[] markers = instance.MakerList.Split([','], StringSplitOptions.RemoveEmptyEntries); + if (markers.Length > 0 && long.TryParse(markers[0], out long nextUserId)) + return nextUserId.ToString(); + + return instance.MakerList; + } + + /// + /// 运行执行人变更回调 + /// + /// 运行实例 + /// 下一执行人ID + /// + protected virtual async Task NotifyMakerChangedAsync(FlowInstance instance, long nextUserId) + { + //请求参数设置 + var callback = new MakerChangedCallback + { + InstanceId = instance.Id, + BusinessId = instance.BusinessId, + BusinessType = instance.BusinessType, + Type = instance.Type, + NextUserId = nextUserId + }; + + await api.PostAsync(instance.MakerNotifyURL, callback); + } + /// /// 对指定的回调URL发起异步请求 /// @@ -516,7 +559,7 @@ public class FlowInstanceService : IFlowInstanceService string makerList = ""; if (wfruntime.NextNodeId == "-1") { - throw (new Exception("无法寻找到下一个节点")); + throw new Exception("无法寻找到下一个节点"); } // if (wfruntime.NextNodeType == 0) //如果是会签节点 @@ -539,7 +582,7 @@ public class FlowInstanceService : IFlowInstanceService makerList = GetNodeMarkers(wfruntime.NextNode); if (string.IsNullOrEmpty(makerList)) { - throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!")); + throw new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"); } } diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs index e24f3ee3..15c10b2c 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs @@ -108,7 +108,7 @@ public class FlowRuntime /// /// 下一个节点对象 /// - public FlowChild NextNode => NextNodeId != "-1" ? ChildNodes.First(x => x.Id == NextNodeId) : null; + public FlowChild? NextNode => NextNodeId != "-1" ? ChildNodes.First(x => x.Id == NextNodeId) : null; /// /// 上一个节点 diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/TaskCreationRequest.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/TaskCreationRequest.cs index 05080338..722a5b41 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/TaskCreationRequest.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/TaskCreationRequest.cs @@ -32,5 +32,10 @@ namespace DS.WMS.Core.Op.Dtos.TaskInteraction /// 任务描述 /// public string? TaskDescription { get; set; } + + /// + /// 任务接收用户ID;此值为空时则默认为任务发起者 + /// + public long[]? RecvUserIdList { get; set; } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTask.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTask.cs index 1a1920ea..bc8839ee 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTask.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTask.cs @@ -1,4 +1,5 @@ using DS.Module.Core; +using DS.Module.Core.Extensions; using SqlSugar; namespace DS.WMS.Core.Op.Entity.TaskInteraction @@ -51,6 +52,19 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction [SugarColumn(ColumnDescription = "工作流ID", IsNullable = true)] public long? FlowId { get; set; } + /// + /// 接收人列表 + /// + [SugarColumn(ColumnDescription = "接收人列表", IsNullable = false, ColumnDataType = "text")] + public string RecvUsers { get; set; } = string.Empty; + + /// + /// 获取接收人用户ID列表 + /// + [SugarColumn(IsIgnore = true)] + public long[] RecvUserIdArray => RecvUsers.IsNullOrEmpty() ? [] : + RecvUsers.Split([','], StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray(); + /// /// 创建人 /// diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/SeaExportTaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/SeaExportTaskService.cs index 2d516dbc..e7ec30dd 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/SeaExportTaskService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/SeaExportTaskService.cs @@ -2,8 +2,6 @@ using DS.Module.Core.Extensions; using DS.Module.DjyServiceStatus; using DS.WMS.Core.Flow.Dtos; -using DS.WMS.Core.Flow.Entity; -using DS.WMS.Core.Flow.Interface; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity.TaskInteraction; @@ -22,7 +20,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction public class SeaExportTaskService : TaskService, ISeaExportTaskService { readonly Lazy djyService; - readonly Lazy flowService; /// /// 初始化 @@ -31,39 +28,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction public SeaExportTaskService(IServiceProvider provider) : base(provider) { djyService = new Lazy(provider.GetRequiredService()); - flowService = new Lazy(provider.GetRequiredService()); - } - - /// - /// 当任务创建时调用 - /// - /// - /// - protected override async Task OnTaskCreated(BusinessTask task) - { - if (task.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) - { - //待审核,需创建工作流 - var template = await FindTemplateAsync(AuditType.SeaExport); - if (template == null) - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound)); - - var result = flowService.Value.CreateFlowInstance(new CreateFlowInstanceReq - { - BusinessId = task.BusinessId, - BusinessType = BusinessType.OceanShippingExport, - TemplateId = template.Id - }); - - if (result.Succeeded) - { - var instance = result.Data as FlowInstance; - task.FlowId = instance.Id; - await TenantDb.Updateable(task).UpdateColumns(x => x.FlowId).ExecuteCommandAsync(); - } - } - - return DataResult.Success; } /// @@ -88,7 +52,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction x.Voyno, x.ETD, }).FirstAsync(x => x.Id == first.BusinessId); - + var userList = await GetRecvUsers(first.RecvUserIdList); foreach (var item in request) { var info = new TaskManageOrderMessageInfo @@ -112,7 +76,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction TaskSource = TaskSourceEnum.WORK_FLOW, TaskUserId = User.UserId, TaskUserName = User.UserName, - RecvUserInfoList = [new RecvUserInfo { RecvUserId = long.Parse(User.UserId), RecvUserName = User.UserName }], + RecvUserInfoList = userList, TaskTenatId = tenatId, TaskTenatName = tenatName } @@ -149,18 +113,19 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction //放舱结束,根据业务所选服务,生成子任务 if (request.TaskType == TaskBaseTypeEnum.WAIT_SPACE_RELEASE && request.TaskStatus == TaskStatusEnum.Complete) { - var list = await GetSubRequestAsync(request.BusinessId, request.BusinessType); + var task = await GetTaskAsync(request.BusinessId, request.BusinessType, request.TaskType); + var list = await GetSubRequestAsync(request.BusinessId, request.BusinessType, task?.RecvUserIdArray); await CreateSubTaskAsync(list); } } - internal async Task GetSubRequestAsync(long id, BusinessType businessType) + internal async Task GetSubRequestAsync(long id, BusinessType businessType, params long[]? recvUsers) { var svcList = await GetServicesAsync(id); var list = new TaskCreationRequest[svcList.Length]; for (int i = 0; i < svcList.Length; i++) { - var dto = new TaskCreationRequest { BusinessId = id, BusinessType = businessType }; + var dto = new TaskCreationRequest { BusinessId = id, BusinessType = businessType, RecvUserIdList = recvUsers }; var svcName = svcList[i]; if (svcName == "报关") @@ -214,8 +179,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction await base.UpdateBusinessAsync(callback); //todo:海运出口主表信息 - - } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs index cb3dd175..564b2794 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs @@ -3,6 +3,9 @@ using DS.Module.Core.Extensions; using DS.Module.Core.Helpers; using DS.WMS.Core.Fee.Method; using DS.WMS.Core.Flow.Dtos; +using DS.WMS.Core.Flow.Entity; +using DS.WMS.Core.Flow.Interface; +using DS.WMS.Core.Flow.Method; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity.TaskInteraction; @@ -28,6 +31,11 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// protected ITaskManageService ManagerService { get; private set; } + /// + /// 工作流服务 + /// + protected Lazy FlowService { get; private set; } + /// /// 初始化 /// @@ -35,6 +43,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction protected TaskService(IServiceProvider provider) : base(provider) { ManagerService = provider.GetRequiredService(); + FlowService = new Lazy(provider.GetRequiredService()); } /// @@ -97,13 +106,20 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction TaskDesp = request.TaskDescription, TaskUserId = User.UserId, TaskUserName = User.UserName, - RecvUserId = User.UserId, - RecvUserName = User.UserName, TaskTenatId = tenatId, TaskTenatName = tenatName } }; + if (request.RecvUserIdList == null || request.RecvUserIdList.Length == 0) + { + info.Main.RecvUserInfoList = [new RecvUserInfo { RecvUserId = long.Parse(User.UserId), RecvUserName = User.UserName }]; + } + else + { + info.Main.RecvUserInfoList = await GetRecvUsers(request.RecvUserIdList); + } + if (info.Main.TaskTitle.IsNullOrEmpty()) { var biz = await TenantDb.Queryable().Select(x => new @@ -133,12 +149,50 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction BusinessType = request.BusinessType, TaskType = request.TaskType, TaskStatus = TaskStatusEnum.Create, + RecvUsers = string.Join(',', info.Main.RecvUserInfoList.Select(x => x.RecvUserId)), CreateBy = long.Parse(User.UserId), CreateTime = DateTime.Now }; task.NextType = GetNextType(task); await TenantDb.Insertable(task).ExecuteCommandAsync(); + //待审核,需创建工作流 + if (task.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) + { + var template = await FindTemplateAsync(AuditType.SeaExport); + if (template == null) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound)); + + result = FlowService.Value.CreateFlowInstance(new CreateFlowInstanceReq + { + BusinessId = task.BusinessId, + BusinessType = BusinessType.OceanShippingExport, + TemplateId = template.Id + }); + //创建并启动实例 + if (result.Succeeded) + { + var instance = result.Data as FlowInstance; + task.FlowId = instance.Id; + await TenantDb.Updateable(task).UpdateColumns(x => x.FlowId).ExecuteCommandAsync(); + + result = FlowService.Value.StartFlowInstance(instance.Id.ToString()); + //工作流为会签,需要更新任务接收人 + if (result.Succeeded && instance.ActivityType == 0) + { + var marker = FlowInstanceService.GetNextMarker(instance); + await UpdateReceiverAsync(new MakerChangedCallback + { + BusinessId = request.BusinessId, + BusinessType = request.BusinessType, + InstanceId = instance.Id, + Type = instance.Type, + NextUserId = long.Parse(marker) + }); + } + } + } + result = await OnTaskCreated(task); if (!result.Succeeded) return result; @@ -197,7 +251,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction await OnTaskStatusChanged(request); task.TaskStatus = request.TaskStatus; - await TenantDb.Updateable(task).UpdateColumns(x => x.TaskStatus).ExecuteCommandAsync(); + if (task.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) + task.FlowId = null; + + await TenantDb.Updateable(task).UpdateColumns(x => new { x.TaskStatus, x.FlowId }).ExecuteCommandAsync(); if (task.TaskStatus == TaskStatusEnum.Complete) { @@ -208,7 +265,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction { BusinessId = request.BusinessId, BusinessType = request.BusinessType, - TaskType = task.NextType.Value + TaskType = task.NextType.Value, + RecvUserIdList = task.RecvUserIdArray, }; await CreateTaskAsync(req, false); } @@ -239,6 +297,19 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction return Task.CompletedTask; } + /// + /// 通知更新任务接收人 + /// + /// 回调信息 + /// + /// 为null时引发 + public virtual async Task UpdateReceiverAsync(MakerChangedCallback callback) + { + ArgumentNullException.ThrowIfNull(callback, nameof(callback)); + + + } + /// /// 审批完成回调更新 /// @@ -257,6 +328,19 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction TaskType = TaskBaseTypeEnum.WAIT_ORDER_AUDIT, TaskStatus = TaskStatusEnum.Complete }); + + if (callback.FlowStatus == FlowStatusEnum.Reject) + { + //创建审单驳回任务以进行通知 + var task = await GetTaskAsync(callback.BusinessId, callback.BusinessType.GetValueOrDefault(), TaskBaseTypeEnum.WAIT_ORDER_AUDIT); + await CreateTaskAsync(new TaskCreationRequest + { + BusinessId = callback.BusinessId, + BusinessType = callback.BusinessType.GetValueOrDefault(), + TaskType = TaskBaseTypeEnum.ORDER_AUDIT_REJECTED, + RecvUserIdList = task.RecvUserIdArray + }); + } } /// @@ -288,5 +372,16 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction return (TaskBaseTypeEnum)currentTypeVal++; } + + /// + /// 获取任务接收用户列表 + /// + /// 用户ID + /// + protected internal async Task> GetRecvUsers(params long[] ids) + { + return await Db.Queryable().Where(x => ids.Contains(x.Id)).Select( + x => new RecvUserInfo { RecvUserId = x.Id, RecvUserName = x.UserName }).ToListAsync(); + } } } diff --git a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user index da141c5a..fb7be066 100644 --- a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user +++ b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user @@ -1,7 +1,7 @@  - E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml + D:\Source\Repos\DS8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml MvcControllerEmptyScaffolder root/Common/MVC/Controller