添加配置与系统错误持久请求
parent
38d6032c34
commit
17edf03886
@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"hospital": "emr",
|
||||
"wzh": "1"
|
||||
},{
|
||||
"hospital": "hl",
|
||||
"wzh": "3"
|
||||
},{
|
||||
"hospital": "sy",
|
||||
"wzh": "6"
|
||||
},{
|
||||
"hospital": "hz",
|
||||
"wzh": "13"
|
||||
}
|
||||
]
|
@ -0,0 +1,63 @@
|
||||
package com.docus.server.collection.util;
|
||||
|
||||
import com.docus.core.util.DateUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author wyb
|
||||
*/
|
||||
public class PersistRequestUtil {
|
||||
private final static Logger logger = LoggerFactory.getLogger(PersistRequestUtil.class);
|
||||
|
||||
public static void persistRequest(String method, String content) {
|
||||
String persistDir = currentPath() + File.separator + "persist";
|
||||
FileWriter fileWriter = null;
|
||||
BufferedWriter bufferedWriter = null;
|
||||
try {
|
||||
File persistDirFile = new File(persistDir);
|
||||
if (!persistDirFile.exists()) {
|
||||
persistDirFile.mkdirs();
|
||||
}
|
||||
String persistFilePath = persistDir + File.separator + method;
|
||||
fileWriter = new FileWriter(persistFilePath, true);
|
||||
bufferedWriter = new BufferedWriter(fileWriter);
|
||||
content = "[" + DateUtil.formatDateTime(new Date()) + "] " + content + "\n";
|
||||
bufferedWriter.write(content);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
} finally {
|
||||
if (bufferedWriter != null) {
|
||||
try {
|
||||
bufferedWriter.close();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
if (fileWriter != null) {
|
||||
try {
|
||||
fileWriter.close();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
persistRequest("test","{xxcc}");
|
||||
}
|
||||
public static String currentPath() {
|
||||
File dir = new File(".");
|
||||
String currentpath = "";
|
||||
|
||||
try {
|
||||
currentpath = dir.getCanonicalPath();
|
||||
} catch (IOException var4) {
|
||||
var4.printStackTrace();
|
||||
}
|
||||
|
||||
return currentpath;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue