lenovodn пре 2 година
родитељ
комит
e63f103600

+ 72 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/controller/DiagnosesController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.medical.controller;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -9,10 +10,13 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
+import org.apache.poi.ss.formula.functions.T;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.medical.entity.Diagnoses;
+import org.jeecg.modules.medical.entity.Operative;
 import org.jeecg.modules.medical.service.IDiagnosesService;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -166,7 +170,74 @@ public class DiagnosesController extends JeecgController<Diagnoses, IDiagnosesSe
     */
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, Diagnoses.class);
+		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+		Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+		for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+			// 获取上传文件对象
+			MultipartFile file = entity.getValue();
+			ImportParams params = new ImportParams();
+			params.setTitleRows(2);
+			params.setHeadRows(1);
+			params.setNeedSave(true);
+			try {
+				List<Diagnoses> list = ExcelImportUtil.importExcel(file.getInputStream(), Diagnoses.class, params);
+				List<Diagnoses> resultData = new ArrayList<>();
+				//临时
+				List<Diagnoses> tempData = new ArrayList<>();
+				boolean flag = false;
+				//倒入的结果集
+				for (int i = 0; i < list.size(); i++) {
+					Diagnoses vo = new Diagnoses();
+					if (oConvertUtils.isEmpty(list.get(i).getClassifiCode())) {
+						if (oConvertUtils.isNotEmpty(list.get(i).getDiagnoseCode())) {
+							flag = true;
+							for (Diagnoses vob : tempData) {
+								Diagnoses vo2 = new Diagnoses();
+								vo2.setClassifiName(vob.getClassifiName());
+								vo2.setClassifiCode(vob.getClassifiCode());
+								vo2.setDiagnoseCode(list.get(i).getDiagnoseCode());
+								vo2.setDiagnosticName(list.get(i).getDiagnosticName());
+								resultData.add(vo2);
+							}
+						}
+						continue;
+					}
+					if (flag) {
+						tempData.clear();
+						flag = false;
+					}
+					vo.setClassifiCode(list.get(i).getClassifiCode());
+					vo.setClassifiName(list.get(i).getClassifiName());
+					tempData.add(vo);
+				}
+
+				//update-begin-author:taoyan date:20190528 for:批量插入数据
+				long start = System.currentTimeMillis();
+				service.saveBatch(resultData,1000);
+				//400条 saveBatch消耗时间1592毫秒  循环插入消耗时间1947毫秒
+				//1200条  saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
+				log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
+				//update-end-author:taoyan date:20190528 for:批量插入数据
+				return Result.ok("文件导入成功!数据行数:" + resultData.size());
+			} catch (Exception e) {
+				//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
+				String msg = e.getMessage();
+				log.error(msg, e);
+				if(msg!=null && msg.indexOf("Duplicate entry")>=0){
+					return Result.error("文件导入失败:有重复数据!");
+				}else{
+					return Result.error("文件导入失败:" + e.getMessage());
+				}
+				//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
+			} finally {
+				try {
+					file.getInputStream().close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		return Result.error("文件导入失败!");
     }
 
 }

+ 73 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/controller/OperativeController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.medical.controller;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -9,6 +10,8 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
+import org.apache.poi.ss.formula.functions.T;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
@@ -166,7 +169,75 @@ public class OperativeController extends JeecgController<Operative, IOperativeSe
     */
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, Operative.class);
-    }
+		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+		Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+		for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+			// 获取上传文件对象
+			MultipartFile file = entity.getValue();
+			ImportParams params = new ImportParams();
+			params.setTitleRows(2);
+			params.setHeadRows(1);
+			params.setNeedSave(true);
+			try {
+				List<Operative> list = ExcelImportUtil.importExcel(file.getInputStream(), Operative.class, params);
+				List<Operative> resultData = new ArrayList<>();
+				//临时
+				List<Operative> tempData = new ArrayList<>();
+				boolean flag = false;
+				//倒入的结果集
+				for (int i = 0; i < list.size(); i++) {
+					Operative vo = new Operative();
+					if (oConvertUtils.isEmpty(list.get(i).getClassifiCode())) {
+						if (oConvertUtils.isNotEmpty(list.get(i).getOperCode())) {
+							flag = true;
+							for (Operative vob : tempData) {
+								Operative vo2 = new Operative();
+								vo2.setClassifiName(vob.getClassifiName());
+								vo2.setClassifiCode(vob.getClassifiCode());
+								vo2.setOperCode(list.get(i).getOperCode());
+								vo2.setOperName(list.get(i).getOperName());
+								resultData.add(vo2);
+							}
+						}
+						continue;
+					}
+					if (flag) {
+						tempData.clear();
+						flag = false;
+					}
+					vo.setClassifiCode(list.get(i).getClassifiCode());
+					vo.setClassifiName(list.get(i).getClassifiName());
+					tempData.add(vo);
+				}
+
+
+				//update-begin-author:taoyan date:20190528 for:批量插入数据
+				long start = System.currentTimeMillis();
+				service.saveBatch(resultData,1000);
+				//400条 saveBatch消耗时间1592毫秒  循环插入消耗时间1947毫秒
+				//1200条  saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
+				log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
+				//update-end-author:taoyan date:20190528 for:批量插入数据
+				return Result.ok("文件导入成功!数据行数:" + resultData.size());
+			} catch (Exception e) {
+				//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
+				String msg = e.getMessage();
+				log.error(msg, e);
+				if(msg!=null && msg.indexOf("Duplicate entry")>=0){
+					return Result.error("文件导入失败:有重复数据!");
+				}else{
+					return Result.error("文件导入失败:" + e.getMessage());
+				}
+				//update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
+			} finally {
+				try {
+					file.getInputStream().close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		return Result.error("文件导入失败!");
+     }
 
 }

