Version 23.2 Modificado orden ubicador y revisión anterior falta activar icono

This commit is contained in:
Sergio De la torre 2023-01-25 16:21:20 +01:00
parent 720b943f60
commit 6e4c2524b7
2 changed files with 86 additions and 39 deletions

View File

@ -30,6 +30,7 @@ import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import java.lang.Boolean.TRUE
@Suppress("UNUSED_ANONYMOUS_PARAMETER") @Suppress("UNUSED_ANONYMOUS_PARAMETER")
@ -52,6 +53,7 @@ class UbicadorFragment(
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private var isShelvinLogfromMainScreen = false private var isShelvinLogfromMainScreen = false
private var modeCheckUbication = false private var modeCheckUbication = false
private var itemScannedScreen = 0
var mperror: MediaPlayer? = null var mperror: MediaPlayer? = null
var mpok: MediaPlayer? = null var mpok: MediaPlayer? = null
var isBack = false var isBack = false
@ -112,7 +114,7 @@ class UbicadorFragment(
iconReload.setImageResource(R.drawable.ic_autorenew_black_24dp) iconReload.setImageResource(R.drawable.ic_autorenew_black_24dp)
// binding.mainToolbar.switchButton.visibility = VISIBLE //Tarea#5052 binding.mainToolbar.switchButton.visibility = VISIBLE
binding.mainToolbar.switchButton.setOnCheckedChangeListener { buttonView, isChecked -> binding.mainToolbar.switchButton.setOnCheckedChangeListener { buttonView, isChecked ->
if (binding.mainToolbar.toolbarTitle.text == getString(R.string.titleUbicator)) { if (binding.mainToolbar.toolbarTitle.text == getString(R.string.titleUbicator)) {
ma.messageWithSound(getString(R.string.scanShelving), false, false) ma.messageWithSound(getString(R.string.scanShelving), false, false)
@ -245,12 +247,9 @@ class UbicadorFragment(
) )
} }
ma.hideKeyboard(binding.editPrioridad) ma.hideKeyboard(binding.editPrioridad)
//return@setOnEditorActionListener false
} }
//return@setOnEditorActionListener false
binding.editMatricula.requestFocus() binding.editMatricula.requestFocus()
return@setOnEditorActionListener false return@setOnEditorActionListener false
} }
@ -259,7 +258,6 @@ class UbicadorFragment(
binding.automaticImg.setOnClickListener { binding.automaticImg.setOnClickListener {
if (!shelvingFk.isNullOrEmpty()) if (!shelvingFk.isNullOrEmpty())
//Tarea #4778 Para llamar a Revisar items poner R.string.titleChecker
ma.onPasillerosItemClickListener( ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titleAuto)), PasillerosItemVO(title = getString(R.string.titleAuto)),
//PasillerosItemVO(title = getString(R.string.titleChecker)), //PasillerosItemVO(title = getString(R.string.titleChecker)),
@ -362,7 +360,8 @@ class UbicadorFragment(
customDialog.setTitle(getString(R.string.empty)) customDialog.setTitle(getString(R.string.empty))
.setDescription(getString(R.string.operationNoReturn)) .setDescription(getString(R.string.operationNoReturn))
.setOkButton(getString(R.string.empty)) { .setOkButton(getString(R.string.empty)) {
viewModel.clearShelvingList(shelvingFk viewModel.clearShelvingList(
shelvingFk
) )
listItems.forEach { listItems.forEach {
it.stickers = "0" it.stickers = "0"
@ -382,37 +381,27 @@ class UbicadorFragment(
} }
private fun checkUbications(itemScanned: Int) { private fun checkUbications(itemScanned: Int) {
itemScannedScreen = itemScanned
for (item in listItems) { val listInt: ArrayList<Int> = ArrayList()
if (item.item == itemScanned) {
item.checked = true
ma.messageWithSound("", false, true, "", false)
}
}
if (listItems.filter { it.item == itemScanned }.isEmpty()) { if (listItems.filter { it.item == itemScanned }.isEmpty()) {
binding.splashProgress.visibility = View.GONE listInt.add(itemScanned)
listItems.add( } else {
ItemUbicadorVO( listItems.sortedBy { it.isChecked }.forEachIndexed { index, item ->
item = itemScanned, if (item.item == itemScanned) {
visible = "0", item.checked = true
packing = "0", listInt.add(item.item)
grouping = "0", ma.messageWithSound("", false, true, "", false)
isNew = true }
) }
)
listLocalItems = listItems.clone() as ArrayList<ItemUbicadorVO>
viewModel.itemShelvingMake(
shelving = shelvingFk,
item = itemScanned,
quantity = 0,
packing = null,
warehouse = getDataInt(WAREHOUSEFK),
grouping = null
)
} }
viewModel.itemShelving_addList(
shelvingFk,
"" + listInt + "",
TRUE,
getDataInt(WAREHOUSEFK)
)
adapter!!.notifyDataSetChanged() adapter!!.notifyDataSetChanged()
} }
@ -488,7 +477,7 @@ class UbicadorFragment(
} }
adapter = UbicadorAdapter( adapter = UbicadorAdapter(
listItems, listItems.sortedBy { it.isChecked },
onPasillerosItemClickListener = pasillerosItemClickListener!!, onPasillerosItemClickListener = pasillerosItemClickListener!!,
onVisibleClickListener = object : OnVisibleClickListener { onVisibleClickListener = object : OnVisibleClickListener {
override fun onVisibleClickListener(item: ItemUbicadorVO) { override fun onVisibleClickListener(item: ItemUbicadorVO) {
@ -520,18 +509,38 @@ class UbicadorFragment(
LinearLayoutManager( LinearLayoutManager(
requireContext(), requireContext(),
LinearLayoutManager.VERTICAL, LinearLayoutManager.VERTICAL,
true false
) )
if (isShelvinLogfromMainScreen) { if (isShelvinLogfromMainScreen) {
//tarea 4454
viewModel.shelvinLog_add(shelvingFk) viewModel.shelvinLog_add(shelvingFk)
} }
if (modeCheckUbication) {
listItems.sortedBy { it.isChecked }.forEachIndexed { index, item ->
if (item.item == itemScannedScreen) {
binding.locationRecyclerview.scrollToPosition(index)
}
}
} else {
(binding.locationRecyclerview.layoutManager as LinearLayoutManager).scrollToPosition(
0
)
}
} }
} }
}) })
responseAddList.observe(viewLifecycleOwner, Observer {
if (it.isError) {
ma.messageWithSound(it.errorMessage, it.isError, false)
} else {
binding.splashProgress.visibility = VISIBLE
viewModel.itemShelvingList(shelvingFk)
}
})
response.observe(viewLifecycleOwner, Observer { response.observe(viewLifecycleOwner, Observer {
if (it.isError) { if (it.isError) {
@ -544,7 +553,7 @@ class UbicadorFragment(
} }
}) })
responseCode.observe(viewLifecycleOwner, Observer { responseCode.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE binding.splashProgress.visibility = GONE
if (it.isError) { if (it.isError) {
ma.messageWithSound(it.errorMessage, true, true) ma.messageWithSound(it.errorMessage, true, true)
} else { } else {
@ -601,7 +610,11 @@ class UbicadorFragment(
} }
saveNewItem( saveNewItem(
customDialogUbicador.getItemValue().toInt(), customDialogUbicador.getItemValue().toInt(),
if (customDialogUbicador.getEtiquetaValue().isNullOrEmpty()) {1}else{customDialogUbicador.getEtiquetaValue().toInt()}, if (customDialogUbicador.getEtiquetaValue().isNullOrEmpty()) {
1
} else {
customDialogUbicador.getEtiquetaValue().toInt()
},
if (customDialogUbicador.getPackingValue().isNullOrEmpty()) { if (customDialogUbicador.getPackingValue().isNullOrEmpty()) {
null null
} else { } else {
@ -676,7 +689,11 @@ class UbicadorFragment(
}, },
if (delete) packingUpdate else null, if (delete) packingUpdate else null,
itemUbicador.id, itemUbicador.id,
if (customDialogUbicador.getGroupingValue().isNullOrEmpty()) {null}else{customDialogUbicador.getGroupingValue().toInt()} if (customDialogUbicador.getGroupingValue().isNullOrEmpty()) {
null
} else {
customDialogUbicador.getGroupingValue().toInt()
}
) )
return@setOnEditorActionListener true return@setOnEditorActionListener true
} }

View File

@ -41,6 +41,9 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
val responseCode: LiveData<ResponseItemVO> val responseCode: LiveData<ResponseItemVO>
get() = _responseCode get() = _responseCode
private val _responseAddList by lazy { MutableLiveData<ResponseItemVO>() }
val responseAddList: LiveData<ResponseItemVO> = _responseAddList
fun itemShelvingList( fun itemShelvingList(
vShelvingFk: String vShelvingFk: String
) { ) {
@ -105,7 +108,34 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
} }
}) })
} }
fun itemShelving_addList(
shelving: String,
items: Any,
isChecking: Boolean,
warehouse: Int
) {
silex.itemShelving_addList(
shelving,
items,
isChecking,
warehouse
).enqueue(object :
SilexCallback<Any>(context) {
override fun onError(t: Throwable) {
_responseAddList.value = ResponseItemVO(
isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), t.message!!
)
)
}
override fun onSuccess(response: Response<Any>) {
_responseAddList.value =
ResponseItemVO(isError = false, response = response.message()!!)
}
})
}
fun itemShelvingMake( fun itemShelvingMake(
shelving: String, shelving: String,
item: Int, item: Int,