Przeglądaj źródła

名字判断更新

yuanzhi_kuang 5 miesięcy temu
rodzic
commit
17251c6db7

+ 52 - 18
GDYSL/websrc/com/kingdee/shr/customer/gtiit/osf/SynADService.java

@@ -313,7 +313,7 @@ public class SynADService implements IHRMsfService {
 					.append("OR ((pep.CFGtiitemail = 'No' OR pep.CFGtiitemail IS NULL) AND f.fnumber = 'FULL') ")
 					//202505  增加.“是否GT邮箱"选项为"No"或为空,且为兼职员工,并且 work mal不包含 @stu.edu.cn 时,该员工信息需同步至AD
 					.append("OR ((pep.CFGtiitemail = 'No' OR pep.CFGtiitemail IS NULL) AND f.fnumber = 'PART'  AND pe.femail  NOT LIKE '%@stu.edu.cn%' ) ")
-					
+
 					.append("OR ((pep.CFGtiitemail = 'No' OR pep.CFGtiitemail IS NULL) ")
 					.append("AND f.fnumber = 'PART' ")
 					.append("AND (post.fname_l1 NOT LIKE '%Student Assistant%' OR post.fname_l1 LIKE '%ERP%')))");
@@ -421,7 +421,7 @@ public class SynADService implements IHRMsfService {
 					.append("OR ((b.cfgtiitemail = 'No' OR b.cfgtiitemail IS NULL) AND fullp.fnumber = 'FULL') ")
 					//202505  增加.“是否GT邮箱"选项为"No"或为空,且为兼职员工,并且 work mal不包含 @stu.edu.cn 时,该员工信息需同步至AD
 					.append("OR ((b.cfgtiitemail = 'No' OR b.cfgtiitemail IS NULL) AND fullp.fnumber = 'PART'  AND b.femail  NOT LIKE '%@stu.edu.cn%' ) ")
-					
+
 					.append("OR ((b.cfgtiitemail = 'No' OR b.cfgtiitemail IS NULL) ")
 					.append("AND fullp.fnumber = 'PART' ")
 					.append("AND post.fname_l1 NOT LIKE '%Student Assistant%')) ");
@@ -527,6 +527,10 @@ public class SynADService implements IHRMsfService {
 		return formatter.format(Long.valueOf(date.getTime()));
 	}
 
+
+	 
+
+
 	/**
 	 * 转换显示名称格式
 	 * @param disPlayName 原始显示名称
@@ -535,26 +539,56 @@ public class SynADService implements IHRMsfService {
 	 * @return 转换后的显示名称
 	 */
 	private String convert(String disPlayName, String giveName, String sn) {
-		String lowerCase = disPlayName.toLowerCase();
-		String newDisplayName = "";
-		if (lowerCase.contains(giveName.toLowerCase()))
-			newDisplayName = lowerCase.replace(giveName.toLowerCase(), upperGiveName(giveName));
-		if (newDisplayName.contains(sn.toLowerCase()))
-			newDisplayName = newDisplayName.replace(sn.toLowerCase(), sn.toUpperCase());
-		return newDisplayName;
+		if (disPlayName == null || giveName == null || sn == null) {
+			return disPlayName;
+		}
+
+		// 分割显示名称为单词部分
+		String[] parts = disPlayName.split("(?<=\\W)|(?=\\W)");
+		StringBuilder newDisplayName = new StringBuilder();
+
+		for (String part : parts) {
+			// 检查是否是完整匹配的姓(不区分大小写)
+			if (part.equalsIgnoreCase(sn)) {
+				newDisplayName.append(sn.toUpperCase());
+			}
+			// 检查是否是完整匹配的名(不区分大小写)
+			else if (part.equalsIgnoreCase(giveName)) {
+				newDisplayName.append(upperGiveName(giveName));
+			}
+			// 检查是否是名的一部分(需要处理大小写)
+			else if (giveName.toLowerCase().contains(part.toLowerCase())) {
+				// 处理名中的子部分
+				String processedPart = processPartialName(part, giveName);
+				newDisplayName.append(processedPart);
+			}
+			// 其他情况保持原样
+			else {
+				newDisplayName.append(part);
+			}
+		}
+
+		return newDisplayName.toString();
 	}
 
-	/**
-	 * 将名字首字母大写
-	 * @param giveName 名字
-	 * @return 处理后的名字
-	 */
 	private String upperGiveName(String giveName) {
-		String[] giveNames = giveName.toLowerCase().split(" ");
-		String newGiveName = "";
+		String[] giveNames = giveName.split("\\s+");
+		StringBuilder newGiveName = new StringBuilder();
 		for (String name : giveNames) {
-			newGiveName = newGiveName + Character.toUpperCase(name.charAt(0)) + name.substring(1) + " ";
+			if (!name.isEmpty()) {
+				newGiveName.append(Character.toUpperCase(name.charAt(0)))
+						.append(name.substring(1).toLowerCase())
+						.append(" ");
+			}
 		}
-		return newGiveName.trim();
+		return newGiveName.toString().trim();
+	}
+
+	private String processPartialName(String partial, String fullName) {
+		int index = fullName.toLowerCase().indexOf(partial.toLowerCase());
+		if (index == -1) return partial;
+
+		// 从完整名中获取正确的大小写形式
+		return fullName.substring(index, index + partial.length());
 	}
 }