From 4921e7872dff34bea2ea88ed2bfa478d60509ea3 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 3 Aug 2023 09:48:59 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingValueAddedService.cs | 100 +++++++++++++----- .../Dto/ModifyServiceProjectDto.cs | 24 +++++ .../Dto/QueryServiceProjectWithStatus.cs | 29 +++++ .../BookingOrder/IBookingValueAddedService.cs | 26 +++-- .../ServiceWorkFlowBaseService.cs | 34 +++--- 5 files changed, 170 insertions(+), 43 deletions(-) create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs create mode 100644 Myshipping.Application/Service/BookingOrder/Dto/QueryServiceProjectWithStatus.cs diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index 89039685..78f808ea 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -1947,7 +1947,8 @@ namespace Myshipping.Application /// /// 订舱ID /// 返回服务状态列表 - public async Task GetAllDataVNTWO(long bookingId) + [HttpGet("/BookingValueAdded/GetAllDataVNTWO")] + public async Task GetAllDataVNTWO([FromQuery] long bookingId) { BookingAttachedDataDto resultDto = new BookingAttachedDataDto(); @@ -1986,7 +1987,8 @@ namespace Myshipping.Application /// /// 订舱ID /// 返回日志详情 - public async Task GetAllLogDataVNTWO(long bookingId) + [HttpGet("/BookingValueAdded/GetAllLogDataVNTWO")] + public async Task GetAllLogDataVNTWO([FromQuery] long bookingId) { BookingLogDataDto resultDto = new BookingLogDataDto(); @@ -2049,10 +2051,10 @@ namespace Myshipping.Application /// /// 保存服务项目 /// - /// 订舱ID - /// 服务项目代码 + /// 修改服务项目详情 /// 返回回执 - public async Task SaveServiceProject(long bookingId, string projectCode) + [HttpPost("/BookingValueAdded/SaveServiceProject")] + public async Task SaveServiceProject([FromBody] ModifyServiceProjectDto model) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -2061,12 +2063,12 @@ namespace Myshipping.Application try { var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null,true) - .First(a=>a.Id == bookingId); + .First(a=>a.Id == model.BookingId); if(bookingOrder == null) throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); - _logger.LogInformation("批次={no} 请求保存服务项目 bookingid={id} project={prj} ", batchNo, bookingId, projectCode); + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); TrackingMessageInfo msgInfo = new TrackingMessageInfo { Head = new TrackingMessageHeadInfo { @@ -2082,7 +2084,7 @@ namespace Myshipping.Application }, Main = new TrackingMessageMainInfo { - BusiId = bookingId.ToString(), + BusiId = model.BookingId.ToString(), BusiSystemCode = "BOOKING_ORDER", MBlNo = bookingOrder.MBLNO, VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}", @@ -2093,11 +2095,10 @@ namespace Myshipping.Application OpertType = TrackingOperTypeEnum.MANUAL, OperUserId = UserManager.UserId.ToString(), OperUserName = UserManager.Name, - ProjectList = new List { - new TrackingMessageMainProjectInfo{ - ServiceProjectCode = projectCode, - } - } + ProjectList = model.ProjectCodes.Select(a=> new TrackingMessageMainProjectInfo + { + ServiceProjectCode = a, + }).ToList() } }; DateTime bDate = DateTime.Now; @@ -2138,10 +2139,10 @@ namespace Myshipping.Application /// /// 取消服务项目 /// - /// 订舱ID - /// 服务项目代码 + /// 修改服务项目详情 /// 返回回执 - public async Task CancelServiceProject(long bookingId, string projectCode) + [HttpPost("/BookingValueAdded/CancelServiceProject")] + public async Task CancelServiceProject([FromBody] ModifyServiceProjectDto model) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -2150,12 +2151,12 @@ namespace Myshipping.Application try { var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) - .First(a => a.Id == bookingId); + .First(a => a.Id == model.BookingId); if (bookingOrder == null) throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); - _logger.LogInformation("批次={no} 请求保存服务项目 bookingid={id} project={prj} ", batchNo, bookingId, projectCode); + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); TrackingMessageInfo msgInfo = new TrackingMessageInfo { @@ -2173,7 +2174,7 @@ namespace Myshipping.Application }, Main = new TrackingMessageMainInfo { - BusiId = bookingId.ToString(), + BusiId = model.BookingId.ToString(), BusiSystemCode = "BOOKING_ORDER", MBlNo = bookingOrder.MBLNO, VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}", @@ -2184,11 +2185,10 @@ namespace Myshipping.Application OpertType = TrackingOperTypeEnum.MANUAL, OperUserId = UserManager.UserId.ToString(), OperUserName = UserManager.Name, - ProjectList = new List { - new TrackingMessageMainProjectInfo{ - ServiceProjectCode = projectCode, - } - } + ProjectList = model.ProjectCodes.Select(a => new TrackingMessageMainProjectInfo + { + ServiceProjectCode = a, + }).ToList() } }; DateTime bDate = DateTime.Now; @@ -2224,6 +2224,58 @@ namespace Myshipping.Application return result; } #endregion + + + /// + /// 获取服务项目列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + public async Task GetServiceProjectList(QueryServiceProjectWithStatus model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + + } + catch(Exception ex) + { + result.succ = false; + result.msg = $"获取服务项目列表失败,原因:{ex.Message}"; + } + + return result; + } + + + /// + /// 获取服务项目下的状态列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + public async Task GetServiceStatusList(QueryServiceProjectWithStatus model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"获取服务项目下的状态列表失败,原因:{ex.Message}"; + } + + return result; + } + + } public class DateTimeJsonConverter : System.Text.Json.Serialization.JsonConverter> diff --git a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs new file mode 100644 index 00000000..98d39465 --- /dev/null +++ b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 修改服务项目 + /// + public class ModifyServiceProjectDto + { + /// + /// 订舱主键 + /// + public long BookingId { get; set; } + + /// + /// 服务项目代码 + /// + public string[] ProjectCodes { get; set; } + } +} diff --git a/Myshipping.Application/Service/BookingOrder/Dto/QueryServiceProjectWithStatus.cs b/Myshipping.Application/Service/BookingOrder/Dto/QueryServiceProjectWithStatus.cs new file mode 100644 index 00000000..cc503c86 --- /dev/null +++ b/Myshipping.Application/Service/BookingOrder/Dto/QueryServiceProjectWithStatus.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 查询服务项目和状态 + /// + public class QueryServiceProjectWithStatus + { + /// + /// 订舱ID(可为空,不为空时需要查询已触发的记录和未触发的记录,为空时只查询已启用的) + /// + public long? BookingId { get; set; } + + /// + /// 0-查服务项目 1-查服务项目下的状态 + /// + public TrackingQueryTypeEnum QueryType { get; set; } + + /// + /// 服务项目代码组 + /// + public string[] ProjectCodes { get; set; } + } +} diff --git a/Myshipping.Application/Service/BookingOrder/IBookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/IBookingValueAddedService.cs index 55780d58..fa1d054a 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingValueAddedService.cs @@ -91,17 +91,31 @@ namespace Myshipping.Application /// /// 保存服务项目 /// - /// 订舱ID - /// 服务项目代码 + /// 修改服务项目详情 /// 返回回执 - Task SaveServiceProject(long bookingId, string projectCode); + Task SaveServiceProject(ModifyServiceProjectDto model); /// /// 取消服务项目 /// - /// 订舱ID - /// 服务项目代码 + /// 修改服务项目详情 + /// 返回回执 + Task CancelServiceProject(ModifyServiceProjectDto model); + + /// + /// 获取服务项目列表 + /// + /// 查询服务项目和状态详情 /// 返回回执 - Task CancelServiceProject(long bookingId, string projectCode); + Task GetServiceProjectList(QueryServiceProjectWithStatus model); + + + /// + /// 获取服务项目下的状态列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + Task GetServiceStatusList(QueryServiceProjectWithStatus model); + } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs index 4c7845a4..44de7433 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs @@ -1756,19 +1756,15 @@ namespace Myshipping.Application if (isAvoidCache || projectList == null || projectList.Count == 0) { - var list = _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true) - .InnerJoin((wf, rela) - => wf.PK_ID == rela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == rela.WF_VERSION) - .InnerJoin((wf, rela, prj) - => rela.SERVICE_PROJECT_ID == prj.PK_ID) - .Where((wf, rela, prj) - => !string.IsNullOrWhiteSpace(wf.RELEASE_VERSION) && wf.BELONG_TENANT_ID == long.Parse(tenantId) - && wf.IS_ENABLE == 1 && !wf.IsDeleted) - .Select((wf, rela, prj) - => prj).ToList(); - - projectList = list.Select(a => a.Adapt()) - .Distinct().OrderBy(a => a.SortNo).ToList(); + var statusList = ReloadServiceProjectCacheInfo(tenantId); + + projectList = statusList.Select(a => new ServiceProjectBaseDto + { + PKId = a.ProjectPKId, + ServiceProjectCode = a.ProjectCode, + ServiceProjectName = a.ProjectName, + SortNo = a.SortNo + }).OrderBy(a => a.SortNo).ToList(); await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList); } @@ -1820,6 +1816,18 @@ namespace Myshipping.Application await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList); _logger.LogInformation($"租户下可用的服务流程详情并写入缓存完成"); + + var projectList = statusList.Select(a => new ServiceProjectBaseDto + { + PKId = a.ProjectPKId, + ServiceProjectCode = a.ProjectCode, + ServiceProjectName = a.ProjectName, + SortNo = a.SortNo + }).OrderBy(a => a.SortNo).ToList(); + + await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList); + + _logger.LogInformation($"租户下可用的服务写入缓存完成"); } catch(Exception ex) { From a9a0d7d6bb94e16ae1150f323cef68cf340fafb4 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 3 Aug 2023 16:21:05 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=BF=9D=E5=AD=98=E3=80=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrackingSystem/ServiceWorkFlowRunInfo.cs | 12 +- .../BookingOrder/BookingValueAddedService.cs | 18 +- .../Dto/QueryServiceProjectWithStatus.cs | 5 + .../Dtos/ServiceProjectWithStatusDto.cs | 12 +- .../Dtos/ServiceWorkFlowRunDto.cs | 15 + .../Interface/IServiceWorkFlowBaseService.cs | 3 + .../IServiceWorkFlowManageService.cs | 6 + .../ServiceWorkFlowBaseService.cs | 2 + .../ServiceWorkFlowManageService.cs | 290 ++++++++++++++---- 9 files changed, 293 insertions(+), 70 deletions(-) diff --git a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunInfo.cs b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunInfo.cs index 74f932e2..243d62c6 100644 --- a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunInfo.cs +++ b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunInfo.cs @@ -87,6 +87,16 @@ namespace Myshipping.Application.Entity /// /// 最后活动名称 /// - public int LST_ACT_NAME { get; set; } + public string LST_ACT_NAME { get; set; } + + /// + /// 是否已产生 1-已产生 0-未产生 + /// + public int IS_YIELD { get; set; } + + /// + /// 项目发生时间 + /// + public Nullable ACT_DATE { get; set; } } } diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index 78f808ea..39c154f3 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2225,13 +2225,14 @@ namespace Myshipping.Application } #endregion - + #region 获取服务项目列表 /// /// 获取服务项目列表 /// /// 查询服务项目和状态详情 /// 返回回执 - public async Task GetServiceProjectList(QueryServiceProjectWithStatus model) + [HttpPost("/BookingValueAdded/GetServiceProjectList")] + public async Task GetServiceProjectList([FromBody] QueryServiceProjectWithStatus model) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -2239,7 +2240,19 @@ namespace Myshipping.Application try { + var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == model.BookingId); + if (bookingOrder == null) + throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); + + QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus { + BookingId = model.BookingId, + QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT, + TenantId = bookingOrder.TenantId.Value + }; + + result = await _serviceWorkFlowManageService.GetEnableProjectList(queryInfo); } catch(Exception ex) { @@ -2249,6 +2262,7 @@ namespace Myshipping.Application return result; } + #endregion /// diff --git a/Myshipping.Application/Service/BookingOrder/Dto/QueryServiceProjectWithStatus.cs b/Myshipping.Application/Service/BookingOrder/Dto/QueryServiceProjectWithStatus.cs index cc503c86..06028d61 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/QueryServiceProjectWithStatus.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/QueryServiceProjectWithStatus.cs @@ -25,5 +25,10 @@ namespace Myshipping.Application /// 服务项目代码组 /// public string[] ProjectCodes { get; set; } + + /// + /// 租户ID + /// + public long TenantId { get; set; } } } diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs index b630f64c..14b16b1e 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs @@ -49,13 +49,23 @@ namespace Myshipping.Application /// /// 发布日期 /// - public DateTime ReleaseDate { get; set; } + public Nullable ReleaseDate { get; set; } /// /// 状态代码列表(方便检索) /// public string[] StatusSKUCodeArgs { get; set; } + /// + /// 是否已完成 + /// + public bool IsYield { get; set; } + + /// + /// 完成时间 + /// + public Nullable ActDate { get; set; } + /// /// 状态列表 /// diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowRunDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowRunDto.cs index d287ad7f..99158850 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowRunDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowRunDto.cs @@ -16,6 +16,11 @@ namespace Myshipping.Application /// public string PKId { get; set; } + /// + /// 服务项目主键 + /// + public string ServiceProjectId { get; set; } + /// /// 服务项目代码 /// @@ -26,6 +31,16 @@ namespace Myshipping.Application /// public string ServiceProjectName { get; set; } + /// + /// 是否已产生 1-已产生 0-未产生 + /// + public int IsYield { get; set; } + + /// + /// 项目发生时间 + /// + public Nullable ActDate { get; set; } + /// /// 状态列表 /// diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs index a589c6ca..518ef0e6 100644 --- a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs @@ -129,5 +129,8 @@ namespace Myshipping.Application /// 是否不从缓存取值 /// 返回回执 Task> GetEnableProjectWithStatusList(string tenantId, bool isAvoidCache = false); + + + } } diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs index a6c8ff41..d6d1e498 100644 --- a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs @@ -64,5 +64,11 @@ namespace Myshipping.Application /// 返回回执 Task ValidateCancelProject(TrackingMessageInfo info); + /// + /// 检索已选中并且可用的服务项目列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + Task GetEnableProjectList(QueryServiceProjectWithStatus model); } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs index 44de7433..3efa89d7 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs @@ -2014,5 +2014,7 @@ namespace Myshipping.Application return statusList; } #endregion + + } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index 1f3503cd..db9a58c6 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -131,6 +131,8 @@ namespace Myshipping.Application throw Oops.Oh($"报文Main的业务主键不能为空", typeof(InvalidOperationException)); } + var statusList = _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(info.Main.OperTenantId.ToString()).GetAwaiter().GetResult(); + var projectList = _cache.Get>($"{CONST_CACHE_ENABLE_PROJECT}_{info.Main.OperTenantId}"); if (info.Main.PushType == TrackingPushTypeEnum.Project) @@ -142,13 +144,84 @@ namespace Myshipping.Application throw Oops.Oh($"推送类型是【服务项目】,服务项目列表不能为空", typeof(InvalidOperationException)); } - //提取 + //提取所有已经有run记录的 var runBaseList = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true) .Where(a => a.BUSI_ID == info.Main.BusiId && a.BUSI_SYSTEM_CODE.Equals(info.Main.BusiSystemCode) && !a.IsDeleted && a.TenantId == info.Main.OperTenantId).ToList(); + + var needProjectArg = info.Main.ProjectList.Select(a=>a.ServiceProjectCode).ToArray(); + + var needProjectList = statusList.Where(a => needProjectArg.Contains(a.ProjectCode)).ToList(); + + var tskList = needProjectList.GroupJoin(runBaseList, l => l.WFPKId, + r => r.SERVICE_WF_ID, + (l, r) => + { + var currList = r.ToList(); + + if (currList.Count == 0) + { + //标识当前服务项目写入运行主表 + return new { OperType = "Insert", Info = l, Run = new ServiceWorkFlowRunInfo() }; + } + + return new { OperType = "Update", Info = l, Run = currList.FirstOrDefault() }; + }).ToList(); + + DateTime nowDate = DateTime.Now; + + tskList.ForEach(async tsk => { + if(tsk.OperType == "Insert") + { + ServiceWorkFlowRunInfo serviceWorkFlowRunInfo = new ServiceWorkFlowRunInfo + { + PK_ID = IDGen.NextID().ToString(), + SERVICE_WF_ID = tsk.Info.WFPKId, + BUSI_SYSTEM_CODE = info.Main.BusiSystemCode.ToUpper(), + BUSI_ID = info.Main.BusiId.ToUpper(), + MBL_NO = info.Main?.MBlNo.ToUpper(), + VESSEL_VOYNO = info.Main?.VesselVoyno.ToUpper(), + ORDER_NO = info.Main?.OrderNo, + STATUS = TaskStatusEnum.Create.ToString(), + RELEASE_VERSION = tsk.Info.ReleaseVersion, + ACTIVITIES_NUM = 0, + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = long.Parse(info.Main.OperUserId), + CreatedUserName = info.Main.OperUserName, + TenantId = info.Main.OperTenantId, + TenantName = info.Main.OperTenantName, + SERVICE_PROJECT_CODE = tsk.Info.ProjectCode, + SERVICE_PROJECT_NAME = tsk.Info.ProjectName, + SERVICE_PROJECT_ID = tsk.Info.ProjectPKId, + IS_YIELD = 1, + ACT_DATE = nowDate, + }; + + await _serviceWorkFlowRunInfoRepository.InsertAsync(serviceWorkFlowRunInfo); + } + else if(tsk.OperType == "Update") + { + var runInfo = _serviceWorkFlowRunInfoRepository.AsQueryable() + .First(a => a.PK_ID == tsk.Run.PK_ID); + + runInfo.IS_YIELD = 1; + runInfo.ACT_DATE = nowDate; + + await _serviceWorkFlowRunInfoRepository.AsUpdateable(runInfo).UpdateColumns(it => new + { + it.ACT_DATE, + it.IS_YIELD, + }).ExecuteCommandAsync(); + } + }); + + result.succ = true; + result.msg = "推送成功"; + + return result; } - //校验状态代码是否一致,不一致直接返回错误不允许推送 var statusArg = info.Main.StatusList.Select(a => a?.StatusCode.ToUpper()) .Where(a => !string.IsNullOrWhiteSpace(a)).Distinct().ToArray(); @@ -432,62 +505,84 @@ namespace Myshipping.Application try { - - - var runList = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true) - .LeftJoin((m, s) => m.PK_ID == s.RUN_ID) - .LeftJoin((m, s, rela) => - m.SERVICE_WF_ID == rela.SERVICE_WORKFLOW_ID && m.RELEASE_VERSION == rela.WF_VERSION) - .LeftJoin((m, s, rela, p) => - rela.SERVICE_PROJECT_ID == p.PK_ID) - .Where((m, s, rela, p) - => m.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && m.BUSI_ID == info.Main.BusiId && - info.Main.ServiceProjectCodeList.Contains(p.SERVICE_PROJECT_CODE)) - .Select((m, s) => new { Run = m, Sub = s }).ToList(); - - - var resultList = runList.GroupBy(a=>a.Run.PK_ID) - .Select(a => { - var currList = a.ToList(); - - var runInfo = currList.FirstOrDefault().Run; - - var showModel = new ServiceWorkFlowRunDto(); + result.succ = true; + result.ext = InnerGetRunListBySigleBusiness(info); + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"单票单服务项目查询失败,原因:{ex.Message}"; + } - showModel.PKId = runInfo.PK_ID; - showModel.ServiceProjectCode = runInfo.SERVICE_PROJECT_CODE; - showModel.ServiceProjectName = runInfo.SERVICE_PROJECT_NAME; + return result; + } + #endregion - showModel.ActivitiesList = currList.Where(t => t.Sub.IS_SUB == 0) - .Select(t => + #region 获取单票业务相关的服务项目运行列表 + /// + /// 获取单票业务相关的服务项目运行列表 + /// + /// 查询服务流程详情 + /// 返回查询列表 + private List InnerGetRunListBySigleBusiness(TrackingQueryMessageInfo info) + { + var runList = _serviceWorkFlowRunInfoRepository.AsQueryable() + .Filter(null, true) + .LeftJoin((m, s) => m.PK_ID == s.RUN_ID) + .LeftJoin((m, s, rela) => + m.SERVICE_WF_ID == rela.SERVICE_WORKFLOW_ID && m.RELEASE_VERSION == rela.WF_VERSION) + .LeftJoin((m, s, rela, p) => + rela.SERVICE_PROJECT_ID == p.PK_ID) + .Where((m, s, rela, p) + => m.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && m.BUSI_ID == info.Main.BusiId && + (info.Main.ServiceProjectCodeList == null || info.Main.ServiceProjectCodeList.Contains(p.SERVICE_PROJECT_CODE))) + .Select((m, s) => new { Run = m, Sub = s }).ToList(); + + var resultList = runList.GroupBy(a => a.Run.PK_ID) + .Select(a => { + var currList = a.ToList(); + + var runInfo = currList.FirstOrDefault().Run; + + var showModel = new ServiceWorkFlowRunDto(); + + showModel.PKId = runInfo.PK_ID; + showModel.ServiceProjectId = runInfo.SERVICE_PROJECT_ID; + showModel.ServiceProjectCode = runInfo.SERVICE_PROJECT_CODE; + showModel.ServiceProjectName = runInfo.SERVICE_PROJECT_NAME; + showModel.IsYield = runInfo.IS_YIELD; + showModel.ActDate = runInfo.ACT_DATE; + + showModel.ActivitiesList = currList.Where(t => t.Sub.IS_SUB == 0) + .Select(t => + { + var runModel = new ServiceWorkFlowActivitiesRunDto { - var runModel = new ServiceWorkFlowActivitiesRunDto - { - PKId = t.Sub.PK_ID, - ActDate = t.Sub.ACT_DATE, - ActId = t.Sub.ACT_ID, - ExecSortNo = t.Sub.EXEC_SORT_NO, - ActVal = t.Sub.ACT_VAL, - IsStart = t.Sub.IS_START, - IsEnd = t.Sub.IS_END, - IsYield = t.Sub.IS_YIELD, - RunId = t.Sub.RUN_ID, - ShowName = t.Sub.SHOW_NAME, - SourceType = t.Sub.SOURCE_TYPE, - StatusSKUCode = t.Sub.STATUS_SKU_CODE, - StatusSKUId = t.Sub.STATUS_SKU_ID - }; + PKId = t.Sub.PK_ID, + ActDate = t.Sub.ACT_DATE, + ActId = t.Sub.ACT_ID, + ExecSortNo = t.Sub.EXEC_SORT_NO, + ActVal = t.Sub.ACT_VAL, + IsStart = t.Sub.IS_START, + IsEnd = t.Sub.IS_END, + IsYield = t.Sub.IS_YIELD, + RunId = t.Sub.RUN_ID, + ShowName = t.Sub.SHOW_NAME, + SourceType = t.Sub.SOURCE_TYPE, + StatusSKUCode = t.Sub.STATUS_SKU_CODE, + StatusSKUId = t.Sub.STATUS_SKU_ID + }; - return runModel; - }).ToList(); + return runModel; + }).ToList(); - var subList = - currList.Where(t => t.Sub.IS_SUB == 1) - .Select(t => t.Sub).ToList(); + var subList = + currList.Where(t => t.Sub.IS_SUB == 1) + .Select(t => t.Sub).ToList(); - showModel.ActivitiesList = showModel.ActivitiesList.GroupJoin(subList, - l => l.PKId, r => r.PARENT_ID, - (l, r) => + showModel.ActivitiesList = showModel.ActivitiesList.GroupJoin(subList, + l => l.PKId, r => r.PARENT_ID, + (l, r) => { var currList = r.ToList(); @@ -513,25 +608,16 @@ namespace Myshipping.Application }; return subModel; - }).OrderBy(x=>x.ExecSortNo).ToList(); + }).OrderBy(x => x.ExecSortNo).ToList(); } return l; }).OrderBy(t => t.ExecSortNo).ToList(); - return showModel; - }).ToList(); - - result.succ = true; - result.ext = resultList; - } - catch (Exception ex) - { - result.succ = false; - result.msg = $"单票单服务项目查询失败,原因:{ex.Message}"; - } + return showModel; + }).ToList(); - return result; + return resultList; } #endregion @@ -558,7 +644,6 @@ namespace Myshipping.Application => m.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && m.BUSI_ID == info.Main.BusiId) .Select((m, s) => new { Run = m, Sub = s }).ToList(); - var resultList = runList.GroupBy(a => a.Run.PK_ID) .Select(a => { var currList = a.ToList(); @@ -1120,6 +1205,79 @@ namespace Myshipping.Application return result; } #endregion + + + #region 检索已选中并且可用的服务项目列表 + /// + /// 检索已选中并且可用的服务项目列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + public async Task GetEnableProjectList(QueryServiceProjectWithStatus model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //先获取可用的服务项目 + var projectList = await _serviceWorkFlowBaseService.GetEnableProjectList(model.TenantId.ToString()); + + TrackingQueryMessageInfo messageInfo = new TrackingQueryMessageInfo { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + },Main = new TrackingMessageQueryMainInfo { + BusiId = model.BookingId.ToString(), + BusiSystemCode = "BOOKING_ORDER", + TenantId = model.TenantId.ToString(), + } + }; + //在获取运行表已有的记录 + var runList = InnerGetRunListBySigleBusiness(messageInfo); + + var resultList = projectList.GroupJoin(runList, l => l.PKId, r => r.ServiceProjectId, (l, r) => { + var currList = r.ToList(); + + var runInfo = currList.FirstOrDefault(); + + var dto = new ServiceProjectWithStatusDto + { + ProjectPKId = l.PKId, + ProjectCode = l.ServiceProjectCode, + ProjectName = l.ServiceProjectName, + SortNo = l.SortNo + + }; + + if(runInfo != null) + { + dto.IsYield = runInfo.IsYield == 1 ? true : false; + dto.ActDate = runInfo.ActDate; + } + + return dto; + }).ToList(); + + result.succ = true; + result.ext = resultList; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"检索已选中并且可用的服务项目列表失败,原因:{ex.Message}"; + } + + return result; + } + #endregion } } From 0092cb53828aff658f69b28035f3e8c80c4419f9 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 3 Aug 2023 17:23:11 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8A=A0=E8=BD=BD=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enum/TrackingQueryTypeEnum.cs | 5 + .../BookingOrder/BookingValueAddedService.cs | 25 ++++- .../IServiceWorkFlowManageService.cs | 15 +++ .../ServiceWorkFlowManageService.cs | 99 ++++++++++++++++++- 4 files changed, 138 insertions(+), 6 deletions(-) diff --git a/Myshipping.Application/Enum/TrackingQueryTypeEnum.cs b/Myshipping.Application/Enum/TrackingQueryTypeEnum.cs index 3aba5277..39f7ad4b 100644 --- a/Myshipping.Application/Enum/TrackingQueryTypeEnum.cs +++ b/Myshipping.Application/Enum/TrackingQueryTypeEnum.cs @@ -22,5 +22,10 @@ namespace Myshipping.Application /// [Description("查询服务项目和状态")] QUERY_SERVICE_PROJECT_STATUS, + /// + /// 查询所有服务项目和关联状态 + /// + [Description("查询所有服务项目和关联状态")] + QUERY_SERVICE_ALL, } } diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index 39c154f3..9057cc64 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2270,7 +2270,8 @@ namespace Myshipping.Application /// /// 查询服务项目和状态详情 /// 返回回执 - public async Task GetServiceStatusList(QueryServiceProjectWithStatus model) + [HttpPost("/BookingValueAdded/GetServiceStatusList")] + public async Task GetServiceStatusList([FromBody] QueryServiceProjectWithStatus model) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -2278,7 +2279,29 @@ namespace Myshipping.Application try { + //查询所有服务服务项目和状态时,需要先获取订舱详情 + if (model.QueryType == TrackingQueryTypeEnum.QUERY_SERVICE_ALL) + { + var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == model.BookingId); + + if (bookingOrder == null) + throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); + + QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus + { + BookingId = model.BookingId, + QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT, + TenantId = bookingOrder.TenantId.Value + }; + result = await _serviceWorkFlowManageService.GetEnableProjectList(queryInfo); + } + else + { + model.TenantId = UserManager.TENANT_ID; + result = await _serviceWorkFlowManageService.GetEnableStatusListByProject(model); + } } catch (Exception ex) { diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs index d6d1e498..6e65f3cf 100644 --- a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs @@ -70,5 +70,20 @@ namespace Myshipping.Application /// 查询服务项目和状态详情 /// 返回回执 Task GetEnableProjectList(QueryServiceProjectWithStatus model); + + + /// + /// 检索服务项目下的状态列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + Task GetEnableStatusListByProject(QueryServiceProjectWithStatus model); + + /// + /// 单票检索服务项目下的状态列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + Task GetEnableStatusListByBusiness(QueryServiceProjectWithStatus model); } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index db9a58c6..49385185 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -506,7 +506,7 @@ namespace Myshipping.Application try { result.succ = true; - result.ext = InnerGetRunListBySigleBusiness(info); + result.ext = InnerGetRunListBySingleBusiness(info); } catch (Exception ex) { @@ -524,7 +524,7 @@ namespace Myshipping.Application /// /// 查询服务流程详情 /// 返回查询列表 - private List InnerGetRunListBySigleBusiness(TrackingQueryMessageInfo info) + private List InnerGetRunListBySingleBusiness(TrackingQueryMessageInfo info) { var runList = _serviceWorkFlowRunInfoRepository.AsQueryable() .Filter(null, true) @@ -1241,7 +1241,7 @@ namespace Myshipping.Application } }; //在获取运行表已有的记录 - var runList = InnerGetRunListBySigleBusiness(messageInfo); + var runList = InnerGetRunListBySingleBusiness(messageInfo); var resultList = projectList.GroupJoin(runList, l => l.PKId, r => r.ServiceProjectId, (l, r) => { var currList = r.ToList(); @@ -1254,7 +1254,6 @@ namespace Myshipping.Application ProjectCode = l.ServiceProjectCode, ProjectName = l.ServiceProjectName, SortNo = l.SortNo - }; if(runInfo != null) @@ -1278,6 +1277,96 @@ namespace Myshipping.Application return result; } #endregion - } + #region 检索服务项目下的状态列表 + /// + /// 检索服务项目下的状态列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + public async Task GetEnableStatusListByProject(QueryServiceProjectWithStatus model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + var statuList = await _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(model.TenantId.ToString()); + + var resultList = statuList.Where(a => model.ProjectCodes.Contains(a.ProjectCode)) + .OrderBy(a => a.SortNo) + .SelectMany(a => a.StatusList.OrderBy(b=>b.SortNo)) + .ToList(); + + result.succ = true; + result.ext = resultList; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"检索服务项目下的状态列表失败,原因:{ex.Message}"; + } + + return result; + } + #endregion + + #region 单票检索服务项目下的状态列表 + /// + /// 单票检索服务项目下的状态列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + public async Task GetEnableStatusListByBusiness(QueryServiceProjectWithStatus model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + var statuList = await _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(model.TenantId.ToString()); + + var resultList = statuList.Where(a => model.ProjectCodes.Contains(a.ProjectCode)) + .OrderBy(a => a.SortNo) + .SelectMany(a => a.StatusList.OrderBy(b => b.SortNo)) + .ToList(); + + /* + TrackingQueryMessageInfo messageInfo = new TrackingQueryMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageQueryMainInfo + { + BusiId = model.BookingId.ToString(), + BusiSystemCode = "BOOKING_ORDER", + TenantId = model.TenantId.ToString(), + } + }; + //在获取运行表已有的记录 + var runList = InnerGetRunListBySingleBusiness(messageInfo); + */ + result.succ = true; + result.ext = resultList; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"检索服务项目下的状态列表失败,原因:{ex.Message}"; + } + + return result; + + + } + #endregion + } } From ebe42059440c8c3fd0eb60c6b4f7021439f47ea8 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 4 Aug 2023 11:05:44 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=8A=B6=E6=80=81=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingValueAddedService.cs | 3 +++ .../ServiceWorkFlowBaseService.cs | 8 ++++---- .../ServiceWorkFlowManageService.cs | 19 ++++++++++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index 9057cc64..92e06243 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2299,6 +2299,9 @@ namespace Myshipping.Application } else { + if (model.ProjectCodes == null || (model.ProjectCodes != null && model.ProjectCodes.Length == 0)) + throw Oops.Oh($"服务项目代码不能为空"); + model.TenantId = UserManager.TENANT_ID; result = await _serviceWorkFlowManageService.GetEnableStatusListByProject(model); } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs index 3efa89d7..c652b0a9 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs @@ -1923,13 +1923,13 @@ namespace Myshipping.Application dto.SubStatusList = currList.Select(e => { - var skuInfo = statusSKUList.FirstOrDefault(e => e.PK_ID == act.STATUS_SKU_ID); + var skuInfo = statusSKUList.FirstOrDefault(t => t.PK_ID == e.Act.STATUS_SKU_ID); var itemDto = new ServiceProjectStatusDto { - SkuPKId = act.STATUS_SKU_ID, - ActPKId = act.PK_ID, - ShowName = act.SHOW_NAME, + SkuPKId = e.Act.STATUS_SKU_ID, + ActPKId = e.Act.PK_ID, + ShowName = e.Act.SHOW_NAME, ActSortNo = e.Rela.SORT_NO, WFPKId = wf.PK_ID, StatusSKUCode = skuInfo.STATUS_SKU_CODE, diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index 49385185..c7754d6e 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -1290,13 +1290,26 @@ namespace Myshipping.Application try { - var statuList = await _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(model.TenantId.ToString()); + var statuList = await _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(model.TenantId.ToString()); var resultList = statuList.Where(a => model.ProjectCodes.Contains(a.ProjectCode)) .OrderBy(a => a.SortNo) - .SelectMany(a => a.StatusList.OrderBy(b=>b.SortNo)) + .SelectMany(a => + a.StatusList.SelectMany(b => { + List currList = new List(); + + currList.Add(b); + if (b.SubStatusList != null && b.SubStatusList.Count > 0) + { + currList.AddRange(b.SubStatusList.OrderBy(e=>e.ActSortNo)); + } + + return currList; + } + )).ToList() .ToList(); - + + result.succ = true; result.ext = resultList; } From 70135e22ab6caf8d2fee0f5ea877078cd6acb221 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 4 Aug 2023 15:50:27 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=8A=B6=E6=80=81=E6=8E=A8=E9=80=81=E5=92=8C?= =?UTF-8?q?=E5=8F=96=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enum/TrackingSourceTypeEnum.cs | 26 + .../BookingOrder/BookingValueAddedService.cs | 182 ++++++- .../Dto/ModifyServiceProjectDto.cs | 16 + .../BookingOrder/IBookingValueAddedService.cs | 14 + .../Dtos/ServiceProjectWithStatusDto.cs | 5 + .../Dtos/TrackingMessageInfo.cs | 5 + .../IServiceWorkFlowManageService.cs | 8 - .../ServiceWorkFlowManageService.cs | 462 +++++++++--------- 8 files changed, 466 insertions(+), 252 deletions(-) create mode 100644 Myshipping.Application/Enum/TrackingSourceTypeEnum.cs diff --git a/Myshipping.Application/Enum/TrackingSourceTypeEnum.cs b/Myshipping.Application/Enum/TrackingSourceTypeEnum.cs new file mode 100644 index 00000000..689d7bc0 --- /dev/null +++ b/Myshipping.Application/Enum/TrackingSourceTypeEnum.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 服务项目来源类型 + /// + public enum TrackingSourceTypeEnum + { + /// + /// 自动 + /// + [Description("自动")] + AUTO, + /// + /// 人工 + /// + [Description("人工")] + MANUAL, + } +} diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index 92e06243..b7028c52 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2095,6 +2095,7 @@ namespace Myshipping.Application OpertType = TrackingOperTypeEnum.MANUAL, OperUserId = UserManager.UserId.ToString(), OperUserName = UserManager.Name, + SourceType = TrackingSourceTypeEnum.MANUAL, ProjectList = model.ProjectCodes.Select(a=> new TrackingMessageMainProjectInfo { ServiceProjectCode = a, @@ -2185,6 +2186,7 @@ namespace Myshipping.Application OpertType = TrackingOperTypeEnum.MANUAL, OperUserId = UserManager.UserId.ToString(), OperUserName = UserManager.Name, + SourceType = TrackingSourceTypeEnum.MANUAL, ProjectList = model.ProjectCodes.Select(a => new TrackingMessageMainProjectInfo { ServiceProjectCode = a, @@ -2195,7 +2197,7 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} 推送取消服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); - var rlt = await _serviceWorkFlowManageService.CancelProject(msgInfo); + var rlt = await _serviceWorkFlowManageService.CancelStatus(msgInfo); DateTime eDate = DateTime.Now; TimeSpan ts = eDate.Subtract(bDate); @@ -2225,6 +2227,184 @@ namespace Myshipping.Application } #endregion + /// + /// 保存服务状态 + /// + /// 修改服务状态详情 + /// 返回回执 + [HttpPost("/BookingValueAdded/SaveServiceStatus")] + public async Task SaveServiceStatus([FromBody] ModifyServiceProjectStatusDto model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == model.BookingId); + + if (bookingOrder == null) + throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); + + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); + + TrackingMessageInfo msgInfo = new TrackingMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageMainInfo + { + BusiId = model.BookingId.ToString(), + BusiSystemCode = "BOOKING_ORDER", + MBlNo = bookingOrder.MBLNO, + VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}", + OrderNo = bookingOrder.BSNO, + PushType = TrackingPushTypeEnum.Status, + OperTenantId = bookingOrder.TenantId.Value, + OperTenantName = bookingOrder.TenantName, + OpertType = TrackingOperTypeEnum.MANUAL, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, + SourceType = TrackingSourceTypeEnum.MANUAL, + StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo + { + StatusCode = a, + }).ToList() + } + }; + DateTime bDate = DateTime.Now; + + _logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); + + var rlt = await _serviceWorkFlowManageService.PushStatus(msgInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") + , JSON.Serialize(rlt)); + + if (!rlt.succ) + { + result = rlt; + } + else + { + result.succ = true; + result.msg = "推送成功"; + } + + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"服务项目状态推送失败,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 取消服务状态 + /// + /// 修改服务状态详情 + /// 返回回执 + [HttpPost("/BookingValueAdded/CancelServiceStatus")] + public async Task CancelServiceStatus([FromBody] ModifyServiceProjectStatusDto model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == model.BookingId); + + if (bookingOrder == null) + throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废"); + + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); + + TrackingMessageInfo msgInfo = new TrackingMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageMainInfo + { + BusiId = model.BookingId.ToString(), + BusiSystemCode = "BOOKING_ORDER", + MBlNo = bookingOrder.MBLNO, + VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}", + OrderNo = bookingOrder.BSNO, + PushType = TrackingPushTypeEnum.Status, + OperTenantId = bookingOrder.TenantId.Value, + OperTenantName = bookingOrder.TenantName, + OpertType = TrackingOperTypeEnum.MANUAL, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, + SourceType = TrackingSourceTypeEnum.MANUAL, + StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo + { + StatusCode = a, + }).ToList() + } + }; + DateTime bDate = DateTime.Now; + + _logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); + + var rlt = await _serviceWorkFlowManageService.CancelStatus(msgInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") + , JSON.Serialize(rlt)); + + if (!rlt.succ) + { + result = rlt; + } + else + { + result.succ = true; + result.msg = "推送成功"; + } + + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"服务项目状态推送失败,原因:{ex.Message}"; + } + + return result; + } + #region 获取服务项目列表 /// /// 获取服务项目列表 diff --git a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs index 98d39465..5e3b284d 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs @@ -21,4 +21,20 @@ namespace Myshipping.Application /// public string[] ProjectCodes { get; set; } } + + /// + /// 修改服务项目状态 + /// + public class ModifyServiceProjectStatusDto + { + /// + /// 订舱主键 + /// + public long BookingId { get; set; } + + /// + /// 服务项目状态代码 + /// + public string[] StatusCodes { get; set; } + } } diff --git a/Myshipping.Application/Service/BookingOrder/IBookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/IBookingValueAddedService.cs index fa1d054a..7fcab96c 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingValueAddedService.cs @@ -117,5 +117,19 @@ namespace Myshipping.Application /// 返回回执 Task GetServiceStatusList(QueryServiceProjectWithStatus model); + /// + /// 保存服务状态 + /// + /// 修改服务状态详情 + /// 返回回执 + Task SaveServiceStatus(ModifyServiceProjectStatusDto model); + + /// + /// 取消服务状态 + /// + /// 修改服务状态详情 + /// 返回回执 + Task CancelServiceStatus(ModifyServiceProjectStatusDto model); + } } diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs index 14b16b1e..c81ac913 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs @@ -66,6 +66,11 @@ namespace Myshipping.Application /// public Nullable ActDate { get; set; } + /// + /// 状态数量(含子状态) + /// + public int StatusNum { get; set; } + /// /// 状态列表 /// diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs index c7117f78..15bcd3d5 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs @@ -158,6 +158,11 @@ namespace Myshipping.Application /// public TrackingPushTypeEnum PushType { get; set; } + /// + /// 来源类型 + /// + public TrackingSourceTypeEnum SourceType { get; set; } + /// /// 服务项目列表 /// diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs index 6e65f3cf..967c580a 100644 --- a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs @@ -49,14 +49,6 @@ namespace Myshipping.Application /// 返回回执 Task QueryServiceInfo(TrackingQueryMessageInfo info); - - /// - /// 取消服务项目 - /// - /// 服务流程报文详情 - /// 返回回执 - Task CancelProject(TrackingMessageInfo info); - /// /// 校验取消状态 /// diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index c7754d6e..e502045c 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -135,9 +135,11 @@ namespace Myshipping.Application var projectList = _cache.Get>($"{CONST_CACHE_ENABLE_PROJECT}_{info.Main.OperTenantId}"); + DateTime nowDate = DateTime.Now; + if (info.Main.PushType == TrackingPushTypeEnum.Project) { - if(info.Main.ProjectList == null || info.Main.ProjectList.Count == 0) + if (info.Main.ProjectList == null || info.Main.ProjectList.Count == 0) { _logger.LogInformation("批次={no} 推送类型是【服务项目】,服务项目列表不能为空", batchNo); @@ -149,7 +151,7 @@ namespace Myshipping.Application .Where(a => a.BUSI_ID == info.Main.BusiId && a.BUSI_SYSTEM_CODE.Equals(info.Main.BusiSystemCode) && !a.IsDeleted && a.TenantId == info.Main.OperTenantId).ToList(); - var needProjectArg = info.Main.ProjectList.Select(a=>a.ServiceProjectCode).ToArray(); + var needProjectArg = info.Main.ProjectList.Select(a => a.ServiceProjectCode).ToArray(); var needProjectList = statusList.Where(a => needProjectArg.Contains(a.ProjectCode)).ToList(); @@ -168,10 +170,11 @@ namespace Myshipping.Application return new { OperType = "Update", Info = l, Run = currList.FirstOrDefault() }; }).ToList(); - DateTime nowDate = DateTime.Now; + - tskList.ForEach(async tsk => { - if(tsk.OperType == "Insert") + tskList.ForEach(async tsk => + { + if (tsk.OperType == "Insert") { ServiceWorkFlowRunInfo serviceWorkFlowRunInfo = new ServiceWorkFlowRunInfo { @@ -200,10 +203,10 @@ namespace Myshipping.Application await _serviceWorkFlowRunInfoRepository.InsertAsync(serviceWorkFlowRunInfo); } - else if(tsk.OperType == "Update") + else if (tsk.OperType == "Update") { - var runInfo = _serviceWorkFlowRunInfoRepository.AsQueryable() - .First(a => a.PK_ID == tsk.Run.PK_ID); + var runInfo = _serviceWorkFlowRunInfoRepository.AsQueryable() + .First(a => a.PK_ID == tsk.Run.PK_ID); runInfo.IS_YIELD = 1; runInfo.ACT_DATE = nowDate; @@ -221,259 +224,194 @@ namespace Myshipping.Application return result; } - + //校验状态代码是否一致,不一致直接返回错误不允许推送 var statusArg = info.Main.StatusList.Select(a => a?.StatusCode.ToUpper()) .Where(a => !string.IsNullOrWhiteSpace(a)).Distinct().ToArray(); if (statusArg.Length == 0) { - _logger.LogInformation("批次={no} 报文Main的状态列表至少需要提供一个以上的状态信息", batchNo); - - throw Oops.Oh($"报文Main的状态列表至少需要提供一个以上的状态信息", typeof(InvalidOperationException)); - } - - - UserTendDto userTendInfo = GetUserTendInfo(info.Main.OperUserId); - - //检索状态对应所有的服务流程,如果已经提取到的状态数量与推送的不一致,提示错误不能入库s - var skuList = _statusSkuBaseInfoRepository.AsQueryable().Filter(null, true) - .LeftJoin((sts, act) => sts.PK_ID == act.STATUS_SKU_ID) - .LeftJoin((sts,act,rela)=> - act.PK_ID == rela.SERVICE_ACTIVITIES_ID) - .LeftJoin((sts, act, rela,wf)=> - rela.SERVICE_WORKFLOW_ID == wf.PK_ID && rela.WF_VERSION == wf.RELEASE_VERSION) - .Where((sts, act) => statusArg.Contains(sts.STATUS_SKU_CODE) && !sts.IsDeleted && sts.IS_ENABLE == 1 - && !act.IsDeleted) - .Select((sts, act,rela,wf) => - new { Sku = sts, Act = act, Rela = rela,WF = wf }).ToList(); - - //推送状态与已有状态进行匹配 - var reqStatusList = - info.Main.StatusList.GroupJoin(skuList, l => l.StatusCode, r => r.Sku.STATUS_SKU_CODE, - (l, r) => - { - var currList = r.ToList(); - if (currList.Count > 0) - return new { Exists = true, Sku = currList.FirstOrDefault().Sku,Act = currList.FirstOrDefault().Act,Req = l }; - - return new { Exists = false, Sku = new StatusSkuBaseInfo(), Act = new ServiceWorkFlowActivitiesInfo(),Req = l }; - }).ToList(); + _logger.LogInformation("批次={no} 服务状态列表不能为空", batchNo); - //如果有不存在的状态则提示无法入库 - if (reqStatusList.Any(a => !a.Exists)) - { - var errList = - reqStatusList.Where(a => !a.Exists) - .Select(a => a.Req.StatusCode).ToArray(); - - string errMsg = $"以下状态不存在 {(string.Join(",", errList))} 不能入库"; - - _logger.LogInformation("批次={no} {msg}", batchNo, errMsg); - - throw Oops.Oh(errMsg, typeof(InvalidOperationException)); + throw Oops.Oh($"服务状态列表不能为空", typeof(InvalidOperationException)); } - //先从运行表按主键获取运行主表和活动表 - var runList = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true) - .LeftJoin( - (m, s) => m.PK_ID == s.RUN_ID) - .Where((m, s) => m.BUSI_ID == info.Main.BusiId - && m.BUSI_SYSTEM_CODE.Equals(info.Main.BusiSystemCode) && !m.IsDeleted && !s.IsDeleted) - .Select((m, s) => new { main = m, sub = s }).ToList(); - - var wfList = skuList.Select(a => a.WF) - .Distinct().ToList(); - - var checkList = wfList.GroupJoin(runList, l => l.PK_ID, - r => r.main.SERVICE_WF_ID, - (l, r) => - { - var currList = r.ToList(); - - if (currList.Count > 0) - { - return new { Exists = true, WF = l }; - } - - return new { Exists = false, WF = l }; + /* + 1、从缓存拉取服务项目和状态详情。 + 2、检索所有相关状态的服务项目。 + 3、拉取run表相关的订单记录。 + 4、如果当前订单没有记录,需要按照服务项目和状态生成run表记录。 + 5、标记相关状态为完成,并更新时间。 + */ + statusList = statusList.Where(a => a.StatusList.Any(b => + statusArg.Contains(b.StatusSKUCode))).ToList(); - }).ToList(); + if (statusList.Count == 0) + throw Oops.Oh($"未检索到可用服务项目和状态列表", typeof(InvalidOperationException)); - if(checkList.Any(a=>a.Exists)) - { - reqStatusList.ForEach(async reqMd => - { - var currRun = - runList.FirstOrDefault(x => x.sub.PK_ID == reqMd.Act.PK_ID); + var wfArgs = statusList.Select(a => a.WFPKId).ToArray(); - var currRunAct = currRun.sub; - - currRunAct.ACT_DATE = reqMd.Req.StatusDate; - currRunAct.IS_YIELD = 1; - - await _serviceWorkFlowRunActivitiesInfoRepository.AsUpdateable(currRunAct).UpdateColumns(it => new - { - it.ACT_DATE, - it.IS_YIELD, - }).ExecuteCommandAsync(); - }); - } + //获取订单下所有Run表记录 + var runHisList = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true) + .LeftJoin((main, detail) + => main.PK_ID == detail.RUN_ID) + .Where((main, detail) + => main.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && main.BUSI_ID == info.Main.BusiId + && !main.IsDeleted && !detail.IsDeleted && wfArgs.Contains(main.SERVICE_WF_ID)) + .Select((main, detail) => new { Main = main, Detail = detail }).ToList(); + /* + 1、判断run表有记录的直接标记完成和完成时间。 + 2、没有run表记录的,根据流程写入run表,并标记完成和完成时间。 + */ - if (checkList.Any(a => !a.Exists)) + info.Main.StatusList.ForEach(async st => { - var noExistsList = checkList.Where(l => !l.Exists).Select(a=>a.WF.PK_ID).Distinct().ToList(); + var relateList = statusList.Where(a => a.StatusList.Any(b => + st.StatusCode.Contains(b.StatusSKUCode))).ToList(); - //状态关联的服务流程与运行表中的服务流程对应,对已经有的进行更新,对未进入运行表的进行写入 - var actArg = reqStatusList.Select(a => a.Act.PK_ID).ToArray(); - //根据服务流程活动获取所有相关的服务流程 - var wfRlt = _serviceWorkFlowBaseService.GetServiceWorkFlowListByActivities(actArg).GetAwaiter().GetResult(); - if (!wfRlt.succ) + relateList.ForEach(async rt => { - string errMsg = $"获取服务流程失败,原因:{wfRlt.msg}"; - - _logger.LogInformation("批次={no} {msg}", batchNo, errMsg); - - throw Oops.Oh(errMsg, typeof(InvalidOperationException)); - } - - var list = JSON.Deserialize>(JSON.Serialize(wfRlt.ext)); + var runList = + runHisList.Where(a => a.Main.SERVICE_WF_ID == rt.WFPKId).ToList(); - if(list.Count > 0) - list = list.Where(a=> noExistsList.Contains( a.PKId)).ToList(); - - DateTime nowDate = DateTime.Now; - - list.ForEach(async wf => - { - ServiceWorkFlowRunInfo serviceWorkFlowRunInfo = new ServiceWorkFlowRunInfo + if(runList.Count == 0) { - PK_ID = IDGen.NextID().ToString(), - SERVICE_WF_ID = wf.PKId, - BUSI_SYSTEM_CODE = info.Main.BusiSystemCode.ToUpper(), - BUSI_ID = info.Main.BusiId.ToUpper(), - MBL_NO = info.Main?.MBlNo.ToUpper(), - VESSEL_VOYNO = info.Main?.VesselVoyno.ToUpper(), - ORDER_NO = info.Main?.OrderNo, - STATUS = TaskStatusEnum.Create.ToString(), - RELEASE_VERSION = wf.ReleaseVersion, - ACTIVITIES_NUM = wf.StatusNum, - CreatedTime = nowDate, - UpdatedTime = nowDate, - CreatedUserId = userTendInfo.userId, - CreatedUserName = userTendInfo.userName, - TenantId = userTendInfo.tendId, - TenantName = userTendInfo.tenantName, - SERVICE_PROJECT_CODE = wf.ServiceProject.ServiceProjectCode, - SERVICE_PROJECT_NAME = wf.ServiceProject.ServiceProjectName, - }; - - await _serviceWorkFlowRunInfoRepository.InsertAsync(serviceWorkFlowRunInfo); - - int endNum = wf.StatusSkuList.Max(sku => sku.SortNo); - - string lastActId = string.Empty; - - wf.StatusSkuList.ForEach(async sku => { - - var currReq = - reqStatusList.FirstOrDefault(x => x.Act.PK_ID == sku.PKId); - - ServiceWorkFlowRunActivitiesInfo activitiesRunInfo = new ServiceWorkFlowRunActivitiesInfo + #region 处理run表 + //需要生成run表记录包含活动明细 + ServiceWorkFlowRunInfo serviceWorkFlowRunInfo = new ServiceWorkFlowRunInfo { PK_ID = IDGen.NextID().ToString(), - RUN_ID = serviceWorkFlowRunInfo.PK_ID, - EXEC_SORT_NO = sku.SortNo, - IS_START = sku.SortNo == 1 ? 1 : 0, - IS_END = sku.SortNo == endNum ? 1 : 0, - ACT_ID = sku.PKId, - STATUS_SKU_CODE = sku.statusSkuBase.StatusSKUCode, - STATUS_SKU_ID = sku.StatusSKUId, - SHOW_NAME = sku.ShowName, - IS_SUB = 0, - IS_SUB_JUST = 0, - IS_YIELD = 0, + SERVICE_WF_ID = rt.WFPKId, + BUSI_SYSTEM_CODE = info.Main.BusiSystemCode.ToUpper(), + BUSI_ID = info.Main.BusiId.ToUpper(), + MBL_NO = info.Main?.MBlNo.ToUpper(), + VESSEL_VOYNO = info.Main?.VesselVoyno.ToUpper(), + ORDER_NO = info.Main?.OrderNo, + STATUS = TaskStatusEnum.Create.ToString(), + RELEASE_VERSION = rt.ReleaseVersion, + ACTIVITIES_NUM = rt.StatusNum, CreatedTime = nowDate, UpdatedTime = nowDate, - CreatedUserId = userTendInfo.userId, - CreatedUserName = userTendInfo.userName, - TenantId = userTendInfo.tendId, - TenantName = userTendInfo.tenantName, - IsDeleted = false, - SOURCE_TYPE = "AUTO" + CreatedUserId = long.Parse(info.Main.OperUserId), + CreatedUserName = info.Main.OperUserName, + TenantId = info.Main.OperTenantId, + TenantName = info.Main.OperTenantName, + SERVICE_PROJECT_CODE = rt.ProjectCode, + SERVICE_PROJECT_NAME = rt.ProjectName, + SERVICE_PROJECT_ID = rt.ProjectPKId, + IS_YIELD = 1, + ACT_DATE = nowDate, }; - if (currReq != null) - { - activitiesRunInfo.ACT_DATE = currReq.Req.StatusDate; - activitiesRunInfo.ACT_VAL = currReq.Req.StatusVal; - activitiesRunInfo.IS_YIELD = 1; - } - - - if (!string.IsNullOrWhiteSpace(lastActId)) - activitiesRunInfo.NEXT_ACT_ID = lastActId; + //写入run主表 + await _serviceWorkFlowRunInfoRepository.InsertAsync(serviceWorkFlowRunInfo); - await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesRunInfo); + //获取状态最大数 + int endNum = rt.StatusList.Max(sku => sku.SortNo); - lastActId = activitiesRunInfo.PK_ID; + string lastActId = string.Empty; - if (sku.IsContainsSub == 1) + rt.StatusList.ForEach(async sku => { - string lastSubActId = string.Empty; + ServiceWorkFlowRunActivitiesInfo activitiesRunInfo = new ServiceWorkFlowRunActivitiesInfo + { + PK_ID = IDGen.NextID().ToString(), + RUN_ID = serviceWorkFlowRunInfo.PK_ID, + EXEC_SORT_NO = sku.SortNo, + IS_START = sku.SortNo == 1 ? 1 : 0, + IS_END = sku.SortNo == endNum ? 1 : 0, + ACT_ID = sku.ActPKId, + STATUS_SKU_CODE = sku.StatusSKUCode, + STATUS_SKU_ID = sku.SkuPKId, + SHOW_NAME = sku.ShowName, + IS_SUB = 0, + IS_SUB_JUST = 0, + IS_YIELD = 0, + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = long.Parse(info.Main.OperUserId), + CreatedUserName = info.Main.OperUserName, + TenantId = info.Main.OperTenantId, + TenantName = info.Main.OperTenantName, + IsDeleted = false, + SOURCE_TYPE = info.Main.SourceType.ToString(), + }; - sku.SubList.ForEach(async sub => { + if (st.StatusCode.Equals(sku.StatusSKUCode,StringComparison.OrdinalIgnoreCase)) + { + activitiesRunInfo.IS_YIELD = 1; + activitiesRunInfo.ACT_DATE = nowDate; + activitiesRunInfo.ACT_VAL = st.StatusVal; + } - var currSubReq = - reqStatusList.FirstOrDefault(x => x.Act.PK_ID == sub.PKId); + //写入run活动表 + await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesRunInfo); - ServiceWorkFlowRunActivitiesInfo activitiesSubRunInfo = new ServiceWorkFlowRunActivitiesInfo - { - PK_ID = IDGen.NextID().ToString(), - RUN_ID = serviceWorkFlowRunInfo.PK_ID, - EXEC_SORT_NO = sub.SortNo, - IS_START = sub.SortNo == 1 ? 1 : 0, - IS_END = sub.SortNo == endNum ? 1 : 0, - ACT_ID = sub.PKId, - STATUS_SKU_CODE = sub.statusSkuBase.StatusSKUCode, - STATUS_SKU_ID = sub.StatusSKUId, - SHOW_NAME = sub.ShowName, - IS_SUB = 1, - IS_SUB_JUST = 1, - IS_YIELD = 0, - CreatedTime = nowDate, - UpdatedTime = nowDate, - CreatedUserId = userTendInfo.userId, - CreatedUserName = userTendInfo.userName, - TenantId = userTendInfo.tendId, - TenantName = userTendInfo.tenantName, - IsDeleted = false, - SOURCE_TYPE = "AUTO", - PARENT_ID = activitiesRunInfo.PK_ID - }; - - if (currSubReq != null) - { - activitiesSubRunInfo.ACT_DATE = currSubReq.Req.StatusDate; - activitiesSubRunInfo.ACT_VAL = currSubReq.Req.StatusVal; - activitiesSubRunInfo.IS_YIELD = 1; - } + if (sku.SubStatusList != null && sku.SubStatusList.Count > 0) + { + string lastSubActId = string.Empty; - if (!string.IsNullOrWhiteSpace(lastSubActId)) - activitiesSubRunInfo.NEXT_ACT_ID = lastSubActId; + sku.SubStatusList.ForEach(async sub => { + + ServiceWorkFlowRunActivitiesInfo activitiesSubRunInfo = new ServiceWorkFlowRunActivitiesInfo + { + PK_ID = IDGen.NextID().ToString(), + RUN_ID = serviceWorkFlowRunInfo.PK_ID, + EXEC_SORT_NO = sub.SortNo, + IS_START = sub.SortNo == 1 ? 1 : 0, + IS_END = sub.SortNo == endNum ? 1 : 0, + ACT_ID = sub.ActPKId, + STATUS_SKU_CODE = sub.StatusSKUCode, + STATUS_SKU_ID = sub.SkuPKId, + SHOW_NAME = sub.ShowName, + IS_SUB = 1, + IS_SUB_JUST = 1, + IS_YIELD = 0, + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = long.Parse(info.Main.OperUserId), + CreatedUserName = info.Main.OperUserName, + TenantId = info.Main.OperTenantId, + TenantName = info.Main.OperTenantName, + IsDeleted = false, + SOURCE_TYPE = info.Main.SourceType.ToString(), + PARENT_ID = activitiesRunInfo.PK_ID + }; - await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesSubRunInfo); + if (st.StatusCode.Equals(sub.StatusSKUCode, StringComparison.OrdinalIgnoreCase)) + { + activitiesSubRunInfo.IS_YIELD = 1; + activitiesSubRunInfo.ACT_DATE = nowDate; + activitiesSubRunInfo.ACT_VAL = st.StatusVal; + } - lastSubActId = activitiesSubRunInfo.PK_ID; + if (!string.IsNullOrWhiteSpace(lastSubActId)) + activitiesSubRunInfo.NEXT_ACT_ID = lastSubActId; - }); - } + await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesSubRunInfo); - }); + lastSubActId = activitiesSubRunInfo.PK_ID; + }); + } + }); + #endregion + } + else + { + if (runList.Any(b => b.Detail == null)) + { + //需要补充活动表明细 + } + else + { + //只需要更新完成标记和完成时间 + } + } }); - } + + }); result.succ = true; result.msg = "推送成功"; @@ -772,10 +710,66 @@ namespace Myshipping.Application throw Oops.Oh($"报文Main的业务主键不能为空", typeof(InvalidOperationException)); } - if (info.Main.StatusList == null || info.Main.StatusList.Count == 0) + var statusList = _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(info.Main.OperTenantId.ToString()).GetAwaiter().GetResult(); + + var projectList = _cache.Get>($"{CONST_CACHE_ENABLE_PROJECT}_{info.Main.OperTenantId}"); + + if (info.Main.PushType == TrackingPushTypeEnum.Project) { - _logger.LogInformation("批次={no} 接收推送状态错误 报文Main的状态列表不能为空,并且至少需要提供一个以上的状态信息", batchNo); - throw Oops.Oh($"报文Main的状态列表不能为空,并且至少需要提供一个以上的状态信息", typeof(InvalidOperationException)); + if (info.Main.ProjectList == null || info.Main.ProjectList.Count == 0) + { + _logger.LogInformation("批次={no} 推送类型是【服务项目】,服务项目列表不能为空", batchNo); + + throw Oops.Oh($"推送类型是【服务项目】,服务项目列表不能为空", typeof(InvalidOperationException)); + } + + //提取所有已经有run记录的 + var runBaseList = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true) + .Where(a => a.BUSI_ID == info.Main.BusiId && a.BUSI_SYSTEM_CODE.Equals(info.Main.BusiSystemCode) + && !a.IsDeleted && a.TenantId == info.Main.OperTenantId).ToList(); + + var needProjectArg = info.Main.ProjectList.Select(a => a.ServiceProjectCode).ToArray(); + + var needProjectList = statusList.Where(a => needProjectArg.Contains(a.ProjectCode)).ToList(); + + var tskList = needProjectList.GroupJoin(runBaseList, l => l.WFPKId, + r => r.SERVICE_WF_ID, + (l, r) => + { + var currList = r.ToList(); + + if (currList.Count == 0) + { + //标识当前服务项目写入运行主表 + return new { OperType = "None", Info = l, Run = new ServiceWorkFlowRunInfo() }; + } + + return new { OperType = "Update", Info = l, Run = currList.FirstOrDefault() }; + }).ToList(); + + DateTime nowDate = DateTime.Now; + + tskList.ForEach(async tsk => { + if (tsk.OperType == "Update") + { + var runInfo = _serviceWorkFlowRunInfoRepository.AsQueryable() + .First(a => a.PK_ID == tsk.Run.PK_ID); + + runInfo.IS_YIELD = 0; + runInfo.ACT_DATE = null; + + await _serviceWorkFlowRunInfoRepository.AsUpdateable(runInfo).UpdateColumns(it => new + { + it.ACT_DATE, + it.IS_YIELD, + }).ExecuteCommandAsync(); + } + }); + + result.succ = true; + result.msg = "取消成功"; + + return result; } @@ -1170,24 +1164,6 @@ namespace Myshipping.Application return result; } - #region 取消服务项目 - /// - /// 取消服务项目 - /// - /// 服务流程报文详情 - /// 返回回执 - public async Task CancelProject(TrackingMessageInfo info) - { - TaskManageOrderResultDto result = new TaskManageOrderResultDto(); - - string batchNo = IDGen.NextID().ToString(); - - _logger.LogInformation("批次={no} 接收推送状态 msg={msg}", batchNo, JSON.Serialize(info)); - - return result; - } - #endregion - #region 校验取消状态 /// /// 校验取消状态 From d59cc41381d43934572921cc1d694af6f78e39aa Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 4 Aug 2023 16:03:27 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=92=8C=E5=8F=96=E6=B6=88=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingValueAddedService.cs | 8 +++++-- .../Dto/ModifyServiceProjectDto.cs | 22 +++++++++++++++++-- .../Dtos/TrackingMessageInfo.cs | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index b7028c52..fb291819 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2279,7 +2279,9 @@ namespace Myshipping.Application SourceType = TrackingSourceTypeEnum.MANUAL, StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo { - StatusCode = a, + StatusCode = a.StatusCode, + StatusDate = a.SetActDate, + StatusVal = a.SetActVal }).ToList() } }; @@ -2368,7 +2370,9 @@ namespace Myshipping.Application SourceType = TrackingSourceTypeEnum.MANUAL, StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo { - StatusCode = a, + StatusCode = a.StatusCode, + StatusDate = a.SetActDate, + StatusVal = a.SetActVal }).ToList() } }; diff --git a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs index 5e3b284d..243a538b 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs @@ -33,8 +33,26 @@ namespace Myshipping.Application public long BookingId { get; set; } /// - /// 服务项目状态代码 + /// 服务项目状态明细 /// - public string[] StatusCodes { get; set; } + public List StatusCodes { get; set; } + } + + public class ModifyServiceProjectStatusDetailDto + { + /// + /// 状态代码 + /// + public string StatusCode { get; set; } + + /// + /// 人工设定状态完成时间 + /// + public Nullable SetActDate { get; set; } + + /// + /// 人工设定状态值(可传箱使天数) + /// + public string SetActVal { get; set; } } } diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs index 15bcd3d5..22351c2e 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs @@ -202,7 +202,7 @@ namespace Myshipping.Application /// /// 状态产生时间 /// - public DateTime StatusDate { get; set; } + public Nullable StatusDate { get; set; } /// /// 状态产生值 From e819764f3bfdbd243946e247a7c140e70da6e437 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Fri, 4 Aug 2023 17:05:37 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B4=BE=E8=BD=A6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AE=A2=E8=88=B1=E7=9A=84=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingTruck/BookingTruckService.cs | 8 +- .../ServiceWorkFlowManageService.cs | 184 +++++++++++++++++- 2 files changed, 181 insertions(+), 11 deletions(-) diff --git a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs index d17690da..01531eaf 100644 --- a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs +++ b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs @@ -1873,7 +1873,8 @@ namespace Myshipping.Application _bookingOrderRepository.AsUpdateable(bookingOrder).UpdateColumns(it => new { it.TRUCKERID, - it.TRUCKER + it.TRUCKER, + it.VERSION }).ExecuteCommand(); var syncDongshengRlt = await _bookingOrderService.SendBookingOrder(new long[] { bookingTruckInfo.BookingId.Value }); @@ -1904,7 +1905,8 @@ namespace Myshipping.Application _bookingOrderRepository.AsUpdateable(bookingOrder).UpdateColumns(it => new { it.TRUCKERID, - it.TRUCKER + it.TRUCKER, + it.VERSION }).ExecuteCommand(); //这里直接调用订舱服务的功能,担心有异常所以这里单独做了异常捕获 @@ -1930,8 +1932,6 @@ namespace Myshipping.Application if (bookingTruckInfo.TenantId.HasValue) messageInfo.Main.TenantId = bookingTruckInfo.TenantId.Value; - - var mqRlt = await PushSyncBookingTruckMQToDS6(messageInfo); _logger.LogInformation("发送MQ,rlt={rlt}", JSON.Serialize(mqRlt)); diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index e502045c..9a89d39e 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -243,8 +243,18 @@ namespace Myshipping.Application 4、如果当前订单没有记录,需要按照服务项目和状态生成run表记录。 5、标记相关状态为完成,并更新时间。 */ - statusList = statusList.Where(a => a.StatusList.Any(b => - statusArg.Contains(b.StatusSKUCode))).ToList(); + statusList = statusList.Where(a => + a.StatusList.Any(b => + { + if (statusArg.Contains(b.StatusSKUCode)) + return true; + + if (b.SubStatusList != null && b.SubStatusList.Any(c => + statusArg.Contains(c.StatusSKUCode))) + return true; + + return false; + })).ToList(); if (statusList.Count == 0) throw Oops.Oh($"未检索到可用服务项目和状态列表", typeof(InvalidOperationException)); @@ -257,7 +267,7 @@ namespace Myshipping.Application => main.PK_ID == detail.RUN_ID) .Where((main, detail) => main.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && main.BUSI_ID == info.Main.BusiId - && !main.IsDeleted && !detail.IsDeleted && wfArgs.Contains(main.SERVICE_WF_ID)) + && wfArgs.Contains(main.SERVICE_WF_ID)) .Select((main, detail) => new { Main = main, Detail = detail }).ToList(); /* @@ -267,8 +277,17 @@ namespace Myshipping.Application info.Main.StatusList.ForEach(async st => { - var relateList = statusList.Where(a => a.StatusList.Any(b => - st.StatusCode.Contains(b.StatusSKUCode))).ToList(); + var relateList = statusList.Where(a => + a.StatusList.Any(b => + { + if (b.StatusSKUCode.Equals(st.StatusCode, StringComparison.OrdinalIgnoreCase)) + return true; + + if (b.SubStatusList != null && b.SubStatusList.Any(c => c.StatusSKUCode.Equals(st.StatusCode, StringComparison.OrdinalIgnoreCase))) + return true; + + return false; + })).ToList(); relateList.ForEach(async rt => { @@ -341,7 +360,16 @@ namespace Myshipping.Application if (st.StatusCode.Equals(sku.StatusSKUCode,StringComparison.OrdinalIgnoreCase)) { activitiesRunInfo.IS_YIELD = 1; - activitiesRunInfo.ACT_DATE = nowDate; + + if(st.StatusDate.HasValue) + { + activitiesRunInfo.ACT_DATE = st.StatusDate.Value; + } + else + { + activitiesRunInfo.ACT_DATE = nowDate; + } + activitiesRunInfo.ACT_VAL = st.StatusVal; } @@ -382,7 +410,16 @@ namespace Myshipping.Application if (st.StatusCode.Equals(sub.StatusSKUCode, StringComparison.OrdinalIgnoreCase)) { activitiesSubRunInfo.IS_YIELD = 1; - activitiesSubRunInfo.ACT_DATE = nowDate; + + if (st.StatusDate.HasValue) + { + activitiesSubRunInfo.ACT_DATE = st.StatusDate.Value; + } + else + { + activitiesSubRunInfo.ACT_DATE = nowDate; + } + activitiesSubRunInfo.ACT_VAL = st.StatusVal; } @@ -402,11 +439,144 @@ namespace Myshipping.Application { if (runList.Any(b => b.Detail == null)) { + var runMain = runList.FirstOrDefault().Main; //需要补充活动表明细 + var runEntity =_serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true) + .First(rn => rn.PK_ID == runMain.PK_ID); + + if(runEntity != null && runEntity.IS_YIELD == 0) + { + runEntity.IS_YIELD = 1; + runEntity.ACT_DATE = nowDate; + runEntity.UpdatedTime = nowDate; + runEntity.CreatedUserId = long.Parse(info.Main.OperUserId); + runEntity.CreatedUserName = info.Main.OperUserName; + + await _serviceWorkFlowRunInfoRepository.AsUpdateable(runEntity).UpdateColumns(it => new + { + it.ACT_DATE, + it.IS_YIELD, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } + + //批量写入活动表 + #region 批量写入活动表 + //获取状态最大数 + int endNum = rt.StatusList.Max(sku => sku.SortNo); + + string lastActId = string.Empty; + + rt.StatusList.ForEach(async sku => + { + ServiceWorkFlowRunActivitiesInfo activitiesRunInfo = new ServiceWorkFlowRunActivitiesInfo + { + PK_ID = IDGen.NextID().ToString(), + RUN_ID = runEntity.PK_ID, + EXEC_SORT_NO = sku.SortNo, + IS_START = sku.SortNo == 1 ? 1 : 0, + IS_END = sku.SortNo == endNum ? 1 : 0, + ACT_ID = sku.ActPKId, + STATUS_SKU_CODE = sku.StatusSKUCode, + STATUS_SKU_ID = sku.SkuPKId, + SHOW_NAME = sku.ShowName, + IS_SUB = 0, + IS_SUB_JUST = 0, + IS_YIELD = 0, + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = long.Parse(info.Main.OperUserId), + CreatedUserName = info.Main.OperUserName, + TenantId = info.Main.OperTenantId, + TenantName = info.Main.OperTenantName, + IsDeleted = false, + SOURCE_TYPE = info.Main.SourceType.ToString(), + }; + + if (st.StatusCode.Equals(sku.StatusSKUCode, StringComparison.OrdinalIgnoreCase)) + { + activitiesRunInfo.IS_YIELD = 1; + + if (st.StatusDate.HasValue) + { + activitiesRunInfo.ACT_DATE = st.StatusDate.Value; + } + else + { + activitiesRunInfo.ACT_DATE = nowDate; + } + + activitiesRunInfo.ACT_VAL = st.StatusVal; + } + + //写入run活动表 + await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesRunInfo); + + if (sku.SubStatusList != null && sku.SubStatusList.Count > 0) + { + string lastSubActId = string.Empty; + + sku.SubStatusList.ForEach(async sub => { + + ServiceWorkFlowRunActivitiesInfo activitiesSubRunInfo = new ServiceWorkFlowRunActivitiesInfo + { + PK_ID = IDGen.NextID().ToString(), + RUN_ID = runEntity.PK_ID, + EXEC_SORT_NO = sub.SortNo, + IS_START = sub.SortNo == 1 ? 1 : 0, + IS_END = sub.SortNo == endNum ? 1 : 0, + ACT_ID = sub.ActPKId, + STATUS_SKU_CODE = sub.StatusSKUCode, + STATUS_SKU_ID = sub.SkuPKId, + SHOW_NAME = sub.ShowName, + IS_SUB = 1, + IS_SUB_JUST = 1, + IS_YIELD = 0, + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = long.Parse(info.Main.OperUserId), + CreatedUserName = info.Main.OperUserName, + TenantId = info.Main.OperTenantId, + TenantName = info.Main.OperTenantName, + IsDeleted = false, + SOURCE_TYPE = info.Main.SourceType.ToString(), + PARENT_ID = activitiesRunInfo.PK_ID + }; + + if (st.StatusCode.Equals(sub.StatusSKUCode, StringComparison.OrdinalIgnoreCase)) + { + activitiesSubRunInfo.IS_YIELD = 1; + + if (st.StatusDate.HasValue) + { + activitiesSubRunInfo.ACT_DATE = st.StatusDate.Value; + } + else + { + activitiesSubRunInfo.ACT_DATE = nowDate; + } + + activitiesSubRunInfo.ACT_VAL = st.StatusVal; + } + + if (!string.IsNullOrWhiteSpace(lastSubActId)) + activitiesSubRunInfo.NEXT_ACT_ID = lastSubActId; + + await _serviceWorkFlowRunActivitiesInfoRepository.InsertAsync(activitiesSubRunInfo); + + lastSubActId = activitiesSubRunInfo.PK_ID; + + }); + } + }); + #endregion } else { //只需要更新完成标记和完成时间 + } } });