diff --git a/data-config/gdszyzh-collect-config b/data-config/gdszyzh-collect-config index f08332b..68120b0 100644 --- a/data-config/gdszyzh-collect-config +++ b/data-config/gdszyzh-collect-config @@ -2,26 +2,26 @@ "PACS": { "collectorId": "PACS", "assortId": "PACS-ASSORT", - "listUrl": "", - "listOperationName": "", + "listUrl": "http://172.16.99.220:7801/Ewell_WS_S02?wsdl", + "listOperationName": "OperationA", "listNamespaceUri": "", - "detailUrl": "", - "detailOperationName": "", + "detailUrl": "http://172.16.99.220:7801/Ewell_WS_S02?wsdl", + "detailOperationName": "OperationA", "detailNamespaceUri": "", "filterReport": "" }, "LIS": { "collectorId": "", "assortId": "", - "listUrl": "", - "listOperationName": "", + "listUrl": "http://172.16.56.150:8304/XingHePlatform.asmx?wsdl", + "listOperationName": "CallInterface", "listNamespaceUri": "", - "detailUrl": "", - "detailOperationName": "", + "detailUrl": "http://172.16.56.150:8304/XingHePlatform.asmx?wsdl", + "detailOperationName": "CallInterface", "detailNamespaceUri": "", "filterReport": "" }, - "DyECG": { + "ECG": { "collectorId": "", "assortId": "", "filterReport": "" @@ -31,7 +31,7 @@ "assortId": "", "filterReport": "" }, - "MaZui": { + "ShouMa": { "collectorId": "", "assortId": "", "filterReport": "" diff --git a/pom.xml b/pom.xml index a5ed584..a65717a 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,9 @@ 1.0-SNAPSHOT 4.0.0 - + + 3.141.59 + docus-collect-file-data @@ -201,6 +203,26 @@ 2.1.1 + + + org.seleniumhq.selenium + selenium-java + 3.141.59 + + + + + io.webfolder + cdp4j + 3.0.3 + + + + + org.jvnet.winp + winp + 1.28 + diff --git a/src/main/java/com/docus/server/archive/entity/AfCollectPatientLog.java b/src/main/java/com/docus/server/archive/entity/AfCollectPatientLog.java new file mode 100644 index 0000000..8803252 --- /dev/null +++ b/src/main/java/com/docus/server/archive/entity/AfCollectPatientLog.java @@ -0,0 +1,36 @@ +package com.docus.server.archive.entity; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 患者采集记录 + * 表: docus_archivefile.af_collect_patient_log + */ +@Data +public class AfCollectPatientLog implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 患者主键 + */ + private String patientId; + + /** + * 采集器id + */ + private String collectId; + + /** + * 最后一次采集时间 + */ + private Date lastCollectTime; + + /** + * 文件个数 + */ + private Integer fileCount; +} \ No newline at end of file diff --git a/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java b/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java index c6df816..0aa7fdd 100644 --- a/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java +++ b/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java @@ -2,6 +2,7 @@ package com.docus.server.archive.mapper; import com.docus.server.archive.dto.PatientState; +import com.docus.server.archive.entity.AfCollectPatientLog; import com.docus.server.archive.entity.AfCollectTask; import com.docus.server.archive.entity.BasicExtend; import com.docus.server.archive.entity.TBasic; @@ -14,18 +15,18 @@ import java.util.List; public interface TBasicMapper { - int invalidFileBySource(@Param("patientId") String patientId,@Param("collectorId") String collectorId); + int invalidFileBySource(@Param("patientId") String patientId, @Param("collectorId") String collectorId); - List getTbasicByReportTimeAndInpNoOrIdCard(@Param("sendDateStr") String sendDateStr,@Param("idCard") String idCard,@Param("inpatientNo") String inpatientNo); + List getTbasicByReportTimeAndInpNoOrIdCard(@Param("sendDateStr") String sendDateStr, @Param("idCard") String idCard, @Param("inpatientNo") String inpatientNo); List getTbasicByPatientIds(@Param("patientIds") List patientIds); - int deleteTaskByPatAndSource(@Param("patientId")String patientId, @Param("collectorId")String collectorId); + int deleteTaskByPatAndSource(@Param("patientId") String patientId, @Param("collectorId") String collectorId); - int flushPatTaskEndTime(@Param("patientId")String patientId,@Param("dateTime")String dateTime); + int flushPatTaskEndTime(@Param("patientId") String patientId, @Param("dateTime") String dateTime); - List getCollectTaskByPatAndSource(@Param("patientId")String patientId, @Param("collectorId") String collectorId); + List getCollectTaskByPatAndSource(@Param("patientId") String patientId, @Param("collectorId") String collectorId); int delTaskById(@Param("id") Long id); @@ -33,7 +34,7 @@ public interface TBasicMapper { int updateTaskById(@Param("task") AfCollectTask task); - List findFailedTaskPatId(@Param("collectorId") String collectorId,@Param("startDate") String startDateStr); + List findFailedTaskPatId(@Param("collectorId") String collectorId, @Param("startDate") String startDateStr); List getZyPatientIdsByYzyJzh(@Param("preJzhs") List preJzhs); @@ -41,11 +42,30 @@ public interface TBasicMapper { List getYzyPatientIdFromScanAssort(); - List getNoTaskPatientByDisDate(@Param("startDateTime") String startDateTime,@Param("collectorId") String collectorId); + List getNoTaskPatientByDisDate(@Param("startDateTime") String startDateTime, @Param("collectorId") String collectorId); int cancelTask(@Param("patientId") String patientId, @Param("sysflag") String collectorId); - PatientState getPatientState(@Param("patientId") String patientId); + PatientState getPatientState(@Param("patientId") String patientId); + + int updateTaskRemarkById(@Param("id") Long id, @Param("remark") String remark); + + int saveOrUpdateCollectLog(@Param("cpLog") AfCollectPatientLog afCollectPatientLog); + + + /** + * + * @param offsetTime 格式 yyyy-MM-dd HH:mm:ss,最后采集时间是否小于该时间 + */ + AfCollectPatientLog getCollectLog(@Param("patientId") String patientId, @Param("collectorId") String collectorId, @Param("offsetTime") String offsetTime); + + /** + * 根据出院时间查询患者主键 + * @param disDateStart 格式 yyyy-MM-dd HH:mm:ss + * @param disDateEnd 格式 yyyy-MM-dd HH:mm:ss + */ + List getPatientIdsByDisDate(@Param("disDateStart") String disDateStart,@Param("disDateEnd") String disDateEnd); + + List getNoCollectPatientIds(@Param("collectorId") String collectorId); - int updateTaskRemarkById(@Param("id") Long id,@Param("remark") String remark); } diff --git a/src/main/java/com/docus/server/gdszyzh/controller/ReportCollectController.java b/src/main/java/com/docus/server/gdszyzh/controller/ReportCollectController.java index c8bbfc2..4965d4e 100644 --- a/src/main/java/com/docus/server/gdszyzh/controller/ReportCollectController.java +++ b/src/main/java/com/docus/server/gdszyzh/controller/ReportCollectController.java @@ -35,4 +35,44 @@ public class ReportCollectController { } return CommonResult.success("采集完成!"); } + + @PostMapping("/collect/lis") + @ApiOperation("采集LIS报告") + public CommonResult collectLis(@RequestBody List patientIds) { + if (Func.isNotEmpty(patientIds)) { + Log.info("LIS报告采集接口,参数:{}", patientIds); + reportCollectService.collectLis(patientIds); + } + return CommonResult.success("采集完成!"); + } + + @PostMapping("/collect/icu") + @ApiOperation("采集ICU报告") + public CommonResult collectIcu(@RequestBody List patientIds) { + if (Func.isNotEmpty(patientIds)) { + Log.info("ICU报告采集接口,参数:{}", patientIds); + reportCollectService.collectIcu(patientIds); + } + return CommonResult.success("采集完成!"); + } + + @PostMapping("/collect/ecg") + @ApiOperation("采集ECG报告") + public CommonResult collectEcg(@RequestBody List patientIds) { + if (Func.isNotEmpty(patientIds)) { + Log.info("ECG报告采集接口,参数:{}", patientIds); + reportCollectService.collectEcg(patientIds); + } + return CommonResult.success("采集完成!"); + } + + @PostMapping("/collect/shouMa") + @ApiOperation("采集ECG报告") + public CommonResult collectShouMa(@RequestBody List patientIds) { + if (Func.isNotEmpty(patientIds)) { + Log.info("ShouMa报告采集接口,参数:{}", patientIds); + reportCollectService.collectShouMa(patientIds); + } + return CommonResult.success("采集完成!"); + } } diff --git a/src/main/java/com/docus/server/gdszyzh/controller/TestController.java b/src/main/java/com/docus/server/gdszyzh/controller/TestController.java new file mode 100644 index 0000000..f9ab90d --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/controller/TestController.java @@ -0,0 +1,134 @@ +package com.docus.server.gdszyzh.controller; + +import cn.hutool.core.io.FileUtil; +import com.docus.infrastructure.web.api.CommonResult; +import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.gdszyzh.entity.GdSzyZhReportDataView; +import com.docus.server.gdszyzh.mapper.GdSzyZhEcgReportDataViewMapper; +import com.docus.server.gdszyzh.mapper.GdSzyZhIcuReportDataViewMapper; +import com.docus.server.gdszyzh.mapper.GdSzyZhShouMaReportDataViewMapper; +import com.docus.server.gdszyzh.util.PrintConfig; +import com.docus.server.gdszyzh.util.WebPagePrinter; +import com.docus.server.rpc.GdSzyZhReportService; +import com.docus.server.rpc.dto.GdSzyZhReportDetailDto; +import com.docus.server.rpc.dto.GdSzyZhReportListDto; +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.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:35 + */ +@RestController +@RequestMapping("/gdszyzhtest") +@Api(tags = "广东省中医珠海测试接口") +public class TestController { + @Autowired + private GdSzyZhIcuReportDataViewMapper icuReportDataViewMapper; + @Autowired + private GdSzyZhEcgReportDataViewMapper ecgReportDataViewMapper; + @Autowired + private GdSzyZhShouMaReportDataViewMapper shouMaReportDataViewMapper; + @Autowired + private TBasicMapper tBasicMapper; + @Autowired + private GdSzyZhReportService gdSzyZhReportService; + + @GetMapping("/shouma/get") + @ApiOperation("手麻视图测试数据") + public CommonResult> shoumaTest(@RequestParam("jzh") String jzh) { + List byJzhs = shouMaReportDataViewMapper.getByJzhs(Collections.singletonList(jzh)); + return CommonResult.success(byJzhs); + } + + @GetMapping("/ecg/get") + @ApiOperation("ecg视图测试数据") + public CommonResult> ecgTest(@RequestParam("jzh") String jzh) { + List byJzhs = ecgReportDataViewMapper.getByJzhs(Collections.singletonList(jzh)); + return CommonResult.success(byJzhs); + } + + @GetMapping("/icu/get") + @ApiOperation("重症视图测试数据") + public CommonResult> icuTest(@RequestParam("zyh") String inpatientNo, @RequestParam("zycs") Integer zycs) { + List dataViewList = icuReportDataViewMapper.getByInpatientNo(inpatientNo); + dataViewList= dataViewList.stream() + .filter(e -> e.getAdmissTimes().equals(zycs)) + .collect(Collectors.toList()); + return CommonResult.success(dataViewList); + } + + + @GetMapping("/pacsList/get") + @ApiOperation("PACS检查列表接口测试 时间格式yyyy-MM-dd") + public CommonResult pacsListTest(@RequestParam("empId") String empId, @RequestParam("jzh") String jzh, + @RequestParam("beginDate") String beginDate, @RequestParam("endDate") String endDate) { + GdSzyZhReportListDto dto = gdSzyZhReportService.pacsList(empId, jzh, beginDate, endDate); + return CommonResult.success(dto); + } + + @GetMapping("/pacsDetail/get") + @ApiOperation("PACS检查报告明细接口测试") + public CommonResult pacsDetailTest(@RequestParam("examNo") String examNo) { + GdSzyZhReportDetailDto pacsDetail = gdSzyZhReportService.pacsDetail(examNo); + return CommonResult.success(pacsDetail); + } + + @GetMapping("/lisList/get") + @ApiOperation("LIS检验列表接口测试 时间格式yyyy-MM-dd HH:mm:ss") + public CommonResult lisListTest(@RequestParam("empId") String empId, @RequestParam("jzh") String jzh, + @RequestParam("beginDate") String beginDate, @RequestParam("endDate") String endDate) { + GdSzyZhReportListDto dto = gdSzyZhReportService.lisList(empId, jzh, beginDate, endDate); + return CommonResult.success(dto); + } + + + @GetMapping("/html/print") + @ApiOperation("html打印测试") + public CommonResult icuPrintTest(@RequestParam(value = "url") String url, + @RequestParam(value = "landscape", required = false) Boolean landscape, + @RequestParam(value = "displayHeaderFooter", required = false) Boolean displayHeaderFooter, + @RequestParam(value = "printBackground", required = false) Boolean printBackground, + @RequestParam(value = "scale", required = false) Double scale, + @RequestParam(value = "paperWidth", required = false) Double paperWidth, + @RequestParam(value = "paperHeight", required = false) Double paperHeight, + @RequestParam(value = "marginTop", required = false) Double marginTop, + @RequestParam(value = "marginBottom", required = false) Double marginBottom, + @RequestParam(value = "marginLeft", required = false) Double marginLeft, + @RequestParam(value = "marginRight", required = false) Double marginRight, + @RequestParam(value = "pageRanges", required = false) String pageRanges, + @RequestParam(value = "ignoreInvalidPageRanges", required = false) Boolean ignoreInvalidPageRanges, + @RequestParam(value = "headerTemplate", required = false) String headerTemplate, + @RequestParam(value = "footerTemplate", required = false) String footerTemplate, + @RequestParam(value = "preferCSSPageSize", required = false) Boolean preferCSSPageSize + ) { + try (WebPagePrinter printer = new WebPagePrinter()) { + printer.init(); + System.out.println(url); + PrintConfig config = new PrintConfig(); + + + byte[] pdfBytes = printer.printToPdf(url, config, landscape, displayHeaderFooter, printBackground, scale, + paperWidth, paperHeight, marginTop, marginBottom, marginLeft, marginRight, pageRanges, + ignoreInvalidPageRanges, headerTemplate, footerTemplate, preferCSSPageSize); + String pdfPath = "urlPrintToPdf.pdf"; + FileUtil.writeBytes(pdfBytes, pdfPath); + System.out.println("PDF已生成: " + pdfPath); + return CommonResult.success("成功"); + + } catch (Exception e) { + e.printStackTrace(); + return CommonResult.failed("失败"); + } + } +} diff --git a/src/main/java/com/docus/server/gdszyzh/entity/ReportDataView.java b/src/main/java/com/docus/server/gdszyzh/entity/GdSzyZhReportDataView.java similarity index 69% rename from src/main/java/com/docus/server/gdszyzh/entity/ReportDataView.java rename to src/main/java/com/docus/server/gdszyzh/entity/GdSzyZhReportDataView.java index 726f2d5..8bd40cc 100644 --- a/src/main/java/com/docus/server/gdszyzh/entity/ReportDataView.java +++ b/src/main/java/com/docus/server/gdszyzh/entity/GdSzyZhReportDataView.java @@ -11,7 +11,7 @@ import java.util.Date; * @date 2026/4/7 17:05 */ @Data -public class ReportDataView { +public class GdSzyZhReportDataView { @ApiModelProperty("报告号") private String reportNo; @ApiModelProperty("报告标题") @@ -22,4 +22,10 @@ public class ReportDataView { private Date reportTime; @ApiModelProperty("报告地址") private String reportUrl; + @ApiModelProperty("住院流水号") + private String jzh; + @ApiModelProperty("住院号") + private String inpatientNo; + @ApiModelProperty("住院次数") + private Integer admissTimes; } diff --git a/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhEcgCollectJob.java b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhEcgCollectJob.java new file mode 100644 index 0000000..3cf784e --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhEcgCollectJob.java @@ -0,0 +1,73 @@ +package com.docus.server.gdszyzh.job; + +import com.alibaba.fastjson.JSONObject; +import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.gdszyzh.service.ReportCollectService; +import com.docus.server.util.TableJsonRead; +import com.xxl.job.core.context.XxlJobHelper; +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.time.LocalDate; +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:25 + */ +@Slf4j +@Component +public class GdSzyZhEcgCollectJob { + @Autowired + private ReportCollectService reportCollectService; + @Autowired + private TBasicMapper basicMapper; + + @XxlJob("GdSzyZhEcgCollectJob") + public void gdSzyZhEcgCollectJob() { + log.info("广东省中医珠海,动态心电血压采集任务开始!"); + LocalDate localDate = LocalDate.now(); + try { + String jobParam = XxlJobHelper.getJobParam(); + String[] days; + if (jobParam == null) { + days = new String[]{"3"}; + } else { + days = jobParam.split(","); + } + for (String day : days) { + LocalDate disDateRange = localDate.plusDays(-Integer.parseInt(day)); + String disDateStart = disDateRange + " 00:00:00"; + String disDateEnd = disDateRange + " 23:59:59"; + log.info("广东省中医珠海,动态心电血压采集,患者出院时间:{} 至 {}", disDateStart, disDateEnd); + List patientIds = basicMapper.getPatientIdsByDisDate(disDateStart, disDateEnd); + reportCollectService.collectEcg(patientIds); + } + log.info("广东省中医珠海,动态心电血压采集任务结束!"); + } catch (Exception e) { + log.error("广东省中医珠海,动态心电血压采集任务出现异常!" + e.getMessage(), e); + } + } + + @XxlJob("GdSzyZhEcgQueryNoCollectJob") + public void gdSzyZhEcgQueryNoCollectJob() { + log.info("广东省中医珠海,检索动态心电血压未采集患者采集任务开始!"); + try { + final String configPath = "data-config"; + final String configName = "gdszyzh-collect-config"; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + JSONObject lisWsConfig = configOjb.getJSONObject("ECG"); + String collectorId = lisWsConfig.getString("collectorId"); + List patientIds = basicMapper.getNoCollectPatientIds(collectorId); + reportCollectService.collectEcg(patientIds); + log.info("广东省中医珠海,检索动态心电血压未采集患者采集任务结束!"); + } catch (Exception e) { + log.info("广东省中医珠海,检索动态心电血压未采集患者采集任务异常!" + e.getMessage(), e); + } + } + +} diff --git a/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhIcuCollectJob.java b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhIcuCollectJob.java new file mode 100644 index 0000000..0fd3b79 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhIcuCollectJob.java @@ -0,0 +1,75 @@ +package com.docus.server.gdszyzh.job; + +import com.alibaba.fastjson.JSONObject; +import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.gdszyzh.service.ReportCollectService; +import com.docus.server.util.TableJsonRead; +import com.xxl.job.core.context.XxlJobHelper; +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.time.LocalDate; +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:25 + */ +@Slf4j +@Component +public class GdSzyZhIcuCollectJob { + @Autowired + private ReportCollectService reportCollectService; + @Autowired + private TBasicMapper basicMapper; + + @XxlJob("GdSzyZhIcuCollectJob") + public void gdSzyZhIcuCollectJob() { + log.info("广东省中医珠海,重症采集任务开始!"); + LocalDate localDate = LocalDate.now(); + try { + String jobParam = XxlJobHelper.getJobParam(); + String[] days; + if (jobParam == null) { + days = new String[]{"3"}; + } else { + days = jobParam.split(","); + } + for (String day : days) { + LocalDate disDateRange = localDate.plusDays(-Integer.parseInt(day)); + String disDateStart = disDateRange + " 00:00:00"; + String disDateEnd = disDateRange + " 23:59:59"; + log.info("广东省中医珠海,重症采集,患者出院时间:{} 至 {}", disDateStart, disDateEnd); + List patientIds = basicMapper.getPatientIdsByDisDate(disDateStart, disDateEnd); + reportCollectService.collectIcu(patientIds); + } + log.info("广东省中医珠海,重症采集任务结束!"); + } catch (Exception e) { + log.error("广东省中医珠海,重症采集任务出现异常!" + e.getMessage(), e); + } + } + + + @XxlJob("GdSzyZhIcuQueryNoCollectJob") + public void gdSzyZhIcuQueryNoCollectJob() { + log.info("广东省中医珠海,检索重症未采集患者采集任务开始!"); + try { + final String configPath = "data-config"; + final String configName = "gdszyzh-collect-config"; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + JSONObject lisWsConfig = configOjb.getJSONObject("ICU"); + String collectorId = lisWsConfig.getString("collectorId"); + List patientIds = basicMapper.getNoCollectPatientIds(collectorId); + reportCollectService.collectIcu(patientIds); + log.info("广东省中医珠海,检索重症未采集患者采集任务结束!"); + } catch (Exception e) { + log.info("广东省中医珠海,检索重症未采集患者采集任务异常!" + e.getMessage(), e); + } + + } + +} diff --git a/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhLisCollectJob.java b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhLisCollectJob.java new file mode 100644 index 0000000..7e0b68d --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhLisCollectJob.java @@ -0,0 +1,74 @@ +package com.docus.server.gdszyzh.job; + +import com.alibaba.fastjson.JSONObject; +import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.gdszyzh.service.ReportCollectService; +import com.docus.server.util.TableJsonRead; +import com.xxl.job.core.context.XxlJobHelper; +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.time.LocalDate; +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:25 + */ +@Slf4j +@Component +public class GdSzyZhLisCollectJob { + @Autowired + private ReportCollectService reportCollectService; + @Autowired + private TBasicMapper basicMapper; + + @XxlJob("GdSzyZhLisCollectJob") + public void gdSzyZhLisCollectJob() { + log.info("广东省中医珠海,LIS检验采集任务开始!"); + LocalDate localDate = LocalDate.now(); + try { + String jobParam = XxlJobHelper.getJobParam(); + String[] days; + if (jobParam == null) { + days = new String[]{"3"}; + } else { + days = jobParam.split(","); + } + for (String day : days) { + LocalDate disDateRange = localDate.plusDays(-Integer.parseInt(day)); + String disDateStart = disDateRange + " 00:00:00"; + String disDateEnd = disDateRange + " 23:59:59"; + log.info("广东省中医珠海,LIS检验采集,患者出院时间:{} 至 {}", disDateStart, disDateEnd); + List patientIds = basicMapper.getPatientIdsByDisDate(disDateStart, disDateEnd); + reportCollectService.collectLis(patientIds); + } + + log.info("广东省中医珠海,LIS检验采集任务结束!"); + } catch (Exception e) { + log.error("广东省中医珠海,LIS检验采集任务出现异常!" + e.getMessage(), e); + } + } + + @XxlJob("GdSzyZhLisQueryNoCollectJob") + public void gdSzyZhLisQueryNoCollectJob() { + log.info("广东省中医珠海,检索LIS检验未采集患者采集任务开始!"); + try { + final String configPath = "data-config"; + final String configName = "gdszyzh-collect-config"; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + JSONObject lisWsConfig = configOjb.getJSONObject("LIS"); + String collectorId = lisWsConfig.getString("collectorId"); + List patientIds = basicMapper.getNoCollectPatientIds(collectorId); + reportCollectService.collectLis(patientIds); + log.info("广东省中医珠海,检索LIS检验未采集患者采集任务结束!"); + } catch (Exception e) { + log.info("广东省中医珠海,检索LIS检验未采集患者采集任务异常!" + e.getMessage(), e); + } + } + +} diff --git a/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhPacsCollectJob.java b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhPacsCollectJob.java new file mode 100644 index 0000000..d2917c7 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhPacsCollectJob.java @@ -0,0 +1,73 @@ +package com.docus.server.gdszyzh.job; + +import com.alibaba.fastjson.JSONObject; +import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.gdszyzh.service.ReportCollectService; +import com.docus.server.util.TableJsonRead; +import com.xxl.job.core.context.XxlJobHelper; +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.time.LocalDate; +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:25 + */ +@Slf4j +@Component +public class GdSzyZhPacsCollectJob { + @Autowired + private ReportCollectService reportCollectService; + @Autowired + private TBasicMapper basicMapper; + + @XxlJob("GdSzyZhPacsCollectJob") + public void gdSzyZhPacsCollectJob() { + log.info("广东省中医珠海,PACS检查采集任务开始!"); + LocalDate localDate = LocalDate.now(); + try { + String jobParam = XxlJobHelper.getJobParam(); + String[] days; + if (jobParam == null) { + days = new String[]{"3"}; + } else { + days = jobParam.split(","); + } + for (String day : days) { + LocalDate disDateRange = localDate.plusDays(-Integer.parseInt(day)); + String disDateStart = disDateRange + " 00:00:00"; + String disDateEnd = disDateRange + " 23:59:59"; + log.info("广东省中医珠海,PACS检查采集,患者出院时间:{} 至 {}", disDateStart, disDateEnd); + List patientIds = basicMapper.getPatientIdsByDisDate(disDateStart, disDateEnd); + reportCollectService.collectPacs(patientIds); + } + log.info("广东省中医珠海,PACS检查采集任务结束!"); + } catch (Exception e) { + log.error("广东省中医珠海,PACS检查采集任务出现异常!" + e.getMessage(), e); + } + } + + @XxlJob("GdSzyZhPacsQueryNoCollectJob") + public void gdSzyZhPacsQueryNoCollectJob() { + log.info("广东省中医珠海,检索PACS检查未采集患者采集任务开始!"); + try { + final String configPath = "data-config"; + final String configName = "gdszyzh-collect-config"; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + JSONObject lisWsConfig = configOjb.getJSONObject("PACS"); + String collectorId = lisWsConfig.getString("collectorId"); + List patientIds = basicMapper.getNoCollectPatientIds(collectorId); + reportCollectService.collectPacs(patientIds); + log.info("广东省中医珠海,检索PACS检查未采集患者采集任务结束!"); + } catch (Exception e) { + log.info("广东省中医珠海,检索PACS检查未采集患者采集任务异常!" + e.getMessage(), e); + } + } + +} diff --git a/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhShouMaCollectJob.java b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhShouMaCollectJob.java new file mode 100644 index 0000000..9e20c86 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/job/GdSzyZhShouMaCollectJob.java @@ -0,0 +1,74 @@ +package com.docus.server.gdszyzh.job; + +import com.alibaba.fastjson.JSONObject; +import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.gdszyzh.service.ReportCollectService; +import com.docus.server.util.TableJsonRead; +import com.xxl.job.core.context.XxlJobHelper; +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.time.LocalDate; +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/7 16:25 + */ +@Slf4j +@Component +public class GdSzyZhShouMaCollectJob { + @Autowired + private ReportCollectService reportCollectService; + @Autowired + private TBasicMapper basicMapper; + + @XxlJob("GdSzyZhShouMaCollectJob") + public void gdSzyZhShouMaCollectJob() { + log.info("广东省中医珠海,手麻采集任务开始!"); + LocalDate localDate = LocalDate.now(); + try { + String jobParam = XxlJobHelper.getJobParam(); + String[] days; + if (jobParam == null) { + days = new String[]{"3"}; + } else { + days = jobParam.split(","); + } + for (String day : days) { + LocalDate disDateRange = localDate.plusDays(-Integer.parseInt(day)); + String disDateStart = disDateRange + " 00:00:00"; + String disDateEnd = disDateRange + " 23:59:59"; + log.info("广东省中医珠海,手麻采集,患者出院时间:{} 至 {}", disDateStart, disDateEnd); + List patientIds = basicMapper.getPatientIdsByDisDate(disDateStart, disDateEnd); + reportCollectService.collectShouMa(patientIds); + } + log.info("广东省中医珠海,手麻采集任务结束!"); + } catch (Exception e) { + log.error("广东省中医珠海,手麻采集任务出现异常!" + e.getMessage(), e); + } + } + + @XxlJob("GdSzyZhShouMaQueryNoCollectJob") + public void gdSzyZhShouMaQueryNoCollectJob() { + log.info("广东省中医珠海,检索手麻未采集患者采集任务开始!"); + try { + final String configPath = "data-config"; + final String configName = "gdszyzh-collect-config"; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + JSONObject lisWsConfig = configOjb.getJSONObject("PACS"); + String collectorId = lisWsConfig.getString("collectorId"); + List patientIds = basicMapper.getNoCollectPatientIds(collectorId); + reportCollectService.collectShouMa(patientIds); + log.info("广东省中医珠海,检索手麻未采集患者采集任务结束!"); + } catch (Exception e) { + log.info("广东省中医珠海,检索手麻未采集患者采集任务异常!" + e.getMessage(), e); + } + } + + +} diff --git a/src/main/java/com/docus/server/gdszyzh/job/PacsCollectJob.java b/src/main/java/com/docus/server/gdszyzh/job/PacsCollectJob.java deleted file mode 100644 index 4a9d9a1..0000000 --- a/src/main/java/com/docus/server/gdszyzh/job/PacsCollectJob.java +++ /dev/null @@ -1,36 +0,0 @@ -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/mapper/GdSzyZhEcgReportDataViewMapper.java b/src/main/java/com/docus/server/gdszyzh/mapper/GdSzyZhEcgReportDataViewMapper.java new file mode 100644 index 0000000..c0bc602 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/mapper/GdSzyZhEcgReportDataViewMapper.java @@ -0,0 +1,19 @@ +package com.docus.server.gdszyzh.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.docus.server.gdszyzh.entity.GdSzyZhReportDataView; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/8 9:00 + */ +@DS("gdszyzh-ecg") +@Mapper +public interface GdSzyZhEcgReportDataViewMapper { + List getByJzhs(@Param("jzhs") List jzhs); +} diff --git a/src/main/java/com/docus/server/gdszyzh/mapper/GdSzyZhIcuReportDataViewMapper.java b/src/main/java/com/docus/server/gdszyzh/mapper/GdSzyZhIcuReportDataViewMapper.java new file mode 100644 index 0000000..179b3dc --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/mapper/GdSzyZhIcuReportDataViewMapper.java @@ -0,0 +1,20 @@ +package com.docus.server.gdszyzh.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.docus.server.gdszyzh.entity.GdSzyZhReportDataView; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/8 9:00 + */ +@DS("gdszyzh-icu") +@Mapper +public interface GdSzyZhIcuReportDataViewMapper { + List getByInpatientNo(@Param("inpatientNo") String inpatientNo); + +} diff --git a/src/main/java/com/docus/server/gdszyzh/mapper/GdSzyZhShouMaReportDataViewMapper.java b/src/main/java/com/docus/server/gdszyzh/mapper/GdSzyZhShouMaReportDataViewMapper.java new file mode 100644 index 0000000..217abdb --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/mapper/GdSzyZhShouMaReportDataViewMapper.java @@ -0,0 +1,19 @@ +package com.docus.server.gdszyzh.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.docus.server.gdszyzh.entity.GdSzyZhReportDataView; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * + * @author YongBin Wen + * @date 2026/4/8 9:00 + */ +@DS("gdszyzh-shouma") +@Mapper +public interface GdSzyZhShouMaReportDataViewMapper { + List getByJzhs(@Param("jzhs") List jzhs); +} diff --git a/src/main/java/com/docus/server/gdszyzh/service/ReportCollectService.java b/src/main/java/com/docus/server/gdszyzh/service/ReportCollectService.java index ae65940..bf9c078 100644 --- a/src/main/java/com/docus/server/gdszyzh/service/ReportCollectService.java +++ b/src/main/java/com/docus/server/gdszyzh/service/ReportCollectService.java @@ -9,8 +9,29 @@ import java.util.List; */ public interface ReportCollectService { /** - * PACS报告采集 + * PACS检查报告采集 * @param patientIds 患者主键 */ void collectPacs(List patientIds); + + /** + * LIS检验报告采集 + * @param patientIds 患者主键 + */ + void collectLis(List patientIds); + /** + * 动态心电血压报告采集 + * @param patientIds 患者主键 + */ + void collectEcg(List patientIds); + /** + * 重症报告采集 + * @param patientIds 患者主键 + */ + void collectIcu(List patientIds); + /** + * 手麻报告采集 + * @param patientIds 患者主键 + */ + void collectShouMa(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 index e99074a..d59a6af 100644 --- a/src/main/java/com/docus/server/gdszyzh/service/impl/ReportCollectServiceImpl.java +++ b/src/main/java/com/docus/server/gdszyzh/service/impl/ReportCollectServiceImpl.java @@ -2,8 +2,13 @@ package com.docus.server.gdszyzh.service.impl; import com.alibaba.fastjson.JSONObject; import com.docus.core.util.Func; +import com.docus.server.archive.entity.AfCollectPatientLog; import com.docus.server.archive.entity.TBasic; import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.gdszyzh.entity.GdSzyZhReportDataView; +import com.docus.server.gdszyzh.mapper.GdSzyZhEcgReportDataViewMapper; +import com.docus.server.gdszyzh.mapper.GdSzyZhIcuReportDataViewMapper; +import com.docus.server.gdszyzh.mapper.GdSzyZhShouMaReportDataViewMapper; import com.docus.server.gdszyzh.service.ReportCollectService; import com.docus.server.rpc.DownPlatformService; import com.docus.server.rpc.GdSzyZhReportService; @@ -18,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; @@ -37,6 +43,12 @@ public class ReportCollectServiceImpl implements ReportCollectService { private TBasicMapper tBasicMapper; @Autowired private DownPlatformService downPlatformService; + @Autowired + private GdSzyZhEcgReportDataViewMapper ecgReportDataViewMapper; + @Autowired + private GdSzyZhIcuReportDataViewMapper icuReportDataViewMapper; + @Autowired + private GdSzyZhShouMaReportDataViewMapper shouMaReportDataViewMapper; @Override public void collectPacs(List patientIds) { @@ -46,6 +58,39 @@ public class ReportCollectServiceImpl implements ReportCollectService { } } + @Override + public void collectLis(List patientIds) { + List basicList = tBasicMapper.getTbasicByPatientIds(patientIds); + for (TBasic basic : basicList) { + collectLis(basic); + } + } + + @Override + public void collectEcg(List patientIds) { + List basicList = tBasicMapper.getTbasicByPatientIds(patientIds); + for (TBasic basic : basicList) { + collectEcg(basic); + } + } + + @Override + public void collectShouMa(List patientIds) { + List basicList = tBasicMapper.getTbasicByPatientIds(patientIds); + for (TBasic basic : basicList) { + collectShouMa(basic); + } + } + + @Override + public void collectIcu(List patientIds) { + List basicList = tBasicMapper.getTbasicByPatientIds(patientIds); + for (TBasic basic : basicList) { + collectIcu(basic); + } + } + + private void collectPacs(TBasic basic) { Date admissDate = basic.getAdmissDate(); Date disDate = basic.getDisDate(); @@ -97,9 +142,217 @@ public class ReportCollectServiceImpl implements ReportCollectService { reportDownDto.setAssortid(assortId); reportDownDto.setScanfiles(scanFiles); downPlatformService.report(reportDownDto); + long count = scanFiles.stream().map(ReportDownScanFileDto::getSerialnum).distinct().count(); + saveOrUpdateCollectLog(patientId, collectorId, (int) count); } - public static void main(String[] args) { + private void collectLis(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("采集LIS报告,患者:{},住院流水号:{},入院、出院时间,empId有空数据,无法采集!", basic.getInpatientNo(), jzh); + return; + } + String beginDate = Func.formatDate(admissDate); + String endDate = Func.formatDate(disDate); + GdSzyZhReportListDto lisList = gdSzyZhReportService.lisList(empId, jzh, beginDate, endDate); + List reportList = lisList.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) { + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(report.getReporPath()); + reportDownScanFileDto.setFiletitle(report.getReportTitle()); + reportDownScanFileDto.setSerialnum(report.getReportNo()); + 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 lisWsConfig = configOjb.getJSONObject("LIS"); + String collectorId = lisWsConfig.getString("collectorId"); + String assortId = lisWsConfig.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); + long count = scanFiles.stream().map(ReportDownScanFileDto::getSerialnum).distinct().count(); + saveOrUpdateCollectLog(patientId, collectorId, (int) count); + } + + private void collectEcg(TBasic basic) { + String jzh = basic.getJzh(); + String patientId = basic.getPatientId(); + + List dataViewList = ecgReportDataViewMapper.getByJzhs(Collections.singletonList(jzh)); + dataViewList = dataViewList.stream() + .sorted(Comparator.comparing(GdSzyZhReportDataView::getReportClass) + .thenComparing(GdSzyZhReportDataView::getReportTime)) + .collect(Collectors.toList()); + + int sort = 0; + List scanFiles = new ArrayList<>(); + for (GdSzyZhReportDataView dataView : dataViewList) { + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(dataView.getReportUrl()); + reportDownScanFileDto.setFiletitle(dataView.getReportTitle()); + reportDownScanFileDto.setSerialnum(dataView.getReportNo()); + 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 lisWsConfig = configOjb.getJSONObject("ECG"); + String collectorId = lisWsConfig.getString("collectorId"); + String assortId = lisWsConfig.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); + long count = scanFiles.stream().map(ReportDownScanFileDto::getSerialnum).distinct().count(); + saveOrUpdateCollectLog(patientId, collectorId, (int) count); + } + + private void collectShouMa(TBasic basic) { + String jzh = basic.getJzh(); + String patientId = basic.getPatientId(); + + List dataViewList = shouMaReportDataViewMapper.getByJzhs(Collections.singletonList(jzh)); + dataViewList = dataViewList.stream() + .sorted(Comparator.comparing(GdSzyZhReportDataView::getReportClass) + .thenComparing(GdSzyZhReportDataView::getReportTime)) + .collect(Collectors.toList()); + + int sort = 0; + List scanFiles = new ArrayList<>(); + for (GdSzyZhReportDataView dataView : dataViewList) { + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(dataView.getReportUrl()); + reportDownScanFileDto.setFiletitle(dataView.getReportTitle()); + reportDownScanFileDto.setSerialnum(dataView.getReportNo()); + 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 lisWsConfig = configOjb.getJSONObject("ShouMa"); + String collectorId = lisWsConfig.getString("collectorId"); + String assortId = lisWsConfig.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); + long count = scanFiles.stream().map(ReportDownScanFileDto::getSerialnum).distinct().count(); + saveOrUpdateCollectLog(patientId, collectorId, (int) count); + } + + private void collectIcu(TBasic basic) { + String patientId = basic.getPatientId(); + Integer admissTimes = basic.getAdmissTimes(); + List dataViewList = icuReportDataViewMapper.getByInpatientNo(basic.getInpatientNo()); + dataViewList = dataViewList.stream() + .filter(d -> admissTimes.equals(d.getAdmissTimes())) + .sorted(Comparator.comparing(GdSzyZhReportDataView::getReportClass) + .thenComparing(GdSzyZhReportDataView::getReportTime)) + .collect(Collectors.toList()); + + int sort = 0; + List scanFiles = new ArrayList<>(); + for (GdSzyZhReportDataView dataView : dataViewList) { + String reportUrl = dataView.getReportUrl(); + // 替换本地地址为ftp代理地址 + reportUrl = reportUrl.replace("\\", "/") + .replace("D:/DocareDocArchived", "ftp://10.0.57.90:21"); + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(reportUrl); + reportDownScanFileDto.setFiletitle(dataView.getReportTitle()); + reportDownScanFileDto.setSerialnum(dataView.getReportNo()); + 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 lisWsConfig = configOjb.getJSONObject("ICU"); + String collectorId = lisWsConfig.getString("collectorId"); + String assortId = lisWsConfig.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); + long count = scanFiles.stream().map(ReportDownScanFileDto::getSerialnum).distinct().count(); + saveOrUpdateCollectLog(patientId, collectorId, (int) count); + } + + + private void saveOrUpdateCollectLog(String patientId, String collectorId, int fileCount) { + AfCollectPatientLog collectPatientLog = new AfCollectPatientLog(); + collectPatientLog.setPatientId(patientId); + collectPatientLog.setCollectId(collectorId); + collectPatientLog.setFileCount(fileCount); + collectPatientLog.setLastCollectTime(new Date()); + tBasicMapper.saveOrUpdateCollectLog(collectPatientLog); + } + + public static void main(String[] args) { + String path = "D:\\DocareDocArchived\\24315539643249459211\\CARE_DOC_GDZY_PDF\\5d7b59066b804affb61d74bfe399c6ce_24315539643249459211_1.PDF"; + path = path.replace("\\", "/") + .replace("D:/DocareDocArchived", "ftp://10.0.57.90:21"); + System.out.println(path); } } diff --git a/src/main/java/com/docus/server/gdszyzh/util/IcuHtmlPrinter.java b/src/main/java/com/docus/server/gdszyzh/util/IcuHtmlPrinter.java new file mode 100644 index 0000000..2621386 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/util/IcuHtmlPrinter.java @@ -0,0 +1,12 @@ +package com.docus.server.gdszyzh.util; + + +/** + * + * @author YongBin Wen + * @date 2026/4/8 12:56 + */ +public class IcuHtmlPrinter { + + +} diff --git a/src/main/java/com/docus/server/gdszyzh/util/PrintConfig.java b/src/main/java/com/docus/server/gdszyzh/util/PrintConfig.java new file mode 100644 index 0000000..67e6f3d --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/util/PrintConfig.java @@ -0,0 +1,12 @@ +package com.docus.server.gdszyzh.util; + +import lombok.Data; + +/** + * @author wyb + */ +@Data +public class PrintConfig { + private Long waitTimeMs = 1000L; + +} \ No newline at end of file diff --git a/src/main/java/com/docus/server/gdszyzh/util/WebPagePrinter.java b/src/main/java/com/docus/server/gdszyzh/util/WebPagePrinter.java new file mode 100644 index 0000000..3405e23 --- /dev/null +++ b/src/main/java/com/docus/server/gdszyzh/util/WebPagePrinter.java @@ -0,0 +1,107 @@ +package com.docus.server.gdszyzh.util; + +import io.webfolder.cdp.Launcher; +import io.webfolder.cdp.command.Page; +import io.webfolder.cdp.session.Session; +import io.webfolder.cdp.session.SessionFactory; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +public class WebPagePrinter implements AutoCloseable { + + private Launcher launcher; + private SessionFactory factory; + private Session session; + + + + + /** + * 初始化 Chrome + */ + public void init() { + // 启动 Chrome,传入 headless 和 disable-gpu 参数 [^51^] +// String chromePath="C:\\Users\\Lenovo\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"; + String chromePath = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"; + List args = Arrays.asList("--headless", "--disable-gpu"); + this.launcher = new Launcher(); + + this.factory = launcher.launch(chromePath, args); + } + + /** + * 打印网页到PDF - 使用 CDP4J 的 Page.printToPDF() 无参方法 [^51^] + */ + public byte[] printToPdf(String url, PrintConfig config, + Boolean landscape, + Boolean displayHeaderFooter, + Boolean printBackground, + Double scale, + Double paperWidth, + Double paperHeight, + Double marginTop, + Double marginBottom, + Double marginLeft, + Double marginRight, + String pageRanges, + Boolean ignoreInvalidPageRanges, + String headerTemplate, + String footerTemplate, + Boolean preferCSSPageSize + + + ) throws IOException { + if (factory == null) { + init(); + } + + // 创建浏览器上下文(可选,用于隔离) + String context = factory.createBrowserContext(); + + try (Session session = factory.create(context)) { + this.session = session; + + // 导航到页面 + session.navigate(url); + session.waitDocumentReady(); + + // 额外等待确保内容加载 + try { + Thread.sleep(config.getWaitTimeMs()); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + + // 获取 Page 命令接口 + Page page = session.getCommand().getPage(); + + // 执行打印 - 无参方法,返回 byte[] [^51^] + byte[] pdfBytes = page.printToPDF(landscape, + displayHeaderFooter, + printBackground, + scale, + paperWidth, + paperHeight, + marginTop, + marginBottom, + marginLeft, + marginRight, + pageRanges, + ignoreInvalidPageRanges, + headerTemplate, + footerTemplate, + preferCSSPageSize); + + return pdfBytes; + } + } + + @Override + public void close() { + if (factory != null) { + factory.close(); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/docus/server/rpc/GdSzyZhReportService.java b/src/main/java/com/docus/server/rpc/GdSzyZhReportService.java index 13c5dec..e5c2a0b 100644 --- a/src/main/java/com/docus/server/rpc/GdSzyZhReportService.java +++ b/src/main/java/com/docus/server/rpc/GdSzyZhReportService.java @@ -23,10 +23,12 @@ public interface GdSzyZhReportService { /** * 查询患者的LIS检验报告列表 + * @param beginDate 格式 yyyy-MM-dd HH:mm:ss + * @param endDate 格式 yyyy-MM-dd HH:mm:ss */ GdSzyZhReportListDto lisList(String empId,String jzh,String beginDate,String endDate); /** - * 根据LIS报告号查询报告明细 + * 根据LIS报告号查询报告明细, 此方法暂未做使用 */ - GdSzyZhReportDetailDto lisDetail(String sampleNo); + Object lisDetail(String sampleNo); } diff --git a/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportListDto.java b/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportListDto.java index 172efd1..8503692 100644 --- a/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportListDto.java +++ b/src/main/java/com/docus/server/rpc/dto/GdSzyZhReportListDto.java @@ -27,5 +27,7 @@ public class GdSzyZhReportListDto { private String reportClass; @ApiModelProperty("报告时间") private Date reportTime; + @ApiModelProperty("报告地址") + private String reporPath; } } diff --git a/src/main/java/com/docus/server/rpc/impl/GdSzyZhReportServiceImpl.java b/src/main/java/com/docus/server/rpc/impl/GdSzyZhReportServiceImpl.java index 919d508..89838c8 100644 --- a/src/main/java/com/docus/server/rpc/impl/GdSzyZhReportServiceImpl.java +++ b/src/main/java/com/docus/server/rpc/impl/GdSzyZhReportServiceImpl.java @@ -128,7 +128,7 @@ public class GdSzyZhReportServiceImpl implements GdSzyZhReportService { report.setReportNo(examNoNode.getTextContent()); report.setReportTitle(examItemNameNode.getTextContent()); report.setReportClass(examClassNode.getTextContent()); - report.setReportTime(Func.parseDate(examDateTime,"yyyy-MM-dd HH:mm:ss")); + report.setReportTime(Func.parseDate(examDateTime, "yyyy-MM-dd HH:mm:ss")); reportList.add(report); } GdSzyZhReportListDto dto = new GdSzyZhReportListDto(); @@ -136,7 +136,6 @@ public class GdSzyZhReportServiceImpl implements GdSzyZhReportService { return dto; } - private static String pacsDetailParam(String examNo) { return "" + "" + @@ -189,13 +188,108 @@ public class GdSzyZhReportServiceImpl implements GdSzyZhReportService { @Override public GdSzyZhReportListDto lisList(String empId, String jzh, String beginDate, String endDate) { - // TODO wyb 接口未测试 - return null; + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + + JSONObject pacsWsConfig = configOjb.getJSONObject("LIS"); + String wsUrl = pacsWsConfig.getString("listUrl"); + String namespaceUri = pacsWsConfig.getString("listNamespaceUri"); + String method = pacsWsConfig.getString("listOperationName"); + + String headParam = "" + + "201_Q_WS_JYBGLBCX" + + "HIS" + + "4" + + "dd1f95caf9b367af90fb2849e791dfd3" + + "XML" + + ""; + String bodyParam = lisListParam(empId, jzh, beginDate, endDate); + String[] params = {headParam, bodyParam}; + Object resultObj = JaxWsDynamicClientUtil.send(wsUrl, namespaceUri, method, params); + String result = String.valueOf(resultObj); + log.info("LIS查询报告列表,地址:{},方法:{},头参数:{},主体参数:{} 调用成功,得到结果为:{}", wsUrl, method, headParam, bodyParam, result); + return parseLisListResult(result); } @Override - public GdSzyZhReportDetailDto lisDetail(String sampleNo) { - // TODO wyb 接口未测试 + public Object lisDetail(String sampleNo) { + + TableJsonRead jsonReader = new TableJsonRead(); + JSONObject configOjb = jsonReader.Read(configPath, configName, JSONObject.class); + + JSONObject pacsWsConfig = configOjb.getJSONObject("LIS"); + String wsUrl = pacsWsConfig.getString("detailUrl"); + String namespaceUri = pacsWsConfig.getString("detailNamespaceUri"); + String method = pacsWsConfig.getString("detailOperationName"); + + String headParam = "" + + "201_Q_WS_JYBGJGMXCX" + + "HIS" + + "4" + + "dd1f95caf9b367af90fb2849e791dfd3" + + "XML" + + ""; + String bodyParam = lisDetailParam(sampleNo); + String[] params = {headParam, bodyParam}; + Object resultObj = JaxWsDynamicClientUtil.send(wsUrl, namespaceUri, method, params); + String result = String.valueOf(resultObj); + + log.info("LIS查询报告详情,地址:{},方法:{},头参数:{},主体参数:{} 调用成功,得到结果为:{}", wsUrl, method, headParam, bodyParam, result); + return parsePacsDetailResult(result); + } + + private static String lisListParam(String empId, String jzh, String beginDate, String endDate) { + return "" + + "" + + "" + + "" + + "" + + "" + + "" + empId + "" + + "" + + "" + beginDate + "" + + "" + endDate + "" + + "" + + ""; + } + + private static GdSzyZhReportListDto parseLisListResult(String result) { + XmlUtil xmlUtil = XmlUtil.of(result); + NodeList nodeList = xmlUtil.getNodeList("/Response/MsgInfo/Msg/ReportInfo"); + int length = nodeList.getLength(); + List reportList = new ArrayList<>(); + for (int i = 1; i <= length; i++) { + Node sampleNoNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ReportInfo[" + i + "]/SAMPLE_NO"); + Node reportPdfUrlNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ReportInfo[" + i + "]/REPORT_PDF_URL"); + Node testCategNameNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ReportInfo[" + i + "]/TEST_CATEG_NAME"); + Node sampleTypeCodeNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ReportInfo[" + i + "]/SAMPLE_TYPE_CODE"); + Node reportApprovalDatetimeNode = xmlUtil.getNode("/Response/MsgInfo/Msg/ReportInfo[" + i + "]/REPORT_APPROVAL_DATETIME"); + + GdSzyZhReportListDto.Report report = new GdSzyZhReportListDto.Report(); + report.setReportNo(sampleNoNode.getTextContent()); + report.setReporPath(reportPdfUrlNode.getTextContent()); + report.setReportClass(sampleTypeCodeNode.getTextContent()); + report.setReportTitle(testCategNameNode.getTextContent()); + report.setReportTime(Func.parseDate(reportApprovalDatetimeNode.getTextContent(), "yyyy-MM-dd HH:mm:ss")); + reportList.add(report); + } + GdSzyZhReportListDto dto = new GdSzyZhReportListDto(); + dto.setReportList(reportList); + return dto; + } + + private static String lisDetailParam(String sampleNo) { + return "" + + "" + + "" + sampleNo + "" + + "" + + ""; + } + + private static Object parseLisDetailResult(String result) { + // 暂未实现 return null; } + + } diff --git a/src/main/java/com/docus/server/ydzyy/controller/ApiController.java b/src/main/java/com/docus/server/ydzyy/controller/ApiController.java index d980c14..b5e9681 100644 --- a/src/main/java/com/docus/server/ydzyy/controller/ApiController.java +++ b/src/main/java/com/docus/server/ydzyy/controller/ApiController.java @@ -5,7 +5,7 @@ import com.docus.infrastructure.web.api.CommonResult; import com.docus.server.archive.entity.TBasic; import com.docus.server.archive.mapper.TBasicMapper; import com.docus.server.rpc.YdZyyPacsService; -import com.docus.server.ydzyy.job.PacsCollectJob; +import com.docus.server.ydzyy.job.YdZyyPacsCollectJob; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +23,7 @@ public class ApiController { @Autowired private YdZyyPacsService pacsService; @Autowired - private PacsCollectJob pacsCollectJob; + private YdZyyPacsCollectJob pacsCollectJob; @Autowired private TBasicMapper tBasicMapper; diff --git a/src/main/java/com/docus/server/ydzyy/job/PacsCollectJob.java b/src/main/java/com/docus/server/ydzyy/job/YdZyyPacsCollectJob.java similarity index 99% rename from src/main/java/com/docus/server/ydzyy/job/PacsCollectJob.java rename to src/main/java/com/docus/server/ydzyy/job/YdZyyPacsCollectJob.java index 9833a6a..dff3589 100644 --- a/src/main/java/com/docus/server/ydzyy/job/PacsCollectJob.java +++ b/src/main/java/com/docus/server/ydzyy/job/YdZyyPacsCollectJob.java @@ -36,7 +36,7 @@ import java.util.stream.Collectors; */ @Component @Slf4j -public class PacsCollectJob { +public class YdZyyPacsCollectJob { @Resource private TBasicMapper tBasicMapper; diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml index 4f44cc5..c3ecaa1 100644 --- a/src/main/resources/bootstrap.yml +++ b/src/main/resources/bootstrap.yml @@ -122,6 +122,73 @@ spring: test-on-borrow: false test-on-return: false validation-query: select 1 + gdszyzh-ecg: + url: jdbc:sqlserver://172.16.99.99:1433;DatabaseName=CardioScanServer + username: dmsuser + password: dmsecg@2020 + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + type: com.alibaba.druid.pool.DruidDataSource + # 初始化配置 + initial-size: 3 + # 最小连接数 + min-idle: 3 + # 最大连接数 + max-active: 10 + # 获取连接超 时时间 + max-wait: 5000 + # 连接有效性检测时间 + time-between-eviction-runs-millis: 90000 + # 最大空闲时间 + min-evictable-idle-time-millis: 1800000 + test-while-idle: true + test-on-borrow: false + test-on-return: false + validation-query: select 1 + gdszyzh-shouma: + url: jdbc:oracle:thin:@//172.16.99.197:1521/docare + username: medcomm + password: medcomm + driver-class-name: oracle.jdbc.driver.OracleDriver + type: com.alibaba.druid.pool.DruidDataSource + # 初始化配置 + initial-size: 1 + # 最小连接数 + min-idle: 1 + # 最大连接数 + max-active: 5 + # 获取连接超 时时间 + max-wait: 5000 + # 连接有效性检测时间 + time-between-eviction-runs-millis: 90000 + # 最大空闲时间 + min-evictable-idle-time-millis: 1800000 + test-while-idle: true + test-on-borrow: false + test-on-return: false + validation-query: select 1 from dual + gdszyzh-icu: + url: jdbc:oracle:thin:@//10.0.57.90:1521/docare + username: medcomm + password: medcomm + driver-class-name: oracle.jdbc.driver.OracleDriver + type: com.alibaba.druid.pool.DruidDataSource + # 初始化配置 + initial-size: 1 + # 最小连接数 + min-idle: 1 + # 最大连接数 + max-active: 5 + # 获取连接超 时时间 + max-wait: 5000 + # 连接有效性检测时间 + time-between-eviction-runs-millis: 90000 + # 最大空闲时间 + min-evictable-idle-time-millis: 1800000 + test-while-idle: true + test-on-borrow: false + test-on-return: false + validation-query: select 1 from dual + redis: host: redis.docus.cn password: JSdocus@702 diff --git a/src/main/resources/mapper/GdSzyZhEcgReportDataViewMapper.xml b/src/main/resources/mapper/GdSzyZhEcgReportDataViewMapper.xml new file mode 100644 index 0000000..76b8e4b --- /dev/null +++ b/src/main/resources/mapper/GdSzyZhEcgReportDataViewMapper.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/src/main/resources/mapper/GdSzyZhIcuReportDataViewMapper.xml b/src/main/resources/mapper/GdSzyZhIcuReportDataViewMapper.xml new file mode 100644 index 0000000..36ea401 --- /dev/null +++ b/src/main/resources/mapper/GdSzyZhIcuReportDataViewMapper.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/src/main/resources/mapper/GdSzyZhShouMaReportDataViewMapper.xml b/src/main/resources/mapper/GdSzyZhShouMaReportDataViewMapper.xml new file mode 100644 index 0000000..d37b185 --- /dev/null +++ b/src/main/resources/mapper/GdSzyZhShouMaReportDataViewMapper.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/src/main/resources/mapper/TBasicMapper.xml b/src/main/resources/mapper/TBasicMapper.xml index 06f8cb8..2150fb1 100644 --- a/src/main/resources/mapper/TBasicMapper.xml +++ b/src/main/resources/mapper/TBasicMapper.xml @@ -10,6 +10,15 @@ #{task.syncTime},#{task.c1},#{task.c2},#{task.c3},#{task.c4}, #{task.c5},#{task.c6},#{task.c7},#{task.t1},#{task.t2},#{task.t3},#{task.createTime}) + + INSERT INTO docus_archivefile.af_collect_patient_log + (patient_id, collect_id, last_collect_time, file_count) + VALUES + (#{cpLog.patientId}, #{cpLog.collectId}, #{cpLog.lastCollectTime}, #{cpLog.fileCount}) + ON DUPLICATE KEY UPDATE + last_collect_time = VALUES(last_collect_time), + file_count = VALUES(file_count) + update docus_archivefile.af_collect_task set sync_time=#{task.syncTime}, C2=#{task.c2}, C3=#{task.c3}, C4=#{task.c4}, C5=#{task.c5}, C6=#{task.c6}, C7=#{task.c7},T1=#{task.t1}, T2=#{task.t2}, T3=#{task.t3} @@ -42,6 +51,7 @@ SET remark = #{remark},end_time=now() WHERE id = #{id} + + + +