|
|
@ -286,6 +286,9 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
List<String> failList = new ArrayList<>(); |
|
|
List<String> failList = new ArrayList<>(); |
|
|
TransactionTemplate sheetTxTemplate = new TransactionTemplate(transactionManager); |
|
|
TransactionTemplate sheetTxTemplate = new TransactionTemplate(transactionManager); |
|
|
sheetTxTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); |
|
|
sheetTxTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); |
|
|
|
|
|
String selectedInvoice = data == null ? null : StringUtils.trimToEmpty(data.getCmcInvoice()); |
|
|
|
|
|
boolean filterBySelectedInvoice = StringUtils.isNotBlank(selectedInvoice); |
|
|
|
|
|
boolean hasMatchedSelectedInvoice = false; |
|
|
|
|
|
|
|
|
try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) { |
|
|
try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) { |
|
|
for (int i = 0; i < workbook.getNumberOfSheets(); i++) { |
|
|
for (int i = 0; i < workbook.getNumberOfSheets(); i++) { |
|
|
@ -294,6 +297,14 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
String cmcInvoice = getInvoiceFromSheet(sheet); |
|
|
String cmcInvoice = getInvoiceFromSheet(sheet); |
|
|
|
|
|
if (filterBySelectedInvoice && !StringUtils.equals(selectedInvoice, StringUtils.trimToEmpty(cmcInvoice))) { |
|
|
|
|
|
log.info("TX改单导入跳过sheet: sheetName={}, sheetInvoice={}, selectedInvoice={}", |
|
|
|
|
|
sheet.getSheetName(), cmcInvoice, selectedInvoice); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if (filterBySelectedInvoice) { |
|
|
|
|
|
hasMatchedSelectedInvoice = true; |
|
|
|
|
|
} |
|
|
try { |
|
|
try { |
|
|
sheetTxTemplate.executeWithoutResult(status -> { |
|
|
sheetTxTemplate.executeWithoutResult(status -> { |
|
|
try { |
|
|
try { |
|
|
@ -317,6 +328,9 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (filterBySelectedInvoice && !hasMatchedSelectedInvoice) { |
|
|
|
|
|
throw new RuntimeException("导入Excel中所有Sheet均未匹配当前选中发票号[" + selectedInvoice + "]"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Map<String, List<String>> result = new HashMap<>(); |
|
|
Map<String, List<String>> result = new HashMap<>(); |
|
|
result.put("success", successList); |
|
|
result.put("success", successList); |
|
|
@ -349,7 +363,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(requestData.getCmcInvoice()) |
|
|
if (StringUtils.isNotBlank(requestData.getCmcInvoice()) |
|
|
&& !StringUtils.equals(requestData.getCmcInvoice(), sheetInvoice)) { |
|
|
|
|
|
|
|
|
&& !StringUtils.equals(StringUtils.trimToEmpty(requestData.getCmcInvoice()), StringUtils.trimToEmpty(sheetInvoice))) { |
|
|
throw new RuntimeException("导入发票号[" + sheetInvoice + "]与当前选中发票号[" + requestData.getCmcInvoice() + "]不一致"); |
|
|
throw new RuntimeException("导入发票号[" + sheetInvoice + "]与当前选中发票号[" + requestData.getCmcInvoice() + "]不一致"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -360,7 +374,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { |
|
|
throw new RuntimeException("未找到原发货通知单,site=" + requestData.getSite() + ",delNo=" + requestData.getDelNo()); |
|
|
throw new RuntimeException("未找到原发货通知单,site=" + requestData.getSite() + ",delNo=" + requestData.getDelNo()); |
|
|
} |
|
|
} |
|
|
if (StringUtils.isNotBlank(sourceHeader.getCmcInvoice()) |
|
|
if (StringUtils.isNotBlank(sourceHeader.getCmcInvoice()) |
|
|
&& !StringUtils.equals(sourceHeader.getCmcInvoice(), sheetInvoice)) { |
|
|
|
|
|
|
|
|
&& !StringUtils.equals(StringUtils.trimToEmpty(sourceHeader.getCmcInvoice()), StringUtils.trimToEmpty(sheetInvoice))) { |
|
|
throw new RuntimeException("导入发票号[" + sheetInvoice + "]与原发货通知单发票号[" + sourceHeader.getCmcInvoice() + "]不一致"); |
|
|
throw new RuntimeException("导入发票号[" + sheetInvoice + "]与原发货通知单发票号[" + sourceHeader.getCmcInvoice() + "]不一致"); |
|
|
} |
|
|
} |
|
|
return sourceHeader; |
|
|
return sourceHeader; |
|
|
|