liupeng 5 年之前
父節點
當前提交
da44a4eedb

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

@@ -19,15 +19,15 @@ import me.chanjar.weixin.cp.bean.WxCpUser.ExternalAttribute;
  */
 public class WXCpUserUtil {
 
-	public static String createOrUpdateForTest(String userId, String name, String[] subCompanyList, String[] departmentList,
-			String position, String mobile, String gender, String email) {
-		WxCpUser user = getById(userId);
+	public static String createOrUpdateForTest(String userId, String name, String[] subCompanyList,
+			String[] departmentList, String position, String mobile, String gender, String email) {
+		WxCpUser user = getByIdOrEmail(userId, email);
 		try {
 			if (user == null) {
 				user = getUserForTest(userId, name, subCompanyList, departmentList, position, mobile, gender, email);
 				userService.create(user);
 			} else {
-				user = getUserForTest(userId, name, subCompanyList, departmentList, position, mobile, gender, email);
+				user = getUserForTest(user.getUserId(), name, subCompanyList, departmentList, position, mobile, gender, email);
 				userService.update(user);
 			}
 			return WebConstants.SUCCESS;
@@ -39,14 +39,14 @@ public class WXCpUserUtil {
 	public static String createOrUpdate(String userId, String name, Long[] firstOrgWxDepartIdList,
 			Long[] secondOrgWxDepartIdList, Long[] thirdOrgWxDepartIdList, Long[] fourthOrgWxDepartIdList,
 			String position, String mobile, String gender, String email, String telephone, String firstOrgName) {
-		WxCpUser user = getById(userId);
+		WxCpUser user = getByIdOrEmail(userId, email);
 		try {
 			if (user == null) {
 				user = getUser(userId, name, firstOrgWxDepartIdList, secondOrgWxDepartIdList, thirdOrgWxDepartIdList,
 						fourthOrgWxDepartIdList, position, mobile, gender, email, telephone, firstOrgName);
 				userService.create(user);
 			} else {
-				user = getUser(userId, name, firstOrgWxDepartIdList, secondOrgWxDepartIdList, thirdOrgWxDepartIdList,
+				user = getUser(user.getUserId(), name, firstOrgWxDepartIdList, secondOrgWxDepartIdList, thirdOrgWxDepartIdList,
 						fourthOrgWxDepartIdList, position, mobile, gender, email, telephone, firstOrgName);
 				userService.update(user);
 			}
@@ -130,21 +130,25 @@ public class WXCpUserUtil {
 		return user;
 	}
 
-	public static WxCpUser getById(String userId) {
+	public static WxCpUser getByIdOrEmail(String userId, String email) {
 		try {
-			return userService.getById(userId);
+			WxCpUser user = userService.getById(userId);
+			if (user == null) {
+				user = userService.getById(email);
+			}
+			return user;
 		} catch (WxErrorException e) {
 			return null;
 		}
 	}
-	
+
 	public static void delete(String userId) {
 		try {
 			userService.delete(userId);
 		} catch (WxErrorException e) {
 		}
 	}
-	
+
 	public static List<WxCpUser> listByDepartment(Long departId) throws WxErrorException {
 		return userService.listByDepartment(departId, true, 0);
 	}

+ 4 - 1
code/sapparent/sapservice/src/main/java/org/fouram/service/TaskService.java

@@ -60,7 +60,7 @@ public class TaskService extends BaseService {
 		// 更新用户头像
 		List<SapUser> successUsers = sapUserService.selectSuccessList();
 		for (SapUser sapUser : successUsers) {
-			WxCpUser user = WXCpUserUtil.getById(sapUser.getPersonId());
+			WxCpUser user = WXCpUserUtil.getByIdOrEmail(sapUser.getPersonId(), sapUser.getEmail());
 			if (user != null && StringUtils.isNotBlank(user.getAvatar())) {
 				sapUser.setAvatar(user.getAvatar());
 				sapUserService.updateAvatar(sapUser);
@@ -70,6 +70,9 @@ public class TaskService extends BaseService {
 		// 查询禁用企业微信账号
 		List<SapUser> unableSapUsers = sapUserService.selectDeleteList();
 		LoggerUtil.info("SAP禁用数据->" + unableSapUsers.size());
+		if (unableSapUsers.size() > 0) {
+
+		}
 
 		// 部分数据插入微信未成功,处理数据后,重新插入
 		List<SapUser> unSyncSapUsers = sapUserService.selectUnSyncList();