| | |
| | | @ApiModelProperty(value = "出差类别")
|
| | | private String category;
|
| | |
|
| | | @Column(name = "`project_id`")
|
| | | @ApiModelProperty(value = "项目ID")
|
| | | private Long projectId;
|
| | |
|
| | | @Column(name = "`approval_status`",nullable = false)
|
| | | @NotBlank
|
| | | @ApiModelProperty(value = "审批状态")
|
| | |
| | | return new ResponseEntity<>(attendanceLeaveService.calcTimeLength(resources), HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping(value = "/getYearTimeLength") |
| | | @PostMapping(value = "/getYearTimeLength/{userId}")
|
| | | @Log("获取年假时长") |
| | | @ApiOperation("获取年假时长") |
| | | public ResponseEntity<Object> getYearTimeLength(@RequestBody Long userId) throws ParseException { |
| | | return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(userId), HttpStatus.OK); |
| | | public ResponseEntity<Object> getYearTimeLength(@PathVariable Long userId, @RequestBody String year) throws ParseException {
|
| | | return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(userId, year), HttpStatus.OK);
|
| | | } |
| | | |
| | | @PostMapping(value = "/getOverTimeLength") |
| | | @PostMapping(value = "/getOverTimeLength/{userId}")
|
| | | @Log("获取调休假时长") |
| | | @ApiOperation("获取调休假时长") |
| | | public ResponseEntity<Object> getOverTimeLength(@RequestBody Long userId) throws ParseException { |
| | | return new ResponseEntity<>(attendanceLeaveService.getOverTimeLength(userId), HttpStatus.OK); |
| | | public ResponseEntity<Object> getOverTimeLength(@PathVariable Long userId, @RequestBody String yearMonth) throws ParseException {
|
| | | Double overTimeLength = attendanceLeaveService.getOverTimeLength(userId, yearMonth);
|
| | | Double overTimeCloseLength = attendanceLeaveService.getOverTimeCloseLength(userId, yearMonth);
|
| | | return new ResponseEntity<>(overTimeLength + overTimeCloseLength, HttpStatus.OK);
|
| | | } |
| | | |
| | | @PutMapping(value = "/approve") |
| | |
| | | Double getYearTimeLength(Long userId) throws ParseException;
|
| | |
|
| | | /**
|
| | | *获取剩余年假
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | Double getYearTimeLength(Long userId, String year) throws ParseException;
|
| | |
|
| | | /**
|
| | | *获取剩余调休假
|
| | | * @return
|
| | | * @throws ParseException
|
| | | */
|
| | | Double getOverTimeLength(Long userId) throws ParseException;
|
| | |
|
| | | Double getOverTimeLength(Long userId, String yearMonth) throws ParseException;
|
| | |
|
| | | Double getOverTimeCloseLength(Long userId);
|
| | |
|
| | | Double getOverTimeCloseLength(Long userId, String yearMonth);
|
| | |
|
| | | /**
|
| | | * 审核功能
|
| | | * @param resources /
|
| | |
| | | */
|
| | | void addAttendanceInfo(Attendance attendance) throws Exception;
|
| | |
|
| | | void generateAttendance(Long id, String startDate, String endDate);
|
| | | } |
| | |
| | | /** 出差类别 */
|
| | | private String category;
|
| | |
|
| | | /** 项目ID */
|
| | | private Long projectId;
|
| | |
|
| | | /** 审批状态 */
|
| | | private String approvalStatus;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户年假剩余时长
|
| | | */
|
| | | @Override
|
| | | public Double getYearTimeLength(Long userId, String year) {
|
| | | //获取年假剩余(新)
|
| | | Double surplusYearTime = new Double(0.00);
|
| | | // 根据用户查询
|
| | | List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(userId);
|
| | | if (sysUserLevelOtherList.size() > 0) {
|
| | | for (SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList) {
|
| | | if (!sysUserLevelOther.getYearMonth().isEmpty() && sysUserLevelOther.getYearMonth().substring(0,4).equals(String.valueOf(year))) {
|
| | | //年假总时长
|
| | | Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8);
|
| | |
|
| | | String startTime = year + "-01-01 00:00:00";
|
| | | String endTime = year + "-12-31 23:59:59";
|
| | | Double usedYearTime = attendanceLeaveRepository.getSurplusYearTime(sysUserLevelOther.getUserId(), startTime, endTime);
|
| | |
|
| | | surplusYearTime = yearTime - (usedYearTime == null ? 0.0 : usedYearTime);
|
| | | }
|
| | | }
|
| | | }
|
| | | return surplusYearTime;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户调休假剩余时长
|
| | | */
|
| | | @Override
|
| | | public Double getOverTimeLength(Long userId) {
|
| | | //获取调休假剩余时长
|
| | | Double surplusYearTime = new Double(0.00);
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.now().withDayOfMonth(1).minusMonths(3);
|
| | | Double overTimeLast = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (overTimeLast == null) {
|
| | | overTimeLast = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| | |
|
| | | LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(3);
|
| | | LocalDate localDateEnd = LocalDate.now().plusDays(1);
|
| | |
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay());
|
| | | if (!attendanceOvertimeList.isEmpty()) {
|
| | | surplusYearTime = attendanceOvertimeList.stream()
|
| | | .filter(attendanceOvertime -> !attendanceOvertime.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))
|
| | | .map(attendanceOvertime -> attendanceOvertime.getOvertimeDuration()).reduce(0.0, (o1, o2) -> o1 + o2);
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateMiddle.atStartOfDay(), localDateEnd.atStartOfDay());
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime > 0) {
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (overTimeLast > usedTime) {
|
| | | return surplusYearTime;
|
| | | }
|
| | | surplusYearTime = surplusYearTime + overTimeLast - usedTime;
|
| | |
|
| | | if (surplusYearTime <= 0.0) {
|
| | | return 0.0;
|
| | | }
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Double getOverTimeLength(Long userId, String yearMonth) {
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.parse(yearMonth + "-01").minusMonths(3);
|
| | | Double overTimeLast = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (overTimeLast == null) {
|
| | | overTimeLast = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.parse(yearMonth + "-01").plusMonths(1).withDayOfMonth(1);
|
| | |
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateMiddle.atStartOfDay(), localDateEnd.atStartOfDay());
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (overTimeLast > usedTime) {
|
| | | return surplusYearTime;
|
| | | }
|
| | | surplusYearTime = surplusYearTime + overTimeLast - usedTime;
|
| | |
|
| | | if (surplusYearTime <= 0.0) {
|
| | | return 0.0;
|
| | | }
|
| | |
| | | */
|
| | | @Override
|
| | | public Double getOverTimeCloseLength(Long userId) {
|
| | | //获取年假剩余(新)
|
| | | Double surplusYearTime = new Double(0.00);
|
| | |
|
| | | LocalDate localDateStart = LocalDate.now().withDayOfMonth(1).minusMonths(4);
|
| | | LocalDate localDateEnd = LocalDate.now().plusDays(1);
|
| | |
|
| | |
|
| | | List<AttendanceOvertime> attendanceOvertimeList = attendanceOvertimeRepository.findByUserIdAndDate(userId, localDateStart.atStartOfDay(), localDateStart.plusMonths(1).withDayOfMonth(1).atStartOfDay());
|
| | | if (!attendanceOvertimeList.isEmpty()) {
|
| | | surplusYearTime = attendanceOvertimeList.stream()
|
| | | .filter(attendanceOvertime -> !attendanceOvertime.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS))
|
| | | .map(attendanceOvertime -> attendanceOvertime.getOvertimeDuration()).reduce(0.0, (o1, o2) -> o1 + o2);
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.now().withDayOfMonth(1).minusMonths(3);
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.now().plusMonths(1).withDayOfMonth(1);
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime > 0) {
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | }
|
| | | if (surplusYearTime <= 0.0) {
|
| | | if (surplusYearTime <= usedTime) {
|
| | | return 0.0;
|
| | | }
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Double getOverTimeCloseLength(Long userId, String yearMonth) {
|
| | | LocalDate localDateStart = LocalDate.of(2024, 1, 1);
|
| | | LocalDate localDateMiddle = LocalDate.parse(yearMonth + "-01").minusMonths(3);
|
| | | Double surplusYearTime = attendanceOvertimeRepository.findByUserIdAndYearMonth(userId, localDateStart.atStartOfDay(), localDateMiddle.atStartOfDay()); // TODO
|
| | | if (surplusYearTime == null) {
|
| | | surplusYearTime = 0.0;
|
| | | }
|
| | | LocalDate localDateEnd = LocalDate.parse(yearMonth + "-01").plusMonths(1).withDayOfMonth(1);
|
| | | Double usedTime = attendanceLeaveRepository.findByUserIdAndDateAndLeaveType(userId, localDateStart.atStartOfDay(), localDateEnd.atStartOfDay(), Constant.LEAVE_TYPE_REPLACE).stream().mapToDouble(AttendanceLeave::getLeaveDuration).sum();
|
| | | if (usedTime == null) {
|
| | | usedTime = 0.0;
|
| | | }
|
| | | if (surplusYearTime <= usedTime) {
|
| | | return 0.0;
|
| | | }
|
| | | surplusYearTime = surplusYearTime - usedTime;
|
| | | return BigDecimal.valueOf(surplusYearTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | }
|
| | |
|
| | |
| | | import me.zhengjie.modules.system.domain.User;
|
| | | import me.zhengjie.modules.system.repository.DictDetailRepository;
|
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
|
| | | import me.zhengjie.modules.system.repository.SysRosteringRepository;
|
| | | import me.zhengjie.modules.system.repository.UserRepository;
|
| | | import me.zhengjie.modules.system.service.dto.SysConfigHolidayQueryCriteria;
|
| | | import me.zhengjie.utils.*;
|
| | | import org.apache.commons.lang3.ObjectUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.data.domain.Page;
|
| | | import org.springframework.data.domain.Pageable;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | dingTalkService.getDingTalkAttendanceList(attendance.getAttendanceDate(), userList);
|
| | | // 选择日期和员工更新员工的考勤信息,未选择员工则更新所有人
|
| | | dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate ,userList);
|
| | | }
|
| | |
|
| | | @Autowired
|
| | | private SysRosteringRepository sysRosteringRepository;
|
| | |
|
| | | @Override
|
| | | public void generateAttendance(Long id, String startDate, String endDate) {
|
| | | Stream.iterate(LocalDate.parse(startDate), date -> date.plusDays(1))
|
| | | .limit(ChronoUnit.DAYS.between(LocalDate.parse(startDate), LocalDate.parse(endDate)) + 1).forEach(date -> {
|
| | | User user = userRepository.findById(id).get();
|
| | | // 用户排班
|
| | | SysRostering sysRostering = sysRosteringRepository.findByRosId(user.getSysRostering().getId());
|
| | | // 考勤记录
|
| | | Attendance attendance = new Attendance();
|
| | |
|
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
| | |
|
| | | // 时间格式化
|
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
| | |
|
| | | // 考勤记录
|
| | | attendance.setUserId(user.getId());
|
| | | attendance.setAttendanceDate(Timestamp.valueOf(date.atStartOfDay()));
|
| | | // 考勤日期类是否是周末、节假日、工作日
|
| | | if (sysConfigHoliday == null && (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY)) {
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | // 考勤记录:日期类型-双休
|
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKEND);
|
| | | } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) {
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | // 考勤记录:日期类型-节假日
|
| | | attendance.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS);
|
| | | } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)) {
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | // 考勤记录:日期类型-法定节假日
|
| | | attendance.setDateType(Constant.DATE_TYPE_HOLIDAYS);
|
| | | } else {
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NORMAL);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NORMAL);
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL);
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL);
|
| | |
|
| | | attendance.setActualWorkStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime())));
|
| | | attendance.setActualWorkEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime())));
|
| | |
|
| | | // 考勤记录:日期类型-工作日
|
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKDAY);
|
| | | }
|
| | |
|
| | | // 考勤记
|
| | | attendance.setRosteringWorkStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime())));
|
| | | attendance.setRosteringWorkEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime())));
|
| | | attendance.setRosteringLunchStartTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getLunchStartTime())));
|
| | | attendance.setRosteringLunchEndTime(Timestamp.valueOf(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " " + dateTimeFormatter.format(sysRostering.getLunchEndTime())));
|
| | |
|
| | | // 保存
|
| | | attendanceRepository.save(attendance);
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | List<Calculate> breakParts = new ArrayList<>();
|
| | | breakParts.add(new Calculate(rosteringLunchStartTime, rosteringLunchEndTime));
|
| | |
|
| | | // 请假信息
|
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | | breakParts.addAll(
|
| | | attendanceLeaveList.stream().map(attendanceLeave -> {
|
| | | LocalDateTime attendanceLeaveStart = attendanceLeave.getLeaveStartTime().toLocalDateTime();
|
| | | LocalDateTime attendanceLeaveEnd = attendanceLeave.getLeaveEndTime().toLocalDateTime();
|
| | | if (attendanceLeaveStart.isBefore(rosteringWorkStartTime)) {
|
| | | attendanceLeaveStart = rosteringWorkStartTime;
|
| | | }
|
| | | if (attendanceLeaveEnd.isAfter(rosteringWorkEndTime)) {
|
| | | attendanceLeaveEnd = rosteringWorkEndTime;
|
| | | }
|
| | | return new Calculate(attendanceLeaveStart, attendanceLeaveEnd);
|
| | | }
|
| | | ).filter(calculate -> calculate.getStart().isBefore(calculate.getEnd())).collect(Collectors.toList())
|
| | | );
|
| | | // 合并请假时间
|
| | | List<Calculate> finalBreakParts = breakParts.stream().sorted().reduce(new Stack<>(), (result, current) -> {
|
| | | // 删除重复时间,合并相连的时间段
|
| | | if (result.empty()) {
|
| | | result.push(current);
|
| | | return result;
|
| | | }
|
| | | Calculate last = result.peek();
|
| | | if (last.getEnd().isBefore(current.getStart())) {
|
| | | result.push(current);
|
| | | } else if (last.getEnd().isBefore(current.getEnd())) {
|
| | | last.setEnd(current.getEnd());
|
| | | }
|
| | | return result;
|
| | | }, (o1, o2) -> null);
|
| | |
|
| | | // 外出信息
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | | attendanceParts.addAll(
|
| | |
| | | return result;
|
| | | }, (o1, o2) -> null).forEach(calculate -> {
|
| | | // 去除休息时间:午休等
|
| | | for (Calculate breakPart : breakParts) {
|
| | | for (Calculate breakPart : finalBreakParts) {
|
| | | if ((calculate.getStart().isBefore(breakPart.getStart()) && calculate.getEnd().isAfter(breakPart.getStart()))
|
| | | || (calculate.getStart().isBefore(breakPart.getEnd()) && calculate.getEnd().isAfter(breakPart.getEnd()))) {
|
| | | Calculate calculate1 = new Calculate(calculate.getStart(), breakPart.getStart());
|
| | |
| | | (total, current) -> total.add(BigDecimal.valueOf(current)),
|
| | | (o1, o2) -> null).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP
|
| | | );
|
| | |
|
| | | // 请假信息
|
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(criteria.getUserId(), startOfDate, endOfDate);
|
| | | // 年假不扣工时
|
| | | BigDecimal annualLeaveHours = attendanceLeaveList.stream()
|
| | | .filter(attendanceLeave -> Constant.LEAVE_TYPE_ANNUAL_LEAVE.equals(attendanceLeave.getLeaveType())
|
| | |
| | | // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(oapiDingTalkRecordResultList为空的情况下)
|
| | | if (ObjectUtils.isNotEmpty(attendance) && (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS))) {
|
| | | // 开始打卡结果
|
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){
|
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME)){
|
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setActualWorkStartTime(null);
|
| | | }
|
| | | // 结束打卡结果
|
| | | if(attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){
|
| | | if(attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME)){
|
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST);
|
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST);
|
| | | attendance.setActualWorkEndTime(null);
|
| | |
| | | }
|
| | | // 修改考勤打卡状态
|
| | | if (ObjectUtils.isNotEmpty(attendance)) {
|
| | | attendance = updateRecord(user, attendance, true, attendDate);
|
| | | getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(),attendance.getRosteringWorkEndTime(), true);
|
| | | // attendance = updateRecord(user, attendance, true, attendDate);
|
| | | attendanceRepository.save(attendance);
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | // 修改考勤打卡状态
|
| | | if (ObjectUtils.isNotEmpty(attendance)) {
|
| | | attendance = updateRecord(user, attendance, false, attendDate);
|
| | | getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(),attendance.getRosteringWorkEndTime(), false);
|
| | | // attendance = updateRecord(user, attendance, false, attendDate);
|
| | | attendanceRepository.save(attendance);
|
| | | }
|
| | | }
|
| | |
| | | Double outDuration = new Double(0.00);
|
| | | Double outStartDuration = new Double(0.00);// 考勤按钮的时长
|
| | | Double outEndDuration = new Double(0.00);// 考勤按钮的时长
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | | if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午时长、下午时长
|
| | | outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | }
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration);
|
| | | }else{
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午or下午总时长
|
| | | outDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | }
|
| | | updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null);
|
| | | }
|
| | | }
|
| | | // for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
|
| | | // // attendDate不等于null 说明是考勤信息按钮
|
| | | // if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | // // 上午时长、下午时长
|
| | | // outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | // outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | // //调用方法修改考勤打卡状态
|
| | | // updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration);
|
| | | // }else{
|
| | | // // 上午or下午总时长
|
| | | // outDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | // updateAttendanceRecord(outDuration,attendance,Constant.ATTENDANCE_STATE_GOOUT, day,null,null);
|
| | | // }
|
| | | // }
|
| | | }else{
|
| | | if(ObjectUtils.isNotEmpty(attendanceBusinessTravel)){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | |
| | | }else{
|
| | | // 查询考勤外出表
|
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime());
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | | if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午时长、下午时长
|
| | | leaveStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | leaveEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | }else{
|
| | | // 上午or下午总时长
|
| | | leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | }
|
| | | }
|
| | | for(AttendanceLeave attendanceLeave : attendanceLeaveList){
|
| | | // attendDate不等于null 说明是考勤信息按钮
|
| | | if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | // 上午总时长、下午总时长
|
| | | leaveStartDuration += getStartDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
|
| | | leaveEndDuration += getEndDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
|
| | | }
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration);
|
| | | }else{
|
| | | for(AttendanceGoOut attendanceGoOut : attendanceGoOutList) {
|
| | | // 上午or下午总时长
|
| | | leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | }
|
| | | for(AttendanceLeave attendanceLeave : attendanceLeaveList){
|
| | | // 上午or下午总时长
|
| | | leaveDuration += getDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance,day);
|
| | | }
|
| | | //调用方法修改考勤打卡状态
|
| | | updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null);
|
| | | }
|
| | | }
|
| | | // for(AttendanceGoOut attendanceGoOut : attendanceGoOutList){
|
| | | // // attendDate不等于null 说明是考勤信息按钮
|
| | | // if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | // // 上午时长、下午时长
|
| | | // leaveStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | // leaveEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance);
|
| | | // }else{
|
| | | // // 上午or下午总时长
|
| | | // leaveDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day);
|
| | | // }
|
| | | // }
|
| | | // for(AttendanceLeave attendanceLeave : attendanceLeaveList){
|
| | | // // attendDate不等于null 说明是考勤信息按钮
|
| | | // if(ObjectUtils.isNotEmpty(attendDate)){
|
| | | // // 上午总时长、下午总时长
|
| | | // leaveStartDuration += getStartDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
|
| | | // leaveEndDuration += getEndDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance);
|
| | | // //调用方法修改考勤打卡状态
|
| | | // updateAttendanceRecord(null,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration);
|
| | | // }else{
|
| | | // // 上午or下午总时长
|
| | | // leaveDuration += getDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance,day);
|
| | | // //调用方法修改考勤打卡状态
|
| | | // updateAttendanceRecord(leaveDuration,attendance,Constant.ATTENDANCE_STATE_LEAVE,day,null,null);
|
| | | // }
|
| | | // }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | // } |
| | | // } |
| | | // 保存 |
| | | resources.setStartDate(new Timestamp(new SimpleDateFormat("yyyy-MM-dd").parse(resources.getYearMonth() + "-01").getTime()));
|
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.save(resources)); |
| | | } |
| | | |
| | |
| | | }
|
| | | returnData.put("onDutyDays", numDay);
|
| | | // 剩余年假
|
| | | Double yearTimes = attendanceLeaveService.getYearTimeLength(userId);
|
| | | Double yearTimes = attendanceLeaveService.getYearTimeLength(userId, sdfDate.substring(0, 4));
|
| | | returnData.put("annualLeave", yearTimes);
|
| | | // 查询当月的补卡记录的条数
|
| | | Integer count = attendanceCardreplacementRepository.count(userId, sdfDate.substring(0, 7));
|
| | |
| | | Map<String, Double> attendanceBusinessTravelMap = attendanceBusinessTravelList.stream().collect(Collectors.groupingBy(AttendanceBusinessTravel::getCategory, Collectors.summingDouble(AttendanceBusinessTravel::getTravelDuration)));
|
| | |
|
| | | BigDecimal travelSubsidy = new BigDecimal(0.0);
|
| | | // 出差补助金
|
| | | attendanceBusinessTravelMap.forEach((key, value) -> {
|
| | | if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
|
| | | for (Map.Entry<String, Double> entry : attendanceBusinessTravelMap.entrySet()) {
|
| | | if (entry.getKey().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
|
| | | // 出差补助金
|
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额");
|
| | | travelSubsidy.add(BigDecimal.valueOf(value * sysConfigProportion.getProportion()));
|
| | | } else if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
|
| | | travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(entry.getValue() * sysConfigProportion.getProportion()));
|
| | | } else if (entry.getKey().equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
|
| | | // 客户现场补助金
|
| | | // SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("客户现场补助金额");
|
| | | travelSubsidy.add(BigDecimal.valueOf(value * 30)); // 按30元/天计算 TODO 待调整
|
| | | travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(entry.getValue() * 30)); // 按30元/天计算 TODO 待调整
|
| | | }
|
| | | });
|
| | | }
|
| | | // // 出差补助金
|
| | | // attendanceBusinessTravelMap.forEach((key, value) -> {
|
| | | // if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_TRAVEL)) {
|
| | | // // 出差补助金
|
| | | // SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("出差补助金额");
|
| | | // travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(value * sysConfigProportion.getProportion()));
|
| | | // } else if (key.equals(Constant.ATTENDANCE_BUSINESS_TRAVEL_CATEGORY_SAME_PLACE)) {
|
| | | // // 客户现场补助金
|
| | | //// SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("客户现场补助金额");
|
| | | // travelSubsidy = travelSubsidy.add(BigDecimal.valueOf(value * 30)); // 按30元/天计算 TODO 待调整
|
| | | // }
|
| | | // });
|
| | | return travelSubsidy.doubleValue();
|
| | | }
|
| | |
|