中西结合数据同步

master
宇宙皮皮娃 1 year ago
parent 129426cf8c
commit 6889f0ffba

@ -0,0 +1,144 @@
[
{
"emrTypeCode": "defaut",
"assortId": ""
},
{"emrTypeCode": "Anaes_Agree_Record","assortId": "C2C40DB213E76592B696244F423152C4"},
{"emrTypeCode": "Blood_Transfusion_Record","assortId": "B2835AB12202CDF825860A305E4D7AE1"},
{"emrTypeCode": "Ops_Agree_Record","assortId": "3DC3F75E2666D0730BCA08A617C20704"},
{"emrTypeCode": "Special_Check_Record","assortId": "8B90E00DBF4B25BF2D0083F2E786BA76"},
{"emrTypeCode": "病理","assortId": "04B1A1E0DDE32223FF8C65487177C7C2"},
{"emrTypeCode": "FirstPage","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"},
{"emrTypeCode": "First_Page","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"},
{"emrTypeCode": "First_Page_Case","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"},
{"emrTypeCode": "PMR.BASY","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"},
{"emrTypeCode": "Scan.BASY","assortId": "AC90CCD4ACC54AD3AEC2BC09B1407C29"},
{"emrTypeCode": "OperationRecord","assortId": "1D0FCD8E4162D51E2655067915B68E96"},
{"emrTypeCode": "Operation_Record","assortId": "1D0FCD8E4162D51E2655067915B68E96"},
{"emrTypeCode": "Operation_Record","assortId": "1D0FCD8E4162D51E2655067915B68E96"},
{"emrTypeCode": "OpsSafeCheck","assortId": "1429AFC1870B60E563903022D733D443"},
{"emrTypeCode": "Scan.SSXGJL","assortId": "1D0FCD8E4162D51E2655067915B68E96"},
{"emrTypeCode": "ConsultationRecord","assortId": "075086B52919A0DBC0734EE3FF8A8A59"},
{"emrTypeCode": "Consultation_Order_Record","assortId": "075086B52919A0DBC0734EE3FF8A8A59"},
{"emrTypeCode": "Consultation_Record","assortId": "075086B52919A0DBC0734EE3FF8A8A59"},
{"emrTypeCode": "Consultation_Record","assortId": "075086B52919A0DBC0734EE3FF8A8A59"},
{"emrTypeCode": "24In_Dead_Record","assortId": "DB65417382ED778C2EA14470FBE5466B"},
{"emrTypeCode": "24In_Record","assortId": "91AEF4D8FAD38646A223016B99349D3F"},
{"emrTypeCode": "InRecord","assortId": "5A74EEAC6970FB03397E6B80E4DC7219"},
{"emrTypeCode": "In_Record","assortId": "5A74EEAC6970FB03397E6B80E4DC7219"},
{"emrTypeCode": "In_Record","assortId": "5A74EEAC6970FB03397E6B80E4DC7219"},
{"emrTypeCode": "PMR.Evaluation","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"},
{"emrTypeCode": "GM","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"},
{"emrTypeCode": "PMR.BLOOD_TRANS","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"},
{"emrTypeCode": "PMR.LIS","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"},
{"emrTypeCode": "RT","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"},
{"emrTypeCode": "Scan.JYBG","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"},
{"emrTypeCode": "Scan.YWJYBG","assortId": "EE3C4A9B7BBAA56DAC0ED65FB09C32FE"},
{"emrTypeCode": "Scan.MZBL","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "2022022515","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "2022062508","assortId": "07BACE747E6C440B9FCC36A6F529C0B3"},
{"emrTypeCode": "2022062510","assortId": "07BACE747E6C440B9FCC36A6F529C0B3"},
{"emrTypeCode": "AnaesthesiaRecord","assortId": "FF246633CB15136448471EDD30FEB6E1"},
{"emrTypeCode": "OpsAfterVisitationRecord","assortId": "520832CB908E21E570D7C7A3F01EF384"},
{"emrTypeCode": "OpsAnaesthesiaRecord","assortId": "1D0FCD8E4162D51E2655067915B68E96"},
{"emrTypeCode": "OpsVisitationRecord","assortId": "8B0D105A3BB9DC994CEAC80D80EEA540"},
{"emrTypeCode": "PMR.AIS","assortId": "FF246633CB15136448471EDD30FEB6E1"},
{"emrTypeCode": "Scan.MZXGJL","assortId": "FF246633CB15136448471EDD30FEB6E1"},
{"emrTypeCode": "anes_informed_consent","assortId": "C2C40DB213E76592B696244F423152C4"},
{"emrTypeCode": "anes_record","assortId": "FF246633CB15136448471EDD30FEB6E1"},
{"emrTypeCode": "anes_summary","assortId": "FF246633CB15136448471EDD30FEB6E1"},
{"emrTypeCode": "equipment_inventory1","assortId": "07BACE747E6C440B9FCC36A6F529C0B3"},
{"emrTypeCode": "postoperative_anes_visit","assortId": "8B0D105A3BB9DC994CEAC80D80EEA540"},
{"emrTypeCode": "pre_anes_visit","assortId": "8B0D105A3BB9DC994CEAC80D80EEA540"},
{"emrTypeCode": "pre_nurse_visit","assortId": "FF246633CB15136448471EDD30FEB6E1"},
{"emrTypeCode": "shoushufusu","assortId": "FF246633CB15136448471EDD30FEB6E1"},
{"emrTypeCode": "shoushujiaojiedan","assortId": "FF246633CB15136448471EDD30FEB6E1"},
{"emrTypeCode": "PMR.HIS","assortId": "E348EE6045DA800A9DA3E106986A16BC"},
{"emrTypeCode": "Scan.YZD","assortId": "E348EE6045DA800A9DA3E106986A16BC"},
{"emrTypeCode": "Dead_Record","assortId": "DB65417382ED778C2EA14470FBE5466B"},
{"emrTypeCode": "OutRecord","assortId": "91AEF4D8FAD38646A223016B99349D3F"},
{"emrTypeCode": "Out_Record","assortId": "91AEF4D8FAD38646A223016B99349D3F"},
{"emrTypeCode": "Out_Record","assortId": "91AEF4D8FAD38646A223016B99349D3F"},
{"emrTypeCode": "CT","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "DR","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_1","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_401","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_402","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_403","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_404","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_405","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_406","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_407","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_408","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_409","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_410","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_411","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_412","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_413","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_414","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_415","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_416","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_417","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_418","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_419","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_420","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ECG_421","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "EI","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "EL","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "ES","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "MR","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "Scan.JCBG","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "Scan.YWJCBG","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "US","assortId": "97D6420FF328A5CB488DE9E4FBCB1CFF"},
{"emrTypeCode": "Path","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Medical_Book","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Medical_Document_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Medical_Document_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Medical_Insur_Document_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Medical_Rating_Scale","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Nurse_Document_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Public_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Public_book","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Scan.GGLWS","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "PMR.IN_NOTICE","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Scan.RYTZD","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "TemperatureRecord","assortId": "2BCC34D0449C2FD2972EEB5F4CAD7E1D"},
{"emrTypeCode": "Temperature_Record","assortId": "2BCC34D0449C2FD2972EEB5F4CAD7E1D"},
{"emrTypeCode": "Temperature_Record","assortId": "2BCC34D0449C2FD2972EEB5F4CAD7E1D"},
{"emrTypeCode": "HDS","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Scan.Other","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Scan.RYJBXX","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "InOtherRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "In_Other_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "In_Other_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Scan.HLJLD","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Scan.ZRWDJ","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "In_Record_FC","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "NurseConsultationRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Nurse_Consultation_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Operation_Other_Report","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutAgreeRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutDiseaseRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutEmergencyRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutFirstPage","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutMedicalRecords","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutNurseBook","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutNurseRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutRecordPortal","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "OutTemperatureRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Out_Agree_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Out_Emergency_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Out_First_Page","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Out_Medical_Records","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Out_Nurse_Measure","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Out_SecondNew","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "Out_Second_Record","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "PMR.Paper","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "SecondNew","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"},
{"emrTypeCode": "SecondRecord","assortId": "C026897BA4069ACEDFF061E4CF7CFEC6"}
]

@ -0,0 +1,18 @@
{
"disDates": "2023-01-01 00:00:00",
"disDatee": "2023-12-31 11:59:59",
"downPath": "",
"url": "http://192.168.12.121:3000/ws/service?wsdl",
"targetNamespace": "http://ws.sie.com",
"method": "service",
"params": [
{
"name": "param",
"value": "flow=02-PAPERLESS-PMRS,app=JS_MR_DOC"
},
{
"name": "data",
"value": "<message>\n\t<body>\n\t\t<rows>\n\t\t\t<row>\n\t\t\t\t<visit_no>%s</visit_no>\n\t\t\t</row>\n\t\t</rows>\n\t</body>\n</message>"
}
]
}

@ -182,6 +182,11 @@
<version>4.0</version> <version>4.0</version>
</dependency> </dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.10.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<resources> <resources>
@ -350,4 +355,4 @@
</project> </project>

@ -0,0 +1,13 @@
package com.docus.server.message.busservice;
import com.docus.server.message.dto.Message;
import com.docus.server.message.dto.MessageResponse;
public interface ZxjhBusinessService {
void wsRecordDown();
void tScanAssortSave(String patientId);
}

@ -0,0 +1,382 @@
package com.docus.server.message.busservice.impl;
import com.alibaba.fastjson.JSONObject;
import com.docus.core.util.DateUtil;
import com.docus.core.util.Func;
import com.docus.infrastructure.core.exception.BaseException;
import com.docus.infrastructure.redis.service.IdService;
import com.docus.server.message.busservice.ZxjhBusinessService;
import com.docus.server.message.config.AssortConfig;
import com.docus.server.message.config.QueryConfig;
import com.docus.server.message.dto.*;
import com.docus.server.message.entity.TBasicExcel;
import com.docus.server.message.entity.TScanAssort;
import com.docus.server.message.mapper.ZxjhMapper;
import com.docus.server.message.util.XmlUtil;
import com.itextpdf.text.pdf.PdfReader;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.namespace.QName;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.net.*;
import java.util.*;
/**
* @BelongsProject: docus-unified-message
* @BelongsPackage: com.docus.server.message.busservice.impl
* @Author: chierhao
* @CreateTime: 2024-03-20 08:57
* @Description: TODO
* @Version: 1.0
*/
@Slf4j
@Service
public class ZxjhBusinessServiceImpl implements ZxjhBusinessService {
@Autowired
private ZxjhMapper zxjhMapper;
@Autowired
private IdService idService;
@Override
public void wsRecordDown() {
QueryConfig.Config config = QueryConfig.getConfig();
if (config == null) {
throw new BaseException("未配置查询配置");
}
List<AssortConfig.Config> assortConfig = AssortConfig.getConfig();
if (assortConfig == null) {
throw new BaseException("未配置分段配置");
}
Date disDates = DateUtil.parse(config.getDisDates(), "yyyy-MM-dd HH:mm:ss");
Date disDatee = DateUtil.parse(config.getDisDatee(), "yyyy-MM-dd HH:mm:ss");
List<TBasicExcel> basicDatas = zxjhMapper.getBasicData("5", disDates, disDatee);
log.info("查询基础数据条数:{}",basicDatas.size());
if(basicDatas.size()==0){
return;
}
List<JSONObject> paramsConfig = config.getParams();
for (TBasicExcel basicData : basicDatas) {
String patientId = basicData.getPatientId();
String jzh = basicData.getJzh();
log.info("同步病案主键:{}jzh:{}开始",patientId,jzh);
try {
List<JSONObject> params = new ArrayList<>();
for (JSONObject jsonObject : paramsConfig) {
if(jsonObject.getString("name").equals("data")){
JSONObject param=new JSONObject();
param.put("name",jsonObject.getString("name"));
String value = jsonObject.getString("value");
String format = String.format(value, jzh);
param.put("value",format);
params.add(param);
continue;
}
params.add(jsonObject);
}
String result = requestFunctionWebServiceCXF(config.getUrl(),config.getTargetNamespace(),config.getMethod(),params);
if(Func.isEmpty(result)){
throw new BaseException("result为空");
}
List<FileDto> fileDtos = getFileDtos(result);
log.info("同步病案主键:{}jzh:{},文件数量:{}",patientId,jzh,fileDtos.size());
if(Func.isEmpty(fileDtos)){
return;
}
String downPath=config.getDownPath()+File.separator+patientId;
List<TScanAssort> tScanAssorts=new ArrayList<TScanAssort>();
for (FileDto fileDto : fileDtos) {
TScanAssort tScanAssort=new TScanAssort();
tScanAssort.setId(idService.getDateSeq());
tScanAssort.setImagePath(downPath);
tScanAssort.setFileStorageType(1);
tScanAssort.setSource("-5");
tScanAssort.setPatientId(patientId);
tScanAssort.setFileTitle(fileDto.getPMR_NAME());
tScanAssort.setAssortId(getAssortId(fileDto.getEMR_TYPE_CODE(),assortConfig));
tScanAssort.setCreateTime(new Date());
downFile(tScanAssort,fileDto.getPMR_URL(),downPath);
tScanAssorts.add(tScanAssort);
}
zxjhMapper.delete(patientId);
zxjhMapper.saveAssort(tScanAssorts);
log.info("同步病案主键:{}jzh:{}结束",patientId,jzh);
}catch (Exception e) {
log.error(e.getMessage(), e);
zxjhMapper.saveLog(patientId,e.getMessage());
}
}
}
@Override
public void tScanAssortSave(String patientId) {
String jzh = zxjhMapper.getJzh(patientId);
if(Func.isEmpty(jzh)){
throw new BaseException("jzh为空或者病案不存在");
}
QueryConfig.Config config = QueryConfig.getConfig();
if (config == null) {
throw new BaseException("未配置查询配置");
}
List<AssortConfig.Config> assortConfig = AssortConfig.getConfig();
if (assortConfig == null) {
throw new BaseException("未配置分段配置");
}
List<JSONObject> paramsConfig = config.getParams();
log.info("同步病案主键:{}jzh:{}开始",patientId,jzh);
try {
List<JSONObject> params = new ArrayList<>();
for (JSONObject jsonObject : paramsConfig) {
if(jsonObject.getString("name").equals("data")){
JSONObject param=new JSONObject();
param.put("name",jsonObject.getString("name"));
String value = jsonObject.getString("value");
String format = String.format(value, jzh);
param.put("value",format);
params.add(param);
continue;
}
params.add(jsonObject);
}
String result = requestFunctionWebServiceCXF(config.getUrl(),config.getTargetNamespace(),config.getMethod(),params);
if(Func.isEmpty(result)){
throw new BaseException("result为空");
}
List<FileDto> fileDtos = getFileDtos(result);
log.info("同步病案主键:{}jzh:{},文件数量:{}",patientId,jzh,fileDtos.size());
if(Func.isEmpty(fileDtos)){
return;
}
String downPath=config.getDownPath()+File.separator+patientId;
List<TScanAssort> tScanAssorts=new ArrayList<TScanAssort>();
for (FileDto fileDto : fileDtos) {
TScanAssort tScanAssort=new TScanAssort();
tScanAssort.setId(idService.getDateSeq());
tScanAssort.setImagePath(downPath);
tScanAssort.setFileStorageType(1);
tScanAssort.setSource("-5");
tScanAssort.setPatientId(patientId);
tScanAssort.setFileTitle(fileDto.getPMR_NAME());
tScanAssort.setAssortId(getAssortId(fileDto.getEMR_TYPE_CODE(),assortConfig));
tScanAssort.setCreateTime(new Date());
downFile(tScanAssort,fileDto.getPMR_URL(),downPath);
tScanAssorts.add(tScanAssort);
}
zxjhMapper.delete(patientId);
zxjhMapper.saveAssort(tScanAssorts);
log.info("同步病案主键:{}jzh:{}结束",patientId,jzh);
}catch (Exception e) {
log.error(e.getMessage(), e);
zxjhMapper.saveLog(patientId,e.getMessage());
}
}
public String getAssortId(String EMR_TYPE_CODE,List<AssortConfig.Config> assortConfig){
String assortId="";
String defaut="";
for (AssortConfig.Config config : assortConfig) {
if(EMR_TYPE_CODE.equals(config.getEmrTypeCode())){
assortId=config.getAssortId();
}
if("defaut".equals(config.getEmrTypeCode())){
defaut=config.getAssortId();
}
}
if(assortId.equals("")){
assortId=defaut;
}
return assortId;
}
public String requestFunctionWebServiceCXF(String url, String namespace, String method, List<JSONObject> params) throws Exception {
String result;
//创建动态客户端工厂 创建客户端
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(url);
//命名空间和方法
QName name = new QName(namespace, method);
// 定义参数
List paramList=new ArrayList();
for (JSONObject param:params){
QName paramName = new QName(namespace, param.getString("name"));
paramList.add(paramName);
paramList.add(param.getString("value"));
}
// 设置参数值
Object[] paramArray = paramList.toArray();
Object[] objects = client.invoke(name, paramArray);
result = objects[0].toString();
return result;
}
public List<FileDto> getFileDtos(String str) {
XmlUtil xml= XmlUtil.of(str);
//请求结果状态
String status="0";
Node statusNode = xml.getNode("/MESSAGE/HEADER/STATUS");
if(Func.isNotEmpty(statusNode)){
status=statusNode.getTextContent();
}
if(status.equals("0")){
throw new BaseException(str);
}
List<FileDto> list=new ArrayList<FileDto>();
NodeList rows= xml.getNodeList("/MESSAGE/BODY/ROWS/ROW");
for (int i = 1; i <= rows.getLength(); i++) {
Node PMR_ID_NODE=xml.getNode("/MESSAGE/BODY/ROWS/ROW["+i+"]/PMR_ID");
String PMR_ID=null;
if(Func.isNotEmpty(PMR_ID_NODE)){
PMR_ID=PMR_ID_NODE.getTextContent();
}
Node PMR_NAME_NODE=xml.getNode("/MESSAGE/BODY/ROWS/ROW["+i+"]/PMR_NAME");
String PMR_NAME=null;
if(Func.isNotEmpty(PMR_NAME_NODE)){
PMR_NAME=PMR_NAME_NODE.getTextContent();
}
Node PMR_NAME_NO_NODE=xml.getNode("/MESSAGE/BODY/ROWS/ROW["+i+"]/PMR_NAME_NO");
String PMR_NAME_NO=null;
if(Func.isNotEmpty(PMR_NAME_NO_NODE)){
PMR_NAME_NO =PMR_NAME_NO_NODE.getTextContent();
}
Node PMR_URL_NODE=xml.getNode("/MESSAGE/BODY/ROWS/ROW["+i+"]/PMR_URL");
String PMR_URL=null;
if(Func.isNotEmpty(PMR_URL_NODE)){
PMR_URL=PMR_URL_NODE.getTextContent();
}
Node RCD_TYPE_CODE_NODE=xml.getNode("/MESSAGE/BODY/ROWS/ROW["+i+"]/RCD_TYPE_CODE");
String RCD_TYPE_CODE=null;
if(Func.isNotEmpty(RCD_TYPE_CODE_NODE)){
RCD_TYPE_CODE =RCD_TYPE_CODE_NODE.getTextContent();
}
Node RCD_TYPE_NAME_NODE=xml.getNode("/MESSAGE/BODY/ROWS/ROW["+i+"]/RCD_TYPE_NAME");
String RCD_TYPE_NAME=null;
if(Func.isNotEmpty(RCD_TYPE_NAME_NODE)){
RCD_TYPE_NAME =RCD_TYPE_NAME_NODE.getTextContent();
}
Node EMR_TYPE_CODE_NODE=xml.getNode("/MESSAGE/BODY/ROWS/ROW["+i+"]/EMR_TYPE_CODE");
String EMR_TYPE_CODE=null;
if(Func.isNotEmpty(EMR_TYPE_CODE_NODE)){
EMR_TYPE_CODE =EMR_TYPE_CODE_NODE.getTextContent();
}
Node EMR_TYPE_NAME_NODE=xml.getNode("/MESSAGE/BODY/ROWS/ROW["+i+"]/EMR_TYPE_NAME");
String EMR_TYPE_NAME=null;
if(Func.isNotEmpty(EMR_TYPE_NAME_NODE)){
EMR_TYPE_NAME =EMR_TYPE_NAME_NODE.getTextContent();
}
if(Func.isEmpty(PMR_URL)){
throw new BaseException("第"+i+"条文件数据文件地址为空");
}
FileDto dto= new FileDto();
dto.setPMR_ID(PMR_ID);
dto.setPMR_NAME(PMR_NAME);
dto.setPMR_NAME_NO(PMR_NAME_NO);
dto.setPMR_URL(PMR_URL);
dto.setRCD_TYPE_CODE(RCD_TYPE_CODE);
dto.setRCD_TYPE_NAME(RCD_TYPE_NAME);
dto.setEMR_TYPE_CODE(EMR_TYPE_CODE);
dto.setEMR_TYPE_NAME(EMR_TYPE_NAME);
list.add(dto);
}
return list;
}
public void downFile(TScanAssort tScanAssort,String sourcePath,String downPath) throws Exception{
//文件地址形似ftp://AdminPLAT:Plat.2023@192.168.12.90:21/PaperlessData/2024/03/05/Emr/b1162dd9-c47a-4353-8572-37667f6114bc.pdf
//获取文件后最
String end = sourcePath.substring(sourcePath.lastIndexOf("."));
//本地文件名
String fileName = UUID.randomUUID()+end; // 假设要下载的文件名为example.pdf
//文件本地存储路径
String localFilePath = downPath + fileName;
URI uri = new URI(sourcePath);
String host = uri.getHost();
int port = uri.getPort() == -1 ? 21 : uri.getPort(); // 默认端口号为21
String userInfo = uri.getRawUserInfo();
String username = "";
String password = "";
if(userInfo != null) {
String[] userInfoArray = userInfo.split(":");
if(userInfoArray.length >= 1) {
username = URLDecoder.decode(userInfoArray[0], "UTF-8");
}
if(userInfoArray.length >= 2) {
password = URLDecoder.decode(userInfoArray[1], "UTF-8");
}
}
String path = uri.getPath();
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect(host, port);
ftpClient.login(username, password);
ftpClient.enterLocalPassiveMode();
File localFile = new File(localFilePath);
OutputStream outputStream = new FileOutputStream(localFile);
ftpClient.retrieveFile(path, outputStream);
outputStream.close();
int numberOfPages=0;
// 判断文件类型并获取页数
if (isPdf(localFilePath)) {
numberOfPages = getPdfPageCount(localFilePath);
tScanAssort.setFileSource(1);
tScanAssort.setFilePages(numberOfPages);
} else if (isImage(localFilePath)) {
numberOfPages=1;
tScanAssort.setFileSource(2);
tScanAssort.setFilePages(numberOfPages);
}
tScanAssort.setScanPage(fileName);
} catch (Exception ex) {
log.error(ex.getMessage(),ex);
throw new BaseException("下载文件出错");
} finally {
if (ftpClient.isConnected()) {
try {
ftpClient.logout();
ftpClient.disconnect();
} catch (Exception ex) {
log.error(ex.getMessage(),ex);
}
}
}
}
private static boolean isPdf(String filePath) {
// 检查文件扩展名是否为.pdf
return filePath.toLowerCase().endsWith(".pdf");
}
private static boolean isImage(String filePath) {
// 检查文件扩展名是否为常见的图片格式
return filePath.toLowerCase().endsWith(".png") || filePath.toLowerCase().endsWith(".jpg") || filePath.toLowerCase().endsWith(".jpeg") || filePath.toLowerCase().endsWith(".bmp");
}
private static int getPdfPageCount(String filePath) {
try{
PdfReader reader = new PdfReader(filePath);
return reader.getNumberOfPages();
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
}

@ -0,0 +1,42 @@
package com.docus.server.message.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.docus.core.util.Func;
import com.docus.server.message.util.TableJsonRead;
import lombok.Data;
import java.util.List;
/**
* @author wyb
*/
public class AssortConfig {
private final static String CONFIG_FILE_PATH = "data-config";
private final static String CONFIG_FILE_NAME = "assort-config.json";
public static List<Config> getConfig() {
TableJsonRead jsonReader = new TableJsonRead();
String configJson = jsonReader.ReadContent(CONFIG_FILE_PATH, CONFIG_FILE_NAME);
if (configJson == null) {
return null;
}
List<Config> configs = JSON.parseArray(configJson, Config.class);
if (Func.isEmpty(configs)) {
return null;
}
return configs;
}
@Data
public static class Config {
private String emrTypeCode;
private String assortId;
}
public static void main(String[] args)
{
List<Config> taskConfig = getConfig();
System.out.println(taskConfig);
}
}

@ -0,0 +1,49 @@
package com.docus.server.message.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.docus.core.util.Func;
import com.docus.server.message.util.TableJsonRead;
import lombok.Data;
import java.util.List;
import java.util.Objects;
/**
* @author wyb
*/
public class QueryConfig {
private final static String CONFIG_FILE_PATH = "data-config";
private final static String CONFIG_FILE_NAME = "query-config.json";
public static Config getConfig() {
TableJsonRead jsonReader = new TableJsonRead();
String configJson = jsonReader.ReadContent(CONFIG_FILE_PATH, CONFIG_FILE_NAME);
System.out.println(configJson);
if (configJson == null) {
return null;
}
Config config = JSON.parseObject(configJson, Config.class);
if (Func.isEmpty(config)) {
return null;
}
return config;
}
@Data
public static class Config {
private String disDates;
private String disDatee;
private String downPath;
private String url;
private String targetNamespace;
private String method;
private List<JSONObject> params;
}
public static void main(String[] args)
{
Config taskConfig = getConfig();
System.out.println(taskConfig);
}
}

@ -0,0 +1,38 @@
package com.docus.server.message.controller;
import com.docus.server.message.busservice.ZxjhBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author WYBDEV
*/
@Api("中西结合医院")
@RestController
@Slf4j
@RequestMapping("/hospital/zxjh")
public class ZxjhHospitalController {
@Autowired
private ZxjhBusinessService zxjhBusinessService;
@GetMapping("/wsRecordDown/do")
@ApiOperation("中西结合同步下载文件数据")
public String wsRecordDown() {
log.info("中西结合同步下载文件数据开始");
zxjhBusinessService.wsRecordDown();
log.info("中西结合同步下载文件数据结束");
return "操作成功";
}
@GetMapping("/tScanAssortSave/do")
@ApiOperation("中西结合同步下载文件数据单个")
public String tScanAssortSave(@RequestParam(value = "pid",required = true) String pid) {
log.info("中西结合同步下载文件数据开始");
zxjhBusinessService.tScanAssortSave(pid);
log.info("中西结合同步下载文件数据结束");
return "操作成功";
}
}

@ -0,0 +1,36 @@
package com.docus.server.message.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author jiashi
* @since 2021-04-14
*/
@Data
public class FileDto {
private String PMR_ID;
private String PMR_NAME;
private String RCD_TYPE_CODE;
private String RCD_TYPE_NAME;
private String PMR_NAME_NO;
private String PMR_URL;
private String EMR_TYPE_CODE;
private String EMR_TYPE_NAME;
}

@ -0,0 +1,43 @@
package com.docus.server.message.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author jiashi
* @since 2021-04-14
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "TBasicExcel对象", description = "病案基本信息")
public class TBasicExcel implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "病案主键")
private String patientId;
@ApiModelProperty(value = "住院次数")
private Integer admissTimes;
@ApiModelProperty(value = "病案号")
private String inpatientNo;
@ApiModelProperty(value = "jzh")
private String jzh;
@ApiModelProperty(value = "身份证")
private String idCard;
}

