Bläddra i källkod

优化,允许当天修改时间标签

zhangqiankun 3 år sedan
förälder
incheckning
ebf5d1a831
1 ändrade filer med 20 tillägg och 15 borttagningar
  1. 20 15
      src/main/java/com/persagy/calendar/handle/WorkCalendarDateHandler.java

+ 20 - 15
src/main/java/com/persagy/calendar/handle/WorkCalendarDateHandler.java

@@ -85,10 +85,14 @@ public class WorkCalendarDateHandler {
 		if (currentDate.before(dateStart)) {
 			currentDate = dateStart;
 		} else {
-			currentDate.offset(DateField.DAY_OF_YEAR, 1);
+			// 验证此日是否已存在数据,已存在,这里往后偏移一日
+			if (resultMap.containsKey(currentDate.toString(DateUtil.FORMAT_DATE_YYYYMMDD))) {
+				currentDate.offset(DateField.DAY_OF_YEAR, 1);
+			}
 		}
+		
+		// 因为dataEnd时分秒一定是000000,所以这里只要当前日期时间点在dateEnd之前,就说明偏移后最坏与dateEnd相同
     	if (currentDate.before(dateEnd) || currentDate.equals(dateEnd)) {
-    		// 因为dataEnd时分秒一定是000000,所以这里只要当前日期时间点在dateEnd之前,就说明偏移后最坏与dateEnd相同
     		String offsetStr = currentDate.toString(DateUtil.FORMAT_DATE_YYYYMMDD);
     		List<WorkCalendarRule> ruleList = this.selectWorkCalendarRuleList(offsetStr, dateEndStr, queryVO);
     		if (CollectionUtil.isNotEmpty(ruleList)) {
@@ -151,6 +155,7 @@ public class WorkCalendarDateHandler {
     }
     
     /**
+     * 获取此段日期内,所有的历史数据,包含自定义的
      * 
      * @param resultMap	key-日期,value-此日对应的作息时间集合,包含未来自定义的
      * @param existsCustom key-项目+日期+type+code,value-true存在自定义信息,false 不存在自定义信息
@@ -486,15 +491,15 @@ public class WorkCalendarDateHandler {
 	public void batchCreateCalendarDate(CustomCalendarVO<WorkCalendarDateCreateVO> createVO) {
 		boolean result = false;
 		List<WorkCalendarDateCreateVO> batchInfos = createVO.getBatchInfo();
+		// 判断日期是否合法
+		DateTime now = DateUtil.date();
+		//now = now.offset(DateField.DAY_OF_YEAR, 1);	//明天
+		String format = DateUtil.format(now, DateUtil.FORMAT_DATE_YYYYMMDD);
+		Integer current = Integer.valueOf(format);
 		for (WorkCalendarDateCreateVO batchInfo : batchInfos) {
-			// 判断日期是否合法
-			DateTime now = DateUtil.date();
-			now = now.offset(DateField.DAY_OF_YEAR, 1);	//明天
-			String format = DateUtil.format(now, DateUtil.FORMAT_DATE_YYYYMMDD);
-			Integer current = Integer.valueOf(format);
 			Integer workDate = Integer.valueOf(batchInfo.getWorkDate());
 			if (workDate < current) {
-				throw new BusinessException("作息日期不合法,必须大于日");
+				throw new BusinessException("作息日期不合法,必须大于等于当日");
 			}
 			// 判断工作历类型是否存在
 			WorkCalendar calendar = this.workCalendarService.getById(batchInfo.getCalendarId(), createVO.getProjectId());
@@ -529,15 +534,15 @@ public class WorkCalendarDateHandler {
 	public <T> void batchUpdateCalendarDate(CustomCalendarVO<WorkCalendarDateUpdateVO> updateVO) {
 		boolean result = false;
 		List<WorkCalendarDateUpdateVO> batchInfos = updateVO.getBatchInfo();
+		// 判断日期是否合法
+		DateTime now = DateUtil.date();
+		//now = now.offset(DateField.DAY_OF_YEAR, 1);	//明天
+		String format = DateUtil.format(now, DateUtil.FORMAT_DATE_YYYYMMDD);
+		Integer current = Integer.valueOf(format);
 		for (WorkCalendarDateUpdateVO batchInfo : batchInfos) {
-			// 判断日期是否合法
-			DateTime now = DateUtil.date();
-			now = now.offset(DateField.DAY_OF_YEAR, 1);	//明天
-			String format = DateUtil.format(now, DateUtil.FORMAT_DATE_YYYYMMDD);
-			Integer current = Integer.valueOf(format);
 			Integer workDate = Integer.valueOf(batchInfo.getWorkDate());
 			if (workDate < current) {
-				throw new BusinessException("作息日期不合法,必须大于日");
+				throw new BusinessException("作息日期不合法,必须大于等于当日");
 			}
 			// 判断工作历类型是否存在
 			WorkCalendar calendar = this.workCalendarService.getById(batchInfo.getCalendarId(), updateVO.getProjectId());
@@ -645,7 +650,7 @@ public class WorkCalendarDateHandler {
 	 */
 	public static boolean isMoreThanToday(String workDate) {
 		DateTime now = DateUtil.date();
-		now = now.offset(DateField.DAY_OF_YEAR, 1);		//明天
+		//now = now.offset(DateField.DAY_OF_YEAR, 1);		//明天
 		String format = DateUtil.format(now, DateUtil.FORMAT_DATE_YYYYMMDD);
 		Integer current = Integer.valueOf(format);
 		Integer dateInt = Integer.valueOf(workDate);