优化2.0标准版代码

master
Godblessyou 4 months ago
parent c6e65402ae
commit 5a273bb7cd

@ -1162,7 +1162,7 @@ public class CommomSearchController {
@RequestMapping(value = "getRecordContentBlood") @RequestMapping(value = "getRecordContentBlood")
@ResponseBody @ResponseBody
public void getRecordContentBlood(String patientId, HttpServletRequest request, HttpServletResponse response) { public void getRecordContentBlood(String patientId, HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> cacheMap = commomService.CACHE_MAP; // Map<String, Object> cacheMap = commomService.CACHE_MAP;
List<CommomTree> commomTrees = archiveDetailMapper.selectPdfPathByPatient2(patientId); List<CommomTree> commomTrees = archiveDetailMapper.selectPdfPathByPatient2(patientId);
Power_User user; Power_User user;
Object currentUser = request.getSession().getAttribute("CURRENT_USER"); Object currentUser = request.getSession().getAttribute("CURRENT_USER");
@ -1176,7 +1176,8 @@ public class CommomSearchController {
if (commomTrees.size() == 0) { if (commomTrees.size() == 0) {
try { try {
String mapKey = user.getUserName() + "_" + patientId; String mapKey = user.getUserName() + "_" + patientId;
List<String> scanPages = (List<String>) cacheMap.get(mapKey); //List<String> scanPages = (List<String>) cacheMap.get(mapKey);
List<String> scanPages = (List<String>) request.getSession().getAttribute(mapKey);
if (!CollectionUtils.isEmpty(scanPages)) { if (!CollectionUtils.isEmpty(scanPages)) {
String pdfName = "档案管理PDF"; String pdfName = "档案管理PDF";
//根据图片路径转换pdf //根据图片路径转换pdf
@ -1192,7 +1193,8 @@ public class CommomSearchController {
img2PdfUtil.imageToPdfUserEffective(response, scanPages, pdfName, emrPdfWaterSet); img2PdfUtil.imageToPdfUserEffective(response, scanPages, pdfName, emrPdfWaterSet);
} }
//移除缓存 //移除缓存
commomService.CACHE_MAP.clear(); //commomService.CACHE_MAP.clear();
request.removeAttribute(mapKey);
} }
} catch (Exception e) { } catch (Exception e) {
ExceptionPrintUtil.printException(e); ExceptionPrintUtil.printException(e);
@ -1201,14 +1203,16 @@ public class CommomSearchController {
} else { } else {
String pdfWater = ""; String pdfWater = "";
String mapKey = user.getUserName() + "_" + patientId; String mapKey = user.getUserName() + "_" + patientId;
List<String> filePaths = (List<String>) cacheMap.get(mapKey); //List<String> filePaths = (List<String>) cacheMap.get(mapKey);
List<String> filePaths = (List<String>) request.getSession().getAttribute(mapKey);
if (!CollectionUtils.isEmpty(filePaths)) { if (!CollectionUtils.isEmpty(filePaths)) {
//根据图片路径转换pdf //根据图片路径转换pdf
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1); EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
//定义第二文本水印 姓名 + 科室 + ip //定义第二文本水印 姓名 + 科室 + ip
Jpg2PdfUtil.mulFile2One2(response, filePaths, pdfWater,emrPdfWaterSet); Jpg2PdfUtil.mulFile2One2(response, filePaths, pdfWater,emrPdfWaterSet);
//移除缓存 //移除缓存
commomService.CACHE_MAP.clear(); //commomService.CACHE_MAP.clear();
request.removeAttribute(mapKey);
} }
} }
} }

@ -998,14 +998,51 @@ public class TemplateSearchController {
private String getSql(String selectSql, String fromTableSql, String whereSql, String orderBys, Power_User user) { private String getSql(String selectSql, String fromTableSql, String whereSql, String orderBys, Power_User user) {
String userName = user.getUserName(); String userName = user.getUserName();
String powerDepts = user.getPowerDepts();
String initSelectSql = "select commomtable.patient_id,CASE WHEN emr_apply_approve.id is null THEN 0 ELSE 1 END isShowDetail,CASE WHEN emr_apply_approve1.id IS NULL THEN 0 ELSE 1 END isDownload,CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus"; String initSelectSql = "select commomtable.patient_id,CASE WHEN emr_apply_approve.id is null THEN 0 ELSE 1 END isShowDetail,CASE WHEN emr_apply_approve1.id IS NULL THEN 0 ELSE 1 END isDownload,CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus";
if(StringUtils.isNotBlank(selectSql)){ if(StringUtils.isNotBlank(selectSql)){
initSelectSql += "," + selectSql; initSelectSql += "," + selectSql;
} }
String initFromTableSql = " from commomtable left join emr_apply_approve on commomtable.patient_id = emr_apply_approve.patient_id and emr_apply_approve.approve_state = 1 and emr_apply_approve.effe_time > GETDATE()-1 and emr_apply_approve.applyer = '" +userName+ "' and emr_apply_approve.apply_type != 3 left join emr_apply_approve emr_apply_approve1 on commomtable.patient_id = emr_apply_approve1.patient_id and emr_apply_approve1.approve_state = 1 and emr_apply_approve1.effe_time > GETDATE()-1 and emr_apply_approve1.applyer = '" +userName+ "' and emr_apply_approve1.apply_type = 3 left join emr_lock on commomtable.patient_id = emr_lock.patient_id and emr_lock.lock_state = 1 "; String initFromTableSql = " from commomtable left join emr_apply_approve on commomtable.patient_id = emr_apply_approve.patient_id and emr_apply_approve.approve_state = 1 and emr_apply_approve.effe_time > GETDATE()-1 and emr_apply_approve.applyer = '" +userName+ "' and emr_apply_approve.apply_type != 3 left join emr_apply_approve emr_apply_approve1 on commomtable.patient_id = emr_apply_approve1.patient_id and emr_apply_approve1.approve_state = 1 and emr_apply_approve1.effe_time > GETDATE()-1 and emr_apply_approve1.applyer = '" +userName+ "' and emr_apply_approve1.apply_type = 3 left join emr_lock on commomtable.patient_id = emr_lock.patient_id and emr_lock.lock_state = 1 ";
String powerDeptsSql = "";
if(StringUtils.isNotBlank(powerDepts)){
// 将powerDepts转换为SQL IN条件
String[] deptArray = powerDepts.split(",");
StringBuilder inClause = new StringBuilder();
for(int i = 0; i < deptArray.length; i++) {
if(i == 0) {
inClause.append("'").append(deptArray[i]).append("'");
} else {
inClause.append(",'").append(deptArray[i]).append("'");
}
}
powerDeptsSql = "where commomtable.dis_dept in (" + inClause.toString() + ")";
}
if(StringUtils.isNotBlank(fromTableSql)){ if(StringUtils.isNotBlank(fromTableSql)){
initFromTableSql += fromTableSql; initFromTableSql += fromTableSql;
} }
String sql = initSelectSql + initFromTableSql;
// 添加powerDepts条件到SQL中
if(StringUtils.isNotBlank(powerDeptsSql)) {
if(StringUtils.isNotBlank(whereSql) && !"undefined".equals(whereSql)){
sql += " " + whereSql.replaceFirst("where", powerDeptsSql + " and ");
} else {
sql += " " + powerDeptsSql;
}
} else if(StringUtils.isNotBlank(whereSql) && !"undefined".equals(whereSql)){
sql += " " + whereSql;
}
if(StringUtils.isNotBlank(orderBys)){
sql += " " + orderBys;
}
return sql;
/*if(StringUtils.isNotBlank(fromTableSql)){
initFromTableSql += fromTableSql;
}
String sql = initSelectSql + initFromTableSql; String sql = initSelectSql + initFromTableSql;
if(StringUtils.isNotBlank(whereSql) && !"undefined".equals(whereSql)){ if(StringUtils.isNotBlank(whereSql) && !"undefined".equals(whereSql)){
sql += whereSql; sql += whereSql;
@ -1013,7 +1050,7 @@ public class TemplateSearchController {
if(StringUtils.isNotBlank(orderBys)){ if(StringUtils.isNotBlank(orderBys)){
sql += orderBys; sql += orderBys;
} }
return sql; return sql;*/
} }
/** /**

@ -46,6 +46,7 @@ import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@ -288,7 +289,7 @@ public class CommomService {
//脐血库显示pdf //脐血库显示pdf
public void showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response, HttpServletRequest request) throws Exception { 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("\'", ""); patientId = patientId.replace("\'", "");
//查询 //查询
if (StringUtils.isNotBlank(flag)) { if (StringUtils.isNotBlank(flag)) {
@ -315,21 +316,21 @@ public class CommomService {
} }
} }
if (!filePaths.isEmpty()) { if (!filePaths.isEmpty()) {
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); Power_User user = getCurrentUser(request);
String mapKey = user.getUserName() + "_" + patientId; String mapKey = user.getUserName() + "_" + patientId;
request.getSession().setAttribute(mapKey, filePaths); request.getSession().setAttribute(mapKey, filePaths);
} }
} else { } else {
List<String> commomTrees = archiveDetailMapper.getPDFRATH(patientId, scanPages); List<String> commomTrees = archiveDetailMapper.getPDFRATH(patientId, scanPages);
if (!commomTrees.isEmpty()) { if (!commomTrees.isEmpty()) {
Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); Power_User user = getCurrentUser(request);
String mapKey = user.getUserName() + "_" + patientId; String mapKey = user.getUserName() + "_" + patientId;
request.getSession().setAttribute(mapKey, commomTrees); request.getSession().setAttribute(mapKey, commomTrees);
} }
} }
} }
}*/ }
if (StringUtils.isBlank(patientId)) { /*if (StringUtils.isBlank(patientId)) {
return; return;
} }
@ -393,10 +394,10 @@ public class CommomService {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}, threadPoolUtil.getExecutor()); }, threadPoolUtil.getExecutor());*/
} }
private Power_User getCurrentUser(HttpServletRequest request) { public Power_User getCurrentUser(HttpServletRequest request) {
Object currentUser = request.getSession().getAttribute("CURRENT_USER"); Object currentUser = request.getSession().getAttribute("CURRENT_USER");
if (ObjectUtils.isEmpty(currentUser)) { if (ObjectUtils.isEmpty(currentUser)) {
ServletContext context = request.getServletContext(); ServletContext context = request.getServletContext();
@ -850,7 +851,32 @@ public class CommomService {
srcPath = srcPath.replace(linuxPath, "picShare"); srcPath = srcPath.replace(linuxPath, "picShare");
outSrc = EMRRECORDJSP + File.separator + srcPath; outSrc = EMRRECORDJSP + File.separator + srcPath;
} else { } else {
outSrc = srcPath; // <-------------------------------------------------共享文件夹路径处理------------------------------------------------------>
// 1. 下载文件到本地 F:\tmp
String name = user.getUserName();
String localDownloadDir = "F:\\tmp"+File.separator+name;
File downloadDir = new File(localDownloadDir);
if (!downloadDir.exists()) {
downloadDir.mkdirs(); // 确保目录存在
}
clearImageFiles(downloadDir);
// 提取文件名
String fileName = new File(srcPath).getName();
String localFilePath = localDownloadDir + File.separator + fileName;
try {
// 执行下载(支持网络路径和本地路径)
downloadFile(srcPath, localFilePath);
} catch (IOException e) {
throw new RuntimeException("文件下载失败: " + srcPath, e);
}
// 使用本地路径进行映射
root = selectRootByNotWater(localFilePath);
String str1 = localFilePath.substring(0, localFilePath.indexOf(":") + 1);
picPath = localFilePath.substring(str1.length() + 1);
outSrc = EMRRECORDJSP + "/" + root + "/" + picPath.replace("\\", "/");
// <-------------------------------------------------共享文件夹路径处理------------------------------------------------------>
} }
} else { } else {
//获取盘符后面的地址 //获取盘符后面的地址
@ -910,6 +936,56 @@ public class CommomService {
return outs;*/ return outs;*/
} }
private void clearImageFiles(File directory) {
if (directory.isDirectory()) {
File[] files = directory.listFiles((dir, name) ->
name.endsWith(".jpg") || name.endsWith(".jpeg") ||
name.endsWith(".png") || name.endsWith(".gif") ||
name.endsWith(".bmp")
);
if (files != null) {
for (File file : files) {
if (file.isFile()) {
file.delete(); // 删除图像文件
}
}
}
}
}
private void downloadFile(String sourcePath, String targetPath) throws IOException {
InputStream in = null;
OutputStream out = null;
try {
// 处理网络路径
if (sourcePath.startsWith("\\\\")) {
sourcePath = sourcePath.replace("\\", "/");
if (!sourcePath.startsWith("file:")) {
sourcePath = "file:" + sourcePath;
}
}
URL sourceUrl = new URL(sourcePath);
in = sourceUrl.openStream();
out = new FileOutputStream(targetPath);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
} finally {
if (in != null) in.close();
if (out != null) out.close();
}
}
/** /**
* IP * IP
*/ */
@ -1182,6 +1258,8 @@ public class CommomService {
return "reloadK\\"; return "reloadK\\";
case "Z:": case "Z:":
return "reloadZ\\"; return "reloadZ\\";
case "Y:":
return "reloadY\\";
case "W:": case "W:":
return "reloadW\\"; return "reloadW\\";
default: default:
@ -1264,7 +1342,7 @@ public class CommomService {
//解析压缩包文件上传并解压返回存放pdf的全路径 //解析压缩包文件上传并解压返回存放pdf的全路径
String saveFileName = UploadUtil.resolveCompressUploadFile(request, multipartFile, costPath); String saveFileName = UploadUtil.resolveCompressUploadFile(request, multipartFile, costPath);
//获取pdf文件名 //获取pdf文件名
List<String> pdfNameList = Pdf2ImgUtil.getPdfName(saveFileName); List<String> pdfNameList = Pdf2ImgUtil.getPdfName(saveFileName+"2025-10医保清单");
//导出失败病案号,出院日期数组 //导出失败病案号,出院日期数组
List<ExportInpVo> exportInpVoList = new ArrayList<>(); List<ExportInpVo> exportInpVoList = new ArrayList<>();
//定义导出异常病案号,出院日期实体对象 //定义导出异常病案号,出院日期实体对象
@ -1310,7 +1388,7 @@ public class CommomService {
filePath.mkdirs(); filePath.mkdirs();
}*/ }*/
//pdf转jpg图片生成到指定路徑 //pdf转jpg图片生成到指定路徑
List<String> picNameList = Pdf2ImgUtil.pdfToPic(saveFileName, pdfName, "jpg", commomVo.getFilePath()); List<String> picNameList = Pdf2ImgUtil.pdfToPic(saveFileName+"2025-10医保清单", pdfName, "jpg", commomVo.getFilePath());
//Zd_Assort zd_assort = zd_assortMapper.getZdAssortByName(commomVo.getPatientId()); //Zd_Assort zd_assort = zd_assortMapper.getZdAssortByName(commomVo.getPatientId());
Zd_Assort zd_assort = zd_assortMapper.getZdAssortByName("费用"); Zd_Assort zd_assort = zd_assortMapper.getZdAssortByName("费用");

@ -1,16 +1,16 @@
#power\u6743\u9650\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934 #power\u6743\u9650\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934
POWER_IP =localhost POWER_IP =localhost
POWER_URLHEAD = http://localhost:8080/power POWER_URLHEAD = http://localhost:8081/power
POWER_JSPHEAD = localhost POWER_JSPHEAD = localhost
POWER_JSP = http://localhost:8080/power POWER_JSP = http://localhost:8081/power
#\u672C\u8EAB\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934 #\u672C\u8EAB\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934
EMR_RECORD_JSP = http://localhost:8081/emr_record EMR_RECORD_JSP = http://localhost:8082/emr_record
#webSocket\u670D\u52A1\u5668\u5730\u5740 #webSocket\u670D\u52A1\u5668\u5730\u5740
WEBSOCKET_URLHEAD = ${POWER_JSPHEAD}:8088 WEBSOCKET_URLHEAD = ${POWER_JSPHEAD}:8088
#\u901A\u77E5\u5B57\u7B26\u4E32\u95F4\u9694\u7B26 #\u901A\u77E5\u5B57\u7B26\u4E32\u95F4\u9694\u7B26x
STR_SPLIT = *^:|,. STR_SPLIT = *^:|,.
#\u65E5\u5FD7\u4FDD\u7559\u5929\u6570 #\u65E5\u5FD7\u4FDD\u7559\u5929\u6570
@ -44,7 +44,7 @@ applyApproveFlag =0
#//????? #//?????
initialization =0 initialization =0
export_pdf_hospital_info = \u5e7f\u4e1c\u7701\u005f\u6e5b\u6c5f\u5e02\u005f\u9042\u6eaa\u53bf\u4eba\u6c11\u533b\u9662 export_pdf_hospital_info = \u5e7f\u4e1c\u7701_\u6e5b\u6c5f\u5e02_\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\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 ?? #\u5e7f\u4e1c\u7701\u005f\u5e7f\u5dde\u5e02\u5929\u6cb3\u533a\u4eba\u6c11\u533b\u9662 ??
@ -66,7 +66,7 @@ fullTextDays = 90
NEW_EMR_RECORD_JSP : http://localhost:8081/emr_record NEW_EMR_RECORD_JSP : http://localhost:8081/emr_record
#\u8D39\u7528\u6E05\u5355\u751F\u6210\u7684\u76EE\u5F55 #\u8D39\u7528\u6E05\u5355\u751F\u6210\u7684\u76EE\u5F55
cost_pdf_path=D://cost// cost_pdf_path=D:/cost
httpMapPort = 9001 httpMapPort = 9001

Loading…
Cancel
Save