Commit b71432b0 by 刘鑫

feat: 支持特殊时间段容量

1 parent ff140296
...@@ -156,10 +156,7 @@ public class CapacityQueryServiceImpl implements CapacityQueryService { ...@@ -156,10 +156,7 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
CopyOnWriteArrayList<TimeSliceEntity> halfDayTypeTimeSlice = new CopyOnWriteArrayList<>(timeSliceDao.findByType("HALF_DAY")); CopyOnWriteArrayList<TimeSliceEntity> halfDayTypeTimeSlice = new CopyOnWriteArrayList<>(timeSliceDao.findByType("HALF_DAY"));
CopyOnWriteArrayList<TimeSliceEntity> allDayTypeTimeSlice = new CopyOnWriteArrayList<>(timeSliceDao.findByType("ALL_DAY")); CopyOnWriteArrayList<TimeSliceEntity> allDayTypeTimeSlice = new CopyOnWriteArrayList<>(timeSliceDao.findByType("ALL_DAY"));
CopyOnWriteArrayList<TimeSliceEntity> timeSliceEntities = new CopyOnWriteArrayList<>(sliceTime(LocalDate.now(), CopyOnWriteArrayList<TimeSliceEntity> timeSliceEntities = getTimeSliceEntities(teamId);
LocalTime.of(8, 0),
LocalTime.of(18, 0)));
//定义返回值 //定义返回值
CapacityQueryDTO.Result result = new CapacityQueryDTO.Result(); CapacityQueryDTO.Result result = new CapacityQueryDTO.Result();
result.setGroupId(groupList.get(0)); result.setGroupId(groupList.get(0));
...@@ -197,6 +194,47 @@ public class CapacityQueryServiceImpl implements CapacityQueryService { ...@@ -197,6 +194,47 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
return Result.success(result); return Result.success(result);
} }
private CopyOnWriteArrayList<TimeSliceEntity> getTimeSliceEntities(String teamId) {
//获取工作队信息
OrgTeamEntity team = orgTeamDao.getByTeamId(teamId);
String workOn = String.format("%s:00", team.getWorkOn());
String workOff = String.format("%s:00", team.getWorkOff());
LocalTime teamWorkStartTime = LocalTime.parse(workOn, DateUtil.TIME_FORMATTER);
LocalTime teamWorkEndTime = LocalTime.parse(workOff, DateUtil.TIME_FORMATTER);
//切片开始时间
LocalTime sliceStartHour = LocalTime.of(teamWorkStartTime.getHour(), 0);
//切片结束时间
LocalTime sliceEndHour;
int minuteOfHour = teamWorkEndTime.getMinute();
if (minuteOfHour > 0) {
sliceEndHour = LocalTime.of(teamWorkEndTime.getHour(), 0).plusHours(1);
} else {
sliceEndHour = LocalTime.of(teamWorkEndTime.getHour(), 0);
}
//正常时间切片
List<TimeSliceEntity> twoHourTimeSlices = sliceTime(LocalDate.now(), sliceStartHour, sliceEndHour);
CopyOnWriteArrayList<TimeSliceEntity> timeSliceEntities = new CopyOnWriteArrayList<>(twoHourTimeSlices);
//特殊时间段
TimeSliceEntity timeSlice20 = new TimeSliceEntity();
timeSlice20.setStart(DateTimeUtil.TIME_FORMAT.format(sliceEndHour));
timeSlice20.setEnd(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(20, 0)));
timeSlice20.setName("时间段");
timeSliceEntities.add(timeSlice20);
TimeSliceEntity timeSlice24 = new TimeSliceEntity();
timeSlice24.setStart(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(20, 0)));
timeSlice24.setEnd(DateTimeUtil.TIME_FORMAT.format(LocalTime.of(23, 59, 59)));
timeSlice24.setName("时间段");
timeSliceEntities.add(timeSlice24);
TimeSliceEntity timeSlice8 = new TimeSliceEntity();
timeSlice8.setStart(DateTimeUtil.TIME_FORMAT.format(LocalTime.MIN));
timeSlice8.setEnd(DateTimeUtil.TIME_FORMAT.format(sliceStartHour));
timeSlice8.setName("时间段");
timeSliceEntities.add(timeSlice8);
return timeSliceEntities;
}
@Override @Override
public CapacityQueryDTO.Segment queryCapacityByTeam(String teamId, CapacityQueryDTO.Service service, public CapacityQueryDTO.Segment queryCapacityByTeam(String teamId, CapacityQueryDTO.Service service,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!