|
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.emr.dao.CommomMapper;
|
|
|
|
import com.emr.dao.CommomMapper;
|
|
|
|
import com.emr.dao.emrPdfWaterSet.EmrPdfWaterSetMapper;
|
|
|
|
import com.emr.dao.emrPdfWaterSet.EmrPdfWaterSetMapper;
|
|
|
|
import com.emr.entity.EmrComomSet;
|
|
|
|
import com.emr.entity.EmrComomSet;
|
|
|
|
|
|
|
|
import com.emr.entity.Power_User;
|
|
|
|
import com.emr.entity.ResultUtil;
|
|
|
|
import com.emr.entity.ResultUtil;
|
|
|
|
import com.emr.entity.emrPdfWaterSet.EmrPdfWaterSet;
|
|
|
|
import com.emr.entity.emrPdfWaterSet.EmrPdfWaterSet;
|
|
|
|
import com.emr.entity.tScanAssort.T_Scan_Assort;
|
|
|
|
import com.emr.entity.tScanAssort.T_Scan_Assort;
|
|
|
|
@ -18,10 +19,13 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -29,6 +33,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.*;
|
|
|
|
import java.net.InetAddress;
|
|
|
|
import java.net.InetAddress;
|
|
|
|
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
@ -160,6 +165,38 @@ public class CommomService {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getOperIp(){
|
|
|
|
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
|
|
|
|
// 获取访问真实IP
|
|
|
|
|
|
|
|
String ipAddress = request.getHeader("x-forwarded-for");
|
|
|
|
|
|
|
|
if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
|
|
|
|
|
|
|
ipAddress = request.getHeader("Proxy-Client-IP");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
|
|
|
|
|
|
|
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
|
|
|
|
|
|
|
ipAddress = request.getRemoteAddr();
|
|
|
|
|
|
|
|
if("127.0.0.1".equals(ipAddress) || "0:0:0:0:0:0:0:1".equals(ipAddress)){
|
|
|
|
|
|
|
|
//根据网卡取本机配置的IP
|
|
|
|
|
|
|
|
InetAddress inet=null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
inet = InetAddress.getLocalHost();
|
|
|
|
|
|
|
|
} catch (UnknownHostException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert inet != null;
|
|
|
|
|
|
|
|
ipAddress= inet.getHostAddress();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
|
|
|
|
|
|
|
if(ipAddress!=null && ipAddress.length()>15){ //"***.***.***.***".length() = 15
|
|
|
|
|
|
|
|
if(ipAddress.indexOf(",")>0){
|
|
|
|
|
|
|
|
ipAddress = ipAddress.substring(0,ipAddress.indexOf(","));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ipAddress;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//脐血库显示pdf
|
|
|
|
//脐血库显示pdf
|
|
|
|
public void showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response) throws Exception {
|
|
|
|
public void showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response) throws Exception {
|
|
|
|
@ -202,12 +239,42 @@ public class CommomService {
|
|
|
|
if (!filePaths.isEmpty()) {
|
|
|
|
if (!filePaths.isEmpty()) {
|
|
|
|
//根据图片路径转换pdf
|
|
|
|
//根据图片路径转换pdf
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
|
|
|
|
img2PdfUtil.imageToPdf(response, filePaths, pdfName, emrPdfWaterSet);
|
|
|
|
//定义第二文本水印 姓名 + 科室 + ip
|
|
|
|
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet1 = getEmrPdfWaterSet(emrPdfWaterSet);
|
|
|
|
|
|
|
|
img2PdfUtil.imageToPdf(response, filePaths, pdfName, emrPdfWaterSet,emrPdfWaterSet1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @Description: getEmrPdfWaterSet方法是定义第二文本水印 姓名 + 科室 + ip
|
|
|
|
|
|
|
|
* @param: [emrPdfWaterSet]
|
|
|
|
|
|
|
|
* @return: com.emr.entity.emrPdfWaterSet.EmrPdfWaterSet
|
|
|
|
|
|
|
|
* @author 曾文和
|
|
|
|
|
|
|
|
* @createTime 2022/7/26 1:15
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EmrPdfWaterSet getEmrPdfWaterSet(EmrPdfWaterSet emrPdfWaterSet) {
|
|
|
|
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet1 = new EmrPdfWaterSet();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(emrPdfWaterSet,emrPdfWaterSet1);
|
|
|
|
|
|
|
|
//定义第二水印文本
|
|
|
|
|
|
|
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
|
|
|
|
|
|
//获取reuqest
|
|
|
|
|
|
|
|
HttpServletRequest request = attributes.getRequest();
|
|
|
|
|
|
|
|
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
|
|
|
|
|
|
|
|
String text = "";
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(user.getUserPosition())){
|
|
|
|
|
|
|
|
text = user.getUserPosition();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(user.getRemark())){
|
|
|
|
|
|
|
|
text += " " + user.getRemark();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
text += " " + getOperIp();
|
|
|
|
|
|
|
|
emrPdfWaterSet1.setText(text);
|
|
|
|
|
|
|
|
return emrPdfWaterSet1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//南方医院显示图像
|
|
|
|
//南方医院显示图像
|
|
|
|
public void showRecordContentSouth(String patientId, String userName, String deptName, String scanPages, String sources, String flag, HttpServletResponse response) throws Exception {
|
|
|
|
public void showRecordContentSouth(String patientId, String userName, String deptName, String scanPages, String sources, String flag, HttpServletResponse response) throws Exception {
|
|
|
|
String pdfName = "档案管理PDF";
|
|
|
|
String pdfName = "档案管理PDF";
|
|
|
|
@ -249,13 +316,9 @@ public class CommomService {
|
|
|
|
if (!filePaths.isEmpty()) {
|
|
|
|
if (!filePaths.isEmpty()) {
|
|
|
|
//根据图片路径转换pdf
|
|
|
|
//根据图片路径转换pdf
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
|
|
|
|
InetAddress netAddress = InetAddress.getLocalHost();
|
|
|
|
//定义第二文本水印 姓名 + 科室 + ip
|
|
|
|
String ip = null;
|
|
|
|
EmrPdfWaterSet emrPdfWaterSet1 = getEmrPdfWaterSet(emrPdfWaterSet);
|
|
|
|
if (null != netAddress) {
|
|
|
|
img2PdfUtil.imageToPdf(response, filePaths, pdfName, emrPdfWaterSet,emrPdfWaterSet1);
|
|
|
|
ip = netAddress.getHostAddress();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
emrPdfWaterSet.setText(userName + " " + ip);
|
|
|
|
|
|
|
|
img2PdfUtil.imageToPdf(response, filePaths, pdfName, emrPdfWaterSet);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|