Browse Source

数据迁移

gaodm 4 years ago
parent
commit
88592d6705

+ 14 - 1
src/main/java/com/diagbot/entity/KlRule.java

@@ -11,7 +11,7 @@ import java.io.Serializable;
  * </p>
  *
  * @author gaodm
- * @since 2021-01-21
+ * @since 2021-01-25
  */
 public class KlRule implements Serializable {
 
@@ -68,6 +68,11 @@ public class KlRule implements Serializable {
      */
     private Integer status;
 
+    /**
+     * 描述
+     */
+    private String msg;
+
     public Long getId() {
         return id;
     }
@@ -138,6 +143,13 @@ public class KlRule implements Serializable {
     public void setStatus(Integer status) {
         this.status = status;
     }
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
 
     @Override
     public String toString() {
@@ -152,6 +164,7 @@ public class KlRule implements Serializable {
             ", description=" + description +
             ", ruleType=" + ruleType +
             ", status=" + status +
+            ", msg=" + msg +
         "}";
     }
 }

+ 11 - 6
src/main/java/com/diagbot/facade/ExportFacade.java

@@ -18,6 +18,7 @@ import com.diagbot.service.KlLibraryInfoService;
 import com.diagbot.service.KlRelationService;
 import com.diagbot.util.Cn2SpellUtil;
 import com.diagbot.util.EntityUtil;
+import com.diagbot.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -143,7 +144,8 @@ public class ExportFacade {
         List<KlLibraryInfo> libraryInfos = new ArrayList<>();
         List<String> names = new ArrayList<>();
         for (ExportNode exportNode : nodes) {
-            if (!names.contains(exportNode.getName())) {
+            if (StringUtil.isNotBlank(exportNode.getName())
+                    && !names.contains(exportNode.getName())) {
                 KlLibraryInfo klLibraryInfo = new KlLibraryInfo();
                 klLibraryInfo.setName(exportNode.getName());
                 klLibraryInfo.setIsConcept(1);
@@ -239,11 +241,14 @@ public class ExportFacade {
     private void import2MySqlR(List<ExportRelation> exportRelations, Integer stype, Integer etype, Map<String, KlConcept> map) {
         List<KlRelation> klRelations = new ArrayList<>();
         for (ExportRelation exportRelation : exportRelations) {
-            KlRelation klRelation = new KlRelation();
-            klRelation.setStartId(map.get(exportRelation.getSname() + "_" + stype).getId());
-            klRelation.setEndId(map.get(exportRelation.getEname() + "_" + etype).getId());
-            klRelation.setRelationId(600);
-            klRelations.add(klRelation);
+            if (null != map.get(exportRelation.getSname() + "_" + stype)
+                    && null != map.get(exportRelation.getEname() + "_" + etype)) {
+                KlRelation klRelation = new KlRelation();
+                klRelation.setStartId(map.get(exportRelation.getSname() + "_" + stype).getId());
+                klRelation.setEndId(map.get(exportRelation.getEname() + "_" + etype).getId());
+                klRelation.setRelationId(600);
+                klRelations.add(klRelation);
+            }
         }
         klRelationService.saveBatch(klRelations);
     }

+ 1 - 1
src/test/java/com/diagbot/CodeGeneration.java

@@ -56,7 +56,7 @@ public class CodeGeneration {
         StrategyConfig strategy = new StrategyConfig();
         // strategy.setTablePrefix(new String[] { "demo_" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "kl_library_info"}); // 需要生成的表
+        strategy.setInclude(new String[] { "kl_rule"}); // 需要生成的表
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);