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){
|
public static void saveRigaCollo(MtbColr mtbColrToSave, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed){
|
||||||
|
|
||||||
EntityRESTConsumer.processEntity(mtbColrToSave, new ISimpleOperationCallback<MtbColr>() {
|
EntityRESTConsumer.processEntity(mtbColrToSave, new ISimpleOperationCallback<MtbColr>() {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package it.integry.integrywmsnative.core.REST.consumers;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.reflect.TypeToken;
|
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 com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.REST.model.ServiceRESTResponse;
|
import it.integry.integrywmsnative.core.REST.model.ServiceRESTResponse;
|
||||||
import it.integry.integrywmsnative.core.model.EntityBase;
|
import it.integry.integrywmsnative.core.model.EntityBase;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
public interface EntityRESTConsumerService {
|
public interface EntityRESTConsumerService {
|
||||||
|
|
||||||
@POST("processEntity")
|
@POST("processEntity")
|
||||||
Call<ServiceRESTResponse<JsonObject>> processEntity(@Body Object entity);
|
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();
|
showNoULFound();
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable();
|
||||||
progressDialog.dismiss();
|
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();
|
showWrongGestioneUL();
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable();
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
@ -242,6 +242,8 @@ public class VersamentoMerceViewModel {
|
|||||||
|
|
||||||
|
|
||||||
private void pickMerceULtoUL(MtbColt destMtbColt, ProgressDialog progressDialog) {
|
private void pickMerceULtoUL(MtbColt destMtbColt, ProgressDialog progressDialog) {
|
||||||
|
MtbColt sourceMtbColt = mtbColt.get();
|
||||||
|
|
||||||
List<MtbColr> mtbColrsToPick = Stream.of(mtbColt.get().getMtbColr())
|
List<MtbColr> mtbColrsToPick = Stream.of(mtbColt.get().getMtbColr())
|
||||||
.filter(x -> x.getQtaCol().floatValue() > 0)
|
.filter(x -> x.getQtaCol().floatValue() > 0)
|
||||||
.toList();
|
.toList();
|
||||||
@ -256,34 +258,61 @@ public class VersamentoMerceViewModel {
|
|||||||
BarcodeManager.enable();
|
BarcodeManager.enable();
|
||||||
|
|
||||||
if(destNewMtbColr != null && destNewMtbColr.size() > 0){
|
if(destNewMtbColr != null && destNewMtbColr.size() > 0){
|
||||||
MtbColt clonedTestata = (MtbColt) destMtbColt.clone();
|
MtbColt clonedSourceTestata = (MtbColt) sourceMtbColt.clone();
|
||||||
ObservableArrayList<MtbColr> mtbColrObservableField = new ObservableArrayList<>();
|
MtbColt clonedDestTestata = (MtbColt) destMtbColt.clone();
|
||||||
|
|
||||||
|
ObservableArrayList<MtbColr> mtbColrSourceObservableField = new ObservableArrayList<>();
|
||||||
|
ObservableArrayList<MtbColr> mtbColrDestObservableField = new ObservableArrayList<>();
|
||||||
|
|
||||||
for(int i = 0; i < destNewMtbColr.size(); i++) {
|
for(int i = 0; i < destNewMtbColr.size(); i++) {
|
||||||
MtbColr cloneMtbColr = (MtbColr) destNewMtbColr.get(i).clone();
|
MtbColr cloneMtbColr = (MtbColr) destNewMtbColr.get(i).clone();
|
||||||
|
|
||||||
cloneMtbColr
|
boolean destroyMtbColrReferences = false;
|
||||||
.setGestioneRif(cloneMtbColr.getGestione())
|
|
||||||
.setGestione(null);
|
|
||||||
|
|
||||||
cloneMtbColr
|
//Se le gestioni sono uguali faccio uno storno sulla sorgente e non lavoro con
|
||||||
.setSerColloRif(cloneMtbColr.getSerCollo())
|
//i riferimenti
|
||||||
.setSerCollo(null);
|
if(sourceMtbColt.getGestioneEnum() == destMtbColt.getGestioneEnum()){
|
||||||
|
destroyMtbColrReferences = true;
|
||||||
|
|
||||||
cloneMtbColr
|
MtbColr stornoSourceMtbColr = (MtbColr) destNewMtbColr.get(i).clone();
|
||||||
.setNumColloRif(cloneMtbColr.getNumCollo())
|
|
||||||
.setNumCollo(null);
|
|
||||||
|
|
||||||
cloneMtbColr
|
stornoSourceMtbColr
|
||||||
.setDataColloRif(cloneMtbColr.getDataColloS())
|
.setGestione(null)
|
||||||
.setDataCollo(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() {
|
private void showWrongGestioneUL() {
|
||||||
DialogSimpleMessageHelper.makeWarningDialog(mContext,
|
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();
|
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);
|
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);
|
mtbColt.getMtbColr().get(i).setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumer.saveCollo(mtbColt, value -> {
|
ColliMagazzinoRESTConsumer.saveColli(mtbColts, value -> {
|
||||||
showDataSavedDialog(() -> {
|
showDataSavedDialog(() -> {
|
||||||
mOnVersamentoCompleted.run();
|
mOnVersamentoCompleted.run();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user