✨ 汇总账单导出保留收货时间
This commit is contained in:
+13
-7
@@ -9,7 +9,6 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -27,6 +26,7 @@ import com.bms.receivable.domain.ArBillDetailFee;
|
||||
import com.bms.receivable.domain.ArExportTemplate;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
@@ -159,10 +159,11 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
XSSFCell cell = detail.getRow(4).getCell(column, XSSFRow.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
boolean identifier = column == 0 || column == 2 || column == 3 || column == 6;
|
||||
boolean money = column == 10 || column == 13 || column == 14 || column == 15 || column == 16;
|
||||
if (!identifier && !money) continue;
|
||||
boolean receiveDate = column == 1;
|
||||
if (!identifier && !money && !receiveDate) continue;
|
||||
XSSFCellStyle style = workbook.createCellStyle();
|
||||
style.cloneStyleFrom(cell.getCellStyle());
|
||||
String format = identifier ? "@" : "0.00";
|
||||
String format = receiveDate ? "yyyy/mm/dd" : identifier ? "@" : "0.00";
|
||||
style.setDataFormat(workbook.createDataFormat().getFormat(format));
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
@@ -194,7 +195,7 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
failed[column] = Short.toUnsignedInt(style.getIndex());
|
||||
}
|
||||
return new DetailStyles(normal, failed, workbook.getSheetAt(1).getRow(4).getHeightInPoints());
|
||||
return new DetailStyles(normal, failed, workbook.getSheetAt(1).getRow(4).getHeightInPoints(), workbook.isDate1904());
|
||||
}
|
||||
|
||||
/** 产品行之间不画网格线;最后一行沿用模板底边,组成完整外框。 */
|
||||
@@ -260,11 +261,16 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
}
|
||||
|
||||
private String detailRow(int rowNumber, ArBill bill, ArBillDetail detail,
|
||||
DetailAmounts amounts, DetailStyles styles) {
|
||||
DetailAmounts amounts, DetailStyles styles) throws IOException {
|
||||
String failure = exportBillingFailDescription(detail.getBillingFailStatus());
|
||||
Double receiveTime = detail.getReceiveTime() == null ? null
|
||||
: DateUtil.getExcelDate(detail.getReceiveTime(), styles.use1904());
|
||||
if (receiveTime != null && !DateUtil.isValidExcelDate(receiveTime)) {
|
||||
throw new IOException("账单明细收货时间超出 Excel 日期范围,请检查账单");
|
||||
}
|
||||
Object[] values = {
|
||||
bill.getCustomerCode(),
|
||||
detail.getReceiveTime() == null ? "" : new SimpleDateFormat("yyyy-MM-dd").format(detail.getReceiveTime()),
|
||||
receiveTime,
|
||||
detail.getTransferNo(), detail.getTrackingNo(),
|
||||
StringUtils.isEmpty(detail.getProductName()) ? detail.getProductCode() : detail.getProductName(),
|
||||
StringUtils.isEmpty(detail.getCountryName()) ? detail.getCountryCode() : detail.getCountryName(),
|
||||
@@ -412,7 +418,7 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
private record SheetXml(String prefix, Map<Integer, String> rows, String suffix) { }
|
||||
private record DetailResult(int count, int lastRow, BigDecimal amount) { }
|
||||
private record SummaryStyles(int[] normal, int[] last) { }
|
||||
private record DetailStyles(int[] normal, int[] failed, float rowHeight) { }
|
||||
private record DetailStyles(int[] normal, int[] failed, float rowHeight, boolean use1904) { }
|
||||
private record DetailAmounts(BigDecimal freight, BigDecimal processing, BigDecimal remote,
|
||||
BigDecimal surcharge, BigDecimal romania, BigDecimal total) { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user