feat boxPicking refs #7357
This commit is contained in:
parent
4d1f22f529
commit
687bd6fc4b
|
@ -2,6 +2,7 @@ package es.verdnatura.di
|
|||
|
||||
import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesViewModel
|
||||
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardViewModel
|
||||
import es.verdnatura.presentation.view.feature.boxPicking.BoxPickingViewModel
|
||||
import es.verdnatura.presentation.view.feature.buffer.fragment.BufferFragmentViewModel
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemViewModel
|
||||
import es.verdnatura.presentation.view.feature.category.ChangeCategoryViewModel
|
||||
|
@ -32,10 +33,10 @@ import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewM
|
|||
import es.verdnatura.presentation.view.feature.photos.fragment.PhotosViewModel
|
||||
import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorViewModel
|
||||
import es.verdnatura.presentation.view.feature.qr.QrFragmentViewModel
|
||||
import es.verdnatura.presentation.view.feature.roadmap.fragment.RoadMapListViewModel
|
||||
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.roadmap.fragment.RoadMapListViewModel
|
||||
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
|
||||
|
@ -205,4 +206,7 @@ val viewModelModule = module {
|
|||
viewModel {
|
||||
ChangeCategoryViewModel(androidContext())
|
||||
}
|
||||
viewModel {
|
||||
BoxPickingViewModel(androidContext())
|
||||
}
|
||||
}
|
|
@ -329,6 +329,12 @@ interface SalixService {
|
|||
|
||||
):
|
||||
Call<CollectionVO>
|
||||
|
||||
@GET("Expedition_printOuts/findOne")
|
||||
fun isBoxPickingInPrintOut(
|
||||
@Query("filter") filter: String,
|
||||
):
|
||||
Call<Any>
|
||||
@GET("TicketCollections/hasUncheckedTicket")
|
||||
fun hasUncheckedTicket(
|
||||
@Query("ticketFk") ticketFk: Number,
|
||||
|
@ -934,6 +940,11 @@ interface SalixService {
|
|||
@Path("barCodeValue") barCodeValue: String
|
||||
): Call<String?>
|
||||
|
||||
@GET("ItemBarCodes/{barCodeValue}/toItem")
|
||||
fun barcodesToItem(
|
||||
@Path("barCodeValue") barCodeValue: String
|
||||
): Call<Int?>
|
||||
|
||||
@GET("Suppliers")
|
||||
fun getSuppliers(
|
||||
//@Query("filter") filter:String="""{"fields":{"id":true,"name":true}}"""
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
package es.verdnatura.presentation.view.feature.boxPicking
|
||||
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import es.verdnatura.R
|
||||
import es.verdnatura.databinding.FragmentGeneralBlackBinding
|
||||
import es.verdnatura.presentation.base.BaseFragment
|
||||
import es.verdnatura.presentation.common.OnCollectionSelectedListener
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
|
||||
class BoxPickingFragment(var title: String) :
|
||||
BaseFragment<FragmentGeneralBlackBinding, BoxPickingViewModel>(BoxPickingViewModel::class) {
|
||||
private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
|
||||
private var isBoxScanned: Boolean = false
|
||||
private lateinit var customDialogInput: CustomDialogInput
|
||||
override fun getLayoutId(): Int = R.layout.fragment_general_black
|
||||
|
||||
companion object {
|
||||
fun newInstance(title: String) = BoxPickingFragment(title = title)
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
|
||||
binding.mainToolbar.toolbarTitle.text = title
|
||||
setEvents()
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
super.init()
|
||||
}
|
||||
|
||||
private fun setEvents() {
|
||||
binding.scanInput.visibility = VISIBLE
|
||||
binding.mainToolbar.backButton.setOnClickListener {
|
||||
ma.onMyBackPressed()
|
||||
}
|
||||
binding.scanInput.hint = getString(R.string.scanLabelExpedition)
|
||||
binding.scanInput.requestFocus()
|
||||
binding.scanInput.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||
|
||||
if (!binding.scanInput.text.isNullOrEmpty()) {
|
||||
|
||||
showScanBarcode(binding.scanInput.text.toString().toLong())
|
||||
|
||||
}
|
||||
binding.scanInput.setText("")
|
||||
ma.hideKeyboard(binding.scanInput)
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun showScanBarcode(expeditionFk: Long) {
|
||||
try {
|
||||
|
||||
customDialogInput.setTitle(getString(R.string.scanItem))
|
||||
.setOkButton(getString(R.string.accept)) {
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
viewModel.isBoxPickingInPrintOut(
|
||||
expeditionFk = expeditionFk,
|
||||
customDialogInput.getValue()
|
||||
)
|
||||
}
|
||||
customDialogInput.dismiss()
|
||||
}
|
||||
|
||||
.setKoButton(getString(R.string.cancel)) {
|
||||
customDialogInput.setValue("")
|
||||
customDialogInput.dismiss()
|
||||
|
||||
}.setValue("").show()
|
||||
|
||||
|
||||
customDialogInput.setFocusText()
|
||||
|
||||
customDialogInput.getEditText().setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||
|
||||
if (customDialogInput.getValue().isNotEmpty()) {
|
||||
viewModel.isBoxPickingInPrintOut(
|
||||
expeditionFk = expeditionFk,
|
||||
customDialogInput.getValue()
|
||||
)
|
||||
}
|
||||
customDialogInput.dismiss()
|
||||
binding.scanInput.requestFocus()
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
} catch (ex: Exception) {
|
||||
getString(R.string.errorInput)
|
||||
}
|
||||
}
|
||||
|
||||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
isBoxPickingInPrintOut.observe(viewLifecycleOwner) {
|
||||
|
||||
ma.messageWithSound(
|
||||
message = getString(R.string.errorInput),
|
||||
isError = !it,
|
||||
isPlayed = true,
|
||||
isToasted = null
|
||||
|
||||
)
|
||||
binding.scanInput.requestFocus()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package es.verdnatura.presentation.view.feature.boxPicking
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
import retrofit2.Response
|
||||
|
||||
class BoxPickingViewModel(val context: Context) : BaseViewModel(context) {
|
||||
|
||||
private val _isBoxPickingInPrintOut by lazy { MutableLiveData<Boolean>() }
|
||||
val isBoxPickingInPrintOut: LiveData<Boolean> = _isBoxPickingInPrintOut
|
||||
|
||||
private val _responseCode by lazy { MutableLiveData<String>() }
|
||||
val responseCode: LiveData<String> = _responseCode
|
||||
fun isBoxPickingOk(
|
||||
expeditionFk: Long, itemFk: Long
|
||||
|
||||
) {
|
||||
salix.isBoxPickingInPrintOut(
|
||||
filter = """{"where":{"expeditionFk":$expeditionFk,"itemFk":$itemFk}}"""
|
||||
).enqueue(object : SalixCallback<Any>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<Any>) {
|
||||
|
||||
_isBoxPickingInPrintOut.value = true
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
|
||||
_isBoxPickingInPrintOut.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun isBoxPickingInPrintOut(expeditionFk: Long, barcode: String) {
|
||||
salix.barcodesToItem(barcode).enqueue(object : SalixCallback<Int?>(context) {
|
||||
|
||||
override fun onSuccess(response: Response<Int?>) {
|
||||
|
||||
if (response.body() != null) {
|
||||
isBoxPickingOk(
|
||||
itemFk = response.body().toString().toLong(),
|
||||
expeditionFk = expeditionFk
|
||||
)
|
||||
} else {
|
||||
_isBoxPickingInPrintOut.value = false
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@ import androidx.lifecycle.map
|
|||
import com.google.gson.JsonObject
|
||||
import es.verdnatura.MobileApplication
|
||||
import es.verdnatura.domain.SalixCallback
|
||||
import es.verdnatura.domain.SilexCallback
|
||||
import es.verdnatura.domain.formatWithQuotes
|
||||
import es.verdnatura.domain.toast
|
||||
import es.verdnatura.presentation.base.BaseViewModel
|
||||
|
@ -343,7 +342,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
isChecked != "0",
|
||||
buyFk,
|
||||
isScanned!!
|
||||
)*/.enqueue(object : SilexCallback<Any>(context) {
|
||||
)*/.enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseSaleReplace.value = ResponseItemVO(
|
||||
isError = true,
|
||||
|
@ -387,7 +386,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
buyFk,
|
||||
itemShelvingFk,
|
||||
quantity,
|
||||
isScanned)*/.enqueue(object : SilexCallback<Any>(context) {
|
||||
isScanned)*/.enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseSaleTracking_mark.value = ResponseItemVO(
|
||||
isError = true,
|
||||
|
@ -756,7 +755,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
)
|
||||
)
|
||||
//silex.saleTrackingDel(saleFk)
|
||||
.enqueue(object : SilexCallback<Any>(context) {
|
||||
.enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseDel.value = ResponseItemVO(
|
||||
isError = true,
|
||||
|
@ -777,7 +776,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
|
|||
//Tarea 6276 OK
|
||||
salix.itemShelvingUpdateFromSale(hashMapOf("saleFk" to saleFk))
|
||||
// silex.itemShelving_updateFromSale(saleFk)
|
||||
.enqueue(object : SilexCallback<Any>(context) {
|
||||
.enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
_responseItemShelvingUpdate.value = ResponseItemVO(
|
||||
isError = true,
|
||||
|
|
|
@ -51,6 +51,7 @@ import es.verdnatura.presentation.view.component.CustomDialogMainActivity
|
|||
import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesFragment
|
||||
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardFragment
|
||||
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemProposalFragment
|
||||
import es.verdnatura.presentation.view.feature.boxPicking.BoxPickingFragment
|
||||
import es.verdnatura.presentation.view.feature.buffer.fragment.BufferFragment
|
||||
import es.verdnatura.presentation.view.feature.buffer.fragment.BufferLoadFragment
|
||||
import es.verdnatura.presentation.view.feature.buscaritem.fragment.BuscarItemFragment
|
||||
|
@ -479,7 +480,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
}
|
||||
}
|
||||
|
||||
fun delete_Fragments() {
|
||||
fun delete_Fragments() {
|
||||
fm.getFragments().forEach {
|
||||
val fragment: Fragment? = supportFragmentManager.findFragmentByTag(it.tag.toString())
|
||||
if (fragment != null) supportFragmentManager.beginTransaction().remove(fragment)
|
||||
|
@ -634,6 +635,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
getString(R.string.titleHistorical) -> {
|
||||
addFragmentOnTop(HistoricoArticuloFragment.newInstance(entryPoint.toInt()))
|
||||
}
|
||||
|
||||
getString(R.string.roadMapSettings) -> {
|
||||
addFragmentOnTop(RoadMapSettingsFragment.newInstance(param as RoadMapTruck))
|
||||
}
|
||||
|
@ -710,6 +712,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
getString(R.string.titleLogShelving) -> {
|
||||
addFragmentOnTop(ShelvingLogFragment.newInstance(item.title, LogType.SHELVING))
|
||||
}
|
||||
|
||||
getString(R.string.titleParkingTicketPrevia) -> {
|
||||
addFragmentOnTop(ShelvingLogFragment.newInstance(item.title, LogType.PREVIOUS))
|
||||
}
|
||||
|
@ -872,11 +875,14 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
addFragmentOnTop(TicketsFragment.newInstance(item.title, entryPoint))
|
||||
}
|
||||
|
||||
getString(R.string.reviewBoxPicking) -> {
|
||||
addFragmentOnTop(BoxPickingFragment.newInstance(item.title))
|
||||
}
|
||||
|
||||
getString(R.string.pickerHelper) -> {
|
||||
addFragmentOnTop(PickerHelperFragment.newInstance(item.title))
|
||||
}
|
||||
|
||||
|
||||
"PREITEMPICKERTEST" -> {
|
||||
addFragmentOnTop(
|
||||
CollectionFragmentPickerPreviousNew.newInstance(
|
||||
|
@ -1114,7 +1120,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
|
|||
if (!isError) {
|
||||
|
||||
if (isPlayed == true) (mpok?.start())
|
||||
if (isToasted!!) message.toast(this, Toast.LENGTH_LONG)
|
||||
if (isToasted != null && isToasted == true) message.toast(this, Toast.LENGTH_LONG)
|
||||
} else {
|
||||
|
||||
if (isPlayed == true) (mperror?.start())
|
||||
|
|
|
@ -380,7 +380,7 @@ class PackagingViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
fun getItemsPackaging(supplierId: Int, entryId: Int) {
|
||||
salix.getItemsPackaging(supplierId, entryId)
|
||||
.enqueue(object : SilexCallback<List<ItemSupplier>>(context) {
|
||||
.enqueue(object : SalixCallback<List<ItemSupplier>>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
val listError: ArrayList<ItemSupplier> = ArrayList()
|
||||
listError.add(
|
||||
|
|
|
@ -13,6 +13,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
|||
private val _pasillerositem by lazy { ArrayList<PasillerosItemVO>() }
|
||||
val pasillerositem: List<PasillerosItemVO>
|
||||
get() = _pasillerositem
|
||||
val userId = (contextApp as MobileApplication).userId
|
||||
|
||||
fun inititializeDefaultData() {
|
||||
|
||||
|
@ -434,8 +435,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
|||
)
|
||||
)
|
||||
|
||||
val userFk = (contextApp).userId
|
||||
if (userFk == 19591) {
|
||||
if (userId == 19591) {
|
||||
_pasillerositem.add(
|
||||
PasillerosItemVO(
|
||||
6,
|
||||
|
@ -548,7 +548,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
|||
)
|
||||
)
|
||||
)
|
||||
val userId = (contextApp as MobileApplication).userId
|
||||
|
||||
if (userId == 19591 || userId == 18404) {
|
||||
_pasillerositem.add(
|
||||
PasillerosItemVO(
|
||||
|
@ -602,6 +602,20 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
|||
)
|
||||
)
|
||||
|
||||
if (userId == 19591 || userId == 9) {
|
||||
_pasillerositem.add(
|
||||
PasillerosItemVO(
|
||||
1,
|
||||
R.drawable.ic_review_boxpicking,
|
||||
contextApp.getString(R.string.reviewBoxPicking),
|
||||
R.string.reviewBoxPicking,
|
||||
contextApp.getString(
|
||||
R.string.reviewBoxPicking
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
_pasillerositem.add(
|
||||
PasillerosItemVO(
|
||||
1,
|
||||
|
@ -616,6 +630,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
|||
|
||||
|
||||
|
||||
|
||||
_pasillerositem.add(
|
||||
PasillerosItemVO(
|
||||
7,
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp" android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="@color/verdnatura_pumpkin_orange">
|
||||
<path android:fillColor="@android:color/white"
|
||||
android:pathData="M508,562L734,336L678,278L508,448L422,364L366,420L508,562ZM320,720Q287,720 263.5,696.5Q240,673 240,640L240,160Q240,127 263.5,103.5Q287,80 320,80L800,80Q833,80 856.5,103.5Q880,127 880,160L880,640Q880,673 856.5,696.5Q833,720 800,720L320,720ZM320,640L800,640Q800,640 800,640Q800,640 800,640L800,160Q800,160 800,160Q800,160 800,160L320,160Q320,160 320,160Q320,160 320,160L320,640Q320,640 320,640Q320,640 320,640ZM160,880Q127,880 103.5,856.5Q80,833 80,800L80,240L160,240L160,800Q160,800 160,800Q160,800 160,800L720,800L720,880L160,880ZM320,160L320,160Q320,160 320,160Q320,160 320,160L320,640Q320,640 320,640Q320,640 320,640L320,640Q320,640 320,640Q320,640 320,640L320,160Q320,160 320,160Q320,160 320,160Z"/>
|
||||
</vector>
|
|
@ -229,7 +229,7 @@
|
|||
<string name="operation">Operación </string>
|
||||
<string name="closeOdrder">¿Estás seguro de cerrar el pedido?</string>
|
||||
<string name="confirm">Confirmar acción</string>
|
||||
<string name="scanItem">Escanea un artículo</string>
|
||||
<string name="scanItem">Escanea artículo</string>
|
||||
<string name="itemNotFound">No hemos podido encontrar el artículo. Revisa el sector.</string>
|
||||
<string name="errorOperation">Error al realizar la operación</string>
|
||||
<string name="scanLabelExpedition">Escanea expedición</string>
|
||||
|
@ -831,5 +831,6 @@
|
|||
<string name="listItems">\nLista de ítems:\n</string>
|
||||
<string name="errorParking">No se ha encontrado parking</string>
|
||||
<string name="scanParkingTxt">Escanea parking</string>
|
||||
<string name="reviewBoxPicking">Revisar sacado por cajas</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -831,5 +831,6 @@
|
|||
<string name="listItems">\nLista de ítems:\n</string>
|
||||
<string name="errorParking">No se ha encontrado parking</string>
|
||||
<string name="scanParkingTxt">Escanea parking</string>
|
||||
<string name="reviewBoxPicking">Revisar sacado por cajas</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -831,5 +831,6 @@
|
|||
<string name="listItems">\nLista de ítems:\n</string>
|
||||
<string name="errorParking">No se ha encontrado parking</string>
|
||||
<string name="scanParkingTxt">Escanea parking</string>
|
||||
<string name="reviewBoxPicking">Revisar sacado por cajas</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -264,7 +264,7 @@
|
|||
<string name="operation">Operation</string>
|
||||
<string name="closeOdrder">Are you sure to close the order ?</string>
|
||||
<string name="confirm">Confirm action</string>
|
||||
<string name="scanItem">Scan item</string>
|
||||
<string name="scanItem">Scan item</string>
|
||||
<string name="itemNotFound">Item not found. Review sector</string>
|
||||
<string name="errorOperation">Error to perform action</string>
|
||||
<string name="scanLabelExpedition">Scan expedition label</string>
|
||||
|
@ -833,5 +833,6 @@
|
|||
<string name="listItems">\nLista de ítems:\n</string>
|
||||
<string name="errorParking">No se ha encontrado parking</string>
|
||||
<string name="scanParkingTxt">Escanea parking</string>
|
||||
<string name="reviewBoxPicking">Revisar sacado por cajas</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue