|
|
@ -2,9 +2,14 @@ package com.dreamchaser.depository_manage.config; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.dreamchaser.depository_manage.config.QyWx_template_card.*; |
|
|
import com.dreamchaser.depository_manage.config.QyWx_template_card.*; |
|
|
import com.dreamchaser.depository_manage.entity.UserByPort; |
|
|
import com.dreamchaser.depository_manage.entity.UserByPort; |
|
|
|
|
|
import com.dreamchaser.depository_manage.entity.qywxDepartment; |
|
|
|
|
|
import com.dreamchaser.depository_manage.entity.qywxLabel; |
|
|
|
|
|
import com.dreamchaser.depository_manage.entity.qywxLabelUser; |
|
|
|
|
|
import com.dreamchaser.depository_manage.exception.MyException; |
|
|
import com.dreamchaser.depository_manage.utils.HttpUtils; |
|
|
import com.dreamchaser.depository_manage.utils.HttpUtils; |
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
import lombok.Data; |
|
|
import lombok.Data; |
|
|
@ -153,4 +158,73 @@ public class QyWxConfig { |
|
|
return jsonObject; |
|
|
return jsonObject; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取企业微信标签成员
|
|
|
|
|
|
public static List<String> getQyWxLabelUserList(String UserAgent){ |
|
|
|
|
|
// 获取当前token
|
|
|
|
|
|
String tempToken = GetQYWXToken(UserAgent); |
|
|
|
|
|
String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/tag/list?access_token=%s",tempToken); |
|
|
|
|
|
String get = HttpUtils.doGet(url); |
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(get); |
|
|
|
|
|
Integer errcode = jsonObject.getInteger("errcode"); |
|
|
|
|
|
List<String> userIdList = new ArrayList<>(); |
|
|
|
|
|
if(Integer.compare(0,errcode) == 0){ |
|
|
|
|
|
JSONArray taglist = jsonObject.getJSONArray("taglist"); |
|
|
|
|
|
for (Object o : taglist) { |
|
|
|
|
|
qywxLabel qywxLabel = JSONObject.toJavaObject((JSON) o, qywxLabel.class); |
|
|
|
|
|
if(qywxLabel.getTagname().contains("仓储中心负责人")){ |
|
|
|
|
|
List<qywxLabelUser> qyWxLabelUserList = getQyWxLabelUserList(tempToken, qywxLabel.getTagid().toString()); |
|
|
|
|
|
for (qywxLabelUser qywxLabelUser : qyWxLabelUserList) { |
|
|
|
|
|
userIdList.add(qywxLabelUser.getUserid()); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
throw new MyException("获取标签列表失败"); |
|
|
|
|
|
} |
|
|
|
|
|
return userIdList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static List<qywxLabelUser> getQyWxLabelUserList(String tempToken,String TAGID){ |
|
|
|
|
|
String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/tag/get?access_token=%s&tagid=%s",tempToken,TAGID); |
|
|
|
|
|
String get = HttpUtils.doGet(url); |
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(get); |
|
|
|
|
|
Integer errcode = jsonObject.getInteger("errcode"); |
|
|
|
|
|
List<qywxLabelUser> userList = new ArrayList<>(); |
|
|
|
|
|
if(Integer.compare(errcode,0) == 0){ |
|
|
|
|
|
JSONArray userlist = jsonObject.getJSONArray("userlist"); |
|
|
|
|
|
for (Object o : userlist) { |
|
|
|
|
|
qywxLabelUser qywxLabelUser = JSONObject.toJavaObject((JSON) o, qywxLabelUser.class); |
|
|
|
|
|
userList.add(qywxLabelUser); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
throw new MyException("获取标签成员失败"); |
|
|
|
|
|
} |
|
|
|
|
|
return userList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于获取当前企业微信部门详情 |
|
|
|
|
|
* @param UserAgent |
|
|
|
|
|
* @param id |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public static qywxDepartment getQyWxDepartment(String UserAgent,Integer id){ |
|
|
|
|
|
String tempToken = GetQYWXToken(UserAgent); |
|
|
|
|
|
String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/department/get?access_token=%s&id=%s",tempToken,id); |
|
|
|
|
|
String get = HttpUtils.doGet(url); |
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(get); |
|
|
|
|
|
Integer errcode = jsonObject.getInteger("errcode"); |
|
|
|
|
|
if(Integer.compare(errcode,0) == 0){ |
|
|
|
|
|
qywxDepartment qywxDepartment = JSONObject.toJavaObject(jsonObject.getJSONObject("department"), qywxDepartment.class); |
|
|
|
|
|
return qywxDepartment; |
|
|
|
|
|
}else{ |
|
|
|
|
|
throw new MyException("获取部门信息失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|