diff --git a/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java b/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java index 991c455a4..01788796a 100644 --- a/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java +++ b/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java @@ -197,9 +197,20 @@ public class IdcServiceImpl implements IdcService { } } } + //拉取失败文件 + fetchFailFile(host); } } + + private void fetchFailFile(String host) { + Map map = new HashMap(); + map.put("sql", "select * from idc_file where createTime> list = dbDao.list(map); + for(int i=0;i whereParams = new HashMap(); whereParams.put("sqlWhere", params.get("sqlWhere")); + String dataWhere = params.get("dataWhere")!=null ? params.get("dataWhere").toString() : ""; Map map = new HashMap(); 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> 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