|
|
|
@ -0,0 +1,102 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Dtos;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 申请类审核任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ApplicationTaskService : TaskService, IApplicationTaskService
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="provider"></param>
|
|
|
|
|
public ApplicationTaskService(IServiceProvider provider) : base(provider)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async override Task<DataResult> AuditAsync(TaskAuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
var tasksList = await TenantDb.Queryable<BusinessTask>().Where(x => x.TaskType == request.TaskType && request.Ids.Contains(x.BusinessId))
|
|
|
|
|
.WhereIF(request.BusinessType.HasValue, x => x.BusinessType == request.BusinessType.Value).ToListAsync();
|
|
|
|
|
if (tasksList.Count == 0)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
|
|
|
|
|
if (tasksList.Count != request.Ids.Length)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCountNotMatch));
|
|
|
|
|
|
|
|
|
|
if (tasksList.Exists(x => x.TaskStatus != TaskStatusEnum.Create && x.TaskStatus != TaskStatusEnum.Pending && x.TaskStatus != TaskStatusEnum.Complete))
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskAuditStatusError));
|
|
|
|
|
|
|
|
|
|
DataResult result = DataResult.Success;
|
|
|
|
|
var tasks = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Create);
|
|
|
|
|
var task2 = tasksList.FindAll(x => x.TaskStatus == TaskStatusEnum.Complete);
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//状态待审核的任务
|
|
|
|
|
if (tasks.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var flowIds = tasks.Select(x => x.FlowId.Value);
|
|
|
|
|
var flowInstances = await Db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
|
|
|
|
|
foreach (var instance in flowInstances)
|
|
|
|
|
{
|
|
|
|
|
result = await FlowService.Value.AuditAsync(new FlowAuditInfo
|
|
|
|
|
{
|
|
|
|
|
AuditNote = request.Remark,
|
|
|
|
|
Status = request.Result,
|
|
|
|
|
Instance = instance
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
var req = new TaskUpdateRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = instance.BusinessId,
|
|
|
|
|
BusinessType = instance.BusinessType,
|
|
|
|
|
RejectReason = request.Remark,
|
|
|
|
|
TaskTypeName = request.TaskType.ToString(),
|
|
|
|
|
TaskStatus = request.Result == 1 ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
|
|
|
|
|
AutoCreateNext = true
|
|
|
|
|
};
|
|
|
|
|
//根据审批结果更新任务状态
|
|
|
|
|
await SetTaskStatusAsync(req, false);
|
|
|
|
|
|
|
|
|
|
if (instance.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
result.Message = request.Remark!;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//已完成审核的任务
|
|
|
|
|
if (task2.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
switch (request.TaskType)
|
|
|
|
|
{
|
|
|
|
|
case TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|