Parcourir la source

Merge remote-tracking branch 'origin/master'

yuchengwei il y a 2 jours
Parent
commit
7434430bc0

+ 11 - 12
pom.xml

@@ -16,7 +16,6 @@
         <mybatis-spring-boot.version>2.1.1</mybatis-spring-boot.version>
         <druid.version>1.1.21</druid.version>
         <swagger.version>2.9.2</swagger.version>
-<!--        <poi.version>4.1.1</poi.version>-->
         <poi.version>5.2.3</poi.version>
 
     </properties>
@@ -195,16 +194,6 @@
             <groupId>com.github.ben-manes.caffeine</groupId>
             <artifactId>caffeine</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.poi</groupId>
-            <artifactId>poi-ooxml</artifactId>
-            <version>5.2.3</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.poi</groupId>
-            <artifactId>poi-ooxml-schemas</artifactId>
-            <version>4.1.2</version>
-        </dependency>
         <dependency>
             <groupId>org.apache.xmlbeans</groupId>
             <artifactId>xmlbeans</artifactId>
@@ -215,7 +204,17 @@
             <artifactId>commons-collections4</artifactId>
             <version>4.4</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-scratchpad</artifactId>
+            <version>${poi.version}</version>
+        </dependency>
+        <!-- 其他依赖 -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.12.0</version> <!-- 请使用最新版本 -->
+        </dependency>
     </dependencies>
     <dependencyManagement>
         <dependencies>

+ 55 - 7
src/main/java/com/qizhen/healsphere/TxtSplitter.java

@@ -120,13 +120,61 @@ public class TxtSplitter {
     }
 
     public static void main(String[] args) {
-        split(false,JIE_PATTERN);
-        split(false,TITLE1_PATTERN);
-        split(true,TITLE2_PATTERN);
+        String rootDirectory = "E:\\急诊科资料\\中华医学期刊数据库"; // 指定根目录
+        TxtSplitter txtSplitter = new TxtSplitter();
+        //txtSplitter.processAllTxtFiles(rootDirectory,1);
+        //txtSplitter.processAllTxtFiles(rootDirectory,2);
+        txtSplitter.processAllTxtFiles(rootDirectory,3);
     }
