修改服务项目检索

optimize
jianghaiqing 1 year ago
parent 574098a0c7
commit 97456c9aa9

@ -117,11 +117,11 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 子状态列表 /// 子状态列表
/// </summary> /// </summary>
List<ServiceProjectStatusDto> SubStatusList { get; set; } public List<ServiceProjectStatusDto> SubStatusList { get; set; }
/// <summary> /// <summary>
/// 触发器列表 /// 触发器列表
/// </summary> /// </summary>
List<string> TriggerList { get; set; } public List<string> TriggerList { get; set; }
} }
} }

@ -1725,7 +1725,8 @@ namespace Myshipping.Application
/// <param name="tenantId">租户ID</param> /// <param name="tenantId">租户ID</param>
/// <param name="isAvoidCache">是否不从缓存取值</param> /// <param name="isAvoidCache">是否不从缓存取值</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
public async Task<List<ServiceProjectBaseDto>> GetEnableProjectList(string tenantId, bool isAvoidCache = false) [HttpGet("/ServiceWorkFlowBase/GetEnableProjectList")]
public async Task<List<ServiceProjectBaseDto>> GetEnableProjectList([FromQuery]string tenantId, [FromQuery] bool isAvoidCache = false)
{ {
List<ServiceProjectBaseDto> projectList = _cache.Get<List<ServiceProjectBaseDto>>($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}"); List<ServiceProjectBaseDto> projectList = _cache.Get<List<ServiceProjectBaseDto>>($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}");
@ -1759,103 +1760,14 @@ namespace Myshipping.Application
/// <param name="tenantId">租户ID</param> /// <param name="tenantId">租户ID</param>
/// <param name="isAvoidCache">是否不从缓存取值</param> /// <param name="isAvoidCache">是否不从缓存取值</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
public async Task<List<ServiceProjectWithStatusDto>> GetEnableProjectWithStatusList(string tenantId, bool isAvoidCache = false) public async Task<List<ServiceProjectWithStatusDto>> GetEnableProjectWithStatusList([FromQuery] string tenantId, [FromQuery] bool isAvoidCache = false)
{ {
List<ServiceProjectWithStatusDto> statusList = _cache.Get<List<ServiceProjectWithStatusDto>>($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}"); List<ServiceProjectWithStatusDto> statusList = _cache.Get<List<ServiceProjectWithStatusDto>>($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}");
if (isAvoidCache || statusList == null || statusList.Count == 0) if (isAvoidCache || statusList == null || statusList.Count == 0)
{ {
var list = _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true) CreateCacheInfo(tenantId);
.InnerJoin<ServiceWorkFlowProjectRelation>((wf, rela) //await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList);
=> wf.PK_ID == rela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == rela.WF_VERSION)
.InnerJoin<ServiceProjectBaseInfo>((wf, rela, prj)
=> rela.SERVICE_PROJECT_ID == prj.PK_ID)
.InnerJoin<ServiceWorkFlowActivitiesRelation>((wf, rela, prj,
arela)
=> wf.PK_ID == arela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == arela.WF_VERSION)
.InnerJoin<ServiceWorkFlowActivitiesInfo>((wf, rela, prj,
arela, act)
=> arela.SERVICE_ACTIVITIES_ID == act.PK_ID)
.LeftJoin<ServiceWorkFlowActivitiesSubRelation>((wf, rela, prj,
arela, act, srela)
=> wf.PK_ID == srela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == srela.WF_VERSION)
.LeftJoin<ServiceWorkFlowActivitiesInfo>((wf, rela, prj,
arela, act, srela, sact)
=> srela.SERVICE_ACTIVITIES_ID == act.PK_ID)
.Where((wf, rela, prj,
arela, act, srela, sact)
=> !string.IsNullOrWhiteSpace(wf.RELEASE_VERSION) && wf.BELONG_TENANT_ID == long.Parse(tenantId)
&& wf.IS_ENABLE == 1 && !wf.IsDeleted)
.Select((wf, rela, prj,
arela, act, srela, sact)
=> new { Project = prj, ARela = arela, Act = act, SRela = srela, SAct = sact }).ToList();
var statusSKUList = _statusSkuBaseInfoRepository.AsQueryable().Filter(null, true)
.Where(a => !a.IsDeleted && a.IS_ENABLE == 1 && a.TenantId == long.Parse(tenantId)).ToList();
statusList = list.GroupBy(a
=> a.Project.PK_ID)
.Select(a =>
{
var currList = a.ToList();
var prjDto = a.FirstOrDefault().Project.Adapt<ServiceProjectWithStatusDto>();
/*
currList.GroupBy(b=>b.Act.PK_ID)
.Select(c => {
var currActList = c.ToList();
var actDto = c.FirstOrDefault().Act;
})
var actList = currList
.OrderBy(b=>b.ARela.SORT_NO)
.Select(b
=>
{
b.
})
.Distinct().ToList();
b.Act.Adapt<ServiceWorkFlowActivitiesDto>()
if (currList.Any(b=>b.SAct != null))
{
var subList = currList
.OrderBy(b => b.SRela.SORT_NO)
.Where(b =>
b.SAct != null)
.Select(b =>
{
return new { SRela = b.SRela, SAct = b.SAct };
})
.Distinct().ToList();
}
prjDto.statusList = actList.GroupJoin(statusSKUList, l => l.STATUS_SKU_ID,
r => r.PK_ID, (l, r) => {
ServiceProjectStatusDto statusDto = new ServiceProjectStatusDto();
var sku = r.FirstOrDefault();
if(sku != null) {
statusDto = sku.Adapt<ServiceProjectStatusDto>();
}
statusDto.ShowName = l.SHOW_NAME;
statusDto.ShowSortNo =
});
*/
return prjDto;
}).ToList();
await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList);
} }
return statusList; return statusList;
@ -1888,20 +1800,19 @@ namespace Myshipping.Application
.InnerJoin<ServiceWorkFlowActivitiesInfo>((wf, rela, prj, .InnerJoin<ServiceWorkFlowActivitiesInfo>((wf, rela, prj,
arela, act) arela, act)
=> arela.SERVICE_ACTIVITIES_ID == act.PK_ID) => arela.SERVICE_ACTIVITIES_ID == act.PK_ID)
.LeftJoin<ServiceWorkFlowActivitiesSubRelation>((wf, rela, prj, .LeftJoin<ServiceWorkFlowActivitiesTriggerRelation>((wf, rela, prj,
arela, act, srela) arela, act, trgrela)
=> wf.PK_ID == srela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == srela.WF_VERSION) => wf.PK_ID == trgrela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == trgrela.WF_VERSION && act.PK_ID == trgrela.SERVICE_ACTIVITIES_ID)
.LeftJoin<ServiceWorkFlowActivitiesInfo>((wf, rela, prj, .LeftJoin<StatusTriggerConditionInfo>((wf, rela, prj,
arela, act, srela, sact) arela, act, trgrela, trg)
=> srela.SERVICE_ACTIVITIES_ID == act.PK_ID) => trgrela.STATUS_TRIGGER_ID == trg.PK_ID)
.Where((wf, rela, prj, .Where((wf, rela, prj,
arela, act, srela, sact) arela, act)
=> !string.IsNullOrWhiteSpace(wf.RELEASE_VERSION) && wf.BELONG_TENANT_ID == long.Parse(tenantId) => !string.IsNullOrWhiteSpace(wf.RELEASE_VERSION) && wf.BELONG_TENANT_ID == long.Parse(tenantId)
&& wf.IS_ENABLE == 1 && !wf.IsDeleted) && wf.IS_ENABLE == 1 && !wf.IsDeleted)
.Select((wf, rela, prj, .Select((wf, rela, prj,
arela, act, srela, sact) arela, act)
=> new { WF = wf,Project = prj, ARela = arela, Act = act, SRela = srela, SAct = sact }).ToList(); => new { WF = wf,Project = prj, ARela = arela, Act = act }).ToList();
var statusList = list.GroupBy(a var statusList = list.GroupBy(a
=> a.Project.PK_ID) => a.Project.PK_ID)
@ -1909,10 +1820,11 @@ namespace Myshipping.Application
{ {
var currList = a.ToList(); var currList = a.ToList();
var wf = a.FirstOrDefault().WF; var wf = currList.FirstOrDefault().WF;
var project = a.FirstOrDefault().Project; var project = currList.FirstOrDefault().Project;
ServiceProjectWithStatusDto baseDto = new ServiceProjectWithStatusDto { ServiceProjectWithStatusDto baseDto = new ServiceProjectWithStatusDto
{
ProjectPKId = project.PK_ID, ProjectPKId = project.PK_ID,
ProjectCode = project.SERVICE_PROJECT_CODE, ProjectCode = project.SERVICE_PROJECT_CODE,
ProjectName = project.SERVICE_PROJECT_NAME, ProjectName = project.SERVICE_PROJECT_NAME,
@ -1929,10 +1841,19 @@ namespace Myshipping.Application
.Select(c => { .Select(c => {
var currActList = c.ToList(); var currActList = c.ToList();
var act = c.FirstOrDefault().Act; var act = currActList.FirstOrDefault().Act;
var ARela = currActList.FirstOrDefault().ARela;
var dto = new ServiceProjectStatusDto();
var dto = new ServiceProjectStatusDto
{
SkuPKId = act.STATUS_SKU_ID,
ActPKId = act.PK_ID,
ActShowName = act.SHOW_NAME,
ActSortNo = ARela.SORT_NO,
HasChild = ARela.IS_CONTAINS_SUB == 1 ? true : false,
SubStatusList = new List<ServiceProjectStatusDto>(),
TriggerList = new List<string>()
};
return dto; return dto;
@ -1942,6 +1863,28 @@ namespace Myshipping.Application
}).ToList(); }).ToList();
if (list.Any(a=>a.ARela.IS_CONTAINS_SUB == 1))
{
//如果存在子活动的,需要关联
var sublist = _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true)
.InnerJoin<ServiceWorkFlowActivitiesSubRelation>((wf, rela)
=> wf.PK_ID == rela.SERVICE_WORKFLOW_ID && wf.RELEASE_VERSION == rela.WF_VERSION)
.InnerJoin<ServiceWorkFlowActivitiesInfo>((wf, rela,act)
=> rela.SERVICE_ACTIVITIES_ID == act.PK_ID)
.LeftJoin<ServiceWorkFlowActivitiesTriggerRelation>((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<StatusTriggerConditionInfo>((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();
}
} }
} }
} }

Loading…
Cancel
Save