refs #5890 newSacador

This commit is contained in:
Sergio De la torre 2023-10-10 10:07:18 +02:00
parent 56437162ca
commit 6f94d7322f
5 changed files with 523 additions and 100 deletions

View File

@ -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<CollectionVO>
get() = _collectionTicketList
private val _collectionTicketSalix by lazy { MutableLiveData<CollectionTicket>() }
val collectionTicketSalix: LiveData<CollectionTicket>
get() = _collectionTicketSalix
private val _collectionTicketListLocal by lazy { MutableLiveData<CollectionTicket>() }
val collectionTicketListLocal: LiveData<CollectionTicket>
get() = _collectionTicketListLocal
private val _placementSuppleyList by lazy { MutableLiveData<PlacementSupplyListVO>() }
val placementSuppleyList: LiveData<PlacementSupplyListVO>
get() = _placementSuppleyList
@ -63,6 +76,18 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) {
val responseSaleTracking_mark: LiveData<ResponseItemVO>
get() = _responseSaleTracking_mark
private val _responseConfirmReservedItemShelvingSale by lazy { MutableLiveData<ResponseItemVO>() }
val responseConfirmReservedItemShelvingSale: LiveData<ResponseItemVO>
get() = _responseConfirmReservedItemShelvingSale
private val _responseConfirmReservedUpdate by lazy { MutableLiveData<ResponseItemVO>() }
val responseConfirmReservedUpdate: LiveData<ResponseItemVO>
get() = _responseConfirmReservedUpdate
private val _responseParking by lazy { MutableLiveData<ResponseItemVO>() }
val responseParking: LiveData<ResponseItemVO>
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<CollectionTicket>(context) {
override fun onError(t: Throwable) {
_collectionTicketSalix.value = CollectionTicket(
0,
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<CollectionTicket>) {
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<Any>(context) {
override fun onError(t: Throwable) {
_responseConfirmReservedItemShelvingSale.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
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<Any>(context) {
override fun onError(t: Throwable) {
_responseConfirmReservedUpdate.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
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<Any>(context) {
override fun onError(t: Throwable) {

View File

@ -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()

View File

@ -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(

View File

@ -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<Ticket> = 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<Sale> = 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<Sale> = mutableListOf(),
var placements: List<PlacementVO> = listOf(),
var Barcodes: List<String> = 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<CollectionTicket> = listOf()
)
// colecciones anteriores
class CollectionListVO(
var list: List<CollectionVO> = listOf()
)
@ -72,8 +142,8 @@ class SaleVO(
var totalSales: Int = 0,
var sonSales: MutableList<SaleVO> = 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<MistakeTypeVO> = 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<Sale> = mutableListOf(sale1, sale7) // 4475590
val listaDeSales2: MutableList<Sale> = mutableListOf(sale2, sale5, sale6) //4474654
val listaDeSales3: MutableList<Sale> = mutableListOf(sale3, sale4) //4475611
val listaDeSales4: MutableList<Sale> = 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
)

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:clickable="false">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/verdnatura_black"
>
<EditText
android:id="@+id/scan_input"
style="@style/ScanLineTextSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/Escaner"
android:inputType="textVisiblePassword"
android:lines="1"
android:maxLines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/main_toolbar"
android:paddingLeft="@dimen/default_layout_margin"/>
<ImageView
android:id="@+id/previaButton"
android:layout_width="32dp"
android:layout_height="32dp"
android:visibility="invisible"
android:tooltipText="Permite marcar las líneas de previa escaneando ticket"
app:srcCompat="@drawable/ic_streetview_black_24dp"
app:layout_constraintStart_toEndOf="@+id/scan_input"
app:layout_constraintTop_toTopOf="@+id/scan_input"
/>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/collection_swipe"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scan_input">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragment_sacador_collections"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
tools:listitem="@layout/sale_row_fragment" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/splash_progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/verdnatura_black_8_alpha_6"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible">
<com.airbnb.lottie.LottieAnimationView
android:layout_width="wrap_content"
android:layout_height="@dimen/verdnatura_logo_large_height"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/orange_loading"
app:lottie_speed="2" />
</LinearLayout>
<include
android:id="@+id/main_toolbar"
layout="@layout/toolbar_fragment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>