feat: refs #7920 shelvingFkMerge

This commit is contained in:
Sergio De la torre 2025-02-14 11:58:41 +01:00
parent aae791f721
commit 2295497e62
5 changed files with 64 additions and 32 deletions

View File

@ -50,6 +50,7 @@ import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
import es.verdnatura.presentation.view.feature.login.model.RenewToken import es.verdnatura.presentation.view.feature.login.model.RenewToken
import es.verdnatura.presentation.view.feature.login.model.VersionApp import es.verdnatura.presentation.view.feature.login.model.VersionApp
import es.verdnatura.presentation.view.feature.login.model.WorkerData import es.verdnatura.presentation.view.feature.login.model.WorkerData
import es.verdnatura.presentation.view.feature.packaging.model.DmsType
import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
import es.verdnatura.presentation.view.feature.packaging.model.NotificationQueue import es.verdnatura.presentation.view.feature.packaging.model.NotificationQueue
@ -450,7 +451,7 @@ interface SalixService {
@GET("ItemShelvings/getAlternative") @GET("ItemShelvings/getAlternative")
fun itemShelvingAlternative( fun itemShelvingAlternative(
@Query("shelvingFk") shelvingFk: String @Query("shelvingCode") shelvingFk: String
): Call<ArrayList<Reubication>> ): Call<ArrayList<Reubication>>
@GET("MobileAppVersionControls/getVersion") @GET("MobileAppVersionControls/getVersion")
@ -916,6 +917,11 @@ interface SalixService {
fun getWithPackaging( fun getWithPackaging(
): Call<List<Supplier>> ): Call<List<Supplier>>
@GET("DmsTypes/findOne")
fun getDmsType(
@Query("filter") filter: String
): Call<DmsType>
@GET("Entries") @GET("Entries")
fun getEntriesFromSupplier( fun getEntriesFromSupplier(
@Query("filter") filter: String @Query("filter") filter: String

View File

@ -181,9 +181,11 @@ class ReubicationCollectionFragment(
private fun customDialogMerge(itemReubication: Reubication) { private fun customDialogMerge(itemReubication: Reubication) {
if (customDialogInputTwoValues.getValueTwo().isNotEmpty()) { if (customDialogInputTwoValues.getValueTwo().isNotEmpty()) {
viewModel.itemShelvingMerge( viewModel.getMergeFromCode(
itemReubication.id, customDialogInputTwoValues.getValueTwo().uppercase() itemReubication.id,
customDialogInputTwoValues.getValueTwo().uppercase()
) )
} else { } else {
ma.messageWithSound( ma.messageWithSound(
getString(R.string.returnScan), isError = true, isPlayed = true, isToasted = true getString(R.string.returnScan), isError = true, isPlayed = true, isToasted = true

View File

@ -56,6 +56,8 @@ class ReubicationFragment(var entrypoint: String) :
if (!binding.scanInput.text.isNullOrEmpty()) { if (!binding.scanInput.text.isNullOrEmpty()) {
shelvingScaned = binding.scanInput.text.toString() shelvingScaned = binding.scanInput.text.toString()
viewModel.itemShelvingAlternative( viewModel.itemShelvingAlternative(
shelvingFk = binding.scanInput.text.toString(), shelvingFk = binding.scanInput.text.toString(),
) )

View File

@ -476,15 +476,15 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
private fun customDialogActionChange() { private fun customDialogActionChange() {
//Tarea 7920 //Tarea 7920
/* if (listItems.isNotEmpty()) {
viewModel.shelvingChangeSalix( if (listItems.isNotEmpty()) {
shelvingFk, customDialogInput.getValue() viewModel.getShelvingFkFromCode(
) listItems[0].shelvingFk, customDialogInput.getValue()
} else {*/ )
viewModel.getShelvingFkFromCode( } else {
listItems[0].shelvingFk, customDialogInput.getValue() getString(R.string.shelvingItems).toast(requireContext())
) }
// }
shelvingFk = customDialogInput.getValue() shelvingFk = customDialogInput.getValue()
customDialogInput.dismiss() customDialogInput.dismiss()
@ -1163,8 +1163,8 @@ class UbicadorFragment : BaseFragment<FragmentUbicadorBinding, UbicadorViewModel
} }
).setOkButton(getString(R.string.delete)) { ).setOkButton(getString(R.string.delete)) {
if (!isAutoSelf) { if (!isAutoSelf) {
listItems.remove(item) // listItems.remove(item)
adapter!!.notifyItemRemoved(listItems.indexOf(item)) //adapter!!.notifyItemRemoved(listItems.indexOf(item))
viewModel.itemShelvingDelete( viewModel.itemShelvingDelete(
item.id item.id
) )

View File

@ -350,6 +350,26 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun getMergeFromCode(
vShelft: Int, shelvingCode: String
) {
salix.shelvingGetFromCode(
filter = """{"where":{"code":"$shelvingCode"}}"""
).enqueue(object : SalixCallback<ItemUbicador>(context) {
override fun onSuccess(response: Response<ItemUbicador>) {
val myItemCode = response.body().let { it as ItemUbicador }
itemShelvingMerge(
vShelft, myItemCode.id.toString()
)
}
})
}
fun itemShelvingMerge( fun itemShelvingMerge(
vShelf: Int, shelvingFk: String vShelf: Int, shelvingFk: String
@ -472,24 +492,6 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun shelvingChangeSalix(
shelvingFkIn: String, shelvingFkOut: String
) {
salix.itemShelvingsUpdate(
where = JsonObject().apply {
addProperty("shelvingFk", shelvingFkIn)
},
hashMapOf("shelvingFk" to shelvingFkOut)
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_responseUbicator.value = true
super.onSuccess(response)
}
})
}
//tarea 7920 //tarea 7920
fun shelvingChangeSalixNew( fun shelvingChangeSalixNew(
shelvingFkIn: Number, shelvingFkOut: Number shelvingFkIn: Number, shelvingFkOut: Number
@ -527,6 +529,26 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun itemShelvingAlternativeFromCode(
shelvingCode: String
) {
salix.shelvingGetFromCode(
filter = """{"where":{"code":"$shelvingCode"}}"""
).enqueue(object : SalixCallback<ItemUbicador>(context) {
override fun onSuccess(response: Response<ItemUbicador>) {
val myItemCode = response.body().let { it as ItemUbicador }
itemShelvingAlternative(
myItemCode.id.toString()
)
}
})
}
fun itemShelvingTransfer( fun itemShelvingTransfer(
itemShelvingFk: Number, shelvingFk: String itemShelvingFk: Number, shelvingFk: String