From 533de37eab2a65dee86b7d311eafc444860e5d9d Mon Sep 17 00:00:00 2001 From: wyb <1977763549@qq.com> Date: Wed, 26 Jul 2023 09:37:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=87=BA=E8=A1=A5=E5=81=BF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataConfig/System-Mapping.json | 34 ++--- .../config/SystemMappingConfig.java | 24 ++-- ...tionary.java => CollectSysDictionary.java} | 2 +- .../mapper/CollectSysDictionaryMapper.java | 23 ++++ .../dao/mapper/TBasicMapper.java | 1 + .../service/impl/MzZyHisServiceImpl.java | 33 +++-- .../server/collection/util/TableJsonRead.java | 123 ++++++++++++++++++ .../mapper/CollectSysDictionaryMapper.xml | 11 ++ src/main/resources/mapper/TBasicMapper.xml | 4 + 9 files changed, 217 insertions(+), 38 deletions(-) rename src/main/java/com/docus/server/collection/entity/{CollectsysDictionary.java => CollectSysDictionary.java} (87%) create mode 100644 src/main/java/com/docus/server/collection/infrastructure/dao/mapper/CollectSysDictionaryMapper.java create mode 100644 src/main/java/com/docus/server/collection/util/TableJsonRead.java create mode 100644 src/main/resources/mapper/CollectSysDictionaryMapper.xml diff --git a/dataConfig/System-Mapping.json b/dataConfig/System-Mapping.json index 0cb2bba..cffecd5 100644 --- a/dataConfig/System-Mapping.json +++ b/dataConfig/System-Mapping.json @@ -1,15 +1,19 @@ -[ - { - "hospital": "emr", - "wzh": "1" - },{ - "hospital": "hl", - "wzh": "3" -},{ - "hospital": "sy", - "wzh": "6" -},{ - "hospital": "hz", - "wzh": "13" -} -] \ No newline at end of file +{ + "mappings": [{ + "hospital": "emr", + "wzh": "1" + }, + { + "hospital": "hl", + "wzh": "3" + }, + { + "hospital": "sy", + "wzh": "6" + }, + { + "hospital": "hz", + "wzh": "13" + } + ] +} \ No newline at end of file diff --git a/src/main/java/com/docus/server/collection/config/SystemMappingConfig.java b/src/main/java/com/docus/server/collection/config/SystemMappingConfig.java index afe6d1e..391af8b 100644 --- a/src/main/java/com/docus/server/collection/config/SystemMappingConfig.java +++ b/src/main/java/com/docus/server/collection/config/SystemMappingConfig.java @@ -1,9 +1,11 @@ package com.docus.server.collection.config; -import com.docus.infrastructure.core.utils.TableJsonRead; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.docus.core.util.Func; +import com.docus.server.collection.util.TableJsonRead; import lombok.Data; -import java.util.ArrayList; import java.util.List; /** @@ -11,24 +13,29 @@ import java.util.List; * * @author wyb */ +@Data public class SystemMappingConfig { private static final String CONFIG_FILE_PATH = "dataConfig"; private static final String CONFIG_FILE_NAME = "System-Mapping.json"; private static volatile boolean FLUSH; private static volatile SystemMappingConfig INSTANCE; - private final List systemMappingList; + private List mappings; @Override public String toString() { return "SystemMappingConfig{" + - "systemMappingList=" + systemMappingList + + "mappings=" + mappings + '}'; } private SystemMappingConfig() { TableJsonRead jsonRead = new TableJsonRead(); - List list = jsonRead.Read(CONFIG_FILE_PATH, CONFIG_FILE_NAME, ArrayList.class); - this.systemMappingList = list; + String readJson = jsonRead.readContent(CONFIG_FILE_PATH, CONFIG_FILE_NAME); + JSONObject jsonObject = Func.readJson(readJson, JSONObject.class); + if (jsonObject != null && jsonObject.getJSONArray("mappings") != null) { + JSONArray mappings = jsonObject.getJSONArray("mappings"); + this.mappings = Func.parseJsonArray(Func.toJson(mappings), SystemMapping.class); + } } public static SystemMappingConfig getInstance() { @@ -49,8 +56,9 @@ public class SystemMappingConfig { FLUSH = true; } - public List getSystemMappingList() { - return systemMappingList; + + public List getMappings() { + return mappings; } public static void main(String[] args) { diff --git a/src/main/java/com/docus/server/collection/entity/CollectsysDictionary.java b/src/main/java/com/docus/server/collection/entity/CollectSysDictionary.java similarity index 87% rename from src/main/java/com/docus/server/collection/entity/CollectsysDictionary.java rename to src/main/java/com/docus/server/collection/entity/CollectSysDictionary.java index febeff2..1121cf5 100644 --- a/src/main/java/com/docus/server/collection/entity/CollectsysDictionary.java +++ b/src/main/java/com/docus/server/collection/entity/CollectSysDictionary.java @@ -9,7 +9,7 @@ import java.io.Serializable; @Data -public class CollectsysDictionary implements Serializable { +public class CollectSysDictionary implements Serializable { @ApiModelProperty(value = "id 雪花算法") private Long id; diff --git a/src/main/java/com/docus/server/collection/infrastructure/dao/mapper/CollectSysDictionaryMapper.java b/src/main/java/com/docus/server/collection/infrastructure/dao/mapper/CollectSysDictionaryMapper.java new file mode 100644 index 0000000..0c6fa19 --- /dev/null +++ b/src/main/java/com/docus/server/collection/infrastructure/dao/mapper/CollectSysDictionaryMapper.java @@ -0,0 +1,23 @@ +package com.docus.server.collection.infrastructure.dao.mapper; + +import com.docus.server.collection.entity.CollectSysDictionary; + +import java.util.List; + +/** + *

+ * 采集系统字典 mapper + *

+ * + * @author wen yongbin + * @since 2023-7-26 08:45:51 + */ +public interface CollectSysDictionaryMapper { + + /** + * 查询无纸化系统所有的采集系统字典 + * @return 无纸化系统所有的采集系统字典 + */ + List findAll(); + +} diff --git a/src/main/java/com/docus/server/collection/infrastructure/dao/mapper/TBasicMapper.java b/src/main/java/com/docus/server/collection/infrastructure/dao/mapper/TBasicMapper.java index 26a2b21..7977dc5 100644 --- a/src/main/java/com/docus/server/collection/infrastructure/dao/mapper/TBasicMapper.java +++ b/src/main/java/com/docus/server/collection/infrastructure/dao/mapper/TBasicMapper.java @@ -22,4 +22,5 @@ public interface TBasicMapper{ Integer update(@Param("tBasic") TBasic tBasic); + String getPatientIdByJzh(@Param("jzh") String jzh); } diff --git a/src/main/java/com/docus/server/collection/service/impl/MzZyHisServiceImpl.java b/src/main/java/com/docus/server/collection/service/impl/MzZyHisServiceImpl.java index a6b85cf..1e6acb6 100644 --- a/src/main/java/com/docus/server/collection/service/impl/MzZyHisServiceImpl.java +++ b/src/main/java/com/docus/server/collection/service/impl/MzZyHisServiceImpl.java @@ -1,14 +1,18 @@ package com.docus.server.collection.service.impl; import com.docus.core.util.Func; +import com.docus.infrastructure.core.exception.BaseException; import com.docus.infrastructure.web.api.CommonResult; import com.docus.infrastructure.web.api.ResultCode; import com.docus.server.collection.config.SystemMappingConfig; import com.docus.server.collection.dto.FirstPageCheckoutInDTO; -import com.docus.server.collection.entity.CollectsysDictionary; +import com.docus.server.collection.dto.PatientInfoDTO; +import com.docus.server.collection.entity.CollectSysDictionary; import com.docus.server.collection.enums.FileSyncMethod; import com.docus.server.collection.feign.dto.CompensateTasRequest; import com.docus.server.collection.feign.service.CollectTaskService; +import com.docus.server.collection.infrastructure.dao.mapper.CollectSysDictionaryMapper; +import com.docus.server.collection.infrastructure.dao.mapper.TBasicMapper; import com.docus.server.collection.service.MzZyHisService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -28,17 +32,20 @@ import java.util.stream.Collectors; public class MzZyHisServiceImpl implements MzZyHisService { @Resource private CollectTaskService collectTaskService; + @Resource + private CollectSysDictionaryMapper collectSysDictionaryMapper; + @Resource + private TBasicMapper tBasicMapper; @Override public void firstPageCheckout(FirstPageCheckoutInDTO dto) { System.out.println(dto); - String patientId = null; -// throw new RuntimeException(""); + PatientInfoDTO patientInfo = dto.getPatientInfo(); //验证基础数据是否存在 -// if(!false){ -// throw new BaseException("系统未找到患者数据!"); -// -// } + String patientId = tBasicMapper.getPatientIdByJzh(patientInfo.getInpatientNo()); + if (Func.isBlank(patientId)) { + throw new BaseException("系统未找到患者数据,住院流水号:" + patientInfo.getInpatientNo()); + } // 取得映射结果后的无纸化系统id List collectorIds = systemMappingCollectorIds(dto); // 进行任务补偿 @@ -51,17 +58,16 @@ public class MzZyHisServiceImpl implements MzZyHisService { if (commonResult.getCode().equals(ResultCode.FAILED.getCode())) { throw new RuntimeException(commonResult.getMsg()); } - // todo 首页签出处理逻辑 } private List systemMappingCollectorIds(FirstPageCheckoutInDTO dto) { // 取得无纸化系统所有的采集系统配置 - List wzhAllCollectSys = getWzhAllCollectSys(); + List wzhAllCollectSys = getWzhAllCollectSys(); if (Func.isEmpty(wzhAllCollectSys)) { throw new RuntimeException("文件同步,未配置系统!"); } List wzhAllCollectSysCode = wzhAllCollectSys.stream() - .map(CollectsysDictionary::getSysCode) + .map(CollectSysDictionary::getSysCode) .distinct().collect(Collectors.toList()); // 文件同步方式,如果是按照系统,则匹配系统,否则取无纸化系统所有的采集系统配置 if (dto.getSyncMethod() == FileSyncMethod.BY_SYS_ID) { @@ -71,7 +77,7 @@ public class MzZyHisServiceImpl implements MzZyHisService { List collectorIds = new ArrayList<>(); // 映射配置读取 SystemMappingConfig instance = SystemMappingConfig.getInstance(); - List systemMappingList = instance.getSystemMappingList(); + List systemMappingList = instance.getMappings(); validateSystemMappingConfig(systemMappingList); // 按照医院的id分组 Map> mappingGroupHosp = systemMappingList.stream().collect(Collectors.groupingBy(SystemMappingConfig.SystemMapping::getHospital)); @@ -94,9 +100,8 @@ public class MzZyHisServiceImpl implements MzZyHisService { return wzhAllCollectSysCode; } - private List getWzhAllCollectSys() { - // todo 获取采集器id大全 - return new ArrayList<>(); + private List getWzhAllCollectSys() { + return collectSysDictionaryMapper.findAll(); } /** diff --git a/src/main/java/com/docus/server/collection/util/TableJsonRead.java b/src/main/java/com/docus/server/collection/util/TableJsonRead.java new file mode 100644 index 0000000..3ee1bf1 --- /dev/null +++ b/src/main/java/com/docus/server/collection/util/TableJsonRead.java @@ -0,0 +1,123 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.docus.server.collection.util; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.poi.ss.formula.functions.T; +import org.springframework.util.StringUtils; + +import java.io.*; + +public class TableJsonRead { + public TableJsonRead() { + } + + public T Read(String path, String fileName, Class clazz) { + String currentPath = this.CurrentPath(); + path = currentPath + "\\" + path; + StringBuilder sb = new StringBuilder(); + T dto = null; + File file = new File(path + "\\" + fileName); + + try { + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException var11) { + var11.printStackTrace(); + } + } else { + BufferedReader bufferedReader = null; + bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); + + String line; + while(!StringUtils.isEmpty(line = bufferedReader.readLine())) { + sb.append(line); + } + + if (sb.length() > 0) { + ObjectMapper objectMapper = new ObjectMapper(); + dto = objectMapper.readValue(sb.toString(), new TypeReference() { + }); + } + + bufferedReader.close(); + } + + return dto; + } catch (Exception var12) { + var12.printStackTrace(); + return null; + } + } + + + public String readContent(String path, String fileName) { + String currentPath = this.CurrentPath(); + path = currentPath + "\\" + path; + StringBuilder content = new StringBuilder(); + T dto = null; + File file = new File(path + "\\" + fileName); + + try { + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException var11) { + var11.printStackTrace(); + } + } else { + BufferedReader bufferedReader = null; + bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); + + String line; + while((line = bufferedReader.readLine())!=null) { + content.append(line); + } + } + return content.toString(); + } catch (Exception var12) { + var12.printStackTrace(); + return null; + } + } + + private String CurrentPath() { + File dir = new File("."); + String currentpath = ""; + + try { + currentpath = dir.getCanonicalPath(); + } catch (IOException var4) { + var4.printStackTrace(); + } + + return currentpath; + } + + public void Save(String path, String fileName, String data) { + String currentPath = this.CurrentPath(); + path = currentPath + "\\" + path; + FileWriter fwriter = null; + + try { + fwriter = new FileWriter(path + "\\" + fileName); + fwriter.write(data); + } catch (IOException var15) { + var15.printStackTrace(); + } finally { + try { + fwriter.flush(); + fwriter.close(); + } catch (IOException var14) { + var14.printStackTrace(); + } + + } + + } +} diff --git a/src/main/resources/mapper/CollectSysDictionaryMapper.xml b/src/main/resources/mapper/CollectSysDictionaryMapper.xml new file mode 100644 index 0000000..fd2daea --- /dev/null +++ b/src/main/resources/mapper/CollectSysDictionaryMapper.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/src/main/resources/mapper/TBasicMapper.xml b/src/main/resources/mapper/TBasicMapper.xml index 7b1121d..3faa1f9 100644 --- a/src/main/resources/mapper/TBasicMapper.xml +++ b/src/main/resources/mapper/TBasicMapper.xml @@ -79,4 +79,8 @@ + +