| | |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | |
| | | public AttendanceCardreplacementDto create(AttendanceCardreplacement resources) throws Exception { |
| | | |
| | | //查询补卡次数(每个月5次) |
| | | getCardreplacement(resources.getUserId()); |
| | | getCardreplacement(resources.getCardReplacementTime(), resources.getUserId()); |
| | | |
| | | //查询补卡记录是否存在 |
| | | AttendanceCardreplacement attendanceCardreplacement = attendanceCardreplacementRepository.findByUserIdAndCardReplacementTime(resources.getUserId(),resources.getCardReplacementTime()); |
| | |
| | | } |
| | | |
| | | //查询补卡次数(每个月5次) |
| | | getCardreplacement(resources.getUserId()); |
| | | getCardreplacement(resources.getCardReplacementTime(), resources.getUserId()); |
| | | |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | |
| | | /** |
| | | * 查询剩余补卡次数 |
| | | */ |
| | | public void getCardreplacement(Long userId){ |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 获取当前年 |
| | | int year = calendar.get(Calendar.YEAR); |
| | | // 获取当前月 |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | String mouths = ""; |
| | | if(month < 10){ |
| | | mouths = "0" + month; |
| | | } |
| | | String baseDate = year + "-" + mouths; |
| | | public void getCardreplacement(Timestamp cardReplacementTime, Long userId){ |
| | | // 日期时间格式化 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 补卡时间字符串 |
| | | String cardReplacementTimeStr = sdf.format(cardReplacementTime); |
| | | // 查询当月的补卡记录的条数 |
| | | Integer count = attendanceCardreplacementRepository.count(userId, baseDate); |
| | | Integer count = attendanceCardreplacementRepository.count(userId, cardReplacementTimeStr.substring(0,7)); |
| | | // 查询配置表的每月补卡次数 |
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("每月可补卡次数"); |
| | | if(count >= sysConfigProportion.getProportion()){ |
| | |
| | | if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE)) { |
| | | // set考勤打卡时间和打卡状态 |
| | | attendance.setActualWorkEndTime(resources.getCardReplacementTime()); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED); |
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL); |
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NORMAL); |
| | | }else if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){ |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED); |
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED); |