刘韬 4 years ago
parent
commit
d0349e4a68

+ 5 - 4
DataFusion/src/com/zskk/config/ZskkConfig.java

@@ -41,6 +41,7 @@ public class ZskkConfig extends JFinalConfig {
 	public void configConstant(Constants me) {
 		loadProp("config.properties", "a_little_config.txt");
 		me.setDevMode(PropKit.getBoolean("devMode", false));
+		me.setBaseDownloadPath("/download");//配置文件下载路径
 	}
 
 	@Override
@@ -72,12 +73,12 @@ public class ZskkConfig extends JFinalConfig {
 		arpConnected.setDialect(new OracleDialect());
 		me.add(arpConnected);
 
-		Cron4jPlugin cpData = new Cron4jPlugin();
-		cpData.addTask("*/5 * * * *", new DataTask());
-		me.add(cpData);
+//		Cron4jPlugin cpData = new Cron4jPlugin();
+//		cpData.addTask("*/5 * * * *", new DataTask());
+//		me.add(cpData);
 		
 		Cron4jPlugin urlData = new Cron4jPlugin();
-		cpData.addTask("*/1 * * * *", new DataTask());
+		urlData.addTask("*/1 * * * *", new DataTask());
 		me.add(urlData);
 	}
 

+ 100 - 56
DataFusion/src/com/zskk/service/DataService.java

@@ -1,6 +1,11 @@
 package com.zskk.service;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -16,72 +21,111 @@ import okhttp3.RequestBody;
 import okhttp3.Response;
 
 public class DataService {
-	
-    private static String GET_EXAM_URL = "https://risserver3.pacsonline.cn/butt/getExam";
-    
-    private static String SAVE_REPORT_URL = "https://risserver3.pacsonline.cn/butt/saveReport";
-	
-    private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
-    
-    /**
-     * 获取未出报告的检查列表
-     * @param instutionId
-     * @param number
-     */
-    public JSONArray getExamList(Integer number) {
-    	Map <String,String> map = new HashMap<String,String>();
-    	map.put("institution_id", PropKit.get("institution_id"));
-    	map.put("num", number.toString());
+
+	private static String GET_EXAM_URL = "https://risserver3.pacsonline.cn/butt/getExam";
+
+	private static String SAVE_REPORT_URL = "https://risserver3.pacsonline.cn/butt/saveReport";
+
+	private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
+
+	/**
+	 * 获取未出报告的检查列表
+	 * 
+	 * @param instutionId
+	 * @param number
+	 */
+	public JSONArray getExamList(Integer number) {
+		Map<String, String> map = new HashMap<String, String>();
+		map.put("institution_id", PropKit.get("institution_id"));
+		map.put("num", number.toString());
 		String content = postWithParameters(GET_EXAM_URL, map);
-	    JSONObject jsonObject = JSON.parseObject(content);
-	    if (!jsonObject.getString("msg").equals("success")) {
+		JSONObject jsonObject = JSON.parseObject(content);
+		if (!jsonObject.getString("msg").equals("success")) {
 			return null;
 		}
-		JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));		
+		JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
 		return jsonArray;
-		
+
 	}
-    
-    /**
-     * 写入报告
-     * @param instutionId
-     * @param number
-     */
-    public void saveReport(Map <String,String> map) {
+
+	/**
+	 * 写入报告
+	 * 
+	 * @param instutionId
+	 * @param number
+	 */
+	public void saveReport(Map<String, String> map) {
 		postWithParameters(SAVE_REPORT_URL, map);
-		
+
 	}
-    
-    public static String postWithParameters(String url, Map<String, String> map) {
-    	
-    	FormBody.Builder formbody = new FormBody.Builder();
-    	
-    	for (Map.Entry<String, String> entry : map.entrySet()) {
-    		formbody.add(entry.getKey(), entry.getValue());
+
+	public static String postWithParameters(String url, Map<String, String> map) {
+
+		FormBody.Builder formbody = new FormBody.Builder();
+
+		for (Map.Entry<String, String> entry : map.entrySet()) {
+			formbody.add(entry.getKey(), entry.getValue());
 		}
 		RequestBody requestBody = formbody.build();
-		
-		Request request = new Request.Builder()
-		        .url(url)
-		        .post(requestBody)
-		        .build();
-
-		    try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
-		      if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
-		      String content = response.body().string();
-		      return content;
-		    } catch (IOException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-				return null;
-			}	
+
+		Request request = new Request.Builder().url(url).post(requestBody).build();
+
+		try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
+			if (!response.isSuccessful())
+				throw new IOException("Unexpected code " + response);
+			String content = response.body().string();
+			return content;
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		}
 	}
-    
-    public static void main(String[] args) {
-    	Map <String,String> map = new HashMap<String,String>();
-    	map.put("institution_id", "47600001");
-    	map.put("num", "10");
-		postWithParameters(GET_EXAM_URL, map);
+
+	public static void main(String[] args) {
+//    	Map <String,String> map = new HashMap<String,String>();
+//    	map.put("institution_id", "47600001");
+//    	map.put("num", "10");
+//		postWithParameters(GET_EXAM_URL, map);
+//		String fileName = "ss";
+//		Request request = new Request.Builder()
+//				.url("https://zskk-dcm.oss-cn-beijing.aliyuncs.com/73090001/d10378a36815fe3babd9b1e814b68fe6").build();
+//
+//		try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
+//			if (!response.isSuccessful())
+//				throw new IOException("Unexpected code " + response);
+//			String dirName = "/zskk_system/zskk_dicomQRScp/DICOM";
+//			File file = new File(dirName);
+//			if (!file.exists()) {
+//				file.mkdir();
+//			}
+//			if (response != null) {
+//				InputStream is = response.body().byteStream();
+//				FileOutputStream fos = new FileOutputStream(new File(dirName + "/" + fileName));
+//				int len = 0;
+//				byte[] buffer = new byte[2048];
+//				while (-1 != (len = is.read(buffer))) {
+//					fos.write(buffer, 0, len);
+//				}
+//				
+//				fos.flush();
+//				fos.close();
+//				is.close();
+//				File filen2 = new File(dirName + "/" + fileName);
+//				File filen = new File(dirName + "/" + fileName+".dcm");
+//				filen2.renameTo(filen);
+//			}
+//			
+//		} catch (IOException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
+
+		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	    Date date = new Date();
+	    long dInteger =date.getTime()-65000;
+		String daString = sdf.format(new Date(dInteger));
+		System.out.println(daString);
 	}
 
 }

+ 69 - 0
DataFusion/src/com/zskk/task/UpdateTask.java

@@ -1,12 +1,68 @@
 package com.zskk.task;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import com.jfinal.plugin.activerecord.Db;
+import com.jfinal.plugin.activerecord.Record;
 import com.jfinal.plugin.cron4j.ITask;
 
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+
 public class UpdateTask implements ITask {
 
+    private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
+
 	@Override
 	public void run() {
 		// TODO Auto-generated method stub
+		List<Record> record = Db.use("connected").find("select * from v_webpacs_image where rownum <10 and IMAGEDATE>to_date('"+parseStringToDate()+"','yyyy-mm-dd hh24:mi:ss')");
+		for (Record record2 : record) {
+			Request request = new Request.Builder()
+			        .url(record2.getStr("FILEPATH").replace("\\", "/"))
+			        .build();
+
+			
+			String fileName = record2.getStr("IMAGE_UID");
+
+			try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
+				if (!response.isSuccessful())
+					throw new IOException("Unexpected code " + response);
+				String dirName = "/zskk_system/zskk_dicomQRScp/DICOM";
+				File file = new File(dirName);
+				if (!file.exists()) {
+					file.mkdir();
+				}
+				if (response != null) {
+					InputStream is = response.body().byteStream();
+					FileOutputStream fos = new FileOutputStream(new File(dirName + "/" + fileName));
+					int len = 0;
+					byte[] buffer = new byte[2048];
+					while (-1 != (len = is.read(buffer))) {
+						fos.write(buffer, 0, len);
+					}
+					
+					fos.flush();
+					fos.close();
+					is.close();
+					File filen2 = new File(dirName + "/" + fileName);
+					File filen = new File(dirName + "/" + fileName+".dcm");
+					filen2.renameTo(filen);
+				}
+				
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
 
 	}
 
@@ -16,4 +72,17 @@ public class UpdateTask implements ITask {
 
 	}
 
+	/**
+	 * 日期字符串格式转换
+	 * @param dateStr
+	 * @return
+	 */
+	private String parseStringToDate() {
+		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	    Date date = new Date();
+	    long dInteger =date.getTime()-65000;
+		String daString = sdf.format(new Date(dInteger));
+	    return daString;
+		
+	}
 }