Refactoring picking resi cliente. Da completare con picking resi fornitore.

This commit is contained in:
2025-06-17 12:15:27 +02:00
parent b8bb20ce0d
commit 5e7af4ced4
24 changed files with 965 additions and 664 deletions

View File

@@ -241,8 +241,8 @@ public class MainApplicationModule {
@Provides @Provides
@Singleton @Singleton
PrinterRESTConsumer providePrinterRESTConsumer(RESTBuilder restBuilder) { PrinterRESTConsumer providePrinterRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
return new PrinterRESTConsumer(restBuilder); return new PrinterRESTConsumer(executorService, restBuilder);
} }
@Provides @Provides
@@ -319,8 +319,8 @@ public class MainApplicationModule {
@Provides @Provides
@Singleton @Singleton
ColliAccettazioneRESTConsumer provideColliAccettazioneRESTConsumer(RESTBuilder restBuilder) { ColliAccettazioneRESTConsumer provideColliAccettazioneRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
return new ColliAccettazioneRESTConsumer(restBuilder); return new ColliAccettazioneRESTConsumer(executorService, restBuilder);
} }
@Provides @Provides

View File

@@ -6,7 +6,7 @@ public interface ILUPrintListener {
void onLUSuccessullyPrinted(); void onLUSuccessullyPrinted();
void onLUPrintRequest(RunnableArgs<Boolean> onComplete); boolean onLUPrintRequest();
void onLUPrintError(Exception ex, Runnable onComplete); void onLUPrintError(Exception ex, Runnable onComplete);

View File

@@ -4,9 +4,8 @@ import com.google.gson.annotations.SerializedName;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date;
import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.model.key.DtbDocrKey;
public class DtbDocr extends EntityBase { public class DtbDocr extends EntityBase {
@@ -17,7 +16,7 @@ public class DtbDocr extends EntityBase {
private String codDtip; private String codDtip;
@SerializedName("dataDoc") @SerializedName("dataDoc")
private String dataDoc; private LocalDate dataDoc;
@SerializedName("idRiga") @SerializedName("idRiga")
private Integer idRiga; private Integer idRiga;
@@ -216,6 +215,10 @@ public class DtbDocr extends EntityBase {
type = "dtb_docr"; type = "dtb_docr";
} }
public DtbDocrKey getKey() {
return new DtbDocrKey(codAnag, codDtip, dataDoc, numDoc, serDoc, idRiga);
}
public String getCodAnag() { public String getCodAnag() {
return codAnag; return codAnag;
} }
@@ -234,17 +237,12 @@ public class DtbDocr extends EntityBase {
return this; return this;
} }
public String getDataDocS() { public LocalDate getDataDoc() {
return dataDoc; return dataDoc;
} }
public Date getDataDocD() { public void setDataDoc(LocalDate dataDoc) {
return UtilityDate.recognizeDateWithExceptionHandler(getDataDocS());
}
public DtbDocr setDataDoc(String dataDoc) {
this.dataDoc = dataDoc; this.dataDoc = dataDoc;
return this;
} }
public Integer getIdRiga() { public Integer getIdRiga() {

View File

@@ -0,0 +1,35 @@
package it.integry.integrywmsnative.core.model.key;
import com.google.gson.annotations.SerializedName;
import java.time.LocalDate;
import java.util.Objects;
public class DtbDocrKey extends DtbDoctKey {
@SerializedName("idRiga")
private final int idRiga;
public DtbDocrKey(String codAnag, String codDtip, LocalDate dataDoc, Integer numDoc, String serDoc, int idRiga) {
super(codAnag, codDtip, dataDoc, numDoc, serDoc);
this.idRiga = idRiga;
}
public int getIdRiga() {
return idRiga;
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
DtbDocrKey that = (DtbDocrKey) o;
return getIdRiga() == that.getIdRiga();
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), getIdRiga());
}
}

View File

@@ -2,6 +2,8 @@ package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
@@ -17,109 +19,131 @@ import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCResponseDTO; import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCResponseDTO;
import it.integry.integrywmsnative.core.rest.model.udc.DeleteUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.DeleteUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowResponseDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliCaricoRESTConsumerInterface { public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliCaricoRESTConsumerInterface {
private final ExecutorService executorService;
private final RESTBuilder restBuilder; private final RESTBuilder restBuilder;
public ColliAccettazioneRESTConsumer(RESTBuilder restBuilder) { public ColliAccettazioneRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
this.executorService = executorService;
this.restBuilder = restBuilder; this.restBuilder = restBuilder;
} }
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { @Override
public CreateUDCResponseDTO synchronousCreateUDC(CreateUDCRequestDTO createUDCRequestDTO) throws Exception {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.createUDC(createUDCRequestDTO) var response = colliAccettazioneRESTConsumerService.createUDC(createUDCRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, Response<ServiceRESTResponse<CreateUDCResponseDTO>> response) {
analyzeAnswer(response, "accettazione/createUDC", data -> onComplete.run(data.getMtbColt()), onFailed);
}
@Override var data = analyzeAnswer(response, "accettazione/createUDC");
public void onFailure(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, @NonNull final Exception e) { return data;
onFailed.run(e); }
}
});
@Override
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
MtbColt result = synchronousCreateUDC(createUDCRequestDTO).getMtbColt();
onComplete.run(result);
} catch (Exception e) {
onFailed.run(e);
}
});
}
@Override
public CloseUDCResponseDTO synchronousCloseUDC(CloseUDCRequestDTO closeUDCRequestDTO) throws Exception {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
var response = colliAccettazioneRESTConsumerService.closeUDC(closeUDCRequestDTO)
.execute();
return analyzeAnswer(response, "accettazione/closeUDC");
} }
@Override @Override
public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
CloseUDCResponseDTO result = synchronousCloseUDC(closeUDCRequestDTO);
onComplete.run(result);
} catch (Exception e) {
onFailed.run(e);
}
});
}
@Override
public MtbColr synchronousInsertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO) throws Exception {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.closeUDC(closeUDCRequestDTO) var response = colliAccettazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, Response<ServiceRESTResponse<CloseUDCResponseDTO>> response) { var data = analyzeAnswer(response, "accettazione/insertUDCRow");
analyzeAnswer(response, "accettazione/closeUDC", onComplete, onFailed);
}
@Override return data.getSavedMtbColr();
public void onFailure(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
} }
@Override @Override
public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
onComplete.run(synchronousInsertUDCRow(insertUDCRowRequestDTO));
} catch (Exception e) {
onFailed.run(e);
}
});
}
@Override
public MtbColr synchronousEditUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO) throws Exception {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO) var response = colliAccettazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDCRowResponseDTO>> response) {
analyzeAnswer(response, "accettazione/insertUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
}
@Override var data = analyzeAnswer(response, "accettazione/editUDCRow");
public void onFailure(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, @NonNull final Exception e) { return data.getSavedMtbColr();
onFailed.run(e);
}
});
} }
@Override @Override
public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
onComplete.run(synchronousEditUDCRow(editUDCRowRequestDTO));
} catch (Exception e) {
onFailed.run(e);
}
});
}
@Override
public void synchronousDeleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO) throws Exception {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO) var response = colliAccettazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDCRowResponseDTO>> response) {
analyzeAnswer(response, "accettazione/editUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
}
@Override analyzeAnswer(response, "accettazione/deleteUDCRow");
public void onFailure(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
} }
@Override @Override
public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class); executorService.execute(() -> {
try {
colliAccettazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO) synchronousDeleteUDCRow(deleteUDCRowRequestDTO);
.enqueue(new ManagedErrorCallback<>() { onComplete.run();
@Override } catch (Exception e) {
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { onFailed.run(e);
analyzeAnswer(response, "accettazione/deleteUDCRow", data -> onComplete.run(), onFailed); }
} });
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
} }
public void checkBarcodeUl(String barcodeUl, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed){ public void checkBarcodeUl(String barcodeUl, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed){

View File

@@ -23,7 +23,6 @@ import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCResponseDTO; import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCResponseDTO;
import it.integry.integrywmsnative.core.rest.model.udc.DeleteUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.DeleteUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO; import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSFromArtRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSFromArtRequestDTO;
@@ -31,7 +30,6 @@ import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.DeleteUDSRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.DeleteUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
@@ -53,75 +51,93 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
} }
@Override @Override
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { public CreateUDCResponseDTO synchronousCreateUDC(CreateUDCRequestDTO createUDCRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.createUDC(createUDCRequestDTO) var response = colliLavorazioneRESTConsumerService.createUDC(createUDCRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, Response<ServiceRESTResponse<CreateUDCResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/createUDC", data -> onComplete.run(data.getMtbColt()), onFailed);
}
@Override var data = analyzeAnswer(response, "lavorazione/createUDC");
public void onFailure(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, @NonNull final Exception e) { return data;
onFailed.run(e); }
}
}); @Override
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
MtbColt result = synchronousCreateUDC(createUDCRequestDTO).getMtbColt();
onComplete.run(result);
} catch (Exception e) {
onFailed.run(e);
}
});
}
@Override
public CloseUDCResponseDTO synchronousCloseUDC(CloseUDCRequestDTO closeUDCRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
var response = colliLavorazioneRESTConsumerService.closeUDC(closeUDCRequestDTO)
.execute();
return analyzeAnswer(response, "lavorazione/closeUDC");
} }
@Override @Override
public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
CloseUDCResponseDTO result = synchronousCloseUDC(closeUDCRequestDTO);
onComplete.run(result);
} catch (Exception e) {
onFailed.run(e);
}
});
}
@Override
public MtbColr synchronousInsertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.closeUDC(closeUDCRequestDTO) var response = colliLavorazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, Response<ServiceRESTResponse<CloseUDCResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/closeUDC", onComplete, onFailed);
}
@Override var data = analyzeAnswer(response, "lavorazione/insertUDCRow");
public void onFailure(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e); return data.getSavedMtbColr();
}
});
} }
@Override @Override
public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
onComplete.run(synchronousInsertUDCRow(insertUDCRowRequestDTO));
} catch (Exception e) {
onFailed.run(e);
}
});
}
@Override
public MtbColr synchronousEditUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO) var response = colliLavorazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDCRowResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/insertUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
}
@Override var data = analyzeAnswer(response, "lavorazione/editUDCRow");
public void onFailure(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, @NonNull final Exception e) { return data.getSavedMtbColr();
onFailed.run(e);
}
});
} }
@Override @Override
public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class); executorService.execute(() -> {
try {
colliLavorazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO) onComplete.run(synchronousEditUDCRow(editUDCRowRequestDTO));
.enqueue(new ManagedErrorCallback<>() { } catch (Exception e) {
@Override onFailed.run(e);
public void onResponse(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDCRowResponseDTO>> response) { }
analyzeAnswer(response, "lavorazione/editUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); });
}
@Override
public void onFailure(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
} }
public MtbColt createUDSSynchronized(CreateUDSRequestDTO createUDSRequestDTO) throws Exception { public MtbColt createUDSSynchronized(CreateUDSRequestDTO createUDSRequestDTO) throws Exception {
@@ -231,22 +247,26 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
}); });
} }
@Override @Override
public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void synchronousDeleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO) var response = colliLavorazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "lavorazione/deleteUDCRow", data -> onComplete.run(), onFailed);
}
@Override analyzeAnswer(response, "lavorazione/deleteUDCRow");
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) { }
onFailed.run(e); @Override
} public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
}); executorService.execute(() -> {
try {
synchronousDeleteUDCRow(deleteUDCRowRequestDTO);
onComplete.run();
} catch (Exception e) {
onFailed.run(e);
}
});
} }

View File

@@ -485,19 +485,25 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
analyzeAnswer(response, "updateDepositoUL"); analyzeAnswer(response, "updateDepositoUL");
} }
public void updateDataFine(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void synchronousUpdateDataFine(MtbColt mtbColt) throws Exception {
MtbColt cloneMtbColt = (MtbColt) mtbColt.clone(); MtbColt cloneMtbColt = (MtbColt) mtbColt.clone();
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.UPDATE); cloneMtbColt.setOperation(CommonModelConsts.OPERATION.UPDATE);
cloneMtbColt.setOraFinePrep(UtilityDate.getDateInstance()); cloneMtbColt.setOraFinePrep(UtilityDate.getDateInstance());
cloneMtbColt.setMtbColr(new ObservableArrayList<>()); cloneMtbColt.setMtbColr(new ObservableArrayList<>());
saveCollo(cloneMtbColt, value -> { var value = saveColloSynchronized(cloneMtbColt);
onComplete.run(); }
}, ex -> {
if (onFailed != null) onFailed.run(ex);
});
public void updateDataFine(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
synchronousUpdateDataFine(mtbColt);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
} }
@@ -743,26 +749,28 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
public void printUL(PrintULRequestDTO printULRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void printULSynchronized(PrintULRequestDTO printULRequestDTO) throws Exception {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
onComplete.run();
return; return;
} }
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.printUL(printULRequestDTO) var response = colliMagazzinoRESTConsumerService.printUL(printULRequestDTO)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "generic/printUL", Void -> onComplete.run(), onFailed);
}
@Override analyzeAnswer(response, "generic/printUL");
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) { }
onFailed.run(e);
} public void printUL(PrintULRequestDTO printULRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
}); executorService.execute(() -> {
try {
printULSynchronized(printULRequestDTO);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
} }

View File

@@ -5,6 +5,7 @@ import androidx.annotation.NonNull;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton; import javax.inject.Singleton;
@@ -25,35 +26,37 @@ import retrofit2.Response;
@Singleton @Singleton
public class PrinterRESTConsumer extends _BaseRESTConsumer { public class PrinterRESTConsumer extends _BaseRESTConsumer {
private final ExecutorService executorService;
private final RESTBuilder restBuilder; private final RESTBuilder restBuilder;
public PrinterRESTConsumer(RESTBuilder restBuilder) { public PrinterRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
this.executorService = executorService;
this.restBuilder = restBuilder; this.restBuilder = restBuilder;
} }
public void printCollo(MtbColt testataColloToPrint, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void synchronousPrintCollo(MtbColt testataColloToPrint) throws Exception {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
onComplete.run();
return; return;
} }
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class); PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService var response = printerService
.printCollo(testataColloToPrint) .printCollo(testataColloToPrint)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "printCollo", data -> {
onComplete.run();
}, onFailed);
}
@Override analyzeAnswer(response, "printCollo");
public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) { }
onFailed.run(e);
} public void printCollo(MtbColt testataColloToPrint, Runnable onComplete, RunnableArgs<Exception> onFailed) {
});
executorService.execute(() -> {
try {
synchronousPrintCollo(testataColloToPrint);
onComplete.run();
} catch (Exception e) {
onFailed.run(e);
}
});
} }

View File

@@ -6,19 +6,25 @@ import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCResponseDTO; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCResponseDTO;
import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCResponseDTO;
import it.integry.integrywmsnative.core.rest.model.udc.DeleteUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.DeleteUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO;
public interface ColliCaricoRESTConsumerInterface { public interface ColliCaricoRESTConsumerInterface {
CreateUDCResponseDTO synchronousCreateUDC(CreateUDCRequestDTO createUDCRequestDTO) throws Exception;
void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed); void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed);
CloseUDCResponseDTO synchronousCloseUDC(CloseUDCRequestDTO closeUDCRequestDTO) throws Exception;
void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed); void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed);
MtbColr synchronousInsertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO) throws Exception;
void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed); void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed);
MtbColr synchronousEditUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO) throws Exception;
void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed); void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed);
void synchronousDeleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO) throws Exception;
void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed); void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed);
} }

View File

@@ -26,6 +26,9 @@ public class CreateUDCRequestDTO {
@SerializedName("annotazioni") @SerializedName("annotazioni")
private String annotazioni; private String annotazioni;
@SerializedName("reso")
private boolean reso;
@SerializedName("orders") @SerializedName("orders")
private List<CreateUDCRequestOrderDTO> orders; private List<CreateUDCRequestOrderDTO> orders;
@@ -94,6 +97,15 @@ public class CreateUDCRequestDTO {
return this; return this;
} }
public boolean isReso() {
return reso;
}
public CreateUDCRequestDTO setReso(boolean reso) {
this.reso = reso;
return this;
}
public List<CreateUDCRequestOrderDTO> getOrders() { public List<CreateUDCRequestOrderDTO> getOrders() {
return orders; return orders;
} }

View File

@@ -6,6 +6,7 @@ import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.model.key.DtbDocrKey;
public class InsertUDCRowRequestDTO { public class InsertUDCRowRequestDTO {
@SerializedName("targetMtbColt") @SerializedName("targetMtbColt")
@@ -48,6 +49,14 @@ public class InsertUDCRowRequestDTO {
@SerializedName("codDtip") @SerializedName("codDtip")
private String codDtip; private String codDtip;
@SerializedName("pesoNettoKg")
private BigDecimal pesoNettoKg;
@SerializedName("pesoLordoKg")
private BigDecimal pesoLordoKg;
@SerializedName("documentReso")
private DtbDocrKey documentReso;
public MtbColt getTargetMtbColt() { public MtbColt getTargetMtbColt() {
return targetMtbColt; return targetMtbColt;
@@ -210,4 +219,29 @@ public class InsertUDCRowRequestDTO {
this.codDtip = codDtip; this.codDtip = codDtip;
return this; return this;
} }
public BigDecimal getPesoNettoKg() {
return pesoNettoKg;
}
public void setPesoNettoKg(BigDecimal pesoNettoKg) {
this.pesoNettoKg = pesoNettoKg;
}
public BigDecimal getPesoLordoKg() {
return pesoLordoKg;
}
public void setPesoLordoKg(BigDecimal pesoLordoKg) {
this.pesoLordoKg = pesoLordoKg;
}
public DtbDocrKey getDocumentReso() {
return documentReso;
}
public InsertUDCRowRequestDTO setDocumentReso(DtbDocrKey documentReso) {
this.documentReso = documentReso;
return this;
}
} }

View File

@@ -530,8 +530,9 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
} }
@Override @Override
public void onLUPrintRequest(RunnableArgs<Boolean> onComplete) { public boolean onLUPrintRequest() {
return false;
} }
@Override @Override

View File

@@ -723,7 +723,8 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
} }
@Override @Override
public void onLUPrintRequest(RunnableArgs<Boolean> onComplete) { public boolean onLUPrintRequest() {
return false;
} }
@Override @Override

View File

