feat: 梅州中医院LIS检验单采集

master
wyb 4 months ago
parent dce5abdc3e
commit 2c5a8cdea7

@ -0,0 +1,11 @@
{
"lis":{
"collectorId":"1",
"assortId":"lis",
"url": "http://199.168.91.176:9001/NeuLisExportPDFService.asmx?wsdl",
"namespaceUri": "",
"pdfListOperationName": "GetTestFormPDF",
"RTBase64OperationName": "ExportTestFormPDF_GMForNoPaper",
"GMBase64OperationName": "ExportTestFormPDF_GMForNoPaper"
}
}

@ -0,0 +1,26 @@
package com.docus.server.config;
import com.docus.server.util.StaticResourceMapping;
import com.docus.server.util.TableJsonRead;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.io.File;
/**
* @author WYBDEV
*/
@Configuration
public class StaticResourceWebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// 静态资源映射
registry.addResourceHandler("/"+ StaticResourceMapping.LIS +"/**")
.addResourceLocations("file:"+ TableJsonRead.currentPath(StaticResourceMapping.STATIC_RESOURCE_PREFIX+ File.separator+StaticResourceMapping.LIS)+File.separator);
}
}

@ -69,7 +69,8 @@ public class GzZxyJhPMRSCollectJob {
String param2 = "<MESSAGE><BODY><ROWS><ROW><VISIT_NO>" + jzh + "</VISIT_NO></ROW></ROWS></BODY></MESSAGE>";
String[] params = {param1, param2};
String result = JaxWsDynamicClientUtil.send(url, namespaceUri, operationName, params);
Object resultObj = JaxWsDynamicClientUtil.send(url, namespaceUri, operationName, params);
String result = String.valueOf(resultObj);
List<FileDto> fileDtos = parseFileDtos(result);
int size = fileDtos.size();

@ -0,0 +1,58 @@
package com.docus.server.mzzyy.controller;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.rpc.MzZyyLisService;
import com.docus.server.rpc.dto.MzZyyLisExportDto;
import com.docus.server.rpc.dto.MzZyyTestDto;
import com.docus.server.rpc.enums.MzZyyLisType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* api
*/
@RestController
@RequestMapping("/mzzyyApi")
@Api(tags = "梅州中医院文件采集接口")
public class MzZyyApiController {
@Autowired
private MzZyyLisService mzZyyLisService;
/**
*
*/
@GetMapping("/lis/getpdftest")
@ApiOperation("获取lis报告列表接口测试")
public CommonResult<Object> getpdftest(@RequestParam(name = "jzh") String jzh,
@RequestParam(name = "inpatientNo") String inpatientNo,
@RequestParam(name = "patientType") String patientType) {
List<MzZyyTestDto> list = mzZyyLisService.getTestFormPdf(jzh, inpatientNo, patientType);
return CommonResult.success(list);
}
/**
*
*/
@GetMapping("/lis/base64test")
@ApiOperation("获取lis报告base64接口测试")
public CommonResult<Object> base64test(@RequestParam(name = "type") String type,
@RequestParam(name = "machineId") String machineId,
@RequestParam(name = "sampleId") String sampleId,
@RequestParam(name = "testdate") String testdate) {
MzZyyLisType mzZyyLisType = MzZyyLisType.getLisType(type);
List<MzZyyLisExportDto> files = mzZyyLisService.exportTestFormPdf(mzZyyLisType, machineId, sampleId, testdate);
return CommonResult.success(files);
}
public static void main(String[] args) {
System.out.println(new MzZyyLisExportDto());
}
}

@ -0,0 +1,130 @@
package com.docus.server.mzzyy.job;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject;
import com.docus.core.util.Func;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.infrastructure.web.api.ResultCode;
import com.docus.server.rpc.DownPlatformService;
import com.docus.server.rpc.MzZyyLisService;
import com.docus.server.rpc.TaskDistributeService;
import com.docus.server.rpc.dto.MzZyyLisExportDto;
import com.docus.server.rpc.dto.MzZyyTestDto;
import com.docus.server.rpc.dto.ReportDownDto;
import com.docus.server.rpc.dto.ReportDownPatientDto;
import com.docus.server.rpc.dto.ReportDownScanFileDto;
import com.docus.server.rpc.dto.ReportDownTwoDto;
import com.docus.server.rpc.dto.ReportHospitalTwoDto;
import com.docus.server.rpc.dto.ReportPatientTwoDto;
import com.docus.server.rpc.dto.ReportTaskTwoDto;
import com.docus.server.rpc.enums.MzZyyLisType;
import com.docus.server.util.StaticResourceMapping;
import com.docus.server.util.TableJsonRead;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* @author YongBin Wen
* @date 2025/3/18 9:18
*/
@Component
@Slf4j
public class MzZyyLisCollectJob {
@Autowired
private DownPlatformService downPlatformService;
@Autowired
private TaskDistributeService taskDistributeService;
@Autowired
private MzZyyLisService mzZyyLisService;
@XxlJob("MzZyyLisCollectJob")
public void lisCollectJob() {
String configPath = "data-config";
String configName = "mzzyy-ws-config";
TableJsonRead jsonReader = new TableJsonRead();
JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class);
JSONObject lisWsConfig = configOjb.getJSONObject("lis");
String collectorId = lisWsConfig.getString("collectorId");
String assortId = lisWsConfig.getString("assortId");
CommonResult<ReportDownTwoDto> commonResult = taskDistributeService.getNoViewTaskByCollectorId(collectorId);
if (!ResultCode.SUCCESS.getCode().equals(commonResult.getCode())
|| commonResult.getData() == null) {
return;
}
final String fileTitle = "Lis检查报告单";
ReportDownTwoDto downTwoDto = commonResult.getData();
ReportTaskTwoDto task = downTwoDto.getTasks().get(0);
log.info(">>>>>>>>>>>>>>>>>>>>>> 梅州中医院Lis采集任务获取了任务{}", Func.toJson(task));
ReportHospitalTwoDto hospitalTwoDto = downTwoDto.getHospitals().get(0);
ReportPatientTwoDto reportPatientTwoDto = downTwoDto.getPatient();
String jzh = downTwoDto.getJzh();
String patientId = downTwoDto.getPatientId();
String inpatientNo = reportPatientTwoDto.getInpatientNo();
String patientType = "住院";
List<MzZyyTestDto> testFormPdfs = mzZyyLisService.getTestFormPdf(jzh, inpatientNo, patientType);
if (Func.isEmpty(testFormPdfs)) {
return;
}
String formatDate = Func.formatDate(new Date());
String fileDirPath = TableJsonRead.currentPath(StaticResourceMapping.STATIC_RESOURCE_PREFIX + File.separator + StaticResourceMapping.LIS)
+ File.separator + formatDate
+ File.separator + patientId;
List<String> httpUrls = new ArrayList<>();
int i = 1;
for (MzZyyTestDto testFormPdf : testFormPdfs) {
MzZyyLisType lisType = MzZyyLisType.getLisType(testFormPdf.getType());
List<MzZyyLisExportDto> base64Files = mzZyyLisService.exportTestFormPdf(lisType, testFormPdf.getMachineId(), testFormPdf.getSampleId(), testFormPdf.getTestDate());
for (MzZyyLisExportDto base64File : base64Files) {
String filePath = fileDirPath + File.separator + i + "." + base64File.getType().toLowerCase(Locale.ROOT);
String httpUrl = "http://127.0.0.1:9010/lis/" + formatDate + "/" + patientId + "/" + i + "." + base64File.getType().toLowerCase(Locale.ROOT);
String base64 = base64File.getBase64();
byte[] decode = Base64.getDecoder().decode(base64);
FileUtil.writeBytes(decode, filePath);
httpUrls.add(httpUrl);
i++;
}
}
log.info("住院号:{},住院流水号:{},采集了 {} 份文件。", inpatientNo, jzh, httpUrls.size());
String urls = String.join("|", httpUrls);
ReportDownPatientDto patient = new ReportDownPatientDto();
patient.setPatientid(patientId);
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(collectorId);
reportDownDto.setIp("java-lis-job");
reportDownDto.setPatient(patient);
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setFiletype(1);
reportDownScanFileDto.setDownurl(urls);
reportDownScanFileDto.setFiletitle(fileTitle);
reportDownScanFileDto.setSerialnum("lis_" + patientId);
reportDownScanFileDto.setFilesource(1);
reportDownScanFileDto.setFilestoragetype(1);
reportDownScanFileDto.setTaskid(task.getTaskId());
reportDownScanFileDto.setSort(0);
List<ReportDownScanFileDto> scanFiles = Collections.singletonList(reportDownScanFileDto);
reportDownDto.setAssortid(assortId);
reportDownDto.setScanfiles(scanFiles);
downPlatformService.report(reportDownDto);
}
}

