Browse Source

基础框架发布: 8.2.41

1. 规则引擎将枚举变量替换为枚举值返回给客户端。
  2. 决策引擎增加血缘关系查询
  3. 修改 logback 日志配置
  4. 提供用于检测 SQL 注入的辅助类 io.sc.platform.jdbc.util.SqlInjectionPreventer
  5. 修改血缘关系查询条件中文提示

前端核心发布: 8.2.135
  1. 修改错误处理机制
  2. 决策引擎增加血缘关系查询,血缘关系采用树状展示
main
wangshaoping 1 month ago
parent
commit
7ed9ac62f5
  1. 19
      io.sc.engine.rule.frontend/src/i18n/messages.json
  2. 19
      io.sc.engine.rule.frontend/src/i18n/messages_tw_CN.json
  3. 19
      io.sc.engine.rule.frontend/src/i18n/messages_zh_CN.json
  4. 140
      io.sc.engine.rule.frontend/src/views/blood/Blood.vue
  5. 123
      io.sc.engine.rule.frontend/src/views/blood/Indicator.vue
  6. 117
      io.sc.engine.rule.frontend/src/views/blood/Lib.vue
  7. 123
      io.sc.engine.rule.frontend/src/views/blood/Parameter.vue
  8. 10
      io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/blood/controller/BloodWebController.java
  9. 4
      io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/blood/service/BloodService.java
  10. 161
      io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/blood/service/impl/BloodServiceImpl.java

19
io.sc.engine.rule.frontend/src/i18n/messages.json

@ -10,9 +10,22 @@
"menu.engine.rule.testcase": "Test Case Manager",
"menu.engine.rule.migration": "Data Back and Migration",
"re.blood.grid.query.code": "Parameter Code",
"re.blood.grid.query.name": "Parameter Name",
"re.blood.grid.query.type": "Parameter Type",
"re.blood.query.tab.parameter": "Query Resource By Parameter",
"re.blood.query.tab.lib": "Query Resource By Lib",
"re.blood.query.tab.indicator": "Query Resource By Indicator",
"re.blood.query.tab.parameter.code": "Parameter Code",
"re.blood.query.tab.parameter.name": "Parameter Name",
"re.blood.query.tab.parameter.type": "Parameter Type",
"re.blood.query.tab.lib.code": "Lib Code",
"re.blood.query.tab.lib.name": "Lib Name",
"re.blood.query.tab.lib.version": "Lib Type",
"re.blood.query.tab.lib.type": "Lib Type",
"re.blood.query.tab.indicator.code": "Indicator Code",
"re.blood.query.tab.indicator.name": "Indicator Name",
"re.blood.query.tab.indicator.type": "Indicator Type",
"re.resources.grid.title": "Resources",
"re.resources.grid.toolbar.addTop": "Top Folder",

19
io.sc.engine.rule.frontend/src/i18n/messages_tw_CN.json

@ -10,9 +10,22 @@
"menu.engine.rule.testcase": "試算用例",
"menu.engine.rule.migration": "數據備份和遷移",
"re.blood.grid.query.code": "參數代碼",
"re.blood.grid.query.name": "參數名稱",
"re.blood.grid.query.type": "參數類型",
"re.blood.query.tab.parameter": "通過參數查詢資源",
"re.blood.query.tab.lib": "通过指标库查找资源",
"re.blood.query.tab.indicator": "通過特征查詢資源",
"re.blood.query.tab.parameter.code": "參數代碼",
"re.blood.query.tab.parameter.name": "參數名稱",
"re.blood.query.tab.parameter.type": "參數類型",
"re.blood.query.tab.lib.code": "特征庫代碼",
"re.blood.query.tab.lib.name": "特征庫名稱",
"re.blood.query.tab.lib.version": "特征庫版本",
"re.blood.query.tab.lib.type": "特征庫類型",
"re.blood.query.tab.indicator.code": "特征代碼",
"re.blood.query.tab.indicator.name": "特征名稱",
"re.blood.query.tab.indicator.type": "特征類型",
"re.resources.grid.title": "資源",
"re.resources.grid.toolbar.addTop": "頂級文件夾",

19
io.sc.engine.rule.frontend/src/i18n/messages_zh_CN.json

