ソースを参照

Merge remote-tracking branch 'origin/master'

lenovodn 2 年 前
コミット
36aa42bf37

+ 129 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/common/ExcelImportUtilService.java

@@ -0,0 +1,129 @@
+package org.jeecg.modules.medical.common;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.medical.common.interfaces.BiFunction;
+import org.jeecg.modules.medical.entity.MedicalInsuranceDrugs;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ * @author soft01
+ * @time 2023/5/14 14:28
+ * @description 'Excel导入工具前置操作'
+ * @parentProject medical-java
+ */
+@Slf4j
+@Transactional(readOnly = true)
+@Component
+public class ExcelImportUtilService {
+
+    /**
+     *
+     * @param request
+     * @param clazz
+     * @param duplicateRm 去重因子
+     * @param dbExistsListService 根据要导入的数据,查询当前库里是否有已存在
+     * @param extractUnion 取出并集,交集(用于更新) T参数为import,U参数为数据库已有的参数
+     * @param extractDiffSet 取出差集,用于新增 T参数为import,U参数为数据库已有的参数
+     * @param updateService 更新服务
+     * @param insertService 新增服务
+     * @return
+     * @param <T>
+     */
+    @Transactional(readOnly = false)
+    public <T extends Serializable> Result<?>  importExcel(HttpServletRequest request, Class<T> clazz,
+                                                           Function<T, String> duplicateRm,
+                                                           BiFunction<List<T>, List<T>> dbExistsListService,
+                                                           com.alibaba.fastjson.util.BiFunction<List<T>,List<T>, List<T>> extractUnion,
+                                                           com.alibaba.fastjson.util.BiFunction<List<T>, List<T>, List<T>> extractDiffSet,
+                                                           com.alibaba.fastjson.util.BiFunction<List<T>, Integer,Boolean> updateService,
+                                                           com.alibaba.fastjson.util.BiFunction<List<T>, Integer,Boolean> insertService
+                                                           ) {
+        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<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
+                if (CollectionUtils.isEmpty(list)) {
+                    return Result.error("文件导入失败:没有找到要导入的数据!");
+                }
+                if (list.size() > 10000) {
+                    return Result.error("文件导入失败:不可一次性导入超过10000条数据!");
+                }
+                // 去重
+                list = list.stream().collect(
+                        Collectors.collectingAndThen(
+                                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(
+                                        duplicateRm
+                                ))), ArrayList::new
+                        )
+                );
+                //检查是否有更新的数据,根据医保药品编码
+                List<T> dbExistsList = dbExistsListService.apply(list);
+                // 更新列表
+                List<T> updateList = new ArrayList<>();
+                // 新增列表
+                List<T> instalList = list;
+                if (!CollectionUtils.isEmpty(dbExistsList)) { // 不为空时, 需要将存在的做更新操作
+                    // 取出交集
+                    updateList = extractUnion.apply(list,dbExistsList);
+                    // 如果有则需要更新
+                    if (!CollectionUtils.isEmpty(updateList)) {
+//                        this.updateBatchById(updateList, 500);
+                        updateService.apply(updateList, 500);
+                    }
+                    // 取出差集
+                    instalList = extractDiffSet.apply(list, dbExistsList);
+                }
+                //update-begin-author:taoyan date:20190528 for:批量插入数据
+                long start = System.currentTimeMillis();
+                if (!CollectionUtils.isEmpty(instalList)) {
+//                    this.saveBatch(instalList, 500);
+                    insertService.apply(instalList, 500);
+                }
+
+                //400条 saveBatch消耗时间1592毫秒  循环插入消耗时间1947毫秒
+                //1200条  saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
+                log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
+                //update-end-author:taoyan date:20190528 for:批量插入数据
+                return Result.ok("文件导入成功!数据行数:" + list.size());
+            } catch (Exception e) {
+                //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
+                String msg = e.getMessage();
+                log.error(msg, e);
+                if(msg!=null && msg.contains("Duplicate entry")){
+                    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("文件导入失败!");
+    }
+}

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/common/interfaces/BiFunction.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.medical.common.interfaces;
+
+/**
+ * @author Scott
+ * @apiNote  提供一个函数式接口,方便单个参数,单个返回的方法参数传递
+ * @param <T>
+ * @param <R>
+ */
+@FunctionalInterface
+public interface BiFunction<T, R> {
+
+    R apply(T t);
+}

