修改服务项目检索

optimize
jianghaiqing 1 year ago
parent 574098a0c7
commit 97456c9aa9

@ -117,11 +117,11 @@ namespace Myshipping.Application
/// <summary>
/// 子状态列表
/// </summary>
List<ServiceProjectStatusDto> SubStatusList { get; set; }
public List<ServiceProjectStatusDto> SubStatusList { get; set; }
/// <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="isAvoidCache">是否不从缓存取值</param>
/// <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}");
@ -1759,103 +1760,14 @@ namespace Myshipping.Application
/// <param name="tenantId">租户ID</param>
/// <param name="isAvoidCache">是否不从缓存取值</param>
/// <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}");
if (isAvoidCache || statusList == null || statusList.Count == 0)
{
var list = _serviceWorkFlowBaseRepository.AsQueryable().Filter(null, true)
.InnerJoin<ServiceWorkFlowProjectRelation>((wf, rela)
=> 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);
CreateCacheInfo(tenantId);
//await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList);
}
return statusList;
@ -1888,20 +1800,19 @@ namespace Myshipping.Application
.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)
.LeftJoin<ServiceWorkFlowActivitiesTriggerRelation>((wf, rela, prj,
arela, 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, prj,
arela, act, trgrela, trg)
=> trgrela.STATUS_TRIGGER_ID == trg.PK_ID)
.Where((wf, rela, prj,
arela, act, srela, sact)
arela, act)
=> !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 { WF = wf,Project = prj, ARela = arela, Act = act, SRela = srela, SAct = sact }).ToList();
arela, act)
=> new { WF = wf,Project = prj, ARela = arela, Act = act }).ToList();
var statusList = list.GroupBy(a
=> a.Project.PK_ID)
@ -1909,10 +1820,11 @@ namespace Myshipping.Application
{
var currList = a.ToList();
var wf = a.FirstOrDefault().WF;
var project = a.FirstOrDefault().Project;
var wf = currList.FirstOrDefault().WF;
var project = currList.FirstOrDefault().Project;
ServiceProjectWithStatusDto baseDto = new ServiceProjectWithStatusDto {
ServiceProjectWithStatusDto baseDto = new ServiceProjectWithStatusDto
{
ProjectPKId = project.PK_ID,
ProjectCode = project.SERVICE_PROJECT_CODE,
ProjectName = project.SERVICE_PROJECT_NAME,
@ -1929,10 +1841,19 @@ namespace Myshipping.Application
.Select(c => {
var currActList = c.ToList();
var act = c.FirstOrDefault().Act;
var dto = new ServiceProjectStatusDto();
var act = currActList.FirstOrDefault().Act;
var ARela = currActList.FirstOrDefault().ARela;
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;
@ -1942,6 +1863,28 @@ namespace Myshipping.Application
}).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