Showing
3 changed files
with
24 additions
and
7 deletions
| @@ -498,9 +498,18 @@ public class ContractDistributorStandardController extends DefaultBaseController | @@ -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 | try { | 509 | try { |
| 510 | + | ||
| 502 | // 加载模板文件 | 511 | // 加载模板文件 |
| 503 | - ClassPathResource templateResource = new ClassPathResource("templates/standardContractTemplate.xls"); | 512 | + ClassPathResource templateResource = new ClassPathResource(templatePath); |
| 504 | try (InputStream inputStream = templateResource.getStream(); | 513 | try (InputStream inputStream = templateResource.getStream(); |
| 505 | Workbook workbook = new HSSFWorkbook(inputStream)) { | 514 | Workbook workbook = new HSSFWorkbook(inputStream)) { |
| 506 | try { | 515 | try { |
| @@ -551,8 +560,16 @@ public class ContractDistributorStandardController extends DefaultBaseController | @@ -551,8 +560,16 @@ public class ContractDistributorStandardController extends DefaultBaseController | ||
| 551 | 560 | ||
| 552 | setCellValue(sheet, startRow, 6, contractDistributorLineBo.getStatus()); // F列 | 561 | setCellValue(sheet, startRow, 6, contractDistributorLineBo.getStatus()); // F列 |
| 553 | setCellValue(sheet, startRow, 7, contractDistributorLineBo.getQuantity()); // G列 | 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 | setCellValue(sheet, startRow, 11, contractDistributorLineBo.getTotalAmount()); // L列 | 573 | setCellValue(sheet, startRow, 11, contractDistributorLineBo.getTotalAmount()); // L列 |
| 557 | setCellValue(sheet, startRow, 12, contractDistributorLineBo.getDeliveryDate() != null ? | 574 | setCellValue(sheet, startRow, 12, contractDistributorLineBo.getDeliveryDate() != null ? |
| 558 | contractDistributorLineBo.getDeliveryDate().format(dateFormatter) : ""); // L列 | 575 | contractDistributorLineBo.getDeliveryDate().format(dateFormatter) : ""); // L列 |
| @@ -566,8 +583,8 @@ public class ContractDistributorStandardController extends DefaultBaseController | @@ -566,8 +583,8 @@ public class ContractDistributorStandardController extends DefaultBaseController | ||
| 566 | dataMap.put("orderDate", data.getOrderDate().format(dateFormatter)); | 583 | dataMap.put("orderDate", data.getOrderDate().format(dateFormatter)); |
| 567 | dataMap.put("supplierName", data.getSupplierName()); | 584 | dataMap.put("supplierName", data.getSupplierName()); |
| 568 | dataMap.put("buyerName", data.getBuyerName()); | 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 | dataMap.put("totalQuantity", data.getTotalQuantity().setScale(0, RoundingMode.HALF_UP).toString()); | 589 | dataMap.put("totalQuantity", data.getTotalQuantity().setScale(0, RoundingMode.HALF_UP).toString()); |
| 573 | dataMap.put("totalAmountExcludingTax", data.getTotalAmountExcludingTax().setScale(2, RoundingMode.HALF_UP).toString()); | 590 | dataMap.put("totalAmountExcludingTax", data.getTotalAmountExcludingTax().setScale(2, RoundingMode.HALF_UP).toString()); |
| @@ -600,9 +617,9 @@ public class ContractDistributorStandardController extends DefaultBaseController | @@ -600,9 +617,9 @@ public class ContractDistributorStandardController extends DefaultBaseController | ||
| 600 | } | 617 | } |
| 601 | 618 | ||
| 602 | } catch (FileNotFoundException e) { | 619 | } catch (FileNotFoundException e) { |
| 603 | - throw new RuntimeException("模板文件不存在: templates/standardContractTemplate.xls", e); | 620 | + throw new RuntimeException("模板文件不存在:" + templatePath, e); |
| 604 | } catch (IOException e) { | 621 | } catch (IOException e) { |
| 605 | - throw new RuntimeException("无法读取模板文件: templates/standardContractTemplate.xls", e); | 622 | + throw new RuntimeException("无法读取模板文件:" + templatePath, e); |
| 606 | } | 623 | } |
| 607 | } catch (Exception e) { | 624 | } catch (Exception e) { |
| 608 | log.error("标准合同模版打印: {}", e.getMessage(), e); | 625 | log.error("标准合同模版打印: {}", e.getMessage(), e); |
No preview for this file type
No preview for this file type