|
|
|
@ -489,8 +489,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// 发起任务审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <param name="useTransaction">是否使用事务</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> SubmitAuditAsync(TaskRequest request)
|
|
|
|
|
public async Task<DataResult> SubmitAuditAsync(TaskRequest request, bool useTransaction = true)
|
|
|
|
|
{
|
|
|
|
|
var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
|
|
|
|
|
if (task == null)
|
|
|
|
@ -510,7 +511,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var req = new TaskUpdateRequest
|
|
|
|
@ -537,12 +540,17 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
|
|
|
|
|
//记录日志
|
|
|
|
|
await LogService.WriteLogAsync(req, "重新审批");
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
return result2;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
@ -555,8 +563,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// 撤销审核任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <param name="useTransaction">是否使用事务</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> WithdrawAsync(TaskRequest request)
|
|
|
|
|
public async Task<DataResult> WithdrawAsync(TaskRequest request, bool useTransaction = true)
|
|
|
|
|
{
|
|
|
|
|
var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).Select(x => new
|
|
|
|
|
{
|
|
|
|
@ -574,7 +583,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInFlows));
|
|
|
|
|
|
|
|
|
|
DateTime dt = DateTime.Now;
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, TaskStatusEnum.Cancel, dt);
|
|
|
|
@ -599,12 +611,16 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
TaskType = request.TaskType
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
@ -614,56 +630,54 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// 任务审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(TaskAuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
long id = request.Ids[0];
|
|
|
|
|
var task = await GetQuery(id, request.BusinessType.GetValueOrDefault(), request.TaskType).FirstAsync();
|
|
|
|
|
if (task == null)
|
|
|
|
|
var tasks = 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 (tasks.Count == 0)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
|
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Complete)
|
|
|
|
|
if (tasks.Exists(x => x.TaskStatus == TaskStatusEnum.Complete))
|
|
|
|
|
{
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
|
|
|
|
|
}
|
|
|
|
|
else if (task.TaskStatus != TaskStatusEnum.Create && task.TaskStatus != TaskStatusEnum.Pending)
|
|
|
|
|
else if (tasks.Exists(x => x.TaskStatus != TaskStatusEnum.Create && x.TaskStatus != TaskStatusEnum.Pending))
|
|
|
|
|
{
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskAuditStatusError));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (task.FlowId == null)
|
|
|
|
|
if (tasks.Exists(x => x.FlowId == null))
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound));
|
|
|
|
|
|
|
|
|
|
DataResult result;
|
|
|
|
|
var flowInstance = await Db.Queryable<FlowInstance>().FirstAsync(x => x.Id == task.FlowId.Value);
|
|
|
|
|
//如果当前审批为终审,则调用规则库进行校验
|
|
|
|
|
if (task.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && flowInstance.GetMarkerList().Length == 1)
|
|
|
|
|
DataResult result = DataResult.Success;
|
|
|
|
|
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 CheckRulesAsync(id, request.BusinessType.GetValueOrDefault(), RuleEngineType.COMMON_OCEAN_BOOKING);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//如果当前审批为终审,则调用规则库进行校验
|
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && instance.GetMarkerList().Length == 1)
|
|
|
|
|
{
|
|
|
|
|
result = await CheckRulesAsync(instance.BusinessId, request.BusinessType.GetValueOrDefault(), RuleEngineType.COMMON_OCEAN_BOOKING);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = FlowService.Value.AuditFlowInstance(new FlowAuditInfo
|
|
|
|
|
{
|
|
|
|
|
AuditNote = request.Remark,
|
|
|
|
|
Status = request.Result,
|
|
|
|
|
Instance = flowInstance
|
|
|
|
|
});
|
|
|
|
|
result = FlowService.Value.AuditFlowInstance(new FlowAuditInfo
|
|
|
|
|
{
|
|
|
|
|
AuditNote = request.Remark,
|
|
|
|
|
Status = request.Result,
|
|
|
|
|
Instance = instance
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var flow = await Db.Queryable<FlowInstance>().Where(x => x.Id == task.FlowId.Value).Select(x => new FlowInstance
|
|
|
|
|
{
|
|
|
|
|
FlowStatus = x.FlowStatus,
|
|
|
|
|
MakerList = x.MakerList,
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
////终审通过且任务类型为审单,则生成费用
|
|
|
|
|
//if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && flow.FlowStatus == FlowStatusEnum.Approve && flow.IsCompleted)
|
|
|
|
|
//{
|
|
|
|
|
// FeeTemplateService.Value.GenerateFeesAsync(request.Ids[0], request.BusinessType.GetValueOrDefault());
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
////终审通过且任务类型为审单,则生成费用
|
|
|
|
|
//if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && flow.FlowStatus == FlowStatusEnum.Approve && flow.IsCompleted)
|
|
|
|
|
//{
|
|
|
|
|
// FeeTemplateService.Value.GenerateFeesAsync(request.Ids[0], request.BusinessType.GetValueOrDefault());
|
|
|
|
|
//}
|
|
|
|
|
result.Data = new { instance.IsCompleted, instance.FlowStatus };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Data = new { flow.IsCompleted, flow.FlowStatus };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -864,11 +878,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
return result.Succeeded ? result.Data : [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 填充用户信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids">用户ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal async Task<List<RecvUserInfo>> FillInUserInfoAsync(params long[] ids)
|
|
|
|
|
{
|
|
|
|
|
return await Db.Queryable<SysUser>().Where(x => ids.Contains(x.Id)).Select(
|
|
|
|
|