|
|
|
@ -185,19 +185,19 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> CreateTaskAsync(TaskCreationRequest request, bool useTransaction = true)
|
|
|
|
|
{
|
|
|
|
|
//if (request.BusinessType.HasValue)
|
|
|
|
|
//{
|
|
|
|
|
// bool isBizValid = false;
|
|
|
|
|
// switch (request.BusinessType.Value)
|
|
|
|
|
// {
|
|
|
|
|
// case BusinessType.OceanShippingExport:
|
|
|
|
|
// isBizValid = await TenantDb.Queryable<SeaExport>().AnyAsync(x => x.Id == request.BusinessId);
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
if (request.BusinessType.HasValue)
|
|
|
|
|
{
|
|
|
|
|
bool isBizValid = false;
|
|
|
|
|
switch (request.BusinessType.Value)
|
|
|
|
|
{
|
|
|
|
|
case BusinessType.OceanShippingExport:
|
|
|
|
|
isBizValid = await TenantDb.Queryable<SeaExport>().AnyAsync(x => x.Id == request.BusinessId);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (!isBizValid)
|
|
|
|
|
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Biz_Not_Valid));
|
|
|
|
|
//}
|
|
|
|
|
if (!isBizValid)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Biz_Not_Valid));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!await HasAuthorizedAsync())
|
|
|
|
@ -248,11 +248,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderMessageInfo? info = null;
|
|
|
|
|
if (task == null)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
info = new TaskManageOrderMessageInfo
|
|
|
|
|
{
|
|
|
|
|
Head = new TaskManageOrderMessageHeadInfo
|
|
|
|
|
{
|
|
|
|
@ -288,7 +289,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
else if (AuditTaskTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
//审核类型默认为提交人,生成工作流后替换为工作流执行人
|
|
|
|
|
//审核任务默认为提交人,生成工作流后替换为工作流执行人
|
|
|
|
|
info.Main.RecvUserInfoList = await FillInUserInfoAsync(long.Parse(User.UserId));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -296,9 +297,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
info.Main.RecvUserInfoList = await FillInUserInfoAsync(request.RecvUserIdList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (info.Main.RecvUserInfoList == null || info.Main.RecvUserInfoList.Count == 0)
|
|
|
|
|
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskReceiverNotFound));
|
|
|
|
|
|
|
|
|
|
//仅为业务订单任务自动填充任务标题/描述
|
|
|
|
|
if (info.Main.TaskTitle.IsNullOrEmpty() && IsOrderType(request.TaskType))
|
|
|
|
|
{
|
|
|
|
@ -347,30 +345,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
info.Main.TaskDesp = info.Main.TaskDesp ?? info.Main.TaskTitle;
|
|
|
|
|
|
|
|
|
|
//费用审核需拆分任务
|
|
|
|
|
if (FeeTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
var fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == request.BusinessId)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
var recvUserList = new List<RecvUserInfo>(info.Main.RecvUserInfoList); //复制接收人列表
|
|
|
|
|
foreach (var item in recvUserList)
|
|
|
|
|
{
|
|
|
|
|
var copiedInfo = info.DeepClone();
|
|
|
|
|
copiedInfo.Head.BSNO = fee.BusinessId; //替换为费用关联的订单ID
|
|
|
|
|
|
|
|
|
|
copiedInfo.Main.RecvUserInfoList.Clear();
|
|
|
|
|
copiedInfo.Main.RecvUserInfoList.Add(item);
|
|
|
|
|
|
|
|
|
|
result = await ManagerService.InitTaskJob(copiedInfo);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (!FeeTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
result = await ManagerService.InitTaskJob(info);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
@ -422,6 +397,33 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else if (FeeTypes.Contains(request.TaskType)) //费用审核需拆分任务
|
|
|
|
|
{
|
|
|
|
|
var instance = result.Data as FlowInstance;
|
|
|
|
|
var ids = FlowInstanceService.GetMarkers(instance).Select(long.Parse).ToArray();
|
|
|
|
|
var recvUserList = await FillInUserInfoAsync(ids);
|
|
|
|
|
|
|
|
|
|
var fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == request.BusinessId)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
foreach (var item in recvUserList)
|
|
|
|
|
{
|
|
|
|
|
var copiedInfo = info.DeepClone();
|
|
|
|
|
copiedInfo.Head.BSNO = fee.BusinessId; //替换为费用关联的订单ID
|
|
|
|
|
copiedInfo.Main.RecvUserInfoList.Clear();
|
|
|
|
|
copiedInfo.Main.RecvUserInfoList.Add(item);
|
|
|
|
|
|
|
|
|
|
result = await ManagerService.InitTaskJob(copiedInfo);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
await Db.Deleteable(instance).ExecuteCommandAsync();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (useTransaction)
|
|
|
|
@ -434,6 +436,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
|
|
|
|
|
if (result.Data is FlowInstance instance)
|
|
|
|
|
await Db.Deleteable(instance).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
@ -480,7 +485,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
result = FlowService.Value.StartFlowInstance(instance.Id.ToString());
|
|
|
|
|
instance = result.Data as FlowInstance;
|
|
|
|
|
|
|
|
|
|
if (result.Succeeded && changeMarker)
|
|
|
|
|
if (result.Succeeded && changeMarker && !FeeTypes.Contains(task.TaskType))
|
|
|
|
|
{
|
|
|
|
|
string[] ids = FlowInstanceService.GetMarkers(instance);
|
|
|
|
|
//变更任务接收人为所有审批执行人
|
|
|
|
|