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; } } }