| | |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceExceptionSaveReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.attendance.HrmAttendanceExceptionDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.attendance.HrmAttendanceExceptionMapper; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.hrm.dal.redis.HrmNoRedisDAO; |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO; |
| | | import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | /** |
| | | * 考勤异常申请 Service 实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @Validated |
| | |
| | | @Resource |
| | | private BpmProcessInstanceApi bpmProcessInstanceApi; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | @Resource |
| | | private BpmProcessDefinitionService bpmProcessDefinitionService; |
| | | @Resource |
| | | private HrmEmployeeService employeeService; |
| | | |
| | | @Override |
| | | public Long createAttendanceException(HrmAttendanceExceptionSaveReqVO createReqVO) { |
| | | HrmEmployeeDO employee = employeeService.getEmployeeByUserId( |
| | | cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId()); |
| | | if (employee == null) { |
| | | throw exception(EMPLOYEE_NOT_EXISTS); |
| | | } |
| | | HrmAttendanceExceptionDO attendanceException = BeanUtils.toBean(createReqVO, HrmAttendanceExceptionDO.class); |
| | | attendanceException.setUserId(employee.getId()).setDeptId(employee.getDeptId()); |
| | | attendanceException.setNo(generateNo()); |
| | | attendanceException.setStatus(HrmAuditStatusEnum.DRAFT.getStatus()); |
| | | attendanceExceptionMapper.insert(attendanceException); |
| | | storageAttachmentApi.bindAttachments("file", "hrm_attendance_exception", |
| | | attendanceException.getId(), createReqVO.getBlobIds()); |
| | | return attendanceException.getId(); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void updateAttendanceException(HrmAttendanceExceptionSaveReqVO updateReqVO) { |
| | | validateAttendanceExceptionExists(updateReqVO.getId()); |
| | | HrmAttendanceExceptionDO attendanceException = validateAttendanceExceptionExists(updateReqVO.getId()); |
| | | if (!HrmAuditStatusEnum.DRAFT.getStatus().equals(attendanceException.getStatus())) { |
| | | throw exception(ATTENDANCE_EXCEPTION_UPDATE_FAIL_NOT_DRAFT); |
| | | } |
| | | HrmAttendanceExceptionDO updateObj = BeanUtils.toBean(updateReqVO, HrmAttendanceExceptionDO.class); |
| | | attendanceExceptionMapper.updateById(updateObj); |
| | | storageAttachmentApi.updateAttachments("file", "hrm_attendance_exception", updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAttendanceException(Long id) { |
| | | validateAttendanceExceptionExists(id); |
| | | HrmAttendanceExceptionDO attendanceException = validateAttendanceExceptionExists(id); |
| | | if (!HrmAuditStatusEnum.DRAFT.getStatus().equals(attendanceException.getStatus())) { |
| | | throw exception(ATTENDANCE_EXCEPTION_DELETE_FAIL_NOT_DRAFT); |
| | | } |
| | | storageAttachmentApi.deleteAttachmentsByRecord("hrm_attendance_exception", id); |
| | | attendanceExceptionMapper.deleteById(id); |
| | | } |
| | | |