|
|
|
@ -222,6 +222,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
logger.error("中继服务地址未配置");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/*未发送重新发送*/
|
|
|
|
|
asyncFailTask(map.get("syncIp").toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] syncTables = TableUtils.syncTables();
|
|
|
|
@ -239,6 +241,70 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*上传失败重新上传*/
|
|
|
|
|
private void asyncFailTask(String host) {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
|
|
|
|
|
String sql = "select * from basic_export_status where status='1' and receiveStatus='0' order by updateTime";
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
map.put("sql", sql);
|
|
|
|
|
List<Map<String,Object>> list = dbDao.list(map);
|
|
|
|
|
ArrayList<String> files = new ArrayList<>();
|
|
|
|
|
for(int i=0;i<list.size();i++) {
|
|
|
|
|
String json = FileUtils.readFileAll(list.get(i).get("cacheFilePath").toString());
|
|
|
|
|
JSONObject object = JSONObject.parseObject(json);
|
|
|
|
|
List<Map> dataList = JSONObject.parseArray(JSON.toJSONString(object.get("data")), Map.class);
|
|
|
|
|
for (int m = 0; m < dataList.size(); m++) {
|
|
|
|
|
if(object.get("filePathColumn")!=null&&!StringUtils.isEmpty(object.get("filePathColumn").toString())&&
|
|
|
|
|
dataList.get(m).get(object.get("filePathColumn").toString()) !=null ) {
|
|
|
|
|
String fileNames = dataList.get(m).get(object.get("filePathColumn").toString()).toString();
|
|
|
|
|
String[] str = fileNames.split(",");
|
|
|
|
|
for (int r = 0; r < str.length; r++) {
|
|
|
|
|
if (!StringUtils.isEmpty(str[r]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[r]))
|
|
|
|
|
files.add(filePath + filePathSlash + imagePath + str[r]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(int k=0;k<30;k++) {
|
|
|
|
|
if(dataList.get(k).get("tableName"+k) == null)
|
|
|
|
|
break;
|
|
|
|
|
if(dataList.get(k).get("data"+k)!=null && dataList.get(k).get("filePathColumn"+k)!=null) {
|
|
|
|
|
List<Map> childList = JSONObject.parseArray(JSON.toJSONString(dataList.get(i).get("data"+k)), Map.class);
|
|
|
|
|
for(int x =0 ;x <childList.size();x++) {
|
|
|
|
|
if (childList.get(x).get(dataList.get(k).get("filePathColumn"+k).toString()) != null) {
|
|
|
|
|
String[] str = childList.get(x).get(dataList.get(k).get("filePathColumn"+k).toString()).toString().split(",");
|
|
|
|
|
for (int s = 0; s < str.length; s++) {
|
|
|
|
|
if (!StringUtils.isEmpty(str[s]) && FileUtils.isFileExist(filePath + filePathSlash + imagePath + str[s]))
|
|
|
|
|
files.add(filePath + filePathSlash + imagePath + str[s]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String result = "";
|
|
|
|
|
try {
|
|
|
|
|
result = relay(list.get(i).get("id").toString(), json, files, host);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (IDCUtils.isJson(result)) {
|
|
|
|
|
JSONObject res = JSON.parseObject(result);
|
|
|
|
|
if (res.getInteger("code") == 20000) {
|
|
|
|
|
executeSql("update basic_export_status set receiveStatus='1',endTime=now() where id='"+list.get(i).get("id")+"'");
|
|
|
|
|
saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->success", 0, 0);
|
|
|
|
|
} else {
|
|
|
|
|
saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->fail", 0, 0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
saveIdcLog(object.getString("messageType"), list.get(i).get("id").toString(), object.getString("tableName") + ">reUpload->fail", 0, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*数据删除同步*/
|
|
|
|
|
private void asyncDelete(String tname,boolean isUpload,String syncIp) {
|
|
|
|
@ -391,7 +457,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
setUpdateTime(tnames[2] + "." + tnames[0]+"."+tnames[1], DateUtil.formatDate(nowUpdateTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
@ -800,6 +865,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
map.put("status", success ? "1" : "0");
|
|
|
|
|
map.put("receiveStatus", isReceive ? "1" : "0");
|
|
|
|
|
map.put("startTime", startTime != null ? startTime : new Date());
|
|
|
|
|
if(isReceive)
|
|
|
|
|
map.put("endTime", new Date());
|
|
|
|
|
map.put("updateTime", new Date());
|
|
|
|
|
map.put("remark", json.get("messageType") + ": " + json.get("total") + "条");
|
|
|
|
|
if (isEnd)
|
|
|
|
|