| | |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceDto; |
| | | 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.User; |
| | | import me.zhengjie.modules.system.repository.RoleRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | |
| | | public Map<String,Object> queryAll(AttendanceCardreplacementQueryCriteria criteria, Pageable pageable){ |
| | | //查询当前登录人 |
| | | User user = userRepository.findById(SecurityUtils.getCurrentUserId()).get(); |
| | | //当前登录人角色包含职员就添加查询条件只能查询自己申请的或审批人是自己的记录 |
| | | if (user.getRoles().contains(roleRepository.findById(Constant.JOB_STAFF).get())) { |
| | | criteria.setApprover(SecurityUtils.getCurrentUserId()); |
| | | } |
| | | Page<AttendanceCardreplacement> page = attendanceCardreplacementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | //将实体转换为Dto(重写) |
| | | Function<AttendanceCardreplacement, AttendanceCardreplacementDto> func = new Function<AttendanceCardreplacement,AttendanceCardreplacementDto >(){ |
| | |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),attDate.substring(0,10)); |
| | | if(ObjectUtils.isEmpty(attendance)){ |
| | | throw new BadRequestException("考勤记录不存在"); |
| | | } |
| | | |
| | | //获取当前登入人信息 |
| | | 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("只能修改自己的记录"); |
| | | } |
| | | } |
| | | //审核通过或者退回不能删除 |
| | | if(attendanceCardreplacement.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE) || attendanceCardreplacement.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){ |
| | | throw new BadRequestException("审核通过或退回的不能进行修改"); |
| | | } |
| | | |
| | | attendanceCardreplacementRepository.save(attendanceCardreplacement); |
| | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | //获取当前登入人信息 |
| | | User user = userRepository.getOne(SecurityUtils.getCurrentUserId()); |
| | | Job job = user.getJobs().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 (!Long.valueOf(attendanceCardreplacement.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){ |
| | | throw new BadRequestException("只能删除自己的记录"); |
| | | } |
| | | } |
| | | //审核通过或者退回不能删除 |
| | | if(attendanceCardreplacement.get().getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE) || attendanceCardreplacement.get().getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){ |
| | | throw new BadRequestException("审核通过或退回的不能进行删除"); |
| | | } |
| | | attendanceCardreplacementRepository.deleteById(id); |
| | | } |
| | | } |