Browse Source

update

main
wangshaoping 10 months ago
parent
commit
6f0679429c
  1. 6
      io.sc.algorithm.weka/build.gradle
  2. 189
      io.sc.engine.st.frontend/src/views/DepFactor/DepFactor.vue
  3. 267
      io.sc.engine.st.frontend/src/views/DepFactor/DepFactorDefine.vue
  4. 122
      io.sc.engine.st.frontend/src/views/EAD.vue
  5. 160
      io.sc.engine.st.frontend/src/views/EconomicIndicator.vue
  6. 2
      io.sc.engine.st/build.gradle
  7. 25
      io.sc.engine.st/src/main/java/io/sc/engine/st/controller/DepFactorWebController.java
  8. 206
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/DepFactorDefineEntity.java
  9. 107
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/DepFactorEntity.java
  10. 157
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/EconomicIndicatorEntity.java
  11. 57
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/sub/DepArithmeticFactorDefineEntity.java
  12. 53
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/sub/DepDelayFactorDefineEntity.java
  13. 53
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/sub/DepDifferentialFactorDefineEntity.java
  14. 24
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/sub/DepFolderEntity.java
  15. 18
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/repository/DepFactorDefineRepository.java
  16. 15
      io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/repository/DepFactorRepository.java
  17. 12
      io.sc.engine.st/src/main/java/io/sc/engine/st/service/DepFactorDefineService.java
  18. 13
      io.sc.engine.st/src/main/java/io/sc/engine/st/service/DepFactorService.java
  19. 12
      io.sc.engine.st/src/main/java/io/sc/engine/st/service/EconomicIndicatorService.java
  20. 23
      io.sc.engine.st/src/main/java/io/sc/engine/st/service/impl/DepFactorDefineServiceImpl.java
  21. 210
      io.sc.engine.st/src/main/java/io/sc/engine/st/service/impl/DepFactorServiceImpl.java
  22. 33
      io.sc.engine.st/src/main/java/io/sc/engine/st/support/Column.java
  23. 90
      io.sc.engine.st/src/main/java/io/sc/engine/st/vo/DepFactorDefineVo.java
  24. 24
      io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepArithmeticFactorDefineVo.java
  25. 24
      io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepDelayFactorDefineVo.java
  26. 24
      io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepDifferentialFactorDefineVo.java
  27. 7
      io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepFolderVo.java
  28. 7
      io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepOriginalFactorDefineVo.java
  29. 12
      io.sc.platform.jdbc.liquibase/src/main/java/io/sc/platform/jdbc/liquibase/task/CsvImportTaskChange.java

6
io.sc.algorithm.weka/build.gradle

@ -0,0 +1,6 @@
dependencies {
api(
"nz.ac.waikato.cms.weka:weka-stable:${weka_version}",
project(":io.sc.platform.core"),
)
}

189
io.sc.engine.st.frontend/src/views/DepFactor/DepFactor.vue

@ -0,0 +1,189 @@
<template>
<q-splitter :model-value="70" horizontal class="w-full" style="height: 100%">
<template #before>
<div class="pl-1" style="height: 100%">
<w-grid
ref="gridRef"
:title="$t('data')"
dense
:checkbox-selection="true"
:fetch-data-url="Environment.apiContextPath('/api/st/depFactor?defineId=' + factorDefine.id)"
:data-url="Environment.apiContextPath('/api/st/depFactor')"
:pageable="false"
:sort-by="['year', 'quarter', 'month', 'day']"
:query-form-cols-num="4"
:query-form-fields="[]"
:toolbar-actions="[
'refresh',
'separator',
{
extend: 'add',
enableIf: () => {
return factorDefine.type === 'ORIGINAL';
},
},
{
extend: 'clone',
enableIf: () => {
return factorDefine.type === 'ORIGINAL';
},
},
{
extend: 'edit',
enableIf: () => {
return factorDefine.type === 'ORIGINAL';
},
},
{
extend: 'remove',
enableIf: () => {
return factorDefine.type === 'ORIGINAL';
},
},
'separator',
'view',
'separator',
'export',
]"
:columns="[
{ width: 60, name: 'year', label: t('year'), align: 'right' },
{ width: 60, name: 'quarter', label: t('quarter'), align: 'right' },
{ width: 60, name: 'month', label: t('month'), align: 'right' },
{ width: 150, name: 'value', label: t('value') },
]"
:editor="{
dialog: {
width: '600px',
},
form: {
colsNum: 1,
fields: [
{
name: 'factorType',
label: $t('factorType'),
type: 'text',
defaultValue: factorDefine.id,
hidden: true,
},
{ name: 'year', label: $t('year'), type: 'number', required: true },
{
name: 'quarter',
label: $t('quarter'),
type: 'number',
required: true,
showIf: () => {
return factorDefine.period === 'QUARTER';
},
},
{
name: 'month',
label: $t('month'),
type: 'number',
required: true,
showIf: () => {
return factorDefine.period === 'MONTH';
},
},
{
name: 'day',
label: $t('day'),
type: 'number',
required: true,
showIf: () => {
return factorDefine.period === 'DAY';
},
},
{ name: 'value', label: $t('value'), type: 'text', required: true },
],
},
}"
:viewer="{
panel: {
columnNum: 1,
fields: [
{ name: 'id', label: $t('id') },
{ name: 'factorType', label: $t('engine.st.depFactorDefine.grid.entity.factorDefine') },
{ name: 'year', label: $t('year') },
{ name: 'quarter', label: $t('quarter') },
{ name: 'month', label: $t('month') },
{ name: 'value', label: $t('value') },
{ name: 'dataComeFrom', label: $t('dataComeFrom') },
{ name: 'creator', label: $t('creator') },
{ name: 'createDate', label: $t('createDate') },
{ name: 'lastModifier', label: $t('lastModifier') },
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() },
{ name: 'corporationCode', label: $t('corporationCode') },
],
},
}"
@after-request-data="
() => {
const rows = gridRef.getRows();
const xAxisData = [];
const seriesData = [];
for (const row of rows) {
xAxisData.push(row.year + (row.month ? '-' + row.month : ''));
seriesData.push(row.value);
}
echartsOptionRef = {
title: {
text: factorDefine.name,
left: 'center',
},
xAxis: {
type: 'category',
name: $t('period'),
data: xAxisData,
},
yAxis: {
type: 'value',
name: $t('value'),
},
series: [
{
data: seriesData,
type: 'line',
smooth: true,
},
],
};
}
"
></w-grid>
</div>
</template>
<template #after>
<w-echarts ref="factorEcharts" style="width: 100%; height: 100%" :option="echartsOptionRef"></w-echarts>
</template>
</q-splitter>
</template>
<script setup lang="ts">
import { ref, computed, onUpdated } from 'vue';
import { useI18n } from 'vue-i18n';
import { Environment, Formater } from 'platform-core';
const props = defineProps({
factorDefine: {
type: Object,
default: () => {
return {};
},
},
});
const { t } = useI18n();
const gridRef = ref();
const echartsOptionRef = ref();
const refresh = () => {
gridRef.value.refresh();
};
onUpdated(() => {
gridRef.value.refresh();
});
defineExpose({
refresh,
});
</script>

267
io.sc.engine.st.frontend/src/views/DepFactor/DepFactorDefine.vue

