|
@@ -0,0 +1,79 @@
|
|
|
+package com.zskk.task;
|
|
|
+
|
|
|
+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 >= 8) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //延迟10分钟获取影像,并且查找状态为待CMOVE和错误状态的检查
|
|
|
+ List<Record> studyidfinds = Db.use("local").find("select * from study where status =3 and modalities='CT' and modalities='MR' and createAt<? order by createAt asc",parseStringToDate());
|
|
|
+ if (studyidfinds == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Record studyidfind : studyidfinds) {
|
|
|
+ flag++;
|
|
|
+ if (flag > 10) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //状态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 {
|
|
|
+ //状态5:重新下载完成
|
|
|
+ studyidfind.set("status", 5);
|
|
|
+ Db.use("local").update("study", studyidfind);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换
|
|
|
+ *
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDate() {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date();
|
|
|
+ long dInteger = date.getTime() - 7200000;
|
|
|
+ String daString = sdf.format(new Date(dInteger));
|
|
|
+ return daString;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|