扫描文件同步

collector-patient-scan
wyb 2 years ago
parent 2f040453ee
commit 4f33626843

@ -0,0 +1 @@
{"lastExecuteDate":"2023-11-15"}

@ -1,17 +1,13 @@
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 com.docus.infrastructure.core.utils.SpringUtil;
import com.docus.server.collect.job.PatScanFileSyncJob;
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;
/**
@ -31,39 +27,16 @@ public class CollectApplication {
props.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
SpringApplication.run(CollectApplication.class, args);
// testBase64Report();
testCollectJob();
}
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;
private static void testCollectJob() {
PatScanFileSyncJob bean = SpringUtil.getApplicationContext().getBean(PatScanFileSyncJob.class);
bean.patScanFileSyncByScanDateJob();
}
}

@ -3,6 +3,7 @@ package com.docus.server.collect.controller;
import com.docus.core.util.Func;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.collect.dto.PatientScanConditionDTO;
import com.docus.server.collect.entity.PatientScan;
import com.docus.server.collect.service.PatientScanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,13 +28,12 @@ public class PatientScanController {
private PatientScanService patientScanService;
@PostMapping("/collect/byInpatientNoAndTimes")
@ApiOperation("根据住院号和住院次数,进行患者电子病历扫描数据采集")
public CommonResult<String> collectByInpatientNoAndTimes(@RequestBody List<PatientScanConditionDTO> patientScanConditionDTOList) {
@PostMapping("/get/byInpatientNoAndTimes")
@ApiOperation("根据住院号和住院次数,进行患者电子病历扫描数据采集,返回采集数据")
public CommonResult<List<PatientScan>> collectByInpatientNoAndTimes(@RequestBody List<PatientScanConditionDTO> patientScanConditionDTOList) {
if (Func.isEmpty(patientScanConditionDTOList)) {
return CommonResult.failed("请输入正确的请求参数!");
}
patientScanService.collectByInpatientNoAndTimes(patientScanConditionDTOList);
return CommonResult.success("采集成功!");
return CommonResult.success(patientScanService.getScanDataByInpatientNoAndTimes(patientScanConditionDTOList));
}
}

@ -1,6 +1,9 @@
package com.docus.server.collect.converter;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.PatientScan;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.enums.DownWayEnum;
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;
@ -20,6 +23,28 @@ import java.util.List;
@Slf4j
public class FileReportConverter {
/**
* ,id
* @param tBasic
* @param patientScan
* @return
*/
public ReportFileInfoDTO convertReportFileInfoDTO(TBasic tBasic, PatientScan patientScan) {
ReportFileInfoDTO fileInfoDTO = new ReportFileInfoDTO();
fileInfoDTO.setPatientId(tBasic.getPatientId());
fileInfoDTO.setInpatientNo(tBasic.getInpatientNo());
fileInfoDTO.setAdmisstimes(tBasic.getAdmissTimes());
fileInfoDTO.setJzh(tBasic.getJzh());
fileInfoDTO.setIp("gdszy-patsm-sync");
fileInfoDTO.setUserName("admin");
fileInfoDTO.setReportUserFullName("pat-sm");
fileInfoDTO.setSerialNum(patientScan.getId()+patientScan.getZdAssortName()+patientScan.getFileName());
fileInfoDTO.setAssortId(patientScan.getZdAssortId());
fileInfoDTO.setFileTitle(patientScan.getFileName().substring(0,patientScan.getFileName().indexOf(".")));
fileInfoDTO.setDownUrl(patientScan.getImagePath()+"/"+patientScan.getFileName());
fileInfoDTO.setDownWayEnum(DownWayEnum.SMB);
return fileInfoDTO;
}
/**
*

@ -1,6 +1,5 @@
package com.docus.server.collect.dto;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -32,14 +31,11 @@ public class TBasicQrDto {
@ApiModelProperty(value = "省中医患者主索引号")
private String empId;
@ApiModelProperty(value = "是否忽略ph字段为1 则添加条件 ph is null")
private int ignorePh;
public TBasicQrDto() {
}
public TBasicQrDto(ReportFileInfoDTO fileInfoDTO) {
this.jzh = fileInfoDTO.getJzh();
this.patientId = fileInfoDTO.getPatientId();
this.inpatientNo = fileInfoDTO.getInpatientNo();
this.admissTimes = fileInfoDTO.getAdmisstimes();
;
}
}

@ -0,0 +1,112 @@
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_collect_task")
public class CollectTask implements Serializable {
@TableField("id")
@ApiModelProperty(value = "id 雪花算法")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
@TableField("patient_id")
@ApiModelProperty(value = "病案主键")
private String patientId;
@TableField("sysflag")
@ApiModelProperty(value = "来源 1护理文书2 HIS电子病历3 Pacs检查4心电系统5手麻系统6 Lis检验7临床首页8长期医嘱 9临时医嘱10 省病案统计系统首页11 扫描首页;")
private String sysflag;
@TableField("start_time")
@ApiModelProperty(value = "开始时间")
private Date startTime;
@TableField("end_time")
@ApiModelProperty(value = "结束时间")
private Date endTime;
@TableField("state")
@ApiModelProperty(value = "任务状态 0未开始1:正在采集2采集错误3采集完成")
private String state;
@TableField("sync_time")
@ApiModelProperty(value = "同步时间")
private Date syncTime;
@TableField("recollect_time")
@ApiModelProperty(value = "最新重新采集时间")
private Date recollectTime;
@TableField("recollect_name")
@ApiModelProperty(value = "最新重新采集人")
private String recollectName;
@TableField("remark")
@ApiModelProperty(value = "备注")
private String remark;
@TableField("presult")
@ApiModelProperty(value = "presult")
private String presult;
@TableField("C1")
@ApiModelProperty(value = "报告唯一单号")
private String c1;
@TableField("C2")
@ApiModelProperty(value = "文件名称")
private String c2;
@TableField("C3")
@ApiModelProperty(value = "记账号")
private String c3;
@TableField("C4")
@ApiModelProperty(value = "c4")
private String c4;
@TableField("C5")
@ApiModelProperty(value = "c5")
private String c5;
@TableField("C6")
@ApiModelProperty(value = "c6")
private String c6;
@TableField("C7")
@ApiModelProperty(value = "c7")
private String c7;
@TableField("C8")
@ApiModelProperty(value = "c8")
private String c8;
@TableField("C9")
@ApiModelProperty(value = "c9")
private String c9;
@TableField("C10")
@ApiModelProperty(value = "c10")
private String c10;
}

@ -1,6 +1,5 @@
package com.docus.server.collect.entity;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -35,17 +34,5 @@ public class TBasic {
private String admissId;
@ApiModelProperty(value = "省中医患者主索引号")
private String empId;
// @ApiModelProperty(value = "省中医患者记账号")
// private String accountRegistration;
public TBasic() {
}
public TBasic(ReportFileInfoDTO fileInfoDTO) {
this.jzh = fileInfoDTO.getJzh();
this.patientId = fileInfoDTO.getPatientId();
this.inpatientNo = fileInfoDTO.getInpatientNo();
this.admissTimes = fileInfoDTO.getAdmisstimes();
;
}
}

@ -0,0 +1,26 @@
package com.docus.server.collect.infrastructure.dao;
import com.docus.infrastructure.core.db.dao.IBaseDao;
import com.docus.server.collect.entity.CollectTask;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
/**
* dao
* @author wyb
*/
public interface CollectTaskDao extends IBaseDao<CollectTask> {
/**
* id
* @param reportFileInfoDTO
* @return id
*/
Long saveTask(ReportFileInfoDTO reportFileInfoDTO);
/**
* saveTask
* @param reportFileInfoDTO
* @return id
* @throws InterruptedException
*/
Long saveTaskUseLock(ReportFileInfoDTO reportFileInfoDTO) throws InterruptedException;
}

