From 135af1bd4c62f73dd3430d9588ae3f62ff2702fd Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Sat, 20 Jan 2024 14:15:09 +0800
Subject: [PATCH] 空值判断

---
 src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
index 8e50a25..e808b88 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -196,8 +196,14 @@
 			//机构名称拼接
 			userVOS.forEach(userVO -> {
 				if (null!=userVO.getDeptId()) {
+					String deptIds = "";
+					if (userVO.getAncestors() != null){
+						deptIds = userVO.getAncestors()+","+userVO.getDeptId();
+					}else{
+						deptIds = userVO.getDeptId();
+					}
 
-					List<String> deptNameList = SysCache.getDeptNames(userVO.getAncestors()+","+userVO.getDeptId());
+					List<String> deptNameList = SysCache.getDeptNames(deptIds);
 
 					userVO.setFullDeptName(getFullDeptName(deptNameList));
 
@@ -230,14 +236,16 @@
 
 	private String getFullDeptName(List<String> deptNameList) {
 		String fullDeptName = "";
-		if (deptNameList.size()>1){
-			//多级
-			if (StringUtil.isNotBlank(deptNameList.get(0))){
-				//本市保安公司  xxx  xxx xxx
-				String first = deptNameList.get(0);
-				if (first.equals("本市保安公司") || first.equals("保安培训学校") || first.equals("自招保安单位") || first.equals("武装押运公司") || first.equals("分公司") || first.equals("其他")){
-					deptNameList.remove(0);
-					fullDeptName = StringUtil.join(deptNameList,",");
+		if (deptNameList != null){
+			if (deptNameList.size()>1){
+				//多级
+				if (StringUtil.isNotBlank(deptNameList.get(0))){
+					//本市保安公司  xxx  xxx xxx
+					String first = deptNameList.get(0);
+					if (first.equals("本市保安公司") || first.equals("保安培训学校") || first.equals("自招保安单位") || first.equals("武装押运公司") || first.equals("分公司") || first.equals("其他")){
+						deptNameList.remove(0);
+						fullDeptName = StringUtil.join(deptNameList,",");
+					}
 				}
 			}
 		}

--
Gitblit v1.9.3