@ -0,0 +1,36 @@
package com.docus.server.rpc;
import com.docus.server.rpc.dto.MzZyyLisExportDto;
import com.docus.server.rpc.dto.MzZyyTestDto;
import com.docus.server.rpc.enums.MzZyyLisType;
import java.util.List;
/**
* @author YongBin Wen
* @date 2025/3/18 9:27
*/
public interface MzZyyLisService {
/**
*
* GetTestFormPDF
*
* @param jzh jzh
* @param inpatientNo inpatientNo
* @param patientType /
* @return TESTDATE|MACHINEID|SAMPLEID|HISITEMNAMELIST|RT/GM
*/
List<MzZyyTestDto> getTestFormPdf(String jzh, String inpatientNo, String patientType);
/**
* JSONJPG/PDFBASE64JPGJPGBASE64
* ExportTestFormPDF_RTForNoPaperRTExportTestFormPDF_GMForNoPaperGM
*
* @param type
* @param machineId
* @param sampleId
* @param testdate
* @return
*/
List<MzZyyLisExportDto> exportTestFormPdf(MzZyyLisType type, String machineId, String sampleId, String testdate);
}

@ -0,0 +1,21 @@
package com.docus.server.rpc.dto;
import lombok.Getter;
import lombok.Setter;
/**
* @author YongBin Wen
* @date 2025/3/18 9:33
*/
@Getter
@Setter
public class MzZyyLisExportDto {
/**
* JPG/PDF
*/
private String type;
/**
* BASE64
*/
private String base64;
}

