diff --git a/src/main/java/com/docus/server/message/busservice/impl/ZxjhBusinessServiceImpl.java b/src/main/java/com/docus/server/message/busservice/impl/ZxjhBusinessServiceImpl.java index 9f33d01..552995a 100644 --- a/src/main/java/com/docus/server/message/busservice/impl/ZxjhBusinessServiceImpl.java +++ b/src/main/java/com/docus/server/message/busservice/impl/ZxjhBusinessServiceImpl.java @@ -95,7 +95,7 @@ public class ZxjhBusinessServiceImpl implements ZxjhBusinessService { List fileDtos = getFileDtos(result); log.info("同步病案主键:{},jzh:{},文件数量:{}",patientId,jzh,fileDtos.size()); if(Func.isEmpty(fileDtos)){ - return; + continue; } String downPath=config.getDownPath()+File.separator+patientId; List tScanAssorts=new ArrayList(); @@ -325,18 +325,17 @@ public class ZxjhBusinessServiceImpl implements ZxjhBusinessService { } String path = uri.getPath(); FTPClient ftpClient = new FTPClient(); + OutputStream outputStream=null; try { ftpClient.connect(host, port); ftpClient.login(username, password); ftpClient.enterLocalPassiveMode(); File localFile = new File(localFilePath); - OutputStream outputStream = new FileOutputStream(localFile); + outputStream = new FileOutputStream(localFile); ftpClient.retrieveFile(path, outputStream); - outputStream.close(); - int numberOfPages=0; // 判断文件类型并获取页数 if (isPdf(localFilePath)) { @@ -361,6 +360,9 @@ public class ZxjhBusinessServiceImpl implements ZxjhBusinessService { log.error(ex.getMessage(),ex); } } + if ( outputStream!=null){ + outputStream.close(); + } } } @@ -379,8 +381,8 @@ public class ZxjhBusinessServiceImpl implements ZxjhBusinessService { PdfReader reader = new PdfReader(filePath); return reader.getNumberOfPages(); } catch (Exception e) { - e.printStackTrace(); - return 0; + log.info(e.getMessage(),e); + throw new BaseException("获取文件页码出错"); } } }