From 3423bb9ee5b25d270a00763b69ed73970d790f63 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期二, 18 二月 2025 16:43:43 +0800 Subject: [PATCH] update --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java | 42 ++++++++++++++++++++++++++++++++---------- 1 files changed, 32 insertions(+), 10 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java index c9c68b1..87eac22 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/LogTableServiceImpl.java @@ -29,10 +29,14 @@ import javax.annotation.Resource; import java.io.File; import java.net.InetAddress; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.sql.Connection; import java.sql.SQLException; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author Lius @@ -77,7 +81,7 @@ @Resource private IMdcPassLogService mdcPassLogService; - private static final String TYPE = "01"; + private static final String TYPE = "18"; @Resource private SqlExecutor sqlExecutor; @@ -107,16 +111,22 @@ // 鏂囦欢璺緞 String locFilePath = localFilePath + TYPE + today + String.format("%06d", sequenceNumber) + ".xml"; - FileWriter writer = new FileWriter(locFilePath); - writer.writeLines(sqlList); +// FileWriter writer = new FileWriter(locFilePath); +// writer.writeLines(sqlList); + String listSql = String.join("\n", sqlList); + try { + FileUtils.fileWriterSql(locFilePath, listSql); + } catch (Exception e) { + throw new JeecgBootException("鏁版嵁鍐欏叆鏂囦欢澶辫触锛�"); + } // step.4 鎺ㄩ�佺綉闂� // step.4.1 娴嬭瘯鏈嶅姟鍣ㄨ繛閫氭�� - boolean ping = NetUtil.ping(host + ":" + port); + /* boolean ping = NetUtil.ping(host + ":" + port); if (!ping) { FileUtil.del(locFilePath); throw new JeecgBootException("鏈嶅姟鍣ㄨ繛鎺ワ細 " + host + ":" + port + " 寮傚父锛�"); - } + }*/ // step.4.2 鑾峰彇token String token = ""; @@ -167,12 +177,19 @@ objectName.setDestination(host); objectName.setResult("澶辫触"); // 鏈湴鏂囦欢璺緞 - String loFilePath = localFilePath + "\\" + file.getName(); + String loFilePath = localFilePath + file.getName(); // 鐩爣鏂囦欢璺緞 - String servicePathName = servicePath + "\\" + file.getName(); + String servicePathName = servicePath + file.getName(); String result = FileClient.uploadFile(host, port, token, file.getName(), servicePathName, loFilePath, addressUploadFile); if ("鎴愬姛".equals(result)) { - FileUtil.del(loFilePath); + if (sequenceNumber == 1) { + // 鍒犻櫎鏄ㄦ棩澶囦唤鏂囦欢澶逛腑鍘嗗彶鏂囦欢 + FileUtil.clean(newFilePath); + } + // 鎴愬姛涔嬪悗灏嗘枃浠跺浠借蛋 + FileUtil.move(new File(locFilePath), new File(newFilePath + fileName), true); +// FileUtil.copy(locFilePath, newFilePath + fileName, true); +// FileUtil.del(loFilePath); objectName.setResult("鎴愬姛"); SyslogClient.sendClient(logIp, Integer.valueOf(logPort), objectName.toString()); } else { @@ -203,7 +220,7 @@ File[] files = FileUtil.ls(localFilePath); for (File file : files) { if (file.isFile()) { - String loFilePath = localFilePath + "\\" + file.getName(); + String loFilePath = localFilePath + file.getName(); FileReader fileReader = new FileReader(loFilePath); String sqlList = fileReader.readString(); try { @@ -211,8 +228,13 @@ } catch (Exception e) { throw new JeecgBootException("鎵цsql澶辫触锛�"); } + if (Integer.parseInt(file.getName().substring(file.getName().length() - 10, file.getName().length() - 4)) == 1) { + // 鍒犻櫎鍘嗗彶鏂囦欢 + FileUtil.clean(newFilePath); + } + // 澶囦唤 - FileUtil.move(new File(loFilePath), new File(newFilePath + "\\" + file.getName()), true); + FileUtil.move(new File(loFilePath), new File(newFilePath + file.getName()), true); } } } -- Gitblit v1.9.3