@ -0,0 +1,62 @@
package com.docus.server.message.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author
* @since 2021-04-23
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "TScanAssort对象", description = "病案文件信息表 ")
public class TScanAssort implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.ID_WORKER_STR)
private Long id;
@ApiModelProperty(value = "病案id")
private String patientId;
@ApiModelProperty(value = "病案分类")
private String assortId;
@ApiModelProperty(value = "文件标题")
private String fileTitle;
@ApiModelProperty(value = "文件目录 单纯文件夹路径,不带文件名")
private String imagePath;
@ApiModelProperty(value = "文件名称")
private String scanPage;
@ApiModelProperty(value = "文件来源 1:pdf2图片")
private Integer fileSource;
@ApiModelProperty(value = "1:服务器本地2ftp服务器3共享文件夹")
private Integer fileStorageType;
@ApiModelProperty(value = "上传时间")
private Date createTime;
@ApiModelProperty(value = "页数")
private Integer filePages;
@ApiModelProperty(value = "来源系统 1护理文书2 电子病历3 Pacs检查4心电图5手麻信息6 Lis检验7病案首页8长临医嘱100客户从平台上传")
private String source;
}

@ -0,0 +1,32 @@
package com.docus.server.message.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.docus.server.message.entity.TBasicExcel;
import com.docus.server.message.entity.TScanAssort;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Mapper
public interface ZxjhMapper {
List<TBasicExcel> getBasicData(@Param("fileSource") String fileSource,
@Param("disDates") Date disDates,
@Param("disDatee") Date disDatee);
int saveLog(@Param("pid") String pid,@Param("msg") String msg);
int delete(@Param("pid") String pid);
int saveAssort(@Param("tScanAssorts")List<TScanAssort> tScanAssorts);
String getJzh(@Param("pid") String pid);
}

