liupeng 4 years ago
parent
commit
f0edb855c8

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

@@ -5,8 +5,10 @@ import static org.fouram.core.plugin.weixin.cp.core.WXCpBase.departService;
 import java.util.List;
 import java.util.Map;
 
+import org.fouram.core.util.LoggerUtil;
 import org.fouram.core.util.Tools;
 
+import com.alibaba.fastjson.JSON;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
@@ -21,10 +23,8 @@ import me.chanjar.weixin.cp.bean.WxCpDepart;
 public class WXCpDepartUtil {
 
 	public static void main(String[] args) throws WxErrorException {
-		List<WxCpDepart> departs = getAllChildDeparts(1L);
-		for (WxCpDepart depart : departs) {
-			System.out.println(depart);
-		}
+//		{"id":228,"name":"财务计划与分析","parentid":223}
+		createOrUpdate(228L, 223L, "财务计划与分析");
 	}
 
 	public static List<WxCpDepart> getChildDeparts(Long id) throws WxErrorException {
@@ -111,6 +111,7 @@ public class WXCpDepartUtil {
 			return depatmentId;
 		} else {
 			Map<String, Long> map = getChildDepartMap(parentId);
+			LoggerUtil.info("createOrUpdate->" + JSON.toJSONString(map));
 			Long depatmentId = map.get(name);
 			if(!id.equals(depatmentId)) {
 				WxCpDepart depart = new WxCpDepart();