|
|
|
@ -61,14 +61,14 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (currentTypeVal >= 300) //300开始的枚举值为可选服务项目,不存在前后关联性
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
return (TaskBaseTypeEnum)currentTypeVal++;
|
|
|
|
|
return (TaskBaseTypeEnum)(currentTypeVal + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 确保任务交互模块已授权
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected virtual async Task<bool> EnsureModuleAuthorized()
|
|
|
|
|
protected virtual async Task<bool> EnsureModuleAuthorized()
|
|
|
|
|
{
|
|
|
|
|
//if (!await Db.Queryable<SysPermissionTenant>().AnyAsync(x => x.PermissionId == PERMISSION_ID))
|
|
|
|
|
// return false;
|
|
|
|
@ -85,39 +85,59 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务审核
|
|
|
|
|
/// 发起任务审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async virtual Task<DataResult> AuditAsync(AuditRequest request)
|
|
|
|
|
public async Task<DataResult> SubmitAuditAsync(TaskRequest request)
|
|
|
|
|
{
|
|
|
|
|
long id = request.Ids[0];
|
|
|
|
|
var task = await GetQuery(id, request.BusinessType.GetValueOrDefault(), TaskBaseTypeEnum.WAIT_ORDER_AUDIT).FirstAsync();
|
|
|
|
|
var task = await GetQuery(request.BusinessId, request.BusinessType, TaskBaseTypeEnum.WAIT_ORDER_AUDIT).FirstAsync();
|
|
|
|
|
if (task == null)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Complete)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
|
|
|
|
|
}
|
|
|
|
|
else if (task.TaskStatus == TaskStatusEnum.Pending) //二次审核
|
|
|
|
|
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Pending || task.TaskStatus == TaskStatusEnum.Create)
|
|
|
|
|
{
|
|
|
|
|
//重新创建工作流
|
|
|
|
|
//创建&启动工作流
|
|
|
|
|
var result = await Create_StartWorkflow(task);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
var flow = result.Data as FlowInstance;
|
|
|
|
|
//更新当前任务的工作流ID
|
|
|
|
|
task.FlowId = flow?.Id;
|
|
|
|
|
await TenantDb.Updateable(task).UpdateColumns(x => new { x.FlowId }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
return FlowService.Value.AuditFlowInstance(new FlowAuditInfo
|
|
|
|
|
if (task.TaskStatus != TaskStatusEnum.Create)
|
|
|
|
|
{
|
|
|
|
|
AuditNote = request.Remark,
|
|
|
|
|
Status = request.Result,
|
|
|
|
|
Instance = flow
|
|
|
|
|
});
|
|
|
|
|
await TenantDb.Updateable<BusinessTask>().SetColumns(x => x.TaskStatus == TaskStatusEnum.Create)
|
|
|
|
|
.Where(x => x.BusinessId == request.BusinessId &&
|
|
|
|
|
x.BusinessType == request.BusinessType && x.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
|
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskStatusNotSupported));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(AuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
long id = request.Ids[0];
|
|
|
|
|
var task = await GetQuery(id, request.BusinessType.Value, TaskBaseTypeEnum.WAIT_ORDER_AUDIT).FirstAsync();
|
|
|
|
|
if (task == null)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
|
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Complete)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
|
|
|
|
|
}
|
|
|
|
|
else if (task.TaskStatus != TaskStatusEnum.Create && task.TaskStatus != TaskStatusEnum.Pending)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskAuditStatusError));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (task.FlowId == null)
|
|
|
|
@ -253,7 +273,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="task"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal async Task<DataResult> Create_StartWorkflow(BusinessTask task)
|
|
|
|
|
protected internal async Task<DataResult> Create_StartWorkflow(BusinessTask task)
|
|
|
|
|
{
|
|
|
|
|
var template = await FindTemplateAsync(AuditType.SeaExport);
|
|
|
|
|
if (template == null)
|
|
|
|
@ -274,17 +294,18 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
|
|
|
|
|
result = FlowService.Value.StartFlowInstance(instance.Id.ToString());
|
|
|
|
|
instance = result.Data as FlowInstance;
|
|
|
|
|
//工作流为会签,需要更新任务接收人
|
|
|
|
|
if (result.Succeeded && instance.ActivityType == 0)
|
|
|
|
|
|
|
|
|
|
if (result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
var marker = FlowInstanceService.GetNextMarker(instance);
|
|
|
|
|
string[] ids = FlowInstanceService.GetNextMarkers(instance);
|
|
|
|
|
//变更任务接收人为审批执行人
|
|
|
|
|
await UpdateReceiverAsync(new MakerChangedCallback
|
|
|
|
|
{
|
|
|
|
|
BusinessId = task.BusinessId,
|
|
|
|
|
BusinessType = task.BusinessType,
|
|
|
|
|
InstanceId = instance.Id,
|
|
|
|
|
Type = instance.Type,
|
|
|
|
|
NextUserId = long.Parse(marker)
|
|
|
|
|
NextUserId = ids.Select(long.Parse).ToArray()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -395,16 +416,15 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (callback.NextUserId == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var users = await GetRecvUsers(callback.NextUserId.Value);
|
|
|
|
|
var users = await GetRecvUsers(callback.NextUserId);
|
|
|
|
|
var result = await ManagerService.TransferTask(callback.BusinessId, TaskBaseTypeEnum.WAIT_ORDER_AUDIT, users);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
//记录日志
|
|
|
|
|
await new ApplicationException("任务API调用失败:" + result.Message).LogAsync(Db);
|
|
|
|
|
await new ApplicationException($"任务API({nameof(ManagerService.TransferTask)})调用失败:" + result.Message).LogAsync(Db);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string recvUser = callback.NextUserId.Value.ToString();
|
|
|
|
|
string recvUser = string.Join(',', callback.NextUserId);
|
|
|
|
|
await TenantDb.Updateable<BusinessTask>().Where(x => x.BusinessId == callback.BusinessId &&
|
|
|
|
|
x.BusinessType == callback.BusinessType && x.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
|
|
|
|
|
.SetColumns(x => x.RecvUsers == recvUser)
|
|
|
|
@ -425,7 +445,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
await SetTaskStatusAsync(new TaskUpdateRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = callback.BusinessId,
|
|
|
|
|
BusinessType = callback.BusinessType.GetValueOrDefault(),
|
|
|
|
|
BusinessType = callback.BusinessType.Value,
|
|
|
|
|
TaskType = TaskBaseTypeEnum.WAIT_ORDER_AUDIT,
|
|
|
|
|
TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
|
|
|
|
|
AutoCreateNext = callback.FlowStatus == FlowStatusEnum.Approve
|
|
|
|
@ -434,7 +454,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
{
|
|
|
|
|
//创建审单驳回任务以进行通知
|
|
|
|
|
var task = await GetQuery(callback.BusinessId, callback.BusinessType.GetValueOrDefault(), TaskBaseTypeEnum.WAIT_ORDER_AUDIT).FirstAsync();
|
|
|
|
|
var task = await GetQuery(callback.BusinessId, callback.BusinessType.Value, TaskBaseTypeEnum.WAIT_ORDER_AUDIT).FirstAsync();
|
|
|
|
|
await CreateTaskAsync(new TaskCreationRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = callback.BusinessId,
|
|
|
|
|