@ -1,6 +1,7 @@
package com.dsideal.FengHuang.Util ;
import cn.binarywang.tools.generator.ChineseMobileNumberGenerator ;
import cn.hutool.core.util.PhoneUtil ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import com.aliyun.dingtalkoauth2_1_0.models.* ;
@ -11,6 +12,7 @@ import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.* ;
import com.dingtalk.api.response.* ;
import com.jfinal.kit.Kv ;
import com.jfinal.kit.StrKit ;
import com.jfinal.plugin.activerecord.Db ;
import com.jfinal.plugin.activerecord.Record ;
import com.jfinal.plugin.redis.Redis ;
@ -446,11 +448,17 @@ public class DingTalkUtil {
}
}
//TODO
public static void delBureauPerson ( String accessToken , long dingtalk_dept_id ) throws ApiException {
DingTalkUtil . getBureauPerson ( accessToken , dingtalk_dept_id ) ;
for ( int i = 0 ; i < DingTalkUtil . personList . size ( ) ; i + + ) {
String userid = DingTalkUtil . personList . get ( i ) . getStr ( "userid" ) ;
delPerson ( accessToken , userid ) ;
}
}
public static void syncPerson ( String accessToken , String orgName ) throws ApiException {
Record rOrg = getOrgByOrgName ( orgName ) ;
int bureauId = rOrg . getInt ( "org_id" ) ;
int sortId = rOrg . getInt ( "sort_id" ) ;
List < Record > list = DingTalkUtil . getDeptPerson ( bureauId ) ;
for ( int i = 0 ; i < list . size ( ) ; i + + ) {
@ -458,16 +466,16 @@ public class DingTalkUtil {
long deptId = r . getLong ( "dingtalk_dept_id" ) ;
int person_id = r . getInt ( "person_id" ) ;
String person_name = r . getStr ( "person_name" ) ;
String tel = ChineseMobileNumberGenerator . getInstance ( ) . generate ( ) ;
DingTalkUtil . createPerson ( accessToken , String . valueOf ( deptId ) , String . valueOf ( person_id ) , person_name , tel , "教师" ) ;
CommonUtil . Print ( "成功加入人员:" + person_name ) ;
String tel = r . getStr ( "tel" ) ;
if ( StrKit . isBlank ( tel ) | | ! PhoneUtil . isMobile ( tel ) ) {
tel = ChineseMobileNumberGenerator . getInstance ( ) . generate ( ) ; //生成一个随机临时测试用的手机号
}
//DingTalkUtil.createPerson(accessToken, String.valueOf(deptId), String.valueOf(person_id), person_name, tel, "教师");
//CommonUtil.Print("成功加入人员:" + person_name);
}
}
/ * *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 下 面 是 数 据 库 操 作 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* /
//-----------------------------------------------------下面是数据库操作---------------------------------------------
public static List < Record > getOrgList ( int orgId ) {
// 学校及学校下的部门
String sql = "select org_id,org_name,parent_id,sort_id,dingtalk_dept_id from t_base_organization where bureau_id=? and org_id<>bureau_id order by org_id" ;
@ -477,7 +485,7 @@ public class DingTalkUtil {
public static List < Record > getDeptPerson ( int bureau_id ) {
String sql = "select t1.person_id,t1.person_name,t2.dingtalk_dept_id from t_base_person as t1 " +
String sql = "select t1.person_id,t1.person_name,t2.dingtalk_dept_id ,t1.tel from t_base_person as t1 " +
"inner join t_base_organization as t2 on t1.org_id=t2.org_id " +
" where t1.bureau_id=? and t1.b_use=1" ;
return Db . find ( sql , bureau_id ) ;