|
@@ -0,0 +1,60 @@
|
|
|
+package com.zskk.task;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+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.DataService;
|
|
|
+import com.zskk.service.ServiceFactory;
|
|
|
+import com.zskk.service.ThreadPoolService;
|
|
|
+
|
|
|
+public class ReDownloadTask implements ITask {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ DataService dService = ServiceFactory.getService(DataService.class);
|
|
|
+ Record recordfind = Db.use("local").findFirst("select * from study where status=2 and modalities <>'US' and updateAt >'2025-04-15 00:00:00' order by createAt asc");
|
|
|
+ JSONArray array = dService.getImage(recordfind.getStr("accessionNumber"));
|
|
|
+ if (array==null) {
|
|
|
+ recordfind.set("status", 2);
|
|
|
+ Db.use("local").update("study",recordfind);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ recordfind.set("status", 4);
|
|
|
+ recordfind.set("imageNum", array.size());
|
|
|
+ recordfind.set("updateAt", getDateStr());
|
|
|
+ Db.use("local").update("study",recordfind);
|
|
|
+ for (Object object : array) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(object.toString());
|
|
|
+ String[] strings = jsonObject.getString("Path").split("\\\\");
|
|
|
+ dService.downloadFtpFile(jsonObject.getString("Path"), strings[1]);
|
|
|
+ }
|
|
|
+ recordfind.set("status", 3);
|
|
|
+ recordfind.set("updateAt", getDateStr());
|
|
|
+ Db.use("local").update("study",recordfind);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+ // 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;
|
|
|
+ timeString = sdf.format(date);
|
|
|
+ return timeString;
|
|
|
+ }
|
|
|
+}
|