|
@@ -64,6 +64,13 @@ public class DeptConfigFacade {
|
|
|
.eq("hospital_id", deptConfig.getHospitalId())
|
|
|
.eq("his_name", deptConfig.getHisName())
|
|
|
.eq("unique_name", deptConfig.getUniqueName());
|
|
|
+ /* if (StringUtil.isNotBlank(deptConfig.getHisCode())) {
|
|
|
+ queryWrapper.eq("his_code", deptConfig.getHisCode());
|
|
|
+ } else {
|
|
|
+ queryWrapper.and(i -> i.isNull("his_code")
|
|
|
+ .or()
|
|
|
+ .eq("his_code", ""));
|
|
|
+ }*/
|
|
|
DeptConfig oldRecord = deptConfigService.getOne(queryWrapper, false);
|
|
|
if (deptConfig.getId() == null
|
|
|
&& oldRecord != null) {
|
|
@@ -93,6 +100,13 @@ public class DeptConfigFacade {
|
|
|
.eq("hospital_id", deptConfig.getHospitalId())
|
|
|
.eq("his_name", deptConfig.getHisName())
|
|
|
.eq("unique_name", deptConfig.getUniqueName());
|
|
|
+ /*if (StringUtil.isNotBlank(deptConfig.getHisCode())) {
|
|
|
+ queryWrapper.eq("his_code", deptConfig.getHisCode());
|
|
|
+ } else {
|
|
|
+ queryWrapper.and(i -> i.isNull("his_code")
|
|
|
+ .or()
|
|
|
+ .eq("his_code", ""));
|
|
|
+ }*/
|
|
|
DeptConfig oldRecord = deptConfigService.getOne(queryWrapper, false);
|
|
|
if (deptConfig.getId() == null
|
|
|
&& oldRecord != null) {
|
|
@@ -158,14 +172,14 @@ public class DeptConfigFacade {
|
|
|
// 验证数据是否已存在,已存在的先删除
|
|
|
// 没id的删除重新插入,有id的更新
|
|
|
List<Long> deleteIds = Lists.newLinkedList();
|
|
|
- Map<String, Map<String, Long>> configMap
|
|
|
+ Map<String, Map<String, List<Long>>> configMap
|
|
|
= getConfigMap(hospitalId, null, null);
|
|
|
deptConfigList.forEach(deptConfig -> {
|
|
|
deptConfig.setModifier(userId);
|
|
|
deptConfig.setGmtModified(now);
|
|
|
if (deptConfig.getId() == null) {
|
|
|
if (configMap.containsKey(deptConfig.getHisName())) {
|
|
|
- deleteIds.add(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
|
|
|
+ deleteIds.addAll(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
|
|
|
}
|
|
|
deptConfig.setCreator(userId);
|
|
|
deptConfig.setGmtCreate(now);
|
|
@@ -296,7 +310,7 @@ public class DeptConfigFacade {
|
|
|
// 验证数据是否已存在,已存在的先删除
|
|
|
// 没id的删除重新插入,有id的更新
|
|
|
List<Long> deleteIds = Lists.newLinkedList();
|
|
|
- Map<String, Map<String, Long>> configMap
|
|
|
+ Map<String, Map<String, List<Long>>> configMap
|
|
|
= getConfigMap(Long.valueOf(hospitalId), null, null);
|
|
|
deptConfigList.forEach(deptConfig -> {
|
|
|
deptConfig.setHospitalId(hospitalId);
|
|
@@ -304,7 +318,7 @@ public class DeptConfigFacade {
|
|
|
deptConfig.setGmtModified(now);
|
|
|
if (deptConfig.getId() == null) {
|
|
|
if (configMap.containsKey(deptConfig.getHisName())) {
|
|
|
- deleteIds.add(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
|
|
|
+ deleteIds.addAll(configMap.get(deptConfig.getHisName()).get(deptConfig.getUniqueName()));
|
|
|
}
|
|
|
deptConfig.setCreator(userId);
|
|
|
deptConfig.setGmtCreate(now);
|
|
@@ -352,7 +366,6 @@ public class DeptConfigFacade {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 获取映射关系-公表名
|
|
|
*
|
|
@@ -361,8 +374,8 @@ public class DeptConfigFacade {
|
|
|
* @param uniqueNames
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String, Map<String, Long>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
|
|
|
- Map<String, Map<String, Long>> retMap = new HashMap<>();
|
|
|
+ public Map<String, Map<String, List<Long>>> getConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
|
|
|
+ Map<String, Map<String, List<Long>>> retMap = new HashMap<>();
|
|
|
QueryWrapper<DeptConfig> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
.eq("hospital_id", hospitalId);
|
|
@@ -379,7 +392,12 @@ public class DeptConfigFacade {
|
|
|
Map<String, List<DeptConfig>> configMap = EntityUtil.makeEntityListMap(records, "hisName");
|
|
|
for (Map.Entry<String, List<DeptConfig>> entry : configMap.entrySet()) {
|
|
|
if (ListUtil.isNotEmpty(entry.getValue())) {
|
|
|
- retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "uniqueName", "id"));
|
|
|
+ Map<String, List<DeptConfig>> subMap = EntityUtil.makeEntityListMap(entry.getValue(), "uniqueName");
|
|
|
+ Map<String, List<Long>> subIdMap = new HashMap<>();
|
|
|
+ for (Map.Entry<String, List<DeptConfig>> subEntry : subMap.entrySet()) {
|
|
|
+ subIdMap.put(subEntry.getKey(), subEntry.getValue().stream().map(i -> i.getId()).distinct().collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ retMap.put(entry.getKey(), subIdMap);
|
|
|
}
|
|
|
}
|
|
|
return retMap;
|
|
@@ -423,10 +441,11 @@ public class DeptConfigFacade {
|
|
|
|
|
|
/**
|
|
|
* 导入数据预匹配
|
|
|
+ *
|
|
|
* @param file
|
|
|
* @param response
|
|
|
*/
|
|
|
- public void precDataMatch(MultipartFile file,HttpServletResponse response) {
|
|
|
+ public void precDataMatch(MultipartFile file, HttpServletResponse response) {
|
|
|
List<DeptConfig> retList = Lists.newLinkedList();
|
|
|
List<DeptConfig> originList = ExcelUtils.importExcel(file, 0, 1, DeptConfig.class);
|
|
|
Map<String, List<DeptConfig>> allMap = getAll();
|
|
@@ -459,6 +478,7 @@ public class DeptConfigFacade {
|
|
|
boolean flag = false;
|
|
|
for (DeptConfig item : items) {
|
|
|
if (uniqueNames.contains(item.getUniqueName())) {
|
|
|
+ item.setHisCode(originItem.getHisCode());
|
|
|
retList.add(item);
|
|
|
flag = true;
|
|
|
}
|
|
@@ -472,15 +492,20 @@ public class DeptConfigFacade {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ retList = retList.stream()
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
String fileName = "科室关联数据(预匹配).xls";
|
|
|
ExcelUtils.exportExcel(retList, null, "sheet1", DeptConfig.class, fileName, response, 12.8f);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取所有医院映射数据
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String,List<DeptConfig>> getAll() {
|
|
|
+ public Map<String, List<DeptConfig>> getAll() {
|
|
|
Map<String, List<DeptConfig>> retMap = new HashMap<>();
|
|
|
List<DeptConfig> records = deptConfigService.list();
|
|
|
if (ListUtil.isEmpty(records)) {
|