Merge branch 'weicd' of http://192.168.1.110:5678/r/pms-upgrade into master
1 files added
27 files modified
| | |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | |
| | | @Query(value = "SELECT * FROM attendance_business_travel WHERE user_id = ?3 AND approval_status IN ('business_approve_status_reviewed', 'business_approve_status_agree') AND id NOT IN ?4 AND ((travel_start_time >= ?1 and travel_start_time <= ?2) OR \n" + |
| | | "(travel_start_time <= ?1 and travel_end_time >= ?2) OR (travel_end_time >= ?1 and travel_end_time <= ?2) OR (travel_start_time >= ?1 and travel_end_time <= ?2))", nativeQuery = true) |
| | | List<AttendanceBusinessTravel> checkCreateUpdateTime(String startTime, String endTime, Long userId, Set<Long> ids); |
| | | |
| | | // 查询出差记录 |
| | | @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) |
| | | AttendanceBusinessTravel findByUserAndDate(Long userId, String startDate, String endDate); |
| | | } |
| | |
| | | **/ |
| | | public interface AttendanceCardreplacementRepository extends JpaRepository<AttendanceCardreplacement, Long>, JpaSpecificationExecutor<AttendanceCardreplacement> { |
| | | |
| | | //查询补卡记录是否存 |
| | | //查询补卡记录是否存在 |
| | | @Query(value = "SELECT * from attendance_cardreplacement WHERE user_id = ? and card_replacement_time = ? and approval_status != 'card_approve_status_refuse'",nativeQuery = true) |
| | | AttendanceCardreplacement findByUserIdAndCardReplacementTime(Long userId, Timestamp checkTime); |
| | | |
| | | // 获取当月补卡状态为未审核和已同意的补卡总条数 |
| | | @Query(value = "SELECT COUNT(*) FROM `attendance_cardreplacement` WHERE user_id = ? and card_replacement_time like %?% and approval_status in('card_approve_status_reviewed','card_approve_status_agree')",nativeQuery = true) |
| | | Integer count(Long userId, String baseDate); |
| | | } |
| | |
| | | |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | |
| | | @Query(value = "SELECT * FROM attendance_go_out WHERE user_id = ?3 AND approval_status IN ('go_out_approve_status_reviewed', 'go_out_approve_status_agree') AND id NOT IN ?4 AND ((out_start_time >= ?1 and out_start_time <= ?2) OR \n" + |
| | | "(out_start_time <= ?1 and out_end_time >= ?2) OR (out_end_time >= ?1 and out_end_time <= ?2) OR (out_start_time >= ?1 and out_end_time <= ?2))", nativeQuery = true) |
| | | 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) |
| | | List<AttendanceGoOut> findByUserAndDate(Long userId, LocalDateTime startDate, LocalDateTime endDate); |
| | | } |
| | |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | |
| | | @Query(value = "SELECT sum(leave_duration) from attendance_leave WHERE user_id = ?1 AND approval_status IN ('approval_status_under_approval','approval_status_passed') " + |
| | | "AND leave_type = 'leave_type_annual_leave' AND leave_start_time >= ?2 AND leave_end_time <= ?3" ,nativeQuery = true) |
| | | Double getSurplusYearTime(Long userId,String startTime,String endTime); |
| | | |
| | | //查询请假记录 |
| | | @Query(value = "SELECT * from attendance_leave where user_id = ?1 and leave_start_time <= ?3 and leave_end_time >= ?2 and approval_status IN ('approval_status_passed')", nativeQuery = true) |
| | | List<AttendanceLeave> findByUserIdAndDate(Long userId, LocalDateTime startDate, LocalDateTime endDate); |
| | | } |
| | |
| | | attendanceService.getUserMakeUpCard(userId); |
| | | return new ResponseEntity<>(HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PostMapping(value = "/addAttendanceInfo") |
| | | @Log("考勤信息补充") |
| | | @ApiOperation("考勤信息补充") |
| | | public ResponseEntity<Object> addAttendanceInfo(@Validated @RequestBody Attendance attendance) throws Exception { |
| | | attendanceService.addAttendanceInfo(attendance); |
| | | return new ResponseEntity<>(HttpStatus.CREATED); |
| | | } |
| | | |
| | | } |
| | |
| | | package me.zhengjie.modules.attendance.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceBusinessTravel; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.attendance.service.AttendanceGoOutService; |
| | |
| | | attendanceGoOutService.updateApprove(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @PutMapping(value = "/revoke") |
| | | @Log("外出撤销") |
| | | @ApiOperation("外出撤销") |
| | | public ResponseEntity<Object> revokeGoOut(@Validated @RequestBody AttendanceGoOut resources){ |
| | | attendanceGoOutService.updateRevoke(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | } |
| | |
| | | |
| | | @PostMapping(value = "/getYearTimeLength") |
| | | @Log("获取年假时长") |
| | | @ApiOperation("计算请假时长") |
| | | public ResponseEntity<Object> getYearTimeLength() throws ParseException { |
| | | return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(), HttpStatus.OK); |
| | | @ApiOperation("获取年假时长") |
| | | public ResponseEntity<Object> getYearTimeLength(@RequestBody Long userId) throws ParseException { |
| | | return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(userId), HttpStatus.OK); |
| | | } |
| | | |
| | | @PutMapping(value = "/approve") |
| | |
| | | * @param resources / |
| | | */ |
| | | void updateApprove(AttendanceGoOut resources); |
| | | |
| | | /** |
| | | * 撤销功能 |
| | | * @param resources |
| | | */ |
| | | void updateRevoke(AttendanceGoOut resources); |
| | | } |
| | |
| | | * @return |
| | | * @throws ParseException |
| | | */ |
| | | Double getYearTimeLength() throws ParseException; |
| | | Double getYearTimeLength(Long userId) throws ParseException; |
| | | |
| | | /** |
| | | * 审核功能 |
| | |
| | | void getExceptional(String Number); |
| | | |
| | | void getUserMakeUpCard(String userId); |
| | | |
| | | /** |
| | | * 补充考勤信息 |
| | | * @param attendance |
| | | */ |
| | | void addAttendanceInfo(Attendance attendance) throws Exception; |
| | | |
| | | } |
| | |
| | | @Query |
| | | private String cardReplacementDistinguish; |
| | | |
| | | @Query(isOr = "userId,approvalUserId") |
| | | private Long approver; |
| | | // @Query(isOr = "userId,approvalUserId") |
| | | // private Long approver; |
| | | } |
| | |
| | | package me.zhengjie.modules.attendance.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceBusinessTravel; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.attendance.domain.Calculate; |
| | | import me.zhengjie.modules.attendance.domain.*; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.attendance.service.AttendanceService; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutDto; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.OpaiDingTalkService; |
| | | import me.zhengjie.modules.system.domain.Job; |
| | | import me.zhengjie.modules.system.domain.Role; |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceBusinessTravelDto; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceBusinessTravelQueryCriteria; |
| | | import me.zhengjie.modules.attendance.service.mapstruct.AttendanceBusinessTravelMapper; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | |
| | | private final AttendanceLeaveServiceImpl attendanceLeaveService; |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | private final AttendanceService attendanceService; |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceBusinessTravelQueryCriteria criteria, Pageable pageable){ |
| | |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String bussStartTime = df.format(resources.getTravelStartTime()); |
| | | String bussEndTime = df.format(resources.getTravelEndTime()); |
| | | // 验证请假时间是否冲突 |
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(bussStartTime,bussEndTime, SecurityUtils.getCurrentUserId()); |
| | | // 查询其他状态的表是否有重复 |
| | | repeatValidation(bussStartTime, bussEndTime, resources.getUserId()); |
| | | // 验证出差时间是否冲突 |
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(bussStartTime,bussEndTime, resources.getUserId()); |
| | | if(attendanceBusinessTravelList.size() > 0){ |
| | | AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
| | |
| | | + "已经存在出差记录,请调整时间"); |
| | | }else { |
| | | // 获取当前登陆人信息,设置为请假发起人 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>(); |
| | | // 查询节假日 |
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll(); |
| | |
| | | //查询审批者信息 |
| | | User appUser = userRepository.getOne(resources.getApprovalUserId()); |
| | | sendList.add(appUser.getDingding()); |
| | | opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n >" + user.getNickName() + " 提交了请假审批,请登录PMS系统处理", "card"); |
| | | opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n >" + user.getNickName() + " 提交了出差审批,请登录PMS系统处理", "card"); |
| | | } |
| | | return attendanceBusinessTravelMapper.toDto(resources); |
| | | } |
| | |
| | | |
| | | //获取当前登入人信息 |
| | | User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user1.getJobs().iterator().next(); |
| | | Role role = user1.getRoles().iterator().next(); |
| | | //除超管、总经理只能修改自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能修改自己的记录"); |
| | | } |
| | |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String bussStartTime = df.format(resources.getTravelStartTime()); |
| | | String bussEndTime = df.format(resources.getTravelEndTime()); |
| | | // 查询其他状态的表是否有重复 |
| | | repeatValidation(bussStartTime, bussEndTime, resources.getUserId()); |
| | | // 验证是否存在时间冲突的请假记录 |
| | | Set<Long> ids = new HashSet<>(); |
| | | ids.add(attendanceBusinessTravel.getId()); |
| | |
| | | attendanceBusinessTravelRepository.deleteById(id); |
| | | } |
| | | // 获取当前登陆人信息,设置为请假发起人 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>(); |
| | | // 查询节假日 |
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll(); |
| | |
| | | return attendanceBusinessTravel; |
| | | } |
| | | |
| | | /** |
| | | * 验证其他状态的表是否有重复 |
| | | * @param buStartTime |
| | | * @param buEndTime |
| | | */ |
| | | public void repeatValidation(String buStartTime, String buEndTime, Long userId){ |
| | | //查询用户的排班时间 |
| | | User user = userRepository.getOne(userId); |
| | | buStartTime = buStartTime.substring(0,10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00"; |
| | | buEndTime = buEndTime.substring(0,10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00"; |
| | | // 查询请假表(时单位) |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(buStartTime,buEndTime, userId); |
| | | if(attendanceLeaveList.size() > 0){ |
| | | AttendanceLeave errorSysAskForLeave = attendanceLeaveList.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime()) |
| | | + "已经存在请假记录,请调整时间"); |
| | | } |
| | | // 查询外出表 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(buStartTime, buEndTime, userId); |
| | | if(attendanceGoOutList.size() > 0){ |
| | | AttendanceGoOut errorSysAskForLeave = attendanceGoOutList.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | throw new BadRequestException("外出时间冲突," + errorFormat.format(errorSysAskForLeave.getOutStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getOutEndTime()) |
| | | + "已经存在外出记录,请调整时间"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | |
| | | |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | Role role = user.getRoles().iterator().next(); |
| | | //除超管、总经理只能删除自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(attendanceBusinessTravel.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能删除自己的记录"); |
| | | } |
| | |
| | | AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findById(resources.getId()).orElseGet(AttendanceBusinessTravel::new); |
| | | ValidationUtil.isNull( attendanceBusinessTravel.getId(),"AttendanceBusinessTravel","id",resources.getId()); |
| | | attendanceBusinessTravel.copy(resources); |
| | | //审批通过直接改考勤记录的状态 |
| | | if(resources.getApprovalStatus().equals(Constant.BUSSINESS_APPROVE_STATUS_AGREE)){ |
| | | // 查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getTravelStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_BUSINESS); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_BUSINESS); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | attendanceBusinessTravelRepository.save(attendanceBusinessTravel); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void updateRevoke(AttendanceBusinessTravel resources) { |
| | | |
| | | AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findById(resources.getId()).orElseGet(AttendanceBusinessTravel::new); |
| | | ValidationUtil.isNull( attendanceBusinessTravel.getId(),"AttendanceBusinessTravel","id",resources.getId()); |
| | | attendanceBusinessTravel.copy(resources); |
| | | attendanceBusinessTravel.setApprovalStatus(Constant.BUSSINESS_APPROVE_STATUS_REVIEWED); |
| | | // 查询考勤记录是否存在,修改状态为等待 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getTravelStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | attendanceBusinessTravelRepository.save(attendanceBusinessTravel); |
| | | } |
| | | } |
| | |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.OpaiDingTalkService; |
| | | import me.zhengjie.modules.system.domain.Job; |
| | | import me.zhengjie.modules.system.domain.Role; |
| | | import me.zhengjie.modules.system.domain.SysConfigProportion; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.RoleRepository; |
| | | import me.zhengjie.modules.system.repository.SysConfigProportionRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | private final OpaiDingTalkService opaiDingTalkService; |
| | | private final RoleRepository roleRepository; |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final SysConfigProportionRepository sysConfigProportionRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceCardreplacementQueryCriteria criteria, Pageable pageable){ |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AttendanceCardreplacementDto create(AttendanceCardreplacement resources) throws Exception { |
| | | |
| | | //查询补卡次数(每个月5次) |
| | | getCardreplacement(resources.getUserId()); |
| | | |
| | | //查询补卡记录是否存在 |
| | | AttendanceCardreplacement attendanceCardreplacement = attendanceCardreplacementRepository.findByUserIdAndCardReplacementTime(resources.getUserId(),resources.getCardReplacementTime()); |
| | | if(ObjectUtils.isNotEmpty(attendanceCardreplacement)) { |
| | |
| | | } |
| | | |
| | | resources.setApprovalStatus(Constant.CARD_APPROVE_STATUS_REVIEWED); |
| | | //查询补卡次数(待加入)? |
| | | |
| | | //发送给审批者 |
| | | List<String> sendList = new ArrayList<>(); |
| | |
| | | throw new BadRequestException("考勤记录不存在"); |
| | | } |
| | | |
| | | //查询补卡次数(每个月5次) |
| | | getCardreplacement(resources.getUserId()); |
| | | |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | Role role = user.getRoles().iterator().next(); |
| | | //除超管、总经理只能修改自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能修改自己的记录"); |
| | | } |
| | |
| | | } |
| | | |
| | | attendanceCardreplacementRepository.save(attendanceCardreplacement); |
| | | } |
| | | |
| | | /** |
| | | * 查询剩余补卡次数 |
| | | */ |
| | | 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; |
| | | // 查询当月的补卡记录的条数 |
| | | Integer count = attendanceCardreplacementRepository.count(userId, baseDate); |
| | | // 查询配置表的每月补卡次数 |
| | | SysConfigProportion sysConfigProportion = sysConfigProportionRepository.findByTitle("每月可补卡次数"); |
| | | if(count >= sysConfigProportion.getProportion()){ |
| | | throw new BadRequestException("补卡次数用尽,请联系管理员"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | attendance.setActualWorkStartTime(resources.getCardReplacementTime()); |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL); |
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NORMAL); |
| | | // 减少补卡次数待加入? |
| | | }else if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED); |
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED); |
| | |
| | | attendance.setActualWorkEndTime(resources.getCardReplacementTime()); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED); |
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED); |
| | | // 减少补卡次数待加入? |
| | | }else if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){ |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED); |
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED); |
| | |
| | | for (Long id : ids) { |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | Role role = user.getRoles().iterator().next(); |
| | | //根据id查询记录 |
| | | Optional<AttendanceCardreplacement> attendanceCardreplacement = attendanceCardreplacementRepository.findById(id); |
| | | //除超管、总经理只能删除自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(attendanceCardreplacement.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能删除自己的记录"); |
| | | } |
| | |
| | | package me.zhengjie.modules.attendance.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.attendance.domain.Calculate; |
| | | import me.zhengjie.modules.attendance.domain.*; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.attendance.service.AttendanceService; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.OpaiDingTalkService; |
| | | import me.zhengjie.modules.system.domain.Job; |
| | | import me.zhengjie.modules.system.domain.Role; |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutDto; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutQueryCriteria; |
| | | import me.zhengjie.modules.attendance.service.mapstruct.AttendanceGoOutMapper; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | private final AttendanceLeaveServiceImpl attendanceLeaveService; |
| | | private final OpaiDingTalkService opaiDingTalkService; |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable){ |
| | |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String goStartTime = df.format(resources.getOutStartTime()); |
| | | String goEndTime = df.format(resources.getOutEndTime()); |
| | | // 查询其他状态的表是否有重复 |
| | | repeatValidation(goStartTime, goEndTime, resources.getUserId()); |
| | | // 验证请假时间是否冲突 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(goStartTime, goEndTime, SecurityUtils.getCurrentUserId()); |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(goStartTime, goEndTime, resources.getUserId()); |
| | | if(attendanceGoOutList.size() > 0){ |
| | | AttendanceGoOut errTime = attendanceGoOutList.get(0); |
| | | //LocalDateTime转换为Date |
| | |
| | | + "已经存在外出记录,请调整时间"); |
| | | }else { |
| | | // 获取当前登陆人信息,设置为请假发起人 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>(); |
| | | // 查询节假日 |
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll(); |
| | |
| | | //查询审批者信息 |
| | | User appUser = userRepository.getOne(resources.getApprovalUserId()); |
| | | sendList.add(appUser.getDingding()); |
| | | opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n >" + user.getNickName() + " 提交了请假审批,请登录PMS系统处理", "card"); |
| | | opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n >" + user.getNickName() + " 提交了外出审批,请登录PMS系统处理", "card"); |
| | | } |
| | | return attendanceGoOutMapper.toDto(resources); |
| | | } |
| | |
| | | |
| | | //获取当前登入人信息 |
| | | User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user1.getJobs().iterator().next(); |
| | | Role role = user1.getRoles().iterator().next(); |
| | | //除超管、总经理只能修改自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能修改自己的记录"); |
| | | } |
| | |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String goStartTime = df.format(resources.getOutStartTime()); |
| | | String goEndTime = df.format(resources.getOutEndTime()); |
| | | // 查询其他状态的表是否有重复 |
| | | repeatValidation(goStartTime, goEndTime, resources.getUserId()); |
| | | // 验证是否存在时间冲突的请假记录 |
| | | Set<Long> ids = new HashSet<>(); |
| | | ids.add(attendanceGoOut.getId()); |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateUpdateTime(goStartTime, goEndTime, SecurityUtils.getCurrentUserId(), ids); |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateUpdateTime(goStartTime, goEndTime, resources.getUserId(), ids); |
| | | if(attendanceGoOutList.size() > 0){ |
| | | AttendanceGoOut errorSysAskForLeave = attendanceGoOutList.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
| | |
| | | attendanceGoOutRepository.deleteById(id); |
| | | } |
| | | // 获取当前登陆人信息,设置为请假发起人 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>(); |
| | | // 查询节假日 |
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll(); |
| | |
| | | return attendanceGoOut; |
| | | } |
| | | |
| | | /** |
| | | * 验证其他状态的表是否有重复 |
| | | * @param goStartTime |
| | | * @param goEndTime |
| | | */ |
| | | public void repeatValidation(String goStartTime, String goEndTime, Long userId){ |
| | | // 查询请假表(时单位) |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(goStartTime,goEndTime, userId); |
| | | if(attendanceLeaveList.size() > 0){ |
| | | AttendanceLeave errorSysAskForLeave = attendanceLeaveList.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime()) |
| | | + "已经存在请假记录,请调整时间"); |
| | | } |
| | | // 查询出差表 |
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(goStartTime.substring(0,10),goEndTime.substring(0,10), userId); |
| | | if(attendanceBusinessTravelList.size() > 0){ |
| | | AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | throw new BadRequestException("出差时间冲突," + errorFormat.format(errorSysAskForLeave.getTravelStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getTravelEndTime()) |
| | | + "已经存在出差记录,请调整时间"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | |
| | | |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | Role role = user.getRoles().iterator().next(); |
| | | //除超管、总经理只能删除自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(attendanceGoOut.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能删除自己的记录"); |
| | | } |
| | |
| | | AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new); |
| | | ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId()); |
| | | attendanceGoOut.copy(resources); |
| | | //审批通过直接改考勤记录的状态 |
| | | if(resources.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE)){ |
| | | // 查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getOutStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | if (!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) && resources.getOutStartTime().toLocalDateTime().compareTo(attendance.getRosteringWorkStartTime().toLocalDateTime()) <= 0) { |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_GOOUT); |
| | | } |
| | | if (!attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_GOOUT) &&resources.getOutEndTime().toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) >= 0) { |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_GOOUT); |
| | | } |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | attendanceGoOutRepository.save(attendanceGoOut); |
| | | } |
| | | |
| | | /** |
| | | * 外出撤销 |
| | | * @param resources |
| | | */ |
| | | @Override |
| | | public void updateRevoke(AttendanceGoOut resources) { |
| | | AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new); |
| | | ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId()); |
| | | attendanceGoOut.copy(resources); |
| | | attendanceGoOut.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED); |
| | | // 查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getOutStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | attendanceGoOutRepository.save(attendanceGoOut); |
| | | } |
| | | } |
| | |
| | | package me.zhengjie.modules.attendance.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.Attendance; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.attendance.domain.Calculate; |
| | | import me.zhengjie.modules.attendance.domain.*; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.attendance.service.AttendanceService; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceDto; |
| | | import me.zhengjie.modules.constant.Constant; |
| | |
| | | private final UserRepository userRepository; |
| | | private final OpaiDingTalkService opaiDingTalkService; |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | private final AttendanceRepository attendanceRepository; |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable){ |
| | |
| | | // 如果按天为单位请假拼接请假时间的时分秒,取上下班基准时间 |
| | | if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)){ |
| | | //查询用户的排班时间 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | LeaStartTime = LeaStartTime.substring(0,10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00"; |
| | | LeaEndTime = LeaEndTime.substring(0,10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00"; |
| | | } |
| | | // 查询其他状态的表是否有重复 |
| | | repeatValidation(LeaStartTime, LeaEndTime, resources.getUserId()); |
| | | // 验证请假时间是否冲突 |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(LeaStartTime,LeaEndTime, SecurityUtils.getCurrentUserId()); |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(LeaStartTime,LeaEndTime, resources.getUserId()); |
| | | if(attendanceLeaveList.size() > 0){ |
| | | AttendanceLeave errTime = attendanceLeaveList.get(0); |
| | | //LocalDateTime转换为Date |
| | |
| | | + "已经存在请假记录,请调整时间"); |
| | | }else { |
| | | // 获取当前登陆人信息,设置为请假发起人 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>(); |
| | | // 查询节假日 |
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll(); |
| | |
| | | |
| | | //获取当前登入人信息 |
| | | User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user1.getJobs().iterator().next(); |
| | | Role role = user1.getRoles().iterator().next(); |
| | | //除超管、总经理只能修改自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能修改自己的记录"); |
| | | } |
| | |
| | | // 如果按天为单位请假拼接请假时间的时分秒,取上下班基准时间 |
| | | if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)){ |
| | | //查询用户的排班时间 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | LeaStartTime = LeaStartTime.substring(0,10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00"; |
| | | LeaEndTime = LeaEndTime.substring(0,10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00"; |
| | | } |
| | | // 查询其他状态的表是否有重复 |
| | | repeatValidation(LeaStartTime, LeaEndTime, resources.getUserId()); |
| | | // 验证是否存在时间冲突的请假记录 |
| | | Set<Long> ids = new HashSet<>(); |
| | | ids.add(attendanceLeave.getId()); |
| | |
| | | attendanceLeaveRepository.deleteById(id); |
| | | } |
| | | // 获取当前登陆人信息,设置为请假发起人 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>(); |
| | | // 查询节假日 |
| | | List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll(); |
| | |
| | | attendanceLeaveRepository.save(attendanceLeave1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 验证其他状态的表是否有重复 |
| | | * @param startTime |
| | | * @param endTime |
| | | * @param userId |
| | | */ |
| | | public void repeatValidation(String startTime, String endTime, Long userId){ |
| | | // 查询外出表 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(startTime, endTime, userId); |
| | | if(attendanceGoOutList.size() > 0){ |
| | | AttendanceGoOut errorSysAskForLeave = attendanceGoOutList.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | throw new BadRequestException("外出时间冲突," + errorFormat.format(errorSysAskForLeave.getOutStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getOutEndTime()) |
| | | + "已经存在外出记录,请调整时间"); |
| | | } |
| | | // 查询出差表 |
| | | List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(startTime.substring(0,10),endTime.substring(0,10), userId); |
| | | if(attendanceBusinessTravelList.size() > 0){ |
| | | AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | throw new BadRequestException("出差时间冲突," + errorFormat.format(errorSysAskForLeave.getTravelStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getTravelEndTime()) |
| | | + "已经存在出差记录,请调整时间"); |
| | | } |
| | | } |
| | | |
| | |
| | | * 获取用户年假剩余时长 |
| | | */ |
| | | @Override |
| | | public Double getYearTimeLength() throws ParseException { |
| | | public Double getYearTimeLength(Long userId) throws ParseException { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 获取当前日期 |
| | | Date date = new Date(); |
| | |
| | | Date dateTime = sdf.parse(nowTime); |
| | | Double surplusYearTime = new Double(0.00); |
| | | // 查询用户剩余年假时长 |
| | | List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(SecurityUtils.getCurrentUserId()); |
| | | List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(userId); |
| | | for(SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList){ |
| | | if(ObjectUtils.isNotEmpty(sysUserLevelOther.getStartDate()) && ObjectUtils.isNotEmpty(sysUserLevelOther.getEndDate())){ |
| | | Date dateStart = new Date(sysUserLevelOther.getStartDate().getTime()); |
| | | Date dateEnd = new Date(sysUserLevelOther.getEndDate().getTime()); |
| | | Date dateEnd = new Date(); |
| | | if (ObjectUtils.isNotEmpty(sysUserLevelOther.getStartDate()) && ObjectUtils.isNotEmpty(sysUserLevelOther.getEndDate())) { |
| | | dateEnd = new Date(sysUserLevelOther.getEndDate().getTime()); |
| | | } |
| | | //取当前日期在数据中开始日期与结束日期之间的数据 |
| | | if(dateTime.compareTo(dateStart) >= 0 && dateTime.compareTo(dateEnd) <= 0){ |
| | | if (dateTime.compareTo(dateStart) >= 0 && dateTime.compareTo(dateEnd) <= 0 || dateTime.compareTo(dateStart) >= 0 && sysUserLevelOther.getEndDate() == null) { |
| | | //年假总时长 |
| | | Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8); |
| | | //已使用年假时长 |
| | |
| | | Double usedYearTime = attendanceLeaveRepository.getSurplusYearTime(sysUserLevelOther.getUserId(),startTime,endTime); |
| | | //剩余年假 |
| | | surplusYearTime = yearTime - (usedYearTime == null ? 0.0 : usedYearTime); |
| | | } |
| | | } |
| | | } |
| | | return surplusYearTime; |
| | |
| | | AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new); |
| | | ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId()); |
| | | attendanceLeave.copy(resources); |
| | | //审批通过直接改考勤记录的状态 |
| | | if(resources.getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED)){ |
| | | // 查询考勤记录是否存在 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getLeaveStartTime().toLocalDateTime().toString().substring(0,10)); |
| | | if(ObjectUtils.isNotEmpty(attendance)){ |
| | | if (!attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LEAVE) && resources.getLeaveStartTime().toLocalDateTime().compareTo(attendance.getRosteringWorkStartTime().toLocalDateTime()) <= 0) { |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LEAVE); |
| | | } |
| | | if (!attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LEAVE) &&resources.getLeaveEndTime().toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) >= 0) { |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_LEAVE); |
| | | } |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | attendanceLeaveRepository.save(attendanceLeave); |
| | | } |
| | | |
| | |
| | | |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | Role role = user.getRoles().iterator().next(); |
| | | //根据id查询记录 |
| | | Optional<AttendanceLeave> attendanceLeave1 = attendanceLeaveRepository.findById(id); |
| | | //除超管、总经理只能删除自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(attendanceLeave1.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能删除自己的记录"); |
| | | } |
| | |
| | | import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository; |
| | | import me.zhengjie.modules.attendance.service.dto.*; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.impl.DingTalkServiceImpl; |
| | | import me.zhengjie.modules.quartz.task.OapiDingTalkMethod; |
| | | import me.zhengjie.modules.system.domain.*; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | private final DingTalkServiceImpl dingTalkService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AttendanceQueryCriteria criteria, Pageable pageable){ |
| | |
| | | Attendance attendance = attendanceRepository.findById(resources.getId()).orElseGet(Attendance::new); |
| | | ValidationUtil.isNull( attendance.getId(),"Attendance","id",resources.getId()); |
| | | attendance.copy(resources); |
| | | |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | Role role = user.getRoles().iterator().next(); |
| | | //除超管、总经理只能修改自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能修改自己的记录"); |
| | | } |
| | |
| | | if (localDateTime.toLocalTime().isBefore(sysRostering.getWorkStartTime())) { |
| | | return localDateTime.toLocalDate().atTime(sysRostering.getWorkStartTime()); |
| | | } else if (localDateTime.toLocalTime().isAfter(sysRostering.getLunchStartTime()) && localDateTime.toLocalTime().isBefore(sysRostering.getLunchEndTime())) { |
| | | return localDateTime.toLocalDate().atTime(sysRostering.getWorkEndTime()); |
| | | return localDateTime.toLocalDate().atTime(sysRostering.getLunchEndTime()); |
| | | } else if (localDateTime.toLocalTime().isAfter(sysRostering.getWorkEndTime())) { |
| | | return localDateTime.toLocalDate().atTime(sysRostering.getWorkEndTime()); |
| | | } |
| | |
| | | |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | Role role = user.getRoles().iterator().next(); |
| | | //根据id查询记录 |
| | | Optional<Attendance> attendance = attendanceRepository.findById(id); |
| | | //除超管、总经理只能删除自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(attendance.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能删除自己的记录"); |
| | | } |
| | |
| | | public void getUserMakeUpCard(String userId) { |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | Role role = user.getRoles().iterator().next(); |
| | | //除超管、总经理只能补自己的卡 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if(role.getId() != Constant.ROLE_LEVEL_SUPER && role.getId() != Constant.ROLE_LEVEL_GENERAL){ |
| | | if (!Long.valueOf(userId).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能补自己的卡"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 补充考勤信息 |
| | | * @param attendance |
| | | */ |
| | | @Override |
| | | public void addAttendanceInfo(Attendance attendance) throws Exception { |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String attendanceDate = df.format(attendance.getAttendanceDate()); |
| | | List<User> userList = new ArrayList<>(); |
| | | if(ObjectUtils.isNotEmpty(attendance.getUserId())){ |
| | | User user = userRepository.findById(attendance.getUserId()).orElseGet(User::new); |
| | | userList.add(user); |
| | | } |
| | | // 选择日期和员工更新员工的考勤信息,未选择员工则更新所有人 |
| | | dingTalkService.getDingTalkAttendanceListOfNoonOrNight(attendanceDate ,userList); |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<AttendanceDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | |
| | | public static final String ATTENDANCE_STATE_LEAVE = "attendance_state_leave"; |
| | | // 考勤状态:休息 |
| | | public static final String ATTENDANCE_STATE_REST = "attendance_state_rest"; |
| | | // 考勤状态:缺时 |
| | | public static final String ATTENDANCE_STATE_LACK_OF_TIME = "attendance_state_lack_of_time"; |
| | | // 考勤状态:迟到 |
| | | public static final String ATTENDANCE_START_LATE = "attendance_state_late"; |
| | | // 考勤状态:早退 |
| | | public static final String ATTENDANCE_START_EARLY = "attendance_state_early"; |
| | | |
| | | //考勤位置状态 |
| | | public static final String LOCATION_RESULTS = "location_results"; |
| | |
| | | // 请假状态:事假 |
| | | public static final String LEAVE_TYPE_COMPASSIONATE_LEAVE = "leave_type_compassionate_leave"; |
| | | // 请假状态:病假 |
| | | public static final String LEAVE_TYPE_SICk_leave = "leave_type_sick_leave"; |
| | | public static final String LEAVE_TYPE_SICK_LEAVE = "leave_type_sick_leave"; |
| | | // 请假状态:产假 |
| | | public static final String LEAVE_TYPE_maternity_leave = "leave_type_maternity_leave"; |
| | | public static final String LEAVE_TYPE_MATERNITY_LEAVE = "leave_type_maternity_leave"; |
| | | // 请假状态:婚假 |
| | | public static final String LEAVE_TYPE_marriage_holiday = "leave_type_marriage_holiday"; |
| | | public static final String LEAVE_TYPE_MARRIAGE_HOLIDAY = "leave_type_marriage_holiday"; |
| | | // 请假状态:丧假 |
| | | public static final String LEAVE_TYPE_bereavement_leave = "leave_type_bereavement_leave"; |
| | | public static final String LEAVE_TYPE_BEREAVEMENT_LEAVE = "leave_type_bereavement_leave"; |
| | | // 请假状态:哺乳假 |
| | | public static final String LEAVE_TYPE_lactation_leave = "leave_type_lactation_leave"; |
| | | public static final String LEAVE_TYPE_LACTATION_LEAVE = "leave_type_lactation_leave"; |
| | | |
| | | // 请假审批状态 |
| | | public static final String APPROVAL_STATUS = "approval_status"; |
| New file |
| | |
| | | package me.zhengjie.modules.quartz.service.impl; |
| | | |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.Attendance; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceBusinessTravel; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceLeave; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.OpaiDingTalkService; |
| | | import me.zhengjie.modules.quartz.service.dto.OapiDingTalkAccessToken; |
| | | import me.zhengjie.modules.quartz.service.dto.OapiDingTalkRecordResult; |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.domain.SysRostering; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | | import me.zhengjie.modules.system.repository.SysRosteringRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Duration; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class DingTalkServiceImpl { |
| | | |
| | | private final AttendanceRepository attendanceRepository; |
| | | |
| | | private final UserRepository userRepository; |
| | | |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | |
| | | private final OpaiDingTalkService opaiDingTalkService; |
| | | |
| | | private final AttendanceGoOutRepository attendanceGoOutRepository; |
| | | |
| | | private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository; |
| | | |
| | | private final AttendanceLeaveRepository attendanceLeaveRepository; |
| | | |
| | | /** |
| | | * 中午12点30或凌晨02:30执行定时任务 |
| | | * @throws Exception |
| | | */ |
| | | public void getDingTalkAttendanceListOfNoonOrNight(String attendDate, List attUser) throws Exception { |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); |
| | | //获取当前执行定时任务的时间 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); |
| | | String nowDate = sdf.format(new Date()); |
| | | List<User> userList = new ArrayList<>(); |
| | | // attUser不为空说明是考勤信息补充功能,userList赋值 |
| | | if(ObjectUtils.isNotEmpty(attUser)){ |
| | | userList = attUser; |
| | | }else{ |
| | | //查询状态正常的员工 |
| | | userList = getUserList(); |
| | | } |
| | | //获取今天时间 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String todayDate = ""; |
| | | // attendDate不为空说明是考勤信息补充功能,todayDate赋值 |
| | | if(ObjectUtils.isNotEmpty(attendDate)){ |
| | | todayDate = attendDate; |
| | | }else{ |
| | | todayDate = df.format(new Date()); |
| | | } |
| | | //获取昨天时间 |
| | | Calendar calYesterDay = Calendar.getInstance(); |
| | | calYesterDay.add(Calendar.DATE, -1); |
| | | String yesterday = ""; |
| | | // attendDate不为空说明是考勤信息补充功能,yesterday赋值 |
| | | if(ObjectUtils.isNotEmpty(attendDate)){ |
| | | yesterday = attendDate; |
| | | }else{ |
| | | yesterday = df.format(calYesterDay.getTime()); |
| | | } |
| | | //获取钉钉 Token |
| | | OapiDingTalkAccessToken oapiDingTalkAccessToken = opaiDingTalkService.getAccessToken(); |
| | | // errcode = 0,表示正常返回 |
| | | if(0 == oapiDingTalkAccessToken.getErrcode()){ |
| | | //获取今天或昨天时间 |
| | | Calendar calDay = Calendar.getInstance(); |
| | | //标识 |
| | | Boolean day = false; |
| | | //定时任务的执行时间大于等于12:30说明是更新早上打卡的考勤记录 |
| | | if(sdf.parse(nowDate).compareTo(sdf.parse(Constant.DATE_TIME_NOON)) >= 0){ |
| | | calDay.setTime(Timestamp.valueOf(todayDate + " 00:00:00")); |
| | | day = true; |
| | | }else { |
| | | calDay.setTime(Timestamp.valueOf(yesterday + " 00:00:00")); |
| | | } |
| | | String timeResult = ""; |
| | | //遍历在职员工向考勤记录添加数据 |
| | | for (User user : userList) { |
| | | if(ObjectUtils.isNotEmpty(user.getDingding())){ |
| | | //用户钉钉id |
| | | List<String> userDinDingList = new ArrayList<>(); |
| | | //钉钉数据 |
| | | List<OapiDingTalkRecordResult> oapiDingTalkRecordResultList = new ArrayList<>(); |
| | | userDinDingList.add(user.getDingding()); |
| | | Attendance attendance = null; |
| | | //查询考勤记录是否存在 |
| | | if(day){ |
| | | attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), todayDate); |
| | | oapiDingTalkRecordResultList = opaiDingTalkService.getAttendanceList(oapiDingTalkRecordResultList, oapiDingTalkAccessToken.getAccessToken(), todayDate + " 00:00:00", userDinDingList, 0l, 50l); |
| | | }else{ |
| | | attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), yesterday); |
| | | oapiDingTalkRecordResultList = opaiDingTalkService.getAttendanceList(oapiDingTalkRecordResultList, oapiDingTalkAccessToken.getAccessToken(), yesterday + " 00:00:00", userDinDingList, 0l, 50l); |
| | | } |
| | | // attendance为空, attendDate不为空是考勤信息补全功能,创建考勤 |
| | | if(ObjectUtils.isEmpty(attendance) && ObjectUtils.isNotEmpty(attendDate)){ |
| | | attendance = new Attendance(); |
| | | Date date = df.parse(attendDate); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String attDate =simpleDateFormat.format(date); |
| | | Calendar calTodayDay = Calendar.getInstance(); |
| | | calTodayDay.setTime(Timestamp.valueOf(attendDate + " 00:00:00")); |
| | | //查询节假日表是否有记录 |
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(todayDate); |
| | | attendance.setUserId(user.getId()); |
| | | attendance.setAttendanceDate(Timestamp.valueOf(attDate)); |
| | | if(calTodayDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && sysConfigHoliday == null || calTodayDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY && sysConfigHoliday == null){ |
| | | //双休 |
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKEND); |
| | | }else if(sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)){ |
| | | //法定 |
| | | attendance.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS); |
| | | }else{ |
| | | //除了法定节假日和双休都属于工作日 |
| | | attendance.setDateType(Constant.DATE_TYPE_WEEKDAY); |
| | | } |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_WAITFOR); |
| | | attendance.setRosteringWorkStartTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(user.getSysRostering().getWorkStartTime()))); |
| | | attendance.setRosteringWorkEndTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(user.getSysRostering().getWorkEndTime()))); |
| | | attendance.setRosteringLunchStartTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(user.getSysRostering().getLunchStartTime()))); |
| | | attendance.setRosteringLunchEndTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(user.getSysRostering().getLunchEndTime()))); |
| | | } |
| | | for (OapiDingTalkRecordResult oapiDingTalkRecordResult : oapiDingTalkRecordResultList) { |
| | | |
| | | if ("NotSigned".equals(oapiDingTalkRecordResult.getTimeResult())) { |
| | | oapiDingTalkRecordResult.setUserCheckTime(null); |
| | | timeResult = "NotSigned"; |
| | | } |
| | | if ("OnDuty".equals(oapiDingTalkRecordResult.getCheckType())) { |
| | | // 状态不等于等待,说明有审批通过,不修改 |
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setStartClockResults(ObjectUtil.isEmpty(oapiDingTalkRecordResult.getUserCheckTime()) ? oapiDingTalkRecordResult.getTimeResult() : checkResult(user.getSysRostering(), oapiDingTalkRecordResult.getUserCheckTime(), 1)); |
| | | } |
| | | attendance.setStartLocationResults(setLocationResults(oapiDingTalkRecordResult.getLocationResult())); |
| | | attendance.setActualWorkStartTime(oapiDingTalkRecordResult.getUserCheckTime()); |
| | | }else if("OffDuty".equals(oapiDingTalkRecordResult.getCheckType())){ |
| | | if(attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setEndClockResults(ObjectUtil.isEmpty(oapiDingTalkRecordResult.getUserCheckTime()) ? oapiDingTalkRecordResult.getTimeResult() : checkResult(user.getSysRostering(), oapiDingTalkRecordResult.getUserCheckTime(), 2)); |
| | | } |
| | | attendance.setEndLocationResults(setLocationResults(oapiDingTalkRecordResult.getLocationResult())); |
| | | attendance.setActualWorkEndTime(oapiDingTalkRecordResult.getUserCheckTime()); |
| | | } |
| | | } |
| | | // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(oapiDingTalkRecordResultList为空的情况下) |
| | | if(calDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)){ |
| | | // 上午 |
| | | if(day && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST); |
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST); |
| | | attendance.setActualWorkStartTime(null); |
| | | }else if(!day && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST); |
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST); |
| | | attendance.setActualWorkEndTime(null); |
| | | } |
| | | } |
| | | |
| | | // 修改考勤打卡状态 |
| | | attendance = updateRecord(user, attendance, timeResult, day, attendDate); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | }else{ |
| | | throw new BadRequestException(oapiDingTalkAccessToken.getErrmsg()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询其他状态表并调用方法修改 |
| | | * @param user |
| | | */ |
| | | public Attendance updateRecord(User user, Attendance attendance, String timeResult, Boolean day, String attendDate){ |
| | | // 查询考勤请假表 |
| | | List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.findByUserIdAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime()); |
| | | Double leaveDuration = new Double(0.00);//钉钉方法的时长 |
| | | Double leaveStartDuration = new Double(0.00);//考勤按钮的时长 |
| | | Double leaveEndDuration = new Double(0.00);//考勤按钮的时长 |
| | | //请假优先于出差优先于外出 |
| | | if(attendanceLeaveList.size() < 1){ |
| | | // 查询考勤出差表 |
| | | AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findByUserAndDate(user.getId(),attendance.getAttendanceDate().toString().substring(0,10),attendance.getAttendanceDate().toString().substring(0,10)); |
| | | Double bussDuration = new Double(0.00); |
| | | Double bussStartDuration = new Double(0.00);//考勤按钮的时长 |
| | | Double bussEndDuration = new Double(0.00);//考勤按钮的时长 |
| | | if(ObjectUtils.isEmpty(attendanceBusinessTravel)){ |
| | | // 查询考勤外出表 |
| | | List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.findByUserAndDate(user.getId(),attendance.getRosteringWorkStartTime().toLocalDateTime(),attendance.getRosteringWorkEndTime().toLocalDateTime()); |
| | | 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)){ |
| | | // 上午时长、下午时长 |
| | | outStartDuration += getStartDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance); |
| | | outEndDuration += getEndDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance); |
| | | //调用方法修改考勤打卡状态 |
| | | updateAttendanceRecord(null,attendance,timeResult,Constant.ATTENDANCE_STATE_GOOUT,day,outStartDuration,outEndDuration); |
| | | }else{ |
| | | // 上午or下午总时长 |
| | | outDuration += getDuration(attendanceGoOut.getOutStartTime(),attendanceGoOut.getOutEndTime(),attendance,day); |
| | | updateAttendanceRecord(outDuration,attendance,timeResult,Constant.ATTENDANCE_STATE_GOOUT, day,null,null); |
| | | } |
| | | } |
| | | }else{ |
| | | if(ObjectUtils.isNotEmpty(attendanceBusinessTravel)){ |
| | | // attendDate不等于null 说明是考勤信息按钮 |
| | | if(ObjectUtils.isNotEmpty(attendDate)){ |
| | | // 上午时长、下午时长 |
| | | bussStartDuration += getStartDuration(attendanceBusinessTravel.getTravelStartTime(),attendance.getRosteringWorkEndTime(),attendance); |
| | | bussEndDuration += getEndDuration(attendanceBusinessTravel.getTravelStartTime(),attendance.getRosteringWorkEndTime(),attendance); |
| | | //调用方法修改考勤打卡状态 |
| | | updateAttendanceRecord(null,attendance,timeResult,Constant.ATTENDANCE_STATE_BUSINESS,day,bussStartDuration,bussEndDuration); |
| | | }else{ |
| | | // 上午or下午总时长 |
| | | bussDuration += getDuration(attendanceBusinessTravel.getTravelStartTime(),attendance.getRosteringWorkEndTime(),attendance,day); |
| | | updateAttendanceRecord(bussDuration,attendance,timeResult,Constant.ATTENDANCE_STATE_BUSINESS,day,null,null); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | 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,timeResult,Constant.ATTENDANCE_STATE_LEAVE,day,leaveStartDuration,leaveEndDuration); |
| | | }else{ |
| | | // 上午or下午总时长 |
| | | leaveDuration += getDuration(attendanceLeave.getLeaveStartTime(),attendanceLeave.getLeaveEndTime(),attendance,day); |
| | | //调用方法修改考勤打卡状态 |
| | | updateAttendanceRecord(leaveDuration,attendance,timeResult,Constant.ATTENDANCE_STATE_LEAVE,day,null,null); |
| | | } |
| | | } |
| | | } |
| | | return attendance; |
| | | } |
| | | |
| | | /** |
| | | * 获取上午/下午时长(请假、出差、外出) |
| | | * @param startDate |
| | | * @param endDate |
| | | * @param attendance |
| | | * @return |
| | | */ |
| | | public Double getDuration(Timestamp startDate, Timestamp endDate, Attendance attendance,Boolean day){ |
| | | Double duration = new Double(0.00); |
| | | // 上午总时长 |
| | | if(day){ |
| | | if(startDate.toLocalDateTime().isBefore(attendance.getRosteringLunchStartTime().toLocalDateTime()) && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0){ |
| | | Integer leaveSTime = calculateTimes(startDate.toLocalDateTime(), endDate.toLocalDateTime()); |
| | | duration += Double.valueOf(new BigDecimal((float) leaveSTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | if(startDate.toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0 && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0 || |
| | | startDate.toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0 && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) > 0 && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) <= 0){ |
| | | Integer leaveSTime = calculateTimes(startDate.toLocalDateTime(), attendance.getRosteringLunchStartTime().toLocalDateTime()); |
| | | duration += Double.valueOf(new BigDecimal((float) leaveSTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | }else{ |
| | | // 下午总时长 |
| | | if(startDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0 && endDate.toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) <= 0){ |
| | | Integer leaveETime = calculateTimes(startDate.toLocalDateTime(), endDate.toLocalDateTime()); |
| | | duration += Double.valueOf(new BigDecimal((float) leaveETime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | if(startDate.toLocalDateTime().isBefore(attendance.getRosteringLunchEndTime().toLocalDateTime()) && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0){ |
| | | Integer leaveETime = calculateTimes(attendance.getRosteringLunchEndTime().toLocalDateTime(), endDate.toLocalDateTime()); |
| | | duration += Double.valueOf(new BigDecimal((float) leaveETime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | } |
| | | return duration; |
| | | } |
| | | |
| | | /** |
| | | * 修改考勤记录打卡状态 |
| | | * @param attendance |
| | | * @param timeResult |
| | | * @param type |
| | | */ |
| | | public void updateAttendanceRecord(Double duration, Attendance attendance, String timeResult, 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()); |
| | | // 上午实际打卡时间到排班午休开始时间的时长 |
| | | Double result1 = new Double(0.00); |
| | | if(ObjectUtils.isNotEmpty(attendance.getActualWorkStartTime()) && attendance.getActualWorkStartTime().compareTo(attendance.getRosteringLunchStartTime()) <= 0){ |
| | | Integer actualTime = calculateTimes(attendance.getActualWorkStartTime().toLocalDateTime(), attendance.getRosteringLunchStartTime().toLocalDateTime()); |
| | | result1 = Double.valueOf(new BigDecimal((float) actualTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | // 下午休排班结束时间到下午排班结束时间的时长 |
| | | Integer workNoonTime = calculateTimes(attendance.getRosteringLunchEndTime().toLocalDateTime(), attendance.getRosteringWorkEndTime().toLocalDateTime()); |
| | | Double noonResult = Double.valueOf(new BigDecimal((float) workNoonTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | // 下午排班午休结束时间到下班打卡的实际时间的时长 |
| | | Double noonResult1 = new Double(0.00); |
| | | if(ObjectUtils.isNotEmpty(attendance.getActualWorkEndTime()) && attendance.getActualWorkEndTime().compareTo(attendance.getRosteringLunchEndTime()) >= 0){ |
| | | Integer actualTime = calculateTimes(attendance.getRosteringLunchEndTime().toLocalDateTime(), attendance.getActualWorkEndTime().toLocalDateTime()); |
| | | noonResult1 = Double.valueOf(new BigDecimal((float) actualTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | // 没打卡的情况下,修改考勤打卡状态 |
| | | if(timeResult.equals("NotSigned")){ |
| | | // duration为null说明是考勤信息按钮 |
| | | if(ObjectUtils.isEmpty(duration)){ |
| | | setAttendance(stDuration,null,result,null,attendance,type); |
| | | setAttendance(null,enDuration,null,noonResult,attendance,type); |
| | | }else{ |
| | | // 上午 |
| | | if(day){ |
| | | // 上午时长 >= 上午排班时间 改打卡状态 否则 缺时 |
| | | if(duration >= result){ |
| | | attendance.setStartClockResults(type); |
| | | attendance.setStartLocationResults(null); |
| | | }else{ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME); |
| | | } |
| | | }else{ |
| | | // 下午时长 >= 下午排班时间 改打卡状态 否则 缺时 |
| | | if(duration >= noonResult){ |
| | | attendance.setEndClockResults(type); |
| | | attendance.setEndLocationResults(null); |
| | | }else{ |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | // duration为null说明是考勤信息按钮 |
| | | if(ObjectUtils.isEmpty(duration)){ |
| | | setAttendanceStart(stDuration,null,result1,result,null,attendance,type); |
| | | setAttendanceStart(null,enDuration,noonResult1,null,noonResult,attendance,type); |
| | | }else{ |
| | | //打卡的情况,修改考勤状态 |
| | | if(day){ |
| | | if((duration + result1) >= result){ |
| | | attendance.setStartClockResults(type); |
| | | attendance.setStartLocationResults(null); |
| | | }else{ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME); |
| | | } |
| | | }else{ |
| | | if((duration + noonResult1) >= noonResult){ |
| | | attendance.setEndClockResults(type); |
| | | attendance.setEndLocationResults(null); |
| | | }else{ |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 计算时间差 |
| | | * @param start |
| | | * @param end |
| | | * @return |
| | | */ |
| | | public Integer calculateTimes(LocalDateTime start, LocalDateTime end){ |
| | | Integer time = 0; |
| | | Duration duration = null; |
| | | duration = Duration.between(start, start.toLocalDate().atTime(end.toLocalTime())); |
| | | Long StartSeconds = duration.getSeconds(); |
| | | time += StartSeconds.intValue(); |
| | | return time; |
| | | } |
| | | |
| | | /** |
| | | * 考勤状态 |
| | | * @param sysRostering |
| | | * @param timestamp |
| | | * @param type |
| | | * @return |
| | | */ |
| | | public String checkResult(SysRostering sysRostering, Timestamp timestamp, Integer type) { |
| | | String result = ObjectUtil.isEmpty(timestamp) ? Constant.ATTENDANCE_STATE_NOTSIGNED : Constant.ATTENDANCE_STATE_NORMAL; |
| | | if (type.equals(1)) { |
| | | if (timestamp.toLocalDateTime().toLocalTime().isAfter(sysRostering.getWorkStartTime())) { |
| | | result = Constant.ATTENDANCE_START_LATE; |
| | | } |
| | | } else { |
| | | if (timestamp.toLocalDateTime().toLocalTime().isBefore(sysRostering.getWorkEndTime())) { |
| | | result = Constant.ATTENDANCE_START_EARLY; |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 判断返回位置状态 |
| | | * @param locationResults |
| | | * @return |
| | | */ |
| | | public String setLocationResults(String locationResults){ |
| | | String result = ""; |
| | | if(locationResults.equals("Normal")) { |
| | | result = Constant.LOCATION_RESULTS_NORMAL; |
| | | } else if(locationResults.equals("Outside")){ |
| | | result = Constant.LOCATION_RESULTS_OUTSIDE; |
| | | } else if(locationResults.equals("NotSigned")){ |
| | | result = Constant.LOCATION_RESULTS_NOTSIGNED; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 查询用户 |
| | | */ |
| | | public List<User> getUserList(){ |
| | | List<User> userList = userRepository.findAllByEnabled(true); |
| | | return userList; |
| | | } |
| | | |
| | | /** |
| | | * 没打卡情况(考勤按钮) |
| | | * @param sDuration |
| | | * @param eDuration |
| | | * @param result |
| | | * @param noonResult |
| | | * @param attendance |
| | | * @param 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){ |
| | | attendance.setStartClockResults(type); |
| | | attendance.setStartLocationResults(null); |
| | | }else{ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME); |
| | | } |
| | | } |
| | | if(ObjectUtils.isEmpty(sDuration) && ObjectUtils.isEmpty(result)){ |
| | | // 下午时长 >= 下午排班时间 改打卡状态 否则 缺时 |
| | | if(eDuration >= noonResult){ |
| | | attendance.setEndClockResults(type); |
| | | attendance.setEndLocationResults(null); |
| | | }else{ |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 打卡情况(考勤按钮) |
| | | * @param sDuration |
| | | * @param eDuration |
| | | * @param result |
| | | * @param noonResult |
| | | * @param attendance |
| | | * @param 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); |
| | | attendance.setStartLocationResults(null); |
| | | }else{ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME); |
| | | } |
| | | } |
| | | if(ObjectUtils.isEmpty(sDuration) && eDuration > 0){ |
| | | if((eDuration + result1) >= noonResult){ |
| | | attendance.setEndClockResults(type); |
| | | attendance.setEndLocationResults(null); |
| | | }else{ |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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){ |
| | | Integer leaveSTime = calculateTimes(startDate.toLocalDateTime(), endDate.toLocalDateTime()); |
| | | duration += Double.valueOf(new BigDecimal((float) leaveSTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | if(startDate.toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0 && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0 || |
| | | startDate.toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) <= 0 && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchStartTime().toLocalDateTime()) > 0 && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) <= 0){ |
| | | Integer leaveSTime = calculateTimes(startDate.toLocalDateTime(), attendance.getRosteringLunchStartTime().toLocalDateTime()); |
| | | duration += Double.valueOf(new BigDecimal((float) leaveSTime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | return duration; |
| | | } |
| | | |
| | | public Double getEndDuration(Timestamp startDate, Timestamp endDate, Attendance attendance){ |
| | | Double duration = new Double(0.00); |
| | | // 下午总时长 |
| | | if(startDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0 && endDate.toLocalDateTime().compareTo(attendance.getRosteringWorkEndTime().toLocalDateTime()) <= 0){ |
| | | Integer leaveETime = calculateTimes(startDate.toLocalDateTime(), endDate.toLocalDateTime()); |
| | | duration += Double.valueOf(new BigDecimal((float) leaveETime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | if(startDate.toLocalDateTime().isBefore(attendance.getRosteringLunchEndTime().toLocalDateTime()) && endDate.toLocalDateTime().compareTo(attendance.getRosteringLunchEndTime().toLocalDateTime()) >= 0){ |
| | | Integer leaveETime = calculateTimes(attendance.getRosteringLunchEndTime().toLocalDateTime(), endDate.toLocalDateTime()); |
| | | duration += Double.valueOf(new BigDecimal((float) leaveETime / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | return duration; |
| | | } |
| | | |
| | | } |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.Attendance; |
| | | import me.zhengjie.modules.attendance.domain.*; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.dto.OapiDingTalkAccessToken; |
| | | import me.zhengjie.modules.quartz.service.OpaiDingTalkService; |
| | | import me.zhengjie.modules.quartz.service.dto.OapiDingTalkRecordResult; |
| | | import me.zhengjie.modules.quartz.service.impl.DingTalkServiceImpl; |
| | | import me.zhengjie.modules.system.domain.SysConfigHoliday; |
| | | import me.zhengjie.modules.system.domain.SysRostering; |
| | | import me.zhengjie.modules.system.domain.User; |
| | |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Duration; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | |
| | | * 钉钉定时任务(取考勤记录) |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Async |
| | | public class OapiDingTalkMethod { |
| | |
| | | |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | |
| | | private final OpaiDingTalkService opaiDingTalkService; |
| | | |
| | | private final SysRosteringRepository sysRosteringRepository; |
| | | |
| | | private final DingTalkServiceImpl dingTalkService; |
| | | |
| | | |
| | | /** |
| | | * 每天0点执行,新增用户考勤信息 |
| | |
| | | SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(todayDate); |
| | | //遍历在职员工向考勤记录添加数据 |
| | | for (User user : userList){ |
| | | if(ObjectUtils.isNotEmpty(user.getDingding())){ |
| | | //查询当前用户的排班 |
| | | SysRostering sysRostering = sysRosteringRepository.findByRosId(user.getSysRostering().getId()); |
| | | //查询考勤记录是否存在 |
| | |
| | | |
| | | attendance.setRosteringWorkStartTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(sysRostering.getWorkStartTime()))); |
| | | attendance.setRosteringWorkEndTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(sysRostering.getWorkEndTime()))); |
| | | attendance.setRosteringLunchStartTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(sysRostering.getLunchStartTime()))); |
| | | attendance.setRosteringLunchEndTime(Timestamp.valueOf(todayDate + " " + dateTimeFormatter.format(sysRostering.getLunchEndTime()))); |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 中午12点30或凌晨02:30执行定时任务 |
| | | * @throws Exception |
| | | * 定时任务调用 |
| | | */ |
| | | public void getDingTalkAttendanceListOfNoonOrNight() throws Exception { |
| | | //获取当前执行定时任务的时间 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); |
| | | String nowDate = sdf.format(new Date()); |
| | | //查询状态正常的员工 |
| | | List<User> userList = getUserList(); |
| | | //获取今天时间 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String todayDate = df.format(new Date()); |
| | | //获取昨天时间 |
| | | Calendar calYesterDay = Calendar.getInstance(); |
| | | calYesterDay.add(Calendar.DATE, -1); |
| | | String yesterday = df.format(calYesterDay.getTime()); |
| | | //获取钉钉 Token |
| | | OapiDingTalkAccessToken oapiDingTalkAccessToken = opaiDingTalkService.getAccessToken(); |
| | | // errcode = 0,表示正常返回 |
| | | if(0 == oapiDingTalkAccessToken.getErrcode()){ |
| | | //获取今天或昨天时间 |
| | | Calendar calDay = Calendar.getInstance(); |
| | | //标识 |
| | | Boolean day = false; |
| | | //定时任务的执行时间大于等于12:30说明是更新早上打卡的考勤记录 |
| | | if(sdf.parse(nowDate).compareTo(sdf.parse(Constant.DATE_TIME_NOON)) >= 0){ |
| | | calDay.setTime(Timestamp.valueOf(todayDate + " 00:00:00")); |
| | | day = true; |
| | | }else { |
| | | calDay.setTime(Timestamp.valueOf(yesterday + " 00:00:00")); |
| | | } |
| | | //遍历在职员工向考勤记录添加数据 |
| | | for (User user : userList) { |
| | | //用户钉钉id |
| | | List<String> userDinDingList = new ArrayList<>(); |
| | | //钉钉数据 |
| | | List<OapiDingTalkRecordResult> oapiDingTalkRecordResultList = new ArrayList<>(); |
| | | userDinDingList.add(user.getDingding()); |
| | | Attendance attendance = null; |
| | | //查询考勤记录是否存在 |
| | | if(day){ |
| | | attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), todayDate); |
| | | oapiDingTalkRecordResultList = opaiDingTalkService.getAttendanceList(oapiDingTalkRecordResultList, oapiDingTalkAccessToken.getAccessToken(), todayDate + " 00:00:00", userDinDingList, 0l, 50l); |
| | | }else{ |
| | | attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), yesterday); |
| | | oapiDingTalkRecordResultList = opaiDingTalkService.getAttendanceList(oapiDingTalkRecordResultList, oapiDingTalkAccessToken.getAccessToken(), yesterday + " 00:00:00", userDinDingList, 0l, 50l); |
| | | } |
| | | for (OapiDingTalkRecordResult oapiDingTalkRecordResult : oapiDingTalkRecordResultList) { |
| | | if ("NotSigned".equals(oapiDingTalkRecordResult.getTimeResult())) { |
| | | oapiDingTalkRecordResult.setUserCheckTime(null); |
| | | } |
| | | if ("OnDuty".equals(oapiDingTalkRecordResult.getCheckType())) { |
| | | //判断状态 |
| | | String result = ObjectUtils.isEmpty(oapiDingTalkRecordResult.getUserCheckTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : Constant.ATTENDANCE_STATE_NORMAL; |
| | | attendance.setStartClockResults(result); |
| | | attendance.setStartLocationResults(setLocationResults(oapiDingTalkRecordResult.getLocationResult())); |
| | | attendance.setActualWorkStartTime(oapiDingTalkRecordResult.getUserCheckTime()); |
| | | }else if("OffDuty".equals(oapiDingTalkRecordResult.getCheckType())){ |
| | | //判断状态 |
| | | String result = ObjectUtils.isEmpty(oapiDingTalkRecordResult.getUserCheckTime()) ? Constant.ATTENDANCE_STATE_NOTSIGNED : Constant.ATTENDANCE_STATE_NORMAL; |
| | | attendance.setEndClockResults(result); |
| | | attendance.setEndLocationResults(setLocationResults(oapiDingTalkRecordResult.getLocationResult())); |
| | | attendance.setActualWorkEndTime(oapiDingTalkRecordResult.getUserCheckTime()); |
| | | } |
| | | } |
| | | //如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(oapiDingTalkRecordResultList为空的情况下) |
| | | if(calDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)){ |
| | | //上午 |
| | | if(day && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST); |
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_REST); |
| | | attendance.setActualWorkStartTime(null); |
| | | }else if(!day && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)){ |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_REST); |
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_REST); |
| | | attendance.setActualWorkEndTime(null); |
| | | } |
| | | } |
| | | |
| | | // 判断修改考勤状态 |
| | | if(day){ |
| | | attendance = updateRecord(user,attendance,todayDate); |
| | | }else{ |
| | | attendance = updateRecord(user,attendance,yesterday); |
| | | } |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | }else{ |
| | | throw new BadRequestException(oapiDingTalkAccessToken.getErrmsg()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断返回位置状态 |
| | | * @param locationResults |
| | | * @return |
| | | */ |
| | | public String setLocationResults(String locationResults){ |
| | | String result = ""; |
| | | if(locationResults.equals("Normal")) { |
| | | result = Constant.LOCATION_RESULTS_NORMAL; |
| | | } else if(locationResults.equals("Outside")){ |
| | | result = Constant.LOCATION_RESULTS_OUTSIDE; |
| | | } else if(locationResults.equals("NotSigned")){ |
| | | result = Constant.LOCATION_RESULTS_NOTSIGNED; |
| | | } |
| | | return result; |
| | | public void getDingTalkAttendance() throws Exception { |
| | | dingTalkService.getDingTalkAttendanceListOfNoonOrNight(null,null); |
| | | } |
| | | |
| | | /** |
| | |
| | | List<User> userList = userRepository.findAllByEnabled(true); |
| | | return userList; |
| | | } |
| | | |
| | | /** |
| | | * 判断修改考勤状态 |
| | | * @param user |
| | | * @param date |
| | | */ |
| | | public Attendance updateRecord(User user, Attendance attendance, String date){ |
| | | //根据日期查询请假表 |
| | | |
| | | //根据日期查询外出表 |
| | | |
| | | //根据日期查询出差表 |
| | | return attendance; |
| | | } |
| | | |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, attendanceHours, getExceptional, getUserMakeUpCard } |
| | | export function addAttendanceInfo(data) { |
| | | return request({ |
| | | url: 'api/attendance/addAttendanceInfo', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, attendanceHours, getExceptional, getUserMakeUpCard, addAttendanceInfo } |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, getRemainingTime, approve } |
| | | export function revoke(data) { |
| | | return request({ |
| | | url: 'api/attendanceGoOut/revoke', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, getRemainingTime, approve, revoke } |
| | |
| | | }) |
| | | } |
| | | |
| | | export function getYearTimeLength() { |
| | | export function getYearTimeLength(data) { |
| | | return request({ |
| | | url: 'api/attendanceLeave/getYearTimeLength', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | |
| | | export const ATTENDANCE_STATE_LEAVE = 'attendance_state_leave' |
| | | // 考勤状态:休息 |
| | | export const ATTENDANCE_STATE_REST = 'attendance_state_rest' |
| | | // 考勤状态:缺时 |
| | | export const ATTENDANCE_STATE_LACK_OF_TIME = 'attendance_state_lack_of_time' |
| | | // 考勤状态:早退 |
| | | export const ATTENDANCE_STATE_EARLY = 'attendance_state_early' |
| | | // 考勤状态:迟到 |
| | | export const ATTENDANCE_STATE_LATE = 'attendance_state_late' |
| | | |
| | | // 考勤位置状态 |
| | | export const LOCATION_RESULTS = 'location_results' |
| | |
| | | // 请假状态:事假 |
| | | export const LEAVE_TYPE_COMPASSIONATE_LEAVE = 'leave_type_compassionate_leave' |
| | | // 请假状态:病假 |
| | | export const LEAVE_TYPE_SICk_leave = 'leave_type_sick_leave' |
| | | export const LEAVE_TYPE_SICK_LEAVE = 'leave_type_sick_leave' |
| | | // 请假状态:产假 |
| | | export const LEAVE_TYPE_maternity_leave = 'leave_type_maternity_leave' |
| | | export const LEAVE_TYPE_MATERNITY_LEAVE = 'leave_type_maternity_leave' |
| | | // 请假状态:婚假 |
| | | export const LEAVE_TYPE_marriage_holiday = 'leave_type_marriage_holiday' |
| | | export const LEAVE_TYPE_MARRIAGE_HOLIDAY = 'leave_type_marriage_holiday' |
| | | // 请假状态:丧假 |
| | | export const LEAVE_TYPE_bereavement_leave = 'leave_type_bereavement_leave' |
| | | export const LEAVE_TYPE_BEREAVEMENT_LEAVE = 'leave_type_bereavement_leave' |
| | | // 请假状态:哺乳假 |
| | | export const LEAVE_TYPE_lactation_leave = 'leave_type_lactation_leave' |
| | | export const LEAVE_TYPE_LACTATION_LEAVE = 'leave_type_lactation_leave' |
| | | |
| | | // 请假审批状态 |
| | | export const APPROVAL_STATUS = 'approval_status' |
| | |
| | | ATTENDANCE_STATE_BUSINESS, |
| | | ATTENDANCE_STATE_LEAVE, |
| | | ATTENDANCE_STATE_REST, |
| | | ATTENDANCE_STATE_LACK_OF_TIME, |
| | | ATTENDANCE_STATE_EARLY, |
| | | ATTENDANCE_STATE_LATE, |
| | | LOCATION_RESULTS, |
| | | LOCATION_RESULTS_NORMAL, |
| | | LOCATION_RESULTS_OUTSIDE, |
| | |
| | | LEAVE_TYPE, |
| | | LEAVE_TYPE_ANNUAL_LEAVE, |
| | | LEAVE_TYPE_COMPASSIONATE_LEAVE, |
| | | LEAVE_TYPE_SICk_leave, |
| | | LEAVE_TYPE_maternity_leave, |
| | | LEAVE_TYPE_marriage_holiday, |
| | | LEAVE_TYPE_bereavement_leave, |
| | | LEAVE_TYPE_lactation_leave, |
| | | LEAVE_TYPE_SICK_LEAVE, |
| | | LEAVE_TYPE_MATERNITY_LEAVE, |
| | | LEAVE_TYPE_MARRIAGE_HOLIDAY, |
| | | LEAVE_TYPE_BEREAVEMENT_LEAVE, |
| | | LEAVE_TYPE_LACTATION_LEAVE, |
| | | APPROVAL_STATUS, |
| | | APPROVAL_STATUS_UNDER_APPROVAL, |
| | | APPROVAL_STATUS_PASSED, |
| | |
| | | >出差 |
| | | </el-button> |
| | | </template> |
| | | <template slot="left"> |
| | | <el-button |
| | | slot="right" |
| | | size="mini" |
| | | type="info" |
| | | icon="el-icon-document" |
| | | class="filter-item" |
| | | style="margin-right: 7.5px" |
| | | :disabled="crud.selections.length == null" |
| | | @click="toSupplementInfo()" |
| | | >考勤信息补充 |
| | | </el-button> |
| | | </template> |
| | | </crudOperation> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | |
| | | <el-button :loading="bussSuccessLoading" type="primary" @click="submitBuss">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--考勤信息补充--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="attendVisible" :title="attendTitle" width="500px"> |
| | | <el-form ref="attform" :model="attform" :rules="attRules" size="small" label-width="100px"> |
| | | <el-form-item label="考勤时间" prop="attendTime"> |
| | | <el-date-picker |
| | | v-model="attform.attendTime" |
| | | type="date" |
| | | placeholder="选择日期时间" |
| | | style="width: 310px;" |
| | | value-format="yyyy-MM-dd" |
| | | align="right" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="审批员工" prop="userId"> |
| | | <el-select v-model="attform.userId" filterable clearable placeholder="请选择员工" style="width: 310px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <div class="attCss" style="color: red;">*选择日期和员工更新员工的考勤信息,未选择员工则更新所有人</div> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="closeCard">取消</el-button> |
| | | <el-button :loading="attendLoading" type="primary" @click="submitAttendance">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateBusiness" type="success">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateLeave" type="success">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictAttendanceStateRest" type="warning">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictEndanceStateLackOfTime" type="danger">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.startClockResults === dictStartLate" type="warning">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="rosteringWorkEndTime" min-width="140" label="排班工作结束时间" show-overflow-tooltip /> |
| | |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateBusiness" type="success">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateLeave" type="success">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictAttendanceStateRest" type="warning">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictEndanceStateLackOfTime" type="danger">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | <el-tag v-if="scope.row.endClockResults === dictStartEarly" type="warning">{{ dict.label[attendanceState][scope.row.endClockResults] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="dateType" min-width="100" label="日期类型" show-overflow-tooltip> |
| | |
| | | ], |
| | | dateType: [ |
| | | { required: true, message: '日期类型不能为空', trigger: 'change' } |
| | | ], |
| | | attendTime: [ |
| | | { required: true, message: '考勤日期不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | makeRules: { |
| | |
| | | { required: true, message: '出差时长不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | attRules: { |
| | | attendTime: [ |
| | | { required: true, message: '考勤日期不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | attendanceState: constant.ATTENDANCE_STATE, |
| | | lacationResules: constant.LOCATION_RESULTS, |
| | | dateType: constant.DATE_TYPE, |
| | |
| | | dictAttendanceStateBusiness: constant.ATTENDANCE_STATE_BUSINESS, |
| | | dictAttendanceStateLeave: constant.ATTENDANCE_STATE_LEAVE, |
| | | dictAttendanceStateRest: constant.ATTENDANCE_STATE_REST, |
| | | dictEndanceStateLackOfTime: constant.ATTENDANCE_STATE_LACK_OF_TIME, |
| | | dictStartEarly: constant.ATTENDANCE_STATE_EARLY, |
| | | dictStartLate: constant.ATTENDANCE_STATE_LATE, |
| | | users: [], |
| | | makeUpCardVisible: false, |
| | | makeUpCardLoading: false, |
| | |
| | | arrivalCity: null, |
| | | remarks: null |
| | | }, |
| | | attform: { |
| | | attendTime: null, |
| | | userId: null |
| | | }, |
| | | dictCardReplacementGoOn: constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON, |
| | | dictCardReplacementOffOn: constant.CARD_REPLACEMENT_DIFFERENTIATION_GOOFF, |
| | | dictCardApproveStatusReviewed: constant.CARD_APPROVE_STATUS_REVIEWED, |
| | |
| | | dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY, |
| | | bussVisible: false, |
| | | bussSuccessLoading: false, |
| | | bussTitle: '出差申请' } |
| | | bussTitle: '出差申请', |
| | | attendVisible: false, |
| | | attendLoading: false, |
| | | attendTitle: '考勤信息补充' } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | |
| | | }) |
| | | }) |
| | | }, |
| | | // 考勤信息补充画面打开 |
| | | toSupplementInfo() { |
| | | this.attendVisible = true |
| | | }, |
| | | // 考勤信息提交 |
| | | submitAttendance() { |
| | | this.$refs['attform'].validate(valid => { |
| | | if (!valid) { |
| | | return |
| | | } |
| | | this.attendLoading = true |
| | | var data = JSON.stringify({ |
| | | 'attendanceDate': this.attform.attendTime, |
| | | 'userId': this.attform.userId |
| | | }) |
| | | crudAttendance.addAttendanceInfo(data).then(res => { |
| | | this.attendVisible = false |
| | | this.attendLoading = false |
| | | this.crud.addSuccessNotify() |
| | | this.crud.toQuery() |
| | | if (this.$refs['attform']) { |
| | | this.$refs['attform'].resetFields() |
| | | } |
| | | }).catch(() => { |
| | | this.attendVisible = true |
| | | }) |
| | | }) |
| | | }, |
| | | // 关闭 |
| | | closeCard() { |
| | | if (this.$refs['makeUpCardForm']) { |
| | |
| | | if (this.$refs['bussForm']) { |
| | | this.$refs['bussForm'].resetFields() |
| | | } |
| | | if (this.$refs['attform']) { |
| | | this.$refs['attform'].resetFields() |
| | | } |
| | | this.crud.cancelCU() |
| | | this.makeUpCardVisible = false |
| | | this.goOutVisible = false |
| | | this.bussVisible = false |
| | | this.attendVisible = false |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | .attCss { |
| | | margin-left:25px; |
| | | } |
| | | </style> |
| | |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | | <el-form-item label="申请用户" prop="userId"> |
| | | <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="userRolesLevelMin == roleLevelOrdinary"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="审批用户" prop="approvalUserId"> |
| | | <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择审批员工" style="width: 370px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | |
| | | @click="toApprove(scope.row)" |
| | | >审核 |
| | | </el-button> |
| | | <el-popover |
| | | :ref="`popover_${scope.row.id}`" |
| | | width="200" |
| | | > |
| | | <p>确定撤销该记录?</p> |
| | | <div style="text-align: right; margin: 0"> |
| | | <el-button size="mini" type="primary" @click="canel(scope.row)">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button> |
| | | </div> |
| | | <el-button |
| | | v-if="scope.row.approvalUserId === $store.state.user.user.id" |
| | | slot="reference" |
| | | type="danger" |
| | | icon="el-icon-edit-outline" |
| | | size="mini" |
| | | :disabled="scope.row.approvalStatus === dictGoOutAppRev ? true : false" |
| | | >撤销 |
| | | </el-button> |
| | | </el-popover> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column v-if="checkPer(['admin','attendanceBusinessTravel:edit','attendanceBusinessTravel:del'])" label="操作" width="150px" align="center"> |
| | |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudUser from '@/api/system/user' |
| | | import { mapGetters } from 'vuex' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | |
| | | }, |
| | | rules: { |
| | | userId: [ |
| | | { required: true, message: '用户id不能为空', trigger: 'blur' } |
| | | { required: true, message: '用户不能为空', trigger: 'blur' } |
| | | ], |
| | | approvalUserId: [ |
| | | { required: true, message: '审批用户id不能为空', trigger: 'blur' } |
| | | { required: true, message: '审批用户不能为空', trigger: 'blur' } |
| | | ], |
| | | travelStartTime: [ |
| | | { required: true, message: '出差开始时间不能为空', trigger: 'blur' } |
| | |
| | | dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY, |
| | | dictLeaveTimeType: constant.LEAVE_TIME_TYPE, |
| | | makeUpCardVisible: false, |
| | | successLoading: false } |
| | | successLoading: false, |
| | | userRolesLevelMin: null, |
| | | // 角色级别:普通用户 |
| | | roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY } |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ |
| | | 'user' |
| | | ]) |
| | | }, |
| | | created() { |
| | | this.getUsers() |
| | |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | return true |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | // 判断用户最大角色级别是否是角色级别:普通用户 |
| | | if (this.userRolesLevelMin === this.roleLevelOrdinary) { |
| | | // 表单赋值 |
| | | this.form.userId = this.user.id |
| | | } |
| | | }, |
| | | // 查询员工 |
| | | getUsers() { |
| | |
| | | } |
| | | }) |
| | | }, |
| | | // 撤消功能 |
| | | revoke(data) { |
| | | crudAttendanceBusinessTravel.revoke(data).then(res => { |
| | | this.crud.refresh() |
| | | this.$message({ type: 'success', message: '撤销成功' }) |
| | | this.$refs[`popover_${data.id}`].showPopper = false |
| | | }).catch((error) => { |
| | | this.$message({ type: 'error', message: error.response.data.message }) |
| | | }) |
| | | if (this.$refs['form']) { |
| | | this.$refs['form'].resetFields() |
| | | } |
| | | this.crud.cancelCU() |
| | | }, |
| | | // 关闭 |
| | | closeCard() { |
| | | if (this.$refs['form']) { |
| | |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | | <el-form-item label="申请人" prop="userId"> |
| | | <el-select v-model="form.userId" clearable filterable placeholder="请选择申请人" style="width: 310px;"> |
| | | <el-form-item label="申请用户" prop="userId"> |
| | | <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="userRolesLevelMin == roleLevelOrdinary"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="审批者" prop="approvalUserId"> |
| | | <el-select v-model="form.approvalUserId" clearable filterable placeholder="请选择审批者" style="width: 310px;"> |
| | | <el-select v-model="form.approvalUserId" clearable filterable placeholder="请选择审批者" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | |
| | | v-model="form.cardReplacementTime" |
| | | type="datetime" |
| | | placeholder="选择补卡时间" |
| | | style="width: 310px;" |
| | | style="width: 370px;" |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | align="right" |
| | | default-time="09:00:00" |
| | |
| | | import crudAttendanceCardreplacement from '@/api/attendance/attendanceCardreplacement' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import crudUser from '@/api/system/user' |
| | | import { mapGetters } from 'vuex' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | |
| | | dictCardApproveStatusReviewed: constant.CARD_APPROVE_STATUS_REVIEWED, |
| | | dictCardApproveStatusAgree: constant.CARD_APPROVE_STATUS_AGREE, |
| | | dictCardApproveStatusRefuse: constant.CARD_APPROVE_STATUS_REFUSE, |
| | | dictCardReplacement: constant.CARD_REPLACEMENT_DIFFERENTIATION } |
| | | dictCardReplacement: constant.CARD_REPLACEMENT_DIFFERENTIATION, |
| | | userRolesLevelMin: null, |
| | | // 角色级别:普通用户 |
| | | roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY } |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ |
| | | 'user' |
| | | ]) |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | this.getUsers() |
| | | return true |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | // 判断用户最大角色级别是否是角色级别:普通用户 |
| | | if (this.userRolesLevelMin === this.roleLevelOrdinary) { |
| | | // 表单赋值 |
| | | this.form.userId = this.user.id |
| | | } |
| | | }, |
| | | // 查询员工 |
| | | getUsers() { |
| | | crudUser.getAll().then(res => { |
| | |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | | <el-form-item label="申请用户" prop="userId"> |
| | | <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="userRolesLevelMin == roleLevelOrdinary"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="审批员工" prop="approvalUserId"> |
| | | <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择审批员工" style="width: 370px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | |
| | | <el-table-column prop="approvalDescription" label="审批说明" show-overflow-tooltip /> |
| | | <el-table-column prop="remarks" label="备注" show-overflow-tooltip /> |
| | | <el-table-column prop="createTime" label="创建时间" min-width="140" show-overflow-tooltip /> |
| | | <el-table-column label="审核操作" min-width="120px" align="center"> |
| | | <el-table-column label="审核操作" min-width="200px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <el-button |
| | | v-if="scope.row.approvalUserId === $store.state.user.user.id" |
| | |
| | | @click="toApprove(scope.row)" |
| | | >审核 |
| | | </el-button> |
| | | <el-popover |
| | | :ref="`popover_${scope.row.id}`" |
| | | width="200" |
| | | > |
| | | <p>确定撤销该记录?</p> |
| | | <div style="text-align: right; margin: 0"> |
| | | <el-button size="mini" type="primary" @click="canel(scope.row)">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button> |
| | | </div> |
| | | <el-button |
| | | v-if="scope.row.approvalUserId === $store.state.user.user.id" |
| | | slot="reference" |
| | | type="danger" |
| | | icon="el-icon-edit-outline" |
| | | size="mini" |
| | | :disabled="scope.row.approvalStatus === dictGoOutAppRev ? true : false" |
| | | >撤销 |
| | | </el-button> |
| | | </el-popover> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column v-if="checkPer(['admin','attendanceGoOut:edit','attendanceGoOut:del'])" label="操作" width="150px" align="center"> |
| | |
| | | import crudAttendanceGoOut from '@/api/attendance/attendanceGoOut' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import { mapGetters } from 'vuex' |
| | | import crudUser from '@/api/system/user' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | |
| | | }, |
| | | rules: { |
| | | userId: [ |
| | | { required: true, message: '用户id不能为空', trigger: 'change' } |
| | | { required: true, message: '用户不能为空', trigger: 'change' } |
| | | ], |
| | | approvalUserId: [ |
| | | { required: true, message: '审批用户id不能为空', trigger: 'change' } |
| | | { required: true, message: '审批用户不能为空', trigger: 'change' } |
| | | ], |
| | | outStartTime: [ |
| | | { required: true, message: '外出开始时间不能为空', trigger: 'change' } |
| | |
| | | dictGoOutAgree: constant.GO_OUT_APPROVE_STATUS_AGREE, |
| | | dictGoOutReturn: constant.GO_OUT_APPROVE_STATUS_REFUSE, |
| | | makeUpCardVisible: false, |
| | | successLoading: false } |
| | | successLoading: false, |
| | | userRolesLevelMin: null, |
| | | // 角色级别:普通用户 |
| | | roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY } |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ |
| | | 'user' |
| | | ]) |
| | | }, |
| | | created() { |
| | | this.getUsers() |
| | |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | return true |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | // 判断用户最大角色级别是否是角色级别:普通用户 |
| | | if (this.userRolesLevelMin === this.roleLevelOrdinary) { |
| | | // 表单赋值 |
| | | this.form.userId = this.user.id |
| | | } |
| | | }, |
| | | // 查询员工 |
| | | getUsers() { |
| | |
| | | } |
| | | }) |
| | | }, |
| | | // 撤消功能 |
| | | revoke(data) { |
| | | crudAttendanceGoOut.revoke(data).then(res => { |
| | | this.crud.refresh() |
| | | this.$message({ type: 'success', message: '撤销成功' }) |
| | | this.$refs[`popover_${data.id}`].showPopper = false |
| | | }).catch((error) => { |
| | | this.$message({ type: 'error', message: error.response.data.message }) |
| | | }) |
| | | if (this.$refs['form']) { |
| | | this.$refs['form'].resetFields() |
| | | } |
| | | this.crud.cancelCU() |
| | | }, |
| | | // 关闭 |
| | | closeCard() { |
| | | if (this.$refs['form']) { |
| | |
| | | } |
| | | this.crud.cancelCU() |
| | | this.makeUpCardVisible = false |
| | | }, |
| | | // 取消 |
| | | canel(data) { |
| | | this.$refs[`popover_${data.id}`].showPopper = false |
| | | } |
| | | } |
| | | } |
| | |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | | <el-form-item label="申请用户" prop="userId"> |
| | | <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="userRolesLevelMin == roleLevelOrdinary" @change="checkLeaveTime"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="审批员工" prop="approvalUserId"> |
| | | <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择审批员工" style="width: 370px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | |
| | | <script> |
| | | import crudAttendanceLeave from '@/api/attendance/attendanceLeave' |
| | | import crudUser from '@/api/system/user' |
| | | import { mapGetters } from 'vuex' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | |
| | | download: ['admin', 'attendanceLeave:download'] |
| | | }, |
| | | rules: { |
| | | userId: [ |
| | | { required: true, message: '申请用户不能为空', trigger: 'change' } |
| | | ], |
| | | approvalUserId: [ |
| | | { required: true, message: '审批用户ID不能为空', trigger: 'change' } |
| | | { required: true, message: '审批用户不能为空', trigger: 'change' } |
| | | ], |
| | | leaveType: [ |
| | | { required: true, message: '请假类型不能为空', trigger: 'change' } |
| | |
| | | dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY, |
| | | yearTimeLenght: null, |
| | | makeUpCardVisible: false, |
| | | successLoading: false } |
| | | successLoading: false, |
| | | userRolesLevelMin: null, |
| | | // 角色级别:普通用户 |
| | | roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY } |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ |
| | | 'user' |
| | | ]) |
| | | }, |
| | | created() { |
| | | this.getUsers() |
| | | this.getUserTimes() |
| | | // this.getUserTimes() |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | return true |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | // 判断用户最大角色级别是否是角色级别:普通用户 |
| | | if (this.userRolesLevelMin === this.roleLevelOrdinary) { |
| | | // 表单赋值 |
| | | this.form.userId = this.user.id |
| | | } |
| | | }, |
| | | // 钩子:在编辑之前执行 |
| | | [CRUD.HOOK.beforeToEdit]() { |
| | | this.getUserTimes() |
| | | }, |
| | | // [CRUD.HOOK.beforeToEdit]() { |
| | | // this.getUserTimes() |
| | | // }, |
| | | // 钩子:在提交表单之后执行 |
| | | [CRUD.HOOK.afterSubmit]() { |
| | | this.getUserTimes() |
| | | }, |
| | | // [CRUD.HOOK.afterSubmit]() { |
| | | // this.getUserTimes() |
| | | // }, |
| | | // 查询员工 |
| | | getUsers() { |
| | | crudUser.getAll().then(res => { |
| | |
| | | if (this.form.leaveType == null || this.form.leaveStartTime == null || this.form.leaveEndTime == null) { |
| | | return |
| | | } |
| | | // 获取年假剩余时长 |
| | | crudAttendanceLeave.getYearTimeLength((this.form.userId == null ? 1 : this.form.userId)).then(res => { |
| | | console.log(res) |
| | | this.yearTimeLenght = res |
| | | }) |
| | | // 通过后台计算时长 |
| | | var data = JSON.stringify({ |
| | | 'leaveType': this.form.leaveType, |
| | |
| | | }) |
| | | }, |
| | | // 查询员工剩余年假时长 |
| | | getUserTimes() { |
| | | crudAttendanceLeave.getYearTimeLength().then(res => { |
| | | console.log(res) |
| | | this.yearTimeLenght = res |
| | | }) |
| | | }, |
| | | // getUserTimes() { |
| | | // crudAttendanceLeave.getYearTimeLength().then(res => { |
| | | // console.log(res) |
| | | // this.yearTimeLenght = res |
| | | // }) |
| | | // }, |
| | | // 审批页面赋值 |
| | | toApprove(data) { |
| | | this.makeUpCardVisible = true |