|
@@ -5,30 +5,6 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.support.fss.FssHelper;
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageImpl;
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
-import org.springframework.data.domain.Pageable;
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
-import org.springframework.data.jpa.domain.Specification;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetUserReq;
|
|
@@ -48,17 +24,31 @@ import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.GetExamMapsReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.GetExamMapsResp;
|
|
|
import cn.com.qmth.examcloud.support.CacheConstants;
|
|
|
+import cn.com.qmth.examcloud.support.fss.FssHelper;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.*;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 导出任务相关接口
|
|
|
*/
|
|
|
@Service
|
|
|
public class ExportTaskServiceImpl implements ExportTaskService {
|
|
|
- private static int cacheTimeOut = 60 * 60;
|
|
|
- @Autowired
|
|
|
- private RedisClient redisClient;
|
|
|
+
|
|
|
+ private static int cacheTimeOut = 60 * 60;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisClient redisClient;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExportTaskRepo exportTaskRepo;
|
|
|
|
|
@@ -68,6 +58,10 @@ public class ExportTaskServiceImpl implements ExportTaskService {
|
|
|
@Autowired
|
|
|
private UserCloudService userCloudService;
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ExportTaskEntity> findExportTaskToDisposes() {
|
|
|
+ return exportTaskRepo.findExportTaskToDisposes();
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public ExportTaskEntity findExportTaskToDispose() {
|
|
@@ -89,8 +83,8 @@ public class ExportTaskServiceImpl implements ExportTaskService {
|
|
|
entity.setExamId(info.getExamId());
|
|
|
entity.setFilePath(info.getFilePath());
|
|
|
entity.setCreator(info.getCreator());
|
|
|
- if(info.getJsonParams()!=null&&info.getJsonParams().length()>980) {
|
|
|
- throw new StatusException("输入的导出条件过长!");
|
|
|
+ if (info.getJsonParams() != null && info.getJsonParams().length() > 980) {
|
|
|
+ throw new StatusException("输入的导出条件过长!");
|
|
|
}
|
|
|
entity.setExportParam(info.getJsonParams());
|
|
|
exportTaskRepo.save(entity);
|
|
@@ -280,35 +274,35 @@ public class ExportTaskServiceImpl implements ExportTaskService {
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ExportTaskEntity findById(Long taskId) {
|
|
|
- return GlobalHelper.getEntity(exportTaskRepo, taskId, ExportTaskEntity.class);
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public void stopExportTaskById(Long taskId) {
|
|
|
- ExportTaskEntity e=findById(taskId);
|
|
|
- if(e==null) {
|
|
|
- throw new StatusException("未找到任务");
|
|
|
- }
|
|
|
- if(!ExportTaskStatus.EXPORTING.equals(e.getStatus())) {
|
|
|
- throw new StatusException("只能终止导出中的任务");
|
|
|
- }
|
|
|
- e.setStatus(ExportTaskStatus.TERMINATING);
|
|
|
- exportTaskRepo.save(e);
|
|
|
- String key = CacheConstants.CACHE_OE_EXPORT_TASK_STOP + e.getId();
|
|
|
- redisClient.set(key, key, cacheTimeOut);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void checkStopExportTaskById(Long taskId) {
|
|
|
- String key = CacheConstants.CACHE_OE_EXPORT_TASK_STOP + taskId;
|
|
|
- String ob=redisClient.get(key,String.class);
|
|
|
- if(ob!=null) {
|
|
|
- redisClient.delete(key);
|
|
|
- throw new ExportTaskStopException();
|
|
|
- }
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public ExportTaskEntity findById(Long taskId) {
|
|
|
+ return GlobalHelper.getEntity(exportTaskRepo, taskId, ExportTaskEntity.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void stopExportTaskById(Long taskId) {
|
|
|
+ ExportTaskEntity e = findById(taskId);
|
|
|
+ if (e == null) {
|
|
|
+ throw new StatusException("未找到任务");
|
|
|
+ }
|
|
|
+ if (!ExportTaskStatus.EXPORTING.equals(e.getStatus())) {
|
|
|
+ throw new StatusException("只能终止导出中的任务");
|
|
|
+ }
|
|
|
+ e.setStatus(ExportTaskStatus.TERMINATING);
|
|
|
+ exportTaskRepo.save(e);
|
|
|
+ String key = CacheConstants.CACHE_OE_EXPORT_TASK_STOP + e.getId();
|
|
|
+ redisClient.set(key, key, cacheTimeOut);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void checkStopExportTaskById(Long taskId) {
|
|
|
+ String key = CacheConstants.CACHE_OE_EXPORT_TASK_STOP + taskId;
|
|
|
+ String ob = redisClient.get(key, String.class);
|
|
|
+ if (ob != null) {
|
|
|
+ redisClient.delete(key);
|
|
|
+ throw new ExportTaskStopException();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|