zhaops 4 éve
szülő
commit
16c9b0517a

+ 50 - 68
src/main/java/com/diagbot/facade/DiseaseConfigFacade.java

@@ -100,41 +100,59 @@ public class DiseaseConfigFacade {
      * @return
      */
     public Boolean saveOrUpdateRecords(DiseaseConfigListVO diseaseConfigListVO) {
+        if (ListUtil.isEmpty(diseaseConfigListVO.getDiseaseConfigList())) {
+            return false;
+        }
+        return saveOrUpdateRecords(diseaseConfigListVO.getDiseaseConfigList());
+    }
+
+    /**
+     * 批量保存
+     *
+     * @param diseaseConfigList
+     * @return
+     */
+    public Boolean saveOrUpdateRecords(List<DiseaseConfig> diseaseConfigList) {
+        if (ListUtil.isEmpty(diseaseConfigList)) {
+            return false;
+        }
         String hospitalId = SysUserUtils.getCurrentHospitalID();
         String userId = SysUserUtils.getCurrentPrincipleID();
         Date now = DateUtil.now();
-        //id为空且已存在的映射关系先删除
-        List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
-                = getConfigMap(Long.valueOf(hospitalId), null, null);
-        if (ListUtil.isNotEmpty(diseaseConfigListVO.getDiseaseConfigList())) {
-            diseaseConfigListVO.getDiseaseConfigList().forEach(diseaseConfig -> {
-                diseaseConfig.setHospitalId(Long.valueOf(hospitalId));
-                diseaseConfig.setModifier(userId);
-                diseaseConfig.setGmtModified(now);
-                if (diseaseConfig.getId() == null) {
-                    if (configMap.get(diseaseConfig.getHisName()) != null
-                            && configMap.get(diseaseConfig.getHisName()).containsKey(diseaseConfig.getUniqueName())) {
-                        deleteIds.add(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
-                    }
-                    diseaseConfig.setCreator(userId);
-                    diseaseConfig.setGmtCreate(now);
-                }
-                if (diseaseConfig.getIsDeleted() == null) {
-                    diseaseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-                }
-            });
-            IdListVO idListVO = new IdListVO();
-            idListVO.setIds(deleteIds);
-            deleteRecords(idListVO);
-        }
+
         //数据不完整的不保存
-        List<DiseaseConfig> records = diseaseConfigListVO.getDiseaseConfigList()
+        //过滤外部名称或公表名为空的数据
+        diseaseConfigList = diseaseConfigList
                 .stream()
                 .filter(i -> StringUtil.isNotBlank(i.getHisName()))
                 .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
                 .collect(Collectors.toList());
-        diseaseConfigService.saveOrUpdateBatch(records);
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        List<Long> deleteIds = Lists.newLinkedList();
+        Map<String, Map<String, Long>> configMap
+                = getConfigMap(Long.valueOf(hospitalId), null, null);
+        diseaseConfigList.forEach(diseaseConfig -> {
+            diseaseConfig.setHospitalId(Long.valueOf(hospitalId));
+            diseaseConfig.setModifier(userId);
+            diseaseConfig.setGmtModified(now);
+            if (diseaseConfig.getId() == null) {
+                if (configMap.containsKey(diseaseConfig.getHisName())) {
+                    deleteIds.add(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
+                }
+                diseaseConfig.setCreator(userId);
+                diseaseConfig.setGmtCreate(now);
+            }
+            if (diseaseConfig.getIsDeleted() == null) {
+                diseaseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            }
+        });
+        //删除已存在映射关系
+        IdListVO idListVO = new IdListVO();
+        idListVO.setIds(deleteIds);
+        deleteRecords(idListVO);
+        diseaseConfigService.saveOrUpdateBatch(diseaseConfigList);
         return true;
     }
 
@@ -148,7 +166,7 @@ public class DiseaseConfigFacade {
         UpdateWrapper<DiseaseConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("id", idVO.getId())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        diseaseConfigService.update(updateWrapper);
+        diseaseConfigService.removeById(idVO.getId());
         return true;
     }
 
@@ -165,7 +183,7 @@ public class DiseaseConfigFacade {
         UpdateWrapper<DiseaseConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.in("id", idListVO.getIds())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        diseaseConfigService.update(updateWrapper);
+        diseaseConfigService.removeByIds(idListVO.getIds());
         return true;
     }
 
@@ -182,50 +200,14 @@ public class DiseaseConfigFacade {
     }
 
     /**
-     * 化验数据导入
+     * 数据导入
      *
      * @param file
      */
     public void importExcel(MultipartFile file) {
-        String hospitalId = SysUserUtils.getCurrentHospitalID();
-        String userId = SysUserUtils.getCurrentPrincipleID();
-        Date now = DateUtil.now();
         List<DiseaseConfig> diseaseConfigList = ExcelUtils.importExcel(file, 0, 1, DiseaseConfig.class);
         if (ListUtil.isNotEmpty(diseaseConfigList)) {
-            //过滤不完整数据
-            diseaseConfigList = diseaseConfigList
-                    .stream()
-                    .filter(i -> StringUtil.isNotBlank(i.getHisName()))
-                    .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
-                    .collect(Collectors.toList());
-            //验证数据是否已存在
-            List<Long> deleteIds = Lists.newArrayList();
-            Map<String, Map<String, Long>> configMap = getConfigMap(Long.valueOf(hospitalId), null, null);
-            diseaseConfigList.forEach(diseaseConfig -> {
-                if (configMap.get(diseaseConfig.getHisName()) != null
-                        && configMap.get(diseaseConfig.getHisName()).containsKey(diseaseConfig.getUniqueName())) {
-                    deleteIds.add(configMap.get(diseaseConfig.getHisName()).get(diseaseConfig.getUniqueName()));
-                }
-            });
-            //删除已存在的映射关系
-            if (ListUtil.isNotEmpty(deleteIds)) {
-                IdListVO idListVO = new IdListVO();
-                idListVO.setIds(deleteIds);
-                deleteRecords(idListVO);
-            }
-
-            //保存数据
-            diseaseConfigList.forEach(diseaseConfig -> {
-                diseaseConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-                diseaseConfig.setHospitalId(Long.valueOf(hospitalId));
-                if (diseaseConfig.getId() == null) {
-                    diseaseConfig.setCreator(userId);
-                    diseaseConfig.setGmtCreate(now);
-                }
-                diseaseConfig.setModifier(userId);
-                diseaseConfig.setGmtModified(now);
-            });
-            diseaseConfigService.saveOrUpdateBatch(diseaseConfigList);
+            saveOrUpdateRecords(diseaseConfigList);
         }
     }
 
@@ -274,4 +256,4 @@ public class DiseaseConfigFacade {
         String fileName = "疾病映射.xls";
         ExcelUtils.exportExcel(records, null, "sheet1", DiseaseConfig.class, fileName, response, 12.8f);
     }
-}
+}

+ 49 - 67
src/main/java/com/diagbot/facade/DrugConfigFacade.java

@@ -99,41 +99,59 @@ public class DrugConfigFacade {
      * @return
      */
     public Boolean saveOrUpdateRecords(DrugConfigListVO drugConfigListVO) {
+        if (ListUtil.isEmpty(drugConfigListVO.getDrugConfigList())) {
+            return false;
+        }
+        return saveOrUpdateRecords(drugConfigListVO.getDrugConfigList());
+    }
+
+    /**
+     * 批量保存
+     *
+     * @param drugConfigList
+     * @return
+     */
+    public Boolean saveOrUpdateRecords(List<DrugConfig> drugConfigList) {
+        if (ListUtil.isEmpty(drugConfigList)) {
+            return false;
+        }
         String hospitalId = SysUserUtils.getCurrentHospitalID();
         String userId = SysUserUtils.getCurrentPrincipleID();
         Date now = DateUtil.now();
-        //id为空且已存在的映射关系先删除
-        List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
-                = getConfigMap(Long.valueOf(hospitalId), null, null);
-        if (ListUtil.isNotEmpty(drugConfigListVO.getDrugConfigList())) {
-            drugConfigListVO.getDrugConfigList().forEach(drugConfig -> {
-                drugConfig.setHospitalId(Long.valueOf(hospitalId));
-                drugConfig.setModifier(userId);
-                drugConfig.setGmtModified(now);
-                if (drugConfig.getId() == null) {
-                    if (configMap.get(drugConfig.getHisName()) != null
-                            && configMap.get(drugConfig.getHisName()).containsKey(drugConfig.getUniqueName())) {
-                        deleteIds.add(configMap.get(drugConfig.getHisName()).get(drugConfig.getUniqueName()));
-                    }
-                    drugConfig.setCreator(userId);
-                    drugConfig.setGmtCreate(now);
-                }
-                if (drugConfig.getIsDeleted() == null) {
-                    drugConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-                }
-            });
-            IdListVO idListVO = new IdListVO();
-            idListVO.setIds(deleteIds);
-            deleteRecords(idListVO);
-        }
+
         //数据不完整的不保存
-        List<DrugConfig> records = drugConfigListVO.getDrugConfigList()
+        //过滤外部名称或公表名为空的数据
+        drugConfigList = drugConfigList
                 .stream()
                 .filter(i -> StringUtil.isNotBlank(i.getHisName()))
                 .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
                 .collect(Collectors.toList());
-        drugConfigService.saveOrUpdateBatch(records);
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        List<Long> deleteIds = Lists.newLinkedList();
+        Map<String, Map<String, Long>> configMap
+                = getConfigMap(Long.valueOf(hospitalId), null, null);
+        drugConfigList.forEach(drugConfig -> {
+            drugConfig.setHospitalId(Long.valueOf(hospitalId));
+            drugConfig.setModifier(userId);
+            drugConfig.setGmtModified(now);
+            if (drugConfig.getId() == null) {
+                if (configMap.containsKey(drugConfig.getHisName())) {
+                    deleteIds.add(configMap.get(drugConfig.getHisName()).get(drugConfig.getUniqueName()));
+                }
+                drugConfig.setCreator(userId);
+                drugConfig.setGmtCreate(now);
+            }
+            if (drugConfig.getIsDeleted() == null) {
+                drugConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            }
+        });
+        //删除已存在映射关系
+        IdListVO idListVO = new IdListVO();
+        idListVO.setIds(deleteIds);
+        deleteRecords(idListVO);
+        drugConfigService.saveOrUpdateBatch(drugConfigList);
         return true;
     }
 
@@ -147,7 +165,7 @@ public class DrugConfigFacade {
         UpdateWrapper<DrugConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("id", idVO.getId())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        drugConfigService.update(updateWrapper);
+        drugConfigService.removeById(idVO.getId());
         return true;
     }
 
@@ -164,7 +182,7 @@ public class DrugConfigFacade {
         UpdateWrapper<DrugConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.in("id", idListVO.getIds())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        drugConfigService.update(updateWrapper);
+        drugConfigService.removeByIds(idListVO.getIds());
         return true;
     }
 
@@ -181,50 +199,14 @@ public class DrugConfigFacade {
     }
 
     /**
-     * 化验数据导入
+     * 数据导入
      *
      * @param file
      */
     public void importExcel(MultipartFile file) {
-        String hospitalId = SysUserUtils.getCurrentHospitalID();
-        String userId = SysUserUtils.getCurrentPrincipleID();
-        Date now = DateUtil.now();
         List<DrugConfig> drugConfigList = ExcelUtils.importExcel(file, 0, 1, DrugConfig.class);
         if (ListUtil.isNotEmpty(drugConfigList)) {
-            //过滤不完整数据
-            drugConfigList = drugConfigList
-                    .stream()
-                    .filter(i -> StringUtil.isNotBlank(i.getHisName()))
-                    .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
-                    .collect(Collectors.toList());
-            //验证数据是否已存在
-            List<Long> deleteIds = Lists.newArrayList();
-            Map<String, Map<String, Long>> configMap = getConfigMap(Long.valueOf(hospitalId), null, null);
-            drugConfigList.forEach(drugConfig -> {
-                if (configMap.get(drugConfig.getHisName()) != null
-                        && configMap.get(drugConfig.getHisName()).containsKey(drugConfig.getUniqueName())) {
-                    deleteIds.add(configMap.get(drugConfig.getHisName()).get(drugConfig.getUniqueName()));
-                }
-            });
-            //删除已存在的映射关系
-            if (ListUtil.isNotEmpty(deleteIds)) {
-                IdListVO idListVO = new IdListVO();
-                idListVO.setIds(deleteIds);
-                deleteRecords(idListVO);
-            }
-
-            //保存数据
-            drugConfigList.forEach(drugConfig -> {
-                drugConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-                drugConfig.setHospitalId(Long.valueOf(hospitalId));
-                if (drugConfig.getId() == null) {
-                    drugConfig.setCreator(userId);
-                    drugConfig.setGmtCreate(now);
-                }
-                drugConfig.setModifier(userId);
-                drugConfig.setGmtModified(now);
-            });
-            drugConfigService.saveOrUpdateBatch(drugConfigList);
+            saveOrUpdateRecords(drugConfigList);
         }
     }
 

+ 7 - 10
src/main/java/com/diagbot/facade/LisConfigFacade.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.entity.LisConfig;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.service.LisConfigService;
-import com.diagbot.service.impl.LisConfigServiceImpl;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ExcelUtils;
@@ -19,7 +18,6 @@ import com.diagbot.vo.LisConfigListVO;
 import com.diagbot.vo.LisConfigPageVO;
 import com.google.common.collect.Lists;
 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;
 
@@ -36,9 +34,8 @@ import java.util.stream.Collectors;
  * @time: 2020/7/29 15:03
  */
 @Component
-public class LisConfigFacade extends LisConfigServiceImpl {
+public class LisConfigFacade{
     @Autowired
-    @Qualifier("lisConfigServiceImpl")
     private LisConfigService lisConfigService;
 
     /**
@@ -52,7 +49,7 @@ public class LisConfigFacade extends LisConfigServiceImpl {
         QueryWrapper<LisConfig> queryWrapper = new QueryWrapper<>();
         LisConfig oldRecord = new LisConfig();
         if (lisConfig.getId() != null) {
-            oldRecord = this.getById(lisConfig.getId());
+            oldRecord = lisConfigService.getById(lisConfig.getId());
             if (oldRecord != null && oldRecord.getIsDeleted().equals(IsDeleteEnum.N.getKey())) {
                 return true;
             }
@@ -70,7 +67,7 @@ public class LisConfigFacade extends LisConfigServiceImpl {
                 queryWrapper
                         .eq("his_detail_name", lisConfig.getHisDetailName());
             }
-            oldRecord = this.getOne(queryWrapper);
+            oldRecord = lisConfigService.getOne(queryWrapper);
             if (oldRecord != null) {
                 return true;
             }
@@ -99,7 +96,7 @@ public class LisConfigFacade extends LisConfigServiceImpl {
         if (lisConfig.getIsDeleted() == null) {
             lisConfig.setIsDeleted(IsDeleteEnum.N.getKey());
         }
-        this.saveOrUpdate(lisConfig);
+        lisConfigService.saveOrUpdate(lisConfig);
         return true;
     }
 
@@ -189,7 +186,7 @@ public class LisConfigFacade extends LisConfigServiceImpl {
         UpdateWrapper<LisConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("id", idVO.getId())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        this.update(updateWrapper);
+        lisConfigService.removeById(idVO.getId());
         return true;
     }
 
@@ -206,7 +203,7 @@ public class LisConfigFacade extends LisConfigServiceImpl {
         UpdateWrapper<LisConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.in("id", idListVO.getIds())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        this.update(updateWrapper);
+        lisConfigService.removeByIds(idListVO.getIds());
         return true;
     }
 
@@ -256,7 +253,7 @@ public class LisConfigFacade extends LisConfigServiceImpl {
         if (ListUtil.isNotEmpty(uniqueNames)) {
             queryWrapper.in("unique_name", uniqueNames);
         }
-        List<LisConfig> records = this.list(queryWrapper);
+        List<LisConfig> records = lisConfigService.list(queryWrapper);
         if (ListUtil.isEmpty(records)) {
             return retMap;
         }

+ 49 - 67
src/main/java/com/diagbot/facade/OperationConfigFacade.java

@@ -99,41 +99,59 @@ public class OperationConfigFacade {
      * @return
      */
     public Boolean saveOrUpdateRecords(OperationConfigListVO operationConfigListVO) {
+        if (ListUtil.isEmpty(operationConfigListVO.getOperationConfigList())) {
+            return false;
+        }
+        return saveOrUpdateRecords(operationConfigListVO.getOperationConfigList());
+    }
+
+    /**
+     * 批量保存
+     *
+     * @param operationConfigList
+     * @return
+     */
+    public Boolean saveOrUpdateRecords(List<OperationConfig> operationConfigList) {
+        if (ListUtil.isEmpty(operationConfigList)) {
+            return false;
+        }
         String hospitalId = SysUserUtils.getCurrentHospitalID();
         String userId = SysUserUtils.getCurrentPrincipleID();
         Date now = DateUtil.now();
-        //id为空且已存在的映射关系先删除
-        List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
-                = getConfigMap(Long.valueOf(hospitalId), null, null);
-        if (ListUtil.isNotEmpty(operationConfigListVO.getOperationConfigList())) {
-            operationConfigListVO.getOperationConfigList().forEach(operationConfig -> {
-                operationConfig.setHospitalId(Long.valueOf(hospitalId));
-                operationConfig.setModifier(userId);
-                operationConfig.setGmtModified(now);
-                if (operationConfig.getId() == null) {
-                    if (configMap.get(operationConfig.getHisName()) != null
-                            && configMap.get(operationConfig.getHisName()).containsKey(operationConfig.getUniqueName())) {
-                        deleteIds.add(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
-                    }
-                    operationConfig.setCreator(userId);
-                    operationConfig.setGmtCreate(now);
-                }
-                if (operationConfig.getIsDeleted() == null) {
-                    operationConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-                }
-            });
-            IdListVO idListVO = new IdListVO();
-            idListVO.setIds(deleteIds);
-            deleteRecords(idListVO);
-        }
+
         //数据不完整的不保存
-        List<OperationConfig> records = operationConfigListVO.getOperationConfigList()
+        //过滤外部名称或公表名为空的数据
+        operationConfigList = operationConfigList
                 .stream()
                 .filter(i -> StringUtil.isNotBlank(i.getHisName()))
                 .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
                 .collect(Collectors.toList());
-        operationConfigService.saveOrUpdateBatch(records);
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        List<Long> deleteIds = Lists.newLinkedList();
+        Map<String, Map<String, Long>> configMap
+                = getConfigMap(Long.valueOf(hospitalId), null, null);
+        operationConfigList.forEach(operationConfig -> {
+            operationConfig.setHospitalId(Long.valueOf(hospitalId));
+            operationConfig.setModifier(userId);
+            operationConfig.setGmtModified(now);
+            if (operationConfig.getId() == null) {
+                if (configMap.containsKey(operationConfig.getHisName())) {
+                    deleteIds.add(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
+                }
+                operationConfig.setCreator(userId);
+                operationConfig.setGmtCreate(now);
+            }
+            if (operationConfig.getIsDeleted() == null) {
+                operationConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            }
+        });
+        //删除已存在映射关系
+        IdListVO idListVO = new IdListVO();
+        idListVO.setIds(deleteIds);
+        deleteRecords(idListVO);
+        operationConfigService.saveOrUpdateBatch(operationConfigList);
         return true;
     }
 
@@ -147,7 +165,7 @@ public class OperationConfigFacade {
         UpdateWrapper<OperationConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("id", idVO.getId())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        operationConfigService.update(updateWrapper);
+        operationConfigService.removeById(idVO.getId());
         return true;
     }
 
@@ -164,7 +182,7 @@ public class OperationConfigFacade {
         UpdateWrapper<OperationConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.in("id", idListVO.getIds())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        operationConfigService.update(updateWrapper);
+        operationConfigService.removeByIds(idListVO.getIds());
         return true;
     }
 
@@ -181,50 +199,14 @@ public class OperationConfigFacade {
     }
 
     /**
-     * 化验数据导入
+     * 数据导入
      *
      * @param file
      */
     public void importExcel(MultipartFile file) {
-        String hospitalId = SysUserUtils.getCurrentHospitalID();
-        String userId = SysUserUtils.getCurrentPrincipleID();
-        Date now = DateUtil.now();
         List<OperationConfig> operationConfigList = ExcelUtils.importExcel(file, 0, 1, OperationConfig.class);
         if (ListUtil.isNotEmpty(operationConfigList)) {
-            //过滤不完整数据
-            operationConfigList = operationConfigList
-                    .stream()
-                    .filter(i -> StringUtil.isNotBlank(i.getHisName()))
-                    .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
-                    .collect(Collectors.toList());
-            //验证数据是否已存在
-            List<Long> deleteIds = Lists.newArrayList();
-            Map<String, Map<String, Long>> configMap = getConfigMap(Long.valueOf(hospitalId), null, null);
-            operationConfigList.forEach(operationConfig -> {
-                if (configMap.get(operationConfig.getHisName()) != null
-                        && configMap.get(operationConfig.getHisName()).containsKey(operationConfig.getUniqueName())) {
-                    deleteIds.add(configMap.get(operationConfig.getHisName()).get(operationConfig.getUniqueName()));
-                }
-            });
-            //删除已存在的映射关系
-            if (ListUtil.isNotEmpty(deleteIds)) {
-                IdListVO idListVO = new IdListVO();
-                idListVO.setIds(deleteIds);
-                deleteRecords(idListVO);
-            }
-
-            //保存数据
-            operationConfigList.forEach(operationConfig -> {
-                operationConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-                operationConfig.setHospitalId(Long.valueOf(hospitalId));
-                if (operationConfig.getId() == null) {
-                    operationConfig.setCreator(userId);
-                    operationConfig.setGmtCreate(now);
-                }
-                operationConfig.setModifier(userId);
-                operationConfig.setGmtModified(now);
-            });
-            operationConfigService.saveOrUpdateBatch(operationConfigList);
+            saveOrUpdateRecords(operationConfigList);
         }
     }
 

+ 49 - 67
src/main/java/com/diagbot/facade/PacsConfigFacade.java

@@ -99,41 +99,59 @@ public class PacsConfigFacade {
      * @return
      */
     public Boolean saveOrUpdateRecords(PacsConfigListVO pacsConfigListVO) {
+        if (ListUtil.isEmpty(pacsConfigListVO.getPacsConfigList())) {
+            return false;
+        }
+        return saveOrUpdateRecords(pacsConfigListVO.getPacsConfigList());
+    }
+
+    /**
+     * 批量保存
+     *
+     * @param pacsConfigList
+     * @return
+     */
+    public Boolean saveOrUpdateRecords(List<PacsConfig> pacsConfigList) {
+        if (ListUtil.isEmpty(pacsConfigList)) {
+            return false;
+        }
         String hospitalId = SysUserUtils.getCurrentHospitalID();
         String userId = SysUserUtils.getCurrentPrincipleID();
         Date now = DateUtil.now();
-        //id为空且已存在的映射关系先删除
-        List<Long> deleteIds = Lists.newLinkedList();
-        Map<String, Map<String, Long>> configMap
-                = getConfigMap(Long.valueOf(hospitalId), null, null);
-        if (ListUtil.isNotEmpty(pacsConfigListVO.getPacsConfigList())) {
-            pacsConfigListVO.getPacsConfigList().forEach(pacsConfig -> {
-                pacsConfig.setHospitalId(Long.valueOf(hospitalId));
-                pacsConfig.setModifier(userId);
-                pacsConfig.setGmtModified(now);
-                if (pacsConfig.getId() == null) {
-                    if (configMap.get(pacsConfig.getHisName()) != null
-                            && configMap.get(pacsConfig.getHisName()).containsKey(pacsConfig.getUniqueName())) {
-                        deleteIds.add(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
-                    }
-                    pacsConfig.setCreator(userId);
-                    pacsConfig.setGmtCreate(now);
-                }
-                if (pacsConfig.getIsDeleted() == null) {
-                    pacsConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-                }
-            });
-            IdListVO idListVO = new IdListVO();
-            idListVO.setIds(deleteIds);
-            deleteRecords(idListVO);
-        }
+
         //数据不完整的不保存
-        List<PacsConfig> records = pacsConfigListVO.getPacsConfigList()
+        //过滤外部名称或公表名为空的数据
+        pacsConfigList = pacsConfigList
                 .stream()
                 .filter(i -> StringUtil.isNotBlank(i.getHisName()))
                 .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
                 .collect(Collectors.toList());
-        pacsConfigService.saveOrUpdateBatch(records);
+
+        // 验证数据是否已存在,已存在的先删除
+        // 没id的删除重新插入,有id的更新
+        List<Long> deleteIds = Lists.newLinkedList();
+        Map<String, Map<String, Long>> configMap
+                = getConfigMap(Long.valueOf(hospitalId), null, null);
+        pacsConfigList.forEach(pacsConfig -> {
+            pacsConfig.setHospitalId(Long.valueOf(hospitalId));
+            pacsConfig.setModifier(userId);
+            pacsConfig.setGmtModified(now);
+            if (pacsConfig.getId() == null) {
+                if (configMap.containsKey(pacsConfig.getHisName())) {
+                    deleteIds.add(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
+                }
+                pacsConfig.setCreator(userId);
+                pacsConfig.setGmtCreate(now);
+            }
+            if (pacsConfig.getIsDeleted() == null) {
+                pacsConfig.setIsDeleted(IsDeleteEnum.N.getKey());
+            }
+        });
+        //删除已存在映射关系
+        IdListVO idListVO = new IdListVO();
+        idListVO.setIds(deleteIds);
+        deleteRecords(idListVO);
+        pacsConfigService.saveOrUpdateBatch(pacsConfigList);
         return true;
     }
 
@@ -147,7 +165,7 @@ public class PacsConfigFacade {
         UpdateWrapper<PacsConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("id", idVO.getId())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        pacsConfigService.update(updateWrapper);
+        pacsConfigService.removeById(idVO.getId());
         return true;
     }
 
@@ -164,7 +182,7 @@ public class PacsConfigFacade {
         UpdateWrapper<PacsConfig> updateWrapper = new UpdateWrapper<>();
         updateWrapper.in("id", idListVO.getIds())
                 .set("is_deleted", IsDeleteEnum.Y.getKey());
-        pacsConfigService.update(updateWrapper);
+        pacsConfigService.removeByIds(idListVO.getIds());
         return true;
     }
 
@@ -181,50 +199,14 @@ public class PacsConfigFacade {
     }
 
     /**
-     * 化验数据导入
+     * 数据导入
      *
      * @param file
      */
     public void importExcel(MultipartFile file) {
-        String hospitalId = SysUserUtils.getCurrentHospitalID();
-        String userId = SysUserUtils.getCurrentPrincipleID();
-        Date now = DateUtil.now();
         List<PacsConfig> pacsConfigList = ExcelUtils.importExcel(file, 0, 1, PacsConfig.class);
         if (ListUtil.isNotEmpty(pacsConfigList)) {
-            //过滤不完整数据
-            pacsConfigList = pacsConfigList
-                    .stream()
-                    .filter(i -> StringUtil.isNotBlank(i.getHisName()))
-                    .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
-                    .collect(Collectors.toList());
-            //验证数据是否已存在
-            List<Long> deleteIds = Lists.newArrayList();
-            Map<String, Map<String, Long>> configMap = getConfigMap(Long.valueOf(hospitalId), null, null);
-            pacsConfigList.forEach(pacsConfig -> {
-                if (configMap.get(pacsConfig.getHisName()) != null
-                        && configMap.get(pacsConfig.getHisName()).containsKey(pacsConfig.getUniqueName())) {
-                    deleteIds.add(configMap.get(pacsConfig.getHisName()).get(pacsConfig.getUniqueName()));
-                }
-            });
-            //删除已存在的映射关系
-            if (ListUtil.isNotEmpty(deleteIds)) {
-                IdListVO idListVO = new IdListVO();
-                idListVO.setIds(deleteIds);
-                deleteRecords(idListVO);
-            }
-
-            //保存数据
-            pacsConfigList.forEach(pacsConfig -> {
-                pacsConfig.setIsDeleted(IsDeleteEnum.N.getKey());
-                pacsConfig.setHospitalId(Long.valueOf(hospitalId));
-                if (pacsConfig.getId() == null) {
-                    pacsConfig.setCreator(userId);
-                    pacsConfig.setGmtCreate(now);
-                }
-                pacsConfig.setModifier(userId);
-                pacsConfig.setGmtModified(now);
-            });
-            pacsConfigService.saveOrUpdateBatch(pacsConfigList);
+            saveOrUpdateRecords(pacsConfigList);
         }
     }