修改导入功能
This commit is contained in:
+36
-13
@@ -797,24 +797,40 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
private List<BmsProduct> parseCatalog(Sheet sheet)
|
||||
{
|
||||
List<BmsProduct> list = new ArrayList<>();
|
||||
// Weishi workbook often starts data at column B (A empty); locate by header.
|
||||
int[] header = findHeaderCell(sheet, "\u4ea7\u54c1\u5bf9\u63a5\u4ee3\u7801");
|
||||
// Header is "\u5bf9\u63a5\u4ee3\u7801" or legacy "\u4ea7\u54c1\u5bf9\u63a5\u4ee3\u7801". Column A is often empty.
|
||||
// 20260928 layout inserts "\u8ba1\u6ce1\u89c4\u5219" before country, so map by header name.
|
||||
int[] header = findHeaderCell(sheet, "\u5bf9\u63a5\u4ee3\u7801");
|
||||
if (header == null)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
int headerRow = header[0];
|
||||
int baseCol = header[1];
|
||||
int headerRowIdx = header[0];
|
||||
int colCode = header[1];
|
||||
Row head = sheet.getRow(headerRowIdx);
|
||||
int colName = catalogColumn(head, "\u4ea7\u54c1\u540d\u79f0", colCode + 1);
|
||||
int colLevel = catalogColumn(head, "\u65f6\u6548", colCode + 2);
|
||||
int colCargo = catalogColumn(head, "\u8d70\u8d27\u5c5e\u6027", colCode + 3);
|
||||
int colDest = findColByHeader(head, "\u56fd\u5bb6", colCode);
|
||||
if (colDest < 0)
|
||||
{
|
||||
colDest = findColByHeader(head, "\u76ee\u7684", colCode);
|
||||
}
|
||||
if (colDest < 0)
|
||||
{
|
||||
colDest = colCode + 4;
|
||||
}
|
||||
int colNote = catalogColumn(head, "\u66f4\u65b0\u5185\u5bb9", colCode + 5);
|
||||
int colDate = catalogColumn(head, "\u751f\u6548", colCode + 6);
|
||||
int lastRow = sheet.getLastRowNum();
|
||||
for (int i = headerRow + 1; i <= lastRow; i++)
|
||||
for (int i = headerRowIdx + 1; i <= lastRow; i++)
|
||||
{
|
||||
Row row = sheet.getRow(i);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String code = cellString(row.getCell(baseCol));
|
||||
if (StringUtils.isEmpty(code) || "\u4ea7\u54c1\u5bf9\u63a5\u4ee3\u7801".equals(code))
|
||||
String code = cellString(row.getCell(colCode));
|
||||
if (StringUtils.isEmpty(code) || code.contains("\u5bf9\u63a5\u4ee3\u7801"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -824,12 +840,12 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
}
|
||||
BmsProduct p = new BmsProduct();
|
||||
p.setProductCode(code.trim());
|
||||
p.setProductName(cellString(row.getCell(baseCol + 1)));
|
||||
p.setServiceLevel(cellString(row.getCell(baseCol + 2)));
|
||||
p.setCargoAttr(cellString(row.getCell(baseCol + 3)));
|
||||
p.setDestRegion(cellString(row.getCell(baseCol + 4)));
|
||||
p.setUpdateNote(cellString(row.getCell(baseCol + 5)));
|
||||
p.setEffectiveDate(cellDate(row.getCell(baseCol + 6)));
|
||||
p.setProductName(cellString(row.getCell(colName)));
|
||||
p.setServiceLevel(cellString(row.getCell(colLevel)));
|
||||
p.setCargoAttr(cellString(row.getCell(colCargo)));
|
||||
p.setDestRegion(cellString(row.getCell(colDest)));
|
||||
p.setUpdateNote(cellString(row.getCell(colNote)));
|
||||
p.setEffectiveDate(cellDate(row.getCell(colDate)));
|
||||
p.setTaxMode(resolveTaxMode(p.getProductName()));
|
||||
if (StringUtils.isEmpty(p.getProductName()))
|
||||
{
|
||||
@@ -840,6 +856,13 @@ public class BmsProductServiceImpl implements IBmsProductService
|
||||
return list;
|
||||
}
|
||||
|
||||
/** Header column, or the legacy fixed offset when the title is absent. */
|
||||
private static int catalogColumn(Row headerRow, String keyword, int fallback)
|
||||
{
|
||||
int col = findColByHeader(headerRow, keyword, 0);
|
||||
return col >= 0 ? col : fallback;
|
||||
}
|
||||
|
||||
/** Keep first row per product_code (catalog often repeats code across country rows). */
|
||||
private List<BmsProduct> dedupeCatalogProducts(List<BmsProduct> products)
|
||||
{
|
||||
|
||||
+10
-2
@@ -204,7 +204,8 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
{
|
||||
countryCode = countryCode.toUpperCase();
|
||||
}
|
||||
BigDecimal weight = request.getWeight();
|
||||
// Charge weight keeps 3 decimals; freight unit price keeps 2 (see buildFromRates).
|
||||
BigDecimal weight = request.getWeight().setScale(3, RoundingMode.HALF_UP);
|
||||
|
||||
String destPostcode = emptyToNull(request.getDestPostcode());
|
||||
String zoneCode = null;
|
||||
@@ -564,7 +565,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
BigDecimal baseRate = base.getFreightPrice();
|
||||
RoundingMode rm = resolveRoundingMode(roundMode);
|
||||
BigDecimal rate = baseRate.multiply(discount)
|
||||
.divide(new BigDecimal("100"), 4, rm);
|
||||
.divide(new BigDecimal("100"), 2, rm);
|
||||
TmsPriceQuoteResult r = buildFromRates(SRC_DISCOUNT, rate, baseRate, discount,
|
||||
base.getRegistrationFee(), base, productCode, productName, weight, roundMode);
|
||||
fillPackage(r, bind, set);
|
||||
@@ -616,6 +617,13 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
RoundingMode rm = resolveRoundingMode(roundMode);
|
||||
String mode = normalizeRoundMode(roundMode);
|
||||
weight = weight.setScale(3, RoundingMode.HALF_UP);
|
||||
freightRate = freightRate.setScale(2, rm);
|
||||
if (baseFreightRate != null)
|
||||
{
|
||||
baseFreightRate = baseFreightRate.setScale(2, rm);
|
||||
}
|
||||
registrationFee = registrationFee.setScale(2, rm);
|
||||
BigDecimal freightAmount = freightRate.multiply(weight).setScale(2, rm);
|
||||
BigDecimal payable = freightAmount.add(registrationFee).setScale(2, rm);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user