[WMSGenericService]
- Se presente viene presa la maxDataCollo dei colli di carico, altrimenti la data odierna, come data_collo degli ordini di scarico
This commit is contained in:
@@ -2499,14 +2499,17 @@ public class WMSGenericService {
|
||||
String codMart = scarico.getCodMart();
|
||||
MtbColt sourceUl = scarico.getSourceUl();
|
||||
DtbOrdr order = scarico.getOrder();
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codMart)) {
|
||||
anomalieList.add(AnomalieDTO.error("Non è stato possibile scaricare la quantita per un articolo: codice articolo non selezionato!"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UtilityString.isNullOrEmpty(codMdep)) {
|
||||
anomalieList.add(AnomalieDTO.error("Non è stato possibile scaricare la quantita per l'articolo:" + codMart + ": deposito non selezionato!"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sourceUl != null && (
|
||||
sourceUl.getDataCollo() == null ||
|
||||
sourceUl.getNumCollo() == null ||
|
||||
@@ -2516,14 +2519,7 @@ public class WMSGenericService {
|
||||
anomalieList.add(AnomalieDTO.error("Non è stato possibile scaricare la quantita per l'articolo " + codMart + ": i dati del collo di origine non cono completi"));
|
||||
continue;
|
||||
}
|
||||
// if (order != null && (
|
||||
// order.getDataOrd() == null ||
|
||||
// order.getNumOrd() == null ||
|
||||
// order.getGestione() == null
|
||||
// )) {
|
||||
// anomalieList.add(AnomalieDTO.error("Non è stato possibile scaricare la quantita per l'articolo " + codMart + ": i dati dell' ordine non sono completi"));
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if (order != null) {
|
||||
codAnag = !UtilityString.isNullOrEmpty(order.getCodAnag()) ? order.getCodAnag() : null;
|
||||
if (UtilityString.isNullOrEmpty(codAnag)) {
|
||||
@@ -2550,15 +2546,17 @@ public class WMSGenericService {
|
||||
anomalieList.add(AnomalieDTO.warning("Non è stato possibile scaricare la quantita di materia prima dell'articolo " + codMart + ": giacenza non disponibile "));
|
||||
continue; //throw new Exception("Non è stato trovato alcun articolo in giacenza");
|
||||
}
|
||||
|
||||
BigDecimal qtaDaScaricare = scarico.getQuantity();
|
||||
BigDecimal qtaRimanente = qtaDaScaricare;
|
||||
for (MvwSitArtUdcDetInventarioDTO giacenza : availableQty) {
|
||||
|
||||
for (MvwSitArtUdcDetInventarioDTO giacenza : availableQty) {
|
||||
if (UtilityBigDecimal.equalsOrLowerThan(qtaRimanente, BigDecimal.ZERO)) {
|
||||
break;
|
||||
}
|
||||
|
||||
MtbColt mtbColt = null;
|
||||
|
||||
if (order != null) {
|
||||
mtbColt = Stream.of(mtbColtsToInsert).filter(x -> order.getDataOrd().equals(x.getDataOrd()) &&
|
||||
order.getNumOrd().equals(x.getNumOrd()) &&
|
||||
@@ -2584,14 +2582,29 @@ public class WMSGenericService {
|
||||
|
||||
List<MtbColt> alreadyPresentMtbColts = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), queryMtbColt, MtbColt.class);
|
||||
|
||||
|
||||
if (alreadyPresentMtbColts != null && alreadyPresentMtbColts.size() > 0) {
|
||||
if (alreadyPresentMtbColts != null && !alreadyPresentMtbColts.isEmpty()) {
|
||||
mtbColt = alreadyPresentMtbColts.get(0);
|
||||
mtbColt.setOperation(OperationType.NO_OP);
|
||||
mtbColtsToInsert.add(mtbColt);
|
||||
}
|
||||
}
|
||||
|
||||
LocalDate maxDataCollo = UtilityLocalDate.getNow();
|
||||
|
||||
if (mtbColt == null || scarico.isCreateNewUl()) {
|
||||
String queryMaxDataCollo = "SELECT MAX(data_collo)" +
|
||||
" FROM mtb_colt" +
|
||||
" WHERE segno = 1 " +
|
||||
" AND data_ord = " + UtilityDB.valueToString(order.getDataOrd()) +
|
||||
" AND num_ord = " + UtilityDB.valueToString(order.getNumOrd()) +
|
||||
" AND gestione = " + UtilityDB.valueToString(order.getGestione());
|
||||
|
||||
Date dateMaxDataCollo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), queryMaxDataCollo);
|
||||
|
||||
if (dateMaxDataCollo != null) {
|
||||
maxDataCollo = UtilityLocalDate.localDateFromDate(dateMaxDataCollo);
|
||||
}
|
||||
|
||||
mtbColt = new MtbColt()
|
||||
.setMtbColr(new ArrayList<>())
|
||||
.setGestione("L")
|
||||
@@ -2602,20 +2615,23 @@ public class WMSGenericService {
|
||||
.setDataOrd(order != null ? order.getDataOrd() : null)
|
||||
.setNumOrd((order != null ? order.getNumOrd() : null))
|
||||
.setIdLotto(scarico.getIdLotto())
|
||||
.setCodAnag(codAnag);
|
||||
.setCodAnag(codAnag)
|
||||
.setDataCollo(maxDataCollo);
|
||||
|
||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
mtbColtsToInsert.add(mtbColt);
|
||||
}
|
||||
|
||||
BigDecimal qtaToTake = UtilityBigDecimal.getLowerBetween(giacenza.getQtaCol(), qtaRimanente);
|
||||
|
||||
|
||||
//TODO: E' stato arrotondato a 4 perchè non si può utilizzare il campo cifre_dec della mtb_unt_mis perché per qta
|
||||
// molto piccole in UM = PZ non scaricherebbe nulla (da valutare un miglioramento)
|
||||
qtaToTake = UtilityBigDecimal.round(qtaToTake, 4);
|
||||
|
||||
if (UtilityBigDecimal.equalsOrLowerThan(qtaToTake, BigDecimal.ZERO)) continue;
|
||||
|
||||
Date dateTimeRow = UtilityLocalDate.localDateToDate(maxDataCollo);
|
||||
|
||||
MtbColr mtbColr = new MtbColr()
|
||||
.setCodMart(giacenza.getCodMart())
|
||||
.setCodJcom(giacenza.getCodJcom())
|
||||
@@ -2627,7 +2643,9 @@ public class WMSGenericService {
|
||||
.setNumColloRif(giacenza.getNumCollo())
|
||||
.setDataColloRif(UtilityLocalDate.localDateToDate(giacenza.getDataCollo()))
|
||||
.setSerColloRif(giacenza.getSerCollo())
|
||||
.setGestioneRif(giacenza.getGestione());
|
||||
.setGestioneRif(giacenza.getGestione())
|
||||
.setDatetimeRow(dateTimeRow);
|
||||
|
||||
mtbColr.setOperation(OperationType.INSERT);
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user