Commit e62d7fd177856c1059e544969e29763c89fe2cb1

Authored by 杨鸣坤
1 parent e78c5713

楚江ERP:外贸合同导出

... ... @@ -498,9 +498,18 @@ public class ContractDistributorStandardController extends DefaultBaseController
498 498 });
499 499 }
500 500
  501 +
  502 + String templatePath = "templates/standardContractTemplate.xls";
  503 + if ("INTL_STD_CONTRACT".equals(data.getType())
  504 + || "INTL_INVENTORY_AGMT".equals(data.getType())
  505 + || "INTL_OPEN_SPEC_AGMT".equals(data.getType())) { // 读取外贸合同模版
  506 + templatePath = "templates/foreignStandardContractTemplate.xls";
  507 + }
  508 +
501 509 try {
  510 +
502 511 // 加载模板文件
503   - ClassPathResource templateResource = new ClassPathResource("templates/standardContractTemplate.xls");
  512 + ClassPathResource templateResource = new ClassPathResource(templatePath);
504 513 try (InputStream inputStream = templateResource.getStream();
505 514 Workbook workbook = new HSSFWorkbook(inputStream)) {
506 515 try {
... ... @@ -551,8 +560,16 @@ public class ContractDistributorStandardController extends DefaultBaseController
551 560
552 561 setCellValue(sheet, startRow, 6, contractDistributorLineBo.getStatus()); // F列
553 562 setCellValue(sheet, startRow, 7, contractDistributorLineBo.getQuantity()); // G列
554   - setCellValue(sheet, startRow, 9, contractDistributorLineBo.getUnitPrice()); // I列
555   - setCellValue(sheet, startRow, 10, contractDistributorLineBo.getAmountExcludingTax()); // K列
  563 + if ("INTL_STD_CONTRACT".equals(data.getType())
  564 + || "INTL_INVENTORY_AGMT".equals(data.getType())
  565 + || "INTL_OPEN_SPEC_AGMT".equals(data.getType())) {
  566 + setCellValue(sheet, startRow, 9, contractDistributorLineBo.getProcessingFee()); // I列
  567 + setCellValue(sheet, startRow, 10, contractDistributorLineBo.getProcessingFee().add(contractDistributorLineBo.getUnitPrice())); // K列
  568 + } else {
  569 + setCellValue(sheet, startRow, 9, contractDistributorLineBo.getUnitPrice()); // I列
  570 + setCellValue(sheet, startRow, 10, contractDistributorLineBo.getAmountExcludingTax()); // K列
  571 + }
  572 +
556 573 setCellValue(sheet, startRow, 11, contractDistributorLineBo.getTotalAmount()); // L列
557 574 setCellValue(sheet, startRow, 12, contractDistributorLineBo.getDeliveryDate() != null ?
558 575 contractDistributorLineBo.getDeliveryDate().format(dateFormatter) : ""); // L列
... ... @@ -566,8 +583,8 @@ public class ContractDistributorStandardController extends DefaultBaseController
566 583 dataMap.put("orderDate", data.getOrderDate().format(dateFormatter));
567 584 dataMap.put("supplierName", data.getSupplierName());
568 585 dataMap.put("buyerName", data.getBuyerName());
569   -// dataMap.put("unitName", data.getUnitName());
570   - dataMap.put("unitName", "元、公斤、元/公斤");
  586 + dataMap.put("unitName", data.getUnit());
  587 +// dataMap.put("unitName", "元、公斤、元/公斤");
571 588
572 589 dataMap.put("totalQuantity", data.getTotalQuantity().setScale(0, RoundingMode.HALF_UP).toString());
573 590 dataMap.put("totalAmountExcludingTax", data.getTotalAmountExcludingTax().setScale(2, RoundingMode.HALF_UP).toString());
... ... @@ -600,9 +617,9 @@ public class ContractDistributorStandardController extends DefaultBaseController
600 617 }
601 618
602 619 } catch (FileNotFoundException e) {
603   - throw new RuntimeException("模板文件不存在: templates/standardContractTemplate.xls", e);
  620 + throw new RuntimeException("模板文件不存在:" + templatePath, e);
604 621 } catch (IOException e) {
605   - throw new RuntimeException("无法读取模板文件: templates/standardContractTemplate.xls", e);
  622 + throw new RuntimeException("无法读取模板文件:" + templatePath, e);
606 623 }
607 624 } catch (Exception e) {
608 625 log.error("标准合同模版打印: {}", e.getMessage(), e);
... ...