feat: multipleShelvingsAdd refs #7805

This commit is contained in:
Sergio De la torre 2024-09-13 11:41:45 +02:00
parent 81758cf340
commit 75a621094c
12 changed files with 209 additions and 104 deletions

View File

@ -34,7 +34,6 @@ import es.verdnatura.presentation.view.feature.roadmap.fragment.RoadMapListViewM
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel
import es.verdnatura.presentation.view.feature.sacador.fragment.showticket.ShowTicketViewModel
import es.verdnatura.presentation.view.feature.ticket.fragment.TicketViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
@ -91,11 +90,6 @@ val viewModelModule = module {
UbicadorViewModel(androidContext())
}
// Ubicador // Automatic
viewModel {
AutomaticAddItemViewModel(androidContext())
}
// Ajustes
viewModel {
AjustesViewModel(androidContext())

View File

@ -131,6 +131,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(
R.drawable.ic_sort -> getString(R.string.sortRouteSalix)
R.drawable.ic_sign_ticket -> getString(R.string.signed)
R.drawable.ic_send -> getString(R.string.sendDriverRoute)
R.drawable.ic_add_multiple -> getString(R.string.addItemMultipleShelvings)
else -> {
""
}

View File

@ -589,8 +589,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.titleUserControlVehicle) -> {
try {
addFragmentOnTop(ControlVehiculoUsuarioFragment.newInstance(entryPoint.toInt()))
}catch (ex:Exception){
e("Crashlytics",ex.message.toString())
} catch (ex: Exception) {
e("Crashlytics", ex.message.toString())
}
}
@ -665,6 +665,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
addFragmentOnTop(AutomaticAddItemFragment.newInstance(entryPoint, itemTitle))
}
getString(R.string.addItemMultipleShelving) -> {
addFragmentOnTop(AutomaticAddItemFragment.newInstance(entryPoint, itemTitle))
}
/* getString(R.string.titleControllersAction) -> {
addFragmentOnTop(AutomaticAddItemFragment.newInstance(entryPoint, itemTitle))
}*/
@ -718,7 +722,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
}
getString(R.string.titlePreControlTest) -> {
addFragmentOnTop(CollectionFragmentPreCheckerNew.newInstance(null, type = PRECHECKERNEW))
addFragmentOnTop(
CollectionFragmentPreCheckerNew.newInstance(
null,
type = PRECHECKERNEW
)
)
}
getString(R.string.titleShelvingHistorical) -> {
@ -997,7 +1006,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
}
override fun onCollectionSelected(
collection: CollectionTicket, type: String, hasPicking: Boolean, hasToAdd:Boolean
collection: CollectionTicket, type: String, hasPicking: Boolean, hasToAdd: Boolean
) {
when (type) {
"PREITEMPICKERTEST" -> {
@ -1153,8 +1162,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
versionApp = (application as MobileApplication).versionName,
androidId = (application as MobileApplication).androidId,
serialnumber = (application as MobileApplication).serialNumber ?: "",
userFk = (application as MobileApplication).userId!!)
}catch (ex:Exception){
userFk = (application as MobileApplication).userId!!
)
} catch (ex: Exception) {
d(ex.message.toString())
}
}

View File

