Bladeren bron

算法平台

LingxinMeng 2 jaren geleden
bovenliggende
commit
67ea7d87a8

+ 7 - 1
simulation-resource-common/src/main/java/com/css/simulation/resource/common/domain/algorithm/AlgorithmExpandDomain.java

@@ -37,7 +37,13 @@ public class AlgorithmExpandDomain {
             List<String> infrastructureAlgorithmIds = algorithmExpandMapper.selectAlgorithmIds(AlgorithmExpandInfrastructureParam.builder().algorithmIds(aclAlgorithmIds).build());
             //2 不存在的数据插入数据库并设置状态为“未测试”
             algorithmExpandAclEntities.forEach(algorithmExpandAclEntity -> {
-                if (!infrastructureAlgorithmIds.contains(algorithmExpandAclEntity.getAlgorithmId())) {
+                final String algorithmId = algorithmExpandAclEntity.getAlgorithmId();
+                if (infrastructureAlgorithmIds.contains(algorithmId)) {
+                    final List<AlgorithmExpandInfrastructureEntity> AlgorithmExpandInfrastructureEntities = algorithmExpandMapper.select(AlgorithmExpandInfrastructureParam.builder().algorithmId(algorithmId).build());
+                    final AlgorithmExpandInfrastructureEntity algorithmExpandInfrastructureEntity = AlgorithmExpandInfrastructureEntities.get(0);
+                    BeanUtils.copyProperties(algorithmExpandAclEntity, algorithmExpandInfrastructureEntity);
+                    algorithmExpandMapper.update(algorithmExpandInfrastructureEntity);
+                }else {
                     final AlgorithmExpandInfrastructureEntity algorithmExpandInfrastructureEntity = new AlgorithmExpandInfrastructureEntity();
                     BeanUtils.copyProperties(algorithmExpandAclEntity, algorithmExpandInfrastructureEntity);
                     algorithmExpandInfrastructureEntity.setStatus(DictConstants.ALGORITHM_EXPAND_STATUS_NOT_TESTED);

+ 22 - 2
simulation-resource-common/src/main/java/com/css/simulation/resource/common/infrastructure/mysql/mapper/AlgorithmExpandMapper.java

@@ -5,6 +5,7 @@ import com.css.simulation.resource.common.infrastructure.mysql.param.AlgorithmEx
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 import java.util.List;
 
@@ -14,11 +15,17 @@ public interface AlgorithmExpandMapper {
     @Select(" <script>" +
             " select id, algorithm_id, algorithm_name, description, algorithm_type, status\n" +
             " from algorithm_expand\n" +
-            " where algorithm_id in\n" +
+            " where 1=1 " +
+            " <if test='algorithmIds != null and algorithmIds.size() > 0'>\n" +
+            " and algorithm_id in\n" +
             "    <foreach item='item' collection='algorithmIds' separator=',' open='(' close=')'>\n" +
             "      #{item}\n" +
             "    </foreach>" +
-            "</script>")
+            " </if>" +
+            " <if test='algorithmId != null and algorithmId != '''>\n" +
+            "  and algorithm_id = #{algorithmId}" +
+            " </if>" +
+            " </script>")
     List<AlgorithmExpandInfrastructureEntity> select(AlgorithmExpandInfrastructureParam algorithmExpandInfrastructureParam);
 
     @Select(" <script>" +
@@ -34,4 +41,17 @@ public interface AlgorithmExpandMapper {
     @Insert("insert into algorithm_expand(id, algorithm_id, algorithm_name, description, algorithm_type, algorithm_version, team, topic, status)\n\n" +
             "    value (#{id}, #{algorithmId}, #{algorithmName}, #{description}, #{algorithmType},#{algorithmVersion},#{team},{topic}, #{status})\n")
     void insert(AlgorithmExpandInfrastructureEntity algorithmExpandInfrastructureEntity);
+
+    @Update("update algorithm_expand\n" +
+            "set id = #{id},\n" +
+            "            algorithm_id = #{algorithmId},\n" +
+            "            algorithm_name = #{algorithmName},\n" +
+            "            description = #{description},\n" +
+            "            algorithm_type = #{algorithmType},\n" +
+            "            algorithm_version = #{algorithmVersion},\n" +
+            "            team = #{team},\n" +
+            "            topic = #{topic},\n" +
+            "            status = #{status}\n" +
+            "where algorithm_id = #{algorithmId}\n")
+    void update(AlgorithmExpandInfrastructureEntity algorithmExpandInfrastructureEntity);
 }