refactor(utils): 优化HTML转图片工具类的时间戳生成方式
- 引入IdUtil雪花算法ID替代时间戳 - 修改文件命名策略为基于唯一ID的方式 - 在WMS管理模块中应用新的ID生成方式 - 在WMS发货模块中统一ID生成逻辑 - 保持原有的临时文件目录创建和清理机制不变
This commit is contained in:
parent
bef4bbd18e
commit
2ddaedeb99
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.wms.admin.util;
|
package com.nflg.wms.admin.util;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -28,7 +29,7 @@ public class HtmlToImageUtil {
|
||||||
if (!Files.exists(tempDir)) {
|
if (!Files.exists(tempDir)) {
|
||||||
Files.createDirectories(tempDir);
|
Files.createDirectories(tempDir);
|
||||||
}
|
}
|
||||||
long t = System.currentTimeMillis();
|
String t = IdUtil.getSnowflakeNextIdStr();
|
||||||
inputHtmlPath = tempDir.resolve("input_" + t + ".html");
|
inputHtmlPath = tempDir.resolve("input_" + t + ".html");
|
||||||
outputImgPath = tempDir.resolve("output_" + t + ".png");
|
outputImgPath = tempDir.resolve("output_" + t + ".png");
|
||||||
Files.write(inputHtmlPath, htmlContent.getBytes());
|
Files.write(inputHtmlPath, htmlContent.getBytes());
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.wms.shipment.util;
|
package com.nflg.wms.shipment.util;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -10,6 +11,7 @@ import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class HtmlToImageUtil {
|
public class HtmlToImageUtil {
|
||||||
|
|
@ -28,7 +30,7 @@ public class HtmlToImageUtil {
|
||||||
if (!Files.exists(tempDir)) {
|
if (!Files.exists(tempDir)) {
|
||||||
Files.createDirectories(tempDir);
|
Files.createDirectories(tempDir);
|
||||||
}
|
}
|
||||||
long t = System.currentTimeMillis();
|
String t = IdUtil.getSnowflakeNextIdStr();
|
||||||
inputHtmlPath = tempDir.resolve("input_" + t + ".html");
|
inputHtmlPath = tempDir.resolve("input_" + t + ".html");
|
||||||
outputImgPath = tempDir.resolve("output_" + t + ".png");
|
outputImgPath = tempDir.resolve("output_" + t + ".png");
|
||||||
Files.write(inputHtmlPath, htmlContent.getBytes());
|
Files.write(inputHtmlPath, htmlContent.getBytes());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue