刘韬 %!s(int64=3) %!d(string=hai) anos
pai
achega
7128d137ca

+ 0 - 6
DataFusion/src/com/zskk/config/ZskkConfig.java

@@ -16,7 +16,6 @@ import com.jfinal.plugin.druid.DruidPlugin;
 import com.jfinal.template.Engine;
 import com.zskk.control.ViewController;
 import com.zskk.service.ServiceFactory;
-import com.zskk.task.CFindTask;
 import com.zskk.task.DownloadTask;
 import com.zskk.task.DataTask;
 import com.zskk.task.InfoTask;
@@ -109,11 +108,6 @@ public class ZskkConfig extends JFinalConfig {
 		inData.addTask("*/2 * * * *", new UpdateTask());
 		me.add(inData);
 		
-//		//执行cfind请求
-//		Cron4jPlugin cgData = new Cron4jPlugin();
-//		cgData.addTask("*/2 * * * *", new CFindTask());
-//		me.add(cgData);
-		
 		//下载检查影像
 		Cron4jPlugin mvData = new Cron4jPlugin();
 		mvData.addTask("*/1 * * * *", new DownloadTask());

+ 0 - 44
DataFusion/src/com/zskk/task/CFindTask.java

@@ -1,44 +0,0 @@
-package com.zskk.task;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import com.jfinal.plugin.activerecord.Db;
-import com.jfinal.plugin.activerecord.Record;
-import com.jfinal.plugin.cron4j.ITask;
-import com.zskk.tools.ExecUtil;
-
-public class CFindTask implements ITask {
-
-	@Override
-	public void run() {
-		// TODO Auto-generated method stub
-		String dateString = parseStringToDate();
-		String fileString = dateString.replace("0", "o");
-		String execCmd = ExecUtil.execCmd("/zskk_system/other/cfind.sh " + dateString + " STUDYUID_" + fileString + ".xml");
-		if (execCmd.contains("Connection refused")) {
-			return;
-		}
-	}
-
-	@Override
-	public void stop() {
-		// TODO Auto-generated method stub
-
-	}
-	
-	/**
-	 * 日期字符串格式转换
-	 * 
-	 * @param dateStr
-	 * @return
-	 */
-	private String parseStringToDate() {
-		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-		Date date = new Date();
-		long dInteger = date.getTime();
-		String daString = sdf.format(new Date(dInteger));
-		return daString;
-
-	}
-
-}

+ 20 - 23
DataFusion/src/com/zskk/task/DownloadTask.java

@@ -87,41 +87,38 @@ public class DownloadTask implements ITask {
 	}
 	
 	private void writeFile(Response response, String uid) {
-        InputStream is = null;
+        InputStream is = response.body().byteStream();;
         FileOutputStream fos = null;
-        is = response.body().byteStream();
         String path = "/home/lenovo/CFIND_XML";
         Random r = new Random();
         Integer ran1 = r.nextInt(100000);
         File file = new File(path, uid+ran1.toString());
         try {
             fos = new FileOutputStream(file);
-            byte[] bytes = new byte[1024];
+            byte[] bytes = new byte[2048];
             int len = 0;
             //获取下载的文件的大小
-            long fileSize = response.body().contentLength();
-            long sum = 0;
-            int porSize = 0;
-            while ((len = is.read(bytes)) != -1) {
-                fos.write(bytes);
-                sum += len;
-                porSize = (int) ((sum * 1.0f / fileSize) * 100);
-            }
+//            long fileSize = response.body().contentLength();
+//            long sum = 0;
+//            int porSize = 0;
+//            while ((len = is.read(bytes)) != -1) {
+//                fos.write(bytes);
+//                sum += len;
+//                porSize = (int) ((sum * 1.0f / fileSize) * 100);
+//            }
+            while (-1 != (len = is.read(bytes))) {
+            	fos.write(bytes, 0, len);
+            	}
+            fos.flush();
+            fos.close();
+            is.close();
+//            file.renameTo(new File(path, uid+ran1.toString()+".dcm"));
+            File filentemp = new File(path, uid+ran1.toString());
+            File filen = new File(path, uid+ran1.toString()+".dcm");
+            filentemp.renameTo(filen);
         } catch (Exception e) {
             e.printStackTrace();
-        } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-                if (fos != null) {
-                    fos.close();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
         }
-        file.renameTo(new File(path, uid+ran1.toString()+".dcm"));
 
     }