|
|
@@ -257,7 +257,7 @@ public class GetWechatData extends BaseClass implements Runnable {
|
|
|
dbConnect.runSqlUpdate(listSql);
|
|
|
|
|
|
getDepartmentUsers(3, 1, positionSeller, "业务员");
|
|
|
- getDepartmentUsers(144, 1, positionAgent, "经销商");
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
|
@@ -305,6 +305,54 @@ public class GetWechatData extends BaseClass implements Runnable {
|
|
|
|
|
|
dbConnect.runSqlUpdate(listSql);
|
|
|
|
|
|
+ getDepartmentUsers2(144, 1, positionAgent, "经销商");
|
|
|
+
|
|
|
+ return array;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取企业微信部门成员列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public JSONArray getDepartmentUsers2(int id, int fetch_child, String[] strArray, String fusertype) {
|
|
|
+ String url = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=" + WechatDock_Enterprise.getAccessToken() + "&department_id=" + id + "&fetch_child=" + fetch_child;
|
|
|
+ String response = new WebRequest().doGet(url);
|
|
|
+ JSONObject object = JSONObject.parseObject(response);
|
|
|
+ JSONArray array = object.getJSONArray("userlist");
|
|
|
+ ArrayList<String> listSql = new ArrayList<>();
|
|
|
+ for (Object obj : array) {
|
|
|
+ JSONObject jsonObject = (JSONObject) obj;
|
|
|
+ String position = jsonObject.getString("position");
|
|
|
+ String name = jsonObject.getString("name");
|
|
|
+ String userid = jsonObject.getString("userid");
|
|
|
+ int main_department = jsonObject.getIntValue("main_department");
|
|
|
+ String mobile = jsonObject.getString("mobile");
|
|
|
+ String open_userid = jsonObject.getString("open_userid");
|
|
|
+ List<String> list = Arrays.asList(strArray);
|
|
|
+ if (list.contains(position)) {
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "插入微信成员");
|
|
|
+ sqlFactory.addParameter("tuserid", createTableID("tuser", "tuserid"));
|
|
|
+ sqlFactory.addParameter("wechat_depid", main_department);
|
|
|
+ sqlFactory.addParameter("wechat_userid", userid);
|
|
|
+ sqlFactory.addParameter("wechat_name", name);
|
|
|
+ sqlFactory.addParameter("wechat_open_userid", open_userid);
|
|
|
+ sqlFactory.addParameter("wechat_mobile", mobile);
|
|
|
+ sqlFactory.addParameter("wechat_position", position);
|
|
|
+ sqlFactory.addParameter("fusertype", fusertype);
|
|
|
+ listSql.add(sqlFactory.getSQL());
|
|
|
+ if (listSql.size() > 50) {
|
|
|
+ System.err.println("start user...");
|
|
|
+ dbConnect.runSqlUpdate(listSql);
|
|
|
+ listSql.clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(listSql);
|
|
|
+
|
|
|
if (fusertype.equals("经销商")) {
|
|
|
updateAgents(array);
|
|
|
}
|