文件上报通用逻辑

master
wyb 2 years ago
parent 31ab311259
commit a88166cf58

@ -1,9 +1,17 @@
package com.docus.server;
import com.docus.core.util.SpringUtils;
import com.docus.server.collect.enums.DownWayEnum;
import com.docus.server.collect.service.FileReportService;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Properties;
/**
@ -11,14 +19,51 @@ import java.util.Properties;
*
* @author wyb
*/
@SpringBootApplication(scanBasePackages = {"com.docus"})
@EnableFeignClients
@EnableAsync
@MapperScan("com.docus.server.**.mapper")
@SpringBootApplication(scanBasePackages = {"com.docus"})
public class CollectApplication {
public static void main(String[] args) {
public static void main(String[] args) throws Exception {
Properties props = System.getProperties();
props.setProperty("org.apache.cxf.stax.allowInsecureParser", "1");
props.setProperty("UseSunHttpHandler", "true");
props.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
SpringApplication.run(CollectApplication.class, args);
// testBase64Report();
}
private static void testBase64Report() {
try {
String url=getBase64();
ReportFileInfoDTO dto = new ReportFileInfoDTO();
dto.setPatientId("20001099999");
dto.setSysFlag("icu");
dto.setSerialNum("0002353348_1229183645");
dto.setFileTitle("szy服务");
dto.setTaskId(2023060815440200002L);
dto.setDownUrl(url);
dto.setDownWayEnum(DownWayEnum.BASE64);
dto.setIp("szy-lis");
dto.setUserName("lis");
dto.setReportUserFullName("lis");
dto.setAssortId("list-assort");
FileReportService reportService = SpringUtils.getBean(FileReportService.class);
reportService.saveDownloadTaskAndReport(dto);
}catch (Exception ex){
ex.printStackTrace();
}
}
private static String getBase64() throws Exception {
FileReader reader = new FileReader("C:\\Users\\WYBDEV\\Desktop\\sb.txt");
BufferedReader bufferedReader = new BufferedReader(reader);
String base64 = bufferedReader.readLine();
bufferedReader.close();
reader.close();
return base64;
}
}

@ -0,0 +1,106 @@
package com.docus.server.collect.converter;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.enums.DownloadStateEnum;
import com.docus.server.collect.infrastructure.client.dto.ReportDownDto;
import com.docus.server.collect.infrastructure.client.dto.ReportDownPatientDto;
import com.docus.server.collect.infrastructure.client.dto.ReportDownScanFileDto;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* @author
*/
@Component
@Slf4j
public class FileReportConverter {
/**
*
*
* @param fileInfoDTO
* @param basicDataType 0 1 2
* @return
*/
public DownloadTask convertDownloadTask(ReportFileInfoDTO fileInfoDTO, Integer basicDataType) {
Date currentTime = new Date();
DownloadTask downloadTask = new DownloadTask();
downloadTask.setPatientId(fileInfoDTO.getPatientId());
downloadTask.setInpatientNo(fileInfoDTO.getInpatientNo());
downloadTask.setAdmissions(fileInfoDTO.getAdmisstimes());
downloadTask.setJzh(fileInfoDTO.getJzh());
downloadTask.setLatestIp(fileInfoDTO.getIp());
downloadTask.setLatestFileUrl(fileInfoDTO.getDownUrl());
downloadTask.setLatestFileUrlType(fileInfoDTO.getDownWayEnum().value());
downloadTask.setLatestFileTitle(fileInfoDTO.getFileTitle());
downloadTask.setLatestZdAssortId(fileInfoDTO.getAssortId());
downloadTask.setLatestReportTime(currentTime);
downloadTask.setLatestDownloadStatus(DownloadStateEnum.WAIT.code());
downloadTask.setCollectTaskId(fileInfoDTO.getTaskId());
downloadTask.setSource(fileInfoDTO.getSysFlag());
downloadTask.setFileSerialNum(fileInfoDTO.getSerialNum());
downloadTask.setLatestReportUserName(fileInfoDTO.getUserName());
downloadTask.setLatestReportUserFullName(fileInfoDTO.getReportUserFullName());
downloadTask.setFileStorageFormat(1);
downloadTask.setBasicDataType(basicDataType);
return downloadTask;
}
/**
*
* @param downloadTask
* @return
*/
public ReportDownDto convertDownloadPlatformParam(DownloadTask downloadTask) {
ReportDownPatientDto patient = convertDownloadPlatformPatientParam(downloadTask);
List<ReportDownScanFileDto> scanFiles = Collections.singletonList(convertDownloadPlatformFileParam(downloadTask));
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(downloadTask.getSource());
reportDownDto.setIp(downloadTask.getLatestIp());
reportDownDto.setAssortid(downloadTask.getLatestZdAssortId());
reportDownDto.setScanusercode(downloadTask.getLatestReportUserName());
reportDownDto.setScanusername(downloadTask.getLatestReportUserFullName());
reportDownDto.setPatient(patient);
reportDownDto.setScanfiles(scanFiles);
return reportDownDto;
}
/**
*
* @param downloadTask
* @return
*/
public ReportDownPatientDto convertDownloadPlatformPatientParam(DownloadTask downloadTask) {
ReportDownPatientDto patientDto = new ReportDownPatientDto();
patientDto.setPatientid(downloadTask.getPatientId());
patientDto.setInpatientno(downloadTask.getInpatientNo());
patientDto.setAdmisstimes(downloadTask.getAdmissions());
patientDto.setJzh(downloadTask.getJzh());
return patientDto;
}
/**
*
* @param downloadTask
* @return
*/
public ReportDownScanFileDto convertDownloadPlatformFileParam(DownloadTask downloadTask) {
ReportDownScanFileDto scanFileDto = new ReportDownScanFileDto();
scanFileDto.setTaskid(downloadTask.getCollectTaskId());
scanFileDto.setFiletitle(downloadTask.getLatestFileTitle());
scanFileDto.setFilesource(1);
scanFileDto.setFilestoragetype(1);
scanFileDto.setFiletype(downloadTask.getLatestFileUrlType());
scanFileDto.setDownurl(downloadTask.getLatestFileUrl());
scanFileDto.setSerialnum(downloadTask.getFileSerialNum());
scanFileDto.setSortdate(null);
scanFileDto.setCancel(0);
scanFileDto.setAssortid(downloadTask.getLatestZdAssortId());
scanFileDto.setFileStorageFormat(1);
return scanFileDto;
}
}

@ -0,0 +1,130 @@
package com.docus.server.collect.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*
*
* @author wyb
**/
@ApiModel(value = "DownloadTask对象", description = "文件生成下载任务")
@Data
@TableName("af_download_task")
public class DownloadTask implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "文件id主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
@TableField("patient_id")
@ApiModelProperty(value = "档案id(患者主键)")
private String patientId;
@TableField("inpatient_no")
@ApiModelProperty(value = "病案号")
private String inpatientNo;
@TableField("admissions")
@ApiModelProperty(value = "住院次数")
private Integer admissions;
@TableField("jzh")
@ApiModelProperty(value = "记账号")
private String jzh;
@TableField("latest_ip")
@ApiModelProperty(value = "最新的上报ip")
private String latestIp;
@TableField("latest_file_url")
@ApiModelProperty(value = "最新的上报文件地址")
private String latestFileUrl;
@TableField("latest_file_url_type")
@ApiModelProperty(value = "最新的获取文件方式(文件地址类型,http(1),base64(2),base64url(3),smb(4),localbase64(5))")
private Integer latestFileUrlType;
@TableField("latest_file_title")
@ApiModelProperty(value = "最新的上报文件标题")
private String latestFileTitle;
@TableField("latest_zd_assort_id")
@ApiModelProperty(value = "最新的上报文件分类id")
private String latestZdAssortId;
@TableField("latest_report_time")
@ApiModelProperty(value = "最新的上报时间")
private Date latestReportTime;
@TableField("latest_download_status")
@ApiModelProperty(value = "最新的下载状态(0:未开始,1:成功,2:失败)")
private Integer latestDownloadStatus;
@TableField("latest_download_time")
@ApiModelProperty(value = "最新的下载时间")
private Date latestDownloadTime;
@TableField("collect_task_id")
@ApiModelProperty(value = "采集任务id")
private Long collectTaskId;
@TableField("source")
@ApiModelProperty(value = "来源或者采集器id")
private String source;
@TableField("file_serial_num")
@ApiModelProperty(value = "来源或者采集器id")
private String fileSerialNum;
@TableField("latest_report_user_name")
@ApiModelProperty(value = "最后一次上报人工号")
private String latestReportUserName;
@TableField("latest_report_user_full_name")
@ApiModelProperty(value = "最后一次上报人姓名")
private String latestReportUserFullName;
@TableField("latest_retry_user_name")
@ApiModelProperty(value = "最后一次重试操作人工号")
private String latestRetryUserName;
@TableField("latest_retry_user_full_name")
@ApiModelProperty(value = "最后一次重试操作人姓名")
private String latestRetryUserFullName;
@TableField("basic_data_type")
@ApiModelProperty(value = "基础数据类型 0普通病案 1门急诊病案 2省中医封存病案")
private Integer basicDataType;
@TableField("download_file_path")
@ApiModelProperty(value = "文件下载存放路径(程序生成)")
private String downloadFilePath;
@TableField("file_storage_format")
@ApiModelProperty(value = "下载存储文件的方式 0 传过来的格式1转为 pdf 默认 2 转为图片jpg存储")
public Integer fileStorageFormat;
public DownloadTask() {
}
}

