From 450e9f08464f7cadf411a47a9fe1b14e21629a49 Mon Sep 17 00:00:00 2001 From: Gauthier LO Date: Thu, 1 Aug 2024 11:56:13 +0200 Subject: [PATCH 1/6] fix: pdf now will stay in one page --- .../PlatformOrderShippingInvoiceService.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/PlatformOrderShippingInvoiceService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/PlatformOrderShippingInvoiceService.java index 421de7b6c..2ae620c0b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/PlatformOrderShippingInvoiceService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/PlatformOrderShippingInvoiceService.java @@ -1,8 +1,6 @@ package org.jeecg.modules.business.service; -import com.aspose.cells.PdfSaveOptions; -import com.aspose.cells.SaveFormat; -import com.aspose.cells.Workbook; +import com.aspose.cells.*; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.shiro.SecurityUtils; @@ -786,6 +784,19 @@ public class PlatformOrderShippingInvoiceService { saveOptions.setDefaultFont("Arial"); saveOptions.setCheckWorkbookDefaultFont(false); Workbook workbook = new Workbook(excelFilePath); + Worksheet sheet = workbook.getWorksheets().get(0); + // get number of lines + Cells cells = sheet.getCells(); + int maxRow = cells.getMaxDataRow(); + PageSetup pageSetup = sheet.getPageSetup(); + // Setting the number of pages to which the length of the worksheet will + if(maxRow < 63) { + // be spanned + pageSetup.setFitToPagesTall(1); + + // Setting the number of pages to which the width of the worksheet will be spanned + pageSetup.setFitToPagesWide(1); + } // On enregistre le document au format PDF workbook.save(pdfFilePath, saveOptions); return pdfFilePath; From 8b144a43d417778e68d90e016fc8af92e9c46b3b Mon Sep 17 00:00:00 2001 From: Gauthier LO Date: Thu, 1 Aug 2024 11:57:12 +0200 Subject: [PATCH 2/6] feat: better logistic channel price comparison --- .../domain/logistic/CostTrialCalculation.java | 8 ++- .../mapper/LogisticChannelPriceMapper.java | 7 ++- .../mapper/xml/LogisticChannelPriceMapper.xml | 61 ++++++++++++++++++- .../mapper/xml/ShippingInvoiceMapper.xml | 2 +- .../impl/LogisticChannelPriceServiceImpl.java | 6 +- .../impl/LogisticChannelServiceImpl.java | 13 +++- 6 files changed, 85 insertions(+), 12 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/logistic/CostTrialCalculation.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/logistic/CostTrialCalculation.java index 9a5cdc5bf..0e6a3f34f 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/logistic/CostTrialCalculation.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/logistic/CostTrialCalculation.java @@ -24,6 +24,9 @@ public class CostTrialCalculation { @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") private final Date effectiveDate; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + private final Date previousEffectiveDate; + private final BigDecimal unitPrice; private final BigDecimal shippingCost; @@ -44,7 +47,7 @@ public class CostTrialCalculation { private CostTrialCalculation(String countryCode, String logisticsChannelName, String logisticChannelCode, BigDecimal unitPrice, BigDecimal shippingCost, BigDecimal registrationCost, BigDecimal additionalCost, Date effectiveDate, - BigDecimal previousUnitPrice,BigDecimal previousShippingCost, BigDecimal previousRegistrationCost, BigDecimal previousAdditionalCost) { + BigDecimal previousUnitPrice,BigDecimal previousShippingCost, BigDecimal previousRegistrationCost, BigDecimal previousAdditionalCost, Date previousEffectiveDate) { this.countryCode = countryCode; this.logisticsChannelName = logisticsChannelName; this.logisticChannelCode = logisticChannelCode; @@ -57,12 +60,13 @@ public class CostTrialCalculation { this.previousShippingCost = previousShippingCost; this.previousRegistrationCost = previousRegistrationCost; this.previousAdditionalCost = previousAdditionalCost; + this.previousEffectiveDate = previousEffectiveDate; } public CostTrialCalculation(LogisticChannelPrice price, LogisticChannelPrice previousPrice,int weight, String logisticsChannelName, String code) { this(price.getEffectiveCountry(), logisticsChannelName, code, price.getCalUnitPrice(), price.calculateShippingPrice(BigDecimal.valueOf(weight)), price.getRegistrationFee(), price.getAdditionalCost(), price.getEffectiveDate(), - previousPrice.getCalUnitPrice(), previousPrice.calculateShippingPrice(BigDecimal.valueOf(weight)), previousPrice.getRegistrationFee(), previousPrice.getAdditionalCost() + previousPrice.getCalUnitPrice(), previousPrice.calculateShippingPrice(BigDecimal.valueOf(weight)), previousPrice.getRegistrationFee(), previousPrice.getAdditionalCost(), previousPrice.getEffectiveDate() ); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/LogisticChannelPriceMapper.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/LogisticChannelPriceMapper.java index 955969d8f..f41f08280 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/LogisticChannelPriceMapper.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/LogisticChannelPriceMapper.java @@ -34,7 +34,12 @@ public interface LogisticChannelPriceMapper extends BaseMapper findBy( + LogisticChannelPrice findBy( + @Param("channelName") String channelName, + @Param("date") Date shippingTime, + @Param("trueWeight") BigDecimal weight, + @Param("countryList") List countryList); + LogisticChannelPrice findPrevious( @Param("channelName") String channelName, @Param("date") Date shippingTime, @Param("trueWeight") BigDecimal weight, diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/LogisticChannelPriceMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/LogisticChannelPriceMapper.xml index a36890c23..5fdf2e8d4 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/LogisticChannelPriceMapper.xml +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/LogisticChannelPriceMapper.xml @@ -33,8 +33,65 @@ AND effective_date <= #{date} AND active = 1 ORDER BY effective_date DESC - LIMIT 2 - + LIMIT 1 + +