@ -0,0 +1,33 @@
package com.docus.server.rpc.dto;
import lombok.Data;
/**
* @author YongBin Wen
* @date 2025/3/18 11:09
*/
@Data
public class MzZyyTestDto {
/**
* yyyyMMdd
*/
private String testDate;
/**
*
*/
private String machineId;
/**
*
*/
private String sampleId;
/**
*
*/
private String hisItemNameList;
/**
* RT/GM
*/
private String type;
}

@ -0,0 +1,26 @@
package com.docus.server.rpc.enums;
/**
* @author YongBin Wen
* @date 2025/3/18 9:37
*/
public enum MzZyyLisType {
/**
* RT
*/
RT,
/**
* GM
*/
GM;
public static MzZyyLisType getLisType(String type) {
if ("RT".equalsIgnoreCase(type)) {
return MzZyyLisType.RT;
} else if ("GM".equalsIgnoreCase(type)) {
return MzZyyLisType.GM;
}
return null;
}
}

@ -30,7 +30,14 @@ public class DownPlatformServiceImpl implements DownPlatformService {
String downUrl = serverUrlConfig.getDownloadPlatformServerUrl() + "api/downplatform/report";
String requestId = Func.randomUUID();
String requestParam = Func.toJson(reportDownDto);
log.info("[{}]调用下载服务,地址:{} ,参数:{}", requestId, downUrl, requestParam);
String requestLogParam = requestParam;
if (reportDownDto.getScanfiles().get(0).getFiletype() == 2) {
String downurl = reportDownDto.getScanfiles().get(0).getDownurl();
reportDownDto.getScanfiles().get(0).setDownurl("base64Str");
requestLogParam = Func.toJson(reportDownDto);
reportDownDto.getScanfiles().get(0).setDownurl(downurl);
}
log.info("[{}]调用下载服务,地址:{} ,参数:{}", requestId, downUrl, requestLogParam);
String respBody = post(downUrl, requestParam);
log.info("[{}]调用下载服务成功,响应参数:{}", requestId, respBody);
return Func.readJson(respBody, CommonResult.class);

@ -0,0 +1,82 @@
package com.docus.server.rpc.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.docus.server.rpc.MzZyyLisService;
import com.docus.server.rpc.dto.MzZyyLisExportDto;
import com.docus.server.rpc.dto.MzZyyTestDto;
import com.docus.server.rpc.enums.MzZyyLisType;
import com.docus.server.util.JaxWsDynamicClientUtil;
import com.docus.server.util.TableJsonRead;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author YongBin Wen
* @date 2025/3/18 9:27
*/
@Service
@Slf4j
public class MzZyyLisServiceImpl implements MzZyyLisService {
final String configPath = "data-config";
final String configName = "mzzyy-ws-config";
@Override
public List<MzZyyTestDto> getTestFormPdf(String jzh, String inpatientNo, String patientType) {
TableJsonRead jsonReader = new TableJsonRead();
JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class);
JSONObject lisWsConfig = configOjb.getJSONObject("lis");
String wsUrl = lisWsConfig.getString("url");
String namespaceUri = lisWsConfig.getString("namespaceUri");
String method = lisWsConfig.getString("pdfListOperationName");
String[] params = {jzh, inpatientNo, patientType};
Object result = JaxWsDynamicClientUtil.send(wsUrl, namespaceUri, method, params);
String reportDataJsonStr = JSONObject.toJSONString(result);
JSONObject reportDataObject = JSONObject.parseObject(reportDataJsonStr);
JSONArray jsonArray = reportDataObject.getJSONArray("string");
return jsonArray.toJavaList(String.class).stream()
.map(str ->{
String[] split = str.split("\\|");
MzZyyTestDto dto = new MzZyyTestDto();
dto.setTestDate(split[0]);
dto.setMachineId(split[1]);
dto.setSampleId(split[2]);
dto.setHisItemNameList(split[3]);
dto.setType(split[4]);
return dto;
}).sorted(Comparator.comparing(MzZyyTestDto::getTestDate)).collect(Collectors.toList());
}
@Override
public List<MzZyyLisExportDto> exportTestFormPdf(MzZyyLisType type, String machineId, String sampleId, String testdate) {
TableJsonRead jsonReader = new TableJsonRead();
JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class);
JSONObject lisWsConfig = configOjb.getJSONObject("lis");
String wsUrl = lisWsConfig.getString("url");
String namespaceUri = lisWsConfig.getString("namespaceUri");
String method = null;
if (type == MzZyyLisType.GM) {
method = lisWsConfig.getString("GMBase64OperationName");
} else if (type == MzZyyLisType.RT) {
method = lisWsConfig.getString("RTBase64OperationName");
} else {
return null;
}
String[] params = {machineId, sampleId, testdate};
Object resultObj = JaxWsDynamicClientUtil.send(wsUrl, namespaceUri, method, params);
String result = String.valueOf(resultObj);
return JSONObject.parseArray(result,MzZyyLisExportDto.class);
}
}

@ -23,7 +23,7 @@ public class JaxWsDynamicClientUtil {
private static final Map<String, Client> CLIENT_MAP = new ConcurrentHashMap<>();
private static final Logger logger = LoggerFactory.getLogger(JaxWsDynamicClientUtil.class);
public static String send(String wsdlUrl, String namespaceUri, String operationName, Object[] params) {
public static Object send(String wsdlUrl, String namespaceUri, String operationName, Object[] params) {
logger.info("wsdlUrl" + wsdlUrl + " ,namespaceUri: " + namespaceUri + " operationName" + operationName + "param:" + Arrays.toString(params));
try {
Client client = getClient(wsdlUrl);
@ -38,7 +38,7 @@ public class JaxWsDynamicClientUtil {
if (result == null || result[0] == null) {
return null;
}
return String.valueOf(result[0]);
return result[0];
} catch (Exception ex) {
logger.error("wsdlUrl" + wsdlUrl + ",namespaceUri: " + namespaceUri + " operationName" + operationName + "param:" + Arrays.toString(params) + " 调用失败了_"+ex.getMessage(), ex);
return null;

@ -0,0 +1,21 @@
package com.docus.server.util;
/**
* @author WYBDEV
*/
public interface StaticResourceMapping {
/**
*
*/
String STATIC_RESOURCE_PREFIX ="static";
/**
*
*/
String BLOOD = "blood";
/**
* lis
*/
String LIS= "lis";
}
Loading…
Cancel
Save