From 1e0da274df067b4a998fee80a496e35cd93c7461 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 7 Jul 2023 12:02:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BE=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingTruck/BookingTruckService.cs | 51 ++++++++++--------- .../TaskManagePlat/TaskManageService.cs | 8 +-- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs index 03b76550..bc015fd8 100644 --- a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs +++ b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs @@ -846,6 +846,28 @@ namespace Myshipping.Application throw Oops.Oh($"请求派车调度失败,原因={taskRlt.msg}", typeof(InvalidOperationException)); } + //更新派车订单为已提交 + model.Status = BookingTruckStatus.SUBMITED.ToString(); + model.UpdatedTime = DateTime.Now; + model.UpdatedUserId = UserManager.UserId; + model.UpdatedUserName = UserManager.Name; + + //提取任务流水号 + if (taskRlt.ext != null) + model.TaskNo = taskRlt.ext.ToString(); + + await _bookingTruckRepository.AsUpdateable(model).UpdateColumns(it => new + { + it.Status, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName, + it.TaskNo + }).ExecuteCommandAsync(); + + result.succ = true; + result.msg = "提交成功"; + //这里直接调用订舱服务的功能,担心有异常所以这里单独做了异常捕获 try { @@ -874,28 +896,6 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} id={id} 触发发送东胜完成,原因:{erro}", batchNo, bookingOrder.Id, bkException.Message); } - //更新派车订单为已提交 - model.Status = BookingTruckStatus.SUBMITED.ToString(); - model.UpdatedTime = DateTime.Now; - model.UpdatedUserId = UserManager.UserId; - model.UpdatedUserName = UserManager.Name; - - //提取任务流水号 - if (taskRlt.ext != null) - model.TaskNo = taskRlt.ext.ToString(); - - await _bookingTruckRepository.AsUpdateable(model).UpdateColumns(it => new - { - it.Status, - it.UpdatedTime, - it.UpdatedUserId, - it.UpdatedUserName, - it.TaskNo - }).ExecuteCommandAsync(); - - - result.succ = true; - result.msg = "提交成功"; } catch (Exception ex) { @@ -1146,7 +1146,7 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} 请求报文msg={msg}", batchNo, JSON.Serialize(messageInfo)); - //推送新增派车任务接口 + //推送取消派车任务接口 var taskRlt = await _taskManageExternalService.CancelTruckDispatchAsync(messageInfo); DateTime eDate = DateTime.Now; @@ -1758,9 +1758,10 @@ namespace Myshipping.Application } else if (operateType == OperateTypeEnum.Cancel) { - if (entityArg.Any(a => a.Status != BookingTruckStatus.SUBMITED.ToString())) + if (entityArg.Any(a => a.Status != BookingTruckStatus.SUBMITED.ToString() + && a.Status != BookingTruckStatus.SEND_DISPATCH.ToString())) { - throw Oops.Oh($"派车状态只有已提交才能撤销派车", typeof(InvalidOperationException)); + throw Oops.Oh($"派车状态只有已提交、已派车才能撤销派车", typeof(InvalidOperationException)); } } else if (operateType == OperateTypeEnum.Delete) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 4f08ecec..7762ddfd 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -4862,10 +4862,10 @@ namespace Myshipping.Application */ try { - var taskInfo = _taskBaseInfoRepository.AsQueryable() + var taskInfo = _taskBaseInfoRepository.AsQueryable().OrderByDescending(a => a.CreatedTime) .First(t => t.OUT_BUSI_NO == $"{info.Head.SenderId}_{info.Head.GID}"); - if(taskInfo == null) + if (taskInfo == null) throw Oops.Oh($"任务不存在"); if(new string[] { TaskStatusEnum.Complete.ToString(), TaskStatusEnum.Pending.ToString(),TaskStatusEnum.Pending.ToString() } @@ -4877,8 +4877,8 @@ namespace Myshipping.Application if (truckInfo == null) throw Oops.Oh($"派车任务不存在"); - if(truckInfo.Status == BookingTruckStatus.SEND_DISPATCH.ToString()) - throw Oops.Oh($"派车任务状态是已派车不能撤销"); + //if(truckInfo.Status == BookingTruckStatus.SEND_DISPATCH.ToString()) + // throw Oops.Oh($"派车任务状态是已派车不能撤销"); DateTime nowDate = DateTime.Now;