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 | 54 +++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 41 insertions(+), 13 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 d63e58a..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;
@@ -19,6 +21,7 @@
import cn.iocoder.yudao.module.hrm.enums.HrmTransferTypeEnum;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.PostApi;
+import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@@ -47,7 +50,7 @@
/**
* 璋冨矖鐢宠 Service 瀹炵幇绫�
*
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
*/
@Service
@Validated
@@ -69,6 +72,8 @@
@Resource
private BpmCategoryService bpmCategoryService;
@Resource
+ private StorageAttachmentApi storageAttachmentApi;
+ @Resource
private BpmProcessDefinitionService bpmProcessDefinitionService;
@Override
@@ -82,28 +87,37 @@
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);
application.setStatus(HrmAuditStatusEnum.DRAFT.getStatus());
transferApplicationMapper.insert(application);
+ storageAttachmentApi.bindAttachments("file", "hrm_transfer_application",
+ application.getId(), createReqVO.getBlobIds());
return application.getId();
}
- private Long getCurrentUserId() {
- return 1L;
+ private Long getLoginUserId() {
+ return SecurityFrameworkUtils.getLoginUserId();
}
private String generateUniqueNo() {
@@ -129,6 +143,7 @@
}
HrmTransferApplicationDO updateObj = BeanUtils.toBean(updateReqVO, HrmTransferApplicationDO.class);
transferApplicationMapper.updateById(updateObj);
+ storageAttachmentApi.updateAttachments("file", "hrm_transfer_application", updateReqVO.getId(), updateReqVO.getBlobIds());
}
@Override
@@ -137,6 +152,7 @@
if (!Objects.equals(application.getStatus(), HrmAuditStatusEnum.DRAFT.getStatus())) {
throw exception(TRANSFER_APPLICATION_UPDATE_FAIL_NOT_DRAFT);
}
+ storageAttachmentApi.deleteAttachmentsByRecord("hrm_transfer_application", id);
transferApplicationMapper.deleteById(id);
}
@@ -170,6 +186,7 @@
fillPostNames(respVO, application);
respVO.setTransferTypeName(HrmTransferTypeEnum.getNameByStatus(application.getTransferType()));
respVO.setStatusName(HrmAuditStatusEnum.getNameByStatus(application.getStatus()));
+ respVO.setAttachmentList(storageAttachmentApi.listAttachments("hrm_transfer_application", id));
return respVO;
}
@@ -249,6 +266,17 @@
if (ObjUtil.notEqual(application.getStatus(), HrmAuditStatusEnum.DRAFT.getStatus())) {
throw exception(TRANSFER_APPLICATION_SUBMIT_FAIL_NOT_DRAFT);
}
+ // 鍏ㄥ眬鍏嶅鎵癸細涓氬姟鏍¢獙閫氳繃鍚庣洿鎺ユ墽琛屽鎵归�氳繃閫昏緫锛屾棤闇�娴佺▼妯″瀷銆�
+ if (bpmProcessInstanceApi.isGlobalAutoApprove()) {
+ transferApplicationMapper.updateById(HrmTransferApplicationDO.builder()
+ .id(id)
+ .processInstanceId("")
+ .status(HrmAuditStatusEnum.PROCESS.getStatus())
+ .build());
+ updateTransferApplicationAuditStatus(id, HrmAuditStatusEnum.APPROVE.getStatus());
+ return;
+ }
+
validateApproveCategoryAndProcessDefinition();
ProcessDefinition processDefinition = bpmProcessDefinitionService.getActiveProcessDefinition(processDefinitionKey);
if (processDefinition == null) {
--
Gitblit v1.9.3