+ 10 - 9
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/controller/TreatmentItemsController.java

@@ -50,7 +50,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
 public class TreatmentItemsController extends JeecgController<TreatmentItems, ITreatmentItemsService> {
 	@Autowired
 	private ITreatmentItemsService treatmentItemsService;
-	
+
 	/**
 	 * 分页列表查询
 	 *
@@ -72,7 +72,7 @@ public class TreatmentItemsController extends JeecgController<TreatmentItems, IT
 		IPage<TreatmentItems> pageList = treatmentItemsService.page(page, queryWrapper);
 		return Result.OK(pageList);
 	}
-	
+
 	/**
 	 *   添加
 	 *
@@ -87,7 +87,7 @@ public class TreatmentItemsController extends JeecgController<TreatmentItems, IT
 		treatmentItemsService.save(treatmentItems);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -102,7 +102,7 @@ public class TreatmentItemsController extends JeecgController<TreatmentItems, IT
 		treatmentItemsService.updateById(treatmentItems);
 		return Result.OK("编辑成功!");
 	}
-	
+
 	/**
 	 *   通过id删除
 	 *
@@ -117,7 +117,7 @@ public class TreatmentItemsController extends JeecgController<TreatmentItems, IT
 		treatmentItemsService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
 	/**
 	 *  批量删除
 	 *
@@ -132,7 +132,7 @@ public class TreatmentItemsController extends JeecgController<TreatmentItems, IT
 		this.treatmentItemsService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("批量删除成功!");
 	}
-	
+
 	/**
 	 * 通过id查询
 	 *
@@ -156,7 +156,7 @@ public class TreatmentItemsController extends JeecgController<TreatmentItems, IT
     * @param request
     * @param treatmentItems
     */
-    @RequiresPermissions("medical:treatment_items:exportXls")
+//    @RequiresPermissions("medical:treatment_items:exportXls")
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, TreatmentItems treatmentItems) {
         return super.exportXls(request, treatmentItems, TreatmentItems.class, "treatment_items");
@@ -169,10 +169,11 @@ public class TreatmentItemsController extends JeecgController<TreatmentItems, IT
     * @param response
     * @return
     */
-    @RequiresPermissions("medical:treatment_items:importExcel")
+//    @RequiresPermissions("medical:treatment_items:importExcel")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, TreatmentItems.class);
+//        return super.importExcel(request, response, TreatmentItems.class);
+		return treatmentItemsService.importExcel(request, response);
     }
 
 }

+ 31 - 23
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/TreatmentItems.java

@@ -32,21 +32,25 @@ import lombok.experimental.Accessors;
 public class TreatmentItems implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+
 	/**医保项目编码;医保诊疗目录编码*/
-	@Excel(name = "医保项目编码;医保诊疗目录编码", width = 15)
-    @ApiModelProperty(value = "医保项目编码;医保诊疗目录编码")
+	@Excel(name = "医保项目编码", width = 15)
+    @ApiModelProperty(value = "医保项目编码")
     private java.lang.String itemId;
 	/**医保项目名称;医保诊疗目录名称*/
-	@Excel(name = "医保项目名称;医保诊疗目录名称", width = 15)
-    @ApiModelProperty(value = "医保项目名称;医保诊疗目录名称")
+	@Excel(name = "医保项目名称", width = 15)
+    @ApiModelProperty(value = "医保项目名称")
     private java.lang.String itemName;
 	/**医院项目编码;医嘱系统中项目的代码*/
