liupeng 5 年之前
父節點
當前提交
7d9929cbd9

+ 8 - 8
code/sapparent/sapservice/src/main/java/org/fouram/core/plugin/weixin/cp/util/WXCpDepartUtil.java

@@ -72,18 +72,18 @@ public class WXCpDepartUtil {
 		return create(thirdOrgId, fourthOrg);
 	}
 
-	public static Long create(Long firstOrgId, Long secondOrgId, Long thirdOrgId, Long fourthOrgId)
+	public static Long create(Long firstOrgWxId, Long secondOrgWxId, Long thirdOrgWxId, Long fourthOrgWxId)
 			throws WxErrorException {
-		if (secondOrgId == null) {
-			return firstOrgId;
+		if (secondOrgWxId == null) {
+			return firstOrgWxId;
 		}
-		if (thirdOrgId == null) {
-			return secondOrgId;
+		if (thirdOrgWxId == null) {
+			return secondOrgWxId;
 		}
-		if (fourthOrgId == null) {
-			return thirdOrgId;
+		if (fourthOrgWxId == null) {
+			return thirdOrgWxId;
 		}
-		return fourthOrgId;
+		return fourthOrgWxId;
 	}
 
 	private static Long create(Long parentId, String depatment) throws WxErrorException {

+ 15 - 15
code/sapparent/sapservice/src/main/java/org/fouram/core/plugin/weixin/cp/util/WXCpUserUtil.java

@@ -35,18 +35,18 @@ public class WXCpUserUtil {
 		}
 	}
 
-	public static String createOrUpdate(String userId, String name, String[] firstOrgList, String[] secondOrgList,
-			String[] thirdOrgList, String[] fourthOrgList, String position, String mobile, String gender,
-			String email, String telephone) {
+	public static String createOrUpdate(String userId, String name, Long[] firstOrgWxIdList,
+			Long[] secondOrgWxIdList, Long[] thirdOrgWxIdList, Long[] fourthOrgWxIdList, String position,
+			String mobile, String gender, String email, String telephone) {
 		WxCpUser user = getById(userId);
 		try {
 			if (user == null) {
-				user = getUser(userId, name, firstOrgList, secondOrgList, thirdOrgList, fourthOrgList, position, mobile,
-						gender, email, telephone);
+				user = getUser(userId, name, firstOrgWxIdList, secondOrgWxIdList, thirdOrgWxIdList, fourthOrgWxIdList,
+						position, mobile, gender, email, telephone);
 				userService.create(user);
 			} else {
-				user = getUser(userId, name, firstOrgList, secondOrgList, thirdOrgList, fourthOrgList, position, mobile,
-						gender, email, telephone);
+				user = getUser(userId, name, firstOrgWxIdList, secondOrgWxIdList, thirdOrgWxIdList, fourthOrgWxIdList,
+						position, mobile, gender, email, telephone);
 				userService.update(user);
 			}
 			return "SUCCESS";
@@ -55,9 +55,9 @@ public class WXCpUserUtil {
 		}
 	}
 
-	private static WxCpUser getUser(String userId, String name, String[] firstOrgList, String[] secondOrgList,
-			String[] thirdOrgList, String[] fourthOrgList, String position, String mobile, String gender, String email, String telephone)
-			throws WxErrorException {
+	private static WxCpUser getUser(String userId, String name, Long[] firstOrgWxIdList, Long[] secondOrgWxIdList,
+			Long[] thirdOrgWxIdList, Long[] fourthOrgWxIdList, String position, String mobile, String gender,
+			String email, String telephone) throws WxErrorException {
 		WxCpUser user = new WxCpUser();
 		if (Tools.notEmpty(userId)) {
 			user.setUserId(userId);
@@ -65,10 +65,10 @@ public class WXCpUserUtil {
 		if (Tools.notEmpty(name)) {
 			user.setName(name);
 		}
-		Long[] departIds = new Long[firstOrgList.length];
-		for (int i = 0; i < firstOrgList.length; i++) {
-			departIds[i] = WXCpDepartUtil.create(firstOrgList[i], secondOrgList[i], thirdOrgList[i],
-					fourthOrgList[i]);
+		Long[] departIds = new Long[firstOrgWxIdList.length];
+		for (int i = 0; i < firstOrgWxIdList.length; i++) {
+			departIds[i] = WXCpDepartUtil.create(firstOrgWxIdList[i], secondOrgWxIdList[i], thirdOrgWxIdList[i],
+					fourthOrgWxIdList[i]);
 		}
 		user.setDepartIds(departIds);
 		if (Tools.notEmpty(position)) {
@@ -87,7 +87,7 @@ public class WXCpUserUtil {
 			user.setTelephone(telephone);
 		}
 		user.setToInvite(false);
-		ExternalAttribute attribute = ExternalAttribute.builder().name("所属公司").type(0).value(firstOrgList[0]).build();
+		ExternalAttribute attribute = ExternalAttribute.builder().name("所属公司").type(0).value(firstOrgName).build();
 		user.addExternalAttr(attribute);
 		return user;
 	}