| | |
| | | public void getWeComAttendanceListOfNoon(String attendDate, List attUser) throws Exception { |
| | | try { |
| | | // 获取企业微信Token |
| | | String weComAccessToken = wxCpService.getAccessToken(); |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 日期格式化 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | |
| | | for (User user : userList) { |
| | | // 考勤记录:根据用户和日期查询 |
| | | NewAttendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), strAttendDate); |
| | | Boolean isHoliday = false; |
| | | if (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)) { |
| | | isHoliday = true; |
| | | } |
| | | // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(返回结果为空数组的情况下) |
| | | 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))) { |
| | | // 开始打卡结果 |
| | |
| | | // 企业微信ID |
| | | List<String> userWeComList = new ArrayList<>(); |
| | | userWeComList.add(user.getWeComId()); |
| | | System.out.println("开始查询用户" + user.getWeComId() + "的" + strAttendDate + "考勤记录"); |
| | | // 企微打卡数据 |
| | | List<WxCpCheckinData> weComRecordResultList = wxCpService.getOaService().getCheckinData(1, sdf.parse(strAttendDate + " 00:00:00"), sdf.parse(strAttendDate + " 23:59:59"), userWeComList); |
| | | // 遍历企微打卡数据 |
| | |
| | | // 调用验证状态方法 |
| | | Boolean flag = getCardSupplement(attendance.getUserId(), attendance.getStartClockResults(), attendance.getActualWorkStartTime()); |
| | | // 考勤记录 |
| | | if (!isHoliday) { |
| | | attendance.setStartClockResults(flag == true ? attendance.getStartClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), new Timestamp(weComRecordResult.getCheckinTime() * 1000), 1))); |
| | | } else { |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL); |
| | | } |
| | | attendance.setStartLocationResults(flag == true ? attendance.getStartLocationResults() : setLocationResults(weComRecordResult.getExceptionType())); |
| | | attendance.setActualWorkStartTime(flag == true ? attendance.getActualWorkStartTime() : new Timestamp(weComRecordResult.getCheckinTime() * 1000)); |
| | | } |
| | |
| | | // 调用验证状态方法 |
| | | Boolean flag = getCardSupplement(attendance.getUserId(), attendance.getEndClockResults(), attendance.getActualWorkEndTime()); |
| | | // 考勤记录 |
| | | if (!isHoliday) { |
| | | attendance.setEndClockResults(flag == true ? attendance.getEndClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), new Timestamp(weComRecordResult.getCheckinTime() * 1000), 2))); |
| | | } else { |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL); |
| | | } |
| | | attendance.setEndLocationResults(flag == true ? attendance.getEndLocationResults() : setLocationResults(weComRecordResult.getExceptionType())); |
| | | attendance.setActualWorkEndTime(flag == true ? attendance.getActualWorkEndTime() : new Timestamp(weComRecordResult.getCheckinTime() * 1000)); |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void getWeComAttendanceListOfNight(String attendDate, List attUser) throws Exception { |
| | | // 获取企业微信Token |
| | | String weComAccessToken = wxCpService.getAccessToken(); |
| | | wxCpService.getAccessToken(); |
| | | |
| | | try { |
| | | // 获取参数日期类 |
| | |
| | | for (User user : userList) { |
| | | // 考勤记录:根据用户和日期查询 |
| | | NewAttendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), strAttendDate); |
| | | Boolean isHoliday = false; |
| | | if (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)) { |
| | | isHoliday = true; |
| | | } |
| | | // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(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))) { |
| | | // 开始打卡结果 |
| | |
| | | // 企业微信ID |
| | | List<String> userWeComList = new ArrayList<>(); |
| | | userWeComList.add(user.getWeComId()); |
| | | System.out.println("开始查询用户" + user.getWeComId() + "的" + strAttendDate + "考勤记录"); |
| | | // 企微打卡数据 |
| | | List<WxCpCheckinData> weComRecordResultList = wxCpService.getOaService().getCheckinData(1, sdf.parse(strAttendDate + " 00:00:00"), sdf.parse(strAttendDate + " 23:59:59"), userWeComList); |
| | | // 遍历企微打卡数据 |
| | |
| | | // 调用验证状态方法 |
| | | Boolean flag = getCardSupplement(attendance.getUserId(), attendance.getStartClockResults(), attendance.getActualWorkStartTime()); |
| | | // 考勤记录 |
| | | if (!isHoliday) { |
| | | attendance.setStartClockResults(flag == true ? attendance.getStartClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), new Timestamp(weComRecordResult.getCheckinTime() * 1000), 1))); |
| | | } else { |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL); |
| | | } |
| | | attendance.setStartLocationResults(flag == true ? attendance.getStartLocationResults() : setLocationResults(weComRecordResult.getExceptionType())); |
| | | attendance.setActualWorkStartTime(flag == true ? attendance.getActualWorkStartTime() : new Timestamp(weComRecordResult.getCheckinTime() * 1000)); |
| | | } |
| | |
| | | // 调用验证状态方法 |
| | | Boolean flag = getCardSupplement(attendance.getUserId(), attendance.getEndClockResults(), attendance.getActualWorkEndTime()); |
| | | // 考勤记录 |
| | | if (!isHoliday) { |
| | | attendance.setEndClockResults(flag == true ? attendance.getEndClockResults() : (ObjectUtil.isEmpty(weComRecordResult.getCheckinTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : checkResult(user.getSysRostering(), new Timestamp(weComRecordResult.getCheckinTime() * 1000), 2))); |
| | | } else { |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL); |
| | | } |
| | | attendance.setEndLocationResults(flag == true ? attendance.getEndLocationResults() : setLocationResults(weComRecordResult.getExceptionType())); |
| | | attendance.setActualWorkEndTime(flag == true ? attendance.getActualWorkEndTime() : new Timestamp(weComRecordResult.getCheckinTime() * 1000)); |
| | | } |