diff --git a/.idea/misc.xml b/.idea/misc.xml index 10071818..f8fd0048 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -150,9 +150,10 @@ + - + @@ -202,7 +203,7 @@ - + @@ -225,6 +226,7 @@ + diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 13477fd1..6a829240 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 123, - "versionName": "8.5.2Beta", + "versionCode": 126, + "versionName": "8.6Beta", "outputFile": "app-release.apk" } ], diff --git a/app/release/vn-pickingBeta.apk b/app/release/vn-pickingBeta.apk index 3d543efb..f05d7b50 100644 Binary files a/app/release/vn-pickingBeta.apk and b/app/release/vn-pickingBeta.apk differ diff --git a/app/src/main/java/es/verdnatura/domain/GetUbicadorUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetUbicadorUserCase.kt index 31e6c64f..9b0e65f2 100644 --- a/app/src/main/java/es/verdnatura/domain/GetUbicadorUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetUbicadorUserCase.kt @@ -173,7 +173,7 @@ class GetUbicadorUserCase(context: Context) : RestClient(context) { password: String, shelvingFk: String - ): Call> { + ): Call> { val params: ArrayList = ArrayList() params.add(shelvingFk) diff --git a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt index 56b4e942..1685eb34 100644 --- a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt +++ b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt @@ -1034,7 +1034,7 @@ interface VerdnaturaService { @Header("Content-Type") content_type: String, @Body params: List ): - Call> + Call> @POST("almacennew/clearShelvingList")//REVISADA diff --git a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogInputTwoValues.kt b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogInputTwoValues.kt new file mode 100644 index 00000000..c6eca434 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogInputTwoValues.kt @@ -0,0 +1,124 @@ +package es.verdnatura.presentation.view.component + +import android.app.Dialog +import android.content.Context +import android.text.InputType +import android.view.View +import com.google.android.material.textfield.TextInputEditText +import es.verdnatura.R +import es.verdnatura.databinding.ComponentCustomEditDialogTwoValuesBinding + + +class CustomDialogInputTwoValues(context: Context) : Dialog(context, R.style.DialogTheme) { + + private var binding: ComponentCustomEditDialogTwoValuesBinding = + ComponentCustomEditDialogTwoValuesBinding.inflate(layoutInflater) + + + init { + + setContentView(binding.root) + setInputText() + setInputTextTwoVisibility() + } + + fun getEditText(): TextInputEditText { + + return binding.customDialogValue + + + } + + fun getEditTextTwo(): TextInputEditText { + + return binding.customDialogValueTwo + + } + + fun getValue(): String { + + return binding.customDialogValue.text.toString() + + + } + + fun getValueTwo(): String { + + return binding.customDialogValueTwo.text.toString() + + } + + fun setValue(value: String): CustomDialogInputTwoValues { + + binding.customDialogValue.setText(value) + binding.customDialogValue.visibility = View.VISIBLE + + + return this + } + fun setValueTwo(value: String): CustomDialogInputTwoValues { + + binding.customDialogValueTwo.setText(value) + binding.customDialogValue.visibility = View.VISIBLE + + + return this + } + + fun setTitle(title: String): CustomDialogInputTwoValues { + + binding.customDialogTitle.visibility = View.VISIBLE + binding.customDialogTitle.text = title + + return this + } + + fun setDescription(description: String): CustomDialogInputTwoValues { + + binding.customDialogDescription.visibility = View.VISIBLE + binding.customDialogDescription.text = description + + + return this + } + + fun setOkButton(text: String, onButtonClicked: () -> Unit): CustomDialogInputTwoValues { + + binding.customDialogButtonOk.visibility = View.VISIBLE + binding.customDialogButtonOk.text = text + binding.customDialogButtonOk.setOnClickListener { onButtonClicked() } + + return this + } + + fun setKoButton(text: String, onButtonClicked: () -> Unit): CustomDialogInputTwoValues { + + binding.customDialogButtonKo.visibility = View.VISIBLE + binding.customDialogButtonKo.text = text + binding.customDialogButtonKo.setOnClickListener { onButtonClicked() } + + + return this + } + + fun setInputText() { + binding.customDialogValue.inputType = InputType.TYPE_CLASS_NUMBER + } + + fun setInputTextTwo() { + binding.customDialogValueTwo.inputType = InputType.TYPE_CLASS_NUMBER + } + + fun setInputTextTwoVisibility() { + binding.textinputlayoutTwo.visibility = View.VISIBLE + } + + /* fun setFocusText() { + binding.customDialogValue.requestFocus() + }*/ + + fun setFocusTextTwo() { + binding.customDialogValueTwo.requestFocus() + } + +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt index ff44bcb7..022dd2f8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt @@ -170,7 +170,7 @@ class AjustesFragment : }.show() } else { - if (it.list != null && it.list.size > 0) { + if (it.list.size > 0) { val listSectores: ArrayList = ArrayList() it.list.forEach { listSectores.add(it.description) @@ -200,7 +200,7 @@ class AjustesFragment : }.show() } else { - if (it.list != null && it.list.size > 0) { + if (it.list.size > 0) { val listPrinters: ArrayList = ArrayList() it.list.forEach { listPrinters.add(it.name) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt index d58f20b3..4bf438b8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt @@ -540,10 +540,8 @@ class ItemCardFragment( LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) binding.scrollView.post { val position = IntArray(2) - if (binding.itemcardImage != null) { - binding.itemcardImage.getLocationInWindow(position) - binding.scrollView.scrollTo(0, position[1]) - } + binding.itemcardImage.getLocationInWindow(position) + binding.scrollView.scrollTo(0, position[1]) } binding.splashProgressTwo.visibility = GONE } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index fbf58451..57649442 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -111,7 +111,7 @@ class CollectionFragment( mperror = MediaPlayer.create((activity as MainActivity), R.raw.error) mpok = MediaPlayer.create((activity as MainActivity), R.raw.ok) - Log.d("VERDNATURA::","El type es "+type) + if ((collection.collectionFk != null) && type.equals(CONTROLADOR)) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index 006de9ce..c99aa811 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -120,17 +120,17 @@ class PasilleroViewModel(context: Context) : BaseViewModel() { ) //Tarea #3754 --> Falta arreglar la colección que se le pasa a ReubicationCollectionFragment y diseño más visual - /* _pasillerositem.add( - PasillerosItemVO( - 1, - R.drawable.ic_reubication, - contextApp.getString(R.string.titleReUbicator), - R.string.titleReUbicator, - contextApp.getString( - R.string.titleReubicatorDescrip - ) - ) - )*/ + /* _pasillerositem.add( + PasillerosItemVO( + 1, + R.drawable.ic_reubication, + contextApp.getString(R.string.titleReUbicator), + R.string.titleReUbicator, + contextApp.getString( + R.string.titleReubicatorDescrip + ) + ) + )*/ _pasillerositem.add( PasillerosItemVO( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/adapter/ReubicatorAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/adapter/ReubicatorAdapter.kt index 4ff54b69..7a7b80bb 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/adapter/ReubicatorAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/adapter/ReubicatorAdapter.kt @@ -18,6 +18,7 @@ package es.verdnatura.presentation.view.feature.reubication.adapter import es.verdnatura.presentation.common.* import es.verdnatura.presentation.view.feature.collection.adapter.PlacementAdapter import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO + import es.verdnatura.presentation.view.feature.reubication.model.PlacementReubication import es.verdnatura.presentation.view.feature.reubication.model.Reubication import es.verdnatura.presentation.view.feature.sacador.model.SaleVO @@ -69,14 +70,14 @@ class ReubicatorAdapter( } /* if (sale.pickedQuantity.isNullOrEmpty()) sale.pickedQuantity = "0" - + */ val childLayoutManager = LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false) itemArticlePlacements.apply { layoutManager = childLayoutManager - adapter = PlacementAdapter(sale.placements, onPasillerosItemClickListener) - }*/ + adapter = reubication.placements?.let { ReubicatorPlacementAdapter(it, onPasillerosItemClickListener) } + } //CLICK EVENTS /* diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/adapter/ReubicatorPlacementAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/adapter/ReubicatorPlacementAdapter.kt new file mode 100644 index 00000000..24b133bb --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/adapter/ReubicatorPlacementAdapter.kt @@ -0,0 +1,53 @@ +package es.verdnatura.presentation.view.feature.reubication.adapter + + + import android.content.Context + import android.view.LayoutInflater + import android.view.ViewGroup + import androidx.recyclerview.widget.RecyclerView + import es.verdnatura.R + import es.verdnatura.databinding.ItemPlacementReubicationRowBinding + import es.verdnatura.databinding.ItemPlacementRowBinding + import es.verdnatura.presentation.common.OnPasillerosItemClickListener + import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO + import es.verdnatura.presentation.view.feature.reubication.model.PlacementReubication + import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO + + class ReubicatorPlacementAdapter ( + private val items: List, + private val onPasillerosItemClickListener: OnPasillerosItemClickListener + ): RecyclerView.Adapter () { + var context: Context? = null + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder { + this.context = parent.context + return AjustesItemHolder( + ItemPlacementReubicationRowBinding.inflate(LayoutInflater.from(parent.context),parent,false) + ) + } + + override fun getItemCount() =items.size + + override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) { + holder.bind(items[position]) + } + + inner class AjustesItemHolder( + val binding: ItemPlacementReubicationRowBinding + ) : RecyclerView.ViewHolder(binding.root){ + fun bind(placement: PlacementReubication) { + binding.apply { + if (placement.plate.isNullOrEmpty()) + placement.plate = ""//placement.parking + if (placement.visible.isNullOrEmpty()) + placement.visible = "("+placement.visible+")" + this.item = placement + + itemRootLayout.setOnClickListener { + onPasillerosItemClickListener.onPasillerosItemClickListener( + PasillerosItemVO(title = binding.root.context.getString( + R.string.titleUbicator)),placement.plate) + } + } + } + } + } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationCollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationCollectionFragment.kt index df2c047a..c08b914a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationCollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationCollectionFragment.kt @@ -2,7 +2,6 @@ package es.verdnatura.presentation.view.feature.reubication.fragment import android.annotation.SuppressLint import android.content.Context -import android.text.Editable import android.util.Log import android.view.View.GONE import android.view.View.VISIBLE @@ -14,8 +13,10 @@ import es.verdnatura.domain.notNull import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnPasillerosItemClickListener import es.verdnatura.presentation.common.OnReubicationClickListener +import es.verdnatura.presentation.view.component.CustomDialogInputTwoValues import es.verdnatura.presentation.view.component.CustomDialogThreeButtons import es.verdnatura.presentation.view.feature.reubication.adapter.ReubicatorAdapter +import es.verdnatura.presentation.view.feature.reubication.model.PlacementReubication import es.verdnatura.presentation.view.feature.reubication.model.Reubication import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel @@ -30,6 +31,7 @@ class ReubicationCollectionFragment( private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null private var adapter: ReubicatorAdapter? = null private lateinit var customDialogThreeButtons: CustomDialogThreeButtons + private lateinit var customDialogInputTwoValues: CustomDialogInputTwoValues companion object { fun newInstance( @@ -52,31 +54,35 @@ class ReubicationCollectionFragment( @SuppressLint("SetTextI18n") override fun init() { customDialogThreeButtons = CustomDialogThreeButtons(requireContext()) + customDialogInputTwoValues = CustomDialogInputTwoValues(requireContext()) ma.hideBottomNavigation(GONE) binding.splashProgress.visibility = GONE binding.mainToolbar.toolbarTitle.text = "${getString(R.string.wagoon)}:${shelving.uppercase()}" setEvents() - for (item in list) { - Log.d("VERDNATURA::", "item " + item.itemFk) - } - showList(list) + // showList(list) + // createReubicationsTwo(list) + //createReubications(list) + showList(list.sortedBy { it.pickingOrder }) super.init() } private fun showList(list: List) { + + + for (l in list){ + Log.d("VERDNATURA:::","El item es "+l.itemFk+":"+l.pickingOrder) + } + adapter = ReubicatorAdapter(list, pasillerosItemClickListener!!, object : OnReubicationClickListener { override fun onReubicationClick(reubication: Reubication) { binding.splashProgress.visibility = VISIBLE - viewModel.itemShelving_merge( - getData(USER), - getData(PASSWORD), - reubication.id, - "xxx" - ) + Log.d("VERDNATURA::", "el click en reubication") + showLeaveItemDialog(reubication, "") + } @@ -118,34 +124,110 @@ class ReubicationCollectionFragment( } private fun scanPlate(plate: String) { - showLeaveItemDialog(plate) - /* for (items in list){ - for (placements in items.placements!!){ - if (placements.plate==plate){ - Log.d("VERDNATURA::","Encontrada matrícula") - showLeaveItemDialog(plate) + //showLeaveItemDialog(plate) + var found = false + all_list@ for (items in list) { - } - } - }*/ + for (placements in items.placements!!) { + + + if (placements.plate == plate ) { + Log.d("VERDNATURA::", "Encontrada matrícula") + found = true + showLeaveItemDialog(items, placements.plate) + break@all_list + + } + + + }} + if (!found) { + ma.messageWithSound(getString(R.string.itemScanetNotFound), true, true, isToasted = true) + } } - private fun showLeaveItemDialog(plate: String) { - customDialogThreeButtons.setDescription("¿ Dejar item:XXX en el carro :$plate ?").setValue("1000") - .setOkButton(getString(R.string.leaveItem)) { + private fun showLeaveItemDialog(itemReubication: Reubication, placementReubication: String) { - }.setKoButton(getString(R.string.cancel)) { - scanRequest() - customDialogThreeButtons.dismiss() - }.show() + if (placementReubication.isNotEmpty()) { + val messageDescrip = + "¿ Dejar item: ${itemReubication.itemFk}-" + itemReubication.longName + " en el carro :" + placementReubication + "?" + customDialogThreeButtons.setDescription(messageDescrip) + .setValue(itemReubication.visible) + .setOkButton(getString(R.string.leaveItem)) { + + if (customDialogThreeButtons.getValue() == itemReubication.visible) { + binding.splashProgress.visibility = VISIBLE + viewModel.itemShelving_merge( + getData(USER), + getData(PASSWORD), + itemReubication.id, + placementReubication + ) + } + customDialogThreeButtons.dismiss() + + }.setKoButton(getString(R.string.cancel)) { + scanRequest() + customDialogThreeButtons.dismiss() + }.show() + + } else { + val messageDescrip = + getString(R.string.scanPlateToLeave)+itemReubication.itemFk+"-" + itemReubication.longName + + customDialogInputTwoValues.setDescription(messageDescrip) + .setValue(itemReubication.visible) + .setOkButton(getString(R.string.leaveItem)) { + + binding.splashProgress.visibility = VISIBLE + viewModel.itemShelving_merge( + getData(USER), + getData(PASSWORD), + itemReubication.id, + placementReubication.uppercase() + ) + + customDialogInputTwoValues.dismiss() + + }.setKoButton(getString(R.string.cancel)) { + binding.splashProgress.visibility = GONE + customDialogInputTwoValues.setValueTwo("") + scanRequest() + + customDialogInputTwoValues.dismiss() + }.show() + } + customDialogInputTwoValues.getEditTextTwo() + .setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { + + if (customDialogInputTwoValues.getValueTwo().isNotEmpty()) { + + binding.splashProgress.visibility = VISIBLE + viewModel.itemShelving_merge( + getData(USER), + getData(PASSWORD), + itemReubication.id, + customDialogInputTwoValues.getValueTwo().uppercase() + ) + } + customDialogInputTwoValues.setValue("") + scanRequest() + customDialogInputTwoValues.dismiss() + //hideKeyboards() + return@setOnEditorActionListener true + } + false + } + + customDialogInputTwoValues.setFocusTextTwo() + } private fun scanRequest() { - if (binding.scanInput != null) { - binding.scanInput.requestFocus() - } + binding.scanInput.requestFocus() } @@ -172,8 +254,8 @@ class ReubicationCollectionFragment( ) ) } else { - showList(it.list) - + // createReubications(it.list) + createReubicationsTwo(it.list) } } @@ -191,7 +273,12 @@ class ReubicationCollectionFragment( ma.messageWithSound(it.response, false, false, "", false) - callItemShelvingReturn() + if (!list.isEmpty()) + { + callItemShelvingReturn() + }else{ + ma.onBackPressed() + } } } @@ -211,5 +298,85 @@ class ReubicationCollectionFragment( } + private fun createReubicationsTwo(list: List) { + + var listItems= mutableListOf() + val reubication=mutableListOf() + + for (item in list){ + Log.d("VERDNATURA::", "itemFk"+item.shelvingFk) + Log.d("VERDNATURA::", "escaneado"+shelving) + if (item.shelvingFk.uppercase()==shelving.uppercase()){ + //listItems.add(item.itemFk) + Log.d("VERDNATURA::", "añadiendo") + reubication.add(Reubication(itemFk =item.itemFk, id=item.id,longName = item.longName, visible = item.visible, shelvingFk = item.shelvingFk)) + } + } + + + for (item in list){ + for (r in reubication){ + if (item.itemFk==r.itemFk){ + + if (item.shelvingFk.uppercase()!=shelving.uppercase()) + r.placements.add(PlacementReubication(code=item.code,plate=item.shelvingFk,visible="("+item.visible+")", idItemShelving = item.id)) + } + } + } + + // ma.openFragmentReubications(reubication,shelving) + } + + + + private fun createReubications(list: List) { + + val listItems = mutableListOf() + val reubication = mutableListOf() + + for (item in list) { + if (!listItems.contains(item.itemFk)) { + listItems.add(item.itemFk) + reubication.add( + Reubication( + itemFk = item.itemFk, + longName = item.longName, + visible = item.visible, + shelvingFk = item.shelvingFk + ) + ) + } + } + + for (item in list) { + for (r in reubication) { + if (item.itemFk == r.itemFk) { + + if (item.shelvingFk.uppercase() != shelving.uppercase()) + r.placements.add( + PlacementReubication( + code = item.code, + plate = item.shelvingFk, + visible = "(" + item.visible + ")", + idItemShelving = item.id + ) + ) + } + } + } + + for (item in list) { + Log.d("VERDNATURA::", "el item es " + item.itemFk + "-" + item.id + "-" + item.visible) + for (r in item.placements) { + Log.d( + "VERDNATURA::", + "la reubic es" + r.idItemShelving + "-" + r.plate + "-" + r.code + ) + } + } + //ma.openFragmentReubications(reubication,shelving) + + showList(list) + } } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationFragment.kt index 6340d71d..ca1da260 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/fragment/ReubicationFragment.kt @@ -10,6 +10,7 @@ import es.verdnatura.databinding.FragmentControladorBinding import es.verdnatura.domain.notNull import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnCollectionSelectedListener +import es.verdnatura.presentation.view.feature.reubication.model.PlacementReubication import es.verdnatura.presentation.view.feature.reubication.model.Reubication import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel @@ -67,6 +68,7 @@ class ReubicationFragment(var entrypoint: String) : shelvingFk = binding.scanInput.text.toString(), ) + } binding.scanInput.setText("") @@ -98,6 +100,11 @@ class ReubicationFragment(var entrypoint: String) : ) ) } else { + + + /* for (item in it.list){ + Log.d("VERDNATURA::", "Listando itemFk"+item.itemFk+":"+item.shelvingFk+":"+item.code) + }*/ createReubications(it.list) } @@ -114,17 +121,64 @@ class ReubicationFragment(var entrypoint: String) : private fun createReubications(list: List) { - for (item in list) { - if (item.shelvingFk != shelvingScaned && item.itemFk == "5987") { + var listItems = mutableListOf() - // TODO("FALTA CREAR REUBICACIONES") - // item.placements!!.add(PlacementReubication(item.shelvingFk, item.visible)) + val reubication = mutableListOf() as ArrayList + Log.d("VERDNATURA::", "Iniciem llistat") + for (item in list.sortedBy { it.pickingOrder }) { + if (item.shelvingFk.uppercase() == shelvingScaned.uppercase()) { + Log.d("VERDNATURA::", "añadiendo" + item.itemFk + ":" + item.shelvingFk) + reubication.add( + Reubication( + itemFk = item.itemFk, + id = item.id, + longName = item.longName, + visible = item.visible, + shelvingFk = item.shelvingFk, + pickingOrder = item.pickingOrder + ) + ) } } - Log.d("VERDNATURA::","LA MATRICULA ES "+shelvingScaned) - ma.openFragmentReubications(list,shelvingScaned) + + + + for (item in list.sortedBy { it.pickingOrder }) { + for (r in reubication) { + if (item.itemFk == r.itemFk) { + if (item.shelvingFk.uppercase() != shelvingScaned.uppercase()) + r.placements.add( + PlacementReubication( + code = item.code, + plate = item.shelvingFk, + visible = "(" + item.visible + ")", + idItemShelving = item.id + ) + ) + } + } + } + + for (item in reubication) { + if (item.placements.isNullOrEmpty()) { + item.pickingOrder = 0 + }else{ + //item.pickingOrder= + } + + } + + for (item in reubication) { + Log.d( + "VERDNATURA::", + "Item:" + item.itemFk + ":" + item.shelvingFk + " pickingORder:" + item.pickingOrder + ) + + } + ma.openFragmentReubications(reubication.sortedBy { it.pickingOrder }, shelvingScaned) + } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/model/Reubication.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/model/Reubication.kt index ddfb9d8b..9328b872 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/model/Reubication.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reubication/model/Reubication.kt @@ -1,7 +1,10 @@ package es.verdnatura.presentation.view.feature.reubication.model +import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO + + class ReubicationList( - var list: List = listOf() + var list: ArrayList = arrayListOf() ) class Reubication( @@ -11,13 +14,16 @@ class Reubication( var itemFk: String = "", var longName: String = "", var visible: String = "", - var placements: MutableList? = null, - var isError: Boolean, - var errorMessage: String + var placements: MutableList = mutableListOf(), + var pickingOrder:Int=0, + var isError: Boolean=false, + var errorMessage: String="" ) class PlacementReubication( + var code:String ="", var plate: String = "", var visible: String = "", + var idItemShelving:String="" ) \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt index a4b9edac..d25981d1 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorFragment.kt @@ -85,11 +85,6 @@ class UbicadorFragment( private fun setToolBar() { - /* val listIcons:ArrayList = ArrayList() - val iconAdd : Drawable = resources.getDrawable(R.drawable.ic_add_black_24dp,resources.newTheme()) - val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme()) - listIcons.add(iconAdd) - listIcons.add(iconReload)*/ val listIcons: ArrayList = ArrayList() val iconAdd = ImageView(context) iconAdd.setImageResource(R.drawable.ic_add_black_24dp) @@ -198,7 +193,7 @@ class UbicadorFragment( ) parking = customDialogInput.getValue() binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(R.string.label) + etiquetas + shelvingFk.uppercase() + " "+getString(R.string.pUppercase) + parking + getString(R.string.label) + etiquetas if (mpok != null) mpok!!.start() customDialogInput.dismiss() }.setKoButton(getString(R.string.cancel)) { @@ -220,7 +215,7 @@ class UbicadorFragment( parking = customDialogInput.getValue() if (binding.mainToolbar.toolbarTitle != null && shelvingFk != null && parking != null && etiquetas != null) { binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(R.string.label) + etiquetas + shelvingFk.uppercase() + "*"+getString(R.string.pUppercase) + parking + "*"+getString(R.string.label) + etiquetas } else { binding.mainToolbar.toolbarTitle.text = "" } @@ -245,7 +240,7 @@ class UbicadorFragment( ) shelvingFk = customDialogInput.getValue() binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(R.string.label) + etiquetas + shelvingFk.uppercase() + " "+getString(R.string.pUppercase) + parking + " "+getString(R.string.label) + etiquetas if (mpok != null) mpok!!.start() customDialogInput.dismiss() }.setKoButton(getString(R.string.cancel)) { @@ -265,7 +260,7 @@ class UbicadorFragment( ) shelvingFk = customDialogInput.getValue() binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(R.string.label) + etiquetas + shelvingFk.uppercase() + " "+getString(R.string.pUppercase) + parking + " "+getString(R.string.label) + etiquetas if (mpok != null) mpok!!.start() customDialogInput.dismiss() return@setOnEditorActionListener true @@ -330,7 +325,7 @@ class UbicadorFragment( } etiquetas = contEtiquetas.toString() binding.mainToolbar.toolbarTitle.text = - shelvingFk.uppercase() + getString(R.string.pUppercase) + parking + getString(R.string.label) + etiquetas + shelvingFk.uppercase() + " " +getString(R.string.pUppercase) + parking + " "+getString(R.string.label) + etiquetas if (it.list.size > 0) binding.editPrioridad.setText(it.list[0].priority) binding.splashProgress.visibility = View.GONE diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt index 373dcfb8..341f2a34 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt @@ -1,6 +1,7 @@ package es.verdnatura.presentation.view.feature.ubicador.fragment import android.content.Context +import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -334,15 +335,16 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { ) { getUbicadorUserCase.itemShelving_return(usuario, password, shelvingFk) - .enqueue(object : Callback> { - override fun onFailure(call: Call>, t: Throwable) { + .enqueue(object : Callback> { + override fun onFailure(call: Call>, t: Throwable) { val listError: ArrayList = ArrayList() listError.add( Reubication( isError = true, errorMessage = getMessageFromAllResponse( nameofFunction(this), - t.message!! + t.message!!, + ) ) ) @@ -350,8 +352,8 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { } override fun onResponse( - call: Call>, - response: Response> + call: Call>, + response: Response> ) { if (response.body()==null) { val listError: ArrayList = ArrayList() @@ -368,7 +370,9 @@ class UbicadorViewModel(context: Context) : BaseViewModel() { } else { _reubicationList.value = response.body()?.let { ReubicationList(it) } - + /* for (item in response.body()!!){ + Log.d("VERDNATURA","El item es "+item.itemFk+":"+item.shelvingFk) + }*/ } } }) diff --git a/app/src/main/res/layout/component_custom_edit_dialog.xml b/app/src/main/res/layout/component_custom_edit_dialog.xml index 36a2877b..d3d766b1 100644 --- a/app/src/main/res/layout/component_custom_edit_dialog.xml +++ b/app/src/main/res/layout/component_custom_edit_dialog.xml @@ -58,7 +58,25 @@ android:textColor="@color/verdnatura_white" android:textColorHint="@android:color/darker_gray" /> + + +