签出补偿接口

首页签出2023/07/24
wyb 2 years ago
parent 1f89c57868
commit 533de37eab

@ -1,15 +1,19 @@
[
{
{
"mappings": [{
"hospital": "emr",
"wzh": "1"
},{
},
{
"hospital": "hl",
"wzh": "3"
},{
},
{
"hospital": "sy",
"wzh": "6"
},{
},
{
"hospital": "hz",
"wzh": "13"
}
]
}
]

@ -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<SystemMapping> systemMappingList;
private List<SystemMapping> mappings;
@Override
public String toString() {
return "SystemMappingConfig{" +
"systemMappingList=" + systemMappingList +
"mappings=" + mappings +
'}';
}
private SystemMappingConfig() {
TableJsonRead jsonRead = new TableJsonRead();
List<SystemMapping> 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<SystemMapping> getSystemMappingList() {
return systemMappingList;
public List<SystemMapping> getMappings() {
return mappings;
}
public static void main(String[] args) {

@ -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;

@ -0,0 +1,23 @@
package com.docus.server.collection.infrastructure.dao.mapper;
import com.docus.server.collection.entity.CollectSysDictionary;
import java.util.List;
/**
* <p>
* mapper
* </p>
*
* @author wen yongbin
* @since 2023-7-26 08:45:51
*/
public interface CollectSysDictionaryMapper {
/**
*
* @return
*/
List<CollectSysDictionary> findAll();
}

@ -22,4 +22,5 @@ public interface TBasicMapper{
Integer update(@Param("tBasic") TBasic tBasic);
String getPatientIdByJzh(@Param("jzh") String jzh);
}

@ -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<String> 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<String> systemMappingCollectorIds(FirstPageCheckoutInDTO dto) {
// 取得无纸化系统所有的采集系统配置
List<CollectsysDictionary> wzhAllCollectSys = getWzhAllCollectSys();
List<CollectSysDictionary> wzhAllCollectSys = getWzhAllCollectSys();
if (Func.isEmpty(wzhAllCollectSys)) {
throw new RuntimeException("文件同步,未配置系统!");
}
List<String> 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<String> collectorIds = new ArrayList<>();
// 映射配置读取
SystemMappingConfig instance = SystemMappingConfig.getInstance();
List<SystemMappingConfig.SystemMapping> systemMappingList = instance.getSystemMappingList();
List<SystemMappingConfig.SystemMapping> systemMappingList = instance.getMappings();
validateSystemMappingConfig(systemMappingList);
// 按照医院的id分组
Map<String, List<SystemMappingConfig.SystemMapping>> mappingGroupHosp = systemMappingList.stream().collect(Collectors.groupingBy(SystemMappingConfig.SystemMapping::getHospital));
@ -94,9 +100,8 @@ public class MzZyHisServiceImpl implements MzZyHisService {
return wzhAllCollectSysCode;
}
private List<CollectsysDictionary> getWzhAllCollectSys() {
// todo 获取采集器id大全
return new ArrayList<>();
private List<CollectSysDictionary> getWzhAllCollectSys() {
return collectSysDictionaryMapper.findAll();
}
/**

@ -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> T Read(String path, String fileName, Class<T> 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<T>() {
});
}
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();
}
}
}
}

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.server.collection.infrastructure.dao.mapper.CollectSysDictionaryMapper">
<select id="findAll" resultType="com.docus.server.collection.entity.CollectSysDictionary">
SELECT id,sys_code sysCode,sys_name sysName
FROM `docus_archivefile`.`af_collectsys_dictionary`
</select>
</mapper>

@ -79,4 +79,8 @@
<select id="selectOne" resultType="java.lang.Integer">
select count(patient_id) from docus_medicalrecord.t_basic where jzh=#{jzh}
</select>
<select id="getPatientIdByJzh" resultType="java.lang.String">
select patient_id from `docus_medicalrecord`.`t_basic` where jzh=#{jzh}
</select>
</mapper>

Loading…
Cancel
Save