refs #6861 feat:reservas previa

This commit is contained in:
Sergio De la torre 2024-04-23 08:01:59 +02:00
parent 14915266d4
commit afc9488f76
7 changed files with 1501 additions and 345 deletions

View File

@ -8,6 +8,7 @@ object ConstAndValues {
const val ON_PREPARATION = "ON_PREPARATION" const val ON_PREPARATION = "ON_PREPARATION"
const val PRESACADOR = "PRESACADOR" //PREITEMPICKER const val PRESACADOR = "PRESACADOR" //PREITEMPICKER
const val PREITEMPICKER = "PREITEMPICKER" const val PREITEMPICKER = "PREITEMPICKER"
const val PREITEMPICKERTEST = "PREITEMPICKERTEST"
const val SERIALNUMBER = "SERIALNUMBER" const val SERIALNUMBER = "SERIALNUMBER"
const val ON_CHECKING = "ON_CHECKING" const val ON_CHECKING = "ON_CHECKING"
const val PRECHECKER = "PRECHECKER" const val PRECHECKER = "PRECHECKER"

View File

@ -2,14 +2,10 @@ package es.verdnatura.presentation.view.feature.collection.fragment
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.content.Intent
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.media.MediaPlayer import android.media.MediaPlayer
import android.net.Uri
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.InputType import android.text.InputType
import android.util.Log.d
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
@ -17,8 +13,6 @@ import android.view.inputmethod.EditorInfo
import android.widget.EditText import android.widget.EditText
import android.widget.ImageView import android.widget.ImageView
import android.widget.Toast import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson import com.google.gson.Gson
@ -64,7 +58,7 @@ import org.json.JSONObject
class CollectionFragmentPickerNew( class CollectionFragmentPickerNew(
var collection: CollectionTicket, var collection: CollectionTicket,
var type: String = SACADOR, var type: String = SACADOR,
var hasPickingOrder: Boolean = false private var hasPickingOrder: Boolean = false
) : BaseFragment<FragmentCollectionNewBinding, CollectionViewModel>( ) : BaseFragment<FragmentCollectionNewBinding, CollectionViewModel>(
CollectionViewModel::class CollectionViewModel::class
) { ) {
@ -107,11 +101,8 @@ class CollectionFragmentPickerNew(
companion object { companion object {
fun newInstance( fun newInstance(
collection: CollectionTicket, collection: CollectionTicket, type: String, hasPickingOrder: Boolean = false
type: String, ) = CollectionFragmentPickerNew(collection, type, hasPickingOrder)
hasPickingOrder: Boolean = false
) =
CollectionFragmentPickerNew(collection, type, hasPickingOrder)
} }
override fun onAttach(context: Context) { override fun onAttach(context: Context) {
@ -143,7 +134,6 @@ class CollectionFragmentPickerNew(
customDialogThreeButtons = CustomDialogThreeButtons(requireContext()) customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext()) customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext())
ma.hideBottomNavigation(View.GONE) ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = View.VISIBLE
setEvents() setEvents()
setToolBar() setToolBar()
@ -185,15 +175,13 @@ class CollectionFragmentPickerNew(
val iconUpdate = ImageView(context) val iconUpdate = ImageView(context)
iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp) iconUpdate.setImageResource(R.drawable.ic_autorenew_black_24dp)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp) iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp) iconViewCollection.tooltipText = getTooltip(R.drawable.ic_collection)
iconViewCollection.tooltipText = getTooltip(R.drawable.ic_collection) iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
iconPhone.tooltipText = getTooltip(R.drawable.phone_call) iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp) iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
}
listIcons.add(iconPrint) listIcons.add(iconPrint)
listIcons.add(iconAdd) listIcons.add(iconAdd)
listIcons.add(iconUpdate) listIcons.add(iconUpdate)
@ -229,16 +217,14 @@ class CollectionFragmentPickerNew(
} }
private fun markPrevia(saleGroupScanned: String): Boolean { private fun markPrevia(saleGroupScanned: String): Boolean {
println("Sacador saleGroup $saleGroupScanned ")
try { try {
for (indice in sales.indices) { for (indice in sales.indices) {
println("Sacador saleGroup ${sales[indice].saleGroupFk}")
if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) { if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) {
println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}")
viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt()) viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt())
positionMarkPrevia = indice positionMarkPrevia = indice
return true
mpok!!.start() mpok!!.start()
return true
} }
} }
@ -248,27 +234,6 @@ class CollectionFragmentPickerNew(
return false return false
} }
/* private fun getCollection() {
binding.splashProgress.visibility = View.VISIBLE
if (!buttonPushedGetCollection) {
viewModel.collection_get(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
print = "0",
type
)
buttonPushedGetCollection = true
} else {
viewModel.collectionTicketGetSalix(
lastScanned,
print = false
)
buttonPushedGetCollection = false
}
lastScanned = collection.collectionFk
}*/
private fun scanRequest() { private fun scanRequest() {
binding.scanInput.requestFocus() binding.scanInput.requestFocus()
hideKeyboards() hideKeyboards()
@ -293,7 +258,7 @@ class CollectionFragmentPickerNew(
binding.scanInput.requestFocus() binding.scanInput.requestFocus()
binding.scanInput.setOnEditorActionListener { v, actionId, event -> binding.scanInput.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED) if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED)
if (!binding.scanInput.text.toString().isNullOrEmpty()) { if (binding.scanInput.text.toString().isNotEmpty()) {
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString())) binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
isScanned = isScanned =
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
@ -331,15 +296,7 @@ class CollectionFragmentPickerNew(
binding.collectionSwipe.setOnRefreshListener { binding.collectionSwipe.setOnRefreshListener {
isMarking = false isMarking = false
binding.collectionSwipe.isRefreshing = false binding.collectionSwipe.isRefreshing = false
binding.splashProgress.visibility = View.VISIBLE
updateScreen() updateScreen()
/* viewModel.collectionTicketGet(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
print = "0",
type
)*/
buttonPushedGetCollection = false buttonPushedGetCollection = false
binding.collectionSwipe.isRefreshing = false binding.collectionSwipe.isRefreshing = false
@ -350,36 +307,17 @@ class CollectionFragmentPickerNew(
try { try {
requireActivity().hideKeyboard() requireActivity().hideKeyboard()
} catch (e: Exception) { } catch (e: Exception) {
e.toast(requireContext())
} }
} }
@RequiresApi(Build.VERSION_CODES.O)
override fun observeViewModel() { override fun observeViewModel() {
with(viewModel) { with(viewModel) {
binding.splashProgress.visibility = View.GONE
/* collectionTicketList.observe(viewLifecycleOwner, Observer {
if (!it.isError) {
if (it.tickets.isNotEmpty()) {
//collection = it
createCollectionList()
workerFkFromTicket = it.tickets.get(0).sales.get(0).workerFk
} else {
binding.mainToolbar.toolbarSubtitle.text = "0/0"
}
} else {
customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage)
.setOkButton(getString(R.string.accept)) {
customDialog.dismiss()
if (activity != null) ma.onMyBackPressed()
}.show()
}
})*/
loadCollectionTicketSalix.observe(viewLifecycleOwner) { event -> loadCollectionTicketSalix.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull { event.getContentIfNotHandled().notNull {
binding.splashProgress.visibility = View.GONE //
if (!it.isError) { if (!it.isError) {
if (it.tickets.isNotEmpty()) { if (it.tickets.isNotEmpty()) {
@ -406,49 +344,22 @@ class CollectionFragmentPickerNew(
} }
} }
/* collectionTicketSalix.observe(viewLifecycleOwner, Observer { responseExistsItemShelvingSale.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
if (!it.isError) {
if (it.tickets.isNotEmpty()) {
collection = it
createCollectionList()
workerFkFromTicket = if (it.tickets[0].sales.isNotEmpty()) {
it.tickets[0].sales[0].workerFk.toString()
} else {
""
}
} else {
binding.mainToolbar.toolbarSubtitle.text = "0/0"
}
} else {
customDialog.setTitle(getString(R.string.error)).setDescription(it.errorMessage)
.setOkButton(getString(R.string.accept)) {
customDialog.dismiss()
if (activity != null) ma.onMyBackPressed()
}.show()
}
})*/
responseExistsItemShelvingSale.observe(viewLifecycleOwner, Observer {
if (!goBack) { if (!goBack) {
if (it.exists) { if (it.exists) {
markLine(it.position, it.quantity, true) markLine(it.position, it.quantity, true)
} else { } else {
"Actualizando las líneas porque la reserva está modificada".toast( getString(R.string.updateSalesReserve).toast(
requireContext() requireContext()
) )
viewModel.collectionTicketGetSalix(collection.collectionFk, false) viewModel.collectionTicketGetSalix(collection.collectionFk, false)
} }
} }
}) }
responseParking.observe(viewLifecycleOwner, Observer { responseParking.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
if (!goBack) { if (!goBack) {
binding.splashProgress.visibility = View.GONE
ma.messageWithSound( ma.messageWithSound(
if (it.isError) it.errorMessage else getString(R.string.Aparcado), if (it.isError) it.errorMessage else getString(R.string.Aparcado),
it.isError, it.isError,
@ -456,24 +367,23 @@ class CollectionFragmentPickerNew(
) )
} }
}) }
responseCollectionAddItem.observe(viewLifecycleOwner, Observer { responseCollectionAddItem.observe(viewLifecycleOwner) {
if (!goBack) { if (!goBack) {
updateScreen() updateScreen()
goBack = false goBack = false
} }
}) }
responsePrint.observe(viewLifecycleOwner, Observer { responsePrint.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
if (!goBack) { if (!goBack) {
if (it.isError) { if (it.isError) {
ma.messageWithSound( ma.messageWithSound(
it.errorMessage, it.isError, true it.errorMessage, isError = true, isPlayed = true
) )
} else { } else {
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>( (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
@ -484,16 +394,15 @@ class CollectionFragmentPickerNew(
} }
} }
}) }
responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner, Observer { responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
if (it.isError) { if (it.isError) {
ma.messageWithSound( ma.messageWithSound(
if (it.isError) it.errorMessage else getString(R.string.confirmReserv), it.errorMessage,
it.isError, isError = true,
it.isError isPlayed = true
) )
} }
if (!it.isError) { if (!it.isError) {
@ -505,36 +414,32 @@ class CollectionFragmentPickerNew(
) )
} }
}) }
responseItemShelvingSale.observe(viewLifecycleOwner, Observer { responseItemShelvingSale.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
myGroupList[positionConfirm].isPicked = 1 myGroupList[positionConfirm].isPicked = 1
myGroupList[positionConfirm].reservedQuantity = quantityConfirm myGroupList[positionConfirm].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix( viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false collection.collectionFk, print = false
) )
lm!!.scrollToPositionWithOffset(positionConfirm, 0) lm!!.scrollToPositionWithOffset(positionConfirm, 0)
//saleAdapter!!.notifyDataSetChanged()
ma.messageWithSound( ma.messageWithSound(
"Confirmada acción", it.isError, !it.isError getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
) )
}) }
responseItemShelvingSaleUnPicked.observe(viewLifecycleOwner, Observer { responseItemShelvingSaleUnPicked.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
myGroupList[positionUnmarked].isPicked = 1 myGroupList[positionUnmarked].isPicked = 1
myGroupList[positionUnmarked].reservedQuantity = quantityConfirm myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix( viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false collection.collectionFk, print = false
) )
lm!!.scrollToPositionWithOffset(positionUnmarked, 0) lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
//saleAdapter!!.notifyDataSetChanged()
ma.messageWithSound( ma.messageWithSound(
"Confirmada acción", it.isError, !it.isError getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
) )
}) }
responseItemShelvingSaleGroup.observe(viewLifecycleOwner, Observer { responseItemShelvingSaleGroup.observe(viewLifecycleOwner) {
viewModel.collectionTicketGetSalix( viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false collection.collectionFk, print = false
@ -542,12 +447,11 @@ class CollectionFragmentPickerNew(
lm!!.scrollToPositionWithOffset(positionMarkPrevia, 0) lm!!.scrollToPositionWithOffset(positionMarkPrevia, 0)
ma.messageWithSound( ma.messageWithSound(
"Previa recogida", it.isError, !it.isError getString(R.string.previousCollected), it.isError, !it.isError
) )
}) }
responseCode.observe(viewLifecycleOwner, Observer { responseCode.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE
if (!goBack2) { if (!goBack2) {
if (it.isError) { if (it.isError) {
customDialog.setTitle(getString(R.string.error)) customDialog.setTitle(getString(R.string.error))
@ -563,7 +467,6 @@ class CollectionFragmentPickerNew(
mpok?.start() mpok?.start()
onQuantityOfShelvingSelected(itemShelvingFkStored) onQuantityOfShelvingSelected(itemShelvingFkStored)
} else { } else {
var value = customDialogList.getValueTwo()
customDialogList.setValueTwo("") customDialogList.setValueTwo("")
if (it.response.isBlank() || it.response.isEmpty()) { if (it.response.isBlank() || it.response.isEmpty()) {
showErrorMessage(text = getString(R.string.codeNotExist)) showErrorMessage(text = getString(R.string.codeNotExist))
@ -580,30 +483,16 @@ class CollectionFragmentPickerNew(
goBack2 = false goBack2 = false
})
}
}
private fun callPicker(extensionNumber: String) {
try {
val intent = Intent(Intent.ACTION_DIAL).apply {
data = Uri.parse("tel:$extensionNumber")
} }
startActivity(intent)
} catch (e: Exception) {
// d("VERDNATURA::" + e.message)
}
}
} }
private fun createCollectionList() { private fun createCollectionList() {
state = 0 state = 0
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString() binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
binding.splashProgress.visibility = View.GONE
collection.map(requireContext()) collection.map(requireContext())
var salesList: ArrayList<Sale> = ArrayList() val salesList: ArrayList<Sale> = ArrayList()
tickets = ArrayList() tickets = ArrayList()
var observations = "" var observations = ""
@ -611,7 +500,7 @@ class CollectionFragmentPickerNew(
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO") val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
collection.tickets.forEach { ticket -> collection.tickets.forEach { ticket ->
if (!observations.isNullOrEmpty()) observations = if (observations.isNotEmpty()) observations =
observations + " " + ticket.observations observations + " " + ticket.observations
ticket.sales.forEach { sale -> ticket.sales.forEach { sale ->
@ -627,11 +516,6 @@ class CollectionFragmentPickerNew(
} }
sales = salesList.sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk }) sales = salesList.sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
for (s in sales) {
println("Sacador sale: ${s.saleFk} saleGRoup: ${s.saleGroupFk} item : ${s.itemFk}")
}
//quitar comentarios FALTA AGRUPAR LAS PREVIAS
myGroupList = myGroupList =
groupSaleGroup(salesList).sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk }) groupSaleGroup(salesList).sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
saleAdapter = SaleAdapterNew( saleAdapter = SaleAdapterNew(
@ -646,10 +530,8 @@ class CollectionFragmentPickerNew(
if (sale.isPicked == 1) { if (sale.isPicked == 1) {
showErrorMessage( showErrorMessage(
title = getString(R.string.info), title = getString(R.string.info),
text = "Tienes que desmarcar la línea para poder modificar la cantidad" text = getString(R.string.unmarkForModify)
) )
} else {
// showQuantityDialog(index)
} }
} }
@ -658,34 +540,16 @@ class CollectionFragmentPickerNew(
} }
}, },
object : OnSaleClickSaleListener { object : OnSaleClickSaleListener {
override fun onSaleClick(mysale: Sale) { override fun onSaleClick(mySale: Sale) {
myGroupList.forEachIndexed { index, sale -> myGroupList.forEachIndexed { index, sale ->
//sales.forEachIndexed { index, sale ->
// println("Sacador la sale es ${sale.saleFk}")
// println("Sacador la sale picked es ${sale.isPicked}")
// println("Sacador la sale group es ${sale.saleGroupFk}")
// println("Sacador la sale reserved es ${sale.reservedQuantity}")
if (sale.itemShelvingSaleFk == 0) {
println("Sacador Que hacemos en este caso ?? ")
} else {
if (sale.itemShelvingSaleFk == mysale.itemShelvingSaleFk) {
println("Sacador **** itemShelvingSale es ${sale.itemShelvingSaleFk}")
println("Sacador **** isPicked es ${sale.isPicked}")
println("Sacador **** saleGroup es ${sale.saleGroupFk}")
//println("Sacador la sale es ${sale.saleFk}")
//println("Sacador la sale picked es ${sale.isPicked}")
//println("Sacador la sale group es ${sale.saleGroupFk}")
//println("Sacador la sale reserved es ${sale.reservedQuantity}")
//println("Sacador la sale dentro es ${sale.saleFk}")
if (sale.isPicked != 1 && sale.saleGroupFk == null) {
println("Sacador **** showScanner")
showScanner(index, sale)
} else {
println("Sacador **** desmarcar")
unMarkLine(index, myGroupList[index])
}
if (sale.itemShelvingSaleFk == mySale.itemShelvingSaleFk) {
if (sale.isPicked != 1 && sale.saleGroupFk == null) {
showScanner(index, sale)
} else {
unMarkLine(index, myGroupList[index])
} }
} }
} }
@ -699,20 +563,18 @@ class CollectionFragmentPickerNew(
object : OnPackingClickSaleListener { object : OnPackingClickSaleListener {
override fun onPackingClick(sale: Sale) { override fun onPackingClick(sale: Sale) {
goBack = true goBack = true
println("ubicador")
if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener( if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
PasillerosItemVO( PasillerosItemVO(
title = getString(R.string.titleUbicator), title = getString(R.string.titleUbicator),
), entryPoint = sale.code!! ), entryPoint = sale.code
) )
} }
}, },
object : OnTicketClickSaleListener { object : OnTicketClickSaleListener {
override fun onTicketClickListener(sale: Sale) { override fun onTicketClickListener(sale: Sale) {
var entryPoint = Gson().toJson( val entryPoint = Gson().toJson(
mutableMapOf( mutableMapOf(
"entryPoint" to sale.ticketFk, "entryPoint" to sale.ticketFk, "web" to "${
"web" to "${
mobileApplication.dataStoreApp.readDataStoreKey<String>( mobileApplication.dataStoreApp.readDataStoreKey<String>(
BASEURLSALIX BASEURLSALIX
) )
@ -735,7 +597,7 @@ class CollectionFragmentPickerNew(
binding.fragmentSacadorCollections.layoutManager = lm binding.fragmentSacadorCollections.layoutManager = lm
setTotalLines() setTotalLines()
setStoredPosition(true) setListPosition()
setScrollListener(lm!!) setScrollListener(lm!!)
printObservations(observations) printObservations(observations)
} }
@ -767,13 +629,18 @@ class CollectionFragmentPickerNew(
if (isOk) { if (isOk) {
//Se ha escanado un ticket y se ha marcado la previa //Se ha escanado un ticket y se ha marcado la previa
ma.messageWithSound(
getString(R.string.previousCollected),
isPlayed = false,
isError = false,
isToasted = true
)
} else { } else {
//Se busca la matricula en las lineas //Se busca la matricula en las lineas
for (indice in myGroupList.indices) { for (indice in myGroupList.indices) {
if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) { if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) {
mpok!!.start() mpok!!.start()
isOk = true isOk = true
positionMarkPrevia = indice
printShelvingResult(indice) printShelvingResult(indice)
break break
} }
@ -794,8 +661,6 @@ class CollectionFragmentPickerNew(
} }
private fun findSale(txtscan: String, position: Int, sale: Sale) { private fun findSale(txtscan: String, position: Int, sale: Sale) {
println("Sacador La position es $position")
println("Sacador El escaneado es $txtscan y el code ${sale.code}")
storedPosition = position storedPosition = position
@ -822,63 +687,19 @@ class CollectionFragmentPickerNew(
myGroupList[position].itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty myGroupList[position].itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty
) )
//nuevo tema agrupacion sales val mySale = sales[position].itemShelvingSaleFk
//checkStateParent()
// var mySale = sales[position].saleFk Ordenar setPosition
var mySale = sales[position].itemShelvingSaleFk
for (indice in myGroupList.indices) { for (indice in myGroupList.indices) {
if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) { if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) {
d("VERDNATURA::", "la pos del index de la sale es" + indice)
storedBackPosition = indice storedBackPosition = indice
} }
} }
//setTotalLines()
} }
//Tarea #4371 private fun setListPosition() {
private fun checkStateParent() {
for (s in myGroupList) {
if (s.isParent) {
var totalLines = s.sonSales.size
var isPreviousPrepared = s.sonSales.filter { it.semaphore == "1" }.size
var isPrepared = s.sonSales.filter { it.semaphore == "2" }.size
var isControlled = s.sonSales.filter { it.semaphore == "1" }.size
var isPreControlled = s.sonSales.filter { it.semaphore == "4" }.size/* if (totalLines == isPreviousPrepared) {
s.isPreviousPrepared = "1"
} else {
s.isPreviousPrepared = "0"
}
if (totalLines == isPrepared) {
s.isPrepared = "1"
} else {
s.isPrepared = "0"
}
if (totalLines == isControlled) {
s.isControlled = "1"
} else {
s.isControlled = "0"
}
if (totalLines == isPreControlled) {
s.isPreControlled = "1"
} else {
s.isPreControlled = "0"
}
*/
}
}
}
private fun setListPosition(position: Int, isFromBack: Boolean) {
d("VERDNATURA::", "Vamos a la pos" + storedBackPosition)
if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos. if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos.
for (indice in myGroupList.indices) { for (indice in myGroupList.indices) {
if (myGroupList[indice].isPicked == 0) { if (myGroupList[indice].isPicked == 0) {
//storedPosition = indice
lm!!.scrollToPositionWithOffset(indice - 1, 0) lm!!.scrollToPositionWithOffset(indice - 1, 0)
break break
} }
@ -897,19 +718,10 @@ class CollectionFragmentPickerNew(
) )
).setOkButton(getString(R.string.unmark)) { ).setOkButton(getString(R.string.unmark)) {
if (!sale.isParent && sale.reservedQuantity == 0 && sale.originalQuantity != sale.saleQuantity) { if (!sale.isParent && sale.reservedQuantity == 0 && sale.originalQuantity != sale.saleQuantity) {
"No es posible desmarcar. Hablar con responsable almacén".toast(requireContext()) getString(R.string.unmarkError).toast(requireContext())
} else { } else {
/* saleAdapter!!.notifyDataSetChanged()
var mySale = sale.saleFk
for (indice in myGroupList.indices) {
if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) {
d("VERDNATURA::", "la pos del index de la sale es" + indice)
storedBackPosition = indice
}
}*/
storedBackPosition = position storedBackPosition = position
setListPosition(position, false) setListPosition()
viewModel.itemShelvingSaleUnpicked(myGroupList[position].itemShelvingSaleFk) viewModel.itemShelvingSaleUnpicked(myGroupList[position].itemShelvingSaleFk)
sale.isPicked = 0 sale.isPicked = 0
positionUnmarked = position positionUnmarked = position
@ -934,11 +746,11 @@ class CollectionFragmentPickerNew(
customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER) customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER)
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER) customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
customDialogList.getEditTextTwo().requestFocus() customDialogList.getEditTextTwo().requestFocus()
var shelving = myGroupList[pos].code val shelving = myGroupList[pos].code
var item = myGroupList[pos].itemFk val item = myGroupList[pos].itemFk
var longName = myGroupList[pos].longName val longName = myGroupList[pos].longName
var totalReserved = myGroupList[pos].reservedQuantity val totalReserved = myGroupList[pos].reservedQuantity
var itemShelvingFk = myGroupList[pos].itemShelvingSaleFk val itemShelvingFk = myGroupList[pos].itemShelvingSaleFk
try { try {
customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton( customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton(
@ -972,7 +784,7 @@ class CollectionFragmentPickerNew(
false false
} }
} catch (e: Exception) { } catch (e: Exception) {
ma.messageWithSound(e.message.toString(), true, true) ma.messageWithSound(e.message.toString(), isError = true, isPlayed = true)
} }
} }
@ -988,7 +800,7 @@ class CollectionFragmentPickerNew(
customDialogList.getValueTwo(), "buy", "more" customDialogList.getValueTwo(), "buy", "more"
).toString() ).toString()
) )
var quantityToReserve = customDialogList.getValue().toInt() val quantityToReserve = customDialogList.getValue().toInt()
if (quantityToReserve < totalReserved) { if (quantityToReserve < totalReserved) {
@ -997,8 +809,10 @@ class CollectionFragmentPickerNew(
showQuestionUbicationEmpty(position, quantityToReserve) showQuestionUbicationEmpty(position, quantityToReserve)
} else { } else {
ma.messageWithSound( ma.messageWithSound(
message = "Indique el item correctamente", isError = message = getString(R.string.errorItem),
true, isPlayed = true, isToasted = false isError = true,
isPlayed = true,
isToasted = false
) )
} }
} }
@ -1010,11 +824,10 @@ class CollectionFragmentPickerNew(
if (quantityToReserve == totalReserved) { if (quantityToReserve == totalReserved) {
originalItemScan = customDialogList.getValueTwo().toLong() originalItemScan = customDialogList.getValueTwo().toLong()
println("Sacador a checkItemScan")
if (checkItemScan(customDialogList.getValueTwo())) { if (checkItemScan(customDialogList.getValueTwo())) {
onQuantityOfShelvingSelected( onQuantityOfShelvingSelected(
itemShelvingFk, quantityToReserve quantityToReserve
) )
mpok?.start() mpok?.start()
@ -1024,7 +837,6 @@ class CollectionFragmentPickerNew(
} else { } else {
itemShelvingFkStored = itemShelvingFk itemShelvingFkStored = itemShelvingFk
binding.splashProgress.visibility = View.VISIBLE
viewModel.getIdFromCodeSalix( viewModel.getIdFromCodeSalix(
code = customDialogList.getValueTwo(), code = customDialogList.getValueTwo(),
) )
@ -1037,17 +849,9 @@ class CollectionFragmentPickerNew(
} }
} }
private fun setStoredPosition(isFromBack: Boolean) {
setListPosition(storedBackPosition, isFromBack)
/*if (goBack) setListPosition(storedBackPosition, isFromBack) else {
setListPosition(storedPosition, isFromBack)*/
}
private fun checkItemScan(valueToCheck: String): Boolean { private fun checkItemScan(valueToCheck: String): Boolean {
println("Sacador valor a checkear ${valueToCheck}")
if (storedPosition >= 0 && sales.size > storedPosition) { if (storedPosition >= 0 && sales.size > storedPosition) {
val saleToCheck = myGroupList[storedPosition] val saleToCheck = myGroupList[storedPosition]
println("Sacador valor de la sale a checkear ${saleToCheck}")
if (saleToCheck.itemFk.toString() == valueToCheck) return true if (saleToCheck.itemFk.toString() == valueToCheck) return true
else { else {
saleToCheck.Barcodes.forEach { barcode -> saleToCheck.Barcodes.forEach { barcode ->
@ -1055,47 +859,40 @@ class CollectionFragmentPickerNew(
} }
} }
} }
return false
return false return false
} }
//Tarea #4371 //Tarea #4371
private fun onQuantityOfShelvingSelected(itemShelvingFk: Int, quantity: Int = 0) { private fun onQuantityOfShelvingSelected(quantity: Int = 0) {
println("Sacador $itemShelvingFk-$quantity")/* if (myGroupList[storedPosition].reservedQuantity == 0) {
showQuestionUbicationEmpty(storedPosition)
} else {*/
markLine(storedPosition, quantity, null) markLine(storedPosition, quantity, null)
// }
} }
private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) { private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) {
customDialogThreeButtonsQuantity.setTitle("Cambio de cantidad a $quantity del artículo ${sales[position].itemFk}") customDialogThreeButtonsQuantity.setTitle(
.setDescription("¿Quedan unidades del artículo ${sales[position].itemFk} en el carro escaneado?") getString(
.setValue("").setCustomDialogValue(View.GONE) R.string.changeQuantity, quantity, sales[position].itemFk
customDialogThreeButtonsQuantity.setOkButtonAdd("SI") { )
).setDescription(getString(R.string.questionItemShelving, sales[position].itemFk))
.setValue("").setValue("").setCustomDialogValue(View.GONE)
customDialogThreeButtonsQuantity.setOkButtonAdd(getString(R.string.yes)) {
scanRequest() scanRequest()
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()
//markLine(position, quantity, false) getString(R.string.errorQuantityShelving).toast(requireContext())
"No puedes seleccionar menos cantidad habiendo en el carro".toast(requireContext())
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()
showQuestionUbicationEmpty(position, quantity) showQuestionUbicationEmpty(position, quantity)
}.setOkButtonTwo("NO") { }.setOkButtonTwo(getString(R.string.no)) {
scanRequest() scanRequest()
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()
if (quantity == 0) { if (quantity == 0) {
viewModel.itemShelvingSaleExists( viewModel.itemShelvingSaleExists(
myGroupList[position].itemShelvingSaleFk, myGroupList[position].itemShelvingSaleFk, position, quantity
position,
quantity
) )
} else { } else {
markLine(position, quantity, true) markLine(position, quantity, true)
} }
//markLine(position, quantity, true) }.setKoButton(getString(R.string.cancel)) {
}.setKoButton("CANCELAR") {
scanRequest() scanRequest()
customDialogThreeButtonsQuantity.dismiss() customDialogThreeButtonsQuantity.dismiss()
}.show() }.show()
@ -1145,7 +942,7 @@ class CollectionFragmentPickerNew(
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event -> customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!customDialogList.getValue().isNullOrEmpty()) { if (customDialogList.getValue().isNotEmpty()) {
try { try {
customDialogList.setValue( customDialogList.setValue(
itemScanValue( itemScanValue(
@ -1154,7 +951,7 @@ class CollectionFragmentPickerNew(
) )
} catch (e: Exception) { } catch (e: Exception) {
ma.messageWithSound(e.message.toString(), true, true) ma.messageWithSound(e.message.toString(), isError = true, isPlayed = true)
} }
customDialogList.getEditTextTwo().requestFocus() customDialogList.getEditTextTwo().requestFocus()
} }
@ -1194,11 +991,11 @@ class CollectionFragmentPickerNew(
private fun customDialogAddItem() { private fun customDialogAddItem() {
if (!customDialogList.getValueTwo().isNullOrEmpty()) { if (customDialogList.getValueTwo().isNotEmpty()) {
if (ticketSelected == 0) { if (ticketSelected == 0) {
getString(R.string.Seleccionaunticketdelaista).toast(requireContext()) getString(R.string.Seleccionaunticketdelaista).toast(requireContext())
} else if (customDialogList.getValue().isNullOrEmpty() || customDialogList.getValueTwo() } else if (customDialogList.getValue().isEmpty() || customDialogList.getValueTwo()
.isNullOrEmpty() .isEmpty()
) { ) {
getString(R.string.Todosloscampossonobligatorios).toast(requireContext()) getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else { } else {
@ -1219,7 +1016,7 @@ class CollectionFragmentPickerNew(
} }
private fun toastDisponibility(item: ItemVO) { private fun toastDisponibility(item: ItemVO) {
if (item.available.isNullOrEmpty()) { if (item.available.isEmpty()) {
item.available = "0" item.available = "0"
} }
customDialog.setTitle(getString(R.string.itemPoints) + item.id) customDialog.setTitle(getString(R.string.itemPoints) + item.id)
@ -1236,27 +1033,24 @@ class CollectionFragmentPickerNew(
var totalMark = 0 var totalMark = 0
sales.forEach { sales.forEach {
if (it.isPicked == 1) { if (it.isPicked == 1) {
totalMark += 1/* } else if (it.reservedQuantity == 0) { totalMark += 1
totalMark += 1*/
} }
} }
if (binding.mainToolbar.toolbarTitle != null) binding.mainToolbar.toolbarTitle.text = binding.mainToolbar.toolbarTitle.text =
if (collection.collectionFk != 0) collection.collectionFk.toString() else "" if (collection.collectionFk != 0) collection.collectionFk.toString() else ""
var total = sales.size var total = sales.size
var totalParents = sales.filter { it.isParent }.size val totalParents = sales.filter { it.isParent }.size
total = total - totalParents total -= totalParents
if (binding.mainToolbar.toolbarSubtitle != null && totalMark != null) binding.mainToolbar.toolbarSubtitle.text = binding.mainToolbar.toolbarSubtitle.text =
"" + totalMark + "/" + total getString(R.string.totalsPicker, totalMark, total)
if (totalMark == sales.size) { if (totalMark == sales.size) {
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT) getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
saleAdapter!!.notifyDataSetChanged() saleAdapter!!.notifyDataSetChanged()
changeTicketState() changeTicketState()
} }
@ -1290,7 +1084,7 @@ class CollectionFragmentPickerNew(
} }
private fun findSaleAction(index: Int, sale: Sale) { private fun findSaleAction(index: Int, sale: Sale) {
if (!customDialogInput.getValue().isNullOrEmpty()) { if (customDialogInput.getValue().isNotEmpty()) {
findSale(customDialogInput.getValue(), index, sale) findSale(customDialogInput.getValue(), index, sale)
} }
closeCustomDialog(binding.scanInput, customDialogInput) closeCustomDialog(binding.scanInput, customDialogInput)
@ -1311,10 +1105,9 @@ class CollectionFragmentPickerNew(
} }
private fun showDialogLabelCount() { private fun showDialogLabelCount() {
//tarea#4672
var isTicket = false var isTicket = false
for (t in collection.tickets) { for (t in collection.tickets) {
if (t.ticketFk.toInt() == (collection.collectionFk)) { if (t.ticketFk == (collection.collectionFk)) {
isTicket = true isTicket = true
} }
} }
@ -1342,19 +1135,9 @@ class CollectionFragmentPickerNew(
} }
fun isNumber(num: String): Boolean {
var numberInt = 0
try {
numberInt = num.toInt()
return true
} catch (e: Exception) {
return false
}
}
private fun groupSaleGroup(salesList: ArrayList<Sale>): MutableList<Sale> { private fun groupSaleGroup(salesList: ArrayList<Sale>): MutableList<Sale> {
var myMap = salesList.groupBy { it.saleGroupFk } val myMap = salesList.groupBy { it.saleGroupFk }
var myList: MutableList<Sale> = mutableListOf() val myList: MutableList<Sale> = mutableListOf()
for ((key, value) in myMap.entries) { for ((key, value) in myMap.entries) {
if (key == null) { // si no tiene saleGroup se añaden las líneas if (key == null) { // si no tiene saleGroup se añaden las líneas
@ -1362,14 +1145,13 @@ class CollectionFragmentPickerNew(
myList.add(s) myList.add(s)
} }
} else { // si tiene saleGroup se crea el padre con el tamaño e indicando que es padre, como ejemplo se toma el primer elemento } else { // si tiene saleGroup se crea el padre con el tamaño e indicando que es padre, como ejemplo se toma el primer elemento
/*crea padre*/ /*crea padre*/
if (value.size > 1) { if (value.size > 1) {
var mySale = //= value[0] val mySale = //= value[0]
Sale( Sale(
level = value[0].level, level = value[0].level,
isPicked = value[0].isPicked, isPicked = value[0].isPicked,
parkingCode = "Líneas : ${value.size}", parkingCode = getString(R.string.linesSaelGroup, value.size),
pickingOrder = value[0].pickingOrder, pickingOrder = value[0].pickingOrder,
workerFk = value[0].workerFk, workerFk = value[0].workerFk,
originalQuantity = value[0].originalQuantity, originalQuantity = value[0].originalQuantity,
@ -1392,10 +1174,7 @@ class CollectionFragmentPickerNew(
mySale.isParent = true mySale.isParent = true
value as MutableList<Sale> value as MutableList<Sale>
mySale.sonSales = mySale.sonSales =
value.sortedWith(compareBy { it.isPicked }) as MutableList<Sale>/*mySale.line1 = "Previa :${mySale.saleGroupFk}" value.sortedWith(compareBy { it.isPicked }) as MutableList<Sale>
mySale.line2 = "Líneas: ${value.size}"
mySale.line3 = value[0].code*/
// mySale.placements = listOf(PlacementVO(shelving = value[0].code!!))
myList.add(mySale) myList.add(mySale)
} else { } else {

View File

@ -55,6 +55,7 @@ import es.verdnatura.presentation.view.feature.claim.fragment.ClaimFragment
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragment import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragment
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPicker import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPicker
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerNew import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPickerPreviousNew
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPreChecker import es.verdnatura.presentation.view.feature.collection.fragment.CollectionFragmentPreChecker
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionShowTicketFragment import es.verdnatura.presentation.view.feature.collection.fragment.CollectionShowTicketFragment
import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorFragment import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorFragment
@ -98,6 +99,7 @@ import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroFragm
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.precontrol.PreControladorFragment import es.verdnatura.presentation.view.feature.precontrol.PreControladorFragment
import es.verdnatura.presentation.view.feature.presacador.fragment.EndSacadorFragment import es.verdnatura.presentation.view.feature.presacador.fragment.EndSacadorFragment
import es.verdnatura.presentation.view.feature.presacador.fragment.SectorCollectionReserveFragment
import es.verdnatura.presentation.view.feature.qr.QrFragment import es.verdnatura.presentation.view.feature.qr.QrFragment
import es.verdnatura.presentation.view.feature.reubication.fragment.ReubicationCollectionFragment import es.verdnatura.presentation.view.feature.reubication.fragment.ReubicationCollectionFragment
import es.verdnatura.presentation.view.feature.reubication.fragment.ReubicationFragment import es.verdnatura.presentation.view.feature.reubication.fragment.ReubicationFragment
@ -168,7 +170,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? { override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {
backDispatcher.addCallback(object : OnBackPressedCallback(true) { backDispatcher.addCallback(object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() {
onMyBackPressed() onMyBackPressed()
} }
@ -690,6 +692,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
addFragmentOnTop(PackingMistakeFragment.newInstance(item.title)) addFragmentOnTop(PackingMistakeFragment.newInstance(item.title))
} }
getString(R.string.titlePrePickerTest) -> {
addFragmentOnTop(SacadorFragmentNew.newInstance("PREITEMPICKERTEST"))
}
getString(R.string.titlePrePicker) -> { getString(R.string.titlePrePicker) -> {
addFragmentOnTop(SacadorFragment.newInstance("PREITEMPICKER")) addFragmentOnTop(SacadorFragment.newInstance("PREITEMPICKER"))
} }
@ -854,6 +860,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.pickerHelper) -> { getString(R.string.pickerHelper) -> {
addFragmentOnTop(PickerHelperFragment.newInstance(item.title)) addFragmentOnTop(PickerHelperFragment.newInstance(item.title))
} }
"PREITEMPICKERTEST" -> {
addFragmentOnTop(
CollectionFragmentPickerPreviousNew.newInstance(
CollectionTicket(collectionFk = entryPoint.toInt()),
"PREITEMPICKERTEST",
false
)
)
}
} }
} }
@ -879,9 +895,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
val index = supportFragmentManager.backStackEntryCount - 1 val index = supportFragmentManager.backStackEntryCount - 1
var backEntry = "" var backEntry = ""
if (index >= 0) { if (index >= 0) {
backEntry = supportFragmentManager.getBackStackEntryAt(index).name.toString() backEntry = supportFragmentManager.getBackStackEntryAt(index).name.toString()
/* println("onback LOadUnload $backEntry")
if (backEntry.contains("itemShelvingLog")){
}*/
if (backEntry.contains(getString(R.string.titleLoadTruck)) || backEntry.contains( if (backEntry.contains(getString(R.string.titleLoadTruck)) || backEntry.contains(
getString(R.string.titleUnLoadTruck) getString(R.string.titleUnLoadTruck)
) )
@ -924,14 +944,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
if (backEntry.contains("fragment.ExpeditionPalletDetailFragment.Companion")) { if (backEntry.contains("fragment.ExpeditionPalletDetailFragment.Companion")) {
addFragmentOnTop(ExpeditionTruckListFragment.newInstance()) addFragmentOnTop(ExpeditionTruckListFragment.newInstance())
} }
if (backEntry.contains(getString(R.string.titleLog)) || backEntry.contains( /* if (backEntry.contains(getString(R.string.titleLog)) || backEntry.contains(
getString( getString(
R.string.titleInfo R.string.titleInfo
) )
) )
) { ) {
println("backk finish ?? ")
finish() finish()
} }*/
} else { } else {
customDialog.setTitle(getString(R.string.closeSession)) customDialog.setTitle(getString(R.string.closeSession))
@ -987,8 +1008,29 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
type: String, type: String,
hasPicking: Boolean hasPicking: Boolean
) { ) {
when (type) {
"PREITEMPICKERTEST" -> {
println("test presacador")
//addFragmentOnTop(EndSacadorFragment.newInstance(collection, type))
addFragmentOnTop(
SectorCollectionReserveFragment.newInstance(
"PREITEMPICKERTEST",
collection.collectionFk
)
)
addFragmentOnTop(CollectionFragmentPickerNew.newInstance(collection, type, hasPicking)) }
else -> {
addFragmentOnTop(
CollectionFragmentPickerNew.newInstance(
collection,
type,
hasPicking
)
)
}
}
} }

View File

@ -79,6 +79,12 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
val loadResponseSaleGropAdd: LiveData<Event<ResponseItemVO>> = val loadResponseSaleGropAdd: LiveData<Event<ResponseItemVO>> =
_responseSaleGroupAdd.map { Event(it) } _responseSaleGroupAdd.map { Event(it) }
private val _responseReserveSectorCollection by lazy { MutableLiveData<ResponseItemVO>() }
val responseReserveSectorCollection: LiveData<ResponseItemVO>
get() = _responseReserveSectorCollection
val loadResponseReserveSectorCollection: LiveData<Event<ResponseItemVO>> =
_responseReserveSectorCollection.map { Event(it) }
private val _responseSaleAddPrevOK by lazy { MutableLiveData<ResponseItemVO>() } private val _responseSaleAddPrevOK by lazy { MutableLiveData<ResponseItemVO>() }
val responseSaleAddPrevOK: LiveData<ResponseItemVO> val responseSaleAddPrevOK: LiveData<ResponseItemVO>
get() = _responseSaleAddPrevOK get() = _responseSaleAddPrevOK
@ -343,6 +349,32 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
} }
}) })
} }
fun getReserveBySectorCollection(
vSectorCollectionFk: Int
) {
salix.getReserveBySectorCollection(
params = arrayListOf(
vSectorCollectionFk
).formatWithQuotes()
).enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_responseReserveSectorCollection.value = ResponseItemVO(
isError = false, errorMessage = "" + getMessageFromAllResponse(
nameofFunction(this), response.message()
)
)
}
override fun onError(t: Throwable) {
_responseReserveSectorCollection.value = ResponseItemVO(
isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), t.message!!
)
)
}
})
}
fun saleTrackingAddPrevOK( fun saleTrackingAddPrevOK(
sectorCollectionFk: Int sectorCollectionFk: Int
@ -399,7 +431,8 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
saleFk: Int saleFk: Int
) { ) {
//Tarea 6276 pasar a Salix //Tarea 6276 pasar a Salix
salix.itemShelvingUpdateFromSale(saleFk) //09/04/2024
salix.itemShelvingUpdateFromSale(hashMapOf("saleFk" to saleFk))
// silex.itemShelving_updateFromSale(saleFk) // silex.itemShelving_updateFromSale(saleFk)
.enqueue(object : SalixCallback<Any>(context) { .enqueue(object : SalixCallback<Any>(context) {

View File

@ -16,7 +16,8 @@ class CollectionAdapterNew(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder {
return AjustesItemHolder( return AjustesItemHolder(
ItemCollectionRowNewBinding.inflate(LayoutInflater.from(parent.context), parent, false) ItemCollectionRowNewBinding.inflate(LayoutInflater.from(parent.context), parent, false),
type
) )
} }
@ -30,11 +31,13 @@ class CollectionAdapterNew(
} }
class AjustesItemHolder( class AjustesItemHolder(
val binding: ItemCollectionRowNewBinding val binding: ItemCollectionRowNewBinding,
val type: String
) : RecyclerView.ViewHolder(binding.root) { ) : RecyclerView.ViewHolder(binding.root) {
fun bind(item: CollectionTicket) { fun bind(item: CollectionTicket) {
binding.apply { binding.apply {
if (item.ticketTotalCount == null) { if (item.ticketTotalCount == null || type == "PREITEMPICKERTEST") {
binding.totalTicketsId.visibility = View.GONE binding.totalTicketsId.visibility = View.GONE
} }
this.item = item this.item = item

View File

@ -55,12 +55,11 @@ class SacadorFragmentNew(
setToolBar() setToolBar()
setEvents() setEvents()
callBack(type) callBack(type)
println("SacadorNEW")
super.init() super.init()
} }
private fun callBack(type: String) { private fun callBack(type: String) {
binding.splashProgress.visibility = View.VISIBLE
when (type) { when (type) {
"PREPARED" -> { "PREPARED" -> {
viewModel.collectionGetSalixLocal() viewModel.collectionGetSalixLocal()
@ -70,8 +69,12 @@ class SacadorFragmentNew(
viewModel.sectorCollectionGet() viewModel.sectorCollectionGet()
} }
"PREITEMPICKERTEST" -> {
viewModel.sectorCollectionGet()
}
else -> { else -> {
binding.splashProgress.visibility = View.GONE
} }
} }
} }
@ -119,7 +122,7 @@ class SacadorFragmentNew(
when (item) { when (item) {
iconAdd.drawable -> { iconAdd.drawable -> {
binding.splashProgress.visibility = View.VISIBLE
if (type == "PREPARED") { if (type == "PREPARED") {
viewModel.collection_assignNew( viewModel.collection_assignNew(
) )
@ -206,24 +209,53 @@ class SacadorFragmentNew(
override fun observeViewModel() { override fun observeViewModel() {
with(viewModel) { with(viewModel) {
binding.splashProgress.visibility = View.GONE
collectionListLocal.observe(viewLifecycleOwner, Observer { collectionListLocal.observe(viewLifecycleOwner, Observer {
if (!goBack2) binding.splashProgress.visibility = View.GONE //if (!goBack2)
createCollectionList(it.list) createCollectionList(it.list)
binding.splashProgress.visibility = View.GONE
goBack2 = false
})
collectionList.observe(viewLifecycleOwner, Observer { it ->
//if (!goBack2)
var myCollectionsList = mutableListOf<CollectionTicket>()
it.list.forEach {
myCollectionsList.add(CollectionTicket(it.collectionFk))
}
createCollectionList(myCollectionsList)
goBack2 = false goBack2 = false
}) })
response.observe(viewLifecycleOwner, Observer { response.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
if (it.isError) { if (it.isError) {
ma.messageWithSound(it.errorMessage, true, false) ma.messageWithSound(it.errorMessage, true, false)
} else { } else {
if (!it.response.isNullOrBlank()) { if (!it.response.isNullOrBlank()) {
addCollectionToList(it.response.toInt()) addCollectionToList(it.response.toInt())
viewModel.collectionGetSalixLocal()
}else{
when (type) {
"PREPARED" -> {
viewModel.collectionGetSalixLocal()
}
"PREITEMPICKER" -> {
viewModel.sectorCollectionGet()
}
"PREITEMPICKERTEST" -> {
println("SacadorFragmentNew sectorCollectionGET")
viewModel.sectorCollectionGet()
}
else -> {
}
}
} }
} }
goBack = false goBack = false
@ -242,6 +274,7 @@ class SacadorFragmentNew(
adapter = CollectionAdapterNew(collectionsList, onCollectionSelectedListener!!, type) adapter = CollectionAdapterNew(collectionsList, onCollectionSelectedListener!!, type)
binding.fragmentSacadorCollections.layoutManager = lm binding.fragmentSacadorCollections.layoutManager = lm
binding.fragmentSacadorCollections.adapter = adapter binding.fragmentSacadorCollections.adapter = adapter
adapter!!.notifyDataSetChanged()
} }