@@ -6,6 +6,7 @@ import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.SpannableString; import android.text.SpannableString;
import android.util.Pair;
import android.view.Gravity; import android.view.Gravity;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
@@ -20,6 +21,8 @@ import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject; import javax.inject.Inject;
@@ -32,7 +35,6 @@ import it.integry.integrywmsnative.core.data_cache.DataCache;
import it.integry.integrywmsnative.core.di.BindableBoolean; import it.integry.integrywmsnative.core.di.BindableBoolean;
import it.integry.integrywmsnative.core.expansion.BaseActivity; import it.integry.integrywmsnative.core.expansion.BaseActivity;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.model.MtbAart; import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbColt;
@@ -144,7 +146,17 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep(); String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
this.mViewmodel.init(mDocumentiResiList, defaultSegnoLU, codMdep); executorService.execute(() -> {
this.onLoadingStarted();
try {
this.mViewmodel.init(mDocumentiResiList, defaultSegnoLU, codMdep);
this.onLoadingEnded();
} catch (Exception ex) {
this.onError(ex);
}
});
} }
@Override @Override
@@ -161,7 +173,14 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
} else if (!noLUPresent.get()) { } else if (!noLUPresent.get()) {
this.mShouldCloseActivity = true; this.mShouldCloseActivity = true;
BarcodeManager.removeCallback(mBarcodeScannerInstanceID); BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
this.mViewmodel.closeLU(true);
executorService.execute(() -> {
try {
this.mViewmodel.closeLU(true);
} catch (Exception e) {
this.onError(e);
}
});
} else { } else {
BarcodeManager.removeCallback(mBarcodeScannerInstanceID); BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed(); super.onBackPressed();
@@ -198,7 +217,13 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
pickingResiListAdapter.setOnItemClicked((clickedItem, refMtbColt) -> { pickingResiListAdapter.setOnItemClicked((clickedItem, refMtbColt) -> {
if (!noLUPresent.get()) { if (!noLUPresent.get()) {
this.mViewmodel.dispatchOrdineRow(clickedItem, refMtbColt); executorService.execute(() -> {
try {
this.mViewmodel.dispatchOrdineRow(clickedItem, refMtbColt);
} catch (Exception e) {
this.onError(e);
}
});
} }
}); });
} }
@@ -212,12 +237,12 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
.toList(); .toList();
Stream.of(tmpList) Stream.of(tmpList)
.sortBy(x -> x.getNumDoc() + " " + x.getDataDocS() + " " + x.getCodDtip() + " " + x.getSerDoc() + " " + x.getCodAnag() + " " + x.getIdRiga()) .sortBy(x -> x.getNumDoc() + " " + x.getDataDoc() + " " + x.getCodDtip() + " " + x.getSerDoc() + " " + x.getCodAnag() + " " + x.getIdRiga())
.forEach(x -> { .forEach(x -> {
PickingResiListModel pickingResiListModel = new PickingResiListModel(); PickingResiListModel pickingResiListModel = new PickingResiListModel();
pickingResiListModel.setGroupTitle(x.getCodDtip() + " - N° " + x.getNumDoc() + " del " + UtilityDate.formatDate(x.getDataDocD(), UtilityDate.COMMONS_DATE_FORMATS.DM_HUMAN)); pickingResiListModel.setGroupTitle(x.getCodDtip() + " - N° " + x.getNumDoc() + " del " + UtilityDate.formatDate(x.getDataDoc(), UtilityDate.COMMONS_DATE_FORMATS.DM_HUMAN));
pickingResiListModel.setBadge1(x.getCodMart()); pickingResiListModel.setBadge1(x.getCodMart());
pickingResiListModel.setDescrizione(UtilityString.isNull(x.getDescrizioneEstesa(), x.getDescrizione())); pickingResiListModel.setDescrizione(UtilityString.isNull(x.getDescrizioneEstesa(), x.getDescrizione()));
pickingResiListModel.setActive(true); pickingResiListModel.setActive(true);
@@ -254,9 +279,15 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> { private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
this.onLoadingStarted(); this.onLoadingStarted();
this.mViewmodel.processBarcodeDTO(data, () -> { executorService.execute(() -> {
this.onLoadingEnded(); try {
this.mViewmodel.processBarcodeDTO(data);
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
}); });
}; };
private void initFab() { private void initFab() {
@@ -287,7 +318,15 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
public void createNewLU() { public void createNewLU() {
this.fabPopupMenu.dismiss(); this.fabPopupMenu.dismiss();
this.onLoadingStarted(); this.onLoadingStarted();
this.mViewmodel.createNewLU(null, null, this::onLoadingEnded);
executorService.execute(() -> {
try {
this.mViewmodel.createNewLU(null, null);
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
});
} }
public void removeListFilter() { public void removeListFilter() {
@@ -296,12 +335,28 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
@Override @Override
public void onMtbColrEdit(MtbColr mtbColr) { public void onMtbColrEdit(MtbColr mtbColr) {
this.mViewmodel.dispatchRowEdit(mtbColr); this.onLoadingStarted();
executorService.execute(() -> {
try {
this.mViewmodel.dispatchRowEdit(mtbColr);
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
});
} }
@Override @Override
public void onMtbColrDelete(MtbColr mtbColr) { public void onMtbColrDelete(MtbColr mtbColr) {
this.mViewmodel.deleteRow(mtbColr); this.onLoadingStarted();
executorService.execute(() -> {
try {
this.mViewmodel.deleteRow(mtbColr);
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
});
} }
@Override @Override
@@ -316,13 +371,38 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
@Override @Override
public void onBottomSheetLUClose() { public void onBottomSheetLUClose() {
this.mViewmodel.closeLU(true); executorService.execute(() -> {
try {
this.mViewmodel.closeLU(true);
} catch (Exception e) {
this.onError(e);
}
});
} }
@Override @Override
public void onInfoAggiuntiveRequired(RunnableArgss<String, ObservableMtbTcol> onComplete) { public Pair<String, ObservableMtbTcol> onInfoAggiuntiveRequired() {
DialogInfoAggiuntiveLUView.newInstance(onComplete, this::onLoadingEnded) AtomicReference<Pair<String, ObservableMtbTcol>> result = new AtomicReference<>();
CountDownLatch countDownLatch = new CountDownLatch(1);
DialogInfoAggiuntiveLUView.newInstance((noteAggiuntive, mtbTcol) -> {
result.set(new Pair<>(noteAggiuntive, mtbTcol));
countDownLatch.countDown();
}, () -> {
result.set(null);
countDownLatch.countDown();
})
.show(getSupportFragmentManager(), DialogInfoAggiuntiveLUView.class.getName()); .show(getSupportFragmentManager(), DialogInfoAggiuntiveLUView.class.getName());
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.onError(e);
}
return result.get();
} }
@Override @Override
@@ -348,41 +428,46 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
BigDecimal qtaCnfAvailable, BigDecimal qtaCnfAvailable,
String partitaMag, String partitaMag,
LocalDate dataScad, LocalDate dataScad,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) { RunnableArgs<PickedQuantityDTO> onComplete) {
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
.setMtbAart(mtbAart)
.setInitialNumCnf(initialNumCnf)
.setInitialQtaCnf(initialQtaCnf)
.setInitialQtaTot(initialQtaTot)
.setTotalQtaAvailable(totalQtaAvailable)
.setTotalNumCnfAvailable(totalNumCnfAvailable)
.setQtaCnfAvailable(qtaCnfAvailable)
.setPartitaMag(partitaMag)
.setDataScad(dataScad)
.setCanOverflowOrderQuantity(false)
.setCanLUBeClosed(false)
.setCanPartitaMagBeChanged(false);
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete(resultDTO -> {
if (resultDTO == null || resultDTO.isAborted()) {
this.mViewmodel.resetMatchedRows();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO() handler.post(() -> {
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
.setQtaTot(resultDTO.getQtaTot())
.setPartitaMag(resultDTO.getPartitaMag())
.setDataScad(resultDTO.getDataScad());
this.onLoadingStarted(); DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu()); .setMtbAart(mtbAart)
}) .setInitialNumCnf(initialNumCnf)
.show(getSupportFragmentManager(), "tag"); .setInitialQtaCnf(initialQtaCnf)
.setInitialQtaTot(initialQtaTot)
.setTotalQtaAvailable(totalQtaAvailable)
.setTotalNumCnfAvailable(totalNumCnfAvailable)
.setQtaCnfAvailable(qtaCnfAvailable)
.setPartitaMag(partitaMag)
.setDataScad(dataScad)
.setCanOverflowOrderQuantity(false)
.setCanLUBeClosed(false)
.setCanPartitaMagBeChanged(false);
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete(pickingResult -> {
if (pickingResult == null || pickingResult.isAborted()) {
onComplete.run(null);
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(pickingResult.getNumCnf())
.setQtaCnf(pickingResult.getQtaCnf())
.setQtaTot(pickingResult.getQtaTot())
.setPartitaMag(pickingResult.getPartitaMag())
.setDataScad(pickingResult.getDataScad())
.setShouldCloseLu(pickingResult.isShouldCloseLu());
onComplete.run(pickedQuantityDTO);
})
.show(getSupportFragmentManager(), "tag");
});
} }
@Override @Override
@@ -406,12 +491,14 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
@Override @Override
public void onMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) { public void onMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) {
String text = getResources().getString(R.string.alert_delete_mtb_colr); handler.post(() -> {
DialogSimpleMessageView.makeWarningDialog(new SpannableString(text), String text = getResources().getString(R.string.alert_delete_mtb_colr);
null, DialogSimpleMessageView.makeWarningDialog(new SpannableString(text),
() -> onComplete.run(true), null,
() -> onComplete.run(false) () -> onComplete.run(true),
).show(getSupportFragmentManager(), "tag"); () -> onComplete.run(false)
).show(getSupportFragmentManager(), "delete-row-dialog");
});
} }
@Override @Override
@@ -439,21 +526,36 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
@Override @Override
public void onLUSuccessullyPrinted() { public void onLUSuccessullyPrinted() {
Resources res = getResources(); handler.post(() -> {
String errorMessage = res.getText(R.string.alert_print_completed_message).toString(); Resources res = getResources();
DialogSimpleMessageView String errorMessage = res.getText(R.string.alert_print_completed_message).toString();
.makeSuccessDialog(res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null) DialogSimpleMessageView
.show(getSupportFragmentManager(), "tag"); .makeSuccessDialog(res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null)
.show(getSupportFragmentManager(), "dialog-print-completed");
});
} }
@Override @Override
public void onLUPrintRequest(RunnableArgs<Boolean> onComplete) { public boolean onLUPrintRequest() {
AtomicReference<Boolean> resultPrintPackingList = new AtomicReference<>();
CountDownLatch countDownLatch = new CountDownLatch(1);
DialogYesNoView.newInstance(getString(R.string.action_print), DialogYesNoView.newInstance(getString(R.string.action_print),
String.format(getString(R.string.message_print_packing_list), "Packing List"), String.format(getString(R.string.message_print_packing_list), "Packing List"),
result -> { result -> {
onComplete.run(result == DialogConsts.Results.YES); resultPrintPackingList.set(result == DialogConsts.Results.YES);
countDownLatch.countDown();
}) })
.show(getSupportFragmentManager(), "dialog-print"); .show(getSupportFragmentManager(), "dialog-print");
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.onError(e);
}
return resultPrintPackingList.get();
} }
@Override @Override
@@ -463,7 +565,8 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
null, null,
null, null,
R.string.button_ignore_print, R.string.button_ignore_print,
onComplete) onComplete != null ? onComplete : () -> {
})
.show(getSupportFragmentManager(), "tag"); .show(getSupportFragmentManager(), "tag");
} }
} }

View File

@@ -1,11 +1,15 @@
package it.integry.integrywmsnative.gest.picking_resi; package it.integry.integrywmsnative.gest.picking_resi;
import android.os.Handler;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService; import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliAccettazioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliSpedizioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
@@ -26,8 +30,26 @@ public class PickingResiModule {
} }
@Provides @Provides
PickingResiViewModel providesPickingResiViewModel(ArticoloRESTConsumer articoloRESTConsumer, ColliDataRecoverService colliDataRecoverService, OrdiniRESTConsumer ordiniRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, PrinterRESTConsumer printerRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, PickingResiRESTConsumer pickingResiRESTConsumer) { PickingResiViewModel providesPickingResiViewModel(Handler handler,
return new PickingResiViewModel(articoloRESTConsumer, barcodeRESTConsumer, colliDataRecoverService, ordiniRESTConsumer, colliMagazzinoRESTConsumer, printerRESTConsumer, pickingResiRESTConsumer); ArticoloRESTConsumer articoloRESTConsumer,
ColliDataRecoverService colliDataRecoverService,
OrdiniRESTConsumer ordiniRESTConsumer,
ColliAccettazioneRESTConsumer colliAccettazioneRESTConsumer,
ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
PrinterRESTConsumer printerRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer,
PickingResiRESTConsumer pickingResiRESTConsumer) {
return new PickingResiViewModel(handler,
articoloRESTConsumer,
barcodeRESTConsumer,
colliDataRecoverService,
ordiniRESTConsumer,
colliAccettazioneRESTConsumer,
colliSpedizioneRESTConsumer,
colliMagazzinoRESTConsumer,
printerRESTConsumer,
pickingResiRESTConsumer);
} }
} }

View File

