|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
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.Op.Dtos.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Entity.TaskInteraction;
|
|
|
|
@ -19,6 +22,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
public class SeaExportTaskService : FeeServiceBase
|
|
|
|
|
{
|
|
|
|
|
ITaskManageService taskService;
|
|
|
|
|
Lazy<IClientFlowInstanceService> flowService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
@ -27,6 +31,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
public SeaExportTaskService(IServiceProvider provider) : base(provider)
|
|
|
|
|
{
|
|
|
|
|
taskService = provider.GetRequiredService<ITaskManageService>();
|
|
|
|
|
flowService = new Lazy<IClientFlowInstanceService>(provider.GetRequiredService<IClientFlowInstanceService>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -93,7 +98,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
var businessTask = new BusinessTask
|
|
|
|
|
task = new BusinessTask
|
|
|
|
|
{
|
|
|
|
|
BusinessId = request.BusinessId,
|
|
|
|
|
BusinessType = request.BusinessType,
|
|
|
|
@ -102,20 +107,32 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
CreateBy = long.Parse(User.UserId),
|
|
|
|
|
CreateTime = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
businessTask.NextType = GetNextType(businessTask);
|
|
|
|
|
await TenantDb.Insertable(businessTask).ExecuteCommandAsync();
|
|
|
|
|
task.NextType = GetNextType(task);
|
|
|
|
|
await TenantDb.Insertable(task).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
|
|
|
|
|
{
|
|
|
|
|
//待审核,需创建工作流
|
|
|
|
|
var template = await FindTemplateAsync(AuditType.SeaExport);
|
|
|
|
|
if (template == null)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (request.TaskType == TaskBaseTypeEnum.WAIT_BILL_CONFIRM)
|
|
|
|
|
result = flowService.Value.CreateFlowInstance(new CreateFlowInstanceReq
|
|
|
|
|
{
|
|
|
|
|
//根据业务所选服务,生成子任务
|
|
|
|
|
BusinessId = request.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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -160,6 +177,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
await CreateTaskAsync(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//放舱结束,根据业务所选服务,生成子任务
|
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.WAIT_SPACE_RELEASE)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -184,12 +207,20 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
.OrderByDescending(x => x.CreateTime).Take(1).FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取给定任务的下一任务类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="current">任务信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal static TaskBaseTypeEnum? GetNextType(BusinessTask current)
|
|
|
|
|
{
|
|
|
|
|
if (current.TaskType == TaskBaseTypeEnum.WAIT_VGM)
|
|
|
|
|
if (current.TaskType == TaskBaseTypeEnum.WAIT_CHECKOUT_BILL)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
int currentTypeVal = (int)current.TaskType;
|
|
|
|
|
if (currentTypeVal >= 300) //300开始的枚举值为可选服务项目,不存在前后关联性
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
return (TaskBaseTypeEnum)currentTypeVal++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|