feat: 英德中医院pacs补偿失败只补偿失败的,调用接口

master
wyb 10 months ago
parent aec246c3ca
commit 80d669bd03

@ -0,0 +1,16 @@
package com.docus.server.rpc;
/**
* @author YongBin Wen
* @date 2024/9/14 16:53
*/
public interface YdZyyPacsService {
/**
* pacs
* @date 2024/9/14 16:59
* @author YongBin Wen
* @param remark
* @return base64
*/
String getJpgReportBase64(String remark);
}

@ -0,0 +1,132 @@
package com.docus.server.rpc.impl;
import com.docus.server.rpc.YdZyyPacsService;
import com.docus.server.util.XmlUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.w3c.dom.Node;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
/**
* @author YongBin Wen
* @date 2024/9/14 16:53
*/
@Component
@Slf4j
public class YdZyyPacsServiceImpl implements YdZyyPacsService {
@Override
public String getJpgReportBase64(String remark) {
String wsUrl = "http://10.10.100.106:8011/PACS_WS.asmx";
String method = "GetStudyReportPreview";
String param = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://127.0.0.1/\">\n" +
" <soapenv:Header/>\n" +
" <soapenv:Body>\n" +
" <ns:GetStudyReportPreview>\n" +
" <!--Optional:-->\n" +
" <ns:para>\n" +
" <ns:DataFormat>dfXML</ns:DataFormat>\n" +
" <!--Optional:-->\n" +
" <ns:Token></ns:Token>\n" +
" <!--Optional:-->\n" +
" <ns:Para>\n" +
" <![CDATA[\n" +
" <CallPara><HospitalID>32</HospitalID><SerialNo>" + remark + "</SerialNo><ImageType>JPG</ImageType><ImageDPI>300</ImageDPI><OutFilePath>D:\\CTTEST</OutFilePath><ConvertBase64>TRUE</ConvertBase64></CallPara>\n" +
" ]]>\n" +
" \n" +
" \n" +
" </ns:Para>\n" +
" </ns:para>\n" +
" </ns:GetStudyReportPreview>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope>";
try {
// 服务器地址
URL url = new URL(wsUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// 拼接soap
byte[] buf = param.getBytes(StandardCharsets.UTF_8);
// 设置报头
conn.setRequestProperty("Content-Length", String.valueOf(buf.length));
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
conn.setRequestProperty("soapActionString", method);
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
OutputStream out = conn.getOutputStream();
out.write(buf);
out.close();
// 获取响应状态码
int code = conn.getResponseCode();
StringBuilder respXml = new StringBuilder();
if (code == HttpStatus.OK.value()) {
InputStream is = conn.getInputStream();
byte[] b = new byte[1024];
int len;
while ((len = is.read(b)) != -1) {
String s = new String(b, 0, len, StandardCharsets.UTF_8);
respXml.append(s);
}
is.close();
}
return parsePacsBase64(respXml.toString());
} catch (Exception ex) {
log.error("英德中医院获取pacs报告出现异常参数" + param + ",异常信息:" + ex.getMessage(), ex);
return null;
}
}
private static String parsePacsBase64(String soapResult) {
String startStr = "<GetStudyReportPreviewResult>";
String endStr = "</GetStudyReportPreviewResult>";
int start = soapResult.indexOf(startStr);
int end = soapResult.indexOf(endStr) + endStr.length();
soapResult = soapResult.substring(start, end);
soapResult = soapResult.replace("&lt;", "<");
soapResult = soapResult.replace("&gt;", ">");
XmlUtil xmlUtil = XmlUtil.of(soapResult);
Node errorCodeNode = xmlUtil.getNode("/GetStudyReportPreviewResult/iErrorCode");
if ("0".equals(errorCodeNode.getTextContent())) {
Node fileBase64Node = xmlUtil.getNode("/GetStudyReportPreviewResult/sResultValue/string/FileBase64");
if (fileBase64Node != null) {
return fileBase64Node.getTextContent();
}
}
return null;
}
public static void main(String[] args) {
String result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" +
"\t<soap:Body>\n" +
"\t\t<GetStudyReportPreviewResponse xmlns=\"http://127.0.0.1/\">\n" +
"\t\t\t<GetStudyReportPreviewResult>\n" +
"\t\t\t\t<DataFormat>dfXML</DataFormat>\n" +
"\t\t\t\t<iErrorCode>0</iErrorCode>\n" +
"\t\t\t\t<sErrorMessage>执行成功</sErrorMessage>\n" +
"\t\t\t\t<iResultValue>0</iResultValue>\n" +
"\t\t\t\t<sResultValue>\n" +
"\t\t\t\t\t<string>&lt;ImageType&gt;JPG&lt;/ImageType&gt;\n" +
"&lt;ImageDPI&gt;300&lt;/ImageDPI&gt;\n" +
"&lt;FileName&gt;D:\\CTTEST\\PACS_REPORT_IMAGE_2018935_202409141634352881.JPG&lt;/FileName&gt;\n" +
"&lt;ImageSize&gt;0&lt;/ImageSize&gt;\n" +
"&lt;Md5Value&gt;&lt;/Md5Value&gt;\n" +
"&lt;FileBase64&gt;/9j/4AAQSkZJRgABAQEAYABgAAtLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3oAKKKKACiiigAooooAKKKKAP/Z&lt;/FileBase64&gt;\n" +
"</string>\n" +
"\t\t\t\t</sResultValue>\n" +
"\t\t\t</GetStudyReportPreviewResult>\n" +
"\t\t</GetStudyReportPreviewResponse>\n" +
"\t</soap:Body>\n" +
"</soap:Envelope>";
System.out.println(parsePacsBase64(result));
}
}

@ -0,0 +1,30 @@
package com.docus.server.ydzyy.controller;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.rpc.YdZyyPacsService;
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;
/**
* api
*/
@RestController
@RequestMapping("/ydzyyApi")
public class ApiController {
@Autowired
private YdZyyPacsService pacsService;
/**
*
*/
@GetMapping("/pacs/xml")
public CommonResult<String> lisXmlTest(@RequestParam(name = "remark") String remark) {
String base64 = pacsService.getJpgReportBase64(remark);
return CommonResult.success(base64);
}
}

@ -8,6 +8,7 @@ import com.docus.server.archive.entity.AfCollectTask;
import com.docus.server.archive.entity.TBasic;
import com.docus.server.archive.mapper.TBasicMapper;
import com.docus.server.rpc.DownPlatformService;
import com.docus.server.rpc.YdZyyPacsService;
import com.docus.server.rpc.dto.ReportDownDto;
import com.docus.server.rpc.dto.ReportDownPatientDto;
import com.docus.server.rpc.dto.ReportDownScanFileDto;
@ -47,6 +48,9 @@ public class PacsCollectJob {
@Resource
private IdService idService;
@Resource
private YdZyyPacsService ydZyyPacsService;
@XxlJob("Ydzyy-CollectPacsByModifyTime")
public void collectPacsByModifyTime() {
@ -118,21 +122,55 @@ public class PacsCollectJob {
@XxlJob("Ydzyy-CollectPacsByFailedTask")
public void collectPacsByFailedTask() {
String collectorId = "3";
String assortId = "AC2C8F4A88884DC894630302C61C6A07";
List<String> notReCollectState = Arrays.asList("3", "4");
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs任务补偿job开始任务");
try {
LocalDate startDate = LocalDate.now().plusMonths(-3);
String startDateStr = startDate + " 00:00:00";
String collectorId = "3";
List<String> patientIds = tBasicMapper.findFailedTaskPatId(collectorId, startDateStr);
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs任务补偿job,查询创建时间>={} 失败的任务患者数量:{} 个。", startDateStr, patientIds);
if (Func.isEmpty(patientIds)) {
return;
}
List<TBasic> tBasicList = tBasicMapper.getTbasicByPatientIds(patientIds);
for (TBasic tBasic : tBasicList) {
collectPacs(tBasic);
// 失败重采不从视图,从接口获取
// List<TBasic> tBasicList = tBasicMapper.getTbasicByPatientIds(patientIds);
// for (TBasic tBasic : tBasicList) {
// collectPacs(tBasic);
// }
for (String patientId : patientIds) {
ReportDownPatientDto patient = new ReportDownPatientDto();
patient.setPatientid(patientId);
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setAssortid(assortId);
reportDownDto.setCollectorid(collectorId);
reportDownDto.setIp("java-collect-pacs");
reportDownDto.setPatient(patient);
List<AfCollectTask> tasks = tBasicMapper.getCollectTaskByPatAndSource(patientId, collectorId);
List<AfCollectTask> reCollectTask = tasks.stream().filter(task -> !notReCollectState.contains(task.getState())).collect(Collectors.toList());
for (AfCollectTask task : reCollectTask) {
String remark = task.getC1();
String base64 = ydZyyPacsService.getJpgReportBase64(remark);
if (Func.isBlank(base64)) {
log.info("remark:{} 获取pacs图片报告base64失败", remark);
continue;
}
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setDownurl(base64);
reportDownScanFileDto.setFiletitle(task.getC6());
reportDownScanFileDto.setSerialnum(remark);
reportDownScanFileDto.setFilesource(1);
reportDownScanFileDto.setFiletype(2);
reportDownScanFileDto.setFilestoragetype(1);
reportDownScanFileDto.setTaskid(task.getId());
List<ReportDownScanFileDto> scanFiles = Collections.singletonList(reportDownScanFileDto);
reportDownDto.setScanfiles(scanFiles);
downPlatformService.report(reportDownDto);
}
}
} catch (Exception ex) {
log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs任务补偿job出现异常结束任务" + ex.getMessage(), ex);
}

Loading…
Cancel
Save