@ -0,0 +1,35 @@
package com.docus.server.collect.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
*
* @author WYBDEV
*/
@Data
@ApiModel(value = "患者基础信息")
public class TBasic {
@ApiModelProperty(value = "病案主键")
private String patientId;
@ApiModelProperty(value = "住院号")
private String inpatientNo;
@ApiModelProperty(value = "住院次数")
private Integer admissTimes;
@ApiModelProperty(value = "入院日期 yyyy-MM-dd HH:mm:ss")
private String admissDate;
@ApiModelProperty(value = "入院科室名称")
private String admissDeptName;
@ApiModelProperty(value = "出院日期 yyyy-MM-dd HH:mm:ss")
private String disDate;
@ApiModelProperty(value = "出院科室名称")
private String disDeptName;
@ApiModelProperty(value = "记账号")
private String jzh;
@ApiModelProperty(value = "姓名")
private String name;
@ApiModelProperty(value = "住院id")
private String admissId;
}

@ -0,0 +1,43 @@
package com.docus.server.collect.enums;
/**
*
*/
public enum DownWayEnum {
/**
* http https ftp
*/
HTTP(1,"网络地址URL"),
/**
* base64
*/
BASE64(2,"BASE64内容文本"),
/**
* urlbase64
*/
BASE64URL(3,"BASE64内容地址"),
/**
*
*/
SMB(4,"共享文件夹"),
/**
* base64
*/
LocalBase64(5,"本地BAE64内容文件"),
;
private final Integer code;
private final String desc;
private DownWayEnum(Integer code, String desc) {
this.code = code;
this.desc=desc;
}
public Integer value() {
return this.code;
}
public String desc(){
return this.desc;
}
}

