|
@@ -1,5 +1,10 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -11,7 +16,10 @@ import cn.com.qmth.examcloud.core.oe.admin.api.request.DeleteExamScoreQueueReq;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.GetTopExamScoreQueueReq;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetTopExamScoreQueueResp;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.base.utils.DateUtils;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreNoticeQueueRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreObtainQueueRepo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScoreNoticeQueueEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScoreObtainQueueEntity;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
@@ -21,44 +29,80 @@ import io.swagger.annotations.ApiOperation;
|
|
|
@Api(tags = "考试分数队列接口")
|
|
|
@RestController
|
|
|
@RequestMapping("${$rmp.cloud.oe}/examScoreObtainQueue")
|
|
|
-public class ExamScoreObtainQueueCloudServiceProvider extends ControllerSupport implements ExamScoreObtainQueueCloudService{
|
|
|
+public class ExamScoreObtainQueueCloudServiceProvider extends ControllerSupport
|
|
|
+ implements ExamScoreObtainQueueCloudService {
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 9204539038969246524L;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamScoreObtainQueueRepo examScoreObtainQueueRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamScoreNoticeQueueRepo examScoreNoticeQueueRepo;
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
- private static final long serialVersionUID = 9204539038969246524L;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExamScoreObtainQueueRepo examScoreObtainQueueRepo;
|
|
|
-
|
|
|
- @Override
|
|
|
- @ApiOperation(value = "获取当前机构分数队列顶层记录")
|
|
|
- @PostMapping("/getTopExamScoreQueue")
|
|
|
- public GetTopExamScoreQueueResp getTopExamScoreQueue(@RequestBody GetTopExamScoreQueueReq req) {
|
|
|
- Check.isNull(req.getRootOrgId(), "顶级机构ID不能为空");
|
|
|
- ExamScoreObtainQueueEntity examScoreObtainQueue = examScoreObtainQueueRepo.findTopByRootOrgIdAndIsValidOrderByIdAsc(req.getRootOrgId(), true);
|
|
|
- GetTopExamScoreQueueResp getTopExamScoreQueueResp = new GetTopExamScoreQueueResp();
|
|
|
- getTopExamScoreQueueResp.setIsEmpty(true);
|
|
|
- if(examScoreObtainQueue!=null){
|
|
|
- getTopExamScoreQueueResp.setExamId(examScoreObtainQueue.getExamId());
|
|
|
- getTopExamScoreQueueResp.setQueueId(examScoreObtainQueue.getId());
|
|
|
- getTopExamScoreQueueResp.setExamRecordDataId(examScoreObtainQueue.getExamRecordDataId());
|
|
|
- getTopExamScoreQueueResp.setIsEmpty(false);
|
|
|
- }
|
|
|
- return getTopExamScoreQueueResp;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ @ApiOperation(value = "获取当前机构分数队列顶层记录")
|
|
|
+ @PostMapping("/getTopExamScoreQueue")
|
|
|
+ public GetTopExamScoreQueueResp getTopExamScoreQueue(@RequestBody GetTopExamScoreQueueReq req) {
|
|
|
+ Check.isNull(req.getRootOrgId(), "顶级机构ID不能为空");
|
|
|
+ ExamScoreObtainQueueEntity examScoreObtainQueue = examScoreObtainQueueRepo
|
|
|
+ .findTopByRootOrgIdAndIsValidOrderByIdAsc(req.getRootOrgId(), true);
|
|
|
+ GetTopExamScoreQueueResp getTopExamScoreQueueResp = new GetTopExamScoreQueueResp();
|
|
|
+ getTopExamScoreQueueResp.setIsEmpty(true);
|
|
|
+ if (examScoreObtainQueue != null) {
|
|
|
+ getTopExamScoreQueueResp.setExamId(examScoreObtainQueue.getExamId());
|
|
|
+ getTopExamScoreQueueResp.setQueueId(examScoreObtainQueue.getId());
|
|
|
+ getTopExamScoreQueueResp.setExamRecordDataId(examScoreObtainQueue.getExamRecordDataId());
|
|
|
+ getTopExamScoreQueueResp.setIsEmpty(false);
|
|
|
+ }
|
|
|
+ return getTopExamScoreQueueResp;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- @ApiOperation(value = "删除分数队列记录")
|
|
|
- @PostMapping("/deleteExamScoreQueue")
|
|
|
- public void deleteExamScoreQueue(@RequestBody DeleteExamScoreQueueReq req) {
|
|
|
- Check.isNull(req.getQueueId(), "队列ID不能为空");
|
|
|
- Check.isNull(req.getRootOrgId(), "顶级机构ID不能为空");
|
|
|
- ExamScoreObtainQueueEntity examScoreObtainQueue =GlobalHelper.getEntity(examScoreObtainQueueRepo,req.getQueueId(),ExamScoreObtainQueueEntity.class);
|
|
|
- if(examScoreObtainQueue!=null && examScoreObtainQueue.getRootOrgId().equals(req.getRootOrgId())){
|
|
|
- examScoreObtainQueue.setIsValid(false);
|
|
|
- examScoreObtainQueueRepo.save(examScoreObtainQueue);
|
|
|
- }
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ @ApiOperation(value = "删除分数队列记录")
|
|
|
+ @PostMapping("/deleteExamScoreQueue")
|
|
|
+ public void deleteExamScoreQueue(@RequestBody DeleteExamScoreQueueReq req) {
|
|
|
+ Check.isNull(req.getQueueId(), "队列ID不能为空");
|
|
|
+ Check.isNull(req.getRootOrgId(), "顶级机构ID不能为空");
|
|
|
+ ExamScoreObtainQueueEntity examScoreObtainQueue = GlobalHelper.getEntity(examScoreObtainQueueRepo,
|
|
|
+ req.getQueueId(), ExamScoreObtainQueueEntity.class);
|
|
|
+ if (examScoreObtainQueue != null && examScoreObtainQueue.getRootOrgId().equals(req.getRootOrgId())) {
|
|
|
+ examScoreObtainQueue.setIsValid(false);
|
|
|
+ examScoreObtainQueueRepo.save(examScoreObtainQueue);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 定时更新获取分数通知队列
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "定时更新获取分数通知队列")
|
|
|
+ @PostMapping("/updateObtainScoreNodifyQueue")
|
|
|
+ @Override
|
|
|
+ public void updateObtainScoreNodifyQueue() {
|
|
|
+ Date now = new Date();
|
|
|
+ Date twoHoursBefore = DateUtils.addHours(now, -2);
|
|
|
+ // 1.查找超过创建超过2小时,且通知队列中不存在的待获取的数据
|
|
|
+ List<ExamScoreObtainQueueEntity> toObtainQueueList = examScoreObtainQueueRepo
|
|
|
+ .findByCreationTimeLessThanEquals(twoHoursBefore);
|
|
|
+ // 1.1如果不存在,不作任何处理
|
|
|
+ if (toObtainQueueList == null || toObtainQueueList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 1.2如果存在,则创建相应组织机构的通知队列
|
|
|
+ List<Long> rootOrgList = toObtainQueueList.stream().map(ExamScoreObtainQueueEntity::getRootOrgId).distinct()
|
|
|
+ .collect(Collectors.<Long> toList());
|
|
|
+ List<ExamScoreNoticeQueueEntity> noticeQueueEntityList = new ArrayList<ExamScoreNoticeQueueEntity>();
|
|
|
+ rootOrgList.forEach(ro -> {
|
|
|
+ ExamScoreNoticeQueueEntity noticeQueueEntity = new ExamScoreNoticeQueueEntity();
|
|
|
+ noticeQueueEntity.setRootOrgId(ro);
|
|
|
+ noticeQueueEntity.setCreationTime(now);
|
|
|
+ noticeQueueEntityList.add(noticeQueueEntity);
|
|
|
+ });
|
|
|
+ // 批量插入通知队列
|
|
|
+ examScoreNoticeQueueRepo.saveAll(noticeQueueEntityList);
|
|
|
+ }
|
|
|
}
|