diff --git a/data-config/gdszyzh-collect-config b/data-config/gdszyzh-collect-config new file mode 100644 index 0000000..f08332b --- /dev/null +++ b/data-config/gdszyzh-collect-config @@ -0,0 +1,39 @@ +{ + "PACS": { + "collectorId": "PACS", + "assortId": "PACS-ASSORT", + "listUrl": "", + "listOperationName": "", + "listNamespaceUri": "", + "detailUrl": "", + "detailOperationName": "", + "detailNamespaceUri": "", + "filterReport": "" + }, + "LIS": { + "collectorId": "", + "assortId": "", + "listUrl": "", + "listOperationName": "", + "listNamespaceUri": "", + "detailUrl": "", + "detailOperationName": "", + "detailNamespaceUri": "", + "filterReport": "" + }, + "DyECG": { + "collectorId": "", + "assortId": "", + "filterReport": "" + }, + "ICU": { + "collectorId": "", + "assortId": "", + "filterReport": "" + }, + "MaZui": { + "collectorId": "", + "assortId": "", + "filterReport": "" + } +} \ No newline at end of file diff --git a/src/main/java/com/docus/server/gdszyzh/controller/ReportCollectController.java b/src/main/java/com/docus/server/gdszyzh/controller/ReportCollectController.java new file mode 100644 index 0000000..c8bbfc2 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/controller/ReportCollectController.java @@ -0,0 +1,38 @@ +package com.docus.server.gdszyzh.controller; + +import com.docus.core.util.Func; +import com.docus.infrastructure.web.api.CommonResult; +import com.docus.server.gdszyzh.service.ReportCollectService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import jline.internal.Log; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:35 + */ +@RestController +@RequestMapping("/gdszyzh") +@Api(tags = "广东省中医珠海文件接口") +public class ReportCollectController { + @Autowired + private ReportCollectService reportCollectService; + + @PostMapping("/collect/pacs") + @ApiOperation("采集PACS报告") + public CommonResult collectPacs(@RequestBody List patientIds) { + if (Func.isNotEmpty(patientIds)) { + Log.info("PACS报告采集接口,参数:{}", patientIds); + reportCollectService.collectPacs(patientIds); + } + return CommonResult.success("采集完成!"); + } +} diff --git a/src/main/java/com/docus/server/gdszyzh/entity/ReportDataView.java b/src/main/java/com/docus/server/gdszyzh/entity/ReportDataView.java new file mode 100644 index 0000000..726f2d5 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/entity/ReportDataView.java @@ -0,0 +1,25 @@ +package com.docus.server.gdszyzh.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 17:05 + */ +@Data +public class ReportDataView { + @ApiModelProperty("报告号") + private String reportNo; + @ApiModelProperty("报告标题") + private String reportTitle; + @ApiModelProperty("报告分类") + private String reportClass; + @ApiModelProperty("报告时间") + private Date reportTime; + @ApiModelProperty("报告地址") + private String reportUrl; +} diff --git a/src/main/java/com/docus/server/gdszyzh/job/PacsCollectJob.java b/src/main/java/com/docus/server/gdszyzh/job/PacsCollectJob.java new file mode 100644 index 0000000..4a9d9a1 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/job/PacsCollectJob.java @@ -0,0 +1,36 @@ +package com.docus.server.gdszyzh.job; + +import com.docus.server.gdszyzh.service.ReportCollectService; +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.util.ArrayList; +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:25 + */ +@Slf4j +@Component +public class PacsCollectJob { + @Autowired + private ReportCollectService reportCollectService; + + @XxlJob("GdSzyZhPacsCollectJob") + public void gdSzyZhPacsCollectJob() throws Exception { + log.info("广东省中医珠海,PACS采集任务开始!"); + try { + // todo wyb 需要采集的患者 + List patientIds = new ArrayList<>(); + reportCollectService.collectPacs(patientIds); + log.info("广东省中医珠海,PACS采集任务结束!"); + } catch (Exception e) { + log.error("广东省中医珠海,PACS采集任务出现异常!" + e.getMessage(), e); + } + } + +} diff --git a/src/main/java/com/docus/server/gdszyzh/service/ReportCollectService.java b/src/main/java/com/docus/server/gdszyzh/service/ReportCollectService.java new file mode 100644 index 0000000..ae65940 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/service/ReportCollectService.java @@ -0,0 +1,16 @@ +package com.docus.server.gdszyzh.service; + +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:28 + */ +public interface ReportCollectService { + /** + * PACS报告采集 + * @param patientIds 患者主键 + */ + void collectPacs(List patientIds); +} diff --git a/src/main/java/com/docus/server/gdszyzh/service/impl/ReportCollectServiceImpl.java b/src/main/java/com/docus/server/gdszyzh/service/impl/ReportCollectServiceImpl.java new file mode 100644 index 0000000..e99074a --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/service/impl/ReportCollectServiceImpl.java @@ -0,0 +1,105 @@ +package com.docus.server.gdszyzh.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.docus.core.util.Func; +import com.docus.server.archive.entity.TBasic; +import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.gdszyzh.service.ReportCollectService; +import com.docus.server.rpc.DownPlatformService; +import com.docus.server.rpc.GdSzyZhReportService; +import com.docus.server.rpc.dto.GdSzyZhReportDetailDto; +import com.docus.server.rpc.dto.GdSzyZhReportListDto; +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.util.TableJsonRead; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:28 + */ +@Slf4j +@Service +public class ReportCollectServiceImpl implements ReportCollectService { + @Autowired + private GdSzyZhReportService gdSzyZhReportService; + @Autowired + private TBasicMapper tBasicMapper; + @Autowired + private DownPlatformService downPlatformService; + + @Override + public void collectPacs(List patientIds) { + List basicList = tBasicMapper.getTbasicByPatientIds(patientIds); + for (TBasic basic : basicList) { + collectPacs(basic); + } + } + + private void collectPacs(TBasic basic) { + Date admissDate = basic.getAdmissDate(); + Date disDate = basic.getDisDate(); + String jzh = basic.getJzh(); + String empId = basic.getEmpId(); + String patientId = basic.getPatientId(); + if (Func.isBlank(empId) || Func.isEmpty(admissDate) || Func.isEmpty(disDate)) { + log.error("采集Pacs报告,患者:{},住院流水号:{},入院、出院时间,empId有空数据,无法采集!", basic.getInpatientNo(), jzh); + return; + } + String beginDate = Func.formatDate(admissDate); + String endDate = Func.formatDate(disDate); + GdSzyZhReportListDto pacsList = gdSzyZhReportService.pacsList(empId, jzh, beginDate, endDate); + List reportList = pacsList.getReportList(); + reportList = reportList.stream() + .sorted(Comparator.comparing(GdSzyZhReportListDto.Report::getReportClass) + .thenComparing(GdSzyZhReportListDto.Report::getReportTime)) + .collect(Collectors.toList()); + int sort = 0; + List scanFiles = new ArrayList<>(); + for (GdSzyZhReportListDto.Report report : reportList) { + String reportNo = report.getReportNo(); + GdSzyZhReportDetailDto pacsDetail = gdSzyZhReportService.pacsDetail(reportNo); + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(pacsDetail.getReportUrl()); + reportDownScanFileDto.setFiletitle(report.getReportTitle()); + reportDownScanFileDto.setSerialnum(reportNo); + reportDownScanFileDto.setFilesource(1); + reportDownScanFileDto.setFiletype(1); + reportDownScanFileDto.setFilestoragetype(1); + reportDownScanFileDto.setTaskid(-1L); + reportDownScanFileDto.setSort(++sort); + } + + final String configPath = "data-config"; + final String configName = "gdszyzh-collect-config"; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + JSONObject pacsWsConfig = configOjb.getJSONObject("PACS"); + String collectorId = pacsWsConfig.getString("collectorId"); + String assortId = pacsWsConfig.getString("assortId"); + + ReportDownPatientDto patient = new ReportDownPatientDto(); + patient.setPatientid(patientId); + ReportDownDto reportDownDto = new ReportDownDto(); + reportDownDto.setCollectorid(collectorId); + reportDownDto.setIp(""); + reportDownDto.setPatient(patient); + reportDownDto.setAssortid(assortId); + reportDownDto.setScanfiles(scanFiles); + downPlatformService.report(reportDownDto); + } + + public static void main(String[] args) { + + } +} diff --git a/src/main/java/com/docus/server/rpc/GdSzyZhReportService.java b/src/main/java/com/docus/server/rpc/GdSzyZhReportService.java new file mode 100644 index 0000000..13c5dec --- /dev/null +++ b/src/main/java/com/docus/server/rpc/GdSzyZhReportService.java @@ -0,0 +1,32 @@ +package com.docus.server.rpc; + +import com.docus.server.rpc.dto.GdSzyZhReportDetailDto; +import com.docus.server.rpc.dto.GdSzyZhReportListDto; + +/** + * 广东省中医珠海 报告接口 + * @author YongBin Wen + * @date 2026/4/7 15:18 + */ +public interface GdSzyZhReportService { + + /** + * 查询患者的PACS报告列表 + * @param beginDate 格式 yyyy-MM-dd + * @param endDate 格式 yyyy-MM-dd + */ + GdSzyZhReportListDto pacsList(String empId, String jzh, String beginDate, String endDate); + /** + * 根据PACS报告号查询报告明细 + */ + GdSzyZhReportDetailDto pacsDetail(String examNo); + + /** + * 查询患者的LIS检验报告列表 + */ + GdSzyZhReportListDto lisList(String empId,String jzh,String beginDate,String endDate); + /** + * 根据LIS报告号查询报告明细 + */ + GdSzyZhReportDetailDto lisDetail(String sampleNo); +} diff --git a/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportDetailDto.java b/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportDetailDto.java new file mode 100644 index 0000000..4bb4af0 --- /dev/null +++ b/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportDetailDto.java @@ -0,0 +1,15 @@ +package com.docus.server.rpc.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 15:29 + */ +@Data +public class GdSzyZhReportDetailDto { + @ApiModelProperty("报告地址") + private String reportUrl; +} diff --git a/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportListDto.java b/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportListDto.java new file mode 100644 index 0000000..172efd1 --- /dev/null +++ b/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportListDto.java @@ -0,0 +1,31 @@ +package com.docus.server.rpc.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 15:28 + */ +@Data +public class GdSzyZhReportListDto { + + @ApiModelProperty("报告列表") + private List reportList; + + @Data + public static class Report { + @ApiModelProperty("报告号") + private String reportNo; + @ApiModelProperty("报告标题") + private String reportTitle; + @ApiModelProperty("报告分类") + private String reportClass; + @ApiModelProperty("报告时间") + private Date reportTime; + } +} diff --git a/src/main/java/com/docus/server/rpc/impl/GdSzyZhReportServiceImpl.java b/src/main/java/com/docus/server/rpc/impl/GdSzyZhReportServiceImpl.java new file mode 100644 index 0000000..919d508 --- /dev/null +++ b/src/main/java/com/docus/server/rpc/impl/GdSzyZhReportServiceImpl.java @@ -0,0 +1,201 @@ +package com.docus.server.rpc.impl; + +import com.alibaba.fastjson.JSONObject; +import com.docus.core.util.Func; +import com.docus.server.rpc.GdSzyZhReportService; +import com.docus.server.rpc.dto.GdSzyZhReportDetailDto; +import com.docus.server.rpc.dto.GdSzyZhReportListDto; +import com.docus.server.util.JaxWsDynamicClientUtil; +import com.docus.server.util.TableJsonRead; +import com.docus.server.util.XmlUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 15:18 + */ +@Slf4j +@Service +public class GdSzyZhReportServiceImpl implements GdSzyZhReportService { + final String configPath = "data-config"; + final String configName = "gdszyzh-collect-config"; + + @Override + public GdSzyZhReportListDto pacsList(String empId, String jzh, String beginDate, String endDate) { + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + + JSONObject pacsWsConfig = configOjb.getJSONObject("PACS"); + String wsUrl = pacsWsConfig.getString("listUrl"); + String namespaceUri = pacsWsConfig.getString("listNamespaceUri"); + String method = pacsWsConfig.getString("listOperationName"); + String param = pacsListParam(empId, jzh, beginDate, endDate); + String[] params = {param}; + Object resultObj = JaxWsDynamicClientUtil.send(wsUrl, namespaceUri, method, params); + String result = String.valueOf(resultObj); + log.info("PACS查询报告列表,地址:{},方法:{},参数:{} 调用成功,得到结果为:{}", wsUrl, method, param, result); + return parsePacsListResult(result); + } + + + @Override + public GdSzyZhReportDetailDto pacsDetail(String examNo) { + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + + JSONObject pacsWsConfig = configOjb.getJSONObject("PACS"); + String wsUrl = pacsWsConfig.getString("detailUrl"); + String namespaceUri = pacsWsConfig.getString("detailNamespaceUri"); + String method = pacsWsConfig.getString("detailOperationName"); + String param = pacsDetailParam(examNo); + String[] params = {param}; + Object resultObj = JaxWsDynamicClientUtil.send(wsUrl, namespaceUri, method, params); + String result = String.valueOf(resultObj); + log.info("PACS查询报告详情,地址:{},方法:{},参数:{} 调用成功,得到结果为:{}", wsUrl, method, param, result); + return parsePacsDetailResult(result); + } + + + private static String pacsListParam(String empId, String jzh, String beginDate, String endDate) { + return "" + + "" + + "1" + + "HIS_ZY" + + "HIS_ZY_0330" + + "BS04002" + + "BS04002S02001" + + "ZH" + + "" + + "" + + "BS04002" + + "BS04002S02001" + + "S02" + + "S00" + + "2020-04-27 23:41:09" + + "" + + "" + + "0" + + "500" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "001" + + "" + + "" + jzh + "" + + "" + + "" + + "" + empId + "" + + "" + beginDate + "" + + "" + endDate + "" + + "PACS.CS,PACS.CT,PACS.FS" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + } + + private static GdSzyZhReportListDto parsePacsListResult(String result) { + XmlUtil xmlUtil = XmlUtil.of(result); + NodeList examInfoList = xmlUtil.getNodeList("/Response/MsgInfo/Msg/ExamInfo"); + int length = examInfoList.getLength(); + List reportList = new ArrayList<>(); + for (int i = 1; i <= length; i++) { + Node examNoNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ExamInfo[" + i + "]/EXAM_NO"); + Node examClassNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ExamInfo[" + i + "]/EXAM_CATEG_CODE"); + Node examDateNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ExamInfo[" + i + "]/EXAM_DATE"); + Node examTimeNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ExamInfo[" + i + "]/EXAM_TIME"); + Node examItemNameNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ExamInfo[" + i + "]/ExamItemInfo/EXAM_ITEM_NAME"); + String examDateTime = examDateNode.getTextContent() + " " + examTimeNode.getTextContent(); + GdSzyZhReportListDto.Report report = new GdSzyZhReportListDto.Report(); + report.setReportNo(examNoNode.getTextContent()); + report.setReportTitle(examItemNameNode.getTextContent()); + report.setReportClass(examClassNode.getTextContent()); + report.setReportTime(Func.parseDate(examDateTime,"yyyy-MM-dd HH:mm:ss")); + reportList.add(report); + } + GdSzyZhReportListDto dto = new GdSzyZhReportListDto(); + dto.setReportList(reportList); + return dto; + } + + + private static String pacsDetailParam(String examNo) { + return "" + + "" + + "1" + + "HIS_ZY" + + "HIS_ZY_0330" + + "BS04002" + + "BS04002S02001" + + "ZH" + + "" + + "" + + "BS04002" + + "BS04002S02001" + + "S02" + + "S00" + + "2020-04-27 23:41:09" + + "" + + "" + + "0" + + "500" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + examNo + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + } + + private static GdSzyZhReportDetailDto parsePacsDetailResult(String result) { + XmlUtil xmlUtil = XmlUtil.of(result); + Node reportUrlNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ReportInfo/REPORT_URL2"); + String reportUrl = reportUrlNode.getTextContent(); + GdSzyZhReportDetailDto dto = new GdSzyZhReportDetailDto(); + dto.setReportUrl(reportUrl); + return dto; + } + + @Override + public GdSzyZhReportListDto lisList(String empId, String jzh, String beginDate, String endDate) { + // TODO wyb 接口未测试 + return null; + } + + @Override + public GdSzyZhReportDetailDto lisDetail(String sampleNo) { + // TODO wyb 接口未测试 + return null; + } +} diff --git a/src/main/resources/mapper/TBasicMapper.xml b/src/main/resources/mapper/TBasicMapper.xml index 3da61ba..06f8cb8 100644 --- a/src/main/resources/mapper/TBasicMapper.xml +++ b/src/main/resources/mapper/TBasicMapper.xml @@ -69,7 +69,8 @@ admiss_date as admissDate, dis_date as disDate, id_card as idCard, - jzh + jzh, + emp_id as empId from docus_medicalrecord.t_basic where patient_id in