|
@@ -8,18 +8,19 @@ import api.common.pojo.param.project.ProjectTaskParam;
|
|
|
import api.common.pojo.param.project.SceneScoreParam;
|
|
|
import api.common.pojo.param.project.SimulationManualProjectKafkaParam;
|
|
|
import api.common.pojo.param.project.SimulationManualProjectParam;
|
|
|
+import api.common.pojo.param.system.DictParam;
|
|
|
import api.common.pojo.po.project.*;
|
|
|
import api.common.pojo.vo.project.*;
|
|
|
import api.common.util.JsonUtil;
|
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
|
import com.css.simulation.resource.project.constants.ProjectConstants;
|
|
|
-import com.css.simulation.resource.project.enums.EvaluationLevelEnum;
|
|
|
import com.css.simulation.resource.project.enums.ProjectRunStateEnum;
|
|
|
import com.css.simulation.resource.project.enums.SceneTypeEnum;
|
|
|
import com.css.simulation.resource.project.feign.KafkaService;
|
|
|
import com.css.simulation.resource.project.mapper.SimulationProjectMapper;
|
|
|
import com.css.simulation.resource.project.service.SimulationProjectService;
|
|
|
+import com.css.simulation.resource.system.service.DictService;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.SneakyThrows;
|
|
@@ -29,10 +30,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
@@ -43,6 +41,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
@Autowired
|
|
|
private KafkaService kafkaService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DictService dictService;
|
|
|
+
|
|
|
private String[] dateFmtArr= new String[]{"yyyyMMdd", "yyyy-MM-dd HH:mm:ss","yyyy-MM-dd"};
|
|
|
|
|
|
@Override
|
|
@@ -247,11 +248,18 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
}
|
|
|
ProjectDetailsVo projectDetailsVo = new ProjectDetailsVo();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//项目基本信息
|
|
|
SimulationManualProjectPo po = simulationProjectMapper.selectProjectById(param);
|
|
|
if(po == null){
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "没有获取到数据");
|
|
|
}
|
|
|
+
|
|
|
+ //评测等级
|
|
|
+ String s = getEvaluationLevel(po);
|
|
|
+
|
|
|
//算法配置
|
|
|
String algorithmId = po.getAlgorithm();
|
|
|
AlgorithmBaseInfoVo algorithmBaseInfoVo = simulationProjectMapper.selectAlgorithmBaseInfoById(algorithmId).get(0);
|
|
@@ -345,8 +353,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
projectDetailsVo.setProjectDescribe(po.getProjectDescribe());
|
|
|
projectDetailsVo.setStartTime(getRqStr(po.getStartTime(),1));
|
|
|
projectDetailsVo.setFinishTime(getRqStr(po.getFinishTime(),1));
|
|
|
- projectDetailsVo.setNowRunState(ProjectRunStateEnum.getState(po.getNowRunState()));
|
|
|
- projectDetailsVo.setEvaluationLevel(EvaluationLevelEnum.getState(po.getEvaluationLevel()));
|
|
|
+ projectDetailsVo.setNowRunState(getDictName(DictConstants.PROJECT_RUN_STATE, po.getNowRunState()));
|
|
|
+// projectDetailsVo.setEvaluationLevel(getDictName(DictConstants.EVALUATION_LEVEL, po.getEvaluationLevel()));
|
|
|
+ projectDetailsVo.setEvaluationLevel(s);
|
|
|
if(algorithmBaseInfoVo != null){
|
|
|
projectDetailsVo.setAlgorithmName(algorithmBaseInfoVo.getAlgorithmName());
|
|
|
projectDetailsVo.setAlgorithmDescribe(algorithmBaseInfoVo.getDescription());
|
|
@@ -418,7 +427,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
Integer totalSceneScoreNum = 0;
|
|
|
|
|
|
for(ScenePackageSubListVO v : scenePackageSubListVOS){
|
|
|
- stringBuffer.append(v+"、");
|
|
|
+ stringBuffer.append(v.getSublistName()+"、");
|
|
|
AlgorithmScoreVo algorithmScoreVo = new AlgorithmScoreVo();
|
|
|
algorithmScoreVo.setProjectName(v.getSublistName());
|
|
|
Integer sceneNum = v.getSceneNum();
|
|
@@ -430,15 +439,17 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo = new SimulationMptFirstTargetScorePo();
|
|
|
simulationMptFirstTargetScorePo.setPId(po.getId());
|
|
|
simulationMptFirstTargetScorePo.setTarget(v.getSublistId());
|
|
|
+ //单个二级指标得分
|
|
|
SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo1 = simulationProjectMapper.selectFirstTargetScore(simulationMptFirstTargetScorePo);
|
|
|
Double score = simulationMptFirstTargetScorePo1.getScore();
|
|
|
- totalScore += score*weightDouble;
|
|
|
+ totalScore += score*(weightDouble/100);
|
|
|
algorithmScoreVo.setScore(saveTwoDecimalPlaces(score));
|
|
|
// totalWeight +=aDouble;
|
|
|
- Integer num = v.getSceneNum();
|
|
|
- Integer scoreNum = getSetScoreNum(po.getId());
|
|
|
+// Integer num = v.getSceneNum();
|
|
|
+ //获取得分不为0的场景数量
|
|
|
+ Integer scoreNum = getSetScoreNum(v.getSublistId(),po.getId());
|
|
|
totalSceneScoreNum += scoreNum;
|
|
|
- algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(Double.valueOf(num/scoreNum)));
|
|
|
+ algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(Double.valueOf(scoreNum)/Double.valueOf(sceneNum)*100));
|
|
|
algorithmScoreVoList.add(algorithmScoreVo);
|
|
|
}
|
|
|
//汇总
|
|
@@ -446,10 +457,10 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
algorithmScoreVo.setProjectName("汇总");
|
|
|
algorithmScoreVo.setSceneNum(totalSceneNum);
|
|
|
// algorithmScoreVo.setWeight(saveTwoDecimalPlaces(totalWeight).toString());
|
|
|
- //指标权重总和默认是1
|
|
|
- algorithmScoreVo.setWeight("1");
|
|
|
+ //指标权重总和默认是100%
|
|
|
+ algorithmScoreVo.setWeight("100");
|
|
|
algorithmScoreVo.setScore(saveTwoDecimalPlaces(totalScore));
|
|
|
- totalScoreRatio = Double.valueOf(totalSceneScoreNum/totalSceneNum);
|
|
|
+ totalScoreRatio = Double.valueOf(totalSceneScoreNum)/Double.valueOf(totalSceneNum)*100;
|
|
|
algorithmScoreVo.setScoreRatio(saveTwoDecimalPlaces(totalScoreRatio));
|
|
|
algorithmScoreVoList.add(algorithmScoreVo);
|
|
|
|
|
@@ -471,7 +482,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
projectReportVo.setEvaluationGrade(evaluationLevelReport);
|
|
|
|
|
|
//算法测试评分细则、详细得分情况
|
|
|
- List<ScenePackageSubListVO> scenePackageSubListVOS1 = selectScenePackageSubListTreeAndSetScore(null, true, po.getScene(), po.getId(), 1);
|
|
|
+ List<ScenePackageSubListVO> scenePackageSubListVOS1 = selectScenePackageSubListTreeAndSetScore(null, true, po.getScene(), po.getId(), 2);
|
|
|
projectReportVo.setSceneScoreList(scenePackageSubListVOS1);
|
|
|
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS, projectReportVo);
|
|
@@ -559,6 +570,18 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,null,systemUserVo.getCpuAvailableNumber());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String getDictName(String type, String code) {
|
|
|
+ DictParam dictParam = new DictParam();
|
|
|
+ dictParam.setDictTypes(type);
|
|
|
+ Map<String, Map<String, String>> dictMapsByTypes = dictService.getDictMapsByTypes(dictParam);
|
|
|
+ Map<String, String> stringStringMap = dictMapsByTypes.get(type);
|
|
|
+ if(stringStringMap != null && stringStringMap.size() > 0){
|
|
|
+ return stringStringMap.get(code);
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据场景id和场景类型获取场景名
|
|
|
* @return
|
|
@@ -676,8 +699,8 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
AlgorithmBaseInfoVo algorithmBaseInfoVo = algorithmBaseInfoVos.get(0);
|
|
|
vo.setAlgorithm(algorithmBaseInfoVo.getAlgorithmName());
|
|
|
}
|
|
|
- vo.setNowRunStateDict(ProjectRunStateEnum.getState(vo.getNowRunState()));
|
|
|
- vo.setEvaluationLevelDict(EvaluationLevelEnum.getState(vo.getEvaluationLevel()));
|
|
|
+ vo.setNowRunStateDict(getDictName(DictConstants.PROJECT_RUN_STATE, vo.getNowRunState()));
|
|
|
+ vo.setEvaluationLevelDict(getDictName(DictConstants.EVALUATION_LEVEL,vo.getEvaluationLevel()));
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
@@ -901,6 +924,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
|
|
|
//获取子节点集合
|
|
|
for(ScenePackageSubListVO pvo : parentVoList){
|
|
|
+
|
|
|
+ pvo.setLevel(level);
|
|
|
+
|
|
|
//二级指标获取总分
|
|
|
if(level == 2){
|
|
|
setFirstTargetScore(pvo,pId);
|
|
@@ -910,10 +936,10 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
if(!isEmpty(cvoList)){
|
|
|
//存入父节点集合中
|
|
|
pvo.setChildScenePackageSubListVOList(cvoList);
|
|
|
- pvo.setLevel(level);
|
|
|
//继续查找下一节点
|
|
|
selectScenePackageSubListTreeAndSetScore(cvoList,false, null, pId, level+1);
|
|
|
}else{
|
|
|
+
|
|
|
//没有子节点;最后一级,获取指标得分和指标下场景得分
|
|
|
setScore(pvo,pId);
|
|
|
}
|
|
@@ -934,15 +960,23 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
String sceneNaturalIds = vo.getSceneNaturalIds();
|
|
|
String sceneTrafficIds = vo.getSceneTrafficIds();
|
|
|
String sceneStatueIds = vo.getSceneStatueIds();
|
|
|
+ List<SceneScoreVo> sceneScoreVos = new ArrayList<>();
|
|
|
List<SceneScoreVo> NaturalSceneScoreVos = setSceneScore(vo, sceneNaturalIds, "1", pId);
|
|
|
List<SceneScoreVo> StatueSceneScoreVos = setSceneScore(vo, sceneStatueIds, "2", pId);
|
|
|
List<SceneScoreVo> TrafficSceneScoreVos = setSceneScore(vo, sceneTrafficIds, "3", pId);
|
|
|
///TODO 暂不支持泛化场景
|
|
|
|
|
|
//合成一个list
|
|
|
- NaturalSceneScoreVos.addAll(StatueSceneScoreVos);
|
|
|
- NaturalSceneScoreVos.addAll(TrafficSceneScoreVos);
|
|
|
- vo.setSceneScoreList(NaturalSceneScoreVos);
|
|
|
+ if(!isEmpty(NaturalSceneScoreVos)){
|
|
|
+ sceneScoreVos.addAll(NaturalSceneScoreVos);
|
|
|
+ }
|
|
|
+ if(!isEmpty(StatueSceneScoreVos)){
|
|
|
+ sceneScoreVos.addAll(StatueSceneScoreVos);
|
|
|
+ }
|
|
|
+ if(!isEmpty(TrafficSceneScoreVos)){
|
|
|
+ sceneScoreVos.addAll(TrafficSceneScoreVos);
|
|
|
+ }
|
|
|
+ vo.setSceneScoreList(sceneScoreVos);
|
|
|
}
|
|
|
private void setLastTargetScore(ScenePackageSubListVO vo, String pId){
|
|
|
SimulationMptLastTargetScorePo poParam = new SimulationMptLastTargetScorePo();
|
|
@@ -1009,24 +1043,122 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
private String getEvaluationLevelReport(Double algorithmScore){
|
|
|
String evaluationLevelReport = "";
|
|
|
if(algorithmScore >= 90){
|
|
|
- evaluationLevelReport = "G";
|
|
|
+ evaluationLevelReport = DictConstants.REPORT_LEVEL_G;
|
|
|
}else if(algorithmScore >= 80 && algorithmScore < 90){
|
|
|
- evaluationLevelReport = "A";
|
|
|
+ evaluationLevelReport = DictConstants.REPORT_LEVEL_A;
|
|
|
}else if(algorithmScore >= 70 && algorithmScore < 80){
|
|
|
- evaluationLevelReport = "M";
|
|
|
+ evaluationLevelReport = DictConstants.REPORT_LEVEL_M;
|
|
|
}else if(algorithmScore < 70){
|
|
|
- evaluationLevelReport = "P";
|
|
|
+ evaluationLevelReport = DictConstants.REPORT_LEVEL_P;
|
|
|
}
|
|
|
return evaluationLevelReport;
|
|
|
}
|
|
|
|
|
|
- private Integer getSetScoreNum(String pId){
|
|
|
+ /**
|
|
|
+ * 获取二级场景下所有得分不为0的场景数量
|
|
|
+ * @param sublistId
|
|
|
+ * @param pId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Integer getSetScoreNum(String sublistId,String pId){
|
|
|
+ SceneScoreVo vo = selectScoreNum(null, null, true, pId, sublistId);
|
|
|
+ return vo.getNum();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取一级指标下所有得分不为0的场景总数
|
|
|
+ * @param resultVo 返回值,返回统计数量,首次传null
|
|
|
+ * @param parentVoList 首次传null
|
|
|
+ * @param isRoot 首次传true
|
|
|
+ * @param pId 项目表id,用于统计得分使用
|
|
|
+ * @param sublistId 指标id(用户查询指标下的所有场景)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private SceneScoreVo selectScoreNum(SceneScoreVo resultVo, List<ScenePackageSubListVO> parentVoList,
|
|
|
+ boolean isRoot, String pId,String sublistId){
|
|
|
+ if(isRoot){
|
|
|
+ //初始化返回值
|
|
|
+ resultVo = new SceneScoreVo();
|
|
|
+ resultVo.setNum(0);
|
|
|
+
|
|
|
+ //查找下一级指标
|
|
|
+ parentVoList = simulationProjectMapper.selectSubSceneByPid(sublistId);
|
|
|
+ if(!isEmpty(parentVoList)){
|
|
|
+ selectScoreNum(resultVo, parentVoList, false, pId,null);
|
|
|
+ }else{
|
|
|
+ //当前指标为最后一级指标,获取当前指标,统计得分场景数
|
|
|
+ setScoreNum(sublistId, pId, resultVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ //获取子节点集合
|
|
|
+ for(ScenePackageSubListVO pvo : parentVoList){
|
|
|
+
|
|
|
+ List<ScenePackageSubListVO> cvoList = simulationProjectMapper.selectSubSceneByPid(pvo.getSublistId());
|
|
|
+ if(!isEmpty(cvoList)){
|
|
|
+ //存入父节点集合中
|
|
|
+ pvo.setChildScenePackageSubListVOList(cvoList);
|
|
|
+ //继续查找下一节点
|
|
|
+ selectScoreNum(resultVo, cvoList,false, pId, null);
|
|
|
+ }else{
|
|
|
+ //没有子节点;获取最后一级的得分场景数量
|
|
|
+ setScoreNum(pvo.getSublistId(), pId, resultVo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setScoreNum(String sublistId, String pId, SceneScoreVo resultVo){
|
|
|
+// ScenePackageSubListVO scenePackageSubListVO = simulationProjectMapper.selectsublistBySublistId(sublistId);
|
|
|
SimulationMptSceneScorePo po = new SimulationMptSceneScorePo();
|
|
|
po.setPId(pId);
|
|
|
+// po.setLastTargerId(scenePackageSubListVO.getSublistId());
|
|
|
+ po.setLastTargerId(sublistId);
|
|
|
SceneScoreVo sceneScoreVo = simulationProjectMapper.selectSceneScoreNumQuery(po);
|
|
|
- return sceneScoreVo.getNum();
|
|
|
+ resultVo.setNum(resultVo.getNum()+sceneScoreVo.getNum());
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 计算评测等级
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getEvaluationLevel(SimulationManualProjectPo po){
|
|
|
+ /*
|
|
|
+ 汇总测试得分(计算评级)计算方法:(每一项一级指标的测试得分*测试权重)累加
|
|
|
+ */
|
|
|
+ List<ScenePackageSubListVO> scenePackageSubListVOS = simulationProjectMapper.selectSubSceneByPid(po.getScene());
|
|
|
+
|
|
|
+ String evaluationLevelReport = "";
|
|
|
+ if(!isEmpty(scenePackageSubListVOS)){
|
|
|
+ //汇总数据初始化
|
|
|
+ Double totalScore = 0D;
|
|
|
+
|
|
|
+ for(ScenePackageSubListVO v : scenePackageSubListVOS){
|
|
|
+ String weight = v.getWeight();
|
|
|
+ Double weightDouble = Double.valueOf(weight);
|
|
|
+ SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo = new SimulationMptFirstTargetScorePo();
|
|
|
+ simulationMptFirstTargetScorePo.setPId(po.getId());
|
|
|
+ simulationMptFirstTargetScorePo.setTarget(v.getSublistId());
|
|
|
+ //单个二级指标得分
|
|
|
+ SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo1 = simulationProjectMapper.selectFirstTargetScore(simulationMptFirstTargetScorePo);
|
|
|
+ Double score = simulationMptFirstTargetScorePo1.getScore();
|
|
|
+ totalScore += score*(weightDouble/100);
|
|
|
+ }
|
|
|
+
|
|
|
+ evaluationLevelReport = getEvaluationLevelReport(saveTwoDecimalPlaces(totalScore));
|
|
|
+ return evaluationLevelReport;
|
|
|
+ }
|
|
|
+
|
|
|
+ return evaluationLevelReport;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|