@ -0,0 +1,36 @@
package com.docus.server.collect.enums;
/**
*
*
* @author wyb
*/
public enum DownloadStateEnum {
/**
*
*/
WAIT(0, "未开始"),
/**
*
*/
success(1, "成功"),
/**
*
*/
fail(2, "失败");
final Integer code;
final String desc;
DownloadStateEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer code() {
return this.code;
}
public String desc() {
return this.desc;
}
}

@ -0,0 +1,21 @@
package com.docus.server.collect.infrastructure.client;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.collect.infrastructure.client.dto.ReportDownDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
*
* @author wyb
*/
@FeignClient(url = "${docus.url.downloadPlatform}",name = "download-platform")
public interface DownloadPlatformService {
@ApiOperation("病案上报文件(通用)")
@RequestMapping(value = "/api/downplatform/report",method = RequestMethod.POST)
public CommonResult report(@RequestBody ReportDownDto resources);
}

@ -0,0 +1,29 @@
package com.docus.server.collect.infrastructure.client.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class ReportDownDto {
@ApiModelProperty(value = "采集器id")
private String collectorid;
@ApiModelProperty(value = "采集器ip")
private String ip;
@ApiModelProperty(value = "分类id")
private String assortid;
@ApiModelProperty(value = "患者信息")
private ReportDownPatientDto patient;
@ApiModelProperty(value = "文件信息")
private List<ReportDownScanFileDto> scanfiles;
@ApiModelProperty(value = "扫描用户代码")
private String scanusercode;
@ApiModelProperty(value = "扫描用户名称")
private String scanusername;
}