@ -10,9 +10,22 @@
"menu.engine.rule.testcase": "试算用例管理",
"menu.engine.rule.migration": "数据备份和迁移",
"re.blood.grid.query.code": "参数代码",
"re.blood.grid.query.name": "参数名称",
"re.blood.grid.query.type": "参数类型",
"re.blood.query.tab.parameter": "通过 [ 参数 ] 查询资源",
"re.blood.query.tab.lib": "通过 [ 指标库 ] 查找资源",
"re.blood.query.tab.indicator": "通过 [ 特征 ] 查询资源",
"re.blood.query.tab.parameter.code": "参数代码",
"re.blood.query.tab.parameter.name": "参数名称",
"re.blood.query.tab.parameter.type": "参数类型",
"re.blood.query.tab.lib.code": "特征库代码",
"re.blood.query.tab.lib.name": "特征库名称",
"re.blood.query.tab.lib.version": "特征库版本",
"re.blood.query.tab.lib.type": "特征库类型",
"re.blood.query.tab.indicator.code": "特征代码",
"re.blood.query.tab.indicator.name": "特征名称",
"re.blood.query.tab.indicator.type": "特征类型",
"re.resources.grid.title": "资源",
"re.resources.grid.toolbar.addTop": "顶级文件夹",

140
io.sc.engine.rule.frontend/src/views/blood/Blood.vue

@ -1,126 +1,32 @@
<template>
<w-grid
ref="treeGridRef"
dense-body
:title="$t('re.resources.grid.title')"
:config-button="true"
:tree="true"
:tree-icon="
(row: any) => {
if (row.type === 'FOLDER') {
return { name: 'folder', color: 'amber' };
} else if (row.type === 'MODEL') {
return { name: 'bi-boxes' };
} else {
return { name: row.icon };
}
}
"
selection="multiple"
:checkbox-selection="false"
:fetch-data-url="Environment.apiContextPath('/api/re/blood/findResourcesByParameterCodeAndNameAndType')"
:sort-by="['name']"
:query-form-cols-num="3"
:query-form-fields="[
{ name: 'code', label: $t('re.blood.grid.query.code'), type: 'w-text', queryOperator: 'equals' },
{ name: 'name', label: $t('re.blood.grid.query.name'), type: 'w-text' },
{
name: 'type',
label: $t('re.blood.grid.query.type'),
type: 'w-select',
options: EngineEnums.ParameterType.options,
clearable: true,
},
]"
:advanced-query="true"
:toolbar-configure="{ noIcon: false }"
:toolbar-actions="['query', 'reset', 'separator', 'expand', '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>
<div style="height: 100%">
<q-tabs v-model="selectedTabRef" inline-label align="left" :breakpoint="0" no-caps>
<q-tab name="parameter" icon="manage_search" :label="$t('re.blood.query.tab.parameter')" />
<q-tab name="lib" icon="manage_search" :label="$t('re.blood.query.tab.lib')" />
<q-tab name="indicator" icon="manage_search" :label="$t('re.blood.query.tab.indicator')" />
</q-tabs>
<q-tab-panels v-model="selectedTabRef" animated swipeable keep-alive style="height: calc(100% - 48px)">
<q-tab-panel name="parameter" class="px-0 pb-0" style="height: 100%; padding-left: 0px; padding-right: 0px; padding-bottom: 0px">
<Parameter></Parameter>
</q-tab-panel>
<q-tab-panel name="lib" class="px-0 pb-0" style="height: 100%; padding-left: 0px; padding-right: 0px; padding-bottom: 0px">
<Lib></Lib>
</q-tab-panel>
<q-tab-panel name="indicator" class="px-0 pb-0" style="height: 100%; padding-left: 0px; padding-right: 0px; padding-bottom: 0px">
<Indicator></Indicator>
</q-tab-panel>
</q-tab-panels>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { Environment, Formater, CorporationAuditorEntityManager } from 'platform-core';
import { EngineEnums } from '@/views/shared/enums/EngineEnums';
import Parameter from './Parameter.vue';
import Lib from './Lib.vue';
import Indicator from './Indicator.vue';
const selectedTabRef = ref('parameter');
const treeGridRef = ref();
await EngineEnums.init();
</script>

123
io.sc.engine.rule.frontend/src/views/blood/Indicator.vue

