Browse Source
1. 规则引擎将枚举变量替换为枚举值返回给客户端。 2. 决策引擎增加血缘关系查询 前端核心发布: 8.2.134 1. 修改错误处理机制 2. 决策引擎增加血缘关系查询main
12 changed files with 253 additions and 3 deletions
@ -0,0 +1,112 @@ |
|||
<template> |
|||
<w-grid |
|||
ref="gridRef" |
|||
dense-body |
|||
:title="$t('re.resources.grid.title')" |
|||
:config-button="true" |
|||
selection="multiple" |
|||
:checkbox-selection="true" |
|||
:fetch-data-url="Environment.apiContextPath('/api/re/blood/findByCodeOrNameContains')" |
|||
:sort-by="['name']" |
|||
:query-form-cols-num="4" |
|||
:query-form-fields="[ |
|||
{ name: 'code', label: $t('code'), type: 'w-text', queryOperator: 'equals' }, |
|||
{ name: 'name', label: $t('name'), type: 'w-text' }, |
|||
{ |
|||
name: 'type', |
|||
label: $t('type'), |
|||
type: 'w-select', |
|||
options: EngineEnums.ParameterType.options, |
|||
clearable: true, |
|||
}, |
|||
]" |
|||
:advanced-query="true" |
|||
:toolbar-configure="{ noIcon: false }" |
|||
:toolbar-actions="['query', 'reset', 'separator', 'view', 'separator', 'export']" |
|||
:columns="[ |
|||
{ |
|||
width: 400, |
|||
name: 'namec', |
|||
label: $t('name'), |
|||
format: (value: any, row: any) => { |
|||
return row.name; |
|||
}, |
|||
}, |
|||
{ |
|||
width: 80, |
|||
name: 'type', |
|||
label: $t('type'), |
|||
showIf: false, |
|||
format: EngineEnums.ResourceType.formater, |
|||
}, |
|||
{ width: 150, name: 'code', label: $t('code'), showIf: false }, |
|||
{ width: 60, name: 'version', label: $t('version'), align: 'right' }, |
|||
{ |
|||
width: 60, |
|||
name: 'status', |
|||
label: $t('status'), |
|||
align: 'center', |
|||
format: EngineEnums.DeployStatus.formater, |
|||
}, |
|||
{ |
|||
width: 60, |
|||
name: 'preDeploy', |
|||
label: $t('re.resources.grid.entity.preDeploy'), |
|||
align: 'center', |
|||
sortable: false, |
|||
format: (value) => { |
|||
if (value) { |
|||
return Formater.yesNo()(value); |
|||
} |
|||
}, |
|||
}, |
|||
{ width: 120, name: 'taskName', label: $t('re.resources.grid.entity.taskName'), sortable: false }, |
|||
{ width: 80, name: 'taskAssignee', label: $t('re.resources.grid.entity.taskAssignee'), sortable: false }, |
|||
{ width: 100, name: 'lastModifier', label: $t('lastModifier') }, |
|||
{ width: 140, name: 'lastModifyDate', label: $t('lastModifyDate') }, |
|||
{ |
|||
width: 80, |
|||
name: 'attachmentCount', |
|||
label: $t('attachment'), |
|||
sortable: false, |
|||
align: 'right', |
|||
format: (value: any, row: any) => { |
|||
if (value > 0) { |
|||
return value; |
|||
} else { |
|||
return ''; |
|||
} |
|||
}, |
|||
}, |
|||
]" |
|||
:viewer="{ |
|||
panel: { |
|||
columnNum: 1, |
|||
fields: [ |
|||
{ name: 'type', label: $t('type') }, |
|||
{ name: 'parent', label: $t('parent') }, |
|||
{ name: 'id', label: $t('id') }, |
|||
{ name: 'code', label: $t('code') }, |
|||
{ name: 'name', label: $t('name') }, |
|||
{ name: 'description', label: $t('description') }, |
|||
{ name: 'version', label: $t('version') }, |
|||
{ name: 'status', label: $t('status'), format: Formater.none() }, |
|||
{ name: 'effectiveDate', label: $t('effectiveDate') }, |
|||
{ name: 'taskName', label: $t('re.resources.grid.entity.taskName') }, |
|||
{ name: 'taskAssignee', label: $t('re.resources.grid.entity.taskAssignee') }, |
|||
{ name: 'attachmentCount', label: $t('attachment') }, |
|||
{ name: 'imports', label: $t('imports') }, |
|||
{ name: 'order', label: $t('order') }, |
|||
...CorporationAuditorEntityManager.getViewerFields(), |
|||
], |
|||
}, |
|||
}" |
|||
> |
|||
</w-grid> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import { Environment, Formater, CorporationAuditorEntityManager } from 'platform-core'; |
|||
import { EngineEnums } from '@/views/shared/enums/EngineEnums'; |
|||
|
|||
await EngineEnums.init(); |
|||
</script> |
|||
@ -0,0 +1,24 @@ |
|||
package io.sc.engine.rule.server.blood.controller; |
|||
|
|||
import io.sc.engine.rule.server.blood.service.BloodService; |
|||
import io.sc.engine.rule.server.model.vo.ModelVo; |
|||
import io.sc.engine.rule.server.resource.vo.ResourceVo; |
|||
import io.sc.platform.orm.service.support.QueryParameter; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
import java.util.Locale; |
|||
|
|||
@RestController("io.sc.engine.rule.server.blood.controller.BloodWebController") |
|||
@RequestMapping("/api/re/blood") |
|||
public class BloodWebController { |
|||
@Autowired BloodService bloodService; |
|||
|
|||
@GetMapping("findByCodeOrNameContains") |
|||
public List<ResourceVo> findByCodeOrNameContains(QueryParameter queryParameter) throws Exception { |
|||
return bloodService.findByCodeOrNameContains(queryParameter); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
package io.sc.engine.rule.server.blood.service; |
|||
|
|||
import io.sc.engine.rule.server.model.vo.ModelVo; |
|||
import io.sc.engine.rule.server.resource.vo.ResourceVo; |
|||
import io.sc.platform.orm.service.support.QueryParameter; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface BloodService { |
|||
public List<ResourceVo> findByCodeOrNameContains(QueryParameter queryParameter) throws Exception; |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
package io.sc.engine.rule.server.blood.service.impl; |
|||
|
|||
import io.sc.engine.rule.server.blood.service.BloodService; |
|||
import io.sc.engine.rule.server.model.entity.ModelEntity; |
|||
import io.sc.engine.rule.server.model.entity.ParameterEntity; |
|||
import io.sc.engine.rule.server.model.repository.ParameterRepository; |
|||
import io.sc.engine.rule.server.model.service.ModelService; |
|||
import io.sc.engine.rule.server.model.service.ParameterService; |
|||
import io.sc.engine.rule.server.model.vo.ModelVo; |
|||
import io.sc.engine.rule.server.resource.entity.ResourceEntity; |
|||
import io.sc.engine.rule.server.resource.service.ResourceService; |
|||
import io.sc.engine.rule.server.resource.vo.ResourceVo; |
|||
import io.sc.platform.orm.service.support.QueryParameter; |
|||
import io.sc.platform.orm.service.support.criteria.Criteria; |
|||
import io.sc.platform.orm.service.support.criteria.impl.InSet; |
|||
import io.sc.platform.orm.util.EntityVoUtil; |
|||
import io.sc.platform.util.ObjectMapperUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
|
|||
@Service("io.sc.engine.rule.server.blood.service.impl.BloodServiceImpl") |
|||
public class BloodServiceImpl implements BloodService { |
|||
@Autowired private ParameterRepository parameterRepository; |
|||
@Autowired private ParameterService parameterService; |
|||
@Autowired private ModelService modelService; |
|||
@Autowired private ResourceService resourceService; |
|||
|
|||
@Override |
|||
public List<ResourceVo> findByCodeOrNameContains(QueryParameter queryParameter) throws Exception { |
|||
if(!queryParameter.existsCriteria()) { |
|||
return Collections.emptyList(); |
|||
} |
|||
// 构造新查询,不排序,因为查询的条件是参数或指标,返回的结果是资源,所以在查询参数时不排序,返回资源时排序
|
|||
QueryParameter query4Parameter =ObjectMapperUtil.json().readValue(ObjectMapperUtil.json().writeValueAsString(queryParameter),QueryParameter.class); |
|||
query4Parameter.setSortBy(null); |
|||
|
|||
// 查询参数
|
|||
List<ParameterEntity> entities = parameterService.list(query4Parameter); |
|||
if(entities==null || entities.isEmpty()){ |
|||
return Collections.emptyList(); |
|||
} |
|||
|
|||
// 获取参数 IDS
|
|||
Set<String> parameterIds = new LinkedHashSet<>(); |
|||
if (entities != null && !entities.isEmpty()) { |
|||
for (ParameterEntity entity : entities) { |
|||
parameterIds.add(entity.getId()); |
|||
} |
|||
} |
|||
if(parameterIds==null || parameterIds.isEmpty()){ |
|||
return Collections.emptyList(); |
|||
} |
|||
|
|||
// 获取参数对应的资源 IDS
|
|||
Set<String> resourceIds =new LinkedHashSet<>(); |
|||
if (!parameterIds.isEmpty()) { |
|||
for (String id : parameterIds) { |
|||
resourceIds.add(modelService.findRootModelByParameterId(id).getResource().getId()); |
|||
} |
|||
} |
|||
if(resourceIds==null || resourceIds.isEmpty()){ |
|||
return Collections.emptyList(); |
|||
} |
|||
|
|||
// 重新构建查询条件, 并保留排序字段
|
|||
InSet inSet =new InSet(); |
|||
inSet.setFieldName("id"); |
|||
inSet.setValue(resourceIds.toArray(new String[]{})); |
|||
|
|||
List<Criteria> criterias =new ArrayList<>(); |
|||
criterias.add(inSet); |
|||
|
|||
queryParameter.setCriterias(criterias); |
|||
return EntityVoUtil.toVo(resourceService.list(queryParameter)); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue