浏览代码

化验导入公表转换

wangfeng 6 年之前
父节点
当前提交
2115e33713

+ 40 - 0
icss-service/src/main/java/com/diagbot/dto/LisConfigDTO.java

@@ -0,0 +1,40 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: TODO
+ * @date 2018年12月25日 上午11:02:17
+ */
+@Setter
+@Getter
+public class LisConfigDTO {
+	 private Long id;
+	 /**
+     * 医院id
+     */
+    private String hospitalId;
+
+    /**
+     * 套餐名
+     */
+    private String mealName;
+
+    /**
+     * 项目名
+     */
+    private String itemName;
+
+    /**
+     * 公表id
+     */
+    private String uniqueId;
+
+    /**
+     * 公表明
+     */
+    private String uniqueName;
+}

+ 174 - 0
icss-service/src/main/java/com/diagbot/entity/LisConfig.java

@@ -0,0 +1,174 @@
+package com.diagbot.entity;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+/**
+ * <p>
+ * 套餐字段映射公表
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2018-12-25
+ */
+@TableName("tran_lis_config")
+public class LisConfig implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 医院id
+     */
+    private String hospitalCode;
+
+    /**
+     * 套餐名
+     */
+    private String mealName;
+
+    /**
+     * 项目名
+     */
+    private String itemName;
+
+    /**
+     * 公表id
+     */
+    private String uniqueId;
+
+    /**
+     * 公表明
+     */
+    private String uniqueName;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+    public Date getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(Date gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+    public Date getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(Date gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+    public String getHospitalCode() {
+        return hospitalCode;
+    }
+
+    public void setHospitalCode(String hospitalCode) {
+        this.hospitalCode = hospitalCode;
+    }
+    public String getMealName() {
+        return mealName;
+    }
+
+    public void setMealName(String mealName) {
+        this.mealName = mealName;
+    }
+    public String getItemName() {
+        return itemName;
+    }
+
+    public void setItemName(String itemName) {
+        this.itemName = itemName;
+    }
+    public String getUniqueId() {
+        return uniqueId;
+    }
+
+    public void setUniqueId(String uniqueId) {
+        this.uniqueId = uniqueId;
+    }
+    public String getUniqueName() {
+        return uniqueName;
+    }
+
+    public void setUniqueName(String uniqueName) {
+        this.uniqueName = uniqueName;
+    }
+
+    @Override
+    public String toString() {
+        return "LisConfig{" +
+        "id=" + id +
+        ", isDeleted=" + isDeleted +
+        ", gmtCreate=" + gmtCreate +
+        ", gmtModified=" + gmtModified +
+        ", creator=" + creator +
+        ", modifier=" + modifier +
+        ", hospitalCode=" + hospitalCode +
+        ", mealName=" + mealName +
+        ", itemName=" + itemName +
+        ", uniqueId=" + uniqueId +
+        ", uniqueName=" + uniqueName +
+        "}";
+    }
+}

+ 38 - 0
icss-service/src/main/java/com/diagbot/facade/LisConfigFacade.java

@@ -0,0 +1,38 @@
+package com.diagbot.facade;
+
+import java.util.List;
+
+import org.springframework.stereotype.Component;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.dto.LisConfigDTO;
+import com.diagbot.entity.LisConfig;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.service.impl.LisConfigServiceImpl;
+import com.diagbot.util.BeanUtil;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: 化验配置
+ * @date 2018年12月25日 上午10:57:34
+ */
+@Component
+public class LisConfigFacade extends LisConfigServiceImpl{
+	
+	/**
+	 * 
+	 * @param hospitalId
+	 * @return
+	 */
+	public List<LisConfigDTO> getLisConfigByhospitalId(String hospitalCode){
+		
+		QueryWrapper<LisConfig> lisConfig = new QueryWrapper<>();
+		lisConfig.eq("is_deleted", IsDeleteEnum.N.getKey()).eq("hospital_code", hospitalCode);
+		List<LisConfig> data = list(lisConfig);
+		// getDisclaimerInformationAll();
+		List<LisConfigDTO> datas = BeanUtil.listCopyTo(data, LisConfigDTO.class);
+		return datas;
+	} 
+
+}

+ 175 - 154
icss-service/src/main/java/com/diagbot/facade/LisExcelResFacade.java

@@ -1,5 +1,6 @@
 package com.diagbot.facade;
 
+import com.diagbot.dto.LisConfigDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
@@ -15,6 +16,7 @@ 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.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -35,167 +37,186 @@ import java.util.stream.Collectors;
 @Component
 public class LisExcelResFacade {
 
-    public RespDTO<LitAssayVO> lisExcelAnalysis(MultipartFile file, HttpServletRequest request) {
+	@Autowired
+	LisConfigFacade lisConfigFacade;
 
-        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();
-                                        min = getValue(row.getCell(4)).trim();
-                                        max = getValue(row.getCell(5)).trim();
-                                        time = getValue(row.getCell(6)).trim();
-                                        type = getValue(row.getCell(7)).trim();
-                                    } else {
-                                        mealName = null;
-                                        itemName = null;
-                                        unit = null;
-                                        value = null;
-                                        min = null;
-                                        max = null;
-                                        time = null;
-                                        type = null;
-                                    }
+	public RespDTO<LitAssayVO> lisExcelAnalysis(MultipartFile file, String hospitalCode, HttpServletRequest request) {
+		System.out.println("hospitalId======" + hospitalCode);
+		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();
+										min = getValue(row.getCell(4)).trim();
+										max = getValue(row.getCell(5)).trim();
+										time = getValue(row.getCell(6)).trim();
+										type = getValue(row.getCell(7)).trim();
+									} else {
+										mealName = null;
+										itemName = null;
+										unit = null;
+										value = null;
+										min = null;
+										max = null;
+										time = null;
+										type = null;
+									}
 
-                                    if (StringUtil.isEmpty(mealName) && StringUtil.isEmpty(itemName)
-                                            && StringUtil.isEmpty(value) && StringUtil.isEmpty(type)) {
-                                        continue;
-                                    }
+									if (StringUtil.isEmpty(mealName) && StringUtil.isEmpty(itemName)
+											&& StringUtil.isEmpty(value) && StringUtil.isEmpty(type)) {
+										continue;
+									}
 
-                                    if (count == 1 && mealName.equals("套餐名")) {
-                                        continue;
-                                    }
+									if (count == 1 && mealName.equals("套餐名")) {
+										continue;
+									}
 
-                                    if (StringUtil.isEmpty(mealName) || StringUtil.isEmpty(itemName)
-                                            || StringUtil.isEmpty(value) || StringUtil.isEmpty(type)) {
-                                        // throw new
-                                        // CommonException(CommonErrorCode.NOT_EXISTS,
-                                        // "第"+count+"行数据不规范,套餐名、项目名、结果三项必填;");
-                                        messages.add("第" + count + "行数据不规范,套餐名、项目名、结果、是否异常四项必填;");
-                                        continue;
-                                    }
-                                    LisExcelWrapperVO lisExcelWrapper = new LisExcelWrapperVO();
+									if (StringUtil.isEmpty(mealName) || StringUtil.isEmpty(itemName)
+											|| StringUtil.isEmpty(value) || StringUtil.isEmpty(type)) {
+										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);
-                                    lisExcelWrapper.setType(type);
-                                    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);
-            }
+									lisExcelWrapper.setMealName(mealName);
+									lisExcelWrapper.setItemName(itemName);
+									// lisExcelWrapper.setUniqueName(uniqueName);
+									lisExcelWrapper.setUnit(unit);
+									lisExcelWrapper.setValue(value);
+									lisExcelWrapper.setMax(max);
+									lisExcelWrapper.setMin(min);
+									lisExcelWrapper.setTime(time);
+									lisExcelWrapper.setType(type);
+									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("无文件上传!");
+			}
+			//匹配公表名
+			List<LisConfigDTO> litData = lisConfigFacade.getLisConfigByhospitalId(hospitalCode);
+			if(litData.size()>0){
+				List<LisExcelWrapperVO> lisExcelWrapperListNew = new ArrayList<>();
+				for (LisExcelWrapperVO lisExcelWrapperNew : lisExcelWrapperList) {
+					for (LisConfigDTO LisNew : litData) {
+						if (LisNew.getMealName().equals(lisExcelWrapperNew.getMealName())
+								&& LisNew.getItemName().equals(lisExcelWrapperNew.getItemName())) {
+							lisExcelWrapperNew.setUniqueName(LisNew.getUniqueName());
+						}
 
-            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) {
-            }
-        }
-    }
+					}
+					lisExcelWrapperListNew.add(lisExcelWrapperNew);
+				}
+				lisExcelWrapperList = lisExcelWrapperListNew;
+			}
+			
 
-    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);
-                    }
+			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);
+			}
 
-                    // obj = cell.getNumericCellValue();
-                    break;
-                case STRING:
-                    obj = cell.getStringCellValue();
-                    break;
-                default:
-                    break;
-            }
-            return obj.toString();
-        } catch (Exception e) {
-            return "";
-        }
-    }
+			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 "";
+		}
+	}
 
 }

+ 16 - 0
icss-service/src/main/java/com/diagbot/mapper/LisConfigMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.LisConfig;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 套餐字段映射公表 Mapper 接口
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2018-12-25
+ */
+public interface LisConfigMapper extends BaseMapper<LisConfig> {
+
+}

+ 16 - 0
icss-service/src/main/java/com/diagbot/service/LisConfigService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.LisConfig;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 套餐字段映射公表 服务类
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2018-12-25
+ */
+public interface LisConfigService extends IService<LisConfig> {
+
+}

+ 20 - 0
icss-service/src/main/java/com/diagbot/service/impl/LisConfigServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.LisConfig;
+import com.diagbot.mapper.LisConfigMapper;
+import com.diagbot.service.LisConfigService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 套餐字段映射公表 服务实现类
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2018-12-25
+ */
+@Service
+public class LisConfigServiceImpl extends ServiceImpl<LisConfigMapper, LisConfig> implements LisConfigService {
+
+}

