| | |
| | | |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | import java.time.temporal.ChronoUnit; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | |
| | | // 判断角色等级 |
| | | if (min == Constant.ROLE_LEVEL_MANAGER || min == Constant.ROLE_LEVEL_LEADER || min == Constant.ROLE_LEVEL_ORDINARY) { |
| | | // 根据用户ID查询参与的项目ID |
| | | List<Long> taskUserProjectIdList = taskDaliyRepository.findProjectIdByUserId(SecurityUtils.getCurrentUserId()); |
| | | List<Long> taskUserProjectIdList = taskUserRepository.findProjectIdByUserId(SecurityUtils.getCurrentUserId()); |
| | | // 根据用户ID查询负责的项目ID |
| | | List<Long> projectIdList = projectRepository.findIdByLiableUserId(SecurityUtils.getCurrentUserId()); |
| | | // 检索条件 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Double calculateHour(TaskUserQueryCriteria criteria) { |
| | | LocalDateTime localEndDateTime = criteria.getTaskEndDate().toLocalDateTime(); |
| | | User user = userRepository.findById(criteria.getUserId()).orElseGet(User::new); |
| | | ValidationUtil.isNull(user.getId(),"User","id", criteria.getUserId()); |
| | | |
| | | Double totalHours = 0.0; |
| | | LocalDateTime toDayDateTime = criteria.getTaskStartDate().toLocalDateTime(); |
| | | while (toDayDateTime.isBefore(localEndDateTime)) { |
| | | if (toDayDateTime.toLocalTime().isBefore(user.getSysRostering().getWorkStartTime())) { |
| | | toDayDateTime = toDayDateTime.with(user.getSysRostering().getWorkStartTime()); |
| | | } |
| | | if (toDayDateTime.toLocalTime().isBefore(user.getSysRostering().getLunchStartTime())) { |
| | | if (toDayDateTime.toLocalDate().isEqual(localEndDateTime.toLocalDate())) { |
| | | if (toDayDateTime.toLocalTime().isBefore(localEndDateTime.toLocalTime())) { |
| | | if (localEndDateTime.toLocalTime().isBefore(user.getSysRostering().getLunchStartTime())) { |
| | | totalHours += toDayDateTime.toLocalTime().until(localEndDateTime.toLocalTime(), ChronoUnit.HOURS); |
| | | } else { |
| | | totalHours += toDayDateTime.toLocalTime().until(user.getSysRostering().getLunchStartTime(), ChronoUnit.HOURS); |
| | | } |
| | | } |
| | | } else { |
| | | totalHours += toDayDateTime.toLocalTime().until(user.getSysRostering().getLunchStartTime(), ChronoUnit.HOURS); |
| | | } |
| | | } |
| | | if (toDayDateTime.toLocalTime().isBefore(user.getSysRostering().getLunchEndTime())) { |
| | | toDayDateTime = toDayDateTime.with(user.getSysRostering().getLunchEndTime()); |
| | | } |
| | | if (toDayDateTime.toLocalTime().isBefore(user.getSysRostering().getWorkEndTime())) { |
| | | if (toDayDateTime.toLocalDate().isEqual(localEndDateTime.toLocalDate())) { |
| | | if (toDayDateTime.toLocalTime().isBefore(localEndDateTime.toLocalTime())) { |
| | | if (localEndDateTime.toLocalTime().isBefore(user.getSysRostering().getWorkEndTime())) { |
| | | totalHours += toDayDateTime.toLocalTime().until(localEndDateTime.toLocalTime(), ChronoUnit.HOURS); |
| | | } else { |
| | | totalHours += toDayDateTime.toLocalTime().until(user.getSysRostering().getWorkEndTime(), ChronoUnit.HOURS); |
| | | } |
| | | } |
| | | } else { |
| | | totalHours += toDayDateTime.toLocalTime().until(user.getSysRostering().getWorkEndTime(), ChronoUnit.HOURS); |
| | | } |
| | | } |
| | | toDayDateTime = toDayDateTime.plusDays(1).with(user.getSysRostering().getWorkStartTime()); |
| | | } |
| | | |
| | | return totalHours; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public TaskUserDto findById(Long id) { |
| | | TaskUser taskUser = taskUserRepository.findById(id).orElseGet(TaskUser::new); |