|
@@ -1,31 +1,34 @@
|
|
package com.diagbot.facade;
|
|
package com.diagbot.facade;
|
|
|
|
|
|
|
|
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.diagbot.api.ImportExcel;
|
|
import com.diagbot.dto.ConceptDTO;
|
|
import com.diagbot.dto.ConceptDTO;
|
|
-import com.diagbot.entity.Concept;
|
|
|
|
-import com.diagbot.entity.LibraryInfo;
|
|
|
|
-import com.diagbot.entity.Medical;
|
|
|
|
-import com.diagbot.dto.RelationDTO;
|
|
|
|
-import com.diagbot.exception.CommonErrorCode;
|
|
|
|
-import com.diagbot.exception.CommonException;
|
|
|
|
|
|
+import com.diagbot.entity.*;
|
|
|
|
+//import com.diagbot.dto.RelationDTO;
|
|
|
|
+//import com.diagbot.exception.CommonErrorCode;
|
|
|
|
+//import com.diagbot.exception.CommonException;
|
|
import com.diagbot.service.impl.ConceptServiceImpl;
|
|
import com.diagbot.service.impl.ConceptServiceImpl;
|
|
import com.diagbot.vo.AmendTermVo;
|
|
import com.diagbot.vo.AmendTermVo;
|
|
-import com.diagbot.vo.MedicalVo;
|
|
|
|
|
|
+//import com.diagbot.vo.MedicalVo;
|
|
import com.diagbot.vo.TermVo;
|
|
import com.diagbot.vo.TermVo;
|
|
-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.apache.poi.ss.usermodel.Row;
|
|
|
|
+//import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
+//import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
+//import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
+//import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
+//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+//import java.io.IOException;
|
|
|
|
+//import java.io.InputStream;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+//import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+//import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -54,12 +57,15 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
*/
|
|
*/
|
|
public ConceptDTO getConceptInfo(@RequestBody TermVo termvo) {
|
|
public ConceptDTO getConceptInfo(@RequestBody TermVo termvo) {
|
|
|
|
|
|
|
|
+ LibraryInfo libraryInfo;
|
|
ConceptDTO conceptDTO = getConcept(termvo);
|
|
ConceptDTO conceptDTO = getConcept(termvo);
|
|
// 获取与医学术语的基本信息
|
|
// 获取与医学术语的基本信息
|
|
if (conceptDTO != null) {
|
|
if (conceptDTO != null) {
|
|
- termvo.setId(conceptDTO.getLibId());
|
|
|
|
- termvo.setConcept_id(conceptDTO.getId());
|
|
|
|
- LibraryInfo libraryInfo = libraryinfoFacade.getLibraryInfor(termvo);
|
|
|
|
|
|
+
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ params.put("id", conceptDTO.getLibId());
|
|
|
|
+ params.put("concept_id", conceptDTO.getId());
|
|
|
|
+ libraryInfo = libraryinfoFacade.getLibraryInfor(params);
|
|
|
|
|
|
if (libraryInfo.getIsConcept() != null && libraryInfo.getIsConcept() == 1) {
|
|
if (libraryInfo.getIsConcept() != null && libraryInfo.getIsConcept() == 1) {
|
|
conceptDTO.setName(libraryInfo.getName());
|
|
conceptDTO.setName(libraryInfo.getName());
|
|
@@ -67,11 +73,14 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
conceptDTO.setLibraryInfo(libraryInfo);
|
|
conceptDTO.setLibraryInfo(libraryInfo);
|
|
|
|
|
|
// 获取与术语相关的医学知识
|
|
// 获取与术语相关的医学知识
|
|
- conceptDTO.setInformation(libraryDetailFacade.getLibraryDetails(termvo));
|
|
|
|
|
|
+ params = new HashMap<>();
|
|
|
|
+ params.put("concept_id", conceptDTO.getId());
|
|
|
|
+ conceptDTO.setInformation(libraryDetailFacade.getLibraryDetails(params));
|
|
// 获取与术语相关的临床医学信息
|
|
// 获取与术语相关的临床医学信息
|
|
- MedicalVo medicalVo = new MedicalVo();
|
|
|
|
- medicalVo.setName(termvo.getTerm());
|
|
|
|
- conceptDTO.setMedicalInfo(medicalFacade.getMedicalInfo(medicalVo));
|
|
|
|
|
|
+ params = new HashMap<>();
|
|
|
|
+ params.put("name", termvo.getTerm());
|
|
|
|
+ params.put("concept_id", conceptDTO.getId());
|
|
|
|
+ conceptDTO.setMedicalInfo(medicalFacade.getMedicalInfo(params));
|
|
// 获取术语的所有上级信息
|
|
// 获取术语的所有上级信息
|
|
conceptDTO.setRelations(relationFacade.getAllRelation(termvo));
|
|
conceptDTO.setRelations(relationFacade.getAllRelation(termvo));
|
|
}
|
|
}
|
|
@@ -90,6 +99,7 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
|
|
|
|
TermVo termVo = new TermVo();
|
|
TermVo termVo = new TermVo();
|
|
termVo.setTerm(amendTermVo.getConcept());
|
|
termVo.setTerm(amendTermVo.getConcept());
|
|
|
|
+ termVo.setType(amendTermVo.getType());
|
|
|
|
|
|
// 如果概念术语不存在,添加新术语,然后添加新的概念
|
|
// 如果概念术语不存在,添加新术语,然后添加新的概念
|
|
conceptDTO = getConcept(termVo);
|
|
conceptDTO = getConcept(termVo);
|
|
@@ -98,13 +108,21 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
amendconcept.setOldterm(amendTermVo.getOldterm());
|
|
amendconcept.setOldterm(amendTermVo.getOldterm());
|
|
amendconcept.setNewterm(amendTermVo.getConcept());
|
|
amendconcept.setNewterm(amendTermVo.getConcept());
|
|
amendconcept.setConcept("");
|
|
amendconcept.setConcept("");
|
|
|
|
+ amendconcept.setType(amendTermVo.getType());
|
|
libraryinfoFacade.upsertLibraryInfo(amendconcept);
|
|
libraryinfoFacade.upsertLibraryInfo(amendconcept);
|
|
|
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ params.put("name", amendTermVo.getConcept());
|
|
|
|
+ params.put("type", amendTermVo.getType());
|
|
|
|
+ int libid = libraryinfoFacade.getLibraryInfor(params).getId().intValue();
|
|
|
|
+
|
|
|
|
+
|
|
Concept concept = new Concept();
|
|
Concept concept = new Concept();
|
|
- int libid = libraryinfoFacade.getLibraryInfor(termVo).getId().intValue();
|
|
|
|
concept.setLibId(libid);
|
|
concept.setLibId(libid);
|
|
|
|
+ concept.setGmtCreated(LocalDateTime.now());
|
|
this.saveOrUpdate(concept);
|
|
this.saveOrUpdate(concept);
|
|
|
|
|
|
|
|
+ termVo.setType(amendTermVo.getType());
|
|
conceptDTO = getConcept(termVo);
|
|
conceptDTO = getConcept(termVo);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -138,204 +156,21 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
return conceptDTO;
|
|
return conceptDTO;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 从文件批量导入术语信息
|
|
|
|
|
|
+ * 获取概念Id
|
|
*
|
|
*
|
|
- * @param file
|
|
|
|
- * @return ConceptDTO
|
|
|
|
|
|
+ * @param term
|
|
|
|
+ * @return Integer
|
|
*/
|
|
*/
|
|
- public ConceptDTO importBatch(MultipartFile file) {
|
|
|
|
- ConceptDTO conceptDTO = new ConceptDTO();
|
|
|
|
- List<String> messages = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- InputStream inputStream = null;
|
|
|
|
- Workbook wb = null;
|
|
|
|
-
|
|
|
|
- AmendTermVo amendTermVo;
|
|
|
|
- Medical medical;
|
|
|
|
- List<Medical> medlist;
|
|
|
|
- RelationDTO relationDTO;
|
|
|
|
- List<RelationDTO> rellist;
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- if (!file.isEmpty()) {
|
|
|
|
- inputStream = file.getInputStream();
|
|
|
|
-
|
|
|
|
- if (inputStream.available() > 1024000) {
|
|
|
|
- messages.add("术语文件最大支持1MB!");
|
|
|
|
- } else {
|
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
|
- if (fileName.lastIndexOf(".") != -1) {
|
|
|
|
- String type = fileName.substring(fileName.lastIndexOf("."));
|
|
|
|
- if (type.equals(".xls")) {
|
|
|
|
- wb = new HSSFWorkbook(inputStream);
|
|
|
|
- } else if (type.equals(".xlsx")) {
|
|
|
|
- wb = new XSSFWorkbook(inputStream);
|
|
|
|
- }
|
|
|
|
- if (wb != null) {
|
|
|
|
- Sheet sheet = wb.getSheetAt(0);
|
|
|
|
- int count = 0;
|
|
|
|
- String group, category, std_name, name, code, prop;
|
|
|
|
- String grp_type = "";
|
|
|
|
- String cate_type = "";
|
|
|
|
- String std_type = "";
|
|
|
|
- for (Row row : sheet) {
|
|
|
|
- count++;
|
|
|
|
-
|
|
|
|
- if (row != null) {
|
|
|
|
- if (count == 1) {
|
|
|
|
- grp_type = row.getCell(0).toString();
|
|
|
|
- if (medicalFacade.getTypeInfo(grp_type) == null) {
|
|
|
|
- System.out.println("术语类型-'" + grp_type + "'不存在!");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- cate_type = row.getCell(1).toString();
|
|
|
|
- if (medicalFacade.getTypeInfo(cate_type) == null) {
|
|
|
|
- System.out.println("术语类型-'" + cate_type + "'不存在!");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- std_type = row.getCell(2).toString().replace("标准名称", "");
|
|
|
|
- if (medicalFacade.getTypeInfo(std_type) == null) {
|
|
|
|
- System.out.println("术语类型-'" + std_type + "'不存在!");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (count > 1) {
|
|
|
|
-
|
|
|
|
- group = (row.getCell(0) == null) ? "" : row.getCell(0).toString();
|
|
|
|
- category = (row.getCell(1) == null) ? "" : row.getCell(1).toString();
|
|
|
|
- std_name = (row.getCell(2) == null) ? "" : row.getCell(2).toString();
|
|
|
|
- name = (row.getCell(3) == null) ? "" : row.getCell(3).toString();
|
|
|
|
- code = category + "\"-\"" + std_name;
|
|
|
|
- prop = (row.getCell(5) == null) ? "" : row.getCell(5).toString();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- System.out.println(group + "\t" + category + "\t" + std_name + "\t" +
|
|
|
|
- name + "\t" + code + "\t" + prop);
|
|
|
|
-
|
|
|
|
- // 设置实体
|
|
|
|
- amendTermVo = new AmendTermVo();
|
|
|
|
- amendTermVo.setConcept(std_name);
|
|
|
|
- amendTermVo.setNewterm(name);
|
|
|
|
- amendTermVo.setOldterm("");
|
|
|
|
-
|
|
|
|
- medical = new Medical();
|
|
|
|
- medical.setName(name);
|
|
|
|
- medical.setType(std_type);
|
|
|
|
- medical.setStdName(std_name);
|
|
|
|
- medical.setCateName(category);
|
|
|
|
- medical.setCode(code);
|
|
|
|
- medical.setNote(prop);
|
|
|
|
- medlist = new ArrayList<>();
|
|
|
|
- medlist.add(medical);
|
|
|
|
- amendTermVo.setMedicalInfo(medlist);
|
|
|
|
-
|
|
|
|
- this.upsertConceptInfo(amendTermVo);
|
|
|
|
- System.out.println(name + ":\t 已入库.");
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (category.length() > 0) {
|
|
|
|
- // 设置套餐
|
|
|
|
- amendTermVo = new AmendTermVo();
|
|
|
|
- amendTermVo.setConcept(category);
|
|
|
|
- amendTermVo.setNewterm(category);
|
|
|
|
- amendTermVo.setOldterm("");
|
|
|
|
-
|
|
|
|
- medical = new Medical();
|
|
|
|
- medical.setName(category);
|
|
|
|
- medical.setType(cate_type);
|
|
|
|
- medical.setStdName(category);
|
|
|
|
- medical.setCateName(group);
|
|
|
|
- medical.setCode("");
|
|
|
|
- medical.setNote("");
|
|
|
|
- medlist = new ArrayList<>();
|
|
|
|
- medlist.add(medical);
|
|
|
|
- amendTermVo.setMedicalInfo(medlist);
|
|
|
|
-
|
|
|
|
- relationDTO = new RelationDTO();
|
|
|
|
- relationDTO.setStartId(getConceptId(std_name));
|
|
|
|
- relationDTO.setStartName(std_name);
|
|
|
|
- relationDTO.setRelationId(1);
|
|
|
|
- relationDTO.setEndId(getConceptId(category));
|
|
|
|
- relationDTO.setEndName(category);
|
|
|
|
- rellist = new ArrayList<>();
|
|
|
|
- rellist.add(relationDTO);
|
|
|
|
- amendTermVo.setRelations(rellist);
|
|
|
|
-
|
|
|
|
- this.upsertConceptInfo(amendTermVo);
|
|
|
|
-
|
|
|
|
- System.out.println(category + ":\t 已入库.");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (group.length() > 0) {
|
|
|
|
- // 设置大类
|
|
|
|
- amendTermVo = new AmendTermVo();
|
|
|
|
- amendTermVo.setConcept(group);
|
|
|
|
- amendTermVo.setNewterm(group);
|
|
|
|
- amendTermVo.setOldterm("");
|
|
|
|
-
|
|
|
|
- medical = new Medical();
|
|
|
|
- medical.setName(group);
|
|
|
|
- medical.setType(grp_type);
|
|
|
|
- medical.setStdName(group);
|
|
|
|
- medical.setCateName("");
|
|
|
|
- medical.setCode("");
|
|
|
|
- medical.setNote("");
|
|
|
|
- medlist = new ArrayList<>();
|
|
|
|
- medlist.add(medical);
|
|
|
|
- amendTermVo.setMedicalInfo(medlist);
|
|
|
|
-
|
|
|
|
- this.upsertConceptInfo(amendTermVo);
|
|
|
|
- System.out.println(group + ":\t 已入库.");
|
|
|
|
- }
|
|
|
|
- // if (count >= 1)
|
|
|
|
- // break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- System.out.println(count + " 条记录添加入库.");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- messages.add("非excel文件无法解析!");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- messages.add("未知文件无法解析!");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- messages.add("无文件上传!");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- catch (IOException ioe) {
|
|
|
|
- ioe.printStackTrace();
|
|
|
|
- }
|
|
|
|
- catch (Exception ex) {
|
|
|
|
- ex.printStackTrace();
|
|
|
|
- }
|
|
|
|
- finally {
|
|
|
|
- try {
|
|
|
|
-
|
|
|
|
- if (inputStream != null) {
|
|
|
|
- inputStream.close();
|
|
|
|
- }
|
|
|
|
- if (wb != null) {
|
|
|
|
- wb.close();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return conceptDTO;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public int getConceptId(String term) {
|
|
|
|
|
|
+ public int getConceptId(String term, String type) {
|
|
int id = 0;
|
|
int id = 0;
|
|
TermVo termVo = new TermVo();
|
|
TermVo termVo = new TermVo();
|
|
|
|
|
|
try {
|
|
try {
|
|
termVo.setTerm(term);
|
|
termVo.setTerm(term);
|
|
|
|
+ termVo.setType(type);
|
|
ConceptDTO conceptDTO = getConcept(termVo);
|
|
ConceptDTO conceptDTO = getConcept(termVo);
|
|
if (conceptDTO != null) {
|
|
if (conceptDTO != null) {
|
|
id = conceptDTO.getId();
|
|
id = conceptDTO.getId();
|
|
@@ -349,4 +184,23 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 从文件批量导入术语信息
|
|
|
|
+ *
|
|
|
|
+ * @param file
|
|
|
|
+ * @return ConceptDTO
|
|
|
|
+ */
|
|
|
|
+ public ConceptDTO importBatch(MultipartFile file) {
|
|
|
|
+ ImportExcel.setConceptFacade(this);
|
|
|
|
+ ImportExcel.setLibraryinfoFacade(libraryinfoFacade);
|
|
|
|
+ ImportExcel.setLibraryDetailFacade(libraryDetailFacade);
|
|
|
|
+ ImportExcel.setMedicalFacade(medicalFacade);
|
|
|
|
+ ImportExcel.setRelationFacade(relationFacade);
|
|
|
|
+
|
|
|
|
+ ConceptDTO conceptDTO = ImportExcel.importBatch(file);
|
|
|
|
+
|
|
|
|
+ return conceptDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|