优化2.0标准版代码

master
jian.wang 1 year ago
parent 680ccfed56
commit 1e0f6d46e3

@ -1,7 +1,12 @@
--commomtable wj 2024-08-19
ALTER TABLE commomtable
ADD medical_no varchar(255) NULL,
ADD
memo varchar(255) NULL,
id_card varchar(255) NULL,
file_source nvarchar(20) NULL,
ph varchar(255) NULL,
medical_no varchar(255) NULL,
female_name varchar(255) NULL,
male_name varchar(255) NULL,
cycle_type varchar(255) NULL,

@ -44,6 +44,7 @@
<poi.version>3.9</poi.version>
<lombok.version>1.16.8</lombok.version>
<itextpdf.version>5.5.7</itextpdf.version>
<itextasian.version>5.2.0</itextasian.version>
<jai.version>1.1.3</jai.version>
<hibernate-validator.version>6.1.5.Final</hibernate-validator.version>
</properties>
@ -213,6 +214,11 @@
<version>${itextpdf.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>${itextasian.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox -->
<dependency>
<groupId>org.apache.pdfbox</groupId>

@ -42,6 +42,7 @@ import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.CollectionUtils;
import org.json.JSONArray;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -51,6 +52,7 @@ import org.springframework.util.Base64Utils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@ -658,9 +660,14 @@ public class FontController {
@RequestParam(value="admissId",required = false) String admissId,
@RequestParam(value="outpatientNo",required = false) String outpatientNo) {
System.out.println("开始跳转接口准备鉴权。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。");
try {
String userName = request.getParameter("userName");
String dataSource = request.getParameter("dataSource");
System.out.println("获取接口传递的参数{}--------------------------用户账号userName为" + userName + "---------dataSource为" + dataSource);
if(ObjectUtils.isEmpty(userName)){
model.addAttribute("msg", "用户账号不能为空");
return "font/msg";
@ -677,6 +684,9 @@ public class FontController {
*/
userParams.put("userName", userName);
String userResult = HttpClientUtils.doPost(POWER_URLHEAD + "/queryUserByUserNameAndPassword", userParams);
System.out.println("通过用户账号获取的用户信息为:" + userResult);
JSONObject userResultJson = JSONObject.parseObject(userResult);
if(ObjectUtils.isEmpty(userResultJson)){
model.addAttribute("msg", "用户账号不存在");
@ -690,9 +700,17 @@ public class FontController {
params.put("userPwd", userResultJson.getString("userPwd"));
params.put("remark", "GZINTERFACE");
System.out.println("开始模拟登录------------参数为:" + params);
String result = HttpClientUtils.doPost(POWER_URLHEAD + "/login", params);
JSONObject jsonObject = JSONObject.parseObject(result);
System.out.println("模拟登录成功------------返回结果为:" + jsonObject);
String token = jsonObject.getString("token");
System.out.println("登录成功------------token为" + token);
if(!ObjectUtils.isEmpty(token)){
this.getUserInfo(request, token, userName);
//查询表格配置表的数据,根据配置动态显示表格字段
@ -753,14 +771,21 @@ public class FontController {
Power_User powerUser = JSON.parseObject(objects[0].toString(), Power_User.class);
powerUser.setUserName(userName);
System.out.println("调用power系统登录成功之后的用户信息为----------------------------------------------------------------" + JSONObject.toJSONString(powerUser));
//设置进session
request.getSession().setAttribute("CURRENT_USER", powerUser);
//request.getSession().setAttribute("CURRENT_USER", powerUser);
ServletContext context = request.getServletContext();
context.setAttribute("CURRENT_USER", powerUser);
request.getSession().setAttribute("power_menus", powerUser.getMenus());
request.getSession().setAttribute("token", token);
//验证shiro(有shiro才此操作)
UsernamePasswordToken userToken = new UsernamePasswordToken(userName, "123456");
System.out.println("验证shiro获取userToken为----------------------------------------------------------" + JSONObject.toJSONString(userToken));
Subject subject = SecurityUtils.getSubject();
subject.login(userToken);
}
@ -800,7 +825,118 @@ public class FontController {
*/
@RequestMapping(value = "getOutpatientData", method = RequestMethod.POST)
@ResponseBody
public void getOutpatientData() {
public Msg getOutpatientData(@RequestBody String json) {
try {
Map<Object, Object> data = new HashMap<>(); //数据集合
//json = new String(Files.readAllBytes(Paths.get("C:\\Users\\Lenovo\\OneDrive\\桌面\\data.json")), StandardCharsets.UTF_8);
String patientID = "";//患者唯一标识
String medicalRecordNo = "";//病历号
String handleTime = "";//就诊时间
String visitCount = "";//就诊次数
String patientName = "";//姓名
String birthday = "";//出生日期
String sex = "";//性别
String SSN = "";//身份证号码
// 创建一个JSONObject对象
org.json.JSONObject jsonObjectData = new org.json.JSONObject(json);
// 获取Request请求数据
if (jsonObjectData.has("Request")) {
org.json.JSONObject requestData = jsonObjectData.getJSONObject("Request");
// 获取返回的body数据并转为JSONObject对象
if (requestData.has("Body")) {
org.json.JSONObject requestBodyData = requestData.getJSONObject("Body");
/**
*
* 1. DemographyPatientName Birthday Sex SSN
* 2. DemographyPatientIdentifierListPatientIdentifierList MedicalRecordNo-
*/
if (requestBodyData.has("Demography")) {
org.json.JSONObject DemographyData = requestBodyData.getJSONObject("Demography");
if (DemographyData.has("PatientName")) {
patientName = DemographyData.getString("PatientName");
}
if (DemographyData.has("Birthday")) {
birthday = DemographyData.getString("Birthday");
}
if (DemographyData.has("Sex") && DemographyData.getJSONObject("Sex").has("Text")) {
org.json.JSONObject sexData = DemographyData.getJSONObject("Sex");
sex = sexData.getString("Text");
}
if (DemographyData.has("SSN")) {
SSN = DemographyData.getString("SSN");
}
// 循环遍历PatientIdentifierList数据拿到MedicalRecordNo 病案号数据
if (DemographyData.has("PatientIdentifierList")) {
JSONArray PatientIdentifierListDataJsonArray = DemographyData.getJSONArray("PatientIdentifierList");
for (int i = 0; i < PatientIdentifierListDataJsonArray.length(); i++) {
org.json.JSONObject PatientIdentifierListDataJsonObject = PatientIdentifierListDataJsonArray.getJSONObject(i);
if ("MedicalRecordNo".equals(PatientIdentifierListDataJsonObject.get("IDType"))) {
medicalRecordNo = PatientIdentifierListDataJsonObject.getString("IDNumber");
} else if ("PatientID".equals(PatientIdentifierListDataJsonObject.get("IDType"))) {
patientID = PatientIdentifierListDataJsonObject.getString("IDNumber");
}
}
}
}
/**
*
*/
if (requestBodyData.has("PatientVisit")) {
org.json.JSONObject patientVisitData = requestBodyData.getJSONObject("PatientVisit");
//就诊次数
if(patientVisitData.has("VisitCount")){
visitCount = patientVisitData.getString("VisitCount");
}
//就诊时间
if(patientVisitData.has("HandleList")){
JSONArray HandleListDataJsonArray = patientVisitData.getJSONArray("HandleList");
for (int i = 0; i < HandleListDataJsonArray.length(); i++) {
org.json.JSONObject HandleListDataJsonObject = HandleListDataJsonArray.getJSONObject(i);
if (HandleListDataJsonObject.has("HandleTime")) {
handleTime = HandleListDataJsonObject.getString("HandleTime");
}
}
}
}
}
}
// System.out.println("患者唯一标识为:" + patientID + "\n病案号为" + medicalRecordNo + "\n姓名为" + patientName +
// "\n出生日期为" + birthday + "\n性别为" + sex + "\n身份证号为" + SSN + "\n就诊时间为" + handleTime + "\n就诊次数为" + visitCount);
data.put("patientID", patientID);
data.put("medicalRecordNo", medicalRecordNo);
data.put("patientName", patientName);
data.put("birthday", birthday);
data.put("sex", sex);
data.put("SSN", SSN);
data.put("handleTime", handleTime);
data.put("visitCount", visitCount);
//判断是否已经存在改数据通过唯一标识patientID
String isExist = commomMapper.quertIsExist(patientID);
if(ObjectUtils.isEmpty(isExist)){
commomMapper.saveData(data);
}else{
commomMapper.updateData(data);
}
return Msg.successData(data);
} catch (Exception e) {
e.printStackTrace();
return Msg.fail("数据接入失败");
}
}
}

@ -152,7 +152,7 @@ public class FontShowRecordController {
//虚假登陆
//验证shiro(有shiro才此操作)
Power_User user = new Power_User();
user.setUserName("第三方");
user.setUserName("第三方") ;
user.setUserId(-999);
user.setRoleId(-999);
Set<String> menu = new TreeSet<>();

@ -19,10 +19,7 @@ import com.emr.service.emrPrintOrDownLoadInfo.PrintOrDownLoadInfoService;
import com.emr.service.recordType.EmrTypeRelatedService;
import com.emr.service.recordType.EmrTypeService;
import com.emr.service.tScanAssort.T_Scan_AssortService;
import com.emr.util.DateUtils;
import com.emr.util.ExceptionPrintUtil;
import com.emr.util.Jpg2PdfUtil;
import com.emr.util.img2PdfUtil;
import com.emr.util.*;
import com.emr.vo.EmrPrintOrDownLoadInfo.EmrPrintOrDownLoadInfoVo;
import com.emr.vo.FontVo.ScanAssortVo;
import com.emr.vo.browseRecords;
@ -30,6 +27,8 @@ import com.emr.vo.commomSearch.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,13 +41,21 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Base64;
import java.util.stream.Collectors;
/**
@ -349,7 +356,15 @@ public class CommomSearchController {
model.addAttribute("patientId", patientId);
model.addAttribute("dataSource", dataSource);
//加载登陆者
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
if (null != user) {
model.addAttribute("user", user);
model.addAttribute("roleId", user.getRoleId());
@ -427,6 +442,129 @@ public class CommomSearchController {
return "recordManage/commomSearch/showRecord174";
}
@RequestMapping("showMegerPDFView")
public String showMegerPDFView(String patientId, String dataSource, Model model, HttpServletRequest request) {
model.addAttribute("patientId", patientId);
model.addAttribute("dataSource", dataSource);
//加载登陆者
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
if (null != user) {
model.addAttribute("user", user);
model.addAttribute("roleId", user.getRoleId());
model.addAttribute("hospitalName", hospitalName);
}
List<EmrPrintOrDownLoadInfoVo> printCount = null;
try {
printCount = printOrDownLoadInfoService.getPrintCount(patientId);
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
}
if (null != printCount && !printCount.isEmpty()) {
model.addAttribute("printCount", 1);
}
Short admissTimes = null;
String name = null;
String disDate = null;
String disDept = null;
String attending = null;
String fileSource = null;
List<CommomVo> commomVos = commomMapper.selectAllAndPatientId(patientId);
for (CommomVo list : commomVos) {
admissTimes = list.getAdmissTimes();
name = list.getName();
fileSource = list.getFileSource();
disDate = list.getDisDate();
disDept = list.getDisDept();
attending = list.getAttending();
}
String userName = user.getUserPosition();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
Date date = new Date(System.currentTimeMillis());
String format = formatter.format(date);
browseRecords browseRecords = new browseRecords();
browseRecords.setAdmissTimes(admissTimes);
browseRecords.setPatientName(name);
browseRecords.setDisDate(disDate);
browseRecords.setDisDept(disDept);
browseRecords.setAttending(attending);
browseRecords.setPatientId(patientId);
browseRecords.setBrowseTime(format);
browseRecords.setBrowseName(userName);
// 获取访问真实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(","));
}
}
browseRecords.setIp(ipAddress);
return "recordManage/commomSearch/showMegerPDFView";
}
@RequestMapping("showMegerRecordIframeBlood")
public String showMegerRecordIframeBlood(String patientId, String flag, Model model, HttpServletRequest request) {
model.addAttribute("patientId", patientId);
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
//打印分类集合
List<Emr_Type> emrTypes = null;
List<Zd_Assort> zdAssorts = null;
int isDownload = 0;
try {
emrTypes = emrTypeService.selectAllByCreater(1, request);
//病案分段集合
zdAssorts = assortService.selectAllByPower(user);
isDownload = apply_approveMapper.selectIsPowerByUser(user.getUserName(), patientId, 3);
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
}
model.addAttribute("emrTypes", emrTypes);
model.addAttribute("zdAssorts", zdAssorts);
model.addAttribute("isDownload", isDownload);
//查询是否有打印权限
int printFlag = 0;
int moveFlag = 0;
Set<String> menus = user.getMenus();
for (String menu : menus) {
if (StringUtils.isNotBlank(menu)) {
if ("/commom/printPdf".equals(menu)) {
printFlag = 1;
}
if ("/commom/movePdf".equals(menu)) {
moveFlag = 1;
}
}
}
model.addAttribute("moveFlag", moveFlag);
model.addAttribute("printFlag", printFlag);
model.addAttribute("flag", flag);
return "recordManage/commomSearch/showMegerRecordIframeBlood";
}
@RequestMapping("showRecordSouth")
public String showRecordSouth(String patientId, String userName, String deptName, Model model, HttpServletRequest request) {
model.addAttribute("patientId", patientId);
@ -531,7 +669,15 @@ public class CommomSearchController {
@RequestMapping("showRecordIframeBlood")
public String showRecordIframeBlood(String patientId, String flag, Model model, HttpServletRequest request) {
model.addAttribute("patientId", patientId);
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
//打印分类集合
List<Emr_Type> emrTypes = null;
List<Zd_Assort> zdAssorts = null;
@ -682,8 +828,16 @@ public class CommomSearchController {
List<CommomTree> treeList = new ArrayList<>();
//查询该有的权限分类
try {
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
List<CommomTree> commomVos = new ArrayList<>();
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
List<CommomTree> commomVos;
if (user.getRoleId() == 0 || user.getRoleId() == -100 || user.getRoleId() == -999) {
commomVos = commomMapper.selectScanImgTreeByPatientId(patientId, sortFlag,null, null);
} else {
@ -795,6 +949,100 @@ public class CommomSearchController {
}
}
}
if (commomVos.size() == 0) {
List<CommomTree> archiveDetail = archiveDetailMapper.selectPdfPathByPatient2(patientId);
//第一级:全部影像资料
CommomTree tree1 = new CommomTree();
Integer id = 1;
tree1.setId(id);
tree1.setNewName("全部影像资料");
if (null != archiveDetail && !archiveDetail.isEmpty()) {
//去重,取出不重复的分类集合
Map<String, CommomTree> assortMap = new LinkedHashMap<>();
for (CommomTree commomVo1 : archiveDetail) {
assortMap.put(commomVo1.getAssortId(), commomVo1);
}
//判断分类是否全选,全选,父类跟着全选
if (null != typeRelateds && !typeRelateds.isEmpty()) {
boolean checkedFlag = true;
for (Map.Entry<String, CommomTree> map : assortMap.entrySet()) {
//定义是否存在
boolean flag = false;
for (Emr_Type_Related typeRelated : typeRelateds) {
if (typeRelated.getAssortId().equals(map.getKey())) {
flag = true;
break;
}
}
if (!flag) {
checkedFlag = false;
break;
}
}
if (checkedFlag) {
tree1.setChecked("true");
}
} else {
tree1.setChecked("true");
}
treeList.add(tree1);
int oneId = 0;
for (Map.Entry<String, CommomTree> map : assortMap.entrySet()) {
id++;
oneId = id;
String assortId = map.getValue().getAssortId();
CommomTree tree2 = new CommomTree();
tree2.setId(id);
tree2.setParentId(1);
tree2.setAssortId(map.getValue().getAssortId());
//判断选中
boolean checkFlag = false;
if (null != typeRelateds && !typeRelateds.isEmpty()) {
for (Emr_Type_Related typeRelated : typeRelateds) {
if (StringUtils.isNotBlank(assortId) && assortId.equals(typeRelated.getAssortId())) {
tree2.setChecked("true");
checkFlag = true;
break;
}
}
} else {
checkFlag = true;
tree2.setChecked("true");
}
//定义该类影像图片数量
int scanPathCount = 0;
//第二层 图片
int scanPathCountNum = 0;
for (CommomTree commomVo : archiveDetail) {
if (StringUtils.isNotBlank(assortId) && StringUtils.isNotBlank(commomVo.getAssortId()) &&
assortId.equals(commomVo.getAssortId())) {
id++;
CommomTree tree3 = new CommomTree();
tree3.setId(id);
tree3.setParentId(oneId);
tree3.setAssortId(assortId);
if (checkFlag) {
tree3.setChecked("true");
}
scanPathCount++;
//图片名称
String name = commomVo.getScanPage();
tree3.setAssortName(name);
//设置树图片节点的名称
tree3.setNewName(commomVo.getTitle());
tree3.setSource(commomVo.getSource());
//存储水印图片
treeList.add(tree3);
scanPathCountNum = commomVo.getPageCount();
}
}
tree2.setNewName(map.getValue().getAssortName() + "(" + scanPathCountNum + ")");
treeList.add(tree2);
}
}
}
return JSON.toJSONString(treeList);
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
@ -817,11 +1065,22 @@ public class CommomSearchController {
@ResponseBody
public ResultUtil selectPrintPic(HttpServletResponse response, String patientId, String rootPaths, String names, String sources, HttpServletRequest request) throws Exception {
//生成加载进度mapKey
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
String mapKey = user.getUserName() + "_" + patientId;
if(!ObjectUtils.isEmpty(rootPaths) && rootPaths.length() > 3){
List<String> outs = commomService.selectPrintPic(response, patientId, rootPaths, names, sources, mapKey);
return ResultUtil.ok(outs);
}
return ResultUtil.ok("图像路径为空,请检查数据是否有误");
}
@RequestMapping(value = "selectPrintPic2", method = RequestMethod.POST)
@ -901,9 +1160,17 @@ public class CommomSearchController {
@ResponseBody
public void getRecordContentBlood(String patientId, HttpServletRequest request, HttpServletResponse response) {
List<CommomTree> commomTrees = archiveDetailMapper.selectPdfPathByPatient2(patientId);
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
if (commomTrees.size() == 0) {
try {
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
String mapKey = user.getUserName() + "_" + patientId;
List<String> scanPages = (List<String>) request.getSession().getAttribute(mapKey);
if (!CollectionUtils.isEmpty(scanPages)) {
@ -929,22 +1196,24 @@ public class CommomSearchController {
}
} else {
String pdfWater = "";
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
String mapKey = user.getUserName() + "_" + patientId;
List<String> filePaths = (List<String>) request.getSession().getAttribute(mapKey);
if (!CollectionUtils.isEmpty(filePaths)) {
//根据图片路径转换pdf
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
//定义第二文本水印 姓名 + 科室 + ip
EmrPdfWaterSet emrPdfWaterSet1 = commomService.getEmrPdfWaterSet(emrPdfWaterSet);
Jpg2PdfUtil.mulFile2One2(response, filePaths, pdfWater,emrPdfWaterSet);
//移除缓存
request.removeAttribute(mapKey);
}
}
}
public int calculateTotalSegments(int totalPages) {
// 假设每段包含100页
return (int) Math.ceil((double) totalPages / 5);
}
/**
* 访
*
@ -1320,6 +1589,87 @@ public class CommomSearchController {
@ResponseBody
public ResultUtil uploadCost(HttpServletRequest request) {
return commomService.uploadCost(request);
}
@RequestMapping(value = "savePdfPage", method = RequestMethod.POST)
@ResponseBody
public ResultUtil savePdfPage(@RequestBody PdfPageRequest request) {
String[] base64Datas = request.getBase64Data();
String[] assortIdDatas = request.getAssortIdData();
String[] pageDatas = request.getPageData();
String patientId = request.getPatientId();
Map<String,Object> dataMap = new HashMap<>();
for(int i = 0; i < base64Datas.length; i++){
String base64Data = base64Datas[i];
String assortId = assortIdDatas[i];
int pageNum = Integer.parseInt(pageDatas[i]);
String fileName = "merger_" + patientId + "_" + pageNum + ".jpg";
try {
// 通过patientId查询文件上传路径
String uploadPath = commomService.getUploadPath(patientId);
String savePath = uploadPath + "\\" + fileName;
// 下载PDF文件
byte[] pdfBytes = Base64.getDecoder().decode(base64Data.split(",")[1]);
// 加载PDF文件
PDDocument document = PDDocument.load(new ByteArrayInputStream(pdfBytes));
// 提取指定页码的内容
PDFRenderer pdfRenderer = new PDFRenderer(document);
BufferedImage image = pdfRenderer.renderImageWithDPI(pageNum - 1, 150); // 使用300 DPI渲染图像
// 将图像保存为JPG文件
File file = new File(savePath);
ImageIO.write(image, "jpg", file);
document.close();
//判断是否已有改图像,防止重复插入
Integer isExistflag = commomService.getIsExistFileName(fileName);
if(isExistflag == 1){
continue;
}
// 存入分段数据表
dataMap.put("patientId", patientId);
dataMap.put("assortId", assortId);
dataMap.put("scanPage", fileName);
commomService.saveAssortData(dataMap);
} catch (IOException e) {
e.printStackTrace();
return ResultUtil.error("上传失败");
}
}
return ResultUtil.ok();
}
@RequestMapping(value = "saveSubmitAssortLog", method = RequestMethod.POST)
@ResponseBody
public ResultUtil saveSubmitAssortLog(@RequestBody PdfPageRequest request) {
String[] assortIdDatas = request.getAssortIdData();
String[] assortTexteData = request.getAssortTexteData();
String[] pageDatas = request.getPageData();
String patientId = request.getPatientId();
Map<String,Object> dataMap = new HashMap<>();
// for(int i = 0; i < assortIdDatas.length; i++){
// String assortId = assortIdDatas[i];
// String assortTexte = assortTexteData[i];
// int pageNum = Integer.parseInt(pageDatas[i]);
// try {
// //判断是否已有改图像,防止重复插入
// Integer isExistflag = commomService.getIsExistFileName(fileName);
// if(isExistflag == 1){
// continue;
// }
// // 存入分段数据表
// dataMap.put("patientId", patientId);
// dataMap.put("assortId", assortId);
// dataMap.put("scanPage", fileName);
// commomService.saveAssortData(dataMap);
// } catch (IOException e) {
// e.printStackTrace();
// return ResultUtil.error("上传失败");
// }
// }
return ResultUtil.ok();
}
}

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.emr.annotation.OptionalLog;
import com.emr.controller.FormTokenFlagUtil;
import com.emr.controller.JAXDynamicClientFactory;
import com.emr.dao.Archive_DetailMapper;
import com.emr.dao.CommomMapper;
import com.emr.dao.EmrComomSetMapper;
@ -37,7 +38,17 @@ import com.emr.vo.templateSearch.Emr_Modle_RelatedVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.endpoint.Client;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.tools.zip.ZipEntry;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
@ -45,13 +56,17 @@ import org.springframework.ui.Model;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.tools.zip.ZipEntry;
import java.util.stream.Collectors;
import org.apache.tools.zip.ZipOutputStream;
/**
@ -69,6 +84,9 @@ import org.apache.tools.zip.ZipOutputStream;
@Controller
@RequestMapping("template/")
public class TemplateSearchController {
@Resource
private Logger logger;
@Autowired
private Emr_CustomizeMapper customizeMapper;
@Autowired
@ -809,8 +827,15 @@ public class TemplateSearchController {
@ResponseBody
public String getApproves(HttpServletRequest request, int type) {
try {
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
user = (Power_User) currentUser;
}
String userName = user.getUserName();
List<Emr_Apply_Approve> approveList = applyApproveMapper.selectPatientIdsByUser(userName, null, type);
StringBuilder approves = new StringBuilder();
@ -864,7 +889,15 @@ public class TemplateSearchController {
@ResponseBody
public String cutomSearchTable(String selectSql,String fromTableSql,String whereSql,String orderBys,Integer page, Integer limit, HttpServletRequest request,String sortNames,String sortOrder) {
//匹配权限
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
//获取默认排序字段和排序方式
String defaultSortField = (String) request.getSession().getAttribute("defaultSortField");
String defaultSortFieldType = (String) request.getSession().getAttribute("defaultSortFieldType");
@ -1136,37 +1169,10 @@ public class TemplateSearchController {
try {
List<ScanPathVo> scanPathVos = scanPathMapper.selectScanFileByBloodPatientIds(patientIds, null, flag);
if (null != scanPathVos && !scanPathVos.isEmpty()) {
Set<ScanPathForPatientListVo> list = new LinkedHashSet<>();
Set<String> patientIdSet = new LinkedHashSet<>();
//批量添加下载记录
printOrDownLoadInfoService.SimpleInsert(scanPathVos, null, Short.valueOf("2"));
for (ScanPathVo scanPathVo : scanPathVos) {
patientIdSet.add(scanPathVo.getPatientId());
}
for (String patinetId : patientIdSet) {
ScanPathForPatientListVo vo = new ScanPathForPatientListVo();
List<String> filePaths = new ArrayList<>();
for (ScanPathVo scanPathVo : scanPathVos) {
if (scanPathVo.getPatientId().equals(patinetId)) {
vo.setName(scanPathVo.getName());
vo.setInpatientNo(scanPathVo.getInpatientNo());
vo.setSubjectNo(scanPathVo.getSubjectNo());
String disDate = scanPathVo.getDisDate();
if(!ObjectUtils.isEmpty(disDate)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
vo.setDisDate(sdf.parse(disDate));
}
String fileRealPath = scanPathVo.getFileRealPath();
if (StringUtils.isNoneBlank(fileRealPath) && new File(fileRealPath).exists()) {
filePaths.add(fileRealPath);
}
}
}
if (!filePaths.isEmpty()) {
vo.setScanPathList(filePaths);
list.add(vo);
}
}
List<ScanPathForPatientListVo> scanPathForPatientListVos = processScanPaths(scanPathVos);
Set<ScanPathForPatientListVo> list = new LinkedHashSet<>(scanPathForPatientListVos);
String zipName = "档案pdf压缩包";
downloadPdfZip(response, zipName, list, dataSource);
}
@ -1238,6 +1244,46 @@ public class TemplateSearchController {
// }
}
public List<ScanPathForPatientListVo> processScanPaths(List<ScanPathVo> scanPathVos) {
// 收集患者ID
Set<String> patientIdSet = scanPathVos.stream()
.map(ScanPathVo::getPatientId)
.collect(Collectors.toSet());
// 处理每个患者的数据
return patientIdSet.parallelStream()
.map(patinetId -> {
ScanPathForPatientListVo vo = new ScanPathForPatientListVo();
List<String> filePaths = scanPathVos.stream()
.filter(scanPathVo -> scanPathVo.getPatientId().equals(patinetId))
.peek(scanPathVo -> {
vo.setName(scanPathVo.getName());
vo.setInpatientNo(scanPathVo.getInpatientNo());
vo.setSubjectNo(scanPathVo.getSubjectNo());
String disDate = scanPathVo.getDisDate();
if (!ObjectUtils.isEmpty(disDate)) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
vo.setDisDate(sdf.parse(disDate));
} catch (ParseException e) {
e.printStackTrace();
}
}
})
.map(ScanPathVo::getFileRealPath)
.filter(StringUtils::isNoneBlank)
.filter(fileRealPath -> new File(fileRealPath).exists())
.collect(Collectors.toList());
if (!filePaths.isEmpty()) {
vo.setScanPathList(filePaths);
}
return vo;
})
.filter(vo -> vo.getScanPathList() != null && !vo.getScanPathList().isEmpty())
.collect(Collectors.toList());
}
public void createFile(File file) {
//如果文件夹不存在则创建
if (!file.exists() && !file.isDirectory()) {
@ -1340,11 +1386,12 @@ public class TemplateSearchController {
//封装下载pdf压缩包方法
private void downloadPdfZip(HttpServletResponse response, String zipName, Set<ScanPathForPatientListVo> list, String dataSource) throws UnsupportedEncodingException {
response.reset();
response.setContentType("application/zip;charset=UTF-8");
zipName = java.net.URLEncoder.encode(zipName, "UTF-8");
response.setContentType("application/zip");
response.setCharacterEncoding("UTF-8"); // 设置响应头的字符编码
zipName = URLEncoder.encode(zipName, "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + zipName + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ").zip");
String filePdfName = "";
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())){
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
for (ScanPathForPatientListVo vo : list) {
@ -1353,29 +1400,52 @@ public class TemplateSearchController {
disDate = fmt.format(vo.getDisDate());
}
List<String> scanPathList = vo.getScanPathList();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
//每个文件名
// 每个文件名
String inpatientNo = ObjectUtils.isEmpty(vo.getInpatientNo()) ? "无" : vo.getInpatientNo().trim();
String name = ObjectUtils.isEmpty(vo.getName()) ? "无" : vo.getName().trim();
if("3".equals(dataSource)){
//药学楼
filePdfName = vo.getSubjectNo().trim() + "-" + name + "_" + fmt.format(new Date());
}else{
filePdfName = inpatientNo + "-" + name + "-" + disDate.trim() + "_" + fmt.format(new Date());
if ("3".equals(dataSource)) {
// 药学楼
filePdfName = vo.getSubjectNo().trim() + "_" + name + "_" + fmt.format(new Date());
} else {
filePdfName = inpatientNo + "_" + name + "_" + disDate.trim() + "_" + fmt.format(new Date());
}
String fileName = hospitaInfo + "_" + filePdfName;
zos.putNextEntry(new ZipEntry(fileName + ".pdf"));
//合成pdf
img2PdfUtil.imageToPdfToBuffOut(out, scanPathList, emrPdfWaterSet);
try (BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(out.toByteArray()))) {
//输出
int len = 0;
byte[] buf = new byte[1024 * 1024];
while ((len = bis.read(buf, 0, buf.length)) != -1) {
zos.write(buf, 0, len);
fileName = new String(fileName.getBytes(),"ISO-8859-1");
ZipEntry zipEntry = new ZipEntry(fileName + ".pdf");
zos.putNextEntry(zipEntry);
// 使用 PipedInputStream 和 PipedOutputStream 实现流式处理
PipedInputStream pis = new PipedInputStream();
PipedOutputStream pos = new PipedOutputStream(pis);
// 创建一个线程生成 PDF 数据
Thread pdfGeneratorThread = new Thread(() -> {
try {
img2PdfUtil.imageToPdfToBuffOut(pos, scanPathList, emrPdfWaterSet);
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
} finally {
try {
pos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
});
pdfGeneratorThread.start();
// 在主线程中读取生成的 PDF 数据并写入 ZIP 文件
byte[] buffer = new byte[1024 * 1024];
int len;
while ((len = pis.read(buffer)) != -1) {
zos.write(buffer, 0, len);
}
// 关闭当前的 ZipEntry
zos.closeEntry();
// 确保生成 PDF 的线程已经完成
pdfGeneratorThread.join();
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
@ -1511,27 +1581,6 @@ public class TemplateSearchController {
emrPdfWaterSet.setIsImg(emrPdfWaterSet.getDownloadIsImg());
EmrPdfWaterSet emrPdfWaterSet1 = commomService.getEmrPdfWaterSet(emrPdfWaterSet);
imgToPdfUtil.imageToPdf(response, scanPathVos, pdfName, emrPdfWaterSet,emrPdfWaterSet1);
}else {
String fileRealPath=null;
List<CommomTree> commomTrees = archiveDetailMapper.selectPdfPathByPatient3(patientIds, assortIds);
List<String> filePaths = new ArrayList();
for (int i = 0; i < commomTrees.size(); ++i) {
fileRealPath = commomTrees.get(i).getPDFPATH();
if (StringUtils.isNoneBlank(new CharSequence[]{fileRealPath})) {
filePaths.add(fileRealPath);
}
}
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
List<ScanPathVo> scanPathVos1 = scanPathMapper.selectFilaname(patientIds);
ScanPathVo vo = scanPathVos1.get(0);
String disDate = "";
if (null != vo.getDisDate()) {
disDate = fmt.format(vo.getDisDate());
}
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
//下载文件名
String filename = vo.getInpatientNo().trim() + "-" + vo.getName().trim() + "-" + disDate.trim() + "_" + fmt.format(new Date());
Jpg2PdfUtil.mulFile2One3(response,filePaths,filename,emrPdfWaterSet);
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
@ -1545,6 +1594,7 @@ public class TemplateSearchController {
sb.append(hospitaInfo);
ScanPathVo scanPathVo = scanPathVos.get(0);
JSONObject jsonObject= (JSONObject) JSONObject.toJSON(scanPathVo);
String name = ObjectUtils.isEmpty(jsonObject.getString("name")) ? "无" : jsonObject.getString("name").trim();
List<String> patientInfoList = Arrays.asList(patientInfo.split(","));
for (String list:patientInfoList){
String contents = ObjectUtils.isEmpty(jsonObject.getString(list)) ? "无" : jsonObject.getString(list).trim();
@ -1556,7 +1606,7 @@ public class TemplateSearchController {
String formattedDate = targetFormat.format(date);
sb.append("_"+formattedDate);
}else {
sb.append("_"+contents);
sb.append("_" + contents + "_" + name);
}
}
return sb.toString();
@ -1631,6 +1681,9 @@ public class TemplateSearchController {
@RequestMapping(value = "printInfoBlood", produces = {"text/json;charset=UTF-8"}, method = RequestMethod.POST)
@ResponseBody
public void printInfoBlood(String patientIds, String assortIds, Integer typeId, String flag) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String printDate = sdf.format(new Date());
if (StringUtils.isNoneBlank(patientIds)) {
try {
if (StringUtils.isNotBlank(assortIds)) {
@ -1647,6 +1700,8 @@ public class TemplateSearchController {
List<ScanPathVo> scanPathVos = scanPathMapper.selectScanFileByBloodPatientIds(patientIds, assortIds, flag);
//批量添加打印记录
printOrDownLoadInfoService.SimpleInsert(scanPathVos, typeId, Short.valueOf("1"));
// //调用湘雅附二病历复印打印状态同步接口
// this.MedicalPrintSyncPrintStatusAction(patientIds , printDate);
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
@ -1655,6 +1710,65 @@ public class TemplateSearchController {
}
}
/**
*
*/
public void MedicalPrintSyncPrintStatusAction(String patientIds, String printDate) {
//创建连接工厂
JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
//创建客户端
Object[] objects;
Client client = dcf.createClient("http://172.16.198.250:13023/dev/openapi/health");
//合作方密钥
String partnerKey = "53fd4f5ff132528e2e071baeeb3f99a2";
try {
String stringSignTemp = "inpatientNo="+ patientIds +
"&partnerId=XYEYYHIS" +
"&printStatus=1" +
"&printTime=" + printDate +
"&serviceCode=MedicalPrintSyncPrintStatusAction" +
"&timeStamp=" + printDate +
"&" + partnerKey;
String password = MD5.KL(stringSignTemp);
//获取请求参数xml字符串
String xmlStr = getXml(patientIds,printDate,password);
objects = client.invoke("MedicalPrintSyncPrintStatusAction", xmlStr);
//应答信息
String result = objects[0].toString();
} catch (Exception e) {
e.printStackTrace();
} finally {
if(null != client) {
client.destroy();
}
}
}
public String getXml(String patientIds, String printDate , String password) {
// 1、创建document对象
Document document = DocumentHelper.createDocument();
// 2、创建根节点rss
Element requestElement = document.addElement("Request");
requestElement.addElement("serviceCode").setText("MedicalPrintSyncPrintStatusAction");
requestElement.addElement("partnerId").setText("XYEYYHIS");
requestElement.addElement("timeStamp").setText(printDate);
requestElement.addElement("password").setText(password);
requestElement.addElement("inpatientNo").setText(patientIds);
requestElement.addElement("printStatus").setText("1");
requestElement.addElement("printTime").setText(printDate);
OutputFormat format = OutputFormat.createPrettyPrint();
// 设置编码格式
format.setEncoding("UTF-8");
String xml = document.asXML();
return document.asXML();
}
/**
* @MethodName: addLockByPatientId
* @Description:

@ -175,4 +175,16 @@ public interface CommomMapper {
List<Map<String, Object>> queryImgStatistics(CommomVo commomVo);
List<Map<String, Object>> queryPeriodsStatistics(CommomVo commomVo);
void saveData(Map<Object, Object> data);
String quertIsExist(String patientID);
void updateData(Map<Object, Object> data);
String getUploadPath(String patientId);
void saveAssortData(Map<String, Object> dataMap);
Integer getIsExistFileName(String fileName);
}

@ -19,6 +19,7 @@ import com.emr.util.UploadUtil;
import com.emr.util.img2PdfUtil;
import com.emr.vo.ExportInpVo;
import com.emr.vo.User;
import com.emr.vo.commomSearch.CommomTree;
import com.emr.vo.commomSearch.CommomVo;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
@ -30,6 +31,8 @@ import org.apache.http.util.EntityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
@ -39,15 +42,19 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.imageio.ImageIO;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* @ProjectName:
@ -274,10 +281,9 @@ public class CommomService {
}
}
//脐血库显示pdf
public void showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response, HttpServletRequest request) throws Exception {
if (StringUtils.isNotBlank(patientId)) {
/*if (StringUtils.isNotBlank(patientId)) {
patientId = patientId.replace("\'", "");
//查询
if (StringUtils.isNotBlank(flag)) {
@ -291,20 +297,16 @@ public class CommomService {
root1 = commomVo.getFilePath();
}
//组织src
List<String> src = new LinkedList<>();
List<String> filePaths = new LinkedList<>();
String[] scanPageArr = scanPages.split(",");
for (int i = 0; i < scanPageArr.length; i++) {
String srcStr = "";
if (StringUtils.isNotBlank(scanPageArr[i])) {
srcStr = root1 + File.separator + scanPageArr[i];
}
src.add(srcStr);
}
List<String> filePaths = new LinkedList<>();
for (String srcs : src) {
File file = new File(srcs);
File file = new File(srcStr);
if (file.isFile()) {
filePaths.add(srcs);
filePaths.add(srcStr);
}
}
}
if (!filePaths.isEmpty()) {
@ -321,6 +323,82 @@ public class CommomService {
}
}
}
}*/
if (StringUtils.isNotBlank(patientId)) {
patientId = patientId.replace("'", "");
// 查询
if (StringUtils.isNotBlank(flag)) {
CommomVo commomVo = commomMapper.selectByPrimaryKey(patientId);
if (commomVo != null && StringUtils.isNotBlank(commomVo.getFilePath())) {
// flag = home_addr取home_addr字段path_file取home_addr字段
String root1;
if ("home_addr".equals(flag)) {
root1 = commomVo.getHomeAddr();
} else if ("file_path".equals(flag)) {
root1 = commomVo.getFilePath();
} else {
root1 = "";
}
// 组织src
ExecutorService executor = Executors.newFixedThreadPool(6); // 创建线程池
String finalPatientId = patientId;
List<String> filePaths = CompletableFuture.supplyAsync(() -> {
List<String> pdfPaths = new LinkedList<>();
String[] scanPageArr = (scanPages != null) ? scanPages.split(",") : new String[0];
for (String scanPage : scanPageArr) {
if (StringUtils.isNotBlank(scanPage)) {
String srcStr = root1 + File.separator + scanPage;
if (StringUtils.isNotBlank(srcStr)) {
File file = new File(srcStr);
if (file.isFile()) {
pdfPaths.add(srcStr);
}
}
}
}
return pdfPaths;
}, executor).exceptionally(ex -> {
ex.printStackTrace();
return Collections.emptyList(); // 返回空列表
}).join(); // 阻塞等待结果
executor.shutdown(); // 关闭线程池
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
if (user != null) {
String mapKey = user.getUserName() + "_" + finalPatientId;
request.getSession().setAttribute(mapKey, filePaths);
}
} else {
List<String> commomTrees = archiveDetailMapper.getPDFRATH(patientId, scanPages);
if (!CollectionUtils.isEmpty(commomTrees) && request != null) {
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
if (user != null) {
String mapKey = user.getUserName() + "_" + patientId;
request.getSession().setAttribute(mapKey, commomTrees);
}
}
}
}
}
}
@ -339,7 +417,15 @@ public class CommomService {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//获取reuqest
HttpServletRequest request = attributes.getRequest();
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
String text = "";
if (StringUtils.isNotBlank(user.getUserName())) {
text += " " + user.getUserName();
@ -604,11 +690,19 @@ public class CommomService {
* @param sources
* @return
*/
public List<String> selectPrintPic(HttpServletResponse response, String patientId, String rootPaths, String names, String sources, String mapKey) throws IOException {
public List<String> selectPrintPic(HttpServletResponse response, String patientId, String rootPaths, String names, String sources, String mapKey) throws IOException, ExecutionException, InterruptedException {
//获取登录用户信息
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// 从session获取用户名
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
List<String> outs = new LinkedList<>();
if (StringUtils.isNotBlank(names)) {
String[] rootPathList = rootPaths.split(",");
@ -689,7 +783,7 @@ public class CommomService {
String root = "";
String picPath = "";
//判断是否是tif图片
boolean tifFileFlag = checkTifFile(srcPath);
boolean tifFileFlag = img2PdfUtil.checkTifFile(srcPath);
if (tifFileFlag) {
//保存目录不存在新增
if (!new File(WATERTIFTOJPGPATH).isDirectory()) {
@ -746,8 +840,47 @@ public class CommomService {
}
}
return outs;
/*// 获取登录用户信息
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER");
List<String> outs = new LinkedList<>();
if (StringUtils.isNotBlank(names)) {
String[] rootPathList = rootPaths.split(",");
String[] nameList = names.split(",");
String[] sourceList = sources.split(",");
// 获取水印设置
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
// 使用 CompletableFuture 进行异步处理
List<CompletableFuture<String>> futures = IntStream.range(0, nameList.length)
.mapToObj(i -> CompletableFuture.supplyAsync(() -> {
try {
return processImagePath(rootPathList[i], nameList[i], sourceList[i], user, emrPdfWaterSet, patientId, mapKey);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}))
.collect(Collectors.toList());
// 等待所有任务完成并收集结果
for (CompletableFuture<String> future : futures) {
String result = future.get();
if (result != null) {
outs.add(result);
}
}
}
return outs;*/
}
public String processImagePath(String rootPath, String name, String source, Power_User user, EmrPdfWaterSet emrPdfWaterSet, String patientId, String mapKey) throws IOException {
return "processed_" + name; // 示例返回值
}
public List<String> selectPrintPic2(HttpServletResponse response, String patientId, String names, String sources, String mapKey) {
List<String> outs = new LinkedList<>();
@ -773,7 +906,7 @@ public class CommomService {
String root = "";
String picPath = "";
//判断是否是tif图片
boolean tifFileFlag = checkTifFile(srcPath);
boolean tifFileFlag = img2PdfUtil.checkTifFile(srcPath);
if (tifFileFlag) {
String picSrc = WATERPICPATH + patientId + File.separator;
//目录不存在则创建
@ -802,32 +935,6 @@ public class CommomService {
return outs;
}
/**
* tif
*
* @param srcPath
* @return
*/
private boolean checkTifFile(String srcPath) {
InputStream is = null;
try {
is = new FileInputStream(new File(srcPath));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] content = new byte[0];
try {
content = IOUtils.toByteArray(is);
} catch (IOException e) {
e.printStackTrace();
}
// 判断图片类型jpg jpeg png bmp编码方式是tif格式的
if (content[0] == 0x49 && content[1] == 0x49 && content[2] == 0x2A && content[3] == 0x00) {
return true;
}
return false;
}
/*private static String tifToJpg(String tifUrl, String tifToJpgRoot) {
File fileTiff = new File(tifToJpgRoot);
if (fileTiff.exists()) {
@ -981,6 +1088,8 @@ public class CommomService {
return "reloadK\\";
case "Z":
return "reloadZ\\";
case "W":
return "reloadW\\";
default:
;
}
@ -1112,9 +1221,8 @@ public class CommomService {
List<String> picNameList = Pdf2ImgUtil.pdfToPic(saveFileName, pdfName, "jpg", commomVo.getFilePath());
if (picNameList != null && picNameList.size() > 0) {
List<T_Scan_Assort> insertList = new ArrayList<>();
T_Scan_Assort t_scan_assort = null;
T_Scan_Assort t_scan_assort;
for (int k = 0; k < picNameList.size(); k++) {
t_scan_assort = new T_Scan_Assort();
t_scan_assort.setPatientId(commomVo.getPatientId());
@ -1131,10 +1239,12 @@ public class CommomService {
insertList.add(t_scan_assort);
}
//批量新增图片记录
if(!CollectionUtils.isEmpty(insertList)){
scanAssortService.SimpleInsert(insertList);
}
}
}
}
ImportExcelEntity excelEntity = null;
if (exportInpVoList != null && exportInpVoList.size() > 0) {
@ -1153,4 +1263,16 @@ public class CommomService {
return ResultUtil.error("费用清单上传失败");
}
}
public String getUploadPath(String patientId) {
return commomMapper.getUploadPath(patientId);
}
public void saveAssortData(Map<String, Object> dataMap) {
commomMapper.saveAssortData(dataMap);
}
public Integer getIsExistFileName(String fileName) {
return commomMapper.getIsExistFileName(fileName);
}
}

@ -7,9 +7,11 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
@ -39,7 +41,15 @@ public class LogServiceImpl implements LogService {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
// 从session获取用户名
Power_User user = (Power_User)request.getSession().getAttribute("CURRENT_USER");
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
String username = user.getUserName();
log.setCreater(username);
// 获取系统当前时间

@ -16,9 +16,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
@ -51,7 +53,16 @@ public class PrintOrDownLoadInfoService {
//组织批量插入集合
List<EmrPrintDownloadInfo> batchInsertList = new ArrayList<>();
//获取登录者用户名
Power_User user = (Power_User)((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getSession().getAttribute("CURRENT_USER");
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
//获取格式化日期
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//遍历主键组织批量插入集合

@ -10,7 +10,9 @@ import com.emr.vo.emrType.EmrTypeFeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -38,7 +40,15 @@ public class EmrTypeServiceImpl implements EmrTypeService {
private Emr_Type_RelatedMapper emrTypeRelatedMapper;
@Override
public List<Emr_Type> selectAllByCreater(Integer isEffective, HttpServletRequest request) {
Power_User user = (Power_User)request.getSession().getAttribute("CURRENT_USER");
Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if(ObjectUtils.isEmpty(currentUser)){
ServletContext context = request.getServletContext();
user = (Power_User)context.getAttribute("CURRENT_USER");
}else{
//查询通过审批且未过期的patientId集合
user = (Power_User) currentUser;
}
String userName = user.getUserName();
Integer roleId = user.getRoleId();
//系统管理员全查

@ -65,6 +65,26 @@ public class T_Scan_AssortServiceImpl implements T_Scan_AssortService {
@Override
public void SimpleInsert(List<T_Scan_Assort> list) {
if (!CollectionUtils.isEmpty(list)) {
// 查询表列数
int colCount = commomMapper.selectColByTableName("t_scan_assort");
// 每条记录的参数数量等于列数,假设每条记录有 colCount 个参数
// 最大参数数为 2100因此每批次插入的记录数为 2100 / colCount
int simpleInsertCount = 1600 / colCount;
List<T_Scan_Assort> scanAssorts = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
// 添加到临时列表
scanAssorts.add(list.get(i));
// 当临时列表达到最大批次大小或到达最后一个元素时,进行插入
if ((i + 1) % simpleInsertCount == 0 || i == list.size() - 1) {
System.out.println("Batch insert: {} records--------- " + scanAssorts.size());
scanAssortMapper.SimpleInsert(scanAssorts);
scanAssorts.clear(); // 清空临时列表
}
}
}
/*if (!CollectionUtils.isEmpty(list)) {
//根据字段多少批量新增
///查询表列数
int colCount = commomMapper.selectColByTableName("t_scan_assort");
@ -81,7 +101,7 @@ public class T_Scan_AssortServiceImpl implements T_Scan_AssortService {
scanAssortMapper.SimpleInsert(scanAssorts);
}
}
}
}*/
}
@Override
@ -271,6 +291,8 @@ public class T_Scan_AssortServiceImpl implements T_Scan_AssortService {
return "reloadK\\";
case "Z":
return "reloadZ\\";
case "W":
return "reloadW\\";
default:
;
}

@ -84,10 +84,19 @@ public class ExportExcelUtil {
sheetNum = 1;
}
int cpuCores = Runtime.getRuntime().availableProcessors();
int threadPoolSize = 2 * cpuCores;
int corePoolSize = Runtime.getRuntime().availableProcessors();
int maximumPoolSize = 2 * corePoolSize;
long keepAliveTime = 60L; // 空闲线程存活时间,单位秒
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
ExecutorService executor = new ThreadPoolExecutor(
corePoolSize,
maximumPoolSize,
keepAliveTime,
TimeUnit.SECONDS,
workQueue
);
ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize);
CompletionService<HSSFWorkbook> completionService = new ExecutorCompletionService<>(executor);
List<Future<HSSFWorkbook>> futures = new ArrayList<>();

@ -30,7 +30,7 @@ public class HttpClientTool {
public static final String CHARSET = "UTF-8";
// 采用静态代码块初始化超时时间配置再根据配置生成默认httpClient对象
static {
RequestConfig config = RequestConfig.custom().setConnectTimeout(60000).setSocketTimeout(15000).build();
RequestConfig config = RequestConfig.custom().setConnectTimeout(360000).setSocketTimeout(360000).build();
httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
}

@ -42,7 +42,7 @@ public class HttpClientUtils {
static {
// 设置请求和传输超时时间
requestConfig = RequestConfig.custom().setSocketTimeout(2000).setConnectTimeout(2000).build();
requestConfig = RequestConfig.custom().setSocketTimeout(360000).setConnectTimeout(360000).build();
}
/**

@ -10,8 +10,10 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
public class Pdf2ImgUtil {
/**
* 使pdfboxpdf
*
@ -55,7 +57,76 @@ public class Pdf2ImgUtil {
}
}
}
/*int corePoolSize = Runtime.getRuntime().availableProcessors();
int maximumPoolSize = 4 * corePoolSize;
long keepAliveTime = 60L; // 空闲线程存活时间,单位秒
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
ExecutorService executor = new ThreadPoolExecutor(
corePoolSize,
maximumPoolSize,
keepAliveTime,
TimeUnit.SECONDS,
workQueue
);
// 记录开始时间
long startTime = System.currentTimeMillis();
try {
// 将文件地址和文件名拼接成路径 注意:线上环境不能使用\\拼接
File file = new File(fileAddress + File.separator + filename + ".pdf");
List<String> picNameList = new ArrayList<>();
PDDocument doc = null;
try {
// 写入文件
doc = PDDocument.load(file);
PDFRenderer renderer = new PDFRenderer(doc);
int pageCount = doc.getNumberOfPages();
List<Future<Void>> futures = new ArrayList<>();
for (int i = 0; i < pageCount; i++) {
int pageIndex = i;
Future<Void> future = executor.submit(() -> {
// dpi为150越高越清晰转换越慢
BufferedImage image = renderer.renderImageWithDPI(pageIndex, 150); // Windows native DPI
// 将图片写出到该路径下
ImageIO.write(image, type, new File(picPath + File.separator + "FY_" + filename + "_" + String.format("%04d", pageIndex + 1) + "." + type));
picNameList.add("FY_" + filename + "_" + String.format("%04d", pageIndex + 1) + "." + type);
return null;
});
futures.add(future);
}
// 等待所有任务完成
for (Future<Void> future : futures) {
future.get();
}
long endTime = System.currentTimeMillis();
long duration = (endTime - startTime) / 1000;
System.out.println("费用清单上传图片处理总耗时: " + duration + " 秒");
return picNameList;
} catch (IOException | InterruptedException | ExecutionException e) {
e.printStackTrace();
return null;
} finally {
if (doc != null) {
try {
doc.close();
} catch (IOException e) {
throw new RuntimeException("关闭PDDocument时发生错误", e);
}
}
// 关闭线程池
executor.shutdown();
}
} catch (Exception e) {
e.printStackTrace();
return null;
}*/
}
public static void main(String[] args) {

@ -8,8 +8,8 @@ import com.itextpdf.text.pdf.PdfWriter;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.pdf.*;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -19,8 +19,9 @@ import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
import java.util.concurrent.*;
/**
* @ProjectName:
@ -37,6 +38,7 @@ import java.util.List;
public class img2PdfUtil {
final private static float A4_weight = 595; //标准A4的宽
final private static float A4_height = 842; //标准A4的高
final private static Map<String, Image> imageCache = new HashMap<>();
public static void imageToPdf(HttpServletResponse response, List<String> filePaths, String pdfName, EmrPdfWaterSet pdfWaterSet,EmrPdfWaterSet pdfWaterSet1) {
Document document = new Document(PageSize.A4, 0, 0, 0, 0); //创建文档容器
@ -78,9 +80,40 @@ public class img2PdfUtil {
}
}
public static void imageToPdf(HttpServletResponse response, List<String> filePaths, String pdfName, EmrPdfWaterSet pdfWaterSet,EmrPdfWaterSet pdfWaterSet1, int page) {
Document document = new Document(PageSize.A4, 0, 0, 0, 0); //创建文档容器
ByteArrayOutputStream bos = new ByteArrayOutputStream();
//是否启用水印
Short effective = pdfWaterSet.getEffective();
Short isImg = pdfWaterSet.getIsImg();
try {
if (effective == 1 || isImg == 1) {
PdfWriter.getInstance(document, bos); //创建编写器PDF类型
} else {
PdfWriter.getInstance(document, response.getOutputStream()); //创建编写器PDF类型
}
//图片合成pdf
imgToPdf(document, filePaths, page);
if (effective == 1 || isImg == 1) {
addWaterMark(bos, response, pdfWaterSet.getUpOrUnder(), pdfWaterSet.getTransparent(),
pdfWaterSet.getText(), pdfWaterSet.getTextX(), pdfWaterSet.getTextY(),
pdfWaterSet.getTextColor(), pdfWaterSet.getTextSize(), pdfWaterSet.getTextRotation(),
pdfWaterSet.getEffective(), pdfWaterSet.getIsImg(), pdfWaterSet.getImgFile(), pdfWaterSet.getImgWidth(),
pdfWaterSet.getImgHeight(), pdfWaterSet.getImgX(), pdfWaterSet.getImgY(),pdfWaterSet1.getText());
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
} finally {
try {
bos.flush();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
document.close();
}
}
public static void imageToPdfUserEffective(HttpServletResponse response, List<String> filePaths, String pdfName, EmrPdfWaterSet pdfWaterSet) {
Document document = new Document(PageSize.A4, 0, 0, 0, 0); //创建文档容器
@ -202,29 +235,35 @@ public class img2PdfUtil {
}
}
//脐血库下载批量
public static void imageToPdfToBuffOut(ByteArrayOutputStream bos, List<String> filePaths, EmrPdfWaterSet pdfWaterSet) throws Exception {
public static void imageToPdfToBuffOut(PipedOutputStream pos, List<String> filePaths, EmrPdfWaterSet pdfWaterSet) throws Exception {
// 实例化图牿
Document document = new Document(PageSize.A4, 30, 30, 30, 30); //创建文档容器
Document document = new Document(PageSize.A4, 0, 0, 0, 0); //创建文档容器
//是否启用水印
PdfWriter.getInstance(document, bos);
PdfWriter.getInstance(document, pos);
try {
//图片合成pdf
imgToPdf(document, filePaths);
//是否启用水印
Short effective = pdfWaterSet.getDownloadEffective();
/*Short effective = pdfWaterSet.getDownloadEffective();
Short isImg = pdfWaterSet.getDownloadIsImg();
if (effective == 1 || isImg == 1) {
addWaterMark(bos, null, pdfWaterSet.getUpOrUnder(), pdfWaterSet.getTransparent(),
pdfWaterSet.getText(), pdfWaterSet.getTextX(), pdfWaterSet.getTextY(),
pdfWaterSet.getTextColor(), pdfWaterSet.getTextSize(), pdfWaterSet.getTextRotation(),
effective, isImg, pdfWaterSet.getImgFile(), pdfWaterSet.getImgWidth(),
pdfWaterSet.getImgHeight(), pdfWaterSet.getImgX(), pdfWaterSet.getImgY());
}
}*/
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
} finally {
try {
if (pos != null) {
pos.flush();
pos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
document.close();
}
}
@ -364,68 +403,202 @@ public class img2PdfUtil {
}
}
//图片合成pdf
private static void imgToPdf(Document document, List<String> filePaths) throws Exception {
public static void imgToPdf(Document document, List<String> filePaths, int imagesPerPage) {
long startTime = System.currentTimeMillis();
document.open();
float percent = 100;
BufferedImage bufferedImage = null;
Image img;
int imageCount = 0;
for (String filePath : filePaths) {
try {
File file = new File(filePath);
if (file.isFile()) {
Image img = Image.getInstance(filePath);
try (FileInputStream fis = new FileInputStream(filePath)) {
if(checkTifFile(filePath)){
bufferedImage = ImageIO.read(fis);
img = Image.getInstance(bufferedImage, null);
}else{
img = Image.getInstance(filePath);
}
float w = img.getWidth();
float h = img.getHeight();
// 计算缩放比例,基于宽度和高度中较大的值
float scaleWidth = A4_weight / w;
float scaleHeight = A4_height / h;
percent = Math.min(scaleWidth, scaleHeight) * 100;
float percent = Math.min(scaleWidth, scaleHeight) * 100;
img.setAlignment(com.lowagie.text.Image.ALIGN_CENTER);
img.setAlignment(Image.ALIGN_CENTER);
img.scalePercent(percent);
//添加图像
document.add(img);
imageCount++;
// 检查是否需要换页
if (imageCount % imagesPerPage == 0) {
document.newPage();
}
if (bufferedImage != null){
// 关闭资源
bufferedImage.flush();
}
} catch (Exception e) {
throw new RuntimeException("Error processing file: " + filePath, e);
System.err.println("文件加载失败: " + filePath + ", " + e.getMessage());
}
}
long endTime = System.currentTimeMillis();
long duration = (endTime - startTime) / 1000;
System.out.println("图像合成中耗时: " + duration + " 秒");
document.close();
// document.open(); //打开容器
// float percent = 100;
// float w, h;
// for (String filePath : filePaths) {
// try {
// File file = new File(filePath);
// if (file.isFile()) {
// Image img = Image.getInstance(filePath);
// /*处理图片缩放比例*/
// w = img.getWidth();
// h = img.getHeight();
// if ((w > A4_weight) && (h < A4_height)) {
// percent = (A4_weight * 100) / w;
// } else if ((w < A4_weight) && (h > A4_height)) {
// percent = (A4_height * 100) / h;
// } else if ((w > A4_weight) && (h > A4_height)) {
//
// percent = (A4_weight * 100) / w;
// h = (h * percent) / 100;
// if (h > A4_height) {
// percent = (A4_height * 100) / h;
// }
// }
// img.setAlignment(com.lowagie.text.Image.ALIGN_CENTER);
// if(percent != 100){
// img.scaleAbsolute(A4_weight,A4_height);
// }else{
// img.scalePercent(percent);
// }
// document.add(img);
// }
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
// document.close(); //关闭容器
}
public static void imgToPdf(Document document, List<String> filePaths) {
document.open();
BufferedImage bufferedImage = null;
Image img;
for (String filePath : filePaths) {
try (FileInputStream fis = new FileInputStream(filePath)) {
if(checkTifFile(filePath)){
bufferedImage = ImageIO.read(fis);
img = Image.getInstance(bufferedImage, null);
}else{
img = Image.getInstance(filePath);
}
float w = img.getWidth();
float h = img.getHeight();
// 计算缩放比例,基于宽度和高度中较大的值
float scaleWidth = A4_weight / w;
float scaleHeight = A4_height / h;
float percent = Math.min(scaleWidth, scaleHeight) * 100;
img.setAlignment(Image.ALIGN_CENTER);
img.scalePercent(percent);
//添加图像
document.add(img);
if (bufferedImage != null){
// 关闭资源
bufferedImage.flush();
}
} catch (Exception e) {
System.err.println("文件加载失败: " + filePath + ", " + e.getMessage());
}
}
document.close();
/*// 记录开始时间
long startTime = System.currentTimeMillis();
int corePoolSize = Runtime.getRuntime().availableProcessors();
int maximumPoolSize = 4 * corePoolSize;
long keepAliveTime = 60L; // 空闲线程存活时间,单位秒
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
ExecutorService executor = new ThreadPoolExecutor(
corePoolSize,
maximumPoolSize,
keepAliveTime,
TimeUnit.SECONDS,
workQueue
);
document.open();
// 使用 CompletableFuture 处理文件路径,并确保按顺序添加到文档
CompletableFuture<Void> allFutures = CompletableFuture.completedFuture(null);
for (int i = 0; i < filePaths.size(); i++) {
String filePath = filePaths.get(i);
int finalI = i;
allFutures = allFutures.thenCompose(v ->
CompletableFuture.supplyAsync(() -> processImage(filePath), executor)
.thenAccept(img -> addImageToDocument(document, img, finalI))
);
}
// 等待所有任务完成
try {
allFutures.get();
} catch (Exception e) {
System.err.println("文件加载失败: " + filePaths + ", " + e.getMessage());
}
long endTime = System.currentTimeMillis();
long duration = (endTime - startTime) / 1000;
System.out.println("图片加载总耗时: " + duration + " 秒");
document.close();
executor.shutdown();*/
}
public static Image processImage(String filePath) {
// 检查缓存
if (imageCache.containsKey(filePath)) {
return imageCache.get(filePath);
}
BufferedImage bufferedImage = null;
Image img = null;
try (FileInputStream fis = new FileInputStream(filePath)) {
if(checkTifFile(filePath)){
bufferedImage = ImageIO.read(fis);
img = Image.getInstance(bufferedImage, null);
}else{
img = Image.getInstance(filePath);
}
float w = img.getWidth();
float h = img.getHeight();
// 计算缩放比例,基于宽度和高度中较大的值
float scaleWidth = A4_weight / w;
float scaleHeight = A4_height / h;
float percent = Math.min(scaleWidth, scaleHeight) * 100;
img.setAlignment(Image.ALIGN_CENTER);
img.scalePercent(percent);
if (bufferedImage != null){
// 关闭资源
bufferedImage.flush();
}
// 缓存处理后的图像
imageCache.put(filePath, img);
} catch (Exception e) {
System.err.println("文件加载失败: " + filePath + ", " + e.getMessage());
}
return img;
}
public static synchronized void addImageToDocument(Document document, Image img, int index) {
try {
if (img != null) {
document.add(img);
}
} catch (Exception e) {
throw new RuntimeException("添加图像到document失败图像序号为" + index, e);
}
}
/**
* tif
*
* @param srcPath
* @return
*/
public static boolean checkTifFile(String srcPath) {
try (InputStream is = new FileInputStream(new File(srcPath))) {
byte[] content = IOUtils.toByteArray(is);
return content.length >= 4 &&
content[0] == 0x49 && content[1] == 0x49 &&
content[2] == 0x2A && content[3] == 0x00;
} catch (IOException e) {
System.err.println("Error reading file: " + srcPath + ", " + e.getMessage());
return false;
}
}
//图片合成pdf
@ -572,14 +745,14 @@ public class img2PdfUtil {
reader.close();
}
}
/*public static void addWaterMark(ByteArrayOutputStream bos, HttpServletResponse response, int upOrUnder, float transparent, String text, int textX, int textY,
public static void addWaterMark(ByteArrayOutputStream bos, HttpServletResponse response, int upOrUnder, float transparent, String text, int textX, int textY,
String textColor, int textSize, int textRotation, Short effective, Short isImg,
String imgFile, int imgWidth, int imgHeight, int imgX, int imgY) {
String imgFile, int imgWidth, int imgHeight, int imgX, int imgY,String text1) {
PdfReader reader = null;
PdfStamper stamper = null;
try {
reader = new PdfReader(bos.toByteArray());
bos.reset(); // 重置 bos以便 PdfStamper 可以写入
// 加完水印的文件
if (null != response) {
stamper = new PdfStamper(reader, response.getOutputStream());
@ -588,13 +761,12 @@ public class img2PdfUtil {
}
// 设置字体
BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
// PDF总页数
int total = reader.getNumberOfPages() + 1;
// 循环对每页插入水印
PdfContentByte content;
PdfGState gs = new PdfGState();
// PDF总页数
int total = reader.getNumberOfPages();
for (int i = 1; i <= total; i++) {
for (int i = 1; i < total; i++) {
//upOrUnder = 1为在文本之上
if (upOrUnder == 1) {
// 水印在之前文本之上
@ -648,6 +820,32 @@ public class img2PdfUtil {
// 底部水印
content.endText();
}
if(StringUtils.isNotBlank(text1)){
content.beginText();
//16进制颜色转color
Color color = toColorFromString(textColor);
content.setColorFill(color);
// 设置字体及字号
content.setFontAndSize(font, textSize);
// 设置起始位置
content.setTextMatrix(textX, textY);
// 中间水印
content.showTextAligned(Element.ALIGN_LEFT, text1, textX, textY - 100, textRotation);
// 底部水印
content.endText();
//第二水印
content.beginText();
//16进制颜色转color
content.setColorFill(color);
// 设置字体及字号
content.setFontAndSize(font, textSize);
// 设置起始位置
content.setTextMatrix(textX, textY);
// 中间水印
content.showTextAligned(Element.ALIGN_LEFT, text, textX, textY, textRotation);
// 底部水印
content.endText();
}
}
} catch (IOException | DocumentException e) {
ExceptionPrintUtil.printException(e);
@ -664,11 +862,7 @@ public class img2PdfUtil {
reader.close();
}
}
}*/
public static void addWaterMark(ByteArrayOutputStream bos, HttpServletResponse response, int upOrUnder, float transparent, String text, int textX, int textY,
String textColor, int textSize, int textRotation, Short effective, Short isImg,
String imgFile, int imgWidth, int imgHeight, int imgX, int imgY,String text1) {
PdfReader reader = null;
/*PdfReader reader = null;
PdfStamper stamper = null;
try {
reader = new PdfReader(bos.toByteArray());
@ -780,7 +974,7 @@ public class img2PdfUtil {
if (null != reader) {
reader.close();
}
}
}*/
}
private static void addWaterMarkFont(ByteArrayOutputStream bos, int upOrUnder, float transparent, String text, int textX, int textY,
@ -882,7 +1076,7 @@ public class img2PdfUtil {
* @param colorStr 16
* @return Color
*/
private static Color toColorFromString(String colorStr) {
public static Color toColorFromString(String colorStr) {
int r = Integer.valueOf(colorStr.substring(1, 3), 16);
int g = Integer.valueOf(colorStr.substring(3, 5), 16);
int b = Integer.valueOf(colorStr.substring(5, 7), 16);

@ -1,23 +1,23 @@
package com.emr.util;
import com.emr.entity.emrPdfWaterSet.EmrPdfWaterSet;
import com.emr.vo.commomSearch.ScanPathVo;
import com.itextpdf.text.*;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.*;
import com.twelvemonkeys.imageio.metadata.tiff.IFD;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.net.URLEncoder;
import java.util.List;
import static com.emr.util.img2PdfUtil.addWaterMark;
/**
* @ClassName imgToPdfUtil
@ -28,8 +28,13 @@ import static com.emr.util.img2PdfUtil.addWaterMark;
*/
public class imgToPdfUtil {
//标签顺序
private static int outNum = 1;
private static int pageIndex = 0;
private static String lastOutline = null; //上一个目录名称
private static boolean outFlag = true;//是否增加标签
public static void imageToPdf(HttpServletResponse response, List<ScanPathVo> scanPathVos, String pdfName, EmrPdfWaterSet pdfWaterSet, EmrPdfWaterSet pdfWaterSet1) {
/*public static void imageToPdf(HttpServletResponse response, List<ScanPathVo> scanPathVos, String pdfName, EmrPdfWaterSet pdfWaterSet, EmrPdfWaterSet pdfWaterSet1) throws IOException {
Document document = new Document(PageSize.A4, 0, 0, 0, 0); //创建文档容器
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PdfWriter writer;
@ -63,8 +68,170 @@ public class imgToPdfUtil {
}
document.close();
}
}*/
public static void imageToPdf(HttpServletResponse response, List<ScanPathVo> scanPathVos, String pdfName, EmrPdfWaterSet pdfWaterSet, EmrPdfWaterSet pdfWaterSet1) throws IOException {
Document document = new Document(PageSize.A4, 0, 0, 0, 0); // 创建文档容器
ServletOutputStream out = response.getOutputStream();
PdfWriter writer;
outNum = 1;
pageIndex = 0;
try {
writer = PdfWriter.getInstance(document, out); // 创建编写器PDF类型
pdfName = URLEncoder.encode(pdfName, "UTF-8");
response.reset();
response.setCharacterEncoding("utf-8");
response.setContentType("application/pdf"); // 设置正确的内容类型
response.setHeader("Content-Disposition", "attachment; filename=" + pdfName + ".pdf");
document.open();
for (ScanPathVo scanPathVo : scanPathVos) {
imgToPdf(document, writer, scanPathVo, pdfWaterSet, pdfWaterSet1.getText());
pageIndex++;
out.flush();
}
document.close();
} catch (Exception e) {
// 记录详细的异常信息
ExceptionPrintUtil.printException(e);
e.printStackTrace();
// 响应客户端错误信息
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.getWriter().write("生成PDF文件时发生错误: " + e.getMessage());
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
//图片合成pdf增加目录
public static void imgToPdf(Document document, PdfWriter writer, ScanPathVo scanPathVos, EmrPdfWaterSet pdfWaterSet, String userText) throws Exception {
PdfContentByte cb = writer.getDirectContent();
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 12);
cb.beginText();
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "目录", 300, 780, 0);
cb.endText();
// 创建目录
PdfOutline root = cb.getRootOutline();
float percent = 100;
// 添加图片到PDF
String assortName = scanPathVos.getAssortName();
if(!ObjectUtils.isEmpty(assortName)){
if (StringUtils.isNotBlank(lastOutline) && lastOutline.equals(assortName)) {
outFlag = false;
}
if (StringUtils.isBlank(lastOutline)) {
lastOutline = assortName;
outFlag=true;
}
if (!lastOutline.equals(assortName)){
lastOutline = assortName;
outFlag=true;
}
}
String imagePath = scanPathVos.getFileRealPath();
if(imagePath.contains("/mnt/share")){
imagePath = imagePath.replace("\\", "/");
}
Image image = Image.getInstance(imagePath);
float w = image.getWidth();
float h = image.getHeight();
// 计算缩放比例,基于宽度和高度中较大的值
float scaleWidth = PageSize.A4.getWidth() / w;
float scaleHeight = PageSize.A4.getHeight() / h;
percent = Math.min(scaleWidth, scaleHeight) * 100;
image.setAlignment(image.MIDDLE);
image.scalePercent(percent);
// 创建新页面并添加图片
if (pageIndex != 0) {
document.newPage();
}
// 创建新页面并添加图片
document.add(image);
//添加水印
addImageWaterMark(image, cb, pdfWaterSet, userText);
if (outFlag) {
//目录跳转页面内容设置。
PdfAction action = PdfAction.gotoLocalPage(pageIndex + 1, new PdfDestination(PdfDestination.FIT), writer);
//标题目录
String title = outNum + "." + scanPathVos.getAssortName();
new PdfOutline(root, action, title, false);
outNum++;
}
}
public static void addImageWaterMark(Image image, PdfContentByte cb, EmrPdfWaterSet pdfWaterSet, String userText) throws Exception {
// 添加图像水印
if (pdfWaterSet.getIsImg() == 1) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String tomcatPath = request.getSession().getServletContext().getRealPath("/");
String imgStr = tomcatPath + "static\\pdfWaterSet\\upload\\" + pdfWaterSet.getImgFile();
Image watermarkImg;
if (StringUtils.isNotBlank(imgStr) && new File(imgStr).isFile()) {
watermarkImg = Image.getInstance(imgStr);
//位置
image.setAbsolutePosition(pdfWaterSet.getImgX(), pdfWaterSet.getImgY());
// 设置图片的显示大小
image.scaleToFit(pdfWaterSet.getImgWidth(), pdfWaterSet.getImgHeight());
cb.addImage(watermarkImg);
}
}
// 添加文字水印
if (pdfWaterSet.getEffective() == 1) {
PdfGState gstate = new PdfGState();
gstate.setFillOpacity(pdfWaterSet.getTransparent()); // 设置透明度
cb.saveState();
cb.setGState(gstate);
cb.beginText();
// 设置字体
BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
cb.setFontAndSize(font, pdfWaterSet.getTextSize());
cb.setTextMatrix(pdfWaterSet.getTextX(), pdfWaterSet.getTextY());
cb.setColorFill(parseColor(pdfWaterSet.getTextColor()));
cb.showTextAligned(Element.ALIGN_LEFT, pdfWaterSet.getText(), pdfWaterSet.getTextX(), pdfWaterSet.getTextY(), pdfWaterSet.getTextRotation()); // 水印文本、位置和旋转角度
cb.endText();
cb.restoreState();
}
//用户水印
if (pdfWaterSet.getUserEffective() == 1) {
PdfGState gstate = new PdfGState();
gstate.setFillOpacity(pdfWaterSet.getTransparent()); // 设置透明度
cb.saveState();
cb.setGState(gstate);
cb.beginText();
BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
cb.setFontAndSize(font, pdfWaterSet.getTextSize());
cb.setTextMatrix(pdfWaterSet.getTextX(), pdfWaterSet.getTextY());
cb.setColorFill(parseColor(pdfWaterSet.getTextColor()));
cb.showTextAligned(Element.ALIGN_LEFT, userText, pdfWaterSet.getTextX(), pdfWaterSet.getTextY() - 100, pdfWaterSet.getTextRotation()); // 水印文本、位置和旋转角度
cb.endText();
cb.restoreState();
}
}
public static BaseColor parseColor(String colorStr) {
if (colorStr.startsWith("#")) {
colorStr = colorStr.substring(1);
}
int r = Integer.parseInt(colorStr.substring(0, 2), 16);
int g = Integer.parseInt(colorStr.substring(2, 4), 16);
int b = Integer.parseInt(colorStr.substring(4, 6), 16);
return new BaseColor(r, g, b);
}
//图片合成pdf增加目录
public static void imgToPdf(Document document, PdfWriter writer, List<ScanPathVo> scanPathVos) throws Exception {
@ -116,7 +283,10 @@ public class imgToPdfUtil {
image.setAlignment(image.MIDDLE);
image.scalePercent(percent);
// 创建新页面并添加图片
//document.newPage();
if (i != 0) {
document.newPage();
}
// 创建新页面并添加图片
document.add(image);
if (outFlag) {
//目录跳转页面内容设置。
@ -128,5 +298,107 @@ public class imgToPdfUtil {
}
}
document.close(); //关闭容器
/*final String[] lastOutline = {null}; // 上一个目录名称
final boolean[] outFlag = {true}; // 是否增加标签
final Integer[] outNum = {1}; // 标签顺序
final float[] percent = {100};
PdfContentByte cb = writer.getDirectContent();
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 12);
cb.beginText();
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "目录", 300, 780, 0);
cb.endText();
// 创建根目录
PdfOutline root = cb.getRootOutline();
// 创建线程池
int corePoolSize = Runtime.getRuntime().availableProcessors();
int maximumPoolSize = 4 * corePoolSize;
long keepAliveTime = 60L; // 空闲线程存活时间,单位秒
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
ExecutorService executor = new ThreadPoolExecutor(
corePoolSize,
maximumPoolSize,
keepAliveTime,
TimeUnit.SECONDS,
workQueue
);
// 使用 CompletableFuture 处理文件路径,并确保按顺序添加到文档
CompletableFuture<Void> allFutures = CompletableFuture.completedFuture(null);
for (int i = 0; i < scanPathVos.size(); i++) {
ScanPathVo scanPathVo = scanPathVos.get(i);
int finalI = i;
allFutures = allFutures.thenCompose(v ->
CompletableFuture.supplyAsync(() -> processImage(scanPathVo), executor)
.thenAccept(img -> addImageToDocument(document, img, finalI, lastOutline, outFlag, outNum, root, writer, scanPathVos))
);
}
// 等待所有任务完成
allFutures.join();
// 关闭线程池
executor.shutdown();*/
}
public static Image processImage(ScanPathVo scanPathVo) {
try {
String imagePath = scanPathVo.getFileRealPath();
if (imagePath.contains("/mnt/share")) {
imagePath = imagePath.replace("\\", "/");
}
Image image = Image.getInstance(imagePath);
float w = image.getWidth();
float h = image.getHeight();
// 计算缩放比例,基于宽度和高度中较大的值
float scaleWidth = PageSize.A4.getWidth() / w;
float scaleHeight = PageSize.A4.getHeight() / h;
float percent = Math.min(scaleWidth, scaleHeight) * 100;
image.setAlignment(image.MIDDLE);
image.scalePercent(percent);
return image;
} catch (IOException | BadElementException e) {
e.printStackTrace();
throw new RuntimeException("Error processing image", e);
}
}
public static void addImageToDocument(Document document, Image image, int pageIndex, String[] lastOutline, boolean[] outFlag, Integer[] outNum, PdfOutline root, PdfWriter writer, List<ScanPathVo> scanPathVos) {
try {
synchronized (document) {
document.add(image);
}
String assortName = scanPathVos.get(pageIndex).getAssortName();
if (!ObjectUtils.isEmpty(assortName)) {
if (StringUtils.isNotBlank(lastOutline[0]) && lastOutline[0].equals(assortName)) {
outFlag[0] = false;
}
if (StringUtils.isBlank(lastOutline[0])) {
lastOutline[0] = assortName;
outFlag[0] = true;
}
if (!lastOutline[0].equals(assortName)) {
lastOutline[0] = assortName;
outFlag[0] = true;
}
}
if (outFlag[0]) {
// 目录跳转页面内容设置。
PdfAction action = PdfAction.gotoLocalPage(pageIndex + 1, new PdfDestination(PdfDestination.FIT), writer);
// 标题目录
String title = outNum[0] + "." + assortName;
new PdfOutline(root, action, title, false);
outNum[0]++;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -25,7 +25,7 @@ public class Msg {
public static Msg success(){
Msg result=new Msg();
result.setCode(100);
result.setCode(200);
result.setMsg("success");
return result;
}
@ -41,7 +41,7 @@ public class Msg {
public static Msg successData(Object data){
Msg result=new Msg();
result.setCode(100);
result.setCode(200);
result.setMsg("success");
result.setData(data);
return result;
@ -51,7 +51,7 @@ public class Msg {
public static Msg fail(){
Msg result=new Msg();
result.setCode(200);
result.setCode(500);
result.setMsg("fail");
return result;
}
@ -60,7 +60,7 @@ public class Msg {
public static Msg fail(String msg){
Msg result=new Msg();
result.setCode(200);
result.setCode(500);
result.setMsg(msg);
return result;
}

@ -54,7 +54,7 @@
</bean>
<bean id="salve" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}"/> <!--数据库连接驱动-->
<property name="driverClassName" value="${jdbc.driver2}"/> <!--数据库连接驱动-->
<property name="url" value="${jdbc.url2}"/> <!--数据库地址-->
<property name="username" value="${jdbc.username2}"/> <!--用户名-->
<property name="password" value="${jdbc.password2}"/> <!--密码-->

@ -1,9 +1,9 @@
#power\u6743\u9650\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934
POWER_IP =localhost
POWER_URLHEAD = http://localhost:8081/power
POWER_URLHEAD = http://localhost:8080/power
POWER_JSPHEAD = localhost
POWER_JSP = http://localhost:8081/power
POWER_JSP = http://localhost:8080/power
#\u672C\u8EAB\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934
EMR_RECORD_JSP = http://localhost:8081/emr_record
@ -17,7 +17,7 @@ STR_SPLIT = *^:|,.
#\u65E5\u5FD7\u4FDD\u7559\u5929\u6570
log.days = 180
pdfWater = \u6F6E\u5DDE\u5E02\u4EBA\u6C11\u533B\u9662
pdfWater = \u5e7f\u4e1c\u7701\u005f\u5e7f\u5dde\u5e02\u5929\u6cb3\u4eba\u6c11\u533b\u9662
#session\u8FC7\u671F\u65F6\u95F4ms
TOKEN_EXPIRE_TIME = 3600000
@ -43,7 +43,9 @@ applyApproveFlag =0
#//?????
initialization =0
export_pdf_hospital_info =\u6E58\u96C5\u533B\u9662
export_pdf_hospital_info = \u5e7f\u4e1c\u7701\u005f\u6e5b\u6c5f\u5e02\u005f\u9042\u6eaa\u53bf\u4eba\u6c11\u533b\u9662
#\u5e7f\u4e1c\u7701\u005f\u6e5b\u6c5f\u5e02\u005f\u9042\u6eaa\u53bf\u4eba\u6c11\u533b\u9662
#\u5e7f\u4e1c\u7701\u005f\u5e7f\u5dde\u5e02\u5929\u6cb3\u533a\u4eba\u6c11\u533b\u9662
export_pdf_patient_info = inpatientNo,disDate
@ -65,8 +67,5 @@ NEW_EMR_RECORD_JSP : http://localhost:8081/emr_record
#\u8D39\u7528\u6E05\u5355\u751F\u6210\u7684\u76EE\u5F55
cost_pdf_path=D://cost//
# ??????token
guangzong_token=JxUAVD4BGlRGTVRFRU5BRk5FQFQ3JyBURkRGQA==

@ -3,10 +3,14 @@ jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
#jdbc.username=sa
#jdbc.password=docus@702
jdbc.url=jdbc\:sqlserver\://localhost:1433;databaseName=qf_record
jdbc.url=jdbc\:sqlserver\://192.168.2.22:1433;databaseName=qf_record_lin
jdbc.username=sa
jdbc.password=admin123
jdbc.password=123456
#dataSource2
jdbc.url2=jdbc\:sqlserver\://localhost:1433;databaseName=blgd_java
jdbc.username2=jsuser
jdbc.password2=123456
jdbc.driver2=com.mysql.jdbc.Driver
jdbc.url2=jdbc\:mysql\://192.168.2.22\:3306/gyw?useUnicode\=true&characterEncoding\=utf-8
jdbc.username2=root
jdbc.password2=root
#jdbc.url2=jdbc\:sqlserver\://localhost:1433;databaseName=blgd_java
#jdbc.username2=jsuser
#jdbc.password2=123456

@ -118,57 +118,21 @@
<select id="selectPdfPathByPatient2" resultType="com.emr.vo.commomSearch.CommomTree"
parameterType="java.lang.String">
SELECT
dbo.commomtable.patient_id,
dbo.t_scan_assort.assort_id,
t_scan_assort.scan_page,
t_scan_assort.source
archive_detail.PDF_PATH,
archive_detail.MasterID as patient_id,
archive_detail.AssortID as assort_id,
zd_assort.assort_name,
archive_detail.PDF_PATH as scan_page,
archive_detail.Source as source,
archive_detail.PageCount,
archive_detail.Title as title
FROM
dbo.commomtable
LEFT JOIN
dbo.t_scan_assort
ON
dbo.commomtable.patient_id = dbo.t_scan_assort.patient_id
<if test="userId != null">
INNER JOIN (
SELECT DISTINCT
assort_id
FROM
zd_assort
LEFT JOIN (
SELECT
record_id
FROM
emr_role_reader
WHERE
role_id = ${roleId}
AND record_id NOT IN (
SELECT
record_id
FROM
emr_user_reader
WHERE
user_id = ${userId}
AND flag = 0
)
UNION ALL
SELECT
record_id
FROM
emr_user_reader
WHERE
user_id = ${userId}
AND flag = 1
) emr_user_reader ON assort_id = emr_user_reader.record_id
WHERE
emr_user_reader.record_id IS NOT NULL
) a
ON dbo.zd_assort.assort_id = a.assort_id
</if>
archive_detail
LEFT JOIN zd_assort
ON archive_detail.AssortID = zd_assort.assort_id
WHERE
dbo.commomtable.patient_id = #{patientId}
and t_scan_assort.is_del = 0
ORDER BY
t_scan_assort.scan_page
MasterID = #{patientId} and flag != 1
ORDER BY zd_assort.assort_sort,UpLoadDateTime
</select>
<select id="selectPdfPathByPatient3" resultType="com.emr.vo.commomSearch.CommomTree">
SELECT

@ -257,12 +257,10 @@
dbo.t_scan_assort
ON
dbo.commomtable.patient_id = dbo.t_scan_assort.patient_id
<if test='sortFlag == null or sortFlag == ""'>
INNER JOIN
dbo.zd_assort
ON
dbo.t_scan_assort.assort_id = dbo.zd_assort.assort_id
</if>
<if test="userId != null">
INNER JOIN (
SELECT DISTINCT
@ -529,132 +527,132 @@
<insert id="insertSelective" parameterType="com.emr.vo.commomSearch.CommomVo">
insert into commomtable
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="patientId != null">
<if test="patientId != null and patientId != ''">
patient_id,
</if>
<if test="admissTimes != null">
<if test="admissTimes != null and admissTimes != ''">
admiss_times,
</if>
<if test="inpatientNo != null">
<if test="inpatientNo != null and inpatientNo != ''">
inpatient_no,
</if>
<if test="name != null">
NAME,
<if test="name != null and name != ''">
name,
</if>
<if test="admissId != null">
<if test="admissId != null and admissId != ''">
admiss_id,
</if>
<if test="sex != null">
<if test="sex != null and sex != ''">
sex,
</if>
<if test="age != null">
<if test="age != null and age != ''">
age,
</if>
<if test="ageMonth != null">
<if test="ageMonth != null and ageMonth != ''">
age_month,
</if>
<if test="ageDay != null">
<if test="ageDay != null and ageDay != ''">
age_day,
</if>
<if test="homeAddr != null">
<if test="homeAddr != null and homeAddr != ''">
home_addr,
</if>
<if test="nameCym != null">
<if test="nameCym != null and nameCym != ''">
name_cym,
</if>
<if test="admissDate != null">
<if test="admissDate != null and admissDate !=''">
admiss_date,
</if>
<if test="disDate != null">
<if test="disDate != null and disDate != ''">
dis_date,
</if>
<if test="admissDays != null">
<if test="admissDays != null and admissDays != ''">
admiss_days,
</if>
<if test="disDept != null">
<if test="disDept != null and disDept != ''">
dis_dept,
</if>
<if test="isOper != null">
<if test="isOper != null and isOper != ''">
is_oper,
</if>
<if test="attending != null">
<if test="attending != null and attending != ''">
attending,
</if>
<if test="mainDiagName != null">
<if test="mainDiagName != null and mainDiagName != ''">
main_diag_name,
</if>
<if test="mainDisThing != null">
<if test="mainDisThing != null and mainDisThing != ''">
main_dis_thing,
</if>
<if test="mainDiagCode != null">
<if test="mainDiagCode != null and mainDiagCode != ''">
main_diag_code,
</if>
<if test="newPath != null">
<if test="newPath != null and newPath != ''">
new_path,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="patientId != null">
<if test="patientId != null and patientId != ''">
#{patientId,jdbcType=VARCHAR},
</if>
<if test="admissTimes != null">
<if test="admissTimes != null and admissTimes != ''">
#{admissTimes,jdbcType=SMALLINT},
</if>
<if test="inpatientNo != null">
<if test="inpatientNo != null and inpatientNo != ''">
#{inpatientNo,jdbcType=VARCHAR},
</if>
<if test="name != null">
<if test="name != null and name != ''">
#{name,jdbcType=VARCHAR},
</if>
<if test="admissId != null">
<if test="admissId != null and admissId != ''">
#{admissId,jdbcType=VARCHAR},
</if>
<if test="sex != null">
<if test="sex != null and sex != ''">
#{sex,jdbcType=NVARCHAR},
</if>
<if test="age != null">
<if test="age != null and age != ''">
#{age,jdbcType=SMALLINT},
</if>
<if test="ageMonth != null">
<if test="ageMonth != null and ageMonth != ''">
#{ageMonth,jdbcType=SMALLINT},
</if>
<if test="ageDay != null">
<if test="ageDay != null and ageDay != ''">
#{ageDay,jdbcType=SMALLINT},
</if>
<if test="homeAddr != null">
<if test="homeAddr != null and homeAddr != ''">
#{homeAddr,jdbcType=NVARCHAR},
</if>
<if test="nameCym != null">
<if test="nameCym != null and nameCym != ''">
#{nameCym,jdbcType=CHAR},
</if>
<if test="admissDate != null">
<if test="admissDate != null and admissDate != ''">
#{admissDate,jdbcType=TIMESTAMP},
</if>
<if test="disDate != null">
<if test="disDate != null and disDate != ''">
#{disDate,jdbcType=TIMESTAMP},
</if>
<if test="admissDays != null">
<if test="admissDays != null and admissDays != ''">
#{admissDays,jdbcType=INTEGER},
</if>
<if test="disDept != null">
<if test="disDept != null and disDept != ''">
#{disDept,jdbcType=NVARCHAR},
</if>
<if test="isOper != null">
<if test="isOper != null and isOper != ''">
#{isOper,jdbcType=VARCHAR},
</if>
<if test="attending != null">
<if test="attending != null and attending != ''">
#{attending,jdbcType=VARCHAR},
</if>
<if test="mainDiagName != null">
<if test="mainDiagName != null and mainDiagName != ''">
#{mainDiagName,jdbcType=VARCHAR},
</if>
<if test="mainDisThing != null">
<if test="mainDisThing != null and mainDisThing != ''">
#{mainDisThing,jdbcType=NVARCHAR},
</if>
<if test="mainDiagCode != null">
<if test="mainDiagCode != null and mainDiagCode != ''">
#{mainDiagCode,jdbcType=NVARCHAR},
</if>
<if test="newPath != null">
<if test="newPath != null and newPath != ''">
#{newPath,jdbcType=NVARCHAR},
</if>
</trim>
@ -664,103 +662,103 @@
<update id="updateByPrimaryKeySelective" parameterType="com.emr.vo.commomSearch.CommomVo">
update commomtable
<set>
<if test="admissTimes != null">
<if test="admissTimes != null and admissTimes != ''">
admiss_times = #{admissTimes},
</if>
<if test="inpatientNo != null">
<if test="inpatientNo != null and inpatientNo != ''">
inpatient_no = #{inpatientNo},
</if>
<if test="name != null">
<if test="name != null and name != ''">
NAME = #{name},
</if>
<if test="admissId != null">
<if test="admissId != null and admissId != ''">
admiss_id = #{admissId},
</if>
<if test="sex != null">
<if test="sex != null and sex != ''">
sex = #{sex},
</if>
<if test="age != null">
<if test="age != null and age != ''">
age = #{age},
</if>
<if test="ageMonth != null">
<if test="ageMonth != null and ageMonth != ''">
age_month = #{ageMonth},
</if>
<if test="ageDay != null">
<if test="ageDay != null and ageDay != ''">
age_day = #{ageDay},
</if>
<if test="homeAddr != null">
<if test="homeAddr != null and homeAddr != ''">
home_addr = #{homeAddr},
</if>
<if test="nameCym != null">
<if test="nameCym != null and nameCym != ''">
name_cym = #{nameCym},
</if>
<if test="admissDate != null">
admiss_date = #{admissDate},
<if test="admissDate != null and admissDate != ''">
admiss_date = CONVERT(DATETIME, #{admissDate}, 120),
</if>
<if test="disDate != null">
dis_date = #{disDate},
<if test="disDate != null and disDate != ''">
dis_date = CONVERT(DATETIME, #{disDate}, 120),
</if>
<if test="admissDays != null">
<if test="admissDays != null and admissDays != ''">
admiss_days = #{admissDays},
</if>
<if test="disDept != null">
<if test="disDept != null and disDept != ''">
dis_dept = #{disDept},
</if>
<if test="isOper != null">
<if test="isOper != null and isOper != ''">
is_oper = #{isOper},
</if>
<if test="attending != null">
<if test="attending != null and attending != ''">
attending = #{attending},
</if>
<if test="mainDiagName != null">
<if test="mainDiagName != null and mainDiagName != ''">
main_diag_name = #{mainDiagName},
</if>
<if test="mainDisThing != null">
<if test="mainDisThing != null and mainDisThing != ''">
main_dis_thing = #{mainDisThing},
</if>
<if test="newPath != null">
<if test="newPath != null and newPath != ''">
new_path = #{newPath},
</if>
<if test="mainDiagCode != null">
<if test="mainDiagCode != null and mainDiagCode != ''">
main_diag_code = #{mainDiagCode},
</if>
<if test="cycleNo != null">
<if test="cycleNo != null and cycleNo != ''">
cycle_no = #{cycleNo},
</if>
<if test="medicalNo != null">
<if test="medicalNo != null and medicalNo != ''">
medical_no = #{medicalNo},
</if>
<if test="femaleName != null">
<if test="femaleName != null and femaleName != ''">
female_name = #{femaleName},
</if>
<if test="maleName != null">
<if test="maleName != null and maleName != ''">
male_name = #{maleName},
</if>
<if test="operationTime != null">
operation_time = #{operationTime},
<if test="operationTime != null and operationTime != ''">
operation_time = CONVERT(DATETIME, #{operationTime}, 120),
</if>
<if test="cycleType != null">
<if test="cycleType != null and cycleType != ''">
cycle_type = #{cycleType},
</if>
<if test="visitTime != null">
visit_time = #{visitTime},
<if test="visitTime != null and visitTime != ''">
visit_time = CONVERT(DATETIME, #{visitTime}, 120),
</if>
<if test="proNo != null">
<if test="proNo != null and proNo != ''">
pro_no = #{proNo},
</if>
<if test="proName != null">
<if test="proName != null and proName != ''">
pro_name = #{proName},
</if>
<if test="applicant != null">
<if test="applicant != null and applicant != ''">
applicant = #{applicant},
</if>
<if test="hemodialysisId != null">
<if test="hemodialysisId != null and hemodialysisId != ''">
hemodialysis_id = #{hemodialysisId},
</if>
<if test="hemodialysisDate != null">
hemodialysis_date = #{hemodialysisDate},
<if test="hemodialysisDate != null and hemodialysisDate != ''">
hemodialysis_date = CONVERT(DATETIME, #{hemodialysisDate}, 120),
</if>
<if test="radiotherapyNo != null">
<if test="radiotherapyNo != null and radiotherapyNo != ''">
radiotherapy_no = #{radiotherapyNo},
</if>
</set>
@ -914,7 +912,7 @@
</insert>
<!--更新commomtable1表-->
<update id="updateByPrimaryKeySelective1" parameterType="com.emr.vo.commomSearch.CommomVo">
<update id="1" parameterType="com.emr.vo.commomSearch.CommomVo">
update commomtable1
<set>
<if test="country != null">
@ -1299,7 +1297,7 @@
commomtable
<where>
<if test="inpatientNo != null and inpatientNo != ''">
AND inpatient_no =#{inpatientNo}
AND inpatient_no = #{inpatientNo}
</if>
<if test="admissId != null and admissId != ''">
AND admiss_id = #{admissId}
@ -1541,4 +1539,76 @@
</where>
group by periods
</select>
<select id="quertIsExist" parameterType="String" resultType="String">
select 1 from lee_basic where patient_id = #{patientID}
</select>
<select id="saveData" parameterType="map">
insert into lee_basic
(
patient_id,
his_id,
inpatient_no,
admiss_times,
name,
admiss_date,
id_card,
oper_date,
create_date
)
values
(
#{patientID},
#{patientID} + '' + #{medicalRecordNo},
#{medicalRecordNo},
#{visitCount},
#{patientName},
#{handleTime},
#{SSN},
GETDATE(),
GETDATE()
)
</select>
<select id="updateData" parameterType="map">
update lee_basic
set
inpatient_no = #{medicalRecordNo},
admiss_times = #{visitCount},
name = #{patientName},
admiss_date = #{handleTime},
oper_date = GETDATE(),
create_date = GETDATE(),
id_card = #{SSN},
his_id = #{patientID} + '' + #{medicalRecordNo}
where patient_id = #{patientID}
</select>
<select id="getUploadPath" parameterType="String" resultType="String">
select file_path from commomtable where patient_id = #{patientId}
</select>
<insert id="saveAssortData" parameterType="map">
insert into t_scan_assort
(
patient_id,
assort_id,
scan_page,
source,
is_del
)
values
(
#{patientId},
#{assortId},
#{scanPage},
1,
0
)
</insert>
<select id="getIsExistFileName" parameterType="String" resultType="java.lang.Integer">
select count(1) from t_scan_assort where scan_page = #{fileName}
</select>
</mapper>

@ -40,6 +40,7 @@
AND CONVERT ( VARCHAR ( 100 ), create_date, 23 ) &lt;= #{endTime}
</if>
</if>
order by create_date desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from Export_Task

@ -75,7 +75,7 @@
SELECT
dbo.zd_assort.assort_id,
dbo.zd_assort.assort_name,
dbo.emr_type_related.id printFlag
dbo.emr_type_related.id print_flag
FROM
dbo.zd_assort
LEFT OUTER JOIN
@ -116,7 +116,7 @@
DISTINCT
assort_id,
assort_name,
emr_user_reader.record_id printFlag,
emr_user_reader.record_id print_flag,
assort_sort
FROM
zd_assort

@ -57,6 +57,7 @@
<mvc:resources mapping="/reloadJ/**" location="file:J:/" />
<mvc:resources mapping="/reloadK/**" location="file:K:/" />
<mvc:resources mapping="/reloadZ/**" location="file:Z:/" />
<mvc:resources mapping="/reloadW/**" location="file:W:/" />
<mvc:resources mapping="/picShare/**" location="file:/mnt/share/" />

@ -162,7 +162,7 @@
<button type="button" class="btn btn-sm btn-primary btns" onclick="applyFlow()">申请</button>
</div>
<div class="importExcelButton">
<button type="button" class="btn btn-sm btn-primary btns" onclick="window.open('${path }/static/js/template/血透文书检查登记表.xls');">下载模板</button>
<button type="button" class="btn btn-sm btn-primary btns" onclick="window.open('${path }/static/js/template/血透文书检查登记表.xlsx');">下载模板</button>
</div>
<div class="importExcelButton">
<button type="button" class="btn btn-sm btn-primary btns" onclick="exportExcel()">导入excel</button>

@ -216,6 +216,8 @@
<input type="hidden" id="loads">
<!--被锁的病案-->
<input type="hidden" id="locks">
<!--合并pdf的patientId-->
<input type="hidden" id="megerPatientId">
<!--按条件搜索的patientIds-->
<input type="hidden" id="patientIds">
<!--类似自定义查询的搜索条件-->
@ -616,6 +618,17 @@
</div>
</div>
</div>
<div class="col-sm-4 hideDiv" id="phDiv">
<div class="form-group">
<div class="col-sm-3 labelDiv">
<label class="control-label">盘号:</label>
</div>
<div class="col-sm-9 inputDiv">
<input type="text" class="form-control input-sm diagTable inputValue"
id="ph" maxlength="100">
</div>
</div>
</div>
<div class="col-sm-4 hideDiv" id="isOperDiv">
<div class="form-group">
<div class="col-sm-3 labelDiv"></div>
@ -863,6 +876,9 @@
<button type="button" class="btn btn-sm btn-success" onclick="uploadBtn()">费用清单上传</button>
</div>
</shiro:hasPermission>
<%--<div class="btn">
<button type="button" class="btn btn-sm btn-success" onclick="mergePDF()">合并PDF</button>
</div>--%>
<shiro:hasPermission name="/commom/exportExcel">
<div class="btn">
<button type="button" class="btn btn-sm btn-success" onclick="exportExcel()">导出excel</button>
@ -1017,6 +1033,14 @@
</div>
<div class="col-sm-1"></div>
</div>
<div class="form-group hideDiv" id="admissDateEditDiv">
<label class="col-sm-3 control-label">入院时间:</label>
<div class="col-sm-7">
<input type="text" class="form-control input-sm input" name="admissDate" id="admissDate"
maxlength="10" autocomplete="off" placeholder="请输入格式为 yyyy-mm-dd 的日期示例2024-01-01">
</div>
<div class="col-sm-1"></div>
</div>
<div class="form-group hideDiv" id="disDateEditDiv">
<label class="col-sm-3 control-label">出院时间:</label>
<div class="col-sm-7">

@ -267,6 +267,8 @@
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.7.570/pdf.min.js"></script>
<script type="text/javascript"
src="${path}/static/js/recordManage/commomSearch/showRecordIframeBlood.js?<%= System.currentTimeMillis() %>"></script>
<script type="text/javascript"

@ -308,7 +308,8 @@
$("#indexTreeMenu").css("height",windowHeight - headerHeight);
const hospitalName = $("#hospitalName").val();
if(hospitalName != '' && hospitalName != null && hospitalName != undefined){
console.log("hospitalName",hospitalName)
if(hospitalName != '' && hospitalName != null && hospitalName != undefined && hospitalName != "null"){
$("#logoTitleName").css('display','block')
$("#logoTitleName").html(hospitalName + '<br/>病案信息管理系统')
}else{

@ -15,7 +15,7 @@
*/
.main{
width:100%;
/* height:100%;*/
height:94%;
background-color: #c1d7e3;
}
/*

@ -112,9 +112,10 @@ function initQueryCondition(){
$("#directorDiv").css('display','');
$("#admissDoctorDiv").css('display','');
$("#memoDiv").css('display','');
$("#phDiv").css('display','');
$("#isOperDiv").css('display','');
$("#inpatientNoEditDiv,#nameEditDiv,#admissTimesEditDiv,#disDateEditDiv,#disDeptEditDiv,#disDiagEditDiv").css('display','');
$("#inpatientNoEditDiv,#nameEditDiv,#admissTimesEditDiv,#admissDateEditDiv,#disDateEditDiv,#disDeptEditDiv,#disDiagEditDiv").css('display','');
}
}
@ -654,6 +655,11 @@ function getSql() {
name = 'medical_no';
whereNames += commomtable + "." + name + " LIKE '%" + $("#" + name).val() + "%' AND ";
}
//盘号
if (!isEmpty($("#ph").val())) {
name = 'ph';
whereNames += commomtable + "." + name + " LIKE '%" + $("#" + name).val() + "%' AND ";
}
//女方姓名
if (!isEmpty($("#female_name").val())) {
name = 'female_name';

@ -126,7 +126,7 @@ function onClick(e, treeId, treeNode) {
};
//打印分类变更事件
$("#typeId").change(function () {
menu.loadMenuTree();
})
//按原件排序
@ -147,6 +147,17 @@ function onloadPdfMethod() {
//加载pdf按钮功能
function onloadPdf(scanPages, sources) {
/*var batchSize = 10; // 每批处理10个PDF文件
var scanPagesArray = scanPages.split(',');
var sourcesArray = sources.split(',');
var totalFiles = scanPagesArray.length;
var batches = Math.ceil(totalFiles / batchSize);
function processBatch(batchIndex){
var start = batchIndex * batchSize;
var end = Math.min(start + batchSize, totalFiles);
var batchScanPages = scanPagesArray.slice(start, end) + "";
var batchSources = sourcesArray.slice(start, end) + "";
$("#iframeLoad").val("");
$("#printPicLoaded").val("");
var patientId = $("#patientId").val();
@ -157,14 +168,15 @@ function onloadPdf(scanPages, sources) {
url: path + "/commom/showRecordContentBlood",
data: {
patientId: patientId,
scanPages: scanPages,
scanPages: batchScanPages,
flag: flag,
sources: sources
sources: batchSources,
batchIndex: batchIndex
},
datType: 'json',
success: function (data) {
if (data.code == 0) {
var str = path + "/commom/getRecordContentBlood?patientId=" + patientId;
var str = path + "/commom/getRecordContentBlood?patientId=" + patientId + "&batchIndex=" + batchIndex;
if (sources.includes("99") ||sources.includes("服务") ||sources.includes("null")||sources.includes("pacs")||sources.includes("扫描上传")) {
$("#iframe1").attr("src", path + "/static/pdfjs/web/viewer.html?file=" + encodeURIComponent(str))
} else {
@ -178,23 +190,44 @@ function onloadPdf(scanPages, sources) {
}
}
})
}
}
// 处理每个批次
for (var i = 0; i < batches; i++) {
processBatch(i);
}*/
/*function onloadPdf(scanPages, sources) {
$("#iframeLoad").val("");
$("#printPicLoaded").val("");
var patientId = $("#patientId").val();
//根目录字段识别名称
var flag = parent.$("#flag").val();
var str = path + "/commom/showRecordContentBlood?patientId=" + patientId + "&scanPages=" + scanPages + "&sources=" + sources + "&flag=" + flag;
$("#iframe1").attr("src", path + "/static/pdfjs/web/viewer1.html?file=" + encodeURIComponent(str));
$.ajax({
type: 'post',
url: path + "/commom/showRecordContentBlood",
data: {
patientId: patientId,
scanPages: scanPages,
flag: flag,
sources: sources
},
datType: 'json',
success: function (data) {
if (data.code == 0) {
var str = path + "/commom/getRecordContentBlood?patientId=" + patientId;
if (sources.includes("99") ||sources.includes("服务") ||sources.includes("null")||sources.includes("pacs")||sources.includes("扫描上传")) {
$("#iframe1").attr("src", path + "/static/pdfjs/web/viewer.html?file=" + encodeURIComponent(str))
} else {
$("#iframe1").attr("src", path + "/static/pdfjs/web/viewer2.html?file=" + encodeURIComponent(str))
var rootPaths = parent.$("#rootPaths").val();
//加载的图片
var print = $("#print").val();
if (scanPages != '' && print == 1) {
if (print == 1) {
selectPrintPic(patientId, rootPaths, scanPages, sources);
}
}*/
}
}
}
})
}
var iframe = document.getElementById("iframe1");
@ -223,41 +256,20 @@ function selectPrintPic(patientId, rootPaths, scanPages, sources) {
}
var interval = setInterval(function () {
if ($("#iframeLoad").val() == 1) {
//initImage();
iframe.contentDocument.getElementById("printContainer1").innerHTML = img;
initImage();
$("#printPicLoaded").val(1);
iframe.contentDocument.getElementById("printLoading").style.display = 'none';
iframe.contentDocument.getElementById("print").style.display = 'block';
clearInterval(interval);
}
}, 200);
}, 100);
}
} else {
toastr.error(data.msg);
}
}
})
//查询进度定时器
// var interval1 = setInterval(function () {
// $.ajax({
// type: 'get',
// url: path + "/commom/getPrintPicLoading",
// data: {patientId: $("#patientId").val()},
// dataType: 'json',
// success: function (data) {
// if (data.code == 0) {
// var value = data.data;
// $("#loading").val(value + "%");
// if (value == 100) {
// //杀死进度定时器
// clearInterval(interval1);
// }
// } else {
// toastr.error(data.msg);
// }
// }
// })
// }, 100);
}
function initImage(){

@ -252,6 +252,7 @@ function freshTable(){
onCheck:function(row){
var checks = $("#checks").val();
$("#checks").val(checks+="'"+row.patientId + "',");
$("#megerPatientId").val(row.patientId);
},
onUncheck: function (row, $element) {
chosenGroupId = "";
@ -263,6 +264,7 @@ function freshTable(){
var checks = $("#checks").val();
checks = checks.replace("'"+row.patientId + "',","");
$("#checks").val(checks);
$("#megerPatientId").val("");
},
//全选
onCheckAll:function(rows){
@ -277,6 +279,7 @@ function freshTable(){
//全不选
onUncheckAll: function (rows) {
$("#checks").val("");
$("#megerPatientId").val("");
},
//双击事件
@ -496,6 +499,13 @@ function getUpdateCommomInfo(patientId) {
/**
* 初始化时间框
*/
//入院时间
$('#admissDate').datepicker({
language: "zh-CN",
format: "yyyy-mm-dd",
autoclose: true,//选中之后自动隐藏日期选择框
})
//出院时间
$('#disDate').datepicker({
language: "zh-CN",
@ -533,6 +543,8 @@ function getUpdateCommomInfo(patientId) {
$("#inpatientNo").val(data.inpatientNo);
$("#updateName").val(data.name);
$("#admissTimes").val(data.admissTimes);
var admissDate = formatTime(data.admissDate,'yyyy-MM-dd')
$("#admissDate").val(admissDate);
var disDate = formatTime(data.disDate,'yyyy-MM-dd')
$("#disDate").val(disDate);
loadDeptDefault(data.disDept);
@ -566,7 +578,7 @@ function updateCommomInfo() {
$.ajax({
type:'post',
url:path+'/commom/updateCommomInfo',
data:$("#form").serialize(),
data: $("#form").serialize(),
dataType:'json',
success:function(data){
if(data!=null && data.code == 0){
@ -1301,6 +1313,19 @@ function powerPotient(patientIds,flag,typeId){
}
return patientIds;
}
/**
* 合并PDF
*/
function mergePDF(){
var patientId = $("#megerPatientId").val();
if(patientId == '' || patientId == null){
return toastr.warning("请选择一条数据");
}
var mergeUrl = path + '/commom/showMegerPDFView?patientId='+ patientId +'&dataSource=';
window.open(mergeUrl, "_blank")
}
/*********************************************************工具*************************************************************/
//格式化时间
function formatTime(datetime, fmt) {

@ -112,6 +112,7 @@
w.focus();
typeof _this.options.onStart === 'function' && _this.options.onStart();
if (!w.document.execCommand('print', false, null)) {
alert("打印失败")
w.print();
}
typeof _this.options.onEnd === 'function' && _this.options.onEnd();

@ -405,6 +405,7 @@ html[dir='rtl'] #sidebarContent {
bottom: 0;
left: 0;
outline: none;
height: 91%;
}
html[dir='ltr'] #viewerContainer {
box-shadow: inset 1px 0 0 hsla(0,0%,100%,.05);

@ -97,10 +97,33 @@ http://sourceforge.net/adobe/cmap/wiki/License/
opacity: 1;
}
/* 设置打印时的样式 */
@media print {
body {
margin: 0;
padding: 0;
}
.a4-paper {
width: 210mm; /* A4 纸张宽度 */
height: 297mm; /* A4 纸张高度 */
margin: 0 auto; /* 居中对齐 */
padding: 0; /* 内边距 */
box-sizing: border-box;
}
.a4-image {
max-width: 850px;
max-height: 1190px;
object-fit: contain;
max-width: 100%; /* 图像最大宽度为容器宽度 */
max-height: 100%; /* 图像最大高度为容器高度 */
height: auto; /* 保持图像比例 */
width: auto; /* 保持图像比例 */
}
}
/* 设置 A4 纸张大小和边距 */
@page {
size: A4;
margin: 0; /* 移除默认页边距 */
}
</style>
</head>
@ -446,7 +469,7 @@ http://sourceforge.net/adobe/cmap/wiki/License/
</div> <!-- outerContainer -->
<div id="printContainer"></div>
<div style="display: none">
<div id="printContainer1" class="a4-image">
<div id="printContainer1" class="a4-paper">
</div>
</div>

Loading…
Cancel
Save