diff --git a/Myshipping.Application/Enum/TaskOperTypeEnum.cs b/Myshipping.Application/Enum/TaskOperTypeEnum.cs new file mode 100644 index 00000000..58837857 --- /dev/null +++ b/Myshipping.Application/Enum/TaskOperTypeEnum.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 任务操作类型枚举 + /// + public enum TaskOperTypeEnum + { + /// + /// 完成任务 + /// + [Description("完成任务")] + COMPLETE_TASK, + /// + /// 取消任务 + /// + [Description("取消任务")] + CANCEL_TASK, + /// + /// 挂起任务 + /// + [Description("挂起任务")] + PENDING_TASK, + } +} diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml index 132c871c..1a574dc3 100644 --- a/Myshipping.Application/Myshipping.Application.xml +++ b/Myshipping.Application/Myshipping.Application.xml @@ -4961,6 +4961,26 @@ 手工完成 + + + 任务操作类型枚举 + + + + + 完成任务 + + + + + 取消任务 + + + + + 挂起任务 + + 任务来源枚举 @@ -12725,6 +12745,27 @@ 任务主键数组 返回结果 + + + 完成任务(可批量) + + 任务主键数组 + 返回结果 + + + + 取消任务(可批量) + + 任务主键数组 + 返回结果 + + + + 挂起任务(可批量) + + 任务主键数组 + 返回结果 + 任务管理 @@ -12799,5 +12840,26 @@ 是否执行扣费 true-执行扣费 false-不执行扣费(主要是符合扣费条件但是由于超时没有得到准确回执) 返回回执 + + + 完成任务(可批量) + + 任务主键数组 + 返回结果 + + + + 取消任务(可批量) + + 任务主键数组 + 返回结果 + + + + 挂起任务(可批量) + + 任务主键数组 + 返回结果 + diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index 0059d33e..feb5d743 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -48,5 +48,27 @@ namespace Myshipping.Application /// 任务主键数组 /// 返回结果 Task DownloadOriginalTask(string[] PKIds); + + /// + /// 完成任务(可批量) + /// + /// 任务主键数组 + /// 返回结果 + Task CompleteTask(string[] PKIds); + + /// + /// 取消任务(可批量) + /// + /// 任务主键数组 + /// 返回结果 + Task CancelTask(string[] PKIds); + + /// + /// 挂起任务(可批量) + /// + /// 任务主键数组 + /// 返回结果 + Task PendingTask(string[] PKIds); + } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 7e1cf551..747089bd 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -26,6 +26,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; +using System.Reflection.Metadata.Ecma335; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; @@ -337,7 +338,7 @@ namespace Myshipping.Application return result; } - + #region 获取登陆人相关的任务统计信息 /// /// 获取登陆人相关的任务统计信息 /// @@ -549,7 +550,7 @@ namespace Myshipping.Application return resultInfo; } - + #endregion /// /// 任务台账查询 @@ -823,6 +824,7 @@ namespace Myshipping.Application return result; } + #region 远程请求正本下载 /// /// 远程请求正本下载 /// @@ -881,7 +883,9 @@ namespace Myshipping.Application return result; } + #endregion + #region 扣费 /// /// 扣费 /// @@ -931,6 +935,169 @@ namespace Myshipping.Application return result; } + #endregion + + #region 完成任务(可批量) + /// + /// 完成任务(可批量) + /// + /// 任务主键数组 + /// 返回结果 + [HttpPost("/TaskManage/CompleteTask")] + public async Task CompleteTask(string[] PKIds) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + _logger.LogInformation("批次={no} ids={ids} 完成任务开始", batchNo, string.Join(",", PKIds)); + + try + { + var taskList = _taskBaseInfoRepository.AsQueryable().Where(t => PKIds.Contains(t.PK_ID)).ToList(); + + _logger.LogInformation("批次={no} 获取任务完成,Num={Num}", batchNo, taskList.Count); + + taskList.ForEach(async tsk => { + + await InnerManualTask(batchNo, tsk, TaskOperTypeEnum.COMPLETE_TASK); + }); + } + catch (Exception ex) + { + throw Oops.Bah($"完成任务异常,{0}", ex.Message); + } + + return result; + } + #endregion + + private async Task InnerManualTask(string batchNo, TaskBaseInfo taskBaseInfo, TaskOperTypeEnum taskOperTypeEnum) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + var model = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskBaseInfo.PK_ID); + + if (taskOperTypeEnum == TaskOperTypeEnum.COMPLETE_TASK) + { + + if (taskBaseInfo.TASK_TYPE == TaskBusiTypeEnum.CANCELLATION.ToString()) + { + //收到订舱已被取消邮件后生成的任务,如果点击完成,(订舱状态变为【退舱】,注意这里还需要确认) + } + + model.COMPLETE_DATE = DateTime.Now; + model.COMPLETE_DEAL = TaskCompleteDealEnum.MANUAL.ToString(); + model.COMPLETE_DEAL = TaskCompleteDealEnum.MANUAL.GetDescription(); + model.IS_COMPLETE = 1; + + _taskBaseInfoRepository.AsUpdateable(model).UpdateColumns(it => new + { + it.COMPLETE_DATE, + it.COMPLETE_DEAL, + it.COMPLETE_DEAL_NAME, + it.IS_COMPLETE + }).ExecuteCommand(); + } + else if (taskOperTypeEnum == TaskOperTypeEnum.CANCEL_TASK) + { + if (taskBaseInfo.TASK_TYPE == TaskBusiTypeEnum.CHANGE_SHIP.ToString()) + { + model.STATUS = TaskStatusEnum.Cancel.ToString(); + } + else if(taskBaseInfo.TASK_TYPE == TaskBusiTypeEnum.ABORT_CHANGE_SHIP.ToString()) + { + /* + 1.如果原换船通知已经接受,需要把原船名航次恢复并通知客户取消换船。 + 2.如果原换船通知未作处理,点击接受或者结束任务时提示:本票货存在未处理换船通知,请先结束原换船任务然后结束本任务。 + 3.如果原换船任务为结束任务,在取消换船任务点接受时,提示未做换船,请点击结束任务。 + */ + + //查询同票主单的是否有未处理的换船通知 + //_taskBaseInfoRepository.AsQueryable().Where(t=>t.MBL_NO.Equals(taskBaseInfo.MBL_NO) && ) + } + } + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"异常,{ex.Message}"; + } + + return result; + } + + #region 取消任务(可批量) + /// + /// 取消任务(可批量) + /// + /// 任务主键数组 + /// 返回结果 + [HttpPost("/TaskManage/CancelTask")] + public async Task CancelTask(string[] PKIds) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + _logger.LogInformation("批次={no} ids={ids} 取消任务开始", batchNo, string.Join(",", PKIds)); + + try + { + var taskList = _taskBaseInfoRepository.AsQueryable().Where(t => PKIds.Contains(t.PK_ID)).ToList(); + + _logger.LogInformation("批次={no} 获取任务完成,Num={Num}", batchNo, taskList.Count); + + taskList.ForEach(async tsk => { + + await InnerManualTask(batchNo, tsk, TaskOperTypeEnum.CANCEL_TASK); + }); + } + catch (Exception ex) + { + throw Oops.Bah($"完成任务异常,{0}", ex.Message); + } + + return result; + } + #endregion + + #region 挂起任务(可批量) + /// + /// 挂起任务(可批量) + /// + /// 任务主键数组 + /// 返回结果 + [HttpPost("/TaskManage/PendingTask")] + public async Task PendingTask(string[] PKIds) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + _logger.LogInformation("批次={no} ids={ids} 挂起任务开始", batchNo, string.Join(",", PKIds)); + + try + { + var taskList = _taskBaseInfoRepository.AsQueryable().Where(t => PKIds.Contains(t.PK_ID)).ToList(); + + _logger.LogInformation("批次={no} 获取任务完成,Num={Num}", batchNo, taskList.Count); + + taskList.ForEach(async tsk => { + + await InnerManualTask(batchNo, tsk, TaskOperTypeEnum.PENDING_TASK); + }); + } + catch (Exception ex) + { + throw Oops.Bah($"完成任务异常,{0}", ex.Message); + } + + return result; + } + #endregion } }