刘韬 3 years ago
parent
commit
b0e8efe0cb
1 changed files with 50 additions and 8 deletions
  1. 50 8
      DataFusion/src/com/zskk/control/ViewController.java

+ 50 - 8
DataFusion/src/com/zskk/control/ViewController.java

@@ -5,6 +5,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -21,6 +22,8 @@ import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
 import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
 import com.jfinal.plugin.druid.DruidPlugin;
+import com.zskk.service.ServiceFactory;
+import com.zskk.service.ThreadPoolService;
 import com.zskk.tools.ExecUtil;
 import com.zskk.tools.XmlHelper;
 
@@ -46,14 +49,53 @@ public class ViewController extends Controller {
 	}
 	
 	public void exe() {
-		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;
-		}
-		this.renderText(execCmd);
-
+		Integer max = 5;
+		List<Record> count = Db.use("local").find("select * from study where status =4");
+		//同时下载的队列
+		Integer flag = count.size();
+		renderText(flag.toString());
+//		if (flag >= max) {
+//			return;
+//		}
+//		List<Record> studyidfinds = Db.use("local").find("select * from study where status =1 or status =2 order by createAt asc limit 6");
+//		if (studyidfinds == null) {
+//			return;
+//		}
+//		for (Record studyidfind : studyidfinds) {
+//			//延时3min获取
+//			Date dateNow = new Date();
+//			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//			try {
+//			Date dateCreate = sdf.parse(studyidfind.getStr("createAt"));
+//			if (dateNow.getTime() - dateCreate.getTime() <= 180000) {
+//				continue;
+//			}
+//			} catch (ParseException e) {
+//				// TODO Auto-generated catch block
+//				e.printStackTrace();
+//				continue;
+//			}
+//			flag++;
+//			if (flag > max) {
+//				break;
+//			}
+//			//状态4:下载中
+//			studyidfind.set("status", 4);
+//			Db.use("local").update("study", studyidfind);
+//			ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
+//			tService.execute(() -> {
+//				String execCmd = ExecUtil.execCmd("/zskk_system/other/cmove.sh " + studyidfind.getStr("studyuid"));
+//				if (execCmd.contains("Connection refused")) {
+//					//状态2:错误
+//					studyidfind.set("status", 2);
+//					Db.use("local").update("study", studyidfind);
+//				}else {
+//					//状态2:完成
+//					studyidfind.set("status", 3);
+//					Db.use("local").update("study", studyidfind);
+//				}
+//			});	
+//		}
 	}
 
 	public void testConn() {