Browse Source

Merge remote-tracking branch 'remotes/upstream/branch-1.0.2' into branch-1.0.2

pull/2/head
qiaozhanwei 6 years ago
parent
commit
d9953a037a
  1. 1
      escheduler-api/src/main/java/cn/escheduler/api/service/ResourcesService.java
  2. 6
      escheduler-common/src/main/java/cn/escheduler/common/utils/DependentUtils.java
  3. 20
      escheduler-common/src/main/java/cn/escheduler/common/utils/dependent/DependentDateUtils.java
  4. 20
      escheduler-common/src/test/java/cn/escheduler/common/utils/DependentUtilsTest.java
  5. 8
      escheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/commcon.js
  6. 2
      escheduler-ui/src/js/module/i18n/locale/en_US.js
  7. 2
      escheduler-ui/src/js/module/i18n/locale/zh_CN.js

1
escheduler-api/src/main/java/cn/escheduler/api/service/ResourcesService.java

@ -643,6 +643,7 @@ public class ResourcesService extends BaseService {
logger.error("{} is not exist", resourcePath); logger.error("{} is not exist", resourcePath);
result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); result.setCode(Status.HDFS_OPERATION_ERROR.getCode());
result.setMsg(String.format("%s is not exist", resourcePath)); result.setMsg(String.format("%s is not exist", resourcePath));
return result;
} }
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);

6
escheduler-common/src/main/java/cn/escheduler/common/utils/DependentUtils.java

