|
|
|
|
@ -9,6 +9,7 @@ import com.example.dto.ArchiveDetailDto;
|
|
|
|
|
import com.example.dto.ArchiveOtherExtDto;
|
|
|
|
|
import com.example.dto.UpdateOtherDao;
|
|
|
|
|
import com.example.service.MedicaRecordService;
|
|
|
|
|
import com.example.vo.CompensateVo;
|
|
|
|
|
import com.example.vo.MedicaRecordVo;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
@ -57,14 +58,103 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
|
|
|
|
|
@Override
|
|
|
|
|
public void gatherMedicaRecord() {
|
|
|
|
|
//根据时间段查询当前时间需要采集的患者信息
|
|
|
|
|
List<MedicaRecordVo> patientInfos = medicaRecordDao.getMedicaRecord();
|
|
|
|
|
if (CollectionUtils.isEmpty(patientInfos)) {
|
|
|
|
|
List<CompensateVo> compensateVos = medicaRecordDao.getMedicaRecord();
|
|
|
|
|
if (CollectionUtils.isEmpty(compensateVos)) {
|
|
|
|
|
log.info("当前时间段内无需要采集的数据");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
log.info("当前时间需要采集:" + patientInfos.size() + "份重耗材");
|
|
|
|
|
PollingGather(patientInfos);
|
|
|
|
|
log.info("当前时间需要采集:" + compensateVos.size() + "份重耗材");
|
|
|
|
|
PollingGather(compensateVos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void CompensateByTime(String sTime, String eTime) {
|
|
|
|
|
//根据时间段查询当前时间需要采集的患者信息
|
|
|
|
|
List<CompensateVo> compensateVos = medicaRecordDao.CompensateByTime(sTime, eTime);
|
|
|
|
|
if (CollectionUtils.isEmpty(compensateVos)) {
|
|
|
|
|
log.info("当前时间段内无需要采集的数据");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
log.info("当前时间需要采集:" + compensateVos.size() + "份");
|
|
|
|
|
//循环补偿
|
|
|
|
|
for (CompensateVo compensateVo : compensateVos){
|
|
|
|
|
//更新任务表
|
|
|
|
|
UpdateOtherDao updateOtherDao=new UpdateOtherDao();
|
|
|
|
|
try {
|
|
|
|
|
//住院号
|
|
|
|
|
String inpNo = compensateVo.getInpNo();
|
|
|
|
|
//住院次数
|
|
|
|
|
String visitId = compensateVo.getVisitId();
|
|
|
|
|
String topic = compensateVo.getTOPIC();
|
|
|
|
|
//唯一id作为任务id文件id使用
|
|
|
|
|
String id = compensateVo.getId();
|
|
|
|
|
//下载地址
|
|
|
|
|
String url = compensateVo.getUrl();
|
|
|
|
|
//文件表
|
|
|
|
|
ArchiveDetailDto archiveDetailDto = new ArchiveDetailDto();
|
|
|
|
|
//任务表
|
|
|
|
|
ArchiveOtherExtDto archiveOtherExtDto = new ArchiveOtherExtDto();
|
|
|
|
|
//使用yyyyMMddHHmmssSSS格式作为文件名
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
|
|
|
|
String newDate = format.format(date);
|
|
|
|
|
//生成保存地址路径
|
|
|
|
|
String newSavePath = GenerateSavePath(inpNo, visitId,newDate);
|
|
|
|
|
//根据住院号住院次数查询归档中患者
|
|
|
|
|
List<String> masterIds = archiveMasterDao.getMasterIdByInpNOAndVisitId(inpNo, visitId);
|
|
|
|
|
if (CollectionUtils.isEmpty(masterIds)) {
|
|
|
|
|
log.info("当前采集患者基础信息不存在归档数据库中采集失败住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//将任务同步到任务表中
|
|
|
|
|
archiveOtherExtDto.setId(newDate);
|
|
|
|
|
archiveOtherExtDto.setSycTime(compensateVo.getExportTime());
|
|
|
|
|
archiveOtherExtDto.setSycObj(compensateVo.getUrl());
|
|
|
|
|
archiveOtherExtDto.setOtherID(BigInteger.valueOf(0));
|
|
|
|
|
archiveOtherExtDto.setZyh(inpNo);
|
|
|
|
|
archiveOtherExtDto.setSysFlag(BigInteger.valueOf(15));
|
|
|
|
|
archiveOtherExtDto.setSysUpdateTime(new Date());
|
|
|
|
|
archiveOtherExtDto.setStime(new Date());
|
|
|
|
|
archiveOtherExtDto.setETime(new Date());
|
|
|
|
|
archiveOtherExtDto.setStatusFlag(BigInteger.valueOf(0));
|
|
|
|
|
archiveOtherExtDto.setPResult("未开始");
|
|
|
|
|
archiveOtherExtDto.setMID(masterIds.get(0));
|
|
|
|
|
archiveOtherExtDto.setC2(id);
|
|
|
|
|
archiveOtherDao.addArchiveOtherExt(archiveOtherExtDto);
|
|
|
|
|
//同步文件
|
|
|
|
|
//下载图像
|
|
|
|
|
if (!DownloadFile(url, newSavePath)){
|
|
|
|
|
log.info("当前文件下载失败住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
failOther(updateOtherDao, compensateVo);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//下载成功保存文件表信息
|
|
|
|
|
archiveDetailDto.setId(newDate);
|
|
|
|
|
archiveDetailDto.setPdfPath(newSavePath);
|
|
|
|
|
archiveDetailDto.setMasterId(masterIds.get(0));
|
|
|
|
|
archiveDetailDto.setUpLoadDateTime(new Date());
|
|
|
|
|
archiveDetailDto.setAssortId("119");
|
|
|
|
|
archiveDetailDto.setSource("血透采集服务");
|
|
|
|
|
archiveDetailDto.setFlag("0");
|
|
|
|
|
archiveDetailDto.setSys("1");
|
|
|
|
|
archiveDetailDto.setTitle(topic);
|
|
|
|
|
archiveDetailDto.setC1(id);
|
|
|
|
|
//插入到文件表中
|
|
|
|
|
if (!archiveDetailDao.addArchiveDetail(archiveDetailDto)){
|
|
|
|
|
log.info("插入文件表失败,采集失败住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
}
|
|
|
|
|
log.info("插入文件表成功,采集成功住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
succeedOther(updateOtherDao, compensateVo, newDate);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
//下载失败更新任务表中任务状态
|
|
|
|
|
failOther(updateOtherDao, compensateVo);
|
|
|
|
|
log.error("系统异常,下载失败住院号为:"+compensateVo.getInpNo()+",住院次数为:"+compensateVo.getVisitId()+"异常信息为:"+e.getMessage(),e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author: linjj
|
|
|
|
|
* @Description: 轮询采集
|
|
|
|
|
@ -72,18 +162,21 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
|
|
|
|
|
* @Params: [patientInfos]
|
|
|
|
|
* @Return void
|
|
|
|
|
*/
|
|
|
|
|
private void PollingGather(List<MedicaRecordVo> patientInfos) {
|
|
|
|
|
private void PollingGather(List<CompensateVo> compensateVos) {
|
|
|
|
|
//更新任务表
|
|
|
|
|
UpdateOtherDao updateOtherDao=new UpdateOtherDao();
|
|
|
|
|
//轮询采集
|
|
|
|
|
for (MedicaRecordVo patientInfo : patientInfos) {
|
|
|
|
|
for (CompensateVo compensateVo : compensateVos) {
|
|
|
|
|
try {
|
|
|
|
|
//记帐号
|
|
|
|
|
String medicaRecord = patientInfo.getMedicaRecord();
|
|
|
|
|
//住院号
|
|
|
|
|
String inpNo = compensateVo.getInpNo();
|
|
|
|
|
//住院次数
|
|
|
|
|
String visitId = patientInfo.getVisitId();
|
|
|
|
|
//http下载地址
|
|
|
|
|
String pdfPath = patientInfo.getPdfPath();
|
|
|
|
|
String visitId = compensateVo.getVisitId();
|
|
|
|
|
String topic = compensateVo.getTOPIC();
|
|
|
|
|
//唯一id作为任务id文件id使用
|
|
|
|
|
String id = compensateVo.getId();
|
|
|
|
|
//下载地址
|
|
|
|
|
String url = compensateVo.getUrl();
|
|
|
|
|
//文件表
|
|
|
|
|
ArchiveDetailDto archiveDetailDto = new ArchiveDetailDto();
|
|
|
|
|
//任务表
|
|
|
|
|
@ -93,43 +186,43 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
|
|
|
|
String newDate = format.format(date);
|
|
|
|
|
//生成保存地址路径
|
|
|
|
|
String newSavePath = GenerateSavePath(medicaRecord, visitId,newDate);
|
|
|
|
|
log.info("当前采集患者记帐号为:"+medicaRecord+",住院次数为:"+visitId);
|
|
|
|
|
String newSavePath = GenerateSavePath(inpNo, visitId,newDate);
|
|
|
|
|
log.info("当前采集患者住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
//根据记帐号住院次数查询患者是否存在归档数据库中
|
|
|
|
|
List<String> masterIds = archiveMasterDao.getMasterId(medicaRecord, visitId);
|
|
|
|
|
List<String> masterIds = archiveMasterDao.getMasterIdByInpNOAndVisitId(inpNo, visitId);
|
|
|
|
|
if (CollectionUtils.isEmpty(masterIds)) {
|
|
|
|
|
log.info("当前采集患者基础信息不存在归档数据库中采集失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
|
|
|
|
|
log.info("当前采集患者基础信息不存在归档数据库中采集失败住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//查询任务表中C2字段跟时间是否都一致,一致不需要重新采集
|
|
|
|
|
List<String> archiveOtherExtAndTime = archiveOtherDao.getArchiveOtherExtAndTime(patientInfo.getId(), patientInfo.getExportTime());
|
|
|
|
|
List<String> archiveOtherExtAndTime = archiveOtherDao.getArchiveOtherExtAndTime(id, compensateVo.getExportTime());
|
|
|
|
|
if (!CollectionUtils.isEmpty(archiveOtherExtAndTime)){
|
|
|
|
|
log.info("已经存在文件表跳过采集:"+medicaRecord+",住院次数为:"+visitId);
|
|
|
|
|
log.info("已经存在文件表跳过采集:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//查询任务表中c2字段是否已经存在,存在直接下载文件,不存在新增任务
|
|
|
|
|
List<String> archiveOtherExt = archiveOtherDao.getArchiveOtherExt(patientInfo.getId());
|
|
|
|
|
List<String> archiveOtherExt = archiveOtherDao.getArchiveOtherExt(id);
|
|
|
|
|
if (CollectionUtils.isEmpty(archiveOtherExt)) {
|
|
|
|
|
archiveOtherExtDto.setId(newDate);
|
|
|
|
|
archiveOtherExtDto.setSycTime(patientInfo.getExportTime());
|
|
|
|
|
archiveOtherExtDto.setSycObj(patientInfo.getPdfPath());
|
|
|
|
|
archiveOtherExtDto.setSycTime(compensateVo.getExportTime());
|
|
|
|
|
archiveOtherExtDto.setSycObj(compensateVo.getUrl());
|
|
|
|
|
archiveOtherExtDto.setOtherID(BigInteger.valueOf(0));
|
|
|
|
|
archiveOtherExtDto.setSysFlag(BigInteger.valueOf(21));
|
|
|
|
|
archiveOtherExtDto.setZyh(inpNo);
|
|
|
|
|
archiveOtherExtDto.setSysFlag(BigInteger.valueOf(15));
|
|
|
|
|
archiveOtherExtDto.setSysUpdateTime(new Date());
|
|
|
|
|
archiveOtherExtDto.setJzh(medicaRecord);
|
|
|
|
|
archiveOtherExtDto.setStime(new Date());
|
|
|
|
|
archiveOtherExtDto.setETime(new Date());
|
|
|
|
|
archiveOtherExtDto.setStatusFlag(BigInteger.valueOf(0));
|
|
|
|
|
archiveOtherExtDto.setPResult("未开始");
|
|
|
|
|
archiveOtherExtDto.setMID(masterIds.get(0));
|
|
|
|
|
archiveOtherExtDto.setC2(patientInfo.getId());
|
|
|
|
|
archiveOtherExtDto.setC2(id);
|
|
|
|
|
archiveOtherDao.addArchiveOtherExt(archiveOtherExtDto);
|
|
|
|
|
}
|
|
|
|
|
updateDetail(patientInfo);
|
|
|
|
|
updateDetail(compensateVo);
|
|
|
|
|
//下载图像
|
|
|
|
|
if (!DownloadFile(pdfPath, newSavePath)){
|
|
|
|
|
log.info("当前文件下载失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
|
|
|
|
|
failOther(updateOtherDao, patientInfo);
|
|
|
|
|
if (!DownloadFile(url, newSavePath)){
|
|
|
|
|
log.info("当前文件下载失败住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
failOther(updateOtherDao, compensateVo);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//下载成功保存文件表信息
|
|
|
|
|
@ -137,32 +230,32 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
|
|
|
|
|
archiveDetailDto.setPdfPath(newSavePath);
|
|
|
|
|
archiveDetailDto.setMasterId(masterIds.get(0));
|
|
|
|
|
archiveDetailDto.setUpLoadDateTime(new Date());
|
|
|
|
|
archiveDetailDto.setAssortId("61");
|
|
|
|
|
archiveDetailDto.setSource("重耗材采集服务");
|
|
|
|
|
archiveDetailDto.setAssortId("119");
|
|
|
|
|
archiveDetailDto.setSource("血透采集服务");
|
|
|
|
|
archiveDetailDto.setFlag("0");
|
|
|
|
|
archiveDetailDto.setSys("1");
|
|
|
|
|
archiveDetailDto.setTitle("高价值耗材清单");
|
|
|
|
|
archiveDetailDto.setC1(patientInfo.getId());
|
|
|
|
|
archiveDetailDto.setTitle(topic);
|
|
|
|
|
archiveDetailDto.setC1(id);
|
|
|
|
|
//插入到文件表中
|
|
|
|
|
if (!archiveDetailDao.addArchiveDetail(archiveDetailDto)){
|
|
|
|
|
log.info("插入文件表失败,采集失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
|
|
|
|
|
log.info("插入文件表失败,采集失败住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
}
|
|
|
|
|
log.info("插入文件表成功,采集成功记帐号为:"+medicaRecord+",住院次数为:"+visitId);
|
|
|
|
|
succeedOther(updateOtherDao, patientInfo, newDate);
|
|
|
|
|
log.info("插入文件表成功,采集成功住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
succeedOther(updateOtherDao, compensateVo, newDate);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
//下载失败更新任务表中任务状态
|
|
|
|
|
failOther(updateOtherDao, patientInfo);
|
|
|
|
|
log.error("系统异常,下载失败记帐号为:"+patientInfo.getMedicaRecord()+",住院次数为:"+patientInfo.getVisitId()+"异常信息为:"+e.getMessage(),e);
|
|
|
|
|
failOther(updateOtherDao, compensateVo);
|
|
|
|
|
log.error("系统异常,下载失败住院号为:"+compensateVo.getInpNo()+",住院次数为:"+compensateVo.getVisitId()+"异常信息为:"+e.getMessage(),e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateDetail(MedicaRecordVo patientInfo) {
|
|
|
|
|
private void updateDetail( CompensateVo compensateVo) {
|
|
|
|
|
//判断文件表是否有记录,有记录先删除后更新
|
|
|
|
|
List<String> pdfPathS = archiveDetailDao.getPdfPath(patientInfo.getId());
|
|
|
|
|
List<String> pdfPathS = archiveDetailDao.getPdfPath(compensateVo.getId());
|
|
|
|
|
if (!CollectionUtils.isEmpty(pdfPathS)) {
|
|
|
|
|
//不为空删除对应记录
|
|
|
|
|
if (archiveDetailDao.delPdfPath(patientInfo.getId())){
|
|
|
|
|
if (archiveDetailDao.delPdfPath(compensateVo.getId())){
|
|
|
|
|
//删除对应文件
|
|
|
|
|
for (String path:pdfPathS){
|
|
|
|
|
File file1 = new File(path);
|
|
|
|
|
@ -183,7 +276,7 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
|
|
|
|
|
* @Params: [updateOtherDao, patientInfo, newDate]
|
|
|
|
|
* @Return void
|
|
|
|
|
*/
|
|
|
|
|
private void succeedOther(UpdateOtherDao updateOtherDao, MedicaRecordVo patientInfo, String newDate) {
|
|
|
|
|
private void succeedOther(UpdateOtherDao updateOtherDao, CompensateVo compensateVo, String newDate) {
|
|
|
|
|
//下载成功更新任务表中任务状态
|
|
|
|
|
updateOtherDao.setSysUpdateTime(new Date());
|
|
|
|
|
updateOtherDao.setStime(new Date());
|
|
|
|
|
@ -192,7 +285,7 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
|
|
|
|
|
updateOtherDao.setPResult("Done");
|
|
|
|
|
updateOtherDao.setDID(newDate);
|
|
|
|
|
updateOtherDao.setC1(newDate +".pdf");
|
|
|
|
|
updateOtherDao.setC2(patientInfo.getId());
|
|
|
|
|
updateOtherDao.setC2(compensateVo.getId());
|
|
|
|
|
archiveOtherDao.updateArchiveOtherExt(updateOtherDao);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -203,14 +296,14 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
|
|
|
|
|
* @Params: [updateOtherDao, patientInfo]
|
|
|
|
|
* @Return void
|
|
|
|
|
*/
|
|
|
|
|
private void failOther(UpdateOtherDao updateOtherDao, MedicaRecordVo patientInfo) {
|
|
|
|
|
private void failOther(UpdateOtherDao updateOtherDao, CompensateVo compensateVo) {
|
|
|
|
|
//下载失败更新任务表中任务状态
|
|
|
|
|
updateOtherDao.setSysUpdateTime(new Date());
|
|
|
|
|
updateOtherDao.setStime(new Date());
|
|
|
|
|
updateOtherDao.setETime(new Date());
|
|
|
|
|
updateOtherDao.setStatusFlag(BigInteger.valueOf(2));
|
|
|
|
|
updateOtherDao.setPResult("文件下载失败");
|
|
|
|
|
updateOtherDao.setC2(patientInfo.getId());
|
|
|
|
|
updateOtherDao.setC2(compensateVo.getId());
|
|
|
|
|
archiveOtherDao.updateArchiveOtherExt(updateOtherDao);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -232,7 +325,7 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
|
|
|
|
|
boolean isCreated = directory.mkdirs(); // 创建所有必需的父目录
|
|
|
|
|
if (!isCreated) {
|
|
|
|
|
// 处理创建目录失败的情况
|
|
|
|
|
log.info("目录创建失败,下载失败记帐号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
log.info("目录创建失败,下载失败住院号为:"+inpNo+",住院次数为:"+visitId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return newSavePath;
|
|
|
|
|
|