|
@@ -246,7 +246,7 @@ public class WorkCalendarDateHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- resultList.forEach(calendarDate -> calendarDate.setId(IdGenerator.getUUID()));
|
|
|
+ resultList.forEach(calendarDate -> calendarDate.setId(IdGenerator.getSnowIdStr(WorkCalendarConstant.WORK_CALENDAR_DATE_ID_PREFIX)));
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
@@ -495,9 +495,12 @@ public class WorkCalendarDateHandler {
|
|
|
throw new BusinessException("作息日期不合法,必须大于等于当日");
|
|
|
}
|
|
|
// 判断工作历类型是否存在
|
|
|
- WorkCalendar calendar = this.workCalendarService.getById(batchInfo.getCalendarId(), createVO.getGroupCode(), createVO.getProjectId());
|
|
|
- if (calendar == null) {
|
|
|
- throw new BusinessException("工作历类型不存在");
|
|
|
+ WorkCalendar calendar = null;
|
|
|
+ if (dictTypeLevel == 2) {
|
|
|
+ calendar = this.workCalendarService.getById(batchInfo.getCalendarId(), createVO.getGroupCode(), createVO.getProjectId());
|
|
|
+ if (calendar == null) {
|
|
|
+ throw new BusinessException("工作历类型不存在");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
WorkCalendarDate calendarDate = new WorkCalendarDate();
|
|
@@ -508,13 +511,11 @@ public class WorkCalendarDateHandler {
|
|
|
throw new BusinessException("当天已存在相同类型额定义,不可重复添加");
|
|
|
}
|
|
|
calendarDate.setGroupCode(createVO.getGroupCode());
|
|
|
- calendarDate.setCalendarName(calendar.getCalendarName());
|
|
|
- calendarDate.setCalendarDesc(calendar.getCalendarDesc());
|
|
|
+ calendarDate.setCalendarName(calendar == null ? null : calendar.getCalendarName());
|
|
|
+ calendarDate.setCalendarDesc(calendar == null ? null : calendar.getCalendarDesc());
|
|
|
calendarDate.setProjectId(dictTypeLevel == 0 ? "0" : createVO.getProjectId());
|
|
|
if (dictTypeLevel != 2) {
|
|
|
calendarDate.setCalendarId("0");
|
|
|
- calendarDate.setCalendarName(null);
|
|
|
- calendarDate.setCalendarDesc(null);
|
|
|
}
|
|
|
calendarDate.setUpdateUser(createVO.getUserId());
|
|
|
calendarDate.setCustomFlag(WorkCalendarConstant.CUSTOM_CALENDAR_DATE_YES);
|
|
@@ -610,37 +611,39 @@ public class WorkCalendarDateHandler {
|
|
|
String format = DateUtil.format(now, DateUtil.FORMAT_DATE_YYYYMMDD);
|
|
|
Integer current = Integer.valueOf(format);
|
|
|
for (WorkCalendarDateUpdateVO batchInfo : batchInfos) {
|
|
|
- int dictTypeLevel = this.workCalendarDictService.getDictTypeLevel(updateVO.getGroupCode(), batchInfo.getDictType());
|
|
|
-
|
|
|
Integer workDate = Integer.valueOf(batchInfo.getWorkDate());
|
|
|
if (workDate < current) {
|
|
|
throw new BusinessException("作息日期不合法,必须大于等于当日");
|
|
|
}
|
|
|
+ // 验证是否存在
|
|
|
+ WorkCalendarDate temp = this.workCalendarDateService.getById(batchInfo.getId());
|
|
|
+ if (temp == null || !WorkCalendarConstant.CUSTOM_CALENDAR_DATE_YES.equals(temp.getCustomFlag())) {
|
|
|
+ throw new BusinessException("当天不存在自定义的作息时间信息");
|
|
|
+ }
|
|
|
+ int dictTypeLevel = this.workCalendarDictService.getDictTypeLevel(updateVO.getGroupCode(), batchInfo.getDictType());
|
|
|
+
|
|
|
// 判断工作历类型是否存在
|
|
|
- WorkCalendar calendar = this.workCalendarService.getById(batchInfo.getCalendarId(), updateVO.getGroupCode(), updateVO.getProjectId());
|
|
|
- if (calendar == null) {
|
|
|
- throw new BusinessException("工作历类型不存在");
|
|
|
+ WorkCalendar calendar = null;
|
|
|
+ if (dictTypeLevel == 2) {
|
|
|
+ calendar = this.workCalendarService.getById(batchInfo.getCalendarId(), updateVO.getGroupCode(), updateVO.getProjectId());
|
|
|
+ if (calendar == null) {
|
|
|
+ throw new BusinessException("工作历类型不存在");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
WorkCalendarDate calendarDate = new WorkCalendarDate();
|
|
|
BeanUtils.copyProperties(batchInfo, calendarDate);
|
|
|
- // 验证数据有效性
|
|
|
- result = this.workCalendarDateService.checkWorkDateValid(calendarDate, dictTypeLevel);
|
|
|
- if (!result) {
|
|
|
- throw new BusinessException("当天已存在相同类型的定义,不可重复添加");
|
|
|
- }
|
|
|
+ calendarDate.setCustomFlag(WorkCalendarConstant.CUSTOM_CALENDAR_DATE_YES);
|
|
|
+
|
|
|
calendarDate.setGroupCode(updateVO.getGroupCode());
|
|
|
- calendarDate.setCalendarName(calendar.getCalendarName());
|
|
|
- calendarDate.setCalendarDesc(calendar.getCalendarDesc());
|
|
|
+ calendarDate.setCalendarName(calendar == null ? null : calendar.getCalendarName());
|
|
|
+ calendarDate.setCalendarDesc(calendar == null ? null : calendar.getCalendarDesc());
|
|
|
calendarDate.setProjectId(dictTypeLevel == 0 ? "0" : updateVO.getProjectId());
|
|
|
if (dictTypeLevel != 2) {
|
|
|
calendarDate.setCalendarId("0");
|
|
|
- calendarDate.setCalendarName(null);
|
|
|
- calendarDate.setCalendarDesc(null);
|
|
|
}
|
|
|
|
|
|
calendarDate.setUpdateUser(updateVO.getUserId());
|
|
|
- calendarDate.setCustomFlag(WorkCalendarConstant.CUSTOM_CALENDAR_DATE_YES);
|
|
|
result = this.workCalendarDateService.updateById(calendarDate);
|
|
|
if (!result) {
|
|
|
throw new BusinessException("自定义工作历作息时间添加失败");
|