@ -0,0 +1,267 @@
<template>
<w-grid
ref="treeGridRef"
:title="$t('engine.st.depFactorDefine.grid.title')"
dense
:checkbox-selection="false"
:tree="true"
:tree-icon="
(row) => {
if (row.type === 'FOLDER') {
return { name: 'folder', color: 'amber' };
} else if (row.type === 'ORIGINAL') {
return { name: 'bi-file-earmark-text' };
} else if (row.type === 'EXTEND_ARITHMETIC') {
return { name: 'bi-file-earmark-text', color: 'green' };
} else if (row.type === 'EXTEND_DELAY') {
return { name: 'bi-file-earmark-text', color: 'blue' };
} else if (row.type === 'EXTEND_DIFFERENTIAL') {
return { name: 'bi-file-earmark-text', color: 'amber' };
} else {
return { name: 'bi-file-earmark-text' };
}
}
"
:data-url="Environment.apiContextPath('/api/st/depFactorDefine')"
:pageable="false"
:sort-by="['order']"
:toolbar-actions="[
'refresh',
'separator',
'expand',
'separator',
[
{
name: '_add',
label: $t('add'),
icon: 'add',
click: undefined,
},
{
extend: 'addTop',
label: $t('engine.st.depFactorDefine.grid.toolbar.addTop'),
enableIf: (arg) => {
return true;
},
afterClick: (arg) => {
arg.grid.getEditorForm().setFieldValue('type', 'FOLDER');
},
},
{
extend: 'addChild',
label: $t('engine.st.depFactorDefine.grid.toolbar.addChild'),
enableIf: (arg) => {
return arg.selected && arg.selected.type === 'FOLDER';
},
afterClick: (arg) => {
arg.grid.getEditorForm().setFieldValue('type', 'FOLDER');
},
},
'separator',
{
extend: 'addChild',
name: 'addFactorDefine',
label: $t('engine.st.depFactorDefine.grid.toolbar.addFactorDefine'),
enableIf: (arg) => {
return arg.selected && arg.selected.type === 'FOLDER';
},
afterClick: (arg) => {
arg.grid.getEditorForm().setFieldValue('type', 'ORIGINAL');
},
},
],
'clone',
'edit',
'remove',
'separator',
'view',
'separator',
'export',
]"
:columns="[
{ width: 160, name: 'name', label: $t('name') },
{ width: 150, name: 'code', label: $t('code') },
{
width: 100,
name: 'type',
label: $t('type'),
format: (value, row) => {
if (value === 'FOLDER') {
return '';
}
return Formater.enum(Enums.FactorDefineType)(value);
},
},
{ width: 60, name: 'period', label: $t('period'), format: Formater.enum(Enums.Period) },
{ width: 70, name: 'valueType', label: $t('valueType'), format: Formater.enum(Enums.ValueType) },
]"
:editor="{
dialog: {
width: '500px',
},
form: {
colsNum: 1,
fields: [
{
name: 'type',
label: $t('type'),
type: 'select',
required: true,
options: Options.enum(Enums.FactorDefineType),
onChange: (arg) => {
findAllWithoutById(arg.form.getFieldValue('id'));
},
},
{
name: 'code',
label: $t('code'),
type: 'text',
required: true,
showIf: (arg) => {
return arg.form.getFieldValue('type') !== 'FOLDER';
},
},
{ name: 'name', label: $t('name'), type: 'text', required: true },
{ name: 'description', label: $t('description'), type: 'text' },
{ name: 'order', label: $t('order'), type: 'number' },
{
name: 'period',
label: $t('period'),
required: true,
type: 'select',
options: Options.enum(Enums.Period),
showIf: (arg) => {
return arg.form.getFieldValue('type') !== 'FOLDER';
},
},
{
name: 'valueType',
label: $t('valueType'),
required: true,
type: 'select',
options: Options.enum(Enums.ValueType),
showIf: (arg) => {
return arg.form.getFieldValue('type') !== 'FOLDER';
},
},
{
name: 'formula',
label: $t('engine.st.depFactorDefine.grid.entity.formula'),
type: 'code-mirror',
rows: 3,
required: true,
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_ARITHMETIC';
},
},
{
name: 'reverseFormula',
label: $t('engine.st.depFactorDefine.grid.entity.reverseFormula'),
type: 'code-mirror',
rows: 3,
required: true,
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_ARITHMETIC';
},
},
{
name: 'delayFactorDefine',
label: $t('engine.st.depFactorDefine.grid.entity.delayFactorDefine'),
type: 'select',
options: factorDefineOptionsRef,
required: true,
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_DELAY';
},
},
{
name: 'delayIssue',
label: $t('engine.st.depFactorDefine.grid.entity.delayIssue'),
type: 'number',
required: true,
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_DELAY';
},
},
{
name: 'differentialFactorDefine',
label: $t('engine.st.depFactorDefine.grid.entity.differentialFactorDefine'),
type: 'select',
options: factorDefineOptionsRef,
required: true,
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_DIFFERENTIAL';
},
},
{
name: 'differentialDegree',
label: $t('engine.st.depFactorDefine.grid.entity.differentialDegree'),
type: 'number',
required: true,
showIf: (arg) => {
return arg.form.getFieldValue('type') === 'EXTEND_DIFFERENTIAL';
},
},
],
},
}"
:viewer="{
panel: {
columnNum: 1,
fields: [
{ name: 'id', label: $t('id') },
{ name: 'type', label: $t('type') },
{ name: 'period', label: $t('period') },
{ name: 'code', label: $t('code') },
{ name: 'name', label: $t('name') },
{ name: 'description', label: $t('description') },
{ name: 'order', label: $t('order') },
{ name: 'valueType', label: $t('valueType') },
{ name: 'formula', label: $t('engine.st.depFactorDefine.grid.entity.formula') },
{ name: 'delayFactorDefine', label: $t('engine.st.depFactorDefine.grid.entity.delayFactorDefine') },
{ name: 'delayIssue', label: $t('engine.st.depFactorDefine.grid.entity.delayIssue') },
{ name: 'differentialFactorDefine', label: $t('engine.st.depFactorDefine.grid.entity.differentialFactorDefine') },
{ name: 'differentialDegree', label: $t('engine.st.depFactorDefine.grid.entity.differentialDegree') },
{ name: 'dataComeFrom', label: $t('dataComeFrom') },
{ name: 'creator', label: $t('creator') },
{ name: 'createDate', label: $t('createDate') },
{ name: 'lastModifier', label: $t('lastModifier') },
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() },
{ name: 'corporationCode', label: $t('corporationCode') },
],
},
}"
@after-editor-open="
(selected) => {
if (selected?.type === 'EXTEND_DELAY' || selected?.type === 'EXTEND_DIFFERENTIAL') {
findAllWithoutById(selected.id);
}
}
"
></w-grid>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { Environment, Formater, Options, EnumTools, axios } from 'platform-core';
const treeGridRef = ref();
const factorDefineOptionsRef = ref([]);
const Enums = await EnumTools.fetch(['io.sc.engine.st.enums.FactorDefineType', 'io.sc.engine.st.enums.Period', 'io.sc.engine.st.enums.ValueType']);
const findAllWithoutById = (id) => {
axios.get(Environment.apiContextPath('/api/st/depFactorDefine/findAllWithoutById?defineId=' + (id ? id : ''))).then((response) => {
const defines = response?.data;
if (defines) {
const options = [];
for (const define of defines) {
if (define.type !== 'FOLDER') {
options.push({ value: define.id, label: define.name });
}
}
console.log(factorDefineOptionsRef.value);
factorDefineOptionsRef.value = options;
}
});
};
</script>

122
io.sc.engine.st.frontend/src/views/EAD.vue

