修复 文件导出

This commit is contained in:
yf 2025-01-20 10:41:35 +08:00
parent 4f061b363d
commit e01f3c9918
1 changed files with 12 additions and 6 deletions

View File

@ -1217,7 +1217,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
throw exception(ErrorCodeConstants.SALE_ORDER_NOT_FILE_EXPORT);
}
// 通过容器创建文件
String pathUrl = System.getProperty("user.dir") + "/pdffile/dsf";
pathUrl = pathUrl.replaceAll("//", "/");
File file1 = new File(pathUrl);
@ -1225,6 +1225,7 @@ public class SaleOrderServiceImpl implements SaleOrderService {
System.out.println("创建目录:"+pathUrl);
file1.mkdirs();
}
// 主机地址
String targetPath = pdfPath + "/dsf";
targetPath = targetPath.replaceAll("//", "/");
List<File> files = new ArrayList<>();
@ -1236,22 +1237,27 @@ public class SaleOrderServiceImpl implements SaleOrderService {
Long entryId = skuDO.getEntryId();
String s = FuncUtil.toStr(codeMap.get(entryId),skuDO.getId().toString());
Integer orderQty = skuDO.getOrderQty();
//主宿机生成路径
String name = DateUtil.format(LocalDateTime.now(), "yyyyMMdd")
+"-"+IdUtil.simpleUUID().substring(0, 4);
String ouput = StrUtil.format(targetPath + "/{}_{}.pdf",(s+"_"+orderQty),name);
String templatePath2 = StrUtil.format(targetPath + "/{}_{}.html",(s+"_"+orderQty),name);
// 创建文件
String templatePath2 = StrUtil.format(pathUrl + "/{}_{}.html",(s+"_"+orderQty),name);
try {
FileUtil.touch(templatePath2);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("templatePath2"+templatePath2);
//宿主机pdf生成路径
String ouput = StrUtil.format(targetPath + "/{}_{}.pdf",(s+"_"+orderQty),name);
// 宿主机html地址
String inputPath = StrUtil.format(targetPath + "/{}_{}.html",(s+"_"+orderQty),name);
String htmlText = HttpUtil.get(sourceFile);
FileUtil.writeString(htmlText, templatePath2, "UTF-8");
//请求wkapp
JSONObject params = new JSONObject();
params.put("input_html_path", templatePath2);
params.put("input_html_path", inputPath);
params.put("output_pdf_path", ouput);
System.out.println("params"+params);
log.info("稿件导出 请求wkapp接口url" + wkappUrl + "/exehtmltopdf");