|
@@ -0,0 +1,849 @@
|
|
|
+package org.diagbot.nlp.test;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.diagbot.pub.jdbc.MysqlJdbc;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName org.diagbot.nlp.test.ConceptTest
|
|
|
+ * @Description TODO
|
|
|
+ * @Author fyeman
|
|
|
+ * @Date 2019/6/6/006 10:18
|
|
|
+ * @Version 1.0
|
|
|
+ **/
|
|
|
+public class ConceptTest {
|
|
|
+ private static final String EXCEL_XLS = "xls";
|
|
|
+ private static final String EXCEL_XLSX = "xlsx";
|
|
|
+
|
|
|
+ private static final String lis_path = "E:\\git\\docs\\医学知识库\\化验\\化验标准库第一期-邵启华0614.xlsx";
|
|
|
+ private static final String pacs_path = "E:\\git\\docs\\医学知识库\\辅检\\辅检标准库第一期-邵青华0612.xlsx";
|
|
|
+ private static final String symptom_path = "E:\\git\\docs\\医学知识库\\症状\\症状标准库-王玲0613.xlsx";
|
|
|
+ private static final String drug_path = "E:\\git\\docs\\医学知识库\\药品\\药品标准库-邵启华0515.xlsx";
|
|
|
+ private static final String vital_path = "E:\\git\\docs\\医学知识库\\体征\\体征标准库第一阶段-吕纯0614.xlsx";
|
|
|
+ private static final String part_path = "E:\\git\\docs\\医学知识库\\部位和科室\\部位标准库-最新结构0613.xlsx";
|
|
|
+ private static final String disease_path = "E:\\git\\docs\\医学知识库\\诊断名和治疗方案\\知识库标准疾病名称和疾病治疗方案-邵青华0605.xlsx";
|
|
|
+ private static final String dept_path = "E:\\git\\docs\\医学知识库\\部位和科室\\科室标准库-邵启华0521.xlsx";
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ try {
|
|
|
+// insertSymptom();
|
|
|
+// insertPart();
|
|
|
+// insertVital();
|
|
|
+// insertLis();
|
|
|
+// insertPacs();
|
|
|
+// insertDisease();
|
|
|
+// insertDept();
|
|
|
+
|
|
|
+// insertStandardInfo();
|
|
|
+// validateSplit();
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void validateSplit() {
|
|
|
+ MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-med-0606?useUnicode=true&characterEncoding=UTF-8");
|
|
|
+ List<Map<String, String>> data = nlpJdbc.query("library_info", new String[]{"id", "name"}, "");
|
|
|
+
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+ for (Map<String, String> map : data) {
|
|
|
+ all_words.put(map.get("name"), map.get("name"));
|
|
|
+ }
|
|
|
+
|
|
|
+ nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-rule?useUnicode=true&characterEncoding=UTF-8");
|
|
|
+ data = nlpJdbc.query("medicine_rule_split", new String[]{"id", "split_word"}, "");
|
|
|
+ String[] names = null;
|
|
|
+ List<String> notin_words = new ArrayList<>();
|
|
|
+ for (Map<String, String> map : data) {
|
|
|
+ names = map.get("split_word").split(",");
|
|
|
+ for (int i = 0; i < names.length; i++) {
|
|
|
+ if (all_words.get(names[i]) == null) {
|
|
|
+ notin_words.add(names[i]);
|
|
|
+ all_words.put(names[i], names[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> notin_words_list = new ArrayList<>();
|
|
|
+ for (String word : notin_words) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ line.put("name", word);
|
|
|
+ notin_words_list.add(line);
|
|
|
+ }
|
|
|
+ nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-med-0606?useUnicode=true&characterEncoding=UTF-8");
|
|
|
+ nlpJdbc.insert(notin_words_list, "kl_standard_notin", new String[]{"name"});
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertDept() throws Exception {
|
|
|
+ File excelFile = new File(dept_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell0 = row.getCell(0);
|
|
|
+ if (cell0 != null && StringUtils.isNotEmpty(cell0.getStringCellValue())) {
|
|
|
+ concept_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ Cell cell1 = row.getCell(1);
|
|
|
+ if (cell1 != null && !"".equals(cell1.getStringCellValue())) {
|
|
|
+ all_words.put(cell1.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "47");
|
|
|
+ line.put("type", "科室");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertSymptom() throws Exception {
|
|
|
+ File excelFile = new File(symptom_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(1);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell0 = row.getCell(0);
|
|
|
+ if (cell0 != null && !"".equals(cell0.getStringCellValue())) {
|
|
|
+ put(concept_words, cell0);
|
|
|
+ all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ Cell cell1 = row.getCell(1);
|
|
|
+ if (cell1 != null && !"".equals(cell1.getStringCellValue())) {
|
|
|
+ all_words.put(cell1.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "1");
|
|
|
+ line.put("type", "症状");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertPart() throws Exception {
|
|
|
+ File excelFile = new File(part_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell0 = row.getCell(1);
|
|
|
+ if (cell0 != null && !"".equals(cell0.getStringCellValue())) {
|
|
|
+ concept_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ Cell cell1 = row.getCell(0);
|
|
|
+ if (cell1 != null && !"".equals(cell1.getStringCellValue())) {
|
|
|
+ all_words.put(cell1.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "3");
|
|
|
+ line.put("type", "部位");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertVital() throws Exception {
|
|
|
+ insertVitalIndex();
|
|
|
+ insertVitalValue();
|
|
|
+ insertVitalResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertLis() throws Exception {
|
|
|
+ insertLisMeal();
|
|
|
+ insertLisDetail();
|
|
|
+ insertLisPublic();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertLisMeal() throws Exception {
|
|
|
+ File excelFile = new File(lis_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+
|
|
|
+ String[] self = null;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell0 = row.getCell(0);
|
|
|
+ Cell cell1 = row.getCell(1);
|
|
|
+ if (cell0 != null && !"".equals(cell0.getStringCellValue())) {
|
|
|
+ put(concept_words, cell0);
|
|
|
+ all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ if (cell1 != null && StringUtils.isNotEmpty(cell1.getStringCellValue())) {
|
|
|
+ self = cell1.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ all_words.put(self[i], cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "12");
|
|
|
+ line.put("type", "化验套餐");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertLisDetail() throws Exception {
|
|
|
+ File excelFile = new File(lis_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+
|
|
|
+ String[] self = null;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell2 = row.getCell(2);
|
|
|
+ Cell cell3 = row.getCell(3);
|
|
|
+ if (cell2 != null && StringUtils.isNotEmpty(cell2.getStringCellValue())) {
|
|
|
+ put(concept_words, cell2);
|
|
|
+ all_words.put(cell2.getStringCellValue(), cell2.getStringCellValue());
|
|
|
+ }
|
|
|
+ if (cell3 != null && StringUtils.isNotEmpty(cell3.getStringCellValue())) {
|
|
|
+ self = cell3.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ all_words.put(self[i], cell2.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "13");
|
|
|
+ line.put("type", "化验明细");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertLisPublic() throws Exception {
|
|
|
+ File excelFile = new File(lis_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+
|
|
|
+ String[] self = null;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell4 = row.getCell(4);
|
|
|
+ if (cell4 != null && StringUtils.isNotEmpty(cell4.getStringCellValue())) {
|
|
|
+ concept_words.put(cell4.getStringCellValue(), cell4.getStringCellValue());
|
|
|
+ all_words.put(cell4.getStringCellValue(), cell4.getStringCellValue());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "46");
|
|
|
+ line.put("type", "化验公表项");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertPacs() throws Exception {
|
|
|
+ File excelFile = new File(pacs_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+
|
|
|
+ String[] self = null;
|
|
|
+ Cell cell = null;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell0 = row.getCell(0);
|
|
|
+ Cell cell1 = row.getCell(1);
|
|
|
+ Cell cell2 = row.getCell(2);
|
|
|
+ Cell cell3 = row.getCell(3);
|
|
|
+ Cell cell4 = row.getCell(4);
|
|
|
+ if (cell0 != null && StringUtils.isNotEmpty(cell0.getStringCellValue())) {
|
|
|
+ cell = cell0;
|
|
|
+ }
|
|
|
+ if (cell1 != null && StringUtils.isNotEmpty(cell1.getStringCellValue())) {
|
|
|
+ cell = cell1;
|
|
|
+ }
|
|
|
+ if (cell2 != null && StringUtils.isNotEmpty(cell2.getStringCellValue())) {
|
|
|
+ cell = cell2;
|
|
|
+ }
|
|
|
+ if (cell3 != null && StringUtils.isNotEmpty(cell3.getStringCellValue())) {
|
|
|
+ cell = cell3;
|
|
|
+ }
|
|
|
+ if (cell != null) {
|
|
|
+ put(concept_words, cell);
|
|
|
+ all_words.put(cell.getStringCellValue(), cell.getStringCellValue());
|
|
|
+ }
|
|
|
+ if (cell4 != null && StringUtils.isNotEmpty(cell4.getStringCellValue()) && cell != null) {
|
|
|
+ self = cell4.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ all_words.put(self[i], cell.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ cell = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "16");
|
|
|
+ line.put("type", "辅检项目");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertDisease() throws Exception {
|
|
|
+ File excelFile = new File(disease_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+
|
|
|
+ String[] self = null;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell0 = row.getCell(0);
|
|
|
+ Cell cell1 = row.getCell(1);
|
|
|
+ if (cell0 != null && StringUtils.isNotEmpty(cell0.getStringCellValue())) {
|
|
|
+ concept_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ if (cell1 != null && StringUtils.isNotEmpty(cell1.getStringCellValue()) && cell0 != null) {
|
|
|
+ self = cell1.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ all_words.put(self[i], cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "18");
|
|
|
+ line.put("type", "疾病");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertDrug() throws Exception {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertVitalIndex() throws Exception {
|
|
|
+ File excelFile = new File(vital_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+
|
|
|
+ String[] self = null;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell1 = row.getCell(1);
|
|
|
+ Cell cell3 = row.getCell(3);
|
|
|
+
|
|
|
+ String concept_word = "";
|
|
|
+ if (cell1 != null && !"".equals(cell1.getStringCellValue())) {
|
|
|
+ self = cell1.getStringCellValue().split("、");
|
|
|
+ concept_word = self[0];
|
|
|
+ if (concept_words.get(self[0]) == null) {
|
|
|
+ put(concept_words, self[0], null, null);
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ if (all_words.get(self[i]) == null) {
|
|
|
+ all_words.put(self[i], self[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ if (all_words.get(self[i]) == null) {
|
|
|
+ all_words.put(self[i], self[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cell3 != null && StringUtils.isNotEmpty(cell3.getStringCellValue())) {
|
|
|
+ self = cell3.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ if (all_words.get(self[i]) == null) {
|
|
|
+ all_words.put(self[i], concept_word);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "33");
|
|
|
+ line.put("type", "体征指标");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertVitalValue() throws Exception {
|
|
|
+ File excelFile = new File(vital_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+
|
|
|
+ String[] self = null;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell2 = row.getCell(2);
|
|
|
+ if (cell2 != null && !"".equals(cell2.getStringCellValue())) {
|
|
|
+ self = cell2.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ put(concept_words, self[i], null, null);
|
|
|
+ all_words.put(self[i], self[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "34");
|
|
|
+ line.put("type", "体征指标值");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertVitalResult() throws Exception {
|
|
|
+ File excelFile = new File(vital_path); // 创建文件对象
|
|
|
+ FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
+ Workbook workbook = getWorkbok(in, excelFile);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+
|
|
|
+ int count = 0;
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+
|
|
|
+ String[] self = null;
|
|
|
+ String[] suffix = null;
|
|
|
+ String[] prefix = null;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ // 跳过第一和第二行的目录
|
|
|
+ if (count < 1) {
|
|
|
+ count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ Cell cell0 = row.getCell(0);
|
|
|
+ Cell cell3 = row.getCell(3);
|
|
|
+ Cell cell4 = row.getCell(4);
|
|
|
+ Cell cell5 = row.getCell(5);
|
|
|
+ Cell cell6 = row.getCell(6);
|
|
|
+ if (cell0 != null && StringUtils.isNotEmpty(cell0.getStringCellValue())) {
|
|
|
+ put(concept_words, cell0);
|
|
|
+ all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ if (cell3 != null && StringUtils.isNotEmpty(cell3.getStringCellValue())) {
|
|
|
+ self = cell3.getStringCellValue().split("、");
|
|
|
+ if (cell4 != null && StringUtils.isNotEmpty(cell4.getStringCellValue())) {
|
|
|
+ suffix = cell4.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ for (int j = 0; j < suffix.length; j++) {
|
|
|
+ all_words.put(self[i] + suffix[j], cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (cell5 != null && StringUtils.isNotEmpty(cell5.getStringCellValue())) {
|
|
|
+ prefix = cell5.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ for (int j = 0; j < prefix.length; j++) {
|
|
|
+ all_words.put(prefix[j] + self[i], cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (cell6 != null && StringUtils.isNotEmpty(cell6.getStringCellValue())) {
|
|
|
+ self = cell6.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < self.length; i++) {
|
|
|
+ all_words.put(self[i], cell0.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("第" + count + "出现错误!");
|
|
|
+ }
|
|
|
+ prefix = null;
|
|
|
+ suffix = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, String> entry : all_words.entrySet()) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(entry.getKey())) {
|
|
|
+ line.put("name", entry.getKey());
|
|
|
+ line.put("type_id", "35");
|
|
|
+ line.put("type", "体征结果");
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertStandardInfo() throws Exception {
|
|
|
+ MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-med-0606?useUnicode=true&characterEncoding=UTF-8");
|
|
|
+ List<Map<String, String>> data = nlpJdbc.query("kl_standard_info_0318", new String[]{"id", "name", "category_id", "category"}, " where category_id not in (1, 3, 13,14,15, 17,18,19,60,61,62, 10)");
|
|
|
+
|
|
|
+ Map<String, String> concept_words = new HashMap<>();
|
|
|
+ Map<String, String> all_words = new HashMap<>();
|
|
|
+ List<Map<String, Object>> all_words_list = new ArrayList<>();
|
|
|
+ for (Map<String, String> map : data) {
|
|
|
+ String name = map.get("name");
|
|
|
+ concept_words.put(name, name);
|
|
|
+ all_words.put(name, name);
|
|
|
+
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ line.put("name", map.get("name"));
|
|
|
+ line.put("type_id", map.get("category_id"));
|
|
|
+ line.put("type", map.get("category"));
|
|
|
+ all_words_list.add(line);
|
|
|
+ }
|
|
|
+
|
|
|
+ insertLibraryInfo(all_words_list, all_words, concept_words);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void insertLibraryInfo(List<Map<String, Object>> list, Map<String, String> all_words, Map<String, String> concept_words) {
|
|
|
+ String updateDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (Map<String, Object> line : list) {
|
|
|
+ line.put("order_no", "0");
|
|
|
+ line.put("is_concept", "0");
|
|
|
+ initInsertLine(line, updateDate);
|
|
|
+ }
|
|
|
+ MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/med-s?useUnicode=true&characterEncoding=UTF-8");
|
|
|
+ int[] infoIds = nlpJdbc.insertBatch(list, "kl_library_info", new String[]{"name", "type_id", "is_concept", "creator", "modifier", "gmt_create", "gmt_modified", "is_deleted"});
|
|
|
+
|
|
|
+ List<Map<String, Object>> concept_words_list = new ArrayList<>();
|
|
|
+ String concept_word = "";
|
|
|
+ for (int i = 0; i < infoIds.length; i++) {
|
|
|
+ concept_word = list.get(i).get("name").toString();
|
|
|
+ if (concept_words.get(concept_word) != null) {
|
|
|
+ Map<String, Object> concept_line = new HashMap<>();
|
|
|
+ concept_line.put("lib_id", infoIds[i]);
|
|
|
+ concept_line.put("lib_name", concept_word);
|
|
|
+ concept_line.put("lib_type", list.get(i).get("type_id"));
|
|
|
+ initInsertLine(concept_line, updateDate);
|
|
|
+ concept_words_list.add(concept_line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int[] conceptIds = nlpJdbc.insertBatch(concept_words_list, "kl_concept", new String[]{"lib_id", "lib_name", "lib_type", "creator", "modifier", "gmt_create", "gmt_modified", "is_deleted"});
|
|
|
+ Map<String, String> concept_word_ids = new HashMap<>();
|
|
|
+ for (int i = 0; i < conceptIds.length; i++) {
|
|
|
+ concept_word_ids.put(concept_words_list.get(i).get("lib_name").toString(), String.valueOf(conceptIds[i]));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> updates = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> wheres = new ArrayList<>();
|
|
|
+
|
|
|
+ for (int i = 0; i < infoIds.length; i++) {
|
|
|
+ Map<String, Object> line = new HashMap<>();
|
|
|
+ Map<String, Object> where = new HashMap<>();
|
|
|
+if (concept_word_ids.get(all_words.get(list.get(i).get("name").toString())) == null) {
|
|
|
+ System.out.println(list.get(i).get("name").toString());
|
|
|
+ System.out.println(all_words.get(list.get(i).get("name").toString()));
|
|
|
+}
|
|
|
+ line.put("concept_id", concept_word_ids.get(all_words.get(list.get(i).get("name").toString())));
|
|
|
+ concept_word = list.get(i).get("name").toString();
|
|
|
+ if (concept_words.get(concept_word) != null) {
|
|
|
+ line.put("is_concept", "1");
|
|
|
+ } else {
|
|
|
+ line.put("is_concept", "0");
|
|
|
+ }
|
|
|
+ updates.add(line);
|
|
|
+ where.put("id", infoIds[i]);
|
|
|
+ wheres.add(where);
|
|
|
+ }
|
|
|
+ nlpJdbc.update("kl_library_info", updates, wheres);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void initInsertLine(Map<String, Object> line, String updateDate) {
|
|
|
+ line.put("is_deleted", "N");
|
|
|
+ line.put("creator", "楼辉荣");
|
|
|
+ line.put("modifier", "楼辉荣");
|
|
|
+ line.put("gmt_create", updateDate);
|
|
|
+ line.put("gmt_modified", updateDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Workbook getWorkbok(InputStream in, File file) throws IOException {
|
|
|
+ Workbook wb = null;
|
|
|
+ if (file.getName().endsWith(EXCEL_XLS)) { //Excel 2003
|
|
|
+ wb = new HSSFWorkbook(in);
|
|
|
+ } else if (file.getName().endsWith(EXCEL_XLSX)) { // Excel 2007/2010
|
|
|
+ wb = new XSSFWorkbook(in);
|
|
|
+ }
|
|
|
+ return wb;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String, String> put(Map<String, String> words, String word, String[] prefix, String[] suffix) {
|
|
|
+ if (words.get(word) == null) {
|
|
|
+ words.put(word, word);
|
|
|
+ }
|
|
|
+ if (prefix != null) {
|
|
|
+ for (int i = 0; i < prefix.length; i++) {
|
|
|
+ if (words.get(prefix[i] + word) == null) {
|
|
|
+ words.put(prefix[i] + word, prefix[i] + word);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (suffix != null) {
|
|
|
+ for (int i = 0; i < suffix.length; i++) {
|
|
|
+ if (words.get(word + suffix[i]) == null) {
|
|
|
+ words.put(word + suffix[i], word + suffix[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (prefix != null && suffix != null) {
|
|
|
+ for (int i = 0; i < prefix.length; i++) {
|
|
|
+ for (int j = 0; j < suffix.length; j++) {
|
|
|
+ if (words.get(prefix[i] + word + suffix[j]) == null) {
|
|
|
+ words.put(prefix[i] + word + suffix[j], prefix[i] + word + suffix[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return words;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String, String> put(Map<String, String> words, Cell cell) {
|
|
|
+ return put(words, cell, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String, String> put(Map<String, String> words, Cell cell, String suffix) {
|
|
|
+ if (cell == null) {
|
|
|
+ return words;
|
|
|
+ }
|
|
|
+ String[] key = cell.getStringCellValue().split("、");
|
|
|
+ for (int i = 0; i < key.length; i++) {
|
|
|
+ if (words.get(key[i]) == null) {
|
|
|
+ if (suffix == null) {
|
|
|
+ words.put(key[i], key[i]);
|
|
|
+ } else {
|
|
|
+ words.put(key[i] + suffix, key[i] + suffix);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return words;
|
|
|
+ }
|
|
|
+}
|