任务台执行调整

usertest
zhangxiaofeng 4 months ago
parent 28a4367ed2
commit 66064b7315

@ -809,9 +809,9 @@ namespace DS.WMS.Core.Op.Method
/// </summary>
public async Task<DataResult<long>> ApiReceiveTask(TaskFlowDataContext dataContext)
{
var a = user.UserId;
var b = user.UserName;
var c = user.TenantId;
//var a = user.UserId;
//var b = user.UserName;
//var c = user.TenantId;
var messageInfo = dataContext.Get<TaskManageOrderMessageInfo>(TaskFlowDataNameConst.TaskManageOrderMessageInfo);
if (messageInfo == null)
{
@ -1076,15 +1076,15 @@ namespace DS.WMS.Core.Op.Method
if (allCountryCodeList.Succeeded)
{
var countryInfo = allCountryCodeList.Data.FirstOrDefault(p => p.Id == portInfo.Data.CountryId);
var countryInfo = allCountryCodeList.Data.FirstOrDefault(p => p.Id == portInfo.Data?.CountryId);
dto.DataObj.PortDischargeCountry = countryInfo?.CountryEnName;
dto.DataObj.PortDischargeCountryCode = countryInfo?.CountryCode;
}
dto.DataObj.PortDischarge = portInfo.Data.PortName;
dto.DataObj.PortDischargeId = portInfo.Data.EdiCode;
dto.DataObj.PortDischarge = portInfo.Data?.PortName;
dto.DataObj.PortDischargeId = portInfo.Data?.EdiCode;

@ -2174,7 +2174,8 @@ namespace DS.WMS.Core.Op.Method
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var model = await tenantDb.Queryable<SpaceBookingOrder>()
.FirstAsync(a => a.BookingReference == mblno && a.Deleted == false);
.Where(a => a.BookingReference == mblno && a.Deleted == false)
.FirstAsync();
//预订舱数据不存在或已作废
if (model == null)

@ -183,6 +183,7 @@ namespace DS.WMS.Core.TaskPlat
{
ConfigId = configItem.Id,
PId = flowLog.Id,
IsSuccess = true,
};
try
{
@ -227,8 +228,10 @@ namespace DS.WMS.Core.TaskPlat
{
throw new Exception($"在依赖注入容器未找到Interface【{module.InterfaceName}】的实现类");
}
var impType = imp.GetType();
MethodInfo? method = imp.GetType().GetMethod(module.MethodName!);
MethodInfo? method = impType.GetMethod(module.MethodName!, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method == null)
{
throw new Exception($"在Interface【{module.InterfaceName}】的实现类中未找到Method【{module.MethodName}】");
@ -236,33 +239,45 @@ namespace DS.WMS.Core.TaskPlat
Stopwatch stopwatch = Stopwatch.StartNew();
var resultTemp = method.Invoke(imp, new object[] { dataContext });
if (resultTemp is DataResult result1 && result1 != null)
var taskObj = method.Invoke(imp, new object[] { dataContext })!;
if (taskObj is Task task)
{
flowLogDetail.ExecuteReturn = JsonConvert.SerializeObject(result1);
flowLogDetail.IsSuccess = result1.Succeeded;
await task;
if (!result1.Succeeded)
if (task.IsFaulted)
{
flowLog.IsSuccess = false;
if (task.Exception != null)
{
throw task.Exception;
}
else
{
throw new Exception("模块执行过程中发生未知异常但是Exception为null请检查");
}
}
}
else if (resultTemp is Task<DataResult> result2 && result2 != null && result2.IsCompleted)
{
flowLogDetail.ExecuteReturn = JsonConvert.SerializeObject(result2.Result);
flowLogDetail.IsSuccess = result2.Result.Succeeded;
if (!result2.Result.Succeeded)
dynamic dynamicTask = task;
if (dynamicTask.Result != null)
{
flowLog.IsSuccess = false;
flowLogDetail.ExecuteReturn = JsonConvert.SerializeObject(dynamicTask.Result);
var isSuccess = dynamicTask.Result.Succeeded;
if (isSuccess != null && isSuccess is bool)
{
flowLogDetail.IsSuccess = isSuccess;
if (isSuccess == false)
{
flowLog.IsSuccess = false;
}
}
}
}
else if (resultTemp is Task result3)
else
{
if (result3.Exception != null && result3.IsFaulted)
{
throw result3.Exception;
}
throw new Exception("模块执行结果不是Task类型请检查");
// 后面支持非异步
}
stopwatch.Stop();
flowLogDetail.ElapsedMillisecond = stopwatch.ElapsedMilliseconds;

Loading…
Cancel
Save