@ -1,122 +0,0 @@
<template>
<div style="height: 100%">
<w-grid
ref="testCaseGridRef"
:title="$t('engine.st.testCase.grid.title')"
:config-button="true"
selection="multiple"
:checkbox-selection="true"
:data-url="Environment.apiContextPath('/api/st/testCase')"
:pageable="true"
:toolbar-configure="{ noIcon: false }"
:toolbar-actions="[
'refresh',
'separator',
'add',
'edit',
'remove',
'separator',
{
name: 'scenario',
label: $t('engine.st.testCase.grid.toolbar.scenario'),
icon: 'bi-pin-angle',
enableIf: (arg) => {
return arg.selected;
},
click: () => {
scenarioRef.open();
},
},
'separator',
{
name: 'test',
label: $t('engine.st.testCase.grid.toolbar.test'),
icon: 'bi-lightning-charge',
enableIf: (arg) => {
return arg.selected;
},
},
'separator',
{
name: 'viewResult',
label: $t('engine.st.testCase.grid.toolbar.viewResult'),
icon: 'bi-display',
enableIf: (arg) => {
return arg.selected;
},
},
'separator',
'view',
'separator',
'export',
]"
:columns="[
{ width: 140, name: 'startDate', label: $t('startDate') },
{ width: 140, name: 'endDate', label: $t('endDate') },
{ name: 'periodType', label: $t('engine.st.testCase.grid.entity.periodType'), format: Formater.enum(StatisticalPeriodTypeEnums) },
{ width: 200, name: 'name', label: $t('name') },
{ width: '100%', name: 'description', label: $t('description') },
]"
:editor="{
dialog: {
width: '600px',
},
form: {
colsNum: 1,
fields: [
{ name: 'name', label: $t('name'), type: 'text', required: true },
{ name: 'description', label: $t('description'), type: 'text' },
{
name: 'periodType',
label: $t('engine.st.testCase.grid.entity.periodType'),
type: 'select',
options: Options.enum(StatisticalPeriodTypeEnums),
required: true,
},
],
},
}"
:viewer="{
panel: {
columnNum: 1,
fields: [
{ name: 'id', label: $t('id') },
{ name: 'name', label: $t('name') },
{ name: 'description', label: $t('description') },
{ name: 'dataComeFrom', label: $t('dataComeFrom'), format: Formater.none() },
{ name: 'creator', label: $t('creator') },
{ name: 'createDate', label: $t('createDate') },
{ name: 'lastModifier', label: $t('lastModifier') },
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() },
],
},
}"
@row-click="
(evt, row, index) => {
currentSelectedTestCaseId = row.id;
}
"
@before-request-data="
() => {
currentSelectedTestCaseId = '';
}
"
></w-grid>
<Scenario
ref="scenarioRef"
:data-url="Environment.apiContextPath('/api/st/testScenario')"
foreign-key="testCase"
:foreign-value="currentSelectedTestCaseId"
></Scenario>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { Environment, Formater, Options, EnumTools } from 'platform-core';
import Scenario from './Scenario.vue';
const testCaseGridRef = ref();
const scenarioRef = ref();
const currentSelectedTestCaseId = ref('');
const StatisticalPeriodTypeEnums = await EnumTools.fetch('io.sc.engine.st.enums.StatisticalPeriodType');
</script>

160
io.sc.engine.st.frontend/src/views/EconomicIndicator.vue

@ -1,160 +0,0 @@
<template>
<div style="height: 100%">
<w-grid
ref="gridRef"
:title="$t('engine.st.economicIndicator.grid.title')"
:checkbox-selection="true"
:data-url="Environment.apiContextPath('/api/st/economicIndicator')"
:pageable="false"
:sort-by="['year', 'month', 'quarter']"
:query-form-cols-num="4"
:query-form-fields="[
{
name: 'periodType',
label: $t('engine.st.economicIndicator.grid.entity.periodType'),
type: 'select',
options: Options.enum(StatisticalPeriodTypeEnums),
queryOperator: 'equals',
//defaultValue: 'MONTH',
},
]"
:toolbar-actions="['query', 'separator', 'refresh', 'separator', 'add', 'clone', 'edit', 'remove', 'separator', 'view', 'separator', 'export']"
:columns="[
{ name: 'periodType', label: $t('engine.st.economicIndicator.grid.entity.periodType'), format: Formater.enum(StatisticalPeriodTypeEnums) },
{ name: 'year', label: $t('year') },
{ name: 'month', label: $t('month') },
{ name: 'quarter', label: $t('quarter') },
{
name: 'gdp',
label: $t('engine.st.economicIndicator.grid.entity.GDP'),
title: $t('engine.st.economicIndicator.grid.entity.GDP.title'),
align: 'right',
format: Formater.thousands(),
},
{
name: 'm2',
label: $t('engine.st.economicIndicator.grid.entity.M2'),
title: $t('engine.st.economicIndicator.grid.entity.M2.title'),
align: 'right',
format: Formater.thousands(),
},
{
name: 'cpi',
label: $t('engine.st.economicIndicator.grid.entity.CPI'),
title: $t('engine.st.economicIndicator.grid.entity.CPI.title'),
align: 'right',
format: Formater.percent(),
},
{
name: 'hpi',
label: $t('engine.st.economicIndicator.grid.entity.HPI'),
title: $t('engine.st.economicIndicator.grid.entity.HPI.title'),
align: 'right',
format: Formater.percent(),
},
{
name: 'pmi',
label: $t('engine.st.economicIndicator.grid.entity.PMI'),
title: $t('engine.st.economicIndicator.grid.entity.PMI.title'),
align: 'right',
format: Formater.percent(),
},
{
name: 'blr',
label: $t('engine.st.economicIndicator.grid.entity.BLR'),
title: $t('engine.st.economicIndicator.grid.entity.BLR.title'),
align: 'right',
format: Formater.percent(),
},
{ name: 'lastModifier', label: $t('lastModifier') },
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.dateOnly() },
]"
:editor="{
dialog: {
width: '600px',
},
form: {
colsNum: 1,
fields: [
{
name: 'periodType',
label: $t('engine.st.economicIndicator.grid.entity.periodType'),
type: 'select',
options: Options.enum(StatisticalPeriodTypeEnums),
},
{
name: 'year',
label: $t('year'),
type: 'select',
options: yearOptionsRef,
showIf: (arg) => {
return arg.form.getFieldValue('periodType') === 'YEAR';
},
},
{
name: 'month',
label: $t('month'),
type: 'select',
options: monthOptionsRef,
showIf: (arg) => {
return arg.form.getFieldValue('periodType') === 'MONTH';
},
},
{
name: 'quarter',
label: $t('quarter'),
type: 'select',
options: quarterOptionsRef,
showIf: (arg) => {
return arg.form.getFieldValue('periodType') === 'QUARTER';
},
},
{ name: 'gdp', label: $t('engine.st.economicIndicator.grid.entity.GDP'), type: 'number' },
{ name: 'm2', label: $t('engine.st.economicIndicator.grid.entity.M2'), type: 'number' },
{ name: 'cpi', label: $t('engine.st.economicIndicator.grid.entity.CPI'), type: 'number', precision: 6 },
{ name: 'hpi', label: $t('engine.st.economicIndicator.grid.entity.HPI'), type: 'number', precision: 6 },
{ name: 'pmi', label: $t('engine.st.economicIndicator.grid.entity.PMI'), type: 'number', precision: 6 },
{ name: 'blr', label: $t('engine.st.economicIndicator.grid.entity.BLR'), type: 'number', precision: 6 },
],
},
}"
:viewer="{
panel: {
columnNum: 1,
fields: [
{ name: 'id', label: $t('id') },
{ name: 'periodType', label: $t('engine.st.economicIndicator.grid.entity.periodType') },
{ name: 'year', label: $t('year') },
{ name: 'month', label: $t('month') },
{ name: 'gdp', label: $t('engine.st.economicIndicator.grid.entity.GDP') },
{ name: 'm2', label: $t('engine.st.economicIndicator.grid.entity.M2') },
{ name: 'cpi', label: $t('engine.st.economicIndicator.grid.entity.CPI') },
{ name: 'hpi', label: $t('engine.st.economicIndicator.grid.entity.HPI') },
{ name: 'pmi', label: $t('engine.st.economicIndicator.grid.entity.PMI') },
{ name: 'blr', label: $t('engine.st.economicIndicator.grid.entity.BLR') },
{ name: 'dataComeFrom', label: $t('dataComeFrom') },
{ name: 'creator', label: $t('creator') },
{ name: 'createDate', label: $t('createDate') },
{ name: 'lastModifier', label: $t('lastModifier') },
{ name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.none() },
{ name: 'corporationCode', label: $t('corporationCode') },
],
},
}"
></w-grid>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { Environment, EnumTools, Formater, Options, Tools } from 'platform-core';
const gridRef = ref();
const years = [];
for (let i = 0; i < 30; i++) {
years.push(new Date().getFullYear() - i);
}
const yearOptionsRef = ref(years);
const monthOptionsRef = ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
const quarterOptionsRef = ref([1, 2, 3, 4]);
const StatisticalPeriodTypeEnums = await EnumTools.fetch('io.sc.engine.st.enums.StatisticalPeriodType');
</script>