@ -0,0 +1,19 @@
package com.docus.server.collect.infrastructure.client.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ReportDownPatientDto {
@ApiModelProperty(value = "记帐号")
private String jzh;
@ApiModelProperty(value = "住院次数,记帐号重复则加这个参数无则Null")
private Integer admisstimes;
@ApiModelProperty(value = "病案主键如有传则使用无则使用jzh")
private String patientid;
@ApiModelProperty(value = "病案号")
private String inpatientno;
@ApiModelProperty(value = "物理存储位置,有则传")
private String storagelocation;
}

@ -0,0 +1,44 @@
package com.docus.server.collect.infrastructure.client.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ReportDownScanFileDto {
@ApiModelProperty(value = "任务id(如无效任务id则不更新任务表数据)")
private Long taskid;
@ApiModelProperty(value = "文件标题")
private String filetitle;
@ApiModelProperty(value = "采集类型(文件来源 1:采集器2扫描生产软件)")
private int filesource;
@ApiModelProperty(value = "下载类型(1:服务器本地2ftp服务器3共享文件夹)")
private int filestoragetype;
@ApiModelProperty(value = "文件类型(1:url,2:base64,3:url base64,4:共享文件5本地文件base64)")
private int filetype=1;
@ApiModelProperty(value = "下载地址")
private String downurl;
// @ApiModelProperty(value = "档案信息")
// private String recordid;
@ApiModelProperty(value = "采集流水号")
private String serialnum;
@ApiModelProperty(value = "排序日期")
private String sortdate;
@ApiModelProperty(value = "是否作废 0否 不作废1是 作废")
private int cancel=0;
@ApiModelProperty(value = "分类id",hidden = true)
private String assortid;
@ApiModelProperty(value = "归档系统文件id",hidden = true)
private Long tScanAssortId;
/**
* 0 1 pdf 2 jpg
*/
public int fileStorageFormat=1;
}

@ -0,0 +1,47 @@
package com.docus.server.collect.infrastructure.dao;
import com.docus.infrastructure.core.db.dao.IBaseDao;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import java.util.List;
/**
* -访
* @author wyb
*/
public interface DownloadTaskDao extends IBaseDao<DownloadTask> {
/**
*
* @param fileInfoDTO
* @return
*/
List<TBasic> getBasicInfo(ReportFileInfoDTO fileInfoDTO);
/**
* id
* @param downloadTask
* @return idid
*/
Long getDownloadTaskIdFromDownloadTask(DownloadTask downloadTask);
/**
* idid
* @param patientId
* @param source
* @param serialNum
* @return idid
*/
Long getDownloadTaskIdFromSanAssort(String patientId, String source, String serialNum);
/**
* idid
* @param patientId
* @param source
* @param serialNum
* @return idid
*/
Long getDownloadTaskIdFromDownFile(String patientId, String source, String serialNum);
}

@ -0,0 +1,51 @@
package com.docus.server.collect.infrastructure.dao.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.docus.core.util.Func;
import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.infrastructure.dao.DownloadTaskDao;
import com.docus.server.collect.infrastructure.mapper.DownloadTaskMapper;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* -访
*
* @author wyb
*/
@Repository
public class DownloadTaskDaoImpl extends BaseDaoImpl<DownloadTaskMapper, DownloadTask> implements DownloadTaskDao {
@Override
public List<TBasic> getBasicInfo(ReportFileInfoDTO fileInfoDTO) {
return baseMapper.getBasicInfo(fileInfoDTO);
}
@Override
public Long getDownloadTaskIdFromDownloadTask(DownloadTask downloadTask) {
LambdaQueryWrapper<DownloadTask> wrapper = new LambdaQueryWrapper<>();
wrapper.select(DownloadTask::getId);
wrapper.eq(Func.isNotBlank(downloadTask.getPatientId()), DownloadTask::getPatientId, downloadTask.getPatientId());
wrapper.eq(Func.isNotBlank(downloadTask.getJzh()), DownloadTask::getJzh, downloadTask.getJzh());
wrapper.eq(Func.isNotBlank(downloadTask.getInpatientNo()), DownloadTask::getInpatientNo, downloadTask.getInpatientNo());
wrapper.eq(Func.isNotEmpty(downloadTask.getAdmissions()), DownloadTask::getAdmissions, downloadTask.getAdmissions());
List<DownloadTask> downloadTasks = baseMapper.selectList(wrapper);
if (Func.isNotEmpty(downloadTasks) && downloadTasks.size() == 1) {
return downloadTasks.get(0).getId();
}
return null;
}
@Override
public Long getDownloadTaskIdFromSanAssort(String patientId, String source, String serialNum) {
return baseMapper.getDownloadTaskIdFromSanAssort(patientId, source, serialNum);
}
@Override
public Long getDownloadTaskIdFromDownFile(String patientId, String source, String serialNum) {
return baseMapper.getDownloadTaskIdFromDownFile(patientId, source, serialNum);
}
}

