Commit 23e192c9 by 刘鑫

feat(工作日历):新增 判定工程师是否全天请假(非派工时间)或者全天休息接口

1 parent 2cb745ed
......@@ -92,4 +92,14 @@ public interface EngineerCalendarService {
* @return 时间窗格式
*/
List<OccupyInfoDetail> timeWindowsSlice(String engineerCode, String teamId, LocalDate targetDate);
/**
* 判定工程师是否全天请假(非派工时间)或者全天休息
*
* @param engineerCode 工程师编号
* @param targetDate 目标日期
* @return 全天休息(含请假)返回true, 否则false
*/
boolean engineerTargetLeave(String engineerCode, LocalDate targetDate);
}
......@@ -716,6 +716,31 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
return CapacityUtils.intervalTime(workStartTime, workEndTime, usedTimeInfo);
}
@Override
public boolean engineerTargetLeave(String engineerCode, LocalDate targetDate) {
Set<OrgTeamEntity> teams = orgTeamDao.selectTeamByEngineerCode(engineerCode);
List<String> teamCommonWorkdaysOfWeek = Optional.ofNullable(teams).orElse(Collections.emptySet()).stream()
.map(team -> Arrays.asList(team.getWorkdays().split(",")))
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
// 求多个工作队的公共空闲时间
final int dayOfWeek = targetDate.getDayOfWeek().getValue();
List<String> commonLeisureDayOfWeek = ALL_WORK_DAY_OF_WEEK.stream()
.filter(day -> teamCommonWorkdaysOfWeek.stream().noneMatch(tDay -> Objects.equals(day, tDay)))
.collect(Collectors.toList());
if (!commonLeisureDayOfWeek.contains(String.valueOf(dayOfWeek))) {
//日程表事件记录时间
List<CapacityEngineerCalendarEntity> configs = capacityEngineerCalendarDao.findCalendarByWorkdayAndEngineerCode(DateTimeUtil.formatDate(targetDate), engineerCode);
return Optional.ofNullable(configs).orElse(Collections.emptyList())
.stream()
.anyMatch(t -> Objects.equals(Boolean.TRUE, t.getWholeDay()));
}
return true;
}
private EngineerCalendarDTO.Calendar getEmptyCalendar(String teamId, String date) {
// 初始化一天的日历
EngineerCalendarDTO.Calendar calendar = new EngineerCalendarDTO.Calendar();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!