@ -95,6 +95,9 @@ public class DependentUtils {
case "last7Days": case "last7Days":
result = DependentDateUtils.getLastDayInterval(businessDate, 7); result = DependentDateUtils.getLastDayInterval(businessDate, 7);
break; break;
case "thisWeek":
result = DependentDateUtils.getThisWeekInterval(businessDate);
break;
case "lastWeek": case "lastWeek":
result = DependentDateUtils.getLastWeekInterval(businessDate); result = DependentDateUtils.getLastWeekInterval(businessDate);
break; break;
@ -119,6 +122,9 @@ public class DependentUtils {
case "lastSunday": case "lastSunday":
result = DependentDateUtils.getLastWeekOneDayInterval(businessDate, 7); result = DependentDateUtils.getLastWeekOneDayInterval(businessDate, 7);
break; break;
case "thisMonth":
result = DependentDateUtils.getThisMonthInterval(businessDate);
break;
case "lastMonth": case "lastMonth":
result = DependentDateUtils.getLastMonthInterval(businessDate); result = DependentDateUtils.getLastMonthInterval(businessDate);
break; break;

20
escheduler-common/src/main/java/cn/escheduler/common/utils/dependent/DependentDateUtils.java

@ -76,6 +76,16 @@ public class DependentDateUtils {
return dateIntervals; return dateIntervals;
} }
/**
* get interval between this month first day and businessDate
* @param businessDate
* @return
*/
public static List<DateInterval> getThisMonthInterval(Date businessDate) {
Date firstDay = DateUtils.getFirstDayOfMonth(businessDate);
return getDateIntervalListBetweenTwoDates(firstDay, businessDate);
}
/** /**
* get interval between last month first day and last day * get interval between last month first day and last day
* @param businessDate * @param businessDate
@ -108,6 +118,16 @@ public class DependentDateUtils {
} }
} }
/**
* get interval between monday to businessDate of this week
* @param businessDate
* @return
*/
public static List<DateInterval> getThisWeekInterval(Date businessDate) {
Date mondayThisWeek = DateUtils.getMonday(businessDate);
return getDateIntervalListBetweenTwoDates(mondayThisWeek, businessDate);
}
/** /**
* get interval between monday to sunday of last week * get interval between monday to sunday of last week
* default set monday the first day of week * default set monday the first day of week

20
escheduler-common/src/test/java/cn/escheduler/common/utils/DependentUtilsTest.java

@ -80,6 +80,26 @@ public class DependentUtilsTest {
Assert.assertEquals(dateIntervals.get(0), diCur); Assert.assertEquals(dateIntervals.get(0), diCur);
dateValue = "thisWeek";
Date firstWeekDay = DateUtils.getMonday(curDay);
dateIntervals = DependentUtils.getDateIntervalList(curDay, dateValue);
DateInterval weekHead = new DateInterval(DateUtils.getStartOfDay(firstWeekDay), DateUtils.getEndOfDay(firstWeekDay));
DateInterval weekThis = new DateInterval(DateUtils.getStartOfDay(curDay), DateUtils.getEndOfDay(curDay));
Assert.assertEquals(dateIntervals.get(0), weekHead);
Assert.assertEquals(dateIntervals.get(dateIntervals.size() - 1), weekThis);
dateValue = "thisMonth";
Date firstMonthDay = DateUtils.getFirstDayOfMonth(curDay);
dateIntervals = DependentUtils.getDateIntervalList(curDay, dateValue);
DateInterval monthHead = new DateInterval(DateUtils.getStartOfDay(firstMonthDay), DateUtils.getEndOfDay(firstMonthDay));
DateInterval monthThis = new DateInterval(DateUtils.getStartOfDay(curDay), DateUtils.getEndOfDay(curDay));
Assert.assertEquals(dateIntervals.get(0), monthHead);
Assert.assertEquals(dateIntervals.get(dateIntervals.size() - 1), monthThis);
} }

8
escheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/commcon.js

@ -64,6 +64,10 @@ const dateValueList = {
} }
], ],
'week': [ 'week': [
{
value: 'thisWeek',
label: `${i18n.$t('ThisWeek')}`
},
{ {
value: 'lastWeek', value: 'lastWeek',
label: `${i18n.$t('LastWeek')}` label: `${i18n.$t('LastWeek')}`
@ -98,6 +102,10 @@ const dateValueList = {
} }
], ],
'month': [ 'month': [
{
value: 'thisMonth',
label: `${i18n.$t('ThisMonth')}`
},
{ {
value: 'lastMonth', value: 'lastMonth',
label: `${i18n.$t('LastMonth')}` label: `${i18n.$t('LastMonth')}`

2
escheduler-ui/src/js/module/i18n/locale/en_US.js

@ -395,6 +395,7 @@ export default {
'Last2Days': 'Last2Days', 'Last2Days': 'Last2Days',
'Last3Days': 'Last3Days', 'Last3Days': 'Last3Days',
'Last7Days': 'Last7Days', 'Last7Days': 'Last7Days',
'ThisWeek': 'ThisWeek',
'LastWeek': 'LastWeek', 'LastWeek': 'LastWeek',
'LastMonday': 'LastMonday', 'LastMonday': 'LastMonday',
'LastTuesday': 'LastTuesday', 'LastTuesday': 'LastTuesday',
@ -403,6 +404,7 @@ export default {
'LastFriday': 'LastFriday', 'LastFriday': 'LastFriday',
'LastSaturday': 'LastSaturday', 'LastSaturday': 'LastSaturday',
'LastSunday': 'LastSunday', 'LastSunday': 'LastSunday',
'ThisMonth': 'ThisMonth',
'LastMonth': 'LastMonth', 'LastMonth': 'LastMonth',
'LastMonthBegin': 'LastMonthBegin', 'LastMonthBegin': 'LastMonthBegin',
'LastMonthEnd': 'LastMonthEnd', 'LastMonthEnd': 'LastMonthEnd',

2
escheduler-ui/src/js/module/i18n/locale/zh_CN.js

@ -395,6 +395,7 @@ export default {
'Last2Days': '前两天', 'Last2Days': '前两天',
'Last3Days': '前三天', 'Last3Days': '前三天',
'Last7Days': '前七天', 'Last7Days': '前七天',
'ThisWeek': '本周',
'LastWeek': '上周', 'LastWeek': '上周',
'LastMonday': '上周一', 'LastMonday': '上周一',
'LastTuesday': '上周二', 'LastTuesday': '上周二',
@ -403,6 +404,7 @@ export default {
'LastFriday': '上周五', 'LastFriday': '上周五',
'LastSaturday': '上周六', 'LastSaturday': '上周六',
'LastSunday': '上周日', 'LastSunday': '上周日',
'ThisMonth': '本月',
'LastMonth': '上月', 'LastMonth': '上月',
'LastMonthBegin': '上月初', 'LastMonthBegin': '上月初',
'LastMonthEnd': '上月末', 'LastMonthEnd': '上月末',

Loading…
Cancel
Save