|
|
|
@ -13,6 +13,7 @@ import com.emr.util.*;
|
|
|
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
|
|
|
import net.sf.json.JSONArray;
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
|
|
import org.apache.shiro.session.Session;
|
|
|
|
@ -22,6 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
@ -338,65 +340,88 @@ public class inHospitalController {
|
|
|
|
|
*/
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/getPdfToPdf")
|
|
|
|
|
public String getPdfToPdf(HttpServletResponse response, HttpServletRequest request, String imgStr, String masterId, String flag) throws Exception {
|
|
|
|
|
//组织分类id集合
|
|
|
|
|
if(StringUtils.isNotBlank(imgStr)){
|
|
|
|
|
String[] assortIds = StringUtils.split(imgStr, ",");
|
|
|
|
|
List<String> srcFileList = archiveDetailService.getPdfUrlByMasterOrId(assortIds,masterId,flag,null);
|
|
|
|
|
if(!CollectionUtils.isEmpty(srcFileList)){
|
|
|
|
|
//设置进缓存
|
|
|
|
|
String key = SessionContant.setPdfUrl(masterId, imgStr, srcFileList, request);
|
|
|
|
|
return key;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/getPdfToPdf")
|
|
|
|
|
public String getPdfToPdf(HttpServletResponse response, HttpServletRequest request, String imgStr, String masterId, String flag) throws Exception {
|
|
|
|
|
request.setCharacterEncoding("utf-8");
|
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
|
String result = "";
|
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
|
//realPath = realPath.split("target")[0]
|
|
|
|
|
realPath = pictureUrl + "\\static\\img\\";
|
|
|
|
|
//pdf名称
|
|
|
|
|
String pdfFileName = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
//病案号文件夹
|
|
|
|
|
if (masterId == "" && masterId == null) {
|
|
|
|
|
result = "";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//判断文件夹是否存在
|
|
|
|
|
File fileDic = new File(realPath + masterId + "\\");
|
|
|
|
|
if (!fileDic.exists() && !fileDic.isDirectory()) {
|
|
|
|
|
fileDic.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
List<Zd_Assort> zds = zd_assortService.selectByColm(new Zd_Assort()); //from db
|
|
|
|
|
//from args
|
|
|
|
|
//病案号/类别/id文件夹(图片路径下的子文件夹名称)
|
|
|
|
|
//生成pdf(图片路径,pdf生成路径,图片路径文件夹列表)
|
|
|
|
|
List imgList = new ArrayList();
|
|
|
|
|
if (imgStr != "" && imgStr != null) {
|
|
|
|
|
String[] imgArr = imgStr.split(",");
|
|
|
|
|
if (imgArr.length > 0) {
|
|
|
|
|
for (int i = 0; i < imgArr.length; i++) {
|
|
|
|
|
imgList.add(imgArr[i]);
|
|
|
|
|
try {
|
|
|
|
|
String result = "";
|
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
|
//realPath = realPath.split("target")[0]
|
|
|
|
|
realPath = pictureUrl + "\\static\\img\\";
|
|
|
|
|
//pdf名称
|
|
|
|
|
String pdfFileName = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
//病案号文件夹
|
|
|
|
|
if (masterId == "" && masterId == null) {
|
|
|
|
|
result = "";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//判断文件夹是否存在
|
|
|
|
|
File fileDic = new File(realPath + masterId + "\\");
|
|
|
|
|
if (!fileDic.exists() && !fileDic.isDirectory()) {
|
|
|
|
|
fileDic.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
List<Zd_Assort> zds = zd_assortService.selectByColm(new Zd_Assort()); //from db
|
|
|
|
|
//from args
|
|
|
|
|
//病案号/类别/id文件夹(图片路径下的子文件夹名称)
|
|
|
|
|
//生成pdf(图片路径,pdf生成路径,图片路径文件夹列表)
|
|
|
|
|
List imgList = new ArrayList();
|
|
|
|
|
if (imgStr != "" && imgStr != null) {
|
|
|
|
|
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);
|
|
|
|
|
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, flag);
|
|
|
|
|
if (pdfA == "" || pdfA.length() == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
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, flag);
|
|
|
|
|
if (pdfA == "" || pdfA.length() == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
fileList.add(pdfA);
|
|
|
|
|
}
|
|
|
|
|
if (fileList.size() == 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
fileList.add(pdfA);
|
|
|
|
|
}
|
|
|
|
|
if (fileList.size() == 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + String.valueOf(System.currentTimeMillis()) + ".pdf";
|
|
|
|
|
PDFHelper.Append(fileList, pdfPath);
|
|
|
|
|
//PrintToPdfUtil.mergePdfFiles(fileList, pdfPath);
|
|
|
|
|
return pdfPath;
|
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + String.valueOf(System.currentTimeMillis()) + ".pdf";
|
|
|
|
|
|
|
|
|
|
//PDFHelper.Append(fileList, pdfPath);
|
|
|
|
|
//PrintToPdfUtil.mergePdfFiles(fileList, pdfPath);
|
|
|
|
|
return "1233";
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据病案号或类别或图片id获取图片列表,并生成PDF并返回pdf文件名
|
|
|
|
@ -1283,6 +1308,35 @@ public class inHospitalController {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description: pdfStreamHandeler方法是加载pdf
|
|
|
|
|
* @param: [request, response]
|
|
|
|
|
* @return: void
|
|
|
|
|
* @author 曾文和
|
|
|
|
|
* @createTime 2023/6/21 15:46
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/pdfStreamHandeler")
|
|
|
|
|
public void pdfStreamHandeler(HttpServletRequest request, HttpServletResponse response)throws Exception {
|
|
|
|
|
String filePath = request.getParameter("url");
|
|
|
|
|
String[] list=filePath.split("titleName=");
|
|
|
|
|
String key =list[0].substring(0,list[0].length()-1);
|
|
|
|
|
//titleName为前端页面title显示的患者姓名,这里要去掉
|
|
|
|
|
List<String> filePaths = SessionContant.getPdfUrl(key, request);
|
|
|
|
|
if (null != filePaths && !filePaths.isEmpty()) {
|
|
|
|
|
try {
|
|
|
|
|
//合成PDF
|
|
|
|
|
Jpg2PdfUtil.mulFile2One(response, filePaths, null);
|
|
|
|
|
//清除session里的filePaths值
|
|
|
|
|
request.removeAttribute(key);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
ExceptionPrintUtil.printException(e);
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
@RequestMapping(value = "/pdfStreamHandeler")
|
|
|
|
|
public void pdfStreamHandeler(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
String filePath = request.getParameter("url");
|
|
|
|
@ -1306,6 +1360,7 @@ public class inHospitalController {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("getImg2")
|
|
|
|
|