add:添加全量部门同步
This commit is contained in:
@@ -128,10 +128,9 @@ public class SyncUserService {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("cookie", Base64.encodeBase64String(cookie));
|
||||
// params.put("timestamp", System.currentTimeMillis());
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// String timestamp = sdf.format(calendar.getTime());
|
||||
// params.put("timestamp", timestamp);
|
||||
params.put("timestamp","");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
String timestamp = sdf.format(calendar.getTime());
|
||||
params.put("timestamp", timestamp);
|
||||
// 组织参数
|
||||
params.put("filter", "(orgNumber=*)");
|
||||
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
|
||||
@@ -162,4 +161,47 @@ public class SyncUserService {
|
||||
} while (cookie != null);
|
||||
return json;
|
||||
}
|
||||
// 不添加时间戳,全量同步部门信息
|
||||
public List<String> syncFotonOrg2()throws Exception{
|
||||
String appuser = "app_slrs";
|
||||
String appkey = "Fxi5LHbI5yGbQQDpVp86GcCdXeC5Bjfe";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss'Z'");
|
||||
AuthUtils util = new AuthUtils(appuser, appkey, null);
|
||||
|
||||
byte[] cookie = null;
|
||||
List<String> json=new ArrayList<>();
|
||||
do {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("cookie", Base64.encodeBase64String(cookie));
|
||||
params.put("timestamp","");
|
||||
// 组织参数
|
||||
params.put("filter", "(orgNumber=*)");
|
||||
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
|
||||
// 组织测试
|
||||
String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/orgs/getOrgList", params);
|
||||
log.info("远程调用同步的部门数据:"+rs);
|
||||
JSONObject responseStr = JSONObject.parseObject(rs);
|
||||
if(responseStr.containsKey("status") && responseStr.getBoolean("status")){
|
||||
json.add(rs);
|
||||
}
|
||||
if (responseStr.containsKey("cookie")) {
|
||||
try {
|
||||
JSONArray entries = responseStr.getJSONArray("cookie");
|
||||
if(entries==null){
|
||||
break;
|
||||
}
|
||||
cookie = new byte[entries.size()];
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
cookie[i] = (byte) entries.getByte(i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
if (e.getMessage().contains("is not a JSONArray")) {
|
||||
cookie = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (cookie != null);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user