刘韬 2 years ago
parent
commit
1bcfce7134

+ 5 - 0
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.DownloadTask;
 import com.zskk.task.StudyTask;
 import com.zskk.task.UpdateTask;
 
@@ -109,6 +110,10 @@ public class ZskkConfig extends JFinalConfig {
 		Cron4jPlugin suData = new Cron4jPlugin();
 		suData.addTask("*/2 * * * *", new StudyTask());
 		me.add(suData);
+		
+		Cron4jPlugin dnData = new Cron4jPlugin();
+		dnData.addTask("*/1 * * * *", new DownloadTask());
+		me.add(dnData);
 	}
 
 	@Override

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

@@ -89,7 +89,7 @@ public class DataService {
      * 下载文件夹
      */
     public void downloadFtpFile(String remoteFileName) {
-        FTPClient ftpClient = new FTPClient();
+    	FTPClient ftpClient = new FTPClient();
         int reply;
         try {
             ftpClient.connect(PropKit.get("ftp_host"), PropKit.getInt("ftp_port"));
@@ -110,8 +110,6 @@ public class DataService {
                  //ftp中文名需要iso-8859-1字符
                  boolean flag2 = ftpClient.retrieveFile(remoteFileName+File.separatorChar+allFile[i].getName(), os);
                  if (!flag2) {
-//                 	fileName=fileName+ allFile[i].getName();
-
                      System.out.println("没有找到" + remoteFileName + "---该文件");
                      localFile.delete();
                  } else {

+ 10 - 9
DataFusion/src/com/zskk/task/DownloadTask.java

@@ -25,17 +25,17 @@ public class DownloadTask implements ITask {
 		Record recordfind = Db.use("local").findFirst("select * from study where status=1 order by createAt asc");
 //		recordfind.set("status", 2);
 //		Db.use("local").update("study", recordfind);
-		
+
 		recordfind.set("status", 4);
 		recordfind.set("updateAt", getDateStr());
-		Db.use("local").update("study",recordfind);
+		Db.use("local").update("study", recordfind);
 //			JSONObject jsonObject = JSON.parseObject(object.toString());
 //			String[] strings = jsonObject.getString("Path").split("\\\\");
-			dService.downloadFtpFile(recordfind.getStr("path"));
+		dService.downloadFtpFile(recordfind.getStr("path"));
 //		}
 		recordfind.set("status", 3);
 		recordfind.set("updateAt", getDateStr());
-		Db.use("local").update("study",recordfind);
+		Db.use("local").update("study", recordfind);
 	}
 
 	@Override
@@ -43,18 +43,19 @@ public class DownloadTask implements ITask {
 		// TODO Auto-generated method stub
 
 	}
-	
+
 	/**
 	 * 日期字符串格式转换
+	 * 
 	 * @param dateStr
 	 * @return
 	 */
 	private String getDateStr() {
-		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-	    Date date = new Date();
-	    String timeString = null;
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		Date date = new Date();
+		String timeString = null;
 		timeString = sdf.format(date);
-        return timeString;
+		return timeString;
 	}
 
 }