|
@@ -3,9 +3,14 @@ package cn.iselab.mooctest.site.web.logic.impl;
|
|
import cn.iselab.mooctest.site.data.GeneralGradeDTO;
|
|
import cn.iselab.mooctest.site.data.GeneralGradeDTO;
|
|
import cn.iselab.mooctest.site.data.NodeExtends;
|
|
import cn.iselab.mooctest.site.data.NodeExtends;
|
|
import cn.iselab.mooctest.site.data.UploadRecordDTO;
|
|
import cn.iselab.mooctest.site.data.UploadRecordDTO;
|
|
-import cn.iselab.mooctest.site.models.UploadRecord;
|
|
|
|
-import cn.iselab.mooctest.site.service.*;
|
|
|
|
-import cn.iselab.mooctest.site.util.BeanFactory;
|
|
|
|
|
|
+import cn.iselab.mooctest.site.service.CatchService;
|
|
|
|
+import cn.iselab.mooctest.site.service.CaughtNodeService;
|
|
|
|
+import cn.iselab.mooctest.site.service.Exam2CaseService;
|
|
|
|
+import cn.iselab.mooctest.site.service.GeneralCalculateScoreService;
|
|
|
|
+import cn.iselab.mooctest.site.service.SubmitRecordService;
|
|
|
|
+import cn.iselab.mooctest.site.service.UserCatchService;
|
|
|
|
+import cn.iselab.mooctest.site.service.WeightGeneralService;
|
|
|
|
+import cn.iselab.mooctest.site.util.data.CacheUtil;
|
|
import cn.iselab.mooctest.site.util.data.JSONUtil;
|
|
import cn.iselab.mooctest.site.util.data.JSONUtil;
|
|
import cn.iselab.mooctest.site.web.data.forMongo.CaseGraphDTO;
|
|
import cn.iselab.mooctest.site.web.data.forMongo.CaseGraphDTO;
|
|
import cn.iselab.mooctest.site.web.data.forMongo.NodeCatch.CatchDTO;
|
|
import cn.iselab.mooctest.site.web.data.forMongo.NodeCatch.CatchDTO;
|
|
@@ -17,20 +22,17 @@ import cn.iselab.mooctest.site.web.exception.ServerException;
|
|
import cn.iselab.mooctest.site.web.logic.strategy.HighestStrategy;
|
|
import cn.iselab.mooctest.site.web.logic.strategy.HighestStrategy;
|
|
import cn.iselab.mooctest.site.web.logic.strategy.LatestStrategy;
|
|
import cn.iselab.mooctest.site.web.logic.strategy.LatestStrategy;
|
|
import cn.iselab.mooctest.site.web.logic.strategy.ScoreStrategy;
|
|
import cn.iselab.mooctest.site.web.logic.strategy.ScoreStrategy;
|
|
-import java.util.stream.Collectors;
|
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.context.ApplicationContext;
|
|
|
|
-import org.springframework.context.annotation.Scope;
|
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
-
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
|
/**
|
|
/**
|
|
* asyncTask
|
|
* asyncTask
|
|
@@ -42,9 +44,6 @@ import java.util.Map;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class GeneralCalculateScoreComponent {
|
|
public class GeneralCalculateScoreComponent {
|
|
|
|
|
|
-// 获取元node服务
|
|
|
|
- @Autowired
|
|
|
|
- CaseGraphService caseGraphService;
|
|
|
|
//获取被命中nodes的服务
|
|
//获取被命中nodes的服务
|
|
@Autowired
|
|
@Autowired
|
|
CaughtNodeService caughtNodeService;
|
|
CaughtNodeService caughtNodeService;
|
|
@@ -64,8 +63,8 @@ public class GeneralCalculateScoreComponent {
|
|
HighestStrategy highestStrategy;
|
|
HighestStrategy highestStrategy;
|
|
@Autowired
|
|
@Autowired
|
|
CatchService catchService;
|
|
CatchService catchService;
|
|
-
|
|
|
|
- private static Map<Long, CaseGraphDTO> basicNodeMap = new HashMap<>();
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ CacheUtil cacheUtil;
|
|
|
|
|
|
public void calculateGrade(long examId, long caseId, Long userId) throws
|
|
public void calculateGrade(long examId, long caseId, Long userId) throws
|
|
Exception {
|
|
Exception {
|
|
@@ -90,7 +89,7 @@ public class GeneralCalculateScoreComponent {
|
|
,null)).collect(Collectors.toList());
|
|
,null)).collect(Collectors.toList());
|
|
|
|
|
|
//通过元node和CatchDTOs计算每种类型的得分
|
|
//通过元node和CatchDTOs计算每种类型的得分
|
|
- CaseGraphDTO basicNode = getBasicNode(caseId);
|
|
|
|
|
|
+ CaseGraphDTO basicNode = cacheUtil.getMetaNode(caseId);
|
|
Map<String, Double> typeScoreMap = calculateTypeScore(basicNode,catchDTOS);
|
|
Map<String, Double> typeScoreMap = calculateTypeScore(basicNode,catchDTOS);
|
|
List<GeneralGradeDTO> gradeDTOList = new ArrayList<>();
|
|
List<GeneralGradeDTO> gradeDTOList = new ArrayList<>();
|
|
typeScoreMap.forEach((type,score) -> gradeDTOList.add(new GeneralGradeDTO(type,score,uploadId)));
|
|
typeScoreMap.forEach((type,score) -> gradeDTOList.add(new GeneralGradeDTO(type,score,uploadId)));
|
|
@@ -134,7 +133,7 @@ public class GeneralCalculateScoreComponent {
|
|
List<GeneralGradeDTO> generalGradeDTOList = new ArrayList<>();
|
|
List<GeneralGradeDTO> generalGradeDTOList = new ArrayList<>();
|
|
|
|
|
|
//元node数据
|
|
//元node数据
|
|
- CaseGraphDTO basicNode = getBasicNode(caseId);
|
|
|
|
|
|
+ CaseGraphDTO basicNode = cacheUtil.getMetaNode(caseId);
|
|
|
|
|
|
if (basicNode != null && userCatchDTOS != null && userCatchDTOS.size() != 0) {
|
|
if (basicNode != null && userCatchDTOS != null && userCatchDTOS.size() != 0) {
|
|
for (UserCatchDTO userCatchDTO : userCatchDTOS) {
|
|
for (UserCatchDTO userCatchDTO : userCatchDTOS) {
|
|
@@ -160,6 +159,9 @@ public class GeneralCalculateScoreComponent {
|
|
private Map<String,Double> calculateTypeScore(CaseGraphDTO basicNode, List<CatchDTO>
|
|
private Map<String,Double> calculateTypeScore(CaseGraphDTO basicNode, List<CatchDTO>
|
|
catchDTOs){
|
|
catchDTOs){
|
|
Map<String, Double> typeScoreMap = new HashMap<>();
|
|
Map<String, Double> typeScoreMap = new HashMap<>();
|
|
|
|
+ if(basicNode == null || catchDTOs == null){
|
|
|
|
+ return typeScoreMap;
|
|
|
|
+ }
|
|
for (Node node : basicNode.getNodes()) {
|
|
for (Node node : basicNode.getNodes()) {
|
|
for (CatchDTO catchDTO : catchDTOs) {
|
|
for (CatchDTO catchDTO : catchDTOs) {
|
|
if (node.getName().equals(catchDTO.getNodeName())) {//用户命中了该node
|
|
if (node.getName().equals(catchDTO.getNodeName())) {//用户命中了该node
|
|
@@ -287,16 +289,4 @@ public class GeneralCalculateScoreComponent {
|
|
calculateGradeCurrent(uploadId,examId,caseId,userId,caughtNodeDTOs);
|
|
calculateGradeCurrent(uploadId,examId,caseId,userId,caughtNodeDTOs);
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- private CaseGraphDTO getBasicNode(long caseId){
|
|
|
|
- CaseGraphDTO basicNode = basicNodeMap.get(caseId);
|
|
|
|
- if(basicNode == null){
|
|
|
|
- basicNode = caseGraphService.getCaseGraph(caseId);
|
|
|
|
- if(basicNode == null){
|
|
|
|
- throw new ServerException(ServerCode.META_NODE_NOT_EXIST);
|
|
|
|
- }
|
|
|
|
- basicNodeMap.put(caseId,basicNode);
|
|
|
|
- }
|
|
|
|
- return basicNode;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|