diff --git a/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java b/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java index 36511603c..2478cda41 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java +++ b/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java @@ -1,11 +1,17 @@ package org.springblade.common.utils; +import cn.hutool.core.lang.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springblade.common.constant.CommonConstant; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Writer; import java.net.HttpURLConnection; import java.net.URL; import java.util.Calendar; @@ -29,16 +35,17 @@ public class FileLogsUtil { String imgPath = CommonConstant.SYSTEMFILEPATH + "logs/"; - //根据当前时间 按照 年/月/日 创建一个文件 + // 根据当前时间 按照 年/月/日 创建一个文件 imgPath = imgPath + dataString; - // 判断文件夹是否存在 + // 判断文件夹是否存在 File imgPathFile = new File(imgPath); if (!imgPathFile.exists()) { imgPathFile.mkdirs(); } // 按照年-月-日 创建一个字符串 - String fileName = System.currentTimeMillis() + ".log"; + // 使用 uuid 作为文件名 确保文件唯一 + String fileName = UUID.randomUUID().toString() + ".log"; Writer writer = null; try { @@ -67,7 +74,7 @@ public class FileLogsUtil { public static String loadFileContent(String urlString) { try { - log.info(">>>> 开始下载 {}",urlString); + log.info(">>>> 开始下载 {}", urlString); URL url = new URL(urlString); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); @@ -78,7 +85,7 @@ public class FileLogsUtil { content.append(inputLine); } in.close(); - log.info(">>>> 结束下载 {}",urlString); + log.info(">>>> 结束下载 {}", urlString); return content.toString(); } catch (Exception e) { e.printStackTrace(); @@ -90,12 +97,12 @@ public class FileLogsUtil { StringBuilder stringBuffer = new StringBuilder(); Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); //放入Date类型数据 - //获取年份 + calendar.setTime(date); // 放入Date类型数据 + // 获取年份 stringBuffer.append(calendar.get(Calendar.YEAR)).append("/"); - //获取月份 + // 获取月份 stringBuffer.append(calendar.get(Calendar.MONTH) + 1).append("/"); - //获取日份 + // 获取日份 stringBuffer.append(calendar.get(Calendar.DATE)).append("/"); return stringBuffer.toString(); diff --git a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/feign/FactoryDataZbomClient.java b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/feign/FactoryDataZbomClient.java index b621af8f4..4b37814e5 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/feign/FactoryDataZbomClient.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/feign/FactoryDataZbomClient.java @@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil; import com.logpm.factorydata.zbom.service.FactoryLogService; import com.logpm.factorydata.zbom.vo.ZBReceiptDTO; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.RestController; @@ -13,12 +14,14 @@ import org.springframework.web.bind.annotation.RestController; */ @RestController @AllArgsConstructor +@Slf4j public class FactoryDataZbomClient implements IFactoryDataZbomClient { private final FactoryLogService factoryLogService; @Override public R order(String data) { + log.info("接收工厂订单:{}", data); factoryLogService.orderData(JSONUtil.toBean(data, ZBReceiptDTO.class)); return R.success("成功"); }