Merge pull request #103 from LQYBill/dev

Prepare release 2.6.1
pull/8040/head
Qiuyi LI 2024-08-05 15:19:06 +02:00 committed by GitHub
commit 60ca4b7e3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 118 additions and 22 deletions

View File

@ -11,7 +11,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Date;
import java.util.HashMap;
@ -171,6 +170,7 @@ public abstract class AbstractInvoice<E, F, G, H, I> {
// si le nombre de lignes de data rentre dans 1 page A4
if(data.size() < 44) {
// Fit in A4 page"
if(TOTAL_ROW > LAST_ROW + 3) { // s'il ne reste pas assez de place pour le footer
// on shift le footer à la page suivante (total + signature etc..)
sheet.shiftRows(startRow, fileLastRow, PAGE_ROW_MAX - LAST_ROW - 1, true, false);
@ -186,12 +186,14 @@ public abstract class AbstractInvoice<E, F, G, H, I> {
}
else {// on dépasse forcément le format A4 d'un PDF
if(((TOTAL_ROW - 44) % 63) < 13) {
// Not enough space for footer
sheet.shiftRows(startRow, fileLastRow, TOTAL_ROW - LAST_ROW + ((TOTAL_ROW-44)%63), true, false);
footerRow = additionalRowNum + ((TOTAL_ROW-44)%63) + 1;
imgShift = TOTAL_ROW-44 + ((TOTAL_ROW-44)%63) -1;
TOTAL_ROW += ((TOTAL_ROW-44)%63) + 1;
}
else {
// Enough space for footer
sheet.shiftRows(startRow, fileLastRow, TOTAL_ROW - LAST_ROW, true, false);
footerRow = TOTAL_ROW - LAST_ROW +1;
}
@ -254,6 +256,7 @@ public abstract class AbstractInvoice<E, F, G, H, I> {
if(data.size() > dataRowNumber)
{
org.apache.poi.ss.usermodel.Row totalRow;
// Si ça pète c'est surement ici
if(additionalRowNum%PAGE_ROW_MAX <= 13)
totalRow = sheet.getRow(TOTAL_ROW-1);
else
@ -322,18 +325,11 @@ public abstract class AbstractInvoice<E, F, G, H, I> {
totalDueCellStyle.setBorderTop(BorderStyle.THIN);
totalDueCellStyle.setFont(arialBold);
if(((LAST_ROW+additionalRowNum - 44) % 63) < 13 && ((LAST_ROW+additionalRowNum - 44) % 63) > 0) {
totalDueRow = sheet.getRow( data.size() < 44 ? PAGE_ROW_MAX + 1 : TOTAL_ROW + 1);
Cell totalDueCell = totalDueRow.createCell(7);
totalDueCell.setCellFormula("H" + (TOTAL_ROW) + "-G" + (TOTAL_ROW));
totalDueCell.setCellStyle(totalDueCellStyle);
}
else {
totalDueRow = sheet.getRow(data.size() < 44 ? TOTAL_ROW + 1 : TOTAL_ROW + 2);
Cell totalDueCell = totalDueRow.createCell(7);
totalDueCell.setCellFormula("H" + (data.size() < 44 ? TOTAL_ROW : TOTAL_ROW + 1) + "-G" + (data.size() < 44 ? TOTAL_ROW : TOTAL_ROW + 1));
totalDueCell.setCellStyle(totalDueCellStyle);
}
// Si ça pète c'est pas là
totalDueRow = sheet.getRow( totalRow.getRowNum() + 2);
Cell totalDueCell = totalDueRow.createCell(7);
totalDueCell.setCellFormula("H" + (totalRow.getRowNum() + 1) + "-G" + (totalRow.getRowNum()) + 1);
totalDueCell.setCellStyle(totalDueCellStyle);
}
if (targetClient.getCurrency().equals("USD")) {

View File

@ -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()
);
}

View File

@ -39,6 +39,11 @@ public interface LogisticChannelPriceMapper extends BaseMapper<LogisticChannelPr
@Param("date") Date shippingTime,
@Param("trueWeight") BigDecimal weight,
@Param("countryList") List<String> countryList);
LogisticChannelPrice findPrevious(
@Param("channelName") String channelName,
@Param("date") Date shippingTime,
@Param("trueWeight") BigDecimal weight,
@Param("countryList") List<String> countryList);
/**
* Find logistic channel price by indicating platform order's shipping time

View File

@ -33,8 +33,71 @@
AND effective_date &lt;= #{date}
AND active = 1
ORDER BY effective_date DESC
LIMIT 2 </select>
LIMIT 2
</select>
<select id="findPrevious" resultType="org.jeecg.modules.business.entity.LogisticChannelPrice">
WITH current_price AS
(
SELECT lcp.*
FROM logistic_channel_price lcp
JOIN logistic_channel lc ON lc.id = lcp.channel_id
WHERE zh_name = #{channelName}
AND weight_range_start &lt;= #{trueWeight}
AND weight_range_end &gt;= #{trueWeight}
AND effective_country IN
<foreach collection="countryList"
separator=","
open="("
close=")"
index="index"
item="country"
>
#{country}
</foreach>
AND effective_date &lt;= #{date}
AND active = 1
ORDER BY effective_date DESC
LIMIT 1
)
SELECT lcp.*
FROM logistic_channel_price lcp
JOIN logistic_channel lc ON lc.id = lcp.channel_id
WHERE lc.zh_name = #{channelName}
AND weight_range_start &lt;= #{trueWeight}
AND weight_range_end &gt;= #{trueWeight}
AND effective_country IN
<foreach collection="countryList"
separator=","
open="("
close=")"
index="index"
item="country"
>#{country}
</foreach>
AND effective_date &lt;= #{date}
AND active = 1
AND (
lcp.cal_unit_price != (
SELECT cal_unit_price
FROM current_price
WHERE effective_country = lcp.effective_country
)
OR
lcp.registration_fee != (
SELECT registration_fee
FROM current_price
WHERE effective_country = lcp.effective_country
)
OR
lcp.picking_fee_per_item != (
SELECT picking_fee_per_item
FROM current_price
WHERE effective_country = lcp.effective_country
)
)
ORDER BY effective_date DESC
LIMIT 1;
</select>
<select id="findPricesBy" resultType="org.jeecg.modules.business.entity.LogisticChannelPrice">
SELECT lcp.id, lcp.create_by, lcp.create_time, lcp.update_by, lcp.update_time,
lc.id AS channel_id, effective_date, effective_country,

View File

@ -7,7 +7,7 @@
FROM client c
JOIN shop s ON c.id = s.owner_id
JOIN platform_order po on s.id = po.shop_id
WHERE po.shipping_invoice_number = #{invoiceNumber}
WHERE po.shipping_invoice_number = #{invoiceNumber} OR po.purchase_invoice_number = #{invoiceNumber};
</select>
<select id="fetchShippingInvoiceId" resultType="java.lang.String">
SELECT id

View File

@ -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;

View File

@ -79,7 +79,22 @@ public class LogisticChannelServiceImpl extends ServiceImpl<LogisticChannelMappe
@Override
public List<LogisticChannelPrice> findLogisticsChannelPrice(String channelName, Date date, int trueWeight, List<String> countryList) {
return logisticChannelPriceMapper.findBy(channelName, new java.util.Date(), BigDecimal.valueOf(trueWeight), countryList);
List<LogisticChannelPrice> priceList = new ArrayList<>();
List<LogisticChannelPrice> currentPriceList = logisticChannelPriceMapper.findBy(channelName, new java.util.Date(), BigDecimal.valueOf(trueWeight), countryList);
LogisticChannelPrice currentPrice = currentPriceList.stream()
.max(Comparator.comparing(LogisticChannelPrice::getEffectiveDate))
.orElse(null);
if(currentPrice != null) {
priceList.add(currentPrice);
LogisticChannelPrice previousPrice = logisticChannelPriceMapper.findPrevious(channelName, new java.util.Date(), BigDecimal.valueOf(trueWeight), countryList);
if(previousPrice != null) {
priceList.add(previousPrice);
} else {
currentPriceList.stream()
.min(Comparator.comparing(LogisticChannelPrice::getEffectiveDate)).ifPresent(priceList::add);
}
}
return priceList;
}
@Override
@ -99,6 +114,8 @@ public class LogisticChannelServiceImpl extends ServiceImpl<LogisticChannelMappe
trueWeight = weight;
}
List<LogisticChannelPrice> priceList = findLogisticsChannelPrice(channelName, new Date(), trueWeight, countryList);
System.out.println("Price list for " + channelName + " is : ");
System.out.println(priceList);
LogisticChannelPrice price = priceList.stream()
.max(Comparator.comparing(LogisticChannelPrice::getEffectiveDate))
.orElse(null);