feat: refs #8090 deleteEpxpedition
This commit is contained in:
parent
2ee835bbb9
commit
91f3da78cf
|
@ -27,7 +27,7 @@ class Expeditions(
|
||||||
|
|
||||||
class ExpeditionSalix(
|
class ExpeditionSalix(
|
||||||
val expeditionFk: Number,
|
val expeditionFk: Number,
|
||||||
val stateCode: String?,
|
val stateCode: String? = null,
|
||||||
val isScanned: Int? = 0
|
val isScanned: Int? = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,9 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
private val _responseFindExpeditionId by lazy { MutableLiveData<Number>() }
|
private val _responseFindExpeditionId by lazy { MutableLiveData<Number>() }
|
||||||
val responseFindExpeditionId: LiveData<Number> = _responseFindExpeditionId
|
val responseFindExpeditionId: LiveData<Number> = _responseFindExpeditionId
|
||||||
|
|
||||||
|
private val _responseDeleteExpedition by lazy { MutableLiveData<Boolean>() }
|
||||||
|
val responseDeleteExpedition: LiveData<Boolean> = _responseDeleteExpedition
|
||||||
|
|
||||||
private val _responseUpdateRoute by lazy { MutableLiveData<Boolean>() }
|
private val _responseUpdateRoute by lazy { MutableLiveData<Boolean>() }
|
||||||
val responseUpdateRoute: LiveData<Boolean>
|
val responseUpdateRoute: LiveData<Boolean>
|
||||||
get() = _responseUpdateRoute
|
get() = _responseUpdateRoute
|
||||||
|
@ -221,8 +224,6 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun expeditionStateAddSalix(expeditions: Any) {
|
fun expeditionStateAddSalix(expeditions: Any) {
|
||||||
|
|
||||||
// No se quita ResponseItem ya que en caso de fallo hay que guardar datos
|
|
||||||
salix.addExpeditionState(expeditions).enqueue(object : SalixCallback<Unit>(context) {
|
salix.addExpeditionState(expeditions).enqueue(object : SalixCallback<Unit>(context) {
|
||||||
override fun onSuccess(response: Response<Unit>) {
|
override fun onSuccess(response: Response<Unit>) {
|
||||||
super.onSuccess(response)
|
super.onSuccess(response)
|
||||||
|
@ -244,7 +245,6 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findExpedition(expedition: Number, expeditionStateId: Number) {
|
fun findExpedition(expedition: Number, expeditionStateId: Number) {
|
||||||
println("Expedition $expedition")
|
|
||||||
salix.findExpedition(
|
salix.findExpedition(
|
||||||
filter = """{"where":
|
filter = """{"where":
|
||||||
{
|
{
|
||||||
|
@ -265,6 +265,19 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun deleteExpedition(expeditionIds: ArrayList<Number>) {
|
||||||
|
salix.deleteExpedition(
|
||||||
|
hashMapOf("expeditionIds" to expeditionIds)
|
||||||
|
).enqueue(object : SalixCallback<Any>(context) {
|
||||||
|
override fun onSuccess(response: Response<Any>) {
|
||||||
|
super.onSuccess(response)
|
||||||
|
_responseDeleteExpedition.value = true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun getExpeditionStateId(stateCode: String) {
|
fun getExpeditionStateId(stateCode: String) {
|
||||||
|
|
||||||
salix.getExpeditionStateTypeId(
|
salix.getExpeditionStateTypeId(
|
||||||
|
@ -445,22 +458,21 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isBoxPickingInPrintOut(expeditionFk: Long, barcode: String) {
|
fun isBoxPickingInPrintOut(expeditionFk: Long, barcode: String) {
|
||||||
getItemFromBarcodeUseCase.execute(barcode)
|
getItemFromBarcodeUseCase.execute(barcode).enqueue(object : SalixCallback<Int?>(context) {
|
||||||
.enqueue(object : SalixCallback<Int?>(context) {
|
|
||||||
|
|
||||||
override fun onSuccess(response: Response<Int?>) {
|
override fun onSuccess(response: Response<Int?>) {
|
||||||
|
|
||||||
if (response.body() != null) {
|
|
||||||
isBoxPickingOk(
|
|
||||||
itemFk = response.body().toString().toLong(),
|
|
||||||
expeditionFk = expeditionFk
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
_responseCode.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (response.body() != null) {
|
||||||
|
isBoxPickingOk(
|
||||||
|
itemFk = response.body().toString().toLong(),
|
||||||
|
expeditionFk = expeditionFk
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
_responseCode.value = false
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isBoxPickingOk(
|
fun isBoxPickingOk(
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.paletizador.fragment
|
||||||
|
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.KeyEvent
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentAutomaticAddExpeditionBinding
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnAutomaticItemClickListener
|
||||||
|
import es.verdnatura.presentation.common.itemScanValue
|
||||||
|
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionSalix
|
||||||
|
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.ubicador.adapter.AutomaticAdapter
|
||||||
|
|
||||||
|
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
||||||
|
class ExpeditionDeleteFragment(var title: String = "") :
|
||||||
|
BaseFragment<FragmentAutomaticAddExpeditionBinding, DeliveryViewModel>(
|
||||||
|
DeliveryViewModel::class
|
||||||
|
) {
|
||||||
|
|
||||||
|
private var adapter: AutomaticAdapter? = null
|
||||||
|
private var contador = 0
|
||||||
|
private var isScanned = false
|
||||||
|
private val listExpeditions: ArrayList<ExpeditionSalix> = arrayListOf()
|
||||||
|
private var expeditionStateTypeId: Number = 0
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(title: String) = ExpeditionDeleteFragment(title = title)
|
||||||
|
|
||||||
|
fun newInstance() = ExpeditionDeleteFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_automatic_add_expedition
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
ma.hideBottomNavigation(View.GONE)
|
||||||
|
binding.mainToolbar.toolbarTitle.text = title
|
||||||
|
setEvents()
|
||||||
|
setViews()
|
||||||
|
setToolBar()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setToolBar() {
|
||||||
|
binding.mainToolbar.toolbarSubtitle.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setSubtitle() {
|
||||||
|
binding.mainToolbar.toolbarSubtitle.text =
|
||||||
|
getString(R.string.countNumber, getString(R.string.label), listExpeditions.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setViews() {
|
||||||
|
adapter =
|
||||||
|
AutomaticAdapter(listExpeditions.map { it.expeditionFk.toLong() } as ArrayList<Long>,
|
||||||
|
object : OnAutomaticItemClickListener {
|
||||||
|
override fun onAutomaticItemClickListener(position: Int) {
|
||||||
|
|
||||||
|
if (listExpeditions.size > position) {
|
||||||
|
listExpeditions.removeAt(position)
|
||||||
|
}
|
||||||
|
adapter!!.updateItems(listExpeditions.map { it.expeditionFk.toLong() } as ArrayList<Long>)
|
||||||
|
setSubtitle()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
binding.itemsRecyclerview.adapter = adapter
|
||||||
|
binding.itemsRecyclerview.layoutManager =
|
||||||
|
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setEvents() {
|
||||||
|
binding.editMatricula.requestFocus()
|
||||||
|
binding.editMatricula.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
isScanned =
|
||||||
|
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||||
|
if (binding.editMatricula.text.toString().isNotEmpty()) {
|
||||||
|
try {
|
||||||
|
val itemScaned = itemScanValue(
|
||||||
|
textScanned_filterDouble(binding.editMatricula.text.toString()),
|
||||||
|
arrayOf("expedition"),
|
||||||
|
"id"
|
||||||
|
).toString().toLong()
|
||||||
|
if (!(listExpeditions.any { it.expeditionFk == itemScaned })) {
|
||||||
|
listExpeditions.add(
|
||||||
|
ExpeditionSalix(
|
||||||
|
expeditionFk = itemScaned,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
binding.itemsRecyclerview.scrollToPosition(0)
|
||||||
|
adapter!!.updateItems(listExpeditions.map { it.expeditionFk.toLong() } as ArrayList<Long>)
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
message = "Caja ya escaneada",
|
||||||
|
isError = true,
|
||||||
|
isPlayed = true,
|
||||||
|
isToasted = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
ma.messageWithSound(ex.message.toString(), isError = true, isPlayed = true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.editMatricula.setText("")
|
||||||
|
ma.hideKeyboard(binding.editMatricula)
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
} else {
|
||||||
|
ma.messageWithSound(
|
||||||
|
getString(R.string.diferentAction), isError = true, isPlayed = true
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return@setOnEditorActionListener false
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.buttonFinalizar.setOnClickListener {
|
||||||
|
if (listExpeditions.isNotEmpty()) viewModel.deleteExpedition(listExpeditions.map { it.expeditionFk } as ArrayList<Number>) else ma.onMyBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.mainToolbar.backButton.setOnClickListener {
|
||||||
|
ma.onMyBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel) {
|
||||||
|
responseDeleteExpedition.observe(viewLifecycleOwner) {
|
||||||
|
ma.onMyBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,11 +5,13 @@ import android.content.Context
|
||||||
import es.verdnatura.MobileApplication
|
import es.verdnatura.MobileApplication
|
||||||
import es.verdnatura.R
|
import es.verdnatura.R
|
||||||
import es.verdnatura.domain.ConstAndValues.RESERVATIONMODE
|
import es.verdnatura.domain.ConstAndValues.RESERVATIONMODE
|
||||||
|
import es.verdnatura.domain.ConstAndValues.SECTORISONRESERVATIONMODE
|
||||||
import es.verdnatura.domain.SalixCallback
|
import es.verdnatura.domain.SalixCallback
|
||||||
import es.verdnatura.presentation.base.BaseViewModel
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
import es.verdnatura.presentation.view.feature.pasillero.model.CodeWorkerAction
|
import es.verdnatura.presentation.view.feature.pasillero.model.CodeWorkerAction
|
||||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
import es.verdnatura.presentation.view.feature.pasillero.model.WorkerActionSalix
|
import es.verdnatura.presentation.view.feature.pasillero.model.WorkerActionSalix
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
|
|
||||||
class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
||||||
|
@ -21,6 +23,18 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
||||||
val userId = (contextApp as MobileApplication).userId
|
val userId = (contextApp as MobileApplication).userId
|
||||||
private val isOnReservationMode =
|
private val isOnReservationMode =
|
||||||
(contextApp as MobileApplication).dataStoreApp.readDataStoreKey<Boolean>(RESERVATIONMODE)
|
(contextApp as MobileApplication).dataStoreApp.readDataStoreKey<Boolean>(RESERVATIONMODE)
|
||||||
|
private val isOnReservationModeSector =
|
||||||
|
(contextApp as MobileApplication).dataStoreApp.readDataStoreKey<Boolean?>(
|
||||||
|
SECTORISONRESERVATIONMODE
|
||||||
|
)
|
||||||
|
private var existSectorOnReservationMode: Boolean = false
|
||||||
|
|
||||||
|
init {
|
||||||
|
runBlocking {
|
||||||
|
existSectorOnReservationMode =
|
||||||
|
(contextApp as MobileApplication).dataStoreApp.isPreferenceExists((SECTORISONRESERVATIONMODE))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun inititializeDefaultData() {
|
fun inititializeDefaultData() {
|
||||||
workerActivityAdd(CodeWorkerAction.STORAGE)
|
workerActivityAdd(CodeWorkerAction.STORAGE)
|
||||||
|
@ -257,20 +271,21 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
||||||
R.string.titleCorridorsDescrip
|
R.string.titleCorridorsDescrip
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
//precontrol
|
//sacador
|
||||||
_pasillerositem.add(
|
if (isOnReservationModeSector == true || (!existSectorOnReservationMode && isOnReservationMode)) {
|
||||||
PasillerosItemVO(
|
|
||||||
R.drawable.ic_picker_ui, R.string.titlePickers, R.string.titlePickersDescrip
|
|
||||||
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if (userId == 19591 || isOnReservationMode) {
|
|
||||||
_pasillerositem.add(
|
_pasillerositem.add(
|
||||||
PasillerosItemVO(
|
PasillerosItemVO(
|
||||||
R.drawable.ic_picker_ui, R.string.sacador_test, R.string.sacador_test
|
R.drawable.ic_picker_ui, R.string.sacador_test, R.string.sacador_test
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
_pasillerositem.add(
|
||||||
|
PasillerosItemVO(
|
||||||
|
R.drawable.ic_picker_ui, R.string.titlePickers, R.string.titlePickersDescrip
|
||||||
|
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
if (userId == 19591) {
|
if (userId == 19591) {
|
||||||
_pasillerositem.add(
|
_pasillerositem.add(
|
||||||
|
@ -392,9 +407,8 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
||||||
|
|
||||||
fun inititializeDefaultPrevia() {
|
fun inititializeDefaultPrevia() {
|
||||||
workerActivityAdd(CodeWorkerAction.PREVIOUS)
|
workerActivityAdd(CodeWorkerAction.PREVIOUS)
|
||||||
//lolass
|
|
||||||
if (isOnReservationMode) {
|
if (isOnReservationModeSector == true || (!existSectorOnReservationMode && isOnReservationMode)) {
|
||||||
// if (userId == 19591 || userId == 18404 || userId == 9) {
|
|
||||||
_pasillerositem.add(
|
_pasillerositem.add(
|
||||||
PasillerosItemVO(
|
PasillerosItemVO(
|
||||||
R.drawable.ic_previous_presacador,
|
R.drawable.ic_previous_presacador,
|
||||||
|
@ -402,7 +416,6 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
||||||
R.string.titlePickerDescrip
|
R.string.titlePickerDescrip
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
//}
|
|
||||||
} else {
|
} else {
|
||||||
_pasillerositem.add(
|
_pasillerositem.add(
|
||||||
PasillerosItemVO(
|
PasillerosItemVO(
|
||||||
|
@ -466,7 +479,13 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_pasillerositem.add(
|
||||||
|
PasillerosItemVO(
|
||||||
|
R.drawable.ic_delete_expedition,
|
||||||
|
R.string.deleteExpedition,
|
||||||
|
R.string.deleleExpeditionDescrip
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
_pasillerositem.add(
|
_pasillerositem.add(
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/colorPrimary">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M560,680L120,680L120,280L840,280L840,400Q826,400 811,400Q796,400 780,400Q775,400 770,400Q765,400 760,400L760,360L200,360L200,600L560,600Q560,605 560,610Q560,615 560,620Q560,636 560,651Q560,666 560,680ZM200,600L200,600L200,360L200,360L200,600Q200,600 200,600Q200,600 200,600ZM640,704L724,620L640,536L696,480L780,564L864,480L920,536L837,620L920,704L864,760L780,677L696,760L640,704Z"/>
|
||||||
|
</vector>
|
Loading…
Reference in New Issue