From 6f94d7322f421a7843b78c0c1c004ee7e44da4e4 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Tue, 10 Oct 2023 10:07:18 +0200 Subject: [PATCH] refs #5890 newSacador --- .../fragment/CollectionViewModel.kt | 135 +++++++++++- .../collection/mapper/CollectionMapper.kt | 22 ++ .../pasillero/fragment/PasilleroViewModel.kt | 200 ++++++++++-------- .../feature/sacador/model/TicketItemVO.kt | 177 +++++++++++++++- .../res/layout/fragment_collection_new.xml | 89 ++++++++ 5 files changed, 523 insertions(+), 100 deletions(-) create mode 100644 app/src/main/res/layout/fragment_collection_new.xml diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt index a89e92ec..9700ebc9 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt @@ -4,17 +4,21 @@ import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations +import es.verdnatura.MobileApplication +import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.common.Event +import es.verdnatura.presentation.common.ItemShelvingSaleSalix import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.collection.* import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.collection.mapper.proposal import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO import es.verdnatura.presentation.view.feature.sacador.model.* +import es.verdnatura.presentation.view.feature.workermistake.model.SaleMistakeSalix import retrofit2.Call import retrofit2.Callback import retrofit2.Response @@ -34,6 +38,15 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { val collectionTicketList: LiveData get() = _collectionTicketList + private val _collectionTicketSalix by lazy { MutableLiveData() } + val collectionTicketSalix: LiveData + get() = _collectionTicketSalix + + + private val _collectionTicketListLocal by lazy { MutableLiveData() } + val collectionTicketListLocal: LiveData + get() = _collectionTicketListLocal + private val _placementSuppleyList by lazy { MutableLiveData() } val placementSuppleyList: LiveData get() = _placementSuppleyList @@ -63,6 +76,18 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { val responseSaleTracking_mark: LiveData get() = _responseSaleTracking_mark + private val _responseConfirmReservedItemShelvingSale by lazy { MutableLiveData() } + val responseConfirmReservedItemShelvingSale: LiveData + get() = _responseConfirmReservedItemShelvingSale + + + private val _responseConfirmReservedUpdate by lazy { MutableLiveData() } + val responseConfirmReservedUpdate: LiveData + get() = _responseConfirmReservedUpdate + + + + private val _responseParking by lazy { MutableLiveData() } val responseParking: LiveData get() = _responseParking @@ -191,6 +216,45 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { }) } + fun collectionTicketGetSalix( + collectionFk: Int, + print: Boolean, + + ) { + salix.getCollectionTickets( + collectionFk, + hashMapOf("print" to print) + ).enqueue(object : + SalixCallback(context) { + override fun onError(t: Throwable) { + _collectionTicketSalix.value = CollectionTicket( + 0, + isError = true, + errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + ) + } + + override fun onSuccess(response: Response) { + + if (response.body() != null) { + _collectionTicketSalix.value = response.body()?.let { it.map(contextApp) } + } else { + _collectionTicketSalix.value = CollectionTicket( + 0, + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() + ) + ) + } + } + }) + } + /* _collectionTicketListLocal.value = collectionLocal + }*/ + + fun collection_get( collectionFk: Int, sectorFk: Int, @@ -303,6 +367,66 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { }) } + fun confirmItemShelvingReserved( + itemShelvingSaleFk: Int, + quantity: Int, + isItemShelvingSaleEmpty:Boolean? + ) { + salix.itemShelvingsConfirmRerserved(params = ItemShelvingSaleSalix(itemShelvingSaleFk,quantity,isItemShelvingSaleEmpty) + ).enqueue(object : SilexCallback(context) { + override fun onError(t: Throwable) { + _responseConfirmReservedItemShelvingSale.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + ) + } + + override fun onSuccess(response: Response) { + if (!response.isSuccessful) { + _responseConfirmReservedItemShelvingSale.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() + ) + ) + } else { + _responseConfirmReservedItemShelvingSale.value = + ResponseItemVO(isError = false, response = "") + } + } + }) + } + + fun confirmItemShelvingReservedUpdate( + itemShelvingSaleFk: Int, + isPicked: Boolean + ) { + salix.itemShelvingsReservedUpdate(id =itemShelvingSaleFk, params = hashMapOf("isPicked" to isPicked) + ).enqueue(object : SilexCallback(context) { + override fun onError(t: Throwable) { + _responseConfirmReservedUpdate.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) + ) + } + + override fun onSuccess(response: Response) { + if (!response.isSuccessful) { + _responseConfirmReservedUpdate.value = ResponseItemVO( + isError = true, + errorMessage = getMessageFromAllResponse( + nameofFunction(this), + response.message() + ) + ) + } else { + _responseConfirmReservedUpdate.value = + ResponseItemVO(isError = false, response = "") + } + } + }) + } fun itemPlacementSupplyAiming( shelvingFk: String, @@ -414,6 +538,7 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { ticketFk: Int, usedShelves: Int ) { + //salix.ticketCollectionUpdate("""where={"ticketFk":$ticketFk}""", hashMapOf("usedShelves" to usedShelves)) silex.ticketCollection_setUsedShelves( ticketFk, usedShelves @@ -806,12 +931,12 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { }*/ fun saleMistakeAdd( - vSaleFk: Int, - vTypeFk: Int + saleFk: Int, + typeFk: Int ) { - /*#4742 - Tiene que estar en produc la parte de Silex referente a saleMistakeAdd dos parámetros no tres-quitar tercer parámetro cuando esté subido*/ - silex.saleMistakeAdd(vSaleFk, vTypeFk, vTypeFk) + + salix.saleMistakeAdd(SaleMistakeSalix(userFk=(context as MobileApplication).userId!!, saleFk = saleFk,typeFk = typeFk)) + //silex.saleMistakeAdd(saleFk, typeFk, typeFk) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt index be8fcd02..43ad107e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt @@ -3,6 +3,7 @@ package es.verdnatura.presentation.view.feature.collection.mapper import android.content.Context import es.verdnatura.R import es.verdnatura.presentation.common.convertToDateString +import es.verdnatura.presentation.view.feature.sacador.model.CollectionTicket import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO import java.text.SimpleDateFormat @@ -63,6 +64,27 @@ fun CollectionVO.map(context: Context): CollectionVO { return this } +fun CollectionTicket.map(context: Context): CollectionTicket { + try { + + this.tickets.forEach { ticket -> + ticket.sales.forEach { + it.level = ticket.level + it.rgb = ticket.rgb}} + + } catch (e: Exception) { + this.isError = true + if (this.tickets.isNullOrEmpty()) { + this.errorMessage = context.getString(R.string.collectionNoTicketsError) + } else { + + this.errorMessage = + context.getString(R.string.collectionErrorBuilding) + e.message.toString() + } + + } + return this +} private fun getCalendarFromDate(date: String,context:Context): Calendar { val sdf = SimpleDateFormat(context.getString(R.string.dateFormat)) val cal = Calendar.getInstance() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index f04a8f4b..0a76cf2c 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -133,7 +133,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { //Tarea 5651 - _pasillerositem.add( + _pasillerositem.add( PasillerosItemVO( 1, R.drawable.ic_advance_ticket, @@ -170,7 +170,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) ) //Tarea 5891 - _pasillerositem.add( + _pasillerositem.add( PasillerosItemVO( 3, R.drawable.ic_inventory_parking, @@ -194,17 +194,17 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) ) //tarea 4585 - _pasillerositem.add( - PasillerosItemVO( - 7, - R.drawable.ic_packing_mistake, - contextApp.getString(R.string.titlePackingMistake), - R.string.titlePackingMistake, - contextApp.getString( - R.string.titlePackingMistakeDescrip - ) + _pasillerositem.add( + PasillerosItemVO( + 7, + R.drawable.ic_packing_mistake, + contextApp.getString(R.string.titlePackingMistake), + R.string.titlePackingMistake, + contextApp.getString( + R.string.titlePackingMistakeDescrip ) ) + ) _pasillerositem.add( PasillerosItemVO( @@ -313,16 +313,16 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) ) - //Tarea #3986 - _pasillerositem.add( - PasillerosItemVO( - 31, - R.drawable.ic_cmr, - contextApp.getString(R.string.titleCMRState), - R.string.titleCMRState, - contextApp.getString(R.string.titleCMRDescrip) - ) - ) + //Tarea #3986 + _pasillerositem.add( + PasillerosItemVO( + 31, + R.drawable.ic_cmr, + contextApp.getString(R.string.titleCMRState), + R.string.titleCMRState, + contextApp.getString(R.string.titleCMRDescrip) + ) + ) _pasillerositem.add( PasillerosItemVO( 40, @@ -461,7 +461,20 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) ) ) - + val working_in_testMenu = false + if (working_in_testMenu) { + _pasillerositem.add( + PasillerosItemVO( + 7, + R.drawable.ic_picker_ui, + contextApp.getString(R.string.sacador_test), + R.string.sacador_test, + contextApp.getString( + R.string.sacador_test + ) + ) + ) + } //sergio para que aparezca el nuevo menu _pasillerositem.add( PasillerosItemVO( @@ -499,8 +512,8 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) ) - //Tarea 4678 - _pasillerositem.add( + //Tarea 4678 + _pasillerositem.add( PasillerosItemVO( 6, R.drawable.ic_delivery_truck, @@ -511,17 +524,16 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) - - //#tarea4021 - /* _pasillerositem.add( - PasillerosItemVO( - 6, - R.drawable.ic_packaging, - contextApp.getString(R.string.titlePackaging), - R.string.titlePackaging, - contextApp.getString(R.string.titlePackagingDescrip) - ) - )*/ + //#tarea4021 + /* _pasillerositem.add( + PasillerosItemVO( + 6, + R.drawable.ic_packaging, + contextApp.getString(R.string.titlePackaging), + R.string.titlePackaging, + contextApp.getString(R.string.titlePackagingDescrip) + ) + )*/ //Tarea 5322 _pasillerositem.add( PasillerosItemVO( @@ -533,8 +545,8 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { ) ) - val working_in_test=false - if (working_in_test){ + val working_in_test = false + if (working_in_test) { _pasillerositem.add( PasillerosItemVO( 6, @@ -543,7 +555,8 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { R.string.testing, contextApp.getString(R.string.testing) ) - )} + ) + } } @@ -563,65 +576,66 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) { } + fun inititializeDefaultDelivery() { - /* _pasillerositem.add( - PasillerosItemVO( - 30, - R.drawable.expedition_find, - contextApp.getString(R.string.titleLog), - R.string.titleLog, - contextApp.getString( - R.string.titleLogDescrip - ) - ) - ) - _pasillerositem.add( - PasillerosItemVO( - 30, - R.drawable.ic_info, - contextApp.getString(R.string.titleInfo), - R.string.titleInfo, - contextApp.getString( - R.string.titleInfoDescription - ) - ) - ) - /* _pasillerositem.add( - PasillerosItemVO( - 30, - R.drawable.ic_delivery_truck, - contextApp.getString(R.string.titleLoadTruck), - R.string.titleLoadTruckInfo, - contextApp.getString( - R.string.titleLoadTruckInfo - ) - ) - ) + /* _pasillerositem.add( + PasillerosItemVO( + 30, + R.drawable.expedition_find, + contextApp.getString(R.string.titleLog), + R.string.titleLog, + contextApp.getString( + R.string.titleLogDescrip + ) + ) + ) + _pasillerositem.add( + PasillerosItemVO( + 30, + R.drawable.ic_info, + contextApp.getString(R.string.titleInfo), + R.string.titleInfo, + contextApp.getString( + R.string.titleInfoDescription + ) + ) + ) + /* _pasillerositem.add( + PasillerosItemVO( + 30, + R.drawable.ic_delivery_truck, + contextApp.getString(R.string.titleLoadTruck), + R.string.titleLoadTruckInfo, + contextApp.getString( + R.string.titleLoadTruckInfo + ) + ) + ) - _pasillerositem.add( - PasillerosItemVO( - 30, - R.drawable.ic_delivery_truck, - contextApp.getString(R.string.titleUnLoadTruck), - R.string.titleUnLoadTruckInfo, - contextApp.getString( - R.string.titleUnLoadTruckInfo - ) - ) - ) -*/ + _pasillerositem.add( + PasillerosItemVO( + 30, + R.drawable.ic_delivery_truck, + contextApp.getString(R.string.titleUnLoadTruck), + R.string.titleUnLoadTruckInfo, + contextApp.getString( + R.string.titleUnLoadTruckInfo + ) + ) + ) + */ - _pasillerositem.add( - PasillerosItemVO( - 6, - R.drawable.ic_delivery_truck, - contextApp.getString(R.string.titleDeliverySummary), - R.string.titleDeliverySummary, - contextApp.getString(R.string.titleDeliverySummary) - ) - ) -*/ + _pasillerositem.add( + PasillerosItemVO( + 6, + R.drawable.ic_delivery_truck, + contextApp.getString(R.string.titleDeliverySummary), + R.string.titleDeliverySummary, + contextApp.getString(R.string.titleDeliverySummary) + ) + ) + */ _pasillerositem.add( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt index df8d78ce..40a5c304 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt @@ -1,5 +1,75 @@ package es.verdnatura.presentation.view.feature.sacador.model +//Tarea 5890 +// Sacado reservado + +class CollectionTicket( + var collectionFk: Int, + var created: String = "", + var ticketTotalCount: Int = 0, + var tickets: MutableList = mutableListOf(), + var isError: Boolean = false, + var errorMessage: String = "", +) + +data class Ticket( + val ticketFk: Int, + var level: String?, + var rgb: String?, + val agencyName: String, + val salesPersonFk: Int, + val observations: String?, + val warehouseFk: Int, + val sales: MutableList = mutableListOf() +) +data class Sale( + val itemShelvingSaleFk: Int, + val ticketFk: Int, + val saleGroupFk: Int?, + val saleFk: Int, + val itemFk: Int, + val longName: String, + val size: Int, + var semaphore: String?, + val color: String ="", + val productor: String?="", + val origin: String="", + val concept: String="", + val packing: Int?=null, + val grouping: Int?=null, + val isAdded: Int=0, + val workerFk: Int, + val packingShelve: Int = 0, + val hasMistake: Boolean?, + val originalQuantity: Int?, + var saleQuantity: Int, + var reservedQuantity: Int= 0 , + val code: String? = null, + val parkingCode: String?=null, + val pickingOrder: Int?=null, + var sonSales: MutableList = mutableListOf(), + var placements: List = listOf(), + var Barcodes: List = listOf(), + var isParent: Boolean = false, + //para agrupar + var totalSales: Int = 0, + //para mostar el level del ticket + var level: String? = "", + //para pintar color + var rgb: String? = "", + var isPicked: Int=0, + var accumulatedQuantity:Int=0, + var totalItemShelving: Int =0, + var currentItemShelving:Int = 0 + + +) + +class CollectionTicketList( + var list: List = listOf() +) +// colecciones anteriores + class CollectionListVO( var list: List = listOf() ) @@ -72,8 +142,8 @@ class SaleVO( var totalSales: Int = 0, var sonSales: MutableList = mutableListOf(), var code: String = "", - var hasMistake :Boolean = false, - var sectorFk : Int? = null + var hasMistake: Boolean = false, + var sectorFk: Int? = null ) @@ -126,3 +196,106 @@ class MistakeTypeListVO( var list: List = listOf() ) +val barcodes = listOf("12345678","87654321","11111111","00000000") + +val sale1 = Sale( + 13421890,4475590, null, 42272072, 24460, "Lilium Oriental Signum 4", 90, null, + "Blanco", "Bakker Lilies", "NLD", "LO Signum 4", 120, 10, 0, 24981, + 180, false, 10, 100, 10, null, null, 6, +) + +val sale2 = Sale( + 13421889,4474654, null, 42263590, 61148, "Paniculata Rainbow MA 40 gr", 75, null, + "Mixto", "Malima", "ECU", "PAN Rainbow MA 40 gr", 250, 25, 0, 24981, + 600, false, 25, 250, 30, null, null, 5 +) + +val sale3 = Sale( + 13421888,4475611, null, 42272185, 56628, "Lilium Oriental A2 Roselily 2", 70, null, + "Mixto", "Moerman Lilium BV", "NLD", "LO A2 Roselily 2", 40, 10, 0, 24981, + 200, false, 80, 800, 20, null, null, 4 +) + +val sale4 = Sale( + 13421887,4475611, null, 42272186, 34087, "Lilium Asiatico Brindisi 4-5", 95, null, + "Rosa", "Double Check Lily", "NLD", "LA Brindisi 4-5", 60, 10, 0, 24981, + 160, false, 60, 600, 10, null, null, 3 +) + +val sale5 = Sale( + 13421886,4474654, null, 42263585, 77582, "Clavel Red Fancy", 60, "2", + "Rojo", "Daliaflora", "COL", "CL Red FCY", 15, 25, 0, 24981, + 933, true, 250, 250, 30, "KQS", "GA-24-3", 1, Barcodes = barcodes +) + +val sale6 = Sale( + 13421885,4474654, null, 42263588, 117832, "Rosa Freedom", 50, "1", + "Rojo", "Multiflora", "COL", "RS Freedom", 200, 25, 0, 24981, + 403, true, 25, 250, 25, "IXF", "B-29-1", 2 +) +val sale7 = Sale( + 13421898,4475590, 222154, 42272074, 10067, "Brillo Floralife", 10, "3", + "Negro", null, "---", "Brillo Floralife", 12, 1, 0, 24981, + 179020, false, 3, 30, 30, null, "CH--43", 121930 +) +val sale8 = Sale( + 13421883,4475557, 222152, 42271653, 103803, "Bolsa Kraft Blanco", 1, null, + "Blanco", null, "NLD", "Bolsa Kraft Blanco", 250, 25, 0, 24981, + 1000, false, 25, 250, 250, null, "CH--43", 121930 +) +val listaDeSales: MutableList = mutableListOf(sale1, sale7) // 4475590 +val listaDeSales2: MutableList = mutableListOf(sale2, sale5, sale6) //4474654 +val listaDeSales3: MutableList = mutableListOf(sale3, sale4) //4475611 +val listaDeSales4: MutableList = mutableListOf(sale8) //4475557 + + +var ticketLocal = mutableListOf( + Ticket( + 4475590, + "ROJO", + "#ff0000", + "VIAEXPRESS Interdia", + 4994, + "", + 60, + sales = listaDeSales + ), + Ticket( + 4474654, + "AMARILLO", + "#ffce30", + "MRW ECOM-TARDE", + 4994, + "En agua", + 60, + sales = listaDeSales2 + ), + Ticket( + 4475611, + "VERDE", + "#008000", + "MRW ECOM-TARDE", + 6264, + "En seco", + 60, + sales = listaDeSales3 + ), + + Ticket( + 4475557, + "ROJO", + "#ff0000", + "VIAEXPRESS Interdia", + 4994, + "", + 60, + sales = listaDeSales4 + ), +) + +var collectionLocal = CollectionTicket( + 895071, + "2023-09-20", + 3, + tickets = ticketLocal +) diff --git a/app/src/main/res/layout/fragment_collection_new.xml b/app/src/main/res/layout/fragment_collection_new.xml new file mode 100644 index 00000000..90e083be --- /dev/null +++ b/app/src/main/res/layout/fragment_collection_new.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file