|
|
|
@ -59,7 +59,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) { |
|
|
|
for (int i = 0; i < workbook.getNumberOfSheets(); i++) { |
|
|
|
Sheet sheet = workbook.getSheetAt(i); |
|
|
|
if (sheet.getPhysicalNumberOfRows() < 3) { |
|
|
|
if (sheet.getPhysicalNumberOfRows() < 2) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
@ -86,7 +86,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} |
|
|
|
|
|
|
|
private Map<String, Object> extractSheetPreviewInfo(Sheet sheet, String site, String username, String buNo) throws Exception { |
|
|
|
Row headerRow = sheet.getRow(2); // 第三行是表头 |
|
|
|
Row headerRow = sheet.getRow(0); // 第一行是表头 |
|
|
|
if (headerRow == null) return null; |
|
|
|
|
|
|
|
Map<String, Integer> headerMap = new HashMap<>(); |
|
|
|
@ -105,12 +105,14 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
String cmcInvoice = ""; |
|
|
|
String readyDateStr = ""; |
|
|
|
String shippingMethod = ""; |
|
|
|
String destination = ""; |
|
|
|
|
|
|
|
Row firstDataRow = sheet.getRow(3); |
|
|
|
Row firstDataRow = sheet.getRow(1); |
|
|
|
if (firstDataRow != null) { |
|
|
|
cmcInvoice = getMergedCellValue(sheet, 3, headerMap.get("发票号")); |
|
|
|
if (headerMap.containsKey("可提货时间")) readyDateStr = getMergedCellValue(sheet, 3, headerMap.get("可提货时间")); |
|
|
|
if (headerMap.containsKey("shipping method")) shippingMethod = getMergedCellValue(sheet, 3, headerMap.get("shipping method")); |
|
|
|
cmcInvoice = getMergedCellValue(sheet, 1, headerMap.get("发票号")); |
|
|
|
if (headerMap.containsKey("可提货时间")) readyDateStr = getMergedCellValue(sheet, 1, headerMap.get("可提货时间")); |
|
|
|
if (headerMap.containsKey("发运方式")) shippingMethod = getMergedCellValue(sheet, 1, headerMap.get("发运方式")); |
|
|
|
if (headerMap.containsKey("目的地")) destination = getMergedCellValue(sheet, 1, headerMap.get("目的地")); |
|
|
|
} |
|
|
|
|
|
|
|
if (cmcInvoice == null || cmcInvoice.isEmpty()) { |
|
|
|
@ -128,7 +130,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
List<String> invalidMaterials = new ArrayList<>(); |
|
|
|
|
|
|
|
int lastRowNum = sheet.getLastRowNum(); |
|
|
|
for (int r = 3; r <= lastRowNum; r++) { |
|
|
|
for (int r = 1; r <= lastRowNum; r++) { |
|
|
|
Row row = sheet.getRow(r); |
|
|
|
if (row == null) continue; |
|
|
|
|
|
|
|
@ -162,7 +164,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
summary.put("readyDate", readyDateStr); |
|
|
|
summary.put("totalQty", totalQty); |
|
|
|
summary.put("totalItems", itemNos.size()); |
|
|
|
summary.put("destination", ""); |
|
|
|
summary.put("destination", destination); |
|
|
|
summary.put("shippingMode", shippingMethod); |
|
|
|
|
|
|
|
boolean hasInvalidMaterials = !invalidMaterials.isEmpty(); |
|
|
|
@ -201,7 +203,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
Workbook workbook = WorkbookFactory.create(file.getInputStream()); |
|
|
|
for (int i = 0; i < workbook.getNumberOfSheets(); i++) { |
|
|
|
Sheet sheet = workbook.getSheetAt(i); |
|
|
|
if (sheet.getPhysicalNumberOfRows() < 3) { |
|
|
|
if (sheet.getPhysicalNumberOfRows() < 2) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
try { |
|
|
|
@ -231,7 +233,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} |
|
|
|
|
|
|
|
private String getInvoiceFromSheet(Sheet sheet) { |
|
|
|
Row headerRow = sheet.getRow(2); |
|
|
|
Row headerRow = sheet.getRow(0); |
|
|
|
if (headerRow == null) return null; |
|
|
|
int invoiceCol = -1; |
|
|
|
for (int j = 0; j < headerRow.getLastCellNum(); j++) { |
|
|
|
@ -242,9 +244,9 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} |
|
|
|
} |
|
|
|
if (invoiceCol != -1) { |
|
|
|
Row firstDataRow = sheet.getRow(3); |
|
|
|
Row firstDataRow = sheet.getRow(1); |
|
|
|
if (firstDataRow != null) { |
|
|
|
return getMergedCellValue(sheet, 3, invoiceCol); |
|
|
|
return getMergedCellValue(sheet, 1, invoiceCol); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
@ -268,7 +270,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} |
|
|
|
|
|
|
|
private void processSheet(Sheet sheet, EcssCoDelNotifyHeaderData data, HttpServletRequest request) throws Exception { |
|
|
|
Row headerRow = sheet.getRow(2); // 第三行是表头 |
|
|
|
Row headerRow = sheet.getRow(0); // 第一行是表头 |
|
|
|
if (headerRow == null) return; |
|
|
|
|
|
|
|
Map<String, Integer> headerMap = new HashMap<>(); |
|
|
|
@ -291,12 +293,12 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
String shippingMethod = ""; |
|
|
|
|
|
|
|
// 获取发货通知单信息 (从第一行数据获取即可) |
|
|
|
Row firstDataRow = sheet.getRow(3); |
|
|
|
Row firstDataRow = sheet.getRow(1); |
|
|
|
if (firstDataRow != null) { |
|
|
|
cmcInvoice = getMergedCellValue(sheet, 3, headerMap.get("发票号")); |
|
|
|
if (headerMap.containsKey("客户")) customerName = getMergedCellValue(sheet, 3, headerMap.get("客户")); |
|
|
|
if (headerMap.containsKey("可提货时间")) readyDateStr = getMergedCellValue(sheet, 3, headerMap.get("可提货时间")); |
|
|
|
if (headerMap.containsKey("shipping method")) shippingMethod = getMergedCellValue(sheet, 3, headerMap.get("shipping method")); |
|
|
|
cmcInvoice = getMergedCellValue(sheet, 1, headerMap.get("发票号")); |
|
|
|
if (headerMap.containsKey("客户")) customerName = getMergedCellValue(sheet, 1, headerMap.get("客户")); |
|
|
|
if (headerMap.containsKey("可提货时间")) readyDateStr = getMergedCellValue(sheet, 1, headerMap.get("可提货时间")); |
|
|
|
if (headerMap.containsKey("发运方式")) shippingMethod = getMergedCellValue(sheet, 1, headerMap.get("发运方式")); |
|
|
|
} |
|
|
|
|
|
|
|
if (cmcInvoice == null || cmcInvoice.isEmpty()) { |
|
|
|
@ -397,7 +399,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
|
|
|
|
Map<String, EcssCoDelBoxListData> boxListMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
for (int r = 3; r <= lastRowNum; r++) { |
|
|
|
for (int r = 1; r <= lastRowNum; r++) { |
|
|
|
Row row = sheet.getRow(r); |
|
|
|
if (row == null) continue; |
|
|
|
|
|
|
|
@ -425,10 +427,9 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} else { |
|
|
|
PartData partData = parts.getFirst(); |
|
|
|
detail.setPartNo(partData.getPartNo()); |
|
|
|
detail.setPartDescription(partData.getPartDesc()); |
|
|
|
if (StringUtils.isBlank(partData.getHsCode()) || StringUtils.isBlank(partData.getHsCodeDesc())) { |
|
|
|
String hsCode = headerMap.containsKey("HS Code") ? getMergedCellValue(sheet, r, headerMap.get("HS Code")) : ""; |
|
|
|
String hsCodeDesc = headerMap.containsKey("名称") ? getMergedCellValue(sheet, r, headerMap.get("名称")) : ""; |
|
|
|
String hsCodeDesc = headerMap.containsKey("申报品名") ? getMergedCellValue(sheet, r, headerMap.get("申报品名")) : ""; |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(hsCode) || StringUtils.isNotBlank(hsCodeDesc)) { |
|
|
|
coDelMapper.updatePartHsCode(site, partData.getPartNo(), hsCode, hsCodeDesc); |
|
|
|
@ -450,17 +451,12 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//if (headerMap.containsKey("名称")) detail.setPartDescription(getMergedCellValue(sheet, r, headerMap.get("名称"))); |
|
|
|
if (headerMap.containsKey("名称")) detail.setPartDescription(getMergedCellValue(sheet, r, headerMap.get("名称"))); |
|
|
|
if (headerMap.containsKey("Manufacturer Name")) detail.setManufacturerName(getMergedCellValue(sheet, r, headerMap.get("Manufacturer Name"))); |
|
|
|
if (headerMap.containsKey("Currency")) detail.setCurrency(getMergedCellValue(sheet, r, headerMap.get("Currency"))); |
|
|
|
if (headerMap.containsKey("TP")) detail.setTp(parseBigDecimal(getMergedCellValue(sheet, r, headerMap.get("TP")))); |
|
|
|
if (headerMap.containsKey("Total Revanue")) detail.setTtlAmount(parseBigDecimal(getMergedCellValue(sheet, r, headerMap.get("Total Revanue")))); |
|
|
|
|
|
|
|
String productNature = headerMap.containsKey("产品性质") ? getMergedCellValue(sheet, r, headerMap.get("产品性质")) : ""; |
|
|
|
String remark = ""; |
|
|
|
if (!productNature.isEmpty()) remark += "产品性质: " + productNature + "; "; |
|
|
|
detail.setRemark(remark); |
|
|
|
|
|
|
|
detail.setQty(BigDecimal.ZERO); |
|
|
|
detailMap.put(invoiceSeqStr, detail); |
|
|
|
} |
|
|
|
@ -518,7 +514,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
|
|
|
|
|
// 4. 箱信息 EcssCoDelBoxList |
|
|
|
String netWeightStr = headerMap.containsKey("净重") ? getMergedCellValue(sheet, r, headerMap.get("净重")) : null; |
|
|
|
String grossWeightStr = headerMap.containsKey("总重量(毛重)") ? getMergedCellValue(sheet, r, headerMap.get("总重量(毛重)")) : null; |
|
|
|
String grossWeightStr = headerMap.containsKey("毛重") ? getMergedCellValue(sheet, r, headerMap.get("毛重")) : null; |
|
|
|
|
|
|
|
if (netWeightStr != null && !netWeightStr.isEmpty()) { |
|
|
|
if (isFirstRowOfMergedRegion(sheet, r, headerMap.get("净重")) || !isMerged(sheet, r, headerMap.get("净重"))) { |
|
|
|
|