|
@@ -8,8 +8,10 @@ import cn.iselab.mooctest.site.data.UserDTOForMT;
|
|
|
import cn.iselab.mooctest.site.models.AssignedTask;
|
|
|
import cn.iselab.mooctest.site.models.Weight;
|
|
|
import cn.iselab.mooctest.site.service.*;
|
|
|
+import cn.iselab.mooctest.site.service.updownload.DownloadService;
|
|
|
import cn.iselab.mooctest.site.web.data.MutationJobVO;
|
|
|
import cn.iselab.mooctest.site.web.data.MutationProgressVO;
|
|
|
+import cn.iselab.mooctest.site.web.data.forMongo.AsyncJobDTO;
|
|
|
import cn.iselab.mooctest.site.web.data.forMongo.AsyncTaskDTO;
|
|
|
import cn.iselab.mooctest.site.web.exception.HttpBadRequestException;
|
|
|
import cn.iselab.mooctest.site.web.logic.BaseLogic;
|
|
@@ -19,6 +21,7 @@ import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -52,6 +55,9 @@ public class MutationProgressLogicImpl extends BaseLogic implements MutationProg
|
|
|
@Autowired
|
|
|
CaseService caseService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DownloadService downloadService;
|
|
|
+
|
|
|
@Override
|
|
|
public MutationProgressVO getMutationProgress(Long examId, Long caseId) {
|
|
|
AsyncTaskDTO asyncTaskDTO = asyncTaskService.getAsyncTask(AsyncJobTool.MUTATION, examId, caseId);
|
|
@@ -87,6 +93,33 @@ public class MutationProgressLogicImpl extends BaseLogic implements MutationProg
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public MutationProgressVO getMutationProgressForOne(Long examId, Long caseId, Long participantId){
|
|
|
+ AsyncTaskDTO asyncTaskDTO = asyncTaskService.getAsyncTaskForOne(AsyncJobTool.MUTATION, examId, caseId, participantId);
|
|
|
+ if (asyncTaskDTO == null) {
|
|
|
+ asyncTaskDTO = triggerOneMutation(examId, caseId, participantId);
|
|
|
+ }
|
|
|
+ Map<String, AsyncJobStatus> jobStatusMap = asyncScheduleService.getStatusMap(asyncTaskDTO.getSessionId());
|
|
|
+ AsyncJobDTO asyncJobDTO=asyncTaskDTO.getJobs().get(0);
|
|
|
+ Long userId= Long.parseLong(asyncJobDTO.getContexts().get("userId"));
|
|
|
+ UserDTOForMT tempUser=userService.findByUserId(userId);
|
|
|
+ MutationJobVO mutationJobVO = new MutationJobVO();
|
|
|
+ mutationJobVO.setJobId(asyncJobDTO.getJobId());
|
|
|
+ mutationJobVO.setStatus(asyncJobDTO.getStatus());
|
|
|
+ mutationJobVO.setUserId(Long.parseLong(asyncJobDTO.getContexts().get("userId")));
|
|
|
+ AsyncJobStatus tempStatus = jobStatusMap.get(asyncJobDTO.getJobId());
|
|
|
+ mutationJobVO.setProgressStatus(tempStatus!=null?tempStatus.getStatus():"");
|
|
|
+ mutationJobVO.setUserName(tempUser!=null?tempUser.getName():null);
|
|
|
+ List<MutationJobVO> jobVOS=new ArrayList<>();
|
|
|
+ jobVOS.add(mutationJobVO);
|
|
|
+ MutationProgressVO mutationProgressVO = new MutationProgressVO();
|
|
|
+ mutationProgressVO.setSessionId(asyncTaskDTO.getSessionId());
|
|
|
+ mutationProgressVO.setExamId(examId);
|
|
|
+ mutationProgressVO.setCaseId(caseId);
|
|
|
+ mutationProgressVO.setJobs(jobVOS);
|
|
|
+ return mutationProgressVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public boolean stopMutation(String taskId) {
|
|
|
return asyncScheduleService.stop(taskId);
|
|
|
}
|
|
@@ -121,15 +154,19 @@ public class MutationProgressLogicImpl extends BaseLogic implements MutationProg
|
|
|
}
|
|
|
List<Map<String, String>> params;
|
|
|
List<Map<String, String>> contexts;
|
|
|
- List<AssignedTask> assignedTasks = assignedTaskService.getSubmittedRecordsByExamId(examId);
|
|
|
- params = assignedTasks.stream().map(assignedTask -> {
|
|
|
+ List<AssignedTask> assignedTasks = assignedTaskService.getSubmittedRecordsByExamId(examId).subList(0,1);
|
|
|
+ params = assignedTasks.stream()
|
|
|
+ .filter(assignedTask -> downloadService.generateUrlForDevAnalysis(examId,caseId,caseService.getCaseById(caseId).getName())!=null)
|
|
|
+ .map(assignedTask -> {
|
|
|
Map<String, String> param = new HashedMap();
|
|
|
- String downloadUrl = pluginLogic.getAnalysisSignature(examId,caseId,caseService.getCaseById(caseId).getName());
|
|
|
+ String downloadUrl = downloadService.generateUrlForDevAnalysis(examId,caseId,caseService.getCaseById(caseId).getName());
|
|
|
param.put("downloadURL", downloadUrl);
|
|
|
param.put("extraArgs", generateNodeExtraArgs(downloadUrl));
|
|
|
return param;
|
|
|
}).collect(Collectors.toList());
|
|
|
- contexts = assignedTasks.stream().map(assignedTask -> {
|
|
|
+ contexts = assignedTasks.stream()
|
|
|
+ .filter(assignedTask -> downloadService.generateUrlForDevAnalysis(examId,caseId,caseService.getCaseById(caseId).getName())!=null)
|
|
|
+ .map(assignedTask -> {
|
|
|
Map<String, String> param = new HashedMap();
|
|
|
param.put("examId", examId.toString());
|
|
|
param.put("caseId", caseId.toString());
|
|
@@ -141,6 +178,32 @@ public class MutationProgressLogicImpl extends BaseLogic implements MutationProg
|
|
|
return asyncScheduleService.start(AsyncJobTool.MUTATION, params,contexts,MutationCallBack.class);
|
|
|
}
|
|
|
|
|
|
+ private AsyncTaskDTO triggerOneMutation(Long examId, Long caseId, Long participantId) {
|
|
|
+ if (weightService.getWeightByTidAndCid(examId, caseId) == null) {
|
|
|
+ throw new HttpBadRequestException("unmatched examId and caseId");
|
|
|
+ }
|
|
|
+ Weight weight = weightService.getWeightByTidAndCid(examId, caseId);
|
|
|
+ if (weight.getMutation() == 0) {
|
|
|
+ throw new HttpBadRequestException(caseId + "'s 变异分析 is 0");
|
|
|
+ }
|
|
|
+ List<Map<String, String>> params=new ArrayList<>();
|
|
|
+ List<Map<String, String>> contexts=new ArrayList<>();
|
|
|
+ AssignedTask assignedTask = assignedTaskService.getAssignedTask(examId,participantId);
|
|
|
+ Map<String, String> param = new HashedMap();
|
|
|
+ String downloadUrl = downloadService.generateUrlForDevAnalysis(examId,caseId,caseService.getCaseById(caseId).getName());
|
|
|
+ param.put("downloadURL", downloadUrl);
|
|
|
+ param.put("extraArgs", generateNodeExtraArgs(downloadUrl));
|
|
|
+ params.add(param);
|
|
|
+ Map<String, String> context = new HashedMap();
|
|
|
+ param.put("examId", examId.toString());
|
|
|
+ param.put("caseId", caseId.toString());
|
|
|
+ param.put("userId", assignedTask.getParticipantId().toString());
|
|
|
+ param.put("type", MutationResultType.MUTAION_NODE);
|
|
|
+ contexts.add(context);
|
|
|
+
|
|
|
+ return asyncScheduleService.start(AsyncJobTool.MUTATION, params,contexts,MutationCallBack.class);
|
|
|
+ }
|
|
|
+
|
|
|
private String generateNodeExtraArgs(String downloadUrl){
|
|
|
String zipName = downloadUrl.split("/")[downloadUrl.split("/").length - 1];
|
|
|
return "-F "+ zipName + " -T "+MutationResultType.MUTAION_NODE;
|