@ -0,0 +1,70 @@
<?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.message.mapper.ZxjhMapper">
<select id="getBasicData" resultType="com.docus.server.message.entity.TBasicExcel">
select
patient_id,
admiss_times,
inpatient_no,
id_card,
jzh
from t_basic_excel
where file_source=#{fileSource}
<if test="disDates!=null">
and dis_date &gt;= #{disDates}
</if>
<if test="disDatee!=null">
and dis_date &lt;= #{disDatee}
</if>
</select>
<insert id="saveLog">
INSERT INTO `docus_medicalrecord`.`t_basic_excel_log` (`patient_id`, `erro`)
VALUES (#{pid}, #{msg});
</insert>
<delete id="delete">
delete from `docus_archivefile`.t_scan_assort
where patient_id=#{pid}
</delete>
<insert id="saveAssort">
<foreach collection="tScanAssorts" item="tScanAssort" >
INSERT INTO `docus_archivefile`.`t_scan_assort` (
`id`,
`patient_id`,
`assort_id`,
`file_title`,
`image_path`,
`scan_page`,
`file_source`,
`file_storage_type`,
`create_time`,
`file_pages`,
`source`
) VALUES (
#{tScanAssort.id},
#{tScanAssort.patientId},
#{tScanAssort.assortId},
#{tScanAssort.fileTitle},
#{tScanAssort.imagePath},
#{tScanAssort.scanPage},
#{tScanAssort.fileSource},
#{tScanAssort.fileStorageType},
#{tScanAssort.createTime},
#{tScanAssort.filePages},
#{tScanAssort.source}
);
</foreach>
</insert>
<select id="getJzh" resultType="java.lang.String">
select
jzh
from t_basic_excel
where patient_id=#{pid}
</select>
</mapper>
Loading…
Cancel
Save