From 5688c8500f3fd2e5bede181b849b705fc29083f4 Mon Sep 17 00:00:00 2001 From: wangshaoping Date: Tue, 31 Dec 2024 11:41:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=208.2.3=201.=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=BB=98=E8=AE=A4=E5=AE=89=E8=A3=85=E6=97=B6=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=20protocol=20=E5=B1=9E=E6=80=A7=E7=9A=84=20bug?= =?UTF-8?q?=E3=80=82=202.=20=E5=89=8D=E7=AB=AF=E6=9B=B4=E6=96=B0=E5=88=B0?= =?UTF-8?q?=208.2.17=E3=80=82=203.=20=E8=A7=84=E5=88=99=E5=BC=95=E6=93=8E?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=E4=B8=BA?= =?UTF-8?q?=E7=89=B9=E5=BE=81=E7=9A=84=E8=BE=93=E5=85=A5=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erm.frontend/package.json | 2 +- gradle.properties | 2 +- io.sc.engine.mv.frontend/package.json | 2 +- .../generator/impl/IndicatorGenerator.java | 9 +- .../rule/core/code/template/impl/lib.tpl | 2 +- .../rule/core/code/template/import_render.tpl | 8 + .../rule/core/code/template/lib_render.tpl | 2 +- io.sc.engine.rule.frontend/package.json | 2 +- .../views/shared/TestcaseParameterGrid.vue | 36 ++- .../views/shared/processors/GroovyScript.ts | 4 +- io.sc.engine.st.frontend/package.json | 2 +- io.sc.platform.core.frontend/package.json | 2 +- .../components/math/toolbar/Toolbar.vue | 4 + .../math/toolbar/functions/Collection.vue | 37 +++ .../math/toolbar/functions/Date.vue | 4 +- .../functions/collection/hasElements.vue | 44 ++++ .../math/toolbar/functions/date/Now.vue | 16 +- .../functions/date/between/Between.vue | 122 ++++++++++ .../functions/date/between/DaysBetween.vue | 52 +++++ .../functions/date/between/HoursBetween.vue | 52 +++++ .../functions/date/between/MinutesBetween.vue | 52 +++++ .../functions/date/between/MonthsBetween.vue | 52 +++++ .../functions/date/between/SecondsBetween.vue | 52 +++++ .../functions/date/between/WeeksBetween.vue | 52 +++++ .../functions/date/between/YearsBetween.vue | 52 +++++ .../src/platform/i18n/messages.json | 12 +- .../src/platform/i18n/messages_tw_CN.json | 10 + .../src/platform/i18n/messages_zh_CN.json | 10 + .../template-project/package.json | 4 +- io.sc.platform.developer.doc/package.json | 2 +- .../package.json | 2 +- io.sc.platform.lcdp.frontend/package.json | 2 +- .../package.json | 2 +- io.sc.platform.mvc.frontend/package.json | 2 +- .../package.json | 2 +- io.sc.platform.system.frontend/package.json | 2 +- .../java/io/sc/platform/util/DateUtil.java | 221 ++++++++++++++++++ io.sc.standard.frontend/package.json | 2 +- io.sc.website/package.json | 2 +- 39 files changed, 903 insertions(+), 36 deletions(-) create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/Collection.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/collection/hasElements.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/Between.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/DaysBetween.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/HoursBetween.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/MinutesBetween.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/MonthsBetween.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/SecondsBetween.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/WeeksBetween.vue create mode 100644 io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/YearsBetween.vue diff --git a/erm.frontend/package.json b/erm.frontend/package.json index 0141f0c8..8717376c 100644 --- a/erm.frontend/package.json +++ b/erm.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/gradle.properties b/gradle.properties index 317065d1..d27793f3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,7 +38,7 @@ application_version=1.0.0 platform_group=io.sc platform_version=8.2.3 platform_plugin_version=8.2.3 -platform_core_frontend_version=8.2.15 +platform_core_frontend_version=8.2.17 ########################################################### # dependencies version diff --git a/io.sc.engine.mv.frontend/package.json b/io.sc.engine.mv.frontend/package.json index 03515641..aed156c0 100644 --- a/io.sc.engine.mv.frontend/package.json +++ b/io.sc.engine.mv.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/generator/impl/IndicatorGenerator.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/generator/impl/IndicatorGenerator.java index 1b750e8f..7aaacd29 100644 --- a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/generator/impl/IndicatorGenerator.java +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/generator/impl/IndicatorGenerator.java @@ -58,7 +58,7 @@ public class IndicatorGenerator { return sb.toString(); } - public static String generateConvertorFromMap(List indicators) { + public static String generateConvertorFromMap(List indicators,String prefix) { if (!CollectionUtil.hasElements(indicators)) { return null; } @@ -70,19 +70,20 @@ public class IndicatorGenerator { Integer valueTypeVersion = indicator.getValueTypeVersion(); Map variables =new HashMap<>(); + variables.put("prefix",prefix); variables.put("code",code); variables.put("name",name); variables.put("fieldName",IdReplacer.fieldName(code)); variables.put("className",IdReplacer.className(valueType,valueTypeVersion)); if (indicator.getValueTypeIsList()) { - String tpl ="this.${fieldName} =TypeConvertor.getValue(map.get('${code}'),new TypeReference>(){}); //${name}"; + String tpl ="${prefix}.${fieldName} =TypeConvertor.getValue(map.get('${code}'),new TypeReference>(){}); //${name}"; sb.append(StringUtil.format(tpl,variables)).append("\n"); } else { - String tpl ="this.${fieldName} =TypeConvertor.getValue(map.get('${code}'),${className}.class); //${name}"; + String tpl ="${prefix}.${fieldName} =TypeConvertor.getValue(map.get('${code}'),${className}.class); //${name}"; sb.append(StringUtil.format(tpl,variables)).append("\n"); } if (!ValueTypeUtil.isBase(valueType)) { - String tpl ="if(this.${fieldName}!=null) { this.${fieldName}.init(); }"; + String tpl ="if(${prefix}.${fieldName}!=null) { ${prefix}.${fieldName}.init(); }"; sb.append(StringUtil.format(tpl,variables)).append("\n"); } } diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/impl/lib.tpl b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/impl/lib.tpl index 0acf137d..8f633187 100644 --- a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/impl/lib.tpl +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/impl/lib.tpl @@ -135,7 +135,7 @@ class Argument { public static Argument convertArgument(Map map){ if(map!=null){ Argument arg =new Argument(); - #(tabs(IndicatorGenerator.generateConvertorFromMap(lib.indicators),3)) + #(tabs(IndicatorGenerator.generateConvertorFromMap(lib.indicators,"arg"),3)) return arg; } return null; diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/import_render.tpl b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/import_render.tpl index 0378d29a..f7f0e338 100644 --- a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/import_render.tpl +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/import_render.tpl @@ -56,6 +56,14 @@ import static io.sc.engine.rule.core.function.StringFunction.lowerCase; import static io.sc.engine.rule.core.function.StringFunction.startsWith; import static io.sc.engine.rule.core.function.StringFunction.trim; import static io.sc.engine.rule.core.function.StringFunction.upperCase; +import static io.sc.platform.util.CollectionUtil.hasElements; +import static io.sc.platform.util.DateUtil.yearBetween; +import static io.sc.platform.util.DateUtil.monthBetween; +import static io.sc.platform.util.DateUtil.weeksBetween; +import static io.sc.platform.util.DateUtil.dayBetween; +import static io.sc.platform.util.DateUtil.hoursBetween; +import static io.sc.platform.util.DateUtil.minutesBetween; +import static io.sc.platform.util.DateUtil.secondsBetween; import static io.sc.platform.util.NumberUtil.comma; import static io.sc.platform.util.NumberUtil.decimal; import static io.sc.platform.util.NumberUtil.money; diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/lib_render.tpl b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/lib_render.tpl index fa12df21..084d83d7 100644 --- a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/lib_render.tpl +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/template/lib_render.tpl @@ -6,7 +6,7 @@ class #(className(lib.code,lib.version)) { //通过输入参数构建指标库对象 public void convertArgument(Map map){ - #(tabs(IndicatorGenerator.generateConvertorFromMap(lib.indicators),2)) + #(tabs(IndicatorGenerator.generateConvertorFromMap(lib.indicators,"this"),2)) } public void convertArgument(String json){ diff --git a/io.sc.engine.rule.frontend/package.json b/io.sc.engine.rule.frontend/package.json index d1672290..211a5b7c 100644 --- a/io.sc.engine.rule.frontend/package.json +++ b/io.sc.engine.rule.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.engine.rule.frontend/src/views/shared/TestcaseParameterGrid.vue b/io.sc.engine.rule.frontend/src/views/shared/TestcaseParameterGrid.vue index 28f5a969..71a3896c 100644 --- a/io.sc.engine.rule.frontend/src/views/shared/TestcaseParameterGrid.vue +++ b/io.sc.engine.rule.frontend/src/views/shared/TestcaseParameterGrid.vue @@ -77,7 +77,18 @@ }, }, ...valueTypeManager.getColumns([], false), - { width: 100, name: 'inputValue', label: $t('re.testCaseParameter.grid.entity.inputValue'), sortable: false }, + { + width: 100, + name: 'inputValue', + label: $t('re.testCaseParameter.grid.entity.inputValue'), + sortable: false, + format: (value: any, row: any) => { + return Tools.escapeHtml(value); + }, + title: (args: any) => { + return args.value; + }, + }, { width: 100, name: 'inputValueValidateMessage', @@ -93,8 +104,27 @@ return args.value; }, }, - { width: 100, name: 'expectValue', label: $t('re.testCaseParameter.grid.entity.expectValue'), sortable: false }, - { width: 100, name: 'resultValue', label: $t('re.testCaseParameter.grid.entity.resultValue'), sortable: false }, + { + width: 100, + name: 'expectValue', + label: $t('re.testCaseParameter.grid.entity.expectValue'), + sortable: false, + format: (value: any, row: any) => { + return Tools.escapeHtml(value); + }, + }, + { + width: 100, + name: 'resultValue', + label: $t('re.testCaseParameter.grid.entity.resultValue'), + sortable: false, + format: (value: any, row: any) => { + return Tools.escapeHtml(value); + }, + title: (args: any) => { + return args.value; + }, + }, { width: 70, name: 'skipCheck', diff --git a/io.sc.engine.rule.frontend/src/views/shared/processors/GroovyScript.ts b/io.sc.engine.rule.frontend/src/views/shared/processors/GroovyScript.ts index d554226c..ca6550a3 100644 --- a/io.sc.engine.rule.frontend/src/views/shared/processors/GroovyScript.ts +++ b/io.sc.engine.rule.frontend/src/views/shared/processors/GroovyScript.ts @@ -5,7 +5,7 @@ class GroovyScript extends Processor { constructor(targetType: string, context?: any) { super(targetType, context); this.PROCESSOR_TYPE = 'GROOVY_SCRIPT'; - this.EDITOR_DIALOG_WIDTH = 800; + this.EDITOR_DIALOG_WIDTH = 1024; } public getToolbarAction(): any { @@ -39,6 +39,8 @@ class GroovyScript extends Processor { label: $t('re.processor.grid.entity.groovyScript'), type: 'w-code-mirror', rows: 20, + lineHeight: '1.3rem', + fontSize: '0.75rem', lineNumber: true, lang: 'java', lineWrap: false, diff --git a/io.sc.engine.st.frontend/package.json b/io.sc.engine.st.frontend/package.json index 65dbff25..97d6c507 100644 --- a/io.sc.engine.st.frontend/package.json +++ b/io.sc.engine.st.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.platform.core.frontend/package.json b/io.sc.platform.core.frontend/package.json index 2ba1f6eb..3aa3abbf 100644 --- a/io.sc.platform.core.frontend/package.json +++ b/io.sc.platform.core.frontend/package.json @@ -1,6 +1,6 @@ { "name": "platform-core", - "version": "8.2.15", + "version": "8.2.17", "description": "前端核心包,用于快速构建前端的脚手架", "//main": "库的主文件", "main": "dist/platform-core.js", diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/Toolbar.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/Toolbar.vue index d85c9a3b..5046f5dd 100644 --- a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/Toolbar.vue +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/Toolbar.vue @@ -84,6 +84,9 @@ + + + @@ -165,6 +168,7 @@ import Log from './functions/Log.vue'; import Trigonometric from './functions/Trigonometric.vue'; import Probability from './functions/Probability.vue'; import Formater from './functions/Formater.vue'; +import Collection from './functions/Collection.vue'; const modelValueRef = defineModel({ type: String, default: '' }); const zoomModelValueRef = defineModel('zoom', { type: Number, default: ZoomLevels.defaultLevel }); diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/Collection.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/Collection.vue new file mode 100644 index 00000000..768af2b7 --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/Collection.vue @@ -0,0 +1,37 @@ + + diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/Date.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/Date.vue index 96cb8811..05c3b2ec 100644 --- a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/Date.vue +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/Date.vue @@ -7,10 +7,11 @@ - + + @@ -18,6 +19,7 @@ diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/Now.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/Now.vue index ecf45fb7..2879e1e1 100644 --- a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/Now.vue +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/Now.vue @@ -1,11 +1,13 @@ diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/DaysBetween.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/DaysBetween.vue new file mode 100644 index 00000000..49ce0960 --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/DaysBetween.vue @@ -0,0 +1,52 @@ + + diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/HoursBetween.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/HoursBetween.vue new file mode 100644 index 00000000..1597bb05 --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/HoursBetween.vue @@ -0,0 +1,52 @@ + + diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/MinutesBetween.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/MinutesBetween.vue new file mode 100644 index 00000000..5d9e5d00 --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/MinutesBetween.vue @@ -0,0 +1,52 @@ + + diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/MonthsBetween.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/MonthsBetween.vue new file mode 100644 index 00000000..8986766a --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/MonthsBetween.vue @@ -0,0 +1,52 @@ + + diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/SecondsBetween.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/SecondsBetween.vue new file mode 100644 index 00000000..bd47d483 --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/SecondsBetween.vue @@ -0,0 +1,52 @@ + + diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/WeeksBetween.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/WeeksBetween.vue new file mode 100644 index 00000000..b2560883 --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/WeeksBetween.vue @@ -0,0 +1,52 @@ + + diff --git a/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/YearsBetween.vue b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/YearsBetween.vue new file mode 100644 index 00000000..2393d90c --- /dev/null +++ b/io.sc.platform.core.frontend/src/platform/components/math/toolbar/functions/date/between/YearsBetween.vue @@ -0,0 +1,52 @@ + + diff --git a/io.sc.platform.core.frontend/src/platform/i18n/messages.json b/io.sc.platform.core.frontend/src/platform/i18n/messages.json index 86c8a475..87ac11dc 100644 --- a/io.sc.platform.core.frontend/src/platform/i18n/messages.json +++ b/io.sc.platform.core.frontend/src/platform/i18n/messages.json @@ -223,6 +223,14 @@ "math.toolbar.functions.string.endsWith": "x end with y", "math.toolbar.functions.date": "Date", "math.toolbar.functions.date.now": "Now", + "math.toolbar.functions.date.between": "Between", + "math.toolbar.functions.date.between.years": "Years", + "math.toolbar.functions.date.between.months": "Months", + "math.toolbar.functions.date.between.weeks": "Weeks", + "math.toolbar.functions.date.between.days": "Days", + "math.toolbar.functions.date.between.hours": "Hours", + "math.toolbar.functions.date.between.minutes": "Minutes", + "math.toolbar.functions.date.between.seconds": "Seconds", "math.toolbar.functions.date.log": "Logarithm", "math.toolbar.functions.date.log.lg": "base 10 logarithm of x", "math.toolbar.functions.date.log.ln": "base e logarithm of x", @@ -264,7 +272,9 @@ "math.toolbar.functions.formater": "Formater", "math.toolbar.functions.formater.precision": "Leave the y digits after the x decimal point", "math.toolbar.functions.formater.comma": "Thousandth place, leave the y digits after the x decimal point", - "math.toolbar.functions.formater.percent": "percentage, leave the y digits after the x decimal point", + "math.toolbar.functions.formater.percent": "Percentage, leave the y digits after the x decimal point", + "math.toolbar.functions.collection": "Collection", + "math.toolbar.functions.collection.hasElements": "Has Elements", "math.toolbar.userDefinedFunction": "User Defined Function", diff --git a/io.sc.platform.core.frontend/src/platform/i18n/messages_tw_CN.json b/io.sc.platform.core.frontend/src/platform/i18n/messages_tw_CN.json index 4d09d301..d5e92802 100644 --- a/io.sc.platform.core.frontend/src/platform/i18n/messages_tw_CN.json +++ b/io.sc.platform.core.frontend/src/platform/i18n/messages_tw_CN.json @@ -223,6 +223,14 @@ "math.toolbar.functions.string.endsWith": "x 是否以 y 結尾", "math.toolbar.functions.date": "日期函數", "math.toolbar.functions.date.now": "當前日期", + "math.toolbar.functions.date.between": "日期間隔", + "math.toolbar.functions.date.between.years": "間隔年數", + "math.toolbar.functions.date.between.months": "間隔月數", + "math.toolbar.functions.date.between.weeks": "間隔周數", + "math.toolbar.functions.date.between.days": "間隔天數", + "math.toolbar.functions.date.between.hours": "間隔小時數", + "math.toolbar.functions.date.between.minutes": "間隔分鐘數", + "math.toolbar.functions.date.between.seconds": "間隔秒數", "math.toolbar.functions.log": "對數", "math.toolbar.functions.log.lg": "以 10 為底的對數", "math.toolbar.functions.log.ln": "以自然對數 e 為底的對數", @@ -265,6 +273,8 @@ "math.toolbar.functions.formater.precision": "保留 x 小數點後 y 位", "math.toolbar.functions.formater.comma": "千分位, 保留 x 小數點後 y 位", "math.toolbar.functions.formater.percent": "百分數, 保留 x 小數點後 y 位", + "math.toolbar.functions.collection": "集合函數", + "math.toolbar.functions.collection.hasElements": "是否有元素", "math.toolbar.userDefinedFunction": "自定義函數", diff --git a/io.sc.platform.core.frontend/src/platform/i18n/messages_zh_CN.json b/io.sc.platform.core.frontend/src/platform/i18n/messages_zh_CN.json index c419ac68..e9675448 100644 --- a/io.sc.platform.core.frontend/src/platform/i18n/messages_zh_CN.json +++ b/io.sc.platform.core.frontend/src/platform/i18n/messages_zh_CN.json @@ -223,6 +223,14 @@ "math.toolbar.functions.string.endsWith": "x 是否以 y 结尾", "math.toolbar.functions.date": "日期函数", "math.toolbar.functions.date.now": "当前日期", + "math.toolbar.functions.date.between": "日期间隔", + "math.toolbar.functions.date.between.years": "间隔年数", + "math.toolbar.functions.date.between.months": "间隔月数", + "math.toolbar.functions.date.between.weeks": "间隔周数", + "math.toolbar.functions.date.between.days": "间隔天数", + "math.toolbar.functions.date.between.hours": "间隔小时数", + "math.toolbar.functions.date.between.minutes": "间隔分钟数", + "math.toolbar.functions.date.between.seconds": "间隔秒数", "math.toolbar.functions.log": "对数函数", "math.toolbar.functions.log.lg": "以 10 为底的对数", "math.toolbar.functions.log.ln": "以自然对数 e 为底的对数", @@ -265,6 +273,8 @@ "math.toolbar.functions.formater.precision": "保留 x 小数点后 y 位", "math.toolbar.functions.formater.comma": "千分位, 保留 x 小数点后 y 位", "math.toolbar.functions.formater.percent": "百分数, 保留 x 小数点后 y 位", + "math.toolbar.functions.collection": "集合函数", + "math.toolbar.functions.collection.hasElements": "是否有元素", "math.toolbar.userDefinedFunction": "自定义函数", diff --git a/io.sc.platform.core.frontend/template-project/package.json b/io.sc.platform.core.frontend/template-project/package.json index c01651b6..a02d7310 100644 --- a/io.sc.platform.core.frontend/template-project/package.json +++ b/io.sc.platform.core.frontend/template-project/package.json @@ -1,6 +1,6 @@ { "name": "platform-core", - "version": "8.2.15", + "version": "8.2.17", "description": "前端核心包,用于快速构建前端的脚手架", "private": false, "keywords": [], @@ -110,7 +110,7 @@ "mockjs": "1.1.0", "node-sql-parser": "5.3.4", "pinia": "2.2.6", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.platform.developer.doc/package.json b/io.sc.platform.developer.doc/package.json index 035df65a..883c413b 100644 --- a/io.sc.platform.developer.doc/package.json +++ b/io.sc.platform.developer.doc/package.json @@ -28,7 +28,7 @@ "vuepress": "2.0.0-rc.15" }, "dependencies": { - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "vue": "3.5.13", "vue-i18n": "10.0.4" diff --git a/io.sc.platform.developer.frontend/package.json b/io.sc.platform.developer.frontend/package.json index 2c2044cf..e5665e0c 100644 --- a/io.sc.platform.developer.frontend/package.json +++ b/io.sc.platform.developer.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.platform.lcdp.frontend/package.json b/io.sc.platform.lcdp.frontend/package.json index 695575c6..eecb3917 100644 --- a/io.sc.platform.lcdp.frontend/package.json +++ b/io.sc.platform.lcdp.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.platform.license.keygen.frontend/package.json b/io.sc.platform.license.keygen.frontend/package.json index b15e39a8..6bef25da 100644 --- a/io.sc.platform.license.keygen.frontend/package.json +++ b/io.sc.platform.license.keygen.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.platform.mvc.frontend/package.json b/io.sc.platform.mvc.frontend/package.json index 2ec3cbbe..a79c270c 100644 --- a/io.sc.platform.mvc.frontend/package.json +++ b/io.sc.platform.mvc.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.platform.scheduler.manager.frontend/package.json b/io.sc.platform.scheduler.manager.frontend/package.json index d09fa6af..b3e63f49 100644 --- a/io.sc.platform.scheduler.manager.frontend/package.json +++ b/io.sc.platform.scheduler.manager.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.platform.system.frontend/package.json b/io.sc.platform.system.frontend/package.json index 35e2bddf..1fa332fd 100644 --- a/io.sc.platform.system.frontend/package.json +++ b/io.sc.platform.system.frontend/package.json @@ -110,7 +110,7 @@ "mockjs": "1.1.0", "node-sql-parser": "5.3.4", "pinia": "2.2.6", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.platform.util/src/main/java/io/sc/platform/util/DateUtil.java b/io.sc.platform.util/src/main/java/io/sc/platform/util/DateUtil.java index 54239da3..a5d5c1e8 100644 --- a/io.sc.platform.util/src/main/java/io/sc/platform/util/DateUtil.java +++ b/io.sc.platform.util/src/main/java/io/sc/platform/util/DateUtil.java @@ -8,6 +8,7 @@ import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; +import java.time.temporal.ChronoUnit; import java.util.Calendar; import java.util.Date; import java.util.Locale; @@ -311,11 +312,231 @@ public class DateUtil { return new java.sql.Date(date.getTime()); } + /** + * 将 Date 对象转换成 LocalDateTime 对象 + * @param date 被转换的对象 + * @return LocalDateTime 转换后的对象 + */ public static LocalDateTime toLocalDateTime(Date date){ return LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()),ZoneId.systemDefault()); } + /** + * 将 LocalDateTime 对象转换成 Date 对象 + * @param localDateTime 被转换的对象 + * @return Date 转换后的对象 + */ public static Date fromLocalDateTime(LocalDateTime localDateTime){ return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); } + + /** + * 计算两个日期相差的年数 + * @param d1 日期1 + * @param d2 日期2 + * @return 两个日期相差的年数 + */ + public static long yearBetween(Date d1,Date d2){ + LocalDateTime ld1 =toLocalDateTime(d1); + LocalDateTime ld2 =toLocalDateTime(d2); + return ChronoUnit.YEARS.between(ld2,ld1); + } + + /** + * 计算两个日期相差的年数 + * @param d1Str 日期字符串1 + * @param d2Str 日期字符串2 + * @return 两个日期相差的年数 + */ + public static long yearBetween(String d1Str,String d2Str){ + try { + Date d1 = tryParseDate(d1Str); + Date d2 = tryParseDate(d2Str); + LocalDateTime ld1 = toLocalDateTime(d1); + LocalDateTime ld2 = toLocalDateTime(d2); + return ChronoUnit.YEARS.between(ld2, ld1); + }catch (Exception e){ + throw new RuntimeException(e); + } + } + + /** + * 计算两个日期相差的月数 + * @param d1 日期1 + * @param d2 日期2 + * @return 两个日期相差的月数 + */ + public static long monthBetween(Date d1,Date d2){ + LocalDateTime ld1 =toLocalDateTime(d1); + LocalDateTime ld2 =toLocalDateTime(d2); + return ChronoUnit.MONTHS.between(ld2,ld1); + } + + /** + * 计算两个日期相差的月数 + * @param d1Str 日期字符串1 + * @param d2Str 日期字符串2 + * @return 两个日期相差的月数 + */ + public static long monthBetween(String d1Str,String d2Str){ + try { + Date d1 = tryParseDate(d1Str); + Date d2 = tryParseDate(d2Str); + LocalDateTime ld1 = toLocalDateTime(d1); + LocalDateTime ld2 = toLocalDateTime(d2); + return ChronoUnit.MONTHS.between(ld2, ld1); + }catch (Exception e){ + throw new RuntimeException(e); + } + } + + /** + * 计算两个日期相差的周数 + * @param d1 日期1 + * @param d2 日期2 + * @return 两个日期相差的周数 + */ + public static long weeksBetween(Date d1,Date d2){ + LocalDateTime ld1 =toLocalDateTime(d1); + LocalDateTime ld2 =toLocalDateTime(d2); + return ChronoUnit.WEEKS.between(ld2,ld1); + } + + /** + * 计算两个日期相差的周数 + * @param d1Str 日期字符串1 + * @param d2Str 日期字符串2 + * @return 两个日期相差的周数 + */ + public static long weeksBetween(String d1Str,String d2Str){ + try { + Date d1 = tryParseDate(d1Str); + Date d2 = tryParseDate(d2Str); + LocalDateTime ld1 = toLocalDateTime(d1); + LocalDateTime ld2 = toLocalDateTime(d2); + return ChronoUnit.SECONDS.between(ld2, ld1); + }catch (Exception e){ + throw new RuntimeException(e); + } + } + + /** + * 计算两个日期相差的天数 + * @param d1 日期1 + * @param d2 日期2 + * @return 两个日期相差的天数 + */ + public static long dayBetween(Date d1,Date d2){ + LocalDateTime ld1 =toLocalDateTime(d1); + LocalDateTime ld2 =toLocalDateTime(d2); + return ChronoUnit.DAYS.between(ld2,ld1); + } + + /** + * 计算两个日期相差的天数 + * @param d1Str 日期字符串1 + * @param d2Str 日期字符串2 + * @return 两个日期相差的天数 + */ + public static long dayBetween(String d1Str,String d2Str){ + try { + Date d1 = tryParseDate(d1Str); + Date d2 = tryParseDate(d2Str); + LocalDateTime ld1 = toLocalDateTime(d1); + LocalDateTime ld2 = toLocalDateTime(d2); + return ChronoUnit.DAYS.between(ld2, ld1); + }catch (Exception e){ + throw new RuntimeException(e); + } + } + + /** + * 计算两个日期相差的小时数 + * @param d1 日期1 + * @param d2 日期2 + * @return 两个日期相差的小时数 + */ + public static long hoursBetween(Date d1,Date d2){ + LocalDateTime ld1 =toLocalDateTime(d1); + LocalDateTime ld2 =toLocalDateTime(d2); + return ChronoUnit.HOURS.between(ld2,ld1); + } + + /** + * 计算两个日期相差的小时数 + * @param d1Str 日期字符串1 + * @param d2Str 日期字符串2 + * @return 两个日期相差的小时数 + */ + public static long hoursBetween(String d1Str,String d2Str){ + try { + Date d1 = tryParseDate(d1Str); + Date d2 = tryParseDate(d2Str); + LocalDateTime ld1 = toLocalDateTime(d1); + LocalDateTime ld2 = toLocalDateTime(d2); + return ChronoUnit.HOURS.between(ld2, ld1); + }catch (Exception e){ + throw new RuntimeException(e); + } + } + + /** + * 计算两个日期相差的分钟数 + * @param d1 日期1 + * @param d2 日期2 + * @return 两个日期相差的分钟数 + */ + public static long minutesBetween(Date d1,Date d2){ + LocalDateTime ld1 =toLocalDateTime(d1); + LocalDateTime ld2 =toLocalDateTime(d2); + return ChronoUnit.MINUTES.between(ld2,ld1); + } + + /** + * 计算两个日期相差的分钟数 + * @param d1Str 日期字符串1 + * @param d2Str 日期字符串2 + * @return 两个日期相差的分钟数 + */ + public static long minutesBetween(String d1Str,String d2Str){ + try { + Date d1 = tryParseDate(d1Str); + Date d2 = tryParseDate(d2Str); + LocalDateTime ld1 = toLocalDateTime(d1); + LocalDateTime ld2 = toLocalDateTime(d2); + return ChronoUnit.HOURS.between(ld2, ld1); + }catch (Exception e){ + throw new RuntimeException(e); + } + } + + /** + * 计算两个日期相差的秒数 + * @param d1 日期1 + * @param d2 日期2 + * @return 两个日期相差的秒数 + */ + public static long secondsBetween(Date d1,Date d2){ + LocalDateTime ld1 =toLocalDateTime(d1); + LocalDateTime ld2 =toLocalDateTime(d2); + return ChronoUnit.SECONDS.between(ld2,ld1); + } + + /** + * 计算两个日期相差的秒数 + * @param d1Str 日期字符串1 + * @param d2Str 日期字符串2 + * @return 两个日期相差的秒数 + */ + public static long secondsBetween(String d1Str,String d2Str){ + try { + Date d1 = tryParseDate(d1Str); + Date d2 = tryParseDate(d2Str); + LocalDateTime ld1 = toLocalDateTime(d1); + LocalDateTime ld2 = toLocalDateTime(d2); + return ChronoUnit.SECONDS.between(ld2, ld1); + }catch (Exception e){ + throw new RuntimeException(e); + } + } } diff --git a/io.sc.standard.frontend/package.json b/io.sc.standard.frontend/package.json index d189766e..8c2f58c2 100644 --- a/io.sc.standard.frontend/package.json +++ b/io.sc.standard.frontend/package.json @@ -111,7 +111,7 @@ "node-sql-parser": "5.3.4", "pinia": "2.2.6", "pinia-undo": "0.2.4", - "platform-core": "8.2.15", + "platform-core": "8.2.17", "quasar": "2.17.4", "sort-array": "5.0.0", "svg-path-commander": "2.1.5", diff --git a/io.sc.website/package.json b/io.sc.website/package.json index d943be35..1ba6fd17 100644 --- a/io.sc.website/package.json +++ b/io.sc.website/package.json @@ -28,6 +28,6 @@ }, "dependencies": { "vue": "3.5.13", - "platform-core": "8.2.15" + "platform-core": "8.2.17" } } \ No newline at end of file