| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import me.chanjar.weixin.cp.api.WxCpService; |
| | | import me.chanjar.weixin.cp.bean.message.WxCpMessage; |
| | | import me.chanjar.weixin.cp.bean.oa.WxCpCheckinData; |
| | | import me.zhengjie.modules.attendance.domain.*; |
| | | import me.zhengjie.modules.attendance.repository.*; |
| | |
| | | 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.DictDetailService; |
| | | import me.zhengjie.utils.StringUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @RequiredArgsConstructor |
| | | public class WeComServiceImpl { |
| | | private final WxCpService wxCpService; |
| | | private final NewAttendanceRepository attendanceRepository; |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final UserRepository userRepository; |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | private final SysRosteringRepository sysRosteringRepository; |
| | |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | private final DictDetailService dictDetailService; |
| | | |
| | | /** |
| | | * 凌晨0点执行,新增用户考勤信息 |
| | |
| | | if (ObjectUtils.isEmpty(attendDate) || attendDate.compareTo(Timestamp.valueOf(strTodayDate + " 00:00:00")) <= 0) { |
| | | // 用户列表 |
| | | List<User> userList = new ArrayList<>(); |
| | | // 获取企业微信考勤白名单 |
| | | List<String> excludeList = dictDetailService.getDictByName("wecom_exclude_list").stream().map(i -> i.getValue()).collect(Collectors.toList()); |
| | | // 参数用户不为空(考勤按钮调用) |
| | | if (ObjectUtils.isNotEmpty(attUser)) { |
| | | // 用户列表 |
| | | userList = attUser; |
| | | userList = userList.stream().filter(i -> StringUtils.isNotBlank(i.getWeComId())).collect(Collectors.toList()); |
| | | userList = userList.stream().filter(i -> StringUtils.isNotBlank(i.getWeComId()) && !excludeList.contains(i.getWeComId())).collect(Collectors.toList()); |
| | | } else { |
| | | // 用户列表:查询状态正常的员工 |
| | | userList = getUserList().stream().filter(i -> StringUtils.isNotBlank(i.getWeComId())).collect(Collectors.toList()); |
| | | userList = getUserList().stream().filter(i -> StringUtils.isNotBlank(i.getWeComId()) && !excludeList.contains(i.getWeComId())).collect(Collectors.toList()); |
| | | } |
| | | // 参数日期 |
| | | String strAttendDate = ""; |
| | |
| | | // 用户排班 |
| | | SysRostering sysRostering = sysRosteringRepository.findByRosId(user.getSysRostering().getId()); |
| | | // 考勤记录 |
| | | NewAttendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), (ObjectUtils.isEmpty(attendDate) ? strTodayDate : strAttendDate)); |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), (ObjectUtils.isEmpty(attendDate) ? strTodayDate : strAttendDate)); |
| | | // 考勤记录为null |
| | | if (ObjectUtil.isEmpty(attendance)) { |
| | | // 新建考勤记录 |
| | | attendance = new NewAttendance(); |
| | | attendance = new Attendance(); |
| | | } |
| | | // 考勤记录 |
| | | attendance.setUserId(user.getId()); |
| | |
| | | calAttendDate.setTime(Timestamp.valueOf(strAttendDate + " 00:00:00")); |
| | | // 用户列表 |
| | | List<User> userList; |
| | | // 获取企业微信考勤白名单 |
| | | List<String> excludeList = dictDetailService.getDictByName("wecom_exclude_list").stream().map(i -> i.getValue()).collect(Collectors.toList()); |
| | | // 参数用户不为空(考勤按钮调用) |
| | | if (ObjectUtils.isNotEmpty(attUser)) { |
| | | // 用户列表 |
| | | userList = attUser; |
| | | userList = userList.stream().filter(i -> StringUtils.isNotBlank(i.getWeComId())).collect(Collectors.toList()); |
| | | userList = userList.stream().filter(i -> StringUtils.isNotBlank(i.getWeComId()) && !excludeList.contains(i.getWeComId())).collect(Collectors.toList()); |
| | | } else { |
| | | // 用户列表:查询状态正常的员工 |
| | | userList = getUserList().stream().filter(i -> StringUtils.isNotBlank(i.getWeComId())).collect(Collectors.toList()); |
| | | userList = getUserList().stream().filter(i -> StringUtils.isNotBlank(i.getWeComId()) && !excludeList.contains(i.getWeComId())).collect(Collectors.toList()); |
| | | } |
| | | // 遍历用户列表 |
| | | for (User user : userList) { |
| | | // 考勤记录:根据用户和日期查询 |
| | | NewAttendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), strAttendDate); |
| | | Attendance 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))) { |
| | | // 开始打卡结果 |
| | | 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); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void getWeComAttendanceListOfNight(String attendDate, List attUser) throws Exception { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(); |
| | | |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 获取参数日期类 |
| | | Calendar calAttendDate = Calendar.getInstance(); |
| | | // 日期格式化 |
| | |
| | | calAttendDate.setTime(Timestamp.valueOf(strAttendDate + " 00:00:00")); |
| | | // 用户列表 |
| | | List<User> userList; |
| | | // 获取企业微信考勤白名单 |
| | | List<String> excludeList = dictDetailService.getDictByName("wecom_exclude_list").stream().map(i -> i.getValue()).collect(Collectors.toList()); |
| | | // 参数用户不为空(考勤按钮调用) |
| | | if (ObjectUtils.isNotEmpty(attUser)) { |
| | | // 用户列表 |
| | | userList = attUser; |
| | | userList = userList.stream().filter(i -> StringUtils.isNotBlank(i.getWeComId())).collect(Collectors.toList()); |
| | | userList = userList.stream().filter(i -> StringUtils.isNotBlank(i.getWeComId()) && !excludeList.contains(i.getWeComId())).collect(Collectors.toList()); |
| | | } else { |
| | | // 用户列表:查询状态正常的员工 |
| | | userList = getUserList().stream().filter(i -> StringUtils.isNotBlank(i.getWeComId())).collect(Collectors.toList()); |
| | | userList = getUserList().stream().filter(i -> StringUtils.isNotBlank(i.getWeComId()) && !excludeList.contains(i.getWeComId())).collect(Collectors.toList()); |
| | | } |
| | | // 遍历用户列表 |
| | | for (User user : userList) { |
| | | // 考勤记录:根据用户和日期查询 |
| | | NewAttendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), strAttendDate); |
| | | Attendance 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)) { |
| | | attendance = updateRecord(user, attendance, false, attendDate); |
| | | getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(),attendance.getRosteringWorkEndTime(), false); |
| | | // attendance = updateRecord(user, attendance, false, attendDate); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 中午12点30或凌晨02:30执行定时任务 |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | public void getWeComAttendanceListOfNoonOrNight(String attendDate, List attUser) throws Exception { |
| | |
| | | * |
| | | * @param user |
| | | */ |
| | | public NewAttendance updateRecord(User user, NewAttendance attendance, Boolean day, String attendDate) { |
| | | public Attendance updateRecord(User user, Attendance attendance, Boolean day, String attendDate) { |
| | | // 查询考勤请假表 |
| | | List<AttendanceLeave> attendanceLeaveLists = attendanceLeaveRepository.findByUserIdAndDate(user.getId(), attendance.getRosteringWorkStartTime().toLocalDateTime(), attendance.getRosteringWorkEndTime().toLocalDateTime()); |
| | | for (AttendanceLeave attendanceLeave : attendanceLeaveLists) { |
| | |
| | | return attendance; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 请假优先于出差优先于外出 |
| | | * |
| | |
| | | * @param startDate |
| | | * @param endDate |
| | | */ |
| | | public void getMornOrNoon(User user, NewAttendance attendance, String attendDate, Timestamp startDate, Timestamp endDate, Boolean day) { |
| | | public void getMornOrNoon(User user, Attendance attendance, String attendDate, Timestamp startDate, Timestamp endDate, Boolean day) { |
| | | // 查询考勤请假表 |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(user.getId(), startDate.toLocalDateTime(), endDate.toLocalDateTime()); |
| | | Double leaveDuration = new Double(0.00);//计算的总时长 |
| | |
| | | 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)) { |
| | | 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 { |
| | | } |
| | | //调用方法修改考勤打卡状态 |
| | | 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); |
| | | } |
| | | 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)) { |
| | | // 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); |
| | | leaveStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance); |
| | | leaveEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance); |
| | | } |
| | | } |
| | | for (AttendanceLeave attendanceLeave : attendanceLeaveList) { |
| | | // attendDate不等于null 说明是考勤信息按钮 |
| | | if (ObjectUtils.isNotEmpty(attendDate)) { |
| | | for(AttendanceLeave attendanceLeave : attendanceLeaveList){ |
| | | // 上午总时长、下午总时长 |
| | | 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); |
| | | 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); |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | |
| | |
| | | * @param attendance |
| | | * @param type |
| | | */ |
| | | public void updateAttendanceRecord(Double duration, NewAttendance attendance, String type, Boolean day, Double stDuration, Double enDuration) { |
| | | public void updateAttendanceRecord(Double duration, Attendance attendance, String type, Boolean day, Double stDuration, Double enDuration) { |
| | | // 上午排班开始时间到排班午休开始时间的时长 |
| | | Integer workMorningTime = calculateTimes(attendance.getRosteringWorkStartTime().toLocalDateTime(), attendance.getRosteringLunchStartTime().toLocalDateTime()); |
| | | Double result = Double.valueOf(new BigDecimal((float) workMorningTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | |
| | | * @param attendance |
| | | * @param type |
| | | */ |
| | | public void setAttendance(Double sDuration, Double eDuration, Double result, Double noonResult, NewAttendance attendance, String type) { |
| | | public void setAttendance(Double sDuration, Double eDuration, Double result, Double noonResult, Attendance attendance, String type) { |
| | | if (ObjectUtils.isEmpty(eDuration) && ObjectUtils.isEmpty(noonResult)) { |
| | | // 上午时长 >= 上午排班时间 改打卡状态 否则 缺时 |
| | | if (sDuration >= result) { |
| | |
| | | * @param attendance |
| | | * @param type |
| | | */ |
| | | public void setAttendanceStart(Double sDuration, Double eDuration, Double result1, Double result, Double noonResult, NewAttendance attendance, String type) { |
| | | public void setAttendanceStart(Double sDuration, Double eDuration, Double result1, Double result, Double noonResult, Attendance attendance, String type) { |
| | | if (ObjectUtils.isEmpty(eDuration) && sDuration > 0) { |
| | | if ((sDuration + result1) >= result) { |
| | | attendance.setStartClockResults(type); |
| | |
| | | * @param attendance |
| | | * @return |
| | | */ |
| | | public Double getDuration(Timestamp startDate, Timestamp endDate, NewAttendance attendance, Boolean day) { |
| | | public Double getDuration(Timestamp startDate, Timestamp endDate, Attendance attendance, Boolean day) { |
| | | Double duration = new Double(0.00); |
| | | // 上午总时长 |
| | | if (day) { |
| | |
| | | return duration; |
| | | } |
| | | |
| | | public Double getStartDuration(Timestamp startDate, Timestamp endDate, NewAttendance attendance) { |
| | | public Double getStartDuration(Timestamp startDate, Timestamp endDate, Attendance attendance) { |
| | | Double duration = new Double(0.00); |
| | | // 上午总时长 |
| | | if (startDate.toLocalDateTime().isBefore(attendance.getRosteringLunchStartTime().toLocalDateTime()) && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0) { |
| | |
| | | return duration; |
| | | } |
| | | |
| | | public Double getEndDuration(Timestamp startDate, Timestamp endDate, NewAttendance attendance) { |
| | | public Double getEndDuration(Timestamp startDate, Timestamp endDate, Attendance attendance) { |
| | | Double duration = new Double(0.00); |
| | | // 下午总时长 |
| | | if (startDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0) { |
| | |
| | | return duration; |
| | | } |
| | | |
| | | /** |
| | | * Unix时间戳转Timestamp |
| | | * |
| | | * @param unixtime Unix时间戳 |
| | | * @return |
| | | */ |
| | | private Timestamp unixtimeToTimestamp(Long unixtime) { |
| | | if (ObjectUtils.isNotEmpty(unixtime)) { |
| | | return new Timestamp(unixtime * 1000); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 发送企微应用消息 |
| | | * |
| | | * @param userWeComIdList 接收消息用户企微ID |
| | | * @param content 消息内容 |
| | | * @param type 消息类型 |
| | | */ |
| | | public void sendNotice(List<String> userWeComIdList, String title, String content, String type) { |
| | | if (userWeComIdList.size() > 0) { |
| | | try { |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 编辑消息 |
| | | WxCpMessage wxCpMessage = new WxCpMessage(); |
| | | wxCpMessage.setToUser(userWeComIdList.stream().collect(Collectors.joining("|"))); |
| | | if (type.equals(Constant.WECOM_MESSAGE_TYPE_TEXT)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXT); |
| | | wxCpMessage.setContent(content); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_IMAGE)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_IMAGE); |
| | | wxCpMessage.setMediaId(content); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_VOICE)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_VOICE); |
| | | wxCpMessage.setMediaId(content); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_VIDEO)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_VIDEO); |
| | | wxCpMessage.setMediaId(content); |
| | | wxCpMessage.setTitle(title); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_FILE)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_FILE); |
| | | wxCpMessage.setMediaId(content); |
| | | } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_TEXTCARD)) { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | wxCpMessage.setTitle(title); |
| | | wxCpMessage.setDescription(content); |
| | | wxCpMessage.setUrl(Constant.WECOM_MESSAGE_URL); |
| | | wxCpMessage.setBtnTxt(Constant.WECOM_MESSAGE_BTNTXT); |
| | | } else { |
| | | wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXT); |
| | | wxCpMessage.setContent(content); |
| | | } |
| | | wxCpMessage.setSafe("0"); |
| | | wxCpMessage.setEnableDuplicateCheck(false); |
| | | wxCpMessage.setDuplicateCheckInterval(600); |
| | | |
| | | // 发送消息 |
| | | wxCpService.getMessageService().send(wxCpMessage); |
| | | } catch (WxErrorException wxErrorException) { |
| | | wxErrorException.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |