Browse Source

Merge remote-tracking branch 'origin/dev/icss' into debug

Zhaops 6 years ago
parent
commit
cd55c2275e

+ 24 - 1
icss-service/pom.xml

@@ -148,7 +148,30 @@
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
         </dependency>
-
+<!-- 文件上传相关架包 -->
+		<dependency>
+			<groupId>commons-fileupload</groupId>
+			<artifactId>commons-fileupload</artifactId>
+			<version>1.3.1</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>2.4</version>
+		</dependency>
+		<dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-web</artifactId>
+    </dependency>
+    <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-thymeleaf</artifactId>
+    </dependency>
+    <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-devtools</artifactId>
+        <optional>true</optional>
+    </dependency>
     </dependencies>
 
     <build>

+ 201 - 0
icss-service/src/main/java/com/diagbot/facade/LisExcelResFacade.java

@@ -0,0 +1,201 @@
+package com.diagbot.facade;
+
+import java.io.InputStream;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.servlet.http.HttpServletRequest;
+
+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.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.diagbot.dto.RespDTO;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.LisExcelResVO;
+import com.diagbot.vo.LisExcelWrapperVO;
+import com.diagbot.vo.LitAssayVO;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: 化验导入
+ * @date 2018年11月29日 上午10:16:35
+ */
+@Component
+public class LisExcelResFacade {
+
+	public RespDTO<LitAssayVO> lisExcelAnalysis(MultipartFile file, HttpServletRequest request) {
+
+		List<String> messages = new ArrayList<>();
+		List<LisExcelWrapperVO> lisExcelWrapperList = new ArrayList<>();
+		InputStream inputStream = null;
+		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);
+							int count = 0;
+							String mealName, itemName, unit, value, max, min, time;
+							for (Row row : sheet) {
+								count++;
+								try {
+									if (row != null) {
+										mealName = getValue(row.getCell(0)).trim().replace(" ", "");
+										itemName = getValue(row.getCell(1)).trim().replace(" ", "");
+										unit = getValue(row.getCell(2)).trim();
+										value = getValue(row.getCell(3)).trim();
+										max = getValue(row.getCell(4)).trim();
+										min = getValue(row.getCell(5)).trim();
+										time = getValue(row.getCell(6)).trim();
+									} else {
+										mealName = null;
+										itemName = null;
+										unit = null;
+										value = null;
+										max = null;
+										min = null;
+										time = null;
+									}
+
+									if (StringUtil.isEmpty(mealName) && StringUtil.isEmpty(itemName)
+											&& StringUtil.isEmpty(value)) {
+										continue;
+									}
+
+									if (count == 1 && mealName.equals("套餐名")) {
+										continue;
+									}
+
+									if (StringUtil.isEmpty(mealName) || StringUtil.isEmpty(itemName)
+											|| StringUtil.isEmpty(value)) {
+										// throw new
+										// CommonException(CommonErrorCode.NOT_EXISTS,
+										// "第"+count+"行数据不规范,套餐名、项目名、结果三项必填;");
+										messages.add("第" + count + "行数据不规范,套餐名、项目名、结果三项必填;");
+										continue;
+									}
+									LisExcelWrapperVO lisExcelWrapper = new LisExcelWrapperVO();
+
+									lisExcelWrapper.setMealName(mealName);
+									lisExcelWrapper.setItemName(itemName);
+									lisExcelWrapper.setUnit(unit);
+									lisExcelWrapper.setValue(value);
+									lisExcelWrapper.setMax(max);
+									lisExcelWrapper.setMin(min);
+									lisExcelWrapper.setTime(time);
+									lisExcelWrapperList.add(lisExcelWrapper);
+								} 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("无文件上传!");
+			}
+			Map<String, List<LisExcelWrapperVO>> lixExMap = lisExcelWrapperList.stream()
+					.collect(Collectors.groupingBy(LisExcelWrapperVO::getMealName));
+			List<LisExcelResVO> LisExcelReslist = new ArrayList<LisExcelResVO>();
+			for (String str : lixExMap.keySet()) {
+				LisExcelResVO lisExcelResVO = new LisExcelResVO();
+				lisExcelResVO.setMenus(str);
+				lisExcelResVO.setLisExcelItem(lixExMap.get(str));
+				LisExcelReslist.add(lisExcelResVO);
+			}
+
+			LitAssayVO litAssay = new LitAssayVO();
+			litAssay.setMessages(messages);
+			litAssay.setLisExcelRes(LisExcelReslist);
+			return RespDTO.onSuc(litAssay);
+		} 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("0");
+					obj = df.format(obj);
+				}
+
+				// obj = cell.getNumericCellValue();
+				break;
+			case STRING:
+				obj = cell.getStringCellValue();
+				break;
+			default:
+				break;
+			}
+			return obj.toString();
+		} catch (Exception e) {
+			return "";
+		}
+	}
+
+}

+ 10 - 11
icss-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -29,8 +29,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -75,11 +75,9 @@ public class PushFacade {
             case 2:
                 searchData.setSex("F");
                 break;
-            case 3:
+            default:
                 searchData.setSex("A");
                 break;
-            default:
-                throw new CommonException(CommonErrorCode.PARAM_ERROR, "性别参数错误");
         }
 
         searchData.setFeatureType(pushVO.getFeatureType());
@@ -110,18 +108,19 @@ public class PushFacade {
         List<FeatureRate> labs = data.getLabs();
 
         Map<String, Object> symptomMap = list2Map(symptom);
-        Map<String, Object> vitalMap = new HashMap<>();
+        Map<String, Object> vitalMap = new LinkedHashMap<>();
         Map<String, Object> disMap = list2Map(dis);
         Map<String, Object> labMap = list2Map(labs);
         Map<String, Object> pacsMap = list2Map(pacs);
 
-        if (featureTypeSet.contains(QuestionTypeEnum.Lis.getKey())) {
+        if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Lis.getKey()))) {
             pushDTO.setLabMap(labMap);
-        } else if (featureTypeSet.contains(QuestionTypeEnum.Pacs.getKey())) {
+        }
+        if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Pacs.getKey()))) {
             pushDTO.setPacsMap(pacsMap);
         }
         //诊断 返回tagName+id
-        else if (featureTypeSet.contains(QuestionTypeEnum.Disease.getKey())) {
+        if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Disease.getKey()))) {
             QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper();
             questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
                     in("tag_name", disMap.keySet()).
@@ -131,7 +130,7 @@ public class PushFacade {
             pushDTO.setDisMap(disMap);
         }
         //症状(主诉 type=1;现病史 type=2) 返回 tagName+填写单
-        else if (featureTypeSet.contains(QuestionTypeEnum.Symptom.getKey())) {
+        if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Symptom.getKey()))) {
             QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper();
             questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
                     in("tag_name", symptomMap.keySet()).
@@ -141,7 +140,7 @@ public class PushFacade {
             pushDTO.setSymptomMap(symptomMap);
         }
         //查体 返回模板
-        else if (featureTypeSet.contains(QuestionTypeEnum.Vital.getKey())) {
+        if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Vital.getKey()))) {
             //没有推送信息时,默认取全科模板
             String deptName = "全科";
             if (dis != null && dis.size() > 0) {
@@ -242,7 +241,7 @@ public class PushFacade {
      * @return
      */
     public Map<String, Object> list2Map(List<FeatureRate> list) {
-        Map<String, Object> map = new HashMap<>();
+        Map<String, Object> map = new LinkedHashMap<>();
         for (FeatureRate featureRate : list) {
             map.put(featureRate.getFeatureName(), null);
         }

+ 23 - 0
icss-service/src/main/java/com/diagbot/vo/LisExcelResVO.java

@@ -0,0 +1,23 @@
+package com.diagbot.vo;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+/**
+ * 
+ * @author wangfeng
+ * @Description: TODO
+ * @date 2018年11月28日 上午9:51:17
+ */
+@Setter
+@Getter
+public class LisExcelResVO {
+
+	
+	private String menus;
+	
+	private List<LisExcelWrapperVO> lisExcelItem ;
+	
+
+}

+ 8 - 7
icss-service/src/main/java/com/diagbot/vo/LisExcelWrapperVO.java

@@ -3,23 +3,24 @@ package com.diagbot.vo;
 import lombok.Getter;
 import lombok.Setter;
 
-/**
- * 
- * @author wangfeng
- * @Description: TODO
- * @date 2018年11月26日 下午1:20:24
- */
+
 @Setter
 @Getter
 public class LisExcelWrapperVO {
 
-private String mealName;
+    private String mealName;
 	
 	private String itemName;
 	
 	private String unit;
 	
 	private String value;
+	
+	private String max;
+	
+	private String min;
+	
+	private String time;
 
 	@Override
 	public String toString() {

+ 15 - 0
icss-service/src/main/java/com/diagbot/vo/LitAssayVO.java

@@ -0,0 +1,15 @@
+package com.diagbot.vo;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class LitAssayVO {
+
+	private List<LisExcelResVO> lisExcelRes;
+	
+	private List<String> messages;
+}

+ 30 - 0
icss-service/src/main/java/com/diagbot/web/DiseaseController.java

@@ -0,0 +1,30 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import io.swagger.annotations.Api;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/11/30 17:25
+ */
+@RestController
+@RequestMapping("/disease")
+@Api(value = "诊断相关API", tags = { "诊断相关API" })
+public class DiseaseController {
+
+    /**
+     * 根据诊断获取治疗方案
+     *
+     * @return
+     */
+    @PostMapping("/getTreatmentPlanByDisease")
+    @SysLogger("getTreatmentPlanByDisease")
+    public RespDTO<Boolean> getTreatmentPlanByDisease() {
+        return RespDTO.onSuc(true);
+    }
+}

+ 40 - 0
icss-service/src/main/java/com/diagbot/web/LisExcelResController.java

@@ -0,0 +1,40 @@
+package com.diagbot.web;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.LisExcelResFacade;
+import com.diagbot.vo.LitAssayVO;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: 化验导入
+ * @date 2018年11月28日 上午10:20:38
+ */
+@RestController
+@RequestMapping("/lisExcelRes")
+@Api(value = "化验导入API[by:wangfeng]", tags = { "WF——化验导入API" })
+@SuppressWarnings("unchecked")
+public class LisExcelResController {
+
+	@Autowired
+	LisExcelResFacade lisExcelResFacade;
+
+	@ApiOperation(value = "导入化验数据:[by:wangfeng]", notes = "导入化验数据")
+	@PostMapping("/lisExcelAnalysis")
+	public RespDTO<LitAssayVO> lisExcelAnalysis(@RequestParam("uploadfile") MultipartFile file,
+			HttpServletRequest request) {
+		return lisExcelResFacade.lisExcelAnalysis(file, request);
+	}
+}

+ 1 - 1
icss-service/src/main/java/com/diagbot/web/PushController.java

@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.validation.Valid;
 
 /**
- * @Description:
+ * @Description:推理接口
  * @Author:zhaops
  * @time: 2018/11/20 11:17
  */