Merge branch 'wcd-2411-update' into wcd
| | |
| | | @Query(value = "SELECT * from attendance_business_travel where user_id = ?1 and travel_start_time <= ?3 and travel_end_time >= ?2 and approval_status in ('business_approve_status_agree')", nativeQuery = true)
|
| | | List<AttendanceBusinessTravel> findByUserAndSEDate(Long userId, LocalDateTime startDate, LocalDateTime endDate);
|
| | |
|
| | | // 查询出差天数
|
| | | @Query(value = "SELECT * from attendance_business_travel where user_id = ?1 and travel_start_time >= ?2 and travel_end_time < ?3 and approval_status in ('business_approve_status_agree')", nativeQuery = true)
|
| | | List<AttendanceBusinessTravel> findByUserIdAndYearMonth(Long userId, LocalDateTime startDate, LocalDateTime endDate);
|
| | |
|
| | | // 查询某天出差总时长
|
| | | @Query(value = "SELECT COALESCE(SUM(travel_duration), 0) FROM attendance_business_travel WHERE user_id = ?2 AND approval_status IN ('business_approve_status_reviewed', 'business_approve_status_agree') AND id != ?3 AND travel_start_time LIKE CONCAT(?1, '%')", nativeQuery = true)
|
| | | BigDecimal countTravelDuration(String date, Long userId, Long id);
|
| | |
| | | List<AttendanceGoOut> checkCreateUpdateTime(String startTime, String endTime, Long userId, Set<Long> ids); |
| | | |
| | | // 查询外出记录 |
| | | @Query(value = "SELECT * from attendance_go_out where user_id = ?1 and out_start_time <= ?3 and out_end_time >= ?2 and approval_status in ('go_out_approve_status_agree')", nativeQuery = true) |
| | | @Query(value = "SELECT * FROM attendance_go_out WHERE user_id = ?1 AND out_start_time <= ?3 AND out_end_time >= ?2 AND approval_status IN ('go_out_approve_status_agree')", nativeQuery = true) |
| | | List<AttendanceGoOut> findByUserAndDate(Long userId, LocalDateTime startDate, LocalDateTime endDate); |
| | | } |
| | |
| | | **/
|
| | | public interface AttendanceOvertimeRepository extends JpaRepository<AttendanceOvertime, Long>, JpaSpecificationExecutor<AttendanceOvertime> {
|
| | |
|
| | | @Query(value = "SELECT SUM(overtime_duration) from attendance_overtime where user_id = ?1 and overtime_start_time >= ?2 and overtime_end_time < ?3 and approval_status in ('overtime_pass')", nativeQuery = true)
|
| | | @Query(value = "SELECT SUM(overtime_duration) FROM attendance_overtime WHERE user_id = ?1 AND overtime_start_time <= ?3 AND overtime_end_time >= ?2 AND approval_status IN ('overtime_pass')", nativeQuery = true)
|
| | | Double findByUserIdAndYearMonth(Long userId, LocalDateTime startDate, LocalDateTime endDate);
|
| | |
|
| | | @Query(value = "SELECT * from attendance_overtime where user_id = ?1 and overtime_start_time >= ?2 and overtime_end_time < ?3 and approval_status in ('overtime_pass')", nativeQuery = true)
|
| | | @Query(value = "SELECT * FROM attendance_overtime WHERE user_id = ?1 AND overtime_start_time <= ?3 AND overtime_end_time >= ?2 AND approval_status IN ('overtime_pass')", nativeQuery = true)
|
| | | List<AttendanceOvertime> findByUserIdAndDate(Long userId, LocalDateTime startDate, LocalDateTime endDate);
|
| | |
|
| | | List<AttendanceOvertime> findByUserId(Long userId);
|
| | |
| | | breakParts.add(new Calculate(rosteringLunchStartTime, rosteringLunchEndTime));
|
| | |
|
| | | // 出差信息
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(userId, startOfDate.withHour(4).withMinute(0).withSecond(0), endOfDate.plusDays(1).withHour(3).withMinute(59).withSecond(59));
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(userId, startOfDate, endOfDate);
|
| | | attendanceParts.addAll(
|
| | | attendanceBusinessTravelList.stream().map(attendanceBusinessTravel ->
|
| | | new Calculate(attendanceBusinessTravel.getTravelStartTime().toLocalDateTime(), attendanceBusinessTravel.getTravelEndTime().toLocalDateTime())
|
| | |
| | | );
|
| | |
|
| | | // 外出信息
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, startOfDate, endOfDate);
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
|
| | | attendanceParts.addAll(
|
| | | attendanceGoOutList.stream().map(attendanceGoOut ->
|
| | | new Calculate(attendanceGoOut.getOutStartTime().toLocalDateTime(), attendanceGoOut.getOutEndTime().toLocalDateTime())
|
| | | ).collect(Collectors.toList())
|
| | | );
|
| | | // 周末加班
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, startOfDate, endOfDate);
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
|
| | | attendanceParts.addAll(
|
| | | attendanceOvertimeList.stream().map(attendanceOvertime ->
|
| | | new Calculate(attendanceOvertime.getOvertimeStartTime().toLocalDateTime(), attendanceOvertime.getOvertimeEndTime().toLocalDateTime())
|
| | |
| | | return 0.0D;
|
| | | }
|
| | | // 加班信息
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), startDate.atStartOfDay(), endDate.atStartOfDay());
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startDate), DateUtil.parseAttEndTime(endDate));
|
| | |
|
| | | return sysConfigHolidayMonthList.stream()
|
| | | .filter(sysConfigHoliday -> Constant.DATE_TYPE_LEGAL_HOLIDAYS.equals(sysConfigHoliday.getDateType()))
|
| | |
| | | List<SysConfigHoliday> sysConfigHolidayMonthList = sysConfigHolidayRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,sysConfigHolidayQueryCriteria,criteriaBuilder));
|
| | |
|
| | | // 加班信息
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), startDate.atStartOfDay(), endDate.atStartOfDay());
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startDate), DateUtil.parseAttEndTime(endDate));
|
| | | Map<LocalDate, String> sysConfigHolidayMap = sysConfigHolidayMonthList.stream().collect(Collectors.toMap(sch -> sch.getHolidayDate().toLocalDateTime().toLocalDate(), SysConfigHoliday::getDateType));
|
| | |
|
| | | return attendanceOvertimeList.stream().mapToDouble(ao -> {
|
| | |
| | | List<Calculate> breakParts = new ArrayList<>();
|
| | | breakParts.add(new Calculate(rosteringWorkStartTime, rosteringWorkEndTime.plusMinutes(30)));
|
| | | // 查询调休(因工作日加班过0点加班时间可转调休的规定,部分调休与加班时间重复,需要扣除这部分时间,具体可咨询Lief)
|
| | | AttendanceOvertimeQueryCriteria aoCriteria = new AttendanceOvertimeQueryCriteria();
|
| | | aoCriteria.setUserId(criteria.getUserId());
|
| | | aoCriteria.setOvertimeStartTime(Arrays.asList(Timestamp.valueOf(startOfDate), Timestamp.valueOf(endOfDate)));
|
| | | aoCriteria.setApprovalStatus(Constant.OVERTIME_PASS);
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, aoCriteria, criteriaBuilder));
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
|
| | | breakParts.addAll(attendanceOvertimeList.stream().map(ao -> new Calculate(ao.getOvertimeStartTime().toLocalDateTime(), ao.getOvertimeEndTime().toLocalDateTime())).collect(Collectors.toList()));
|
| | |
|
| | | // 外出信息
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
|
| | | attendanceParts.addAll(
|
| | | attendanceGoOutList.stream().map(attendanceGoOut -> {
|
| | | LocalDateTime attendanceGoOutStart = attendanceGoOut.getOutStartTime().toLocalDateTime();
|
| | |
| | | );
|
| | |
|
| | | // 外出信息
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate));
|
| | | attendanceParts.addAll(
|
| | | attendanceGoOutList.stream().map(attendanceGoOut -> {
|
| | | LocalDateTime attendanceGoOutStart = attendanceGoOut.getOutStartTime().toLocalDateTime();
|
| | |
| | | ); |
| | | |
| | | // 外出信息 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, startOfDate, endOfDate); |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate)); |
| | | attendanceParts.addAll( |
| | | attendanceGoOutList.stream().map(attendanceGoOut -> |
| | | new Calculate(attendanceGoOut.getOutStartTime().toLocalDateTime(), attendanceGoOut.getOutEndTime().toLocalDateTime()) |
| | | ).collect(Collectors.toList()) |
| | | ); |
| | | // 周末加班 |
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, startOfDate, endOfDate); |
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate)); |
| | | attendanceParts.addAll( |
| | | attendanceOvertimeList.stream().map(attendanceOvertime -> |
| | | new Calculate(attendanceOvertime.getOvertimeStartTime().toLocalDateTime(), attendanceOvertime.getOvertimeEndTime().toLocalDateTime()) |
| | |
| | | return 0.0D; |
| | | } |
| | | // 加班信息 |
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), startDate.atStartOfDay(), endDate.atStartOfDay()); |
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startDate), DateUtil.parseAttEndTime(endDate)); |
| | | |
| | | return sysConfigHolidayMonthList.stream() |
| | | .filter(sysConfigHoliday -> Constant.DATE_TYPE_LEGAL_HOLIDAYS.equals(sysConfigHoliday.getDateType())) |
| | |
| | | breakParts.add(new Calculate(rosteringWorkStartTime, rosteringWorkEndTime.plusMinutes(30))); |
| | | |
| | | // 外出信息 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate); |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate)); |
| | | attendanceParts.addAll( |
| | | attendanceGoOutList.stream().map(attendanceGoOut -> { |
| | | LocalDateTime attendanceGoOutStart = attendanceGoOut.getOutStartTime().toLocalDateTime(); |
| | |
| | | ); |
| | | |
| | | // 外出信息 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate); |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), DateUtil.parseAttStartTime(startOfDate), DateUtil.parseAttEndTime(endOfDate)); |
| | | attendanceParts.addAll( |
| | | attendanceGoOutList.stream().map(attendanceGoOut -> { |
| | | LocalDateTime attendanceGoOutStart = attendanceGoOut.getOutStartTime().toLocalDateTime(); |
| | |
| | | import me.zhengjie.modules.system.domain.User;
|
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
|
| | | import me.zhengjie.modules.system.repository.UserRepository;
|
| | | import me.zhengjie.utils.DateUtil;
|
| | | import org.apache.commons.lang3.ObjectUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | |
| | | List<AttendanceMonth> insertData = new ArrayList<>();
|
| | | for (AttendanceMonth value : info.values()) {
|
| | | // 查询当月外出
|
| | | List<AttendanceGoOut> goOutList = attendanceGoOutRepository.findByUserAndDate(value.getUserId(), startTime, endTime);
|
| | | List<AttendanceGoOut> goOutList = attendanceGoOutRepository.findByUserAndDate(value.getUserId(), DateUtil.parseAttStartTime(startTime), DateUtil.parseAttEndTime(endTime));
|
| | | int goOutNumber = goOutList.size();
|
| | | // 外出次数
|
| | | value.setGoOutNumber(Long.valueOf(goOutNumber));
|
| | |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
|
| | | import me.zhengjie.modules.system.repository.SysRosteringRepository;
|
| | | import me.zhengjie.modules.system.repository.UserRepository;
|
| | | import me.zhengjie.utils.DateUtil;
|
| | | import me.zhengjie.utils.StringUtils;
|
| | | import org.apache.commons.lang3.ObjectUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | }
|
| | | }
|
| | | // 查询外出表o
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime());
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), DateUtil.parseAttStartTime(attendance.getRosteringWorkStartTime().toLocalDateTime()), DateUtil.parseAttEndTime(attendance.getRosteringWorkEndTime().toLocalDateTime()));
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午/下午
|
| | | if (attendanceGoOut.getOutStartTime().toLocalDateTime().isBefore(attendance.getRosteringLunchStartTime().toLocalDateTime()) && attendanceGoOut.getOutEndTime().toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0) {
|
| | |
| | | // 查询考勤请假表
|
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(user.getId(), startDate.toLocalDateTime(), endDate.toLocalDateTime());
|
| | | // 查询考勤出差表
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(999));
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(0));
|
| | | // 查询考勤外出表
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), attendance.getRosteringWorkStartTime().toLocalDateTime(), attendance.getRosteringWorkEndTime().toLocalDateTime());
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), DateUtil.parseAttStartTime(attendance.getRosteringWorkStartTime().toLocalDateTime()), DateUtil.parseAttEndTime(attendance.getRosteringWorkEndTime().toLocalDateTime()));
|
| | |
|
| | | // TODO:统计规则请假优先于出差优先于外出
|
| | | if (attendanceGoOutList.size() > 0) {
|
| | |
| | | import me.zhengjie.modules.treatment.domain.UserLevelWage; |
| | | import me.zhengjie.modules.treatment.repository.UserInsuranceRepository; |
| | | import me.zhengjie.modules.treatment.repository.UserLevelWageRepository; |
| | | import me.zhengjie.utils.DateUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | import me.zhengjie.utils.StringUtils; |
| | | import me.zhengjie.modules.weixin.cp.api.WxCpOaWeDocSmartsheetService; |
| | |
| | | } |
| | | } |
| | | // 查询外出表 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), attendance.getRosteringWorkStartTime().toLocalDateTime(), attendance.getRosteringWorkEndTime().toLocalDateTime()); |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), DateUtil.parseAttStartTime(attendance.getRosteringWorkStartTime().toLocalDateTime()), DateUtil.parseAttEndTime(attendance.getRosteringWorkEndTime().toLocalDateTime())); |
| | | for (AttendanceGoOut attendanceGoOut : attendanceGoOutList) { |
| | | // 上午/下午 |
| | | if (attendanceGoOut.getOutStartTime().toLocalDateTime().isBefore(attendance.getRosteringLunchStartTime().toLocalDateTime()) && attendanceGoOut.getOutEndTime().toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0) { |
| | |
| | | // 查询考勤请假表 |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(user.getId(), startDate.toLocalDateTime(), endDate.toLocalDateTime()); |
| | | // 查询考勤出差表 |
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(999)); |
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(0)); |
| | | // 查询考勤外出表 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), attendance.getAttendanceDate().toLocalDateTime().withHour(0).withMinute(0).withSecond(0).withNano(0), attendance.getAttendanceDate().toLocalDateTime().withHour(23).withMinute(59).withSecond(59).withNano(999)); |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(), DateUtil.parseAttStartTime(attendance.getAttendanceDate().toLocalDateTime()), DateUtil.parseAttEndTime(attendance.getAttendanceDate().toLocalDateTime())); |
| | | |
| | | Double outStartDuration = new Double(0.00); // 上午时长 |
| | | Double outEndDuration = new Double(0.00); // 下午时长 |
| | |
| | | AttendanceQueryCriteria attendanceQueryCriteria = new AttendanceQueryCriteria();
|
| | | attendanceQueryCriteria.setUserId(userId);
|
| | | attendanceQueryCriteria.setTargetYearMonth(targetYearMonth);
|
| | | // 查询某月平日加班小时数
|
| | | // 查询某月平日加班小时数(已去除调休转换的时间)
|
| | | Double attendanceHours = attendanceService.queryAttendanceOverTimeHours(attendanceQueryCriteria);
|
| | | // 查询某月需结算的(结算三个月前的,如4月时结算1月份的)节假日调休小时数
|
| | | Double attendanceHolidayHours = attendanceService.queryAttendanceHolidaysOverTimeHours(attendanceQueryCriteria);
|
| | |
| | | criteria.setUserId(userId);
|
| | | criteria.setTargetYearMonth(targetYearMonth);
|
| | | UserLevelWageDto userLevelWageDto = userLevelWageService.queryTargetYearMonth(criteria);
|
| | |
|
| | | // 换休转补助
|
| | | LocalDateTime startLocalDateTime = LocalDateTime.parse(targetYearMonth + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
| | | LocalDateTime startLocalDateTime3MonthsPrevious = startLocalDateTime.minusMonths(3).withDayOfMonth(1);
|
| | | LocalDateTime endLocalDateTime3MonthsPrevious = startLocalDateTime3MonthsPrevious.plusMonths(1).withDayOfMonth(1);
|
| | | LocalDateTime endLocalDateTime = startLocalDateTime.plusMonths(1).withDayOfMonth(1);
|
| | |
|
| | | Double approvedTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, startLocalDateTime3MonthsPrevious, endLocalDateTime3MonthsPrevious);
|
| | | Double leaveTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(
|
| | | userId, startLocalDateTime3MonthsPrevious, endLocalDateTime, Constant.LEAVE_TYPE_REPLACE).stream()
|
| | | .map(AttendanceLeave::getLeaveDuration).mapToDouble(Double::doubleValue).sum();
|
| | | if (approvedTime != null && approvedTime.compareTo(leaveTime) > 0) {
|
| | | attendanceHours = attendanceHours + approvedTime - leaveTime;
|
| | | System.out.println("换休转补助:" + (approvedTime - leaveTime));
|
| | | }
|
| | |
|
| | | // 平日加班费
|
| | | if (userLevelWageDto.getOverTimeWage() != null) {
|
| | |
| | | // 外出时长
|
| | | Double goOutTimes = 0.0;
|
| | | // 查询外出表
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, Timestamp.valueOf(startTime).toLocalDateTime(), Timestamp.valueOf(endTime).toLocalDateTime());
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(userId, DateUtil.parseAttStartTime(Timestamp.valueOf(startTime).toLocalDateTime()), DateUtil.parseAttEndTime(Timestamp.valueOf(endTime).toLocalDateTime()));
|
| | | for (AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | goOutTimes = goOutTimes + attendanceGoOut.getOutDuration();
|
| | | }
|
| | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
| | | LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter);
|
| | | // 获取月初日期
|
| | | LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1);
|
| | | LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
| | | // 获取下月初日期
|
| | | LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1);
|
| | | LocalDateTime lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
|
| | |
|
| | | // 查询指定员工的加班补助金额工资
|
| | | Double overTimeSalary = attendanceOvertimeRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth);
|
| | | Double overTimeSalary = attendanceOvertimeRepository.findByUserIdAndYearMonth(criteria.getUserId(), DateUtil.parseAttStartTime(firstDayOfMonth), DateUtil.parseAttEndTime(lastDayOfMonth));
|
| | |
|
| | | // 查询配置表
|
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("加班补助金额");
|
| | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
| | | LocalDateTime dateTime = LocalDateTime.parse(criteria.getTargetYearMonth(), formatter);
|
| | | // 获取月初日期
|
| | | LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1);
|
| | | // 获取下月初日期
|
| | | LocalDateTime firstDayOfNextMonth = firstDayOfMonth.plusMonths(1);
|
| | | LocalDateTime firstDayOfMonth = dateTime.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
| | | // 获取月末最后一天日期
|
| | | LocalDateTime lastDayOfMonth = firstDayOfMonth.plusMonths(1).minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0);
|
| | |
|
| | | // 查询出差表的记录
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserIdAndYearMonth(criteria.getUserId(), firstDayOfMonth, firstDayOfNextMonth);
|
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.findByUserAndSEDate(criteria.getUserId(), firstDayOfMonth, lastDayOfMonth);
|
| | | // TODO:因一天可填多条出差记录,每条最小的时长是0.5天,导致可能会有当天总时长超出1天的情况。(每天出差类型只会有一种,不考虑多种的情况)
|
| | | List<AttendanceBusinessTravel> calcAttendanceBusinessTravelList = attendanceBusinessTravelList.stream().collect(Collectors.groupingBy(
|
| | | (AttendanceBusinessTravel businessTravel) -> businessTravel.getTravelStartTime().toLocalDateTime().toLocalDate().toString(),
|
| | |
| | | // 设置秒数 |
| | | cal.set(Calendar.SECOND, 59); |
| | | // 设置毫秒数 |
| | | cal.set(Calendar.MILLISECOND, 999); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | // 格式化日期 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm"); |
| | | return sdf.format(cal.getTime()); |
| | |
| | | // 设置秒数 |
| | | cal.set(Calendar.SECOND, 59); |
| | | // 设置毫秒数 |
| | | cal.set(Calendar.MILLISECOND, 999); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | // 日历类 |
| | | return cal; |
| | | } |
| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); |
| | | return sdf.format(dayCal.getTime()); |
| | | } |
| | | |
| | | private static final Integer ATT_START_HOUR = 4; |
| | | private static final Integer ATT_START_MINUTE = 0; |
| | | private static final Integer ATT_START_SECOND = 0; |
| | | private static final Integer ATT_START_NANO = 0; |
| | | private static final Integer ATT_END_HOUR = 3; |
| | | private static final Integer ATT_END_MINUTE = 59; |
| | | private static final Integer ATT_END_SECOND = 59; |
| | | private static final Integer ATT_END_NANO = 0; |
| | | private static final Long ATT_END_PLUS_DAY = 1L; |
| | | |
| | | /** |
| | | * 转为考勤开始时间 |
| | | * |
| | | * @param localDateTime / 考勤当天 |
| | | * @return / |
| | | */ |
| | | public static LocalDateTime parseAttStartTime(LocalDateTime localDateTime) { |
| | | return localDateTime.withHour(ATT_START_HOUR).withMinute(ATT_START_MINUTE).withSecond(ATT_START_SECOND).withNano(ATT_START_NANO); |
| | | } |
| | | |
| | | /** |
| | | * 转为考勤结束时间 |
| | | * |
| | | * @param localDateTime / 考勤当天 |
| | | * @return / |
| | | */ |
| | | public static LocalDateTime parseAttEndTime(LocalDateTime localDateTime) { |
| | | // 因数据库Nano太大的话会识别为整点,如03:59:59:999识别为04:00:00,所以Nano需要设置为0 |
| | | return localDateTime.plusDays(ATT_END_PLUS_DAY).withHour(ATT_END_HOUR).withMinute(ATT_END_MINUTE).withSecond(ATT_END_SECOND).withNano(ATT_END_NANO); |
| | | } |
| | | |
| | | /** |
| | | * 转为考勤开始时间 |
| | | * |
| | | * @param localDate / 考勤当天 |
| | | * @return / |
| | | */ |
| | | public static LocalDateTime parseAttStartTime(LocalDate localDate) { |
| | | return localDate.atTime(ATT_START_HOUR, ATT_START_MINUTE, ATT_START_SECOND).withNano(ATT_START_NANO); |
| | | } |
| | | |
| | | /** |
| | | * 转为考勤结束时间 |
| | | * |
| | | * @param localDate / 考勤当天 |
| | | * @return / |
| | | */ |
| | | public static LocalDateTime parseAttEndTime(LocalDate localDate) { |
| | | // 因数据库Nano太大的话会识别为整点,如03:59:59:999识别为04:00:00,所以Nano需要设置为0 |
| | | return localDate.atTime(ATT_END_HOUR, ATT_END_MINUTE, ATT_END_SECOND).plusDays(ATT_END_PLUS_DAY).withNano(ATT_END_NANO); |
| | | } |
| | | } |