@ -6,9 +6,14 @@ import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentAutomaticAddItemBinding
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
import es.verdnatura.domain.isShelving
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnAutomaticItemClickListener
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
import es.verdnatura.presentation.view.feature.ubicador.adapter.AutomaticAdapter
import java.lang.Boolean.TRUE
@ -16,13 +21,16 @@ import java.lang.Boolean.TRUE
class AutomaticAddItemFragment(
private var shelvingFk: String = "",
private var titleAction: String? = null
) : BaseFragment<FragmentAutomaticAddItemBinding, AutomaticAddItemViewModel>(
AutomaticAddItemViewModel::class
) : BaseFragment<FragmentAutomaticAddItemBinding, UbicadorViewModel>(
UbicadorViewModel::class
) {
private var adapter: AutomaticAdapter? = null
private var listItems: ArrayList<Long> = ArrayList()
private var contador = 0
private lateinit var customDialogList: CustomDialogList
private var listShelvings: ArrayList<BarcodeVO> = ArrayList()
private var listShelvingsAdapter: BarcodeAdapter? = null
companion object {
fun newInstance(entryPoint: String, titleAction: String) =
@ -106,36 +114,126 @@ class AutomaticAddItemFragment(
}
binding.buttonFinalizar.setOnClickListener {
val listString: ArrayList<Long> = ArrayList()
val listInt: ArrayList<Long> = ArrayList()
listItems.forEach {
listString.add(it)
listInt.add(it)
}
if (binding.mainToolbar.toolbarTitle.text.equals(getString(R.string.titleChecker))) {
if (listItems.isEmpty()) {
ma.messageWithSound(
getString(R.string.scanItem),
isError = false,
isPlayed = false,
isToasted = true
)
} else {
when (titleAction) {
getString(R.string.titleChecker) -> {
viewModel.itemShelvingAddList(
shelvingFk,
"" + listInt + "",
listItems.joinToString(),
TRUE,
mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
)
} else {
}
getString(R.string.addItemMultipleShelving) -> {
inputMultipleShelvingsForUbicator()
}
else -> {
viewModel.itemShelvingMakeMulti(
shelvingFk,
listString,
ArrayList(listItems),
mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
)
}
}
}
}
binding.mainToolbar.backButton.setOnClickListener {
ma.onMyBackPressed()
}
}
private fun inputMultipleShelvingsForUbicator() {
if (listShelvings.isNotEmpty()) listShelvings.clear()
customDialogList = CustomDialogList(requireContext())
customDialogList.setTitle(
getString(R.string.shelvingsLocate)
)
customDialogList.setDescription(
getString(R.string.scanShelvingsLocate)
).setOkButton(getString(R.string.locate)) {
listShelvings.forEach {
viewModel.itemShelvingMakeMulti(
it.code!!,
ArrayList(listItems),
mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
)
}
customDialogList.dismiss()
}.setKoButton(getString(R.string.cancel)) {
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.dismiss()
}.setValue("").show()
customDialogList.getEditText().requestFocus()
ma.hideKeyboard(customDialogList.getEditText())
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (customDialogList.getValue().isNotEmpty()) {
try {
customDialogList.setValue(
itemScanValue(
customDialogList.getValue(), arrayOf("buy"), field = "id"
).toString()
)
if (customDialogList.getValue().isShelving()) {
if (listShelvings.firstOrNull { it.code == customDialogList.getValue() } == null) {
listShelvings.add(BarcodeVO(code = customDialogList.getValue()))
} else {
throw Exception(getString(R.string.errorRepeatedShelving))
}
} else {
throw Exception()
}
} catch (ex: Exception) {
ma.messageWithSound(
getString(R.string.errorInput),
isError = true,
isPlayed = true,
isToasted = true
)
listShelvings.removeAt(0)
}
listShelvingsAdapter!!.notifyItemChanged(0)
}
customDialogList.setValue("")
ma.hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false
}
listShelvingsAdapter = BarcodeAdapter(
listShelvings, object : OnBarcodeRowClickListener {
override fun onBarcodeRowClickListener(item: BarcodeVO) {
}
}, showDelete = false
)
customDialogList.getRecyclerView().adapter = listShelvingsAdapter
customDialogList.getRecyclerView().layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
override fun observeViewModel() {
with(viewModel) {
response.observe(viewLifecycleOwner) {

View File

@ -1,52 +0,0 @@
package es.verdnatura.presentation.view.feature.ubicador.fragment
import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.SalixCallback
import es.verdnatura.domain.formatWithQuotes
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.view.feature.workermistake.model.MakeMultiSalix
import retrofit2.Response
class AutomaticAddItemViewModel(val context: Context) : BaseViewModel(context) {
private val _response by lazy { MutableLiveData<Boolean>() }
val response: LiveData<Boolean> = _response
fun itemShelvingMakeMulti(
shelvingFk: String, items: List<Long>, warehouseFk: Int
) {
salix.upsertItem(MakeMultiSalix(shelvingFk, items, warehouseFk))
.enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
_response.value = false
}
override fun onSuccess(response: Response<Any>) {
_response.value = true
}
})
}
fun itemShelvingAddList(
shelving: String, items: Any, isChecking: Boolean, warehouse: Int
) {
salix.itemShelvingAddList(
arrayListOf(shelving, items, isChecking, warehouse).formatWithQuotes()
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_response.value = true
}
override fun onError(t: Throwable) {
_response.value = false
}
})
}
}

