bug: 修改人员同步定时任务,去掉时间戳,改为全量同步
This commit is contained in:
@@ -129,12 +129,12 @@ public class SyncUserService {
|
||||
do {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("cookie", Base64.encodeBase64String(cookie));
|
||||
params.put("timestamp", "");
|
||||
// params.put("timestamp", "");
|
||||
|
||||
// 用户参数
|
||||
params.put("filter", "(userid=*)");
|
||||
params.put("basedn", "ou=People,o=foton.com.cn,o=isp");
|
||||
log.info("RequestBody:" + params.toString());
|
||||
params.forEach((key, value) -> log.info("同步用户数据的请求参数:" + key + " : " + value));
|
||||
// 用户测试
|
||||
String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/users/getUserList", params);
|
||||
log.info("远程调用同步的员工数据:"+rs);
|
||||
@@ -255,4 +255,48 @@ public class SyncUserService {
|
||||
} while (cookie != null);
|
||||
return json;
|
||||
}
|
||||
|
||||
// 不添加时间戳,全量同步部门信息
|
||||
public List<String> syncFotonOrg3()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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,11 @@ public class AuthUtils {
|
||||
public String getResponseFromServer(String url, Map<String, Object> params) throws Exception {
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
createSignHeader(httpPost, params);
|
||||
Header[] allHeaders = httpPost.getAllHeaders();
|
||||
for (Header header : allHeaders) {
|
||||
logger.info("请求头:" + header.getName() + ":" + header.getValue());
|
||||
}
|
||||
JSONObject object = JSONObject.fromObject(params);
|
||||
params.forEach((key,value) -> logger.info("请求参数:{}:{}",key,value));
|
||||
httpPost.setEntity(new ByteArrayEntity(object.toString().getBytes(), ContentType.APPLICATION_JSON));
|
||||
return execute(httpPost);
|
||||
}
|
||||
@@ -52,7 +55,7 @@ public class AuthUtils {
|
||||
client = HttpClientBuilder.create().build();
|
||||
logger.info("请求地址:"+request.getURI().toString());
|
||||
for (Header header : request.getAllHeaders()) {
|
||||
logger.info("请求头:"+header.toString());
|
||||
logger.info("请求头:"+header.getName() + ":" + header.getValue());
|
||||
}
|
||||
resp = client.execute(request);
|
||||
return EntityUtils.toString(resp.getEntity());
|
||||
|
||||
Reference in New Issue
Block a user