From f098c881d7d7c3387e0e00c20935316133f39bf3 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 31 Jul 2023 17:20:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=8E=B7=E5=8F=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/ServiceProjectWithStatusDto.cs | 15 ++- .../ServiceWorkFlowBaseService.cs | 115 ++++++++++++++---- 2 files changed, 100 insertions(+), 30 deletions(-) diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs index dbb00811..b630f64c 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs @@ -74,11 +74,6 @@ namespace Myshipping.Application /// public string ActPKId { get; set; } - /// - /// 活动显示名称 - /// - public string ActShowName { get; set; } - /// /// 活动显示顺序号 /// @@ -104,6 +99,16 @@ namespace Myshipping.Application /// public string ShowName { get; set; } + /// + /// 流程主键 + /// + public string WFPKId { get; set; } + + /// + /// 父活动主键 + /// + public string ParentActPKId { get; set; } + /// /// 显示顺序号 /// diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs index 36298f2b..39fc396f 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs @@ -13,6 +13,7 @@ using Myshipping.Application.Helper; using Myshipping.Core; using Myshipping.Core.Entity; using MySqlX.XDevAPI.Common; +using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.PTG; using NPOI.Util; using SqlSugar; @@ -1760,13 +1761,19 @@ namespace Myshipping.Application /// 租户ID /// 是否不从缓存取值 /// 返回回执 + [HttpGet("/ServiceWorkFlowBase/GetEnableProjectWithStatusList")] public async Task> GetEnableProjectWithStatusList([FromQuery] string tenantId, [FromQuery] bool isAvoidCache = false) { + if(string.IsNullOrWhiteSpace(tenantId)) + { + throw Oops.Oh($"租户ID不能为空", typeof(InvalidOperationException)); + } + List statusList = _cache.Get>($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}"); if (isAvoidCache || statusList == null || statusList.Count == 0) { - CreateCacheInfo(tenantId); + statusList = CreateCacheInfo(tenantId); //await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList); } @@ -1775,7 +1782,7 @@ namespace Myshipping.Application } #endregion - private void CreateCacheInfo(string tenantId) + private List CreateCacheInfo(string tenantId) { var statusSKUList = _statusSkuBaseInfoRepository.AsQueryable().Filter(null, true) .Where(a => !a.IsDeleted && a.IS_ENABLE == 1 && a.TenantId == long.Parse(tenantId)).ToList(); @@ -1814,8 +1821,75 @@ namespace Myshipping.Application arela, act) => new { WF = wf,Project = prj, ARela = arela, Act = act }).ToList(); + List subActList = new List(); + + if (list.Any(a => a.ARela.IS_CONTAINS_SUB == 1)) + { + //如果存在子活动的,需要关联 + var sublist = + _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true) + .InnerJoin((wf, rela) + => wf.PK_ID == rela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == rela.WF_VERSION) + .InnerJoin((wf, rela, act) + => rela.SUB_SERVICE_ACTIVITIES_ID == act.PK_ID) + .LeftJoin((wf, rela, act, trgrela) + => wf.PK_ID == trgrela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == trgrela.WF_VERSION && act.PK_ID == trgrela.SERVICE_ACTIVITIES_ID) + .LeftJoin((wf, rela, act, trgrela, trg) + => trgrela.STATUS_TRIGGER_ID == trg.PK_ID) + .Where((wf, rela, act, + trgrela, trg) + => !string.IsNullOrWhiteSpace(wf.RELEASE_VERSION) && wf.BELONG_TENANT_ID == long.Parse(tenantId) + && wf.IS_ENABLE == 1 && !wf.IsDeleted) + .Select((wf, rela, act) + => new { WF = wf, Rela = rela, Act = act }).ToList(); + + subActList = sublist.GroupBy(a=>a.Rela.SERVICE_ACTIVITIES_ID) + .Select(a => { + var currList = a.ToList(); + + var act = currList.FirstOrDefault().Act; + var rela = currList.FirstOrDefault().Rela; + var wf = currList.FirstOrDefault().WF; + + var dto = new ServiceProjectStatusDto + { + ActPKId = rela.SERVICE_ACTIVITIES_ID, + WFPKId = wf.PK_ID, + HasChild = false, + SubStatusList = new List() + }; + + dto.SubStatusList = currList.Select(e => { + + var skuInfo = statusSKUList.FirstOrDefault(e => e.PK_ID == act.STATUS_SKU_ID); + + var itemDto = new ServiceProjectStatusDto + { + SkuPKId = act.STATUS_SKU_ID, + ActPKId = act.PK_ID, + ShowName = act.SHOW_NAME, + ActSortNo = e.Rela.SORT_NO, + WFPKId = wf.PK_ID, + StatusSKUCode = skuInfo.STATUS_SKU_CODE, + StatusSKUName = skuInfo.STATUS_SKU_NAME, + BackgroundColor = skuInfo.BACKGROUND_COLOR, + SortNo = skuInfo.SORT_NO, + HasChild = false, + ParentActPKId = e.Rela.SERVICE_ACTIVITIES_ID, + SubStatusList = new List(), + TriggerList = new List() + }; + + return itemDto; + + }).ToList(); + + return dto; + }).ToList(); + } + var statusList = list.GroupBy(a - => a.Project.PK_ID) + => a.WF.PK_ID) .Select(a => { var currList = a.ToList(); @@ -1843,18 +1917,29 @@ namespace Myshipping.Application var act = currActList.FirstOrDefault().Act; var ARela = currActList.FirstOrDefault().ARela; + var skuInfo = statusSKUList.FirstOrDefault(e => e.PK_ID == act.STATUS_SKU_ID); var dto = new ServiceProjectStatusDto { SkuPKId = act.STATUS_SKU_ID, ActPKId = act.PK_ID, - ActShowName = act.SHOW_NAME, + ShowName = act.SHOW_NAME, ActSortNo = ARela.SORT_NO, + WFPKId = wf.PK_ID, + StatusSKUCode = skuInfo.STATUS_SKU_CODE, + StatusSKUName = skuInfo.STATUS_SKU_NAME, + BackgroundColor = skuInfo.BACKGROUND_COLOR, + SortNo = skuInfo.SORT_NO, HasChild = ARela.IS_CONTAINS_SUB == 1 ? true : false, SubStatusList = new List(), TriggerList = new List() }; + if(ARela.IS_CONTAINS_SUB == 1) + { + dto.SubStatusList = subActList.FirstOrDefault(e=>e.ActPKId == act.PK_ID).SubStatusList; + } + return dto; }).ToList(); @@ -1864,27 +1949,7 @@ namespace Myshipping.Application }).ToList(); - if (list.Any(a=>a.ARela.IS_CONTAINS_SUB == 1)) - { - //如果存在子活动的,需要关联 - var sublist = _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true) - .InnerJoin((wf, rela) - => wf.PK_ID == rela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == rela.WF_VERSION) - .InnerJoin((wf, rela,act) - => rela.SERVICE_ACTIVITIES_ID == act.PK_ID) - .LeftJoin((wf, rela,act, trgrela) - => wf.PK_ID == trgrela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == trgrela.WF_VERSION && act.PK_ID == trgrela.SERVICE_ACTIVITIES_ID) - .LeftJoin((wf, rela, act, trgrela, trg) - => trgrela.STATUS_TRIGGER_ID == trg.PK_ID) - .Where((wf, rela, prj, - arela, act) - => !string.IsNullOrWhiteSpace(wf.RELEASE_VERSION) && wf.BELONG_TENANT_ID == long.Parse(tenantId) - && wf.IS_ENABLE == 1 && !wf.IsDeleted) - .Select((wf, rela, act) - => new { WF = wf, Rela = rela, Act = act }).ToList(); - - - } + return statusList; } } }