From f83950d292a8933390b3b4b516f90f21a9946c68 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 27 八月 2026 11:41:47 +0800
Subject: [PATCH] fix  修复逻辑缺陷

---
 yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceExceptionServiceImpl.java |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceExceptionServiceImpl.java b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceExceptionServiceImpl.java
index 625be8e..54eb8ab 100644
--- a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceExceptionServiceImpl.java
+++ b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceExceptionServiceImpl.java
@@ -12,6 +12,8 @@
 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;
@@ -43,10 +45,18 @@
     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);
@@ -61,7 +71,10 @@
 
     @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());
@@ -69,7 +82,10 @@
 
     @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);
     }

--
Gitblit v1.9.3