@ -0,0 +1,37 @@
package com.docus.server.collect.infrastructure.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface DownloadTaskMapper extends BaseMapper<DownloadTask> {
/**
* from `docus_medicalrecord`.`t_basic`
*
* @param fileInfoDTO
* @return
*/
List<TBasic> getBasicInfo(@Param("dto") ReportFileInfoDTO fileInfoDTO);
/**
* idid
* @param patientId
* @param source
* @param serialNum
* @return idid
*/
Long getDownloadTaskIdFromSanAssort(@Param("patientId") String patientId, @Param("source") String source, @Param("serialNum") String serialNum);
/**
* idid
* @param patientId
* @param source
* @param serialNum
* @return idid
*/
Long getDownloadTaskIdFromDownFile(@Param("patientId") String patientId, @Param("source") String source, @Param("serialNum") String serialNum);
}

@ -0,0 +1,25 @@
package com.docus.server.collect.service;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
/**
* -
* @author wyb
*/
public interface FileReportService {
/**
*
* | t_basic
* @param fileInfoDTO
*/
void saveDownloadTaskAndReport(ReportFileInfoDTO fileInfoDTO);
/**
* idid
* patientIdpatientId
* @param downloadTask
* @return id
*/
Long getDownloadTaskId(DownloadTask downloadTask);
}

@ -0,0 +1,104 @@
package com.docus.server.collect.service.dto;
import com.docus.server.collect.enums.DownWayEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
*
* ,,,
*
* @author wyb
*/
@ApiModel("上报的文件信息对象")
@Data
public class ReportFileInfoDTO {
/**
*
*/
@ApiModelProperty("住院号")
private String inpatientNo;
/**
* /
*/
@ApiModelProperty("记账号/住院流水号")
private String jzh;
/**
*
*/
@ApiModelProperty("住院次数")
private Integer admisstimes;
/**
*
*/
@ApiModelProperty("患者病案主键")
private String patientId;
/**
*
*/
@ApiModelProperty("采集来源系统")
@NotBlank
private String sysFlag;
/**
*
*/
@ApiModelProperty("下载地址")
@NotBlank
private String downUrl;
/**
*
*/
@ApiModelProperty("下载地址类型")
@NotNull
private DownWayEnum downWayEnum;
/**
*
*/
@ApiModelProperty("文件名")
@NotBlank
private String fileTitle;
/**
* /id
*/
@ApiModelProperty("采集流水号/文件唯一id")
@NotBlank
private String serialNum;
/**
* id
*/
@ApiModelProperty("文件分类id")
@NotBlank
private String assortId;
/**
* id ,
*/
@ApiModelProperty("下载对应任务id ,接收处理")
private Long taskId;
/**
* ip
*/
@ApiModelProperty("ip地址")
private String ip;
/**
*
*/
@ApiModelProperty("用户工号")
private String userName;
/**
*
*/
@ApiModelProperty("用户名")
private String reportUserFullName;
}

