From 0f4aa5957957d9124e88da4490fac60da5324058 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期六, 14 十一月 2026 10:43:34 +0800
Subject: [PATCH] fix(excel): 兼容模板表头必填星号并完善部门/岗位导入校验
---
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java
index 79da07a..6c73c18 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java
@@ -14,7 +14,9 @@
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
+import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils;
import com.google.common.annotations.VisibleForTesting;
+import com.mzt.logapi.starter.annotation.LogRecord;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@@ -27,6 +29,7 @@
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
+import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*;
/**
* 閮ㄩ棬 Service 瀹炵幇绫�
@@ -240,6 +243,8 @@
}
@Override
+ @LogRecord(type = SYSTEM_DEPT_TYPE, subType = SYSTEM_DEPT_IMPORT_SUB_TYPE, bizNo = "0",
+ success = SYSTEM_DEPT_IMPORT_SUCCESS)
public DeptImportRespVO importDeptList(List<DeptImportExcelVO> importDepts, boolean isUpdateSupport) {
if (CollUtil.isEmpty(importDepts)) {
throw exception(DEPT_IMPORT_LIST_IS_EMPTY);
@@ -259,7 +264,24 @@
importDepts.sort(Comparator.comparingInt(dept -> StrUtil.isEmpty(dept.getParentPath()) ? 0 : dept.getParentPath().split("/").length));
// 3. 閬嶅巻瀵煎叆
- for (DeptImportExcelVO importDept : importDepts) {
+ for (int i = 0; i < importDepts.size(); i++) {
+ DeptImportExcelVO importDept = importDepts.get(i);
+ // 3.0 鏍¢獙蹇呭~椤癸細鍚嶇О涓虹┖浼氱敓鎴� null 鐨� Map key锛屽鑷村搷搴斿簭鍒楀寲澶辫触锛�
+ // 椤哄簭銆佺姸鎬佷负绌轰細瑙﹀彂鏁版嵁搴撻潪绌虹害鏉燂紝鐩存帴鎶涚郴缁熷紓甯�
+ String rowLabel = StrUtil.blankToDefault(importDept.getName(), "绗� " + (i + 1) + " 鏉¤褰�");
+ if (StrUtil.isBlank(importDept.getName())) {
+ respVO.getFailureDeptNames().put(rowLabel, "閮ㄩ棬鍚嶇О涓嶈兘涓虹┖锛岃琛ュ叏 Excel 鐨勩�岄儴闂ㄥ悕绉般�嶅垪鍚庨噸鏂板鍏�");
+ continue;
+ }
+ if (importDept.getSort() == null) {
+ respVO.getFailureDeptNames().put(rowLabel, "鏄剧ず椤哄簭涓嶈兘涓虹┖锛岃琛ュ叏 Excel 鐨勩�屾樉绀洪『搴忋�嶅垪鍚庨噸鏂板鍏�");
+ continue;
+ }
+ if (importDept.getStatus() == null) {
+ respVO.getFailureDeptNames().put(rowLabel, "鐘舵�佹湭濉啓鎴栦笉鏄�屽紑鍚�/鍏抽棴銆嶏紝璇峰~鍐� Excel 鐨勩�岀姸鎬併�嶅垪鍚庨噸鏂板鍏�");
+ continue;
+ }
+
// 3.1 鑾峰彇鐖堕儴闂� ID
Long parentId = DeptDO.PARENT_ID_ROOT;
if (StrUtil.isNotEmpty(importDept.getParentPath())) {
@@ -302,6 +324,9 @@
fullPathDeptIdMap.put(myFullPath, newDept.getId());
}
+ // 璁板綍瀵煎叆缁撴灉姹囨�伙紝渚� @LogRecord 鐨� success 鏂囨寮曠敤
+ OperateLogUtils.putImportSummary(respVO.getCreateDeptNames(), respVO.getUpdateDeptNames(),
+ respVO.getFailureDeptNames());
return respVO;
}
--
Gitblit v1.9.3