+ 71 - 46
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/DiagnosisTreatment.java

@@ -36,84 +36,105 @@ public class DiagnosisTreatment implements Serializable {
 	@TableId(type = IdType.ASSIGN_ID)
     @ApiModelProperty(value = "主键ID")
     private java.lang.Integer id;
-    /**国家编码*/
-    @Excel(name = "国家编码", width = 15)
-    @ApiModelProperty(value = "国家编码")
-    private java.lang.String countryCode;
     /**计算机编码*/
     @Excel(name = "计算机编码", width = 15)
     @ApiModelProperty(value = "计算机编码")
     private java.lang.String computerCode;
-    /**财务编码*/
-    @Excel(name = "财务编码", width = 15)
-    @ApiModelProperty(value = "财务编码")
-    private java.lang.String financeCode;
+    /**项目编码*/
+    @Excel(name = "项目编码", width = 15)
+    @ApiModelProperty(value = "项目编码")
+    private java.lang.String projectCode;
     /**财务项目*/
     @Excel(name = "财务项目", width = 15)
     @ApiModelProperty(value = "财务项目")
     private java.lang.String financeItem;
-    /**医保属性*/
-    @Excel(name = "医保属性", width = 15)
-    @ApiModelProperty(value = "医保属性")
-    private java.lang.String medicalAttribute;
-    /**先行自付比例*/
-    @Excel(name = "先行自付比例", width = 15)
-    @ApiModelProperty(value = "先行自付比例")
-    private java.lang.String pTypePct;
-	/**病案项目*/
-	@Excel(name = "病案项目", width = 15)
+    /**财务编码*/
+    @Excel(name = "财务编码", width = 15)
+    @ApiModelProperty(value = "财务编码")
+    private java.lang.String financeCode;
+    /**病案项目*/
+    @Excel(name = "病案项目", width = 15)
     @ApiModelProperty(value = "病案项目")
     private java.lang.String medicalItem;
-	/**病案编码*/
-	@Excel(name = "病案编码", width = 15)
+    /**病案编码*/
+    @Excel(name = "病案编码", width = 15)
     @ApiModelProperty(value = "病案编码")
     private java.lang.String medicalCode;
-	/**项目编码*/
-	@Excel(name = "项目编码", width = 15)
-    @ApiModelProperty(value = "项目编码")
-    private java.lang.String projectCode;
-	/**项目名称*/
-	@Excel(name = "项目名称", width = 15)
+    /**项目名称*/
+    @Excel(name = "项目名称", width = 15)
     @ApiModelProperty(value = "项目名称")
     private java.lang.String projectName;
-	/**项目内涵*/
-	@Excel(name = "项目内涵", width = 15)
+    /**项目内涵*/
+    @Excel(name = "项目内涵", width = 15)
     @ApiModelProperty(value = "项目内涵")
     private java.lang.String projectConnotation;
-
-    @Excel(name = "单价", width = 15)
-    @ApiModelProperty(value = "单价")
-    private BigDecimal price;
-
-	/**除外内容*/
-	@Excel(name = "除外内容", width = 15)
+    /**除外内容*/
+    @Excel(name = "除外内容", width = 15)
     @ApiModelProperty(value = "除外内容")
     private java.lang.String excluedContent;
-	/**计价单位*/
-	@Excel(name = "计价单位", width = 15)
+    /**计价单位*/
+    @Excel(name = "计价单位", width = 15)
     @ApiModelProperty(value = "计价单位")
     private java.lang.String unitAccount;
     /**市级价格*/
     @Excel(name = "市级价格", width = 15)
     @ApiModelProperty(value = "市级价格")
     private java.math.BigDecimal cityPrice;
-	/**县级价格*/
-	@Excel(name = "县级价格", width = 15)
+    /**县级价格*/
+    @Excel(name = "县级价格", width = 15)
     @ApiModelProperty(value = "县级价格")
     private java.math.BigDecimal countyPrice;
-
-	/**基层价格*/
-	@Excel(name = "基层价格", width = 15)
+    /**基层价格*/
+    @Excel(name = "基层价格", width = 15)
     @ApiModelProperty(value = "基层价格")
     private java.math.BigDecimal grassrootsPrice;
-	/**说明*/
-	@Excel(name = "说明", width = 15)
+    /**说明*/
+    @Excel(name = "说明", width = 15)
     @ApiModelProperty(value = "说明")
     private java.lang.String description;
-	/**限制范围*/
-	@Excel(name = "限制范围", width = 15)
+    /**医保属性*/
+    @Excel(name = "医保属性", width = 15)
+    @ApiModelProperty(value = "医保属性")
+    private java.lang.String medicalAttribute;
+    /**先行自付比例*/
+    @Excel(name = "先行自付比例", width = 15)
+    @ApiModelProperty(value = "先行自付比例")
+    private java.lang.String pTypePct;
+    /**限制范围*/
+    @Excel(name = "限制范围", width = 15)
     @ApiModelProperty(value = "限制范围")
     private java.lang.String limitRange;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    @Excel(name = "单价", width = 15)
+    @ApiModelProperty(value = "单价")
+    private BigDecimal price;
+
+
+
+
+
+
 	/**执行日期*/
 	@Excel(name = "执行日期", width = 15, format =  "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(timezone = "GMT+8",pattern =  "yyyy-MM-dd HH:mm:ss")
@@ -148,4 +169,8 @@ public class DiagnosisTreatment implements Serializable {
     @DateTimeFormat(pattern= "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "更新时间")
     private java.util.Date updateTime;
+    /**国家编码*/
+    @Excel(name = "国家编码", width = 15)
+    @ApiModelProperty(value = "国家编码")
+    private java.lang.String countryCode;
 }