|
|
|
@ -19,6 +19,7 @@ using DS.WMS.Core.TaskPlat;
|
|
|
|
|
using DS.WMS.Core.TaskPlat.Dtos;
|
|
|
|
|
using DS.WMS.Core.TaskPlat.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskPlat.Interface;
|
|
|
|
|
using LanguageExt.Common;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Masuit.Tools;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
@ -115,6 +116,13 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (task != null && task.TaskStatus != TaskStatusEnum.Cancel)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists));
|
|
|
|
|
|
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
|
|
|
|
|
{
|
|
|
|
|
var result = await CheckRulesAsync(request.BusinessId, request.BusinessType);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long tenatId = long.Parse(User.TenantId);
|
|
|
|
|
string tenatName = Db.Queryable<SysTenant>().Where(x => x.Id == tenatId).Select(x => x.Name).First();
|
|
|
|
|
var info = new TaskManageOrderMessageInfo
|
|
|
|
@ -208,28 +216,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
//审核任务需创建工作流
|
|
|
|
|
if (AuditTaskTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
|
|
|
|
|
{
|
|
|
|
|
var rulesReq = new RuleEngineReq();
|
|
|
|
|
rulesReq.Head.MessageType = "BUSI_RULE";
|
|
|
|
|
rulesReq.Head.SenderId = "NewOceanBooking";
|
|
|
|
|
rulesReq.Head.RequestAction = "CheckRule";
|
|
|
|
|
rulesReq.Main.ProjectCode = ["COMMON_OCEAN_BOOKING"];
|
|
|
|
|
|
|
|
|
|
var order = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == request.BusinessId).FirstAsync();
|
|
|
|
|
rulesReq.Main.BusinessInfo = info.Adapt<RulesEngineOrderBookingMainBusinessInfo>();
|
|
|
|
|
|
|
|
|
|
var ruleResult = await RuleEngineService.Value.ExecuteSeaExportAuditRulesAsync(rulesReq);
|
|
|
|
|
if (ruleResult?.Extra.DetailList?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (var item in ruleResult?.Extra.DetailList)
|
|
|
|
|
sb.Append(item.ResultName);
|
|
|
|
|
|
|
|
|
|
return DataResult.Failed(sb.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = await CreateAndStartWorkflow(task);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
@ -472,8 +458,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Complete)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
|
|
|
|
|
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Pending || task.TaskStatus == TaskStatusEnum.Create)
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Pending)
|
|
|
|
|
{
|
|
|
|
|
var result = await CheckRulesAsync(request.BusinessId, request.BusinessType);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -486,7 +476,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
TaskTypeName = request.TaskTypeName
|
|
|
|
|
};
|
|
|
|
|
//重置任务为待处理
|
|
|
|
|
var result = await SetTaskStatusAsync(req, false);
|
|
|
|
|
result = await SetTaskStatusAsync(req, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return DataResult.Failed(result.Message, result.MultiCode);
|
|
|
|
|
|
|
|
|
@ -560,11 +550,21 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (task.FlowId == null)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound));
|
|
|
|
|
|
|
|
|
|
var result = FlowService.Value.AuditFlowInstance(new FlowAuditInfo
|
|
|
|
|
DataResult result;
|
|
|
|
|
var flowInstance = await Db.Queryable<FlowInstance>().FirstAsync(x => x.Id == task.FlowId.Value);
|
|
|
|
|
//如果当前审批为终审,则调用规则库进行校验
|
|
|
|
|
if (flowInstance.GetMarkerList().Length == 1)
|
|
|
|
|
{
|
|
|
|
|
result = await CheckRulesAsync(id, request.BusinessType.GetValueOrDefault());
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = FlowService.Value.AuditFlowInstance(new FlowAuditInfo
|
|
|
|
|
{
|
|
|
|
|
AuditNote = request.Remark,
|
|
|
|
|
Status = request.Result,
|
|
|
|
|
Instance = await Db.Queryable<FlowInstance>().FirstAsync(x => x.Id == task.FlowId.Value)
|
|
|
|
|
Instance = flowInstance
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var flow = await Db.Queryable<FlowInstance>().Where(x => x.Id == task.FlowId.Value).Select(x => new FlowInstance
|
|
|
|
@ -673,6 +673,29 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async Task<DataResult> CheckRulesAsync(long bsId, BusinessType businessType)
|
|
|
|
|
{
|
|
|
|
|
var rulesReq = new RuleEngineReq();
|
|
|
|
|
var order = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == bsId).FirstAsync();
|
|
|
|
|
rulesReq.Main.BusinessInfo = order.Adapt<RulesEngineOrderBookingMainBusinessInfo>();
|
|
|
|
|
|
|
|
|
|
var ruleResult = await RuleEngineService.Value.ExecuteSeaExportAuditRulesAsync(rulesReq);
|
|
|
|
|
if (string.Equals(ruleResult.Succ, bool.FalseString, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed(ruleResult.Msg);
|
|
|
|
|
}
|
|
|
|
|
else if (ruleResult.Extra.DetailList?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (var item in ruleResult?.Extra.DetailList)
|
|
|
|
|
sb.Append(item.ResultName);
|
|
|
|
|
|
|
|
|
|
return DataResult.Failed(sb.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取给定任务的下一任务类型
|
|
|
|
|
/// </summary>
|
|
|
|
|