+ 2 - 0
icss-service/src/main/java/com/diagbot/vo/LisExcelWrapperVO.java

@@ -12,6 +12,8 @@ public class LisExcelWrapperVO {
 	
 	private String itemName;
 	
+	private String uniqueName;
+	
 	private String unit;
 	
 	private String value;

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

@@ -30,8 +30,8 @@ public class LisExcelResController {
 
     @ApiOperation(value = "导入化验数据:[by:wangfeng]", notes = "导入化验数据")
     @PostMapping("/lisExcelAnalysis")
-    public RespDTO<LitAssayVO> lisExcelAnalysis(@RequestParam("uploadfile") MultipartFile file,
+    public RespDTO<LitAssayVO> lisExcelAnalysis(@RequestParam("uploadfile") MultipartFile file,String hospitalCode,
                                                 HttpServletRequest request) {
-        return lisExcelResFacade.lisExcelAnalysis(file, request);
+        return lisExcelResFacade.lisExcelAnalysis(file,hospitalCode, request);
     }
 }

+ 20 - 0
icss-service/src/main/resources/mapper/LisConfigMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.LisConfigMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.LisConfig">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="hospital_code" property="hospitalCode" />
+        <result column="meal_name" property="mealName" />
+        <result column="item_name" property="itemName" />
+        <result column="unique_id" property="uniqueId" />
+        <result column="unique_name" property="uniqueName" />
+    </resultMap>
+
+</mapper>