123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- 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 >= 5) {
- 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%' or modalities like '%DX%') order by createAt asc", parseStringToDateTo(), parseStringToDateFrom());
- if (studyidfinds == null) {
- return;
- }
- for (Record studyidfind : studyidfinds) {
- flag++;
- if (flag <= 5) {
- //状态4:下载中
- studyidfind.set("status", 4);
- studyidfind.set("updateAt", parseStringToDateTime());
- 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() - 5400000;
- 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;
- }
- }
|