Bläddra i källkod

关系根节点和顺序导入

gaodm 4 år sedan
förälder
incheckning
51e0c63df4

+ 139 - 0
src/main/java/com/diagbot/entity/KlRelationOrder.java

@@ -0,0 +1,139 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 术语关系排序表
+ * </p>
+ *
+ * @author gaodm
+ * @since 2021-02-24
+ */
+public class KlRelationOrder implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 关系表主键id
+     */
+    private Long tRelationId;
+
+    /**
+     * 区域顺序
+     */
+    private Integer orderNo;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+
+    public Date getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(Date gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+
+    public Date getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(Date gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+
+    public Long gettRelationId() {
+        return tRelationId;
+    }
+
+    public void settRelationId(Long tRelationId) {
+        this.tRelationId = tRelationId;
+    }
+
+    public Integer getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(Integer orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    @Override
+    public String toString() {
+        return "KlRelationOrder{" +
+                "id=" + id +
+                ", isDeleted=" + isDeleted +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", creator=" + creator +
+                ", modifier=" + modifier +
+                ", tRelationId=" + tRelationId +
+                ", orderNo=" + orderNo +
+                "}";
+    }
+}

+ 38 - 0
src/main/java/com/diagbot/facade/ExportFacade.java

@@ -10,6 +10,7 @@ import com.diagbot.entity.KlConceptStatic;
 import com.diagbot.entity.KlDisease;
 import com.diagbot.entity.KlLibraryInfo;
 import com.diagbot.entity.KlRelation;
+import com.diagbot.entity.KlRelationOrder;
 import com.diagbot.entity.KlRule;
 import com.diagbot.entity.KlRuleBase;
 import com.diagbot.entity.KlRuleCondition;
@@ -26,6 +27,7 @@ import com.diagbot.service.KlConceptService;
 import com.diagbot.service.KlConceptStaticService;
 import com.diagbot.service.KlDiseaseService;
 import com.diagbot.service.KlLibraryInfoService;
+import com.diagbot.service.KlRelationOrderService;
 import com.diagbot.service.KlRelationService;
 import com.diagbot.service.KlRuleBaseService;
 import com.diagbot.service.KlRuleConditionService;
@@ -82,6 +84,9 @@ public class ExportFacade {
     @Qualifier("klRelationServiceImpl")
     private KlRelationService klRelationService;
     @Autowired
+    @Qualifier("klRelationOrderServiceImpl")
+    private KlRelationOrderService klRelationOrderService;
+    @Autowired
     private TestFacade testFacade;
     @Autowired
     @Qualifier("klRuleServiceImpl")
@@ -321,29 +326,52 @@ public class ExportFacade {
         Map<String, KlConcept> map = getConceptMap();
         //药品化学物质类别树形结构
         List<ExportRelation> exportRelations = exportRelationRepository.getDrugRelationA();
+        rootImport2MySqlR("药品化学物质类别", exportRelations, 402, 301, map);
         import2MySqlR(exportRelations, 301, 101, map);
         //药品治疗学类别树形结构
         exportRelations.clear();
         exportRelations = exportRelationRepository.getDrugRelationB();
+        rootImport2MySqlR("药品治疗学类别", exportRelations, 403, 302, map);
         import2MySqlR(exportRelations, 302, 101, map);
         //药品药理学类别树形结构
         exportRelations.clear();
         exportRelations = exportRelationRepository.getDrugRelationC();
+        rootImport2MySqlR("药品药理学类别", exportRelations, 404, 303, map);
         import2MySqlR(exportRelations, 303, 101, map);
         //药品解剖学类别树形结构
         exportRelations.clear();
         exportRelations = exportRelationRepository.getDrugRelationD();
+        rootImport2MySqlR("药品解剖学类别", exportRelations, 405, 304, map);
         import2MySqlR(exportRelations, 304, 101, map);
         //实验室检查类别树形结构
         exportRelations.clear();
         exportRelations = exportRelationRepository.getLisRelation();
+        rootImport2MySqlR("实验室检查", exportRelations, 408, 107, map);
         import2MySqlR(exportRelations, 107, 108, map);
         //辅助检查类别树形结构
         exportRelations.clear();
         exportRelations = exportRelationRepository.getPacsRelation();
+        rootImport2MySqlR("辅助检查", exportRelations, 409, 109, map);
         import2MySqlR(exportRelations, 109, 110, map);
     }
 
+    private void rootImport2MySqlR(String rootName, List<ExportRelation> exportRelations, Integer stype, Integer etype, Map<String, KlConcept> map) {
+        List<ExportRelation> rootRelations = new ArrayList<>();
+        List<String> sNames = new ArrayList<>();
+        for (ExportRelation exportRelation : exportRelations) {
+            if (!sNames.contains(exportRelation.getSname())) {
+                sNames.add(exportRelation.getSname());
+                ExportRelation rootRelation = new ExportRelation();
+                rootRelation.setSname(rootName);
+                rootRelation.setEname(exportRelation.getSname());
+                rootRelations.add(rootRelation);
+            }
+        }
+        if(ListUtil.isNotEmpty(rootRelations)){
+            import2MySqlR(rootRelations, stype, etype, 600, map);
+        }
+    }
+
     private void import2MySqlR(List<ExportRelation> exportRelations, Integer stype, Integer etype, Map<String, KlConcept> map) {
         import2MySqlR(exportRelations, stype, etype, 600, map);
     }
@@ -361,6 +389,16 @@ public class ExportFacade {
             }
         }
         klRelationService.saveBatch(klRelations);
+        Integer orderNo = 1;
+        List<KlRelationOrder> klRelationOrders = new ArrayList<>();
+        for (KlRelation klRelation : klRelations) {
+            KlRelationOrder klRelationOrder = new KlRelationOrder();
+            klRelationOrder.settRelationId(klRelation.getId());
+            klRelationOrder.setOrderNo(orderNo);
+            klRelationOrders.add(klRelationOrder);
+            orderNo++;
+        }
+        klRelationOrderService.saveBatch(klRelationOrders);
     }
 
     public Map<String, Object> importExcelGraphDB() {

+ 16 - 0
src/main/java/com/diagbot/mapper/KlRelationOrderMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.KlRelationOrder;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 术语关系排序表 Mapper 接口
+ * </p>
+ *
+ * @author gaodm
+ * @since 2021-02-24
+ */
+public interface KlRelationOrderMapper extends BaseMapper<KlRelationOrder> {
+
+}

+ 18 - 0
src/main/java/com/diagbot/service/KlRelationOrderService.java

@@ -0,0 +1,18 @@
+package com.diagbot.service;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.diagbot.entity.KlRelationOrder;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 术语关系排序表 服务类
+ * </p>
+ *
+ * @author gaodm
+ * @since 2021-02-24
+ */
+@DS("med")
+public interface KlRelationOrderService extends IService<KlRelationOrder> {
+
+}

+ 20 - 0
src/main/java/com/diagbot/service/impl/KlRelationOrderServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.KlRelationOrder;
+import com.diagbot.mapper.KlRelationOrderMapper;
+import com.diagbot.service.KlRelationOrderService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 术语关系排序表 服务实现类
+ * </p>
+ *
+ * @author gaodm
+ * @since 2021-02-24
+ */
+@Service
+public class KlRelationOrderServiceImpl extends ServiceImpl<KlRelationOrderMapper, KlRelationOrder> implements KlRelationOrderService {
+
+}

+ 17 - 0
src/main/resources/mapper/KlRelationOrderMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.KlRelationOrderMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.KlRelationOrder">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="t_relation_id" property="tRelationId" />
+        <result column="order_no" property="orderNo" />
+    </resultMap>
+
+</mapper>

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

@@ -49,14 +49,14 @@ public class CodeGeneration {
         dsc.setDriverName("com.mysql.cj.jdbc.Driver");
         dsc.setUsername("root");
         dsc.setPassword("lantone");
-        dsc.setUrl("jdbc:mysql://192.168.2.236:3306/cdss?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8");
+        dsc.setUrl("jdbc:mysql://192.168.2.236:3306/med_2021?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8");
         mpg.setDataSource(dsc);
 
         // 策略配置
         StrategyConfig strategy = new StrategyConfig();
         // strategy.setTablePrefix(new String[] { "demo_" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "graph_concept_detail"}); // 需要生成的表
+        strategy.setInclude(new String[] { "kl_relation_order"}); // 需要生成的表
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);