fix: 重构底层基础数据同步的代码逻辑,去掉清空表数据的操作,更换为更新或添加操作
This commit is contained in:
@@ -19,10 +19,6 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class SyncUserService {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SyncUserService syncUserService=new SyncUserService();
|
||||
syncUserService.syncFotonUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步福田IDM数据
|
||||
@@ -46,12 +42,11 @@ public class SyncUserService {
|
||||
System.out.println("RequestBody:" + params.toString());
|
||||
// 用户测试
|
||||
String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/users/getUserList", params);
|
||||
|
||||
json.add(rs);
|
||||
|
||||
log.debug(rs);
|
||||
JSONObject responseStr = JSON.parseObject(rs);
|
||||
System.out.println(rs);
|
||||
log.info(rs);
|
||||
if(responseStr.containsKey("status") && responseStr.getBoolean("status")){
|
||||
json.add(rs);
|
||||
}
|
||||
if (responseStr.containsKey("cookie")) {
|
||||
try {
|
||||
JSONArray entries = responseStr.getJSONArray("cookie");
|
||||
@@ -63,6 +58,7 @@ public class SyncUserService {
|
||||
cookie[i] = (byte) entries.getByte(i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
if (e.getMessage().contains("is not a JSONArray")) {
|
||||
cookie = null;
|
||||
}
|
||||
@@ -92,13 +88,11 @@ public class SyncUserService {
|
||||
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
|
||||
// 组织测试
|
||||
String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/orgs/getOrgList", params);
|
||||
json.add(rs);
|
||||
|
||||
|
||||
JSONObject responseStr = JSONObject.parseObject(rs);
|
||||
|
||||
System.out.println(responseStr);
|
||||
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");
|
||||
@@ -110,14 +104,12 @@ public class SyncUserService {
|
||||
cookie[i] = (byte) entries.getByte(i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
e.printStackTrace();
|
||||
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