|
@@ -0,0 +1,104 @@
|
|
|
+package com.zskk.task;
|
|
|
+
|
|
|
+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 com.zskk.service.ServiceFactory;
|
|
|
+import com.zskk.service.ThreadPoolService;
|
|
|
+import com.zskk.tools.ExecUtil;
|
|
|
+
|
|
|
+public class ReCMoveTask implements ITask {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ List<Record> count = Db.use("local").find("select * from study where status =4");
|
|
|
+ //同时下载的队列
|
|
|
+ Integer flag = count.size();
|
|
|
+ if (flag >= 6) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //2小时到2天内的检查重新获取
|
|
|
+ List<Record> studyidfinds = Db.use("local").find("select * from study where status =3 and createAt between ? and ? and (modalities like '%CT%' or modalities like '%MR%') order by createAt asc", parseStringToDateTo(), parseStringToDateFrom());
|
|
|
+ if (studyidfinds == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Record studyidfind : studyidfinds) {
|
|
|
+ flag++;
|
|
|
+ if (flag > 6) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //状态4:下载中
|
|
|
+ studyidfind.set("status", 4);
|
|
|
+ Db.use("local").update("study", studyidfind);
|
|
|
+ String execCmd = ExecUtil.execCmd("/zskk_system/other/cmove.sh " + studyidfind.getStr("studyuid"));
|
|
|
+ if (execCmd.contains("Connection refused")) {
|
|
|
+ // 状态2:错误
|
|
|
+ studyidfind.set("status", 2);
|
|
|
+ studyidfind.set("updateAt", parseStringToDateTime());
|
|
|
+ Db.use("local").update("study", studyidfind);
|
|
|
+ } else {
|
|
|
+ // 状态5:重新下载完成
|
|
|
+ studyidfind.set("status", 5);
|
|
|
+ studyidfind.set("updateAt", parseStringToDateTime());
|
|
|
+ Db.use("local").update("study", studyidfind);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换
|
|
|
+ *
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDateFrom() {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date();
|
|
|
+ long dInteger = date.getTime() - 3600000;
|
|
|
+ String daString = sdf.format(new Date(dInteger));
|
|
|
+ return daString;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换
|
|
|
+ *
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDateTo() {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date();
|
|
|
+ long dInteger = date.getTime() - 172800000;
|
|
|
+ String daString = sdf.format(new Date(dInteger));
|
|
|
+ return daString;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换年月日时分秒
|
|
|
+ *
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDateTime() {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date();
|
|
|
+ String daString = sdf.format(date);
|
|
|
+ return daString;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|