LingxinMeng 1 år sedan
förälder
incheckning
7d2263ea00

+ 58 - 37
simulation-resource-common/src/main/java/com/css/simulation/resource/common/domain/service/algorithm/AlgorithmExpandDomainService.java

@@ -13,6 +13,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -24,45 +25,65 @@ public class AlgorithmExpandDomainService {
     private AlgorithmExpandMapper algorithmExpandMapper;
 
     public void checkIsExisted(ResponseBodyVO<String> algorithmBody) {
-        final String algorithmListResponseJson = algorithmBody.getInfo();
-        log.info("算法平台请求结果为:{}", algorithmListResponseJson);
-        final String algorithmListJson = JsonUtil.getString(algorithmListResponseJson, "data.content");
-        log.info("算法平台的算法列表JSON为:{}", algorithmListJson);
-        final List<AlgorithmExpandAclEntity> algorithmExpandAclEntities = JsonUtil.jsonToList(algorithmListJson, AlgorithmExpandAclEntity.class);
-        log.info("算法平台的算法列表为:{}", algorithmExpandAclEntities);
-        if (CollectionUtil.isNotEmpty(algorithmExpandAclEntities)) {
-            //1 获取算法平台查询到的所有算法ID
-            final List<String> aclAlgorithmIds = algorithmExpandAclEntities.stream().map(AlgorithmExpandAclEntity::getAlgorithmId).collect(Collectors.toList());
-            log.info("算法平台的算法ID列表为:{}", aclAlgorithmIds);
-            List<String> infrastructureAlgorithmIds = algorithmExpandMapper.selectAlgorithmIds(AlgorithmExpandInfrastructureParam.builder().algorithmIds(aclAlgorithmIds).build());
-            //2 不存在的数据插入数据库并设置状态为“未测试”
-            algorithmExpandAclEntities.forEach(algorithmExpandAclEntity -> {
-                final String algorithmId = algorithmExpandAclEntity.getAlgorithmId();
-                if (infrastructureAlgorithmIds.contains(algorithmId)) {
-                    log.info("更新算法平台算法。");
-                    final List<AlgorithmExpandEntity> AlgorithmExpandInfrastructureEntities = algorithmExpandMapper.select(AlgorithmExpandInfrastructureParam.builder().algorithmId(algorithmId).build());
-                    final AlgorithmExpandEntity algorithmExpandEntity = AlgorithmExpandInfrastructureEntities.get(0);
-                    // status 不能被覆盖
-//                    BeanUtils.copyProperties(algorithmExpandAclEntity, algorithmExpandEntity);
-                    {
-                        algorithmExpandEntity.setId(algorithmExpandAclEntity.getId());
-                        algorithmExpandEntity.setAlgorithmId(algorithmExpandAclEntity.getAlgorithmId());
-                        algorithmExpandEntity.setAlgorithmName(algorithmExpandAclEntity.getAlgorithmName());
-                        algorithmExpandEntity.setDescription(algorithmExpandAclEntity.getDescription());
-                        algorithmExpandEntity.setAlgorithmType(algorithmExpandAclEntity.getAlgorithmType());
-                        algorithmExpandEntity.setAlgorithmVersion(algorithmExpandAclEntity.getAlgorithmVersion());
-                        algorithmExpandEntity.setTeam(algorithmExpandAclEntity.getTeam());
-                        algorithmExpandEntity.setTopic(algorithmExpandAclEntity.getTopic());
+        try {
+            final String algorithmListResponseJson = algorithmBody.getInfo();
+            log.info("算法平台请求结果为:{}", algorithmListResponseJson);
+            final String algorithmListJson = JsonUtil.getString(algorithmListResponseJson, "data.content");
+            log.info("算法平台的算法列表JSON为:{}", algorithmListJson);
+            List<AlgorithmExpandAclEntity> algorithmExpandAclEntitiesTemp = JsonUtil.jsonToList(algorithmListJson, AlgorithmExpandAclEntity.class);
+            List<AlgorithmExpandAclEntity> algorithmExpandAclEntities = new ArrayList<>();
+            for (AlgorithmExpandAclEntity algorithmExpandAclEntity : algorithmExpandAclEntitiesTemp) {
+                if (algorithmExpandAclEntity == null) { // v20240605 竟然有空数据
+                    continue;
+                }
+                algorithmExpandAclEntities.add(algorithmExpandAclEntity);
+            }
+            log.info("算法平台的算法列表为:{}", algorithmExpandAclEntities);
+            if (CollectionUtil.isNotEmpty(algorithmExpandAclEntities)) {
+                //1 获取算法平台查询到的所有算法ID
+//                final List<String> aclAlgorithmIds = algorithmExpandAclEntities.stream().map(AlgorithmExpandAclEntity::getAlgorithmId).collect(Collectors.toList());
+                List<String> aclAlgorithmIds = new ArrayList<>();
+                for (AlgorithmExpandAclEntity algorithmExpandAclEntity : algorithmExpandAclEntities) {
+                    if (algorithmExpandAclEntity.getAlgorithmId() == null || algorithmExpandAclEntity.getAlgorithmId().isEmpty()) {
+                        log.error("存在错误数据(algorithmId为空):{}", algorithmExpandAclEntity);
+                    } else {
+                        aclAlgorithmIds.add(algorithmExpandAclEntity.getAlgorithmId());
                     }
-                    algorithmExpandMapper.update(algorithmExpandEntity);
-                } else {
-                    log.info("插入算法平台算法。");
-                    final AlgorithmExpandEntity algorithmExpandEntity = new AlgorithmExpandEntity();
-                    BeanUtils.copyProperties(algorithmExpandAclEntity, algorithmExpandEntity);
-                    algorithmExpandEntity.setStatus(DictConstants.ALGORITHM_EXPAND_STATUS_NOT_TESTED);
-                    algorithmExpandMapper.insert(algorithmExpandEntity);
                 }
-            });
+                log.info("算法平台的算法ID列表为:{}", aclAlgorithmIds);
+                List<String> infrastructureAlgorithmIds = algorithmExpandMapper.selectAlgorithmIds(AlgorithmExpandInfrastructureParam.builder().algorithmIds(aclAlgorithmIds).build());
+                //2 不存在的数据插入数据库并设置状态为“未测试”
+                algorithmExpandAclEntities.forEach(algorithmExpandAclEntity -> {
+                    final String algorithmId = algorithmExpandAclEntity.getAlgorithmId();
+                    if (infrastructureAlgorithmIds.contains(algorithmId)) {
+                        log.info("更新算法平台算法。");
+                        final List<AlgorithmExpandEntity> AlgorithmExpandInfrastructureEntities = algorithmExpandMapper.select(AlgorithmExpandInfrastructureParam.builder().algorithmId(algorithmId).build());
+                        final AlgorithmExpandEntity algorithmExpandEntity = AlgorithmExpandInfrastructureEntities.get(0);
+                        // status 不能被覆盖
+                        //                    BeanUtils.copyProperties(algorithmExpandAclEntity, algorithmExpandEntity);
+                        {
+                            algorithmExpandEntity.setId(algorithmExpandAclEntity.getId());
+                            algorithmExpandEntity.setAlgorithmId(algorithmExpandAclEntity.getAlgorithmId());
+                            algorithmExpandEntity.setAlgorithmName(algorithmExpandAclEntity.getAlgorithmName());
+                            algorithmExpandEntity.setDescription(algorithmExpandAclEntity.getDescription());
+                            algorithmExpandEntity.setAlgorithmType(algorithmExpandAclEntity.getAlgorithmType());
+                            algorithmExpandEntity.setAlgorithmVersion(algorithmExpandAclEntity.getAlgorithmVersion());
+                            algorithmExpandEntity.setTeam(algorithmExpandAclEntity.getTeam());
+                            algorithmExpandEntity.setTopic(algorithmExpandAclEntity.getTopic());
+                        }
+                        algorithmExpandMapper.update(algorithmExpandEntity);
+                    } else {
+                        log.info("插入算法平台算法。");
+                        final AlgorithmExpandEntity algorithmExpandEntity = new AlgorithmExpandEntity();
+                        BeanUtils.copyProperties(algorithmExpandAclEntity, algorithmExpandEntity);
+                        algorithmExpandEntity.setStatus(DictConstants.ALGORITHM_EXPAND_STATUS_NOT_TESTED);
+                        algorithmExpandMapper.insert(algorithmExpandEntity);
+                    }
+                });
+            }
+        } catch (Exception e) {
+            log.error("检查算法是否存在报错:", e);
+            throw new RuntimeException(e);
         }
     }
 

+ 1 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/infra/entity/OgtEntity.java

@@ -21,7 +21,7 @@ import java.math.BigDecimal;
  * 					"sensor_h": 0,
  * 					"sensor_p": 0,
  * 					"sensor_r": 0,
- * 					"sensor_filter": [0,1,5],
+ * 					"sensor_filter": "0,1,5",
  * 					"sensor_display": true,
  * 					"sensor_maxObjects": 10,
  * 					"sensor_port": 62002

+ 22 - 18
simulation-resource-server/src/main/java/com/css/simulation/resource/server/app/impl/SimulationProjectServiceImpl.java

@@ -159,7 +159,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
         if (isEmpty(param.getProjectName())) {
             return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "工作名称不能为空。");
         }
-        if (isEmpty(param.getSimulationMageGroupId())){
+        if (isEmpty(param.getSimulationMageGroupId())) {
             return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "仿真镜像组不能为空");
         }
         SimulationManualProjectPO po = convertParamToPo(param);
@@ -336,7 +336,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             projectDetailsVO.setNowRunStateName(DictConstants.PROJECT_RUNNING_NAME);
             //1 校验项目的信息是否可用
             SimulationMageGroupPO groupPO = mageGroupMapper.selectSimulationMageGroupById(oldProjectPO.getSimulationMageGroupId());
-            if (Objects.isNull(groupPO)){
+            if (Objects.isNull(groupPO)) {
                 throw new RuntimeException("仿真镜像组无效");
             }
             projectUtil.checkProject(oldProjectPO.getAlgorithm(), oldProjectPO.getVehicle(), oldProjectPO.getScene(), parallelism);
@@ -498,9 +498,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             projectId = simulationManualProjectPO.getProjectId();
             createTime = String.valueOf(simulationManualProjectPO.getCreateTime());
             simulationMageGroupId = simulationManualProjectPO.getSimulationMageGroupId();
-            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(simulationMageGroupId)){
+            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(simulationMageGroupId)) {
                 SimulationMageGroupPO groupPO = mageGroupMapper.selectSimulationMageGroupById(simulationMageGroupId);
-                if (!Objects.isNull(groupPO)){
+                if (!Objects.isNull(groupPO)) {
                     simulationMageGroupName = groupPO.getGroupName();
                 }
             }
@@ -633,9 +633,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             algorithmType = po.getAlgorithmType();
             algorithmId = po.getAlgorithm();
             String simulationMageGroupId = po.getSimulationMageGroupId();
-            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(simulationMageGroupId)){
+            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(simulationMageGroupId)) {
                 SimulationMageGroupPO groupPO = mageGroupMapper.selectSimulationMageGroupById(simulationMageGroupId);
-                if (!Objects.isNull(groupPO)){
+                if (!Objects.isNull(groupPO)) {
                     projectDetailsVO.setSimulationMageGroupId(simulationMageGroupId);
                     projectDetailsVO.setSimulationMageGroupName(groupPO.getGroupName());
                 }
@@ -1743,6 +1743,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             List<DropDownVo> algorithmList = new ArrayList<>();
 
             ResponseBodyVO<String> algorithmBody = algoPlatformService.getAlgorithmList(query);
+            log.info("获取算法列表接口结果为:{}", algorithmBody);
 
             // 解析数据
             Map jsonMap = JsonUtil.jsonToMap(algorithmBody.getInfo());
@@ -1751,6 +1752,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
             Integer totalElements = (Integer) dataMap.get("totalElements");
             if (totalElements > 0) {
                 for (Map<String, String> content : contentList) {
+                    if (content == null) {
+                        continue;
+                    }
                     final String teamName = content.get("teamName");
                     final String algorithmId = content.get("algorithmId");
                     final String algorithmName = content.get("algorithmName");
@@ -6008,45 +6012,45 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
                 }
             }
             // 计算复杂度显著性
-            if (!CollectionUtils.isEmpty(comList)){
+            if (!CollectionUtils.isEmpty(comList)) {
                 Double standardDeviationByStrList = CalculateUtils.getStandardDeviationByStrList(comList);
                 Double avaByStrList = CalculateUtils.getAvaByStrList(comList);
-                if (standardDeviationByStrList != null && avaByStrList != null){
+                if (standardDeviationByStrList != null && avaByStrList != null) {
                     for (ManualProjectTaskVo po : pageInfo.getList()) {
                         try {
                             String complexity = po.getComplexity();
                             Double score = po.getScore();
-                            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(complexity)){
+                            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(complexity)) {
                                 Double aDouble = Double.valueOf(complexity);
-                                if (aDouble >= (avaByStrList-standardDeviationByStrList ) && aDouble <= (avaByStrList + standardDeviationByStrList) && score != null && score < 80){
+                                if (aDouble >= (avaByStrList - standardDeviationByStrList) && aDouble <= (avaByStrList + standardDeviationByStrList) && score != null && score < 80) {
                                     po.setComplexitySignificance(true);
-                                }else {
+                                } else {
                                     po.setComplexitySignificance(false);
                                 }
                             }
-                        }catch (Exception e){
+                        } catch (Exception e) {
                             log.info("计算复杂度失败", e);
                         }
                     }
                 }
             }
-            if (!CollectionUtils.isEmpty(riskList)){
+            if (!CollectionUtils.isEmpty(riskList)) {
                 Double standardDeviationByStrList = CalculateUtils.getStandardDeviationByStrList(riskList);
                 Double avaByStrList = CalculateUtils.getAvaByStrList(riskList);
-                if (standardDeviationByStrList != null && avaByStrList != null){
+                if (standardDeviationByStrList != null && avaByStrList != null) {
                     for (ManualProjectTaskVo po : pageInfo.getList()) {
                         try {
                             String risk = po.getRisk();
                             Double score = po.getScore();
-                            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(risk)){
+                            if (com.alibaba.cloud.commons.lang.StringUtils.isNotBlank(risk)) {
                                 Double aDouble = Double.valueOf(risk);
-                                if (aDouble >= (avaByStrList-standardDeviationByStrList ) && aDouble <= (avaByStrList + standardDeviationByStrList) && score != null && score < 80){
+                                if (aDouble >= (avaByStrList - standardDeviationByStrList) && aDouble <= (avaByStrList + standardDeviationByStrList) && score != null && score < 80) {
                                     po.setRiskSignificance(true);
-                                }else {
+                                } else {
                                     po.setRiskSignificance(false);
                                 }
                             }
-                        }catch (Exception e){
+                        } catch (Exception e) {
                             log.info("计算危险度失败", e);
                         }
                     }