|
@@ -27,10 +27,7 @@ import com.css.simulation.resource.project.constants.ProjectConstants;
|
|
import com.css.simulation.resource.project.enums.ProjectRunStateEnum;
|
|
import com.css.simulation.resource.project.enums.ProjectRunStateEnum;
|
|
import com.css.simulation.resource.project.enums.SceneTypeEnum;
|
|
import com.css.simulation.resource.project.enums.SceneTypeEnum;
|
|
import com.css.simulation.resource.project.feign.KafkaService;
|
|
import com.css.simulation.resource.project.feign.KafkaService;
|
|
-import com.css.simulation.resource.project.mapper.SimulationMptFirstTargetScoreMapper;
|
|
|
|
-import com.css.simulation.resource.project.mapper.SimulationMptLastTargetScoreMapper;
|
|
|
|
-import com.css.simulation.resource.project.mapper.SimulationProjectMapper;
|
|
|
|
-import com.css.simulation.resource.project.mapper.SimulationProjectTaskMapper;
|
|
|
|
|
|
+import com.css.simulation.resource.project.mapper.*;
|
|
import com.css.simulation.resource.project.service.SimulationProjectService;
|
|
import com.css.simulation.resource.project.service.SimulationProjectService;
|
|
import com.css.simulation.resource.system.service.DictService;
|
|
import com.css.simulation.resource.system.service.DictService;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@@ -72,6 +69,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
@Autowired
|
|
@Autowired
|
|
private SimulationProjectMapper simulationProjectMapper;
|
|
private SimulationProjectMapper simulationProjectMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SimulationAutomaticProjectMapper simulationAutomaticProjectMapper;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private SimulationProjectTaskMapper simulationProjectTaskMapper;
|
|
private SimulationProjectTaskMapper simulationProjectTaskMapper;
|
|
|
|
|
|
@@ -296,6 +296,12 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //项目终止,推送到kafka
|
|
|
|
+ if(DictConstants.PROJECT_TERMINATED.equals(param.getNowRunState())){
|
|
|
|
+ projectStopToKafka(po);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -312,9 +318,20 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
kafkaParameter.setTopic(ProjectConstants.RUN_TASK_TOPIC);
|
|
kafkaParameter.setTopic(ProjectConstants.RUN_TASK_TOPIC);
|
|
String data = JsonUtil.beanToJson(kafkaParam);
|
|
String data = JsonUtil.beanToJson(kafkaParam);
|
|
kafkaParameter.setData(data);
|
|
kafkaParameter.setData(data);
|
|
- log.info("推送消息到kafka:"+data);
|
|
|
|
|
|
+ log.info("推送项目运行消息到kafka:"+data);
|
|
kafkaService.send(kafkaParameter);
|
|
kafkaService.send(kafkaParameter);
|
|
}
|
|
}
|
|
|
|
+ private void projectStopToKafka(SimulationManualProjectPo po) throws JsonProcessingException{
|
|
|
|
+ SimulationManualProjectKafkaParam kafkaParam = new SimulationManualProjectKafkaParam();
|
|
|
|
+ kafkaParam.setProjectId(po.getId());
|
|
|
|
+ KafkaParameter kafkaParameter = new KafkaParameter();
|
|
|
|
+ kafkaParameter.setTopic(ProjectConstants.STOP_TASK_TOPPIC);
|
|
|
|
+ String data = JsonUtil.beanToJson(kafkaParam);
|
|
|
|
+ kafkaParameter.setData(data);
|
|
|
|
+ log.info("推送项目中止消息到kafka:"+data);
|
|
|
|
+ kafkaService.send(kafkaParameter);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResponseBodyVO selectProjectDetailsById(SimulationManualProjectParam param) {
|
|
public ResponseBodyVO selectProjectDetailsById(SimulationManualProjectParam param) {
|
|
@@ -605,7 +622,8 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
//单个二级指标得分
|
|
//单个二级指标得分
|
|
SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo1 = simulationMptFirstTargetScoreMapper.selectFirstTargetScore(simulationMptFirstTargetScorePo);
|
|
SimulationMptFirstTargetScorePo simulationMptFirstTargetScorePo1 = simulationMptFirstTargetScoreMapper.selectFirstTargetScore(simulationMptFirstTargetScorePo);
|
|
Double score = simulationMptFirstTargetScorePo1.getScore();
|
|
Double score = simulationMptFirstTargetScorePo1.getScore();
|
|
- totalScore += score*(weightDouble/100);
|
|
|
|
|
|
+ totalScore += BigDecimal.valueOf(score).multiply(BigDecimal.valueOf(weightDouble).divide(BigDecimal.valueOf(100))).doubleValue();
|
|
|
|
+// totalScore += score*(weightDouble/100);
|
|
algorithmScoreVo.setScore(saveTwoDecimalPlaces(score));
|
|
algorithmScoreVo.setScore(saveTwoDecimalPlaces(score));
|
|
// totalWeight +=aDouble;
|
|
// totalWeight +=aDouble;
|
|
// Integer num = v.getSceneNum();
|
|
// Integer num = v.getSceneNum();
|
|
@@ -1325,6 +1343,20 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void createProjectId(SimulationAutomaticProjectPo po){
|
|
|
|
+ Integer nowRq = getRq(null,0);
|
|
|
|
+ po.setProjectDate(nowRq);
|
|
|
|
+ SimulationAutomaticProjectPo po1 = simulationAutomaticProjectMapper.selectLastProjectId(nowRq);
|
|
|
|
+ if(po1 == null){
|
|
|
|
+ //生成新id
|
|
|
|
+ po.setProjectNum(1);
|
|
|
|
+ }else{
|
|
|
|
+ po.setProjectNum(po1.getProjectNum()+1);
|
|
|
|
+ }
|
|
|
|
+ po.setProjectId(po.getProjectDate()+"-"+po.getProjectNum());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private Integer getRq(Date date, int index){
|
|
private Integer getRq(Date date, int index){
|
|
return TimeUtil.getRq(date,index);
|
|
return TimeUtil.getRq(date,index);
|
|
}
|
|
}
|
|
@@ -1509,7 +1541,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
BeanUtils.copyProperties(po, sublistScoreVo);
|
|
BeanUtils.copyProperties(po, sublistScoreVo);
|
|
sublistScoreVo.setRunResult(sc.getRunResult());
|
|
sublistScoreVo.setRunResult(sc.getRunResult());
|
|
|
|
|
|
- sublistScoreVo.setSceneScore(sc.getScore()); //得分
|
|
|
|
|
|
+ sublistScoreVo.setSceneScore(saveTwoDecimalPlaces(sc.getScore())); //得分
|
|
sublistScoreVo.setTargetEvaluate(sc.getTargetEvaluate());//指标评价
|
|
sublistScoreVo.setTargetEvaluate(sc.getTargetEvaluate());//指标评价
|
|
// sublistScoreVo.setReturnSceneId(sc.getReturnSceneId());//显示的场景id
|
|
// sublistScoreVo.setReturnSceneId(sc.getReturnSceneId());//显示的场景id
|
|
String sceneType = sc.getSceneType();
|
|
String sceneType = sc.getSceneType();
|
|
@@ -1710,8 +1742,16 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
setParent(po,null,pos,scenePackageId);
|
|
setParent(po,null,pos,scenePackageId);
|
|
|
|
|
|
String sublistName = po.getSublistName();
|
|
String sublistName = po.getSublistName();
|
|
- String firstScore = po.getFirScore();//first得分
|
|
|
|
- String LastScore = po.getLasScore();//last得分
|
|
|
|
|
|
+ Double firScore = po.getFirScore();
|
|
|
|
+ String firstScore = "";//first得分
|
|
|
|
+ if(firScore != null){
|
|
|
|
+ firstScore = saveTwoDecimalPlaces(firScore,1).toString();
|
|
|
|
+ }
|
|
|
|
+ Double lasScore = po.getLasScore();
|
|
|
|
+ String LastScore = "";//last得分
|
|
|
|
+ if(lasScore != null){
|
|
|
|
+ LastScore = saveTwoDecimalPlaces(lasScore,1).toString();
|
|
|
|
+ }
|
|
String sceneNum = po.getSceneNum();//场景数量
|
|
String sceneNum = po.getSceneNum();//场景数量
|
|
String notStandardSceneNum = po.getNotStandardSceneNum();//未达标场景数量
|
|
String notStandardSceneNum = po.getNotStandardSceneNum();//未达标场景数量
|
|
|
|
|
|
@@ -3499,15 +3539,58 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
|
|
|
if(isEmpty(param.getId())){
|
|
if(isEmpty(param.getId())){
|
|
//工作名称一样的的不能创建
|
|
//工作名称一样的的不能创建
|
|
- List<SimulationManualProjectPo> simulationManualProjectPos = simulationProjectMapper.selectProjectByName(param);
|
|
|
|
|
|
+ List<SimulationAutomaticProjectPo> simulationManualProjectPos = simulationAutomaticProjectMapper.selectAutomaticProjectByQuery(param);
|
|
if(!isEmpty(simulationManualProjectPos)){
|
|
if(!isEmpty(simulationManualProjectPos)){
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE,"工作名称已经存在,请修改后再保存");
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE,"工作名称已经存在,请修改后再保存");
|
|
}
|
|
}
|
|
|
|
+ po.createPo(AuthUtil.getCurrentUserId());
|
|
|
|
+ //生成id
|
|
|
|
+ createProjectId(po);
|
|
|
|
+ int add = simulationAutomaticProjectMapper.add(po);
|
|
|
|
+ if(add > 0){
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,ResponseBodyVO.Response.SUCCESS.getMessage(),po.getId());
|
|
|
|
+ }
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
|
|
|
|
+ }else{
|
|
|
|
+ //获取工作状态,仅未开始的才可以修改信息
|
|
|
|
+ SimulationAutomaticProjectPo saPo = simulationAutomaticProjectMapper.selectById(param.getId());
|
|
|
|
+ if(!ProjectRunStateEnum.NOT_START.getCode().equals(saPo.getNowRunState())){
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"当前状态不支持修改");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ po.updatePo(AuthUtil.getCurrentUserId());
|
|
|
|
+ int update = simulationAutomaticProjectMapper.updateById(po);
|
|
|
|
+ if(update > 0){
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,ResponseBodyVO.Response.SUCCESS.getMessage(),po.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"修改失败");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseBodyVO deleteAutomaticProjectByids(SimulationManualProjectParam param) {
|
|
|
|
+ String ids = param.getIds();
|
|
|
|
+ if(isEmpty(ids)){
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
|
+ }
|
|
|
|
+ String[] idArr = ids.split(",");
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ //未执行和已中止的可以删除
|
|
|
|
+ List<SimulationAutomaticProjectPo> pos = simulationAutomaticProjectMapper.selectProjectNowRunState(idArr);
|
|
|
|
+ for(SimulationAutomaticProjectPo p : pos){
|
|
|
|
+ if(!isEmpty(p.getNowRunState()) && !ProjectRunStateEnum.NOT_START.getCode().equals(p.getNowRunState()) && !ProjectRunStateEnum.DISCONTINUE.getCode().equals(p.getNowRunState())){
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"数据不支持删除");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int i = simulationAutomaticProjectMapper.deleteProject(idArr);
|
|
|
|
+ if(i > 0){
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"删除失败");
|
|
}
|
|
}
|
|
|
|
|
|
private SimulationAutomaticProjectPo convertToSimulationAutomaticProjectPo(SimulationManualProjectParam param){
|
|
private SimulationAutomaticProjectPo convertToSimulationAutomaticProjectPo(SimulationManualProjectParam param){
|