修改小伙纸比对

optimize
jianghaiqing 2 years ago
parent e277105098
commit ec65b2ed1d

@ -31,10 +31,15 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public int total { get; set; } public int total { get; set; }
/// <summary>
/// 当前页列表数据
/// </summary>
public object rows { get; set; }
/// <summary> /// <summary>
/// 比对详情 /// 比对详情
/// </summary> /// </summary>
public CompareResultDetailInfo extra { get; set; } public CompareResultInfo extra { get; set; }
/// <summary> /// <summary>
/// 比对展示详情 /// 比对展示详情

@ -119,25 +119,23 @@ namespace Myshipping.Application
DateTime bDate = DateTime.Now; DateTime bDate = DateTime.Now;
var ruleResult = await ExcuteCompare(msgModel); var compareResult = await ExcuteCompare(msgModel);
DateTime eDate = DateTime.Now; DateTime eDate = DateTime.Now;
TimeSpan ts = eDate.Subtract(bDate); TimeSpan ts = eDate.Subtract(bDate);
var timeDiff = ts.TotalMilliseconds; var timeDiff = ts.TotalMilliseconds;
_logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg}", batchNo, timeDiff, ruleResult.succ ? "成功" : "失败"); _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg}", batchNo, timeDiff, compareResult.succ ? "成功" : "失败");
if (ruleResult == null) if (compareResult == null)
throw Oops.Oh($"订舱主键{bookingId}请求下货纸比对失败,返回为空"); throw Oops.Oh($"订舱主键{bookingId}请求下货纸比对失败,返回为空");
result.succ = ruleResult.succ; result.succ = compareResult.succ;
result.msg = compareResult.msg;
result.extra = compareResult.extra;
result.extra2 = compareResult.extra2;
if(ruleResult.total > 0 ) _logger.LogInformation("批次={no} 请求下货纸比对返回结果{msg}", batchNo, JSON.Serialize(compareResult));
{
result.msg = "比对完成,比对数据差异";
}
_logger.LogInformation("批次={no} 请求下货纸比对返回结果{msg}", batchNo, JSON.Serialize(ruleResult));
/* /*
result.msg = ruleResult.msg; result.msg = ruleResult.msg;
result.extra = ruleResult.extra; result.extra = ruleResult.extra;
@ -162,13 +160,13 @@ namespace Myshipping.Application
/// <param name="bookingIds">订舱主键组</param> /// <param name="bookingIds">订舱主键组</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
[HttpPost("/TaskShippingOrderCompare/ExcuteShippingOrderCompareBatch")] [HttpPost("/TaskShippingOrderCompare/ExcuteShippingOrderCompareBatch")]
public async Task<TaskManageExcuteResultDto> ExcuteShippingOrderCompareBatchAsync(string[] bookingIds) public async Task<TaskManageExcuteResultDto> ExcuteShippingOrderCompareBatchAsync([FromBody] string[] bookingIds)
{ {
TaskManageExcuteResultDto result = new TaskManageExcuteResultDto(); TaskManageExcuteResultDto result = new TaskManageExcuteResultDto();
try try
{ {
var ids = bookingIds.Select(a => long.Parse(a)).ToArray(); var ids = bookingIds.Select(a => long.Parse(a)).Distinct().ToArray();
var list = _bookingOrderRepository.AsQueryable().Where(t => ids.Contains(t.Id)).ToList(); var list = _bookingOrderRepository.AsQueryable().Where(t => ids.Contains(t.Id)).ToList();
@ -187,17 +185,49 @@ namespace Myshipping.Application
throw Oops.Oh($"以下主键信息 {noRecord} 检索失败或者已作废过"); throw Oops.Oh($"以下主键信息 {noRecord} 检索失败或者已作废过");
} }
List<TaskManageExcuteResultDto> rltList = new List<TaskManageExcuteResultDto>(); //这里单票下货纸比对时,等待结果返回
if(ids.Length == 1)
list.ForEach(async entity => {
result = await InnerExcuteShippingOrderCompareAsync(list.FirstOrDefault().Id.ToString());
}
else
{ {
var curRlt = await InnerExcuteShippingOrderCompareAsync(entity.Id.ToString()); List<Task<TaskManageExcuteResultDto>> listOfTasks = new List<Task<TaskManageExcuteResultDto>>();
list.ForEach(entity =>
{
listOfTasks.Add(InnerExcuteShippingOrderCompareAsync(entity.Id.ToString()));
});
await Task.WhenAll<TaskManageExcuteResultDto>(listOfTasks);
result.succ = true;
result.msg = "比对完成";
string rltMsg = string.Empty;
result.rows = listOfTasks.Select(a =>
{
var origId = a.Result.extra.OrigPKId;
var order = list.FirstOrDefault(x => x.Id == long.Parse(origId));
if (a.Result.succ)
{
if (a.Result.total > 0)
{
return new { MblNo = order.MBLNO, Msg = "比对异常", IsDiff = true, rlt = a.Result.succ };
}
return new { MblNo = order.MBLNO, Msg = "比对一致", IsDiff = false, rlt = a.Result.succ };
}
return new { MblNo = order?.MBLNO, Msg = "比对一致", IsDiff = false, rlt = a.Result.succ };
}).ToList();
}
rltList.Add(curRlt);
});
result.succ = true;
result.msg = "比对完成";
} }
catch (Exception ex) catch (Exception ex)
{ {

Loading…
Cancel
Save