|
|
@ -54,6 +54,9 @@ public class inHospitalController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private Emr_PictureService emrPictureService;
|
|
|
|
private Emr_PictureService emrPictureService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private Zd_AssortService zd_assortService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private LogService logService;
|
|
|
|
private LogService logService;
|
|
|
|
|
|
|
|
|
|
|
@ -209,6 +212,56 @@ public class inHospitalController {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2021-03-15更新优化
|
|
|
|
|
|
|
|
private String GeneratePDFFileByAssortID(String masterId, String assortID, String realPath )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List pdfList = new ArrayList();
|
|
|
|
|
|
|
|
Archive_Detail archiveDetail = new Archive_Detail();
|
|
|
|
|
|
|
|
archiveDetail.setFlag("0");
|
|
|
|
|
|
|
|
archiveDetail.setMasterid(masterId.trim());
|
|
|
|
|
|
|
|
archiveDetail.setTitle(assortID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Archive_Detail> arList = archiveDetailService.selectByCol(archiveDetail);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Archive_Detail> errorPdfList = new ArrayList<>();
|
|
|
|
|
|
|
|
int size = 0;
|
|
|
|
|
|
|
|
if (arList == null || arList.size()==0) {
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int m = 0; m < arList.size(); m++) {
|
|
|
|
|
|
|
|
String str = arList.get(m).getPdfPath();
|
|
|
|
|
|
|
|
if (str != "" && str != null) {
|
|
|
|
|
|
|
|
if (str.indexOf("..\\static\\img\\pdfFiles\\") != -1) {
|
|
|
|
|
|
|
|
str = str.split("pdfFiles")[1];
|
|
|
|
|
|
|
|
str = realPath + "pdfFiles" + str;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!PrintToPdfUtil.checkPdfFile(str)) {
|
|
|
|
|
|
|
|
arList.get(m).setPdfPath(str);
|
|
|
|
|
|
|
|
errorPdfList.add(arList.get(m));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
pdfList.add(str);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String pdfFileName = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + pdfFileName + ".pdf";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pdfList.size() > 0) {
|
|
|
|
|
|
|
|
//对所有地址的pdf进行合成
|
|
|
|
|
|
|
|
//if (errorPdfList.size() != size) {
|
|
|
|
|
|
|
|
PrintToPdfUtil.mergePdfFiles(pdfList, pdfPath);
|
|
|
|
|
|
|
|
//} else {
|
|
|
|
|
|
|
|
// result = "";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (errorPdfList.size() > 0) {
|
|
|
|
|
|
|
|
ExportTxtPaper.exportTxtPaper(pdfErrorUrl, "不存在或损坏PDF文件列表" + pdfFileName + ".txt", errorPdfList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return pdfPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 根据病案号或类别或图片id获取图片列表,并生成PDF并返回pdf文件名
|
|
|
|
* 根据病案号或类别或图片id获取图片列表,并生成PDF并返回pdf文件名
|
|
|
@ -229,85 +282,123 @@ public class inHospitalController {
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
//realPath = realPath.split("target")[0]
|
|
|
|
//realPath = realPath.split("target")[0]
|
|
|
|
realPath = pictureUrl + "\\static\\img\\";
|
|
|
|
realPath = pictureUrl + "\\static\\img\\";
|
|
|
|
//pdf名称
|
|
|
|
//pdf名称
|
|
|
|
String pdfFileName = String.valueOf(System.currentTimeMillis());
|
|
|
|
String pdfFileName = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
|
|
|
|
|
|
|
//病案号文件夹
|
|
|
|
//病案号文件夹
|
|
|
|
if (masterId != "" && masterId != null) {
|
|
|
|
if (masterId == "" && masterId == null) {
|
|
|
|
//判断文件夹是否存在
|
|
|
|
result = "";
|
|
|
|
File fileDic = new File(realPath + masterId + "\\");
|
|
|
|
return result;
|
|
|
|
if (!fileDic.exists() && !fileDic.isDirectory()) {
|
|
|
|
}
|
|
|
|
fileDic.mkdirs();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断文件夹是否存在
|
|
|
|
|
|
|
|
File fileDic = new File(realPath + masterId + "\\");
|
|
|
|
|
|
|
|
if (!fileDic.exists() && !fileDic.isDirectory()) {
|
|
|
|
|
|
|
|
fileDic.mkdirs();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//病案号/类别/id文件夹(图片路径下的子文件夹名称)
|
|
|
|
List<Zd_Assort> zds = zd_assortService.selectByColm(new Zd_Assort()); //from db
|
|
|
|
//生成pdf(图片路径,pdf生成路径,图片路径文件夹列表)
|
|
|
|
|
|
|
|
List imgList = new ArrayList();
|
|
|
|
//from args
|
|
|
|
if (imgStr != "" && imgStr != null) {
|
|
|
|
//病案号/类别/id文件夹(图片路径下的子文件夹名称)
|
|
|
|
String[] imgArr = imgStr.split(",");
|
|
|
|
//生成pdf(图片路径,pdf生成路径,图片路径文件夹列表)
|
|
|
|
if (imgArr.length > 0) {
|
|
|
|
List imgList = new ArrayList();
|
|
|
|
for (int i = 0; i < imgArr.length; i++) {
|
|
|
|
if (imgStr != "" && imgStr != null) {
|
|
|
|
imgList.add(imgArr[i]);
|
|
|
|
String[] imgArr = imgStr.split(",");
|
|
|
|
}
|
|
|
|
if (imgArr.length > 0) {
|
|
|
|
|
|
|
|
for (int i = 0; i < imgArr.length; i++) {
|
|
|
|
|
|
|
|
imgList.add(imgArr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = zds.size()-1; i >=0 ; i--) {
|
|
|
|
|
|
|
|
String a = zds.get(i).getAssortId();
|
|
|
|
|
|
|
|
if(imgList.indexOf(a)==-1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
zds.remove(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<String> fileList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < zds.size(); i++) {
|
|
|
|
|
|
|
|
String asordID = zds.get(i).getAssortId();
|
|
|
|
|
|
|
|
String pdfA = GeneratePDFFileByAssortID(masterId, asordID, realPath);
|
|
|
|
|
|
|
|
if(pdfA=="" || pdfA.length()==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fileList.add(pdfA);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(fileList.size()==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + String.valueOf(System.currentTimeMillis()) + ".pdf";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PrintToPdfUtil.mergePdfFiles(fileList, pdfPath);
|
|
|
|
|
|
|
|
return pdfPath;
|
|
|
|
|
|
|
|
|
|
|
|
// if(imgList.size()==1){
|
|
|
|
// if(imgList.size()==1){
|
|
|
|
// result= masterId.trim() + "/"+ imgList.get(0) +"/"+ imgList.get(0)+".pdf";
|
|
|
|
// result= masterId.trim() + "/"+ imgList.get(0) +"/"+ imgList.get(0)+".pdf";
|
|
|
|
// }else{
|
|
|
|
// }else{
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + pdfFileName + ".pdf";
|
|
|
|
// String pdfPath = autoPdfUrl.trim() + "/" + pdfFileName + ".pdf";
|
|
|
|
String imgPath = realPath + "pdfFiles\\" + masterId.trim() + "\\";
|
|
|
|
// String imgPath = realPath + "pdfFiles\\" + masterId.trim() + "\\";
|
|
|
|
//获取废除的pdf文件名列表archive_detail
|
|
|
|
// //获取废除的pdf文件名列表archive_detail
|
|
|
|
List pdfList = new ArrayList();
|
|
|
|
// List pdfList = new ArrayList();
|
|
|
|
Archive_Detail archiveDetail = new Archive_Detail();
|
|
|
|
// Archive_Detail archiveDetail = new Archive_Detail();
|
|
|
|
archiveDetail.setFlag("0");
|
|
|
|
// archiveDetail.setFlag("0");
|
|
|
|
archiveDetail.setMasterid(masterId.trim());
|
|
|
|
// archiveDetail.setMasterid(masterId.trim());
|
|
|
|
archiveDetail.setTitle(imgStr);
|
|
|
|
// archiveDetail.setTitle(imgStr);
|
|
|
|
List<Archive_Detail> arList = archiveDetailService.selectByCol(archiveDetail);
|
|
|
|
//
|
|
|
|
//损坏PDF文件列表
|
|
|
|
// List<Archive_Detail> arList = archiveDetailService.selectByCol(archiveDetail);
|
|
|
|
List<Archive_Detail> errorPdfList = new ArrayList<Archive_Detail>();
|
|
|
|
// //损坏PDF文件列表
|
|
|
|
int size = 0;
|
|
|
|
// List<Archive_Detail> errorPdfList = new ArrayList<Archive_Detail>();
|
|
|
|
if (arList != null) {
|
|
|
|
// int size = 0;
|
|
|
|
for (int m = 0; m < arList.size(); m++) {
|
|
|
|
// if (arList == null || arList.size()==0) {
|
|
|
|
String str = arList.get(m).getPdfPath();
|
|
|
|
// }
|
|
|
|
if (str != "" && str != null) {
|
|
|
|
// else {
|
|
|
|
if (str.indexOf("..\\static\\img\\pdfFiles\\") != -1) {
|
|
|
|
// for (int m = 0; m < arList.size(); m++) {
|
|
|
|
str = str.split("pdfFiles")[1];
|
|
|
|
// String str = arList.get(m).getPdfPath();
|
|
|
|
str = realPath + "pdfFiles" + str;
|
|
|
|
// if (str != "" && str != null) {
|
|
|
|
}
|
|
|
|
// if (str.indexOf("..\\static\\img\\pdfFiles\\") != -1) {
|
|
|
|
if (!PrintToPdfUtil.checkPdfFile(str)) {
|
|
|
|
// str = str.split("pdfFiles")[1];
|
|
|
|
arList.get(m).setPdfPath(str);
|
|
|
|
// str = realPath + "pdfFiles" + str;
|
|
|
|
errorPdfList.add(arList.get(m));
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
// if (!PrintToPdfUtil.checkPdfFile(str)) {
|
|
|
|
pdfList.add(str);
|
|
|
|
// arList.get(m).setPdfPath(str);
|
|
|
|
}
|
|
|
|
// errorPdfList.add(arList.get(m));
|
|
|
|
}
|
|
|
|
// } else {
|
|
|
|
// str= str.substring(str.lastIndexOf("\\") + 1);
|
|
|
|
// pdfList.add(str);
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// // str= str.substring(str.lastIndexOf("\\") + 1);
|
|
|
|
if (pdfList.size() > 0) {
|
|
|
|
//
|
|
|
|
//对所有地址的pdf进行合成
|
|
|
|
|
|
|
|
//if (errorPdfList.size() != size) {
|
|
|
|
|
|
|
|
PrintToPdfUtil.mergePdfFiles(pdfList, pdfPath);
|
|
|
|
|
|
|
|
result = pdfPath;
|
|
|
|
|
|
|
|
//} else {
|
|
|
|
|
|
|
|
// result = "";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (errorPdfList.size() > 0) {
|
|
|
|
|
|
|
|
ExportTxtPaper.exportTxtPaper(pdfErrorUrl, "不存在或损坏PDF文件列表" + pdfFileName + ".txt", errorPdfList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//PrintToPdfUtil.pdtToPdf(imgPath,pdfPath, imgList,pdfList);
|
|
|
|
|
|
|
|
//PDFUtils.getPdf(pdfPath, pdfList);
|
|
|
|
|
|
|
|
//result = "typesPdf/" + pdfFileName + ".pdf";
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
// }
|
|
|
|
result = "";
|
|
|
|
//
|
|
|
|
}
|
|
|
|
// if (pdfList.size() > 0) {
|
|
|
|
return result;
|
|
|
|
// //对所有地址的pdf进行合成
|
|
|
|
|
|
|
|
// //if (errorPdfList.size() != size) {
|
|
|
|
|
|
|
|
// PrintToPdfUtil.mergePdfFiles(pdfList, pdfPath);
|
|
|
|
|
|
|
|
// result = pdfPath;
|
|
|
|
|
|
|
|
// //} else {
|
|
|
|
|
|
|
|
// // result = "";
|
|
|
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// if (errorPdfList.size() > 0) {
|
|
|
|
|
|
|
|
// ExportTxtPaper.exportTxtPaper(pdfErrorUrl, "不存在或损坏PDF文件列表" + pdfFileName + ".txt", errorPdfList);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//PrintToPdfUtil.pdtToPdf(imgPath,pdfPath, imgList,pdfList);
|
|
|
|
|
|
|
|
//PDFUtils.getPdf(pdfPath, pdfList);
|
|
|
|
|
|
|
|
//result = "typesPdf/" + pdfFileName + ".pdf";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|