新增MessageLog masterId,webserviceInfo

master
leijx 5 years ago
parent 5451546bbb
commit 8475aafdc2

@ -150,5 +150,9 @@
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.1" level="project" />
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.15" level="project" />
<orderEntry type="library" name="Maven: commons-net:commons-net:3.6" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8" level="project" />
<orderEntry type="library" name="Maven: com.itextpdf:itextpdf:5.5.11" level="project" />
</component>
</module>

@ -100,6 +100,31 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<!-- FTP Client-->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8</version>
</dependency>
<!--图片 转 pdf-->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.11</version>
</dependency>
</dependencies>
<build>

@ -46,7 +46,8 @@ public class TestController {
Objects.equals(interfaceForm.getInterfaceName(), InterfaceName.ICU_REPORT) ||
Objects.equals(interfaceForm.getInterfaceName(), InterfaceName.BLOODAPPLY_REPORT) ||
Objects.equals(interfaceForm.getInterfaceName(), "DoctorData") ||
Objects.equals(interfaceForm.getInterfaceName(), "NurseData")) {
Objects.equals(interfaceForm.getInterfaceName(), "NurseData") ||
Objects.equals(interfaceForm.getInterfaceName(), "ScanningFile")) {
objects = client.invoke(interfaceForm.getInterfaceName(), interfaceForm.getContent());
} else {
objects = client.invoke(interfaceForm.getInterfaceName(), interfaceForm.getParameter(), interfaceForm.getContent());

@ -10,59 +10,60 @@ import java.util.Map;
*/
public class AliasName {
public static final String USER = "用户字典";
public static final String DEPARTMENT = "科室字典";
// 超声报告
public static final String ULTRASONIC_REPORT = "57";
// 病理检查报告单
public static final String PATHOLOGY_REPORT = "52";
// 放射诊断报告单 54
public static final String RADIATION_REPORT = "54";
// 心电图报告单 59
public static final String EKG_REPORT = "59";
// 入院记录
public static final String ADMISSION_RECORD = "9";
// 出院记录
public static final String DISCHARGE_RECORD = "113";
// 转科记录
public static final String TRANSFER_RECORD = "114";
// 取消入院
public static final String CANCELLATION_DISCHARGE = "115";
// 手麻
public static final String HANDNUMBNESS_REPORT = "117";
// ICU报告
public static final String ICU_REPORT = "121";
// 其他类型 目前来说 是手麻系统的其他三个
// public static final String USER = "用户字典";
//
// public static final String DEPARTMENT = "科室字典";
//
// // 超声报告
// public static final String ULTRASONIC_REPORT = "57";
//
// // 病理检查报告单
// public static final String PATHOLOGY_REPORT = "52";
//
// // 放射诊断报告单 54
// public static final String RADIATION_REPORT = "54";
//
// // 心电图报告单 59
// public static final String EKG_REPORT = "59";
//
// // 入院记录
// public static final String ADMISSION_RECORD = "9";
//
// // 出院记录
// public static final String DISCHARGE_RECORD = "113";
//
// // 转科记录
// public static final String TRANSFER_RECORD = "114";
//
// // 取消入院
// public static final String CANCELLATION_DISCHARGE = "115";
//
// // 手麻
// public static final String HANDNUMBNESS_REPORT = "117";
//
// // ICU报告
// public static final String ICU_REPORT = "121";
//
// // 其他类型 目前来说 是手麻系统的其他三个
public static final String OTHER = "18";
// 检查申请单
public static final String PARAMETER_EXAMAPPLY = "119";
// 输血单
public static final String BLOODAPPLY_REPORT = "120";
// PET/CT报告单
public static final String PETCT_REPORT = "60";
// 检验申请单
//public static final String PARAMETER_EXAMAPPLY = "118";
// 检验报告
public static final String INSPECTION_REPORT = "10";
// 扫描文件
//
// // 检查申请单
// public static final String PARAMETER_EXAMAPPLY = "119";
//
// // 输血单
// public static final String BLOODAPPLY_REPORT = "120";
//
// // PET/CT报告单
// public static final String PETCT_REPORT = "60";
//
// // 检验申请单
// //public static final String PARAMETER_EXAMAPPLY = "118";
//
// // 检验报告
// public static final String INSPECTION_REPORT = "10";
//
// // 扫描文件
public static final String SCANNING_FILE = "30";
// 护理、医生
@ -70,7 +71,7 @@ public class AliasName {
public static final Map<String, String> NURSE_MAP;
// 病案首页
public static final String MEDICAL_RECORD_HOMEPAGE = "3";
// public static final String MEDICAL_RECORD_HOMEPAGE = "3";
static {

@ -51,6 +51,9 @@ public class ArchiveDetail {
*/
private String applyId;
@Column(name = "page_number")
private Integer number;
public ArchiveDetail() {
}
@ -60,4 +63,14 @@ public class ArchiveDetail {
this.assortID = assortID;
this.source = source;
}
public ArchiveDetail(String masterID, Date upLoadDateTime, String assortID, String source, String applyId, String pdfPath,Integer number) {
this.masterID = masterID;
this.upLoadDateTime = upLoadDateTime;
this.assortID = assortID;
this.source = source;
this.applyId = applyId;
this.pdfPath = pdfPath;
this.number = number;
}
}

@ -61,6 +61,8 @@ public class MessageDto<T> {
//20200609 0是老数据 1是新数据
private String isOld;
private String pageNum;
public MessageDto() {
}

@ -133,4 +133,13 @@ public class ArchiveMaster {
* 2019-7-30
*/
private String transferDept;
/**
*
* 2020-12-14
*/
@Column(name = "isscaned")
private String isScaned;
}

@ -13,5 +13,7 @@ public interface HomepageDictionary {
@WebMethod
String DoctorData(@WebParam(name = "xmlStr") String xmlStr);
@WebMethod
String ScanningFile(@WebParam(name = "xmlStr") String xmlStr);
}

@ -47,6 +47,9 @@ public class HomepageDictionaryImpl implements HomepageDictionary {
@Autowired
private ArchiveMasterRepository archiveMasterRepository;
@Autowired
private AnalysisService analysisService;
@Override
public String NurseData(String xmlStr) {
String outContent = "失败";
@ -194,14 +197,16 @@ public class HomepageDictionaryImpl implements HomepageDictionary {
if(! (archiveMaster.getArchiveState().equals("初审") || archiveMaster.getArchiveState().equals("已归档") )){
String addFlag = messageDto.getAddFlag();
if(Objects.equals(addFlag,"delete") || Objects.equals(addFlag,"update") || Objects.equals(addFlag,"insert")){
if(Objects.equals(addFlag,"delete") || Objects.equals(addFlag,"update")
|| Objects.equals(addFlag,"insert") || Objects.equals(addFlag,"")){
if(Objects.equals(messageDto.getIsOld(),"0")){
messageDto.setApplyId(messageDto.getInpNo() + "-" + messageDto.getVisitId()+"-doctor-"+messageDto.getCommitTime());
remark = archiveDetailService.updateAllFlag(messageDto.getApplyId(), messageDto.getSource());
}else if(Objects.equals(messageDto.getIsOld(),"1")){
ArchiveDetail archiveDetail = archiveDetailService.isExit(archiveMaster.getId(), messageDto.getType(), messageDto.getSource(), messageDto.getApplyId());
if(archiveDetail == null && !Objects.equals(addFlag,"insert")){
if(archiveDetail == null && !Objects.equals(addFlag,"insert") ){
remark = messageDto.getSubType()+"没有生成对应的文件不能"+addFlag;
}else{
if(Objects.equals(addFlag,"delete")){
@ -274,4 +279,26 @@ public class HomepageDictionaryImpl implements HomepageDictionary {
}
return outContent;
}
@Override
public String ScanningFile(String xmlStr) {
String outContent = "失败";
try {
boolean flag = false;
String remark = null;
MessageDto messageDto = XMLUtils.xpathToBean(xmlStr, EMRData.class, InterfaceName.SCANNING_FILE);
if (messageDto != null) {
remark = analysisService.handlePdfFile(messageDto);
if(remark == null){
flag = true;
}
} else {
remark = "传过来的消息无法解析。。";
}
outContent = AnalysisService.getReturnResult(flag, remark);
}catch (Exception e){
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e,e.getStackTrace()[0]);
}
return outContent;
}
}

@ -1,11 +1,21 @@
package com.ann.demo.service;
import com.ann.demo.entity.filing.ArchiveDetail;
import com.ann.demo.entity.filing.dto.MessageDto;
import com.ann.demo.entity.interfaceEntity.ArchiveMaster;
import com.ann.demo.entity.normalEntity.OutPara;
import com.ann.demo.utils.DownloadUtils;
import com.ann.demo.utils.FileUtils;
import com.ann.demo.utils.PdfUtils;
import com.ann.demo.utils.XMLUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.Date;
/**
*
*
@ -14,6 +24,10 @@ import org.springframework.stereotype.Component;
*/
@Component
public class AnalysisService {
@Autowired
private ArchiveMasterService archiveMasterService;
@Autowired
private ArchiveDetailService archiveDetailService;
public static String getReturnResult(boolean resultCode,String content) throws Exception {
OutPara outPara = new OutPara();
@ -28,4 +42,30 @@ public class AnalysisService {
}
public String handlePdfFile(MessageDto messageDto) throws Exception{
String pdfPath = "";
ArchiveMaster archiveMaster = archiveMasterService.findByInpNoAndVisitIdAndIsValid(messageDto.getInpNo(),messageDto.getVisitId());
if(archiveMaster == null){
return "没有患者信息";
}
File imageFile = FileUtils.createFile("images", messageDto.getInpNo(), messageDto.getVisitId(),"");
if(DownloadUtils.downloadImageFile(messageDto.getReportAddress(), imageFile) == null){
return "下载图像出错";
}
File pdfFile = FileUtils.createFile("pdfs", messageDto.getInpNo(), messageDto.getVisitId(), messageDto.getApplyId());
//存入pdf地址
pdfPath = PdfUtils.imagesToPdf(imageFile, pdfFile);
if (pdfPath == null) {
return "image转成pdf出错了。。。";
}
ArchiveDetail archiveDetail = new ArchiveDetail(archiveMaster.getId(), new Date(), messageDto.getType(), "嘉时扫描系统", messageDto.getApplyId(), pdfPath,Integer.valueOf(messageDto.getPageNum()));
archiveDetail.setTitle(messageDto.getDetailType());
archiveDetailService.save(archiveDetail);
if(archiveDetail.getId() != null){
archiveMaster.setIsScaned("1");
archiveMasterService.save(archiveMaster);
return null;
}
return "出错了";
}
}

@ -15,4 +15,6 @@ public interface ArchiveDetailService {
ArchiveDetail isExit(String id, String type, String source, String applyId);
boolean delete(String id);
void save(ArchiveDetail archiveDetail);
}

@ -0,0 +1,15 @@
package com.ann.demo.service;
import com.ann.demo.entity.interfaceEntity.ArchiveMaster;
/**
* @Author: LeiJiaXin
* @Date: 2019/7/11 20:53
*/
public interface ArchiveMasterService {
public void save(ArchiveMaster archiveMaster);
public ArchiveMaster findByInpNoAndVisitIdAndIsValid(String inpNo, String visitId) throws Exception;
}

@ -84,4 +84,9 @@ public class ArchiveDetailServiceImpl implements ArchiveDetailService {
return true;
return false;
}
@Override
public void save(ArchiveDetail archiveDetail) {
archiveDetailRepository.save(archiveDetail);
}
}

@ -0,0 +1,28 @@
package com.ann.demo.service.impl;
import com.ann.demo.entity.interfaceEntity.ArchiveMaster;
import com.ann.demo.repository.ArchiveMasterRepository;
import com.ann.demo.service.ArchiveMasterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @Author: LeiJiaXin
* @Date: 2019/7/11 20:53
*/
@Service
public class ArchiveMasterServiceImpl implements ArchiveMasterService {
@Autowired
private ArchiveMasterRepository archiveMasterRepository;
@Override
public void save(ArchiveMaster archiveMaster) {
archiveMasterRepository.save(archiveMaster);
}
@Override
public ArchiveMaster findByInpNoAndVisitIdAndIsValid(String inpNo, String visitId) throws Exception {
return archiveMasterRepository.findByInpNoAndVisitIdAndIsValid(inpNo, visitId, 0);
}
}

@ -0,0 +1,136 @@
package com.ann.demo.utils;
import org.apache.commons.net.ftp.FTPClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* @Description
* @Date 2019/7/2 16:56
* @Created by ljx
*/
public class DownloadUtils {
static final Logger logger = LoggerFactory.getLogger(DownloadUtils.class);
/**
* Url
*
* @param urlStr
* @param fileName
* @param savePath
* @throws IOException
*/
public static void downLoadByUrl(String urlStr, String fileName, String savePath) throws IOException {
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//设置超时间为5秒
conn.setConnectTimeout(5 * 1000);
//防止屏蔽程序抓取而返回403错误
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//得到输入流
InputStream inputStream = conn.getInputStream();
//获取自己数组
byte[] getData = readInputStream(inputStream);
//文件保存位置
File saveDir = new File(savePath);
if (!saveDir.exists()) {
saveDir.mkdir();
}
File file = new File(saveDir + File.separator + fileName);
FileOutputStream fos = new FileOutputStream(file);
fos.write(getData);
if (fos != null) {
fos.close();
}
if (inputStream != null) {
inputStream.close();
}
System.out.println("info:" + url + " download success");
}
/**
*
*
* @param inputStream
* @return
* @throws IOException
*/
public static byte[] readInputStream(InputStream inputStream) throws IOException {
byte[] buffer = new byte[1024];
int len = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
while ((len = inputStream.read(buffer)) != -1) {
bos.write(buffer, 0, len);
}
bos.close();
return bos.toByteArray();
}
//从共享目录下载文件
public static boolean cmdFile(String path, File imageFile) {
boolean result = false;
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
Runtime.getRuntime().exec("net use \\10.6.0.74 his /user:his");
in = new BufferedInputStream(new FileInputStream(path));
out = new BufferedOutputStream(new FileOutputStream(imageFile));
byte[] buffer = new byte[1024];
while (in.read(buffer) != -1) {
out.write(buffer);
buffer = new byte[1024];
}
out.flush();
result = true;
} catch (IOException e) {
// FileUtils.deleteImageFile(imageFile);
logger.error("出错咯!错误信息:" + e);
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException e) {
// FileUtils.deleteImageFile(imageFile);
e.printStackTrace();
}
}
return result;
}
public static String downloadImageFile(String address, File imageFile) throws Exception {
String url = "";
String path = "";
Integer port = 21;
address = address.substring(address.indexOf("/") + 2, address.length());
path = address.substring(address.indexOf("/"), address.length());
//处理url 以及端口 如果有端口 截取 否则默认端口
if (address.indexOf(":") != -1 && address.indexOf("/") != -1) {
port = Integer.parseInt(address.substring(address.indexOf(":") + 1, address.indexOf("/")));
url = address.substring(0, address.indexOf(":"));
}
String userName = "common";
String password = "common";
FTPClient ftpClient = FTPUtil.connectFtpServer(url, port, userName, password);
if (FTPUtil.downloadFtp(path, ftpClient, imageFile)) {
return imageFile.getAbsolutePath();
}
return null;
// return imageFile.getAbsolutePath();
}
}

@ -0,0 +1,181 @@
package com.ann.demo.utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* @Author: LeiJiaXin
* @Date: 2019/8/22 9:17
*/
public class FTPUtil {
static final Logger logger = LoggerFactory.getLogger(FTPUtil.class);
/**
* FTP
*
* @param addr FTP IP
* @param port FTP
* @param username
* @param password
* @return
* @throws Exception
*/
public static FTPClient connectFtpServer(String addr, int port, String username, String password) throws Exception {
FTPClient ftpClient = new FTPClient();
try {
ftpClient.setControlEncoding("UTF-8");
ftpClient.setAutodetectUTF8(true);
// ftpClient.setControlEncoding("UTF-8"); // 设置组件工作字符集为UTF-8
ftpClient.connect(addr, port);
/** FTP
* 1使使 "Anonymous"*/
if (StringUtils.isBlank(username)) {
ftpClient.login("Anonymous", "");
} else {
ftpClient.login(username, password);
}
/**
* BINARY_FILE_TYPE
* ASCII_FILE_TYPEASCII
* ....
*/
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
/**
*
* 2 isPositiveCompletion true
* return (reply >= 200 && reply < 300);
*/
int reply = ftpClient.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
/**
* FTP
* abort true, false
* disconnect
*/
ftpClient.abort();
ftpClient.disconnect();
}
} catch (IOException e) {
throw e;
}
return ftpClient;
}
/**
* 使
* ftp
* ftp
*
* @param ftpClient
* @return
*/
public static FTPClient closeFTPConnect(FTPClient ftpClient) throws Exception {
try {
if (ftpClient != null && ftpClient.isConnected()) {
ftpClient.abort();
ftpClient.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
}
return ftpClient;
}
public static boolean downloadFtp(String path, FTPClient ftp, File file) throws Exception {
InputStream is = null;
FileOutputStream fos = null;
boolean result = false;
try {
is = ftp.retrieveFileStream(path);
if(is != null){
byte[] bytes = new byte[1024];
int i;
fos = new FileOutputStream(file);
while ((i = is.read(bytes)) != -1) {
fos.write(bytes, 0, i);
}
closeFTPConnect(ftp);
}
if(file.length() == 0){
FileUtils.deleteImageFile(file);
}else{
result = true;
}
} catch (Exception e) {
FileUtils.deleteImageFile(file);
throw e;
} finally {
try {
if (fos != null) {
fos.close();
}
if (is != null) {
is.close();
}
} catch (IOException e) {
FileUtils.deleteImageFile(file);
throw e;
}
}
return result;
}
public static boolean deleteFile(String address) throws Exception {
boolean flag = false;
FTPClient ftpClient = null;
try {
String url = "";
String path = "";
Integer port = 21;
// 处理 “/”
if (address.indexOf("/") == -1) {
address = address.replace("\\", "/");
}
address = address.substring(address.indexOf("/") + 2, address.length());
path = address.substring(address.indexOf("/"), address.length());
url = address.substring(0, address.indexOf("/"));
ftpClient = connectFtpServer(url, port, "his", "his_docus");
// 切换FTP目录
ftpClient.changeWorkingDirectory("/");
int dele = ftpClient.dele(path);
logger.error("删除FTP文件为{}",address);
flag = true;
} catch (Exception e) {
throw e;
} finally {
if (ftpClient != null && ftpClient.isConnected()) {
try {
ftpClient.disconnect();// 断开连接如果想连续删除就得把finally块注掉
} catch (IOException e) {
e.printStackTrace();
}
}
}
return flag;
}
public static void main(String[] args) throws Exception {
/* String address = "ftp://10.6.0.241/02019-08-29.png;ftp://10.6.0.241/12019-08-29.png";
File imageFile = FileUtils.createFile("images","2019","0827", "阿雷小猴子" );
File pdfFile = FileUtils.createFile("pdfs","2019","0827", "阿雷小猴子" );
String s = DownloadUtils.downloadImageFiles(address, imageFile.getParent());
// 图片那么转成pdf
String pdfPath = PdfUtils.imageDirToPdf(s,pdfFile);
System.out.println(pdfPath);*/
}
}

@ -0,0 +1,210 @@
package com.ann.demo.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.*;
import java.time.LocalDate;
import java.util.Objects;
/**
* @Author: LeiJiaXin
* @Date: 2019/7/24 16:42
*/
@Component
public class FileUtils {
static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
// pdf地址
public static String pdfPath;
@Value("${file.pdfPath}")
public void setPdfPath(String pdfPath) {
FileUtils.pdfPath = pdfPath;
}
public static String getPdfPath() {
return pdfPath;
}
// image地址
public static String imagePath;
@Value("${file.imagePath}")
public void setImagePath(String imagePath) {
FileUtils.imagePath = imagePath;
}
public static String getImagePath() {
return imagePath;
}
public static File createFile(String fileType, String inpNo, String visitId, String path) throws IOException {
File localFile = null;
try {
//生成图片地址
// ---------------------------此处写死 年月需改善
LocalDate date = LocalDate.now();
String fileDirName = null;
if (Objects.equals(fileType, "images")) {
fileDirName = imagePath+ date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
} else if (Objects.equals(fileType, "pdfs")) {
fileDirName = pdfPath + "/" + date.getYear() + "/" + date.getMonthValue() + "/" + inpNo + "_" + visitId;
}
//判断是否有该文件夹 否则创建
File fileDir = new File(fileDirName);
if (!fileDir.exists()) {
fileDir.mkdirs();
}
String fileName = null;
if (Objects.equals(fileType, "images")) {
fileName = fileDir + "/" + path + ".jpg";
} else if (Objects.equals(fileType, "pdfs")) {
fileName = fileDir + "/" + path + ".pdf";
}
localFile = new File(fileName);
if (!localFile.exists()) {
localFile.createNewFile();
}
} catch (IOException e) {
logger.error("出错咯!错误信息:" + e);
throw e;
}
return localFile;
}
public static void deleteImageFile(File file) {
if (!file.exists()) {
System.out.println(file.getAbsolutePath() + "文件不存在");
} else {
if (file.length() == 0) {
// 当前文件 大小为0
File fileParent = new File(file.getParent());
File[] fileParents = fileParent.listFiles();
// 如果文件个数大于1 那么已经有其他的报告 只删除本身 否则就删除当前文件以及父级目录
if (fileParents.length > 1) {
// -----------------------------改成log 形式
file.delete();
System.out.println("删除文件为:" + file.getAbsolutePath());
} else {
file.delete();
fileParent.delete();
System.out.println("删除文件为:" + file.getAbsolutePath() + ",以及父文件:" + fileParent.getName());
}
}
}
}
public static int deleteImageFile1(File file, int i) {
if (!file.exists()) {
System.out.println(file.getAbsolutePath() + "文件不存在");
return i;
} else {
// 当前文件 大小为0
File fileParent = new File(file.getParent());
File[] fileParents = fileParent.listFiles();
// 如果文件个数大于1 那么已经有其他的报告 只删除本身 否则就删除当前文件以及父级目录
if (fileParents.length > 1) {
// -----------------------------改成log 形式
file.delete();
System.out.println("删除文件为:" + file.getAbsolutePath());
} else {
file.delete();
fileParent.delete();
System.out.println("删除文件为:" + file.getAbsolutePath() + ",以及父文件:" + fileParent.getName());
}
return i++;
}
}
public static File getImageFileByByteArray(Object[] objects, File file) throws Exception {
OutputStream out = null;
InputStream is = null;
try {
out = new FileOutputStream(file);
is = new ByteArrayInputStream((byte[])objects[0]);
byte[] buff = new byte[1024];
int len = 0;
while((len=is.read(buff))!=-1){
out.write(buff, 0, len);
}
return file;
} catch (Exception e) {
FileUtils.deleteImageFile(file);
logger.error("出错咯!错误信息:" + e);
throw e;
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e1) {
FileUtils.deleteImageFile(file);
logger.error("出错咯!错误信息:" + e1);
throw e1;
}
}
if (is != null) {
try {
is.close();
} catch (IOException e1) {
FileUtils.deleteImageFile(file);
logger.error("出错咯!错误信息:" + e1);
throw e1;
}
}
}
}
public static String haha(String path,byte[] bytes){
int n = 1024;
FileOutputStream os = null;
try {
// 创建文件输出流对象
File file = new File(path);
os= new FileOutputStream(file);
// 写入输出流
int length = bytes.length;
int start = 0;
while(length>start+n){
os.write(bytes, start, n);
start= start+n;
}
if(length != start+n){
n = length-start;
os.write(bytes, start, n);
}
return path;
} catch (IOException e) {
return null;
}finally{
// 关闭输出流
try {
if(os !=null){
os.close();
}
} catch (IOException e) {
return null;
}
}
}
public static void main(String[] args) throws ClassNotFoundException {
String address = "ftp://10.6.0.155/2019-10-21/000581031700_1_000581031700_0_1_JHR06.00.02_34_2_0.pdf";
String a = address.substring(0, address.indexOf(".pdf"));
String emrPath = a.substring(a.lastIndexOf("_") + 1, a.length());
System.out.println(emrPath);
}
}

@ -0,0 +1,64 @@
package com.ann.demo.utils;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @Author: LeiJiaXin
* @Date: 2019/7/11 22:32
*/
public class PdfUtils {
static final Logger logger = LoggerFactory.getLogger(PdfUtils.class);
/**
* pdf
*
* @param imageFile
* @param pdfFile
*/
public static String imagesToPdf(File imageFile, File pdfFile) throws IOException, DocumentException {
String fileName = null;
try {
// 第一步创建一个document对象。
Document document = new Document();
document.setMargins(0, 0, 0, 0);
// 第二步:
// 创建一个PdfWriter实例
PdfWriter.getInstance(document, new FileOutputStream(pdfFile));
// 第三步:打开文档。
document.open();
// 第四步:在文档中增加图片。
if (imageFile.getName().endsWith(".bmp")
|| imageFile.getName().endsWith(".jpg")
|| imageFile.getName().endsWith(".jpeg")
|| imageFile.getName().endsWith(".gif")
|| imageFile.getName().endsWith(".png")) {
String imagesPath = imageFile.getAbsolutePath();
Image img = Image.getInstance(imagesPath);
img.setAlignment(Image.ALIGN_CENTER);
// 根据图片大小设置页面一定要先设置页面再newPage否则无效
document.setPageSize(new Rectangle(img.getWidth(), img.getHeight()));
document.newPage();
document.add(img);
}
// 第五步:关闭文档。
document.close();
//返回pdf路径
fileName = pdfFile.getAbsolutePath();
} catch (Exception e) {
logger.error("出错咯!错误信息:" + e);
throw e;
}
return fileName;
}
}

@ -1,6 +1,7 @@
package com.ann.demo.utils;
import com.alibaba.fastjson.JSON;
import com.ann.demo.entity.constant.AliasName;
import com.ann.demo.entity.constant.InterfaceName;
import com.ann.demo.entity.filing.dto.MessageDto;
import com.ann.demo.entity.interfaceEntity.*;
@ -55,13 +56,22 @@ public class XMLUtils {
@Value("${file.nurseDataPath}")
private String nurseDataPathTemp;
// 扫描文件
public static String scanningFilePath;
@Value("${file.scanningFilePath}")
private String scanningFilePathTemp;
@PostConstruct
public void init() {
path = pathTemp;
nurseDataPath = nurseDataPathTemp;
doctorDataPath = doctorDataPathTemp;
scanningFilePath = scanningFilePathTemp;
}
// private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
// 病案首页独享
// private static SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
@ -191,6 +201,9 @@ public class XMLUtils {
case InterfaceName.DOCTOR_DATA: // 医生
messageDto = new MessageDto(EMRData.class.getName(), new EMRData(), "", doctorDataPath, source);
break;
case InterfaceName.SCANNING_FILE:
messageDto = new MessageDto(EMRData.class.getName(), new EMRData(), AliasName.SCANNING_FILE, scanningFilePath, InterfaceName.SCANNING_FILE);
break;
}
return messageDto;
}

@ -11,7 +11,7 @@ spring:
# hibernate:
# ddl-auto: update
# database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
# url: jdbc:sqlserver://120.27.212.36:1433;DatabaseName=emr_record
## url: jdbc:sqlserver://120.27.212.36:1433;DatabaseName=emr_record
url: jdbc:sqlserver://10.6.1.127:1433;DatabaseName=DB_PrivilegeManagement_GYFY
username: sa
password: docus@702
@ -47,4 +47,7 @@ file:
path: D:\\1\MCCI_IN000002UV01.xml
doctorDataPath: D:\\1\doctorData.properties
nurseDataPath: D:\\1\nurseData.properties
pdfPath: Z:/project_js/docus_scanningfile/
imagePath: Z:/images/docus_scanningfile/
scanningFilePath: D:\\1\scanningFile.properties

@ -31,6 +31,7 @@
<option value="BloodTransfusionUrl">BloodTransfusionUrl</option>
<option value="NurseData">NurseData</option>
<option value="DoctorData">DoctorData</option>
<option value="ScanningFile">ScanningFile</option>
</select>
</div>
</div>
@ -45,6 +46,7 @@
<option value="InpatientTransferRequest">转科记录</option>
<option value="ExamApplyRequest">检查申请单</option>
<option value="LisSendReportBack">检验报告</option>
</select>
</div>
</div>

Loading…
Cancel
Save