View File

@ -127,7 +127,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
isShelvinLogfromMainScreen = true
setIconsActions(false)
//Tarea 7805
// setIcons(true)
setIcons(true)
}
super.init()
}
@ -158,11 +158,13 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
}
}
private fun setIcons(isOnlyIconAdd: Boolean = false) {
private fun setIcons(isInitMenu: Boolean = false) {
listIcons.clear()
val iconAdd = ImageView(context)
iconAdd.setImageResource(R.drawable.ic_add_black_24dp)
val iconAddMultiple = ImageView(context)
iconAddMultiple.setImageResource(R.drawable.ic_add_multiple)
val iconReload = ImageView(context)
iconReload.setImageResource(R.drawable.ic_autorenew_black_24dp)
val iconReset = ImageView(context)
@ -197,15 +199,19 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
iconReload.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
iconAdd.tooltipText = getString(R.string.addItemShelving)
iconAdd.tooltipText =
if (isInitMenu) getString(R.string.addItemMultipleShelving) else getString(R.string.addItemShelving)
iconAddMultiple.tooltipText = getTooltip(R.drawable.ic_add_multiple)
iconReset.tooltipText = getTooltip(R.drawable.ic_remove_checks)
listIcons.add(iconAdd)
if (!isOnlyIconAdd) {
if (!isInitMenu) {
listIcons.add(iconReload)
} else {
listIcons.add(iconAddMultiple)
}
//Tarea7805
// locateMultipleShelvings = isOnlyIconAdd
locateMultipleShelvings = isInitMenu
binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
@ -216,6 +222,13 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
isEditItem = false, null
)
iconAddMultiple.drawable ->
ma.onPasillerosItemClickListener(
PasillerosItemVO(
title = R.string.addItemMultipleShelving,
), entryPoint = getString(R.string.addItemMultipleShelving)
)
iconReload.drawable -> {
if (shelvingFk.isNotBlank()) {
@ -794,8 +807,6 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
customDialogUbicador.getPackingItem().requestFocus()
}
setWatcher()
customDialogUbicador.getEditItem().requestFocus()
ma.hideKeyboard(customDialogUbicador.getEditItem())
@ -875,7 +886,7 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
}
private fun insertShelvingsForUbicator(barCode: Number, visible: Int, packing: Int?) {
if (listShelvings.isNotEmpty()) listShelvings.clear()
customDialogList = CustomDialogList(requireContext())
customDialogList.setTitle(
getString(R.string.shelvingsLocate)

View File

@ -25,6 +25,7 @@ import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListNew
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import es.verdnatura.presentation.view.feature.workermistake.model.MakeMultiSalix
import retrofit2.Call
import retrofit2.Response
@ -301,7 +302,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_response.value = ResponseItemVO(isError = false, response = response.message()!!)
_responseUbicator.value = true
super.onSuccess(response)
}
})
@ -450,4 +451,25 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun itemShelvingMakeMulti(
shelvingFk: String, items: List<Long>, warehouseFk: Int
) {
salix.upsertItem(MakeMultiSalix(shelvingFk, items, warehouseFk))
.enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
super.onError(t)
_response.value =
ResponseItemVO(isError = true, response = t.message.toString())
}
override fun onSuccess(response: Response<Any>) {
super.onSuccess(response)
_response.value = ResponseItemVO(isError = false, response = response.message())
}
})
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M120,640L120,560L400,560L400,640L120,640ZM120,480L120,400L560,400L560,480L120,480ZM120,320L120,240L560,240L560,320L120,320ZM640,800L640,640L480,640L480,560L640,560L640,400L720,400L720,560L880,560L880,640L720,640L720,800L640,800Z" />
</vector>

View File

@ -843,7 +843,7 @@
<string name="rename">Renombrar</string>
<string name="itemNew">Nuevo artículo</string>
<string name="locate">Ubicar</string>
<string name="scanShelvingsLocate">Escanea carros para ubicar el artículo</string>
<string name="scanShelvingsLocate">Escanea carros para ubicar el artículo/s</string>
<string name="shelvingsLocate">Carros a ubicar</string>
<string name="errorRepeatedShelving">Carro ya introducido</string>
<string name="errorGetData">errorGetData</string>
@ -862,6 +862,9 @@
<string name="scanExpeditions">Escanear cajas</string>
<string name="titleprepickertest">titlePrePickerTest</string>
<string name="preitempickertestMayus">PREITEMPICKERTEST</string>
<string name="reviewSector">Revisa el SECTOR</string>
<string name="addItemMultipleShelving">Añade artículo en varios carros</string>
<string name="addItemMultipleShelvings">Añade artículos en varios carros</string>
</resources>

View File

@ -844,7 +844,7 @@
<string name="itemNew">Nuevo artículo</string>
<string name="errorRepeatedShelving">Carro ya introducido</string>
<string name="locate">Ubicar</string>
<string name="scanShelvingsLocate">Escanea carros para ubicar el artículo</string>
<string name="scanShelvingsLocate">Escanea carros para ubicar el artículo/s</string>
<string name="shelvingsLocate">Carros a ubicar</string>
<string name="errorGetData">Fallo al intentar obtener datos. Avise a Informática</string>
<string name="errorSector">No tienes sector seleccionado. Ve a pantalla ajustes y selecciona uno</string>
@ -862,5 +862,8 @@
<string name="scanExpeditions">Escanear cajas</string>
<string name="titleprepickertest">titlePrePickerTest</string>
<string name="preitempickertestMayus">PREITEMPICKERTEST</string>
<string name="reviewSector">Revisa el SECTOR</string>
<string name="addItemMultipleShelving">Añade artículo en varios carros</string>
<string name="addItemMultipleShelvings">Añade artículos en varios carros</string>
</resources>

View File

@ -844,7 +844,7 @@
<string name="itemNew">Nuevo artículo</string>
<string name="errorRepeatedShelving">Carro ya introducido</string>
<string name="locate">Ubicar</string>
<string name="scanShelvingsLocate">Escanea carros para ubicar el artículo</string>
<string name="scanShelvingsLocate">Escanea carros para ubicar el artículo/s</string>
<string name="shelvingsLocate">Carros a ubicar</string>
<string name="errorGetData">Fallo al intentar obtener datos. Avise a Informática</string>
<string name="errorSector">No tienes sector seleccionado. Ve a pantalla ajustes y selecciona uno</string>
@ -862,6 +862,9 @@
<string name="scanExpeditions">Escanear cajas</string>
<string name="titleprepickertest">titlePrePickerTest</string>
<string name="preitempickertestMayus">PREITEMPICKERTEST</string>
<string name="reviewSector">Revisa el SECTOR</string>
<string name="addItemMultipleShelving">Añade artículo en varios carros</string>
<string name="addItemMultipleShelvings">Añade artículos en varios carros</string>
</resources>

View File

@ -846,7 +846,7 @@
<string name="itemNew">Nuevo artículo</string>
<string name="errorRepeatedShelving">Carro ya introducido</string>
<string name="locate">Ubicar</string>
<string name="scanShelvingsLocate">Escanea carros para ubicar el artículo</string>
<string name="scanShelvingsLocate">Escanea carros para ubicar el artículo/s</string>
<string name="shelvingsLocate">Carros a ubicar</string>
<string name="errorGetData">Fallo al intentar obtener datos. Avise a Informática</string>
<string name="errorSector">No tienes sector seleccionado. Ve a pantalla ajustes y selecciona uno</string>
@ -865,5 +865,8 @@
<string name="titleprepickertest">titlePrePickerTest</string>
<string name="preitempickertestMayus">PREITEMPICKERTEST</string>
<string name="expeditionInfo" translatable="false">%1$s %2$s</string>
<string name="reviewSector">Revisa el SECTOR</string>
<string name="addItemMultipleShelving">Añade artículo en varios carros</string>
<string name="addItemMultipleShelvings">Añade artículos en varios carros</string>
</resources>