Migrata gestione del recupero materiale in un servizio dedicato

This commit is contained in:
Giuseppe Scorrano 2025-02-04 09:48:03 +01:00
parent e85e05a526
commit d4a7dee121
15 changed files with 439 additions and 251 deletions

View File

@ -4,7 +4,7 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-01-17T09:18:08.345092200Z">
<DropdownSelection timestamp="2025-01-27T15:42:06.256113400Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=21088B8EFD" />

View File

@ -36,6 +36,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoAutomaticoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoBufferRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MaterialiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PVOrdiniAcquistoRESTConsumer;
@ -320,6 +321,12 @@ public class MainApplicationModule {
return new MagazzinoBufferRESTConsumer();
}
@Provides
@Singleton
MaterialiRESTConsumer provideMaterialiRESTConsumer(ExecutorService executorService) {
return new MaterialiRESTConsumer(executorService);
}
@Provides
@Singleton
SoundAlertService provideSoundAlertService() {

View File

@ -26,7 +26,7 @@ public class MtbColr extends EntityBase {
private String gestioneRif;
private String serColloRif;
private String note;
private String dataOrd;
private LocalDate dataOrd;
private String dataColloRif;
private BigDecimal qtaCnf;
private BigDecimal qtaCol;
@ -225,24 +225,15 @@ public class MtbColr extends EntityBase {
return this;
}
public String getDataOrdS() {
public LocalDate getDataOrd() {
return dataOrd;
}
public Date getDataOrdD() {
return UtilityDate.recognizeDateWithExceptionHandler(getDataOrdS());
}
public MtbColr setDataOrd(String dataOrd) {
public MtbColr setDataOrd(LocalDate dataOrd) {
this.dataOrd = dataOrd;
return this;
}
public MtbColr setDataOrd(Date dataOrd) {
this.dataOrd = UtilityDate.formatDate(dataOrd, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
return this;
}
public String getDataColloRifS() {
return dataColloRif;
}

View File

@ -0,0 +1,44 @@
package it.integry.integrywmsnative.core.rest.consumers;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
@Singleton
public class MaterialiRESTConsumer extends _BaseRESTConsumer {
private final ExecutorService executorService;
public MaterialiRESTConsumer(ExecutorService executorService) {
this.executorService = executorService;
}
public MtbColt makeSynchronousRecuperaRequest(RecuperaMaterialiRequestDTO request) throws Exception {
var materialiRESTConsumerService = RESTBuilder.getService(MaterialiRESTConsumerService.class);
var response = materialiRESTConsumerService.recupera(request)
.execute();
var data = analyzeAnswer(response, "recuperaMateriali");
if (data == null) return null;
return data.getUpdatedMtbColtScarico();
}
public void makeRecuperaRequest(RecuperaMaterialiRequestDTO request, final RunnableArgs<MtbColt> onComplete, final RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = makeSynchronousRecuperaRequest(request);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
}

View File

@ -0,0 +1,15 @@
package it.integry.integrywmsnative.core.rest.consumers;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiResponseDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
public interface MaterialiRESTConsumerService {
@POST("wms/materiali/recupera")
Call<ServiceRESTResponse<RecuperaMaterialiResponseDTO>> recupera(@Body RecuperaMaterialiRequestDTO request);
}

View File

@ -43,6 +43,11 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<LatestAppVersionInfoDTO> call, Response<LatestAppVersionInfoDTO> response) {
if(response.code() == 404) {
onSuccess.run(null);
return;
}
analyzeAnswerGeneric(response, "updates", onSuccess, onFailed);
}

View File

@ -0,0 +1,237 @@
package it.integry.integrywmsnative.core.rest.model.materiali;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import it.integry.integrywmsnative.core.model.MtbColt;
public class RecuperaMaterialiRequestDTO {
private String codMart;
private String partitaMag;
private BigDecimal numCnf;
private BigDecimal qtaCnf;
private BigDecimal qtaTot;
private int numCollo;
private LocalDate dataCollo;
private String gestione;
private String serCollo;
private int numColloRif;
private LocalDate dataColloRif;
private String gestioneRif;
private String serColloRif;
private List<Ordine> ordini;
private MtbColt mtbColtCarico;
public String getCodMart() {
return codMart;
}
public RecuperaMaterialiRequestDTO setCodMart(String codMart) {
this.codMart = codMart;
return this;
}
public String getPartitaMag() {
return partitaMag;
}
public RecuperaMaterialiRequestDTO setPartitaMag(String partitaMag) {
this.partitaMag = partitaMag;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
public RecuperaMaterialiRequestDTO setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf;
return this;
}
public BigDecimal getQtaCnf() {
return qtaCnf;
}
public RecuperaMaterialiRequestDTO setQtaCnf(BigDecimal qtaCnf) {
this.qtaCnf = qtaCnf;
return this;
}
public BigDecimal getQtaTot() {
return qtaTot;
}
public RecuperaMaterialiRequestDTO setQtaTot(BigDecimal qtaTot) {
this.qtaTot = qtaTot;
return this;
}
public int getNumCollo() {
return numCollo;
}
public RecuperaMaterialiRequestDTO setNumCollo(int numCollo) {
this.numCollo = numCollo;
return this;
}
public LocalDate getDataCollo() {
return dataCollo;
}
public RecuperaMaterialiRequestDTO setDataCollo(LocalDate dataCollo) {
this.dataCollo = dataCollo;
return this;
}
public String getGestione() {
return gestione;
}
public RecuperaMaterialiRequestDTO setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public String getSerCollo() {
return serCollo;
}
public RecuperaMaterialiRequestDTO setSerCollo(String serCollo) {
this.serCollo = serCollo;
return this;
}
public int getNumColloRif() {
return numColloRif;
}
public RecuperaMaterialiRequestDTO setNumColloRif(int numColloRif) {
this.numColloRif = numColloRif;
return this;
}
public LocalDate getDataColloRif() {
return dataColloRif;
}
public RecuperaMaterialiRequestDTO setDataColloRif(LocalDate dataColloRif) {
this.dataColloRif = dataColloRif;
return this;
}
public String getGestioneRif() {
return gestioneRif;
}
public RecuperaMaterialiRequestDTO setGestioneRif(String gestioneRif) {
this.gestioneRif = gestioneRif;
return this;
}
public String getSerColloRif() {
return serColloRif;
}
public RecuperaMaterialiRequestDTO setSerColloRif(String serColloRif) {
this.serColloRif = serColloRif;
return this;
}
public List<Ordine> getOrdini() {
return ordini;
}
public RecuperaMaterialiRequestDTO setOrdini(List<Ordine> ordini) {
this.ordini = ordini;
return this;
}
public MtbColt getMtbColtCarico() {
return mtbColtCarico;
}
public RecuperaMaterialiRequestDTO setMtbColtCarico(MtbColt mtbColtCarico) {
this.mtbColtCarico = mtbColtCarico;
return this;
}
public static class Ordine {
private Integer numero;
private LocalDate data;
private String gestione;
private Integer rigaOrd;
private BigDecimal qtaCol;
private BigDecimal numCnf;
private Integer percentageHr;
public Integer getNumero() {
return numero;
}
public Ordine setNumero(Integer numero) {
this.numero = numero;
return this;
}
public LocalDate getData() {
return data;
}
public Ordine setData(LocalDate data) {
this.data = data;
return this;
}
public String getGestione() {
return gestione;
}
public Ordine setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public Integer getRigaOrd() {
return rigaOrd;
}
public Ordine setRigaOrd(Integer rigaOrd) {
this.rigaOrd = rigaOrd;
return this;
}
public BigDecimal getQtaCol() {
return qtaCol;
}
public Ordine setQtaCol(BigDecimal qtaCol) {
this.qtaCol = qtaCol;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
public Ordine setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf;
return this;
}
public Integer getPercentageHr() {
return percentageHr;
}
public Ordine setPercentageHr(Integer percentageHr) {
this.percentageHr = percentageHr;
return this;
}
}
}

View File

@ -0,0 +1,12 @@
package it.integry.integrywmsnative.core.rest.model.materiali;
import it.integry.integrywmsnative.core.model.MtbColt;
public class RecuperaMaterialiResponseDTO {
private MtbColt updatedMtbColtScarico;
public MtbColt getUpdatedMtbColtScarico() {
return updatedMtbColtScarico;
}
}

View File

@ -39,6 +39,9 @@ public class UpdatesManager {
systemRESTConsumer.retrieveUpdatesInfo(latestData -> {
if(latestData == null)
return;
AppUpdater appUpdater = new AppUpdater(mContext)
.setDisplay(Display.DIALOG)
.setUpdateFrom(UpdateFrom.JSON)

View File

@ -4,21 +4,25 @@ import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MaterialiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.rest.ProdRecuperMaterialeRESTConsumer;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.rest.ProdRecuperoMaterialeRESTConsumer;
@Module(subcomponents = ProdRecuperoMaterialeComponent.class)
public class ProdRecuperoMaterialeModule {
@Provides
ProdRecuperMaterialeRESTConsumer providesProdRecuperMaterialeRESTConsumer(SystemRESTConsumer systemRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
return new ProdRecuperMaterialeRESTConsumer(systemRESTConsumer, articoloRESTConsumer);
ProdRecuperoMaterialeRESTConsumer providesProdRecuperMaterialeRESTConsumer(SystemRESTConsumer systemRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
return new ProdRecuperoMaterialeRESTConsumer(systemRESTConsumer, articoloRESTConsumer);
}
@Provides
ProdRecuperoMaterialeViewModel providesProdRecuperoMaterialeViewModel(ProdRecuperMaterialeRESTConsumer prodRecuperMaterialeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, PrinterRESTConsumer printerRESTConsumer) {
return new ProdRecuperoMaterialeViewModel(prodRecuperMaterialeRESTConsumer, colliMagazzinoRESTConsumer, printerRESTConsumer);
ProdRecuperoMaterialeViewModel providesProdRecuperoMaterialeViewModel(ProdRecuperoMaterialeRESTConsumer prodRecuperoMaterialeRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
PrinterRESTConsumer printerRESTConsumer,
MaterialiRESTConsumer materialiRESTConsumer) {
return new ProdRecuperoMaterialeViewModel(prodRecuperoMaterialeRESTConsumer, colliMagazzinoRESTConsumer, printerRESTConsumer, materialiRESTConsumer);
}
}

View File

@ -1,11 +1,8 @@
package it.integry.integrywmsnative.gest.prod_recupero_materiale;
import androidx.databinding.ObservableArrayList;
import androidx.lifecycle.MutableLiveData;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@ -17,26 +14,24 @@ import it.integry.integrywmsnative.core.exception.NoLUFoundException;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.model.CommonModelConsts;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MaterialiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.rest.ProdRecuperMaterialeRESTConsumer;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.rest.ProdRecuperoMaterialeRESTConsumer;
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
public class ProdRecuperoMaterialeViewModel {
private final ProdRecuperMaterialeRESTConsumer mProdRecuperMaterialeRESTConsumer;
private final ProdRecuperoMaterialeRESTConsumer mProdRecuperoMaterialeRESTConsumer;
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
private final PrinterRESTConsumer mPrinterRESTConsumer;
private final MaterialiRESTConsumer mMaterialiRESTConsumer;
private final MutableLiveData<List<HistoryVersamentoProdULDTO>> mUlList = new MutableLiveData<>();
@ -44,18 +39,20 @@ public class ProdRecuperoMaterialeViewModel {
@Inject
public ProdRecuperoMaterialeViewModel(ProdRecuperMaterialeRESTConsumer prodRecuperMaterialeRESTConsumer,
public ProdRecuperoMaterialeViewModel(ProdRecuperoMaterialeRESTConsumer prodRecuperoMaterialeRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
PrinterRESTConsumer printerRESTConsumer) {
this.mProdRecuperMaterialeRESTConsumer = prodRecuperMaterialeRESTConsumer;
PrinterRESTConsumer printerRESTConsumer,
MaterialiRESTConsumer materialiRESTConsumer) {
this.mProdRecuperoMaterialeRESTConsumer = prodRecuperoMaterialeRESTConsumer;
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mPrinterRESTConsumer = printerRESTConsumer;
this.mMaterialiRESTConsumer = materialiRESTConsumer;
}
public void init(String codJfas) {
this.sendOnLoadingStarted();
mProdRecuperMaterialeRESTConsumer.loadLastULVersate(codJfas, ulList -> {
mProdRecuperoMaterialeRESTConsumer.loadLastULVersate(codJfas, ulList -> {
this.mUlList.setValue(ulList);
this.sendOnLoadingEnded();
@ -138,184 +135,46 @@ public class ProdRecuperoMaterialeViewModel {
this.sendOnLoadingStarted();
BigDecimal inputNumCnf = pickedQuantityDTO.getNumCnf();
BigDecimal inputQtaTot = pickedQuantityDTO.getQtaTot();
BigDecimal inputQtaCnf = pickedQuantityDTO.getQtaCnf();
final MtbColt mtbColtScarico = new MtbColt()
.setDataCollo(item.getDataCollo())
.setSerCollo(item.getSerCollo())
.setNumCollo(item.getNumCollo())
.setGestione(item.getGestione())
.setMtbColr(new ObservableArrayList<>());
BigDecimal totalSumOfQtaCol = BigDecimal.ZERO;
BigDecimal totalSumOfNumCnf = BigDecimal.ZERO;
if (SettingsManager.iDB().isFlagVersamentoDirettoProduzione()) {
for (HistoryVersamentoProdULDTO.OrdineDto ordine : item.getOrdini()) {
BigDecimal qtaColToSave;
BigDecimal numCnfToSave;
if (SettingsManager.iDB().isFlagForceAllToColli() || (item.getMtbAart() != null && !item.getMtbAart().isFlagQtaCnfFissaBoolean())) {
numCnfToSave = UtilityBigDecimal.divideAndRoundToInteger(inputNumCnf.multiply(BigDecimal.valueOf(ordine.getPercentageHr())), BigDecimal.valueOf(100), RoundingMode.FLOOR);
qtaColToSave = numCnfToSave.multiply(inputQtaCnf).setScale(0, BigDecimal.ROUND_FLOOR);
} else {
qtaColToSave = UtilityBigDecimal.divideAndRoundToInteger(inputQtaTot.multiply(BigDecimal.valueOf(ordine.getPercentageHr())), BigDecimal.valueOf(100), RoundingMode.FLOOR);
numCnfToSave = UtilityBigDecimal.divide(qtaColToSave, item.getQtaCnf(), RoundingMode.FLOOR);
}
totalSumOfQtaCol = totalSumOfQtaCol.add(qtaColToSave);
totalSumOfNumCnf = totalSumOfNumCnf.add(numCnfToSave);
numCnfToSave = numCnfToSave.multiply(BigDecimal.valueOf(-1));
qtaColToSave = qtaColToSave.multiply(BigDecimal.valueOf(-1));
final MtbColr mtbColrScarico = new MtbColr()
.setCodMart(item.getCodMart())
.setPartitaMag(UtilityString.empty2null(item.getPartitaMag()))
.setQtaCol(qtaColToSave)
.setQtaCnf(inputQtaCnf)
.setNumCnf(numCnfToSave)
.setDescrizione(UtilityString.isNullOrEmpty(item.getMtbAart().getDescrizioneEstesa()) ? item.getMtbAart().getDescrizione() : item.getMtbAart().getDescrizioneEstesa())
.setDatetimeRow(UtilityDate.getDateInstance())
.setNumColloRif(item.getNumColloRif())
.setDataColloRif(item.getDataColloRif())
.setGestioneRif(item.getGestioneRif())
.setSerColloRif(item.getSerColloRif())
.setDataOrd(ordine.getData())
.setNumOrd(ordine.getNumero())
.setRigaOrd(ordine.getRigaOrd());
mtbColrScarico.setOperation(CommonModelConsts.OPERATION.INSERT);
mtbColtScarico.getMtbColr().add(mtbColrScarico);
}
} else {
BigDecimal qtaColToSave;
BigDecimal numCnfToSave;
if (SettingsManager.iDB().isFlagForceAllToColli() || (item.getMtbAart() != null && !item.getMtbAart().isFlagQtaCnfFissaBoolean())) {
numCnfToSave = inputNumCnf;
qtaColToSave = numCnfToSave.multiply(inputQtaCnf).setScale(0, BigDecimal.ROUND_FLOOR);
} else {
qtaColToSave = inputQtaTot;
numCnfToSave = UtilityBigDecimal.divide(qtaColToSave, item.getQtaCnf(), RoundingMode.FLOOR);
}
totalSumOfQtaCol = qtaColToSave;
totalSumOfNumCnf = numCnfToSave;
numCnfToSave = numCnfToSave.multiply(BigDecimal.valueOf(-1));
qtaColToSave = qtaColToSave.multiply(BigDecimal.valueOf(-1));
final MtbColr mtbColrScarico = new MtbColr()
.setCodMart(item.getCodMart())
.setPartitaMag(UtilityString.empty2null(item.getPartitaMag()))
.setQtaCol(qtaColToSave)
.setQtaCnf(inputQtaCnf)
.setNumCnf(numCnfToSave)
.setDescrizione(UtilityString.isNullOrEmpty(item.getMtbAart().getDescrizioneEstesa()) ? item.getMtbAart().getDescrizione() : item.getMtbAart().getDescrizioneEstesa())
.setDatetimeRow(UtilityDate.getDateInstance())
.setNumColloRif(item.getNumColloRif())
.setDataColloRif(item.getDataColloRif())
.setGestioneRif(item.getGestioneRif())
.setSerColloRif(item.getSerColloRif());
mtbColrScarico.setOperation(CommonModelConsts.OPERATION.INSERT);
mtbColtScarico.getMtbColr().add(mtbColrScarico);
}
boolean updateQtaCnfFirstRow = false;
if (UtilityBigDecimal.lowerThan(totalSumOfNumCnf, inputNumCnf)) {
BigDecimal diff = inputNumCnf.subtract(totalSumOfNumCnf).multiply(BigDecimal.valueOf(-1));
mtbColtScarico.getMtbColr().get(0).setNumCnf(mtbColtScarico.getMtbColr().get(0).getNumCnf().add(diff));
updateQtaCnfFirstRow = true;
}
if (UtilityBigDecimal.lowerThan(totalSumOfQtaCol, inputQtaTot)) {
BigDecimal diff = inputQtaTot.subtract(totalSumOfQtaCol).multiply(BigDecimal.valueOf(-1));
mtbColtScarico.getMtbColr().get(0).setQtaCol(mtbColtScarico.getMtbColr().get(0).getQtaCol().add(diff));
updateQtaCnfFirstRow = true;
}
if (updateQtaCnfFirstRow) {
mtbColtScarico.getMtbColr().get(0).setQtaCnf(
UtilityBigDecimal.divide(mtbColtScarico.getMtbColr().get(0).getQtaCol(), mtbColtScarico.getMtbColr().get(0).getNumCnf()));
}
for (int i = 0; i < mtbColtScarico.getMtbColr().size(); i++) {
if (mtbColtScarico.getMtbColr().get(i).getQtaCol().equals(BigDecimal.ZERO)) {
mtbColtScarico.getMtbColr().remove(i);
i--;
}
}
mtbColtScarico.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
RunnableArgss<MtbColt, Boolean> saveRunnable = (mtbColt, createdLU) -> {
if (mtbColt != null) {
List<RecuperaMaterialiRequestDTO.Ordine> ordiniRequest = item.getOrdini().stream()
.map(x -> new RecuperaMaterialiRequestDTO.Ordine()
.setData(x.getData())
.setNumero(x.getNumero())
.setGestione(x.getGestione())
.setRigaOrd(x.getRigaOrd())
.setPercentageHr(x.getPercentageHr())
.setQtaCol(x.getQtaCol())
.setNumCnf(x.getNumCnf()))
.collect(Collectors.toUnmodifiableList());
List<MtbColt> colliToSave = new ArrayList<>();
boolean shouldPrint = false;
if (!Objects.equals(mtbColt.getNumCollo(), item.getNumColloRif()) ||
!Objects.equals(mtbColt.getSerCollo(), item.getSerColloRif()) ||
!Objects.equals(mtbColt.getDataColloLD(), item.getDataColloRif()) ||
!Objects.equals(mtbColt.getGestione(), item.getGestioneRif())) {
final MtbColt mtbColtCarico = mtbColt
.setMtbColr(new ObservableArrayList<>());
mtbColtCarico
.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
final MtbColr mtbColrCarico = new MtbColr()
.setCodMart(item.getCodMart())
.setPartitaMag(UtilityString.empty2null(item.getPartitaMag()))
.setQtaCol(inputQtaTot)
.setNumCnf(inputNumCnf)
.setQtaCnf(inputQtaCnf)
.setDescrizione(UtilityString.isNullOrEmpty(item.getMtbAart().getDescrizioneEstesa()) ? item.getMtbAart().getDescrizione() : item.getMtbAart().getDescrizioneEstesa())
.setDatetimeRow(UtilityDate.getDateInstance())
.setNumColloRif(item.getNumColloRif())
.setDataColloRif(item.getDataColloRif())
.setGestioneRif(item.getGestioneRif())
.setSerColloRif(item.getSerColloRif());
mtbColtCarico.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
mtbColtCarico.getMtbColr().add(mtbColrCarico);
colliToSave.add(mtbColtCarico);
shouldPrint = true;
}
colliToSave.add(mtbColtScarico);
boolean finalShouldPrint = shouldPrint;
this.mColliMagazzinoRESTConsumer.saveColli(colliToSave, value -> {
// FBToast.successToast(mContext, mContext.getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
//
if (finalShouldPrint) {
printCollo(value.get(0), this::sendOnDataSaved);
} else {
this.sendOnDataSaved();
}
}, this::sendError);
RecuperaMaterialiRequestDTO request = new RecuperaMaterialiRequestDTO()
.setCodMart(item.getCodMart())
.setPartitaMag(item.getPartitaMag())
.setDataCollo(item.getDataCollo())
.setSerCollo(item.getSerCollo())
.setNumCollo(item.getNumCollo())
.setGestione(item.getGestione())
.setQtaTot(pickedQuantityDTO.getQtaTot())
.setNumCnf(pickedQuantityDTO.getNumCnf())
.setQtaCnf(pickedQuantityDTO.getQtaCnf())
.setDataColloRif(item.getDataColloRif())
.setSerColloRif(item.getSerColloRif())
.setGestioneRif(item.getGestioneRif())
.setNumColloRif(item.getNumColloRif())
.setOrdini(ordiniRequest);
if(mtbColt != null) {
request.setMtbColtCarico(mtbColt);
} else {
this.sendOnLoadingEnded();
request.setMtbColtCarico(sourceMtbColt);
}
//se mtbColt != sourceMtbColt allora devo stampare
this.mMaterialiRESTConsumer.makeRecuperaRequest(request, updatedMtbColt -> {
this.sendOnLoadingEnded();
}, this::sendError);
};
if (sourceMtbColt != null) saveRunnable.run(sourceMtbColt, false);

View File

@ -3,11 +3,9 @@ package it.integry.integrywmsnative.gest.prod_recupero_materiale.dto;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
public class HistoryVersamentoProdULDTO {
@ -22,6 +20,7 @@ public class HistoryVersamentoProdULDTO {
private String codJfas;
private String descrizioneFase;
private BigDecimal qtaCol;
private BigDecimal qtaCnf;
private BigDecimal numCnf;
private String partitaMag;
private String codJcom;
@ -38,8 +37,12 @@ public class HistoryVersamentoProdULDTO {
private MtbAart mtbAart;
public BigDecimal getQtaCnf() {
if(UtilityBigDecimal.equalsTo(numCnf, BigDecimal.ZERO)) return BigDecimal.ONE;
return qtaCol.divide(numCnf, 3, RoundingMode.HALF_EVEN);
return qtaCnf;
}
public HistoryVersamentoProdULDTO setQtaCnf(BigDecimal qtaCnf) {
this.qtaCnf = qtaCnf;
return this;
}
public String getGestione() {
@ -251,7 +254,7 @@ public class HistoryVersamentoProdULDTO {
public static class OrdineDto {
private Integer numero;
private Date data;
private LocalDate data;
private String gestione;
private Integer rigaOrd;
private BigDecimal qtaCol;
@ -271,11 +274,11 @@ public class HistoryVersamentoProdULDTO {
return this;
}
public Date getData() {
public LocalDate getData() {
return data;
}
public HistoryVersamentoProdULDTO.OrdineDto setData(Date data) {
public HistoryVersamentoProdULDTO.OrdineDto setData(LocalDate data) {
this.data = data;
return this;
}

View File

@ -2,9 +2,6 @@ package it.integry.integrywmsnative.gest.prod_recupero_materiale.dto;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import it.integry.integrywmsnative.core.utility.UtilityDate;
public class HistoryVersamentoProdULRestDTO {
@ -20,6 +17,7 @@ public class HistoryVersamentoProdULRestDTO {
private String codJfas;
private String descrizioneFase;
private BigDecimal qtaCol;
private BigDecimal qtaCnf;
private BigDecimal numCnf;
private String partitaMag;
private String codJcom;
@ -32,7 +30,7 @@ public class HistoryVersamentoProdULRestDTO {
private Integer numColloRif;
private Integer numOrd;
private String dataOrd;
private LocalDate dataOrd;
private String gestioneOrd;
private Integer rigaOrd;
private Integer percentageHr;
@ -145,6 +143,15 @@ public class HistoryVersamentoProdULRestDTO {
return this;
}
public BigDecimal getQtaCnf() {
return qtaCnf;
}
public HistoryVersamentoProdULRestDTO setQtaCnf(BigDecimal qtaCnf) {
this.qtaCnf = qtaCnf;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
@ -244,15 +251,11 @@ public class HistoryVersamentoProdULRestDTO {
return this;
}
public Date getDataOrdD() {
return UtilityDate.recognizeDateWithExceptionHandler(getDataOrdS());
}
public String getDataOrdS() {
public LocalDate getDataOrd() {
return dataOrd;
}
public HistoryVersamentoProdULRestDTO setDataOrd(String dataOrd) {
public HistoryVersamentoProdULRestDTO setDataOrd(LocalDate dataOrd) {
this.dataOrd = dataOrd;
return this;
}

View File

@ -4,10 +4,11 @@ import com.annimon.stream.Stream;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.inject.Singleton;
@ -23,12 +24,12 @@ import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersa
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULRestDTO;
@Singleton
public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
public class ProdRecuperoMaterialeRESTConsumer extends _BaseRESTConsumer {
private final SystemRESTConsumer mSystemRESTConsumer;
private final ArticoloRESTConsumer mArticoloRESTConsumer;
public ProdRecuperMaterialeRESTConsumer(SystemRESTConsumer systemRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
public ProdRecuperoMaterialeRESTConsumer(SystemRESTConsumer systemRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
this.mSystemRESTConsumer = systemRESTConsumer;
this.mArticoloRESTConsumer = articoloRESTConsumer;
}
@ -51,6 +52,7 @@ public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
" mtb_colr.cod_col, " +
" mtb_colr.cod_tagl, " +
" SUM(mtb_colr.qta_col) AS qta_col, " +
" mtb_colr.qta_cnf AS qta_cnf, " +
" SUM(mtb_colr.num_cnf) AS num_cnf, " +
" mtb_colr.partita_mag, " +
" mtb_colr.cod_jcom, " +
@ -62,11 +64,11 @@ public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
" ISNULL(mtb_aart.descrizione_estesa, mtb_aart.descrizione) AS descrizione_art, " +
" mtb_aart.unt_mis, " +
" MAX(datetime_row) AS datetime_row, " +
" dtb_ord_steps.num_ord, " +
" dtb_ord_steps.data_ord, " +
" dtb_ord_steps.gestione as gestione_ord, " +
" dtb_ord_steps.hr_num as hr, " +
" mtb_colr.num_ord, " +
" mtb_colr.data_ord, " +
" mtb_colr.gestione as gestione_ord, " +
" mtb_colr.riga_ord, " +
" dtb_ord_steps.hr_num as hr, " +
" CONVERT(INTEGER, ROUND((CAST(dtb_ord_steps.hr_num AS DECIMAL(20, 5)) / " +
" SUM(dtb_ord_steps.hr_num) OVER (PARTITION BY mtb_colr.num_collo)) * 100, " +
" SUM(CASE WHEN dtb_ord_steps.hr_num > 0 then dtb_ord_steps.hr_num else 1 end) OVER (PARTITION BY mtb_colr.num_collo)) * 100, " +
@ -93,6 +95,7 @@ public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
" mtb_colr.data_collo, " +
" mtb_colr.num_collo, " +
" mtb_colr.ser_collo, " +
" mtb_colr.qta_cnf, " +
" mtb_colr.cod_mart, " +
" mtb_colr.cod_col, " +
" mtb_colr.cod_tagl, " +
@ -107,9 +110,9 @@ public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
" mtb_colr.ser_collo_rif, " +
" mtb_colr.gestione_rif, " +
" mtb_colt.segno, " +
" dtb_ord_steps.num_ord, " +
" dtb_ord_steps.data_ord, " +
" dtb_ord_steps.gestione, " +
" mtb_colr.num_ord, " +
" mtb_colr.data_ord, " +
" mtb_colr.gestione, " +
" mtb_colr.riga_ord, " +
" dtb_ord_steps.hr_num " +
" HAVING SUM(mtb_colr.qta_col) > 0 " +
@ -161,7 +164,7 @@ public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
" hr " +
") " +
" " +
"SELECT qta_col, num_cnf, * FROM max_ul " +
"SELECT ul_list.* FROM max_ul " +
"LEFT OUTER JOIN ul_list ON " +
" ISNULL(max_ul.cod_jfas, '') = ISNULL(ul_list.cod_jfas, '') AND " +
" ISNULL(max_ul.descrizione_fase, '') = ISNULL(ul_list.descrizione_fase, '') AND " +
@ -214,29 +217,30 @@ public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
})
.forEach(restDTO -> {
List<HistoryVersamentoProdULDTO.OrdineDto> ordineList = Stream.of(ulList)
List<HistoryVersamentoProdULDTO.OrdineDto> ordineList = ulList.stream()
.filter(x -> x.getNumCollo().equals(restDTO.getNumCollo()) &&
x.getDataCollo().equals(restDTO.getDataCollo()) &&
x.getSerCollo().equals(restDTO.getSerCollo()) &&
x.getGestione().equals(restDTO.getGestione()))
x.getGestione().equals(restDTO.getGestione()) &&
(x.getRigaOrd() == null || Objects.equals(x.getRigaOrd(), restDTO.getRigaOrd())))
.map(x -> new HistoryVersamentoProdULDTO.OrdineDto()
.setData(x.getDataOrdD())
.setData(x.getDataOrd())
.setNumero(x.getNumOrd())
.setGestione(x.getGestioneOrd())
.setGestione(x.getGestione())
.setRigaOrd(x.getRigaOrd())
.setQtaCol(x.getQtaCol())
.setNumCnf(x.getNumCnf())
.setPercentageHr(x.getPercentageHr()))
.toList();
.collect(Collectors.toList());
BigDecimal qtaColTot = BigDecimal.ZERO;
BigDecimal numCnfColTot = BigDecimal.ZERO;
for (HistoryVersamentoProdULDTO.OrdineDto ordine :
ordineList) {
qtaColTot = qtaColTot.add(ordine.getQtaCol());
numCnfColTot = numCnfColTot.add(ordine.getNumCnf());
}
// BigDecimal qtaColTot = BigDecimal.ZERO;
// BigDecimal numCnfColTot = BigDecimal.ZERO;
//
// for (HistoryVersamentoProdULDTO.OrdineDto ordine :
// ordineList) {
// qtaColTot = qtaColTot.add(ordine.getQtaCol());
// numCnfColTot = numCnfColTot.add(ordine.getNumCnf());
// }
newUlList.add(new HistoryVersamentoProdULDTO()
.setGestione(restDTO.getGestione())
@ -250,8 +254,9 @@ public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
.setCodJfas(restDTO.getCodJfas())
.setDescrizioneArt(restDTO.getDescrizioneArt())
.setDescrizioneFase(restDTO.getDescrizioneFase())
.setQtaCol(qtaColTot)
.setNumCnf(numCnfColTot)
.setQtaCol(restDTO.getQtaCol())
.setQtaCnf(restDTO.getQtaCnf())
.setNumCnf(restDTO.getNumCnf())
.setPartitaMag(restDTO.getPartitaMag())
.setCodJcom(restDTO.getCodJcom())
.setDatetimeRow(restDTO.getDatetimeRow())
@ -274,7 +279,7 @@ public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
this.mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
if (arts != null && arts.size() > 0) {
if (arts != null && !arts.isEmpty()) {
for (HistoryVersamentoProdULDTO value : newUlList) {
MtbAart foundMtbAart = null;

View File

@ -11,7 +11,7 @@ import it.integry.integrywmsnative.core.utility.UtilityDate;
public class OrdineLavorazioneDTO {
private String dataOrdProd;
private LocalDate dataOrdProd;
private Integer numOrdProd;
@ -109,11 +109,11 @@ public class OrdineLavorazioneDTO {
private BindableFloat qtaColVersamento = new BindableFloat();
private BindableFloat numCnfVersamento = new BindableFloat();
public String getDataOrdProd() {
public LocalDate getDataOrdProd() {
return dataOrdProd;
}
public void setDataOrdProd(String dataOrdProd) {
public void setDataOrdProd(LocalDate dataOrdProd) {
this.dataOrdProd = dataOrdProd;
}