diff --git a/data-config/mzsy-module-alis b/data-config/mzsy-module-alis new file mode 100644 index 0000000..bf4d490 --- /dev/null +++ b/data-config/mzsy-module-alis @@ -0,0 +1,9 @@ +{ + "lis":"lis对应的分段", + "us":"us对应的分段", + "dx":"dx对应的分段", + "ct":"ct对应的分段", + "ecg":"ecg对应的分段", + "mect":"mect对应的分段", + "default":"默认文件分段" +} \ No newline at end of file diff --git a/src/main/java/com/docus/server/mzsy/entity/MzsyReportDataView.java b/src/main/java/com/docus/server/mzsy/entity/MzsyReportDataView.java new file mode 100644 index 0000000..c28dc66 --- /dev/null +++ b/src/main/java/com/docus/server/mzsy/entity/MzsyReportDataView.java @@ -0,0 +1,39 @@ +package com.docus.server.mzsy.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 梅州三院检验、检查、心电等报告视图 + * + * @author YongBin Wen + * @date 2024/8/16 14:39 + */ +@Data +@ApiModel("梅州三院检验、检查、心电等报告视图") +public class MzsyReportDataView { + + @ApiModelProperty("住院号") + private String zyh; + @ApiModelProperty("住院次数") + private Integer zycs; + @ApiModelProperty("文件ID(主键)定义文件唯一") + private String ffileId; + @ApiModelProperty("文件名称") + private String ffileName; + @ApiModelProperty("申请时间") + private Date ffileAfTime; + @ApiModelProperty("报告时间") + private Date ffileTime; + @ApiModelProperty("文件路径 HTTP路径") + private String ffilePath; + @ApiModelProperty("记账号(住院流水号)匹配患者主键唯一值") + private String fpatJzh; + @ApiModelProperty("分检验,检查,心电等,LIS、US,DX,CT,ECG") + private String fpatModule; + @ApiModelProperty("最后更新时间") + private Date updateTime; +} diff --git a/src/main/java/com/docus/server/mzsy/job/MzsyReportCollectJob.java b/src/main/java/com/docus/server/mzsy/job/MzsyReportCollectJob.java new file mode 100644 index 0000000..6108b01 --- /dev/null +++ b/src/main/java/com/docus/server/mzsy/job/MzsyReportCollectJob.java @@ -0,0 +1,111 @@ +package com.docus.server.mzsy.job; + +import com.alibaba.fastjson.JSONObject; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.utils.TableJsonRead; +import com.docus.infrastructure.web.api.CommonResult; +import com.docus.infrastructure.web.api.ResultCode; +import com.docus.server.mzsy.entity.MzsyReportDataView; +import com.docus.server.mzsy.mapper.MzsyReportDataViewMapper; +import com.docus.server.rpc.DownPlatformService; +import com.docus.server.rpc.TaskDistributeService; +import com.docus.server.rpc.dto.*; +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.util.Collections; +import java.util.List; + +/** + * @author YongBin Wen + * @date 2024/8/16 14:45 + */ +@Component +@Slf4j +public class MzsyReportCollectJob { + + @Autowired + private DownPlatformService downPlatformService; + @Autowired + private TaskDistributeService taskDistributeService; + @Autowired + private MzsyReportDataViewMapper reportDataViewMapper; + + @XxlJob("MzsyReportCollectJob") + public void reportCollect() { + // 1.获取任务和患者信息 2.查询视图信息 3.上报下载 + String jobParam = XxlJobHelper.getJobParam(); + JSONObject jobParamJsonObject = JSONObject.parseObject(jobParam); + String collectorId = jobParamJsonObject.getString("collectorId"); + String extraCondition = jobParamJsonObject.getString("extraCondition"); + if (Func.isBlank(collectorId)) { + log.warn(">>>>>>>>>>>>>>>>>>>>>> 梅州三院 检查、检验、心电等报告视图采集,未配置采集器获取任务信息"); + return; + } + + CommonResult commonResult = taskDistributeService.getNoViewTaskByCollectorId(collectorId); + if (ResultCode.SUCCESS.getCode().equals(commonResult.getCode()) + && commonResult.getData() != null) { + ReportDownTwoDto downTwoDto = commonResult.getData(); + ReportTaskTwoDto task = downTwoDto.getTasks().get(0); + log.info(">>>>>>>>>>>>>>>>>>>>>> 梅州三院 检查、检验、心电等报告视图采集任务,获取了任务:{}", Func.toJson(task)); + + ReportHospitalTwoDto hospitalTwoDto = downTwoDto.getHospitals().get(0); + ReportPatientTwoDto reportPatientTwoDto = downTwoDto.getPatient(); + String jzh = downTwoDto.getJzh(); + + List mzsyReportDataViewList = reportDataViewMapper.findByPatJzhAndOtherCondition(jzh, extraCondition); + int size = mzsyReportDataViewList.size(); + log.info("住院号:{},住院次数:{},记账号:{} 采集视图数据:{} 条!数据:{}", reportPatientTwoDto.getInpatientNo(), hospitalTwoDto.getAdmissTimes(), jzh, size,Func.toJson(mzsyReportDataViewList)); + if (size <= 0) { + return; + } + TableJsonRead tableJsonRead = new TableJsonRead(); + JSONObject moduleAlisConfig = tableJsonRead.Read("data-config", "mzsy-module-alis", JSONObject.class); + + ReportDownPatientDto patient = new ReportDownPatientDto(); + patient.setPatientid(downTwoDto.getPatientId()); + + ReportDownDto reportDownDto = new ReportDownDto(); + reportDownDto.setCollectorid(collectorId); + reportDownDto.setIp(""); + reportDownDto.setPatient(patient); + int sort=0; + for (MzsyReportDataView mzsyReportDataView : mzsyReportDataViewList) { + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(mzsyReportDataView.getFfilePath()); + reportDownScanFileDto.setFiletitle(mzsyReportDataView.getFfileName()); + reportDownScanFileDto.setSerialnum(mzsyReportDataView.getFfileId()); + reportDownScanFileDto.setFilesource(1); + reportDownScanFileDto.setFiletype(1); + reportDownScanFileDto.setFilestoragetype(1); + reportDownScanFileDto.setTaskid(task.getTaskId()); + reportDownScanFileDto.setSort(++sort); + List scanFiles = Collections.singletonList(reportDownScanFileDto); + + String assortId; + String fpatModule = mzsyReportDataView.getFpatModule(); + if (Func.isBlank(fpatModule)) { + assortId = moduleAlisConfig.getString("default"); + } else { + assortId = moduleAlisConfig.getString(fpatModule.toLowerCase().trim()); + if (Func.isBlank(assortId)) { + assortId = moduleAlisConfig.getString("default"); + } + } + reportDownDto.setAssortid(assortId); + reportDownDto.setScanfiles(scanFiles); + downPlatformService.report(reportDownDto); + } + } + } + + public static void main(String[] args) { + TableJsonRead tableJsonRead = new TableJsonRead(); + JSONObject moduleAlisConfig = tableJsonRead.Read("data-config", "mzsy-module-alis", JSONObject.class); + System.out.println(moduleAlisConfig); + } +} diff --git a/src/main/java/com/docus/server/mzsy/mapper/MzsyReportDataViewMapper.java b/src/main/java/com/docus/server/mzsy/mapper/MzsyReportDataViewMapper.java new file mode 100644 index 0000000..6b2bc7f --- /dev/null +++ b/src/main/java/com/docus/server/mzsy/mapper/MzsyReportDataViewMapper.java @@ -0,0 +1,25 @@ +package com.docus.server.mzsy.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.docus.server.mzsy.entity.MzsyReportDataView; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author YongBin Wen + * @date 2024/8/16 14:42 + */ +@DS("mzsy") +@Mapper +public interface MzsyReportDataViewMapper { + /** + * 根据患者记账号和额外条件查询视图数据 + * + * @param patJzh 记账号 + * @param extCondition 额外条件 + * @return 视图数据 + */ + List findByPatJzhAndOtherCondition(@Param("jzh") String patJzh, @Param("ext") String extCondition); +} diff --git a/src/main/java/com/docus/server/rpc/dto/ReportDownScanFileDto.java b/src/main/java/com/docus/server/rpc/dto/ReportDownScanFileDto.java index ef6127c..b70d3e6 100644 --- a/src/main/java/com/docus/server/rpc/dto/ReportDownScanFileDto.java +++ b/src/main/java/com/docus/server/rpc/dto/ReportDownScanFileDto.java @@ -28,5 +28,8 @@ public class ReportDownScanFileDto { @ApiModelProperty(value = "是否作废 : 0:否 不作废,1:是 作废") private int cancel=0; + @ApiModelProperty(value = "文件排序") + private int sort=0; + } diff --git a/src/main/java/com/docus/server/rpc/impl/DownPlatformServiceImpl.java b/src/main/java/com/docus/server/rpc/impl/DownPlatformServiceImpl.java index 1082271..8d8a983 100644 --- a/src/main/java/com/docus/server/rpc/impl/DownPlatformServiceImpl.java +++ b/src/main/java/com/docus/server/rpc/impl/DownPlatformServiceImpl.java @@ -8,7 +8,6 @@ import com.docus.infrastructure.web.api.CommonResult; import com.docus.server.config.DocusServerUrlConfig; import com.docus.server.rpc.DownPlatformService; import com.docus.server.rpc.dto.ReportDownDto; -import com.docus.server.rpc.dto.ReportDownScanFileDto; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -31,8 +30,7 @@ public class DownPlatformServiceImpl implements DownPlatformService { String downUrl = serverUrlConfig.getDownloadPlatformServerUrl() + "api/downplatform/report"; String requestId = Func.randomUUID(); String requestParam = Func.toJson(reportDownDto); - ReportDownScanFileDto report = reportDownDto.getScanfiles().get(0); - log.info("[{}]调用下载服务,地址:{} ,参数:taskid={}", requestId, downUrl, report.getTaskid()); + log.info("[{}]调用下载服务,地址:{} ,参数:{}", requestId, downUrl, requestParam); String respBody = post(downUrl, requestParam); log.info("[{}]调用下载服务成功,响应参数:{}", requestId, respBody); return Func.readJson(respBody, CommonResult.class); diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml index b06aa7f..acad337 100644 --- a/src/main/resources/bootstrap.yml +++ b/src/main/resources/bootstrap.yml @@ -33,11 +33,11 @@ spring: test-on-borrow: false test-on-return: false validation-query: select 1 - shouMa: - url: jdbc:log4jdbc:mysql://192.168.8.108:3306/lancet-aims?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai - username: wzh - password: wzh - driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy + mzsy: + url: jdbc:sqlserver://192.168.0.109;DatabaseName=interface_xmjs + username: xmjs + password: xmjs + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver type: com.alibaba.druid.pool.DruidDataSource # 初始化配置 initial-size: 3 @@ -54,7 +54,7 @@ spring: test-while-idle: true test-on-borrow: false test-on-return: false - validation-query: select 1 from dual + validation-query: select 1 redis: host: redis.docus.cn password: JSdocus@702 diff --git a/src/main/resources/mapper/MzsyReportDataViewMapper.xml b/src/main/resources/mapper/MzsyReportDataViewMapper.xml new file mode 100644 index 0000000..d4af12b --- /dev/null +++ b/src/main/resources/mapper/MzsyReportDataViewMapper.xml @@ -0,0 +1,27 @@ + + + + + + +