-	@Excel(name = "医院项目编码;医嘱系统中项目的代码", width = 15)
-    @ApiModelProperty(value = "医院项目编码;医嘱系统中项目的代码")
+	@Excel(name = "医院项目编码", width = 15)
+    @ApiModelProperty(value = "医院项目编码")
     private java.lang.String itemIdHosp;
 	/**医院项目名称;医嘱系统中项目的名称*/
-	@Excel(name = "医院项目名称;医嘱系统中项目的名称", width = 15)
-    @ApiModelProperty(value = "医院项目名称;医嘱系统中项目的名称")
+	@Excel(name = "医院项目名称", width = 15)
+    @ApiModelProperty(value = "医院项目名称")
     private java.lang.String itemNameHosp;
 	/**医保项目内涵*/
 	@Excel(name = "医保项目内涵", width = 15)
@@ -57,31 +61,35 @@ public class TreatmentItems implements Serializable {
     @ApiModelProperty(value = "医保目录除外内容")
     private java.lang.String excludedMedical;
 	/**支付类别;指甲、乙、丙类*/
-	@Excel(name = "支付类别;指甲、乙、丙类", width = 15)
-    @ApiModelProperty(value = "支付类别;指甲、乙、丙类")
+	@Excel(name = "支付类别", width = 15)
+    @ApiModelProperty(value = "支付类别")
     private java.lang.String pCategory;
+
+    @Excel(name = "支付比例", width = 15)
+    @ApiModelProperty(value = "支付比例")
+    private String percentagePayment;
 	/**自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)*/
-	@Excel(name = "自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)", width = 15)
-    @ApiModelProperty(value = "自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)")
+	@Excel(name = "自付比例", width = 15)
+    @ApiModelProperty(value = "自付比例")
     private java.lang.String pTypePct;
 	/**备注*/
 	@Excel(name = "备注", width = 15)
     @ApiModelProperty(value = "备注")
     private java.lang.String remarks;
 	/**最高限价;物价规定的最高限价*/
-	@Excel(name = "最高限价;物价规定的最高限价", width = 15)
+	@Excel(name = "最高限价", width = 15)
     @ApiModelProperty(value = "最高限价;物价规定的最高限价")
     private java.math.BigDecimal cellingPrice;
 	/**三级医院最高价格;或其他定价规则体现下的最高级别定价*/
-	@Excel(name = "三级医院最高价格;或其他定价规则体现下的最高级别定价", width = 15)
-    @ApiModelProperty(value = "三级医院最高价格;或其他定价规则体现下的最高级别定价")
+	@Excel(name = "三级医院最高价格", width = 15)
+    @ApiModelProperty(value = "三级医院最高价格")
     private java.math.BigDecimal tertiaryHospPrice;
 	/**二级医院最高价格;或其他定价规则体现下的第二级别定价*/
-	@Excel(name = "二级医院最高价格;或其他定价规则体现下的第二级别定价", width = 15)
+	@Excel(name = "二级医院最高价格", width = 15)
     @ApiModelProperty(value = "二级医院最高价格;或其他定价规则体现下的第二级别定价")
     private java.math.BigDecimal twoHospPrice;
 	/**一级医院最高价格;或其他定价规则体现下的第三级别定价*/
-	@Excel(name = "一级医院最高价格;或其他定价规则体现下的第三级别定价", width = 15)
+	@Excel(name = "一级医院最高价格", width = 15)
     @ApiModelProperty(value = "一级医院最高价格;或其他定价规则体现下的第三级别定价")
     private java.math.BigDecimal oneHospPrice;
 	/**离休价格*/
@@ -89,16 +97,16 @@ public class TreatmentItems implements Serializable {
     @ApiModelProperty(value = "离休价格")
     private java.math.BigDecimal retirementPrice;
 	/**门诊自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)*/
-	@Excel(name = "门诊自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)", width = 15)
+	@Excel(name = "门诊自付比例", width = 15)
     @ApiModelProperty(value = "门诊自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)")
     private java.lang.String outpatientPPayRate;
 	/**住院自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)*/
-	@Excel(name = "住院自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)", width = 15)
+	@Excel(name = "住院自付比例", width = 15)
     @ApiModelProperty(value = "住院自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)")
     private java.lang.String hospPPayRate;
 	/**工伤自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)*/
-	@Excel(name = "工伤自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)", width = 15)
-    @ApiModelProperty(value = "工伤自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)")
+	@Excel(name = "工伤自付比例", width = 15)
+    @ApiModelProperty(value = "工伤自付比例")
     private java.lang.String injuryPPayRate;
 	/**创建时间;*/
 	@JsonFormat(timezone = "GMT+8",pattern =  "yyyy-MM-dd HH:mm:ss")
@@ -117,7 +125,7 @@ public class TreatmentItems implements Serializable {
     @ApiModelProperty(value = "创建人员;")
     private java.lang.String createBy;
 	/**生育自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)*/
-	@Excel(name = "生育自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)", width = 15)
-    @ApiModelProperty(value = "生育自付比例;甲类为100%,乙类根据当地实际情况(80%,70%),丙类(0%)")
+	@Excel(name = "生育自付比例", width = 15)
+    @ApiModelProperty(value = "生育自付比例")
     private java.lang.String procreationPPayRate;
 }

+ 42 - 31
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/ruleengine/FactorEnchangeFactory.java

@@ -84,17 +84,11 @@ public class FactorEnchangeFactory {
             if (null == factorEnchance) {
                 continue;
             }
-            LambdaQueryWrapper<FactorAttrRela> queryWrapper = new LambdaQueryWrapper();
-            queryWrapper.eq(FactorAttrRela::getFactorEnhanceId, factorEnchanceId);
-            queryWrapper.orderByAsc(FactorAttrRela::getSeqNum);
-            List<FactorAttrRela> factorAttrRelaList = factorAttrRelaService.list(queryWrapper);
-            Map<Integer, List<FactorAttrRela>> ioTypeMap = new HashMap<>();
-            if (CollectionUtil.isNotEmpty(factorAttrRelaList)) {
-                ioTypeMap = factorAttrRelaList.stream().collect(Collectors.groupingBy(FactorAttrRela::getIoType));
-            }
+
             EnchanceTypeEnum enchanceTypeEnum = EnchanceTypeEnum.getType(factorEnchanceId);
             switch (enchanceTypeEnum) {
                 case SQL:
+                    Map<Integer, List<FactorAttrRela>> ioTypeMap = getIoMap(factorEnchanceId);
                     setSqlResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
                     break;
                 case EXPRESSION:
@@ -104,14 +98,16 @@ public class FactorEnchangeFactory {
                     dictUtil.transferData(localMap, factorEnchance, medicalInfoRuleInfoId);
                     break;
                 case PLUGIN:
+                    Map<Integer, List<FactorAttrRela>> ioTypeMap1 = getIoMap(factorEnchanceId);
                     PluginInterface pluginInterface = (PluginInterface) SpringContextUtils.getBean(factorEnchance.getEnhanceValue());
-                    pluginInterface.plugin(localMap, ioTypeMap, factorEnchance, medicalInfoRuleInfoId);
+                    pluginInterface.plugin(localMap, ioTypeMap1, factorEnchance, medicalInfoRuleInfoId);
                     break;
                 case CONSTANT:
                     localMap.put(factorEnchance.getEventAttrId().toString(), factorEnchance.getExtAttr1());
                     break;
                 case LOGICAL_EXPRESSION:
-                    result = setLogicalExpressionResultByFactorEnchance(localMap, ioTypeMap, factorEnchance, medicalInsRuleInfo);
+//                    Map<Integer, List<FactorAttrRela>> ioTypeMap2 = getIoMap(factorEnchanceId);
+                    result = setLogicalExpressionResultByFactorEnchance(localMap,  factorEnchance);
                     if(Constant.WARING_EVENT_ATTR_ID == factorEnchance.getEventAttrId()){
                         if(result){
                             insertMidWarningDetail(localMap, medicalInsRuleInfo, midIncidentAudit);
@@ -136,6 +132,18 @@ public class FactorEnchangeFactory {
         return result;
     }
 
+    public Map<Integer, List<FactorAttrRela>> getIoMap(Integer factorEnchanceId){
+        LambdaQueryWrapper<FactorAttrRela> queryWrapper = new LambdaQueryWrapper();
+        queryWrapper.eq(FactorAttrRela::getFactorEnhanceId, factorEnchanceId);
+        queryWrapper.orderByAsc(FactorAttrRela::getSeqNum);
+        List<FactorAttrRela> factorAttrRelaList = factorAttrRelaService.list(queryWrapper);
+        Map<Integer, List<FactorAttrRela>> ioTypeMap = new HashMap<>();
+        if (CollectionUtil.isNotEmpty(factorAttrRelaList)) {
+            ioTypeMap = factorAttrRelaList.stream().collect(Collectors.groupingBy(FactorAttrRela::getIoType));
+        }
+        return ioTypeMap;
+    }
+
     public void insertMidWarningDetail(Map<String,Object> itemMap, MedicalInsRuleInfo medicalInsRuleInfo,MidIncidentAudit midIncidentAudit){
         MidIncidentWarningVO midIncidentWarningVO = RuleEngine.midIncidentWarningVOThreadLocal.get();
         MidIncidentAuditDetail midIncidentAuditDetail = new MidIncidentAuditDetail();
@@ -173,33 +181,36 @@ public class FactorEnchangeFactory {
      * 逻辑表达式
      *
      * @param localMap
-     * @param ioTypeMap
      * @param factorEnchance
-     * @param medicalInsRuleInfo
      */
-    public boolean setLogicalExpressionResultByFactorEnchance(Map<String, Object> localMap, Map<Integer, List<FactorAttrRela>> ioTypeMap, FactorEnchance factorEnchance, MedicalInsRuleInfo medicalInsRuleInfo) {
-        List<FactorCondRela> factorCondRelaList = factorCondRelaMap.get(factorEnchance.getId());
-        if (CollectionUtil.isNotEmpty(factorCondRelaList)) {
-            Boolean result = null;
-            if (Constant.AND.equals(factorEnchance.getExtAttr1())) {
-                result = true;
-            } else {
-                result = false;
-            }
-            for (FactorCondRela factorCondRela : factorCondRelaList) {
-                if (!StringUtils.isNotBlank(factorCondRela.getCondStr())) {
-                    log.error("未正常生成表达式");
-                    String condStr = spelUtil.getSPELString(factorCondRela, enchanceAttrMap);
-                    factorCondRela.setCondStr(condStr);
-                }
-                Boolean resultTemp = (Boolean) spelUtil.runSpelExpression(localMap, factorCondRela.getCondStr());
+    public boolean setLogicalExpressionResultByFactorEnchance(Map<String, Object> localMap, FactorEnchance factorEnchance) {
+        if(StringUtils.isNotBlank(factorEnchance.getEnhanceValue())){
+            Boolean resultTemp = (Boolean) spelUtil.runSpelExpression(localMap, factorEnchance.getEnhanceValue());
+            return resultTemp;
+        }else {
+            List<FactorCondRela> factorCondRelaList = factorCondRelaMap.get(factorEnchance.getId());
+            if (CollectionUtil.isNotEmpty(factorCondRelaList)) {
+                Boolean result = null;
                 if (Constant.AND.equals(factorEnchance.getExtAttr1())) {
-                    result = resultTemp && result;
+                    result = true;
                 } else {
-                    result = resultTemp || result;
+                    result = false;
+                }
+                for (FactorCondRela factorCondRela : factorCondRelaList) {
+                    if (!StringUtils.isNotBlank(factorCondRela.getCondStr())) {
+                        log.error("未正常生成表达式");
+                        String condStr = spelUtil.getSPELString(factorCondRela, enchanceAttrMap);
+                        factorCondRela.setCondStr(condStr);
+                    }
+                    Boolean resultTemp = (Boolean) spelUtil.runSpelExpression(localMap, factorCondRela.getCondStr());
+                    if (Constant.AND.equals(factorEnchance.getExtAttr1())) {
+                        result = resultTemp && result;
+                    } else {
+                        result = resultTemp || result;
+                    }
                 }
+                return result;
             }
-            return result;
         }
 
         return false;

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/ITreatmentItemsService.java

@@ -1,8 +1,12 @@
 package org.jeecg.modules.medical.service;
 
+import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.medical.entity.TreatmentItems;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * @Description: treatment_items
  * @Author: jeecg-boot
@@ -11,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ITreatmentItemsService extends IService<TreatmentItems> {
 
+    Result<?> importExcel(HttpServletRequest request, HttpServletResponse response);
 }

+ 36 - 6
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/impl/MedicalInsuranceDrugsServiceImpl.java

@@ -2,17 +2,19 @@ package org.jeecg.modules.medical.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.math3.geometry.partitioning.BSPTree;
+import org.checkerframework.checker.nullness.qual.Nullable;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.medical.common.ExcelImportUtilService;
+import org.jeecg.modules.medical.common.interfaces.BiFunction;
 import org.jeecg.modules.medical.entity.MedicalInsuranceDrugs;
 import org.jeecg.modules.medical.mapper.MedicalInsuranceDrugsMapper;
 import org.jeecg.modules.medical.service.IMedicalInsuranceDrugsService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
@@ -21,9 +23,9 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.transaction.TransactionScoped;
 import java.io.IOException;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -37,9 +39,38 @@ import java.util.stream.Collectors;
 @Service
 public class MedicalInsuranceDrugsServiceImpl extends ServiceImpl<MedicalInsuranceDrugsMapper, MedicalInsuranceDrugs> implements IMedicalInsuranceDrugsService {
 
+    @Autowired
+    private ExcelImportUtilService excelImportUtilService;
+
     @Transactional(readOnly = false)
     @Override
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        excelImportUtilService.importExcel(request, MedicalInsuranceDrugs.class,
+                // 根据什么字段去重
+                MedicalInsuranceDrugs::getMedicineCode,
+                // 根据导入数据,查询哪些在数据库中已经有了
+                list -> {
+                    List<String> collect = list.stream().map(MedicalInsuranceDrugs::getMedicineCode).collect(Collectors.toList());
+                    return listByMedicineCodeIn(collect);
+                },
+                // 根据导入数据,和数据库中的数据,取出交集 用于更新
+                (list, dbExistsList) -> list.stream().filter(
+                        a -> dbExistsList.stream().map(MedicalInsuranceDrugs::getMedicineCode)
+                                .anyMatch(
+                                        medicineCode -> ObjectUtils.nullSafeEquals(a.getMedicineCode(), medicineCode)
+                                )
+                ).collect(Collectors.toList()),
+                // 根据导入数据,和数据库中的数据,取出差集 用于新增
+                (list, dbExistsList) -> list.stream().filter(
+                        excelData -> dbExistsList.stream().map(MedicalInsuranceDrugs::getMedicineCode).noneMatch(medicineCode ->
+                                ObjectUtils.nullSafeEquals(excelData.getMedicineCode(), medicineCode))
+                ).collect(Collectors.toList()),
+                this::updateBatchById,
+                this::saveBatch
+        );
+        /*if (1 == 1) {
+            return null;
+        }
         MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
         Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
         for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
@@ -63,7 +94,6 @@ public class MedicalInsuranceDrugsServiceImpl extends ServiceImpl<MedicalInsuran
                                 Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MedicalInsuranceDrugs::getMedicineCode))), ArrayList::new
                         )
                 );
-
                 //检查是否有更新的数据,根据医保药品编码
                 List<String> collect = list.stream().map(MedicalInsuranceDrugs::getMedicineCode).collect(Collectors.toList());
                 List<MedicalInsuranceDrugs> dbExistsList = this.listByMedicineCodeIn(collect);
@@ -117,7 +147,7 @@ public class MedicalInsuranceDrugsServiceImpl extends ServiceImpl<MedicalInsuran
                     e.printStackTrace();
                 }
             }
-        }
+        }*/
         return Result.error("文件导入失败!");
     }
 

+ 64 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/impl/TreatmentItemsServiceImpl.java

@@ -1,11 +1,23 @@
 package org.jeecg.modules.medical.service.impl;
 
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.medical.common.ExcelImportUtilService;
+import org.jeecg.modules.medical.common.interfaces.BiFunction;
+import org.jeecg.modules.medical.entity.MedicalInsuranceDrugs;
 import org.jeecg.modules.medical.entity.TreatmentItems;
 import org.jeecg.modules.medical.mapper.TreatmentItemsMapper;
 import org.jeecg.modules.medical.service.ITreatmentItemsService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @Description: treatment_items
@@ -13,7 +25,59 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  * @Date:   2023-04-23
  * @Version: V1.0
  */
+@Slf4j
+@Transactional
 @Service
 public class TreatmentItemsServiceImpl extends ServiceImpl<TreatmentItemsMapper, TreatmentItems> implements ITreatmentItemsService {
 
+    @Autowired
+    private ExcelImportUtilService excelImportUtilService;
+
+    @Override
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        excelImportUtilService.importExcel(request, TreatmentItems.class,
+                TreatmentItems::getItemId,
+                new BiFunction<List<TreatmentItems>, List<TreatmentItems>>() {
+                    @Override
+                    public List<TreatmentItems> apply(List<TreatmentItems> list) {
+                        List<String> collect = list.stream().map(TreatmentItems::getItemId).collect(Collectors.toList());
+                        return listByItemId(collect);
+                    }
+                },
+                new com.alibaba.fastjson.util.BiFunction<List<TreatmentItems>, List<TreatmentItems>, List<TreatmentItems>>() {
+                    @Override
+                    public List<TreatmentItems> apply(List<TreatmentItems> treatmentItems, List<TreatmentItems> treatmentItems2) {
+                        return null;
+                    }
+                },
+                new com.alibaba.fastjson.util.BiFunction<List<TreatmentItems>, List<TreatmentItems>, List<TreatmentItems>>() {
+                    @Override
+                    public List<TreatmentItems> apply(List<TreatmentItems> treatmentItems, List<TreatmentItems> treatmentItems2) {
+                        return null;
+                    }
+                },
+                new com.alibaba.fastjson.util.BiFunction<List<TreatmentItems>, Integer, Boolean>() {
+                    @Override
+                    public Boolean apply(List<TreatmentItems> treatmentItems, Integer integer) {
+                        return null;
+                    }
+                },
+                new com.alibaba.fastjson.util.BiFunction<List<TreatmentItems>, Integer, Boolean>() {
+                    @Override
+                    public Boolean apply(List<TreatmentItems> treatmentItems, Integer integer) {
+                        return null;
+                    }
+                }
+        );
+        return null;
+    }
+
+    /**
+     * 根据医保项目编码,获取数据库中以后的内容
+     * @param itemIds 医保项目编码
+     * @return
+     */
+    private List<TreatmentItems> listByItemId(List<String> itemIds) {
+        return null;
+    }
 }

+ 1 - 1
jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml

@@ -185,7 +185,7 @@ jeecg:
     #webapp文件路径
     webapp: /Users/lanhongjie/Documents/temp/webapp
   shiro:
-    excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
+    excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/his/check/**
   #阿里云oss存储和大鱼短信秘钥配置
   oss:
     accessKey: ??