liupeng %!s(int64=5) %!d(string=hai) anos
pai
achega
5ca714e61c

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

@@ -98,25 +98,16 @@ public class WXCpDepartUtil {
 		return depatmentId;
 	}
 	
-	public static Long createOrUpdate(Long id, Long parentId, String name) throws WxErrorException {
-		if(id == null) {
-			Map<String, Long> map = getChildDepartMap(parentId);
-			Long depatmentId = map.get(name);
-			if (depatmentId == null) {
-				WxCpDepart depart = new WxCpDepart();
-				depart.setName(name);
-				depart.setParentId(parentId);
-				depatmentId = departService.create(depart);
-			}
-			return depatmentId;
-		} else {
+	public static Long createOrUpdate(Long parentId, String name) throws WxErrorException {
+		Map<String, Long> map = getChildDepartMap(parentId);
+		Long depatmentId = map.get(name);
+		if (depatmentId == null) {
 			WxCpDepart depart = new WxCpDepart();
-			depart.setId(id);
 			depart.setName(name);
 			depart.setParentId(parentId);
-			departService.update(depart);
-			return id;
+			depatmentId = departService.create(depart);
 		}
+		return depatmentId;
 	}
 
 	public static List<WxCpDepart> getAllChildDeparts(Long id) throws WxErrorException {

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

@@ -157,7 +157,7 @@ public class SapOrgService extends BaseService {
 	}
 
 	private Long getWxDepartId(SapOrg org, Long parentId) throws WxErrorException {
-		return WXCpDepartUtil.createOrUpdate(org.getWxDepartId(), parentId, org.getSapName());
+		return WXCpDepartUtil.createOrUpdate(parentId, org.getSapName());
 	}
 
 	@SuppressWarnings("unchecked")