Implementate logiche per il versamento merce tra due bancali con stessa gestione.
This commit is contained in:
parent
d433d1a22c
commit
bffa291cc6
@ -74,6 +74,23 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void saveColli(List<MtbColt> mtbColtsToSave, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed){
|
||||
|
||||
EntityRESTConsumer.processEntityList(mtbColtsToSave, new ISimpleOperationCallback<List<MtbColt>>() {
|
||||
@Override
|
||||
public void onSuccess(List<MtbColt> value) {
|
||||
if(onComplete != null) onComplete.run(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
}, true);
|
||||
|
||||
}
|
||||
|
||||
public static void saveRigaCollo(MtbColr mtbColrToSave, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed){
|
||||
|
||||
EntityRESTConsumer.processEntity(mtbColrToSave, new ISimpleOperationCallback<MtbColr>() {
|
||||
|
||||
@ -3,6 +3,7 @@ package it.integry.integrywmsnative.core.REST.consumers;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@ -59,6 +60,53 @@ public class EntityRESTConsumer {
|
||||
|
||||
}
|
||||
|
||||
public static <T extends EntityBase> void processEntityList(List<T> entitiesToSave, final ISimpleOperationCallback<List<T>> callback, boolean singleTransaction){
|
||||
|
||||
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class);
|
||||
Call<List<ServiceRESTResponse<JsonObject>>> request = service.processEntityList(singleTransaction, entitiesToSave);
|
||||
request.enqueue(new Callback<List<ServiceRESTResponse<JsonObject>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<ServiceRESTResponse<JsonObject>>> call, Response<List<ServiceRESTResponse<JsonObject>>> response) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.body() != null) {
|
||||
|
||||
ArrayList<T> responseList = new ArrayList<>();
|
||||
Gson gson = new Gson();
|
||||
Type typeOfObjectsList = new TypeToken<T>() {}.getType();
|
||||
|
||||
for(ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
|
||||
|
||||
if (jsonSingleObject.getEsito() == EsitoType.OK) {
|
||||
responseList.add(gson.fromJson(jsonSingleObject.getEntity(), typeOfObjectsList));
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", jsonSingleObject.getErrorMessage());
|
||||
callback.onFailed(new Exception(jsonSingleObject.getErrorMessage()));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
callback.onSuccess(responseList);
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", response.message());
|
||||
callback.onFailed(new Exception(response.message()));
|
||||
}
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
||||
callback.onFailed(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<ServiceRESTResponse<JsonObject>>> call, Throwable t) {
|
||||
Log.e("EntityRESTConsumer", t.toString());
|
||||
callback.onFailed(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3,15 +3,21 @@ package it.integry.integrywmsnative.core.REST.consumers;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.REST.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.model.EntityBase;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface EntityRESTConsumerService {
|
||||
|
||||
@POST("processEntity")
|
||||
Call<ServiceRESTResponse<JsonObject>> processEntity(@Body Object entity);
|
||||
|
||||
@POST("processEntityList")
|
||||
Call<List<ServiceRESTResponse<JsonObject>>> processEntityList(@Query("forceTransaction") boolean singleTransaction, @Body Object entity);
|
||||
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class VersamentoMerceViewModel {
|
||||
showNoULFound();
|
||||
BarcodeManager.enable();
|
||||
progressDialog.dismiss();
|
||||
} else if(mtbColt != null && (mtbColt.getGestioneEnum() == GestioneEnum.ACQUISTO || mtbColt.getGestioneEnum() == GestioneEnum.VENDITA)) {
|
||||
} else if(mtbColt != null && (/*mtbColt.getGestioneEnum() == GestioneEnum.ACQUISTO ||*/ mtbColt.getGestioneEnum() == GestioneEnum.VENDITA)) {
|
||||
showWrongGestioneUL();
|
||||
BarcodeManager.enable();
|
||||
progressDialog.dismiss();
|
||||
@ -242,6 +242,8 @@ public class VersamentoMerceViewModel {
|
||||
|
||||
|
||||
private void pickMerceULtoUL(MtbColt destMtbColt, ProgressDialog progressDialog) {
|
||||
MtbColt sourceMtbColt = mtbColt.get();
|
||||
|
||||
List<MtbColr> mtbColrsToPick = Stream.of(mtbColt.get().getMtbColr())
|
||||
.filter(x -> x.getQtaCol().floatValue() > 0)
|
||||
.toList();
|
||||
@ -256,34 +258,61 @@ public class VersamentoMerceViewModel {
|
||||
BarcodeManager.enable();
|
||||
|
||||
if(destNewMtbColr != null && destNewMtbColr.size() > 0){
|
||||
MtbColt clonedTestata = (MtbColt) destMtbColt.clone();
|
||||
ObservableArrayList<MtbColr> mtbColrObservableField = new ObservableArrayList<>();
|
||||
MtbColt clonedSourceTestata = (MtbColt) sourceMtbColt.clone();
|
||||
MtbColt clonedDestTestata = (MtbColt) destMtbColt.clone();
|
||||
|
||||
ObservableArrayList<MtbColr> mtbColrSourceObservableField = new ObservableArrayList<>();
|
||||
ObservableArrayList<MtbColr> mtbColrDestObservableField = new ObservableArrayList<>();
|
||||
|
||||
for(int i = 0; i < destNewMtbColr.size(); i++) {
|
||||
MtbColr cloneMtbColr = (MtbColr) destNewMtbColr.get(i).clone();
|
||||
|
||||
cloneMtbColr
|
||||
.setGestioneRif(cloneMtbColr.getGestione())
|
||||
.setGestione(null);
|
||||
boolean destroyMtbColrReferences = false;
|
||||
|
||||
cloneMtbColr
|
||||
.setSerColloRif(cloneMtbColr.getSerCollo())
|
||||
.setSerCollo(null);
|
||||
//Se le gestioni sono uguali faccio uno storno sulla sorgente e non lavoro con
|
||||
//i riferimenti
|
||||
if(sourceMtbColt.getGestioneEnum() == destMtbColt.getGestioneEnum()){
|
||||
destroyMtbColrReferences = true;
|
||||
|
||||
cloneMtbColr
|
||||
.setNumColloRif(cloneMtbColr.getNumCollo())
|
||||
.setNumCollo(null);
|
||||
MtbColr stornoSourceMtbColr = (MtbColr) destNewMtbColr.get(i).clone();
|
||||
|
||||
cloneMtbColr
|
||||
.setDataColloRif(cloneMtbColr.getDataColloS())
|
||||
.setDataCollo(null);
|
||||
stornoSourceMtbColr
|
||||
.setGestione(null)
|
||||
.setNumCollo(null)
|
||||
.setSerCollo(null)
|
||||
.setDataCollo(null)
|
||||
.setGestioneRif(null)
|
||||
.setNumColloRif(null)
|
||||
.setSerColloRif(null)
|
||||
.setDataColloRif((String) null)
|
||||
|
||||
mtbColrObservableField.add(cloneMtbColr);
|
||||
.setQtaCol(stornoSourceMtbColr.getQtaCol().multiply(new BigDecimal(-1)));
|
||||
|
||||
mtbColrSourceObservableField.add(stornoSourceMtbColr);
|
||||
}
|
||||
|
||||
clonedTestata.setMtbColr(mtbColrObservableField);
|
||||
if(!destroyMtbColrReferences) {
|
||||
cloneMtbColr
|
||||
.setGestioneRif(cloneMtbColr.getGestione())
|
||||
.setSerColloRif(cloneMtbColr.getSerCollo())
|
||||
.setNumColloRif(cloneMtbColr.getNumCollo())
|
||||
.setDataColloRif(cloneMtbColr.getDataColloS());
|
||||
}
|
||||
|
||||
saveLU(clonedTestata);
|
||||
cloneMtbColr
|
||||
.setGestione(null)
|
||||
.setSerCollo(null)
|
||||
.setNumCollo(null)
|
||||
.setDataCollo(null);
|
||||
|
||||
mtbColrDestObservableField.add(cloneMtbColr);
|
||||
}
|
||||
|
||||
clonedSourceTestata.setMtbColr(mtbColrSourceObservableField);
|
||||
clonedDestTestata.setMtbColr(mtbColrDestObservableField);
|
||||
|
||||
|
||||
saveLUs(clonedSourceTestata, clonedDestTestata);
|
||||
}
|
||||
|
||||
});
|
||||
@ -345,7 +374,7 @@ public class VersamentoMerceViewModel {
|
||||
|
||||
private void showWrongGestioneUL() {
|
||||
DialogSimpleMessageHelper.makeWarningDialog(mContext,
|
||||
new SpannableString(Html.fromHtml(mContext.getResources().getText(R.string.gestione_A_V_not_accepted_message).toString())),
|
||||
new SpannableString(Html.fromHtml(mContext.getResources().getText(R.string.gestione_V_not_accepted_message).toString())),
|
||||
null, null).show();
|
||||
}
|
||||
|
||||
@ -356,15 +385,22 @@ public class VersamentoMerceViewModel {
|
||||
}
|
||||
*/
|
||||
|
||||
private void saveLU(MtbColt mtbColt) {
|
||||
private void saveLUs(MtbColt mtbColt1, MtbColt mtbColt2) {
|
||||
|
||||
ArrayList<MtbColt> mtbColts = new ArrayList<>();
|
||||
mtbColts.add(mtbColt1);
|
||||
mtbColts.add(mtbColt2);
|
||||
|
||||
for(MtbColt mtbColt : mtbColts) {
|
||||
mtbColt.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||
|
||||
for(int i = 0; i < mtbColt.getMtbColr().size(); i++) {
|
||||
for (int i = 0; i < mtbColt.getMtbColr().size(); i++) {
|
||||
mtbColt.getMtbColr().get(i).setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ColliMagazzinoRESTConsumer.saveCollo(mtbColt, value -> {
|
||||
ColliMagazzinoRESTConsumer.saveColli(mtbColts, value -> {
|
||||
showDataSavedDialog(() -> {
|
||||
mOnVersamentoCompleted.run();
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user