@@ -1,15 +1,20 @@
package it.integry.integrywmsnative.gest.picking_resi; package it.integry.integrywmsnative.gest.picking_resi;
import android.os.Handler;
import android.util.Pair;
import androidx.databinding.ObservableArrayList; import androidx.databinding.ObservableArrayList;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import com.annimon.stream.Optional;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject; import javax.inject.Inject;
@@ -20,27 +25,29 @@ import it.integry.integrywmsnative.core.exception.InvalidLUException;
import it.integry.integrywmsnative.core.exception.NoLUFoundException; import it.integry.integrywmsnative.core.exception.NoLUFoundException;
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException; import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUBaseOperationsListener; import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUBaseOperationsListener;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUPrintListener; import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUPrintListener;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener; 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.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.model.dto.PickDataDTO; import it.integry.integrywmsnative.core.model.dto.PickDataDTO;
import it.integry.integrywmsnative.core.model.observable.ObservableMtbTcol; import it.integry.integrywmsnative.core.model.observable.ObservableMtbTcol;
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliAccettazioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliSpedizioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.DocumentoResoDTO; import it.integry.integrywmsnative.core.rest.model.DocumentoResoDTO;
import it.integry.integrywmsnative.core.rest.model.udc.CreateUDCRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.DeleteUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.DeleteULRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.DeleteULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO;
import it.integry.integrywmsnative.core.utility.UtilityBarcode; import it.integry.integrywmsnative.core.utility.UtilityBarcode;
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal; 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.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.picking_resi.exceptions.DocumentsLoadException; import it.integry.integrywmsnative.gest.picking_resi.exceptions.DocumentsLoadException;
import it.integry.integrywmsnative.gest.picking_resi.rest.PickingResiRESTConsumer; import it.integry.integrywmsnative.gest.picking_resi.rest.PickingResiRESTConsumer;
@@ -63,47 +70,58 @@ public class PickingResiViewModel {
private int mDefaultSegnoOfLU; private int mDefaultSegnoOfLU;
private String mDefaultCodMdepOfLU; private String mDefaultCodMdepOfLU;
private final Handler mHandler;
private final ArticoloRESTConsumer mArticoloRESTConsumer; private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final BarcodeRESTConsumer mBarcodeRESTConsumer; private final BarcodeRESTConsumer mBarcodeRESTConsumer;
private final ColliDataRecoverService mColliDataRecoverService; private final ColliDataRecoverService mColliDataRecoverService;
private final OrdiniRESTConsumer mOrdiniRestConsumerService; private final OrdiniRESTConsumer mOrdiniRestConsumerService;
private final ColliAccettazioneRESTConsumer mColliAccettazioneRESTConsumer;
private final ColliSpedizioneRESTConsumer mColliSpedizioneRESTConsumer;
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer; private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
private final PrinterRESTConsumer mPrinterRESTConsumer; private final PrinterRESTConsumer mPrinterRESTConsumer;
private final PickingResiRESTConsumer mPickingResiRESTConsumer; private final PickingResiRESTConsumer mPickingResiRESTConsumer;
@Inject @Inject
public PickingResiViewModel(ArticoloRESTConsumer articoloRESTConsumer, public PickingResiViewModel(Handler handler,
ArticoloRESTConsumer articoloRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer,
ColliDataRecoverService colliDataRecoverService, ColliDataRecoverService colliDataRecoverService,
OrdiniRESTConsumer ordiniRESTConsumer, OrdiniRESTConsumer ordiniRESTConsumer,
ColliAccettazioneRESTConsumer colliAccettazioneRESTConsumer,
ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
PrinterRESTConsumer printerRESTConsumer, PrinterRESTConsumer printerRESTConsumer,
PickingResiRESTConsumer mPickingResiRESTConsumer) { PickingResiRESTConsumer mPickingResiRESTConsumer) {
this.mHandler = handler;
this.mArticoloRESTConsumer = articoloRESTConsumer; this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mBarcodeRESTConsumer = barcodeRESTConsumer; this.mBarcodeRESTConsumer = barcodeRESTConsumer;
this.mColliDataRecoverService = colliDataRecoverService; this.mColliDataRecoverService = colliDataRecoverService;
this.mOrdiniRestConsumerService = ordiniRESTConsumer; this.mOrdiniRestConsumerService = ordiniRESTConsumer;
this.mColliAccettazioneRESTConsumer = colliAccettazioneRESTConsumer;
this.mColliSpedizioneRESTConsumer = colliSpedizioneRESTConsumer;
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer; this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mPrinterRESTConsumer = printerRESTConsumer; this.mPrinterRESTConsumer = printerRESTConsumer;
this.mPickingResiRESTConsumer = mPickingResiRESTConsumer; this.mPickingResiRESTConsumer = mPickingResiRESTConsumer;
} }
public void init(List<DocumentoResoDTO> documentList, int defaultSegnoLU, String codMdep) { public void init(List<DocumentoResoDTO> documentList, int defaultSegnoLU, String codMdep) throws Exception {
this.mDefaultSegnoOfLU = defaultSegnoLU; this.mDefaultSegnoOfLU = defaultSegnoLU;
this.mDefaultCodMdepOfLU = codMdep; this.mDefaultCodMdepOfLU = codMdep;
this.sendOnLoadingStarted();
this.initDatiPicking(documentList); this.initDatiPicking(documentList);
this.mPickingResiRESTConsumer.loadDocRows(documentList, withdrawableDtbDocr -> { try {
var withdrawableDtbDocr = this.mPickingResiRESTConsumer.makeSynchronousRetrieveDocRowsRequest(documentList);
this.mPickingList.postValue(withdrawableDtbDocr); this.mPickingList.postValue(withdrawableDtbDocr);
this.sendOnLoadingEnded(); } catch (Exception ex) {
}, ex -> this.sendError(new DocumentsLoadException(ex))); throw new DocumentsLoadException(ex);
}
} }
private void initDatiPicking(List<DocumentoResoDTO> documentList) { private void initDatiPicking(List<DocumentoResoDTO> documentList) throws Exception {
List<String> foundGestioni = Stream.of(documentList) List<String> foundGestioni = Stream.of(documentList)
.map(DocumentoResoDTO::getGestione) .map(DocumentoResoDTO::getGestione)
.distinct() .distinct()
@@ -111,8 +129,10 @@ public class PickingResiViewModel {
.toList(); .toList();
if (foundGestioni.size() > 1) { if (foundGestioni.size() > 1) {
this.sendError(new Exception("Sono stati caricati documenti con diverse gestioni")); throw new Exception("Sono stati caricati documenti con diverse gestioni");
} else mDefaultGestioneOfLU = foundGestioni.get(0); }
mDefaultGestioneOfLU = foundGestioni.get(0);
List<String> foundCodAnags = Stream.of(documentList) List<String> foundCodAnags = Stream.of(documentList)
@@ -121,113 +141,93 @@ public class PickingResiViewModel {
.toList(); .toList();
if (foundCodAnags.size() > 1) { if (foundCodAnags.size() > 1) {
this.sendError(new Exception("Sono stati caricati documenti con diversi codici anagrafici")); throw new Exception("Sono stati caricati documenti con diversi codici anagrafici");
} else mDefaultCodAnagOfLU = foundCodAnags.get(0); }
mDefaultCodAnagOfLU = foundCodAnags.get(0);
} }
public void createNewLU(Integer customNumCollo, String customSerCollo, Runnable onComplete) { public void createNewLU(Integer customNumCollo, String customSerCollo) throws Exception {
MtbColt mtbColt = new MtbColt(); // mColliAccettazioneRESTConsumer.createUDC(new Cre);
mtbColt.initDefaultFields(GestioneEnum.fromString(mDefaultGestioneOfLU))
.setSegno(mDefaultSegnoOfLU) var createUdcResponse = mColliAccettazioneRESTConsumer.synchronousCreateUDC(new CreateUDCRequestDTO()
.setCodAnag(mDefaultCodAnagOfLU) .setCodAnag(mDefaultCodAnagOfLU)
.setCodMdep(mDefaultCodMdepOfLU) .setCodMdep(mDefaultCodMdepOfLU)
.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE); .setNumCollo(customNumCollo)
.setSerCollo(customSerCollo)
.setReso(true));
if (customNumCollo != null) mtbColt.setNumCollo(customNumCollo); this.mCurrentMtbColt = createUdcResponse.getMtbColt();
if (!UtilityString.isNullOrEmpty(customSerCollo)) mtbColt.setSerCollo(customSerCollo); this.sendLUOpened(createUdcResponse.getMtbColt());
mColliMagazzinoRESTConsumer.saveCollo(mtbColt, value -> {
mtbColt
.setNumCollo(value.getNumCollo())
.setDataCollo(value.getDataColloS())
.setMtbColr(new ObservableArrayList<>());
this.mCurrentMtbColt = mtbColt;
if (onComplete != null) onComplete.run();
this.sendLUOpened(mtbColt);
}, this::sendError);
} }
public void closeLU(boolean shouldPrint) { public void closeLU(boolean shouldPrint) throws Exception {
if (mCurrentMtbColt == null) return; if (mCurrentMtbColt == null) return;
this.sendOnLoadingStarted(); var canBeDeleted = mColliMagazzinoRESTConsumer.canULBeDeletedSynchronized(mCurrentMtbColt);
mColliMagazzinoRESTConsumer.canULBeDeleted(mCurrentMtbColt, canBeDeleted -> { if (canBeDeleted) {
deleteLU();
this.sendLUClosed();
if (canBeDeleted) { } else {
deleteLU(() -> { var noteAggiuntiveResponse = this.sendOnInfoAggiuntiveRequired();
this.sendLUClosed();
this.sendOnLoadingEnded();
});
} else {
this.sendOnInfoAggiuntiveRequired((noteAggiuntive, tCol) -> {
if (!UtilityString.isNullOrEmpty(noteAggiuntive)) { if (noteAggiuntiveResponse != null) {
this.mCurrentMtbColt.setAnnotazioni(noteAggiuntive); if (!UtilityString.isNullOrEmpty(noteAggiuntiveResponse.first)) {
} this.mCurrentMtbColt.setAnnotazioni(noteAggiuntiveResponse.first);
if (tCol != null) { }
this.mCurrentMtbColt.setCodTcol(tCol.getCodTcol());
this.mCurrentMtbColt.setMtbTCol(tCol);
} if (noteAggiuntiveResponse.second != null) {
this.mCurrentMtbColt.setCodTcol(noteAggiuntiveResponse.second.getCodTcol());
this.mColliMagazzinoRESTConsumer.updateDataFine(mCurrentMtbColt, () -> { this.mCurrentMtbColt.setMtbTCol(noteAggiuntiveResponse.second);
}
if (shouldPrint) {
printCollo(mCurrentMtbColt, () -> {
postCloseOperations(mCurrentMtbColt, () -> {
this.sendLUClosed();
this.sendOnLoadingEnded();
});
});
} else {
postCloseOperations(mCurrentMtbColt, () -> {
this.sendLUClosed();
this.sendOnLoadingEnded();
});
}
}, this::sendError);
});
} }
}, this::sendError);
this.mColliMagazzinoRESTConsumer.synchronousUpdateDataFine(mCurrentMtbColt);
if (shouldPrint) {
printCollo(mCurrentMtbColt);
}
postCloseOperations(mCurrentMtbColt);
this.sendLUClosed();
}
} }
private void deleteLU(Runnable onComplete) { private void deleteLU() throws Exception {
DeleteULRequestDTO deleteULRequestDTO = new DeleteULRequestDTO() DeleteULRequestDTO deleteULRequestDTO = new DeleteULRequestDTO()
.setMtbColt(mCurrentMtbColt); .setMtbColt(mCurrentMtbColt);
mColliMagazzinoRESTConsumer.deleteUL(deleteULRequestDTO, () -> { mColliMagazzinoRESTConsumer.deleteULSynchronized(deleteULRequestDTO);
this.mCurrentMtbColt = null; this.mCurrentMtbColt = null;
if (onComplete != null) onComplete.run();
}, this::sendError);
} }
private void printCollo(MtbColt mtbColtToPrint, Runnable onComplete) { private void printCollo(MtbColt mtbColtToPrint) {
this.sendLUPrintRequest(shouldPrint -> { var shouldPrint = this.sendLUPrintRequest();
if (!shouldPrint) {
onComplete.run(); if (!shouldPrint) {
} else { return;
singlePrint(mtbColtToPrint, onComplete, ex -> this.sendLUPrintError(ex, onComplete)); }
}
}); try {
this.mPrinterRESTConsumer.synchronousPrintCollo(mtbColtToPrint);
} catch (Exception e) {
this.sendLUPrintError(e);
}
} }
private void singlePrint(MtbColt mtbColtToPrint, Runnable onComplete, RunnableArgs<Exception> onFailed) { private void singlePrint(MtbColt mtbColtToPrint) {
this.mPrinterRESTConsumer.printCollo(
mtbColtToPrint,
onComplete, onFailed);
} }
private void postCloseOperations(MtbColt mtbColt, Runnable onComplete) { private void postCloseOperations(MtbColt mtbColt) {
this.mColliRegistrati.add(mtbColt); this.mColliRegistrati.add(mtbColt);
List<WithdrawableDtbDocr> tmpList = getPickingList().getValue(); List<WithdrawableDtbDocr> tmpList = getPickingList().getValue();
@@ -250,10 +250,9 @@ public class PickingResiViewModel {
} }
this.mPickingList.postValue(tmpList); this.mPickingList.postValue(tmpList);
onComplete.run();
} }
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
//Se non c'è una UL aperta //Se non c'è una UL aperta
if (mCurrentMtbColt == null) { if (mCurrentMtbColt == null) {
@@ -263,120 +262,107 @@ public class PickingResiViewModel {
//Se il collo non esiste allora lo creo associandolo a questa etichetta anonima //Se il collo non esiste allora lo creo associandolo a questa etichetta anonima
//invece se esiste apro un collo nuovo e cerco gli articoli presenti nell'ul //invece se esiste apro un collo nuovo e cerco gli articoli presenti nell'ul
//dell'etichetta anonima //dell'etichetta anonima
this.executeEtichettaAnonimaNotOpenedLU(barcodeScanDTO, onComplete); this.executeEtichettaAnonimaNotOpenedLU(barcodeScanDTO);
} else { } else {
this.processBarcodeNotOpenedLU(barcodeScanDTO, onComplete); this.processBarcodeNotOpenedLU(barcodeScanDTO);
} }
} else { } else {
if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) { if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) {
//Cerco gli articoli presenti nell'ul dell'etichetta anonima //Cerco gli articoli presenti nell'ul dell'etichetta anonima
this.executeEtichettaLU(barcodeScanDTO.getStringValue(), onComplete); this.executeEtichettaLU(barcodeScanDTO.getStringValue());
} else { } else {
this.processBarcodeAlreadyOpenedLU(barcodeScanDTO, onComplete); this.processBarcodeAlreadyOpenedLU(barcodeScanDTO);
} }
} }
} }
private void processBarcodeNotOpenedLU(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void processBarcodeNotOpenedLU(BarcodeScanDTO barcodeScanDTO) throws Exception {
this.createNewLU( this.createNewLU(
null, null,
null, null);
() -> processBarcodeAlreadyOpenedLU(barcodeScanDTO, onComplete)); processBarcodeAlreadyOpenedLU(barcodeScanDTO);
} }
private void processBarcodeAlreadyOpenedLU(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void processBarcodeAlreadyOpenedLU(BarcodeScanDTO barcodeScanDTO) throws Exception {
if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) { if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
//Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL) //Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
this.executeEtichettaEan128(barcodeScanDTO, onComplete); this.executeEtichettaEan128(barcodeScanDTO);
}
} else onComplete.run();
} }
private void executeEtichettaAnonimaNotOpenedLU(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void executeEtichettaAnonimaNotOpenedLU(BarcodeScanDTO barcodeScanDTO) throws Exception {
mColliMagazzinoRESTConsumer.getBySSCC(barcodeScanDTO.getStringValue(), true, false, mtbColt -> { var mtbColt = mColliMagazzinoRESTConsumer.getBySsccSynchronized(barcodeScanDTO.getStringValue(), true, false);
if (mtbColt == null) { if (mtbColt == null) {
if (!UtilityBarcode.isEtichettaAnonimaOfCurrentYear(barcodeScanDTO.getStringValue())) {
if (!UtilityBarcode.isEtichettaAnonimaOfCurrentYear(barcodeScanDTO.getStringValue())) { throw new NotCurrentYearLUException();
this.sendError(new NotCurrentYearLUException());
} else {
int numCollo = -1;
try {
numCollo = UtilityBarcode.getNumColloFromULAnonima(barcodeScanDTO.getStringValue());
this.createNewLU(
numCollo,
CommonConst.Config.DEFAULT_ANONYMOUS_UL_SERIE, onComplete);
} catch (Exception ex) {
this.sendError(ex);
}
}
} else { } else {
int numCollo = -1;
numCollo = UtilityBarcode.getNumColloFromULAnonima(barcodeScanDTO.getStringValue());
this.createNewLU( this.createNewLU(
null, numCollo,
null, CommonConst.Config.DEFAULT_ANONYMOUS_UL_SERIE);
() -> searchArtFromUL(mtbColt, onComplete)
);
} }
}, this::sendError); } else {
this.createNewLU(
null,
null);
searchArtFromUL(mtbColt);
}
} }
private void executeEtichettaLU(String SSCC, Runnable onComplete) { private void executeEtichettaLU(String SSCC) throws Exception {
mColliMagazzinoRESTConsumer.getBySSCC(SSCC, true, false, mtbColt -> { var mtbColt = mColliMagazzinoRESTConsumer.getBySsccSynchronized(SSCC, true, false);
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) { if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
if (mtbColt.getSegno() != -1) { if (mtbColt.getSegno() != -1) {
searchArtFromUL(mtbColt, onComplete); searchArtFromUL(mtbColt);
} else this.sendError(new InvalidLUException()); } else
} else { throw new InvalidLUException();
this.sendError(new NoResultFromBarcodeException(SSCC)); } else {
} throw new NoResultFromBarcodeException(SSCC);
}
}, this::sendError);
} }
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO) throws Exception {
mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> { var ean128Model = mBarcodeRESTConsumer.decodeEan128Synchronized(barcodeScanDTO);
String barcodeProd = null;
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) barcodeProd = ean128Model.Sscc;
if (!UtilityString.isNullOrEmpty(ean128Model.Gtin)) barcodeProd = ean128Model.Gtin;
if (!UtilityString.isNullOrEmpty(ean128Model.Content))
barcodeProd = ean128Model.Content;
if (!UtilityString.isNullOrEmpty(barcodeProd)) { String barcodeProd = null;
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) barcodeProd = ean128Model.Sscc;
if (!UtilityString.isNullOrEmpty(ean128Model.Gtin)) barcodeProd = ean128Model.Gtin;
if (!UtilityString.isNullOrEmpty(ean128Model.Content))
barcodeProd = ean128Model.Content;
if (!UtilityString.isNullOrEmpty(barcodeProd)) {
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
this.executeEtichettaLU(ean128Model.Sscc);
} else
throw new NoLUFoundException();
}
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
this.executeEtichettaLU(ean128Model.Sscc, onComplete);
} else {
this.sendError(new NoLUFoundException());
}
} else {
//EAN 128 non completo o comunque mancano i riferimenti al prodotto
onComplete.run();
}
}, this::sendError);
} }
private void searchArtFromUL(MtbColt scannedUL, Runnable onComplete) { private void searchArtFromUL(MtbColt scannedUL) throws Exception {
final List<WithdrawableDtbDocr> pickingList = mPickingList.getValue(); final List<WithdrawableDtbDocr> pickingList = mPickingList.getValue();
final List<WithdrawableDtbDocr> matchPickingObject = new ArrayList<>(); final List<WithdrawableDtbDocr> matchPickingObject = new ArrayList<>();
//Controllo se nel collo ho degli articoli che corrispondono per codice / taglia / colore / lotto //Controllo se nel collo ho degli articoli che corrispondono per codice / taglia / colore / lotto
Stream.of(scannedUL.getMtbColr()) scannedUL.getMtbColr().stream()
.filter(x -> !UtilityString.isNullOrEmpty(x.getCodMart())) .filter(x -> !UtilityString.isNullOrEmpty(x.getCodMart()))
.forEach(x -> { .forEach(x -> {
@@ -399,7 +385,7 @@ public class PickingResiViewModel {
ObservableArrayList<MtbColr> cloneMtbColrs = (ObservableArrayList<MtbColr>) cloneMtbColt.getMtbColr().clone(); ObservableArrayList<MtbColr> cloneMtbColrs = (ObservableArrayList<MtbColr>) cloneMtbColt.getMtbColr().clone();
Stream.of(cloneMtbColt.getMtbColr()) cloneMtbColt.getMtbColr().stream()
.filter(x -> !(UtilityString.equalsIgnoreCase(x.getCodMart(), matchedObject.getCodMart()) && .filter(x -> !(UtilityString.equalsIgnoreCase(x.getCodMart(), matchedObject.getCodMart()) &&
UtilityString.equalsIgnoreCase(x.getCodTagl(), matchedObject.getCodTagl()) && UtilityString.equalsIgnoreCase(x.getCodTagl(), matchedObject.getCodTagl()) &&
UtilityString.equalsIgnoreCase(x.getCodCol(), matchedObject.getCodCol()))) UtilityString.equalsIgnoreCase(x.getCodCol(), matchedObject.getCodCol())))
@@ -415,11 +401,10 @@ public class PickingResiViewModel {
this.loadMatchedRows(matchPickingObject); this.loadMatchedRows(matchPickingObject);
onComplete.run();
} }
private void loadMatchedRows(List<WithdrawableDtbDocr> matchedRows) { private void loadMatchedRows(List<WithdrawableDtbDocr> matchedRows) throws Exception {
if (matchedRows == null || matchedRows.isEmpty()) { if (matchedRows == null || matchedRows.isEmpty()) {
this.sendError(new NoResultFromBarcodeException()); this.sendError(new NoResultFromBarcodeException());
} else if (matchedRows.size() == 1) { } else if (matchedRows.size() == 1) {
@@ -455,7 +440,7 @@ public class PickingResiViewModel {
} }
public void dispatchOrdineRow(final WithdrawableDtbDocr withdrawableDtbDocr, final MtbColt refMtbColt) { public void dispatchOrdineRow(final WithdrawableDtbDocr withdrawableDtbDocr, final MtbColt refMtbColt) throws Exception {
BigDecimal totalQtaDoc = withdrawableDtbDocr.getQtaDoc(); BigDecimal totalQtaDoc = withdrawableDtbDocr.getQtaDoc();
BigDecimal totalNumCnfDoc = withdrawableDtbDocr.getNumCnf(); BigDecimal totalNumCnfDoc = withdrawableDtbDocr.getNumCnf();
BigDecimal qtaCnfDoc = withdrawableDtbDocr.getQtaCnf(); BigDecimal qtaCnfDoc = withdrawableDtbDocr.getQtaCnf();
@@ -481,7 +466,7 @@ public class PickingResiViewModel {
totalAvailableNumCnf = totalNumCnfDoc; totalAvailableNumCnf = totalNumCnfDoc;
} }
this.sendOnItemDispatched( var pickedQuantityDTO = this.sendOnItemDispatched(
withdrawableDtbDocr.getMtbAart(), withdrawableDtbDocr.getMtbAart(),
totalAvailableNumCnf, totalAvailableNumCnf,
totalAvailableQtaCnf, totalAvailableQtaCnf,
@@ -490,23 +475,26 @@ public class PickingResiViewModel {
totalAvailableNumCnf, totalAvailableNumCnf,
totalAvailableQtaCnf, totalAvailableQtaCnf,
withdrawableDtbDocr.getPartitaMag(), withdrawableDtbDocr.getPartitaMag(),
withdrawableDtbDocr.getDataScadPartitaMag(), withdrawableDtbDocr.getDataScadPartitaMag());
(pickedQuantityDTO, shouldCloseLU) -> {
this.saveNewRow(withdrawableDtbDocr, if (pickedQuantityDTO == null) {
refMtbColt, resetMatchedRows();
pickedQuantityDTO.getNumCnf(), return;
pickedQuantityDTO.getQtaCnf(), }
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(), this.saveNewRow(withdrawableDtbDocr,
pickedQuantityDTO.getDataScad(), refMtbColt,
shouldCloseLU); pickedQuantityDTO.getNumCnf(),
}); pickedQuantityDTO.getQtaCnf(),
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(),
pickedQuantityDTO.isShouldCloseLu());
} }
public void dispatchRowEdit(final MtbColr mtbColrToEdit) { public void dispatchRowEdit(final MtbColr mtbColrToEdit) throws Exception {
this.sendOnItemDispatched( var pickedQuantityDTO = this.sendOnItemDispatched(
mtbColrToEdit.getMtbAart(), mtbColrToEdit.getMtbAart(),
mtbColrToEdit.getNumCnf(), mtbColrToEdit.getNumCnf(),
mtbColrToEdit.getQtaCnf(), mtbColrToEdit.getQtaCnf(),
@@ -515,39 +503,39 @@ public class PickingResiViewModel {
null, null,
null, null,
mtbColrToEdit.getPartitaMag(), mtbColrToEdit.getPartitaMag(),
mtbColrToEdit.getDataScadPartita(), mtbColrToEdit.getDataScadPartita());
(pickedQuantityDTO, shouldCloseLU) -> {
this.saveEditedRow(mtbColrToEdit, if (pickedQuantityDTO == null) {
pickedQuantityDTO.getNumCnf(), resetMatchedRows();
pickedQuantityDTO.getQtaCnf(), return;
pickedQuantityDTO.getQtaTot(), }
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(),
shouldCloseLU); this.saveEditedRow(mtbColrToEdit,
}); pickedQuantityDTO.getNumCnf(),
pickedQuantityDTO.getQtaCnf(),
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(),
pickedQuantityDTO.isShouldCloseLu());
} }
public void saveNewRow(WithdrawableDtbDocr withdrawableDtbDocr, MtbColt refMtbColt, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) { public void saveNewRow(WithdrawableDtbDocr withdrawableDtbDocr, MtbColt refMtbColt, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) throws Exception {
this.sendOnLoadingStarted(); this.sendOnLoadingStarted();
final MtbColr mtbColr = new MtbColr() InsertUDCRowRequestDTO insertUDCRowRequestDTO = new InsertUDCRowRequestDTO()
.setTargetMtbColt(mCurrentMtbColt)
.setCodMart(withdrawableDtbDocr.getMtbAart().getCodMart()) .setCodMart(withdrawableDtbDocr.getMtbAart().getCodMart())
.setPartitaMag(partitaMag) .setPartitaMag(partitaMag)
.setDataScadPartita(dataScad) .setDataScad(dataScad)
.setQtaCol(qtaTot) .setQtaTot(qtaTot)
.setQtaCnf(qtaCnf) .setQtaCnf(qtaCnf)
.setNumCnf(numCnf) .setNumCnf(numCnf)
.setDescrizione(withdrawableDtbDocr.getMtbAart().getDescrizioneEstesa()) .setDescrizione(withdrawableDtbDocr.getMtbAart().getDescrizioneEstesa())
.setDatetimeRow(UtilityDate.getNowTime())
.setCodAnagDoc(withdrawableDtbDocr.getCodAnag()) .setDocumentReso(withdrawableDtbDocr.getKey());
.setCodDtipDoc(withdrawableDtbDocr.getCodDtip())
.setSerDoc(withdrawableDtbDocr.getSerDoc())
.setNumDoc(withdrawableDtbDocr.getNumDoc())
.setDataDoc(withdrawableDtbDocr.getDataDocS())
.setIdRigaDoc(withdrawableDtbDocr.getIdRiga());
//TODO: Al posto di prelevare la prima riga bisognerebbe controllare se c'è ne una che corrisponde con la partita richiesta //TODO: Al posto di prelevare la prima riga bisognerebbe controllare se c'è ne una che corrisponde con la partita richiesta
MtbColr mtbColrToDispatch = withdrawableDtbDocr.getTempPickData() != null && MtbColr mtbColrToDispatch = withdrawableDtbDocr.getTempPickData() != null &&
@@ -557,39 +545,35 @@ public class PickingResiViewModel {
withdrawableDtbDocr.getTempPickData().getSourceMtbColt().getMtbColr().get(0) : null; withdrawableDtbDocr.getTempPickData().getSourceMtbColt().getMtbColr().get(0) : null;
if (mtbColrToDispatch != null) { if (mtbColrToDispatch != null) {
if (UtilityString.isNullOrEmpty(mCurrentMtbColt.getCodTcol())) String newCodTcol = UtilityString.empty2null(withdrawableDtbDocr.getTempPickData().getSourceMtbColt().getCodTcol());
mCurrentMtbColt.setCodTcol(UtilityString.empty2null(withdrawableDtbDocr.getTempPickData().getSourceMtbColt().getCodTcol()));
mtbColr if (UtilityString.isNullOrEmpty(mCurrentMtbColt.getCodTcol()) && !UtilityString.isNullOrEmpty(newCodTcol)) {
.setCodJcom(UtilityString.empty2null(mtbColrToDispatch.getCodJcom())) mColliMagazzinoRESTConsumer.updateTipoULSynchronized(mCurrentMtbColt, newCodTcol);
.setSerColloRif(UtilityString.empty2null(mtbColrToDispatch.getSerCollo())) mCurrentMtbColt.setCodTcol(newCodTcol);
.setNumColloRif(mtbColrToDispatch.getNumCollo()) }
.setGestioneRif(UtilityString.empty2null(mtbColrToDispatch.getGestione()))
.setDataColloRif(UtilityString.empty2null(mtbColrToDispatch.getDataColloS())); // insertUDCRowRequestDTO
// .setCodJcom(UtilityString.empty2null(mtbColrToDispatch.getCodJcom()))
// .setSerColloRif(UtilityString.empty2null(mtbColrToDispatch.getSerCollo()))
// .setNumColloRif(mtbColrToDispatch.getNumCollo())
// .setGestioneRif(UtilityString.empty2null(mtbColrToDispatch.getGestione()))
// .setDataColloRif(UtilityString.empty2null(mtbColrToDispatch.getDataColloS()));
if (mtbColrToDispatch.getPesoNettoKg() != null) { if (mtbColrToDispatch.getPesoNettoKg() != null) {
//Proporzione //Proporzione
BigDecimal pesoNettoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(qtaTot, mtbColrToDispatch.getPesoNettoKg()), mtbColrToDispatch.getQtaCol()); BigDecimal pesoNettoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(qtaTot, mtbColrToDispatch.getPesoNettoKg()), mtbColrToDispatch.getQtaCol());
mtbColr.setPesoNettoKg(pesoNettoKg); insertUDCRowRequestDTO.setPesoNettoKg(pesoNettoKg);
} }
if (mtbColrToDispatch.getPesoLordoKg() != null) { if (mtbColrToDispatch.getPesoLordoKg() != null) {
//Proporzione //Proporzione
BigDecimal pesoLordoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(qtaTot, mtbColrToDispatch.getPesoLordoKg()), mtbColrToDispatch.getQtaCol()); BigDecimal pesoLordoKg = UtilityBigDecimal.divide(UtilityBigDecimal.multiply(qtaTot, mtbColrToDispatch.getPesoLordoKg()), mtbColrToDispatch.getQtaCol());
mtbColr.setPesoLordoKg(pesoLordoKg); insertUDCRowRequestDTO.setPesoLordoKg(pesoLordoKg);
} }
} }
mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
MtbColt cloneMtbColt = (MtbColt) mCurrentMtbColt.clone();
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.UPDATE);
cloneMtbColt.setMtbColr(new ObservableArrayList<>());
cloneMtbColt.getMtbColr().add((MtbColr) mtbColr.clone());
boolean shouldPrint = true; boolean shouldPrint = true;
//Se è l'unico articolo del collo (controllo se è uguale a 0 perché ancora non è stato aggiunto nella lista delle righe) //Se è l'unico articolo del collo (controllo se è uguale a 0 perché ancora non è stato aggiunto nella lista delle righe)
@@ -605,115 +589,87 @@ public class PickingResiViewModel {
} }
boolean finalShouldPrint = shouldPrint; boolean finalShouldPrint = shouldPrint;
this.mColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, value -> { MtbColr insertedULRow = this.mColliAccettazioneRESTConsumer.synchronousInsertUDCRow(insertUDCRowRequestDTO);
mtbColr insertedULRow
.setDataCollo(value.getDataColloS()) .setUntMis(withdrawableDtbDocr.getMtbAart().getUntMis())
.setNumCollo(value.getNumCollo()) .setMtbAart(withdrawableDtbDocr.getMtbAart());
.setGestione(value.getGestione())
.setSerCollo(value.getSerCollo())
.setRiga(value.getMtbColr().get(value.getMtbColr().size() - 1).getRiga())
.setUntMis(withdrawableDtbDocr.getMtbAart().getUntMis())
.setMtbAart(withdrawableDtbDocr.getMtbAart());
withdrawableDtbDocr.getWithdrawRows().add(mtbColr); mHandler.post(() -> {
mCurrentMtbColt.getMtbColr().add(mtbColr); withdrawableDtbDocr.getWithdrawRows().add(insertedULRow);
mCurrentMtbColt.getMtbColr().add(insertedULRow);
});
this.mPickingList.postValue(this.mPickingList.getValue()); this.mPickingList.postValue(this.mPickingList.getValue());
this.sendOnRowSaved(); this.sendOnRowSaved();
this.sendOnLoadingEnded(); this.sendOnLoadingEnded();
if (shouldCloseLU) closeLU(finalShouldPrint); if (shouldCloseLU) closeLU(finalShouldPrint);
}, this::sendError);
} }
private void saveEditedRow(MtbColr mtbColrToUpdate, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) { private void saveEditedRow(MtbColr mtbColrToUpdate, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) throws Exception {
this.sendOnLoadingStarted(); EditUDCRowRequestDTO editUDCRowRequest = new EditUDCRowRequestDTO()
.setSourceMtbColr(mtbColrToUpdate)
.setNewNumCnf(numCnf)
.setNewQtaCnf(qtaCnf)
.setNewQtaTot(qtaTot)
.setNewPartitaMag(partitaMag)
.setNewDataScad(dataScad);
MtbColt mtbColt = new MtbColt() MtbColr updatedMtbColr = this.mColliAccettazioneRESTConsumer.synchronousEditUDCRow(editUDCRowRequest);
.setNumCollo(mtbColrToUpdate.getNumCollo())
.setDataCollo(mtbColrToUpdate.getDataColloS())
.setSerCollo(mtbColrToUpdate.getSerCollo())
.setGestione(mtbColrToUpdate.getGestione())
.setMtbColr(new ObservableArrayList<>());
mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
final MtbColr mtbColr = (MtbColr) mtbColrToUpdate.clone(); updatedMtbColr
mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT); .setUntMis(mtbColrToUpdate.getUntMis())
mtbColr.setRiga(null) .setMtbAart(mtbColrToUpdate.getMtbAart());
.setNumCnf(numCnf.subtract(mtbColrToUpdate.getNumCnf()))
.setQtaCnf(qtaCnf)
.setQtaCol(qtaTot.subtract(mtbColrToUpdate.getQtaCol()))
.setPartitaMag(partitaMag)
.setDataScadPartita(dataScad);
mtbColt.getMtbColr().add(mtbColr); java.util.Optional<WithdrawableDtbDocr> pickingObjectDTO = this.mPickingList.getValue().stream()
.filter(x -> x.getWithdrawRows().stream().anyMatch(y -> y == mtbColrToUpdate))
this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> { .findFirst();
mtbColr.setNumCnf(numCnf)
.setQtaCnf(qtaCnf)
.setQtaCol(qtaTot);
Optional<WithdrawableDtbDocr> pickingObjectDTO = Stream.of(this.mPickingList.getValue())
.filter(x -> Stream.of(x.getWithdrawRows()).anyMatch(y -> y == mtbColrToUpdate))
.findSingle();
mHandler.post(() -> {
if (pickingObjectDTO.isPresent()) { if (pickingObjectDTO.isPresent()) {
pickingObjectDTO.get().getWithdrawRows().remove(mtbColrToUpdate); pickingObjectDTO.get().getWithdrawRows().remove(mtbColrToUpdate);
pickingObjectDTO.get().getWithdrawRows().add(mtbColr); pickingObjectDTO.get().getWithdrawRows().add(updatedMtbColr);
this.mPickingList.postValue(this.mPickingList.getValue());
} }
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate); this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate);
this.mCurrentMtbColt.getMtbColr().add(mtbColr); this.mCurrentMtbColt.getMtbColr().add(updatedMtbColr);
});
this.sendOnRowSaved(); this.sendOnRowSaved();
this.sendOnLoadingEnded();
}, this::sendError);
} }
public void deleteRow(MtbColr mtbColrToDelete) { public void deleteRow(MtbColr mtbColrToDelete) throws Exception {
this.sendMtbColrDeleteRequest(canDelete -> { var canDelete = this.sendMtbColrDeleteRequest();
if (canDelete) {
this.sendOnLoadingStarted();
MtbColt mtbColt = new MtbColt() if (canDelete) {
.setNumCollo(mtbColrToDelete.getNumCollo()) DeleteUDCRowRequestDTO deleteUDCRowRequest = new DeleteUDCRowRequestDTO()
.setDataCollo(mtbColrToDelete.getDataColloS()) .setMtbColrToDelete(mtbColrToDelete);
.setSerCollo(mtbColrToDelete.getSerCollo())
.setGestione(mtbColrToDelete.getGestione())
.setMtbColr(new ObservableArrayList<>());
mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
MtbColr mtbColr = (MtbColr) mtbColrToDelete.clone(); this.mColliAccettazioneRESTConsumer.synchronousDeleteUDCRow(deleteUDCRowRequest);
mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT);
mtbColr.setQtaCol(mtbColr.getQtaCol().multiply(new BigDecimal(-1)))
.setNumCnf(mtbColr.getNumCnf().multiply(new BigDecimal(-1)))
.setRiga(null);
mtbColt.getMtbColr().add(mtbColr);
this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> { Optional<WithdrawableDtbDocr> pickingObjectDTO = this.mPickingList.getValue().stream()
.filter(x -> x.getWithdrawRows().stream().anyMatch(y -> y == mtbColrToDelete))
.findFirst();
Optional<WithdrawableDtbDocr> pickingObjectDTO = Stream.of(this.mPickingList.getValue()) mHandler.post(() -> {
.filter(x -> Stream.of(x.getWithdrawRows()).anyMatch(y -> y == mtbColrToDelete))
.findSingle();
if (pickingObjectDTO.isPresent()) { if (pickingObjectDTO.isPresent()) {
pickingObjectDTO.get().getWithdrawRows().remove(mtbColrToDelete); pickingObjectDTO.get().getWithdrawRows().remove(mtbColrToDelete);
}
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete); this.mPickingList.postValue(this.mPickingList.getValue());
}
this.sendOnRowSaved(); this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete);
this.sendOnLoadingEnded(); });
}, this::sendError); this.sendOnRowSaved();
} }
});
} }
public void updateTipoUl(ObservableMtbTcol newTipoUL, Runnable onComplete) { public void updateTipoUl(ObservableMtbTcol newTipoUL, Runnable onComplete) {
@@ -739,8 +695,10 @@ public class PickingResiViewModel {
return mPickingList; return mPickingList;
} }
private void sendOnInfoAggiuntiveRequired(RunnableArgss<String, ObservableMtbTcol> onComplete) { private Pair<String, ObservableMtbTcol> sendOnInfoAggiuntiveRequired() {
if (this.mListener != null) this.mListener.onInfoAggiuntiveRequired(onComplete); if (this.mListener != null) return this.mListener.onInfoAggiuntiveRequired();
return null;
} }
private void sendOnLoadingStarted() { private void sendOnLoadingStarted() {
@@ -763,28 +721,55 @@ public class PickingResiViewModel {
if (this.mListener != null) mListener.onLUClosed(); if (this.mListener != null) mListener.onLUClosed();
} }
private void sendLUPrintRequest(RunnableArgs<Boolean> onComplete) { private boolean sendLUPrintRequest() {
if (this.mListener != null) mListener.onLUPrintRequest(onComplete); if (this.mListener != null) return mListener.onLUPrintRequest();
return false;
} }
private void sendLUPrintError(Exception ex, Runnable onComplete) { private void sendLUPrintError(Exception ex) {
if (this.mListener != null) mListener.onLUPrintError(ex, onComplete); if (this.mListener != null) mListener.onLUPrintError(ex, null);
} }
private void sendMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) { private boolean sendMtbColrDeleteRequest() {
if (this.mListener != null) mListener.onMtbColrDeleteRequest(onComplete); CountDownLatch countDownLatch = new CountDownLatch(1);
AtomicReference<Boolean> result = new AtomicReference<>();
if (this.mListener != null)
mListener.onMtbColrDeleteRequest(data -> {
result.set(data);
countDownLatch.countDown();
});
else {
result.set(false);
countDownLatch.countDown();
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.sendError(e);
}
return result.get();
} }
private void sendOnItemDispatched(MtbAart mtbAart, private PickedQuantityDTO sendOnItemDispatched(MtbAart mtbAart,
BigDecimal initialNumCnf, BigDecimal initialNumCnf,
BigDecimal initialQtaCnf, BigDecimal initialQtaCnf,
BigDecimal initialQtaTot, BigDecimal initialQtaTot,
BigDecimal totalQtaAvailable, BigDecimal totalQtaAvailable,
BigDecimal totalNumCnfAvailable, BigDecimal totalNumCnfAvailable,
BigDecimal qtaCnfAvailable, BigDecimal qtaCnfAvailable,
String partitaMag, String partitaMag,
LocalDate dataScad, LocalDate dataScad) {
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
CountDownLatch countDownLatch = new CountDownLatch(1);
AtomicReference<PickedQuantityDTO> result = new AtomicReference<>();
if (this.mListener != null) mListener.onItemDispatched(mtbAart, if (this.mListener != null) mListener.onItemDispatched(mtbAart,
initialNumCnf, initialNumCnf,
initialQtaCnf, initialQtaCnf,
@@ -794,7 +779,24 @@ public class PickingResiViewModel {
qtaCnfAvailable, qtaCnfAvailable,
partitaMag, partitaMag,
dataScad, dataScad,
onComplete); pickedQuantity -> {
result.set(pickedQuantity);
countDownLatch.countDown();
});
else {
result.set(null);
countDownLatch.countDown();
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.sendError(e);
}
return result.get();
} }
private void sendOnRowSaved() { private void sendOnRowSaved() {
@@ -818,7 +820,7 @@ public class PickingResiViewModel {
public interface Listener extends ILUPrintListener, ILoadingListener, ILUBaseOperationsListener { public interface Listener extends ILUPrintListener, ILoadingListener, ILUBaseOperationsListener {
void onInfoAggiuntiveRequired(RunnableArgss<String, ObservableMtbTcol> onComplete); Pair<String, ObservableMtbTcol> onInfoAggiuntiveRequired();
void onError(Exception ex); void onError(Exception ex);
@@ -831,7 +833,7 @@ public class PickingResiViewModel {
BigDecimal qtaCnfAvailable, BigDecimal qtaCnfAvailable,
String partitaMag, String partitaMag,
LocalDate dataScad, LocalDate dataScad,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete); RunnableArgs<PickedQuantityDTO> onComplete);
void onFilterApplied(String newValue); void onFilterApplied(String newValue);

View File

@@ -1,17 +1,16 @@
package it.integry.integrywmsnative.gest.picking_resi.rest; package it.integry.integrywmsnative.gest.picking_resi.rest;
import com.annimon.stream.Stream;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.DtbDocr; import it.integry.integrywmsnative.core.model.DtbDocr;
import it.integry.integrywmsnative.core.model.MtbAart; import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
@@ -32,20 +31,19 @@ public class PickingResiRESTConsumer {
this.mArticoloRESTConsumer = articoloRESTConsumer; this.mArticoloRESTConsumer = articoloRESTConsumer;
} }
public void loadDocRows(List<DocumentoResoDTO> documents, RunnableArgs<ArrayList<WithdrawableDtbDocr>> onComplete, RunnableArgs<Exception> onFailed) { public ArrayList<WithdrawableDtbDocr> makeSynchronousRetrieveDocRowsRequest(List<DocumentoResoDTO> documents) throws Exception {
List<HashMap<String, Object>> filterCond = new ArrayList<>(); List<HashMap<String, Object>> filterCond = new ArrayList<>();
for(int i = 0; i < documents.size(); i++) { documents.forEach(x ->
HashMap<String, Object> filter = new HashMap<>(); filterCond.add(new HashMap<>() {
{
filter.put("data_doc", documents.get(i).getDataDoc()); put("data_doc", x.getDataDoc());
filter.put("num_doc", documents.get(i).getNumDoc()); put("num_doc", x.getNumDoc());
filter.put("ser_doc", documents.get(i).getSerDoc()); put("ser_doc", x.getSerDoc());
filter.put("cod_anag", documents.get(i).getCodAnag()); put("cod_anag", x.getCodAnag());
filter.put("cod_dtip", documents.get(i).getCodDtip()); put("cod_dtip", x.getCodDtip());
}
filterCond.add(filter); }));
}
String sql = "SELECT * FROM dvw_situazione_qta_docs " + String sql = "SELECT * FROM dvw_situazione_qta_docs " +
"WHERE " + "WHERE " +
@@ -53,43 +51,46 @@ public class PickingResiRESTConsumer {
"ORDER BY cod_mart"; "ORDER BY cod_mart";
Type typeOfObjectsList = new TypeToken<ArrayList<WithdrawableDtbDocr>>() {}.getType(); Type typeOfObjectsList = new TypeToken<ArrayList<WithdrawableDtbDocr>>() {
this.mSystemRestConsumer.<ArrayList<WithdrawableDtbDocr>>processSql(sql, typeOfObjectsList, values -> { }.getType();
if(values != null && !values.isEmpty()){ var values = this.mSystemRestConsumer.<ArrayList<WithdrawableDtbDocr>>processSqlSynchronized(sql, typeOfObjectsList);
List<String> codMarts = Stream.of(values)
.map(DtbDocr::getCodMart)
.withoutNulls()
.distinct()
.toList();
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
if(arts != null && !arts.isEmpty()) {
for (DtbDocr value : values) {
MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = Stream.of(arts)
.filter(x -> x.getCodMart().equalsIgnoreCase(value.getCodMart())).toList();
if(mtbAartStream != null && !mtbAartStream.isEmpty()){
foundMtbAart = mtbAartStream.get(0);
}
value.setMtbAart(foundMtbAart);
}
if(onComplete != null) onComplete.run(values); if (values != null && !values.isEmpty()) {
} else onComplete.run(new ArrayList<>()); List<String> codMarts = values.stream()
.map(DtbDocr::getCodMart)
.filter(x -> x != null && !x.isEmpty())
.distinct()
.toList();
}, onFailed); var arts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
} else {
if(onComplete != null) onComplete.run(values); if (arts != null && !arts.isEmpty()) {
for (DtbDocr value : values) {
MtbAart foundMtbAart = null;
Optional<MtbAart> foundArt = arts.stream()
.filter(x -> x.getCodMart().equalsIgnoreCase(value.getCodMart()))
.findFirst();
if (!foundArt.isEmpty()) {
foundMtbAart = foundArt.get();
}
value.setMtbAart(foundMtbAart);
} }
}, onFailed);
return values;
} else
return new ArrayList<>();
}
return values;
} }
} }

View File

@@ -25,6 +25,8 @@ import com.google.android.material.textfield.TextInputLayout;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject; import javax.inject.Inject;
@@ -518,14 +520,33 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
} }
@Override @Override
public void onLUPrintRequest(RunnableArgs<Boolean> onComplete) { public boolean onLUPrintRequest() {
AtomicReference<Boolean> resultPrintPackingList = new AtomicReference<>();
CountDownLatch countDownLatch = new CountDownLatch(1);
DialogSimpleMessageView.makeInfoDialog( DialogSimpleMessageView.makeInfoDialog(
getActivity().getResources().getString(R.string.action_print_ul), getActivity().getResources().getString(R.string.action_print_ul),
new SpannableString(getActivity().getResources().getString(R.string.ask_print_message)), new SpannableString(getActivity().getResources().getString(R.string.ask_print_message)),
null, null,
() -> onComplete.run(true), () -> {
() -> onComplete.run(false)) resultPrintPackingList.set(true);
.show(getActivity().getSupportFragmentManager(), "tag"); countDownLatch.countDown();
},
() -> {
resultPrintPackingList.set(false);
countDownLatch.countDown();
})
.show(getActivity().getSupportFragmentManager(), "dialog-print");
try {
countDownLatch.await();
} catch (
InterruptedException e) {
this.onError(e);
}
return resultPrintPackingList.get();
} }
@Override @Override

