This commit is contained in:
parent
bd20b3ef05
commit
377eec9d81
|
|
@ -22,6 +22,7 @@ import cn.hangtag.module.oms.service.customer.CustomerService;
|
|||
import cn.hangtag.module.oms.service.productinfo.ProductInfoService;
|
||||
import cn.hangtag.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.hangtag.module.system.service.user.AdminUserService;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
|
|
@ -211,34 +212,38 @@ public class DeliveryOrderServiceImpl implements DeliveryOrderService {
|
|||
List<DeliveryOrderDO> deliveryOrders = deliveryOrderMapper.selectList(DeliveryOrderDO::getId, ids);
|
||||
for (DeliveryOrderDO deliveryOrder : deliveryOrders) {
|
||||
List<DeliveryOrderEntryDO> entrys = getDeliveryOrderEntryListByParentId(deliveryOrder.getId());
|
||||
String htmlContent = generateHtmlContent(deliveryOrder, entrys);
|
||||
List<List<DeliveryOrderEntryDO>> split = ListUtil.split(entrys, 6);
|
||||
int i = 1;
|
||||
for (List<DeliveryOrderEntryDO> entrys2 : split) {
|
||||
String htmlContent = generateHtmlContent(deliveryOrder, entrys2);
|
||||
|
||||
//docker生成路径
|
||||
String pathUrl = System.getProperty("user.dir") + "/pdffile";
|
||||
String fileName = StrUtil.format(pathUrl + "/DeliveryOrder_{}", deliveryOrder.getBillno() + "_" + i);
|
||||
//主宿机生成路径
|
||||
String fileName2 = StrUtil.format(pdfPath + "/DeliveryOrder_{}", deliveryOrder.getBillno() + "_" + i);
|
||||
|
||||
//docker生成路径
|
||||
String pathUrl = System.getProperty("user.dir") + "/pdffile";
|
||||
String fileName = StrUtil.format(pathUrl + "/DeliveryOrder_{}", deliveryOrder.getBillno());
|
||||
//主宿机生成路径
|
||||
String fileName2 = StrUtil.format(pdfPath + "/DeliveryOrder_{}", deliveryOrder.getBillno());
|
||||
String templatePath = fileName + ".html";
|
||||
String pdfPath = fileName + ".pdf";
|
||||
String templatePath2 = fileName2 + ".html";
|
||||
String pdfPath2 = fileName2 + ".pdf";
|
||||
FileUtil.writeString(htmlContent, templatePath, "UTF-8");
|
||||
|
||||
String templatePath = fileName + ".html";
|
||||
String pdfPath = fileName + ".pdf";
|
||||
String templatePath2 = fileName2 + ".html";
|
||||
String pdfPath2 = fileName2 + ".pdf";
|
||||
FileUtil.writeString(htmlContent, templatePath, "UTF-8");
|
||||
|
||||
log.info("已生成HTML文件:" + templatePath);
|
||||
//请求wkapp
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("input_html_path", "file://" + templatePath2);
|
||||
params.put("output_pdf_path", pdfPath2);
|
||||
log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf");
|
||||
String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params, 5 * 60 * 1000);
|
||||
log.info("请求wkapp接口返回结果:" + result);
|
||||
//WKHtmlToPdfUtil.convert(templatePath, pdfPath);
|
||||
File file = FileUtil.file(pdfPath);
|
||||
files.add(file);
|
||||
delFiles.add(pdfPath);
|
||||
delFiles.add(templatePath);
|
||||
log.info("已生成HTML文件:" + templatePath);
|
||||
//请求wkapp
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("input_html_path", "file://" + templatePath2);
|
||||
params.put("output_pdf_path", pdfPath2);
|
||||
log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf");
|
||||
String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params, 5 * 60 * 1000);
|
||||
log.info("请求wkapp接口返回结果:" + result);
|
||||
//WKHtmlToPdfUtil.convert(templatePath, pdfPath);
|
||||
File file = FileUtil.file(pdfPath);
|
||||
files.add(file);
|
||||
delFiles.add(pdfPath);
|
||||
delFiles.add(templatePath);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
String pathUrl = System.getProperty("user.dir") + "/pdffile";
|
||||
String zipFileName = StrUtil.format(pathUrl + "/DeliveryOrder_{}", new Date().getTime());
|
||||
|
|
|
|||
|
|
@ -476,29 +476,50 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
//saleOrder.setSaleContractCode(saleContractVO.getBillno());
|
||||
saleOrderMapper.updateById(saleOrder);
|
||||
|
||||
String htmlContent = generateHtmlContent(saleContractId);
|
||||
List<String> delFiles = new ArrayList<>();
|
||||
List<File> files = new ArrayList<>();
|
||||
|
||||
SaleContractDO saleContract = saleContractService.getSaleContract(saleContractId);
|
||||
List<SaleContractEntryDO> saleContractEntrys = saleContractService.getSaleContractEntryListByParentId(saleContractId);
|
||||
List<List<SaleContractEntryDO>> split = ListUtil.split(saleContractEntrys, 6);
|
||||
int i = 1;
|
||||
for (List<SaleContractEntryDO> saleContractEntryDOS : split) {
|
||||
String htmlContent = generateHtmlContent(saleContract, saleContractEntryDOS);
|
||||
|
||||
//docker生成路径
|
||||
String pathUrl = System.getProperty("user.dir") + "/pdffile";
|
||||
String fileName = StrUtil.format(pathUrl + "/SaleContract_{}0", saleOrder.getBillno()+"_"+i);
|
||||
//主宿机生成路径
|
||||
String fileName2 = StrUtil.format(pdfPath + "/SaleContract_{}0", saleOrder.getBillno()+"_"+i);
|
||||
|
||||
String templatePath = fileName + ".html";
|
||||
String pdfPath = fileName + ".pdf";
|
||||
String templatePath2 = fileName2 + ".html";
|
||||
String pdfPath2 = fileName2 + ".pdf";
|
||||
|
||||
FileUtil.writeString(htmlContent, templatePath, "UTF-8");
|
||||
|
||||
log.info("已生成HTML文件:" + templatePath);
|
||||
//请求wkapp
|
||||
JSONObject params2 = new JSONObject();
|
||||
params2.put("input_html_path", "file://" + templatePath2);
|
||||
params2.put("output_pdf_path", pdfPath2);
|
||||
log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf");
|
||||
String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params2, 5 * 60 * 1000);
|
||||
log.info("请求wkapp接口返回结果:" + result);
|
||||
File file = FileUtil.file(pdfPath);
|
||||
files.add(file);
|
||||
delFiles.add(pdfPath);
|
||||
delFiles.add(templatePath);
|
||||
i++;
|
||||
}
|
||||
|
||||
//docker生成路径
|
||||
String pathUrl = System.getProperty("user.dir") + "/pdffile";
|
||||
String fileName = StrUtil.format(pathUrl + "/SaleContract_{}", saleOrder.getBillno());
|
||||
//主宿机生成路径
|
||||
String fileName2 = StrUtil.format(pdfPath + "/SaleContract_{}", saleOrder.getBillno());
|
||||
String zipFileName = StrUtil.format(pathUrl + "/SaleContract_{}0", new Date().getTime());
|
||||
|
||||
String templatePath = fileName + ".html";
|
||||
String pdfPath = fileName + ".pdf";
|
||||
String templatePath2 = fileName2 + ".html";
|
||||
String pdfPath2 = fileName2 + ".pdf";
|
||||
|
||||
FileUtil.writeString(htmlContent, templatePath, "UTF-8");
|
||||
|
||||
log.info("已生成HTML文件:" + templatePath);
|
||||
//请求wkapp
|
||||
JSONObject params2 = new JSONObject();
|
||||
params2.put("input_html_path", "file://" + templatePath2);
|
||||
params2.put("output_pdf_path", pdfPath2);
|
||||
log.info("请求wkapp接口url:" + wkappUrl + "/exehtmltopdf");
|
||||
String result = HttpUtil.post(wkappUrl + "/exehtmltopdf", params2, 5 * 60 * 1000);
|
||||
log.info("请求wkapp接口返回结果:" + result);
|
||||
// 压缩到的位置
|
||||
File zipFile = new File(zipFileName + ".zip");
|
||||
ZipUtil.zip(zipFile, false, files.toArray(new File[files.size()]));
|
||||
|
||||
|
||||
//发送消息
|
||||
|
|
@ -524,9 +545,15 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
message.setMail(email);
|
||||
message.setTitle("OMS订单系统");
|
||||
message.setContent("您好,订单:" + saleOrder.getBillno() + ",已审核通过!");
|
||||
mailSendService.doSendMail(message, new File(pdfPath));
|
||||
mailSendService.doSendMail(message, zipFile);
|
||||
}
|
||||
}
|
||||
|
||||
// 导出完删除
|
||||
delFiles.add(zipFileName);
|
||||
for (String delFile : delFiles) {
|
||||
FileUtil.del(delFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -631,13 +658,6 @@ public class SaleOrderServiceImpl implements SaleOrderService {
|
|||
}
|
||||
}
|
||||
|
||||
private String generateHtmlContent(Long saleContractId) {
|
||||
SaleContractDO saleContract = saleContractService.getSaleContract(saleContractId);
|
||||
List<SaleContractEntryDO> saleContractEntrys = saleContractService.getSaleContractEntryListByParentId(saleContractId);
|
||||
Context context = generateHtmlContents(saleContract, saleContractEntrys);
|
||||
return templateEngine.process("pdf_template", context);
|
||||
}
|
||||
|
||||
private String generateHtmlContent(SaleContractDO saleContract, List<SaleContractEntryDO> saleContractEntrys) {
|
||||
Context context = generateHtmlContents(saleContract, saleContractEntrys);
|
||||
return templateEngine.process("pdf_template", context);
|
||||
|
|
|
|||
Loading…
Reference in New Issue