|
|
|
@ -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
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected ITaskManageService ManagerService { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作流服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected Lazy<IClientFlowInstanceService> FlowService { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
@ -35,6 +43,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
protected TaskService(IServiceProvider provider) : base(provider)
|
|
|
|
|
{
|
|
|
|
|
ManagerService = provider.GetRequiredService<ITaskManageService>();
|
|
|
|
|
FlowService = new Lazy<IClientFlowInstanceService>(provider.GetRequiredService<IClientFlowInstanceService>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -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<SeaExport>().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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通知更新任务接收人
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="callback">回调信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="ArgumentNullException"><paramref name="callback"/>为null时引发</exception>
|
|
|
|
|
public virtual async Task UpdateReceiverAsync(MakerChangedCallback callback)
|
|
|
|
|
{
|
|
|
|
|
ArgumentNullException.ThrowIfNull(callback, nameof(callback));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 审批完成回调更新
|
|
|
|
|
/// </summary>
|
|
|
|
@ -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
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -288,5 +372,16 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
|
|
|
|
|
return (TaskBaseTypeEnum)currentTypeVal++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取任务接收用户列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids">用户ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal async Task<List<RecvUserInfo>> GetRecvUsers(params long[] ids)
|
|
|
|
|
{
|
|
|
|
|
return await Db.Queryable<SysUser>().Where(x => ids.Contains(x.Id)).Select(
|
|
|
|
|
x => new RecvUserInfo { RecvUserId = x.Id, RecvUserName = x.UserName }).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|