From 093fc57beccecbf8d5d51d45edb3ae484e8f8ffd Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 06 十一月 2026 16:32:52 +0800
Subject: [PATCH] fix(hrm/transfer): 调岗申请按所选员工创建并补齐校验提示

---
 yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java
index fb14bad..9482aed 100644
--- a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java
+++ b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java
@@ -2,8 +2,10 @@
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
 import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
 import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO;
@@ -85,18 +87,25 @@
         if (Objects.equals(createReqVO.getTargetPostId(), createReqVO.getCurrentPostId())) {
             throw exception(TRANSFER_APPLICATION_SAME_POST);
         }
-        // 3. 鐢熸垚鐢宠鍗曞彿
-        String no = generateUniqueNo();
-        // 4. 璁剧疆鐢宠浜轰俊鎭�
-        Long userId = createReqVO.getUserId();
-        if (userId == null) {
-            userId = getCurrentUserId();
-        }
-        AdminUserRespDTO user = adminUserApi.getUser(userId);
+        // 3. 纭畾琚皟宀楀憳宸ワ紙鏈寚瀹氭椂榛樿褰撳墠鐧诲綍鐢ㄦ埛锛�
+        Long userId = createReqVO.getUserId() != null ? createReqVO.getUserId() : getLoginUserId();
+        AdminUserRespDTO user = userId != null ? adminUserApi.getUser(userId) : null;
         if (user == null) {
-            userId = getCurrentUserId();
+            throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_NOT_EXISTS.getCode(),
+                    String.format("璋冨矖鐢宠澶辫触锛氭墍閫夊憳宸ユ湭鍏宠仈鏈夋晥鐨勭郴缁熻处鍙凤紙鐢ㄦ埛缂栧彿 %s锛夈�傝鍒般�屽憳宸ョ鐞嗐�嶇‘璁よ鍛樺伐宸茬粦瀹氳处鍙蜂笖璐﹀彿鏈仠鐢ㄥ悗閲嶆柊閫夋嫨銆�", userId));
         }
-        // 5. 鎻掑叆
+        // 4. 鏍¢獙鍘熼儴闂ㄣ�佸師宀椾綅锛堣〃瀛楁闈炵┖锛涘憳宸ユ。妗堢己澶辨椂缁欏嚭鍙墽琛屾彁绀猴紝閬垮厤鐩存帴鎶涙暟鎹簱寮傚父锛�
+        if (createReqVO.getCurrentDeptId() == null) {
+            throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_DEPT_EMPTY.getCode(),
+                    String.format("璋冨矖鐢宠澶辫触锛氬憳宸%s]鏈缃儴闂紝鏃犳硶纭畾鍘熼儴闂ㄣ�傝鍏堝埌銆屽憳宸ョ鐞嗐�嶇紪杈戣鍛樺伐妗f琛ュ叏閮ㄩ棬锛屽啀閲嶆柊鍙戣捣璋冨矖鐢宠銆�", user.getNickname()));
+        }
+        if (createReqVO.getCurrentPostId() == null) {
+            throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_POST_EMPTY.getCode(),
+                    String.format("璋冨矖鐢宠澶辫触锛氬憳宸%s]鏈缃矖浣嶏紝鏃犳硶纭畾鍘熷矖浣嶃�傝鍏堝埌銆屽憳宸ョ鐞嗐�嶇紪杈戣鍛樺伐妗f琛ュ叏宀椾綅锛屽啀閲嶆柊鍙戣捣璋冨矖鐢宠銆�", user.getNickname()));
+        }
+        // 5. 鐢熸垚鐢宠鍗曞彿
+        String no = generateUniqueNo();
+        // 6. 鎻掑叆
         HrmTransferApplicationDO application = BeanUtils.toBean(createReqVO, HrmTransferApplicationDO.class);
         application.setNo(no);
         application.setUserId(userId);
@@ -107,8 +116,8 @@
         return application.getId();
     }
 
-    private Long getCurrentUserId() {
-        return 1L;
+    private Long getLoginUserId() {
+        return SecurityFrameworkUtils.getLoginUserId();
     }
 
     private String generateUniqueNo() {

--
Gitblit v1.9.3