|
|
@ -174,14 +174,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
logger.info("fetch from ip:"+host);
|
|
|
|
logger.info("fetch from ip:"+host);
|
|
|
|
if(!StringUtils.isEmpty(host)) {
|
|
|
|
if(!StringUtils.isEmpty(host)) {
|
|
|
|
String result = post(host+"/spssync/common/list",null);
|
|
|
|
String result = post(host+"/spssync/common/list",null);
|
|
|
|
|
|
|
|
|
|
|
|
if(IDCUtils.isJson(result)) {
|
|
|
|
if(IDCUtils.isJson(result)) {
|
|
|
|
JSONObject json = JSON.parseObject(result);
|
|
|
|
JSONObject json = JSON.parseObject(result);
|
|
|
|
|
|
|
|
if(json!=null&&json.getInteger("code")==20000&&json.getString("data")!=null) {
|
|
|
|
if(json!=null&&json.getInteger("code")==20000&&json.get("data")!=null) {
|
|
|
|
List<Map> list = JSON.parseArray(json.getString("data"), Map.class);
|
|
|
|
|
|
|
|
|
|
|
|
List<Map> list = JSON.parseArray(JSON.toJSONString(json.get("data")), Map.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(list!=null) {
|
|
|
|
if(list!=null) {
|
|
|
|
for(Map map:list) {
|
|
|
|
for(Map map:list) {
|
|
|
|
Map<String,Object> params = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> params = new HashMap<String,Object>();
|
|
|
@ -290,12 +287,13 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
String result = "";
|
|
|
|
String result = "";
|
|
|
|
MultipartFile[] files = {};
|
|
|
|
MultipartFile[] files = {};
|
|
|
|
|
|
|
|
Date startTime = new Date();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean success=true;
|
|
|
|
boolean success=true;
|
|
|
|
Response response = client.newCall(request).execute();
|
|
|
|
Response response = client.newCall(request).execute();
|
|
|
|
result = response.body().string();
|
|
|
|
result = response.body().string();
|
|
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
|
|
|
|
|
|
|
|
|
|
if(isLastLevel()) {
|
|
|
|
if(isLastLevel()) {
|
|
|
|
if(json.get("code")!=null&&json.getInteger("code")==20000) {
|
|
|
|
if(json.get("code")!=null&&json.getInteger("code")==20000) {
|
|
|
|
success = analyMiddle(host,json.getJSONObject("data"),files,false,true);
|
|
|
|
success = analyMiddle(host,json.getJSONObject("data"),files,false,true);
|
|
|
@ -304,11 +302,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
success = false;
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
syncAddTaskStatus(json.getJSONObject("data"),3,success);
|
|
|
|
syncAddTaskStatus(json.getJSONObject("data"),3,success,startTime,true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if(json.get("code")!=null&&json.get("data")!=null) {
|
|
|
|
if(json.get("code")!=null&&json.get("data")!=null) {
|
|
|
|
logger.info("res1-->"+JSON.toJSONString(json));
|
|
|
|
//logger.info("res1-->"+JSON.toJSONString(json));
|
|
|
|
syncAddTaskStatus(json.getJSONObject("data"),0,success);
|
|
|
|
syncAddTaskStatus(json.getJSONObject("data"),0,success,startTime,true);
|
|
|
|
analyMiddle(host,json.getJSONObject("data"),files,false,false);
|
|
|
|
analyMiddle(host,json.getJSONObject("data"),files,false,false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -351,7 +349,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BaseResponse downlaodSuccess(HttpServletRequest request,Map<String,Object> params) {
|
|
|
|
public BaseResponse downlaodSuccess(HttpServletRequest request,Map<String,Object> params) {
|
|
|
|
String sql = "update basic_export_status set receiveStatus='1' where id='"+params.get("taskId")+"'";
|
|
|
|
String sql = "update basic_export_status set receiveStatus='1',endTime=now() where id='"+params.get("taskId")+"'";
|
|
|
|
dbDao.update(sql);
|
|
|
|
dbDao.update(sql);
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -377,9 +375,9 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
FileUtils.SaveFileAs(content, fileName);
|
|
|
|
FileUtils.SaveFileAs(content, fileName);
|
|
|
|
FileUtils.SaveFileAs(content, backFileName);
|
|
|
|
FileUtils.SaveFileAs(content, backFileName);
|
|
|
|
ArrayList<String> saveFiles = new ArrayList<>();
|
|
|
|
ArrayList<String> saveFiles = new ArrayList<>();
|
|
|
|
|
|
|
|
Date startTime = new Date();
|
|
|
|
if(files!=null) {
|
|
|
|
if(files!=null) {
|
|
|
|
|
|
|
|
|
|
|
|
int n=0;
|
|
|
|
int n=0;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
for(MultipartFile file:files) {
|
|
|
|
for(MultipartFile file:files) {
|
|
|
@ -404,7 +402,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
boolean success = false;
|
|
|
|
boolean success = false;
|
|
|
|
if(isLastLevel()) {
|
|
|
|
if(isLastLevel()) {
|
|
|
|
success = analyMiddle("",json,files,true,true);
|
|
|
|
success = analyMiddle("",json,files,true,true);
|
|
|
|
syncAddTaskStatus(json,2,success);
|
|
|
|
syncAddTaskStatus(json,2,success,startTime,true);
|
|
|
|
if(!success) {
|
|
|
|
if(!success) {
|
|
|
|
|
|
|
|
|
|
|
|
return ResultVOUtils.error(9000, "解析失败");
|
|
|
|
return ResultVOUtils.error(9000, "解析失败");
|
|
|
@ -415,11 +413,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
String host = getNextHost();
|
|
|
|
String host = getNextHost();
|
|
|
|
String result = relay(request.getHeader("reqNo"),content,saveFiles,host);
|
|
|
|
String result = relay(request.getHeader("reqNo"),content,saveFiles,host);
|
|
|
|
if(IDCUtils.isJson(result)) {
|
|
|
|
if(IDCUtils.isJson(result)) {
|
|
|
|
syncAddTaskStatus(json,1,true);
|
|
|
|
syncAddTaskStatus(json,1,true,startTime,true);
|
|
|
|
BaseResponse object = JSON.parseObject(result,BaseResponse.class);
|
|
|
|
BaseResponse object = JSON.parseObject(result,BaseResponse.class);
|
|
|
|
return object;
|
|
|
|
return object;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
syncAddTaskStatus(json,1,false);
|
|
|
|
syncAddTaskStatus(json,1,false,startTime,false);
|
|
|
|
return ResultVOUtils.error(9000, "转发失败");
|
|
|
|
return ResultVOUtils.error(9000, "转发失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -448,10 +446,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
public void downloadFile(String fileName,HttpServletResponse response) {
|
|
|
|
public void downloadFile(String fileName,HttpServletResponse response) {
|
|
|
|
OutputStream os;
|
|
|
|
OutputStream os;
|
|
|
|
String filePathSlash = filePath.substring(filePath.length() -1).equals("/") ? "" : fileName.substring(0,1).equals("/") ? "" : "/";
|
|
|
|
String filePathSlash = filePath.substring(filePath.length() -1).equals("/") ? "" : fileName.substring(0,1).equals("/") ? "" : "/";
|
|
|
|
if(!FileUtils.isFileExist(filePath+filePathSlash+fileName))
|
|
|
|
|
|
|
|
fileName = "11.jpg";
|
|
|
|
try {
|
|
|
|
logger.info(filePath+filePathSlash+fileName);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if(FileUtils.isFileExist(filePath+filePathSlash+fileName)) {
|
|
|
|
if(FileUtils.isFileExist(filePath+filePathSlash+fileName)) {
|
|
|
|
byte[] bytes = FileUtils.readFileByBytes(filePath+filePathSlash+fileName);
|
|
|
|
byte[] bytes = FileUtils.readFileByBytes(filePath+filePathSlash+fileName);
|
|
|
|
os = response.getOutputStream();
|
|
|
|
os = response.getOutputStream();
|
|
|
@ -468,23 +464,21 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
private void saveUploadStatus(Map<String,Object> params) {
|
|
|
|
private void saveUploadStatus(Map<String,Object> params) {
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
map.putAll(params);
|
|
|
|
map.putAll(params);
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
|
|
|
|
map.put("updateTime", new Date());
|
|
|
|
|
|
|
|
Map<String,Object> columns = getColumn("basic_upload_status");
|
|
|
|
Map<String,Object> columns = getColumn("basic_upload_status");
|
|
|
|
String sql = "insert into basic_upload_status "+DBAUtils.parseInsert(map, columns);
|
|
|
|
String sql = "replace basic_upload_status "+DBAUtils.parseInsert(map, columns);
|
|
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
dbDao.save(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void saveExportStatus(Map<String,Object> params) {
|
|
|
|
private void saveExportStatus(Map<String,Object> params) {
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
|
|
|
|
|
|
|
map.putAll(params);
|
|
|
|
map.putAll(params);
|
|
|
|
map.put("receiveStatus", "0");
|
|
|
|
map.put("receiveStatus", "0");
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
|
|
|
|
map.put("updateTime", new Date());
|
|
|
|
|
|
|
|
Map<String,Object> columns = getColumn("basic_export_status");
|
|
|
|
Map<String,Object> columns = getColumn("basic_export_status");
|
|
|
|
String sql = "insert into basic_export_status "+DBAUtils.parseInsert(map, columns);
|
|
|
|
String sql = "replace basic_export_status "+DBAUtils.parseInsert(map, columns);
|
|
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
dbDao.save(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -492,10 +486,9 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
map.put("receiveStatus", "0");
|
|
|
|
map.put("receiveStatus", "0");
|
|
|
|
map.putAll(params);
|
|
|
|
map.putAll(params);
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
|
|
|
|
map.put("updateTime", new Date());
|
|
|
|
|
|
|
|
Map<String,Object> columns = getColumn("basic_download_status");
|
|
|
|
Map<String,Object> columns = getColumn("basic_download_status");
|
|
|
|
String sql = "insert into basic_download_status "+DBAUtils.parseInsert(map, columns);
|
|
|
|
String sql = "replace basic_download_status "+DBAUtils.parseInsert(map, columns);
|
|
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
dbDao.save(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -566,15 +559,17 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
for(int i=0;i<Math.ceil(total/limit)+1;i++) {
|
|
|
|
for(int i=0;i<Math.ceil(total/limit)+1;i++) {
|
|
|
|
whereParams.replace("page", i *limit);
|
|
|
|
whereParams.replace("page", i *limit);
|
|
|
|
whereParams.replace("limit",limit);
|
|
|
|
whereParams.replace("limit",limit);
|
|
|
|
|
|
|
|
Date startTime = new Date();
|
|
|
|
Map<String,Object> data = getData(messageType,tableName,params,whereParams);
|
|
|
|
Map<String,Object> data = getData(messageType,tableName,params,whereParams);
|
|
|
|
String recordSql = "";
|
|
|
|
String recordSql = "";
|
|
|
|
orderNum++;
|
|
|
|
orderNum++;
|
|
|
|
saveIdcLog(messageType,"",tableName +">"+where,i *limit,total);
|
|
|
|
saveIdcLog(messageType,"",tableName +">"+where,i *limit,total);
|
|
|
|
if(data.get("data")!=null) {
|
|
|
|
if(data.get("data")!=null) {
|
|
|
|
|
|
|
|
|
|
|
|
List<Map> list = JSONObject.parseArray(JSON.toJSONString(data.get("data")), Map.class);
|
|
|
|
List<Map> list = JSONObject.parseArray(JSON.toJSONString(data.get("data")), Map.class);
|
|
|
|
if(list!=null&&list.size()>0) {
|
|
|
|
if(list!=null&&list.size()>0) {
|
|
|
|
for(int m=0;m<list.size();m++) {
|
|
|
|
for(int m=0;m<list.size();m++) {
|
|
|
|
|
|
|
|
|
|
|
|
if(!StringUtils.isEmpty(filePathColumn)&&list.get(m).get(filePathColumn)!=null) {
|
|
|
|
if(!StringUtils.isEmpty(filePathColumn)&&list.get(m).get(filePathColumn)!=null) {
|
|
|
|
String fileNames = list.get(m).get(filePathColumn).toString();
|
|
|
|
String fileNames = list.get(m).get(filePathColumn).toString();
|
|
|
|
String[] str = fileNames.split(",");
|
|
|
|
String[] str = fileNames.split(",");
|
|
|
@ -585,6 +580,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
recordSql+=!StringUtils.isEmpty(recordSql) ? "," : "";
|
|
|
|
recordSql+=!StringUtils.isEmpty(recordSql) ? "," : "";
|
|
|
|
recordSql+="('"+UUID.randomUUID().toString().replaceAll("-", "")+"','"+tableName+"','"+list.get(m).get(keyColumn)+"','"+isEnd+"',now())";
|
|
|
|
recordSql+="('"+UUID.randomUUID().toString().replaceAll("-", "")+"','"+tableName+"','"+list.get(m).get(keyColumn)+"','"+isEnd+"',now())";
|
|
|
|
|
|
|
|
|
|
|
|
if(childNum>-1) {
|
|
|
|
if(childNum>-1) {
|
|
|
|
for(int z=0;z<childNum+1;z++) {
|
|
|
|
for(int z=0;z<childNum+1;z++) {
|
|
|
|
String[] chidTnames = childs[z].split("/");
|
|
|
|
String[] chidTnames = childs[z].split("/");
|
|
|
@ -643,7 +639,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
saveIdcLog(messageType,"",tableName +">success",i *limit,total);
|
|
|
|
saveIdcLog(messageType,"",tableName +">success",i *limit,total);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
syncAddTaskStatus(data,isUpload ? 1 : 0 ,success);
|
|
|
|
syncAddTaskStatus(data,isUpload ? 1 : 0 ,success,startTime,isUpload);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -654,7 +650,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*增加同步任务状态*/
|
|
|
|
/*增加同步任务状态*/
|
|
|
|
private void syncAddTaskStatus(Map<String,Object> json,int scheduleType,boolean success) {
|
|
|
|
private void syncAddTaskStatus(Map<String,Object> json,int scheduleType,boolean success,Date startTime,boolean isEnd) {
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
String content = JSON.toJSONString(json);
|
|
|
|
String content = JSON.toJSONString(json);
|
|
|
@ -672,11 +668,18 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
//type,transportType,superiorService,subordinateService,cacheFilePath
|
|
|
|
//type,transportType,superiorService,subordinateService,cacheFilePath
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
map.put("type", json.get("messageType"));
|
|
|
|
map.put("type", json.get("messageType"));
|
|
|
|
|
|
|
|
map.put("id", json.get("messageId"));
|
|
|
|
|
|
|
|
if(json.get("id")==null)
|
|
|
|
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
map.put("transportType", scheduleType == 0 ? "1" : "2");
|
|
|
|
map.put("transportType", scheduleType == 0 ? "1" : "2");
|
|
|
|
map.put("scheduleType", scheduleType);
|
|
|
|
map.put("scheduleType", scheduleType);
|
|
|
|
map.put("taskId", json.get("messageId"));
|
|
|
|
map.put("taskId", json.get("messageId"));
|
|
|
|
map.put("cacheFilePath", fileName);
|
|
|
|
map.put("cacheFilePath", fileName);
|
|
|
|
map.put("status", success ? "1" : "0");
|
|
|
|
map.put("status", success ? "1" : "0");
|
|
|
|
|
|
|
|
map.put("startTime", startTime!=null ? startTime : new Date());
|
|
|
|
|
|
|
|
map.put("updateTime", new Date());
|
|
|
|
|
|
|
|
if(isEnd)
|
|
|
|
|
|
|
|
map.put("endTime", new Date());
|
|
|
|
if(scheduleType==2) {
|
|
|
|
if(scheduleType==2) {
|
|
|
|
saveUploadStatus(map);
|
|
|
|
saveUploadStatus(map);
|
|
|
|
} else if (scheduleType==3) {
|
|
|
|
} else if (scheduleType==3) {
|
|
|
@ -864,7 +867,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
for (Object o : (List<?>) obj) {
|
|
|
|
for (Object o : (List<?>) obj) {
|
|
|
|
chList.add((Map<String,Object>)o);
|
|
|
|
chList.add((Map<String,Object>)o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//logger.info("childList-->"+list.get(i).get("tableName"+m)+"-->"+JSON.toJSONString(chList));
|
|
|
|
|
|
|
|
analyToDB(host,list.get(i).get("tableName"+m).toString(),"","",chList,isUpload);
|
|
|
|
analyToDB(host,list.get(i).get("tableName"+m).toString(),"","",chList,isUpload);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -873,7 +875,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(n>0) {
|
|
|
|
if(n>0) {
|
|
|
|
|
|
|
|
|
|
|
|
result = (dbDao.save(sql)>0);
|
|
|
|
result = (dbDao.save(sql)>0);
|
|
|
|
if(!result)
|
|
|
|
if(!result)
|
|
|
|
logger.error(tableName+"-->fetchSave Fail");
|
|
|
|
logger.error(tableName+"-->fetchSave Fail");
|
|
|
@ -947,7 +948,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
String[] str = fileName.split(",");
|
|
|
|
String[] str = fileName.split(",");
|
|
|
|
for(int i=0;i<str.length;i++) {
|
|
|
|
for(int i=0;i<str.length;i++) {
|
|
|
|
if(!StringUtils.isEmpty(str[i])) {
|
|
|
|
if(!StringUtils.isEmpty(str[i])) {
|
|
|
|
|
|
|
|
//logger.info("downloadFile-->"+str[i]);
|
|
|
|
if(!signleDownloadFile(syncIp,str[i]))
|
|
|
|
if(!signleDownloadFile(syncIp,str[i]))
|
|
|
|
success = false;
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1033,7 +1034,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
String where = DBAUtils.convertWhere(column,params,"");
|
|
|
|
String where = DBAUtils.convertWhere(column,params,"");
|
|
|
|
sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
|
|
|
|
sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
map.putAll(params);
|
|
|
|
map.putAll(params);
|
|
|
|
map.put("sql", sql);
|
|
|
|
map.put("sql", sql);
|
|
|
@ -1044,7 +1044,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
private Map<String,Object> getData(String messageType,String tableName,Map<String,Object> params,Map<String,Object> whereParams) {
|
|
|
|
private Map<String,Object> getData(String messageType,String tableName,Map<String,Object> params,Map<String,Object> whereParams) {
|
|
|
|
List<Map<String,Object>> list = getList(tableName,whereParams);
|
|
|
|
List<Map<String,Object>> list = getList(tableName,whereParams);
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
map.put("messageId", UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
|
map.put("messageId", CustomUtil.getId());
|
|
|
|
map.put("messageType", messageType);
|
|
|
|
map.put("messageType", messageType);
|
|
|
|
map.put("apiCode", "common");
|
|
|
|
map.put("apiCode", "common");
|
|
|
|
map.put("tableName", DBAUtils.tableAliasName(tableName));
|
|
|
|
map.put("tableName", DBAUtils.tableAliasName(tableName));
|
|
|
|