fetch:机构人员bug
This commit is contained in:
@@ -8,9 +8,9 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSONSerializer;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -19,16 +19,21 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class SyncUserService {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SyncUserService syncUserService=new SyncUserService();
|
||||
syncUserService.syncFotonOrg();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步福田IDM数据
|
||||
* @throws Exception
|
||||
*/
|
||||
public void syncFotonUser()throws Exception{
|
||||
String appuser = "wsuser";
|
||||
String appkey = "o1bnrph3pe6i63txm3z5l3cnka2a82pi";
|
||||
public List<String> syncFotonUser()throws Exception{
|
||||
String appuser = "app_slrs";
|
||||
String appkey = "wj5iDTqyguQCxnsoo5VU21BoRSZqevhI";
|
||||
AuthUtils util = new AuthUtils(appuser, appkey, null);
|
||||
|
||||
List<String> json=new ArrayList<>();
|
||||
byte[] cookie = null;
|
||||
do {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
@@ -41,13 +46,17 @@ public class SyncUserService {
|
||||
System.out.println("RequestBody:" + params.toString());
|
||||
// 用户测试
|
||||
String rs = util.getResponseFromServer("http://172.24.224.42:82/rest/users/getUserList", params);
|
||||
System.err.println(rs);
|
||||
|
||||
JSONObject responseStr = (JSONObject) JSONSerializer.toJSON(rs);
|
||||
json.add(rs);
|
||||
|
||||
JSONObject responseStr = JSON.parseObject(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);
|
||||
@@ -60,16 +69,18 @@ public class SyncUserService {
|
||||
}
|
||||
|
||||
} while (cookie != null);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void syncFotonOrg()throws Exception{
|
||||
String appuser = "wsuser";
|
||||
String appkey = "o1bnrph3pe6i63txm3z5l3cnka2a82pi";
|
||||
public List<String> syncFotonOrg()throws Exception{
|
||||
String appuser = "app_slrs";
|
||||
String appkey = "wj5iDTqyguQCxnsoo5VU21BoRSZqevhI";
|
||||
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));
|
||||
@@ -80,19 +91,25 @@ public class SyncUserService {
|
||||
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
|
||||
// 组织测试
|
||||
String rs = util.getResponseFromServer("http://172.24.224.42:82/rest/orgs/getOrgList", params);
|
||||
System.err.println(rs);
|
||||
json.add(rs);
|
||||
|
||||
|
||||
JSONObject responseStr = (JSONObject) JSONSerializer.toJSON(rs);
|
||||
JSONObject responseStr = JSONObject.parseObject(rs);
|
||||
|
||||
System.out.println(responseStr);
|
||||
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) {
|
||||
System.out.println(e);
|
||||
e.printStackTrace();
|
||||
if (e.getMessage().contains("is not a JSONArray")) {
|
||||
cookie = null;
|
||||
}
|
||||
@@ -100,6 +117,7 @@ public class SyncUserService {
|
||||
}
|
||||
|
||||
} while (cookie != null);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user