1、新增错误日志补充

master
leijx 4 years ago
parent 24812ecda7
commit e0c852f8cd

@ -15,12 +15,14 @@ import com.ann.demo.interfaces.HomepageDictionary;
import com.ann.demo.repository.ArchiveMasterRepository; import com.ann.demo.repository.ArchiveMasterRepository;
import com.ann.demo.repository.MessageScanningRepository; import com.ann.demo.repository.MessageScanningRepository;
import com.ann.demo.service.*; import com.ann.demo.service.*;
import com.ann.demo.utils.FileUtils;
import com.ann.demo.utils.XMLUtils; import com.ann.demo.utils.XMLUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.jws.WebService; import javax.jws.WebService;
import java.io.IOException;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
@ -154,13 +156,13 @@ public class HomepageDictionaryImpl implements HomepageDictionary {
messageSubordinateService.save(new MessageSubordinate(messageLog.getId(), patientMainStr, JSON.toJSONString(messageLog))); messageSubordinateService.save(new MessageSubordinate(messageLog.getId(), patientMainStr, JSON.toJSONString(messageLog)));
} }
}catch (Exception e){ }catch (Exception e){
// 生成一个临时文件
try { try {
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e,e.getStackTrace()[0]); logger.error("消息出错,请检查消息内容,错误详情:{},消息所在位置:{}",e.getMessage(), FileUtils.createFile("NurseData",null,xmlStr));
return AnalysisService.getReturnResult(false,e.toString()); } catch (IOException e1) {
} catch (Exception e1) {
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e1,e1.getStackTrace()[0]);
return outContent; return outContent;
} }
return outContent;
} }
return outContent; return outContent;
} }
@ -260,12 +262,13 @@ public class HomepageDictionaryImpl implements HomepageDictionary {
messageSubordinateService.save(new MessageSubordinate(messageLog.getId(), patientMainStr, JSON.toJSONString(messageLog))); messageSubordinateService.save(new MessageSubordinate(messageLog.getId(), patientMainStr, JSON.toJSONString(messageLog)));
} }
}catch (Exception e){ }catch (Exception e){
// 生成一个临时文件
try { try {
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e,e.getStackTrace()[0]); logger.error("消息出错,请检查消息内容,错误详情:{},消息所在位置:{}",e.getMessage(), FileUtils.createFile("DoctorData",null,xmlStr));
return AnalysisService.getReturnResult(false,e.toString()); } catch (IOException e1) {
} catch (Exception e1) { return outContent;
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e1,e1.getStackTrace()[0]);
} }
return outContent;
} }
return outContent; return outContent;
} }

@ -4,10 +4,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.io.*; import java.io.*;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Objects; import java.util.Objects;
import java.util.UUID;
/** /**
* @Author: LeiJiaXin * @Author: LeiJiaXin
@ -20,29 +22,36 @@ public class FileUtils {
// pdf地址 // pdf地址
public static String pdfPath; public static String pdfPath;
@Value("${file.pdfPath}") @Value("${file.pdfPath}")
public void setPdfPath(String pdfPath) { public void setPdfPath(String pdfPath) {
FileUtils.pdfPath = pdfPath; FileUtils.pdfPath = pdfPath;
} }
public static String getPdfPath() { public static String getPdfPath() {
return pdfPath; return pdfPath;
} }
// image地址 // image地址
public static String imagePath; public static String imagePath;
@Value("${file.imagePath}") @Value("${file.imagePath}")
public void setImagePath(String imagePath) { public void setImagePath(String imagePath) {
FileUtils.imagePath = imagePath; FileUtils.imagePath = imagePath;
} }
public static String getImagePath() { public static String getImagePath() {
return imagePath; return imagePath;
} }
// 错误文件地址
public static String errorPath;
@Value("${file.errorPath}")
public void setErrorPath(String errorPath) {
FileUtils.errorPath = errorPath;
}
public static String getErrorPath() {
return errorPath;
}
public static File createFile(String fileType, String inpNo, String visitId, String path) throws IOException { public static File createFile(String fileType, String inpNo, String visitId, String path) throws IOException {
File localFile = null; File localFile = null;
try { try {
@ -82,6 +91,47 @@ public class FileUtils {
} }
public static String createFile(String interfaceName, String param,String message) throws IOException {
File localFile = null;
OutputStreamWriter write = null;
BufferedWriter writer = null;
try {
//生成文件地址
LocalDate date = LocalDate.now();
String fileDirName = null;
fileDirName = errorPath+"/" + date.getYear() + "/" + date.getMonthValue() + "/" + interfaceName;
// 如果参数不为空时,再增加一级目录
if(!ObjectUtils.isEmpty(param)){
fileDirName += "_" + param;
}
//判断是否有该文件夹 否则创建
File fileDir = new File(fileDirName);
if (!fileDir.exists()) {
fileDir.mkdirs();
}
String fileName = fileDir + "/" + UUID.randomUUID() + ".txt";
localFile = new File(fileName);
if (!localFile.exists()) {
localFile.createNewFile();
}
write = new OutputStreamWriter(new FileOutputStream(localFile));
writer = new BufferedWriter(write);
writer.write(message);
writer.flush();
} catch (IOException e) {
throw e;
}finally {
if(!ObjectUtils.isEmpty(write)){
write.close();
}
if(!ObjectUtils.isEmpty(writer)){
writer.close();
}
}
return localFile.getAbsolutePath();
}
public static void deleteImageFile(File file) { public static void deleteImageFile(File file) {
if (!file.exists()) { if (!file.exists()) {
System.out.println(file.getAbsolutePath() + "文件不存在"); System.out.println(file.getAbsolutePath() + "文件不存在");

@ -1,26 +1,26 @@
spring: spring:
datasource: datasource:
# url: jdbc:mysql://localhost:3306/test url: jdbc:mysql://localhost:3306/test
# # url: jdbc:mysql://10.6.1.127:3306/test # url: jdbc:mysql://10.6.1.127:3306/test
# username: root username: root
# password: 123456 password: 123456
# driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
# jpa:
# database: mysql
# show-sql: false
# hibernate:
# ddl-auto: update
# database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
# 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
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
jpa: jpa:
database: sql_server database: mysql
show-sql: false show-sql: false
hibernate: hibernate:
dialect: org.hibernate.dialect.SQLServer2008Dialect ddl-auto: update
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
# 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
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# jpa:
# database: sql_server
# show-sql: false
# hibernate:
# dialect: org.hibernate.dialect.SQLServer2008Dialect
hikari: hikari:
#是否为只读数据库 #是否为只读数据库
read-only: false read-only: false
@ -50,4 +50,5 @@ file:
pdfPath: Z:/project_js/docus_scanningfile_20201216/ pdfPath: Z:/project_js/docus_scanningfile_20201216/
imagePath: Z:/images/docus_scanningfile_20201216/ imagePath: Z:/images/docus_scanningfile_20201216/
scanningFilePath: D:\\1\scanningFile.properties scanningFilePath: D:\\1\scanningFile.properties
errorPath: D:/logs/errorMessage/

Loading…
Cancel
Save