刘韬 4 jaren geleden
bovenliggende
commit
c64420f0c8

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

@@ -18,6 +18,7 @@ import com.jfinal.template.Engine;
 import com.zskk.control.ViewController;
 import com.zskk.service.ServiceFactory;
 import com.zskk.task.DataTask;
+import com.zskk.task.UpdateTask;
 
 public class ZskkConfig extends JFinalConfig {
 
@@ -68,14 +69,18 @@ public class ZskkConfig extends JFinalConfig {
 		me.add(druidPluginConnected);
 //
 //		// 配置ActiveRecord插件
-		ActiveRecordPlugin arpConnected = new ActiveRecordPlugin("connected", druidPluginConnected);
-		arpConnected.setDialect(new MysqlDialect());
-		me.add(arpConnected);
+//		ActiveRecordPlugin arpConnected = new ActiveRecordPlugin("connected", druidPluginConnected);
+//		arpConnected.setDialect(new MysqlDialect());
+//		me.add(arpConnected);
 
 		
 //		Cron4jPlugin cpData = new Cron4jPlugin();
 //		cpData.addTask("*/5 * * * *", new DataTask());
 //		me.add(cpData);
+		
+		Cron4jPlugin cpData = new Cron4jPlugin();
+		cpData.addTask("*/5 * * * *", new UpdateTask());
+		me.add(cpData);
 	}
 
 	@Override
@@ -97,8 +102,8 @@ public class ZskkConfig extends JFinalConfig {
 		ServiceFactory.init();
 	}
 	
-//	public static void main(String[] args) {
-//		JFinal.start("WebRoot", 10002, "/", 5);
-//	}
+	public static void main(String[] args) {
+		JFinal.start("WebRoot", 10002, "/", 5);
+	}
 
 }

+ 17 - 1
DataFusion/src/com/zskk/service/DataService.java

@@ -19,6 +19,7 @@ import jcifs.smb.NtlmPasswordAuthentication;
 import jcifs.smb.SmbFile;
 import jcifs.smb.SmbFileInputStream;
 import okhttp3.FormBody;
+import okhttp3.MediaType;
 import okhttp3.OkHttpClient;
 import okhttp3.Request;
 import okhttp3.RequestBody;
@@ -31,6 +32,7 @@ public class DataService {
     private static String SAVE_REPORT_URL = "https://risserver3.pacsonline.cn/butt/saveReport";
 	
     private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
+    public static final MediaType MEDIA_TYPE_MARKDOWN = MediaType.parse("text/x-markdown; charset=utf-8");
     
     /**
      * 获取未出报告的检查列表
@@ -92,6 +94,7 @@ public class DataService {
         try {
             SmbFile remoteFile = new SmbFile(remoteUrl + shareFolderPath + File.separator + fileName);
             File localFile = new File(localDir + File.separator + fileName);
+            localFile.getParentFile().mkdirs();
             in = new BufferedInputStream(new SmbFileInputStream(remoteFile));
             out = new BufferedOutputStream(new FileOutputStream(localFile));
             byte[] buffer = new byte[1024];
@@ -105,6 +108,19 @@ public class DataService {
             try {
                 out.close();
                 in.close();
+                System.out.print("11");
+                File localFile = new File(localDir + File.separator + fileName);
+
+                Request request = new Request.Builder()
+                    .url("https://api.github.com/markdown/raw")
+                    .post(RequestBody.create(MEDIA_TYPE_MARKDOWN, localFile))
+                    .build();
+
+                try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
+                  if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
+
+                  System.out.println(response.body().string());
+                }
             } catch (IOException e) {
                 e.printStackTrace();
             }
@@ -116,7 +132,7 @@ public class DataService {
 //    	map.put("institution_id", "47600001");
 //    	map.put("num", "10");
 //		postWithParameters(GET_EXAM_URL, map);
-    	downloadFileToFolder("smb://192.168.129.120", "/JIMAGE/20721103/29", "B4446F3F", "/Users/liutao/Desktop/GIT_CODE");
+    	downloadFileToFolder("smb://"+"hao:"+"123456@" +"192.168.31.150", "/share/pagkage", "factor1.py", "./tempImg");
 	}
 
 }

+ 26 - 1
DataFusion/src/com/zskk/task/UpdateTask.java

@@ -1,13 +1,32 @@
 package com.zskk.task;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jfinal.plugin.activerecord.Db;
+import com.jfinal.plugin.activerecord.Record;
 import com.jfinal.plugin.cron4j.ITask;
+import com.zskk.service.ServiceFactory;
+import com.zskk.service.ThreadPoolService;
 
 public class UpdateTask implements ITask {
 
 	@Override
 	public void run() {
 		// TODO Auto-generated method stub
-
+		JSONArray jsonArray = null;	
+        for (Object object : jsonArray) {
+        	String spString = "\\\\\\11\\22\\33\\44";
+        	String[] spStrings = spString.split("\\\\");
+        	
+			ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
+			tService.execute(() -> {
+//				dService.saveReport(params);
+			});	
+        }
 	}
 
 	@Override
@@ -16,4 +35,10 @@ public class UpdateTask implements ITask {
 
 	}
 
+	public static void main(String[] args) {
+		String dString = "\\\\11\\223344\\d";
+    	String[] fdStrings = dString.split("\\\\");
+//		String dString2 = dString.replaceAll("\\\", ",");
+    	System.out.print(fdStrings[fdStrings.length-1]);
+	}
 }