feat: refs #7763 rename
This commit is contained in:
parent
98ecb8e365
commit
251cdd32ee
|
@ -12,7 +12,6 @@ import android.view.View.VISIBLE
|
|||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentUbicadorBinding
|
||||
|
@ -40,7 +39,6 @@ import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
|||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapterNew
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||
class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel>(
|
||||
|
@ -760,7 +758,8 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
.setItemValue(itemUbicador.item.toString())
|
||||
.setPackingValue(itemUbicador.packing.toString())
|
||||
.setVisibleValue(itemUbicador.visible.toString())
|
||||
.setEtiquetaValue((itemUbicador.visible / (itemUbicador.packing ?: 0)).toString())
|
||||
//.setEtiquetaValue((itemUbicador.visible / (itemUbicador.packing ?: 0)).toString())
|
||||
.setEtiquetaValue(itemUbicador.stickers.toString())
|
||||
.setUnits(
|
||||
if (itemUbicador.stickers != 0) {
|
||||
(itemUbicador.visible % itemUbicador.stickers).toString()
|
||||
|
@ -1051,7 +1050,8 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
}
|
||||
customDialogConfirm.show()
|
||||
}//Tarea 7763
|
||||
/*.setOkButtonThree(getString(R.string.rename)) {
|
||||
/*
|
||||
.setOkButtonThree(getString(R.string.rename)) {
|
||||
customDialogInput.setTitle(getString(R.string.itemNew))
|
||||
.setDescription(getString(R.string.scanItem)).setValue("")
|
||||
.setOkButton(getString(R.string.rename)) {
|
||||
|
@ -1071,8 +1071,8 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
false
|
||||
}
|
||||
customDialogInput.getEditText().requestFocus()
|
||||
}*/
|
||||
|
||||
}
|
||||
*/
|
||||
customDialogTwoButtons.setKoButton(getString(R.string.cancel)) {
|
||||
customDialogTwoButtons.dismiss()
|
||||
}
|
||||
|
@ -1098,20 +1098,14 @@ class UbicadorFragmentNew : BaseFragment<FragmentUbicadorBinding, UbicadorViewMo
|
|||
}
|
||||
|
||||
private fun renameItem(item: ItemUbicador, barCode: Long) {
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
try {
|
||||
viewModel.rename(
|
||||
item = item,
|
||||
barCode = barCode,
|
||||
warehouse = mobileApplication.dataStoreApp.readDataStoreKey(WAREHOUSEFK)
|
||||
)
|
||||
viewModel.getInfoFromBuy(item.id, buyFk = barCode)
|
||||
} catch (ex: Exception) {
|
||||
ma.messageWithSound(ex.message.toString(), isError = true, isPlayed = true)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun customDialogTransferAction(item: ItemUbicador) {
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
|
|
|
@ -5,8 +5,6 @@ import androidx.lifecycle.LiveData
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.map
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonParser
|
||||
import com.google.gson.JsonPrimitive
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.userCases.GetItemFromBarcodeUseCase
|
||||
|
@ -16,9 +14,9 @@ import es.verdnatura.presentation.base.nameofFunction
|
|||
import es.verdnatura.presentation.common.Event
|
||||
import es.verdnatura.presentation.common.ItemShelvingSalix
|
||||
import es.verdnatura.presentation.common.ResponseHasOlder
|
||||
import es.verdnatura.presentation.common.ResponseItemVO
|
||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.Reubication
|
||||
import es.verdnatura.presentation.view.feature.claim.fragment.reubication.model.ReubicationList
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemBuy
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewer
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemShelvingNewerList
|
||||
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicador
|
||||
|
@ -34,10 +32,6 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
private val _shelvingList by lazy { MutableLiveData<ItemUbicadorListVO>() }
|
||||
|
||||
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||
val response: LiveData<ResponseItemVO>
|
||||
get() = _response
|
||||
|
||||
private val _responseUbicator by lazy { MutableLiveData<Boolean>() }
|
||||
val responseUbicator: LiveData<Boolean>
|
||||
get() = _responseUbicator
|
||||
|
@ -151,7 +145,6 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
packing: Int?,
|
||||
warehouse: Int,
|
||||
grouping: Int?,
|
||||
createdRename: String? = null
|
||||
) {
|
||||
salix.itemShelvingAdd(
|
||||
arrayListOf(
|
||||
|
@ -166,18 +159,6 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
).enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onResponse(call: Call<Any>, response: Response<Any>) {
|
||||
|
||||
if (!createdRename.isNullOrBlank() && response.body() != null) {
|
||||
|
||||
val jsonArray = JsonParser().parse(response.body().toString()).asJsonArray
|
||||
val jsonObject = jsonArray.get(0).asJsonObject
|
||||
itemShelvingUpdateCreated(
|
||||
itemShelvingFk = (jsonObject.get("LAST_INSERT_ID()") as JsonPrimitive).asInt,
|
||||
created = createdRename
|
||||
)
|
||||
} else {
|
||||
_responseUbicator.value =
|
||||
true
|
||||
}
|
||||
_responseUbicator.value =
|
||||
true
|
||||
super.onResponse(call, response)
|
||||
|
@ -207,32 +188,16 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun rename(
|
||||
item: ItemUbicador, barCode: Long, warehouse: Int
|
||||
fun getInfoFromBuy(
|
||||
itemShelvingFk: Number, buyFk: Number
|
||||
|
||||
) {
|
||||
salix.itemShelvingUpdate(
|
||||
params = ItemShelvingSalix(
|
||||
visible = 0,
|
||||
packing = item.packing,
|
||||
grouping = item.grouping,
|
||||
available = item.available
|
||||
),
|
||||
id = item.id,
|
||||
).enqueue(object : SalixCallback<ItemUbicador?>(context) {
|
||||
override fun onSuccess(response: Response<ItemUbicador?>) {
|
||||
|
||||
itemShelvingAdd(
|
||||
shelving = response.body()!!.shelvingFk!!,
|
||||
item = barCode,
|
||||
quantity = item.visible,
|
||||
packing = null,
|
||||
warehouse = warehouse,
|
||||
grouping = null,
|
||||
createdRename = response.body()!!.created
|
||||
)
|
||||
salix.getInfoFromBuyId(
|
||||
id = buyFk,
|
||||
).enqueue(object : SalixCallback<ItemBuy?>(context) {
|
||||
override fun onSuccess(response: Response<ItemBuy?>) {
|
||||
itemShelvingUpdateFromBuy(itemShelvingFk, response.body().let { it as ItemBuy })
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -278,16 +243,18 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
|
||||
fun itemShelvingMerge(
|
||||
vShelf: Int, vShelvingFk: String
|
||||
vShelf: Int, shelvingFk: String
|
||||
|
||||
) {
|
||||
salix.itemShelvingsUpdate(
|
||||
where = JsonObject().apply { addProperty("id", vShelf) },
|
||||
params = hashMapOf("shelvingFk" to vShelvingFk)
|
||||
params = hashMapOf("shelvingFk" to shelvingFk)
|
||||
).enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
_response.value = ResponseItemVO(isError = false, response = response.message()!!)
|
||||
super.onSuccess(response)
|
||||
itemShelvingAlternative(
|
||||
shelvingFk = shelvingFk,
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -308,17 +275,23 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun itemShelvingUpdateCreated(
|
||||
itemShelvingFk: Int, created: String
|
||||
fun itemShelvingUpdateFromBuy(
|
||||
itemShelvingFk: Number, itemBuy: ItemBuy
|
||||
|
||||
) {
|
||||
salix.itemShelvingsUpdate(
|
||||
where = JsonObject().apply { addProperty("id", itemShelvingFk) },
|
||||
params = hashMapOf("created" to created)
|
||||
).enqueue(object : SalixCallback<Any>(context) {
|
||||
JsonObject().apply {
|
||||
addProperty("itemFk", itemBuy.itemFk)
|
||||
addProperty("buyFk", itemBuy.id)
|
||||
addProperty("grouping", itemBuy.grouping)
|
||||
addProperty("packing", itemBuy.packing)
|
||||
addProperty("packagingFk", itemBuy.packagingFk)
|
||||
})
|
||||
.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)
|
||||
}
|
||||
})
|
||||
|
@ -364,7 +337,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)
|
||||
}
|
||||
})
|
||||
|
@ -397,7 +370,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)
|
||||
}
|
||||
})
|
||||
|
@ -457,15 +430,10 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
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())
|
||||
_responseUbicator.value = true
|
||||
|
||||
}
|
||||
})
|
||||
|
|
|
@ -49,6 +49,7 @@ class ItemEscanerVO(
|
|||
class ItemUbicadorListVO(
|
||||
var list: List<ItemUbicadorVO> = listOf()
|
||||
)
|
||||
|
||||
class ItemUbicadorListNew(
|
||||
var list: List<ItemUbicador> = listOf()
|
||||
)
|
||||
|
@ -62,5 +63,12 @@ class ItemShelvingNewerList(
|
|||
data class ItemShelvingNewer(
|
||||
var itemFk: Int,
|
||||
var shelvingFk: String,
|
||||
|
||||
)
|
||||
|
||||
data class ItemBuy(
|
||||
val id: Number,
|
||||
val itemFk: Number,
|
||||
val grouping: Int?,
|
||||
val packing: Int,
|
||||
val packagingFk: String?
|
||||
)
|
Loading…
Reference in New Issue