|
|
|
@ -271,11 +271,10 @@ public class DingTalkUtil {
|
|
|
|
|
Record rOrg = getOrgByOrgName(orgName);
|
|
|
|
|
int bureauId = rOrg.getInt("org_id");
|
|
|
|
|
int sortId = rOrg.getInt("sort_id");
|
|
|
|
|
//获取部门信息
|
|
|
|
|
deptList.clear();
|
|
|
|
|
//获取数据库中记录的钉钉端的dept_id,但不一定准确存在,需要继续判断一下
|
|
|
|
|
long DT_BureauId = getDtDeptId(bureauId);
|
|
|
|
|
|
|
|
|
|
//获取部门信息
|
|
|
|
|
deptList.clear();
|
|
|
|
|
JSONObject jRes = getDeptInfo(accessToken, DT_BureauId);
|
|
|
|
|
if (jRes.getLong("errcode") > 0) {
|
|
|
|
|
DT_BureauId = createDept(accessToken, orgName, 1, sortId);
|
|
|
|
@ -404,12 +403,11 @@ public class DingTalkUtil {
|
|
|
|
|
//System.out.println(rsp.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void updatePerson(String access_token, String person_id, String person_name, String tel) throws ApiException {
|
|
|
|
|
public static void updatePerson(String access_token, String person_id, String person_name) throws ApiException {
|
|
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/update");
|
|
|
|
|
OapiV2UserUpdateRequest req = new OapiV2UserUpdateRequest();
|
|
|
|
|
req.setUserid(person_id);
|
|
|
|
|
req.setName(person_name);
|
|
|
|
|
req.setMobile(tel);
|
|
|
|
|
OapiV2UserUpdateResponse rsp = client.execute(req, access_token);
|
|
|
|
|
System.out.println(rsp.getBody());
|
|
|
|
|
}
|
|
|
|
@ -482,6 +480,10 @@ public class DingTalkUtil {
|
|
|
|
|
Record rOrg = getOrgByOrgName(orgName);
|
|
|
|
|
int bureauId = rOrg.getInt("org_id");
|
|
|
|
|
|
|
|
|
|
//获取数据库中记录的钉钉端的dept_id,但不一定准确存在,需要继续判断一下
|
|
|
|
|
long DT_BureauId = getDtDeptId(bureauId);
|
|
|
|
|
getBureauPerson(accessToken, DT_BureauId);
|
|
|
|
|
|
|
|
|
|
Set<String> keysOfA = new HashSet<>();
|
|
|
|
|
Map<String, JSONObject> mapOfA = new HashMap<>();
|
|
|
|
|
Set<String> keysOfB = new HashSet<>();
|
|
|
|
@ -509,6 +511,7 @@ public class DingTalkUtil {
|
|
|
|
|
String tel = r.getStr("tel");
|
|
|
|
|
if (StrKit.isBlank(tel) || !PhoneUtil.isMobile(tel)) {
|
|
|
|
|
tel = ChineseMobileNumberGenerator.getInstance().generate();//生成一个随机临时测试用的手机号
|
|
|
|
|
tel = "14" + tel.substring(2);//以14段开头,避开已存在的号码
|
|
|
|
|
}
|
|
|
|
|
keysOfB.add(String.valueOf(person_id));
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
@ -527,8 +530,14 @@ public class DingTalkUtil {
|
|
|
|
|
delPerson(accessToken, key);
|
|
|
|
|
} else {
|
|
|
|
|
// key在A和B中都存在
|
|
|
|
|
updatePerson(accessToken, key, mapOfB.get(key).getString("person_name"), mapOfB.get(key).getString("tel"));
|
|
|
|
|
CommonUtil.Print("暴力修改钉钉与云平台间部门人员姓名、手机号!,person_name=" + mapOfB.get(key).getString("person_name"));
|
|
|
|
|
String aName = mapOfA.get(key).getString("person_name");
|
|
|
|
|
String bName = mapOfB.get(key).getString("person_name");
|
|
|
|
|
if (!aName.equals(bName)) {
|
|
|
|
|
updatePerson(accessToken, key, mapOfB.get(key).getString("person_name"));
|
|
|
|
|
CommonUtil.Print("发现钉钉与云平台间部门人员姓名不一致,将修改,person_name=" + mapOfB.get(key).getString("person_name"));
|
|
|
|
|
} else {
|
|
|
|
|
CommonUtil.Print("钉钉与云平台间部门人员姓名一致,无需修改,person_name=" + mapOfB.get(key).getString("person_name"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|