From 6e5742ff08c0aa1900a17c5093449172f95356cc Mon Sep 17 00:00:00 2001 From: baoliang Date: Fri, 24 May 2019 19:07:00 +0800 Subject: [PATCH 1/2] add depend item interval "today" --- .../escheduler/common/utils/DependentUtils.java | 3 +++ .../utils/dependent/DependentDateUtils.java | 15 +++++++++++++++ .../common/utils/DependentUtilsTest.java | 11 +++++++++++ .../_source/formModel/tasks/_source/commcon.js | 4 ++++ escheduler-ui/src/js/module/i18n/locale/en_US.js | 1 + escheduler-ui/src/js/module/i18n/locale/zh_CN.js | 1 + 6 files changed, 35 insertions(+) diff --git a/escheduler-common/src/main/java/cn/escheduler/common/utils/DependentUtils.java b/escheduler-common/src/main/java/cn/escheduler/common/utils/DependentUtils.java index 5f3e15328d..4e589c37fa 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/utils/DependentUtils.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/utils/DependentUtils.java @@ -80,6 +80,9 @@ public class DependentUtils { case "last3Hours": result = DependentDateUtils.getLastHoursInterval(businessDate, 3); break; + case "today": + result = DependentDateUtils.getTodayInterval(businessDate); + break; case "last1Days": result = DependentDateUtils.getLastDayInterval(businessDate, 1); break; diff --git a/escheduler-common/src/main/java/cn/escheduler/common/utils/dependent/DependentDateUtils.java b/escheduler-common/src/main/java/cn/escheduler/common/utils/dependent/DependentDateUtils.java index c6c2375827..df79dd163a 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/utils/dependent/DependentDateUtils.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/utils/dependent/DependentDateUtils.java @@ -42,6 +42,21 @@ public class DependentDateUtils { return dateIntervals; } + /** + * get today day interval list + * @param businessDate + * @return + */ + public static List getTodayInterval(Date businessDate){ + + List dateIntervals = new ArrayList<>(); + + Date beginTime = DateUtils.getStartOfDay(businessDate); + Date endTime = DateUtils.getEndOfDay(businessDate); + dateIntervals.add(new DateInterval(beginTime, endTime)); + return dateIntervals; + } + /** * get last day interval list * @param businessDate diff --git a/escheduler-common/src/test/java/cn/escheduler/common/utils/DependentUtilsTest.java b/escheduler-common/src/test/java/cn/escheduler/common/utils/DependentUtilsTest.java index b907b018a4..a0569b02ee 100644 --- a/escheduler-common/src/test/java/cn/escheduler/common/utils/DependentUtilsTest.java +++ b/escheduler-common/src/test/java/cn/escheduler/common/utils/DependentUtilsTest.java @@ -52,6 +52,10 @@ public class DependentUtilsTest { public void getDateIntervalList() { Date curDay = DateUtils.stringToDate("2019-02-05 00:00:00"); + + DateInterval diCur = new DateInterval(DateUtils.getStartOfDay(curDay), + DateUtils.getEndOfDay(curDay)); + Date day1 = DateUtils.stringToDate("2019-02-04 00:00:00"); DateInterval di1 = new DateInterval(DateUtils.getStartOfDay(day1), DateUtils.getEndOfDay(day1)); @@ -70,6 +74,13 @@ public class DependentUtilsTest { Assert.assertEquals(dateIntervals.get(1), di1); Assert.assertEquals(dateIntervals.get(0), di2); + + dateValue = "today"; + dateIntervals = DependentUtils.getDateIntervalList(curDay, dateValue); + Assert.assertEquals(dateIntervals.get(0), diCur); + + + } @Test diff --git a/escheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/commcon.js b/escheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/commcon.js index 389ac6f603..6274533c1a 100644 --- a/escheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/commcon.js +++ b/escheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/commcon.js @@ -42,6 +42,10 @@ const dateValueList = { } ], 'day': [ + { + value: 'today', + label: `${i18n.$t('today')}` + }, { value: 'last1Days', label: `${i18n.$t('Last1Days')}` diff --git a/escheduler-ui/src/js/module/i18n/locale/en_US.js b/escheduler-ui/src/js/module/i18n/locale/en_US.js index 3cffeeb376..50c33c061b 100644 --- a/escheduler-ui/src/js/module/i18n/locale/en_US.js +++ b/escheduler-ui/src/js/module/i18n/locale/en_US.js @@ -390,6 +390,7 @@ export default { 'Last1Hour': 'Last1Hour', 'Last2Hours': 'Last2Hours', 'Last3Hours': 'Last3Hours', + 'today': 'today', 'Last1Days': 'Last1Days', 'Last2Days': 'Last2Days', 'Last3Days': 'Last3Days', diff --git a/escheduler-ui/src/js/module/i18n/locale/zh_CN.js b/escheduler-ui/src/js/module/i18n/locale/zh_CN.js index affc01235f..f4ff68fe03 100644 --- a/escheduler-ui/src/js/module/i18n/locale/zh_CN.js +++ b/escheduler-ui/src/js/module/i18n/locale/zh_CN.js @@ -390,6 +390,7 @@ export default { 'Last1Hour': '前1小时', 'Last2Hours': '前2小时', 'Last3Hours': '前3小时', + 'today': '今天', 'Last1Days': '昨天', 'Last2Days': '前两天', 'Last3Days': '前三天', From 8033a6304c8d22c6d790d78183213c4e7789e5fa Mon Sep 17 00:00:00 2001 From: baoliang Date: Fri, 24 May 2019 19:58:11 +0800 Subject: [PATCH 2/2] update sql for dependent --- .../escheduler/dao/mapper/ProcessInstanceMapperProvider.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ProcessInstanceMapperProvider.java b/escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ProcessInstanceMapperProvider.java index 7e078b995b..a6d09d431b 100644 --- a/escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ProcessInstanceMapperProvider.java +++ b/escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ProcessInstanceMapperProvider.java @@ -572,11 +572,10 @@ public class ProcessInstanceMapperProvider { FROM(TABLE_NAME); - WHERE("process_definition_id=#{processDefinitionId} "); if(parameter.get("startTime") != null && parameter.get("endTime") != null ){ - WHERE("schedule_time between #{startTime} and #{endTime} " + - "or start_time between #{startTime} and #{endTime}"); + WHERE("process_definition_id=#{processDefinitionId} and (schedule_time between #{startTime} and #{endTime} " + + "or start_time between #{startTime} and #{endTime})"); } WHERE("`state` in (" + strStates.toString() + ")"); ORDER_BY("start_time desc limit 1");