|
|
|
@ -197,10 +197,21 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//拉取失败文件
|
|
|
|
|
fetchFailFile(host);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void fetchFailFile(String host) {
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
map.put("sql", "select * from idc_file where createTime<date_sub(now(),interval 30 minute) order by createTime");
|
|
|
|
|
List<Map<String,Object>> list = dbDao.list(map);
|
|
|
|
|
for(int i=0;i<list.size();i++) {
|
|
|
|
|
signleDownloadFile(host,list.get(i).get("filePath").toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void asyncDataTask(boolean isUpload) {
|
|
|
|
|
initTable();
|
|
|
|
|
Map<String, Object> map = dbDao.get("select * from sync_data_set limit 1");
|
|
|
|
@ -564,6 +575,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
Map<String, Object> whereParams = new HashMap<String, Object>();
|
|
|
|
|
whereParams.put("sqlWhere", params.get("sqlWhere"));
|
|
|
|
|
|
|
|
|
|
String dataWhere = params.get("dataWhere")!=null ? params.get("dataWhere").toString() : "";
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
String where = DBAUtils.convertWhere(column, whereParams, dataWhere);
|
|
|
|
@ -771,7 +783,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
if (!StringUtils.isEmpty(filePathColumn)) {
|
|
|
|
|
files[i] = list.get(i).get(filePathColumn) != null ? list.get(i).get(filePathColumn).toString() : "";
|
|
|
|
|
//logger.info("file-->"+files[i]);
|
|
|
|
|
logger.info("file-->"+files[i]);
|
|
|
|
|
}
|
|
|
|
|
for (int z = 0; z < 30; z++) {
|
|
|
|
|
if (list.get(i).get("data" + z) != null) {
|
|
|
|
@ -796,7 +808,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
filePathColumn, List<Map<String, Object>> list, boolean isUpload) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String tName = DBAUtils.tableRealName(tableName);
|
|
|
|
|
String tName = DBAUtils.tableRealName(tableName);
|
|
|
|
|
String sql = "replace " + tName + "(";
|
|
|
|
|
String del = "delete from " + tName + " where ";
|
|
|
|
|
String upd = "update " + tName + " set ";
|
|
|
|
@ -1012,8 +1024,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
try {
|
|
|
|
|
Response result = client.newCall(request).execute();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (MediaType.parse("application/force-download").equals(result.body().contentType())) {
|
|
|
|
|
int total = 0;
|
|
|
|
|
if (result!=null&&result.isSuccessful()&&MediaType.parse("application/force-download").equals(result.body().contentType())) {
|
|
|
|
|
try (InputStream inputStream = result.body().byteStream()) {
|
|
|
|
|
|
|
|
|
|
String filePathSlash = filePath.substring(filePath.length() - 1).equals("/") ? "" : "/";
|
|
|
|
@ -1023,22 +1035,28 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
byte b[] = new byte[1024];
|
|
|
|
|
|
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
|
|
while ((len = inputStream.read(b)) != -1) {
|
|
|
|
|
|
|
|
|
|
total += len;
|
|
|
|
|
outputStream.write(b, 0, len);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
outputStream.close();
|
|
|
|
|
|
|
|
|
|
if(!(total>0)) {
|
|
|
|
|
new File(filePath + filePathSlash + fileName).delete();
|
|
|
|
|
executeSql("delete from idc_file where filePath='"+fileName+"'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!(total>0)) {
|
|
|
|
|
String sql = "replace idc_file (filePath,createTime) values ('"+fileName+"',now())";
|
|
|
|
|
executeSql(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
@ -1202,6 +1220,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
alterTable("idc_status", "create table idc_status (id varchar(100),statusTime datetime,PRIMARY KEY (id))");
|
|
|
|
|
alterTable("idc_record", "create table idc_record (id varchar(36),type varchar(60),fkId varchar(36),isEnd char(1),createTime datetime,primary key (id),INDEX i_idc_record_fk_id (fkId),INDEX i_idc_record_create_time (createTime))");
|
|
|
|
|
alterTable("idc_log", "create table idc_log (id varchar(36),orderNum int,taskId varchar(60),type varchar(60),content varchar(2000),offset int,total int,createTime datetime,PRIMARY KEY (id))");
|
|
|
|
|
alterTable("idc_file", "create table idc_file (filePath varchar(255),createTime datetime,PRIMARY KEY (filePath))");
|
|
|
|
|
dbDao.delete("delete from idc_record where createTime<date_sub(now(),interval 2 day) and isEnd='0'");
|
|
|
|
|
try {
|
|
|
|
|
executeSql("alter table basic_export_status add column cacheFilePath varchar(255)");
|
|
|
|
@ -1211,6 +1230,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
executeSql("alter table basic_export_status add column msg varchar(255)");
|
|
|
|
|
executeSql("alter table basic_upload_status add column msg varchar(255)");
|
|
|
|
|
executeSql("alter table basic_download_status add column msg varchar(255)");
|
|
|
|
|
executeSql("create index i_idc_file_create_time on idc_file (createTime asc)");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|