From e0e9e657c974f792800cd60d23560373852a58e4 Mon Sep 17 00:00:00 2001 From: ValerioC Date: Wed, 25 May 2022 17:17:48 +0200 Subject: [PATCH] Nuova gestione linee di produzione --- .../core/di/binders/ImageViewBinders.java | 12 + .../ProductionLinesRESTConsumer.java | 91 +++++++ .../ProductionLinesRESTConsumerService.java | 27 +++ .../ProdLineeProduzioneComponent.java | 14 ++ .../ProdLineeProduzioneFragment.java | 187 ++++++++++++++ .../ProdLineeProduzioneModule.java | 25 ++ .../ProdLineeProduzioneViewModel.java | 142 +++++++++++ .../dialogs/BottomSheetLineAction.java | 111 +++++++++ .../dialogs/DialogStartProduction.java | 77 ++++++ .../dto/ProdLineStatusDTO.java | 129 ++++++++++ .../ui/LinesListAdapter.java | 62 +++++ .../res/drawable/ic_baseline_pause_24.xml | 5 + .../drawable/ic_baseline_person_add_24.xml | 5 + .../drawable/ic_baseline_play_arrow_24.xml | 5 + .../main/res/drawable/ic_baseline_stop_24.xml | 5 + .../main/res/drawable/ic_production_line.png | Bin 0 -> 827 bytes .../main/res/drawable/ic_stop_circle_24.xml | 6 + .../res/layout/bottom_sheet_line_actions.xml | 211 ++++++++++++++++ .../res/layout/dialog_start_production.xml | 81 +++++++ .../main/res/layout/fragment_linee_prod.xml | 86 +++++++ .../fragment_linee_prod_main_list_model.xml | 228 ++++++++++++++++++ 21 files changed, 1509 insertions(+) create mode 100644 app/src/main/java/it/integry/integrywmsnative/core/di/binders/ImageViewBinders.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumer.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumerService.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneComponent.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneFragment.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneModule.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneViewModel.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dialogs/BottomSheetLineAction.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dialogs/DialogStartProduction.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dto/ProdLineStatusDTO.java create mode 100644 app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ui/LinesListAdapter.java create mode 100644 app/src/main/res/drawable/ic_baseline_pause_24.xml create mode 100644 app/src/main/res/drawable/ic_baseline_person_add_24.xml create mode 100644 app/src/main/res/drawable/ic_baseline_play_arrow_24.xml create mode 100644 app/src/main/res/drawable/ic_baseline_stop_24.xml create mode 100644 app/src/main/res/drawable/ic_production_line.png create mode 100644 app/src/main/res/drawable/ic_stop_circle_24.xml create mode 100644 app/src/main/res/layout/bottom_sheet_line_actions.xml create mode 100644 app/src/main/res/layout/dialog_start_production.xml create mode 100644 app/src/main/res/layout/fragment_linee_prod.xml create mode 100644 app/src/main/res/layout/fragment_linee_prod_main_list_model.xml diff --git a/app/src/main/java/it/integry/integrywmsnative/core/di/binders/ImageViewBinders.java b/app/src/main/java/it/integry/integrywmsnative/core/di/binders/ImageViewBinders.java new file mode 100644 index 00000000..3f135d3c --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/core/di/binders/ImageViewBinders.java @@ -0,0 +1,12 @@ +package it.integry.integrywmsnative.core.di.binders; + +import androidx.appcompat.widget.AppCompatImageView; +import androidx.databinding.BindingAdapter; + +public class ImageViewBinders { + @BindingAdapter("tint") + public static void bindImageViewTint(final AppCompatImageView view, final int color) { + view.setColorFilter(color, android.graphics.PorterDuff.Mode.MULTIPLY); + } + +} diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumer.java new file mode 100644 index 00000000..035536f1 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumer.java @@ -0,0 +1,91 @@ +package it.integry.integrywmsnative.core.rest.consumers; + +import com.google.gson.JsonObject; + +import java.util.List; + +import javax.inject.Singleton; + +import it.integry.integrywmsnative.core.expansion.RunnableArgs; +import it.integry.integrywmsnative.core.rest.RESTBuilder; +import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; +import it.integry.integrywmsnative.gest.prod_linee_produzione.dto.ProdLineStatusDTO; +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +@Singleton +public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { + + public void avviaLineaDiProduzione(String codJfas, Integer hrNum, Runnable onComplete, RunnableArgs onFailed) { + ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); + Call> callable = restService.avviaLineaDiProduzione(codJfas, hrNum); + callable.enqueue(new Callback<>() { + @Override + public void onResponse(Call> call, Response> response) { + analyzeAnswer(response, "avviaLineaDiProduzione", data -> { + onComplete.run(); + }, onFailed); + } + + @Override + public void onFailure(Call> call, Throwable t) { + onFailed.run(new Exception(t)); + } + }); + } + + public void arrestaLineaDiProduzione(String codJfas, Runnable onComplete, RunnableArgs onFailed) { + ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); + Call> callable = restService.arrestaLineaDiProduzione(codJfas); + callable.enqueue(new Callback<>() { + @Override + public void onResponse(Call> call, Response> response) { + analyzeAnswer(response, "arrestaLineaDiProduzione", data -> { + onComplete.run(); + }, onFailed); + } + + @Override + public void onFailure(Call> call, Throwable t) { + onFailed.run(new Exception(t)); + } + }); + } + + public void avviaProduzioneArticoloSuLinea(String codJfas, String codMart, String partitaMag, Runnable onComplete, RunnableArgs onFailed) { + ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class, 300); + Call> callable = restService.avviaProduzioneArticoloSuLinea(codJfas, codMart, partitaMag); + callable.enqueue(new Callback<>() { + @Override + public void onResponse(Call> call, Response> response) { + analyzeAnswer(response, "avviaProduzioneArticoloSuLinea", data -> { + onComplete.run(); + }, onFailed); + } + + @Override + public void onFailure(Call> call, Throwable t) { + onFailed.run(new Exception(t)); + } + }); + } + + public void getStatoLinee(String codMdep, RunnableArgs> onComplete, RunnableArgs onFailed) { + ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); + Call>> callable = restService.getStatoLinee(codMdep); + callable.enqueue(new Callback<>() { + @Override + public void onResponse(Call>> call, Response>> response) { + analyzeAnswer(response, "getStatoLinee", onComplete::run, onFailed); + } + + @Override + public void onFailure(Call>> call, Throwable t) { + onFailed.run(new Exception(t)); + } + }); + } + + +} diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumerService.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumerService.java new file mode 100644 index 00000000..c225d8d4 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ProductionLinesRESTConsumerService.java @@ -0,0 +1,27 @@ +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.gest.prod_linee_produzione.dto.ProdLineStatusDTO; +import retrofit2.Call; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.Query; + +public interface ProductionLinesRESTConsumerService { + + @POST("mes_v2/avviaLineaDiProduzione") + Call> avviaLineaDiProduzione(@Query("codJfas") String codJfas, @Query("hrNum") Integer hrNum); + + @POST("mes_v2/arrestaLineaDiProduzione") + Call> arrestaLineaDiProduzione(@Query("codJfas") String codJfas); + + @POST("mes_v2/avviaProduzioneArticoloSuLinea") + Call> avviaProduzioneArticoloSuLinea(@Query("codJfas") String codJfas, @Query("codMart") String codMart, @Query("partitaMag") String partitaMag); + + @GET("mes_v2/statoLineeProd") + Call>> getStatoLinee(@Query("codMdep") String codMdep); +} diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneComponent.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneComponent.java new file mode 100644 index 00000000..b7167ea2 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneComponent.java @@ -0,0 +1,14 @@ +package it.integry.integrywmsnative.gest.prod_linee_produzione; + +import dagger.Subcomponent; + +@Subcomponent +public interface ProdLineeProduzioneComponent { + + @Subcomponent.Factory + interface Factory { + ProdLineeProduzioneComponent create(); + } + + void inject(ProdLineeProduzioneFragment prodLineeProduzioneFragment); +} diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneFragment.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneFragment.java new file mode 100644 index 00000000..92fa730b --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneFragment.java @@ -0,0 +1,187 @@ +package it.integry.integrywmsnative.gest.prod_linee_produzione; + +import android.content.Context; +import android.os.Bundle; +import android.text.Html; +import android.text.InputType; +import android.text.SpannableString; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.appcompat.widget.AppCompatTextView; +import androidx.databinding.DataBindingUtil; +import androidx.databinding.ObservableArrayList; +import androidx.recyclerview.widget.LinearLayoutManager; + +import java.util.List; + +import javax.inject.Inject; + +import it.integry.barcode_base_android_library.model.BarcodeScanDTO; +import it.integry.integrywmsnative.MainApplication; +import it.integry.integrywmsnative.R; +import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO; +import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager; +import it.integry.integrywmsnative.core.expansion.BaseFragment; +import it.integry.integrywmsnative.core.expansion.RunnableArgs; +import it.integry.integrywmsnative.core.interfaces.IScrollableFragment; +import it.integry.integrywmsnative.core.interfaces.ITitledFragment; +import it.integry.integrywmsnative.core.utility.UtilityString; +import it.integry.integrywmsnative.databinding.FragmentLineeProdBinding; +import it.integry.integrywmsnative.gest.prod_linee_produzione.dialogs.BottomSheetLineAction; +import it.integry.integrywmsnative.gest.prod_linee_produzione.dialogs.DialogStartProduction; +import it.integry.integrywmsnative.gest.prod_linee_produzione.dto.ProdLineStatusDTO; +import it.integry.integrywmsnative.gest.prod_linee_produzione.ui.LinesListAdapter; +import it.integry.integrywmsnative.ui.ElevatedToolbar; +import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleInputHelper; +import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView; + +public class ProdLineeProduzioneFragment extends BaseFragment implements ITitledFragment, IScrollableFragment, ProdLineeProduzioneViewModel.Listener { + + + @Inject + ProdLineeProduzioneViewModel mViewModel; + + private final ObservableArrayList mLinesObservableList = new ObservableArrayList<>(); + private FragmentLineeProdBinding mBinding; + private ElevatedToolbar mToolbar; + private int barcodeScannerIstanceID = -1; + private final RunnableArgs onScanSuccessful = data -> { + this.onLoadingStarted(); + + this.mViewModel.processBarcodeDTO(data); + }; + + public static ProdLineeProduzioneFragment newInstance() { + return new ProdLineeProduzioneFragment(); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + + mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_linee_prod, container, false); + MainApplication.appComponent + .prodLineeProduzioneComponent() + .create() + .inject(this); + + mViewModel.setListener(this); + mBinding.setLifecycleOwner(this); + this.initRecyclerView(); + this.initBarcodeReader(); + mViewModel.init(); + + return mBinding.getRoot(); + } + + private void initBarcodeReader() { + barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO() + .setOnScanSuccessful(onScanSuccessful) + .setOnScanFailed(this::onError)); + } + + @Override + public void setScrollToolbar(ElevatedToolbar toolbar) { + mToolbar = toolbar; + } + + public void refreshLineeProd(List linesList) { + this.mLinesObservableList.clear(); + if (linesList != null) { + + this.mLinesObservableList.addAll(linesList); + } + } + + private void initRecyclerView() { + this.mViewModel.getProdLinesList().observe(getViewLifecycleOwner(), this::refreshLineeProd); + LinesListAdapter prodLinesListAdapter = new LinesListAdapter(this.requireActivity(), this.mLinesObservableList); + prodLinesListAdapter.setEmptyView(this.mBinding.linesListEmptyView); + this.mBinding.linesMainList.setAdapter(prodLinesListAdapter); + this.mBinding.linesMainList.setLayoutManager(new LinearLayoutManager(this.requireActivity())); + prodLinesListAdapter.setOnItemClicked(this.mViewModel::onLineSelected); + if (mToolbar != null) + mToolbar.setRecyclerView(this.mBinding.linesMainList); + } + + public void requestResources(ProdLineStatusDTO prodLine) { + this.onLoadingEnded(); + BarcodeManager.disable(); + requireActivity().runOnUiThread(() -> { + + DialogSimpleInputHelper.makeInputDialog(requireContext(), "Inserisci il numero di risorse da allocare", qta -> { + this.onLoadingStarted(); + try { + Integer hrNum = Integer.parseInt(qta); + this.mViewModel.startProductionLine(prodLine, hrNum); + } catch (NumberFormatException ex) { + this.onError(new Exception("Inserire un numero di risorse valido")); + } + }, BarcodeManager::enable, InputType.TYPE_CLASS_NUMBER).show(); + }); + } + + public void requestOrderChange(ProdLineStatusDTO prodLine) { + this.onLoadingEnded(); + requireActivity().runOnUiThread(() -> { + DialogStartProduction.newInstance((dto) -> { + this.mViewModel.checkBarcodeAndStartOrdine(prodLine, dto); + }).show(getChildFragmentManager(), "DialogStartProduction"); + }); + } + + public void requestProductionStop(ProdLineStatusDTO prodLine) { + this.onLoadingEnded(); + BarcodeManager.disable(); + if (UtilityString.isNullOrEmpty(prodLine.getListaOrd())) { + mViewModel.stopProduction(prodLine); + } else { + this.confirmOrderClose(() -> { + mViewModel.stopProduction(prodLine); + }); + } + + } + + @Override + public void successDialog(String message, Runnable onComplete) { + BarcodeManager.disable(); + requireActivity().runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(getResources().getString(R.string.success), + new SpannableString(message), null, onComplete).show(getChildFragmentManager(), "successDialog")); + + } + + @Override + public void selectLine(ProdLineStatusDTO dto) { + this.onLoadingEnded(); + BarcodeManager.disable(); + if (!dto.isStarted()) { + this.requestResources(dto); + } else { + BottomSheetLineAction.newInstance(dto, this::requestResources, this::requestOrderChange, this::requestProductionStop, BarcodeManager::enable).show(getChildFragmentManager(), "BottomSheetLineAction"); + } + } + + @Override + public void confirmOrderClose(Runnable onConfirm) { + this.onLoadingEnded(); + requireActivity().runOnUiThread(() -> { + DialogSimpleMessageView.makeWarningDialog( + Html.fromHtml("Per completare l'operazione è necessario chiudere gli ordini attualmente aperti sulla linea." + + "

" + + "Continuare?"), + null, + onConfirm, + BarcodeManager::enable + ).show(getChildFragmentManager(), "confirmOrderClose"); + }); + } + + + @Override + public void onCreateActionBar(AppCompatTextView titleText, Context context) { + titleText.setText(context.getText(R.string.nav_prod_linee_title).toString()); + } +} \ No newline at end of file diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneModule.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneModule.java new file mode 100644 index 00000000..a36e3629 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneModule.java @@ -0,0 +1,25 @@ +package it.integry.integrywmsnative.gest.prod_linee_produzione; + +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; +import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; +import it.integry.integrywmsnative.core.rest.consumers.ProductionLinesRESTConsumer; +import it.integry.integrywmsnative.gest.prod_rientro_merce.ProdRientroMerceComponent; + +@Module(subcomponents = ProdRientroMerceComponent.class) +public class ProdLineeProduzioneModule { + + @Provides + ProdLineeProduzioneViewModel providesProdRientroMerceViewModel(ProductionLinesRESTConsumer productionLinesRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer) { + return new ProdLineeProduzioneViewModel(productionLinesRESTConsumer, barcodeRESTConsumer); + } + + @Provides + @Singleton + ProductionLinesRESTConsumer providesProductionLinesRESTConsumer() { + return new ProductionLinesRESTConsumer(); + } + +} diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneViewModel.java new file mode 100644 index 00000000..d2ac9714 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ProdLineeProduzioneViewModel.java @@ -0,0 +1,142 @@ +package it.integry.integrywmsnative.gest.prod_linee_produzione; + +import androidx.lifecycle.MutableLiveData; + +import com.annimon.stream.Stream; + +import java.util.List; + +import javax.inject.Inject; + +import it.integry.barcode_base_android_library.model.BarcodeScanDTO; +import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager; +import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener; +import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; +import it.integry.integrywmsnative.core.rest.consumers.ProductionLinesRESTConsumer; +import it.integry.integrywmsnative.core.settings.SettingsManager; +import it.integry.integrywmsnative.core.utility.UtilityString; +import it.integry.integrywmsnative.gest.prod_linee_produzione.dto.ProdLineStatusDTO; + +public class ProdLineeProduzioneViewModel { + + + private final ProductionLinesRESTConsumer productionLinesRESTConsumer; + private final BarcodeRESTConsumer mBarcodeRESTConsumer; + private final MutableLiveData> prodLines = new MutableLiveData<>(); + + private Listener mListener; + + @Inject + public ProdLineeProduzioneViewModel(ProductionLinesRESTConsumer productionLinesRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer) { + this.productionLinesRESTConsumer = productionLinesRESTConsumer; + this.mBarcodeRESTConsumer = barcodeRESTConsumer; + } + + public void init() { + this.sendOnLoadingStarted(); + reloadLines(); + + } + + private void reloadLines() { + BarcodeManager.disable(); + sendOnLoadingStarted(); + this.productionLinesRESTConsumer.getStatoLinee(SettingsManager.i().getUserSession().getDepo().getCodMdep(), lineeProdList -> { + this.sendOnLoadingEnded(); + BarcodeManager.enable(); + prodLines.postValue(lineeProdList); + }, this::sendError); + } + + public MutableLiveData> getProdLinesList() { + return prodLines; + } + + public void setListener(Listener listener) { + this.mListener = listener; + } + + public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) { + String codJfas = barcodeScanDTO.getStringValue(); + + ProdLineStatusDTO prodLine = prodLines.getValue() != null ? Stream.of(prodLines.getValue()).filter(x -> x.getCodJfas().equalsIgnoreCase(codJfas)).findFirstOrElse(null) : null; + if (prodLine != null) { + this.onLineSelected(prodLine); + } else { + this.sendError(new Exception("Linea di produzione " + codJfas + " non trovata")); + } + + + } + + + private void sendOnLoadingStarted() { + if (this.mListener != null) mListener.onLoadingStarted(); + } + + private void sendOnLoadingEnded() { + if (this.mListener != null) mListener.onLoadingEnded(); + } + + private void sendError(Exception ex) { + if (this.mListener != null) mListener.onError(ex); + } + + public void startProductionLine(ProdLineStatusDTO prodLine, Integer hrNum) { + this.sendOnLoadingStarted(); + this.productionLinesRESTConsumer.avviaLineaDiProduzione(prodLine.getCodJfas(), + hrNum, + () -> this.mListener.successDialog("Operazione completata", this::reloadLines), + this::sendError); + } + + public void onLineSelected(ProdLineStatusDTO lineSelected) { + mListener.selectLine(lineSelected); + } + + public void checkBarcodeAndStartOrdine(ProdLineStatusDTO prodLine, BarcodeScanDTO dto) { + this.sendOnLoadingStarted(); + mBarcodeRESTConsumer.decodeEan128(dto, (ean128) -> { + String codMart = ean128.Content; + String partitaMag = ean128.BatchLot; + if (!prodLine.isStarted()) { + this.sendError(new Exception("Impossibile avviare una produzione su una linea ferma!")); + } else if (UtilityString.isNullOrEmpty(prodLine.getListaOrd())) { + this.startProduction(prodLine, codMart, partitaMag); + } else { + this.mListener.confirmOrderClose(() -> { + this.startProduction(prodLine, codMart, partitaMag); + }); + } + }, this::sendError); + } + + private void startProduction(ProdLineStatusDTO prodLine, String codMart, String partitaMag) { + this.sendOnLoadingStarted(); + this.productionLinesRESTConsumer.avviaProduzioneArticoloSuLinea(prodLine.getCodJfas(), codMart, partitaMag, + () -> this.mListener.successDialog("Operazione completata", this::reloadLines), + this::sendError); + } + + public void stopProduction(ProdLineStatusDTO prodLine) { + this.sendOnLoadingStarted(); + this.productionLinesRESTConsumer.arrestaLineaDiProduzione(prodLine.getCodJfas(), + () -> this.mListener.successDialog("Operazione completata", this::reloadLines), + this::sendError); + } + + + public interface Listener extends ILoadingListener { + + void onError(Exception ex); + + void successDialog(String message, Runnable onComplete); + + void selectLine(ProdLineStatusDTO prodLineStatusDTO); + + void confirmOrderClose(Runnable onConfirm); + + } + + +} \ No newline at end of file diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dialogs/BottomSheetLineAction.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dialogs/BottomSheetLineAction.java new file mode 100644 index 00000000..07f3f01c --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dialogs/BottomSheetLineAction.java @@ -0,0 +1,111 @@ +package it.integry.integrywmsnative.gest.prod_linee_produzione.dialogs; + +import android.content.DialogInterface; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.google.android.material.bottomsheet.BottomSheetDialogFragment; + +import it.integry.integrywmsnative.core.expansion.RunnableArgs; +import it.integry.integrywmsnative.databinding.BottomSheetLineActionsBinding; +import it.integry.integrywmsnative.gest.prod_linee_produzione.dto.ProdLineStatusDTO; + +public class BottomSheetLineAction extends BottomSheetDialogFragment { + + private BottomSheetLineActionsBinding mBinding; + + private ProdLineStatusDTO prodLine; + private RunnableArgs onChangeResourcesRequest; + private RunnableArgs onChangeOrdersRequest; + private RunnableArgs onLineCloseRequest; + private Runnable onCancelAction; + + public static BottomSheetLineAction newInstance(ProdLineStatusDTO dto, RunnableArgs onChangeResourcesRequest, RunnableArgs onChangeOrdersRequest, RunnableArgs onLineCloseRequest, Runnable onCancel) { + BottomSheetLineAction fragment = new BottomSheetLineAction(); + fragment + .setProdLine(dto) + .setOnChangeResourcesRequest(onChangeResourcesRequest) + .setOnChangeOrdersRequest(onChangeOrdersRequest) + .setOnLineCloseRequest(onLineCloseRequest) + .setOnCancelAction(onCancel); + return fragment; + } + + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + mBinding = BottomSheetLineActionsBinding.inflate(inflater, container, false); + mBinding.setLifecycleOwner(this); + mBinding.setView(this); + mBinding.setListModel(this.prodLine); + + return mBinding.getRoot(); + } + + public BottomSheetLineAction setOnCancelAction(Runnable onCancelAction) { + this.onCancelAction = onCancelAction; + return this; + } + + public BottomSheetLineAction setOnChangeResourcesRequest(RunnableArgs onChangeResourcesRequest) { + this.onChangeResourcesRequest = onChangeResourcesRequest; + return this; + } + + + public BottomSheetLineAction setOnChangeOrdersRequest(RunnableArgs onChangeOrdersRequest) { + this.onChangeOrdersRequest = onChangeOrdersRequest; + return this; + } + + + public BottomSheetLineAction setOnLineCloseRequest(RunnableArgs onLineCloseRequest) { + this.onLineCloseRequest = onLineCloseRequest; + return this; + } + + public ProdLineStatusDTO getProdLine() { + return prodLine; + } + + public BottomSheetLineAction setProdLine(ProdLineStatusDTO prodLine) { + this.prodLine = prodLine; + return this; + } + + public void onResourcesClicked() { + if (this.onChangeResourcesRequest != null) { + this.onChangeResourcesRequest.run(prodLine); + } + this.dismiss(); + + } + + public void onPlayClicked() { + if (this.onChangeOrdersRequest != null) { + this.onChangeOrdersRequest.run(prodLine); + } + this.dismiss(); + } + + public void onStopClicked() { + if (this.onLineCloseRequest != null) { + this.onLineCloseRequest.run(prodLine); + } + this.dismiss(); + } + + @Override + public void onCancel(@NonNull DialogInterface dialog) { + if (this.onCancelAction != null) { + onCancelAction.run(); + } + super.onCancel(dialog); + } +} diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dialogs/DialogStartProduction.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dialogs/DialogStartProduction.java new file mode 100644 index 00000000..d1fa80ba --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dialogs/DialogStartProduction.java @@ -0,0 +1,77 @@ +package it.integry.integrywmsnative.gest.prod_linee_produzione.dialogs; + +import android.content.DialogInterface; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import it.integry.barcode_base_android_library.model.BarcodeScanDTO; +import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO; +import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager; +import it.integry.integrywmsnative.core.expansion.BaseDialogFragment; +import it.integry.integrywmsnative.core.expansion.RunnableArgs; +import it.integry.integrywmsnative.core.utility.UtilityBarcode; +import it.integry.integrywmsnative.databinding.DialogStartProductionBinding; + +public class DialogStartProduction extends BaseDialogFragment { + private int barcodeScannerIstanceID = -1; + private RunnableArgs onScanSuccessful; + private DialogStartProductionBinding mBinding; + + public static DialogStartProduction newInstance(RunnableArgs onScanSuccessful) { + + Bundle args = new Bundle(); + + DialogStartProduction fragment = new DialogStartProduction(); + fragment.setArguments(args); + fragment.setOnScanSuccessful(onScanSuccessful); + return fragment; + } + + + @Override + public void onDismiss(@NonNull DialogInterface dialog) { + BarcodeManager.removeCallback(barcodeScannerIstanceID); + super.onDismiss(dialog); + } + + public DialogStartProduction setOnScanSuccessful(RunnableArgs onScanSuccessful) { + this.onScanSuccessful = onScanSuccessful; + return this; + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + mBinding = DialogStartProductionBinding.inflate(inflater, container, false); + mBinding.setLifecycleOwner(this); + this.initBarcodeReader(); + setCancelable(true); + getDialog().setCanceledOnTouchOutside(true); + getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + return mBinding.getRoot(); + } + + + private void initBarcodeReader() { + barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO() + .setOnScanSuccessful(this::processBarcode) + .setOnScanFailed(this::onError)); + BarcodeManager.enable(); + } + + private void processBarcode(BarcodeScanDTO barcodeScanDTO) { + if (UtilityBarcode.isEan128(barcodeScanDTO)) { + this.onScanSuccessful.run(barcodeScanDTO); + this.dismiss(); + } else { + this.onError(new Exception("Il barcode scansionato non è valido!")); + } + } +} diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dto/ProdLineStatusDTO.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dto/ProdLineStatusDTO.java new file mode 100644 index 00000000..10808248 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/dto/ProdLineStatusDTO.java @@ -0,0 +1,129 @@ +package it.integry.integrywmsnative.gest.prod_linee_produzione.dto; + +import java.math.BigDecimal; +import java.util.Calendar; +import java.util.Date; + +public class ProdLineStatusDTO { + + private String codJfas; + + private String descrizione; + + private String codMdepLav; + + private Date datetimeStart; + + private Date datetimeEnd; + + private BigDecimal maxAllocazione; + + private Integer qtaAllocate; + + private String listaOrd; + + + public String getCodJfas() { + return codJfas; + } + + public ProdLineStatusDTO setCodJfas(String codJfas) { + this.codJfas = codJfas; + return this; + } + + public String getDescrizione() { + return descrizione; + } + + public ProdLineStatusDTO setDescrizione(String descrizione) { + this.descrizione = descrizione; + return this; + } + + public String getCodMdepLav() { + return codMdepLav; + } + + public ProdLineStatusDTO setCodMdepLav(String codMdepLav) { + this.codMdepLav = codMdepLav; + return this; + } + + public Date getDatetimeStart() { + return datetimeStart; + } + + public ProdLineStatusDTO setDatetimeStart(Date datetimeStart) { + this.datetimeStart = datetimeStart; + return this; + } + + public Date getDatetimeEnd() { + return datetimeEnd; + } + + public ProdLineStatusDTO setDatetimeEnd(Date datetimeEnd) { + this.datetimeEnd = datetimeEnd; + return this; + } + + public BigDecimal getMaxAllocazione() { + return maxAllocazione; + } + + public ProdLineStatusDTO setMaxAllocazione(BigDecimal maxAllocazione) { + this.maxAllocazione = maxAllocazione; + return this; + } + + public Integer getQtaAllocate() { + return qtaAllocate; + } + + public ProdLineStatusDTO setQtaAllocate(Integer qtaAllocate) { + this.qtaAllocate = qtaAllocate; + return this; + } + + public String getListaOrd() { + return listaOrd; + } + + public ProdLineStatusDTO setListaOrd(String listaOrd) { + this.listaOrd = listaOrd; + return this; + } + + public boolean isStarted() { + return datetimeStart != null && datetimeEnd == null; + } + + + public boolean isPaused() { + if (datetimeEnd == null) { + return false; + } + Calendar today = Calendar.getInstance(); + today.set(Calendar.MILLISECOND, 0); + today.set(Calendar.SECOND, 0); + today.set(Calendar.MINUTE, 0); + today.set(Calendar.HOUR_OF_DAY, 0); + Calendar lastCloseTime = Calendar.getInstance(); + lastCloseTime.setTime(datetimeEnd); + lastCloseTime.set(Calendar.MILLISECOND, 0); + lastCloseTime.set(Calendar.SECOND, 0); + lastCloseTime.set(Calendar.MINUTE, 0); + lastCloseTime.set(Calendar.HOUR_OF_DAY, 0); + return datetimeStart != null && datetimeEnd != null && today.equals(lastCloseTime); + } + + public String getLabel() { + return codJfas + " - " + descrizione; + } + + public String getRisorseLabel() { + return qtaAllocate + (maxAllocazione != null && maxAllocazione.compareTo(BigDecimal.ZERO) > 0 ? "/" + maxAllocazione : ""); + } + +} diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ui/LinesListAdapter.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ui/LinesListAdapter.java new file mode 100644 index 00000000..c7f01ae0 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_linee_produzione/ui/LinesListAdapter.java @@ -0,0 +1,62 @@ +package it.integry.integrywmsnative.gest.prod_linee_produzione.ui; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.databinding.ObservableArrayList; +import androidx.recyclerview.widget.RecyclerView; + +import it.integry.integrywmsnative.R; +import it.integry.integrywmsnative.core.expansion.RunnableArgs; +import it.integry.integrywmsnative.core.expansion.view.ExtendedRecyclerView; +import it.integry.integrywmsnative.databinding.FragmentLineeProdMainListModelBinding; +import it.integry.integrywmsnative.gest.prod_linee_produzione.dto.ProdLineStatusDTO; + +public class LinesListAdapter extends ExtendedRecyclerView { + private Context mContext; + + private RunnableArgs mOnItemClicked; + + public LinesListAdapter(Context context, ObservableArrayList myDataset) { + super(myDataset); + this.mContext = context; + } + + @NonNull + @Override + public LinesListAdapter.SingleItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + FragmentLineeProdMainListModelBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.fragment_linee_prod_main_list_model, parent, false); + return new LinesListAdapter.SingleItemViewHolder(binding); + } + + @Override + public void onBindViewHolder(@NonNull LinesListAdapter.SingleItemViewHolder holder, int position) { + final ProdLineStatusDTO line = mDataset.get(position); + + holder.binding.setListModel(line); + holder.binding.executePendingBindings(); + holder.binding.getRoot().setOnClickListener(v -> { + if (this.mOnItemClicked != null) + this.mOnItemClicked.run(line); + }); + } + + + public void setOnItemClicked(RunnableArgs onItemClicked) { + this.mOnItemClicked = onItemClicked; + } + + static class SingleItemViewHolder extends RecyclerView.ViewHolder { + + FragmentLineeProdMainListModelBinding binding; + + SingleItemViewHolder(FragmentLineeProdMainListModelBinding binding) { + super(binding.getRoot()); + this.binding = binding; + } + } + +} diff --git a/app/src/main/res/drawable/ic_baseline_pause_24.xml b/app/src/main/res/drawable/ic_baseline_pause_24.xml new file mode 100644 index 00000000..938bd7f1 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_pause_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_person_add_24.xml b/app/src/main/res/drawable/ic_baseline_person_add_24.xml new file mode 100644 index 00000000..ee564be1 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_person_add_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_play_arrow_24.xml b/app/src/main/res/drawable/ic_baseline_play_arrow_24.xml new file mode 100644 index 00000000..e3fd2e9d --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_play_arrow_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_stop_24.xml b/app/src/main/res/drawable/ic_baseline_stop_24.xml new file mode 100644 index 00000000..19bcbee7 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_stop_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_production_line.png b/app/src/main/res/drawable/ic_production_line.png new file mode 100644 index 0000000000000000000000000000000000000000..19f5ada7b6327098d12965ecf863f3535d814e21 GIT binary patch literal 827 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGoY)RhkE)4%caKYZ?lNlJ8K6tt~ zhE&XXduM;XP@>H7kLN!ZFfuW=u?4+JTD11+7yA##7fo*V^V>DcLQ=i_KT~>oY;WM} zWuD1DxqaGST`<|Wl{fa6vzEf0#|zfV{yGqA`^V(Y^R4%6@5}75v{0~gZ~+4qU!P0N z(eEElnz8x6Vy9-k=sI=db z1B%uZzw^7#Hh-ON{@t!U8B^S+1gWNfcy(&}v%?zJ+6OWs9-q0ak>14A(^tx-ucx0s zS8~hc&iA5%Rtd$sd!NOz|DG$yuwVjrfcA5P$diYU?b-ik#yRcCW_5;lzn{%}p|#>R z_r@*zn!}dYznPV!ci>KlOqm{}{H z*us57*gYQOgFd>FnnbH?+A{C%bynXjDs`QrDq zO+bSfv_X8IuumFp6;DNq8DC9($UeWT^4yu<*N*Zf@EVwh%2fog$NTh1{wpmdKI;Vst0FZ-bJOBUy literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/ic_stop_circle_24.xml b/app/src/main/res/drawable/ic_stop_circle_24.xml new file mode 100644 index 00000000..d1561510 --- /dev/null +++ b/app/src/main/res/drawable/ic_stop_circle_24.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/layout/bottom_sheet_line_actions.xml b/app/src/main/res/layout/bottom_sheet_line_actions.xml new file mode 100644 index 00000000..9bd37c8e --- /dev/null +++ b/app/src/main/res/layout/bottom_sheet_line_actions.xml @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_start_production.xml b/app/src/main/res/layout/dialog_start_production.xml new file mode 100644 index 00000000..f9894f3a --- /dev/null +++ b/app/src/main/res/layout/dialog_start_production.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_linee_prod.xml b/app/src/main/res/layout/fragment_linee_prod.xml new file mode 100644 index 00000000..13b3603a --- /dev/null +++ b/app/src/main/res/layout/fragment_linee_prod.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_linee_prod_main_list_model.xml b/app/src/main/res/layout/fragment_linee_prod_main_list_model.xml new file mode 100644 index 00000000..440ad8a1 --- /dev/null +++ b/app/src/main/res/layout/fragment_linee_prod_main_list_model.xml @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file