@ -0,0 +1,97 @@
package com.docus.server.collect.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.docus.core.util.Func;
import com.docus.infrastructure.redis.service.IdService;
import com.docus.server.collect.converter.FileReportConverter;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.infrastructure.client.DownloadPlatformService;
import com.docus.server.collect.infrastructure.dao.DownloadTaskDao;
import com.docus.server.collect.service.FileReportService;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ThreadPoolExecutor;
/**
* -
*
* @author wyb
*/
@Slf4j
@Service
public class FileReportServiceImpl implements FileReportService {
@Autowired
private DownloadPlatformService downloadPlatformService;
@Autowired
private DownloadTaskDao downloadTaskDao;
@Autowired
private FileReportConverter fileReportConverter;
@Autowired
private IdService idService;
@Autowired
private ThreadPoolExecutor threadPoolExecutor;
@Override
public void saveDownloadTaskAndReport(ReportFileInfoDTO fileInfoDTO) {
// 查询基础数据,更新新的病案信息
List<TBasic> tBasics = downloadTaskDao.getBasicInfo(fileInfoDTO);
// 如果找到患者基础数据并且刚好为1条
if (CollUtil.isNotEmpty(tBasics) && tBasics.size() == 1) {
TBasic tBasic = tBasics.get(0);
fileInfoDTO.setPatientId(tBasic.getPatientId());
fileInfoDTO.setInpatientNo(tBasic.getInpatientNo());
fileInfoDTO.setAdmisstimes(tBasic.getAdmissTimes());
fileInfoDTO.setJzh(tBasic.getJzh());
}
// 转换下载任务对象
DownloadTask downloadTask = fileReportConverter.convertDownloadTask(fileInfoDTO, 0);
// 查询旧的下载任务id,更新/保存任务信息
Long downloadTaskId = Optional.ofNullable(getDownloadTaskId(downloadTask)).orElse(idService.getDateSeq());
downloadTask.setId(downloadTaskId);
downloadTaskDao.saveOrUpdate(downloadTask);
report(downloadTask);
}
@Override
public Long getDownloadTaskId(DownloadTask downloadTask) {
String patientId = downloadTask.getPatientId();
if(StrUtil.isNotBlank(patientId)){
String serialNum = downloadTask.getFileSerialNum();
String source = downloadTask.getSource();
// 从文件表获取
Long downloadTaskId = downloadTaskDao.getDownloadTaskIdFromSanAssort(patientId,source,serialNum);
if (Func.isNotEmpty(downloadTaskId)) {
return downloadTaskId;
}
// 从下载记录表获取
downloadTaskId = downloadTaskDao.getDownloadTaskIdFromDownFile(patientId,source,serialNum);
if (Func.isNotEmpty(downloadTaskId)) {
return downloadTaskId;
}
}
// 从下载任务表获取,不考虑重复,重复那就是调研不清楚或者代码调用错误
return downloadTaskDao.getDownloadTaskIdFromDownloadTask(downloadTask);
}
/**
*
*
* @param downloadTask
*/
private void report(DownloadTask downloadTask) {
threadPoolExecutor.execute(() -> {
if (downloadTask.getBasicDataType().equals(0)) {
downloadPlatformService.report(fileReportConverter.convertDownloadPlatformParam(downloadTask));
}
});
}
}

@ -4,7 +4,7 @@ spring:
application:
name: @artifactId@
datasource:
url: jdbc:log4jdbc:mysql://db.docus.cn:3306/docus_medicalrecord?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
url: jdbc:log4jdbc:mysql://db.docus.cn:3306/docus_archivefile?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: docus
password: docus702
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
@ -46,6 +46,9 @@ spring:
docus:
dbtype: mysql
url:
# 下载平台服务地址
downloadPlatform: http://192.168.16.85:9291
mybatis-plus:
configuration:

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.server.collect.infrastructure.mapper.DownloadTaskMapper">
<select id="getBasicInfo" resultType="com.docus.server.collect.entity.TBasic">
select
`patient_id` as patientId,
`admiss_times` as admissTimes,
`inpatient_no` as inpatientNo,
`admiss_id` as admissId,
`admiss_date` as admissDate,
`dis_date` as disDate,
`admiss_dept_name` as admissDeptName,
`dis_dept_name` as disDeptName ,
`jzh`,
`name`
FROM
`docus_medicalrecord`.`t_basic`
WHERE
is_cancel=0
<if test="dto.patientId != null and dto.patientId != ''">
and `patient_id` = #{dto.patientId}
</if>
<if test="dto.jzh != null and dto.jzh != ''">
and `jzh` = #{dto.jzh}
</if>
<if test="dto.inpatientNo != null and dto.inpatientNo != ''">
and `inpatient_no` = #{dto.inpatientNo}
</if>
<if test="dto.admisstimes != null">
and `admiss_times` = #{dto.admisstimes}
</if>
limit 2
</select>
<select id="getDownloadTaskIdFromSanAssort" resultType="java.lang.Long">
SELECT
`id`
FROM
`docus_archivefile`.`t_scan_assort`
where
`patient_id` = #{patientId}
and `source`= #{source}
and `file_column_1`= #{serialNum}
</select>
<select id="getDownloadTaskIdFromDownFile" resultType="java.lang.Long">
SELECT
`t_scan_assort_id`
FROM
`docus_archivefile`.`af_downfile`
WHERE
`patient_id` = #{patientId}
and `collectorid` = #{source}
and `serialnum` = #{serialNum}
order by `create_time` desc limit 1
</select>
</mapper>
Loading…
Cancel
Save