@ -2,9 +2,6 @@ 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 java.util.List;
/**
* -访
@ -12,13 +9,7 @@ import java.util.List;
* @author wyb
*/
public interface DownloadTaskDao extends IBaseDao<DownloadTask> {
/**
*
*
* @param tBasic
* @return
*/
List<TBasic> getBasicInfo(TBasic tBasic);
/**

@ -0,0 +1,70 @@
package com.docus.server.collect.infrastructure.dao.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl;
import com.docus.infrastructure.redis.service.IdService;
import com.docus.infrastructure.redis.service.RedisLock;
import com.docus.server.collect.entity.CollectTask;
import com.docus.server.collect.infrastructure.dao.CollectTaskDao;
import com.docus.server.collect.infrastructure.mapper.CollectTaskMapper;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.Date;
/**
* dao
*
* @author wyb
*/
@Repository
public class CollectTaskDaoImpl extends BaseDaoImpl<CollectTaskMapper, CollectTask> implements CollectTaskDao {
@Resource
private IdService idService;
@Resource
private RedisLock redisLock;
@Override
public Long saveTask(ReportFileInfoDTO reportFileInfoDTO) {
Date now = new Date();
LambdaQueryWrapper<CollectTask> queryCollectTaskWrapper = new LambdaQueryWrapper<>();
queryCollectTaskWrapper.eq(CollectTask::getC1, reportFileInfoDTO.getSerialNum());
queryCollectTaskWrapper.eq(CollectTask::getSysflag, reportFileInfoDTO.getSysFlag());
queryCollectTaskWrapper.eq(CollectTask::getPatientId, reportFileInfoDTO.getPatientId());
CollectTask collectTask = baseMapper.selectOne(queryCollectTaskWrapper);
// 更新或者新增
if (collectTask != null) {
collectTask.setState("0");
collectTask.setSyncTime(now);
collectTask.setC2(reportFileInfoDTO.getFileTitle());
baseMapper.updateById(collectTask);
} else {
collectTask = new CollectTask();
collectTask.setId(idService.getDateSeq());
collectTask.setPatientId(reportFileInfoDTO.getPatientId());
collectTask.setSysflag(reportFileInfoDTO.getSysFlag());
collectTask.setState("0");
collectTask.setSyncTime(now);
collectTask.setC1(reportFileInfoDTO.getSerialNum());
collectTask.setC2(reportFileInfoDTO.getFileTitle());
collectTask.setC3(reportFileInfoDTO.getJzh());
baseMapper.insert(collectTask);
}
return collectTask.getId();
}
@Override
public Long saveTaskUseLock(ReportFileInfoDTO reportFileInfoDTO) throws InterruptedException {
String lockFlag = "docus:gdszy:downloadplatform:report:" + reportFileInfoDTO.getPatientId() + ":" + reportFileInfoDTO.getSysFlag();
try {
redisLock.tryLock(lockFlag, 10 * 1000, 10 * 1000);
return saveTask(reportFileInfoDTO);
} finally {
redisLock.unLock(lockFlag);
}
}
}

@ -4,7 +4,6 @@ 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 org.springframework.stereotype.Repository;
@ -18,10 +17,6 @@ import java.util.List;
*/
@Repository
public class DownloadTaskDaoImpl extends BaseDaoImpl<DownloadTaskMapper, DownloadTask> implements DownloadTaskDao {
@Override
public List<TBasic> getBasicInfo(TBasic basic) {
return baseMapper.getBasicInfo(basic);
}
@Override
public Long getDownloadTaskIdFromDownloadTask(DownloadTask downloadTask) {

@ -1,6 +1,8 @@
package com.docus.server.collect.infrastructure.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.server.collect.entity.CollectTask;
import org.apache.ibatis.annotations.Mapper;
/**
@ -8,5 +10,5 @@ import org.apache.ibatis.annotations.Mapper;
*/
@DS("archive-mysql")
@Mapper
public interface CollectTaskMapper {
public interface CollectTaskMapper extends BaseMapper<CollectTask> {
}

@ -2,41 +2,13 @@ package com.docus.server.collect.infrastructure.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.server.collect.dto.TBasicQrDto;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@DS("archive-mysql")
@Mapper
public interface DownloadTaskMapper extends BaseMapper<DownloadTask> {
/**
* from `docus_medicalrecord`.`t_basic`
*
* @param tBasic
* @return
*/
List<TBasic> getBasicInfo(@Param("basic") TBasic tBasic);
/**
*
* @param qrDto
* @return
*/
int countBasicInfo(@Param("dto") TBasicQrDto qrDto);
/**
*
* @param qrDto
* @param offset
* @param size
* @return
*/
List<TBasic> pageBasicInfo(@Param("dto") TBasicQrDto qrDto,@Param("offset") long offset,@Param("size") long size);
/**
* idid
* @param patientId

@ -1,7 +1,12 @@
package com.docus.server.collect.infrastructure.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.docus.server.collect.dto.TBasicQrDto;
import com.docus.server.collect.entity.TBasic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author wyb
@ -9,4 +14,11 @@ import org.apache.ibatis.annotations.Mapper;
@DS("archive-mysql")
@Mapper
public interface PatientBasicMapper {
/**
* from `docus_medicalrecord`.`t_basic`
*
* @param dto
* @return
*/
List<TBasic> getBasicInfo(@Param("dto") TBasicQrDto dto);
}

@ -30,7 +30,14 @@ public interface PatientScanMapper {
* @param scanEndTime
* @return
*/
List<PatientScanConditionDTO> getScanPatientCondition(@Param("start")String scanStartTime,@Param("end") String scanEndTime);
List<PatientScanConditionDTO> getScanPatientConditionByScanDate(@Param("start")String scanStartTime, @Param("end") String scanEndTime);
/**
*
* @param scanStartTime
* @param scanEndTime
* @return
*/
List<PatientScanConditionDTO> getScanPatientConditionByDisDate(@Param("start")String scanStartTime, @Param("end") String scanEndTime);
}

@ -0,0 +1,167 @@
package com.docus.server.collect.job;
import com.docus.core.util.Func;
import com.docus.infrastructure.core.utils.TableJsonRead;
import com.docus.server.collect.converter.FileReportConverter;
import com.docus.server.collect.dto.PatientScanConditionDTO;
import com.docus.server.collect.dto.TBasicQrDto;
import com.docus.server.collect.entity.PatientScan;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.infrastructure.dao.CollectTaskDao;
import com.docus.server.collect.infrastructure.mapper.PatientBasicMapper;
import com.docus.server.collect.service.FileReportService;
import com.docus.server.collect.service.PatientScanService;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
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.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
/**
*
*
* @author wyb
*/
@Component
@Slf4j
public class PatScanFileSyncJob {
@Resource
private PatientScanService patientScanService;
@Resource
private PatientBasicMapper patientBasicMapper;
@Resource
private FileReportService fileReportService;
@Resource
private CollectTaskDao collectTaskDao;
@Resource
private FileReportConverter fileReportConverter;
@Value("${docus.sync.patsmGSys}")
private String patmGSys;
@XxlJob("PatScanFileSyncByScanDateJob")
public void patScanFileSyncByScanDateJob() {
final String taskName = "电子病历扫描视图同步,根据扫描时间同步Job";
log.info("============================= {}采集开始!=============================", taskName);
try {
patScanFileSyncByScanDate();
} catch (Exception ex) {
log.error(taskName + "============================= 采集出现错误!============================= ", ex);
}
log.info("============================= {}采集结束!=============================", taskName);
}
private void patScanFileSyncByScanDate() {
String delayDayParam = XxlJobHelper.getJobParam();
int delayDay = 1;
try {
if (Func.isNotBlank(delayDayParam)) {
delayDay = Integer.parseInt(delayDayParam);
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
LocalDate jobStartDate = LocalDate.now();
QueryConfig config = QueryConfig.getQueryConfig();
LocalDate dateStartCondition;
if (config == null) {
config = new QueryConfig();
dateStartCondition = jobStartDate.plusDays(-delayDay);
} else {
dateStartCondition = LocalDate.parse(config.getLastExecuteDate()).plusDays(-delayDay);
}
config.setLastExecuteDate(dateStartCondition.toString());
LocalDate lastExecuteDate = dateStartCondition;
// 一天一天的执行,查询一天的住院号和住院次数,单个患者进行采集上传
// 执行的时间如果大于job的当天则结束
do {
if (lastExecuteDate.isAfter(jobStartDate)) {
break;
}
String startTime = lastExecuteDate + " 00:00:00";
String endTime = lastExecuteDate + " 23:59:59";
List<PatientScanConditionDTO> inpatientNoAndTimesByScanDate = patientScanService.getInpatientNoAndTimesByScanDate(startTime, endTime);
inpatientNoAndTimesByScanDate = Optional.ofNullable(inpatientNoAndTimesByScanDate).orElse(new ArrayList<>());
for (PatientScanConditionDTO patientScanConditionDTO : inpatientNoAndTimesByScanDate) {
List<TBasic> basicList = getBasicInfo(patientScanConditionDTO);
if (Objects.isNull(basicList) || basicList.size() != 1) {
log.warn("{},住院号:{},住院次数:{} 查询基础数据没有数据或者有多条数据,请检查!", "电子病历扫描视图同步,根据扫描时间同步Job", patientScanConditionDTO.getInpatientNo(), patientScanConditionDTO.getAdmissTimes());
continue;
}
List<PatientScan> patientScanList = patientScanService.getScanDataByInpatientNoAndTimes(patientScanConditionDTO);
log.warn("{},住院号:{},住院次数:{} 采集视图数据:{} 条!,数据为:{}", "电子病历扫描视图同步,根据扫描时间同步Job", patientScanConditionDTO.getInpatientNo(), patientScanConditionDTO.getAdmissTimes(), patientScanList.size(), patientScanList);
saveCollectTaskAndReport(basicList.get(0), patientScanList);
log.warn("{},住院号:{},住院次数:{} 采集视图数据:{} 条,执行成功!", "电子病历扫描视图同步,根据扫描时间同步Job", patientScanConditionDTO.getInpatientNo(), patientScanConditionDTO.getAdmissTimes(), patientScanList);
}
lastExecuteDate = lastExecuteDate.plusDays(1);
} while (!lastExecuteDate.isAfter(jobStartDate));
config.setLastExecuteDate(jobStartDate.toString());
config.refresh();
}
private void saveCollectTaskAndReport(TBasic tBasic, List<PatientScan> patientScanList) {
for (PatientScan patientScan : patientScanList) {
// 转换后的对象缺失的补充
ReportFileInfoDTO reportFileInfoDTO = fileReportConverter.convertReportFileInfoDTO(tBasic, patientScan);
reportFileInfoDTO.setSysFlag(patmGSys);
Long taskId = collectTaskDao.saveTask(reportFileInfoDTO);
reportFileInfoDTO.setTaskId(taskId);
fileReportService.saveDownloadTaskAndReport(reportFileInfoDTO);
}
}
private List<TBasic> getBasicInfo(PatientScanConditionDTO patientScanConditionDTO) {
TBasicQrDto basicQrDto = new TBasicQrDto();
basicQrDto.setInpatientNo(patientScanConditionDTO.getInpatientNo());
basicQrDto.setAdmissTimes(Integer.parseInt(patientScanConditionDTO.getAdmissTimes()));
basicQrDto.setIgnorePh(1);
return patientBasicMapper.getBasicInfo(basicQrDto);
}
public static void main(String[] args) {
QueryConfig config = QueryConfig.getQueryConfig();
if (config == null) {
config = new QueryConfig();
}
config.setLastExecuteDate(LocalDate.now().toString());
config.refresh();
}
public static class QueryConfig {
private String lastExecuteDate;
public String getLastExecuteDate() {
return lastExecuteDate;
}
public void setLastExecuteDate(String lastExecuteDate) {
this.lastExecuteDate = lastExecuteDate;
}
public static QueryConfig getQueryConfig() {
TableJsonRead tableJsonRead = new TableJsonRead();
return tableJsonRead.Read("docus", "PatScanFileSyncByScanDateJobQuery.json", QueryConfig.class);
}
public void refresh() {
TableJsonRead tableJsonRead = new TableJsonRead();
tableJsonRead.Save("docus", "PatScanFileSyncByScanDateJobQuery.json", Func.toJson(this));
}
}
}

@ -10,14 +10,34 @@ import java.util.List;
*/
public interface PatientScanService {
/**
* -
* -,
* @param patientScanConditionDTOList
* @return
*/
void collectByInpatientNoAndTimes(List<PatientScanConditionDTO> patientScanConditionDTOList);
List<PatientScan> getScanDataByInpatientNoAndTimes(List<PatientScanConditionDTO> patientScanConditionDTOList);
/**
* -
* -
* @param patientScanConditionDto
* @return
*/
List<PatientScan> collectByInpatientNoAndTimes(PatientScanConditionDTO patientScanConditionDto);
List<PatientScan> getScanDataByInpatientNoAndTimes(PatientScanConditionDTO patientScanConditionDto);
/**
*
* @param startTime
* @param endTime
* @return
*/
List<PatientScanConditionDTO> getInpatientNoAndTimesByScanDate(String startTime,String endTime);
/**
*
* @param startTime
* @param endTime
* @return
*/
List<PatientScanConditionDTO> getInpatientNoAndTimesByDisDate(String startTime,String endTime);
}

@ -5,9 +5,6 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
*
* ,,,
@ -42,39 +39,33 @@ public class ReportFileInfoDTO {
*
*/
@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;

@ -4,11 +4,16 @@ 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.infrastructure.web.api.CommonResult;
import com.docus.infrastructure.web.api.ResultCode;
import com.docus.server.collect.converter.FileReportConverter;
import com.docus.server.collect.dto.TBasicQrDto;
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.client.dto.ReportDownDto;
import com.docus.server.collect.infrastructure.dao.DownloadTaskDao;
import com.docus.server.collect.infrastructure.mapper.PatientBasicMapper;
import com.docus.server.collect.service.FileReportService;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import lombok.extern.slf4j.Slf4j;
@ -32,6 +37,8 @@ public class FileReportServiceImpl implements FileReportService {
@Autowired
private DownloadTaskDao downloadTaskDao;
@Autowired
private PatientBasicMapper patientBasicMapper;
@Autowired
private FileReportConverter fileReportConverter;
@Autowired
@ -42,9 +49,10 @@ public class FileReportServiceImpl implements FileReportService {
@Override
public void saveDownloadTaskAndReport(ReportFileInfoDTO fileInfoDTO) {
TBasic basic = new TBasic(fileInfoDTO);
TBasicQrDto basicQrDto = convertTbasicQrDto(fileInfoDTO);
// 查询基础数据,更新新的病案信息
List<TBasic> tBasics = downloadTaskDao.getBasicInfo(basic);
List<TBasic> tBasics = patientBasicMapper.getBasicInfo(basicQrDto);
// 如果找到患者基础数据并且刚好为1条
if (CollUtil.isNotEmpty(tBasics) && tBasics.size() == 1) {
TBasic tBasic = tBasics.get(0);
@ -62,19 +70,34 @@ public class FileReportServiceImpl implements FileReportService {
report(downloadTask);
}
private TBasicQrDto convertTbasicQrDto(ReportFileInfoDTO fileInfoDTO) {
String patientId = fileInfoDTO.getPatientId();
String jzh = fileInfoDTO.getJzh();
String inpatientNo = fileInfoDTO.getInpatientNo();
Integer admisstimes = fileInfoDTO.getAdmisstimes();
TBasicQrDto dto = new TBasicQrDto();
dto.setPatientId(patientId);
dto.setJzh(jzh);
dto.setInpatientNo(inpatientNo);
dto.setAdmissTimes(admisstimes);
return dto;
}
@Override
public Long getDownloadTaskId(DownloadTask downloadTask) {
String patientId = downloadTask.getPatientId();
if(StrUtil.isNotBlank(patientId)){
if (StrUtil.isNotBlank(patientId)) {
String serialNum = downloadTask.getFileSerialNum();
String source = downloadTask.getSource();
// 从文件表获取
Long downloadTaskId = downloadTaskDao.getDownloadTaskIdFromSanAssort(patientId,source,serialNum);
Long downloadTaskId = downloadTaskDao.getDownloadTaskIdFromSanAssort(patientId, source, serialNum);
if (Func.isNotEmpty(downloadTaskId)) {
return downloadTaskId;
}
// 从下载记录表获取
downloadTaskId = downloadTaskDao.getDownloadTaskIdFromDownFile(patientId,source,serialNum);
downloadTaskId = downloadTaskDao.getDownloadTaskIdFromDownFile(patientId, source, serialNum);
if (Func.isNotEmpty(downloadTaskId)) {
return downloadTaskId;
}
@ -91,7 +114,17 @@ public class FileReportServiceImpl implements FileReportService {
private void report(DownloadTask downloadTask) {
threadPoolExecutor.execute(() -> {
if (downloadTask.getBasicDataType().equals(0)) {
downloadPlatformService.report(fileReportConverter.convertDownloadPlatformParam(downloadTask));
ReportDownDto reportDownDto = fileReportConverter.convertDownloadPlatformParam(downloadTask);
try {
CommonResult commonResult = downloadPlatformService.report(reportDownDto);
if (commonResult.getCode().equals(ResultCode.SUCCESS.getCode())) {
log.info("{},文件上报成功!返回信息:{}", Func.toJson(reportDownDto.getPatient()), Func.toJson(commonResult));
} else {
log.error("文件上报失败!返回信息:{},上报信息:{}", Func.toJson(commonResult), Func.toJson(reportDownDto));
}
} catch (Exception ex) {
log.error("文件上报下载服务出错啦!数据为:" + Func.toJson(reportDownDto), ex);
}
}
});
}

@ -2,7 +2,6 @@ package com.docus.server.collect.service.impl;
import com.docus.server.collect.dto.PatientScanConditionDTO;
import com.docus.server.collect.entity.PatientScan;
import com.docus.server.collect.infrastructure.mapper.DownloadTaskMapper;
import com.docus.server.collect.infrastructure.mapper.PatientScanMapper;
import com.docus.server.collect.service.PatientScanService;
import groovy.util.logging.Slf4j;
@ -22,18 +21,32 @@ import java.util.Map;
public class PatientScanServiceImpl implements PatientScanService {
@Resource
private PatientScanMapper patientScanMapper;
@Override
public void collectByInpatientNoAndTimes(List<PatientScanConditionDTO> patientScanConditionDTOList) {
public List<PatientScan> getScanDataByInpatientNoAndTimes(List<PatientScanConditionDTO> patientScanConditionDTOList) {
List<PatientScanConditionDTO> distinctPatientScanConditionDTOList = distinctForInpatientNoAndTimes(patientScanConditionDTOList);
List<PatientScan> list = new LinkedList<>();
for (PatientScanConditionDTO patientScanConditionDTO : distinctPatientScanConditionDTOList) {
collectByInpatientNoAndTimes(patientScanConditionDTO);
List<PatientScan> patientScanList = getScanDataByInpatientNoAndTimes(patientScanConditionDTO);
list.addAll(patientScanList);
}
return list;
}
@Override
public List<PatientScan> getScanDataByInpatientNoAndTimes(PatientScanConditionDTO patientScanConditionDto) {
return patientScanMapper.getScanData(patientScanConditionDto);
}
@Override
public List<PatientScanConditionDTO> getInpatientNoAndTimesByScanDate(String startTime, String endTime) {
return patientScanMapper.getScanPatientConditionByScanDate(startTime,endTime);
}
@Override
public List<PatientScan> collectByInpatientNoAndTimes(PatientScanConditionDTO patientScanConditionDto) {
return patientScanMapper.getScanData(patientScanConditionDto);
public List<PatientScanConditionDTO> getInpatientNoAndTimesByDisDate(String startTime, String endTime) {
return patientScanMapper.getScanPatientConditionByScanDate(startTime,endTime);
}
/**

@ -78,6 +78,9 @@ docus:
url:
# 下载平台服务地址
downloadPlatform: http://192.168.16.85:9291
sync:
# 电子病历视图扫描文件同步采集器id定义
patsmGSys: 25
mybatis-plus:
configuration:

@ -0,0 +1,29 @@
<?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="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>

@ -0,0 +1,53 @@
<?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.PatientBasicMapper">
<sql id="basicInfoColumns">
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,
emp_id as empId
</sql>
<select id="getBasicInfo" resultType="com.docus.server.collect.entity.TBasic">
select
<include refid="basicInfoColumns"></include>
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.empId != null and dto.empId != ''">
and `emp_id` = #{dto.empId}
</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>
<if test="dto.disDateStart != null and dto.disDateStart != ''">
and `dis_date` between #{dto.disDateStart} and #{dto.disDateEnd}
</if>
<if test="dto.ignorePh==1">
and ph is null
</if>
limit 2
</select>
</mapper>

@ -3,9 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.server.collect.infrastructure.mapper.PatientScanMapper">
<select id="getScanData" resultType="com.docus.server.collect.entity.PatientScan">
select
<sql id="patSmViewField">
主键 as id,
住院号 as inpatientNo,
次数 as admissTimes,
@ -17,13 +15,18 @@
分类id as zdAssortId,
扫描日期 as scanDate,
扫描盘号 as ph
</sql>
<select id="getScanData" resultType="com.docus.server.collect.entity.PatientScan">
select
<include refid="patSmViewField"></include>
from pat_sm
where
住院号=#{dto.inpatientNo}
and 次数=#{dto.admissTimes}
and 扫描盘号 like 'G%'
</select>
<select id="getScanPatientCondition" resultType="com.docus.server.collect.dto.PatientScanConditionDTO">
<select id="getScanPatientConditionByScanDate" resultType="com.docus.server.collect.dto.PatientScanConditionDTO">
select 住院号 as inpatientNo,
次数 as admissTimes
from pat_sm
@ -32,5 +35,12 @@
group by 住院号, 次数
</select>
<select id="getScanPatientConditionByDisDate" resultType="com.docus.server.collect.dto.PatientScanConditionDTO">
select 住院号 as inpatientNo,
次数 as admissTimes
from pat_sm
where 出院日期 between #{start} and #{end}
and 扫描盘号 like 'G%'
group by 住院号, 次数
</select>
</mapper>

@ -1,123 +0,0 @@
<?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">
<sql id="basicInfoColumns">
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,
emp_id as empId
</sql>
<select id="getBasicInfo" resultType="com.docus.server.collect.entity.TBasic">
select
<include refid="basicInfoColumns"></include>
FROM
`docus_medicalrecord`.`t_basic`
WHERE
is_cancel=0
<if test="basic.patientId != null and basic.patientId != ''">
and `patient_id` = #{basic.patientId}
</if>
<if test="basic.jzh != null and basic.jzh != ''">
and `jzh` = #{basic.jzh}
</if>
<if test="basic.empId != null and basic.empId != ''">
and `emp_id` = #{basic.empId}
</if>
<if test="basic.inpatientNo != null and basic.inpatientNo != ''">
and `inpatient_no` = #{basic.inpatientNo}
</if>
<if test="basic.admisstimes != null">
and `admiss_times` = #{basic.admissTimes}
</if>
limit 2
</select>
<select id="countBasicInfo" resultType="java.lang.Integer">
select
count(1)
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.empId != null and dto.empId != ''">
and `emp_id` = #{dto.empId}
</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>
<if test="dto.admisstimes != null">
and `dis_date` between #{dto.disDateStart} AND #{dto.disDateEnd}
</if>
</select>
<select id="pageBasicInfo" resultType="com.docus.server.collect.entity.TBasic">
select
<include refid="basicInfoColumns"></include>
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.empId != null and dto.empId != ''">
and `emp_id` = #{dto.empId}
</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>
<if test="dto.admisstimes != null">
and `dis_date` between #{dto.disDateStart} AND #{dto.disDateEnd}
</if>
<if test="dto.admisstimes != null">
and `dis_date` between #{dto.disDateStart} AND #{dto.disDateEnd}
</if>
LIMIT ${offset},${size}
</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