aggiunto messaggio di errore se l'articolo non esiste
This commit is contained in:
@@ -76,14 +76,22 @@ public class ToscaSalesService {
|
||||
Iterator<Row> rowIterator = UtilityExcel.readXlsxFile(inputStream, true);
|
||||
List<ToscaOrdineVenditaDTO> ordiniDaImportare = new ArrayList<>();
|
||||
|
||||
|
||||
List<Long> diacodNotFound = new ArrayList<>();
|
||||
while (rowIterator.hasNext()) {
|
||||
Row row = rowIterator.next();
|
||||
ToscaOrdineVenditaDTO newDTO = new ToscaOrdineVenditaDTO();
|
||||
|
||||
String codMart = null;
|
||||
Long diacod= Long.valueOf(UtilityExcel.getCellAsString(row, 2));
|
||||
codMart = findCodMartFromDiacod(String.valueOf(diacod));
|
||||
if (UtilityString.isNullOrEmpty(codMart) && !diacodNotFound.contains(diacod)) {
|
||||
diacodNotFound.add(diacod);
|
||||
continue;
|
||||
}
|
||||
newDTO
|
||||
.setTransactionNumber(UtilityExcel.getCellAsString(row, 0))
|
||||
.setDateTransaction(UtilityExcel.getCellAsDate(row, 1, CommonConstants.DATE_FORMAT_DMY_DASHED))
|
||||
.setItemNumber(Long.valueOf(UtilityExcel.getCellAsString(row, 2)))
|
||||
.setItemNumber(diacod)
|
||||
.setItemName(UtilityExcel.getCellAsString(row, 3))
|
||||
.setQuantityDelivered(new BigDecimal(UtilityExcel.getCellAsString(row, 4)))
|
||||
.setDepotNumber(UtilityExcel.getCellAsString(row, 5))
|
||||
@@ -99,12 +107,17 @@ public class ToscaSalesService {
|
||||
.setTransporterName(UtilityExcel.getCellAsString(row, 15))
|
||||
.setDeliveryDate(UtilityExcel.getCellAsDate(row, 16, CommonConstants.DATE_FORMAT_DMY_DASHED))
|
||||
.setCodAnag(findCodAnagFromDiacod(newDTO.getCounterPNr()))
|
||||
.setCodMart(findCodMartFromDiacod(String.valueOf(newDTO.getItemNumber())))
|
||||
.setCodMart(codMart)
|
||||
.setCodMdep(findCodMdepFromDiacod(newDTO.getDepotNumber()))
|
||||
;
|
||||
|
||||
ordiniDaImportare.add(newDTO);
|
||||
}
|
||||
|
||||
if (!diacodNotFound.isEmpty()) {
|
||||
throw new Exception("Articoli non trovati: " + String.join(", ", String.valueOf(diacodNotFound)));
|
||||
}
|
||||
|
||||
return ordiniDaImportare;
|
||||
}
|
||||
|
||||
@@ -115,7 +128,11 @@ public class ToscaSalesService {
|
||||
|
||||
private String findCodMartFromDiacod(String diacod) throws Exception {
|
||||
String sql = "SELECT cod_mart from mtb_aart where diacod = " + UtilityDB.valueToString(diacod);
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
String codMart = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (UtilityString.isNullOrEmpty(codMart)) {
|
||||
throw new Exception(String.format("Articolo non trovato per il codice %S", diacod));
|
||||
}
|
||||
return codMart;
|
||||
}
|
||||
|
||||
private String findCodAnagFromDiacod(String diacod) throws Exception {
|
||||
@@ -235,7 +252,6 @@ public class ToscaSalesService {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
String ragSoc = order.getTransporterName();
|
||||
GtbAnag gtbAnag = new GtbAnag();
|
||||
gtbAnag
|
||||
|
||||
Reference in New Issue
Block a user