View File

@@ -112,7 +112,7 @@ public class RettificaGiacenzeViewModel {
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
if(UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) { if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) {
//Not implemented now //Not implemented now
onComplete.run(); onComplete.run();
} else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) { } else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
@@ -213,7 +213,7 @@ public class RettificaGiacenzeViewModel {
private void dispatchArts(List<MtbAart> artsList, PickDataDTO pickData, String description, BarcodeScanDTO barcodeProd) { private void dispatchArts(List<MtbAart> artsList, PickDataDTO pickData, String description, BarcodeScanDTO barcodeProd) {
if (artsList == null || artsList.isEmpty()) { if (artsList == null || artsList.isEmpty()) {
if(SettingsManager.iDB().isFlagEnableArtCreation()) if (SettingsManager.iDB().isFlagEnableArtCreation())
this.sendRequestNewArtCreation(description, barcodeProd); this.sendRequestNewArtCreation(description, barcodeProd);
else else
this.sendError(new NoArtsFoundException()); this.sendError(new NoArtsFoundException());
@@ -509,17 +509,16 @@ public class RettificaGiacenzeViewModel {
} }
private void printLU(Runnable onComplete) { private void printLU(Runnable onComplete) {
this.sendLUPrintRequest(shouldPrint -> { var shouldPrint = this.sendLUPrintRequest();
if (!shouldPrint) { if (!shouldPrint) {
onComplete.run(); onComplete.run();
} else { } else {
this.mPrinterRESTConsumer.printCollo(mCurrentMtbColt, () -> { this.mPrinterRESTConsumer.printCollo(mCurrentMtbColt, () -> {
this.sendLUSuccessfullyPrinted(); this.sendLUSuccessfullyPrinted();
onComplete.run(); onComplete.run();
}, ex -> this.sendLUPrintError(ex, onComplete)); }, ex -> this.sendLUPrintError(ex, onComplete));
} }
});
} }
public void dispatchRowEdit(MtbColr mtbColrToUpdate) { public void dispatchRowEdit(MtbColr mtbColrToUpdate) {
@@ -620,7 +619,7 @@ public class RettificaGiacenzeViewModel {
} }
private void sendRequestNewArtCreation(String description, BarcodeScanDTO barcode) { private void sendRequestNewArtCreation(String description, BarcodeScanDTO barcode) {
if(this.mListener != null) mListener.onRequestNewArtCreation(description, barcode); if (this.mListener != null) mListener.onRequestNewArtCreation(description, barcode);
} }
@@ -695,8 +694,9 @@ public class RettificaGiacenzeViewModel {
if (this.mListener != null) mListener.onLUSuccessullyPrinted(); if (this.mListener != null) mListener.onLUSuccessullyPrinted();
} }
private void sendLUPrintRequest(RunnableArgs<Boolean> onComplete) { private boolean sendLUPrintRequest() {
if (this.mListener != null) mListener.onLUPrintRequest(onComplete); if (this.mListener != null) return mListener.onLUPrintRequest();
return false;
} }
private void sendLUPrintError(Exception ex, Runnable onComplete) { private void sendLUPrintError(Exception ex, Runnable onComplete) {

View File

@@ -918,15 +918,28 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
} }
@Override @Override
public void onLUPrintRequest(RunnableArgs<Boolean> onComplete) { public boolean onLUPrintRequest() {
AtomicReference<Boolean> resultPrintPackingList = new AtomicReference<>();
CountDownLatch countDownLatch = new CountDownLatch(1);
handler.post(() -> { handler.post(() -> {
DialogYesNoView.newInstance(getString(R.string.action_print), DialogYesNoView.newInstance(getString(R.string.action_print),
String.format(getString(R.string.message_print_packing_list), "Packing List"), String.format(getString(R.string.message_print_packing_list), "Packing List"),
result -> { result -> {
onComplete.run(result == DialogConsts.Results.YES); resultPrintPackingList.set(result == DialogConsts.Results.YES);
countDownLatch.countDown();
}) })
.show(getSupportFragmentManager(), "dialog-print"); .show(getSupportFragmentManager(), "dialog-print");
}); });
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.onError(e);
}
return resultPrintPackingList.get();
} }
@Override @Override

View File

@@ -422,8 +422,9 @@ public class SpedizioneViewModel {
mListener.onLUPesoRequired(codTcol, netWeightKG, grossWeightKG, onComplete); mListener.onLUPesoRequired(codTcol, netWeightKG, grossWeightKG, onComplete);
} }
private void sendLUPrintRequest(RunnableArgs<Boolean> onComplete) { private boolean sendLUPrintRequest() {
if (this.mListener != null) mListener.onLUPrintRequest(onComplete); if (this.mListener != null) return mListener.onLUPrintRequest();
return false;
} }
private void sendLUPrintError(Exception ex, Runnable onComplete) { private void sendLUPrintError(Exception ex, Runnable onComplete) {
@@ -918,10 +919,10 @@ public class SpedizioneViewModel {
final boolean isFilterApplied = Boolean.TRUE.equals(mFilterApplied.getValue()); final boolean isFilterApplied = Boolean.TRUE.equals(mFilterApplied.getValue());
if(pickingList == null) if (pickingList == null)
return; return;
if(isFilterApplied) { if (isFilterApplied) {
pickingList = pickingList.stream().filter(x -> !x.isHidden()) pickingList = pickingList.stream().filter(x -> !x.isHidden())
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@@ -934,7 +935,7 @@ public class SpedizioneViewModel {
return !mEnableCheckPartitaMag || (mtbPartitaMag != null && UtilityString.equalsIgnoreCase(x.getSitArtOrdDTO().getPartitaMag(), mtbPartitaMag.getPartitaMag())); return !mEnableCheckPartitaMag || (mtbPartitaMag != null && UtilityString.equalsIgnoreCase(x.getSitArtOrdDTO().getPartitaMag(), mtbPartitaMag.getPartitaMag()));
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if(matchPickingObject.isEmpty() && isFilterApplied) { if (matchPickingObject.isEmpty() && isFilterApplied) {
matchPickingObject = pickingList.stream() matchPickingObject = pickingList.stream()
.filter(x -> UtilityString.equalsIgnoreCase(mtbAart.getCodMart(), x.getSitArtOrdDTO().getCodMart())) .filter(x -> UtilityString.equalsIgnoreCase(mtbAart.getCodMart(), x.getSitArtOrdDTO().getCodMart()))
.filter(x -> x.getTempPickData() != null) .filter(x -> x.getTempPickData() != null)
@@ -2003,32 +2004,21 @@ public class SpedizioneViewModel {
return; return;
} }
var shouldPrint = this.sendLUPrintRequest();
final CountDownLatch latch = new CountDownLatch(1); if (!shouldPrint) {
return;
this.sendLUPrintRequest(shouldPrint -> {
if (!shouldPrint) {
latch.countDown();
return;
}
var printUDSRequestDto = new PrintULRequestDTO()
.setMtbColts(mtbColtsToPrint);
this.mColliMagazzinoRESTConsumer
.printUL(printUDSRequestDto,
latch::countDown,
ex -> this.sendLUPrintError(ex, latch::countDown));
});
try {
latch.await(); // Attende che il dialog venga chiuso
} catch (InterruptedException e) {
this.sendError(e);
} }
var printUDSRequestDto = new PrintULRequestDTO()
.setMtbColts(mtbColtsToPrint);
try {
this.mColliMagazzinoRESTConsumer
.printULSynchronized(printUDSRequestDto);
} catch (Exception e) {
this.sendLUPrintError(e, () -> {
});
}
} }

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.WindowManager;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -77,6 +78,7 @@ public class DialogUltimeConsegneFiltroAvanzatoView extends BaseDialogFragment {
alertDialog.setCanceledOnTouchOutside(isCancelable()); alertDialog.setCanceledOnTouchOutside(isCancelable());
alertDialog.setOnShowListener(this); // Rimosso se non specificamente necessario per altro alertDialog.setOnShowListener(this); // Rimosso se non specificamente necessario per altro
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
this.initDropDowns(); this.initDropDowns();

View File

@@ -94,7 +94,17 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
this.mViewModel.init(mShouldCheckResiduo, mShouldCheckIfExistDoc, mEnableCreation, mWarnOnOpeningVendita); this.mViewModel.init(mShouldCheckResiduo, mShouldCheckIfExistDoc, mEnableCreation, mWarnOnOpeningVendita);
mBindings.createNewLuButton.setOnClickListener(v -> { mBindings.createNewLuButton.setOnClickListener(v -> {
this.mViewModel.createNewLU(); executorService.execute(() -> {
this.onLoadingStarted();
try {
this.mViewModel.createNewLU();
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
});
// dismiss(); // dismiss();
}); });
@@ -118,7 +128,7 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
@Override @Override
public void dismiss() { public void dismiss() {
if(getDialog() != null) getDialog().dismiss(); if (getDialog() != null) getDialog().dismiss();
} }
@Override @Override
@@ -131,8 +141,6 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
} }
private void initBarcode() { private void initBarcode() {
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO() mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessfull) .setOnScanSuccessful(onScanSuccessfull)

View File

@@ -59,16 +59,13 @@ public class DialogScanOrCreateLUViewModel {
this.mWarnOnOpeningVendita = warnOnOpeningVendita; this.mWarnOnOpeningVendita = warnOnOpeningVendita;
} }
public void createNewLU() { public void createNewLU() throws Exception {
this.sendOnLoadingStarted();
var createUdcRequest = new CreateUDCRequestDTO() var createUdcRequest = new CreateUDCRequestDTO()
.setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep()); .setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep());
this.mColliLavorazioneRESTConsumer.createUDC(createUdcRequest, createdMtbColt -> { var createResponse = this.mColliLavorazioneRESTConsumer.synchronousCreateUDC(createUdcRequest);
this.sendOnLoadingEnded(); this.sendOnLUOpened(createResponse.getMtbColt(), true);
this.sendOnLUOpened(createdMtbColt, true);
}, this::sendError);
} }
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {