@ -46,6 +46,7 @@ import java.awt.*;
import java.awt.image.BufferedImage ;
import java.io.* ;
import java.net.InetAddress ;
import java.net.URL ;
import java.net.UnknownHostException ;
import java.text.SimpleDateFormat ;
import java.util.* ;
@ -288,7 +289,7 @@ 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 ) ) {
@ -315,21 +316,21 @@ public class CommomService {
}
}
if ( ! filePaths . isEmpty ( ) ) {
Power_User user = ( Power_User ) request . getSession ( ) . getAttribute ( "CURRENT_USER" ) ;
Power_User user = getCurrentUser ( request ) ;
String mapKey = user . getUserName ( ) + "_" + patientId ;
request . getSession ( ) . setAttribute ( mapKey , filePaths ) ;
}
} else {
List < String > commomTrees = archiveDetailMapper . getPDFRATH ( patientId , scanPages ) ;
if ( ! commomTrees . isEmpty ( ) ) {
Power_User user = ( Power_User ) request . getSession ( ) . getAttribute ( "CURRENT_USER" ) ;
Power_User user = getCurrentUser ( request ) ;
String mapKey = user . getUserName ( ) + "_" + patientId ;
request . getSession ( ) . setAttribute ( mapKey , commomTrees ) ;
}
}
}
} * /
if ( StringUtils . isBlank ( patientId ) ) {
}
/ * if ( StringUtils . isBlank ( patientId ) ) {
return ;
}
@ -393,10 +394,10 @@ public class CommomService {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
} , threadPoolUtil . getExecutor ( ) ) ;
} , threadPoolUtil . getExecutor ( ) ) ; * /
}
p rivate Power_User getCurrentUser ( HttpServletRequest request ) {
p ublic Power_User getCurrentUser ( HttpServletRequest request ) {
Object currentUser = request . getSession ( ) . getAttribute ( "CURRENT_USER" ) ;
if ( ObjectUtils . isEmpty ( currentUser ) ) {
ServletContext context = request . getServletContext ( ) ;
@ -850,7 +851,32 @@ public class CommomService {
srcPath = srcPath . replace ( linuxPath , "picShare" ) ;
outSrc = EMRRECORDJSP + File . separator + srcPath ;
} 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 {
//获取盘符后面的地址
@ -910,6 +936,56 @@ public class CommomService {
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 地 址
* /
@ -1182,6 +1258,8 @@ public class CommomService {
return "reloadK\\" ;
case "Z:" :
return "reloadZ\\" ;
case "Y:" :
return "reloadY\\" ;
case "W:" :
return "reloadW\\" ;
default :
@ -1264,7 +1342,7 @@ public class CommomService {
//解析压缩包文件上传并解压, 返回存放pdf的全路径
String saveFileName = UploadUtil . resolveCompressUploadFile ( request , multipartFile , costPath ) ;
//获取pdf文件名
List < String > pdfNameList = Pdf2ImgUtil . getPdfName ( saveFileName );
List < String > pdfNameList = Pdf2ImgUtil . getPdfName ( saveFileName +"2025-10医保清单" );
//导出失败病案号,出院日期数组
List < ExportInpVo > exportInpVoList = new ArrayList < > ( ) ;
//定义导出异常病案号,出院日期实体对象
@ -1310,7 +1388,7 @@ public class CommomService {
filePath . mkdirs ( ) ;
} * /
//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 ( "费用" ) ;