Browse Source

Merge remote-tracking branch 'origin/master'

SGTY 5 months ago
parent
commit
f06cc9f7dd
21 changed files with 565 additions and 468 deletions
  1. 18 0
      pom.xml
  2. 1 0
      src/main/java/com/qizhen/healsphere/Application.java
  3. 22 0
      src/main/java/com/qizhen/healsphere/config/MyMetaObjectHandler.java
  4. 33 0
      src/main/java/com/qizhen/healsphere/config/MybatisPlusConfig.java
  5. 12 9
      src/main/java/com/qizhen/healsphere/config/MysqlConfig.java
  6. 24 10
      src/main/java/com/qizhen/healsphere/repository/mapper/KgCountInfoMapper.java
  7. 24 5
      src/main/java/com/qizhen/healsphere/repository/mapper/KgCountTotalInfoMapper.java
  8. 3 2
      src/main/java/com/qizhen/healsphere/repository/mapper/PresetInfoMapper.java
  9. 27 18
      src/main/java/com/qizhen/healsphere/repository/mapper/entity/KgCountInfo.java
  10. 22 47
      src/main/java/com/qizhen/healsphere/repository/mapper/entity/KgCountTotalInfo.java
  11. 15 88
      src/main/java/com/qizhen/healsphere/repository/mapper/entity/PresetInfo.java
  12. 45 44
      src/main/java/com/qizhen/healsphere/repository/neo4j/BaseNodeRepository.java
  13. 84 63
      src/main/java/com/qizhen/healsphere/service/impl/KgCountServiceImpl.java
  14. 13 3
      src/main/java/com/qizhen/healsphere/service/impl/PresetInfoServiceImpl.java
  15. 1 1
      src/main/java/com/qizhen/healsphere/web/KgCountController.java
  16. 19 0
      src/main/java/com/qizhen/healsphere/web/vo/CountListVO.java
  17. 12 1
      src/main/resources/application-local.yml
  18. 14 1
      src/main/resources/application.yml
  19. 81 81
      src/main/resources/mapper/mysql/KgCountInfoMapper.xml
  20. 75 75
      src/main/resources/mapper/mysql/KgCountTotalInfoMapper.xml
  21. 20 20
      src/main/resources/mapper/mysql/PresetInfoMapper.xml

+ 18 - 0
pom.xml

@@ -168,6 +168,24 @@
             <version>2.0.1</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.3.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis</artifactId>
+            <version>3.5.9</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <scope>runtime</scope>
+            <optional>true</optional>
+        </dependency>
 
     </dependencies>
     <dependencyManagement>

+ 1 - 0
src/main/java/com/qizhen/healsphere/Application.java

@@ -16,6 +16,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
 @ConfigurationPropertiesScan
 @EnableNeo4jRepositories
 @EnableSwagger2
