zhoutg пре 5 година
родитељ
комит
f0baa368ee

+ 7 - 2
pom.xml

@@ -29,6 +29,7 @@
         <mybatis-plus-boot-starter.version>3.2.0</mybatis-plus-boot-starter.version>
         <mybatis-spring-boot.version>2.1.1</mybatis-spring-boot.version>
         <druid.version>1.1.21</druid.version>
+        <easypoi.version>4.2.0</easypoi.version>
         <swagger.version>2.9.2</swagger.version>
         <logstash.version>5.2</logstash.version>
         <docker-maven-plugin.version>1.2.1</docker-maven-plugin.version>
@@ -114,8 +115,12 @@
             <artifactId>springfox-swagger-ui</artifactId>
             <version>${swagger.version}</version>
         </dependency>
-
-
+        <!-- easypoi -->
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-spring-boot-starter</artifactId>
+            <version>${easypoi.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>

+ 21 - 0
src/main/java/com/diagbot/client/StandConvertServiceClient.java

@@ -0,0 +1,21 @@
+package com.diagbot.client;
+
+import com.diagbot.dto.StandConvertCrfDTO;
+import com.diagbot.vo.StandConvertCrfVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+
+/**
+ * @description: 标准词转换
+ * @author: zhoutg
+ * @date: 2020/8/12 10:41
+ */
+@FeignClient(value = "StandConvert-service", url="${StandConvert.url}")
+public interface StandConvertServiceClient {
+
+    @PostMapping(value = "/api/similarity")
+    StandConvertCrfDTO similarity(StandConvertCrfVO standConvertCrfVO);
+}
+
+
+

+ 18 - 0
src/main/java/com/diagbot/client/hystrix/StandConvertServiceHystrix.java

@@ -0,0 +1,18 @@
+package com.diagbot.client.hystrix;
+
+import com.diagbot.client.StandConvertServiceClient;
+import com.diagbot.dto.StandConvertCrfDTO;
+import com.diagbot.vo.StandConvertCrfVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class StandConvertServiceHystrix implements StandConvertServiceClient {
+
+    @Override
+    public StandConvertCrfDTO similarity(StandConvertCrfVO standConvertCrfVO) {
+        log.error("【hystrix】调用{}异常", "similarity");
+        return null;
+    }
+}

+ 30 - 0
src/main/java/com/diagbot/dto/StandConvertCrfDTO.java

@@ -0,0 +1,30 @@
+package com.diagbot.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @description: 标准词转换类出参
+ * @author: zhoutg
+ * @date: 2020/8/12 10:48
+ */
+@Data
+public class StandConvertCrfDTO {
+    // 成功返回true, 否则返回false
+    private Boolean status;
+    // 标准词列表,有顺序,第一个是最大可能性的
+    private List<String> standard_words;
+    /**
+     * 错误码(error_code)列表:
+     *     1000 ---> 正常
+     *     1001 ---> 输入错误,word_type或word为空
+     *     1002 ---> 没有这个模型, word_type出错
+     *     1003 ---> 模型预测出错
+     *     1004 ---> 模型其他错误
+     *     1005 ---> 其他错误
+     *     1006 ---> 字符串(即word)不符合所规定的格式【错误格式:没有中文字符,数字或者非前括号符号开头,空字符串,
+     *         不是字符串, 长度超过40字符】
+     */
+    private Integer error_code;
+}

+ 4 - 0
src/main/java/com/diagbot/facade/IndicationFacade.java

@@ -1,5 +1,6 @@
 package com.diagbot.facade;
 
+import com.diagbot.client.StandConvertServiceClient;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
@@ -26,6 +27,8 @@ public class IndicationFacade {
     CommonFacade commonFacade;
     @Autowired
     BillFacade billFacade;
+    @Autowired
+    StandConvertServiceClient standConvertServiceClient;
 
     /**
      * 病情提示总入口
@@ -43,6 +46,7 @@ public class IndicationFacade {
         // 标准词转换
         long l2 = System.currentTimeMillis();
         StandConvert standConvert = commonFacade.dataTypeGet(wordCrfDTO);
+        // neoFacade.standConvertCrf(standConvert);
         Map<String, Map<String, String>> standConvertMap = neoFacade.standConvert(standConvert);
         commonFacade.dataTypeSet(wordCrfDTO, standConvertMap);
         CoreUtil.getDubugStr(l2, "同义词转换", res.getDubugStr());

+ 54 - 4
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -2,24 +2,46 @@ package com.diagbot.facade;
 
 import com.alibaba.fastjson.JSONArray;
 import com.diagbot.client.ChiefPresentSimilarityServiceClient;
+import com.diagbot.client.StandConvertServiceClient;
 import com.diagbot.dto.BillNeoDTO;
 import com.diagbot.dto.DrugBillNeoDTO;
 import com.diagbot.dto.LisBillNeoDTO;
 import com.diagbot.dto.PacsBillNeoDTO;
 import com.diagbot.dto.PushDTO;
-import com.diagbot.entity.node.*;
+import com.diagbot.dto.StandConvertCrfDTO;
+import com.diagbot.entity.node.Disease;
+import com.diagbot.entity.node.LIS;
+import com.diagbot.entity.node.Medicine;
+import com.diagbot.entity.node.Medicine_Code;
+import com.diagbot.entity.node.OralMedicine;
+import com.diagbot.entity.node.PACS;
 import com.diagbot.enums.StandConvertEnum;
 import com.diagbot.model.ai.ModelAI;
-import com.diagbot.repository.*;
+import com.diagbot.repository.DiseaseNode;
+import com.diagbot.repository.DiseaseRepository;
+import com.diagbot.repository.LISNode;
+import com.diagbot.repository.LisRepository;
+import com.diagbot.repository.MedicineCodeRepository;
+import com.diagbot.repository.MedicineNode;
+import com.diagbot.repository.MedicineRepository;
+import com.diagbot.repository.PACSNode;
+import com.diagbot.repository.PacsRepository;
 import com.diagbot.util.ListUtil;
 import com.diagbot.vo.BillNeoVO;
 import com.diagbot.vo.PushNeoVO;
 import com.diagbot.vo.StandConvert;
+import com.diagbot.vo.StandConvertCrfVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Component;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 图谱facade
@@ -43,6 +65,8 @@ public class NeoFacade {
     ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
     @Autowired
     NeoFacade self;
+    @Autowired
+    StandConvertServiceClient standConvertServiceClient;
 
     /**
      * 返回药品缓存信息
@@ -79,7 +103,6 @@ public class NeoFacade {
         return res;
     }
 
-
     /**
      * 返回文本相似度匹配需要的词性列表
      *
@@ -334,4 +357,31 @@ public class NeoFacade {
         }
     }
 
+
+    /**
+     * 标准词转换
+     *
+     * @param standConvert
+     *
+     * @return  Map<String, Map<String, String>> -->Map<类型, Map<原始词, 标准词>>
+     */
+    public Map<String, Map<String, String>> standConvertCrf(StandConvert standConvert) {
+        Map<String, Map<String, String>> map = new LinkedHashMap<>();
+
+        Map<String, String> clinicalMap = new LinkedHashMap<>();
+        List<String> clinicalList = standConvert.getClinicalList();
+        for (String s : clinicalList) {
+            StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
+            standConvertCrfVO.setWord_type("symptom");
+            standConvertCrfVO.setWord(s);
+            StandConvertCrfDTO standConvertCrfDTO = standConvertServiceClient.similarity(standConvertCrfVO);
+            System.out.println(standConvertCrfDTO);
+            clinicalMap.put(s, standConvertCrfDTO.getStandard_words().get(0));
+        }
+        map.put(StandConvertEnum.clinical.getName(), clinicalMap);
+
+
+        return map;
+    }
+
 }

+ 178 - 0
src/main/java/com/diagbot/util/ExcelUtils.java

@@ -0,0 +1,178 @@
+// package com.diagbot.util;
+//
+//
+// import cn.afterturn.easypoi.excel.ExcelExportUtil;
+// import cn.afterturn.easypoi.excel.ExcelImportUtil;
+// import cn.afterturn.easypoi.excel.entity.ExportParams;
+// import cn.afterturn.easypoi.excel.entity.ImportParams;
+// import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+// import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
+// import com.diagbot.exception.CommonErrorCode;
+// import com.diagbot.exception.CommonException;
+// import org.apache.commons.lang3.StringUtils;
+// import org.apache.poi.ss.usermodel.Row;
+// import org.apache.poi.ss.usermodel.Sheet;
+// import org.apache.poi.ss.usermodel.Workbook;
+// import org.springframework.web.multipart.MultipartFile;
+//
+// import javax.servlet.http.HttpServletResponse;
+// import java.io.File;
+// import java.io.IOException;
+// import java.net.URLEncoder;
+// import java.util.Collection;
+// import java.util.List;
+// import java.util.Map;
+// import java.util.NoSuchElementException;
+//
+// /**
+//  * @Description: excel 导入导出工具类
+//  * @author: gaodm
+//  * @time: 2020/6/2 19:18
+//  */
+// public class ExcelUtils {
+//     public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
+//                                    boolean isCreateHeader, HttpServletResponse response) {
+//         ExportParams exportParams = new ExportParams(title, sheetName);
+//         exportParams.setCreateHeadRows(isCreateHeader);
+//         defaultExport(list, pojoClass, fileName, response, exportParams);
+//     }
+//
+//     public static void exportExcelDynamicCol(List<ExcelExportEntity> entityList, Collection<?> dataSet, String title, String sheetName, String fileName,
+//                                     HttpServletResponse response) {
+//         ExportParams exportParams = new ExportParams(title, sheetName);
+//         dynamicColExport(entityList, dataSet, fileName, response, exportParams);
+//     }
+//
+//     public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
+//                                    HttpServletResponse response, float height) {
+//         Boolean havTitle = false;
+//         if (StringUtil.isNotBlank(title)) {
+//             havTitle = true;
+//         }
+//         userExport2(list, pojoClass, fileName, response, new ExportParams(title, sheetName), height, havTitle);
+//     }
+//
+//     public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
+//                                    HttpServletResponse response) {
+//         defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName));
+//     }
+//
+//     public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
+//         defaultExport(list, fileName, response);
+//     }
+//
+//     private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response,
+//                                       ExportParams exportParams) {
+//         Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
+//         if (workbook != null) {
+//             ;
+//         }
+//         downLoadExcel(fileName, response, workbook);
+//     }
+//
+//     private static void dynamicColExport(List<ExcelExportEntity> entityList, Collection<?> dataSet, String fileName, HttpServletResponse response,
+//                                          ExportParams exportParams) {
+//         Workbook workbook = ExcelExportUtil.exportExcel(exportParams,entityList,dataSet);
+//         if (workbook != null) {
+//             ;
+//         }
+//         downLoadExcel(fileName, response, workbook);
+//     }
+//
+//     private static void userExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response,
+//                                    ExportParams exportParams) {
+//         Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
+//         if (workbook != null) {
+//             Sheet sheet = workbook.getSheetAt(0);
+//             //列宽设置
+//             sheet.setColumnWidth(8, 256 * 20);
+//             sheet.setColumnWidth(9, 256 * 50);
+//             int rowNum = sheet.getLastRowNum();
+//             Row row = sheet.getRow(0);
+//             for (int i = 1; i <= rowNum; i++) {
+//                 row = sheet.getRow(i);
+//                 row.setHeightInPoints(12.8f);
+//             }
+//         }
+//         downLoadExcel(fileName, response, workbook);
+//     }
+//
+//     private static void userExport2(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response,
+//                                     ExportParams exportParams, float height, Boolean havTitle) {
+//         Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
+//         if (workbook != null) {
+//             Sheet sheet = workbook.getSheetAt(0);
+//             int rowNum = sheet.getLastRowNum();
+//             Row row = sheet.getRow(0);
+//             int startRowNum = 1;
+//             if (havTitle) {
+//                 startRowNum = 2;
+//             }
+//             for (int i = startRowNum; i <= rowNum; i++) {
+//                 row = sheet.getRow(i);
+//                 row.setHeightInPoints(height);
+//             }
+//         }
+//         downLoadExcel(fileName, response, workbook);
+//     }
+//
+//     private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
+//         try {
+//             response.setCharacterEncoding("UTF-8");
+//             response.setHeader("content-Type", "application/vnd.ms-excel");
+//             response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
+//             workbook.write(response.getOutputStream());
+//         } catch (IOException e) {
+//             // throw new NormalException(e.getMessage());
+//             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "导出Excel异常");
+//         }
+//     }
+//
+//     private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
+//         Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF);
+//         if (workbook != null) {
+//             ;
+//         }
+//         downLoadExcel(fileName, response, workbook);
+//     }
+//
+//     public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
+//         if (StringUtils.isBlank(filePath)) {
+//             return null;
+//         }
+//         ImportParams params = new ImportParams();
+//         params.setTitleRows(titleRows);
+//         params.setHeadRows(headerRows);
+//         List<T> list = null;
+//         try {
+//             list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
+//         } catch (NoSuchElementException e) {
+//             // throw new NormalException("模板不能为空");
+//         } catch (Exception e) {
+//             e.printStackTrace();
+//             // throw new NormalException(e.getMessage());
+//         }
+//         return list;
+//     }
+//
+//     public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows,
+//                                           Class<T> pojoClass) {
+//         if (file == null) {
+//             return null;
+//         }
+//         ImportParams params = new ImportParams();
+//         params.setTitleRows(titleRows);
+//         params.setHeadRows(headerRows);
+//         List<T> list = null;
+//         try {
+//             list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
+//         } catch (NoSuchElementException e) {
+//             // throw new NormalException("excel文件不能为空");
+//         } catch (Exception e) {
+//             // throw new NormalException(e.getMessage());
+//             System.out.println(e.getMessage());
+//         }
+//         return list;
+//     }
+//
+// }

+ 18 - 0
src/main/java/com/diagbot/vo/StandConvertCrfVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Data;
+
+/**
+ * @description: 标准词转换类
+ * @author: zhoutg
+ * @date: 2020/8/12 10:48
+ */
+@Data
+public class StandConvertCrfVO {
+    // 类型,疾病: disease,症状: symptom,手术和操作:operation,药品: drug,实验室检查:lis,辅助检查:pacs, 辅助检查:vital
+    private String word_type;
+    // 原始词
+    private String word;
+    // 最多返回个数
+    private Integer number = 1;
+}

+ 3 - 0
src/main/resources/application-dev.yml

@@ -150,3 +150,6 @@ CRF:
 
 ChiefPresentSimilarity:
   url: http://192.168.2.234:3456
+
+StandConvert:
+  url: http://192.168.2.123:23232

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

@@ -149,4 +149,7 @@ CRF:
   url: http://192.168.2.234:3456
 
 ChiefPresentSimilarity:
-  url: http://192.168.2.234:3456
+  url: http://192.168.2.234:3456
+
+StandConvert:
+  url: http://192.168.2.123:23232

+ 4 - 1
src/main/resources/application-pre.yml

@@ -149,4 +149,7 @@ CRF:
   url: http://192.168.2.234:3456
 
 ChiefPresentSimilarity:
-  url: http://192.168.2.234:3456
+  url: http://192.168.2.234:3456
+
+StandConvert:
+  url: http://192.168.2.123:23232

+ 3 - 0
src/main/resources/application-pro.yml

@@ -152,3 +152,6 @@ CRF:
 
 ChiefPresentSimilarity:
   url: http://192.168.2.234:3456
+
+StandConvert:
+  url: http://192.168.2.123:23232

+ 4 - 1
src/main/resources/application-test.yml

@@ -149,4 +149,7 @@ CRF:
   url: http://192.168.2.234:3456
 
 ChiefPresentSimilarity:
-  url: http://192.168.2.234:3456
+  url: http://192.168.2.234:3456
+
+StandConvert:
+  url: http://192.168.2.123:23232