-    private static void split(boolean split,String pattern) {
-        String inputDirectoryPath = "E:\\project\\vscode\\《急诊与灾难医学(第4版)》\\"; // 修改为目录路径
-        //String inputDirectoryPath = "E:\\project\\vscode\\《急诊与灾难医学(第4版)》\\"; // 修改为目录路径
+
+    /**
+     * 递归查找指定根目录下的所有 .txt 文件,并调用 split 方法处理
+     * @param rootDirectory 根目录路径
+     */
+    public void processAllTxtFiles(String rootDirectory,int opt) {
+        File rootDir = new File(rootDirectory);
+        if (rootDir.exists() && rootDir.isDirectory()) {
+            findAndProcessTxtFiles(rootDir,opt);
+        } else {
+            System.out.println("指定的根目录不存在或不是一个目录: " + rootDirectory);
+        }
+    }
+
+    /**
+     * 递归查找 .txt 文件并调用 split 方法处理
+     * @param directory 当前目录
+     */
+    private void findAndProcessTxtFiles(File directory,int opt) {
+        File[] files = directory.listFiles();
+        if (files != null) {
+            for (File file : files) {
+                if (file.isDirectory()) {
+                    // 递归处理子目录
+                    findAndProcessTxtFiles(file,opt);
+                } else if (file.isFile() && file.getName().toLowerCase().endsWith(".txt")) {
+                    // 处理 .txt 文件
+                    String inputFilePath = file.getAbsolutePath();
+                    // 获取父文件夹路径
+                    String parentDirectoryPath = file.getParent();
+                    // 调用 split 方法时,传入父文件夹路径
+                    if(opt==1) {
+                        split(false,JIE_PATTERN, parentDirectoryPath);
+                    }else if(opt==2){
+                        split(false,TITLE1_PATTERN, parentDirectoryPath);
+                    }else if(opt==3){
+                        split(true, TITLE2_PATTERN, parentDirectoryPath);
+                    }
+                }
+            }
+        }
+    }
+
+    public static void main1(String[] args) {
+//        /*split(false,JIE_PATTERN);
+//        split(false,TITLE1_PATTERN);
+//        split(true,TITLE2_PATTERN);*/
+    }
+    private static void split(boolean split,String pattern,String inputDirectoryPath) {
         File inputDirectory = new File(inputDirectoryPath);
         traverse(inputDirectory, split,pattern);
     }
@@ -157,7 +205,7 @@ public class TxtSplitter {
             TxtSplitter txtSplitter = new TxtSplitter();
             // 无子目录时处理txt文件
             for (File file : files) {
-                if (file.getName().toLowerCase().endsWith(".txt")) {
+                if (file.getName().toLowerCase().endsWith(".txt") && !file.getName().toLowerCase().contains("_split")) {
                     //System.out.println("发现文本文件: " + file.getName());
                     String inputFilePath = file.getAbsolutePath();
                     try {

+ 131 - 10
src/main/java/com/qizhen/healsphere/WordSplitter.java

@@ -2,6 +2,8 @@ package com.qizhen.healsphere;
 
 import com.qizhen.healsphere.util.FileCommonUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.usermodel.Range;
 import org.apache.poi.xwpf.usermodel.*;
 
 import java.io.*;
@@ -13,8 +15,67 @@ import java.util.regex.Pattern;
 public class WordSplitter {
 
     private static final String ZHANG_PATTERN = "^第[零一二三四五六七八九十百千万0123456789]+章\\s+[^\\n]+";
-    public void splitWordDocument(String inputFilePath, String outputDirectory,String pattern) throws IOException {
-        System.out.println(inputFilePath+"==="+outputDirectory+"==="+pattern);
+
+    public void splitWordDocument(String inputFilePath, String outputDirectory, String pattern) throws IOException {
+        System.out.println(inputFilePath + "===" + outputDirectory + "===" + pattern);
+        if (inputFilePath.endsWith(".doc")) {
+            processDocFile(inputFilePath, outputDirectory, pattern);
+        } else if (inputFilePath.endsWith(".docx")) {
+            processDocxFile(inputFilePath, outputDirectory, pattern);
+        } else {
+            throw new IllegalArgumentException("Unsupported file format: " + inputFilePath);
+        }
+    }
+
+    private void processDocFile(String inputFilePath, String outputDirectory, String pattern) throws IOException {
+        HWPFDocument document = new HWPFDocument(new FileInputStream(inputFilePath));
+        Range range = document.getRange();
+        String text = range.text();
+
+        StringBuilder currentChapter = new StringBuilder();
+        String currentChapterTitle = null;
+        Pattern compile = Pattern.compile(pattern);
+        String[] paragraphs = text.split("\n");
+        for (String paragraph : paragraphs) {
+            Matcher matcher = compile.matcher(paragraph);
+            boolean isAppendTitle = false;
+            if (matcher.find()) {
+                String tempTitle = matcher.group();
+                // 标题一样的话,不保存
+                if (currentChapterTitle == null) {
+                    currentChapterTitle = tempTitle;
+                    isAppendTitle = true;
+                } else if (currentChapterTitle != null && !trim(currentChapterTitle).equals(trim(tempTitle))) {
+                    save(currentChapterTitle, currentChapter.toString(), outputDirectory);
+                    currentChapter.setLength(0); // Clear the StringBuilder
+                    currentChapterTitle = tempTitle;
+                    isAppendTitle = true;
+                }
+            }
+            String trimText = trim(paragraph);
+            if (StringUtils.isNotEmpty(paragraph) && (isAppendTitle || !trim(currentChapterTitle).equals(trimText))
+                    && !"本章数字资源".equals(trimText)) {
+                currentChapter.append(paragraph).append("\n");
+            }
+        }
+        if(StringUtils.isBlank(currentChapterTitle)){
+            currentChapterTitle =  getFileName(inputFilePath);
+        }
+        save(currentChapterTitle, currentChapter.toString(), outputDirectory);
+        document.close();
+    }
+
+    private static String getFileName(String inputFilePath) {
+        File inputFile = new File(inputFilePath);
+        String fileNameWithoutExtension = inputFile.getName();
+        int lastDotIndex = fileNameWithoutExtension.lastIndexOf('.');
+        if (lastDotIndex > 0) {
+            return fileNameWithoutExtension.substring(0, lastDotIndex);
+        }
+        return fileNameWithoutExtension;
+    }
+
+    private void processDocxFile(String inputFilePath, String outputDirectory, String pattern) throws IOException {
         XWPFDocument document = new XWPFDocument(new FileInputStream(inputFilePath));
         StringBuilder currentChapter = new StringBuilder();
         String currentChapterTitle = null;
@@ -43,16 +104,16 @@ public class WordSplitter {
                         && !"本章数字资源".equals(trimText)) {
                     currentChapter.append(text).append("\n");
                 }
-
-            } /*else if (element instanceof XWPFTable) {
-                // Handle tables if necessary
-                currentChapter.append(element.toString()).append("\n");
-            }*/
+            }
+        }
+        if(StringUtils.isBlank(currentChapterTitle)){
+            currentChapterTitle =  getFileName(inputFilePath);
         }
         save(currentChapterTitle, currentChapter.toString(), outputDirectory);
         document.close();
     }
 
+
     private void save(String chapterTitle, String chapterContents, String outputDirectory) throws IOException {
         if (StringUtils.isEmpty(chapterTitle)) {
             return;
@@ -78,6 +139,9 @@ public class WordSplitter {
     }
 
     private String trim(String text) {
+        if (StringUtils.isEmpty(text)) {
+            return "";
+        }
         return text.replaceAll("\\s+", "");
     }
 
@@ -114,11 +178,68 @@ public class WordSplitter {
 
     public static void main(String[] args) {
         WordSplitter wordSplitter1 = new WordSplitter();
-        String inputFilePath = "E:\\project\\vscode\\急诊与灾难医学(第4版).docx";
-        String outputDirectory = "E:\\project\\vscode\\《急诊与灾难医学(第4版)》\\";
+        String rootDirectory = "E:\\急诊科资料\\中华医学期刊数据库"; // 指定根目录
+
+        // 递归查找所有 .doc 和 .docx 文件
+        File rootDir = new File(rootDirectory);
+        if (rootDir.exists() && rootDir.isDirectory()) {
+            findAndProcessFiles(rootDir, wordSplitter1);
+        } else {
+            System.out.println("指定的根目录不存在或不是一个目录: " + rootDirectory);
+        }
+    }
+
+    private static void findAndProcessFiles(File directory, WordSplitter wordSplitter) {
+        File[] files = directory.listFiles();
+        if (files != null) {
+            for (File file : files) {
+                if (file.isDirectory()) {
+                    // 递归处理子目录
+                    findAndProcessFiles(file, wordSplitter);
+                } else if (file.isFile() && (file.getName().endsWith(".doc") || file.getName().endsWith(".docx"))) {
+                    // 处理 .doc 和 .docx 文件
+                    String inputFilePath = file.getAbsolutePath();
+                    try {
+                        // 获取文件的上一级目录
+                        File parentDir = file.getParentFile().getParentFile();
+                        if (parentDir == null) {
+                            throw new IOException("无法获取文件的上一级目录: " + inputFilePath);
+                        }
+
+                        // 在上一级目录下创建 trunk 目录
+                        File trunkDir = new File(parentDir, "trunk");
+                       /* if (trunkDir.exists()) {
+                            throw new IOException("目录已存在,无法创建: " + trunkDir.getAbsolutePath());
+                        }*/
+
+                        // 创建 trunk 目录
+                        trunkDir.mkdirs();
+                    /*    boolean isCreated = trunkDir.mkdirs();
+                        if (!isCreated) {
+                            throw new IOException("目录创建失败: " + trunkDir.getAbsolutePath());
+                        }*/
+
+                        // 设置 outputDirectory 为 trunk 目录
+                        String outputDirectory = trunkDir.getAbsolutePath() + File.separator;
+
+                        // 调用 splitWordDocument 方法处理文件
+                        wordSplitter.splitWordDocument(inputFilePath, outputDirectory, ZHANG_PATTERN);
+                    } catch (IOException e) {
+                        System.err.println("处理文件时发生错误: " + inputFilePath);
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+    }
+
+    public static void main1(String[] args) {
+        WordSplitter wordSplitter1 = new WordSplitter();
+        String inputFilePath = "E:\\project\\vscode\\急诊医学(第2版)\\09. 急诊医学(第2版)_701-718.docx";
+        String outputDirectory = "E:\\project\\vscode\\《急诊医学(第2版)》\\";
         try {
             //removeHeadersAndFooters(inputFilePath, outputFilePath);
-            wordSplitter1.splitWordDocument(inputFilePath, outputDirectory,ZHANG_PATTERN);
+            wordSplitter1.splitWordDocument(inputFilePath, outputDirectory, ZHANG_PATTERN);
         } catch (IOException e) {
             e.printStackTrace();
         }

Fichier diff supprimé car celui-ci est trop grand
+ 43 - 80
src/main/java/com/qizhen/healsphere/common/ai/DeepSeekUtil.java


+ 111 - 0
src/main/java/com/qizhen/healsphere/common/ai/QizhenAssistant.java

@@ -140,4 +140,115 @@ public class QizhenAssistant {
         return resposne;
     }
 
+    public static void main(String[] args) {
+        JSONObject json = new JSONObject();
+        json.put("text", "{\n" +
+                "  \"hospitalId\": -1,\n" +
+                "  \"age\": \"28\",\n" +
+                "  \"sex\": 2,\n" +
+                "  \"doctor\": {\n" +
+                "    \"professionalTitle\": \"付医生\"\n" +
+                "  },\n" +
+                "  \"chief\": \"上腹痛绞痛2小时\",\n" +
+                "  \"symptom\": \"2小时前无诱因下出现持续性上腹部绞痛,剧痛难忍,伴恶心慢性,无呕吐,无大小便异常,曾至当地卫生院就诊,查血常规提示:血小板计数5*10^9/L\",\n" +
+                "  \"vital\": \"神清,急性病容,皮肤巩膜黄软,心肺无殊,腹平软,上腹部压痛明显,无反跳痛\",\n" +
+                "  \"pasts\": \"既往有胆总管结石,既往青霉素过敏\",\n" +
+                "  \"marriage\": \"\",\n" +
+                "  \"personal\": \"不饮酒,不抽烟\",\n" +
+                "  \"family\": \"不详\",\n" +
+                "  \"marital\": \"未婚未育\",\n" +
+                "  \"menstrual\": \"末次月经2020-12-23,月经期第二天\",\n" +
+                "  \"diseaseName\": {\n" +
+                "    \"dateValue\": \"\",\n" +
+                "    \"name\": \"胆囊结石伴有急性胆囊炎\",\n" +
+                "    \"uniqueName\": \"\"\n" +
+                "  },\n" +
+                "  \"otherIndex\": {},\n" +
+                "  \"operationName\": {\n" +
+                "    \"dateValue\": \"2020-12-24 17:39:20\",\n" +
+                "    \"name\": \"经皮肝穿刺引流术\",\n" +
+                "    \"uniqueName\": \"经皮肝穿刺引流术\"\n" +
+                "  },\n" +
+                "  \"infectious\": \"\",\n" +
+                "  \"operation\": [],\n" +
+                "  \"allergy\": \"\",\n" +
+                "  \"vaccination\": \"\",\n" +
+                "  \"other\": \"\",\n" +
+                "  \"lisString\": \"\",\n" +
+                "  \"pacsString\": \"\",\n" +
+                "  \"diagString\": \"\",\n" +
+                "  \"drugString\": \"\",\n" +
+                "  \"lis\": [],\n" +
+                "  \"pacs\": [],\n" +
+                "  \"diag\": [\n" +
+                "    {\n" +
+                "      \"dateValue\": \"\",\n" +
+                "      \"name\": \"胆囊结石伴有急性胆囊炎\",\n" +
+                "      \"uniqueName\": \"\"\n" +
+                "    }\n" +
+                "  ],\n" +
+                "  \"lisOrder\": [],\n" +
+                "  \"pacsOrder\": [\n" +
+                "    {\n" +
+                "      \"uniqueName\": \"经皮肝穿刺胆管造影\",\n" +
+                "      \"detailName\": \"经皮肝穿刺胆管造影\",\n" +
+                "      \"name\": \"经皮肝穿刺胆管造影\",\n" +
+                "      \"dateValue\": \"2020-12-24 17:33:52\",\n" +
+                "      \"time\": \"2020-12-24 17:33:52\",\n" +
+                "      \"check\": true\n" +
+                "    }\n" +
+                "  ],\n" +
+                "  \"diagOrder\": [],\n" +
+                "  \"drugOrder\": [\n" +
+                "    {\n" +
+                "      \"uniqueName\": \"利多卡因\",\n" +
+                "      \"detailName\": \"利多卡因\",\n" +
+                "      \"name\": \"利多卡因注射剂\",\n" +
+                "      \"flg\": 5,\n" +
+                "      \"time\": \"2020-12-24 17:37:27\",\n" +
+                "      \"dateValue\": \"2020-12-24 17:37:27\",\n" +
+                "      \"selectShow\": false,\n" +
+                "      \"check\": true,\n" +
+                "      \"form\": \"注射剂\",\n" +
+                "      \"selectVal\": \"1\"\n" +
+                "    },\n" +
+                "    {\n" +
+                "      \"uniqueName\": \"青霉素\",\n" +
+                "      \"detailName\": \"青霉素\",\n" +
+                "      \"name\": \"青霉素注射剂\",\n" +
+                "      \"flg\": 5,\n" +
+                "      \"time\": \"2020-12-24 17:40:08\",\n" +
+                "      \"dateValue\": \"2020-12-24 17:40:08\",\n" +
+                "      \"selectShow\": false,\n" +
+                "      \"check\": true,\n" +
+                "      \"form\": \"注射剂\",\n" +
+                "      \"selectVal\": \"1\"\n" +
+                "    }\n" +
+                "  ],\n" +
+                "  \"operationOrder\": [\n" +
+                "    {\n" +
+                "      \"uniqueName\": \"经皮肝穿刺引流术\",\n" +
+                "      \"detailName\": \"经皮肝穿刺引流术\",\n" +
+                "      \"name\": \"经皮肝穿刺引流术\",\n" +
+                "      \"flg\": 6,\n" +
+                "      \"time\": \"2020-12-24 17:39:20\",\n" +
+                "      \"dateValue\": \"2020-12-24 17:39:20\",\n" +
+                "      \"hasTreat\": 1,\n" +
+                "      \"check\": true\n" +
+                "    }\n" +
+                "  ],\n" +
+                "  \"otherOrder\": [],\n" +
+                "  \"drug\": [],\n" +
+                "  \"transfusion\": [],\n" +
+                "  \"transfusionOrder\": [],\n" +
+                "  \"dept\": [\n" +
+                "    {\n" +
+                "      \"name\": \"全科\",\n" +
+                "      \"uniqueName\": \"全科\"\n" +
+                "    }\n" +
+                "  ]\n" +
+                "}");
+        json.put("need_convert", false);
+        System.out.println(JSON.toJSONString(json));
+    }
 }

+ 102 - 0
src/main/java/com/qizhen/healsphere/util/ObjectToMapConverter.java

@@ -0,0 +1,102 @@
+package com.qizhen.healsphere.util;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import java.lang.reflect.Field;
+import java.util.*;
+
+public class ObjectToMapConverter {
+
+    /**
+     * 将对象转换为Map<String, List<Object>>格式
+     * @param obj 需要转换的对象
+     * @return 转换后的Map
+     */
+    public static JSONArray convertToMap(Object obj) {
+        JSONArray jsonArray = new JSONArray();
+        if (obj == null) {
+            return jsonArray;
+        }
+
+        Class<?> clazz = obj.getClass();
+        for (Field field : clazz.getDeclaredFields()) {
+            field.setAccessible(true);
+            try {
+                Object value = field.get(obj);
+                List<Object> valueList = new ArrayList<>();
+                if (value != null) {
+                    if (value instanceof Map) {
+                        // 处理 Map 类型的字段
+                        Map<?, ?> mapValue = (Map<?, ?>) value;
+                        for (Map.Entry<?, ?> entry : mapValue.entrySet()) {
+                            JSONObject mapEntry = new JSONObject();
+                            mapEntry.put("key", entry.getKey());
+                            mapEntry.put("value", Arrays.asList(entry.getValue()));
+                            valueList.add(mapEntry);
+                        }
+                    } else if (value instanceof Collection) {
+                        // 处理 Collection 类型的字段
+                        valueList.addAll((Collection<?>) value);
+                    } else {
+                        // 处理普通字段
+                        valueList.add(value);
+                    }
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("key", field.getName());
+                    jsonObject.put("value", valueList);
+                    jsonArray.add(jsonObject);
+                }
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        return jsonArray;
+    }
+
+    public static void main(String[] args) {
+        // 示例对象
+        ExampleObject exampleObject = new ExampleObject();
+        exampleObject.setName("Test");
+        exampleObject.setHobbies(Arrays.asList("Reading", "Swimming"));
+        Map<String, Object> properties = new HashMap<>();
+        properties.put("描述", "英俊潇洒");
+        exampleObject.setProperties(properties);
+        System.out.println(JSON.toJSONString(exampleObject));
+        // 转换为Map
+        System.out.println(JSON.toJSONString(convertToMap(exampleObject)));
+    }
+}
+
+class ExampleObject {
+    private String name;
+    private List<String> hobbies;
+
+    public Map<String, Object> getProperties() {
+        return properties;
+    }
+
+    public void setProperties(Map<String, Object> properties) {
+        this.properties = properties;
+    }
+
+    private Map<String, Object> properties;
+
+    // Getters and Setters
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<String> getHobbies() {
+        return hobbies;
+    }
+
+    public void setHobbies(List<String> hobbies) {
+        this.hobbies = hobbies;
+    }
+}

+ 55 - 0
src/main/java/com/qizhen/healsphere/web/NKgController.java

@@ -0,0 +1,55 @@
+package com.qizhen.healsphere.web;
+
+import com.qizhen.healsphere.facade.KgFacade;
+import com.qizhen.healsphere.web.dto.NNodeDTO;
+import com.qizhen.healsphere.web.dto.NNodeDetailDTO;
+import com.qizhen.healsphere.web.dto.NRelationshipDTO;
+import com.qizhen.healsphere.web.dto.RespDTO;
+import com.qizhen.healsphere.web.param.NKgQuery;
+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.cache.CacheManager;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * @Description: 朗通知识图谱控制层
+ * @author: gaodm
+ * @time: 2018/8/30 10:12
+ */
+@Controller
+@RequestMapping("/v1")
+@Api(value = "朗通知识图谱API", tags = { "朗通知识图谱API" })
+@SuppressWarnings("unchecked")
+@Slf4j
+public class NKgController {
+    private static final String KGTREECACHE = "KgTreeCache";
+
+    @Autowired
+    private KgFacade kgFacade;
+
+    @Autowired
+    private CacheManager cacheManager;
+
+    @ApiOperation(value = "获取实体", notes = "获取实体")
+    @RequestMapping(value = "/node/query", method = RequestMethod.POST)
+    @ResponseBody
+    public RespDTO<List<NNodeDTO>> query(@RequestBody @Valid NKgQuery kgQuery) {
+
+        return RespDTO.onSuc(null);
+    }
+
+
+    private NNodeDTO node;
+    private List<NRelationshipDTO> relationships;
+
+}
+

+ 22 - 0
src/main/java/com/qizhen/healsphere/web/dto/NNodeDTO.java

@@ -0,0 +1,22 @@
+package com.qizhen.healsphere.web.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/3/16 10:11
+ */
+@Getter
+@Setter
+public class NNodeDTO {
+
+    private String category;
+    private String name;
+    private Map<String, Object> properties;
+    private String id;
+
+}

+ 13 - 0
src/main/java/com/qizhen/healsphere/web/dto/NNodeDetailDTO.java

@@ -0,0 +1,13 @@
+package com.qizhen.healsphere.web.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+@Getter
+@Setter
+public class NNodeDetailDTO extends NResponseDTO{
+    private NNodeDTO node;
+    private List<NRelationshipDTO> relationships;
+}

+ 15 - 0
src/main/java/com/qizhen/healsphere/web/dto/NRelationshipDTO.java

@@ -0,0 +1,15 @@
+package com.qizhen.healsphere.web.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+@Getter
+@Setter
+public class NRelationshipDTO {
+    private NNodeDTO targetNode;
+    private String name;
+    private Map<String, Object> properties;
+
+}

+ 14 - 0
src/main/java/com/qizhen/healsphere/web/dto/NResponseDTO.java

@@ -0,0 +1,14 @@
+package com.qizhen.healsphere.web.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+@Getter
+@Setter
+public class NResponseDTO {
+
+    private String requestId;
+
+}

+ 18 - 0
src/main/java/com/qizhen/healsphere/web/param/NKgQuery.java

@@ -0,0 +1,18 @@
+package com.qizhen.healsphere.web.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+
+@Getter
+@Setter
+public class NKgQuery {
+    @ApiModelProperty(value = "实体类型")
+    private String nodeLabel;
+    @ApiModelProperty(value = "实体名称")
+    @NotBlank(message = "实体名称不能为空")
+    private String nodeName;
+
+}

+ 17 - 9
src/test/java/com/qizhen/healsphere/SnomedCTFromExcelTest.java

@@ -19,10 +19,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 
 import java.io.FileInputStream;
 import java.io.InputStream;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * 是否空腹及归大类
@@ -46,24 +43,33 @@ public class SnomedCTFromExcelTest {
         InputStream fis = new FileInputStream(urlExcelPath);
         Workbook urlWorkbook = WorkbookFactory.create(fis);
         Sheet urlSheet = urlWorkbook.getSheetAt(index);
-
+        List<RelationshipVO> batch = new ArrayList<>();
         for (int rowNum = 0; rowNum <= urlSheet.getLastRowNum(); rowNum++) {
             try {
                 Row row = urlSheet.getRow(rowNum);
-                saveNeo4j(row.getCell(0).getStringCellValue().trim(), row.getCell(1).getStringCellValue().trim(), row.getCell(2).getStringCellValue().trim(), row.getCell(3).getStringCellValue().trim(), row.getCell(4).getStringCellValue().trim());
+                RelationshipVO relationshipVO = saveNeo4j(row.getCell(0).getStringCellValue().trim(), row.getCell(1).getStringCellValue().trim(), row.getCell(2).getStringCellValue().trim(), row.getCell(3).getStringCellValue().trim(), row.getCell(4).getStringCellValue().trim());
+                batch.add(relationshipVO);
+                if (batch.size() >= 100) {
+                    relationshipService.createRelationship(batch);
+                    batch.clear();
+                }
+
             } catch (Exception e) {
             }
         }
     }
 
-    private void saveNeo4j(String startName, String startLabel, String relationShip, String endName, String endLabel) throws Exception {
+    private RelationshipVO saveNeo4j(String startName, String startLabel, String relationShip, String endName, String endLabel) throws Exception {
         try {
             if(StringUtils.isEmpty(startName) || StringUtils.isEmpty(startLabel)|| StringUtils.isEmpty(relationShip)|| StringUtils.isEmpty(endName) || StringUtils.isEmpty(endLabel)){
-                return;
+                return null;
             }
+            long currentTimeMillis = System.currentTimeMillis();
             BaseEntity startEntity = createNoExists(startLabel, startName);
+            System.out.println(System.currentTimeMillis()-currentTimeMillis);
             long startId = startEntity.getId();
             BaseEntity endEntity = createNoExists(endLabel, endName);
+            System.out.println(System.currentTimeMillis()-currentTimeMillis);
             Long endId = endEntity.getId();
             RelationshipVO relationshipVO = new RelationshipVO();
             relationshipVO.setStartId(startId);
@@ -71,10 +77,12 @@ public class SnomedCTFromExcelTest {
             relationshipVO.setStartLabel(startLabel);
             relationshipVO.setEndLabel(endLabel);
             relationshipVO.setRelationshipType(relationShip);
-            System.out.println(relationshipService.createRelationship(Arrays.asList(relationshipVO)));
+            return relationshipVO;
+
         } catch (Exception e) {
             e.printStackTrace();
         }
+        return null;
     }
 
     private BaseEntity createNoExists(String labelName, String name) {