+@MapperScan("com.qizhen.healsphere.repository.mapper")
 public class Application {
 
     public static void main(String[] args) {

+ 22 - 0
src/main/java/com/qizhen/healsphere/config/MyMetaObjectHandler.java

@@ -0,0 +1,22 @@
+package com.qizhen.healsphere.config;
+
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+
+@Component
+public class MyMetaObjectHandler implements MetaObjectHandler {
+
+    @Override
+    public void insertFill(MetaObject metaObject) {
+        this.strictInsertFill(metaObject, "gmtCreate", LocalDateTime.class, LocalDateTime.now());
+        this.strictInsertFill(metaObject, "gmtModified", LocalDateTime.class, LocalDateTime.now());
+    }
+
+    @Override
+    public void updateFill(MetaObject metaObject) {
+        this.strictUpdateFill(metaObject, "gmtModified", LocalDateTime.class, LocalDateTime.now());
+    }
+} 

+ 33 - 0
src/main/java/com/qizhen/healsphere/config/MybatisPlusConfig.java

@@ -0,0 +1,33 @@
+package com.qizhen.healsphere.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MybatisPlusConfig {
+    
+    private static final Logger log = LoggerFactory.getLogger(MybatisPlusConfig.class);
+    
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+        return interceptor;
+    }
+    
+    @Bean
+    public ConfigurationCustomizer configurationCustomizer() {
+        return configuration -> {
+            configuration.setMapUnderscoreToCamelCase(true);
+            configuration.setCallSettersOnNulls(true);
+            log.info("MyBatis-Plus configuration: mapUnderscoreToCamelCase={}", 
+                configuration.isMapUnderscoreToCamelCase());
+        };
+    }
+} 

+ 12 - 9
src/main/java/com/qizhen/healsphere/config/MysqlConfig.java

@@ -1,33 +1,36 @@
 package com.qizhen.healsphere.config;
 
+import com.baomidou.mybatisplus.core.MybatisConfiguration;
+import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
 import org.apache.ibatis.session.SqlSessionFactory;
-import org.mybatis.spring.SqlSessionFactoryBean;
-import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.boot.jdbc.DataSourceBuilder;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
 
 import javax.sql.DataSource;
 
 @Configuration
-@MapperScan(basePackages = "com.qizhen.healsphere.repository.mapper")
 public class MysqlConfig {
 
-    @Bean(name = "mysqlDataSource")
+    @Bean(name = "dataSource")
     @ConfigurationProperties(prefix = "spring.datasource.hikari")
     public DataSource dataSource() {
         return DataSourceBuilder.create().build();
     }
 
     @Bean
-    public SqlSessionFactory sqlSessionFactory(@Qualifier("mysqlDataSource") DataSource dataSource) throws Exception {
-        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
+    public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
+        MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
         sqlSessionFactoryBean.setDataSource(dataSource);
-        // 设置MyBatis的XML映射文件路径
-        sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/mysql/*.xml"));
+        
+        // 添加 MyBatis 配置
+        MybatisConfiguration configuration = new MybatisConfiguration();
+        configuration.setMapUnderscoreToCamelCase(true);
+        configuration.setCallSettersOnNulls(true);
+        sqlSessionFactoryBean.setConfiguration(configuration);
+        
         return sqlSessionFactoryBean.getObject();
     }
 }

+ 24 - 10
src/main/java/com/qizhen/healsphere/repository/mapper/KgCountInfoMapper.java

@@ -1,8 +1,9 @@
 package com.qizhen.healsphere.repository.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qizhen.healsphere.repository.mapper.entity.KgCountInfo;
 import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 
@@ -12,14 +13,27 @@ import java.util.List;
  * </p>
  */
 @Mapper
-public interface KgCountInfoMapper {
-    List<KgCountInfo> getCountList(@Param("pageSize") Integer pageSize,@Param("offset") Integer offset);
-
-    Integer count();
-
+public interface KgCountInfoMapper extends BaseMapper<KgCountInfo> {
+    
+    @Select("SELECT " +
+            "n.category as node_type, " +
+            "COUNT(DISTINCT n.id) as node_num, " +
+            "COALESCE(SUM(prop_counts.prop_num), 0) as node_prop_num, " +
+            "COUNT(DISTINCT edge_counts.type) as relation_type, " +
+            "COALESCE(SUM(edge_counts.relation_count), 0) as relation_num, " +
+            "now() AT TIME ZONE 'UTC' as gmt_create, " +
+            "now() AT TIME ZONE 'UTC' as gmt_modified " +
+            "FROM kg_nodes n " +
+            "LEFT JOIN (" +
+            "   SELECT ref_id, COUNT(*) as prop_num FROM kg_props GROUP BY ref_id" +
+            ") prop_counts ON n.id = prop_counts.ref_id " +
+            "LEFT JOIN (" +
+            "   SELECT src_id as node_id, name as type, COUNT(*) as relation_count " +
+            "   FROM kg_edges GROUP BY src_id, name " +
+            "   UNION ALL " +
+            "   SELECT dest_id as node_id, name as type, COUNT(*) as relation_count " +
+            "   FROM kg_edges GROUP BY dest_id, name" +
+            ") edge_counts ON n.id = edge_counts.node_id " +
+            "GROUP BY n.category")
     List<KgCountInfo> calculateDetailInfo();
-
-    void clearTable();
-
-    void batchInsert(List<KgCountInfo> list);
 }

+ 24 - 5
src/main/java/com/qizhen/healsphere/repository/mapper/KgCountTotalInfoMapper.java

@@ -1,7 +1,9 @@
 package com.qizhen.healsphere.repository.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qizhen.healsphere.repository.mapper.entity.KgCountTotalInfo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * <p>
@@ -9,12 +11,29 @@ import org.apache.ibatis.annotations.Mapper;
  * </p>
  */
 @Mapper
-public interface KgCountTotalInfoMapper {
-    KgCountTotalInfo getCountTotalInfo();
-    
-    void save(KgCountTotalInfo info);
+public interface KgCountTotalInfoMapper extends BaseMapper<KgCountTotalInfo> {
     
-    void update(KgCountTotalInfo info);
+    @Select("SELECT id, gmt_create, gmt_modified, " +
+            "node_type_num, node_num, node_prop_num, " +
+            "relation_type_num, relation_num " +
+            "FROM kg_count_total_info LIMIT 1")
+    KgCountTotalInfo getCountTotalInfo();
     
+    @Select("SELECT " +
+            "1 as id, " +
+            "now() as gmt_create, " +
+            "now() as gmt_modified, " +
+            "t1.node_type_num as node_type_num, " +
+            "t1.node_num as node_num, " +
+            "t2.node_prop_num as node_prop_num, " +
+            "t3.relation_type_num as relation_type_num, " +
+            "t3.relation_num as relation_num " +
+            "FROM (" +
+            "   SELECT COUNT(DISTINCT category) as node_type_num, COUNT(*) as node_num FROM kg_nodes" +
+            ") t1, (" +
+            "   SELECT COUNT(*) as node_prop_num FROM kg_props" +
+            ") t2, (" +
+            "   SELECT COUNT(DISTINCT name) as relation_type_num, COUNT(*) as relation_num FROM kg_edges" +
+            ") t3")
     KgCountTotalInfo calculateTotalInfo();
 }

+ 3 - 2
src/main/java/com/qizhen/healsphere/repository/mapper/PresetInfoMapper.java

@@ -1,5 +1,6 @@
 package com.qizhen.healsphere.repository.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qizhen.healsphere.repository.mapper.entity.PresetInfo;
 import org.apache.ibatis.annotations.Mapper;
 
@@ -12,6 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
  * @since 2020-03-31
  */
 @Mapper
-public interface PresetInfoMapper {
-    PresetInfo getPresetInfoByType(Integer type);
+public interface PresetInfoMapper extends BaseMapper<PresetInfo> {
+    // 使用 MyBatis-Plus 的 BaseMapper 方法即可
 }

+ 27 - 18
src/main/java/com/qizhen/healsphere/repository/mapper/entity/KgCountInfo.java

@@ -1,10 +1,8 @@
 package com.qizhen.healsphere.repository.mapper.entity;
 
-
+import com.baomidou.mybatisplus.annotation.*;
 import lombok.Data;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
 
 /**
  * <p>
@@ -12,48 +10,59 @@ import java.time.LocalDateTime;
  * </p>
  */
 @Data
-public class KgCountInfo implements Serializable {
-
-    private static final long serialVersionUID = 1L;
+@TableName("kg_count_info")
+public class KgCountInfo {
 
-    /**
-     * 主键
-     */
+    @TableId(value = "id", type = IdType.AUTO)
     private Long id;
 
-    /**
-     * 记录创建时间
-     */
-    private LocalDateTime gmtCreate;
+    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
+    private OffsetDateTime gmtCreate;
 
-    /**
-     * 记录修改时间,如果时间是1970年则表示纪录未修改
-     */
-    private LocalDateTime gmtModified;
+    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
+    private OffsetDateTime gmtModified;
 
     /**
      * 实体类型
      */
+    @TableField(value = "node_type")
     private String nodeType;
 
     /**
      * 实体数量
      */
+    @TableField(value = "node_num")
     private Integer nodeNum;
 
     /**
      * 实体属性数量
      */
+    @TableField(value = "node_prop_num")
     private Integer nodePropNum;
 
     /**
      * 关系类型
      */
+    @TableField(value = "relation_type")
     private Integer relationType;
 
     /**
      * 关系数量
      */
+    @TableField(value = "relation_num")
     private Integer relationNum;
 
+    @Override
+    public String toString() {
+        return "KgCountInfo{" +
+                "id=" + id +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", nodeType='" + nodeType + '\'' +
+                ", nodeNum=" + nodeNum +
+                ", nodePropNum=" + nodePropNum +
+                ", relationType=" + relationType +
+                ", relationNum=" + relationNum +
+                '}';
+    }
 }

+ 22 - 47
src/main/java/com/qizhen/healsphere/repository/mapper/entity/KgCountTotalInfo.java

@@ -1,59 +1,34 @@
 package com.qizhen.healsphere.repository.mapper.entity;
 
-
+import com.baomidou.mybatisplus.annotation.*;
 import lombok.Data;
+import java.time.OffsetDateTime;
 
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-/**
- * <p>
- * 知识图谱统计信息
- * </p>
- */
 @Data
-public class KgCountTotalInfo implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 主键
-     */
+@TableName("kg_count_total_info")
+public class KgCountTotalInfo {
+    
+    @TableId(value = "id", type = IdType.AUTO)
     private Long id;
-
-    /**
-     * 记录创建时间
-     */
-    private LocalDateTime gmtCreate;
-
-    /**
-     * 记录修改时间,如果时间是1970年则表示纪录未修改
-     */
-    private LocalDateTime gmtModified;
-
-    /**
-     * 实体类型
-     */
+    
+    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
+    private OffsetDateTime gmtCreate;
+    
+    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
+    private OffsetDateTime gmtModified;
+    
+    @TableField("node_type_num")
     private Integer nodeTypeNum;
-
-    /**
-     * 实体数量
-     */
+    
+    @TableField("node_num")
     private Integer nodeNum;
-
-    /**
-     * 实体属性数量
-     */
+    
+    @TableField("node_prop_num")
     private Integer nodePropNum;
-
-    /**
-     * 关系类型
-     */
+    
+    @TableField("relation_type_num")
     private Integer relationTypeNum;
-
-    /**
-     * 关系数量
-     */
+    
+    @TableField("relation_num")
     private Integer relationNum;
-
 }

+ 15 - 88
src/main/java/com/qizhen/healsphere/repository/mapper/entity/PresetInfo.java

@@ -1,6 +1,9 @@
 package com.qizhen.healsphere.repository.mapper.entity;
 
 
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
@@ -12,144 +15,68 @@ import java.time.LocalDateTime;
  * @author gaodm
  * @since 2020-03-31
  */
+@Data
+@TableName("ltkg_preset_info")
 public class PresetInfo implements Serializable {
 
-    private static final long serialVersionUID = 1L;
 
     /**
      * 主键
      */
+    @TableId(value = "id", type = IdType.AUTO)
     private Long id;
 
     /**
      * 是否删除,N:未删除,Y:删除
      */
+    @TableField("is_deleted")
     private String isDeleted;
 
     /**
      * 记录创建时间
      */
+    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
     private LocalDateTime gmtCreate;
 
     /**
      * 记录修改时间,如果时间是1970年则表示纪录未修改
      */
+    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
     private LocalDateTime gmtModified;
 
     /**
      * 创建人,0表示无创建人值
      */
+    @TableField("creator")
     private String creator;
 
     /**
      * 修改人,如果为0则表示纪录未修改
      */
+    @TableField("modifier")
     private String modifier;
 
     /**
      * 类型 (0:默认,1:病历,20:疾病ICD10)
      */
+    @TableField("type")
     private Integer type;
 
     /**
      * 标题
      */
+    @TableField("title")
     private String title;
 
     /**
      * 内容
      */
+    @TableField("content")
     private String content;
 
     /**
      * 备注
      */
+    @TableField("remark")
     private String remark;
-
-    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 LocalDateTime getGmtCreate() {
-        return gmtCreate;
-    }
-
-    public void setGmtCreate(LocalDateTime gmtCreate) {
-        this.gmtCreate = gmtCreate;
-    }
-    public LocalDateTime getGmtModified() {
-        return gmtModified;
-    }
-
-    public void setGmtModified(LocalDateTime 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 Integer getType() {
-        return type;
-    }
-
-    public void setType(Integer type) {
-        this.type = type;
-    }
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-    public String getRemark() {
-        return remark;
-    }
-
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
-
-    @Override
-    public String toString() {
-        return "PresetInfo{" +
-            "id=" + id +
-            ", isDeleted=" + isDeleted +
-            ", gmtCreate=" + gmtCreate +
-            ", gmtModified=" + gmtModified +
-            ", creator=" + creator +
-            ", modifier=" + modifier +
-            ", type=" + type +
-            ", title=" + title +
-            ", content=" + content +
-            ", remark=" + remark +
-        "}";
-    }
 }

+ 45 - 44
src/main/java/com/qizhen/healsphere/repository/neo4j/BaseNodeRepository.java

@@ -190,63 +190,64 @@ public class BaseNodeRepository {
      * 实体合并
      */
     public Map<String, Object> mergeNode(MergeNodeParam mergeNodeParam) {
-
         try(Session session = neo4jUtil.getSession()) {
             // 找到要合并的两个节点
             String firstQuery = String.format("MATCH (a:`%s`) WHERE id(a) = $firstId RETURN a", mergeNodeParam.getFirstLabel());
             String secondQuery = String.format("MATCH (b:`%s`) WHERE id(b) = $secondId RETURN b", mergeNodeParam.getSecondLabel());
-            StatementResult aResult = session.run(firstQuery,Values.parameters("firstId", mergeNodeParam.getFirstId()));
-            Record aRecord = aResult.single();
-            Node a = aRecord.get("a").asNode();
-            StatementResult bResult = session.run(secondQuery,Values.parameters("secondId", mergeNodeParam.getSecondId()));
-            Record bRecord = bResult.single();
-            Node b = bRecord.get("b").asNode();
+            
+            StatementResult aResult = session.run(firstQuery, Values.parameters("firstId", mergeNodeParam.getFirstId()));
+            StatementResult bResult = session.run(secondQuery, Values.parameters("secondId", mergeNodeParam.getSecondId()));
+            
+            // 检查节点是否存在
+            if (!aResult.hasNext() || !bResult.hasNext()) {
+                throw new RuntimeException("One or both nodes not found");
+            }
+            
+            Node a = aResult.single().get("a").asNode();
+            Node b = bResult.single().get("b").asNode();
 
             // 创建新节点
             Map<String, Object> newNodeProps = new HashMap<>();
             newNodeProps.put("name", mergeNodeParam.getNewName());
-            // 合并属性
-            for (String key : a.keys()) {
-                newNodeProps.put(key, a.get(key).asObject());
-            }
-            for (String key : b.keys()) {
-                if (!newNodeProps.containsKey(key)) {
-                    newNodeProps.put(key, b.get(key).asObject());
-                }
-            }
-            StatementResult newNodeResult = session.run(String.format("MERGE (n:`%s` $props) RETURN n", mergeNodeParam.getNewLabel()), Values.parameters("props", newNodeProps));
+            StatementResult newNodeResult = session.run(
+                String.format("MERGE (n:`%s` {name:$name}) RETURN n", mergeNodeParam.getNewLabel()), 
+                Values.parameters("name", newNodeProps.get("name"))
+            );
             Node newNode = newNodeResult.single().get("n").asNode();
             long newNodeId = newNode.id();
 
-            // 合并关系
-            String firstRelationQuery = String.format("MATCH (a:`%s`)-[aR]-(aOther) WHERE id(a) = $firstId RETURN a,aR,aOther", mergeNodeParam.getFirstLabel());
-            String secondRelationQuery = String.format("MATCH (b:`%s`)-[bR]-(bOther) WHERE id(b) = $secondId RETURN b,bR,bOther", mergeNodeParam.getSecondLabel());
-            StatementResult aRelationResult = session.run(firstRelationQuery,Values.parameters("firstId", mergeNodeParam.getFirstId()));
-            StatementResult bRelationResult = session.run(secondRelationQuery,Values.parameters("secondId", mergeNodeParam.getSecondId()));
-            while (aRelationResult.hasNext()) {
-                Record record = aRelationResult.next();
-                Relationship relationship = record.get("aR").asRelationship();
-                String relType = relationship.type();
-                Node aOtherNode = record.get("aOther").asNode();
-                session.run("MATCH (a), (other) WHERE id(a) = $newNodeId and id(other) = $otherId " +
-                                "MERGE (a)-[newRel:$relType]->(other) SET newRel = $relProps",
-                        Values.parameters("newNodeId", newNodeId,"otherId", aOtherNode.id(), "relType", relType, "relProps", relationship.asMap()));
-
-            }
-            while (bRelationResult.hasNext()) {
-                Record record = aRelationResult.next();
-                Relationship relationship = record.get("bR").asRelationship();
-                String relType = relationship.type();
-                Node bOtherNode = record.get("bOther").asNode();
-                session.run("MATCH (a), (other) WHERE id(a) = $newNodeId and id(other) = $otherId " +
-                                "MERGE (a)-[newRel:$relType]->(other) SET newRel = $relProps",
-                        Values.parameters("newNodeId", newNodeId,"otherId", bOtherNode.id(), "relType", relType, "relProps", relationship.asMap()));
-
-            }
+            // 合并关系 - 修改这部分代码
+            String firstRelationQuery = String.format(
+                "MATCH (a:`%s`)-[r]-(other) WHERE id(a) = $firstId " +
+                "WITH r, other, type(r) as relType, properties(r) as props " +
+                "MATCH (n) WHERE id(n) = $newNodeId " +
+                "MERGE (n)-[newRel:`${type(r)}`]->(other) " +
+                "SET newRel += props", 
+                mergeNodeParam.getFirstLabel()
+            );
+            
+            String secondRelationQuery = String.format(
+                "MATCH (b:`%s`)-[r]-(other) WHERE id(b) = $secondId " +
+                "WITH r, other, type(r) as relType, properties(r) as props " +
+                "MATCH (n) WHERE id(n) = $newNodeId " +
+                "MERGE (n)-[newRel:`${type(r)}`]->(other) " +
+                "SET newRel += props",
+                mergeNodeParam.getSecondLabel()
+            );
+
+            // 执行关系迁移
+            session.run(firstRelationQuery, Values.parameters("firstId", mergeNodeParam.getFirstId(), "newNodeId", newNodeId));
+            session.run(secondRelationQuery, Values.parameters("secondId", mergeNodeParam.getSecondId(), "newNodeId", newNodeId));
 
             // 删除原始节点
-            session.run(String.format("MATCH (a:`%s`) WHERE id(a) = $firstId  DETACH DELETE a", mergeNodeParam.getFirstLabel()),Values.parameters("firstId", mergeNodeParam.getFirstId()));
-            session.run(String.format("MATCH (a:`%s`) WHERE id(a) = $secondId  DETACH DELETE a", mergeNodeParam.getSecondLabel()),Values.parameters("secondId", mergeNodeParam.getSecondId()));
+            session.run(
+                String.format("MATCH (a:`%s`) WHERE id(a) = $firstId DETACH DELETE a", mergeNodeParam.getFirstLabel()),
+                Values.parameters("firstId", mergeNodeParam.getFirstId())
+            );
+            session.run(
+                String.format("MATCH (a:`%s`) WHERE id(a) = $secondId DETACH DELETE a", mergeNodeParam.getSecondLabel()),
+                Values.parameters("secondId", mergeNodeParam.getSecondId())
+            );
 
             Map<String,Object> map = new HashMap<>();
             map.put("id", newNode.id());

+ 84 - 63
src/main/java/com/qizhen/healsphere/service/impl/KgCountServiceImpl.java

@@ -2,6 +2,8 @@ package com.qizhen.healsphere.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qizhen.healsphere.repository.mapper.KgCountInfoMapper;
 import com.qizhen.healsphere.repository.mapper.KgCountTotalInfoMapper;
 import com.qizhen.healsphere.repository.mapper.entity.KgCountInfo;
@@ -10,14 +12,14 @@ import com.qizhen.healsphere.service.KgCountService;
 import com.qizhen.healsphere.web.param.KgCountListPageQuery;
 import com.qizhen.healsphere.web.vo.CountInfoVO;
 import com.qizhen.healsphere.web.vo.CountListVO;
-import com.qizhen.healsphere.web.vo.Page;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import lombok.extern.slf4j.Slf4j;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -36,63 +38,87 @@ public class KgCountServiceImpl implements KgCountService {
 
     @Override
     public CountInfoVO getCountTotalInfo() {
-
         CountInfoVO countInfoVO = new CountInfoVO();
         List<CountInfoVO.InfoVO> infoVOS = new ArrayList<>();
-        CountInfoVO.InfoVO nodeTypeInfoVO = new CountInfoVO.InfoVO();
-        nodeTypeInfoVO.setName("实体类型");
-        nodeTypeInfoVO.setNum(0);
-
-        CountInfoVO.InfoVO nodeInfoVO = new CountInfoVO.InfoVO();
-        nodeInfoVO.setName("实体");
-        nodeInfoVO.setNum(0);
-
-        CountInfoVO.InfoVO nodePropInfoVO = new CountInfoVO.InfoVO();
-        nodePropInfoVO.setName("实体属性");
-        nodePropInfoVO.setNum(0);
-
-        CountInfoVO.InfoVO relationTypeInfoVO = new CountInfoVO.InfoVO();
-        relationTypeInfoVO.setName("关系类型");
-        relationTypeInfoVO.setNum(0);
-
-        CountInfoVO.InfoVO relationInfoVO = new CountInfoVO.InfoVO();
-        relationInfoVO.setName("关系");
-        relationInfoVO.setNum(0);
-
+        
+        // 初始化各个统计项
+        infoVOS.add(createInfoVO("实体类型", 0));
+        infoVOS.add(createInfoVO("实体", 0));
+        infoVOS.add(createInfoVO("实体属性", 0));
+        infoVOS.add(createInfoVO("关系类型", 0));
+        infoVOS.add(createInfoVO("关系", 0));
+
+        // 查询统计数据 - 使用原来的方法
         KgCountTotalInfo countTotalInfo = kgCountTotalInfoMapper.getCountTotalInfo();
+
+        // 更新统计数据
         if (countTotalInfo != null) {
-            nodeTypeInfoVO.setNum(countTotalInfo.getNodeTypeNum());
-            nodeInfoVO.setNum(countTotalInfo.getNodeNum());
-            nodePropInfoVO.setNum(countTotalInfo.getNodePropNum());
-            relationTypeInfoVO.setNum(countTotalInfo.getRelationTypeNum());
-            relationInfoVO.setNum(countTotalInfo.getRelationNum());
+            infoVOS.get(0).setNum(countTotalInfo.getNodeTypeNum());
+            infoVOS.get(1).setNum(countTotalInfo.getNodeNum());
+            infoVOS.get(2).setNum(countTotalInfo.getNodePropNum());
+            infoVOS.get(3).setNum(countTotalInfo.getRelationTypeNum());
+            infoVOS.get(4).setNum(countTotalInfo.getRelationNum());
         }
-        infoVOS.add(nodeTypeInfoVO);
-        infoVOS.add(nodeInfoVO);
-        infoVOS.add(nodePropInfoVO);
-        infoVOS.add(relationTypeInfoVO);
-        infoVOS.add(relationInfoVO);
+
         countInfoVO.setInfos(infoVOS);
         return countInfoVO;
     }
 
+    private CountInfoVO.InfoVO createInfoVO(String name, Integer num) {
+        CountInfoVO.InfoVO infoVO = new CountInfoVO.InfoVO();
+        infoVO.setName(name);
+        infoVO.setNum(num);
+        return infoVO;
+    }
+
     @Override
-    public Page<CountListVO> getCountListInfo(KgCountListPageQuery query) {
-        Integer pageNo = query.getPageNo();
-        Integer pageSize = query.getPageSize();
-
-        Integer count = kgCountInfoMapper.count();
-        List<CountListVO> listVOS = new ArrayList<>();
-        if (count > 0){
-            List<KgCountInfo> countList = kgCountInfoMapper.getCountList(pageSize, (pageNo - 1) * pageSize);
-            if (CollUtil.isNotEmpty(countList)){
-                countList.forEach(kgCountInfo -> {
-                    CountListVO countListVO = BeanUtil.copyProperties(kgCountInfo, CountListVO.class);
-                    listVOS.add(countListVO);
-                });
+    public com.qizhen.healsphere.web.vo.Page<CountListVO> getCountListInfo(KgCountListPageQuery query) {
+        try {
+            // 在这里设置断点
+            Page<KgCountInfo> page = new Page<>(query.getPageNo(), query.getPageSize());
+            
+            // 在这里设置断点
+            QueryWrapper<KgCountInfo> queryWrapper = new QueryWrapper<>();
+            queryWrapper.orderByDesc("node_num");
+            
+            // 在这里设置断点
+            Page<KgCountInfo> result = kgCountInfoMapper.selectPage(page, queryWrapper);
+            
+            if (result == null || result.getRecords() == null) {
+                log.warn("查询结果为null");
+                return new com.qizhen.healsphere.web.vo.Page<>(query.getPageNo(), query.getPageSize(), 0, 0, new ArrayList<>());
             }
+            
+            log.info("查询到 {} 条记录", result.getRecords().size());
+            result.getRecords().forEach(record -> {
+                log.info("记录详情: {}", record);
+                log.info("SQL查询结果字段值: id={}, nodeType={}, nodeNum={}, nodePropNum={}, relationType={}, relationNum={}",
+                    record.getId(), record.getNodeType(), record.getNodeNum(), 
+                    record.getNodePropNum(), record.getRelationType(), record.getRelationNum());
+            });
+            
+            // 转换为 VO 对象
+            List<CountListVO> listVOS = result.getRecords().stream()
+                .map(info -> {
+                    CountListVO vo = new CountListVO();
+                    log.info("转换前的实体对象: {}", info);
+                    BeanUtil.copyProperties(info, vo);
+                    log.info("转换后的VO对象: {}", vo);
+                    return vo;
+                })
+                .collect(Collectors.toList());
+                
+            return new com.qizhen.healsphere.web.vo.Page<>(
+                query.getPageNo(), 
+                query.getPageSize(), 
+                listVOS.size(), 
+                (int)result.getTotal(), 
+                listVOS
+            );
+        } catch (Exception e) {
+            log.error("获取统计列表失败", e);
+            throw new RuntimeException("获取统计列表失败", e);
         }
-        return new Page<>(pageNo,pageSize,listVOS.size(),count,listVOS);
     }
 
     @Override
@@ -100,13 +126,8 @@ public class KgCountServiceImpl implements KgCountService {
     public Boolean updateStatisticsData() {
         try {
             log.info("开始更新统计数据...");
-            
-            // 1. 更新总体统计信息
             updateTotalInfo();
-            
-            // 2. 更新分类统计信息
             updateDetailInfo();
-            
             log.info("统计数据更新完成");
             return true;
         } catch (Exception e) {
@@ -116,42 +137,42 @@ public class KgCountServiceImpl implements KgCountService {
     }
 
     private void updateTotalInfo() {
-        // 1. 获取新的统计数据
         KgCountTotalInfo totalInfo = kgCountTotalInfoMapper.calculateTotalInfo();
+        log.info("计算得到的统计数据: {}", totalInfo);
         if (totalInfo == null) {
             throw new RuntimeException("计算总体统计数据失败");
         }
 
-        // 2. 查询现有数据
         KgCountTotalInfo existingInfo = kgCountTotalInfoMapper.getCountTotalInfo();
-
-        // 3. 更新或插入数据
+        log.info("查询到的现有数据: {}", existingInfo);
+        
         if (existingInfo != null) {
             totalInfo.setId(existingInfo.getId());
-            kgCountTotalInfoMapper.update(totalInfo);
+            kgCountTotalInfoMapper.updateById(totalInfo);
             log.info("更新总体统计数据成功");
         } else {
             totalInfo.setId(1L);
-            kgCountTotalInfoMapper.save(totalInfo);
+            kgCountTotalInfoMapper.insert(totalInfo);
             log.info("插入总体统计数据成功");
         }
     }
 
     private void updateDetailInfo() {
         try {
-            // 1. 获取新的分类统计数据
             List<KgCountInfo> detailInfoList = kgCountInfoMapper.calculateDetailInfo();
             if (CollUtil.isEmpty(detailInfoList)) {
                 log.warn("没有获取到分类统计数据");
                 return;
             }
 
-            // 2. 清空现有数据
-            kgCountInfoMapper.clearTable();
+            // 清空现有数据
+            kgCountInfoMapper.delete(null);
             log.info("清空分类统计表成功");
 
-            // 3. 批量插入新数据
-            kgCountInfoMapper.batchInsert(detailInfoList);
+            // 批量插入新数据
+            for (KgCountInfo info : detailInfoList) {
+                kgCountInfoMapper.insert(info);
+            }
             log.info("插入分类统计数据成功,共 {} 条记录", detailInfoList.size());
         } catch (Exception e) {
             log.error("更新分类统计数据失败", e);

+ 13 - 3
src/main/java/com/qizhen/healsphere/service/impl/PresetInfoServiceImpl.java

@@ -1,10 +1,16 @@
 package com.qizhen.healsphere.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qizhen.healsphere.repository.mapper.PresetInfoMapper;
 import com.qizhen.healsphere.repository.mapper.entity.PresetInfo;
 import com.qizhen.healsphere.service.PresetInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import lombok.extern.slf4j.Slf4j;
+import java.util.List;
 
 /**
  * <p>
@@ -15,13 +21,17 @@ import org.springframework.stereotype.Service;
  * @since 2020-03-31
  */
 @Service
-public class PresetInfoServiceImpl implements PresetInfoService {
+@Slf4j
+public class PresetInfoServiceImpl extends ServiceImpl<PresetInfoMapper, PresetInfo> {
 
     @Autowired
     private PresetInfoMapper presetInfoMapper;
 
-    @Override
     public PresetInfo getPresetInfo(Integer type) {
-        return presetInfoMapper.getPresetInfoByType(type);
+        // 使用 QueryWrapper 构建查询条件
+        return presetInfoMapper.selectOne(
+            new QueryWrapper<PresetInfo>()
+                .eq("type", type)
+        );
     }
 }

+ 1 - 1
src/main/java/com/qizhen/healsphere/web/KgCountController.java

@@ -5,11 +5,11 @@ import com.qizhen.healsphere.web.dto.RespDTO;
 import com.qizhen.healsphere.web.param.KgCountListPageQuery;
 import com.qizhen.healsphere.web.vo.CountInfoVO;
 import com.qizhen.healsphere.web.vo.CountListVO;
+import com.qizhen.healsphere.web.vo.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;

+ 19 - 0
src/main/java/com/qizhen/healsphere/web/vo/CountListVO.java

@@ -2,11 +2,30 @@ package com.qizhen.healsphere.web.vo;
 
 import lombok.Data;
 
+import java.time.OffsetDateTime;
+
 @Data
 public class CountListVO {
+    private Long id;
+    private OffsetDateTime gmtCreate;
+    private OffsetDateTime gmtModified;
     private String nodeType;
     private Integer nodeNum;
     private Integer nodePropNum;
     private Integer relationType;
     private Integer relationNum;
+    
+    @Override
+    public String toString() {
+        return "CountListVO{" +
+                "id=" + id +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", nodeType='" + nodeType + '\'' +
+                ", nodeNum=" + nodeNum +
+                ", nodePropNum=" + nodePropNum +
+                ", relationType=" + relationType +
+                ", relationNum=" + relationNum +
+                '}';
+    }
 }

+ 12 - 1
src/main/resources/application-local.yml

@@ -24,10 +24,21 @@ spring:
       username: neo4j
       password: 12345678
 
+  devtools:
+    restart:
+      enabled: true
+      additional-paths: src/main/java
+      exclude: static/**,public/**
+
 springfox:
   documentation:
     enabled: true
 
 server:
   port: 8086
-  max-http-header-size: 10MB
+  max-http-header-size: 10MB
+
+logging:
+  level:
+    com.qizhen.healsphere.repository.mapper: debug
+    org.apache.ibatis: debug

+ 14 - 1
src/main/resources/application.yml

@@ -6,4 +6,17 @@ spring:
 
 server:
   servlet:
-    context-path: /healsphere
+    context-path: /healsphere
+
+mybatis-plus:
+  configuration:
+    map-underscore-to-camel-case: true
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    call-setters-on-nulls: true
+    jdbc-type-for-null: null
+    default-executor-type: reuse
+  type-aliases-package: com.qizhen.healsphere.repository.mapper.entity
+  global-config:
+    db-config:
+      id-type: auto
+    banner: false

+ 81 - 81
src/main/resources/mapper/mysql/KgCountInfoMapper.xml

@@ -1,88 +1,88 @@
-<?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.qizhen.healsphere.repository.mapper.KgCountInfoMapper">
+<!--<?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.qizhen.healsphere.repository.mapper.KgCountInfoMapper">-->
 
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.qizhen.healsphere.repository.mapper.entity.KgCountInfo">
-        <id column="id" property="id" />
-        <result column="gmt_create" property="gmtCreate" />
-        <result column="gmt_modified" property="gmtModified" />
-        <result column="node_type" property="nodeType" />
-        <result column="node_num" property="nodeNum" />
-        <result column="node_prop_num" property="nodePropNum" />
-        <result column="relation_type" property="relationType" />
-        <result column="relation_num" property="relationNum" />
-    </resultMap>
+<!--    &lt;!&ndash; 通用查询映射结果 &ndash;&gt;-->
+<!--    <resultMap id="BaseResultMap" type="com.qizhen.healsphere.repository.mapper.entity.KgCountInfo">-->
+<!--        <id column="id" property="id" />-->
+<!--        <result column="gmt_create" property="gmtCreate" />-->
+<!--        <result column="gmt_modified" property="gmtModified" />-->
+<!--        <result column="node_type" property="nodeType" />-->
+<!--        <result column="node_num" property="nodeNum" />-->
+<!--        <result column="node_prop_num" property="nodePropNum" />-->
+<!--        <result column="relation_type" property="relationType" />-->
+<!--        <result column="relation_num" property="relationNum" />-->
+<!--    </resultMap>-->
 
-    <select id="getCountList" resultMap="BaseResultMap">
-        select * from kg_count_info limit #{pageSize} offset #{offset}
-    </select>
+<!--    <select id="getCountList" resultMap="BaseResultMap">-->
+<!--        select * from kg_count_info limit #{pageSize} offset #{offset}-->
+<!--    </select>-->
 
-    <select id="count" resultType="java.lang.Integer">
-        select count(*) from kg_count_info
-    </select>
+<!--    <select id="count" resultType="java.lang.Integer">-->
+<!--        select count(*) from kg_count_info-->
+<!--    </select>-->
 
-    <!-- 按照节点类型统计详细信息 -->
-    <select id="calculateDetailInfo" resultMap="BaseResultMap">
-        SELECT 
-            n.category as node_type,
-            COUNT(DISTINCT n.id) as node_num,
-            COALESCE(SUM(prop_counts.prop_num), 0) as node_prop_num,
-            COUNT(DISTINCT edge_counts.type) as relation_type,
-            COALESCE(SUM(edge_counts.relation_count), 0) as relation_num
-        FROM kg_nodes n
-        LEFT JOIN (
-            SELECT 
-                ref_id,
-                COUNT(*) as prop_num
-            FROM kg_props
-            GROUP BY ref_id
-        ) prop_counts ON n.id = prop_counts.ref_id
-        LEFT JOIN (
-            SELECT 
-                src_id as node_id,
-                name as type,
-                COUNT(*) as relation_count
-            FROM kg_edges
-            GROUP BY src_id, name
-            UNION ALL
-            SELECT 
-                dest_id as node_id,
-                name as type,
-                COUNT(*) as relation_count
-            FROM kg_edges
-            GROUP BY dest_id, name
-        ) edge_counts ON n.id = edge_counts.node_id
-        GROUP BY n.category
-    </select>
+<!--    &lt;!&ndash; 按照节点类型统计详细信息 &ndash;&gt;-->
+<!--    <select id="calculateDetailInfo" resultMap="BaseResultMap">-->
+<!--        SELECT -->
+<!--            n.category as node_type,-->
+<!--            COUNT(DISTINCT n.id) as node_num,-->
+<!--            COALESCE(SUM(prop_counts.prop_num), 0) as node_prop_num,-->
+<!--            COUNT(DISTINCT edge_counts.type) as relation_type,-->
+<!--            COALESCE(SUM(edge_counts.relation_count), 0) as relation_num-->
+<!--        FROM kg_nodes n-->
+<!--        LEFT JOIN (-->
+<!--            SELECT -->
+<!--                ref_id,-->
+<!--                COUNT(*) as prop_num-->
+<!--            FROM kg_props-->
+<!--            GROUP BY ref_id-->
+<!--        ) prop_counts ON n.id = prop_counts.ref_id-->
+<!--        LEFT JOIN (-->
+<!--            SELECT -->
+<!--                src_id as node_id,-->
+<!--                name as type,-->
+<!--                COUNT(*) as relation_count-->
+<!--            FROM kg_edges-->
+<!--            GROUP BY src_id, name-->
+<!--            UNION ALL-->
+<!--            SELECT -->
+<!--                dest_id as node_id,-->
+<!--                name as type,-->
+<!--                COUNT(*) as relation_count-->
+<!--            FROM kg_edges-->
+<!--            GROUP BY dest_id, name-->
+<!--        ) edge_counts ON n.id = edge_counts.node_id-->
+<!--        GROUP BY n.category-->
+<!--    </select>-->
 
-    <!-- 清空统计表 -->
-    <delete id="clearTable">
-        DELETE FROM kg_count_info
-    </delete>
+<!--    &lt;!&ndash; 清空统计表 &ndash;&gt;-->
+<!--    <delete id="clearTable">-->
+<!--        DELETE FROM kg_count_info-->
+<!--    </delete>-->
 
-    <!-- 批量插入统计数据 -->
-    <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
-        INSERT INTO kg_count_info (
-            gmt_create,
-            gmt_modified,
-            node_type,
-            node_num,
-            node_prop_num,
-            relation_type,
-            relation_num
-        ) VALUES 
-        <foreach collection="list" item="item" separator=",">
-            (
-                now(),
-                now(),
-                #{item.nodeType},
-                #{item.nodeNum},
-                #{item.nodePropNum},
-                #{item.relationType},
-                #{item.relationNum}
-            )
-        </foreach>
-    </insert>
+<!--    &lt;!&ndash; 批量插入统计数据 &ndash;&gt;-->
+<!--    <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">-->
+<!--        INSERT INTO kg_count_info (-->
+<!--            gmt_create,-->
+<!--            gmt_modified,-->
+<!--            node_type,-->
+<!--            node_num,-->
+<!--            node_prop_num,-->
+<!--            relation_type,-->
+<!--            relation_num-->
+<!--        ) VALUES -->
+<!--        <foreach collection="list" item="item" separator=",">-->
+<!--            (-->
+<!--                now(),-->
+<!--                now(),-->
+<!--                #{item.nodeType},-->
+<!--                #{item.nodeNum},-->
+<!--                #{item.nodePropNum},-->
+<!--                #{item.relationType},-->
+<!--                #{item.relationNum}-->
+<!--            )-->
+<!--        </foreach>-->
+<!--    </insert>-->
 
-</mapper>
+<!--</mapper>-->

+ 75 - 75
src/main/resources/mapper/mysql/KgCountTotalInfoMapper.xml

@@ -1,81 +1,81 @@
-<?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.qizhen.healsphere.repository.mapper.KgCountTotalInfoMapper">
+<!--<?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.qizhen.healsphere.repository.mapper.KgCountTotalInfoMapper">-->
 
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.qizhen.healsphere.repository.mapper.entity.KgCountTotalInfo">
-        <id column="id" property="id" />
-        <result column="gmt_create" property="gmtCreate" />
-        <result column="gmt_modified" property="gmtModified" />
-        <result column="node_type_num" property="nodeTypeNum" />
-        <result column="node_num" property="nodeNum" />
-        <result column="node_prop_num" property="nodePropNum" />
-        <result column="relation_type_num" property="relationTypeNum" />
-        <result column="relation_num" property="relationNum" />
-    </resultMap>
+<!--    &lt;!&ndash; 通用查询映射结果 &ndash;&gt;-->
+<!--    <resultMap id="BaseResultMap" type="com.qizhen.healsphere.repository.mapper.entity.KgCountTotalInfo">-->
+<!--        <id column="id" property="id" />-->
+<!--        <result column="gmt_create" property="gmtCreate" />-->
+<!--        <result column="gmt_modified" property="gmtModified" />-->
+<!--        <result column="node_type_num" property="nodeTypeNum" />-->
+<!--        <result column="node_num" property="nodeNum" />-->
+<!--        <result column="node_prop_num" property="nodePropNum" />-->
+<!--        <result column="relation_type_num" property="relationTypeNum" />-->
+<!--        <result column="relation_num" property="relationNum" />-->
+<!--    </resultMap>-->
 
-    <select id="getCountTotalInfo" resultMap="BaseResultMap">
-        select * from kg_count_total_info limit 1
-    </select>
+<!--    <select id="getCountTotalInfo" resultMap="BaseResultMap">-->
+<!--        select * from kg_count_total_info limit 1-->
+<!--    </select>-->
 
-    <insert id="save" parameterType="com.qizhen.healsphere.repository.mapper.entity.KgCountTotalInfo" 
-            useGeneratedKeys="true" keyProperty="id">
-        insert into kg_count_total_info (
-            id,
-            gmt_create,
-            gmt_modified,
-            node_type_num,
-            node_num,
-            node_prop_num,
-            relation_type_num,
-            relation_num
-        ) values (
-            1,  <!-- 由于只有一条记录,直接使用固定值 1 -->
-            now(),
-            now(),
-            #{nodeTypeNum},
-            #{nodeNum},
-            #{nodePropNum},
-            #{relationTypeNum},
-            #{relationNum}
-        )
-    </insert>
+<!--    <insert id="save" parameterType="com.qizhen.healsphere.repository.mapper.entity.KgCountTotalInfo" -->
+<!--            useGeneratedKeys="true" keyProperty="id">-->
+<!--        insert into kg_count_total_info (-->
+<!--            id,-->
+<!--            gmt_create,-->
+<!--            gmt_modified,-->
+<!--            node_type_num,-->
+<!--            node_num,-->
+<!--            node_prop_num,-->
+<!--            relation_type_num,-->
+<!--            relation_num-->
+<!--        ) values (-->
+<!--            1,  &lt;!&ndash; 由于只有一条记录,直接使用固定值 1 &ndash;&gt;-->
+<!--            now(),-->
+<!--            now(),-->
+<!--            #{nodeTypeNum},-->
+<!--            #{nodeNum},-->
+<!--            #{nodePropNum},-->
+<!--            #{relationTypeNum},-->
+<!--            #{relationNum}-->
+<!--        )-->
+<!--    </insert>-->
 
-    <update id="update" parameterType="com.qizhen.healsphere.repository.mapper.entity.KgCountTotalInfo">
-        update kg_count_total_info
-        set gmt_modified = now(),
-            node_type_num = #{nodeTypeNum},
-            node_num = #{nodeNum},
-            node_prop_num = #{nodePropNum},
-            relation_type_num = #{relationTypeNum},
-            relation_num = #{relationNum}
-        where id = #{id}
-    </update>
+<!--    <update id="update" parameterType="com.qizhen.healsphere.repository.mapper.entity.KgCountTotalInfo">-->
+<!--        update kg_count_total_info-->
+<!--        set gmt_modified = now(),-->
+<!--            node_type_num = #{nodeTypeNum},-->
+<!--            node_num = #{nodeNum},-->
+<!--            node_prop_num = #{nodePropNum},-->
+<!--            relation_type_num = #{relationTypeNum},-->
+<!--            relation_num = #{relationNum}-->
+<!--        where id = #{id}-->
+<!--    </update>-->
 
-    <!-- 统计所有节点和关系的汇总信息 -->
-    <select id="calculateTotalInfo" resultMap="BaseResultMap">
-        SELECT 
-            t1.node_type_num,
-            t1.node_num,
-            t2.node_prop_num,
-            t3.relation_type_num,
-            t3.relation_num
-        FROM (
-            SELECT 
-                COUNT(DISTINCT category) as node_type_num,
-                COUNT(*) as node_num 
-            FROM kg_nodes
-        ) t1,
-        (
-            SELECT COUNT(*) as node_prop_num 
-            FROM kg_props
-        ) t2,
-        (
-            SELECT 
-                COUNT(DISTINCT name) as relation_type_num,
-                COUNT(*) as relation_num 
-            FROM kg_edges
-        ) t3
-    </select>
+<!--    &lt;!&ndash; 统计所有节点和关系的汇总信息 &ndash;&gt;-->
+<!--    <select id="calculateTotalInfo" resultMap="BaseResultMap">-->
+<!--        SELECT -->
+<!--            t1.node_type_num,-->
+<!--            t1.node_num,-->
+<!--            t2.node_prop_num,-->
+<!--            t3.relation_type_num,-->
+<!--            t3.relation_num-->
+<!--        FROM (-->
+<!--            SELECT -->
+<!--                COUNT(DISTINCT category) as node_type_num,-->
+<!--                COUNT(*) as node_num -->
+<!--            FROM kg_nodes-->
+<!--        ) t1,-->
+<!--        (-->
+<!--            SELECT COUNT(*) as node_prop_num -->
+<!--            FROM kg_props-->
+<!--        ) t2,-->
+<!--        (-->
+<!--            SELECT -->
+<!--                COUNT(DISTINCT name) as relation_type_num,-->
+<!--                COUNT(*) as relation_num -->
+<!--            FROM kg_edges-->
+<!--        ) t3-->
+<!--    </select>-->
 
-</mapper>
+<!--</mapper>-->

+ 20 - 20
src/main/resources/mapper/mysql/PresetInfoMapper.xml

@@ -1,24 +1,24 @@
-<?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.qizhen.healsphere.repository.mapper.PresetInfoMapper">
+<!--<?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.qizhen.healsphere.repository.mapper.PresetInfoMapper">-->
 
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.qizhen.healsphere.repository.mapper.entity.PresetInfo">
-        <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="type" property="type" />
-        <result column="title" property="title" />
-        <result column="content" property="content" />
-        <result column="remark" property="remark" />
-    </resultMap>
+<!--    &lt;!&ndash; 通用查询映射结果 &ndash;&gt;-->
+<!--    <resultMap id="BaseResultMap" type="com.qizhen.healsphere.repository.mapper.entity.PresetInfo">-->
+<!--        <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="type" property="type" />-->
+<!--        <result column="title" property="title" />-->
+<!--        <result column="content" property="content" />-->
+<!--        <result column="remark" property="remark" />-->
+<!--    </resultMap>-->
 
-    <select id="getPresetInfoByType" resultMap="BaseResultMap" parameterType="java.lang.Integer">
-        select * from ltkg_preset_info where type = #{type} and is_deleted = 'N' limit 1
-    </select>
+<!--    <select id="getPresetInfoByType" resultMap="BaseResultMap" parameterType="java.lang.Integer">-->
+<!--        select * from ltkg_preset_info where type = #{type} and is_deleted = 'N' limit 1-->
+<!--    </select>-->
 
 
-</mapper>
+<!--</mapper>-->