@ -0,0 +1,123 @@
<template>
<w-grid
dense-body
:title="$t('re.resources.grid.title')"
:config-button="true"
:tree="true"
:tree-icon="
(row: any) => {
if (row.type === 'FOLDER') {
return { name: 'folder', color: 'amber' };
} else if (row.type === 'MODEL') {
return { name: 'bi-boxes' };
} else {
return { name: row.icon };
}
}
"
selection="multiple"
:checkbox-selection="false"
:fetch-data-url="Environment.apiContextPath('/api/re/blood/findResourcesByIndicatorCodeAndNameAndType')"
:sort-by="['type', 'namec', 'version']"
:query-form-cols-num="3"
:query-form-fields="[
{ name: 'code', label: $t('re.blood.query.tab.indicator.code'), type: 'w-text', queryOperator: 'equals' },
{ name: 'name', label: $t('re.blood.query.tab.indicator.name'), type: 'w-text' },
{
name: 'type',
label: $t('re.blood.query.tab.indicator.type'),
type: 'w-select',
options: EngineEnums.IndicatorType.options,
clearable: true,
},
]"
:advanced-query="true"
:toolbar-configure="{ noIcon: false }"
:toolbar-actions="['query', 'reset', 'separator', 'expand', '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>

117
io.sc.engine.rule.frontend/src/views/blood/Lib.vue

@ -0,0 +1,117 @@
<template>
<w-grid
dense-body
:title="$t('re.resources.grid.title')"
:config-button="true"
:tree="true"
:tree-icon="
(row: any) => {
if (row.type === 'FOLDER') {
return { name: 'folder', color: 'amber' };
} else if (row.type === 'MODEL') {
return { name: 'bi-boxes' };
} else {
return { name: row.icon };
}
}
"
selection="multiple"
:checkbox-selection="false"
:fetch-data-url="Environment.apiContextPath('/api/re/blood/findResourcesByLibCodeAndVersionAndType')"
:sort-by="['type', 'namec', 'version']"
:query-form-cols-num="3"
:query-form-fields="[
{ name: 'code', label: $t('re.blood.query.tab.lib.code'), type: 'w-text', queryOperator: 'equals' },
{ name: 'name', label: $t('re.blood.query.tab.lib.name'), type: 'w-text' },
{ name: 'version', label: $t('re.blood.query.tab.lib.version'), type: 'w-integer', queryOperator: 'equals' },
]"
:advanced-query="true"
:toolbar-configure="{ noIcon: false }"
:toolbar-actions="['query', 'reset', 'separator', 'expand', '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>

123
io.sc.engine.rule.frontend/src/views/blood/Parameter.vue

@ -0,0 +1,123 @@
<template>
<w-grid
dense-body
:title="$t('re.resources.grid.title')"
:config-button="true"
:tree="true"
:tree-icon="
(row: any) => {
if (row.type === 'FOLDER') {
return { name: 'folder', color: 'amber' };
} else if (row.type === 'MODEL') {
return { name: 'bi-boxes' };
} else {
return { name: row.icon };
}
}
"
selection="multiple"
:checkbox-selection="false"
:fetch-data-url="Environment.apiContextPath('/api/re/blood/findResourcesByParameterCodeAndNameAndType')"
:sort-by="['type', 'namec', 'version']"
:query-form-cols-num="3"
:query-form-fields="[
{ name: 'code', label: $t('re.blood.query.tab.parameter.code'), type: 'w-text', queryOperator: 'equals' },
{ name: 'name', label: $t('re.blood.query.tab.parameter.name'), type: 'w-text' },
{
name: 'type',
label: $t('re.blood.query.tab.parameter.type'),
type: 'w-select',
options: EngineEnums.ParameterType.options,
clearable: true,
},
]"
:advanced-query="true"
:toolbar-configure="{ noIcon: false }"
:toolbar-actions="['query', 'reset', 'separator', 'expand', '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>

10
io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/blood/controller/BloodWebController.java

