修改UDI上传地址参数使用syncIp

version1
admin 2 years ago
parent e9124b43ed
commit 59e628be5d

@ -168,16 +168,24 @@ public class IdcServiceImpl implements IdcService {
initTable();
Map<String,Object> map = dbDao.get("select * from sync_data_set limit 1");
if(map!=null&&map.get("downstreamEnable")!=null&&map.get("downstreamEnable").toString().equals("1")) {
if(isUpload) {
if(!(map.get("syncIp")!=null&&!StringUtils.isEmpty(map.get("syncIp").toString()))) {
logger.error("中继服务地址未配置");
return;
}
}
for(int i=0;i<SYNC_TABLES.length;i++) {
String[] tnames = SYNC_TABLES[i].split("/");
saveIdcLog("---","",map.get(tnames[0])+SYNC_TABLES[i],0,0);
if(!StringUtils.isEmpty(tnames[0])&&map!=null&&map.get(tnames[0])!=null&&map.get(tnames[0]).toString().equals("1"))
syncData(SYNC_TABLES[i],isUpload);
if(!StringUtils.isEmpty(tnames[0])&&map!=null&&map.get(tnames[0])!=null&&map.get(tnames[0]).toString().equals("1")) {
String syncIp = map.get("syncIp")!=null ? map.get("syncIp").toString() : "";
syncData(SYNC_TABLES[i],isUpload,syncIp);
}
}
}
}
private void syncData(String t,boolean isUpload) {
private void syncData(String t,boolean isUpload,String syncIp) {
boolean sync = true;
String[] tnames = t.split("/");
@ -216,7 +224,7 @@ public class IdcServiceImpl implements IdcService {
sync = nextTimePoint.before(nowUpdateTime);
}
if(sync) {
if(syncMasterData(map,isUpload)) {
if(syncMasterData(map,isUpload,syncIp)) {
setUpdateTime(tnames[2],DateUtil.formatDate(nowUpdateTime,"yyyy-MM-dd HH:mm:ss"));
}
}
@ -322,7 +330,8 @@ public class IdcServiceImpl implements IdcService {
} else {
//需要转发
if(isRelay()) {
String result = relay(request.getHeader("reqNo"),content,saveFiles);
String host = getNextHost();
String result = relay(request.getHeader("reqNo"),content,saveFiles,host);
if(IDCUtils.isJson(result)) {
JSONObject object = JSON.parseObject(result);
if(object.getInteger("code")!=20000)
@ -405,7 +414,7 @@ public class IdcServiceImpl implements IdcService {
}
private boolean syncMasterData(Map<String,Object> params,boolean isUplaod) {
private boolean syncMasterData(Map<String,Object> params,boolean isUplaod,String syncIp) {
boolean success=false;
String tableName = params.get("tableName").toString();
String tableKey = params.get("tableKey").toString();
@ -487,7 +496,7 @@ public class IdcServiceImpl implements IdcService {
if(isUplaod) {
String result = "";
try {
result = relay("",JSON.toJSONString(data),files);
result = relay("",JSON.toJSONString(data),files,syncIp);
} catch (Exception ex) {
}
@ -682,8 +691,8 @@ public class IdcServiceImpl implements IdcService {
/*转发下级或上级中继服务*/
private String relay(String reqNo,String content,String[] files) {
String host = getNextHost();
private String relay(String reqNo,String content,String[] files,String ip) {
String host = ip;
String result="";
if(StringUtils.isEmpty(reqNo))
reqNo = UUID.randomUUID().toString();

Loading…
Cancel
Save