2
io.sc.engine.st/build.gradle

@ -1,6 +1,8 @@
dependencies { dependencies {
api( api(
project(":io.sc.algorithm.weka"),
project(":io.sc.platform.core"), project(":io.sc.platform.core"),
project(":io.sc.platform.groovy"),
project(":io.sc.platform.orm"), project(":io.sc.platform.orm"),
project(":io.sc.platform.mvc"), project(":io.sc.platform.mvc"),

25
io.sc.engine.st/src/main/java/io/sc/engine/st/controller/DepFactorWebController.java

@ -0,0 +1,25 @@
package io.sc.engine.st.controller;
import io.sc.engine.st.jpa.entity.DepFactorEntity;
import io.sc.engine.st.jpa.repository.DepFactorRepository;
import io.sc.engine.st.service.DepFactorService;
import io.sc.engine.st.vo.DepFactorVo;
import io.sc.platform.mvc.controller.support.RestCrudController;
import io.sc.platform.orm.service.support.QueryParameter;
import io.sc.platform.orm.service.support.QueryResult;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@RestController("io.sc.engine.st.controller.DepFactorWebController")
@RequestMapping("/api/st/depFactor")
public class DepFactorWebController extends RestCrudController<DepFactorVo, DepFactorEntity,String, DepFactorRepository, DepFactorService> {
@Override
protected Page<DepFactorVo> query(HttpServletRequest request, HttpServletResponse response, QueryParameter queryParameter) throws Exception {
String defineId =request.getParameter("defineId");
return QueryResult.page(service.findByFactorDefineId(defineId));
}
}

206
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/DepFactorDefineEntity.java

@ -0,0 +1,206 @@
package io.sc.engine.st.jpa.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.sc.engine.st.enums.FactorDefineType;
import io.sc.engine.st.enums.Period;
import io.sc.engine.st.enums.ValueType;
import io.sc.engine.st.jpa.entity.sub.*;
import io.sc.engine.st.vo.DepFactorDefineVo;
import io.sc.platform.core.util.DateUtil;
import io.sc.platform.orm.api.validator.ValidatorMessage;
import io.sc.platform.orm.api.validator.ValidatorRegExp;
import io.sc.platform.orm.entity.CorporationAuditorEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@Entity(name="io.sc.engine.st.jpa.entity.DepFactorDefineEntity")
@Table(name="ST_DEP_FACTOR_DEF")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE_",discriminatorType=DiscriminatorType.STRING,length=20)
@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type",visible=true,defaultImpl = DepFolderEntity.class )
@JsonSubTypes({
@JsonSubTypes.Type(value = DepFolderEntity.class, name = "FOLDER"),
@JsonSubTypes.Type(value = DepOriginalFactorDefineEntity.class, name = "ORIGINAL"),
@JsonSubTypes.Type(value = DepArithmeticFactorDefineEntity.class, name = "EXTEND_ARITHMETIC"),
@JsonSubTypes.Type(value = DepDelayFactorDefineEntity.class, name = "EXTEND_DELAY"),
@JsonSubTypes.Type(value = DepDifferentialFactorDefineEntity.class, name = "EXTEND_DIFFERENTIAL")
})
public class DepFactorDefineEntity extends CorporationAuditorEntity<DepFactorDefineVo> {
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
@Column(name="ID_", length=36)
@Size(max=36)
protected String id;
// 类型
@Column(name="TYPE_",insertable=false,updatable=false)
@Enumerated(EnumType.STRING)
protected FactorDefineType type;
// 代码
@Column(name="CODE_", length=255)
@Size(max=255)
@Pattern(regexp = ValidatorRegExp.ID,message = ValidatorMessage.ID)
protected String code;
// 名称
@Column(name="NAME_", length=255)
@NotBlank
@Size(max=255)
protected String name;
// 描述
@Column(name="DESCRIPTION_", length=255)
@Size(max=255)
protected String description;
// 顺序
@Column(name="ORDER_")
protected Integer order;
// 周期
@Column(name="PERIOD_", length=20)
@Enumerated(EnumType.STRING)
protected Period period;
// 值类型
@Column(name="VALUE_TYPE_", length=20)
@Enumerated(EnumType.STRING)
protected ValueType valueType;
// 父
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PARENT_ID_")
protected DepFactorDefineEntity parent;
@OneToMany(mappedBy="define",fetch = FetchType.LAZY)
@OrderBy("year,quarter,month")
protected List<DepFactorEntity> factors =new ArrayList<>();
public Object convertValue(String value) throws ParseException {
if(value==null){
return null;
}
switch (valueType){
case NUMERIC:
return new BigDecimal(value);
case STRING:
return value;
case DATE:
return DateUtil.tryParseDate(value);
default:
return value;
}
}
@Override
public void toVo(DepFactorDefineVo vo) {
if(vo!=null){
vo.setType(this.getType());
vo.setId(this.getId());
vo.setCode(this.getCode());
vo.setName(this.getName());
vo.setDescription(this.getDescription());
vo.setOrder(this.getOrder());
vo.setPeriod(this.getPeriod());
vo.setValueType(this.getValueType());
vo.setParent(this.getParent()==null?null:this.getParent().getId());
}
}
public DepFactorDefineEntity(){}
public DepFactorDefineEntity(String id){
this.id =id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public FactorDefineType getType() {
return type;
}
public void setType(FactorDefineType type) {
this.type = type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public Period getPeriod() {
return period;
}
public void setPeriod(Period period) {
this.period = period;
}
public ValueType getValueType() {
return valueType;
}
public void setValueType(ValueType valueType) {
this.valueType = valueType;
}
public DepFactorDefineEntity getParent() {
return parent;
}
public void setParent(DepFactorDefineEntity parent) {
this.parent = parent;
}
public List<DepFactorEntity> getFactors() {
return factors;
}
public void setFactors(List<DepFactorEntity> factors) {
this.factors = factors;
}
}

107
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/DepFactorEntity.java

@ -0,0 +1,107 @@
package io.sc.engine.st.jpa.entity;
import io.sc.engine.st.support.PeriodWrapper;
import io.sc.engine.st.vo.DepFactorVo;
import io.sc.platform.orm.entity.CorporationAuditorEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import javax.validation.constraints.Size;
@Entity(name="io.sc.engine.st.jpa.entity.DepFactorEntity")
@Table(name="ST_DEP_FACTOR")
public class DepFactorEntity extends CorporationAuditorEntity<DepFactorVo> {
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
@Column(name="ID_", length=36)
@Size(max=36)
protected String id;
@Column(name="YEAR_")
protected Integer year;
@Column(name="QUARTER_")
protected Integer quarter;
@Column(name="MONTH_")
protected Integer month;
@Column(name="VALUE_", length=255)
@Size(max=255)
protected String value;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="DEF_ID_")
protected DepFactorDefineEntity define;
public PeriodWrapper calUniqueKey(){
return new PeriodWrapper(year,quarter,month);
}
@Override
public DepFactorVo toVo() {
DepFactorVo vo =new DepFactorVo();
super.toVo(vo);
vo.setId(this.getId());
vo.setYear(this.getYear());
vo.setQuarter(this.getQuarter());
vo.setMonth(this.getMonth());
vo.setValue(this.getValue());
vo.setDefine(this.getDefine()==null?null:this.getDefine().getId());
return vo;
}
public DepFactorEntity(){}
public DepFactorEntity(String id){
this.id =id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getYear() {
return year;
}
public void setYear(Integer year) {
this.year = year;
}
public Integer getQuarter() {
return quarter;
}
public void setQuarter(Integer quarter) {
this.quarter = quarter;
}
public Integer getMonth() {
return month;
}
public void setMonth(Integer month) {
this.month = month;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public DepFactorDefineEntity getDefine() {
return define;
}
public void setDefine(DepFactorDefineEntity define) {
this.define = define;
}
}

157
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/EconomicIndicatorEntity.java

@ -1,157 +0,0 @@
package io.sc.engine.st.jpa.entity;
import io.sc.engine.st.enums.StatisticalPeriodType;
import io.sc.engine.st.vo.EconomicIndicatorVo;
import io.sc.platform.orm.entity.CorporationAuditorEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import javax.validation.constraints.Size;
@Entity(name="io.sc.engine.st.jpa.entity.EconomicIndicatorEntity" /* 避免和 io.sc.platform.system.dictionary.jpa.entity.DictionaryEntity 冲突 */)
@Table(name="ST_ECONOMIC_INDICATOR")
public class EconomicIndicatorEntity extends CorporationAuditorEntity<EconomicIndicatorVo> {
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
@Column(name="ID_", length=36)
@Size(max=36)
protected String id;
@Column(name="PERIOD_TYPE_")
@Enumerated(EnumType.STRING)
protected StatisticalPeriodType periodType;
@Column(name="YEAR_")
protected Integer year;
@Column(name="MONTH_")
protected Integer month;
@Column(name="QUARTER_")
protected Integer quarter;
@Column(name="GDP_")
protected Double gdp;
@Column(name="M2_")
protected Double m2;
@Column(name="CPI_")
protected Double cpi;
@Column(name="HPI_")
protected Double hpi;
@Column(name="PMI_")
protected Double pmi;
@Column(name="BLR_")
protected Double blr;
@Override
public EconomicIndicatorVo toVo() {
EconomicIndicatorVo vo =new EconomicIndicatorVo();
super.toVo(vo);
vo.setId(this.getId());
vo.setPeriodType(this.getPeriodType());
vo.setYear(this.getYear());
vo.setMonth(this.getMonth());
vo.setQuarter(this.getQuarter());
vo.setGdp(this.getGdp());
vo.setM2(this.getM2());
vo.setCpi(this.getCpi());
vo.setHpi(this.getHpi());
vo.setPmi(this.getPmi());
vo.setBlr(this.getBlr());
return vo;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public StatisticalPeriodType getPeriodType() {
return periodType;
}
public void setPeriodType(StatisticalPeriodType periodType) {
this.periodType = periodType;
}
public Integer getYear() {
return year;
}
public void setYear(Integer year) {
this.year = year;
}
public Integer getMonth() {
return month;
}
public void setMonth(Integer month) {
this.month = month;
}
public Integer getQuarter() {
return quarter;
}
public void setQuarter(Integer quarter) {
this.quarter = quarter;
}
public Double getGdp() {
return gdp;
}
public void setGdp(Double gdp) {
this.gdp = gdp;
}
public Double getM2() {
return m2;
}
public void setM2(Double m2) {
this.m2 = m2;
}
public Double getCpi() {
return cpi;
}
public void setCpi(Double cpi) {
this.cpi = cpi;
}
public Double getHpi() {
return hpi;
}
public void setHpi(Double hpi) {
this.hpi = hpi;
}
public Double getPmi() {
return pmi;
}
public void setPmi(Double pmi) {
this.pmi = pmi;
}
public Double getBlr() {
return blr;
}
public void setBlr(Double blr) {
this.blr = blr;
}
}

57
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/sub/DepArithmeticFactorDefineEntity.java

@ -0,0 +1,57 @@
package io.sc.engine.st.jpa.entity.sub;
import io.sc.engine.st.jpa.entity.DepFactorDefineEntity;
import io.sc.engine.st.vo.DepFactorDefineVo;
import io.sc.engine.st.vo.sub.DepArithmeticFactorDefineVo;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.validation.constraints.Size;
/**
* 算术运算自变量定义实体类
*/
@Entity
@DiscriminatorValue("EXTEND_ARITHMETIC")
public class DepArithmeticFactorDefineEntity extends DepFactorDefineEntity {
// 算术公式
@Column(name="ARITHMETIC_FORMULA_", length=512)
@Size(max=512)
protected String formula;
// 算术反公式
@Column(name="ARITHMETIC_FORMULA_REV_", length=512)
@Size(max=512)
protected String reverseFormula;
@Override
public DepFactorDefineVo toVo() {
DepArithmeticFactorDefineVo vo =new DepArithmeticFactorDefineVo();
super.toVo(vo);
vo.setFormula(this.getFormula());
vo.setReverseFormula(this.getReverseFormula());
return vo;
}
public DepArithmeticFactorDefineEntity(){}
public DepArithmeticFactorDefineEntity(String id){
this.id =id;
}
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
public String getReverseFormula() {
return reverseFormula;
}
public void setReverseFormula(String reverseFormula) {
this.reverseFormula = reverseFormula;
}
}

53
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/sub/DepDelayFactorDefineEntity.java

@ -0,0 +1,53 @@
package io.sc.engine.st.jpa.entity.sub;
import io.sc.engine.st.jpa.entity.DepFactorDefineEntity;
import io.sc.engine.st.vo.DepFactorDefineVo;
import io.sc.engine.st.vo.sub.DepDelayFactorDefineVo;
import javax.persistence.*;
/**
* 滞后运算自变量定义实体类
*/
@Entity
@DiscriminatorValue("EXTEND_DELAY")
public class DepDelayFactorDefineEntity extends DepFactorDefineEntity {
// 滞后自变量定义
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DELAY_FACTOR_DEF_ID_")
protected DepFactorDefineEntity delayFactorDefine;
// 滞后期数
@Column(name="DELAY_ISSUE_")
protected Integer delayIssue;
@Override
public DepFactorDefineVo toVo() {
DepDelayFactorDefineVo vo =new DepDelayFactorDefineVo();
super.toVo(vo);
vo.setDelayFactorDefine(this.getDelayFactorDefine()==null?null:this.getDelayFactorDefine().getId());
vo.setDelayIssue(this.getDelayIssue());
return vo;
}
public DepDelayFactorDefineEntity(){}
public DepDelayFactorDefineEntity(String id){
this.id =id;
}
public DepFactorDefineEntity getDelayFactorDefine() {
return delayFactorDefine;
}
public void setDelayFactorDefine(DepFactorDefineEntity delayFactorDefine) {
this.delayFactorDefine = delayFactorDefine;
}
public Integer getDelayIssue() {
return delayIssue;
}
public void setDelayIssue(Integer delayIssue) {
this.delayIssue = delayIssue;
}
}

53
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/sub/DepDifferentialFactorDefineEntity.java

@ -0,0 +1,53 @@
package io.sc.engine.st.jpa.entity.sub;
import io.sc.engine.st.jpa.entity.DepFactorDefineEntity;
import io.sc.engine.st.vo.DepFactorDefineVo;
import io.sc.engine.st.vo.sub.DepDifferentialFactorDefineVo;
import javax.persistence.*;
/**
* 差分运算自变量定义实体类
*/
@Entity
@DiscriminatorValue("EXTEND_DIFFERENTIAL")
public class DepDifferentialFactorDefineEntity extends DepFactorDefineEntity {
// 差分自变量定义
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DIFFERENTIAL_FACTOR_DEF_ID_")
protected DepFactorDefineEntity differentialFactorDefine;
// 差分阶数
@Column(name="DIFFERENTIAL_DEGREE_")
protected Integer differentialDegree;
@Override
public DepFactorDefineVo toVo() {
DepDifferentialFactorDefineVo vo =new DepDifferentialFactorDefineVo();
super.toVo(vo);
vo.setDifferentialFactorDefine(this.getDifferentialFactorDefine()==null?null:this.getDifferentialFactorDefine().getId());
vo.setDifferentialDegree(this.getDifferentialDegree());
return vo;
}
public DepDifferentialFactorDefineEntity(){}
public DepDifferentialFactorDefineEntity(String id){
this.id =id;
}
public DepFactorDefineEntity getDifferentialFactorDefine() {
return differentialFactorDefine;
}
public void setDifferentialFactorDefine(DepFactorDefineEntity differentialFactorDefine) {
this.differentialFactorDefine = differentialFactorDefine;
}
public Integer getDifferentialDegree() {
return differentialDegree;
}
public void setDifferentialDegree(Integer differentialDegree) {
this.differentialDegree = differentialDegree;
}
}

24
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/entity/sub/DepFolderEntity.java

@ -0,0 +1,24 @@
package io.sc.engine.st.jpa.entity.sub;
import io.sc.engine.st.jpa.entity.DepFactorDefineEntity;
import io.sc.engine.st.vo.DepFactorDefineVo;
import io.sc.engine.st.vo.sub.DepFolderVo;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
@Entity
@DiscriminatorValue("FOLDER")
public class DepFolderEntity extends DepFactorDefineEntity {
@Override
public DepFactorDefineVo toVo() {
DepFolderVo vo =new DepFolderVo();
super.toVo(vo);
return vo;
}
public DepFolderEntity(){}
public DepFolderEntity(String id){
this.id =id;
}
}

18
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/repository/DepFactorDefineRepository.java

@ -0,0 +1,18 @@
package io.sc.engine.st.jpa.repository;
import io.sc.engine.st.jpa.entity.DepFactorDefineEntity;
import io.sc.platform.orm.repository.DaoRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("io.sc.engine.st.jpa.repository.DepFactorDefineRepository")
public interface DepFactorDefineRepository extends DaoRepository<DepFactorDefineEntity,String>{
@Query("select e from io.sc.engine.st.jpa.entity.DepFactorDefineEntity e where e.code in (:defineCodes)")
public List<DepFactorDefineEntity> findByCodes(@Param("defineCodes") List<String> defineCodes);
@Query("select e from io.sc.engine.st.jpa.entity.DepFactorDefineEntity e where e.id<>:defineId")
public List<DepFactorDefineEntity> findAllWithoutById(@Param("defineId") String defineId);
}

15
io.sc.engine.st/src/main/java/io/sc/engine/st/jpa/repository/DepFactorRepository.java

@ -0,0 +1,15 @@
package io.sc.engine.st.jpa.repository;
import io.sc.engine.st.jpa.entity.DepFactorEntity;
import io.sc.platform.orm.repository.DaoRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("io.sc.engine.st.jpa.repository.DepFactorRepository")
public interface DepFactorRepository extends DaoRepository<DepFactorEntity,String>{
@Query("select e from io.sc.engine.st.jpa.entity.DepFactorEntity e where e.define.id=:defineId order by e.year, e.quarter, e.month")
public List<DepFactorEntity> findByDefineId(@Param("defineId") String defineId);
}

12
io.sc.engine.st/src/main/java/io/sc/engine/st/service/DepFactorDefineService.java

@ -0,0 +1,12 @@
package io.sc.engine.st.service;
import io.sc.engine.st.jpa.entity.DepFactorDefineEntity;
import io.sc.engine.st.jpa.repository.DepFactorDefineRepository;
import io.sc.engine.st.vo.DepFactorDefineVo;
import io.sc.platform.orm.service.DaoService;
import java.util.List;
public interface DepFactorDefineService extends DaoService<DepFactorDefineEntity, String, DepFactorDefineRepository>{
public List<DepFactorDefineVo> findAllWithoutById(String defineId) throws Exception;
}

13
io.sc.engine.st/src/main/java/io/sc/engine/st/service/DepFactorService.java

@ -0,0 +1,13 @@
package io.sc.engine.st.service;
import io.sc.engine.st.jpa.entity.DepFactorEntity;
import io.sc.engine.st.jpa.repository.DepFactorRepository;
import io.sc.engine.st.vo.DepFactorVo;
import io.sc.platform.orm.service.DaoService;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
public interface DepFactorService extends DaoService<DepFactorEntity, String, DepFactorRepository>{
public List<DepFactorVo> findByFactorDefineId(@RequestParam("defineId") String defineId) throws Exception;
}

12
io.sc.engine.st/src/main/java/io/sc/engine/st/service/EconomicIndicatorService.java

@ -1,12 +0,0 @@
package io.sc.engine.st.service;
import io.sc.engine.st.jpa.entity.EconomicIndicatorEntity;
import io.sc.engine.st.jpa.repository.EconomicIndicatorRepository;
import io.sc.platform.orm.service.DaoService;
import io.sc.platform.orm.service.support.QueryParameter;
import org.springframework.data.domain.Page;
import java.util.Map;
public interface EconomicIndicatorService extends DaoService<EconomicIndicatorEntity, String, EconomicIndicatorRepository>{
}

23
io.sc.engine.st/src/main/java/io/sc/engine/st/service/impl/DepFactorDefineServiceImpl.java

@ -0,0 +1,23 @@
package io.sc.engine.st.service.impl;
import io.sc.engine.st.jpa.entity.DepFactorDefineEntity;
import io.sc.engine.st.jpa.repository.DepFactorDefineRepository;
import io.sc.engine.st.service.DepFactorDefineService;
import io.sc.engine.st.vo.DepFactorDefineVo;
import io.sc.platform.orm.service.impl.DaoServiceImpl;
import io.sc.platform.orm.util.EntityVoUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@Service("io.sc.engine.st.service.impl.DepFactorDefineServiceImpl")
public class DepFactorDefineServiceImpl extends DaoServiceImpl<DepFactorDefineEntity, String, DepFactorDefineRepository> implements DepFactorDefineService {
@Override
public List<DepFactorDefineVo> findAllWithoutById(String defineId) throws Exception {
if(!StringUtils.hasText(defineId)){
EntityVoUtil.toVo(repository.findAll());
}
return EntityVoUtil.toVo(repository.findAllWithoutById(defineId));
}
}

210
io.sc.engine.st/src/main/java/io/sc/engine/st/service/impl/DepFactorServiceImpl.java

@ -0,0 +1,210 @@
package io.sc.engine.st.service.impl;
import io.sc.engine.st.enums.FactorDefineType;
import io.sc.engine.st.enums.Period;
import io.sc.engine.st.exception.FactorDefinePeroidNotSameException;
import io.sc.engine.st.jpa.entity.DepFactorDefineEntity;
import io.sc.engine.st.jpa.entity.DepFactorEntity;
import io.sc.engine.st.jpa.entity.sub.DepArithmeticFactorDefineEntity;
import io.sc.engine.st.jpa.entity.sub.DepDelayFactorDefineEntity;
import io.sc.engine.st.jpa.entity.sub.DepDifferentialFactorDefineEntity;
import io.sc.engine.st.jpa.repository.DepFactorRepository;
import io.sc.engine.st.service.DepFactorDefineService;
import io.sc.engine.st.service.DepFactorService;
import io.sc.engine.st.support.FormulaUtil;
import io.sc.engine.st.support.PeriodWrapper;
import io.sc.engine.st.vo.DepFactorVo;
import io.sc.platform.groovy.GroovyScriptExecutor;
import io.sc.platform.orm.service.impl.DaoServiceImpl;
import io.sc.platform.orm.util.EntityVoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.*;
@Service("io.sc.engine.st.service.impl.DepFactorServiceImpl")
public class DepFactorServiceImpl extends DaoServiceImpl<DepFactorEntity, String, DepFactorRepository> implements DepFactorService {
@Autowired private DepFactorDefineService depFactorDefineService;
@Override
public List<DepFactorVo> findByFactorDefineId(String defineId) throws Exception {
if(!StringUtils.hasText(defineId)){
return Collections.emptyList();
}
DepFactorDefineEntity factorDefineEntity = depFactorDefineService.findById(defineId);
if(factorDefineEntity==null){
return Collections.emptyList();
}
if(FactorDefineType.FOLDER.equals(factorDefineEntity.getType())){
return Collections.emptyList();
}
if(FactorDefineType.ORIGINAL.equals(factorDefineEntity.getType())){
return EntityVoUtil.toVo(repository.findByDefineId(defineId));
}
if(factorDefineEntity instanceof DepArithmeticFactorDefineEntity){
DepArithmeticFactorDefineEntity arithmeticFactorDefineEntity =(DepArithmeticFactorDefineEntity)factorDefineEntity;
return cal(arithmeticFactorDefineEntity);
}else if(factorDefineEntity instanceof DepDelayFactorDefineEntity){
DepDelayFactorDefineEntity delayFactorDefineEntity =(DepDelayFactorDefineEntity)factorDefineEntity;
return cal(delayFactorDefineEntity);
}else if(factorDefineEntity instanceof DepDifferentialFactorDefineEntity){
DepDifferentialFactorDefineEntity differentialFactorDefineEntity =(DepDifferentialFactorDefineEntity)factorDefineEntity;
return cal(differentialFactorDefineEntity);
}
return Collections.emptyList();
}
private List<DepFactorVo> cal(DepArithmeticFactorDefineEntity selfEntity) throws Exception {
// 获取算术运算表达式中引用的其他自变量代码
List<String> variableNames = FormulaUtil.extractVariableNames(selfEntity.getFormula());
// 查找算术运算表达式中引用的其他自变量定义
List<DepFactorDefineEntity> referenceEntities = depFactorDefineService.getRepository().findByCodes(variableNames);
// 算术运算表达式中引用的其他自变量的周期是否相同
if(!isSamePeroid(referenceEntities,selfEntity.getPeriod())){
throw new FactorDefinePeroidNotSameException();
}
// 所有算术运算表达式中引用的其他自变量集合的行 key 集合
Set<PeriodWrapper> rowKeys =new LinkedHashSet<>();
// 查找算术运算表达式中引用的其他自变量Map
// key : 自变量定义代码
// value: 自变量的值 Map(key:唯一标识,value:值)
Map<String,Map<PeriodWrapper,Object>> variableValueMap =new HashMap<>();
for(DepFactorDefineEntity defineEntity : referenceEntities){
Map<PeriodWrapper,Object> records =new HashMap<>();
List<DepFactorEntity> factorEntities =repository.findByDefineId(defineEntity.getId());
if(factorEntities!=null){
for(DepFactorEntity factorEntity : factorEntities){
rowKeys.add(new PeriodWrapper(factorEntity.getYear(),factorEntity.getQuarter(),factorEntity.getMonth()));
records.put(factorEntity.calUniqueKey(),defineEntity.convertValue(factorEntity.getValue()));
}
}
variableValueMap.put(defineEntity.getCode(),records);
}
// 结果集
List<DepFactorVo> result =new ArrayList<>();
for(PeriodWrapper rowKey : rowKeys){
DepFactorVo vo =new DepFactorVo();
vo.setYear(rowKey.getYear());
vo.setQuarter(rowKey.getQuarter());
vo.setMonth(rowKey.getMonth());
Map<String,Object> context =new HashMap<>();
for(String variableName : variableNames){
Map<PeriodWrapper,Object> values =variableValueMap.get(variableName);
Object value =values.get(rowKey);
context.put(variableName,value);
}
String groovyScript =FormulaUtil.getGroovyScript(selfEntity.getFormula());
String value =GroovyScriptExecutor.getInstance().eval(groovyScript,context).toString();
vo.setValue(new BigDecimal(value).setScale(6,BigDecimal.ROUND_HALF_UP).toString());
result.add(vo);
}
return result;
}
private List<DepFactorVo> cal(DepDelayFactorDefineEntity selfEntity) throws Exception {
// 获取滞后自变量定义引用的自变量定义实体
DepFactorDefineEntity referenceEntity =selfEntity.getDelayFactorDefine();
if(referenceEntity==null){
return Collections.emptyList();
}
// 滞后自变量定义和引用的自变量定义实体的周期是否相同
if(!referenceEntity.getPeriod().equals(selfEntity.getPeriod())){
throw new FactorDefinePeroidNotSameException();
}
List<DepFactorEntity> factorEntities =repository.findByDefineId(referenceEntity.getId());
if(factorEntities==null || factorEntities.isEmpty()){
return Collections.emptyList();
}
Map<PeriodWrapper,Object> recordCache =new LinkedHashMap<>();
for(DepFactorEntity factorEntity : factorEntities){
recordCache.put(factorEntity.calUniqueKey(),selfEntity.convertValue(factorEntity.getValue()));
}
// 结果集
List<DepFactorVo> result =new ArrayList<>();
for(PeriodWrapper key : recordCache.keySet()){
DepFactorVo vo =new DepFactorVo();
vo.setYear(key.getYear());
vo.setQuarter(key.getQuarter());
vo.setMonth(key.getMonth());
Object value =recordCache.get(key.previous(selfEntity.getDelayIssue()));
vo.setValue(value==null?null:value.toString());
result.add(vo);
}
return result;
}
private List<DepFactorVo> cal(DepDifferentialFactorDefineEntity selfEntity) throws Exception {
// 获取差分自变量定义引用的自变量定义实体
DepFactorDefineEntity referenceEntity =selfEntity.getDifferentialFactorDefine();
if(referenceEntity==null){
return Collections.emptyList();
}
// 滞后自变量定义和引用的自变量定义实体的周期是否相同
if(!referenceEntity.getPeriod().equals(selfEntity.getPeriod())){
throw new FactorDefinePeroidNotSameException();
}
List<DepFactorEntity> factorEntities =repository.findByDefineId(referenceEntity.getId());
if(factorEntities==null || factorEntities.isEmpty()){
return Collections.emptyList();
}
Map<PeriodWrapper,Object> recordCache =new LinkedHashMap<>();
for(DepFactorEntity factorEntity : factorEntities){
recordCache.put(factorEntity.calUniqueKey(),selfEntity.convertValue(factorEntity.getValue()));
}
for(int i=0;i<selfEntity.getDifferentialDegree();i++) {
Map<PeriodWrapper,Object> recordCacheTemp =new LinkedHashMap<>();
for (PeriodWrapper key : recordCache.keySet()) {
Object value =recordCache.get(key);
Object value_1 =recordCache.get(key.previous(1));
if(value_1!=null){
recordCacheTemp.put(key,new BigDecimal(value.toString()).subtract(new BigDecimal(value_1.toString())));
}else{
recordCacheTemp.put(key,null);
}
}
recordCache =recordCacheTemp;
}
// 结果集
List<DepFactorVo> result =new ArrayList<>();
for(PeriodWrapper key : recordCache.keySet()){
DepFactorVo vo =new DepFactorVo();
vo.setYear(key.getYear());
vo.setQuarter(key.getQuarter());
vo.setMonth(key.getMonth());
Object value =recordCache.get(key);
vo.setValue(value==null?null:value.toString());
result.add(vo);
}
return result;
}
private boolean isSamePeroid(List<DepFactorDefineEntity> factorDefineEntities,Period period){
if(period==null){
return false;
}
if(factorDefineEntities==null || !factorDefineEntities.isEmpty()){
return true;
}
for(DepFactorDefineEntity defineEntity : factorDefineEntities){
if(!period.equals(defineEntity.getPeriod())){
return false;
}
}
return true;
}
}

33
io.sc.engine.st/src/main/java/io/sc/engine/st/support/Column.java

@ -0,0 +1,33 @@
package io.sc.engine.st.support;
import io.sc.engine.st.enums.ValueType;
import java.util.ArrayList;
import java.util.List;
public class Column {
private String code;
private ValueType valueType =ValueType.NUMERIC;
public Column(){}
public Column(String code,ValueType valueType){
this.code =code;
this.valueType =valueType;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public ValueType getValueType() {
return valueType;
}
public void setValueType(ValueType valueType) {
this.valueType = valueType;
}
}

90
io.sc.engine.st/src/main/java/io/sc/engine/st/vo/DepFactorDefineVo.java

@ -0,0 +1,90 @@
package io.sc.engine.st.vo;
import io.sc.engine.st.enums.FactorDefineType;
import io.sc.engine.st.enums.Period;
import io.sc.engine.st.enums.ValueType;
import io.sc.platform.orm.api.vo.CorporationAuditorVo;
public class DepFactorDefineVo extends CorporationAuditorVo {
protected String id;
protected FactorDefineType type;
protected String code;
protected String name;
protected String description;
protected Integer order;
protected Period period;
protected ValueType valueType;
protected String parent;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public FactorDefineType getType() {
return type;
}
public void setType(FactorDefineType type) {
this.type = type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
public Period getPeriod() {
return period;
}
public void setPeriod(Period period) {
this.period = period;
}
public ValueType getValueType() {
return valueType;
}
public void setValueType(ValueType valueType) {
this.valueType = valueType;
}
public String getParent() {
return parent;
}
public void setParent(String parent) {
this.parent = parent;
}
}

24
io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepArithmeticFactorDefineVo.java

@ -0,0 +1,24 @@
package io.sc.engine.st.vo.sub;
import io.sc.engine.st.vo.DepFactorDefineVo;
public class DepArithmeticFactorDefineVo extends DepFactorDefineVo {
protected String formula;
protected String reverseFormula;
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
public String getReverseFormula() {
return reverseFormula;
}
public void setReverseFormula(String reverseFormula) {
this.reverseFormula = reverseFormula;
}
}

24
io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepDelayFactorDefineVo.java

@ -0,0 +1,24 @@
package io.sc.engine.st.vo.sub;
import io.sc.engine.st.vo.DepFactorDefineVo;
public class DepDelayFactorDefineVo extends DepFactorDefineVo {
protected String delayFactorDefine;
protected Integer delayIssue;
public String getDelayFactorDefine() {
return delayFactorDefine;
}
public void setDelayFactorDefine(String delayFactorDefine) {
this.delayFactorDefine = delayFactorDefine;
}
public Integer getDelayIssue() {
return delayIssue;
}
public void setDelayIssue(Integer delayIssue) {
this.delayIssue = delayIssue;
}
}

24
io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepDifferentialFactorDefineVo.java

@ -0,0 +1,24 @@
package io.sc.engine.st.vo.sub;
import io.sc.engine.st.vo.DepFactorDefineVo;
public class DepDifferentialFactorDefineVo extends DepFactorDefineVo {
protected String differentialFactorDefine;
protected Integer differentialDegree;
public String getDifferentialFactorDefine() {
return differentialFactorDefine;
}
public void setDifferentialFactorDefine(String differentialFactorDefine) {
this.differentialFactorDefine = differentialFactorDefine;
}
public Integer getDifferentialDegree() {
return differentialDegree;
}
public void setDifferentialDegree(Integer differentialDegree) {
this.differentialDegree = differentialDegree;
}
}

7
io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepFolderVo.java

@ -0,0 +1,7 @@
package io.sc.engine.st.vo.sub;
import io.sc.engine.st.vo.DepFactorDefineVo;
public class DepFolderVo extends DepFactorDefineVo {
}

7
io.sc.engine.st/src/main/java/io/sc/engine/st/vo/sub/DepOriginalFactorDefineVo.java

@ -0,0 +1,7 @@
package io.sc.engine.st.vo.sub;
import io.sc.engine.st.vo.DepFactorDefineVo;
public class DepOriginalFactorDefineVo extends DepFactorDefineVo {
}

12
io.sc.platform.jdbc.liquibase/src/main/java/io/sc/platform/jdbc/liquibase/task/CsvImportTaskChange.java

@ -111,13 +111,22 @@ public class CsvImportTaskChange implements CustomTaskChange {
for(int i=0;i<columns.length;i++) { for(int i=0;i<columns.length;i++) {
ps.setObject(i+1, TypeConvertor.getValue(data[i],columns[i].getJavaType(),null)); ps.setObject(i+1, TypeConvertor.getValue(data[i],columns[i].getJavaType(),null));
} }
if(table.isSelfReference()) {
ps.execute();
if ((++count) % 1000 == 0) {
log.info("[" + table.getName() + "] : " + count);
}
}else {
ps.addBatch(); ps.addBatch();
if ((++count) % 1000 == 0) { if ((++count) % 1000 == 0) {
ps.executeBatch(); ps.executeBatch();
log.info("[" + table.getName() + "] : " + count); log.info("[" + table.getName() + "] : " + count);
} }
} }
}
if(!table.isSelfReference()) {
ps.executeBatch(); ps.executeBatch();
}
ps.close(); ps.close();
log.info("[" + table.getName() + "] : " + count + " completed"); log.info("[" + table.getName() + "] : " + count + " completed");
} }
@ -128,6 +137,9 @@ public class CsvImportTaskChange implements CustomTaskChange {
String[] names =iterator.next(); String[] names =iterator.next();
Table table =new Table(); Table table =new Table();
table.setName(names[0]); table.setName(names[0]);
if("SELF_REFERENCE".equals(names[1])) {
table.setSelfReference(true);
}
return table; return table;
} }

Loading…
Cancel
Save