@ -23,6 +23,16 @@ public class BloodWebController {
return bloodService.findResourcesByParameterCodeAndNameAndType(queryParameter);
}
@GetMapping("findResourcesByLibCodeAndVersionAndType")
public List<ResourceVo> findResourcesByLibCodeAndVersionAndType(QueryParameter queryParameter) throws Exception {
return bloodService.findResourcesByLibCodeAndVersionAndType(queryParameter);
}
@GetMapping("findResourcesByIndicatorCodeAndNameAndType")
public List<ResourceVo> findResourcesByIndicatorCodeAndNameAndType(QueryParameter queryParameter) throws Exception {
return bloodService.findResourcesByIndicatorCodeAndNameAndType(queryParameter);
}
@GetMapping("findResourcesByIndicator")
public List<ResourceVo> findResourcesByIndicator(@Param("libCode")String libCode,@Param("libVersion")Integer libVersion,@Param("indicatorCode")String indicatorCode) throws Exception {
return bloodService.findResourcesByIndicator(libCode,libVersion,indicatorCode);

4
io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/blood/service/BloodService.java

@ -7,5 +7,9 @@ import java.util.List;
public interface BloodService {
public List<ResourceVo> findResourcesByParameterCodeAndNameAndType(QueryParameter queryParameter) throws Exception;
public List<ResourceVo> findResourcesByLibCodeAndVersionAndType(QueryParameter queryParameter) throws Exception;
public List<ResourceVo> findResourcesByIndicatorCodeAndNameAndType(QueryParameter queryParameter) throws Exception;
public List<ResourceVo> findResourcesByIndicator(String libCode,Integer libVersion,String IndicatorCode) throws Exception;
}

161
io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/blood/service/impl/BloodServiceImpl.java

@ -1,6 +1,11 @@
package io.sc.engine.rule.server.blood.service.impl;
import io.sc.engine.rule.core.po.lib.Indicator;
import io.sc.engine.rule.server.blood.service.BloodService;
import io.sc.engine.rule.server.lib.entity.IndicatorEntity;
import io.sc.engine.rule.server.lib.entity.LibEntity;
import io.sc.engine.rule.server.lib.service.IndicatorService;
import io.sc.engine.rule.server.lib.service.LibService;
import io.sc.engine.rule.server.model.entity.ParameterEntity;
import io.sc.engine.rule.server.model.entity.parameter.IndicatorParameterEntity;
import io.sc.engine.rule.server.model.repository.ParameterRepository;
@ -11,6 +16,7 @@ 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.Equals;
import io.sc.platform.orm.service.support.criteria.impl.InSet;
import io.sc.platform.orm.util.EntityVoUtil;
import io.sc.platform.util.ObjectMapperUtil;
@ -22,8 +28,9 @@ 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 LibService libService;
@Autowired private IndicatorService indicatorService;
@Autowired private ModelService modelService;
@Autowired private ResourceService resourceService;
@ -34,7 +41,7 @@ public class BloodServiceImpl implements BloodService {
}
// 构造新查询,不排序,因为查询的条件是参数或指标,返回的结果是资源,所以在查询参数时不排序,返回资源时排序
QueryParameter query4Parameter =ObjectMapperUtil.json().readValue(ObjectMapperUtil.json().writeValueAsString(queryParameter),QueryParameter.class);
query4Parameter.setSortBy(null);
query4Parameter.setSortBy(new ArrayList<String>());
// 查询参数
List<ParameterEntity> entities = parameterService.list(query4Parameter);
@ -55,17 +62,15 @@ public class BloodServiceImpl implements BloodService {
// 获取参数对应的资源及父资源 IDS
Set<String> resourceIds =new LinkedHashSet<>();
if (!parameterIds.isEmpty()) {
for (String id : parameterIds) {
modelService.findRootModelByParameterId(id).getResource();
ResourceEntity resourceEntity =modelService.findRootModelByParameterId(id).getResource();
if(resourceEntity!=null) {
resourceIds.add(resourceEntity.getId());
ResourceEntity parentResourceEntity =resourceEntity.getParent();
while(parentResourceEntity!=null){
resourceIds.add(parentResourceEntity.getId());
parentResourceEntity =parentResourceEntity.getParent();
}
for (String id : parameterIds) {
modelService.findRootModelByParameterId(id).getResource();
ResourceEntity resourceEntity =modelService.findRootModelByParameterId(id).getResource();
if(resourceEntity!=null) {
resourceIds.add(resourceEntity.getId());
ResourceEntity parentResourceEntity =resourceEntity.getParent();
while(parentResourceEntity!=null){
resourceIds.add(parentResourceEntity.getId());
parentResourceEntity =parentResourceEntity.getParent();
}
}
}
@ -86,6 +91,116 @@ public class BloodServiceImpl implements BloodService {
return EntityVoUtil.toVo(resourceEntities);
}
@Override
public List<ResourceVo> findResourcesByLibCodeAndVersionAndType(QueryParameter queryParameter) throws Exception {
if(!queryParameter.existsCriteria()) {
return Collections.emptyList();
}
// 构造新查询,不排序,因为查询的条件是参数或指标,返回的结果是资源,所以在查询参数时不排序,返回资源时排序
QueryParameter query4Lib =ObjectMapperUtil.json().readValue(ObjectMapperUtil.json().writeValueAsString(queryParameter),QueryParameter.class);
query4Lib.getSortBy().clear();
List<LibEntity> libEntities =libService.list(query4Lib);
if(libEntities==null || libEntities.isEmpty()){
return Collections.emptyList();
}
// 获取参数 IDS
Set<String> parameterIds = new LinkedHashSet<>();
for(LibEntity libEntity : libEntities){
List<IndicatorParameterEntity> entities =null;
Equals equalsCriteria =(Equals)query4Lib.getCriteriaByFieldName("version");
if(equalsCriteria!=null && StringUtils.hasText(equalsCriteria.getValue())) {
entities =parameterService.getRepository().findIndicatorParameterEntityByLibCodeAndVersion(libEntity.getCode(), libEntity.getVersion());
}else{
entities =parameterService.getRepository().findIndicatorParameterEntityByLibCode(libEntity.getCode());
}
if(entities!=null && !entities.isEmpty()){
for(IndicatorParameterEntity entity : entities) {
parameterIds.add(entity.getId());
}
}
}
if(parameterIds==null || parameterIds.isEmpty()){
return Collections.emptyList();
}
// 获取参数对应的资源及父资源 IDS
Set<String> resourceIds =new LinkedHashSet<>();
for (String id : parameterIds) {
modelService.findRootModelByParameterId(id).getResource();
ResourceEntity resourceEntity =modelService.findRootModelByParameterId(id).getResource();
if(resourceEntity!=null) {
resourceIds.add(resourceEntity.getId());
ResourceEntity parentResourceEntity =resourceEntity.getParent();
while(parentResourceEntity!=null){
resourceIds.add(parentResourceEntity.getId());
parentResourceEntity =parentResourceEntity.getParent();
}
}
}
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 queryParameter2 =new QueryParameter();
queryParameter2.setCriterias(criterias);
queryParameter2.addSortBy("type");
queryParameter2.addSortBy("namec");
queryParameter2.addSortBy("version");
return EntityVoUtil.toVo(resourceService.list(queryParameter2));
}
@Override
public List<ResourceVo> findResourcesByIndicatorCodeAndNameAndType(QueryParameter queryParameter) throws Exception {
if(!queryParameter.existsCriteria()) {
return Collections.emptyList();
}
// 构造新查询,不排序,因为查询的条件是参数或指标,返回的结果是资源,所以在查询参数时不排序,返回资源时排序
QueryParameter query4Indicator =ObjectMapperUtil.json().readValue(ObjectMapperUtil.json().writeValueAsString(queryParameter),QueryParameter.class);
query4Indicator.setSortBy(new ArrayList<String>());
// 查询指标
List<IndicatorEntity> entities = indicatorService.list(query4Indicator);
if(entities==null || entities.isEmpty()){
return Collections.emptyList();
}
List<String> resourceIds =new ArrayList<>();
for (IndicatorEntity entity : entities) {
List<ResourceVo> vos =findResourcesByIndicator(entity.getLib().getCode(),entity.getLib().getVersion(),entity.getCode());
if(vos!=null && !vos.isEmpty()){
for(ResourceVo vo : vos){
resourceIds.add(vo.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 queryParameter2 =new QueryParameter();
queryParameter2.setCriterias(criterias);
queryParameter2.addSortBy("type");
queryParameter2.addSortBy("namec");
queryParameter2.addSortBy("version");
return EntityVoUtil.toVo(resourceService.list(queryParameter2));
}
@Override
public List<ResourceVo> findResourcesByIndicator(String libCode, Integer libVersion, String indicatorCode) throws Exception {
if(!StringUtils.hasText(libCode) || libVersion==null) {
@ -115,17 +230,15 @@ public class BloodServiceImpl implements BloodService {
// 获取参数对应的资源及父资源 IDS
Set<String> resourceIds =new LinkedHashSet<>();
if (!parameterIds.isEmpty()) {
for (String id : parameterIds) {
modelService.findRootModelByParameterId(id).getResource();
ResourceEntity resourceEntity =modelService.findRootModelByParameterId(id).getResource();
if(resourceEntity!=null) {
resourceIds.add(resourceEntity.getId());
ResourceEntity parentResourceEntity =resourceEntity.getParent();
while(parentResourceEntity!=null){
resourceIds.add(parentResourceEntity.getId());
parentResourceEntity =parentResourceEntity.getParent();
}
for (String id : parameterIds) {
modelService.findRootModelByParameterId(id).getResource();
ResourceEntity resourceEntity =modelService.findRootModelByParameterId(id).getResource();
if(resourceEntity!=null) {
resourceIds.add(resourceEntity.getId());
ResourceEntity parentResourceEntity =resourceEntity.getParent();
while(parentResourceEntity!=null){
resourceIds.add(parentResourceEntity.getId());
parentResourceEntity =parentResourceEntity.getParent();
}
}
}

Loading…
Cancel
Save