|
@@ -1,385 +1,390 @@
|
|
|
-package com.diagbot.facade;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.diagbot.dto.DiagnoseImportDTO;
|
|
|
-import com.diagbot.dto.DiagnosticAllExportDTO;
|
|
|
-import com.diagbot.dto.DiagnosticBasisExportDTO;
|
|
|
-import com.diagbot.dto.EquationDTO;
|
|
|
-import com.diagbot.dto.FeatureDTO;
|
|
|
-import com.diagbot.dto.RespDTO;
|
|
|
-import com.diagbot.entity.Diagnose;
|
|
|
-import com.diagbot.entity.DiagnoseDetail;
|
|
|
-import com.diagbot.entity.DiagnoseQuestion;
|
|
|
-import com.diagbot.enums.DiagnoseFeatureTypeEnum;
|
|
|
-import com.diagbot.enums.DiagnoseTypeEnum;
|
|
|
-import com.diagbot.enums.HasQuestionEnum;
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
-import com.diagbot.enums.TermEnum;
|
|
|
-import com.diagbot.exception.CommonErrorCode;
|
|
|
-import com.diagbot.exception.CommonException;
|
|
|
-import com.diagbot.service.DiagnoseDetailService;
|
|
|
-import com.diagbot.service.DiagnoseQuestionService;
|
|
|
-import com.diagbot.service.DiagnoseService;
|
|
|
-import com.diagbot.util.ExportBeanExcelUtil;
|
|
|
-import com.diagbot.util.GsonUtil;
|
|
|
-import com.diagbot.util.IntegerUtil;
|
|
|
-import com.diagbot.util.StringUtil;
|
|
|
-import com.diagbot.vo.DiagnosticAllExportVO;
|
|
|
-import com.diagbot.vo.DiagnosticBasisExportVO;
|
|
|
-import org.apache.commons.lang.time.DateFormatUtils;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
-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.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.text.DecimalFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author wangfeng
|
|
|
- * @Description: TODO
|
|
|
- * @date 2019年8月8日 下午1:30:53
|
|
|
- */
|
|
|
-@Component
|
|
|
-public class DiagnoseImportFacade {
|
|
|
-
|
|
|
- private static final Map<String, Integer> typeMap = new HashMap<String, Integer>() {
|
|
|
- {
|
|
|
- put(String.valueOf(DiagnoseFeatureTypeEnum.Dis.getKey()), 0);
|
|
|
- put(String.valueOf(DiagnoseFeatureTypeEnum.Symptom.getKey()), 1);
|
|
|
- put(String.valueOf(DiagnoseFeatureTypeEnum.Vital.getKey()), 2);
|
|
|
- put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_2", 3);
|
|
|
- put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_3", 4);
|
|
|
- put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_4", 5);
|
|
|
- put(DiagnoseFeatureTypeEnum.Pacs.getKey() + "_2", 6);
|
|
|
- put(DiagnoseFeatureTypeEnum.Pacs.getKey() + "_3", 7);
|
|
|
- put(String.valueOf(DiagnoseFeatureTypeEnum.Antidiastole.getKey()), 8);
|
|
|
- put(String.valueOf(DiagnoseFeatureTypeEnum.History.getKey()), 8);
|
|
|
- put(String.valueOf(DiagnoseFeatureTypeEnum.Cause.getKey()), 9);
|
|
|
- put(String.valueOf(DiagnoseFeatureTypeEnum.CourseOfDisease.getKey()), 10);
|
|
|
- put(String.valueOf(DiagnoseFeatureTypeEnum.Other.getKey()), 10);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- @Autowired
|
|
|
- DiagnoseQuestionService diagnoseQuestionService;
|
|
|
- @Autowired
|
|
|
- @Qualifier("diagnoseDetailServiceImpl")
|
|
|
- DiagnoseDetailService diagnoseDetailService;
|
|
|
- @Autowired
|
|
|
- @Qualifier("diagnoseServiceImpl")
|
|
|
- DiagnoseService diagnoseService;
|
|
|
-
|
|
|
- @SuppressWarnings("null")
|
|
|
- public RespDTO<DiagnoseImportDTO> importDiagnosticBasisAll(MultipartFile file, HttpServletRequest request) {
|
|
|
-
|
|
|
- List<String> messages = new ArrayList<>();
|
|
|
- InputStream inputStream = null;
|
|
|
- DiagnoseImportDTO diagnoseImportDTO = new DiagnoseImportDTO();
|
|
|
- List<FeatureDTO> featureList = new ArrayList<FeatureDTO>();
|
|
|
- List<EquationDTO> equationList = new ArrayList<EquationDTO>();
|
|
|
- List<String> assemblys = new ArrayList<String>();
|
|
|
- Workbook wb = null;
|
|
|
- try {
|
|
|
- if (!file.isEmpty()) {
|
|
|
- inputStream = file.getInputStream();
|
|
|
- if (inputStream.available() > 512000) {
|
|
|
- messages.add("化验文件最大支持500KB!");
|
|
|
- } 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);
|
|
|
- diagnoseImportDTO.setDisName(sheet.getSheetName());
|
|
|
- int count = 0;
|
|
|
- String name, code, standardWord, associatedWord, consequence;
|
|
|
- for (Row row : sheet) {
|
|
|
- count++;
|
|
|
- try {
|
|
|
- if (row != null) {
|
|
|
- name = getValue(row.getCell(0)).trim().replace(" ", "");
|
|
|
- code = getValue(row.getCell(1)).trim().replace(" ", "");
|
|
|
- standardWord = getValue(row.getCell(2)).trim();
|
|
|
- associatedWord = getValue(row.getCell(3)).trim();
|
|
|
- consequence = getValue(row.getCell(4)).trim();
|
|
|
-
|
|
|
- } else {
|
|
|
- name = null;
|
|
|
- code = null;
|
|
|
- standardWord = null;
|
|
|
- associatedWord = null;
|
|
|
- consequence = null;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (count == 1 && name.equals("类型")) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtil.isEmpty(name)) {
|
|
|
- messages.add("第" + count + "行数据不规范,类型必填;");
|
|
|
- continue;
|
|
|
- }
|
|
|
- FeatureDTO feature = new FeatureDTO();
|
|
|
- EquationDTO equation = new EquationDTO();
|
|
|
- if (code.equals("")) {
|
|
|
- equation.setType(name);
|
|
|
- equation.setAssociated(associatedWord);
|
|
|
- equationList.add(equation);
|
|
|
- } else {
|
|
|
- feature.setType(name);
|
|
|
- feature.setCode(code);
|
|
|
- feature.setResult(consequence);
|
|
|
- feature.setAssociated(associatedWord);
|
|
|
- feature.setStandard(standardWord);
|
|
|
- featureList.add(feature);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, e.toString());
|
|
|
- // logger.error("",e);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- // throw new
|
|
|
- // CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
- // "非excel文件无法解析!");
|
|
|
- messages.add("非excel文件无法解析!");
|
|
|
- }
|
|
|
- } else {
|
|
|
- // throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
- // "未知文件无法解析!");
|
|
|
- messages.add("未知文件无法解析!");
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- // throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
- // "无文件上传!");
|
|
|
- messages.add("无文件上传!");
|
|
|
- }
|
|
|
-
|
|
|
- diagnoseImportDTO.setEquation(equationList);
|
|
|
- diagnoseImportDTO.setFeature(featureList);
|
|
|
- diagnoseImportDTO.setMessages(messages);
|
|
|
- return RespDTO.onSuc(diagnoseImportDTO);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "化验excel文件解析出错!");
|
|
|
- // return response.failure("化验excel文件解析出错!");
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- if (inputStream != null) {
|
|
|
- inputStream.close();
|
|
|
- }
|
|
|
- if (wb != null) {
|
|
|
- wb.close();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private String getValue(Cell cell) {
|
|
|
- try {
|
|
|
- Object obj = null;
|
|
|
- switch (cell.getCellTypeEnum()) {
|
|
|
- case BOOLEAN:
|
|
|
- obj = cell.getBooleanCellValue();
|
|
|
- break;
|
|
|
- case ERROR:
|
|
|
- obj = cell.getErrorCellValue();
|
|
|
- break;
|
|
|
- case NUMERIC:
|
|
|
- if (HSSFDateUtil.isCellDateFormatted(cell)) {
|
|
|
- Date date = cell.getDateCellValue();
|
|
|
- obj = DateFormatUtils.format(date, "yyyy-MM-dd");
|
|
|
- } else {
|
|
|
- obj = cell.getNumericCellValue();
|
|
|
- DecimalFormat df = new DecimalFormat();
|
|
|
- obj = df.format(obj);
|
|
|
- }
|
|
|
-
|
|
|
- // obj = cell.getNumericCellValue();
|
|
|
- break;
|
|
|
- case STRING:
|
|
|
- obj = cell.getStringCellValue();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- return obj.toString();
|
|
|
- } catch (Exception e) {
|
|
|
- return "";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void exportDiagnosticBasis(DiagnosticBasisExportVO diaExportVO, HttpServletResponse response) {
|
|
|
- QueryWrapper<DiagnoseQuestion> diaQuery = new QueryWrapper<>();
|
|
|
- diaQuery.like("dis_name", diaExportVO.getDisName()).like("question_name", diaExportVO.getQuestion())
|
|
|
- .like("type", diaExportVO.getType()).eq("is_deleted", IsDeleteEnum.N.getKey()).orderByDesc("gmt_modified");
|
|
|
- List<DiagnoseQuestion> datas = diagnoseQuestionService.list(diaQuery);
|
|
|
-
|
|
|
- GsonUtil.toJson(datas);
|
|
|
- System.out.println(GsonUtil.toJson(datas));
|
|
|
- List<String> listName = new ArrayList<>();
|
|
|
-
|
|
|
- listName.add("归属诊断");
|
|
|
- listName.add("标准术语*");
|
|
|
- listName.add("类型*");
|
|
|
- listName.add("术语同义词*(多个时用\",\"隔开,必须需要包含本体)");
|
|
|
- listName.add("标准术语说明");
|
|
|
- listName.add("性别");
|
|
|
- listName.add("最小年龄");
|
|
|
- listName.add("最大年龄");
|
|
|
-
|
|
|
- List<String> listId = new ArrayList<>();
|
|
|
- listId.add("disName");
|
|
|
- listId.add("term");
|
|
|
- listId.add("type");
|
|
|
- listId.add("termSynonym");
|
|
|
- listId.add("TermNote");
|
|
|
- listId.add("sex");
|
|
|
- listId.add("minAge");
|
|
|
- listId.add("maxAge");
|
|
|
-
|
|
|
- List<DiagnosticBasisExportDTO> list = new ArrayList<>();
|
|
|
- for (int i = 0; i < datas.size(); i++) {
|
|
|
- DiagnoseQuestion diagnose = datas.get(i);
|
|
|
- list.add(new DiagnosticBasisExportDTO(diagnose.getDisName(), diagnose.getQuestionName(),
|
|
|
- getType(diagnose.getType(), diagnose.getQuestionType()), diagnose.getQuestionName(), "", "通用", "0",
|
|
|
- "200"));
|
|
|
-
|
|
|
- }
|
|
|
- response.setContentType("text/html;charset=UTF-8");
|
|
|
- ExportBeanExcelUtil ex = new ExportBeanExcelUtil();
|
|
|
- ex.exportExcelNew("诊断依据问题词", listName, listId, list, response);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param diaAllExportVO
|
|
|
- * @param response
|
|
|
- */
|
|
|
- public void exportDiagnosticAll(DiagnosticAllExportVO diaAllExportVO, HttpServletResponse response) {
|
|
|
- //判断是否无问题词
|
|
|
- QueryWrapper<Diagnose> diagnoseQuery = new QueryWrapper<>();
|
|
|
- diagnoseQuery.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("has_question", HasQuestionEnum.NO_QUESTION.getKey())
|
|
|
- .eq("id", diaAllExportVO.getDiagnoseId());
|
|
|
- if (0 == diagnoseService.count(diagnoseQuery)) {
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "该诊断依据存在问题!");
|
|
|
- }
|
|
|
-
|
|
|
- QueryWrapper<DiagnoseDetail> diaQuery = new QueryWrapper<>();
|
|
|
- diaQuery.eq("diagnose_id", diaAllExportVO.getDiagnoseId()).eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
- List<DiagnoseDetail> datas = diagnoseDetailService.list(diaQuery);
|
|
|
-
|
|
|
- GsonUtil.toJson(datas);
|
|
|
- System.out.println(GsonUtil.toJson(datas));
|
|
|
- List<String> listName = new ArrayList<>();
|
|
|
-
|
|
|
- listName.add("类型");
|
|
|
- listName.add("序号");
|
|
|
- listName.add("标准词*");
|
|
|
- listName.add("是否需要病史采集");
|
|
|
- listName.add("关联词");
|
|
|
- listName.add("结果");
|
|
|
-
|
|
|
- List<String> listId = new ArrayList<>();
|
|
|
- listId.add("type");
|
|
|
- listId.add("code");
|
|
|
- listId.add("standard");
|
|
|
- listId.add("historyTaking");
|
|
|
- listId.add("relation");
|
|
|
- listId.add("result");
|
|
|
-
|
|
|
-
|
|
|
- String disName = (datas.size() > 0) ? datas.get(0).getDisName() : " ";
|
|
|
- List<DiagnosticAllExportDTO> list = new ArrayList<>();
|
|
|
- for (int i = 0; i < datas.size(); i++) {
|
|
|
- DiagnoseDetail diagnose = datas.get(i);
|
|
|
- disName = diagnose.getDisName();
|
|
|
- list.add(new DiagnosticAllExportDTO(getDisType(diagnose.getType()), diagnose.getCode(),
|
|
|
- diagnose.getStandard(), "", getRelation(diagnose.getType(), diagnose), diagnose.getResult()));
|
|
|
-
|
|
|
- }
|
|
|
- response.setContentType("text/html;charset=UTF-8");
|
|
|
- ExportBeanExcelUtil ex = new ExportBeanExcelUtil();
|
|
|
- ex.exportExcelNew(disName, listName, listId, list, response);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出类型转换
|
|
|
- *
|
|
|
- * @param type
|
|
|
- * @param questionType
|
|
|
- * @return
|
|
|
- */
|
|
|
- public String getType(Integer type, Integer questionType) {
|
|
|
- String typeName = "";
|
|
|
- Integer showType = null;
|
|
|
- if (typeMap.containsKey(type.toString())) {
|
|
|
- showType = typeMap.get(type.toString());
|
|
|
- } else {
|
|
|
- if (typeMap.containsKey(type + "_" + questionType)) {
|
|
|
- showType = typeMap.get(type + "_" + questionType);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!IntegerUtil.isNull(showType)) {
|
|
|
- typeName = TermEnum.getName(showType);
|
|
|
- }
|
|
|
- return typeName;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出公式类型转换
|
|
|
- */
|
|
|
- public String getDisType(Integer type) {
|
|
|
- String typeName = "";
|
|
|
-
|
|
|
- typeName = DiagnoseFeatureTypeEnum.getName(type);
|
|
|
- if (typeName == null) {
|
|
|
- typeName = DiagnoseTypeEnum.getName(type);
|
|
|
- }
|
|
|
- return typeName;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出公式和标准词切换
|
|
|
- */
|
|
|
- public String getRelation(Integer type, DiagnoseDetail diagnose) {
|
|
|
- String typeName = "";
|
|
|
- String relation = "";
|
|
|
- typeName = DiagnoseFeatureTypeEnum.getName(type);
|
|
|
- relation = diagnose.getRelation();
|
|
|
- if (typeName == null) {
|
|
|
- relation = diagnose.getFormula();
|
|
|
- }
|
|
|
- return relation;
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.DiagnoseImportDTO;
|
|
|
+import com.diagbot.dto.DiagnosticAllExportDTO;
|
|
|
+import com.diagbot.dto.DiagnosticBasisExportDTO;
|
|
|
+import com.diagbot.dto.EquationDTO;
|
|
|
+import com.diagbot.dto.FeatureDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.entity.Diagnose;
|
|
|
+import com.diagbot.entity.DiagnoseDetail;
|
|
|
+import com.diagbot.entity.DiagnoseQuestion;
|
|
|
+import com.diagbot.enums.DiagnoseFeatureTypeEnum;
|
|
|
+import com.diagbot.enums.DiagnoseTypeEnum;
|
|
|
+import com.diagbot.enums.HasQuestionEnum;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.enums.TermEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.DiagnoseDetailService;
|
|
|
+import com.diagbot.service.DiagnoseQuestionService;
|
|
|
+import com.diagbot.service.DiagnoseService;
|
|
|
+import com.diagbot.util.ExportBeanExcelUtil;
|
|
|
+import com.diagbot.util.GsonUtil;
|
|
|
+import com.diagbot.util.IntegerUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.DiagnosticAllExportVO;
|
|
|
+import com.diagbot.vo.DiagnosticBasisExportVO;
|
|
|
+import org.apache.commons.lang.time.DateFormatUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
+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.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wangfeng
|
|
|
+ * @Description: TODO
|
|
|
+ * @date 2019年8月8日 下午1:30:53
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class DiagnoseImportFacade {
|
|
|
+
|
|
|
+ private static final Map<String, Integer> typeMap = new HashMap<String, Integer>() {
|
|
|
+ {
|
|
|
+ put(String.valueOf(DiagnoseFeatureTypeEnum.Dis.getKey()), 0);
|
|
|
+ put(String.valueOf(DiagnoseFeatureTypeEnum.Symptom.getKey()), 1);
|
|
|
+ put(String.valueOf(DiagnoseFeatureTypeEnum.Vital.getKey()), 2);
|
|
|
+ put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_2", 3);
|
|
|
+ put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_3", 4);
|
|
|
+ put(DiagnoseFeatureTypeEnum.Lis.getKey() + "_4", 5);
|
|
|
+ put(DiagnoseFeatureTypeEnum.Pacs.getKey() + "_2", 6);
|
|
|
+ put(DiagnoseFeatureTypeEnum.Pacs.getKey() + "_3", 7);
|
|
|
+ put(String.valueOf(DiagnoseFeatureTypeEnum.Antidiastole.getKey()), 8);
|
|
|
+ put(String.valueOf(DiagnoseFeatureTypeEnum.History.getKey()), 8);
|
|
|
+ put(String.valueOf(DiagnoseFeatureTypeEnum.Cause.getKey()), 9);
|
|
|
+ put(String.valueOf(DiagnoseFeatureTypeEnum.CourseOfDisease.getKey()), 10);
|
|
|
+ put(String.valueOf(DiagnoseFeatureTypeEnum.Other.getKey()), 10);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DiagnoseQuestionService diagnoseQuestionService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("diagnoseDetailServiceImpl")
|
|
|
+ DiagnoseDetailService diagnoseDetailService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("diagnoseServiceImpl")
|
|
|
+ DiagnoseService diagnoseService;
|
|
|
+
|
|
|
+ @SuppressWarnings("null")
|
|
|
+ public RespDTO<DiagnoseImportDTO> importDiagnosticBasisAll(MultipartFile file, HttpServletRequest request) {
|
|
|
+
|
|
|
+ List<String> messages = new ArrayList<>();
|
|
|
+ InputStream inputStream = null;
|
|
|
+ DiagnoseImportDTO diagnoseImportDTO = new DiagnoseImportDTO();
|
|
|
+ List<FeatureDTO> featureList = new ArrayList<FeatureDTO>();
|
|
|
+ List<EquationDTO> equationList = new ArrayList<EquationDTO>();
|
|
|
+ List<String> assemblys = new ArrayList<String>();
|
|
|
+ Workbook wb = null;
|
|
|
+ try {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ inputStream = file.getInputStream();
|
|
|
+ if (inputStream.available() > 512000) {
|
|
|
+ messages.add("化验文件最大支持500KB!");
|
|
|
+ } 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);
|
|
|
+ diagnoseImportDTO.setDisName(sheet.getSheetName());
|
|
|
+ int count = 0;
|
|
|
+ String name, code, standardWord, associatedWord, consequence;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ count++;
|
|
|
+ try {
|
|
|
+ if (row != null) {
|
|
|
+ name = getValue(row.getCell(0)).trim().replace(" ", "");
|
|
|
+ code = getValue(row.getCell(1)).trim().replace(" ", "");
|
|
|
+ standardWord = getValue(row.getCell(2)).trim();
|
|
|
+ associatedWord = getValue(row.getCell(3)).trim();
|
|
|
+ consequence = getValue(row.getCell(4)).trim();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ name = null;
|
|
|
+ code = null;
|
|
|
+ standardWord = null;
|
|
|
+ associatedWord = null;
|
|
|
+ consequence = null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (count == 1 && name.equals("类型")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.isEmpty(name)) {
|
|
|
+ messages.add("第" + count + "行数据不规范,类型必填;");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ FeatureDTO feature = new FeatureDTO();
|
|
|
+ EquationDTO equation = new EquationDTO();
|
|
|
+ if (code.equals("")) {
|
|
|
+ equation.setType(name);
|
|
|
+ equation.setAssociated(associatedWord);
|
|
|
+ equationList.add(equation);
|
|
|
+ } else {
|
|
|
+ feature.setType(name);
|
|
|
+ feature.setCode(code);
|
|
|
+ feature.setResult(consequence);
|
|
|
+ feature.setAssociated(associatedWord);
|
|
|
+ feature.setStandard(standardWord);
|
|
|
+ featureList.add(feature);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, e.toString());
|
|
|
+ // logger.error("",e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // throw new
|
|
|
+ // CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ // "非excel文件无法解析!");
|
|
|
+ messages.add("非excel文件无法解析!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ // "未知文件无法解析!");
|
|
|
+ messages.add("未知文件无法解析!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ // "无文件上传!");
|
|
|
+ messages.add("无文件上传!");
|
|
|
+ }
|
|
|
+
|
|
|
+ diagnoseImportDTO.setEquation(equationList);
|
|
|
+ diagnoseImportDTO.setFeature(featureList);
|
|
|
+ diagnoseImportDTO.setMessages(messages);
|
|
|
+ return RespDTO.onSuc(diagnoseImportDTO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "化验excel文件解析出错!");
|
|
|
+ // return response.failure("化验excel文件解析出错!");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (inputStream != null) {
|
|
|
+ inputStream.close();
|
|
|
+ }
|
|
|
+ if (wb != null) {
|
|
|
+ wb.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getValue(Cell cell) {
|
|
|
+ try {
|
|
|
+ Object obj = null;
|
|
|
+ switch (cell.getCellTypeEnum()) {
|
|
|
+ case BOOLEAN:
|
|
|
+ obj = cell.getBooleanCellValue();
|
|
|
+ break;
|
|
|
+ case ERROR:
|
|
|
+ obj = cell.getErrorCellValue();
|
|
|
+ break;
|
|
|
+ case NUMERIC:
|
|
|
+ if (HSSFDateUtil.isCellDateFormatted(cell)) {
|
|
|
+ Date date = cell.getDateCellValue();
|
|
|
+ obj = DateFormatUtils.format(date, "yyyy-MM-dd");
|
|
|
+ } else {
|
|
|
+ obj = cell.getNumericCellValue();
|
|
|
+ DecimalFormat df = new DecimalFormat();
|
|
|
+ obj = df.format(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ // obj = cell.getNumericCellValue();
|
|
|
+ break;
|
|
|
+ case STRING:
|
|
|
+ obj = cell.getStringCellValue();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return obj.toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void exportDiagnosticBasis(DiagnosticBasisExportVO diaExportVO, HttpServletResponse response) {
|
|
|
+ QueryWrapper<DiagnoseQuestion> diaQuery = new QueryWrapper<>();
|
|
|
+ diaQuery.like("dis_name", diaExportVO.getDisName()).like("question_name", diaExportVO.getQuestion())
|
|
|
+ .like("type", diaExportVO.getType()).eq("is_deleted", IsDeleteEnum.N.getKey()).orderByDesc("gmt_modified");
|
|
|
+ List<DiagnoseQuestion> datas = diagnoseQuestionService.list(diaQuery);
|
|
|
+
|
|
|
+ GsonUtil.toJson(datas);
|
|
|
+ System.out.println(GsonUtil.toJson(datas));
|
|
|
+ List<String> listName = new ArrayList<>();
|
|
|
+
|
|
|
+ listName.add("归属诊断");
|
|
|
+ listName.add("标准术语*");
|
|
|
+ listName.add("类型*");
|
|
|
+ listName.add("术语同义词*(多个时用\",\"隔开,必须需要包含本体)");
|
|
|
+ listName.add("标准术语说明");
|
|
|
+ listName.add("性别");
|
|
|
+ listName.add("最小年龄");
|
|
|
+ listName.add("最大年龄");
|
|
|
+
|
|
|
+ List<String> listId = new ArrayList<>();
|
|
|
+ listId.add("disName");
|
|
|
+ listId.add("term");
|
|
|
+ listId.add("type");
|
|
|
+ listId.add("termSynonym");
|
|
|
+ listId.add("TermNote");
|
|
|
+ listId.add("sex");
|
|
|
+ listId.add("minAge");
|
|
|
+ listId.add("maxAge");
|
|
|
+
|
|
|
+ List<DiagnosticBasisExportDTO> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ DiagnoseQuestion diagnose = datas.get(i);
|
|
|
+ list.add(new DiagnosticBasisExportDTO(diagnose.getDisName(), diagnose.getQuestionName(),
|
|
|
+ getType(diagnose.getType(), diagnose.getQuestionType()), diagnose.getQuestionName(), "", "通用", "0",
|
|
|
+ "200"));
|
|
|
+
|
|
|
+ }
|
|
|
+ response.setContentType("text/html;charset=UTF-8");
|
|
|
+ ExportBeanExcelUtil ex = new ExportBeanExcelUtil();
|
|
|
+ ex.exportExcelNew("诊断依据问题词", listName, listId, list, response);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param diaAllExportVO
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ public void exportDiagnosticAll(DiagnosticAllExportVO diaAllExportVO, HttpServletResponse response) {
|
|
|
+ //判断是否无问题词
|
|
|
+ QueryWrapper<Diagnose> diagnoseQuery = new QueryWrapper<>();
|
|
|
+ diagnoseQuery.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("has_question", HasQuestionEnum.NO_QUESTION.getKey())
|
|
|
+ .eq("id", diaAllExportVO.getDiagnoseId());
|
|
|
+ if (0 == diagnoseService.count(diagnoseQuery)) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该诊断依据存在问题!");
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<DiagnoseDetail> diaQuery = new QueryWrapper<>();
|
|
|
+ diaQuery.eq("diagnose_id", diaAllExportVO.getDiagnoseId()).eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ List<DiagnoseDetail> datas = diagnoseDetailService.list(diaQuery);
|
|
|
+
|
|
|
+ GsonUtil.toJson(datas);
|
|
|
+ System.out.println(GsonUtil.toJson(datas));
|
|
|
+ List<String> listName = new ArrayList<>();
|
|
|
+
|
|
|
+ listName.add("类型");
|
|
|
+ listName.add("序号");
|
|
|
+ listName.add("标准词*");
|
|
|
+ listName.add("是否需要病史采集");
|
|
|
+ listName.add("关联词");
|
|
|
+ listName.add("结果");
|
|
|
+
|
|
|
+ List<String> listId = new ArrayList<>();
|
|
|
+ listId.add("type");
|
|
|
+ listId.add("code");
|
|
|
+ listId.add("standard");
|
|
|
+ listId.add("historyTaking");
|
|
|
+ listId.add("relation");
|
|
|
+ listId.add("result");
|
|
|
+
|
|
|
+
|
|
|
+ String disName = (datas.size() > 0) ? datas.get(0).getDisName() : " ";
|
|
|
+ List<DiagnosticAllExportDTO> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ DiagnoseDetail diagnose = datas.get(i);
|
|
|
+ disName = diagnose.getDisName();
|
|
|
+ list.add(new DiagnosticAllExportDTO(getDisType(diagnose.getType()), diagnose.getCode(),
|
|
|
+ diagnose.getStandard(), "", getRelation(diagnose.getType(), diagnose), diagnose.getResult()));
|
|
|
+
|
|
|
+ }
|
|
|
+ response.setContentType("text/html;charset=UTF-8");
|
|
|
+ ExportBeanExcelUtil ex = new ExportBeanExcelUtil();
|
|
|
+ ex.exportExcelNew(disName, listName, listId, list, response);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出类型转换
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @param questionType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getType(Integer type, Integer questionType) {
|
|
|
+ String typeName = "";
|
|
|
+ Integer showType = null;
|
|
|
+ if (typeMap.containsKey(type.toString())) {
|
|
|
+ showType = typeMap.get(type.toString());
|
|
|
+ } else {
|
|
|
+ if (typeMap.containsKey(type + "_" + questionType)) {
|
|
|
+ showType = typeMap.get(type + "_" + questionType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!IntegerUtil.isNull(showType)) {
|
|
|
+ typeName = TermEnum.getName(showType);
|
|
|
+ }
|
|
|
+ return typeName;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出公式类型转换
|
|
|
+ */
|
|
|
+ public String getDisType(Integer type) {
|
|
|
+ String typeName = "";
|
|
|
+
|
|
|
+ typeName = DiagnoseFeatureTypeEnum.getName(type);
|
|
|
+ if (typeName == null) {
|
|
|
+ typeName = DiagnoseTypeEnum.getName(type);
|
|
|
+ }
|
|
|
+ return typeName;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出公式和标准词切换
|
|
|
+ */
|
|
|
+ public String getRelation(Integer type, DiagnoseDetail diagnose) {
|
|
|
+ String typeName = "";
|
|
|
+ String relation = "";
|
|
|
+ typeName = DiagnoseFeatureTypeEnum.getName(type);
|
|
|
+ if (typeName == null) {
|
|
|
+ relation = diagnose.getFormula();
|
|
|
+ } else {
|
|
|
+ if (typeName.equals(DiagnoseFeatureTypeEnum.Lis.getName())) {
|
|
|
+ relation = diagnose.getRelation() + diagnose.getMidResult();
|
|
|
+ } else {
|
|
|
+ relation = diagnose.getResult();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return relation;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|