|
|
@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
@ -382,83 +383,96 @@ public class QueueService {
|
|
|
|
|
|
|
|
|
|
|
|
public void doSomethingByHIS() {
|
|
|
|
public void doSomethingByHIS() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
//循环开始处理 所有未处理的
|
|
|
|
while (true) {
|
|
|
|
List<InterfaceHisCacheDto> interfaceHisCaches = interfaceHisCacheService.findInterfaceHisCacheByState();
|
|
|
|
//循环开始处理 所有未处理的
|
|
|
|
for (InterfaceHisCacheDto interfaceHisCacheDto: interfaceHisCaches) {
|
|
|
|
List<InterfaceHisCacheDto> interfaceHisCaches = interfaceHisCacheService.findInterfaceHisCacheByState();
|
|
|
|
InterfaceHisCache interfaceHisCache = new InterfaceHisCache();
|
|
|
|
if(CollectionUtils.isEmpty(interfaceHisCaches)){
|
|
|
|
BeanUtils.copyProperties(interfaceHisCacheDto,interfaceHisCache);
|
|
|
|
break;
|
|
|
|
String type = null,remark = null,title = null,pdfPath = null,state = "2";
|
|
|
|
}
|
|
|
|
ArchiveDetail archiveDetail = null;
|
|
|
|
doSomethingByHISMethod(interfaceHisCaches);
|
|
|
|
try{
|
|
|
|
}
|
|
|
|
ArchiveMaster archiveMaster = archiveMasterService.findByInpNoAndVisitIdAndIsValid(interfaceHisCache.getInpNo(), interfaceHisCache.getVisitId());
|
|
|
|
}catch (Exception e){
|
|
|
|
if(archiveMaster != null){
|
|
|
|
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e,e.getStackTrace()[0]);
|
|
|
|
if(interfaceHisCache.getType() != null){
|
|
|
|
}
|
|
|
|
//给type 属性赋值
|
|
|
|
|
|
|
|
if(Objects.equals(interfaceHisCache.getType(),"0")){
|
|
|
|
|
|
|
|
type = AliasName.SOS;
|
|
|
|
|
|
|
|
title = "临时医嘱";
|
|
|
|
|
|
|
|
}else if(Objects.equals(interfaceHisCache.getType(),"1")){
|
|
|
|
|
|
|
|
type = AliasName.PRN;
|
|
|
|
|
|
|
|
title = "长期医嘱";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询库中是否存在 如果存在就更新
|
|
|
|
}
|
|
|
|
archiveDetail = archiveDetailService.isExit(archiveMaster.getId(), type, "HIS系统", title);
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
if (archiveDetail == null) {
|
|
|
|
|
|
|
|
archiveDetail = new ArchiveDetail(archiveMaster.getId(), date, type, "HIS系统", title,
|
|
|
|
|
|
|
|
title ,1);
|
|
|
|
|
|
|
|
archiveDetailService.save(archiveDetail);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//更新时间
|
|
|
|
|
|
|
|
archiveDetail.setUpLoadDateTime(date);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//开始下载
|
|
|
|
private void doSomethingByHISMethod(List<InterfaceHisCacheDto> interfaceHisCaches){
|
|
|
|
File pdfFile = FileUtils.createFile("pdfs", interfaceHisCache.getInpNo(), interfaceHisCache.getVisitId(), archiveDetail.getId(), "");
|
|
|
|
for (InterfaceHisCacheDto interfaceHisCacheDto: interfaceHisCaches) {
|
|
|
|
if (pdfFile != null) {
|
|
|
|
InterfaceHisCache interfaceHisCache = new InterfaceHisCache();
|
|
|
|
if (interfaceHisCache.getPdfPath().endsWith(".pdf") || interfaceHisCache.getPdfPath().endsWith(".PDF")) {
|
|
|
|
BeanUtils.copyProperties(interfaceHisCacheDto,interfaceHisCache);
|
|
|
|
pdfPath = DownloadUtils.downLoadPdfFile(pdfFile, interfaceHisCache.getPdfPath(), type);
|
|
|
|
String type = null,remark = null,title = null,pdfPath = null,state = "2";
|
|
|
|
if (pdfPath != null) {
|
|
|
|
ArchiveDetail archiveDetail = null;
|
|
|
|
// 转成格式
|
|
|
|
try{
|
|
|
|
archiveDetail.setPdfPath(pdfPath);
|
|
|
|
ArchiveMaster archiveMaster = archiveMasterService.findByInpNoAndVisitIdAndIsValid(interfaceHisCache.getInpNo(), interfaceHisCache.getVisitId());
|
|
|
|
archiveDetailService.save(archiveDetail);
|
|
|
|
if(archiveMaster != null){
|
|
|
|
//删除FTP文件
|
|
|
|
if(interfaceHisCache.getType() != null){
|
|
|
|
if(FTPUtil.deleteFile(interfaceHisCache.getPdfPath())){
|
|
|
|
//给type 属性赋值
|
|
|
|
// 成功
|
|
|
|
if(Objects.equals(interfaceHisCache.getType(),"0")){
|
|
|
|
state = "1";
|
|
|
|
type = AliasName.SOS;
|
|
|
|
}
|
|
|
|
title = "临时医嘱";
|
|
|
|
}else {
|
|
|
|
}else if(Objects.equals(interfaceHisCache.getType(),"1")){
|
|
|
|
remark = "下载失败";
|
|
|
|
type = AliasName.PRN;
|
|
|
|
|
|
|
|
title = "长期医嘱";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询库中是否存在 如果存在就更新
|
|
|
|
|
|
|
|
archiveDetail = archiveDetailService.isExit(archiveMaster.getId(), type, "HIS系统", title);
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
if (archiveDetail == null) {
|
|
|
|
|
|
|
|
archiveDetail = new ArchiveDetail(archiveMaster.getId(), date, type, "HIS系统", title,
|
|
|
|
|
|
|
|
title ,1);
|
|
|
|
|
|
|
|
archiveDetailService.save(archiveDetail);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//更新时间
|
|
|
|
|
|
|
|
archiveDetail.setUpLoadDateTime(date);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//开始下载
|
|
|
|
|
|
|
|
File pdfFile = FileUtils.createFile("pdfs", interfaceHisCache.getInpNo(), interfaceHisCache.getVisitId(), archiveDetail.getId(), "");
|
|
|
|
|
|
|
|
if (pdfFile != null) {
|
|
|
|
|
|
|
|
if (interfaceHisCache.getPdfPath().endsWith(".pdf") || interfaceHisCache.getPdfPath().endsWith(".PDF")) {
|
|
|
|
|
|
|
|
pdfPath = DownloadUtils.downLoadPdfFile(pdfFile, interfaceHisCache.getPdfPath(), type);
|
|
|
|
|
|
|
|
if (pdfPath != null) {
|
|
|
|
|
|
|
|
// 转成格式
|
|
|
|
|
|
|
|
archiveDetail.setPdfPath(pdfPath);
|
|
|
|
|
|
|
|
archiveDetailService.save(archiveDetail);
|
|
|
|
|
|
|
|
//删除FTP文件
|
|
|
|
|
|
|
|
if(FTPUtil.deleteFile(interfaceHisCache.getPdfPath())){
|
|
|
|
|
|
|
|
// 成功
|
|
|
|
|
|
|
|
state = "1";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
remark = "下载失败";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
|
|
|
|
remark = "文件创建失败";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
remark = "类型为空";
|
|
|
|
remark = "文件创建失败";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
remark = "没有入院信息";
|
|
|
|
remark = "类型为空";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
}else{
|
|
|
|
remark = e.getMessage();
|
|
|
|
remark = "没有入院信息";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
remark = e.getMessage();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(remark != null){
|
|
|
|
if(remark != null){
|
|
|
|
// 报错删掉患者报告详情信息
|
|
|
|
// 报错删掉患者报告详情信息
|
|
|
|
if (archiveDetail != null) {
|
|
|
|
if (archiveDetail != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
archiveDetailService.delete(archiveDetail.getId());
|
|
|
|
archiveDetailService.delete(archiveDetail.getId());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//赋值
|
|
|
|
|
|
|
|
interfaceHisCache.setValue(state,remark,new Date());
|
|
|
|
|
|
|
|
interfaceHisCacheService.save(interfaceHisCache);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
//赋值
|
|
|
|
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e,e.getStackTrace()[0]);
|
|
|
|
interfaceHisCache.setValue(state,remark,new Date());
|
|
|
|
|
|
|
|
interfaceHisCacheService.save(interfaceHisCache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isInteger(String str) {
|
|
|
|
public boolean isInteger(String str) {
|
|
|
|