Implementato pulsante chiudi ordine in Spedizione
This commit is contained in:
parent
035f058bc3
commit
f90e2acc3e
@ -5,6 +5,6 @@ import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public class NoPrintersFoundException extends Exception {
|
||||
public NoPrintersFoundException() {
|
||||
super(UtilityResources.getString(R.string.exception_printer_not_found));
|
||||
super(UtilityResources.getString(R.string.exception_no_printer_found));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import android.util.Log;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
@ -11,6 +12,8 @@ import javax.inject.Singleton;
|
||||
import it.integry.integrywmsnative.BuildConfig;
|
||||
import it.integry.integrywmsnative.core.exception.NoPrintersFoundException;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.model.JasperDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.JasperPairDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
@ -89,7 +92,10 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
printerService.getAvailablePrinters(codMdep, printerTypeStr).enqueue(new Callback<ServiceRESTResponse<List<String>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
|
||||
analyzeAnswer(response, "GetAvailablePrinters", onComplete, onFailed);
|
||||
analyzeAnswer(response, "GetAvailablePrinters", printerList -> {
|
||||
printerList = Stream.of(printerList).filter(x -> !UtilityString.isNullOrEmpty(x)).toList();
|
||||
onComplete.run(printerList);
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -130,7 +136,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
.enqueue(new Callback<ServiceRESTResponse<Object>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
|
||||
analyzeAnswer(response, "PrintCollo", data -> {
|
||||
analyzeAnswer(response, "printCollo", data -> {
|
||||
onComplete.run();
|
||||
}, onFailed);
|
||||
}
|
||||
@ -142,7 +148,38 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
} else onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void printReport(String printerName, String reportName, HashMap<String, Object> params, int quantity, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
// if(BuildConfig.DEBUG) {
|
||||
// onComplete.run();
|
||||
// return;
|
||||
// }
|
||||
|
||||
JasperDTO jasperDTO = new JasperDTO();
|
||||
jasperDTO.setReportName(reportName);
|
||||
|
||||
Stream.of(params)
|
||||
.forEach(x -> jasperDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue())));
|
||||
|
||||
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
|
||||
printerService
|
||||
.processPrintReport(printerName, quantity, jasperDTO)
|
||||
.enqueue(new Callback<ServiceRESTResponse<Object>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
|
||||
analyzeAnswer(response, "printReport", data -> {
|
||||
onComplete.run();
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) {
|
||||
if(t.getMessage().contains("Printer not found")) {
|
||||
onFailed.run(new NoPrintersFoundException());
|
||||
} else onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,8 +2,10 @@ package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.rest.model.JasperDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
@ -34,4 +36,11 @@ public interface PrinterRESTConsumerService {
|
||||
);
|
||||
|
||||
|
||||
@POST("processPrintReport")
|
||||
Call<ServiceRESTResponse<Object>> processPrintReport(
|
||||
@Query("printerName") String printerName,
|
||||
@Query("numberOfCopies") int printQuantity,
|
||||
@Body JasperDTO jasperDTO
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package it.integry.integrywmsnative.core.rest.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JasperDTO {
|
||||
|
||||
private String reportName;
|
||||
private List<JasperPairDTO> params = new ArrayList<>();
|
||||
|
||||
public String getReportName() {
|
||||
return reportName;
|
||||
}
|
||||
|
||||
public JasperDTO setReportName(String reportName) {
|
||||
this.reportName = reportName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<JasperPairDTO> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public JasperDTO setParams(List<JasperPairDTO> params) {
|
||||
this.params = params;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package it.integry.integrywmsnative.core.rest.model;
|
||||
|
||||
public class JasperPairDTO {
|
||||
|
||||
private String name;
|
||||
private Object value;
|
||||
|
||||
public JasperPairDTO(String name, Object value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public JasperPairDTO setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public JasperPairDTO setValue(Object value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -33,6 +33,7 @@ public class DBSettingsModel {
|
||||
private boolean flagSpedizioneEnableManualPick;
|
||||
private boolean flagSpedizioneCanSelectMultipleOrders;
|
||||
private String produzioneDefaultCodAnag;
|
||||
private String reportNameSpedizionChiudiOrdine;
|
||||
|
||||
public boolean isFlagSpedizioneEnableFakeGiacenza() {
|
||||
return flagSpedizioneEnableFakeGiacenza;
|
||||
@ -231,4 +232,13 @@ public class DBSettingsModel {
|
||||
this.produzioneDefaultCodAnag = produzioneDefaultCodAnag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getReportNameSpedizionChiudiOrdine() {
|
||||
return reportNameSpedizionChiudiOrdine;
|
||||
}
|
||||
|
||||
public DBSettingsModel setReportNameSpedizionChiudiOrdine(String reportNameSpedizionChiudiOrdine) {
|
||||
this.reportNameSpedizionChiudiOrdine = reportNameSpedizionChiudiOrdine;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,6 +250,10 @@ public class SettingsManager {
|
||||
.setGestName("PICKING")
|
||||
.setSection("SPEDIZIONE")
|
||||
.setKeySection("FLAG_CAN_SELECT_MULTIPLE_ORDERS"));
|
||||
stbGestSetupList.add(new StbGestSetup()
|
||||
.setGestName("PICKING")
|
||||
.setSection("SPEDIZIONE")
|
||||
.setKeySection("REPORT_PACKING_LIST"));
|
||||
|
||||
|
||||
GestSetupRESTConsumer.getValues(stbGestSetupList, list -> {
|
||||
@ -271,6 +275,7 @@ public class SettingsManager {
|
||||
dbSettingsModelIstance.setFlagSpedizioneEnableManualPick(getValueFromList(list, "SPEDIZIONE", "ENABLE_MANUAL_PICK", Boolean.class));
|
||||
dbSettingsModelIstance.setFlagSpedizioneEnableFakeGiacenza(getValueFromList(list, "SPEDIZIONE", "ENABLE_FAKE_GIACENZA", Boolean.class));
|
||||
dbSettingsModelIstance.setFlagSpedizioneCanSelectMultipleOrders(getValueFromList(list, "SPEDIZIONE", "FLAG_CAN_SELECT_MULTIPLE_ORDERS", Boolean.class));
|
||||
dbSettingsModelIstance.setReportNameSpedizionChiudiOrdine(getValueFromList(list, "SPEDIZIONE", "REPORT_PACKING_LIST", String.class));
|
||||
|
||||
if(onComplete != null) onComplete.run();
|
||||
}, onFailed);
|
||||
|
||||
@ -84,6 +84,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
public BindableBoolean noItemsToPick = new BindableBoolean(false);
|
||||
public BindableBoolean noLUPresent = new BindableBoolean(true);
|
||||
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
|
||||
public BindableBoolean closeOrderButtonEnabled = new BindableBoolean(false);
|
||||
|
||||
private boolean mEnableGiacenza;
|
||||
private boolean mFlagShowCodForn;
|
||||
@ -150,6 +151,10 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
this.initRecyclerView();
|
||||
|
||||
|
||||
String reportNameSpedizioneChiudiOrdine = SettingsManager.iDB().getReportNameSpedizionChiudiOrdine();
|
||||
closeOrderButtonEnabled.set(!UtilityString.isNullOrEmpty(reportNameSpedizioneChiudiOrdine));
|
||||
|
||||
|
||||
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||
mEnableGiacenza = !SettingsManager.iDB().isFlagSpedizioneEnableFakeGiacenza();
|
||||
boolean enableCheckPartitaMag = SettingsManager.iDB().isEnableCheckPartitaMagCheckPickingV();
|
||||
@ -157,7 +162,16 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
boolean shouldAskPesoLU = SettingsManager.iDB().isFlagAskPesoColloSpedizione();
|
||||
|
||||
if (mEnableGiacenza) this.openProgress();
|
||||
mViewmodel.init(codMdep, mEnableGiacenza, enableCheckPartitaMag, shouldAskPesoLU, canOverflowOrderQuantity, mSitArtOrd, mTestateOrdini, mColliRegistrati);
|
||||
mViewmodel.init(
|
||||
codMdep,
|
||||
mEnableGiacenza,
|
||||
enableCheckPartitaMag,
|
||||
shouldAskPesoLU,
|
||||
canOverflowOrderQuantity,
|
||||
mSitArtOrd,
|
||||
mTestateOrdini,
|
||||
mColliRegistrati,
|
||||
reportNameSpedizioneChiudiOrdine);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -606,6 +620,12 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
}
|
||||
|
||||
|
||||
public void closeOrder() {
|
||||
this.mBindings.spedizioneFab.close(true);
|
||||
|
||||
this.mViewmodel.closeOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingStarted() {
|
||||
this.openProgress();
|
||||
@ -620,6 +640,8 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
public void onLUOpened(MtbColt mtbColt) {
|
||||
this.addExtraItemsEnabled.set(SettingsManager.iDB().isFlagCanAddExtraItemSpedizione());
|
||||
noLUPresent.set(false);
|
||||
closeOrderButtonEnabled.set(false);
|
||||
|
||||
FBToast.successToast(this, getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
|
||||
|
||||
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(mtbColt);
|
||||
@ -630,6 +652,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
this.addExtraItemsEnabled.set(false);
|
||||
noLUPresent.set(true);
|
||||
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null);
|
||||
closeOrderButtonEnabled.set(!UtilityString.isNullOrEmpty(SettingsManager.iDB().getReportNameSpedizionChiudiOrdine()));
|
||||
|
||||
if (this.mShouldCloseActivity) super.onBackPressed();
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -91,6 +92,7 @@ public class SpedizioneViewModel {
|
||||
private boolean mEnableCheckPartitaMag;
|
||||
private boolean mCanOverflowOrderQuantity;
|
||||
private boolean mShouldAskPesoLU;
|
||||
private String mReportNameSpedizioneChiudiOrdine;
|
||||
|
||||
private MtbColt mCurrentMtbColt = null;
|
||||
|
||||
@ -125,7 +127,8 @@ public class SpedizioneViewModel {
|
||||
boolean canOverflowOrderQuantity,
|
||||
List<SitArtOrdDTO> pickingList,
|
||||
List<OrdineVenditaInevasoDTO> testateOrdini,
|
||||
List<MtbColt> colliRegistrati) {
|
||||
List<MtbColt> colliRegistrati,
|
||||
String reportNameSpedizioneChiudiOrdine) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
this.mDefaultCodMdep = codMdep;
|
||||
@ -135,6 +138,7 @@ public class SpedizioneViewModel {
|
||||
this.mEnableCheckPartitaMag = enableCheckPartitaMag;
|
||||
this.mCanOverflowOrderQuantity = canOverflowOrderQuantity;
|
||||
this.mShouldAskPesoLU = shouldAskPesoLU;
|
||||
this.mReportNameSpedizioneChiudiOrdine = reportNameSpedizioneChiudiOrdine;
|
||||
|
||||
if (enableGiacenza) {
|
||||
mOrdiniRestConsumerService.getSuggestedPickingList(this.mDefaultCodMdep, pickingList, pickingObjectList -> {
|
||||
@ -1217,7 +1221,7 @@ public class SpedizioneViewModel {
|
||||
.setMtbAart(pickingObjectDTO.getMtbAart());
|
||||
|
||||
|
||||
if(mEnableGiacenza) {
|
||||
if (mEnableGiacenza) {
|
||||
mtbColr.setRefMtbColr(new MtbColr()
|
||||
.setCodMart(mtbColr.getCodMart())
|
||||
.setPartitaMag(mtbColr.getPartitaMag())
|
||||
@ -1546,6 +1550,56 @@ public class SpedizioneViewModel {
|
||||
this.sendFilterRemoved();
|
||||
}
|
||||
|
||||
public void closeOrder() {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
Runnable onComplete = () -> this.sendOnLoadingEnded();
|
||||
|
||||
this.mPrinterRESTConsumer.getAvailablePrinters(mDefaultCodMdep, PrinterRESTConsumer.Type.PRIMARIA, printerList -> {
|
||||
|
||||
if (printerList == null || printerList.size() == 0) {
|
||||
this.sendError(new NoPrintersFoundException());
|
||||
onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
cyclicPrintPackingList(
|
||||
this.mTestateOrdini.iterator(),
|
||||
printerList.get(0),
|
||||
onComplete,
|
||||
ex -> this.sendLUPrintError(ex, onComplete));
|
||||
|
||||
}, this::sendError);
|
||||
|
||||
}
|
||||
|
||||
private void cyclicPrintPackingList(@NotNull Iterator<OrdineVenditaInevasoDTO> sourceTestateOrdineVenditaIterator, String printerName, Runnable onComplete, RunnableArgs<Exception> onAbort) {
|
||||
if (sourceTestateOrdineVenditaIterator.hasNext()) {
|
||||
singlePrintPackingList(sourceTestateOrdineVenditaIterator.next(), printerName, () -> {
|
||||
cyclicPrintPackingList(sourceTestateOrdineVenditaIterator, printerName, onComplete, onAbort);
|
||||
}, onAbort);
|
||||
} else {
|
||||
onComplete.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void singlePrintPackingList(OrdineVenditaInevasoDTO ordineVenditaInevasoDTO, String printerName, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("gestione", ordineVenditaInevasoDTO.getGestione());
|
||||
params.put("num_ord", ordineVenditaInevasoDTO.getNumOrd());
|
||||
params.put("data_ord", UtilityDate.formatDate(ordineVenditaInevasoDTO.getDataOrdD(), UtilityDate.COMMONS_DATE_FORMATS.YMD_DASH));
|
||||
|
||||
this.mPrinterRESTConsumer.printReport(
|
||||
printerName,
|
||||
this.mReportNameSpedizioneChiudiOrdine,
|
||||
params,
|
||||
1,
|
||||
onComplete,
|
||||
onFailed);
|
||||
|
||||
}
|
||||
|
||||
public MutableLiveData<List<PickingObjectDTO>> getPickingList() {
|
||||
return mPickingList;
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="@color/colorPrimary">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M19,3h-4.18C14.4,1.84 13.3,1 12,1c-1.3,0 -2.4,0.84 -2.82,2L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM12,3c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM10,17l-4,-4 1.41,-1.41L10,14.17l6.59,-6.59L18,9l-8,8z"/>
|
||||
</vector>
|
||||
@ -265,7 +265,17 @@
|
||||
app:visibility="@{spedizioneView.noLUPresent}">
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/spedizione_fab_item1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_baseline_assignment_turned_in_24"
|
||||
app:visibility="@{spedizioneView.closeOrderButtonEnabled}"
|
||||
app:fab_colorNormal="@color/white"
|
||||
app:fab_colorPressed="@color/white_pressed"
|
||||
app:fab_colorRipple="#66FFFFFF"
|
||||
app:fab_label="@string/action_close_order"
|
||||
app:onClick="@{() -> spedizioneView.closeOrder()}" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_box"
|
||||
@ -276,7 +286,6 @@
|
||||
app:onClick="@{() -> spedizioneView.showCreatedUL()}" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/spedizione_fab_item2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_add_24dp"
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
<string name="action_insert_quantity">Inserisci quantità</string>
|
||||
<string name="action_insert_weight">Inserisci peso</string>
|
||||
<string name="dialog_input_peso_lu_description">Inserisci le informazioni del TIPO UL e il peso NETTO e LORDO</string>
|
||||
<string name="action_close_order">Chiudi ordine</string>
|
||||
<string name="action_show_created_ul">Mostra UL già create</string>
|
||||
<string name="action_recover_ul">Recupera UL</string>
|
||||
<string name="action_print_ul">Stampa UL</string>
|
||||
@ -257,6 +258,7 @@
|
||||
<string name="ultime_arrivi_fornitore_title">Ultimi arrivi</string>
|
||||
|
||||
<string name="exception_printer_not_found">Stampante non trovata</string>
|
||||
<string name="exception_no_printer_found">Nessuna stampante trovata</string>
|
||||
|
||||
<string name="action_select_all">Seleziona tutto</string>
|
||||
|
||||
|
||||
@ -74,6 +74,7 @@
|
||||
<string name="action_create_ul">Create new LU</string>
|
||||
<string name="action_insert_quantity">Insert quantity</string>
|
||||
<string name="action_insert_weight">Insert weight</string>
|
||||
<string name="action_close_order">Close order</string>
|
||||
<string name="action_show_created_ul">Show already created LU</string>
|
||||
<string name="dialog_input_peso_lu_description">Insert info about LU TYPE and NET / GROSS weight</string>
|
||||
<string name="lu_info">LU\'s info</string>
|
||||
@ -262,6 +263,7 @@
|
||||
<string name="ultime_arrivi_fornitore_title">Latest arrivals</string>
|
||||
|
||||
<string name="exception_printer_not_found">Printer not found</string>
|
||||
<string name="exception_no_printer_found">No printer found</string>
|
||||
|
||||
<string name="action_select_all">Select all</string>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user