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 PRESACADOR = "PRESACADOR" //PREITEMPICKER
const val PREITEMPICKER = "PREITEMPICKER"
const val PREITEMPICKERTEST = "PREITEMPICKERTEST"
const val SERIALNUMBER = "SERIALNUMBER"
const val ON_CHECKING = "ON_CHECKING"
const val PRECHECKER = "PRECHECKER"

View File

@ -2,14 +2,10 @@ package es.verdnatura.presentation.view.feature.collection.fragment
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.graphics.drawable.Drawable
import android.media.MediaPlayer
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.text.InputType
import android.util.Log.d
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
@ -17,8 +13,6 @@ import android.view.inputmethod.EditorInfo
import android.widget.EditText
import android.widget.ImageView
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
@ -64,7 +58,7 @@ import org.json.JSONObject
class CollectionFragmentPickerNew(
var collection: CollectionTicket,
var type: String = SACADOR,
var hasPickingOrder: Boolean = false
private var hasPickingOrder: Boolean = false
) : BaseFragment<FragmentCollectionNewBinding, CollectionViewModel>(
CollectionViewModel::class
) {
@ -107,11 +101,8 @@ class CollectionFragmentPickerNew(
companion object {
fun newInstance(
collection: CollectionTicket,
type: String,
hasPickingOrder: Boolean = false
) =
CollectionFragmentPickerNew(collection, type, hasPickingOrder)
collection: CollectionTicket, type: String, hasPickingOrder: Boolean = false
) = CollectionFragmentPickerNew(collection, type, hasPickingOrder)
}
override fun onAttach(context: Context) {
@ -143,7 +134,6 @@ class CollectionFragmentPickerNew(
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
customDialogThreeButtonsQuantity = CustomDialogThreeButtons(requireContext())
ma.hideBottomNavigation(View.GONE)
binding.splashProgress.visibility = View.VISIBLE
setEvents()
setToolBar()
@ -185,15 +175,13 @@ class CollectionFragmentPickerNew(
val iconUpdate = ImageView(context)
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)
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
iconViewCollection.tooltipText = getTooltip(R.drawable.ic_collection)
iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
iconPrint.tooltipText = getTooltip(R.drawable.ic_print_black_24dp)
iconAdd.tooltipText = getTooltip(R.drawable.ic_playlist_add_black_24dp)
iconViewCollection.tooltipText = getTooltip(R.drawable.ic_collection)
iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
iconParking.tooltipText = getTooltip(R.drawable.ic_local_parking_black_24dp)
iconUpdate.tooltipText = getTooltip(R.drawable.ic_autorenew_black_24dp)
}
listIcons.add(iconPrint)
listIcons.add(iconAdd)
listIcons.add(iconUpdate)
@ -229,16 +217,14 @@ class CollectionFragmentPickerNew(
}
private fun markPrevia(saleGroupScanned: String): Boolean {
println("Sacador saleGroup $saleGroupScanned ")
try {
for (indice in sales.indices) {
println("Sacador saleGroup ${sales[indice].saleGroupFk}")
if (sales[indice].saleGroupFk != null && sales[indice].saleGroupFk == saleGroupScanned.toInt()) {
println("Sacador saleGroup ${sales[indice].itemShelvingSaleFk}")
viewModel.itemShelvingSaleSetSaleGroup(saleGroupScanned.toInt())
positionMarkPrevia = indice
return true
mpok!!.start()
return true
}
}
@ -248,27 +234,6 @@ class CollectionFragmentPickerNew(
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() {
binding.scanInput.requestFocus()
hideKeyboards()
@ -293,7 +258,7 @@ class CollectionFragmentPickerNew(
binding.scanInput.requestFocus()
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 (!binding.scanInput.text.toString().isNullOrEmpty()) {
if (binding.scanInput.text.toString().isNotEmpty()) {
binding.scanInput.setText(textScanned_filterDouble(binding.scanInput.text!!.toString()))
isScanned =
event != null && event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER
@ -331,15 +296,7 @@ class CollectionFragmentPickerNew(
binding.collectionSwipe.setOnRefreshListener {
isMarking = false
binding.collectionSwipe.isRefreshing = false
binding.splashProgress.visibility = View.VISIBLE
updateScreen()
/* viewModel.collectionTicketGet(
collection.collectionFk,
mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK),
print = "0",
type
)*/
buttonPushedGetCollection = false
binding.collectionSwipe.isRefreshing = false
@ -350,36 +307,17 @@ class CollectionFragmentPickerNew(
try {
requireActivity().hideKeyboard()
} catch (e: Exception) {
e.toast(requireContext())
}
}
@RequiresApi(Build.VERSION_CODES.O)
override fun observeViewModel() {
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 ->
event.getContentIfNotHandled().notNull {
binding.splashProgress.visibility = View.GONE
//
if (!it.isError) {
if (it.tickets.isNotEmpty()) {
@ -406,49 +344,22 @@ class CollectionFragmentPickerNew(
}
}
/* collectionTicketSalix.observe(viewLifecycleOwner, Observer {
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 {
responseExistsItemShelvingSale.observe(viewLifecycleOwner) {
if (!goBack) {
if (it.exists) {
markLine(it.position, it.quantity, true)
} else {
"Actualizando las líneas porque la reserva está modificada".toast(
getString(R.string.updateSalesReserve).toast(
requireContext()
)
viewModel.collectionTicketGetSalix(collection.collectionFk, false)
}
}
})
responseParking.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
}
responseParking.observe(viewLifecycleOwner) {
if (!goBack) {
binding.splashProgress.visibility = View.GONE
ma.messageWithSound(
if (it.isError) it.errorMessage else getString(R.string.Aparcado),
it.isError,
@ -456,24 +367,23 @@ class CollectionFragmentPickerNew(
)
}
})
}
responseCollectionAddItem.observe(viewLifecycleOwner, Observer {
responseCollectionAddItem.observe(viewLifecycleOwner) {
if (!goBack) {
updateScreen()
goBack = false
}
})
}
responsePrint.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
responsePrint.observe(viewLifecycleOwner) {
if (!goBack) {
if (it.isError) {
ma.messageWithSound(
it.errorMessage, it.isError, true
it.errorMessage, isError = true, isPlayed = true
)
} else {
(getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey<String>(
@ -484,16 +394,15 @@ class CollectionFragmentPickerNew(
}
}
})
}
responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
responseConfirmReservedItemShelvingSale.observe(viewLifecycleOwner) {
if (it.isError) {
ma.messageWithSound(
if (it.isError) it.errorMessage else getString(R.string.confirmReserv),
it.isError,
it.isError
it.errorMessage,
isError = true,
isPlayed = true
)
}
if (!it.isError) {
@ -505,36 +414,32 @@ class CollectionFragmentPickerNew(
)
}
})
}
responseItemShelvingSale.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
responseItemShelvingSale.observe(viewLifecycleOwner) {
myGroupList[positionConfirm].isPicked = 1
myGroupList[positionConfirm].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
lm!!.scrollToPositionWithOffset(positionConfirm, 0)
//saleAdapter!!.notifyDataSetChanged()
ma.messageWithSound(
"Confirmada acción", it.isError, !it.isError
getString(R.string.operationSuccess), it.isError, !it.isError, isToasted = false
)
})
responseItemShelvingSaleUnPicked.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
}
responseItemShelvingSaleUnPicked.observe(viewLifecycleOwner) {
myGroupList[positionUnmarked].isPicked = 1
myGroupList[positionUnmarked].reservedQuantity = quantityConfirm
viewModel.collectionTicketGetSalix(
collection.collectionFk, print = false
)
lm!!.scrollToPositionWithOffset(positionUnmarked, 0)
//saleAdapter!!.notifyDataSetChanged()
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(
collection.collectionFk, print = false
@ -542,12 +447,11 @@ class CollectionFragmentPickerNew(
lm!!.scrollToPositionWithOffset(positionMarkPrevia, 0)
ma.messageWithSound(
"Previa recogida", it.isError, !it.isError
getString(R.string.previousCollected), it.isError, !it.isError
)
})
}
responseCode.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = View.GONE
responseCode.observe(viewLifecycleOwner) {
if (!goBack2) {
if (it.isError) {
customDialog.setTitle(getString(R.string.error))
@ -563,7 +467,6 @@ class CollectionFragmentPickerNew(
mpok?.start()
onQuantityOfShelvingSelected(itemShelvingFkStored)
} else {
var value = customDialogList.getValueTwo()
customDialogList.setValueTwo("")
if (it.response.isBlank() || it.response.isEmpty()) {
showErrorMessage(text = getString(R.string.codeNotExist))
@ -580,30 +483,16 @@ class CollectionFragmentPickerNew(
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() {
state = 0
binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString()
binding.splashProgress.visibility = View.GONE
collection.map(requireContext())
var salesList: ArrayList<Sale> = ArrayList()
val salesList: ArrayList<Sale> = ArrayList()
tickets = ArrayList()
var observations = ""
@ -611,7 +500,7 @@ class CollectionFragmentPickerNew(
val myPickingTo = mobileApplication.dataStoreApp.readDataStoreKey<Int>("PICKING_TO")
collection.tickets.forEach { ticket ->
if (!observations.isNullOrEmpty()) observations =
if (observations.isNotEmpty()) observations =
observations + " " + ticket.observations
ticket.sales.forEach { sale ->
@ -627,11 +516,6 @@ class CollectionFragmentPickerNew(
}
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 =
groupSaleGroup(salesList).sortedWith(compareBy<Sale> { it.pickingOrder }.thenBy { it.itemFk })
saleAdapter = SaleAdapterNew(
@ -646,10 +530,8 @@ class CollectionFragmentPickerNew(
if (sale.isPicked == 1) {
showErrorMessage(
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 {
override fun onSaleClick(mysale: Sale) {
override fun onSaleClick(mySale: 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 {
override fun onPackingClick(sale: Sale) {
goBack = true
println("ubicador")
if (!sale.code.isNullOrEmpty()) ma.onPasillerosItemClickListener(
PasillerosItemVO(
title = getString(R.string.titleUbicator),
), entryPoint = sale.code!!
), entryPoint = sale.code
)
}
},
object : OnTicketClickSaleListener {
override fun onTicketClickListener(sale: Sale) {
var entryPoint = Gson().toJson(
val entryPoint = Gson().toJson(
mutableMapOf(
"entryPoint" to sale.ticketFk,
"web" to "${
"entryPoint" to sale.ticketFk, "web" to "${
mobileApplication.dataStoreApp.readDataStoreKey<String>(
BASEURLSALIX
)
@ -735,7 +597,7 @@ class CollectionFragmentPickerNew(
binding.fragmentSacadorCollections.layoutManager = lm
setTotalLines()
setStoredPosition(true)
setListPosition()
setScrollListener(lm!!)
printObservations(observations)
}
@ -767,13 +629,18 @@ class CollectionFragmentPickerNew(
if (isOk) {
//Se ha escanado un ticket y se ha marcado la previa
ma.messageWithSound(
getString(R.string.previousCollected),
isPlayed = false,
isError = false,
isToasted = true
)
} else {
//Se busca la matricula en las lineas
for (indice in myGroupList.indices) {
if (myGroupList[indice].isPicked != 1 && myGroupList[indice].code != null && myGroupList[indice].code!!.uppercase() == txtscan.uppercase()) {
mpok!!.start()
isOk = true
positionMarkPrevia = indice
printShelvingResult(indice)
break
}
@ -794,8 +661,6 @@ class CollectionFragmentPickerNew(
}
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
@ -822,63 +687,19 @@ class CollectionFragmentPickerNew(
myGroupList[position].itemShelvingSaleFk, quantity, isItemShelvingSaleEmpty
)
//nuevo tema agrupacion sales
//checkStateParent()
// var mySale = sales[position].saleFk Ordenar setPosition
var mySale = sales[position].itemShelvingSaleFk
val mySale = sales[position].itemShelvingSaleFk
for (indice in myGroupList.indices) {
if (!myGroupList[indice].isParent && myGroupList[indice].itemShelvingSaleFk == mySale) {
d("VERDNATURA::", "la pos del index de la sale es" + indice)
storedBackPosition = indice
}
}
//setTotalLines()
}
//Tarea #4371
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)
private fun setListPosition() {
if (storedPosition == 0 && storedBackPosition == 0) { // se inicia lista, se busca porqué item vamos.
for (indice in myGroupList.indices) {
if (myGroupList[indice].isPicked == 0) {
//storedPosition = indice
lm!!.scrollToPositionWithOffset(indice - 1, 0)
break
}
@ -897,19 +718,10 @@ class CollectionFragmentPickerNew(
)
).setOkButton(getString(R.string.unmark)) {
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 {
/* 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
setListPosition(position, false)
setListPosition()
viewModel.itemShelvingSaleUnpicked(myGroupList[position].itemShelvingSaleFk)
sale.isPicked = 0
positionUnmarked = position
@ -934,11 +746,11 @@ class CollectionFragmentPickerNew(
customDialogList.getEditTextTwo().setRawInputType(InputType.TYPE_CLASS_NUMBER)
customDialogList.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER)
customDialogList.getEditTextTwo().requestFocus()
var shelving = myGroupList[pos].code
var item = myGroupList[pos].itemFk
var longName = myGroupList[pos].longName
var totalReserved = myGroupList[pos].reservedQuantity
var itemShelvingFk = myGroupList[pos].itemShelvingSaleFk
val shelving = myGroupList[pos].code
val item = myGroupList[pos].itemFk
val longName = myGroupList[pos].longName
val totalReserved = myGroupList[pos].reservedQuantity
val itemShelvingFk = myGroupList[pos].itemShelvingSaleFk
try {
customDialogList.setTitle("$shelving($item) $totalReserved de $longName").setOkButton(
@ -972,7 +784,7 @@ class CollectionFragmentPickerNew(
false
}
} 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"
).toString()
)
var quantityToReserve = customDialogList.getValue().toInt()
val quantityToReserve = customDialogList.getValue().toInt()
if (quantityToReserve < totalReserved) {
@ -997,8 +809,10 @@ class CollectionFragmentPickerNew(
showQuestionUbicationEmpty(position, quantityToReserve)
} else {
ma.messageWithSound(
message = "Indique el item correctamente", isError =
true, isPlayed = true, isToasted = false
message = getString(R.string.errorItem),
isError = true,
isPlayed = true,
isToasted = false
)
}
}
@ -1010,11 +824,10 @@ class CollectionFragmentPickerNew(
if (quantityToReserve == totalReserved) {
originalItemScan = customDialogList.getValueTwo().toLong()
println("Sacador a checkItemScan")
if (checkItemScan(customDialogList.getValueTwo())) {
onQuantityOfShelvingSelected(
itemShelvingFk, quantityToReserve
quantityToReserve
)
mpok?.start()
@ -1024,7 +837,6 @@ class CollectionFragmentPickerNew(
} else {
itemShelvingFkStored = itemShelvingFk
binding.splashProgress.visibility = View.VISIBLE
viewModel.getIdFromCodeSalix(
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 {
println("Sacador valor a checkear ${valueToCheck}")
if (storedPosition >= 0 && sales.size > storedPosition) {
val saleToCheck = myGroupList[storedPosition]
println("Sacador valor de la sale a checkear ${saleToCheck}")
if (saleToCheck.itemFk.toString() == valueToCheck) return true
else {
saleToCheck.Barcodes.forEach { barcode ->
@ -1055,47 +859,40 @@ class CollectionFragmentPickerNew(
}
}
}
return false
return false
}
//Tarea #4371
private fun onQuantityOfShelvingSelected(itemShelvingFk: Int, quantity: Int = 0) {
println("Sacador $itemShelvingFk-$quantity")/* if (myGroupList[storedPosition].reservedQuantity == 0) {
showQuestionUbicationEmpty(storedPosition)
} else {*/
private fun onQuantityOfShelvingSelected(quantity: Int = 0) {
markLine(storedPosition, quantity, null)
// }
}
private fun showQuestionUbicationEmpty(position: Int, quantity: Int = 0) {
customDialogThreeButtonsQuantity.setTitle("Cambio de cantidad a $quantity del artículo ${sales[position].itemFk}")
.setDescription("¿Quedan unidades del artículo ${sales[position].itemFk} en el carro escaneado?")
.setValue("").setCustomDialogValue(View.GONE)
customDialogThreeButtonsQuantity.setOkButtonAdd("SI") {
customDialogThreeButtonsQuantity.setTitle(
getString(
R.string.changeQuantity, quantity, sales[position].itemFk
)
).setDescription(getString(R.string.questionItemShelving, sales[position].itemFk))
.setValue("").setValue("").setCustomDialogValue(View.GONE)
customDialogThreeButtonsQuantity.setOkButtonAdd(getString(R.string.yes)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
//markLine(position, quantity, false)
"No puedes seleccionar menos cantidad habiendo en el carro".toast(requireContext())
getString(R.string.errorQuantityShelving).toast(requireContext())
customDialogThreeButtonsQuantity.dismiss()
showQuestionUbicationEmpty(position, quantity)
}.setOkButtonTwo("NO") {
}.setOkButtonTwo(getString(R.string.no)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
if (quantity == 0) {
viewModel.itemShelvingSaleExists(
myGroupList[position].itemShelvingSaleFk,
position,
quantity
myGroupList[position].itemShelvingSaleFk, position, quantity
)
} else {
markLine(position, quantity, true)
}
//markLine(position, quantity, true)
}.setKoButton("CANCELAR") {
}.setKoButton(getString(R.string.cancel)) {
scanRequest()
customDialogThreeButtonsQuantity.dismiss()
}.show()
@ -1145,7 +942,7 @@ class CollectionFragmentPickerNew(
customDialogList.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!customDialogList.getValue().isNullOrEmpty()) {
if (customDialogList.getValue().isNotEmpty()) {
try {
customDialogList.setValue(
itemScanValue(
@ -1154,7 +951,7 @@ class CollectionFragmentPickerNew(
)
} catch (e: Exception) {
ma.messageWithSound(e.message.toString(), true, true)
ma.messageWithSound(e.message.toString(), isError = true, isPlayed = true)
}
customDialogList.getEditTextTwo().requestFocus()
}
@ -1194,11 +991,11 @@ class CollectionFragmentPickerNew(
private fun customDialogAddItem() {
if (!customDialogList.getValueTwo().isNullOrEmpty()) {
if (customDialogList.getValueTwo().isNotEmpty()) {
if (ticketSelected == 0) {
getString(R.string.Seleccionaunticketdelaista).toast(requireContext())
} else if (customDialogList.getValue().isNullOrEmpty() || customDialogList.getValueTwo()
.isNullOrEmpty()
} else if (customDialogList.getValue().isEmpty() || customDialogList.getValueTwo()
.isEmpty()
) {
getString(R.string.Todosloscampossonobligatorios).toast(requireContext())
} else {
@ -1219,7 +1016,7 @@ class CollectionFragmentPickerNew(
}
private fun toastDisponibility(item: ItemVO) {
if (item.available.isNullOrEmpty()) {
if (item.available.isEmpty()) {
item.available = "0"
}
customDialog.setTitle(getString(R.string.itemPoints) + item.id)
@ -1236,27 +1033,24 @@ class CollectionFragmentPickerNew(
var totalMark = 0
sales.forEach {
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 ""
var total = sales.size
var totalParents = sales.filter { it.isParent }.size
total = total - totalParents
val totalParents = sales.filter { it.isParent }.size
total -= totalParents
if (binding.mainToolbar.toolbarSubtitle != null && totalMark != null) binding.mainToolbar.toolbarSubtitle.text =
"" + totalMark + "/" + total
binding.mainToolbar.toolbarSubtitle.text =
getString(R.string.totalsPicker, totalMark, total)
if (totalMark == sales.size) {
getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT)
saleAdapter!!.notifyDataSetChanged()
changeTicketState()
}
@ -1290,7 +1084,7 @@ class CollectionFragmentPickerNew(
}
private fun findSaleAction(index: Int, sale: Sale) {
if (!customDialogInput.getValue().isNullOrEmpty()) {
if (customDialogInput.getValue().isNotEmpty()) {
findSale(customDialogInput.getValue(), index, sale)
}
closeCustomDialog(binding.scanInput, customDialogInput)
@ -1311,10 +1105,9 @@ class CollectionFragmentPickerNew(
}
private fun showDialogLabelCount() {
//tarea#4672
var isTicket = false
for (t in collection.tickets) {
if (t.ticketFk.toInt() == (collection.collectionFk)) {
if (t.ticketFk == (collection.collectionFk)) {
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> {
var myMap = salesList.groupBy { it.saleGroupFk }
var myList: MutableList<Sale> = mutableListOf()
val myMap = salesList.groupBy { it.saleGroupFk }
val myList: MutableList<Sale> = mutableListOf()
for ((key, value) in myMap.entries) {
if (key == null) { // si no tiene saleGroup se añaden las líneas
@ -1362,14 +1145,13 @@ class CollectionFragmentPickerNew(
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
/*crea padre*/
if (value.size > 1) {
var mySale = //= value[0]
val mySale = //= value[0]
Sale(
level = value[0].level,
isPicked = value[0].isPicked,
parkingCode = "Líneas : ${value.size}",
parkingCode = getString(R.string.linesSaelGroup, value.size),
pickingOrder = value[0].pickingOrder,
workerFk = value[0].workerFk,
originalQuantity = value[0].originalQuantity,
@ -1392,10 +1174,7 @@ class CollectionFragmentPickerNew(
mySale.isParent = true
value as MutableList<Sale>
mySale.sonSales =
value.sortedWith(compareBy { it.isPicked }) as MutableList<Sale>/*mySale.line1 = "Previa :${mySale.saleGroupFk}"
mySale.line2 = "Líneas: ${value.size}"
mySale.line3 = value[0].code*/
// mySale.placements = listOf(PlacementVO(shelving = value[0].code!!))
value.sortedWith(compareBy { it.isPicked }) as MutableList<Sale>
myList.add(mySale)
} 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.CollectionFragmentPicker
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.CollectionShowTicketFragment
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.precontrol.PreControladorFragment
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.reubication.fragment.ReubicationCollectionFragment
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? {
backDispatcher.addCallback(object : OnBackPressedCallback(true) {
backDispatcher.addCallback(object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
onMyBackPressed()
}
@ -690,6 +692,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
addFragmentOnTop(PackingMistakeFragment.newInstance(item.title))
}
getString(R.string.titlePrePickerTest) -> {
addFragmentOnTop(SacadorFragmentNew.newInstance("PREITEMPICKERTEST"))
}
getString(R.string.titlePrePicker) -> {
addFragmentOnTop(SacadorFragment.newInstance("PREITEMPICKER"))
}
@ -854,6 +860,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.pickerHelper) -> {
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
var backEntry = ""
if (index >= 0) {
backEntry = supportFragmentManager.getBackStackEntryAt(index).name.toString()
/* println("onback LOadUnload $backEntry")
if (backEntry.contains("itemShelvingLog")){
}*/
if (backEntry.contains(getString(R.string.titleLoadTruck)) || backEntry.contains(
getString(R.string.titleUnLoadTruck)
)
@ -924,14 +944,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
if (backEntry.contains("fragment.ExpeditionPalletDetailFragment.Companion")) {
addFragmentOnTop(ExpeditionTruckListFragment.newInstance())
}
if (backEntry.contains(getString(R.string.titleLog)) || backEntry.contains(
/* if (backEntry.contains(getString(R.string.titleLog)) || backEntry.contains(
getString(
R.string.titleInfo
)
)
) {
println("backk finish ?? ")
finish()
}
}*/
} else {
customDialog.setTitle(getString(R.string.closeSession))
@ -987,8 +1008,29 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
type: String,
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>> =
_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>() }
val responseSaleAddPrevOK: LiveData<ResponseItemVO>
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(
sectorCollectionFk: Int
@ -399,7 +431,8 @@ class PreSacadorViewModel(val context: Context) : BaseViewModel(context) {
saleFk: Int
) {
//Tarea 6276 pasar a Salix
salix.itemShelvingUpdateFromSale(saleFk)
//09/04/2024
salix.itemShelvingUpdateFromSale(hashMapOf("saleFk" to saleFk))
// silex.itemShelving_updateFromSale(saleFk)
.enqueue(object : SalixCallback<Any>(context) {

View File

@ -16,7 +16,8 @@ class CollectionAdapterNew(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): 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(
val binding: ItemCollectionRowNewBinding
val binding: ItemCollectionRowNewBinding,
val type: String
) : RecyclerView.ViewHolder(binding.root) {
fun bind(item: CollectionTicket) {
binding.apply {
if (item.ticketTotalCount == null) {
if (item.ticketTotalCount == null || type == "PREITEMPICKERTEST") {
binding.totalTicketsId.visibility = View.GONE
}
this.item = item

View File

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