| | |
| | | |
| | | 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.Calculate; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | 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.domain.*; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.SysConfigHolidayRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | |
| | | 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(); |
| | | //除超管、总经理只能修改自己信息 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能修改自己的记录"); |
| | | } |
| | | } |
| | | |
| | | attendanceRepository.save(attendance); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().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 (!Long.valueOf(attendance.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能删除自己的记录"); |
| | | } |
| | | } |
| | | |
| | | attendanceRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 补卡获取异常信息 |
| | | * @param Number |
| | | */ |
| | | @Override |
| | | public void getExceptional(String Number) { |
| | | if(Number.equals("1")){ |
| | | throw new BadRequestException("上班无需补卡"); |
| | | }else{ |
| | | throw new BadRequestException("下班无需补卡"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 补卡判断登录人 |
| | | */ |
| | | @Override |
| | | public void getUserMakeUpCard(String userId) { |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().iterator().next(); |
| | | //除超管、总经理只能补自己的卡 |
| | | if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if (!Long.valueOf(userId).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能补自己的卡"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<AttendanceDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |