|
|
|
@ -10,19 +10,16 @@ import com.emr.annotation.OptionalLog;
|
|
|
|
|
import com.emr.entity.*;
|
|
|
|
|
import com.emr.service.*;
|
|
|
|
|
import com.emr.util.*;
|
|
|
|
|
import com.github.pagehelper.util.StringUtil;
|
|
|
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
|
|
|
import com.lowagie.text.DocumentException;
|
|
|
|
|
import net.sf.json.JSONArray;
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
|
|
import org.apache.shiro.session.Session;
|
|
|
|
|
import org.apache.shiro.subject.Subject;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.context.annotation.PropertySource;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
@ -60,6 +57,9 @@ public class inHospitalController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private Zd_AssortService zd_assortService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private Archive_Detail_PictureService archiveDetailPictureService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private LogService logService;
|
|
|
|
|
|
|
|
|
@ -75,6 +75,10 @@ public class inHospitalController {
|
|
|
|
|
@Value("${pdfErrorUrl}")
|
|
|
|
|
private String pdfErrorUrl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//@Value("${pdfDelPicUrl}")
|
|
|
|
|
//private String pdfDelPicUrl;
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/inHospitals")
|
|
|
|
|
public String inHospitals(Model model) {
|
|
|
|
|
return "inHospitalDir/inHositalList";
|
|
|
|
@ -153,21 +157,32 @@ public class inHospitalController {
|
|
|
|
|
if (file2.exists() && file2.isFile()) {
|
|
|
|
|
file2.delete();
|
|
|
|
|
}
|
|
|
|
|
if(detail.getRecoverPdfPath()!=null &&detail.getRecoverPdfPath()!="") {
|
|
|
|
|
File file3 = new File(detail.getRecoverPdfPath());
|
|
|
|
|
if (file3.exists() && file3.isFile()) {
|
|
|
|
|
file3.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int bol=archiveDetailService.delById(archiveDetail.getId());
|
|
|
|
|
//http://127.0.0.1:8080/emr_medical_record/static/img/login.jpg
|
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
|
// 设置存放图片文件的路径
|
|
|
|
|
String pdfDelPicUrl = "static\\img\\delPicImg\\";
|
|
|
|
|
int bol = archiveDetailService.delById(archiveDetail.getId());
|
|
|
|
|
//备份都删除
|
|
|
|
|
if(bol==1){
|
|
|
|
|
Archive_Detail archiveDetailV=new Archive_Detail();
|
|
|
|
|
archiveDetailV.setMasterid(detail.getMasterid());
|
|
|
|
|
archiveDetailV.setFlag("1");
|
|
|
|
|
archiveDetailV.setAssortid(detail.getAssortid());
|
|
|
|
|
archiveDetailV.setSource(detail.getSource());
|
|
|
|
|
String oldPath=detail.getPdfPath();
|
|
|
|
|
String newPath=oldPath.substring(0,oldPath.lastIndexOf("\\")+1);
|
|
|
|
|
String newName=oldPath.substring(oldPath.lastIndexOf("\\")+1,oldPath.length());
|
|
|
|
|
archiveDetailV.setPdfPath(newPath+"%备份_"+newName);
|
|
|
|
|
archiveDetailService.delByClo(archiveDetailV);
|
|
|
|
|
if (bol == 1) {
|
|
|
|
|
Archive_Detail_Picture archiveDetailPicture = new Archive_Detail_Picture();
|
|
|
|
|
archiveDetailPicture.setParentId(archiveDetail.getId());
|
|
|
|
|
if (archiveDetail.getPdfPath() != null && archiveDetail.getPdfPath() != "") {
|
|
|
|
|
archiveDetailPicture.setMaxPicture("static\\img\\delPicImg\\" + archiveDetail.getPdfPath() + "\\" + archiveDetail.getPdfPath() + "_");
|
|
|
|
|
}
|
|
|
|
|
archiveDetailPictureService.deleteByCol(archiveDetailPicture);
|
|
|
|
|
//删除图片
|
|
|
|
|
//将之前文件删除
|
|
|
|
|
File file = new File(realPath + pdfDelPicUrl + archiveDetail.getPdfPath() + "\\");
|
|
|
|
|
PrintToPdfUtil.delete(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -232,7 +247,7 @@ public class inHospitalController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//2021-03-15更新优化
|
|
|
|
|
private String GeneratePDFFileByAssortID(String masterId, String assortID, String realPath,String flag) throws Exception {
|
|
|
|
|
private String GeneratePDFFileByAssortID(String masterId, String assortID, String realPath, String flag) throws Exception {
|
|
|
|
|
List<MergePDFItem> pdfList = new ArrayList();
|
|
|
|
|
Archive_Detail archiveDetail = new Archive_Detail();
|
|
|
|
|
archiveDetail.setFlag(flag);
|
|
|
|
@ -243,30 +258,30 @@ public class inHospitalController {
|
|
|
|
|
|
|
|
|
|
List<Archive_Detail> errorPdfList = new ArrayList<>();
|
|
|
|
|
int size = 0;
|
|
|
|
|
if (arList == null || arList.size()==0) {
|
|
|
|
|
if (arList == null || arList.size() == 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
for (int m = 0; m < arList.size(); m++) {
|
|
|
|
|
MergePDFItem mergePDFItem = new MergePDFItem();
|
|
|
|
|
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 {
|
|
|
|
|
mergePDFItem.setPdfPath(str);
|
|
|
|
|
mergePDFItem.setdObj(arList.get(m));
|
|
|
|
|
pdfList.add(mergePDFItem);
|
|
|
|
|
}
|
|
|
|
|
for (int m = 0; m < arList.size(); m++) {
|
|
|
|
|
MergePDFItem mergePDFItem = new MergePDFItem();
|
|
|
|
|
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 {
|
|
|
|
|
mergePDFItem.setPdfPath(str);
|
|
|
|
|
mergePDFItem.setdObj(arList.get(m));
|
|
|
|
|
pdfList.add(mergePDFItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String pdfFileName = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + pdfFileName + ".pdf";
|
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + pdfFileName + ".pdf";
|
|
|
|
|
|
|
|
|
|
if (pdfList.size() > 0) {
|
|
|
|
|
//对所有地址的pdf进行合成
|
|
|
|
@ -283,7 +298,6 @@ public class inHospitalController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据病案号或类别或图片id获取图片列表,并生成PDF并返回pdf文件名
|
|
|
|
|
*
|
|
|
|
@ -296,7 +310,7 @@ public class inHospitalController {
|
|
|
|
|
*/
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/getPdfToPdf")
|
|
|
|
|
public String getPdfToPdf(HttpServletResponse response, HttpServletRequest request, String imgStr, String masterId,String flag) throws Exception {
|
|
|
|
|
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 = "";
|
|
|
|
@ -334,10 +348,9 @@ public class inHospitalController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = zds.size()-1; i >=0 ; i--) {
|
|
|
|
|
for (int i = zds.size() - 1; i >= 0; i--) {
|
|
|
|
|
String a = zds.get(i).getAssortId();
|
|
|
|
|
if(imgList.indexOf(a)==-1)
|
|
|
|
|
{
|
|
|
|
|
if (imgList.indexOf(a) == -1) {
|
|
|
|
|
zds.remove(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -347,19 +360,17 @@ public class inHospitalController {
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
String pdfA = GeneratePDFFileByAssortID(masterId, asordID, realPath, flag);
|
|
|
|
|
if (pdfA == "" || pdfA.length() == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
fileList.add(pdfA);
|
|
|
|
|
}
|
|
|
|
|
if(fileList.size()==0)
|
|
|
|
|
{
|
|
|
|
|
if (fileList.size() == 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + String.valueOf(System.currentTimeMillis()) + ".pdf";
|
|
|
|
|
String pdfPath = autoPdfUrl.trim() + "/" + String.valueOf(System.currentTimeMillis()) + ".pdf";
|
|
|
|
|
PDFHelper.Append(fileList, pdfPath);
|
|
|
|
|
//PrintToPdfUtil.mergePdfFiles(fileList, pdfPath);
|
|
|
|
|
return pdfPath;
|
|
|
|
@ -524,11 +535,11 @@ public class inHospitalController {
|
|
|
|
|
}
|
|
|
|
|
if (pdfList.size() > 0) {
|
|
|
|
|
//if (errorPdfList.size() != size) {
|
|
|
|
|
//对所有地址的pdf进行合成
|
|
|
|
|
PrintToPdfUtil.mergePdfFiles(pdfList, pdfPath);
|
|
|
|
|
result = pdfPath;
|
|
|
|
|
//对所有地址的pdf进行合成
|
|
|
|
|
PrintToPdfUtil.mergePdfFiles(pdfList, pdfPath);
|
|
|
|
|
result = pdfPath;
|
|
|
|
|
//} else {
|
|
|
|
|
// result = "";
|
|
|
|
|
// result = "";
|
|
|
|
|
//}
|
|
|
|
|
if (errorPdfList.size() > 0) {
|
|
|
|
|
ExportTxtPaper.exportTxtPaper(pdfErrorUrl, "不存在或损坏PDF文件列表" + pdfFile + ".txt", errorPdfList);
|
|
|
|
@ -589,36 +600,36 @@ public class inHospitalController {
|
|
|
|
|
}
|
|
|
|
|
String pdfPath = realPath + entity.getRelationId() + "\\" + entity.getAssortId() + "\\" + entity.getAssortId() + ".pdf";
|
|
|
|
|
|
|
|
|
|
// if (msg.equals("文件未被操作!")) {
|
|
|
|
|
//将之前文件删除
|
|
|
|
|
File file = new File(pdfPath);
|
|
|
|
|
if (file1.exists() && file1.isFile()) {
|
|
|
|
|
file1.delete();
|
|
|
|
|
}
|
|
|
|
|
//重新生成pdf
|
|
|
|
|
//读取指定路径下的文件名和目录名
|
|
|
|
|
List arr = new ArrayList();
|
|
|
|
|
//arr.add(pathType);
|
|
|
|
|
//图片转PDF(病案号文件夹+类别文件夹)
|
|
|
|
|
if(arr.size()>0) {
|
|
|
|
|
msg = PrintToPdfUtil.toPdf(realPath + path2, pdfPath, arr);
|
|
|
|
|
}
|
|
|
|
|
//存在删除
|
|
|
|
|
bol = emrPictureService.deleteById(emrPicture.getId());
|
|
|
|
|
//判断图片是否存在如果不存在则删除类别PDF
|
|
|
|
|
Emr_Picture obj=new Emr_Picture();
|
|
|
|
|
// if (msg.equals("文件未被操作!")) {
|
|
|
|
|
//将之前文件删除
|
|
|
|
|
File file = new File(pdfPath);
|
|
|
|
|
if (file1.exists() && file1.isFile()) {
|
|
|
|
|
file1.delete();
|
|
|
|
|
}
|
|
|
|
|
//重新生成pdf
|
|
|
|
|
//读取指定路径下的文件名和目录名
|
|
|
|
|
List arr = new ArrayList();
|
|
|
|
|
//arr.add(pathType);
|
|
|
|
|
//图片转PDF(病案号文件夹+类别文件夹)
|
|
|
|
|
if (arr.size() > 0) {
|
|
|
|
|
msg = PrintToPdfUtil.toPdf(realPath + path2, pdfPath, arr);
|
|
|
|
|
}
|
|
|
|
|
//存在删除
|
|
|
|
|
bol = emrPictureService.deleteById(emrPicture.getId());
|
|
|
|
|
//判断图片是否存在如果不存在则删除类别PDF
|
|
|
|
|
Emr_Picture obj = new Emr_Picture();
|
|
|
|
|
obj.setRelationId(entity.getRelationId());
|
|
|
|
|
obj.setAssortId(entity.getAssortId());
|
|
|
|
|
List<Emr_Picture> picL=emrPictureService.selectByClo(obj);
|
|
|
|
|
if(picL.size()==0){
|
|
|
|
|
Archive_Detail detailObj=new Archive_Detail();
|
|
|
|
|
List<Emr_Picture> picL = emrPictureService.selectByClo(obj);
|
|
|
|
|
if (picL.size() == 0) {
|
|
|
|
|
Archive_Detail detailObj = new Archive_Detail();
|
|
|
|
|
detailObj.setMasterid(entity.getRelationId());
|
|
|
|
|
detailObj.setAssortid(entity.getAssortId());
|
|
|
|
|
String pdfpaht= pictureUrl + "\\" + entity.getRelationId() + "\\" + entity.getAssortId() + "\\" + entity.getAssortId() + ".pdf";
|
|
|
|
|
String pdfpaht = pictureUrl + "\\" + entity.getRelationId() + "\\" + entity.getAssortId() + "\\" + entity.getAssortId() + ".pdf";
|
|
|
|
|
detailObj.setPdfPath(pdfpaht);
|
|
|
|
|
//该病案的类型无图片则删除该病案类型的PDF及删除PDF记录
|
|
|
|
|
List<Archive_Detail> detailsL= archiveDetailService.selectByColm(detailObj);
|
|
|
|
|
if(detailsL.size()>0) {
|
|
|
|
|
List<Archive_Detail> detailsL = archiveDetailService.selectByColm(detailObj);
|
|
|
|
|
if (detailsL.size() > 0) {
|
|
|
|
|
archiveDetailService.delById(detailsL.get(0).getId());
|
|
|
|
|
// 判断pdf是否存在,将之前文件删除
|
|
|
|
|
File file2 = new File(pdfpaht);
|
|
|
|
@ -628,18 +639,18 @@ public class inHospitalController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// if (msg.equals("文件未被操作!")) {
|
|
|
|
|
if (bol == 1) {
|
|
|
|
|
msg = "删除成功!";
|
|
|
|
|
} else {
|
|
|
|
|
msg = "删除失败!";
|
|
|
|
|
}
|
|
|
|
|
// if (msg.equals("文件未被操作!")) {
|
|
|
|
|
if (bol == 1) {
|
|
|
|
|
msg = "删除成功!";
|
|
|
|
|
} else {
|
|
|
|
|
msg = "删除失败!";
|
|
|
|
|
}
|
|
|
|
|
//}else{
|
|
|
|
|
// msg="文件正被操作!";
|
|
|
|
|
// }
|
|
|
|
|
// msg="文件正被操作!";
|
|
|
|
|
// }
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -934,7 +945,7 @@ public class inHospitalController {
|
|
|
|
|
List dirList = new ArrayList();
|
|
|
|
|
dirList.add(pathType.replace("\\", ""));
|
|
|
|
|
try {
|
|
|
|
|
PrintToPdfUtil.image2pdf(realPath + path2,dirList);
|
|
|
|
|
PrintToPdfUtil.image2pdf(realPath + path2, dirList);
|
|
|
|
|
} catch (DocumentException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -1122,7 +1133,6 @@ public class inHospitalController {
|
|
|
|
|
String trueFileName = firstFile + fileName;
|
|
|
|
|
// 设置存放图片文件的路径
|
|
|
|
|
path = realPath + "\\static\\img\\uploads\\" + trueFileName;
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String nowTime = format1.format(new Date());
|
|
|
|
|
//将其路径及文件名类型以及参数保存图片相关信息到分段详细表
|
|
|
|
@ -1130,7 +1140,6 @@ public class inHospitalController {
|
|
|
|
|
entity.setMasterid(masterID);
|
|
|
|
|
entity.setAssortid(assortID);
|
|
|
|
|
entity.setUploaddatetime(nowTime);
|
|
|
|
|
|
|
|
|
|
entity.setPdfPath("../static/img/uploads/" + trueFileName);
|
|
|
|
|
Archive_Detail detail = new Archive_Detail();
|
|
|
|
|
int bol = 0;
|
|
|
|
@ -1240,36 +1249,36 @@ public class inHospitalController {
|
|
|
|
|
Archive_Detail detail = new Archive_Detail();
|
|
|
|
|
int bol = 0;
|
|
|
|
|
//PDF文件操作
|
|
|
|
|
if (!id.equals("")) {
|
|
|
|
|
entity.setId(id);
|
|
|
|
|
detail = archiveDetailService.selectByid(id);
|
|
|
|
|
if (detail != null) {
|
|
|
|
|
//判断类型是否变更
|
|
|
|
|
if (assortID.equals(detail.getAssortid())) {
|
|
|
|
|
//相同
|
|
|
|
|
} else {
|
|
|
|
|
//判断file是否为空
|
|
|
|
|
if (file == null) {
|
|
|
|
|
if (detail.getPdfPath() != null) {
|
|
|
|
|
String newFileName = (detail.getPdfPath()).substring((detail.getPdfPath()).lastIndexOf("\\") + 1);
|
|
|
|
|
entity.setPdfPath(path.replace("\\\\", "\\") + newFileName);
|
|
|
|
|
//不同pdf转移在删除
|
|
|
|
|
PrintToPdfUtil.copyFile(detail.getPdfPath(), entity.getPdfPath());
|
|
|
|
|
}
|
|
|
|
|
if (!id.equals("")) {
|
|
|
|
|
entity.setId(id);
|
|
|
|
|
detail = archiveDetailService.selectByid(id);
|
|
|
|
|
if (detail != null) {
|
|
|
|
|
//判断类型是否变更
|
|
|
|
|
if (assortID.equals(detail.getAssortid())) {
|
|
|
|
|
//相同
|
|
|
|
|
} else {
|
|
|
|
|
//判断file是否为空
|
|
|
|
|
if (file == null) {
|
|
|
|
|
if (detail.getPdfPath() != null) {
|
|
|
|
|
String newFileName = (detail.getPdfPath()).substring((detail.getPdfPath()).lastIndexOf("\\") + 1);
|
|
|
|
|
entity.setPdfPath(path.replace("\\\\", "\\") + newFileName);
|
|
|
|
|
//不同pdf转移在删除
|
|
|
|
|
PrintToPdfUtil.copyFile(detail.getPdfPath(), entity.getPdfPath());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//根据id修改记录
|
|
|
|
|
bol = archiveDetailService.updateCloById(entity);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//根据id修改记录
|
|
|
|
|
bol = archiveDetailService.updateCloById(entity);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//插入记录
|
|
|
|
|
if (file != null) {
|
|
|
|
|
bol = archiveDetailService.insertSel(entity);
|
|
|
|
|
} else {
|
|
|
|
|
//插入记录
|
|
|
|
|
if (file != null) {
|
|
|
|
|
bol = archiveDetailService.insertSel(entity);
|
|
|
|
|
} else {
|
|
|
|
|
result = "没有找到相对应的文件!";
|
|
|
|
|
}
|
|
|
|
|
result = "没有找到相对应的文件!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (file != null) {
|
|
|
|
|
type = fileName.indexOf(".") != -1 ? fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()) : null;
|
|
|
|
|
|
|
|
|
@ -1341,7 +1350,7 @@ public class inHospitalController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("getImg2")
|
|
|
|
|
public void getImg2(HttpServletRequest request, HttpServletResponse response,String path)throws IOException {
|
|
|
|
|
public void getImg2(HttpServletRequest request, HttpServletResponse response, String path) throws IOException {
|
|
|
|
|
FileInputStream fis = null;
|
|
|
|
|
OutputStream os = null;
|
|
|
|
|
try {
|
|
|
|
@ -1366,7 +1375,7 @@ public class inHospitalController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping("insertLog")
|
|
|
|
|
public void insertLog(HttpServletRequest request, HttpServletResponse response,Emr_Log logBo)throws IOException {
|
|
|
|
|
public void insertLog(HttpServletRequest request, HttpServletResponse response, Emr_Log logBo) throws IOException {
|
|
|
|
|
// 从session获取用户名
|
|
|
|
|
Subject currentUser = SecurityUtils.getSubject();
|
|
|
|
|
Session session = currentUser.getSession();
|
|
|
|
@ -1378,19 +1387,19 @@ public class inHospitalController {
|
|
|
|
|
logBo.setCreater(username);
|
|
|
|
|
//日志实体对象
|
|
|
|
|
logBo.setSysFlag("EMR_Medical_Record");
|
|
|
|
|
String idStr=logBo.getLogContent();
|
|
|
|
|
String idStr = logBo.getLogContent();
|
|
|
|
|
logBo.setIp("10.10.01.1");
|
|
|
|
|
|
|
|
|
|
if(idStr!=null &&idStr!=""){
|
|
|
|
|
if(idStr.indexOf(",")!=-1){
|
|
|
|
|
String[] idArr =idStr.split(",");
|
|
|
|
|
if (idStr != null && idStr != "") {
|
|
|
|
|
if (idStr.indexOf(",") != -1) {
|
|
|
|
|
String[] idArr = idStr.split(",");
|
|
|
|
|
for (int i = 0; i < idArr.length; i++) {
|
|
|
|
|
logBo.setLogTitle(idArr[i]);
|
|
|
|
|
logBo.setLogContent("调用手动作废.");
|
|
|
|
|
// 添加到数据库
|
|
|
|
|
logService.insert(logBo);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
logBo.setLogTitle(idStr);
|
|
|
|
|
logBo.setLogContent("调用单手动作废.");
|
|
|
|
|
// 添加到数据库
|
|
|
|
@ -1402,63 +1411,240 @@ public class inHospitalController {
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/delPdfPage")
|
|
|
|
|
public int delPdfPage(HttpServletResponse response, HttpServletRequest request,Archive_Detail archiveDetail) throws Exception {
|
|
|
|
|
public int delPdfPage(HttpServletResponse response, HttpServletRequest request, Archive_Detail archiveDetail) throws Exception {
|
|
|
|
|
request.setCharacterEncoding("utf-8");
|
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
|
// 从session获取用户名
|
|
|
|
|
Subject currentUser = SecurityUtils.getSubject();
|
|
|
|
|
Session session = currentUser.getSession();
|
|
|
|
|
String username = (String) session.getAttribute("userSession");//获取前面登录的用户名
|
|
|
|
|
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
SimpleDateFormat format2 = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
String nowTime = format2.format(new Date());
|
|
|
|
|
int pageNum=Integer.parseInt(archiveDetail.getTitle());
|
|
|
|
|
int bol = 0;
|
|
|
|
|
if(pageNum==0){
|
|
|
|
|
pageNum=1;
|
|
|
|
|
}else if(pageNum==1){
|
|
|
|
|
pageNum=0;
|
|
|
|
|
int pageNum = Integer.parseInt(archiveDetail.getTitle());
|
|
|
|
|
int pageNum2 = 0;
|
|
|
|
|
if (archiveDetail.getSys() != null && archiveDetail.getSys() != "") {
|
|
|
|
|
pageNum2 = Integer.parseInt(archiveDetail.getSys());
|
|
|
|
|
}
|
|
|
|
|
File file=new File(archiveDetail.getPdfPath());
|
|
|
|
|
int bol = 1;
|
|
|
|
|
File file = new File(archiveDetail.getPdfPath());
|
|
|
|
|
|
|
|
|
|
PdfReader pdfReader = new PdfReader(new FileInputStream(file));
|
|
|
|
|
int pages = pdfReader.getNumberOfPages();
|
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
|
// 设置存放图片文件的路径
|
|
|
|
|
String pdfDelPicUrl = realPath + "static\\img\\delPicImg\\";
|
|
|
|
|
// System.out.println("pdf文件的总页数为:" + pages);
|
|
|
|
|
if(pages>=pageNum) {
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
//删除之前备份并作废记录
|
|
|
|
|
String id=archiveDetail.getId();
|
|
|
|
|
//查询记录
|
|
|
|
|
Archive_Detail archiveDetailDel=archiveDetailService.selectByid(id);
|
|
|
|
|
//插入新作废记录
|
|
|
|
|
archiveDetailDel.setTitle(archiveDetailDel.getTitle()+"_备份"+nowTime);
|
|
|
|
|
if(archiveDetailDel.getTitle().indexOf("_备份")!=-1){
|
|
|
|
|
String oldName=archiveDetailDel.getTitle().split("_备份")[0];
|
|
|
|
|
archiveDetailDel.setTitle(oldName+"_备份"+nowTime);
|
|
|
|
|
}
|
|
|
|
|
archiveDetailDel.setFlag("1");
|
|
|
|
|
archiveDetailDel.setUploaddatetime(format1.format(new Date()));
|
|
|
|
|
//复制一份原有null的pdf文件
|
|
|
|
|
String copyPdfName=nowTime+"备份_"+file.getName();
|
|
|
|
|
if(file.getName().indexOf("备份_")!=-1){
|
|
|
|
|
String oldName=file.getName().split("备份_")[1];
|
|
|
|
|
copyPdfName=nowTime+"备份_"+oldName;
|
|
|
|
|
|
|
|
|
|
if (pages != 1) {
|
|
|
|
|
if ((pages >= pageNum && pageNum2 == 0) || (pages > ((pageNum2 - pageNum) + 1) && (pageNum2 != 0 && pages >= pageNum2))) {
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
if (bol == 1) {
|
|
|
|
|
//判断是否有备份如果没有则备份pdf文件
|
|
|
|
|
Archive_Detail archiveDetail2 = archiveDetailService.selectByid(archiveDetail.getId());
|
|
|
|
|
if (archiveDetail2 != null) {
|
|
|
|
|
if (archiveDetail2.getRecoverPdfPath() == null|| archiveDetail2.getRecoverPdfPath() == "") {
|
|
|
|
|
//备份pdf文件复印并将记录保存
|
|
|
|
|
String recoverPdfPath = archiveDetail2.getPdfPath().replace(file.getName(), "") + nowTime + ".pdf";
|
|
|
|
|
archiveDetail2.setRecoverPdfPath(recoverPdfPath);
|
|
|
|
|
archiveDetailService.updateCloById(archiveDetail2);
|
|
|
|
|
//复印pdf备份
|
|
|
|
|
PrintToPdfUtil.copyFile2(archiveDetail2.getPdfPath(), recoverPdfPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List arrL = new ArrayList();
|
|
|
|
|
// bol = pdfDelPageTest.cutPdf(archiveDetail.getPdfPath(), archiveDetail.getPdfPath(), pageNum);//删除第n页
|
|
|
|
|
String pdfPath = archiveDetail.getPdfPath();
|
|
|
|
|
List<Map<String, String>> list = PrintToPdfUtil.pdfToImage(archiveDetail.getPdfPath(), pageNum, pageNum2, pdfDelPicUrl);
|
|
|
|
|
nowTime = format1.format(new Date());
|
|
|
|
|
//删除pdf页码成功,保存记录到数据库删除图片表中
|
|
|
|
|
Archive_Detail_Picture archiveDetailPicture = new Archive_Detail_Picture();
|
|
|
|
|
archiveDetailPicture.setCreater(username);
|
|
|
|
|
archiveDetailPicture.setCreateTime(nowTime);
|
|
|
|
|
archiveDetailPicture.setUpdateTime(nowTime);
|
|
|
|
|
archiveDetailPicture.setUpdater(username);
|
|
|
|
|
archiveDetailPicture.setEffective(1);
|
|
|
|
|
archiveDetailPicture.setParentId(archiveDetail.getId());
|
|
|
|
|
if (list.size() > 0) {
|
|
|
|
|
for (Map<String, String> map : list) {
|
|
|
|
|
if (map.get("max_picture") != null && map.get("max_picture") != "") {
|
|
|
|
|
if (map.get("max_picture").indexOf("static") != -1) {
|
|
|
|
|
String[] maxPicArr = map.get("max_picture").trim().split("static");
|
|
|
|
|
String maxPic = maxPicArr[1];
|
|
|
|
|
archiveDetailPicture.setMaxPicture("static" + maxPic);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (arrL.indexOf(archiveDetailPicture.getMaxPicture()) == -1) {
|
|
|
|
|
arrL.add(archiveDetailPicture.getMaxPicture());
|
|
|
|
|
archiveDetailPicture.setPictureNumber(Integer.parseInt(map.get("picture_number")));
|
|
|
|
|
archiveDetailPictureService.insertSelective(archiveDetailPicture);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
bol = 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//备份失败
|
|
|
|
|
bol = 4;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//pdf文件不存在
|
|
|
|
|
bol = 2;
|
|
|
|
|
}
|
|
|
|
|
String copyPath=archiveDetail.getPdfPath().substring(0,archiveDetail.getPdfPath().lastIndexOf("\\"));
|
|
|
|
|
archiveDetailDel.setPdfPath(copyPath+"\\"+copyPdfName);
|
|
|
|
|
bol=archiveDetailService.insertSel(archiveDetailDel);
|
|
|
|
|
//保存旧版本文件
|
|
|
|
|
PrintToPdfUtil.save(file, copyPdfName, copyPath);
|
|
|
|
|
if(bol==1) {
|
|
|
|
|
bol = pdfDelPageTest.cutPdf(archiveDetail.getPdfPath(), archiveDetail.getPdfPath(), pageNum);//删除第n页
|
|
|
|
|
}else{
|
|
|
|
|
//备份失败
|
|
|
|
|
bol=4;
|
|
|
|
|
} else {
|
|
|
|
|
//删除页码大于总页数
|
|
|
|
|
bol = 3;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
bol = 5;
|
|
|
|
|
}
|
|
|
|
|
return bol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//@OptionalLog(methods = "查询相关的页码图片列表")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/selDelPicList")
|
|
|
|
|
public List<Archive_Detail_Picture> selDelPicList(HttpServletRequest request, HttpServletResponse response, Archive_Detail_Picture archiveDetailPicture) {
|
|
|
|
|
List<Archive_Detail_Picture> list = archiveDetailPictureService.selectByCol(archiveDetailPicture);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//@OptionalLog(methods = "删除所有页码图片")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/delPageImgAll")
|
|
|
|
|
public int delPageImgAll(HttpServletRequest request, HttpServletResponse response, Archive_Detail_Picture archiveDetailPicture) {
|
|
|
|
|
int bol = 0;
|
|
|
|
|
String fileDirName = archiveDetailPicture.getMaxPicture();
|
|
|
|
|
archiveDetailPicture.setMaxPicture(null);
|
|
|
|
|
bol = archiveDetailPictureService.deleteByCol(archiveDetailPicture);
|
|
|
|
|
if (bol == 1) {
|
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
|
// 设置存放图片文件的路径
|
|
|
|
|
String pdfDelPicUrl = "static\\img\\delPicImg\\";
|
|
|
|
|
//将之前文件目录下图片删除
|
|
|
|
|
File file = new File(realPath + pdfDelPicUrl + fileDirName + "\\");
|
|
|
|
|
PrintToPdfUtil.delete(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//@OptionalLog(methods = "删除单张页码图片")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/delPageImg")
|
|
|
|
|
public int delPageImg(HttpServletRequest request, HttpServletResponse response, Archive_Detail_Picture archiveDetailPicture) {
|
|
|
|
|
int bol = 0;
|
|
|
|
|
bol = archiveDetailPictureService.deleteByCol(archiveDetailPicture);
|
|
|
|
|
if (bol == 1) {
|
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
|
//将之前图片文件删除
|
|
|
|
|
File file = new File(realPath + archiveDetailPicture.getMaxPicture());
|
|
|
|
|
if (file.exists() && file.isFile()) {
|
|
|
|
|
file.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//@OptionalLog(methods = "PDF文件添加页码")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/addPdfPageBtn")
|
|
|
|
|
public int addPdfPageBtn(HttpServletRequest request, HttpServletResponse response, Archive_Detail_Picture archiveDetailPicture) {
|
|
|
|
|
String orgPdfPath = archiveDetailPicture.getMaxPicture();
|
|
|
|
|
File file = new File(orgPdfPath);
|
|
|
|
|
SimpleDateFormat format2 = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
String nowTime = format2.format(new Date());
|
|
|
|
|
String filePath = file.getAbsolutePath().replace(file.getName(), "");
|
|
|
|
|
String fileName = nowTime + "_" + file.getName();
|
|
|
|
|
filePath += fileName;
|
|
|
|
|
File file1 = new File(filePath);
|
|
|
|
|
file.renameTo(file1);
|
|
|
|
|
String result = PrintToPdfUtil.addPageNum(filePath, orgPdfPath);
|
|
|
|
|
if (result != "" && result != null) {
|
|
|
|
|
file1.deleteOnExit();
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//@OptionalLog(methods = "PDF文件还原页码")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/returnPage")
|
|
|
|
|
public String returnPage(HttpServletRequest request, HttpServletResponse response, Archive_Detail_Picture archiveDetailPicture) throws Exception {
|
|
|
|
|
String result = "";
|
|
|
|
|
int bol = 0;
|
|
|
|
|
// 模板文件路径
|
|
|
|
|
String templatePath = (archiveDetailPicture.getMinPicture());
|
|
|
|
|
// 生成的文件路径
|
|
|
|
|
String targetPath = archiveDetailPicture.getMinPicture();
|
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
|
// 图片路径
|
|
|
|
|
String imagePath = realPath + archiveDetailPicture.getMaxPicture();
|
|
|
|
|
// 页数
|
|
|
|
|
int pageNum = archiveDetailPicture.getPictureNumber();
|
|
|
|
|
File file = new File(templatePath);
|
|
|
|
|
PdfReader pdfReader = new PdfReader(new FileInputStream(file));
|
|
|
|
|
int pages = pdfReader.getNumberOfPages();
|
|
|
|
|
if (pages >= 1) {
|
|
|
|
|
if ((pages) >= pageNum) {
|
|
|
|
|
if (file.exists() && file.isFile()) {
|
|
|
|
|
result = AddImgToPdf.addImgToPdf(templatePath, targetPath, imagePath, pageNum);
|
|
|
|
|
if (result != "文件不存在") {
|
|
|
|
|
archiveDetailPicture.setMaxPicture(null);
|
|
|
|
|
archiveDetailPicture.setMinPicture(null);
|
|
|
|
|
archiveDetailPicture.setPictureNumber(null);
|
|
|
|
|
//删除记录
|
|
|
|
|
bol = archiveDetailPictureService.deleteByCol(archiveDetailPicture);
|
|
|
|
|
if (bol == 1) {
|
|
|
|
|
file.delete();
|
|
|
|
|
}
|
|
|
|
|
result = "图片还原到" + pageNum + "页成功!";
|
|
|
|
|
} else {
|
|
|
|
|
result = "图片还原失败!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//pdf文件不存在
|
|
|
|
|
bol = 2;
|
|
|
|
|
result = "图片还原" + pageNum + "要小于等于" + pages + "!";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
result = "pdf文件无内容!";
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping(value = "/returnPdfFile")
|
|
|
|
|
public String returnPdfFile(HttpServletRequest request, HttpServletResponse response, Archive_Detail archiveDetail) throws Exception {
|
|
|
|
|
String result="";
|
|
|
|
|
//判断是否有备份如果没有则备份pdf文件
|
|
|
|
|
archiveDetail = archiveDetailService.selectByid(archiveDetail.getId());
|
|
|
|
|
if(archiveDetail!=null){
|
|
|
|
|
if(archiveDetail.getPdfPath()!="" && archiveDetail.getPdfPath()!=null && archiveDetail.getRecoverPdfPath()!="" && archiveDetail.getRecoverPdfPath()!=null){
|
|
|
|
|
PrintToPdfUtil.copyFile2(archiveDetail.getRecoverPdfPath(), archiveDetail.getPdfPath());
|
|
|
|
|
//并删除图片记录
|
|
|
|
|
Archive_Detail_Picture archiveDetailPicture=new Archive_Detail_Picture();
|
|
|
|
|
archiveDetailPicture.setParentId(archiveDetail.getId());
|
|
|
|
|
String fileDirName=archiveDetail.getPdfPath();
|
|
|
|
|
fileDirName = fileDirName.substring(fileDirName.lastIndexOf("\\")+1).replace(".pdf","");
|
|
|
|
|
int bol = archiveDetailPictureService.deleteByCol(archiveDetailPicture);
|
|
|
|
|
if (bol == 1) {
|
|
|
|
|
// 项目在容器中实际发布运行的根路径
|
|
|
|
|
String realPath = request.getSession().getServletContext().getRealPath("/");
|
|
|
|
|
// 设置存放图片文件的路径
|
|
|
|
|
String pdfDelPicUrl = "static\\img\\delPicImg\\";
|
|
|
|
|
//将之前文件目录下图片删除
|
|
|
|
|
File file = new File(realPath + pdfDelPicUrl + fileDirName + "\\");
|
|
|
|
|
PrintToPdfUtil.delete(file);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
result="暂无备份pdf文件!";
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
//删除页码大于总页数
|
|
|
|
|
bol=3;
|
|
|
|
|
}
|
|
|
|
|
return bol;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|