Versión 6.1.9 añadido función error para llamadas web, getSaleDay y teclado numérico

This commit is contained in:
Sergio De la torre 2021-10-28 11:18:22 +02:00
parent cf72038ee4
commit 4c0223d4af
86 changed files with 2791 additions and 935 deletions

View File

@ -23,9 +23,12 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/car_control.xml" value="0.22407407407407406" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/car_control.xml" value="0.22407407407407406" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/circleshape.xml" value="0.11979166666666667" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/circleshape.xml" value="0.11979166666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/component_progress.xml" value="0.11979166666666667" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/component_progress.xml" value="0.11979166666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/crane.xml" value="0.23802083333333332" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/day_of_sale.xml" value="0.184375" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/delete.xml" value="0.19166666666666668" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/delete.xml" value="0.19166666666666668" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/face_man_outline.xml" value="0.22708333333333333" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/face_man_outline.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/filter_outline.xml" value="0.22239583333333332" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/filter_outline.xml" value="0.22239583333333332" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/human_dolly.xml" value="0.2111111111111111" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_add_black_24dp.xml" value="0.22708333333333333" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_add_black_24dp.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_arrow_back_black_24dp.xml" value="0.22708333333333333" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_arrow_back_black_24dp.xml" value="0.22708333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_arrow_drop_down_black_24dp.xml" value="0.22708333333333333" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable/ic_arrow_drop_down_black_24dp.xml" value="0.22708333333333333" />
@ -84,8 +87,10 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_inventary.xml" value="0.11271529888551166" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_inventary.xml" value="0.11271529888551166" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_inventary_old.xml" value="0.22604166666666667" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_inventary_old.xml" value="0.22604166666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_item_card.xml" value="0.16666666666666666" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_item_card.xml" value="0.16666666666666666" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_itemdayofsale_card.xml" value="0.1693840579710145" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_itemexpeditionstate_card.xml" value="0.22" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_itemexpeditionstate_card.xml" value="0.22" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_itemproposal.xml" value="0.22" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_itemproposal.xml" value="0.22" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_itemshelvingdayofsale.xml" value="0.3333333333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_login.xml" value="0.22" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_login.xml" value="0.22" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_paletizador_menu.xml" value="0.13829787234042554" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_paletizador_menu.xml" value="0.13829787234042554" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_parking.xml" value="0.5" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/fragment_parking.xml" value="0.5" />
@ -100,11 +105,14 @@
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_article_row.xml" value="0.4466666666666667" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_article_row.xml" value="0.4466666666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_card_row.xml" value="0.2269021739130435" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_card_row.xml" value="0.2269021739130435" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_expeditionstate_row.xml" value="0.23489583333333333" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_expeditionstate_row.xml" value="0.23489583333333333" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_historicovehiculo_row.xml" value="0.18795289855072464" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_inventary_row.xml" value="0.22604166666666667" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_inventary_row.xml" value="0.22604166666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_itemshelvingdayofsale_row.xml" value="0.18206521739130435" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_location_row.xml" value="0.16875" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_location_row.xml" value="0.16875" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_pasilleros_main_menu.xml" value="0.13829787234042554" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_pasilleros_main_menu.xml" value="0.13829787234042554" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_proposal_row.xml" value="0.22604166666666667" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_proposal_row.xml" value="0.22604166666666667" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_reposicion.xml" value="0.1" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_reposicion.xml" value="0.1" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_shelvingdayofsale_row.xml" value="0.2375" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_smarttag_row.xml" value="0.20153985507246377" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_smarttag_row.xml" value="0.20153985507246377" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_worker_image.xml" value="0.23177083333333334" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/item_worker_image.xml" value="0.23177083333333334" />
<entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/toolbar.xml" value="0.15353260869565216" /> <entry key="..\:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/layout/toolbar.xml" value="0.15353260869565216" />

View File

@ -14,10 +14,11 @@ android {
applicationId "es.verdnatura" applicationId "es.verdnatura"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 74 versionCode 76
versionName "6.1.8.5" //VERSION CODE 74 . Modificado itemtrash, deprecated preferenceManager, quitados ;,puesto menu general al controlador versionName "6.1.9" //Sin subir, Modificado y añadido mensajes de error, añadido opcion Dia de venta y su parking, teclado numerico para controlador
//versionName "6.1.8.4.1" //VERSION CODE 73 . Modificar itemtrash // versionName "6.1.8.5" VERSION CODE 75 // 23-10-2021//VERSION CODE 74-75 .Pantalla "Dia de venta y parking" Modificado itemtrash, deprecated preferenceManager, quitados ;,puesto menu general al controlador
//versionName "6.1.8.4" //VERSION CODE 72 . Se añade ExpedtionScan para el Sorter, y modificion llamadas itemtrash y collectionGetTicket. //versionName "6.1.8.4.1" //VERSION CODE 73 . Modificar itemtrash
//versionName "6.1.8.4" //VERSION CODE 72 . Se añade ExpedtionScan para el Sorter, y modificion llamadas itemtrash y collectionGetTicket.
//versionName "6.1.8.3.1"//(VERSION CODE 71) Se añade ViewModel.collectionGet cuando se hace un collectionNew y un refresco de adapter //versionName "6.1.8.3.1"//(VERSION CODE 71) Se añade ViewModel.collectionGet cuando se hace un collectionNew y un refresco de adapter
//versionName "6.1.8.3" //(VERSION CODE 69) Tres campos más en pantalla cel1,cel2,cel3, obtener artículos similares con filtro, mostrar foto del sacador. //versionName "6.1.8.3" //(VERSION CODE 69) Tres campos más en pantalla cel1,cel2,cel3, obtener artículos similares con filtro, mostrar foto del sacador.
//versionName "6.1.8.2" //(VERSIONCODE 68) Menu Operaciones buffer, pantalla mas grande en control vehiculo, deletefragments a todos los menus. //versionName "6.1.8.2" //(VERSIONCODE 68) Menu Operaciones buffer, pantalla mas grande en control vehiculo, deletefragments a todos los menus.

Binary file not shown.

View File

@ -11,7 +11,7 @@
"type": "SINGLE", "type": "SINGLE",
"filters": [], "filters": [],
"attributes": [], "attributes": [],
"versionCode": 74, "versionCode": 75,
"versionName": "6.1.8.5", "versionName": "6.1.8.5",
"outputFile": "app-release.apk" "outputFile": "app-release.apk"
} }

BIN
app/release/vn-picking.apk Normal file

Binary file not shown.

View File

@ -10,6 +10,7 @@ import es.verdnatura.presentation.view.feature.calidad.fragment.QaualityViewMode
import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel import es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel
import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorViewModel import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorViewModel
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel
import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasViewModel import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasViewModel
import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoViewModel import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoViewModel
import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoViewModel import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoViewModel
@ -41,6 +42,10 @@ val viewModelModule = module {
viewModel { viewModel {
PasilleroViewModel(androidContext()) PasilleroViewModel(androidContext())
} }
//Pasilleros Dia de venta
viewModel {
DayOfSaleViewModel(androidContext())
}
// Pasilleros / Item Card // Pasilleros / Item Card
viewModel { viewModel {

View File

@ -0,0 +1,63 @@
package es.verdnatura.domain
import android.content.Context
import com.google.gson.JsonObject
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
import retrofit2.Call
class GetDayOfSaleUSerCase(context: Context) : RestClient(context) {
fun itemShelving_updateSpam(usuario: String, password: String,vShelvingFK:String): Call<Boolean> {
val params: ArrayList<String> = ArrayList()
params.add(vShelvingFK)
return restClient!!.itemShelving_updateSpam("json", "1", usuario, password, "application/json",params=params)
}
/* fun itemShelving_getSaleDateOld(
usuario: String,
password: String,
expeditionFk: String
): Call<JsonObject> {
val params: ArrayList<String> = ArrayList()
params.add(expeditionFk)
return restClient!!.itemShelving_getSaleDate(
"json",
"1",
usuario,
password,
"application/json",
params = params
)
}*/
fun itemShelving_getSaleDate(
usuario: String,
password: String,
vShelvingFk: String
): Call<List<ItemShelvingSaleDate>> {
val params: ArrayList<String> = ArrayList()
params.add(vShelvingFk)
return restClient!!.itemShelving_getSaleDate(
"json",
"1",
usuario,
password,
"application/json",
params
)
}
fun shelvingPark(
usuario: String,
password: String,
shelving: String,
parking: String
): Call<String> {
val params: ArrayList<String> = ArrayList()
params.add(shelving)
params.add(parking)
return restClient!!.shelvingPark("json", "1", usuario, password, "application/json", params)
}
}

View File

@ -89,11 +89,11 @@ class GetLoginUserCase(context: Context) : RestClient(context)
//SALIX MENSAJE :SERGIO: PARA NO ENVIAR MENSAJES A COMERCIALES PONGO QUE LAS MODIFICACIONES SE ENVIAN AL CANAL CREADO. //SALIX MENSAJE :SERGIO: PARA NO ENVIAR MENSAJES A COMERCIALES PONGO QUE LAS MODIFICACIONES SE ENVIAN AL CANAL CREADO.
fun sendChekingPresence(token:String,workerId:Int,message:String) : Call<Boolean>{ fun sendChekingPresence(token:String,workerId:Int,message:String) : Call<Boolean>{
return salixClient!!.sendChekingPresence(content_type = "application/json", authorization = token, params = SalixMessageVO(workerId = workerId,message = message)) return salixClient!!.sendChekingPresence(content_type = "application/json", authorization = token, params = SalixMessageVO(workerId = workerId,message = message))
} }
// SERGIO: PARA DESARROLLO Y PRUEBAS SE DESCOMENTA ESTAS LÍNEAS Y SE COMENTAN LAS DE ARRIBA // SERGIO: PARA DESARROLLO Y PRUEBAS SE DESCOMENTA ESTAS LÍNEAS Y SE COMENTAN LAS DE ARRIBA
/* fun sendChekingPresence(token: String, workerId: Int, message: String): Call<Boolean> /*fun sendChekingPresence(token: String, workerId: Int, message: String): Call<Boolean>
{ {
return salixClient!!.sendGroup( return salixClient!!.sendGroup(
content_type = "application/json", content_type = "application/json",

View File

@ -10,6 +10,7 @@ import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationA
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO
import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.collection.ItemVO
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
@ -834,6 +835,44 @@ interface VerdnaturaService {
): ):
Call<JsonObject> Call<JsonObject>
//DIA DE VENTA
@POST("almacennew/itemShelving_getSaleDateOld")//REVISADA
fun itemShelving_getSaleDateOld(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<JsonObject>
@POST("almacennew/itemShelving_getSaleDate")//REVISADA
fun itemShelving_getSaleDate(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<List<ItemShelvingSaleDate>>
@POST("almacennew/itemShelving_updateSpam")//REVISADA
fun itemShelving_updateSpam(
@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>
):
Call<Boolean>
@POST("almacennew/expeditionTruckList")//REVISADA @POST("almacennew/expeditionTruckList")//REVISADA
fun expeditionTruckList( fun expeditionTruckList(
@Header("aplicacion") aplicacion: String, @Header("aplicacion") aplicacion: String,

View File

@ -2,5 +2,71 @@ package es.verdnatura.presentation.base
import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import org.json.JSONObject
abstract class BaseViewModel : ViewModel(), LifecycleObserver abstract class BaseViewModel : ViewModel(), LifecycleObserver
fun nameofFunction(function: Any): String
{
return function.javaClass.enclosingMethod!!.name
}
fun getMessageFromResponse(ResponseMessage: String): String
{
return try
{
val answerError = JSONObject(ResponseMessage)
answerError.get("Message").toString()
} catch (e: Exception)
{
ResponseMessage
}
}
fun getMessageError(callFunction: String): String
{
return when (callFunction)
{
"collection_getTickets" -> "No hay tickets para sacar. Llamada $callFunction."
"collection_new_wagon" -> "No hay tickets para sacar. Llamada $callFunction."
else ->
{
"Error en la llamada $callFunction."
}
}
}
fun getMessageFromAllResponse(callFunction: String, ResponseMessage: String): String
{
var messageFromError: String
var returnMessage: String
try
{
val answerError = JSONObject(ResponseMessage)
messageFromError = answerError.get("Message").toString()
} catch (e: Exception)
{
messageFromError = ResponseMessage
}
// if (messageFromError.isEmpty()) {
//sergio:para personalizar los mensajes de respuesta según la llamada.
when (callFunction)
{
"collection_getTickets" -> returnMessage ="No hay tickets para sacar. Llamada $callFunction."
else ->
{
returnMessage = "Llamada $callFunction."
}
}
//}
return "$messageFromError.$returnMessage"
}

View File

@ -160,8 +160,8 @@ class ItemCardFragment(
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
this.itemFk = itemFk this.itemFk = itemFk
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.getItemCard(itemFk,warehouseFk,user,password) viewModel.getItemCard(itemFk,warehouseFk,user,password,"item_card")
viewModel.getItemPackingType(user,password) viewModel.getItemPackingType(user,password,"get_ItemPackingType")
} }
override fun observeViewModel() { override fun observeViewModel() {
@ -383,10 +383,10 @@ class ItemCardFragment(
// "itemStockUpdate" -> prepareItemStockUpdate(item,value) // "itemStockUpdate" -> prepareItemStockUpdate(item,value)
"itemStockUpdateAdd" -> prepareItemStockUpdate2(item,value) "itemStockUpdateAdd" -> prepareItemStockUpdate2(item,value)
"itemStockUpdateRemove" -> prepareItemStockUpdate2(item,value) "itemStockUpdateRemove" -> prepareItemStockUpdate2(item,value)
"itemPlacementSave" -> viewModel.itemPlacementSave(itemFk = itemFk, warehouseFk = warehouseFk, user = user, password = password, value = value) "itemPlacementSave" -> viewModel.itemPlacementSave(itemFk = itemFk, warehouseFk = warehouseFk, user = user, password = password, value = value,"itemPlacementSave")
"updateGrouping" -> viewModel.updateGrouping(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk) "updateGrouping" -> viewModel.updateGrouping(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk,"buy_updateGrouping")
"updatePacking" -> viewModel.updatePacking(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk) "updatePacking" -> viewModel.updatePacking(itemFk = itemFk, user = user, password = password, value = value,warehouseFk = warehouseFk,"buy_updateGrouping")
"itemSaveMin" -> viewModel.itemSaveMin(itemFk = itemFk, user = user, password = password, value = value) "itemSaveMin" -> viewModel.itemSaveMin(itemFk = itemFk, user = user, password = password, value = value,"itemSaveMin")
} }
if(item.action != "itemStockUpdate") if(item.action != "itemStockUpdate")
@ -456,13 +456,13 @@ class ItemCardFragment(
if (itemB.action == "itemStockUpdateRemove") { if (itemB.action == "itemStockUpdateRemove") {
customDialogTwo.setTitle(itemB.title!!).setDescription("Indica la causa de eliminar stock:").setOkButton("Falta"){ customDialogTwo.setTitle(itemB.title!!).setDescription("Indica la causa de eliminar stock:").setOkButton("Falta"){
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0") viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "0","itemTrash")
//changeOfflineValue(itemB,value, listBarcodes) //changeOfflineValue(itemB,value, listBarcodes)
showProgress() showProgress()
customDialogTwo.dismiss() customDialogTwo.dismiss()
}.setOkButtonTwo("Basura"){ }.setOkButtonTwo("Basura"){
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "1") viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = value,isTrash = "1","itemTrash")
//changeOfflineValue(itemB,value, listBarcodes) //changeOfflineValue(itemB,value, listBarcodes)
showProgress() showProgress()
customDialogTwo.dismiss() customDialogTwo.dismiss()
@ -474,7 +474,7 @@ class ItemCardFragment(
}else{ }else{
//changeOfflineValue(itemB,value, listBarcodes) //changeOfflineValue(itemB,value, listBarcodes)
showProgress() showProgress()
viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = (value.toInt() * -1).toString(),isTrash = "0") viewModel.itemTrash(itemFk = itemFk,warehouseFk = warehouseFk,user = user,password = password,newValue = (value.toInt() * -1).toString(),isTrash = "0","itemTrash")
} }
}catch (e:Exception){ }catch (e:Exception){
itemcard_layout.visibility = View.GONE itemcard_layout.visibility = View.GONE
@ -534,7 +534,7 @@ class ItemCardFragment(
}else{ }else{
listBarcodes.add(BarcodeVO(code)) listBarcodes.add(BarcodeVO(code))
} }
viewModel.barcodesEdit(itemFk = itemFk, user = user, password = password, value = code, delete = delete) viewModel.barcodesEdit(itemFk = itemFk, user = user, password = password, value = code, delete = delete,"itemBarcode_update")
barcodeAdapter!!.notifyDataSetChanged() barcodeAdapter!!.notifyDataSetChanged()
//changeOfflineValue(item,"", listBarcodes) //changeOfflineValue(item,"", listBarcodes)
showProgress() showProgress()
@ -558,7 +558,7 @@ class ItemCardFragment(
private fun updateItemPackingType(itemPackingType:String) { private fun updateItemPackingType(itemPackingType:String) {
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.updatePackingType(this.itemFk,user,password,itemPackingType) viewModel.updatePackingType(this.itemFk,user,password,itemPackingType,"item_updatePackingType")
} }
} }

View File

@ -7,6 +7,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.domain.GetItemCardUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.articulo.model.* import es.verdnatura.presentation.view.feature.articulo.model.*
import retrofit2.Call import retrofit2.Call
@ -39,28 +41,28 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
fun getItemCard(itemFk:String,warehouseFk:String,user:String,password:String) { fun getItemCard(itemFk:String,warehouseFk:String,user:String,password:String,callFunction:String) {
getItemCardUserCase.getItemCard(user,password,itemFk,warehouseFk).enqueue(object :Callback<ItemCardVO>{ getItemCardUserCase.getItemCard(user,password,itemFk,warehouseFk).enqueue(object :Callback<ItemCardVO>{
override fun onFailure(call: Call<ItemCardVO>, t: Throwable) { override fun onFailure(call: Call<ItemCardVO>, t: Throwable) {
_itemcard.value = ItemCardVO(isError = true,errorMessage = "Error al OBTENER "+itemFk+ " Respuesta:"+t.message!!) _itemcard.value = ItemCardVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<ItemCardVO>, response: Response<ItemCardVO>) { override fun onResponse(call: Call<ItemCardVO>, response: Response<ItemCardVO>) {
if (response.body() != null){ if (response.body() != null){
_itemcard.value = response.body()!! _itemcard.value = response.body()!!
}else{ }else{
_itemcard.value = ItemCardVO(isError = true,errorMessage = "Error al llamar a vn.itemCard") _itemcard.value = ItemCardVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} }
} }
}) })
} }
fun item_getSimilar(itemFk:String, warehouseFk: String, vShipped: String, vIsShowedByType:String, user:String, password:String) { fun item_getSimilar(itemFk:String, warehouseFk: String, vShipped: String, vIsShowedByType:String, user:String, password:String,callFunction:String) {
getItemCardUserCase.item_getSimilar(user,password,itemFk,warehouseFk,vShipped,vIsShowedByType).enqueue(object :Callback<List<ItemProposal>>{ getItemCardUserCase.item_getSimilar(user,password,itemFk,warehouseFk,vShipped,vIsShowedByType).enqueue(object :Callback<List<ItemProposal>>{
override fun onFailure(call: Call<List<ItemProposal>>, t: Throwable) { override fun onFailure(call: Call<List<ItemProposal>>, t: Throwable) {
val listError:ArrayList<ItemProposal> = ArrayList() val listError:ArrayList<ItemProposal> = ArrayList()
listError.add(ItemProposal(isError = true,errorMessage = t.message!!)) listError.add(ItemProposal(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_itemProposallist.value = ItemProposalList(listError) _itemProposallist.value = ItemProposalList(listError)
} }
@ -71,7 +73,7 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
}else{ }else{
val listError:ArrayList<ItemProposal> = ArrayList() val listError:ArrayList<ItemProposal> = ArrayList()
listError.add(ItemProposal(isError = true,errorMessage = "Error en la llamada de getItemPackingType")) listError.add(ItemProposal(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_itemProposallist.value = ItemProposalList(listError) _itemProposallist.value = ItemProposalList(listError)
} }
@ -81,12 +83,12 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
} }
fun getItemPackingType(user:String,password:String) { fun getItemPackingType(user:String,password:String,callFunction:String) {
getItemCardUserCase.getItemPackingType(user,password).enqueue(object : getItemCardUserCase.getItemPackingType(user,password).enqueue(object :
Callback<List<ItemPackingType>>{ Callback<List<ItemPackingType>>{
override fun onFailure(call: Call<List<ItemPackingType>>, t: Throwable) { override fun onFailure(call: Call<List<ItemPackingType>>, t: Throwable) {
val listError:ArrayList<ItemPackingType> = ArrayList() val listError:ArrayList<ItemPackingType> = ArrayList()
listError.add(ItemPackingType(isError = true,errorMessage = t.message!!)) listError.add(ItemPackingType(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_itemspackinglist.value = ItemPackingTypeList(listError) _itemspackinglist.value = ItemPackingTypeList(listError)
} }
@ -96,7 +98,7 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
}else{ }else{
val listError:ArrayList<ItemPackingType> = ArrayList() val listError:ArrayList<ItemPackingType> = ArrayList()
listError.add(ItemPackingType(isError = true,errorMessage = "Error en la llamada de getItemPackingType")) listError.add(ItemPackingType(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_itemspackinglist.value = ItemPackingTypeList(listError) _itemspackinglist.value = ItemPackingTypeList(listError)
} }
} }
@ -106,15 +108,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){ fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String,callFunction:String){
getItemCardUserCase.itemStockUpdate(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{ getItemCardUserCase.itemStockUpdate(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada $callFunction."+t.message!!)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate") _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada $callFunction")
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -124,15 +126,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){ fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String,callFunction:String){
getItemCardUserCase.itemTrash(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{ getItemCardUserCase.itemTrash(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemTrash") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -142,15 +144,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemPlacementSave(itemFk:String,warehouseFk:String,user:String,password:String,value:String){ fun itemPlacementSave(itemFk:String,warehouseFk:String,user:String,password:String,value:String,callFunction:String){
getItemCardUserCase.itemPlacementSave(user,password,itemFk,warehouseFk,value).enqueue(object : Callback<String>{ getItemCardUserCase.itemPlacementSave(user,password,itemFk,warehouseFk,value).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar NICHO "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemPlacementSave") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -160,15 +162,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun updateGrouping(itemFk:String,user:String,password:String,value:String,warehouseFk: String){ fun updateGrouping(itemFk:String,user:String,password:String,value:String,warehouseFk: String,callFunction:String){
getItemCardUserCase.updateGrouping(user,password,itemFk,value,warehouseFk).enqueue(object : Callback<String>{ getItemCardUserCase.updateGrouping(user,password,itemFk,value,warehouseFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar GROUPING "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updateGrouping") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -178,15 +180,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun updatePacking(itemFk:String,user:String,password:String,value:String,warehouseFk: String){ fun updatePacking(itemFk:String,user:String,password:String,value:String,warehouseFk: String,callFunction:String){
getItemCardUserCase.updatePacking(user,password,itemFk,value,warehouseFk).enqueue(object : Callback<String>{ getItemCardUserCase.updatePacking(user,password,itemFk,value,warehouseFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar PACKING "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePacking") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -197,15 +199,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
} }
//sergio ver como solucionar el tema del "Finish" //sergio ver como solucionar el tema del "Finish"
fun updatePackingType(itemFk:String,user:String,password:String,itemPackingType:String){ fun updatePackingType(itemFk:String,user:String,password:String,itemPackingType:String,callFunction:String){
getItemCardUserCase.updatePackingType(user,password,itemFk,itemPackingType).enqueue(object : Callback<Boolean>{ getItemCardUserCase.updatePackingType(user,password,itemFk,itemPackingType).enqueue(object : Callback<Boolean>{
override fun onFailure(call: Call<Boolean>, t: Throwable) { override fun onFailure(call: Call<Boolean>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar PackingType "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) { override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePackingType") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
//if (response.body()=="Finish"){ //if (response.body()=="Finish"){
// //Log.i("VERDNATURA:","Fisnih encontrado")} // //Log.i("VERDNATURA:","Fisnih encontrado")}
@ -217,15 +219,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemSaveMin(itemFk:String,user:String,password:String,value:String){ fun itemSaveMin(itemFk:String,user:String,password:String,value:String,callFunction:String){
getItemCardUserCase.itemSaveMin(user,password,itemFk,value).enqueue(object : Callback<String>{ getItemCardUserCase.itemSaveMin(user,password,itemFk,value).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar MIN "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada updatePacking") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -235,15 +237,15 @@ class ItemCardViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun barcodesEdit(itemFk:String,user:String,password:String,value:String,delete:String){ fun barcodesEdit(itemFk:String,user:String,password:String,value:String,delete:String,callFunction:String){
getItemCardUserCase.barcodes_edit(user,password,itemFk,value,delete).enqueue(object : Callback<String>{ getItemCardUserCase.barcodes_edit(user,password,itemFk,value,delete).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar BARCODES "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemBarcode_update") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }

View File

@ -83,7 +83,7 @@ class ItemProposalFragment(
vShipped = currentDay(), vShipped = currentDay(),
vIsShowedByType = "TRUE", vIsShowedByType = "TRUE",
user = user, user = user,
password = password password = password,"item_getSimilar"
) )
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
} }
@ -137,7 +137,7 @@ class ItemProposalFragment(
vShipped = currentDay(), vShipped = currentDay(),
user = user, user = user,
password = password password = password
) ,callFunction = "item_getSimilar")
} }
if (item == iconFilter) { if (item == iconFilter) {
@ -172,8 +172,8 @@ class ItemProposalFragment(
vIsShowedByType = filter, vIsShowedByType = filter,
vShipped = currentDay(), vShipped = currentDay(),
user = user, user = user,
password = password password = password ,
) callFunction = "item_getSimilar")
} }
} }

View File

@ -90,16 +90,16 @@ class BufferFragment(
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
if (entryPoint.equals("Vaciado buffer")){ if (entryPoint.equals("Vaciado buffer")){
viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"UNLOADING") viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"UNLOADING","buffer_setTypeByName")
} }
if (entryPoint.equals("Llenado buffer")){ if (entryPoint.equals("Llenado buffer")){
viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"LOADING") viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"LOADING","buffer_setTypeByName")
} }
if (entryPoint.equals("Acumulación buffer")){ if (entryPoint.equals("Acumulación buffer")){
viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"ACCUMULATION") viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"ACCUMULATION","buffer_setTypeByName")
} }
if (entryPoint.equals("Desactivado buffer")){ if (entryPoint.equals("Desactivado buffer")){
viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"DISABLED") viewModel.buffer_setTypeByName(user,password,scan_input.text.toString(),"DISABLED","buffer_setTypeByName")
} }
} }

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.domain.GetPaletizadoresUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
@ -26,7 +28,7 @@ class BufferFragmentViewModel(context: Context) : BaseViewModel() {
get() = _bufferresponse get() = _bufferresponse
fun buffer_setTypeByName(user: String, password: String, vBufferFk: String, vType: String) { fun buffer_setTypeByName(user: String, password: String, vBufferFk: String, vType: String,callFunction:String){
GetPaletizadoresUserCase.buffer_setTypeByName(user, password, vBufferFk, vType) GetPaletizadoresUserCase.buffer_setTypeByName(user, password, vBufferFk, vType)
.enqueue(object : Callback<Boolean> { .enqueue(object : Callback<Boolean> {
override fun onFailure(call: Call<Boolean>, t: Throwable) { override fun onFailure(call: Call<Boolean>, t: Throwable) {
@ -34,15 +36,14 @@ class BufferFragmentViewModel(context: Context) : BaseViewModel() {
_itembuffertype.value = ResponseItemVO( _itembuffertype.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error al realizar operación con buffer.Respuesta:" + t.message!! errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
)
} }
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) { override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
// Log.i("VERDNATURA:", "la respuesta es ${response.body()!!}")
if (response.body() != null && response.body() == true) { if (response.body() != null && response.body() == true) {
// _bufferresponse.value = response.body()!!
_itembuffertype.value = ResponseItemVO( _itembuffertype.value = ResponseItemVO(
isError = false, isError = false,
errorMessage = "" errorMessage = ""
@ -52,8 +53,8 @@ class BufferFragmentViewModel(context: Context) : BaseViewModel() {
//_bufferresponse.value = false //_bufferresponse.value = false
_itembuffertype.value = ResponseItemVO( _itembuffertype.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error al realizar operación con buffer." errorMessage = getMessageFromAllResponse(callFunction,response.message()))
)
} }
} }

View File

@ -78,7 +78,7 @@ class BuscarItemFragment(
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
this.itemFk = itemFk this.itemFk = itemFk
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.getLocations(user,password,itemFk) viewModel.getLocations(user,password,itemFk,"getItemUbication")
} }
override fun observeViewModel() { override fun observeViewModel() {

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetBuscarItemUserCase import es.verdnatura.domain.GetBuscarItemUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO
import es.verdnatura.presentation.view.feature.buscaritem.model.LocationListVO import es.verdnatura.presentation.view.feature.buscaritem.model.LocationListVO
@ -25,11 +27,11 @@ class BuscarItemViewModel(context: Context) : BaseViewModel() {
val loadLocationList = Transformations.map(_locationList) { Event(it) } val loadLocationList = Transformations.map(_locationList) { Event(it) }
fun getLocations(user:String,password:String,itemFk:String){ fun getLocations(user:String,password:String,itemFk:String,callFunction:String){
getBuscarItemUserCase.searchItemsUbicador(user,password,itemFk).enqueue(object : Callback<List<ItemLocationVO>> { getBuscarItemUserCase.searchItemsUbicador(user,password,itemFk).enqueue(object : Callback<List<ItemLocationVO>> {
override fun onFailure(call: Call<List<ItemLocationVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemLocationVO>>, t: Throwable) {
val listError:ArrayList<ItemLocationVO> = ArrayList() val listError:ArrayList<ItemLocationVO> = ArrayList()
listError.add(ItemLocationVO(isError = true,errorMessage = t.message!!)) listError.add(ItemLocationVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_locationList.value = LocationListVO(listError) _locationList.value = LocationListVO(listError)
} }
@ -41,7 +43,7 @@ class BuscarItemViewModel(context: Context) : BaseViewModel() {
_locationList.value = response.body()?.let { LocationListVO(it) } _locationList.value = response.body()?.let { LocationListVO(it) }
}else{ }else{
val listError:ArrayList<ItemLocationVO> = ArrayList() val listError:ArrayList<ItemLocationVO> = ArrayList()
listError.add(ItemLocationVO(isError = true,errorMessage = "Error en la llamada de searchItemsUbicador")) listError.add(ItemLocationVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_locationList.value = LocationListVO(listError) _locationList.value = LocationListVO(listError)
} }
} }

View File

@ -113,7 +113,7 @@ class BuscarItemAllFragment(
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
this.itemFk = itemFk this.itemFk = itemFk
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.getLocationsAll(user,password,itemFk) viewModel.getLocationsAll(user,password,itemFk,"getItemUbication")
} }
override fun observeViewModel() { override fun observeViewModel() {

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetBuscarItemAllUserCase import es.verdnatura.domain.GetBuscarItemAllUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationAll import es.verdnatura.presentation.view.feature.buscaritemall.model.ItemLocationAll
import es.verdnatura.presentation.view.feature.buscaritemall.model.LocationListAll import es.verdnatura.presentation.view.feature.buscaritemall.model.LocationListAll
@ -26,11 +28,11 @@ class BuscarItemAllViewModel(context: Context) : BaseViewModel() {
val loadLocationListAll = Transformations.map(_locationListAll) { Event(it) } val loadLocationListAll = Transformations.map(_locationListAll) { Event(it) }
fun getLocationsAll(user:String,password:String,itemFk:String){ fun getLocationsAll(user:String,password:String,itemFk:String,callFunction:String){
getBuscarItemAllUserCase.searchItemsUbicadorAll(user,password,itemFk).enqueue(object : Callback<List<ItemLocationAll>> { getBuscarItemAllUserCase.searchItemsUbicadorAll(user,password,itemFk).enqueue(object : Callback<List<ItemLocationAll>> {
override fun onFailure(call: Call<List<ItemLocationAll>>, t: Throwable) { override fun onFailure(call: Call<List<ItemLocationAll>>, t: Throwable) {
val listError:ArrayList<ItemLocationAll> = ArrayList() val listError:ArrayList<ItemLocationAll> = ArrayList()
listError.add(ItemLocationAll(isError = true,errorMessage = t.message!!)) listError.add(ItemLocationAll(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_locationListAll.value = LocationListAll(listError) _locationListAll.value = LocationListAll(listError)
} }
@ -42,7 +44,7 @@ class BuscarItemAllViewModel(context: Context) : BaseViewModel() {
_locationListAll.value = response.body()?.let { LocationListAll(it) } _locationListAll.value = response.body()?.let { LocationListAll(it) }
}else{ }else{
val listError:ArrayList<ItemLocationAll> = ArrayList() val listError:ArrayList<ItemLocationAll> = ArrayList()
listError.add(ItemLocationAll(isError = true,errorMessage = "Error en la llamada de searchItemsUbicadorAll")) listError.add(ItemLocationAll(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_locationListAll.value = LocationListAll(listError) _locationListAll.value = LocationListAll(listError)
} }
} }

View File

@ -54,7 +54,7 @@ class BuyersFragment : BaseFragment<BuyersFragmentBinding,BuyersViewModel>(Buyer
password = prefs.getString(PASSWORD,"").toString() password = prefs.getString(PASSWORD,"").toString()
sectorFk = prefs.getInt(SECTORFK,1).toString() sectorFk = prefs.getInt(SECTORFK,1).toString()
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
viewModel.itemShelvingBuyerGet(user = user,password = password) viewModel.itemShelvingBuyerGet(user = user,password = password,"itemShelving_BuyerGet")
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
} }
@ -76,7 +76,7 @@ class BuyersFragment : BaseFragment<BuyersFragmentBinding,BuyersViewModel>(Buyer
override fun onOptionsItemSelected(item: Drawable) { override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){ if (item == iconReload){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.itemShelvingBuyerGet(user = user,password = password) viewModel.itemShelvingBuyerGet(user = user,password = password,"itemShelving_BuyerGet")
} }
} }

View File

@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetQualityUserCase import es.verdnatura.domain.GetQualityUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO
@ -21,12 +23,12 @@ class BuyersViewModel(context: Context) : BaseViewModel() {
val buyersList: LiveData<BuyerListVO> val buyersList: LiveData<BuyerListVO>
get() = _buyersList get() = _buyersList
fun itemShelvingBuyerGet(user:String,password:String){ fun itemShelvingBuyerGet(user:String,password:String,callFunction:String){
getQualityUserCase.itemShelvingBuyerGet(user,password).enqueue(object : getQualityUserCase.itemShelvingBuyerGet(user,password).enqueue(object :
Callback<List<BuyerVO>> { Callback<List<BuyerVO>> {
override fun onFailure(call: Call<List<BuyerVO>>, t: Throwable) { override fun onFailure(call: Call<List<BuyerVO>>, t: Throwable) {
val listError:ArrayList<BuyerVO> = ArrayList() val listError:ArrayList<BuyerVO> = ArrayList()
listError.add(BuyerVO(isError = true,errorMessage = t.message!!)) listError.add(BuyerVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_buyersList.value = BuyerListVO(listError) _buyersList.value = BuyerListVO(listError)
} }
@ -38,7 +40,7 @@ class BuyersViewModel(context: Context) : BaseViewModel() {
_buyersList.value = response.body()?.let { BuyerListVO(it) } _buyersList.value = response.body()?.let { BuyerListVO(it) }
}else{ }else{
val listError:ArrayList<BuyerVO> = ArrayList() val listError:ArrayList<BuyerVO> = ArrayList()
listError.add(BuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelving_buyerGet")) listError.add(BuyerVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,response.message())))
_buyersList.value = BuyerListVO(listError) _buyersList.value = BuyerListVO(listError)
} }
} }

View File

@ -61,7 +61,7 @@ class QaualityFragment(
password = prefs.getString(PASSWORD,"").toString() password = prefs.getString(PASSWORD,"").toString()
sectorFk = prefs.getInt(SECTORFK,1).toString() sectorFk = prefs.getInt(SECTORFK,1).toString()
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk,"itemShelving_BuyerTask")
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
} }
@ -89,7 +89,7 @@ class QaualityFragment(
override fun onOptionsItemSelected(item: Drawable) { override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){ if (item == iconReload){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk,"itemShelving_BuyerTask")
} }
} }
}) })
@ -131,7 +131,7 @@ class QaualityFragment(
}) })
response.observe(viewLifecycleOwner, Observer { response.observe(viewLifecycleOwner, Observer {
viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk) viewModel.itemShelvingBuyerTask(user = user,password = password,userFk = userFk,"itemShelving_BuyerTask")
}) })
} }
} }

View File

@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetQualityUserCase import es.verdnatura.domain.GetQualityUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
@ -28,12 +30,12 @@ class QaualityViewModel(context: Context) : BaseViewModel() {
get() = _response get() = _response
fun itemShelvingBuyerTask(user:String,password:String,userFk:String){ fun itemShelvingBuyerTask(user:String,password:String,userFk:String,callFunction:String){
getQualityUserCase.itemShelvingBuyerTask(user,password,userFk).enqueue(object : getQualityUserCase.itemShelvingBuyerTask(user,password,userFk).enqueue(object :
Callback<List<ItemBuyerVO>> { Callback<List<ItemBuyerVO>> {
override fun onFailure(call: Call<List<ItemBuyerVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemBuyerVO>>, t: Throwable) {
val listError:ArrayList<ItemBuyerVO> = ArrayList() val listError:ArrayList<ItemBuyerVO> = ArrayList()
listError.add(ItemBuyerVO(isError = true,errorMessage = t.message!!)) listError.add(ItemBuyerVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_buyersList.value = ItemBuyerListVO(listError) _buyersList.value = ItemBuyerListVO(listError)
} }
@ -45,7 +47,7 @@ class QaualityViewModel(context: Context) : BaseViewModel() {
_buyersList.value = response.body()?.let { ItemBuyerListVO(it) } _buyersList.value = response.body()?.let { ItemBuyerListVO(it) }
}else{ }else{
val listError:ArrayList<ItemBuyerVO> = ArrayList() val listError:ArrayList<ItemBuyerVO> = ArrayList()
listError.add(ItemBuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelvingBuyerTask")) listError.add(ItemBuyerVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_buyersList.value = ItemBuyerListVO(listError) _buyersList.value = ItemBuyerListVO(listError)
} }
} }
@ -56,12 +58,13 @@ class QaualityViewModel(context: Context) : BaseViewModel() {
fun itemShelvingStarsUpdate(usuario:String,password:String, vId: String,vStars: String) { fun itemShelvingStarsUpdate(usuario:String,password:String, vId: String,vStars: String) {
getQualityUserCase.itemShelvingStarsUpdate(usuario,password,vId,vStars).enqueue(object : Callback<String>{ getQualityUserCase.itemShelvingStarsUpdate(usuario,password,vId,vStars).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelving_StarsUpdate."+t.message!!)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingStarsUpdate") _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelving_StarsUpdate")
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }

View File

@ -7,6 +7,7 @@ import android.graphics.drawable.Drawable
import android.media.MediaPlayer import android.media.MediaPlayer
import android.os.Bundle import android.os.Bundle
import android.speech.SpeechRecognizer import android.speech.SpeechRecognizer
import android.text.InputType
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
@ -120,12 +121,12 @@ class CollectionFragment(
if ((collection.collectionFk != null) && type.equals(CONTROLADOR)) { if ((collection.collectionFk != null) && type.equals(CONTROLADOR)) {
//sergio: comprueba si viene de la pantalla de controlador //sergio: comprueba si viene de la pantalla de controlador
viewModel.ticketOrCollection_checkFullyControlled(user, password, collection.collectionFk) viewModel.ticketOrCollection_checkFullyControlled(user, password, collection.collectionFk,"ticketOrCollection_checkFullyControlled")
workerFkFromTicket=collection.tickets.get(0).sales.get(0).workerFk workerFkFromTicket=collection.tickets.get(0).sales.get(0).workerFk
} }
if (collection.tickets.isEmpty()) { if (collection.tickets.isEmpty()) {
viewModel.collectionTicketGet(user, password, collection.collectionFk, sectorFk, type) viewModel.collectionTicketGet(user, password, collection.collectionFk, sectorFk, type,"collection_getTickets")
} }
@ -237,6 +238,9 @@ class CollectionFragment(
} }
//ESCANER ========= //ESCANER =========
hideKeyboards() hideKeyboards()
if (type.equals(CONTROLADOR)){
scan_input.inputType= InputType.TYPE_CLASS_NUMBER
}
scan_input.requestFocus() scan_input.requestFocus()
scan_input.setOnEditorActionListener { v, actionId, event -> scan_input.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)
@ -265,7 +269,7 @@ class CollectionFragment(
collection.collectionFk, collection.collectionFk,
sectorFk, sectorFk,
type type
) ,"collection_getTickets")
collection_swipe.isRefreshing = false collection_swipe.isRefreshing = false
} }
} }
@ -335,7 +339,7 @@ class CollectionFragment(
collection.collectionFk, collection.collectionFk,
sectorFk, sectorFk,
type type
) ,"collection_getTickets")
// //Log.i("VERDNATURA:","La collection es ${collection.collectionFk}") // //Log.i("VERDNATURA:","La collection es ${collection.collectionFk}")
} }
@ -401,7 +405,7 @@ class CollectionFragment(
} }
.setKoButton("Revisar"){ .setKoButton("Revisar"){
splash_progress.visibility=View.VISIBLE splash_progress.visibility=View.VISIBLE
viewModel.collectionTicketGet(user, password, it.response, sectorFk, type) viewModel.collectionTicketGet(user, password, it.response, sectorFk, type,"collection_getTickets")
customDialog.dismiss() customDialog.dismiss()
} }
customDialog.show() customDialog.show()
@ -411,6 +415,16 @@ class CollectionFragment(
} }
}) })
responseSalixMessage.observe(viewLifecycleOwner, Observer{
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}
})
} }
} }
@ -618,7 +632,8 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
ticketFk = tickets[0], ticketFk = tickets[0],
parking = txtscan parking = txtscan,
"shelvingPark"
) )
} }
Timber.i("La coleccion es "+tickets[0]) Timber.i("La coleccion es "+tickets[0])
@ -661,7 +676,8 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
ticketFk = tickets[0], ticketFk = tickets[0],
parking = txtscan parking = txtscan,
"shelvingPark"
) )
} }
if (mpok != null) mpok!!.start() if (mpok != null) mpok!!.start()
@ -672,10 +688,10 @@ class CollectionFragment(
storedBackPosition = 0 storedBackPosition = 0
if (type != PRECHECKER) { if (type != PRECHECKER) {
viewModel.collectionTicketGet(user, password, txtscan, sectorFk, type) viewModel.collectionTicketGet(user, password, txtscan, sectorFk, type,"collection_getTickets")
if (type.equals(CONTROLADOR)) { if (type.equals(CONTROLADOR)) {
viewModel.ticketOrCollection_checkFullyControlled(user, password, txtscan) viewModel.ticketOrCollection_checkFullyControlled(user, password, txtscan,"ticketOrCollection_checkFullyControlled")
} }
} else { } else {
splash_progress.visibility = View.GONE splash_progress.visibility = View.GONE
@ -732,7 +748,8 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
ticketFk = it, ticketFk = it,
parking = txtscan parking = txtscan,
"shelvingPark"
) )
} }
if (mpok != null) mpok!!.start() if (mpok != null) mpok!!.start()
@ -807,7 +824,8 @@ class CollectionFragment(
vIsChecked = if (type == SACADOR) sales[position].isPrepared else if (type == CONTROLADOR) sales[position].isControlled else "1", vIsChecked = if (type == SACADOR) sales[position].isPrepared else if (type == CONTROLADOR) sales[position].isControlled else "1",
vOriginalQuantity = sales[position].pickedQuantity, vOriginalQuantity = sales[position].pickedQuantity,
vStateFk = type,//type.toString(), vStateFk = type,//type.toString(),
vBuyFk = originalItemScan vBuyFk = originalItemScan,
callFunction = "saleTrackingReplace"
) )
//Log.i("VERDNATURA:","POSICION $position y el vStateFk $type") //Log.i("VERDNATURA:","POSICION $position y el vStateFk $type")
//Log.i("VERDNATURA:","vIscheked es ${if(type == CONTROLADOR) sales[position].isControlled else "1"}") //Log.i("VERDNATURA:","vIscheked es ${if(type == CONTROLADOR) sales[position].isControlled else "1"}")
@ -829,7 +847,8 @@ class CollectionFragment(
viewModel.saleTrackingDel( viewModel.saleTrackingDel(
usuario = user, usuario = user,
password = password, password = password,
saleFk = sales[position].saleFk saleFk = sales[position].saleFk,
"saleTracking_del"
) )
} }
setTotalLines() setTotalLines()
@ -860,7 +879,8 @@ class CollectionFragment(
password = password, password = password,
itemFk = sales[position].itemFk, itemFk = sales[position].itemFk,
quantity = quantityGet, quantity = quantityGet,
shelvingFk = sales[position].placements[shelvingPosition].shelving shelvingFk = sales[position].placements[shelvingPosition].shelving,
callFunction = "itemPlacementSupplyAiming"
) )
} }
@ -916,7 +936,7 @@ class CollectionFragment(
viewModel.getIdFromCode( viewModel.getIdFromCode(
usuario = user, usuario = user,
password = password, password = password,
code = customDialogList.getValueTwo() code = customDialogList.getValueTwo(),"barcodeToItem"
) )
customDialogList.dismiss() customDialogList.dismiss()
} }
@ -982,7 +1002,7 @@ class CollectionFragment(
viewModel.getIdFromCode( viewModel.getIdFromCode(
usuario = user, usuario = user,
password = password, password = password,
code = customDialogList.getValueTwo() code = customDialogList.getValueTwo(),"barcodeToItem"
) )
customDialogList.dismiss() customDialogList.dismiss()
scanRequest() scanRequest()
@ -1043,7 +1063,7 @@ class CollectionFragment(
if (quantityPicked<quantityTotal) if (quantityPicked<quantityTotal)
{ {
// Log.i("VERDNATURA::","Lanzamos collection para que refresque adaptador y ordene") // Log.i("VERDNATURA::","Lanzamos collection para que refresque adaptador y ordene")
viewModel.collectionTicketGet(user, password, collection.collectionFk, sectorFk, type) viewModel.collectionTicketGet(user, password, collection.collectionFk, sectorFk, type,"collection_getTickets")
} }
} }
@ -1087,7 +1107,8 @@ class CollectionFragment(
password = password, password = password,
itemShelvingFk = itemShelvingFk, itemShelvingFk = itemShelvingFk,
saleFk = sales[storedPosition].saleFk, saleFk = sales[storedPosition].saleFk,
quantity = if (quantity != "0") quantity else customDialogList.getValue() quantity = if (quantity != "0") quantity else customDialogList.getValue(),
callFunction = "itemShelvingSaleSupplyAdd"
) )
} catch (e: Exception) { } catch (e: Exception) {
@ -1123,7 +1144,8 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
collectionFk = collection.collectionFk, collectionFk = collection.collectionFk,
sectorFk = sectorFk sectorFk = sectorFk,
"collectionStickerPrint"
) )
@ -1155,7 +1177,8 @@ class CollectionFragment(
itemFk = customDialogList.getValue(), itemFk = customDialogList.getValue(),
ticketFk = ticketSelected, ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo(), quantityFk = customDialogList.getValueTwo(),
warehouseFk = warehouseFk warehouseFk = warehouseFk,
callFunction="collection_addItem"
) )
scanRequest() scanRequest()
customDialogList.dismiss() customDialogList.dismiss()
@ -1198,7 +1221,8 @@ class CollectionFragment(
itemFk = customDialogList.getValue(), itemFk = customDialogList.getValue(),
ticketFk = ticketSelected, ticketFk = ticketSelected,
quantityFk = customDialogList.getValueTwo(), quantityFk = customDialogList.getValueTwo(),
warehouseFk = warehouseFk warehouseFk = warehouseFk,
callFunction = "collection_addItem"
) )
scanRequest() scanRequest()
customDialogList.dismiss() customDialogList.dismiss()
@ -1246,7 +1270,8 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
itemFk = customDialogInput.getValue(), itemFk = customDialogInput.getValue(),
warehouseFk = warehouseFk warehouseFk = warehouseFk,
"item_GetVisibleAvailable"
) )
scanRequest() scanRequest()
customDialogInput.dismiss() customDialogInput.dismiss()
@ -1269,7 +1294,7 @@ class CollectionFragment(
password = password, password = password,
itemFk = customDialogInput.getValue(), itemFk = customDialogInput.getValue(),
warehouseFk = warehouseFk warehouseFk = warehouseFk
) ,"item_GetVisibleAvailable")
} }
customDialogInput.setValue("") customDialogInput.setValue("")
scanRequest() scanRequest()
@ -1383,7 +1408,8 @@ class CollectionFragment(
password = password, password = password,
saleFk = sales[position].saleFk, saleFk = sales[position].saleFk,
quantity = totalQuantity.toString(), quantity = totalQuantity.toString(),
originalQuantity = sales[position].quantity originalQuantity = sales[position].quantity,
"saleMove"
) )
//sales[position].originalQuantity = quantity //sales[position].originalQuantity = quantity
sales[position].quantity = quantity sales[position].quantity = quantity
@ -1401,7 +1427,7 @@ class CollectionFragment(
viewModel.sendChekingPresence( viewModel.sendChekingPresence(
token = token, token = token,
workerId = sales[position].salePersonFk, workerId = sales[position].salePersonFk,
message = message message = message,"sendChekingPresence"
) )
} }
@ -1419,7 +1445,8 @@ class CollectionFragment(
quantity = totalQuantity.toString(), quantity = totalQuantity.toString(),
warehouseFk = warehouseFk, warehouseFk = warehouseFk,
type = "FALSE", type = "FALSE",
originalQuantity = quantity originalQuantity = quantity,
callFunction = "saleMistake_Add"
) )
//sales[position].originalQuantity = quantity //sales[position].originalQuantity = quantity
sales[position].quantity = quantity sales[position].quantity = quantity
@ -1436,7 +1463,7 @@ class CollectionFragment(
viewModel.sendChekingPresence( viewModel.sendChekingPresence(
token = token, token = token,
workerId = sales[position].salePersonFk, workerId = sales[position].salePersonFk,
message = message message = message,"sendChekingPresence"
) )
} }
@ -1453,7 +1480,8 @@ class CollectionFragment(
quantity = totalQuantity.toString(), quantity = totalQuantity.toString(),
warehouseFk = warehouseFk, warehouseFk = warehouseFk,
type = "TRUE", type = "TRUE",
originalQuantity = quantity originalQuantity = quantity,
callFunction = "collectionMissingTrash",
) )
//sales[position].originalQuantity = quantity //sales[position].originalQuantity = quantity
sales[position].quantity = quantity sales[position].quantity = quantity
@ -1471,7 +1499,7 @@ class CollectionFragment(
viewModel.sendChekingPresence( viewModel.sendChekingPresence(
token = token, token = token,
workerId = sales[position].salePersonFk, workerId = sales[position].salePersonFk,
message = message message = message,"sendChekingPresence"
) )
} }
@ -1489,7 +1517,8 @@ class CollectionFragment(
warehouseFk = warehouseFk, warehouseFk = warehouseFk,
type = "reject", type = "reject",
originalQuantity = quantity originalQuantity = quantity
) ,callFunction = "collectionMissingTrash")
//sales[position].originalQuantity = quantity //sales[position].originalQuantity = quantity
sales[position].quantity = quantity sales[position].quantity = quantity
//sales[position].startQuantity = quantity //sales[position].startQuantity = quantity
@ -1505,7 +1534,7 @@ class CollectionFragment(
viewModel.sendChekingPresence( viewModel.sendChekingPresence(
token = token, token = token,
workerId = sales[position].salePersonFk, workerId = sales[position].salePersonFk,
message = message message = message,"sendChekingPresence"
) )
} }
@ -1514,7 +1543,7 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
saleFk = sales[position].saleFk, saleFk = sales[position].saleFk,
quantity = quantity quantity = quantity,"collection_increaseQuantity"
) )
try { try {
//val quantityPicked = (quantity.toInt() - sales[position].quantity.toInt()).toString() //val quantityPicked = (quantity.toInt() - sales[position].quantity.toInt()).toString()
@ -1535,7 +1564,7 @@ class CollectionFragment(
viewModel.sendChekingPresence( viewModel.sendChekingPresence(
token = token, token = token,
workerId = sales[position].salePersonFk, workerId = sales[position].salePersonFk,
message = message message = message,"sendChekingPresence"
) )
} }
@ -1547,7 +1576,7 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
collectionFk = it, collectionFk = it,
state = CHECKED state = CHECKED,"collection_updateState"
) )
} }
} else if (type == SACADOR) { } else if (type == SACADOR) {
@ -1556,7 +1585,7 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
collectionFk = it, collectionFk = it,
state = PREPARED state = PREPARED,"collection_updateState"
) )
} }
@ -1570,7 +1599,7 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
collectionFk = it, collectionFk = it,
state = ON_CHECKING state = ON_CHECKING,"collection_updateState"
) )
} }
} else if (type == SACADOR) { } else if (type == SACADOR) {
@ -1579,7 +1608,7 @@ class CollectionFragment(
usuario = user, usuario = user,
password = password, password = password,
collectionFk = it, collectionFk = it,
state = ON_PREPARATION state = ON_PREPARATION,"collection_updateState"
) )
} }
} }
@ -1649,7 +1678,7 @@ class CollectionFragment(
password = password, password = password,
vSaleFk = mistakeSale?.saleFk!!, vSaleFk = mistakeSale?.saleFk!!,
vUserFk = mistakeSale?.workerFk!!, vUserFk = mistakeSale?.workerFk!!,
vTypeFk = it.id vTypeFk = it.id,"saleMistake_Add"
) )
"Causa del error registrado".toast(requireContext()) "Causa del error registrado".toast(requireContext())
customDialogList.dismiss() customDialogList.dismiss()

View File

@ -1,13 +1,15 @@
package es.verdnatura.presentation.view.feature.collection.fragment package es.verdnatura.presentation.view.feature.collection.fragment
import android.content.Context import android.content.Context
import android.util.Log
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetLoginUserCase import es.verdnatura.domain.GetLoginUserCase
import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.domain.GetUbicadorUserCase import es.verdnatura.domain.GetUbicadorUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.getMessageFromResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.collection.ItemVO
import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.collection.mapper.map
@ -16,11 +18,13 @@ import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
class CollectionViewModel(context: Context) : BaseViewModel() { class CollectionViewModel(context: Context) : BaseViewModel()
{
val emptyMessage = "La colección no tiene tickets" val emptyMessage = "La colección no tiene tickets"
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context) private val getSacadorControladorUserCase: GetSacadorControladorUserCase =
GetSacadorControladorUserCase(context)
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context)
private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context) private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context)
@ -36,12 +40,10 @@ class CollectionViewModel(context: Context) : BaseViewModel() {
val response: LiveData<ResponseItemVO> val response: LiveData<ResponseItemVO>
get() = _response get() = _response
private val _responsecheckfully by lazy { MutableLiveData<ResponseItemVO>() } private val _responsecheckfully by lazy { MutableLiveData<ResponseItemVO>() }
val responsecheckfully: LiveData<ResponseItemVO> val responsecheckfully: LiveData<ResponseItemVO>
get() = _responsecheckfully get() = _responsecheckfully
private val _responseNew by lazy { MutableLiveData<ResponseItemVO>() } private val _responseNew by lazy { MutableLiveData<ResponseItemVO>() }
val responseNew: LiveData<ResponseItemVO> val responseNew: LiveData<ResponseItemVO>
get() = _responseNew get() = _responseNew
@ -58,323 +60,690 @@ class CollectionViewModel(context: Context) : BaseViewModel() {
val mistakeList: LiveData<MistakeTypeListVO> val mistakeList: LiveData<MistakeTypeListVO>
get() = _mistakeList get() = _mistakeList
private val _responseSalixMessage by lazy { MutableLiveData<ResponseItemVO>() }
val responseSalixMessage: LiveData<ResponseItemVO>
get() = _responseSalixMessage
private val _item by lazy { MutableLiveData<ItemVO>() } private val _item by lazy { MutableLiveData<ItemVO>() }
val item: LiveData<ItemVO> val item: LiveData<ItemVO>
get() = _item get() = _item
fun collectionTicketGet(
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,type:String){ usuario: String,
getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0",type).enqueue(object : password: String,
Callback<CollectionVO> { collectionFk: String,
override fun onFailure(call: Call<CollectionVO>, t: Throwable) { sectorFk: String,
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!) type: String,
callFunction:String){
getSacadorControladorUserCase.collectionTicketGet(
usuario,
password,
collectionFk,
sectorFk,
"0",
type
).enqueue(object :
Callback<CollectionVO>
{
override fun onFailure(call: Call<CollectionVO>, t: Throwable)
{
_collectionTicketList.value = CollectionVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
} }
override fun onResponse( override fun onResponse(
call: Call<CollectionVO>, call: Call<CollectionVO>,
response: Response<CollectionVO> response: Response<CollectionVO>
) { )
if (response.body() != null){ {
if (response.body() != null)
{
_collectionTicketList.value = response.body()?.let { it.map() } _collectionTicketList.value = response.body()?.let { it.map() }
}else{ } else
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = "Error en la llamada de collection_get") {
_collectionTicketList.value = CollectionVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} }
} }
}) })
} }
fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String,vBuyFk:String){ fun saleTrackingReplace(
getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked,vBuyFk).enqueue(object : Callback<String>{ usuario: String,
override fun onFailure(call: Call<String>, t: Throwable) { password: String,
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) saleFk: String,
vOriginalQuantity: String,
vStateFk: String,
vIsChecked: String,
vBuyFk: String,callFunction:String)
{
getSacadorControladorUserCase.saleTrackingReplace(
usuario,
password,
saleFk,
vOriginalQuantity,
vStateFk,
vIsChecked,
vBuyFk
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>)
if (response.body() == null){ {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleTracking_Replace") if (response.body() == null)
}else{ {
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
} }
} }
}) })
} }
fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String){ fun itemPlacementSupplyAiming(
getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object : usuario: String,
Callback<List<PlacementSupplyVO>> { password: String,
override fun onFailure(call: Call<List<PlacementSupplyVO>>, t: Throwable) { shelvingFk: String,
val listError:ArrayList<PlacementSupplyVO> = ArrayList() quantity: String,
listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!)) itemFk: String,callFunction:String)
{
getSacadorControladorUserCase.itemPlacementSupplyAiming(
usuario,
password,
shelvingFk,
quantity,
itemFk
).enqueue(object :
Callback<List<PlacementSupplyVO>>
{
override fun onFailure(call: Call<List<PlacementSupplyVO>>, t: Throwable)
{
val listError: ArrayList<PlacementSupplyVO> = ArrayList()
listError.add(
PlacementSupplyVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
)
_placementSuppleyList.value = PlacementSupplyListVO(listError) _placementSuppleyList.value = PlacementSupplyListVO(listError)
} }
override fun onResponse( override fun onResponse(
call: Call<List<PlacementSupplyVO>>, call: Call<List<PlacementSupplyVO>>,
response: Response<List<PlacementSupplyVO>> response: Response<List<PlacementSupplyVO>>
) { )
if (response.body() != null){ {
if (response.body() != null)
{
_placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) }
}else{ } else
val listError:ArrayList<PlacementSupplyVO> = ArrayList() {
listError.add(PlacementSupplyVO(isError = true,errorMessage = "Error en la llamada de itemPlacementSupplyAiming")) val listError: ArrayList<PlacementSupplyVO> = ArrayList()
listError.add(
PlacementSupplyVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
)
_placementSuppleyList.value = PlacementSupplyListVO(listError) _placementSuppleyList.value = PlacementSupplyListVO(listError)
} }
} }
}) })
} }
fun itemShelvingSaleSupplyAdd(usuario:String,password:String,itemShelvingFk:String,saleFk:String,quantity:String){ fun itemShelvingSaleSupplyAdd(
getSacadorControladorUserCase.itemShelvingSaleSupplyAdd(usuario,password,itemShelvingFk,saleFk,quantity).enqueue(object : Callback<String>{ usuario: String,
override fun onFailure(call: Call<String>, t: Throwable) { password: String,
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) itemShelvingFk: String,
saleFk: String,
quantity: String,callFunction:String
)
{
getSacadorControladorUserCase.itemShelvingSaleSupplyAdd(
usuario,
password,
itemShelvingFk,
saleFk,
quantity
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>)
if (response.body() == null){ {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingSaleSupplyAdd") if (response.body() == null)
}else{ {
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
} }
} }
}) })
} }
fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String){ fun collectionStickerPrint(
getSacadorControladorUserCase.collectionStickerPrint(usuario,password,collectionFk,sectorFk).enqueue(object : Callback<String>{ usuario: String,
override fun onFailure(call: Call<String>, t: Throwable) { password: String,
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) collectionFk: String,
sectorFk: String,callFunction:String)
{
getSacadorControladorUserCase.collectionStickerPrint(
usuario,
password,
collectionFk,
sectorFk
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>)
if (response.body() == null){ {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionStickerPrint") if (response.body() == null)
}else{ {
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
} }
} }
}) })
} }
fun itemGetAvailable(usuario:String,password:String,itemFk: String,warehouseFk: String){ fun itemGetAvailable(usuario: String, password: String, itemFk: String, warehouseFk: String,callFunction:String)
getSacadorControladorUserCase.itemGetAvailable(usuario,password,itemFk,warehouseFk).enqueue(object : Callback<ItemVO>{ {
override fun onFailure(call: Call<ItemVO>, t: Throwable) { getSacadorControladorUserCase.itemGetAvailable(usuario, password, itemFk, warehouseFk)
_item.value = ItemVO(isError = true,errorMessage = ""+t.message!!) .enqueue(object : Callback<ItemVO>
} {
override fun onFailure(call: Call<ItemVO>, t: Throwable)
override fun onResponse(call: Call<ItemVO>, response: Response<ItemVO>) { {
if (response.body() == null){ _item.value = ItemVO(
_item.value = ItemVO(isError = true,errorMessage = "Error en la llamada item_GetVisibleAvailable") isError = true,
}else{ errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
_item.value = response.body() )
}
}
})
}
fun collectionAddItem(usuario:String,password:String,itemFk: String,quantityFk: String,ticketFk: String,warehouseFk: String){
getSacadorControladorUserCase.collectionAddItem(usuario,password,itemFk,quantityFk,ticketFk,warehouseFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseNew.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responseNew.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionAddItem")
}else{
_responseNew.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun saleMove(usuario:String,password:String,saleFk: String,quantity: String,originalQuantity : String){
getSacadorControladorUserCase.saleMove(usuario,password,saleFk,quantity,originalQuantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleMove")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun collectionMissingTrash(usuario:String,password:String,saleFk: String,quantity: String,type:String,warehouseFk:String,originalQuantity: String){
getSacadorControladorUserCase.collectionMissingTrash(usuario,password,saleFk,quantity,type,warehouseFk,originalQuantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun saleTrackingDel(usuario:String,password:String,saleFk: String){
getSacadorControladorUserCase.saleTrackingDel(usuario,password,saleFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun parking(usuario: String,password: String,ticketFk: String,parking:String){
getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun collectionUpdateState(usuario:String,password:String,collectionFk: String,state : String){
getSacadorControladorUserCase.collectionUpdateState(usuario,password,collectionFk,state).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionUpdateState")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun getIdFromCode(usuario:String,password:String,code: String){
getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseCode.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responseCode.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada barcodeToItem")
}else{
_responseCode.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String,quantity: String){
getSacadorControladorUserCase.collectionIncreaseQuantity(usuario,password,saleFk,quantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionIncreaseQuantity")
}else{
_responseIncQuantity.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun sendChekingPresence(token:String,workerId:String,message:String){
try{
getLoginUserCase.sendChekingPresence(token,workerId.toInt(),message).enqueue(object : Callback<Boolean>{
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
Log.i("Salix","Mensaje enviado a salix")
} }
override fun onFailure(call: Call<Boolean>, t: Throwable) { override fun onResponse(call: Call<ItemVO>, response: Response<ItemVO>)
Log.i("Salix Error",""+t.message) {
if (response.body() == null)
{
_item.value = ItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_item.value = response.body()
}
} }
}) })
}catch (e:Exception){}
} }
fun saleMistakeAdd(usuario:String,password:String,vSaleFk: String, vUserFk: String, vTypeFk: String){ fun collectionAddItem(
getSacadorControladorUserCase.saleMistakeAdd(usuario,password,vSaleFk,vUserFk,vTypeFk).enqueue(object : usuario: String,
Callback<String> { password: String,
override fun onFailure(call: Call<String>, t: Throwable) { itemFk: String,
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) quantityFk: String,
ticketFk: String,
warehouseFk: String,callFunction:String)
{
getSacadorControladorUserCase.collectionAddItem(
usuario,
password,
itemFk,
quantityFk,
ticketFk,
warehouseFk
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_responseNew.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
} }
override fun onResponse(
call: Call<String>, override fun onResponse(call: Call<String>, response: Response<String>)
response: Response<String> {
) { if (response.body() == null)
if (response.body() == null){ {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleMistakeAdd") _responseNew.value = ResponseItemVO(
}else{ isError = true,
_response.value = ResponseItemVO(isError = false,response = response.body()!!) errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_responseNew.value =
ResponseItemVO(isError = false, response = response.body()!!)
} }
} }
}) })
} }
fun mistakeType(usuario:String,password:String){ fun saleMove(
getSacadorControladorUserCase.mistakeType(usuario,password).enqueue(object : Callback<List<MistakeTypeVO>>{ usuario: String,
override fun onFailure(call: Call<List<MistakeTypeVO>>, t: Throwable) { password: String,
val listError:ArrayList<MistakeTypeVO> = ArrayList() saleFk: String,
listError.add(MistakeTypeVO("0","")) quantity: String,
_mistakeList.value = MistakeTypeListVO(listError) originalQuantity: String,callFunction:String)
{
getSacadorControladorUserCase.saleMove(
usuario,
password,
saleFk,
quantity,
originalQuantity
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
} }
override fun onResponse( override fun onResponse(call: Call<String>, response: Response<String>)
call: Call<List<MistakeTypeVO>>, {
response: Response<List<MistakeTypeVO>> if (response.body() == null)
) { {
if (response.body() != null){ _response.value = ResponseItemVO(
_mistakeList.value = response.body()?.let { MistakeTypeListVO(it) } isError = true,
}else{ errorMessage = getMessageFromAllResponse(callFunction,response.message()))
val listError:ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO("0","")) } else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun collectionMissingTrash(
usuario: String,
password: String,
saleFk: String,
quantity: String,
type: String,
warehouseFk: String,
originalQuantity: String,callFunction:String
)
{
getSacadorControladorUserCase.collectionMissingTrash(
usuario,
password,
saleFk,
quantity,
type,
warehouseFk,
originalQuantity
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun saleTrackingDel(usuario: String, password: String, saleFk: String,callFunction:String)
{
getSacadorControladorUserCase.saleTrackingDel(usuario, password, saleFk)
.enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun parking(usuario: String, password: String, ticketFk: String, parking: String,callFunction:String)
{
getUbicadorUserCase.shelvingPark(usuario, password, ticketFk, parking)
.enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun collectionUpdateState(
usuario: String,
password: String,
collectionFk: String,
state: String,callFunction:String
)
{
getSacadorControladorUserCase.collectionUpdateState(usuario, password, collectionFk, state)
.enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage =getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun getIdFromCode(usuario: String, password: String, code: String,callFunction:String)
{
getSacadorControladorUserCase.getIdFromCode(usuario, password, code)
.enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_responseCode.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_responseCode.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_responseCode.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun collectionIncreaseQuantity(
usuario: String,
password: String,
saleFk: String,
quantity: String,callFunction:String
)
{
getSacadorControladorUserCase.collectionIncreaseQuantity(
usuario,
password,
saleFk,
quantity,
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_responseIncQuantity.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_responseIncQuantity.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_responseIncQuantity.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun sendChekingPresence(token: String, workerId: String, message: String,calledFunction:String)
{
try
{
getLoginUserCase.sendChekingPresence(token, workerId.toInt(), message)
.enqueue(object : Callback<Boolean>
{
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>)
{
if (!response.isSuccessful)
{
_responseSalixMessage.value = ResponseItemVO(
isError = true,
errorMessage = "Error en la llamada $calledFunction al enviar mensaje rocket." + getMessageFromResponse(
response.message()
))
//Log.i("Salix","Mensaje enviado a salix")
}
}
override fun onFailure(call: Call<Boolean>, t: Throwable)
{
//Log.i("Salix Error",""+t.message)
}
})
} catch (e: Exception)
{
}
}
fun saleMistakeAdd(
usuario: String,
password: String,
vSaleFk: String,
vUserFk: String,
vTypeFk: String,callFunction:String
)
{
getSacadorControladorUserCase.saleMistakeAdd(usuario, password, vSaleFk, vUserFk, vTypeFk)
.enqueue(object :
Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage =getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(
call: Call<String>,
response: Response<String>
)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun mistakeType(usuario: String, password: String)
{
getSacadorControladorUserCase.mistakeType(usuario, password)
.enqueue(object : Callback<List<MistakeTypeVO>>
{
override fun onFailure(call: Call<List<MistakeTypeVO>>, t: Throwable)
{
val listError: ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO("0", ""))
_mistakeList.value = MistakeTypeListVO(listError) _mistakeList.value = MistakeTypeListVO(listError)
} }
override fun onResponse(
call: Call<List<MistakeTypeVO>>,
response: Response<List<MistakeTypeVO>>
)
{
if (response.body() != null)
{
_mistakeList.value = response.body()?.let { MistakeTypeListVO(it) }
} else
{
val listError: ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO("0", ""))
_mistakeList.value = MistakeTypeListVO(listError)
}
}
})
}
fun ticketOrCollection_checkFullyControlled(
usuario: String,
password: String,
collectionFk: String,callFunction:String
)
{
getSacadorControladorUserCase.ticketOrCollection_checkFullyControlled(
usuario,
password,
collectionFk
).enqueue(object :
Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_responsecheckfully.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
} }
})
}
fun ticketOrCollection_checkFullyControlled(usuario:String,password:String,collectionFk:String){
getSacadorControladorUserCase.ticketOrCollection_checkFullyControlled(usuario,password,collectionFk).enqueue(object :
Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) {
_responsecheckfully.value = ResponseItemVO(isError = true, errorMessage = "" + t.message!!)
}
override fun onResponse( override fun onResponse(
call: Call<String?>, call: Call<String?>,
response: Response<String> response: Response<String>
) { )
{
if (response.body() != "false"){ if (response.body() != "false")
{
//sergio: //sergio:
_responsecheckfully.value = ResponseItemVO(isError = false, response = response.body()!!,errorMessage = "") _responsecheckfully.value = ResponseItemVO(
isError = false,
response = response.body()!!,
errorMessage = ""
)
} }
} }
}) })
} }
} }

View File

@ -85,7 +85,7 @@ class ControladorFragment : BaseFragment<FragmentControladorBinding,ControladorV
sectorFk = sectorFk, sectorFk = sectorFk,
collectionFk = scan_input.text.toString(), collectionFk = scan_input.text.toString(),
type = type type = type
) ,callFunction = "collection_getTickets")
// viewModel.ticket_checkControlled(user,password,scan_input.text.toString()) // viewModel.ticket_checkControlled(user,password,scan_input.text.toString())
} }
scan_input.setText("") scan_input.setText("")

View File

@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
@ -25,11 +27,11 @@ class ControladorViewModel(context: Context) : BaseViewModel() {
get() = _collectionTicketList get() = _collectionTicketList
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,type:String){ fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,type:String,callFunction:String){
getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0",type).enqueue(object : getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0",type).enqueue(object :
Callback<CollectionVO> { Callback<CollectionVO> {
override fun onFailure(call: Call<CollectionVO>, t: Throwable) { override fun onFailure(call: Call<CollectionVO>, t: Throwable) {
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!) _collectionTicketList.value = CollectionVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse( override fun onResponse(
call: Call<CollectionVO>, call: Call<CollectionVO>,
@ -41,7 +43,7 @@ class ControladorViewModel(context: Context) : BaseViewModel() {
}else{ }else{
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = "No hay tickets para sacar") _collectionTicketList.value = CollectionVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} }
} }
}) })

View File

@ -201,7 +201,7 @@ class ControlVehiculoFragment(
if (!goBack) { if (!goBack) {
splash_progress.visibility = VISIBLE splash_progress.visibility = VISIBLE
viewModel.workerMachinery_isRegistered(user, password) viewModel.workerMachinery_isRegistered(user, password,"workerMachinery_isRegistered")
} }
} }
@ -214,10 +214,10 @@ class ControlVehiculoFragment(
) )
} else if (direction.equals("IN")) { } else if (direction.equals("IN")) {
splash_progress.visibility = VISIBLE splash_progress.visibility = VISIBLE
viewModel.machineWorker_add(user, password, plateNumber) viewModel.machineWorker_add(user, password, plateNumber,"machineWorker_add")
} else if (direction.equals("OUT")) { } else if (direction.equals("OUT")) {
viewModel.machineWorker_update(user, password, plateNumber) viewModel.machineWorker_update(user, password, plateNumber,"machineWorker_update")
} else if (direction.equals("")) { } else if (direction.equals("")) {
(activity as MainActivity).openFragmentPickers() (activity as MainActivity).openFragmentPickers()

View File

@ -67,9 +67,9 @@ class ControlVehiculoUsuarioFragment(
if (userFk.equals(vUserFK)) { if (userFk.equals(vUserFK)) {
splash_progress.visibility = VISIBLE splash_progress.visibility = VISIBLE
viewModel.machine_getWorkerPlate(user, password) viewModel.machine_getWorkerPlate(user, password,"machine_getWorkerPlate")
viewModel.deviceProduction_getnameDevice(user, password, android_id) viewModel.deviceProduction_getnameDevice(user, password, android_id,"deviceProduction_getnameDevice")
viewModel.deviceProductionUser_getWorker(user, password, android_id) viewModel.deviceProductionUser_getWorker(user, password, android_id,"deviceProductionUser_getWorker")
} else { } else {
userFk = vUserFK userFk = vUserFK
@ -80,7 +80,7 @@ class ControlVehiculoUsuarioFragment(
} }
user_image.loadUrl("https://salix.verdnatura.es/api/Images/user/160x160/$userFk/download?access_token=$token") user_image.loadUrl("https://salix.verdnatura.es/api/Images/user/160x160/$userFk/download?access_token=$token")
viewModel.machine_getWorkerPlate(user, password) viewModel.machine_getWorkerPlate(user, password,"machine_getWorkerPlate")
name_vehiclecontrol.text = user name_vehiclecontrol.text = user
registered_vehiclecontrol.text = "" registered_vehiclecontrol.text = ""
deviceName.text = "" deviceName.text = ""

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetVehicleControlTimeUserCase import es.verdnatura.domain.GetVehicleControlTimeUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemMachineControl import es.verdnatura.presentation.common.ResponseItemMachineControl
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
@ -33,14 +35,14 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
fun machineWorker_add( fun machineWorker_add(
usuario: String, usuario: String,
password: String, password: String,
PlateNumber: String PlateNumber: String,callFunction:String
) { ) {
getVehicleControlTimeUserCase.machineWorker_add(usuario, password, PlateNumber) getVehicleControlTimeUserCase.machineWorker_add(usuario, password, PlateNumber)
.enqueue(object : Callback<Boolean> { .enqueue(object : Callback<Boolean> {
override fun onFailure(call: Call<Boolean>, t: Throwable) { override fun onFailure(call: Call<Boolean>, t: Throwable) {
_responseinsert.value = ResponseItemVO( _responseinsert.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error en la llamada de registro de vehículo" errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
) )
} }
@ -48,13 +50,13 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
if (response.body() == null || response.body().toString() == "false") { if (response.body() == null || response.body().toString() == "false") {
_responseinsert.value = ResponseItemVO( _responseinsert.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error en la llamada. Escanea matrícula de nuevo" errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} else { } else {
//_response.value = ResponseItemVO(isError = false,response = response.body()!!)
_responseinsert.value = _responseinsert.value =
ResponseItemVO(isError = false, response = response.body()!!.toString()) ResponseItemVO(isError = false, response = response.body()!!.toString())
//Log.i("VERDNATURA:","Respuesta call vehicle_insert ${response.body()}")
} }
} }
@ -65,14 +67,14 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
fun machineWorker_update( fun machineWorker_update(
usuario: String, usuario: String,
password: String, password: String,
PlateNumber: String PlateNumber: String,callFunction:String
) { ) {
getVehicleControlTimeUserCase.machineWorker_update(usuario, password, PlateNumber) getVehicleControlTimeUserCase.machineWorker_update(usuario, password, PlateNumber)
.enqueue(object : Callback<Boolean> { .enqueue(object : Callback<Boolean> {
override fun onFailure(call: Call<Boolean>, t: Throwable) { override fun onFailure(call: Call<Boolean>, t: Throwable) {
_responseinsert.value = ResponseItemVO( _responseinsert.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error en la llamada de registro de vehículo" errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
) )
} }
@ -80,7 +82,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
if (response.body() == null || response.body().toString() == "false") { if (response.body() == null || response.body().toString() == "false") {
_responseinsert.value = ResponseItemVO( _responseinsert.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error en la llamada. Escanea matrícula de nuevo" errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} else { } else {
//_response.value = ResponseItemVO(isError = false,response = response.body()!!) //_response.value = ResponseItemVO(isError = false,response = response.body()!!)
@ -94,7 +96,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun workerMachinery_isRegistered(usuario: String, password: String) { fun workerMachinery_isRegistered(usuario: String, password: String,callFunction:String) {
getVehicleControlTimeUserCase.workerMachinery_isRegistered( getVehicleControlTimeUserCase.workerMachinery_isRegistered(
usuario, usuario,
password password
@ -102,7 +104,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_responsecontrol.value = ResponseItemVO( _responsecontrol.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error al comprobar el control vehículo" errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
) )
} }
@ -110,7 +112,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
if (response.body() == null) { if (response.body() == null) {
_responsecontrol.value = ResponseItemVO( _responsecontrol.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error al comprobar control vehículo" errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} else { } else {
_responsecontrol.value = _responsecontrol.value =
@ -124,7 +126,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
fun deviceProduction_getnameDevice(usuario: String, password: String, android_id: String) { fun deviceProduction_getnameDevice(usuario: String, password: String, android_id: String,callFunction:String) {
getVehicleControlTimeUserCase.deviceProduction_getnameDevice( getVehicleControlTimeUserCase.deviceProduction_getnameDevice(
usuario, usuario,
password, password,
@ -134,7 +136,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
// Log.i("VERDNATURA::","${t.message}") // Log.i("VERDNATURA::","${t.message}")
_responsemachine.value = ResponseItemMachineControl( _responsemachine.value = ResponseItemMachineControl(
isError = true, isError = true,
errorMessage = "Error al comprobar el nombre del dispositivo", errorMessage = getMessageFromAllResponse(callFunction,t.message!!),
type = "" type = ""
) )
} }
@ -161,7 +163,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun deviceProductionUser_getWorker(usuario: String, password: String, userFk: String) { fun deviceProductionUser_getWorker(usuario: String, password: String, userFk: String,callFunction:String) {
getVehicleControlTimeUserCase.deviceProductionUser_getWorker( getVehicleControlTimeUserCase.deviceProductionUser_getWorker(
usuario, usuario,
password, password,
@ -170,7 +172,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_responsemachine.value = ResponseItemMachineControl( _responsemachine.value = ResponseItemMachineControl(
isError = true, isError = true,
errorMessage = "Error al comprobar usuario del dispositivo", errorMessage = getMessageFromAllResponse(callFunction,t.message!!),
type = "" type = ""
) )
} }
@ -198,7 +200,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
fun machine_getWorkerPlate(usuario: String, password: String) { fun machine_getWorkerPlate(usuario: String, password: String,callFunction:String) {
getVehicleControlTimeUserCase.machine_getWorkerPlate( getVehicleControlTimeUserCase.machine_getWorkerPlate(
usuario, usuario,
password password
@ -208,7 +210,7 @@ class ControlVehiculoViewModel(context: Context) : BaseViewModel() {
_responsemachine.value = ResponseItemMachineControl( _responsemachine.value = ResponseItemMachineControl(
isError = true, isError = true,
errorMessage = " Error al comprobar el trabajador si ha cogido el vehículo", errorMessage = getMessageFromAllResponse(callFunction,t.message!!),
type = "" type = ""
) )
} }

View File

@ -0,0 +1,51 @@
package es.verdnatura.presentation.view.feature.diadeventa.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.ItemShelvingdayofsaleRowBinding
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
import java.text.SimpleDateFormat
import java.util.*
class DayOfSaleAdapter (
private val items: List<ItemShelvingSaleDate>
): RecyclerView.Adapter<DayOfSaleAdapter.ItemHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
return ItemHolder(
ItemShelvingdayofsaleRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
)
}
override fun getItemCount() =items.size
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
holder.bind(items[position])
}
inner class ItemHolder(
val binding: ItemShelvingdayofsaleRowBinding
) : RecyclerView.ViewHolder(binding.root){
private val res = binding.root.context.resources
fun bind(item: ItemShelvingSaleDate) {
binding.apply {
this.item = item
val sdf = SimpleDateFormat("yyyy-MM-dd")
val currentDate = sdf.format(Date())
if (currentDate == item.dated){
saledate.setBackgroundColor(
ContextCompat.getColor(historicoDate.context,
R.color.verdnatura_pumpkin_orange))
}else{
saledate.setBackgroundColor(
ContextCompat.getColor(historicoDate.context,
R.color.verdnatura_black_5))
}
}
}
}
}

View File

@ -0,0 +1,247 @@
package es.verdnatura.presentation.view.feature.diadeventa.fragment
import android.content.SharedPreferences
import android.graphics.drawable.Drawable
import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentItemdayofsaleCardBinding
import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.feature.diadeventa.adapter.DayOfSaleAdapter
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionStateRow
import es.verdnatura.presentation.view.feature.paletizador.model.itemExpedetionState
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.buyers_fragment.*
import kotlinx.android.synthetic.main.fragment_historicovehiculo.*
import kotlinx.android.synthetic.main.fragment_item_card.*
import kotlinx.android.synthetic.main.fragment_item_card.edit_itemFk
import kotlinx.android.synthetic.main.fragment_item_card.splash_progress
import kotlinx.android.synthetic.main.fragment_itemexpeditionstate_card.*
import kotlinx.android.synthetic.main.fragment_itemshelvingdayofsale.*
import kotlinx.android.synthetic.main.fragment_parking.*
import kotlinx.android.synthetic.main.toolbar.*
class DayOfSaleFragment(
var entryPoint: String = ""
) : BaseFragment<FragmentItemdayofsaleCardBinding, DayOfSaleViewModel>(DayOfSaleViewModel::class) {
private lateinit var customDialogList: CustomDialogList
private var user = ""
private var password = ""
private var warehouseFk = ""
private var adapter: DayOfSaleAdapter? = null
private var listItemsRow: ArrayList<ItemExpeditionStateRow> = ArrayList()
private var itemScan = ""
companion object {
fun newInstance(entryPoint: String) = DayOfSaleFragment(entryPoint)
}
private lateinit var customDialog: CustomDialog
override fun getLayoutId(): Int = R.layout.fragment_itemdayofsale_card
override fun init() {
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
setEvents()
setToolBar(getString(R.string.dayofSale))
super.init()
}
private fun setToolBar(title: String) {
toolbar_title.text = title
val listIcons: ArrayList<Drawable> = ArrayList()
val iconParking: Drawable =
resources.getDrawable(R.drawable.ic_local_parking_black_24dp, resources.newTheme())
listIcons.add(iconParking)
toolbar_icons.adapter = ToolBarAdapter(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
if (item == iconParking) {
showParking()
}
}
})
toolbar_icons.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
private fun setEvents() {
edit_itemFk.requestFocus()
edit_itemFk.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!edit_itemFk.text.toString().isNullOrEmpty()) {
getItemsSaleDate(edit_itemFk.text.toString())
itemScan = edit_itemFk.text.toString()
}
edit_itemFk.setText("")
(activity as MainActivity).hideKeyboard(edit_itemFk)
return@setOnEditorActionListener true
}
false
}
backButton.setOnClickListener {
requireActivity().onBackPressed()
}
}
private fun getItemsSaleDate(vShelvingFK: String) {
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_USER, 0)
user = prefs.getString(USER, "").toString()
password = prefs.getString(PASSWORD, "").toString()
warehouseFk = prefs.getInt(WAREHOUSEFK, 1).toString()
splash_progress.visibility = View.VISIBLE
viewModel.itemShelving_getSaleDate(user, password,vShelvingFK,"itemShelving_getSaleDate")
}
override fun observeViewModel() {
with(viewModel) {
loadItemShelvingSaleDateList.observe(viewLifecycleOwner, Observer{ event ->
event.getContentIfNotHandled().notNull {
splash_progress.visibility = View.GONE
adapter = DayOfSaleAdapter(it.list)
itemexpeditionstate_recyclerview.adapter = adapter
itemexpeditionstate_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
// navigateToToday(it)
if (it.list.isEmpty()){
customDialog.setTitle("Sin resultados")
.setDescription("No se ha podido obtener datos de la etiqueta escaneada. ")
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}else{
if (it.list.get(0).isError){
customDialog.setTitle("Error")
.setDescription(it.list.get(0).errorMessage)
.setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}
}
}
})
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
splash_progress.visibility = View.GONE
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.dismiss()
}.show()
}else{
customDialog.setTitle("Información").setDescription("Parking ok").setOkButton("Cerrar") {
customDialog.dismiss()
}.show()
}
})
}
}
/* private fun setItemExpeditionState(itemInfo: itemExpedetionState) {
setToolBar(getString(R.string.wagon) +":"+ itemScan)
listItemsRow = ArrayList()
for (i in itemInfo.list) {
listItemsRow.add(
ItemExpeditionStateRow(
title = i.key,
value = i.value.replace(".0",""),
isEditable = false
)
)
}
itemexpeditionstate_recyclerview.adapter = adapter
itemexpeditionstate_recyclerview.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}*/
private fun showParking() {
customDialogList.setTitle("Escanea el parking")
.setOkButton("Cerrar") {
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
customDialogList.dismiss()
}.setValue("").show()
customDialogList.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
customDialogList.getEditText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5 || actionId == 6) {
if (customDialogList.getValue().isNotEmpty()) {
parking(customDialogList.getValue())
}
customDialogList.setValue("")
(activity as MainActivity).hideKeyboard(customDialogList.getEditText())
return@setOnEditorActionListener true
}
false
}
}
fun parking(parking:String){
viewModel.parking(
usuario = user,
password = password,
parking = parking,
scanItem = itemScan,
callFunction="shelvingPark")
customDialogList.dismiss()
}
}

View File

@ -0,0 +1,188 @@
package es.verdnatura.presentation.view.feature.diadeventa.fragment
import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetDayOfSaleUSerCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.getMessageFromResponse
import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDateList
import es.verdnatura.presentation.view.feature.paletizador.model.itemExpedetionState
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import timber.log.Timber.i
class DayOfSaleViewModel(context: Context) : BaseViewModel() {
private val GetDayOfSaleUSerCase: GetDayOfSaleUSerCase =
GetDayOfSaleUSerCase(context)
/* private val _itemexpedition by lazy { MutableLiveData<itemExpedetionState>() }
val itemexpedition: LiveData<itemExpedetionState>
get() = _itemexpedition*/
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
val response: LiveData<ResponseItemVO>
get() = _response
private val _itemShelvingSaleDateList by lazy { MutableLiveData<ItemShelvingSaleDateList>() }
val itemShelvingSaleDateList: LiveData<ItemShelvingSaleDateList>
get() = _itemShelvingSaleDateList
//val loadHistoricoVehiculoList = Transformations.map(_itemShelvingSaleDateList) { Event(it) }
val loadItemShelvingSaleDateList = Transformations.map(_itemShelvingSaleDateList) { Event(it) }
fun itemShelving_getSaleDate(usuario:String,password:String,vShelvingFK: String,callFunction:String){
GetDayOfSaleUSerCase.itemShelving_getSaleDate(usuario,password,vShelvingFK).enqueue(object :
Callback<List<ItemShelvingSaleDate>> {
override fun onFailure(call: Call<List<ItemShelvingSaleDate>>, t: Throwable) {
val listError:ArrayList<ItemShelvingSaleDate> = ArrayList()
listError.add(ItemShelvingSaleDate(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_itemShelvingSaleDateList.value = ItemShelvingSaleDateList(listError)
}
override fun onResponse(
call: Call<List<ItemShelvingSaleDate>>,
response: Response<List<ItemShelvingSaleDate>>
) {
if (!response.isSuccessful){
}
if (response.body() != null){
i("crea la lista "+response.body())
_itemShelvingSaleDateList.value = response.body()?.let { ItemShelvingSaleDateList(it)
}
i("finalizada la lista ${response.body()}")
}else{
if (!response.isSuccessful){
val listError:ArrayList<ItemShelvingSaleDate> = ArrayList()
listError.add(ItemShelvingSaleDate(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_itemShelvingSaleDateList.value = ItemShelvingSaleDateList(listError) }
}
}
})
}
/*fun itemShelving_getSaleDateOld(expeditionFk: String, user: String, password: String) {
GetDayOfSaleUSerCase.itemShelving_getSaleDate(user, password, expeditionFk)
.enqueue(object : Callback<JsonObject> {
override fun onFailure(call: Call<JsonObject>, t: Throwable) {
var listProperties: MutableList<itemsExpeditionDynamics> = mutableListOf()
_itemexpedition.value = itemExpedetionState(
isError = true,
errorMessage = "Error en la llamada itemShelving_getSaleDate " + expeditionFk + " Respuesta:" + t.message!!, list= listProperties
)
}
override fun onResponse(call: Call<JsonObject>, response: Response<JsonObject>) {
var listProperties: MutableList<itemsExpeditionDynamics> = mutableListOf()
if (response.body() != null) {
listProperties=getListFromJSON(response.body()!!.asJsonObject)
_itemexpedition.value = itemExpedetionState(
isError = false,
errorMessage = "Error al obtener el estado de la expedición",list = listProperties)
} else {
_itemexpedition.value = itemExpedetionState(
isError = true,
errorMessage = "Error en la llamada itemShelving_getSaleDate",list = listProperties
)
}
}
})
}*/
/* fun getListFromJSON(json: JsonObject): MutableList<itemsExpeditionDynamics> {
val gson = Gson()
var list = mutableListOf<itemsExpeditionDynamics>()
var expeditionState: Map<String, Any> = gson.fromJson(json, object : TypeToken<Map<String, Any>>() {}.type)
expeditionState.forEach {
list.add(itemsExpeditionDynamics(key=it.key,value=it.value.toString()))
}
return list
}*/
/* fun itemShelving_updateSpam(user: String, password: String,vShelvingFK:String){
GetDayOfSaleUSerCase.itemShelving_updateSpam(user,password,vShelvingFK).enqueue(object : Callback<Boolean>{
override fun onFailure(call: Call<Boolean>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelving_updateSpam."+t.message!!)
}
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelving_updateSpam")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!.toString())
}
}
})
}*/
fun parking(usuario: String,password: String,scanItem: String,parking:String,callFunction:String){
GetDayOfSaleUSerCase.shelvingPark(usuario,password,scanItem,parking).enqueue(object :
Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{
if (response.body() == "Finish")
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
else
_response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}
}
})
}
}

View File

@ -0,0 +1,21 @@
package es.verdnatura.presentation.view.feature.diadeventa.model
class ItemShelvingSaleDate (
var itemFk:String = "",
var longName:String = "",
var dated:String = "",
var amount:String = "",
var stock:String = "",
var isError:Boolean = false,
var errorMessage:String = ""
)
class ItemShelvingSaleDateList(
var list:List<ItemShelvingSaleDate> = listOf()
)

View File

@ -144,7 +144,7 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
adapter = FaltasAdapter(listInvetory,object: OnFaltasNichoClickListener { adapter = FaltasAdapter(listInvetory,object: OnFaltasNichoClickListener {
override fun onFaltasNichoClickListener(item: ItemFaltasVO) { override fun onFaltasNichoClickListener(item: ItemFaltasVO) {
customDialogInput.setTitle(item.itemFk+"\n"+item.longName+" "+item.size).setDescription("Cantidad real("+item.nicho+")").setOkButton("Tirar"){ customDialogInput.setTitle(item.itemFk+"\n"+item.longName+" "+item.size).setDescription("Cantidad real("+item.nicho+")").setOkButton("Tirar"){
viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0") viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0","temTrash")
changeOfflineValue(item) changeOfflineValue(item)
customDialogInput.dismiss() customDialogInput.dismiss()
}.setKoButton("Cancelar"){ }.setKoButton("Cancelar"){
@ -155,7 +155,7 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogInput.getValue().isNullOrEmpty()){ if (!customDialogInput.getValue().isNullOrEmpty()){
viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0") viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0","temTrash")
changeOfflineValue(item) changeOfflineValue(item)
} }
customDialogInput.setValue("") customDialogInput.setValue("")
@ -169,7 +169,7 @@ class FaltasFragment : BaseFragment<FragmentFaltasBinding, FaltasViewModel>(Falt
} }
},object: OnFaltasReviewClickListener{ },object: OnFaltasReviewClickListener{
override fun onFaltasReviewClickListener(item: ItemFaltasVO) { override fun onFaltasReviewClickListener(item: ItemFaltasVO) {
viewModel.faultsReview_isChecked(user,password,item.itemFk,warehouseFk) viewModel.faultsReview_isChecked(user,password,item.itemFk,warehouseFk,"faultsReview_isChecked")
changeOfflineValue(item) changeOfflineValue(item)
} }

View File

@ -7,6 +7,8 @@ import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetInventaryUserCase import es.verdnatura.domain.GetInventaryUserCase
import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.domain.GetItemCardUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasListVO import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasListVO
@ -39,7 +41,7 @@ class FaltasViewModel(context: Context) : BaseViewModel() {
Callback<List<ItemFaltasVO>> { Callback<List<ItemFaltasVO>> {
override fun onFailure(call: Call<List<ItemFaltasVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemFaltasVO>>, t: Throwable) {
val listError:ArrayList<ItemFaltasVO> = ArrayList() val listError:ArrayList<ItemFaltasVO> = ArrayList()
listError.add(ItemFaltasVO(isError = true,errorMessage = t.message!!)) listError.add(ItemFaltasVO(isError = true,errorMessage ="Error en la llamada faultsReview."+ t.message!!))
_faltasList.value = ItemFaltasListVO(listError) _faltasList.value = ItemFaltasListVO(listError)
} }
@ -51,7 +53,7 @@ class FaltasViewModel(context: Context) : BaseViewModel() {
_faltasList.value = response.body()?.let { ItemFaltasListVO(it) } _faltasList.value = response.body()?.let { ItemFaltasListVO(it) }
}else{ }else{
val listError:ArrayList<ItemFaltasVO> = ArrayList() val listError:ArrayList<ItemFaltasVO> = ArrayList()
listError.add(ItemFaltasVO(isError = true,errorMessage = "Error en la llamada de faultsReview")) listError.add(ItemFaltasVO(isError = true,errorMessage = "Error en la llamada faultsReview"))
_faltasList.value = ItemFaltasListVO(listError) _faltasList.value = ItemFaltasListVO(listError)
} }
} }
@ -59,16 +61,16 @@ class FaltasViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){ fun itemStockUpdate(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String,callFunction:String){
getItemCardUserCase.itemStockUpdate(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : getItemCardUserCase.itemStockUpdate(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object :
Callback<String> { Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -78,15 +80,15 @@ class FaltasViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun faultsReview_isChecked(user:String,password:String,itemFk:String,warehouseFk:String){ fun faultsReview_isChecked(user:String,password:String,itemFk:String,warehouseFk:String,callFunction:String){
getInventaryUserCase.faultsReview_isChecked(user,password,itemFk,warehouseFk).enqueue(object : getInventaryUserCase.faultsReview_isChecked(user,password,itemFk,warehouseFk).enqueue(object :
Callback<String> { Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error faultsReview_isChecked "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada faultsReview_isChecked") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }

View File

@ -68,7 +68,7 @@ class HistoricoFragment(
customDialog = CustomDialog(requireContext()) customDialog = CustomDialog(requireContext())
requireActivity().main_bottom_navigation.visibility = View.GONE requireActivity().main_bottom_navigation.visibility = View.GONE
filter = "all" filter = "all"
viewModel.itemDiary(user, password, itemFk, warehouseFk) viewModel.itemDiary(user, password, itemFk, warehouseFk,"itemDiary")
toolbar_title.text = getString(R.string.itemdiary) + ":" + itemFk toolbar_title.text = getString(R.string.itemdiary) + ":" + itemFk
setToolBar() setToolBar()
setEvents() setEvents()
@ -161,7 +161,7 @@ class HistoricoFragment(
private fun viewModelwithFilter(keyfilter: String) { private fun viewModelwithFilter(keyfilter: String) {
filter = keyfilter filter = keyfilter
viewModel.itemDiary(user, password, itemFk, warehouseFk) viewModel.itemDiary(user, password, itemFk, warehouseFk,"itemDiary")
} }
private fun setEvents() { private fun setEvents() {
@ -249,8 +249,6 @@ class HistoricoFragment(
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
listHistoryAux.addAll(listHistoric) listHistoryAux.addAll(listHistoric)
// //Log.i("VERDNATURA:","el total de aux es ${listHistoryAux.size}")
////Log.i("VERDNATURA:","el total de histor es ${listHistoric.size}")
} }

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.domain.GetItemCardUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoListVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoListVO
import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO
@ -26,12 +28,12 @@ class HistoricoViewModel(context: Context) : BaseViewModel() {
val loadHistoricoList = Transformations.map(_historicoList) { Event(it) } val loadHistoricoList = Transformations.map(_historicoList) { Event(it) }
fun itemDiary(usuario:String,password:String,itemFk:String,vWarehouseFk:String){ fun itemDiary(usuario:String,password:String,itemFk:String,vWarehouseFk:String,callFunction:String){
getItemCardUserCase.itemDiary(usuario,password,itemFk,vWarehouseFk).enqueue(object : getItemCardUserCase.itemDiary(usuario,password,itemFk,vWarehouseFk).enqueue(object :
Callback<List<ItemHistoricoVO>> { Callback<List<ItemHistoricoVO>> {
override fun onFailure(call: Call<List<ItemHistoricoVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemHistoricoVO>>, t: Throwable) {
val listError:ArrayList<ItemHistoricoVO> = ArrayList() val listError:ArrayList<ItemHistoricoVO> = ArrayList()
listError.add(ItemHistoricoVO(isError = true,errorMessage = t.message!!)) listError.add(ItemHistoricoVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_historicoList.value = ItemHistoricoListVO(listError) _historicoList.value = ItemHistoricoListVO(listError)
} }
@ -43,7 +45,7 @@ class HistoricoViewModel(context: Context) : BaseViewModel() {
_historicoList.value = response.body()?.let { ItemHistoricoListVO(it) } _historicoList.value = response.body()?.let { ItemHistoricoListVO(it) }
}else{ }else{
val listError:ArrayList<ItemHistoricoVO> = ArrayList() val listError:ArrayList<ItemHistoricoVO> = ArrayList()
listError.add(ItemHistoricoVO(isError = true,errorMessage = "Error en la llamada de shelvingParking_get")) listError.add(ItemHistoricoVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_historicoList.value = ItemHistoricoListVO(listError) _historicoList.value = ItemHistoricoListVO(listError)
} }
} }

View File

@ -62,7 +62,7 @@ class HistoricoVehiculoFragment (
////Log.i("VERDNATURA:","la matricula es $numberPlate") ////Log.i("VERDNATURA:","la matricula es $numberPlate")
//sergio: revisar entrypoint //sergio: revisar entrypoint
viewModel.machineWorker_getHistorical(user,password,numberPlate) viewModel.machineWorker_getHistorical(user,password,numberPlate,"machineWorker_getHistorical")
toolbar_title.text = getString(R.string.vehiclediary) toolbar_title.text = getString(R.string.vehiclediary)
setEvents() setEvents()
super.init() super.init()

View File

@ -4,15 +4,17 @@ import android.content.Context
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetItemCardUserCase
import es.verdnatura.domain.GetVehicleControlTimeUserCase import es.verdnatura.domain.GetVehicleControlTimeUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculo
import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList import es.verdnatura.presentation.view.feature.historicovehiculo.model.ItemHistoricoVehiculoList
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
import timber.log.Timber.i
class HistoricoVehiculoViewModel (context: Context) : BaseViewModel() { class HistoricoVehiculoViewModel (context: Context) : BaseViewModel() {
private val GetVehicleControlTimeUserCase: GetVehicleControlTimeUserCase = GetVehicleControlTimeUserCase(context) private val GetVehicleControlTimeUserCase: GetVehicleControlTimeUserCase = GetVehicleControlTimeUserCase(context)
@ -26,12 +28,12 @@ class HistoricoVehiculoViewModel (context: Context) : BaseViewModel() {
val loadHistoricoVehiculoList = Transformations.map(_historicovehiculoList) { Event(it) } val loadHistoricoVehiculoList = Transformations.map(_historicovehiculoList) { Event(it) }
fun machineWorker_getHistorical(usuario:String,password:String,plateNumber:String){ fun machineWorker_getHistorical(usuario:String,password:String,plateNumber:String,callFunction:String){
GetVehicleControlTimeUserCase.machineWorker_getHistorical(usuario,password,plateNumber).enqueue(object : GetVehicleControlTimeUserCase.machineWorker_getHistorical(usuario,password,plateNumber).enqueue(object :
Callback<List<ItemHistoricoVehiculo>> { Callback<List<ItemHistoricoVehiculo>> {
override fun onFailure(call: Call<List<ItemHistoricoVehiculo>>, t: Throwable) { override fun onFailure(call: Call<List<ItemHistoricoVehiculo>>, t: Throwable) {
val listError:ArrayList<ItemHistoricoVehiculo> = ArrayList() val listError:ArrayList<ItemHistoricoVehiculo> = ArrayList()
listError.add(ItemHistoricoVehiculo(isError = true,errorMessage = t.message!!)) listError.add(ItemHistoricoVehiculo(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_historicovehiculoList.value = ItemHistoricoVehiculoList(listError) _historicovehiculoList.value = ItemHistoricoVehiculoList(listError)
} }
@ -40,10 +42,11 @@ class HistoricoVehiculoViewModel (context: Context) : BaseViewModel() {
response: Response<List<ItemHistoricoVehiculo>> response: Response<List<ItemHistoricoVehiculo>>
) { ) {
if (response.body() != null){ if (response.body() != null){
i("El response es "+response.body())
_historicovehiculoList.value = response.body()?.let { ItemHistoricoVehiculoList(it) } _historicovehiculoList.value = response.body()?.let { ItemHistoricoVehiculoList(it) }
}else{ }else{
val listError:ArrayList<ItemHistoricoVehiculo> = ArrayList() val listError:ArrayList<ItemHistoricoVehiculo> = ArrayList()
listError.add(ItemHistoricoVehiculo(isError = true,errorMessage = "Error en la llamada de historico vehículo")) listError.add(ItemHistoricoVehiculo(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_historicovehiculoList.value = ItemHistoricoVehiculoList(listError) _historicovehiculoList.value = ItemHistoricoVehiculoList(listError)
} }
} }

View File

@ -76,7 +76,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
warehouseFk = prefs!!.getInt(WAREHOUSEFK,1).toString() warehouseFk = prefs!!.getInt(WAREHOUSEFK,1).toString()
//sergio. se quita para subir version.A la espera de como será el inventario //sergio. se quita para subir version.A la espera de como será el inventario
viewModel.itemShelvingBuyerGet(user = user,password = password) viewModel.itemShelvingBuyerGet(user = user,password = password,"itemShelvingBuyerGet")
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
} }
@ -88,7 +88,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
buyerId=prefs!!.getString(BUYERID,"").toString() buyerId=prefs!!.getString(BUYERID,"").toString()
////Log.i("VERDNATURA:","el sector es $warehouseFk") ////Log.i("VERDNATURA:","el sector es $warehouseFk")
////Log.i("VERDNATURA:","el sbuyerid es $buyerId") ////Log.i("VERDNATURA:","el sbuyerid es $buyerId")
viewModel.getInventory(user,password,buyerId,warehouseFk) viewModel.getInventory(user,password,buyerId,warehouseFk,"itemShelving_filterBuyer")
filter_buyer.setOnClickListener{ filter_buyer.setOnClickListener{
//SimpleSearchDialogCompat(context,getString(R.string.compradores),getString(R.string.escribirparteNombre),null,initData(), //SimpleSearchDialogCompat(context,getString(R.string.compradores),getString(R.string.escribirparteNombre),null,initData(),
SimpleSearchDialogCompat(context,getString(R.string.compradores),getString(R.string.escribirparteNombre),null,items, SimpleSearchDialogCompat(context,getString(R.string.compradores),getString(R.string.escribirparteNombre),null,items,
@ -99,7 +99,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
saveBuyer(nombre.getBuyerNickname()) saveBuyer(nombre.getBuyerNickname())
saveBuyerId(nombre.getBuyerId()) saveBuyerId(nombre.getBuyerId())
buyerId=nombre.getBuyerId() buyerId=nombre.getBuyerId()
viewModel.getInventory(user,password,nombre.getBuyerId(),warehouseFk) viewModel.getInventory(user,password,nombre.getBuyerId(),warehouseFk,"itemShelving_filterBuyer")
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
baseSearchDialogCompat.dismiss() baseSearchDialogCompat.dismiss()
}).show() }).show()
@ -118,7 +118,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
reload = false reload = false
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
hideLoad = false hideLoad = false
viewModel.getInventory(user,password,buyerId,warehouseFk) viewModel.getInventory(user,password,buyerId,warehouseFk,"itemShelving_filterBuyer")
} }
@ -139,7 +139,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
firstVisiblePosition = layoutManager?.findFirstVisibleItemPosition() ?: 0 firstVisiblePosition = layoutManager?.findFirstVisibleItemPosition() ?: 0
// sergio. // sergio.
viewModel.getInventory(user,password,buyerId,warehouseFk) viewModel.getInventory(user,password,buyerId,warehouseFk,"itemShelving_filterBuyer")
//viewModel.getInventory(user,password,prefs!!.getInt(SECTORFK,1).toString()) //viewModel.getInventory(user,password,prefs!!.getInt(SECTORFK,1).toString())
} }
@ -227,7 +227,7 @@ class InventaryFragment : BaseFragment<FragmentInventaryBinding,InventaryViewMod
//sergio: cambiado customdialogInput pòr customdialog 6.1.4 //sergio: cambiado customdialogInput pòr customdialog 6.1.4
customDialog.setTitle(item.itemFk+"\n"+item.longName+" "+item.size).setDescription("Cantidad real("+item.nicho+")").setOkButton("Tirar"){ customDialog.setTitle(item.itemFk+"\n"+item.longName+" "+item.size).setDescription("Cantidad real("+item.nicho+")").setOkButton("Tirar"){
//customDialogInput.setTitle(item.itemFk+"\n"+item.longName+" "+item.size).setDescription("Cantidad real("+item.nicho+")").setOkButton("Tirar"){ //customDialogInput.setTitle(item.itemFk+"\n"+item.longName+" "+item.size).setDescription("Cantidad real("+item.nicho+")").setOkButton("Tirar"){
viewModel.itemTrash(item.itemFk,warehouseFk,user,password,item.nicho,"0") viewModel.itemTrash(item.itemFk,warehouseFk,user,password,item.nicho,"0","itemTrash")
//viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,"0","0") //viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,"0","0")
// viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0") // viewModel.itemStockUpdate(item.itemFk,warehouseFk,user,password,customDialogInput.getValue(),"0")
changeOfflineValue(item) changeOfflineValue(item)

View File

@ -7,12 +7,15 @@ import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetInventaryUserCase import es.verdnatura.domain.GetInventaryUserCase
import es.verdnatura.domain.GetItemCardUserCase import es.verdnatura.domain.GetItemCardUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerListVO
import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO import es.verdnatura.presentation.view.feature.inventario.model.InventaryListVO
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.login.model.errorMessage
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
@ -38,12 +41,12 @@ class InventaryViewModel(context: Context) : BaseViewModel() {
//sergio para obtener comprador //sergio para obtener comprador
fun itemShelvingBuyerGet(user:String,password:String){ fun itemShelvingBuyerGet(user:String,password:String,callFunction:String){
getInventaryUserCase.itemShelvingBuyerGet(user,password).enqueue(object : getInventaryUserCase.itemShelvingBuyerGet(user,password).enqueue(object :
Callback<List<BuyerVO>> { Callback<List<BuyerVO>> {
override fun onFailure(call: Call<List<BuyerVO>>, t: Throwable) { override fun onFailure(call: Call<List<BuyerVO>>, t: Throwable) {
val listError:ArrayList<BuyerVO> = ArrayList() val listError:ArrayList<BuyerVO> = ArrayList()
listError.add(BuyerVO(isError = true,errorMessage = t.message!!)) listError.add(BuyerVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_buyersList.value = BuyerListVO(listError) _buyersList.value = BuyerListVO(listError)
} }
@ -55,7 +58,8 @@ class InventaryViewModel(context: Context) : BaseViewModel() {
_buyersList.value = response.body()?.let { BuyerListVO(it) } _buyersList.value = response.body()?.let { BuyerListVO(it) }
}else{ }else{
val listError:ArrayList<BuyerVO> = ArrayList() val listError:ArrayList<BuyerVO> = ArrayList()
listError.add(BuyerVO(isError = true,errorMessage = "Error en la llamada de itemShelving_buyerGet")) listError.add(BuyerVO(isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_buyersList.value = BuyerListVO(listError) _buyersList.value = BuyerListVO(listError)
} }
} }
@ -94,13 +98,13 @@ class InventaryViewModel(context: Context) : BaseViewModel() {
}) })
}*/ }*/
fun getInventory(user:String,password:String,buyerFk:String,warehouseFk: String){ fun getInventory(user:String,password:String,buyerFk:String,warehouseFk: String,callFunction:String){
// getInventaryUserCase.itemShelvingRadar(user,password,buyerFk).enqueue(object : // getInventaryUserCase.itemShelvingRadar(user,password,buyerFk).enqueue(object :
getInventaryUserCase.itemShelvingRadarFilterBuyer(user,password,buyerFk,warehouseFk).enqueue(object : getInventaryUserCase.itemShelvingRadarFilterBuyer(user,password,buyerFk,warehouseFk).enqueue(object :
Callback<List<ItemInventaryVO>> { Callback<List<ItemInventaryVO>> {
override fun onFailure(call: Call<List<ItemInventaryVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemInventaryVO>>, t: Throwable) {
val listError:ArrayList<ItemInventaryVO> = ArrayList() val listError:ArrayList<ItemInventaryVO> = ArrayList()
listError.add(ItemInventaryVO(isError = true,errorMessage = t.message!!)) listError.add(ItemInventaryVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)))
_inventaryList.value = InventaryListVO(listError) _inventaryList.value = InventaryListVO(listError)
} }
@ -112,7 +116,7 @@ class InventaryViewModel(context: Context) : BaseViewModel() {
_inventaryList.value = response.body()?.let { InventaryListVO(it) } _inventaryList.value = response.body()?.let { InventaryListVO(it) }
}else{ }else{
val listError:ArrayList<ItemInventaryVO> = ArrayList() val listError:ArrayList<ItemInventaryVO> = ArrayList()
listError.add(ItemInventaryVO(isError = true,errorMessage = "Error en la llamada de itemShelvingRadar")) listError.add(ItemInventaryVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_inventaryList.value = InventaryListVO(listError) _inventaryList.value = InventaryListVO(listError)
} }
@ -146,19 +150,19 @@ class InventaryViewModel(context: Context) : BaseViewModel() {
} }
//sergio: se modifica por CAU a itemTrash //sergio: se modifica por CAU a itemTrash
fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String){ fun itemTrash(itemFk:String,warehouseFk:String,user:String,password:String,newValue:String,isTrash:String,callFunction:String){
getItemCardUserCase.itemTrash(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{ getItemCardUserCase.itemTrash(user,password,itemFk,warehouseFk,newValue,isTrash).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar STOCK "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemStockUpdate") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }

View File

@ -28,7 +28,8 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>() {
//goToMain() //goToMain()
addFragment(LoginFragment.newInstance(), R.id.main_frame_layout, LoginFragment.TAG) //goToMain()
addFragment(LoginFragment.newInstance(), R.id.main_frame_layout, LoginFragment.TAG)
} }
fun goToMain() { fun goToMain() {

View File

@ -57,7 +57,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
viewModel.device_checkLogin( viewModel.device_checkLogin(
edittext_username.text.toString(), edittext_username.text.toString(),
edittext_password.text.toString(), edittext_password.text.toString(),
getANDROIDID() getANDROIDID(),callFunction = "device_checkLogin"
) )
}) })
@ -190,14 +190,15 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
//sergio: se añade el log //sergio: se añade el log
viewModel.worker_getId( viewModel.worker_getId(
edittext_username.text.toString(), edittext_username.text.toString(),
edittext_password.text.toString() edittext_password.text.toString(),
callFunction = "worker_getId"
) )
deviceLog_add( deviceLog_add(
edittext_username.text.toString(), edittext_username.text.toString(),
edittext_password.text.toString(), edittext_password.text.toString(),
"warehouse", "warehouse",
getInfoVersionNameApp(), getInfoVersionNameApp(),
getANDROIDID() getANDROIDID(),"deviceLog_add"
) )
splash_progress.visibility = View.INVISIBLE splash_progress.visibility = View.INVISIBLE
@ -219,7 +220,8 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
loginSalix( loginSalix(
user = edittext_username.text.toString(), user = edittext_username.text.toString(),
password = edittext_password.text.toString() password = edittext_password.text.toString(),
callFunction = "login de Salix"
) )
} }
@ -231,7 +233,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
loginSalix( loginSalix(
user = edittext_username.text.toString(), user = edittext_username.text.toString(),
password = edittext_password.text.toString() password = edittext_password.text.toString(),"login de Salix"
) )
}.show() }.show()
@ -283,7 +285,8 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
loginSalix( loginSalix(
user = edittext_username.text.toString(), user = edittext_username.text.toString(),
password = edittext_password.text.toString() password = edittext_password.text.toString(),
callFunction = "login de Salix"
) )
} }
@ -408,7 +411,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
viewModel.checkVersion( viewModel.checkVersion(
user = edittext_username.text.toString(), user = edittext_username.text.toString(),
password = edittext_password.text.toString(), password = edittext_password.text.toString(),
nameApp = "warehouse" nameApp = "warehouse","getVersion"
) )
} }

View File

@ -4,19 +4,21 @@ import android.content.Context
import android.util.Log import android.util.Log
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.google.gson.JsonObject
import com.google.gson.reflect.TypeToken
import es.verdnatura.domain.GetLoginUserCase import es.verdnatura.domain.GetLoginUserCase
import es.verdnatura.domain.NodeJsService import es.verdnatura.domain.NodeJsService
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.*
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.login.model.* import es.verdnatura.presentation.view.feature.login.model.*
import org.json.JSONObject import es.verdnatura.presentation.view.feature.paletizador.model.itemsExpeditionDynamics
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
import java.lang.Boolean.FALSE
import java.lang.Boolean.TRUE
class LoginViewModel(context: Context) : BaseViewModel() { class LoginViewModel(context: Context) : BaseViewModel()
{
private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context) private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context)
@ -54,31 +56,40 @@ class LoginViewModel(context: Context) : BaseViewModel() {
get() = _nodejs get() = _nodejs
fun login(user: String, password: String, androiid: String) { //sergio:anterior login
getLoginUserCase.login(user, password, androiid).enqueue(object : Callback<String> { fun login(user: String, password: String, androiid: String)
override fun onResponse(call: Call<String>, response: Response<String>) { {
getLoginUserCase.login(user, password, androiid).enqueue(object : Callback<String>
{
override fun onResponse(call: Call<String>, response: Response<String>)
{
var loginItemVO: LoginItemVO? var loginItemVO: LoginItemVO?
if (response.raw().code() == 555) { if (response.raw().code() == 555)
{
var message = response.raw().message().toString() var message = response.raw().message().toString()
if (message.contains("autorizado")) { if (message.contains("autorizado"))
{
loginItemVO = LoginItemVO( loginItemVO = LoginItemVO(
id = "0", id = "0",
isError = true, isError = true,
errorMessage = "Usuario no autorizado para este dispositivo" errorMessage = "Usuario no autorizado para este dispositivo"
) )
} else { } else
{
loginItemVO = LoginItemVO( loginItemVO = LoginItemVO(
id = "0", id = "0",
isError = true, isError = true,
errorMessage = "Usuario o contraseña incorrectos" errorMessage = "Usuario o contraseña incorrectos"
) )
} }
} else if (!response.body().isNullOrEmpty()) { } else if (!response.body().isNullOrEmpty())
{
loginItemVO = response.body()?.let { LoginItemVO(id = it) } loginItemVO = response.body()?.let { LoginItemVO(id = it) }
} else { } else
{
loginItemVO = loginItemVO =
LoginItemVO(id = "0", isError = true, errorMessage = "Error desconocido") LoginItemVO(id = "0", isError = true, errorMessage = "Error desconocido")
} }
@ -86,7 +97,8 @@ class LoginViewModel(context: Context) : BaseViewModel() {
_loginitem.value = loginItemVO!! _loginitem.value = loginItemVO!!
} }
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable)
{
val loginItemVO: LoginItemVO? = val loginItemVO: LoginItemVO? =
LoginItemVO(id = "0", isError = true, errorMessage = t.message!!) LoginItemVO(id = "0", isError = true, errorMessage = t.message!!)
_loginitem.value = loginItemVO _loginitem.value = loginItemVO
@ -94,12 +106,16 @@ class LoginViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun loginSalix(user: String, password: String) { fun loginSalix(user: String, password: String,callFunction:String)
getLoginUserCase.salixLogin(user, password).enqueue(object : Callback<LoginSalixVO> { {
override fun onResponse(call: Call<LoginSalixVO>, response: Response<LoginSalixVO>) { getLoginUserCase.salixLogin(user, password).enqueue(object : Callback<LoginSalixVO>
{
override fun onResponse(call: Call<LoginSalixVO>, response: Response<LoginSalixVO>)
{
var loginSalixVO: LoginSalixVO? var loginSalixVO: LoginSalixVO?
if (response.body() != null) { if (response.body() != null)
{
loginSalixVO = response.body()?.token?.let { loginSalixVO = response.body()?.token?.let {
LoginSalixVO( LoginSalixVO(
user, user,
@ -107,48 +123,64 @@ class LoginViewModel(context: Context) : BaseViewModel() {
it, it,
isError = false, isError = false,
errorMessage = "" errorMessage = ""
) )
} }
} else { } else
{
loginSalixVO = LoginSalixVO( loginSalixVO = LoginSalixVO(
user, user,
password, password,
isError = true, isError = true,
errorMessage = "Error al conectar con salix" errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} }
_loginsalixitem.value = loginSalixVO _loginsalixitem.value = loginSalixVO
} }
override fun onFailure(call: Call<LoginSalixVO>, t: Throwable) { override fun onFailure(call: Call<LoginSalixVO>, t: Throwable)
{
val loginSalixVO = val loginSalixVO =
LoginSalixVO(user, password, "", isError = true, errorMessage = t.message!!) LoginSalixVO(
user,
password,
"",
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
_loginsalixitem.value = loginSalixVO _loginsalixitem.value = loginSalixVO
} }
}) })
} }
fun device_checkLogin(user: String, password: String, android_id: String,callFunction:String)
{
//var name=nameofFunction(object{})
fun device_checkLogin(user: String, password: String, android_id: String) {
getLoginUserCase.device_checkLogin(user, password, android_id) getLoginUserCase.device_checkLogin(user, password, android_id)
.enqueue(object : Callback<LoginDevice> { .enqueue(object : Callback<LoginDevice>
override fun onResponse(call: Call<LoginDevice>, response: Response<LoginDevice>) { {
override fun onResponse(call: Call<LoginDevice>, response: Response<LoginDevice>)
{
var loginDevice: LoginDevice? var loginDevice: LoginDevice?
if (response.raw().code() == 555) { /* Log.d("VERDNATIRA",response.message())
// var message = response.raw().message().toString() Log.d("VERDNATIRA",response.errorBody().toString())
loginDevice = LoginDevice( Log.d("VERDNATIRA",response.toString())
isError = true, Log.d("VERDNATIRA",response.raw().toString())*/
errorMessage = "Usuario o contraseña incorrectos."
)
} else {
if (response.body() != null) { if (!response.isSuccessful)
{
loginDevice = LoginDevice(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} else
{
if (response.body() != null)
{
loginDevice = response.body()?.let { loginDevice = response.body()?.let {
@ -156,89 +188,115 @@ class LoginViewModel(context: Context) : BaseViewModel() {
it.vMessage, it.vIsAuthorized, it.vMessage, it.vIsAuthorized,
isError = false, isError = false,
errorMessage = "" errorMessage = ""
) )
} }
} else { } else
{
loginDevice = LoginDevice( loginDevice = LoginDevice(
isError = true, isError = true,
errorMessage = "Error al intentar hacer login." errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} }
} }
_logindevice.value = loginDevice _logindevice.value = loginDevice
} }
override fun onFailure(call: Call<LoginDevice>, t: Throwable) { override fun onFailure(call: Call<LoginDevice>, t: Throwable)
{
val loginDevice = val loginDevice =
LoginDevice("", "", isError = true, errorMessage = t.message!!) LoginDevice(
"",
"",
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
_logindevice.value = loginDevice _logindevice.value = loginDevice
} }
}) })
} }
fun worker_getId(user: String, password: String) {
fun worker_getId(user: String, password: String,callFunction: String)
{
getLoginUserCase.worker_getId(user, password) getLoginUserCase.worker_getId(user, password)
.enqueue(object : Callback<String> { .enqueue(object : Callback<String>
override fun onResponse(call: Call<String>, response: Response<String>) { {
override fun onResponse(call: Call<String>, response: Response<String>)
{
var workerId: workerId? var workerId: workerId?
if (response.body() != null) { if (response.body() != null)
{
workerId = workerId( workerId = workerId(
response.body().toString(), response.body().toString(),
isError = false, isError = false,
errorMessage = "" errorMessage = ""
) )
} else { } else
{
workerId = workerId( workerId = workerId(
isError = true, isError = true,
errorMessage = "Error al intentar obtener el id." errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} }
_workerId.value = workerId _workerId.value = workerId
} }
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable)
{
val workerId = val workerId =
workerId(isError = true, errorMessage = t.message!!) workerId(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
_workerId.value = workerId _workerId.value = workerId
} }
}) })
} }
fun deviceLog_add(user: String, password: String, app: String, versionApp: String, android_id: String fun deviceLog_add(
) { user: String, password: String, app: String, versionApp: String, android_id: String,callFunction: String
)
{
getLoginUserCase.deviceLog_add(user, password, app, versionApp, android_id) getLoginUserCase.deviceLog_add(user, password, app, versionApp, android_id)
.enqueue(object : Callback<Void> { .enqueue(object : Callback<Void>
override fun onResponse(call: Call<Void>, response: Response<Void>) { {
override fun onResponse(call: Call<Void>, response: Response<Void>)
{
if (!response.isSuccessful) { if (!response.isSuccessful)
{
messageError(response.message()) messageError(callFunction,response.message())
} }
} }
override fun onFailure(call: Call<Void>, t: Throwable) { override fun onFailure(call: Call<Void>, t: Throwable)
{
messageError(t.message!!) messageError(callFunction,t.message!!)
} }
}) })
} }
fun messageError(message: String) { fun messageError(callFunction:String,message: String)
{
_devicelogresponse.value = ResponseItemVO( _devicelogresponse.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error al realizar llamada a devicelog. Descripción del error:" + message errorMessage = getMessageFromAllResponse(callFunction,message)
) )
} }
/*fun checkVersion_old(user:String,password:String,version:String){ /*fun checkVersion_old(user:String,password:String,version:String){
@ -257,14 +315,18 @@ class LoginViewModel(context: Context) : BaseViewModel() {
}) })
}*/ }*/
//sergio:checkVersion new //sergio:checkVersion new
fun checkVersion(user: String, password: String, nameApp: String) { fun checkVersion(user: String, password: String, nameApp: String,callFunction: String)
{
getLoginUserCase.checkVersion(user, password, nameApp) getLoginUserCase.checkVersion(user, password, nameApp)
.enqueue(object : Callback<versionApp> { .enqueue(object : Callback<versionApp>
override fun onResponse(call: Call<versionApp>, response: Response<versionApp>) { {
override fun onResponse(call: Call<versionApp>, response: Response<versionApp>)
{
var versionApp: versionApp? var versionApp: versionApp?
if (response.body() != null) { if (response.body() != null)
{
versionApp = response.body()?.let { versionApp = response.body()?.let {
@ -274,71 +336,85 @@ class LoginViewModel(context: Context) : BaseViewModel() {
it.IsVersionCritical, it.IsVersionCritical,
isError = false, isError = false,
errorMessage = "" errorMessage = ""
) )
} }
} else { } else
{
versionApp = versionApp( versionApp = versionApp(
user, user,
password, password,
isError = true, isError = true,
errorMessage = "Error al conectar." errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} }
_versionappitem.value = versionApp _versionappitem.value = versionApp
} }
override fun onFailure(call: Call<versionApp>, t: Throwable) { override fun onFailure(call: Call<versionApp>, t: Throwable)
{
val versionApp = val versionApp =
versionApp(nameApp, "", isError = true, errorMessage = t.message!!) versionApp(
nameApp,
"",
isError = true,
errorMessage =getMessageFromAllResponse(callFunction, t.message!!)
)
_versionappitem.value = versionApp _versionappitem.value = versionApp
} }
}) })
} }
fun nodeJsTest(smarttag: String, wagon: String,shelving:String) { fun nodeJsTest(smarttag: String, wagon: String, shelving: String)
getLoginUserCase.nodeJsTest(smarttag, wagon,shelving) {
.enqueue(object : Callback<NodeJsService.SmartTagNode> { getLoginUserCase.nodeJsTest(smarttag, wagon, shelving)
override fun onResponse(call: Call<NodeJsService.SmartTagNode>, response: Response<NodeJsService.SmartTagNode>) { .enqueue(object : Callback<NodeJsService.SmartTagNode>
{
override fun onResponse(
call: Call<NodeJsService.SmartTagNode>,
response: Response<NodeJsService.SmartTagNode>
)
{
var workerId: NodeJsService.SmartTagNode? var workerId: NodeJsService.SmartTagNode?
/* if (response.isSuccessful()){
Log.i("VERDNATURA::","OK")
}
/* if (response.isSuccessful()){ if (!response.errorBody().toString().isEmpty()){
Log.i("VERDNATURA::","OK")
}
if (!response.errorBody().toString().isEmpty()){ }*/
}*/ if (response.body() != null)
{
if (response.body() != null) { Log.i("VERDNATURA::", "el valor nodejs no es nulo ")
Log.i("VERDNATURA::","el valor nodejs no es nulo ")
workerId = NodeJsService.SmartTagNode( workerId = NodeJsService.SmartTagNode(
response.body().toString(), response.body().toString(),
isError = false, isError = false,
errorMessage = "" errorMessage = ""
) )
} else { } else
{
workerId = NodeJsService.SmartTagNode( workerId = NodeJsService.SmartTagNode(
isError = true, isError = true,
errorMessage = "Error al llamar al servicio Node." errorMessage = "Error al llamar al servicio Node."
) )
Log.i("VERDNATURA::","el valor nodejs es NULL") Log.i("VERDNATURA::", "el valor nodejs es NULL")
} }
_nodejs.value = workerId _nodejs.value = workerId
} }
override fun onFailure(call: Call<NodeJsService.SmartTagNode>, t: Throwable) { override fun onFailure(call: Call<NodeJsService.SmartTagNode>, t: Throwable)
{
val workerId = val workerId =
NodeJsService.SmartTagNode(isError = true, errorMessage = t.message!!) NodeJsService.SmartTagNode(isError = true, errorMessage = t.message!!)
// Log.i("VERDNATURA::","el error nodejs es "+t.message+"--"+t.cause.toString()+"--"+t.stackTrace.toString()) // Log.i("VERDNATURA::","el error nodejs es "+t.message+"--"+t.cause.toString()+"--"+t.stackTrace.toString())
_nodejs.value = workerId _nodejs.value = workerId
} }
@ -346,6 +422,22 @@ class LoginViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun getListFromJSON(json: JsonObject): MutableList<itemsExpeditionDynamics>
{
val gson = Gson()
var list = mutableListOf<itemsExpeditionDynamics>()
// val mapType = object : TypeToken<Map<String, Any>>() {}.type
var expeditionState: Map<String, Any> =
gson.fromJson(json, object : TypeToken<Map<String, Any>>()
{}.type)
expeditionState.forEach {
list.add(itemsExpeditionDynamics(key = it.key, value = it.value.toString()))
}
return list
}
} }

View File

@ -24,6 +24,7 @@ import es.verdnatura.presentation.view.feature.controlador.fragment.ControladorF
import es.verdnatura.presentation.view.feature.controlador.fragment.WebFragment import es.verdnatura.presentation.view.feature.controlador.fragment.WebFragment
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoFragment import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoFragment
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoUsuarioFragment import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoUsuarioFragment
import es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleFragment
import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasFragment import es.verdnatura.presentation.view.feature.faltas.fragment.FaltasFragment
import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoFragment import es.verdnatura.presentation.view.feature.historico.fragment.HistoricoFragment
import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoFragment import es.verdnatura.presentation.view.feature.historicovehiculo.fragment.HistoricoVehiculoFragment
@ -316,6 +317,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
"Pre Sacador" -> { "Pre Sacador" -> {
addFragmentOnTop(PreSacadorFragment.newInstance()) addFragmentOnTop(PreSacadorFragment.newInstance())
} }
"Día de venta" -> {
addFragmentOnTop(DayOfSaleFragment("diadeventa"))
}
"Ver Ticket" -> { "Ver Ticket" -> {
addFragmentOnTop(PreControladorFragment.newInstance()) addFragmentOnTop(PreControladorFragment.newInstance())
} }

View File

@ -81,7 +81,7 @@ class ExpeditionPalletDetailFragment(
toolbar_title.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino toolbar_title.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino
setToolBar() setToolBar()
setEvents() setEvents()
viewModel.expeditionPallet_List(user,password,itemPallet!!.Pallet) viewModel.expeditionPallet_List(user,password,itemPallet!!.Pallet,"expeditionPallet_View")
super.init() super.init()
} }
@ -113,17 +113,17 @@ class ExpeditionPalletDetailFragment(
override fun onOptionsItemSelected(item: Drawable) { override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){ if (item == iconReload){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.expeditionPallet_List(user,password,itemPallet!!.Pallet) viewModel.expeditionPallet_List(user,password,itemPallet!!.Pallet,"expeditionPallet_View")
}else if(item == iconEditar){ }else if(item == iconEditar){
onPalletClickListener!!.onPalletClickListener(itemExpeditionTruckVO!!,itemPallet!!) onPalletClickListener!!.onPalletClickListener(itemExpeditionTruckVO!!,itemPallet!!)
}else if(item == iconBorrar){ }else if(item == iconBorrar){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.expeditionPalletDel(user,password,itemPallet!!.Pallet) viewModel.expeditionPalletDel(user,password,itemPallet!!.Pallet,"expeditionPallet_Del")
}else if(item == iconPrint){ }else if(item == iconPrint){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
(getString(R.string.Imprimiendo)+" por " +SectorDescription).toast(requireContext()) (getString(R.string.Imprimiendo)+" por " +SectorDescription).toast(requireContext())
viewModel.expeditionPalletPrintSet(user,password,itemPallet!!.Pallet,sectorFk) viewModel.expeditionPalletPrintSet(user,password,itemPallet!!.Pallet,sectorFk,"expeditionPallet_PrintSet")
} }
} }

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.domain.GetPaletizadoresUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletViewListVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletViewListVO
@ -25,12 +27,12 @@ class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() {
val response: LiveData<ResponseItemVO> val response: LiveData<ResponseItemVO>
get() = _response get() = _response
fun expeditionPallet_List(usuario:String,password:String,vPalletFk:String){ fun expeditionPallet_List(usuario:String,password:String,vPalletFk:String,callFunction:String){
getPaletizadoresUserCase.expeditionPalletView(usuario,password,vPalletFk).enqueue(object : getPaletizadoresUserCase.expeditionPalletView(usuario,password,vPalletFk).enqueue(object :
Callback<List<ItemPalletViewVO>> { Callback<List<ItemPalletViewVO>> {
override fun onFailure(call: Call<List<ItemPalletViewVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemPalletViewVO>>, t: Throwable) {
val listError:ArrayList<ItemPalletViewVO> = ArrayList() val listError:ArrayList<ItemPalletViewVO> = ArrayList()
listError.add(ItemPalletViewVO(isError = true,errorMessage = t.message!!)) listError.add(ItemPalletViewVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_expeditionPalletList.value = ItemPalletViewListVO(listError) _expeditionPalletList.value = ItemPalletViewListVO(listError)
} }
@ -42,7 +44,7 @@ class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() {
_expeditionPalletList.value = response.body()?.let { ItemPalletViewListVO(it) } _expeditionPalletList.value = response.body()?.let { ItemPalletViewListVO(it) }
}else{ }else{
val listError:ArrayList<ItemPalletViewVO> = ArrayList() val listError:ArrayList<ItemPalletViewVO> = ArrayList()
listError.add(ItemPalletViewVO(isError = true,errorMessage = "Error en la llamada de expeditionPallet_View")) listError.add(ItemPalletViewVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_expeditionPalletList.value = ItemPalletViewListVO(listError) _expeditionPalletList.value = ItemPalletViewListVO(listError)
} }
} }
@ -50,14 +52,14 @@ class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() {
}) })
} }
fun expeditionPalletDel(usuario:String,password:String,vPalletFk:String){ fun expeditionPalletDel(usuario:String,password:String,vPalletFk:String,callFunction:String){
getPaletizadoresUserCase.expeditionPalletDel(usuario,password,vPalletFk).enqueue(object : Callback<String>{ getPaletizadoresUserCase.expeditionPalletDel(usuario,password,vPalletFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al borrar pallet "+vPalletFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionPallet_Del") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -69,15 +71,15 @@ class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() {
usuario: String, usuario: String,
password: String, password: String,
vPalletFk: String, vPalletFk: String,
vSectorFk: String vSectorFk: String,callFunction:String){
){
getPaletizadoresUserCase.expeditionPalletPrintSet(usuario,password,vPalletFk,vSectorFk).enqueue(object : Callback<String>{ getPaletizadoresUserCase.expeditionPalletPrintSet(usuario,password,vPalletFk,vSectorFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al imprimir pallet "+vPalletFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionPallet_PrintSet") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }

View File

@ -88,7 +88,7 @@ class ExpeditionPalletFragment(
toolbar_title.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino toolbar_title.text = getCURDATE(itemExpeditionTruckVO!!.ETD) + " " + itemExpeditionTruckVO!!.Destino
setToolBar() setToolBar()
setEvents() setEvents()
viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk) viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk,"expeditionPallet_List")
////Log.i("VERDNATURA:","4-listamos listado de pallets para la expedicion") ////Log.i("VERDNATURA:","4-listamos listado de pallets para la expedicion")
super.init() super.init()
} }
@ -110,7 +110,7 @@ class ExpeditionPalletFragment(
override fun onOptionsItemSelected(item: Drawable) { override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){ if (item == iconReload){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk) viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk,"expeditionPallet_List")
}else if(item == iconPlus){ }else if(item == iconPlus){
expeditionScanAdd() expeditionScanAdd()
} }
@ -182,7 +182,7 @@ class ExpeditionPalletFragment(
private fun expeditionScanAdd(){ private fun expeditionScanAdd(){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.expeditionScanAdd(usuario = user,password = password,vPalletFk = "0",vTruckFk = itemExpeditionTruckVO!!.truckFk) viewModel.expeditionScanAdd(usuario = user,password = password,vPalletFk = "0",vTruckFk = itemExpeditionTruckVO!!.truckFk,"expeditionScan_Add")
} }
private fun showScanExpeditions(it:ItemScanList){ private fun showScanExpeditions(it:ItemScanList){
@ -216,7 +216,7 @@ class ExpeditionPalletFragment(
}.setKoButton("Cerrar"){ }.setKoButton("Cerrar"){
(activity as MainActivity).hideKeyboard(customDialogList.getEditText()) (activity as MainActivity).hideKeyboard(customDialogList.getEditText())
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk) viewModel.expeditionPallet_List(user,password,itemExpeditionTruckVO!!.truckFk,"expeditionPallet_List")
listExpeditions = ArrayList() listExpeditions = ArrayList()
customDialogList.dismiss() customDialogList.dismiss()
}.setValue("").show() }.setValue("").show()
@ -232,9 +232,9 @@ class ExpeditionPalletFragment(
if(customDialogList.getValue().length >= 7){ if(customDialogList.getValue().length >= 7){
listExpeditions.add(0,BarcodeVO(code = customDialogList.getValue())) listExpeditions.add(0,BarcodeVO(code = customDialogList.getValue()))
customDialogList.setDescription("Total: "+listExpeditions.size) customDialogList.setDescription("Total: "+listExpeditions.size)
viewModel.expeditionScanPut(user,password,it.list.get(0).palletFk,customDialogList.getValue()) viewModel.expeditionScanPut(user,password,it.list.get(0).palletFk,customDialogList.getValue(),"expeditionScan_Put")
////Log.i("VERDNATURA:"," palletizando ${it.list.get(0).palletFk} expedi: ${customDialogList.getValue()}") ////Log.i("VERDNATURA:"," palletizando ${it.list.get(0).palletFk} expedi: ${customDialogList.getValue()}")
viewModel.checkRouteExpeditionScanPut(user,password,it.list.get(0).palletFk,customDialogList.getValue()) viewModel.checkRouteExpeditionScanPut(user,password,it.list.get(0).palletFk,customDialogList.getValue(),"expedition_checkRoute")
}else{ }else{
if (mperror != null) mperror!!.start() if (mperror != null) mperror!!.start()
} }

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.domain.GetPaletizadoresUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletListVO import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletListVO
@ -39,12 +41,12 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() {
fun expeditionPallet_List(usuario:String,password:String,vTruckFk:String){ fun expeditionPallet_List(usuario:String,password:String,vTruckFk:String,callFunction:String){
getPaletizadoresUserCase.expeditionPallet_List(usuario,password,vTruckFk).enqueue(object : getPaletizadoresUserCase.expeditionPallet_List(usuario,password,vTruckFk).enqueue(object :
Callback<List<ItemPalletVO>> { Callback<List<ItemPalletVO>> {
override fun onFailure(call: Call<List<ItemPalletVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemPalletVO>>, t: Throwable) {
val listError:ArrayList<ItemPalletVO> = ArrayList() val listError:ArrayList<ItemPalletVO> = ArrayList()
listError.add(ItemPalletVO(isError = true,errorMessage = t.message!!)) listError.add(ItemPalletVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_expeditionPalletList.value = ItemPalletListVO(listError) _expeditionPalletList.value = ItemPalletListVO(listError)
} }
@ -56,7 +58,7 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() {
_expeditionPalletList.value = response.body()?.let { ItemPalletListVO(it) } _expeditionPalletList.value = response.body()?.let { ItemPalletListVO(it) }
}else{ }else{
val listError:ArrayList<ItemPalletVO> = ArrayList() val listError:ArrayList<ItemPalletVO> = ArrayList()
listError.add(ItemPalletVO(isError = true,errorMessage = "Error en la llamada de expeditionTruck_List")) listError.add(ItemPalletVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_expeditionPalletList.value = ItemPalletListVO(listError) _expeditionPalletList.value = ItemPalletListVO(listError)
} }
} }
@ -64,12 +66,12 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() {
}) })
} }
fun expeditionScanAdd(usuario:String,password:String,vPalletFk:String,vTruckFk:String){ fun expeditionScanAdd(usuario:String,password:String,vPalletFk:String,vTruckFk:String,callFunction:String){
getPaletizadoresUserCase.expeditionScanAdd(usuario,password,vPalletFk,vTruckFk).enqueue(object : getPaletizadoresUserCase.expeditionScanAdd(usuario,password,vPalletFk,vTruckFk).enqueue(object :
Callback<List<ItemScanVO>> { Callback<List<ItemScanVO>> {
override fun onFailure(call: Call<List<ItemScanVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemScanVO>>, t: Throwable) {
val listError:ArrayList<ItemScanVO> = ArrayList() val listError:ArrayList<ItemScanVO> = ArrayList()
listError.add(ItemScanVO(isError = true,errorMessage = t.message!!)) listError.add(ItemScanVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_scanList.value = ItemScanList(listError) _scanList.value = ItemScanList(listError)
} }
@ -81,7 +83,7 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() {
_scanList.value = response.body()?.let { ItemScanList(it) } _scanList.value = response.body()?.let { ItemScanList(it) }
}else{ }else{
val listError:ArrayList<ItemScanVO> = ArrayList() val listError:ArrayList<ItemScanVO> = ArrayList()
listError.add(ItemScanVO(isError = true,errorMessage = "Error en la llamada de expeditionTruck_List")) listError.add(ItemScanVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_scanList.value = ItemScanList(listError) _scanList.value = ItemScanList(listError)
} }
} }
@ -89,14 +91,14 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() {
}) })
} }
fun expeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){ fun expeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String,callFunction:String){
getPaletizadoresUserCase.expeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback<String>{ getPaletizadoresUserCase.expeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar expedition "+vExpeditionFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionScan_Put") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -104,17 +106,17 @@ class ExpeditionPalletViewModel (context: Context) : BaseViewModel() {
}) })
} }
fun checkRouteExpeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){ fun checkRouteExpeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String,callFunction:String){
getPaletizadoresUserCase.checkRouteExpeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback<String>{ getPaletizadoresUserCase.checkRouteExpeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar expedition "+vExpeditionFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_responseCheckexpeditionScanPut.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada checkExpeditionScan_Put") _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_responseCheckexpeditionScanPut.value = ResponseItemVO(isError = false,response = response.body()!!) _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = false,response = response.body()!!)
////Log.i("VERDNATURA:","Resultado checkExpeditionScan ${_responseCheckexpeditionScanPut.value}")
} }
} }
}) })

View File

@ -75,7 +75,7 @@ class ExpeditionScanSorterFragment(
private fun expeditionscan(ExpeditionScan: String) { private fun expeditionscan(ExpeditionScan: String) {
splash_progress.visibility = VISIBLE splash_progress.visibility = VISIBLE
viewModel.expedition_scan(user, password, ExpeditionScan) viewModel.expedition_scan(user, password, ExpeditionScan,"expedition_scan")
itemScaned = ExpeditionScan itemScaned = ExpeditionScan
} }

View File

@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.domain.GetPaletizadoresUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
@ -19,11 +21,11 @@ class ExpeditionScanSorterViewModel(context: Context) : BaseViewModel() {
get() = _responsescan get() = _responsescan
fun expedition_scan(usuario:String,password:String,vExpeditionId:String){ fun expedition_scan(usuario:String,password:String,vExpeditionId:String,callFunction:String){
GetPaletizadoresUserCase.expedition_scan(usuario,password,vExpeditionId).enqueue(object : Callback<Void>{ GetPaletizadoresUserCase.expedition_scan(usuario,password,vExpeditionId).enqueue(object : Callback<Void>{
override fun onFailure(call: Call<Void>, t: Throwable) { override fun onFailure(call: Call<Void>, t: Throwable) {
_responsescan.value = messageError(t.message!!,"expedition_scan") _responsescan.value = messageError(getMessageFromAllResponse(callFunction,t.message!!),"expedition_scan")
} }
override fun onResponse(call: Call<Void>, response: Response<Void>) { override fun onResponse(call: Call<Void>, response: Response<Void>) {
@ -42,7 +44,7 @@ class ExpeditionScanSorterViewModel(context: Context) : BaseViewModel() {
fun messageError(message: String,call: String ): ResponseItemVO { fun messageError(message: String,call: String ): ResponseItemVO {
return ResponseItemVO( return ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error al llamar a " + call + " . Descripción del error:" + message errorMessage = "Error en la llamada expedition_scan " + call + " . Descripción del error:" + message
) )
} }

View File

@ -70,7 +70,7 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() {
Callback<List<ItemScanVO>> { Callback<List<ItemScanVO>> {
override fun onFailure(call: Call<List<ItemScanVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemScanVO>>, t: Throwable) {
val listError:ArrayList<ItemScanVO> = ArrayList() val listError:ArrayList<ItemScanVO> = ArrayList()
listError.add(ItemScanVO(isError = true,errorMessage = t.message!!)) listError.add(ItemScanVO(isError = true,errorMessage ="Error en la llamada de expeditionScan_Add." + t.message!!))
_scanList.value = ItemScanList(listError) _scanList.value = ItemScanList(listError)
} }
@ -82,7 +82,7 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() {
_scanList.value = response.body()?.let { ItemScanList(it) } _scanList.value = response.body()?.let { ItemScanList(it) }
}else{ }else{
val listError:ArrayList<ItemScanVO> = ArrayList() val listError:ArrayList<ItemScanVO> = ArrayList()
listError.add(ItemScanVO(isError = true,errorMessage = "Error en la llamada de expeditionTruck_List")) listError.add(ItemScanVO(isError = true,errorMessage = "Error en la llamada de expeditionScan_Add"))
_scanList.value = ItemScanList(listError) _scanList.value = ItemScanList(listError)
} }
} }
@ -93,7 +93,7 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() {
fun expeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){ fun expeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){
getPaletizadoresUserCase.expeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback<String>{ getPaletizadoresUserCase.expeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar expedition "+vExpeditionFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionScan_Put."+t.message!!)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
@ -109,11 +109,11 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() {
fun checkRouteExpeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){ fun checkRouteExpeditionScanPut(usuario:String,password:String,vPalletFk:String,vExpeditionFk:String){
getPaletizadoresUserCase.checkRouteExpeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback<String>{ getPaletizadoresUserCase.checkRouteExpeditionScanPut(usuario,password,vPalletFk,vExpeditionFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar expedition "+vExpeditionFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = "Error al lamar expedition_checkRoute "+vExpeditionFk+ " Respuesta:"+t.message!!)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_responseCheckexpeditionScanPut.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada checkExpeditionScan_Put") _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expedition_checkRoute")
}else{ }else{
_responseCheckexpeditionScanPut.value = ResponseItemVO(isError = false,response = response.body()!!) _responseCheckexpeditionScanPut.value = ResponseItemVO(isError = false,response = response.body()!!)
// ////Log.i("VERDNATURA:","Resultado checkExpeditionScan ${_responseCheckexpeditionScanPut.value}") // ////Log.i("VERDNATURA:","Resultado checkExpeditionScan ${_responseCheckexpeditionScanPut.value}")
@ -127,7 +127,7 @@ class ExpeditionScanViewModel(context: Context) : BaseViewModel() {
fun expeditionScanDel(usuario:String,password:String,vScanFk:String){ fun expeditionScanDel(usuario:String,password:String,vScanFk:String){
getPaletizadoresUserCase.expeditionScanDel(usuario,password,vScanFk).enqueue(object : Callback<String>{ getPaletizadoresUserCase.expeditionScanDel(usuario,password,vScanFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_responseDeleteScan.value = ResponseItemVO(isError = true,errorMessage = "Error al eliminar expedition "+vScanFk+ " Respuesta:"+t.message!!) _responseDeleteScan.value = ResponseItemVO(isError = true,errorMessage = "Error al llamar expeditionScan_Del."+t.message!!)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){

View File

@ -26,6 +26,7 @@ import kotlinx.android.synthetic.main.fragment_item_card.itemcard_layout
import kotlinx.android.synthetic.main.fragment_item_card.splash_progress import kotlinx.android.synthetic.main.fragment_item_card.splash_progress
import kotlinx.android.synthetic.main.fragment_itemexpeditionstate_card.* import kotlinx.android.synthetic.main.fragment_itemexpeditionstate_card.*
import kotlinx.android.synthetic.main.toolbar.* import kotlinx.android.synthetic.main.toolbar.*
import timber.log.Timber.i
class ExpeditionStateFragment( class ExpeditionStateFragment(
var entryPoint: String = "" var entryPoint: String = ""
@ -98,7 +99,7 @@ class ExpeditionStateFragment(
warehouseFk = prefs.getInt(WAREHOUSEFK, 1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK, 1).toString()
// this.itemFk = itemFk // this.itemFk = itemFk
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.expedition_getStateJSON(expeditionFk, user, password) viewModel.expedition_getStateJSON(expeditionFk, user, password,"expedition_getState")
} }
@ -123,6 +124,7 @@ class ExpeditionStateFragment(
setItemExpeditionState(it) setItemExpeditionState(it)
} else { } else {
itemcard_layout.visibility = View.GONE itemcard_layout.visibility = View.GONE
toolbar_title.text = "Estado de la expedición" toolbar_title.text = "Estado de la expedición"

View File

@ -12,6 +12,8 @@ import com.google.gson.JsonObject
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.domain.GetPaletizadoresUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList
@ -94,7 +96,7 @@ class ExpeditionStateViewModel(context: Context) : BaseViewModel() {
}) })
}*/ }*/
fun expedition_getStateJSON(expeditionFk: String, user: String, password: String) { fun expedition_getStateJSON(expeditionFk: String, user: String, password: String,callFunction:String){
GetPaletizadoresUserCase.expedition_getStateJSON(user, password, expeditionFk) GetPaletizadoresUserCase.expedition_getStateJSON(user, password, expeditionFk)
.enqueue(object : Callback<JsonObject> { .enqueue(object : Callback<JsonObject> {
override fun onFailure(call: Call<JsonObject>, t: Throwable) { override fun onFailure(call: Call<JsonObject>, t: Throwable) {
@ -103,7 +105,7 @@ class ExpeditionStateViewModel(context: Context) : BaseViewModel() {
_itemexpedition.value = itemExpedetionState( _itemexpedition.value = itemExpedetionState(
isError = true, isError = true,
errorMessage = "Error al obtener " + expeditionFk + " Respuesta:" + t.message!!, list= listProperties errorMessage = getMessageFromAllResponse(callFunction,t.message!!), list= listProperties
) )
} }
@ -115,40 +117,21 @@ class ExpeditionStateViewModel(context: Context) : BaseViewModel() {
if (response.body() != null) { if (response.body() != null) {
Log.i(
"VERDNATURA:",
"El resultado con JSONOBJECT es ${response.body()}"
)
//var list = getListFromJSON(response.body()!!.asJsonObject)
listProperties=getListFromJSON(response.body()!!.asJsonObject) listProperties=getListFromJSON(response.body()!!.asJsonObject)
/* for (i in list) {
/* if (TextUtils.isDigitsOnly(i.value)){
(i.value.toInt())
println("Convertido" + i.key + i.value.toInt())
}else{println(i.key + i.value)}*/
println("esta en " + i.value.indexOf(".0"))
if (i.value.indexOf(".0")>-1){
println(java.lang.String.format(i.value,"%i"))
}
// println("Sin convertir :" + i.key + java.lang.String.format(i.value.replace(".0","")))
}*/
_itemexpedition.value = itemExpedetionState( _itemexpedition.value = itemExpedetionState(
isError = false, isError = false,
errorMessage = "Error al obtener el estado de la expedición",list = listProperties) errorMessage = "",list = listProperties)
let { let {
Log.i(
"VERDNATURA:",
"El resultado con JSONOBJECT es ${it.toString()}"
)
} }
} else { } else {
_itemexpedition.value = itemExpedetionState( _itemexpedition.value = itemExpedetionState(
isError = true, isError = true,
errorMessage = "Error al obtener el estado de la expedición",list = listProperties errorMessage = getMessageFromAllResponse(callFunction,response.message()),list = listProperties
) )
} }
} }

View File

@ -69,7 +69,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
backButton.visibility = View.GONE backButton.visibility = View.GONE
setToolBar() setToolBar()
////Log.i("VERDNATURA:","1-cargamos expediciones") ////Log.i("VERDNATURA:","1-cargamos expediciones")
viewModel.expeditionTruckList(user,password) viewModel.expeditionTruckList(user,password,"expeditionTruck_List")
super.init() super.init()
} }
@ -88,7 +88,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
override fun onOptionsItemSelected(item: Drawable) { override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){ if (item == iconReload){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.expeditionTruckList(user,password) viewModel.expeditionTruckList(user,password,"expeditionTruck_List")
}else if(item == iconPlus){ }else if(item == iconPlus){
addTruck() addTruck()
} }
@ -112,7 +112,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
event.getContentIfNotHandled().notNull {printExpeditionList(it) } event.getContentIfNotHandled().notNull {printExpeditionList(it) }
}) })
loadResponseExpeditionAdd.observe(viewLifecycleOwner, Observer { event -> loadResponseExpeditionAdd.observe(viewLifecycleOwner, Observer { event ->
viewModel.expeditionTruckList(user,password) viewModel.expeditionTruckList(user,password,"expeditionTruck_List")
}) })
} }
} }
@ -130,7 +130,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
customDialogHor.setTitle("Nuevo Camión").setOkButton("Guardar"){ customDialogHor.setTitle("Nuevo Camión").setOkButton("Guardar"){
(activity as MainActivity).hideKeyboard(customDialogHor.getDestinoEditText()) (activity as MainActivity).hideKeyboard(customDialogHor.getDestinoEditText())
if (!customDialogHor.getDestinoValue().isNullOrEmpty() && !customDialogHor.getHoraValue().isNullOrEmpty()){ if (!customDialogHor.getDestinoValue().isNullOrEmpty() && !customDialogHor.getHoraValue().isNullOrEmpty()){
viewModel.expeditionTruckAdd(user,password,customDialogHor.getHoraValue(),customDialogHor.getDestinoValue()) viewModel.expeditionTruckAdd(user,password,customDialogHor.getHoraValue(),customDialogHor.getDestinoValue(),"expeditionTruck_Add")
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
customDialogHor.dismiss() customDialogHor.dismiss()
} }
@ -144,7 +144,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
customDialogHor.getDestinoEditText().setOnEditorActionListener { v, actionId, event -> customDialogHor.getDestinoEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!customDialogHor.getDestinoValue().isNullOrEmpty() && !customDialogHor.getHoraValue().isNullOrEmpty()){ if (!customDialogHor.getDestinoValue().isNullOrEmpty() && !customDialogHor.getHoraValue().isNullOrEmpty()){
viewModel.expeditionTruckAdd(user,password,customDialogHor.getHoraValue(),customDialogHor.getDestinoValue()) viewModel.expeditionTruckAdd(user,password,customDialogHor.getHoraValue(),customDialogHor.getDestinoValue(),"expeditionTruck_Add")
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
customDialogHor.dismiss() customDialogHor.dismiss()
} }

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetPaletizadoresUserCase import es.verdnatura.domain.GetPaletizadoresUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckList import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckList
@ -27,12 +29,12 @@ class ExpeditionTruckListViewModel(context: Context) : BaseViewModel() {
fun expeditionTruckList(usuario:String,password:String){ fun expeditionTruckList(usuario:String,password:String,callFunction:String){
getPaletizadoresUserCase.expeditionTruckList(usuario,password).enqueue(object : getPaletizadoresUserCase.expeditionTruckList(usuario,password).enqueue(object :
Callback<List<ItemExpeditionTruckVO>> { Callback<List<ItemExpeditionTruckVO>> {
override fun onFailure(call: Call<List<ItemExpeditionTruckVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemExpeditionTruckVO>>, t: Throwable) {
val listError:ArrayList<ItemExpeditionTruckVO> = ArrayList() val listError:ArrayList<ItemExpeditionTruckVO> = ArrayList()
listError.add(ItemExpeditionTruckVO(isError = true,errorMessage = t.message!!)) listError.add(ItemExpeditionTruckVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)))
_expeditionTruckList.value = ItemExpeditionTruckList(listError) _expeditionTruckList.value = ItemExpeditionTruckList(listError)
} }
@ -44,7 +46,7 @@ class ExpeditionTruckListViewModel(context: Context) : BaseViewModel() {
_expeditionTruckList.value = response.body()?.let { ItemExpeditionTruckList(it) } _expeditionTruckList.value = response.body()?.let { ItemExpeditionTruckList(it) }
}else{ }else{
val listError:ArrayList<ItemExpeditionTruckVO> = ArrayList() val listError:ArrayList<ItemExpeditionTruckVO> = ArrayList()
listError.add(ItemExpeditionTruckVO(isError = true,errorMessage = "Error en la llamada de expeditionTruck_List")) listError.add(ItemExpeditionTruckVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_expeditionTruckList.value = ItemExpeditionTruckList(listError) _expeditionTruckList.value = ItemExpeditionTruckList(listError)
} }
} }
@ -52,15 +54,15 @@ class ExpeditionTruckListViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun expeditionTruckAdd(usuario:String,password:String,vHour:String,vDescription:String){ fun expeditionTruckAdd(usuario:String,password:String,vHour:String,vDescription:String,callFunction:String){
getPaletizadoresUserCase.expeditionTruckAdd(usuario,password,vHour,vDescription).enqueue(object : Callback<String>{ getPaletizadoresUserCase.expeditionTruckAdd(usuario,password,vHour,vDescription).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error al guardar CAMIÓN "+vDescription+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada expeditionTruckAdd") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }

View File

@ -121,7 +121,7 @@ class ParkingFragment : BaseFragment<FragmentParkingBinding,ParkingViewModel>(Pa
usuario = user, usuario = user,
password = password, password = password,
parking = txtScan, parking = txtScan,
scanItem = it.code!! scanItem = it.code!!,callFunction = "shelvingPark"
) )
} }
}else{ }else{

View File

@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetUbicadorUserCase import es.verdnatura.domain.GetUbicadorUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
@ -29,22 +31,22 @@ class ParkingViewModel(context: Context) : BaseViewModel() {
} }
fun parking(usuario: String,password: String,scanItem: String,parking:String){ fun parking(usuario: String,password: String,scanItem: String,parking:String,callFunction:String){
showProgressLoading() showProgressLoading()
getUbicadorUserCase.shelvingPark(usuario,password,scanItem,parking).enqueue(object : getUbicadorUserCase.shelvingPark(usuario,password,scanItem,parking).enqueue(object :
Callback<String> { Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
if (response.body() == "Finish") if (response.body() == "Finish")
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
else else
_response.value = ResponseItemVO(isError = true,errorMessage = "No existe el parking en la Base de Datos (shelvingPark)") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} }
} }
}) })

View File

@ -42,6 +42,13 @@ class PasilleroViewModel(context: Context) : BaseViewModel() {
) )
) )
_pasillerositem.add(
PasillerosItemVO(
41,
R.drawable.day_of_sale,
"Día de venta", R.string.dayofSale
)
)
_pasillerositem.add( _pasillerositem.add(
PasillerosItemVO( PasillerosItemVO(
22, 22,

View File

@ -85,7 +85,7 @@ class PreControladorFragment: BaseFragment<FragmentControladorBinding,PreControl
password = password, password = password,
sectorFk = sectorFk, sectorFk = sectorFk,
collectionFk = scan_input.text.toString(), collectionFk = scan_input.text.toString(),
type = type type = type,callFunction = "collection_getTickets"
) )
// //Log.i("VERDNATURA:","La collection es ${scan_input.text.toString()}") // //Log.i("VERDNATURA:","La collection es ${scan_input.text.toString()}")
} }

View File

@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.domain.GetPreControladorUserCase import es.verdnatura.domain.GetPreControladorUserCase
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import retrofit2.Call import retrofit2.Call
@ -19,11 +21,11 @@ class PreControladorViewModel(context: Context) : BaseViewModel() {
val collectionTicketList: LiveData<CollectionVO> val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList get() = _collectionTicketList
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,type:String){ fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,type:String,callFunction:String){
getPreControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0",type).enqueue(object : getPreControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0",type).enqueue(object :
Callback<CollectionVO> { Callback<CollectionVO> {
override fun onFailure(call: Call<CollectionVO>, t: Throwable) { override fun onFailure(call: Call<CollectionVO>, t: Throwable) {
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = t.message!!) _collectionTicketList.value = CollectionVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse( override fun onResponse(
call: Call<CollectionVO>, call: Call<CollectionVO>,
@ -32,7 +34,7 @@ class PreControladorViewModel(context: Context) : BaseViewModel() {
if (response.body() != null){ if (response.body() != null){
_collectionTicketList.value = response.body()?.let { it.map() } _collectionTicketList.value = response.body()?.let { it.map() }
}else{ }else{
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = "No hay tickets para sacar") _collectionTicketList.value = CollectionVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} }
} }
}) })

View File

@ -161,6 +161,15 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
goBack = false goBack = false
}) })
responseSalixMessage.observe(viewLifecycleOwner, Observer{
if (it.isError){
customDialog.setTitle("Error").setDescription(it.errorMessage)
.setOkButton("Aceptar") {
customDialog.dismiss()
}.show()
}
})
responseCode.observe(viewLifecycleOwner, Observer { responseCode.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE splash_progress.visibility = View.GONE
if (!goBack2){ if (!goBack2){
@ -370,7 +379,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
vStateFk = PRESACADOR, vStateFk = PRESACADOR,
//sergio: se añade originalItemScan para //sergio: se añade originalItemScan para
vBuyFk = originalItemScan vBuyFk = originalItemScan,callFunction = "saleTrackingReplace"
) )
@ -391,7 +400,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
viewModel.saleTrackingDel( viewModel.saleTrackingDel(
usuario = user, usuario = user,
password = password, password = password,
saleFk = sales[position].idMovimiento saleFk = sales[position].idMovimiento,"saleTracking_del"
) )
setTotalLines() setTotalLines()
scanRequest() scanRequest()
@ -420,7 +429,8 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
password = password, password = password,
itemFk = sales[position].itemFk, itemFk = sales[position].itemFk,
quantity = quantityGet, quantity = quantityGet,
shelvingFk = sales[position].carros[shelvingPosition].shelving shelvingFk = sales[position].carros[shelvingPosition].shelving,
callFunction = "itemPlacementSupplyAiming"
) )
} }
@ -460,7 +470,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
viewModel.getIdFromCode( viewModel.getIdFromCode(
usuario = user, usuario = user,
password = password, password = password,
code = customDialogList.getValueTwo() code = customDialogList.getValueTwo(),"barcodeToItem"
) )
customDialogList.dismiss() customDialogList.dismiss()
} }
@ -503,7 +513,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
viewModel.getIdFromCode( viewModel.getIdFromCode(
usuario = user, usuario = user,
password = password, password = password,
code = customDialogList.getValueTwo() code = customDialogList.getValueTwo(),"barcodeToItem"
) )
customDialogList.dismiss() customDialogList.dismiss()
} }
@ -549,7 +559,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
password = password, password = password,
itemShelvingFk = itemShelvingFk, itemShelvingFk = itemShelvingFk,
saleFk = sales[storedPosition].idMovimiento, saleFk = sales[storedPosition].idMovimiento,
quantity = customDialogList.getValue() quantity = customDialogList.getValue(),callFunction = "itemShelvingSaleSupplyAdd"
) )
}catch (e:Exception){} }catch (e:Exception){}
@ -606,7 +616,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
usuario = user, usuario = user,
password = password, password = password,
collectionFk = ticket, collectionFk = ticket,
sectorFk = sectorFk sectorFk = sectorFk,"collectionSticker_print"
) )
////Log.i("VERDNATURA:","La collection es $ticket, sectorFk $sectorFk, user $user i pass $password") ////Log.i("VERDNATURA:","La collection es $ticket, sectorFk $sectorFk, user $user i pass $password")
(getString(R.string.Imprimiendo) + " por " + SectorDescription).toast(requireContext()) (getString(R.string.Imprimiendo) + " por " + SectorDescription).toast(requireContext())
@ -657,7 +667,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
usuario = user, usuario = user,
password = password, password = password,
ticketFk = ticket, ticketFk = ticket,
parking = parking parking = parking,"shelvingPark"
) )
////Log.i("VERDNATURA:","El usuario $user pass $password ticket $ticketFk y parking $parking") ////Log.i("VERDNATURA:","El usuario $user pass $password ticket $ticketFk y parking $parking")
@ -744,7 +754,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
password = password, password = password,
saleFk = sales[position].idMovimiento, saleFk = sales[position].idMovimiento,
quantity = totalQuantity.toString(), quantity = totalQuantity.toString(),
originalQuantity = sales[position].quantity.toString() originalQuantity = sales[position].quantity.toString(),"saleMove"
) )
//sales[position].originalQuantity = quantity //sales[position].originalQuantity = quantity
try{ try{
@ -762,7 +772,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
//enviar mensaje a salix //enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)" val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha enviado a Split el articulo "+sales[position].itemFk+" del ticket "+ticket val message = "Se ha enviado a Split el articulo "+sales[position].itemFk+" del ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message) viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message, "sendChekingPresence")
} }
@ -779,7 +789,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
quantity = totalQuantity.toString(), quantity = totalQuantity.toString(),
warehouseFk = warehouseFk, warehouseFk = warehouseFk,
type = "FALSE", type = "FALSE",
originalQuantity = quantity originalQuantity = quantity,callFunction = "collectionMissingTrash"
) )
//sales[position].originalQuantity = quantity //sales[position].originalQuantity = quantity
try{ try{
@ -796,7 +806,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
//enviar mensaje a salix //enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)" val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha enviado a Faltas la cantidad de "+ totalQuantity +" del articulo "+sales[position].itemFk+" ticket "+ticket val message = "Se ha enviado a Faltas la cantidad de "+ totalQuantity +" del articulo "+sales[position].itemFk+" ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message) viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message,"sendChekingPresence")
} }
private fun missing(position: Int,quantity:String){ private fun missing(position: Int,quantity:String){
@ -811,7 +821,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
quantity = totalQuantity.toString(), quantity = totalQuantity.toString(),
warehouseFk = warehouseFk, warehouseFk = warehouseFk,
type = "TRUE", type = "TRUE",
originalQuantity = quantity originalQuantity = quantity,callFunction = "collectionMissingTrash"
) )
//sales[position].originalQuantity = quantity //sales[position].originalQuantity = quantity
try{ try{
@ -830,7 +840,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
//enviar mensaje a salix //enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)" val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha enviado a Basura "+ totalQuantity +" del articulo "+sales[position].itemFk+" ticket "+ticket val message = "Se ha enviado a Basura "+ totalQuantity +" del articulo "+sales[position].itemFk+" ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message) viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message,"sendChekingPresence")
} }
private fun reject(position: Int,quantity:String){ private fun reject(position: Int,quantity:String){
@ -845,13 +855,13 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
quantity = totalQuantity.toString(), quantity = totalQuantity.toString(),
warehouseFk = warehouseFk, warehouseFk = warehouseFk,
type = "reject", type = "reject",
originalQuantity = quantity originalQuantity = quantity,callFunction = "collectionMissingTrash"
) )
//enviar mensaje a salix //enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)" val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha modificado la cantidad original "+sales[position].saldo+" del artículo "+sales[position].itemFk+" a nueva cantidad: "+ quantity +" del ticket "+ticket val message = "Se ha modificado la cantidad original "+sales[position].saldo+" del artículo "+sales[position].itemFk+" a nueva cantidad: "+ quantity +" del ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message) viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message,"sendChekingPresence")
try{ try{
sales[position].saldo = quantity.toInt() sales[position].saldo = quantity.toInt()
@ -872,14 +882,15 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
usuario = user, usuario = user,
password = password, password = password,
saleFk = sales[position].idMovimiento, saleFk = sales[position].idMovimiento,
quantity = quantity quantity = quantity,
callFunction = "collection_increaseQuantity"
) )
try { try {
//enviar mensaje a salix //enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)" val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha modificado la cantidad original "+sales[position].saldo+" del artículo "+sales[position].itemFk+" a nueva cantidad: "+ quantity +" del ticket "+ticket val message = "Se ha modificado la cantidad original "+sales[position].saldo+" del artículo "+sales[position].itemFk+" a nueva cantidad: "+ quantity +" del ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message) viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message,"sendChekingPresence")
try{ try{
sales[position].saldo = quantity.toInt() sales[position].saldo = quantity.toInt()

View File

@ -9,6 +9,9 @@ import es.verdnatura.domain.GetPreSacadorUseCase
import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.domain.GetUbicadorUserCase import es.verdnatura.domain.GetUbicadorUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.getMessageFromResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO
@ -17,9 +20,11 @@ import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
class PreSacadorViewModel (context: Context): BaseViewModel() { class PreSacadorViewModel(context: Context) : BaseViewModel()
{
private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase(context) private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase(context)
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context) private val getSacadorControladorUserCase: GetSacadorControladorUserCase =
GetSacadorControladorUserCase(context)
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context)
private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context) private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context)
@ -43,208 +48,447 @@ class PreSacadorViewModel (context: Context): BaseViewModel() {
val responseIncQuantity: LiveData<ResponseItemVO> val responseIncQuantity: LiveData<ResponseItemVO>
get() = _responseIncQuantity get() = _responseIncQuantity
private val _responseSalixMessage by lazy { MutableLiveData<ResponseItemVO>() }
val responseSalixMessage: LiveData<ResponseItemVO>
get() = _responseSalixMessage
fun ticketToPrePrepare(usuario:String,password:String,ticketFk:String,sectorFk:String){ fun ticketToPrePrepare(usuario: String, password: String, ticketFk: String, sectorFk: String)
getPreSacadorUseCase.ticketToPrePrepare(usuario,password,ticketFk,sectorFk).enqueue(object : {
Callback<List<PreSacadorItemVO>> { getPreSacadorUseCase.ticketToPrePrepare(usuario, password, ticketFk, sectorFk)
override fun onFailure(call: Call<List<PreSacadorItemVO>>, t: Throwable) { .enqueue(object :
_salesList.value = listOf() Callback<List<PreSacadorItemVO>>
} {
override fun onResponse( override fun onFailure(call: Call<List<PreSacadorItemVO>>, t: Throwable)
call: Call<List<PreSacadorItemVO>>, {
response: Response<List<PreSacadorItemVO>>
) {
if (response.body() != null){
_salesList.value = response.body()?.let { it }
}else{
_salesList.value = listOf() _salesList.value = listOf()
} }
}
}) override fun onResponse(
call: Call<List<PreSacadorItemVO>>,
response: Response<List<PreSacadorItemVO>>
)
{
if (response.body() != null)
{
_salesList.value = response.body()?.let { it }
} else
{
_salesList.value = listOf()
}
}
})
} }
fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String){ fun collectionStickerPrint(
getSacadorControladorUserCase.collectionStickerPrint(usuario,password,collectionFk,sectorFk).enqueue(object : Callback<String>{ usuario: String,
override fun onFailure(call: Call<String>, t: Throwable) { password: String,
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) collectionFk: String,
sectorFk: String,callFunction:String
)
{
getSacadorControladorUserCase.collectionStickerPrint(
usuario,
password,
collectionFk,
sectorFk
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>)
if (response.body() == null){ {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionStickerPrint") if (response.body() == null)
}else{ {
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
} }
} }
}) })
} }
fun parking(usuario: String,password: String,ticketFk: String,parking:String){ fun parking(usuario: String, password: String, ticketFk: String, parking: String,callFunction:String)
getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).enqueue(object : Callback<String>{ {
override fun onFailure(call: Call<String>, t: Throwable) { getUbicadorUserCase.shelvingPark(usuario, password, ticketFk, parking)
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) .enqueue(object : Callback<String>
} {
override fun onFailure(call: Call<String>, t: Throwable)
override fun onResponse(call: Call<String>, response: Response<String>) { {
if (response.body() == null){ _response.value = ResponseItemVO(
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") isError = true,
}else{ errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
_response.value = ResponseItemVO(isError = false,response = response.body()!!) )
} }
}
}) override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
} }
fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String){ fun itemPlacementSupplyAiming(
getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object : usuario: String,
Callback<List<PlacementSupplyVO>> { password: String,
override fun onFailure(call: Call<List<PlacementSupplyVO>>, t: Throwable) { shelvingFk: String,
val listError:ArrayList<PlacementSupplyVO> = ArrayList() quantity: String,
listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!)) itemFk: String,callFunction:String
)
{
getSacadorControladorUserCase.itemPlacementSupplyAiming(
usuario,
password,
shelvingFk,
quantity,
itemFk
).enqueue(object :
Callback<List<PlacementSupplyVO>>
{
override fun onFailure(call: Call<List<PlacementSupplyVO>>, t: Throwable)
{
val listError: ArrayList<PlacementSupplyVO> = ArrayList()
listError.add(PlacementSupplyVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!)))
_placementSuppleyList.value = PlacementSupplyListVO(listError) _placementSuppleyList.value = PlacementSupplyListVO(listError)
} }
override fun onResponse( override fun onResponse(
call: Call<List<PlacementSupplyVO>>, call: Call<List<PlacementSupplyVO>>,
response: Response<List<PlacementSupplyVO>> response: Response<List<PlacementSupplyVO>>
) { )
if (response.body() != null){ {
if (response.body() != null)
{
_placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) }
}else{ } else
val listError:ArrayList<PlacementSupplyVO> = ArrayList() {
listError.add(PlacementSupplyVO(isError = true,errorMessage = "Error en la llamada de itemPlacementSupplyAiming")) val listError: ArrayList<PlacementSupplyVO> = ArrayList()
listError.add(
PlacementSupplyVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
)
_placementSuppleyList.value = PlacementSupplyListVO(listError) _placementSuppleyList.value = PlacementSupplyListVO(listError)
} }
} }
}) })
} }
fun itemShelvingSaleSupplyAdd(usuario:String,password:String,itemShelvingFk:String,saleFk:String,quantity:String){ fun itemShelvingSaleSupplyAdd(
getSacadorControladorUserCase.itemShelvingSaleSupplyAdd(usuario,password,itemShelvingFk,saleFk,quantity).enqueue(object : Callback<String>{ usuario: String,
override fun onFailure(call: Call<String>, t: Throwable) { password: String,
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) itemShelvingFk: String,
saleFk: String,
quantity: String,callFunction:String
)
{
getSacadorControladorUserCase.itemShelvingSaleSupplyAdd(
usuario,
password,
itemShelvingFk,
saleFk,
quantity
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>)
if (response.body() == null){ {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingSaleSupplyAdd") if (response.body() == null)
}else{ {
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
} }
} }
}) })
} }
fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String,vBuyFk:String){ fun saleTrackingReplace(
usuario: String,
password: String,
saleFk: String,
vOriginalQuantity: String,
vStateFk: String,
vIsChecked: String,
vBuyFk: String,callFunction:String
)
{
//Lo ultimo que se envia //Lo ultimo que se envia
//sergio: se quita el 0 que habia por defecto para la previa se añada el buyFk que sera el item escaneado. //sergio: se quita el 0 que habia por defecto para la previa se añada el buyFk que sera el item escaneado.
//getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked,"0").enqueue(object : Callback<String>{ //getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked,"0").enqueue(object : Callback<String>{
getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked,vBuyFk).enqueue(object : Callback<String>{ getSacadorControladorUserCase.saleTrackingReplace(
override fun onFailure(call: Call<String>, t: Throwable) { usuario,
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) password,
saleFk,
vOriginalQuantity,
vStateFk,
vIsChecked,
vBuyFk
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>)
if (response.body() == null){ {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleTracking_Replace") if (response.body() == null)
}else{ {
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message())
)
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
} }
} }
}) })
} }
fun getIdFromCode(usuario:String,password:String,code: String){ fun getIdFromCode(usuario: String, password: String, code: String,callFunction:String)
getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback<String>{ {
override fun onFailure(call: Call<String>, t: Throwable) { getSacadorControladorUserCase.getIdFromCode(usuario, password, code)
_responseCode.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) .enqueue(object : Callback<String>
} {
override fun onFailure(call: Call<String>, t: Throwable)
override fun onResponse(call: Call<String>, response: Response<String>) { {
if (response.body() == null){ _responseCode.value = ResponseItemVO(
_responseCode.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada barcodeToItem") isError = true,
}else{ errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
_responseCode.value = ResponseItemVO(isError = false,response = response.body()!!) )
}
}
})
}
fun saleTrackingDel(usuario:String,password:String,saleFk: String){
getSacadorControladorUserCase.saleTrackingDel(usuario,password,saleFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun saleMove(usuario:String,password:String,saleFk: String,quantity: String,originalQuantity : String){
getSacadorControladorUserCase.saleMove(usuario,password,saleFk,quantity,originalQuantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleMove")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun collectionMissingTrash(usuario:String,password:String,saleFk: String,quantity: String,type:String,warehouseFk:String,originalQuantity: String){
getSacadorControladorUserCase.collectionMissingTrash(usuario,password,saleFk,quantity,type,warehouseFk,originalQuantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionMissingTrash")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String,quantity: String){
getSacadorControladorUserCase.collectionIncreaseQuantity(usuario,password,saleFk,quantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionIncreaseQuantity")
}else{
_responseIncQuantity.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun sendChekingPresence(token:String,workerId:String,message:String){
try{
getLoginUserCase.sendChekingPresence(token,workerId.toInt(),message).enqueue(object : Callback<Boolean>{
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
Log.i("Salix","Mensaje enviado a salix")
} }
override fun onFailure(call: Call<Boolean>, t: Throwable) { override fun onResponse(call: Call<String>, response: Response<String>)
Log.i("Salix Error",""+t.message) {
if (response.body() == null)
{
_responseCode.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} else
{
_responseCode.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
} }
}) })
}catch (e:Exception){} }
fun saleTrackingDel(usuario: String, password: String, saleFk: String,callFunction:String){
getSacadorControladorUserCase.saleTrackingDel(usuario, password, saleFk)
.enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} else
{
_response.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun saleMove(
usuario: String,
password: String,
saleFk: String,
quantity: String,
originalQuantity: String,callFunction:String)
{
getSacadorControladorUserCase.saleMove(
usuario,
password,
saleFk,
quantity,
originalQuantity
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun collectionMissingTrash(
usuario: String,
password: String,
saleFk: String,
quantity: String,
type: String,
warehouseFk: String,
originalQuantity: String,callFunction:String)
{
getSacadorControladorUserCase.collectionMissingTrash(
usuario,
password,
saleFk,
quantity,
type,
warehouseFk,
originalQuantity
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_response.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} else
{
_response.value = ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun collectionIncreaseQuantity(
usuario: String,
password: String,
saleFk: String,
quantity: String,callFunction:String)
{
getSacadorControladorUserCase.collectionIncreaseQuantity(
usuario,
password,
saleFk,
quantity
).enqueue(object : Callback<String>
{
override fun onFailure(call: Call<String>, t: Throwable)
{
_responseIncQuantity.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
)
}
override fun onResponse(call: Call<String>, response: Response<String>)
{
if (response.body() == null)
{
_responseIncQuantity.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(callFunction,response.message()))
} else
{
_responseIncQuantity.value =
ResponseItemVO(isError = false, response = response.body()!!)
}
}
})
}
fun sendChekingPresence(
token: String,
workerId: String,
message: String,
calledFunction: String
)
{
try
{
getLoginUserCase.sendChekingPresence(token, workerId.toInt(), message)
.enqueue(object : Callback<Boolean>
{
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>)
{
if (!response.isSuccessful)
{
_responseSalixMessage.value = ResponseItemVO(
isError = true,
errorMessage = "Error en la llamada $calledFunction al enviar mensaje rocket." + getMessageFromResponse(
response.message()
)
)
//Log.i("Salix","Mensaje enviado a salix")
}
}
override fun onFailure(call: Call<Boolean>, t: Throwable)
{
Log.i("Salix Error", "" + t.message)
}
})
} catch (e: Exception)
{
}
} }
} }

View File

@ -1,8 +1,15 @@
package es.verdnatura.presentation.view.feature.qr package es.verdnatura.presentation.view.feature.qr
import android.annotation.SuppressLint
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.Typeface
import android.inputmethodservice.Keyboard
import android.os.Bundle import android.os.Bundle
import android.text.InputType
import android.util.Log
import android.view.KeyEvent
import android.view.KeyEvent.*
import android.view.View import android.view.View
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
@ -24,7 +31,6 @@ class QrFragment(
private var sectorFk = "" private var sectorFk = ""
private var warehouseFk = "" private var warehouseFk = ""
private var goBack: Boolean = false private var goBack: Boolean = false
// private var onCollectionSelectedListener: OnCollectionSelectedListener? = null
override fun getLayoutId(): Int = R.layout.fragment_qr override fun getLayoutId(): Int = R.layout.fragment_qr
private lateinit var customDialog: CustomDialog private lateinit var customDialog: CustomDialog
private var type = "" private var type = ""
@ -33,11 +39,6 @@ class QrFragment(
companion object { companion object {
fun newInstance(entryPoint: String) = QrFragment(entryPoint) fun newInstance(entryPoint: String) = QrFragment(entryPoint)
} }
/*
override fun onAttach(context: Context) {
super.onAttach(context)
if (context is OnCollectionSelectedListener) onCollectionSelectedListener = context
}*/
override fun init() { override fun init() {
@ -69,6 +70,7 @@ class QrFragment(
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
} }
private fun setEvents() { private fun setEvents() {
backButton.setOnClickListener { backButton.setOnClickListener {
@ -77,11 +79,15 @@ class QrFragment(
scan_input.requestFocus() scan_input.requestFocus()
scan_input.setOnEditorActionListener { v, actionId, event -> scan_input.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
goBack = false goBack = false
if (!scan_input.text.isNullOrEmpty()) { if (!scan_input.text.isNullOrEmpty()) {
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.qr_getCall(user, password, scan_input.text.toString()) viewModel.qr_getCall(user, password, scan_input.text.toString(),"qr_getCall")
itemscaned = scan_input.text.toString() itemscaned = scan_input.text.toString()
} }
@ -91,6 +97,9 @@ class QrFragment(
return@setOnEditorActionListener true return@setOnEditorActionListener true
} }
//false //false
} }

View File

@ -7,6 +7,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetQrReaderUserCase import es.verdnatura.domain.GetQrReaderUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
@ -22,14 +24,14 @@ class QrFragmentViewModel(context: Context) : BaseViewModel() {
get() = _qrresponse get() = _qrresponse
fun qr_getCall(user: String, password: String, vStatement: String) { fun qr_getCall(user: String, password: String, vStatement: String,callFunction:String){
GetQrReaderUserCase.qr_getCall(user, password, vStatement) GetQrReaderUserCase.qr_getCall(user, password, vStatement)
.enqueue(object : Callback<String> { .enqueue(object : Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_qrresponse.value = ResponseItemVO( _qrresponse.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error al realizar operación del Qr.Respuesta:" + t.message!! errorMessage = getMessageFromAllResponse(callFunction,t.message!!)
) )
} }
@ -59,7 +61,7 @@ class QrFragmentViewModel(context: Context) : BaseViewModel() {
if (response.body() == null) { if (response.body() == null) {
_qrresponse.value = ResponseItemVO( _qrresponse.value = ResponseItemVO(
isError = true, isError = true,
errorMessage = "Error en la llamada Qr" errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} }

View File

@ -116,7 +116,7 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
btn_obtener.setOnClickListener { btn_obtener.setOnClickListener {
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.itemPlacementSupplyGetOrder(usuario = user,password = password,sectorFk = sectorFk) viewModel.itemPlacementSupplyGetOrder(usuario = user,password = password,sectorFk = sectorFk,"itemPlacementSupplyGetOrder")
} }
btn_cancelar.setOnClickListener { btn_cancelar.setOnClickListener {
@ -127,7 +127,7 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
}.setOkButton("Cerrar"){ }.setOkButton("Cerrar"){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
if (sales.count() > 0){ if (sales.count() > 0){
viewModel.itemPlacementSupplyCloseOrder(usuario = user,password = password,id = sales[0].id,quantity = sales[0].quantity.toString()) viewModel.itemPlacementSupplyCloseOrder(usuario = user,password = password,id = sales[0].id,quantity = sales[0].quantity.toString(),"itemPlacementSupplyCloseOrder")
} }
customDialog.dismiss() customDialog.dismiss()
@ -165,7 +165,7 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
//LISTA ========= //LISTA =========
collection_swipe.setOnRefreshListener { collection_swipe.setOnRefreshListener {
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.itemPlacementSupplyGetOrder(usuario = user,password = password,sectorFk = sectorFk) viewModel.itemPlacementSupplyGetOrder(usuario = user,password = password,sectorFk = sectorFk,"itemPlacementSupplyGetOrder")
collection_swipe.isRefreshing = false collection_swipe.isRefreshing = false
} }
@ -352,7 +352,8 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
password = password, password = password,
itemFk = sales[position].itemFk, itemFk = sales[position].itemFk,
quantity = quantityGet, quantity = quantityGet,
shelvingFk = sales[position].carros[shelvingPosition].shelving shelvingFk = sales[position].carros[shelvingPosition].shelving,
callFunction = "itemPlacementSupplyAiming"
) )
} }
@ -387,7 +388,7 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
viewModel.getIdFromCode( viewModel.getIdFromCode(
usuario = user, usuario = user,
password = password, password = password,
code = customDialogList.getValueTwo() code = customDialogList.getValueTwo(),"barcodeToItem"
) )
customDialogList.dismiss() customDialogList.dismiss()
} }
@ -425,7 +426,7 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
viewModel.getIdFromCode( viewModel.getIdFromCode(
usuario = user, usuario = user,
password = password, password = password,
code = customDialogList.getValueTwo() code = customDialogList.getValueTwo(),"barcodeToItem"
) )
customDialogList.dismiss() customDialogList.dismiss()
} }
@ -471,7 +472,7 @@ class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionVie
password = password, password = password,
itemShelvingFk = itemShelvingFk, itemShelvingFk = itemShelvingFk,
itemPlacementSupplyFk = sales[storedPosition].id, itemPlacementSupplyFk = sales[storedPosition].id,
quantity = customDialogList.getValue() quantity = customDialogList.getValue(),"itemShelvingPlacementSupplyAdd"
) )
}catch (e:Exception){} }catch (e:Exception){}

View File

@ -7,6 +7,8 @@ import es.verdnatura.domain.GetPreSacadorUseCase
import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.domain.GetUbicadorUserCase import es.verdnatura.domain.GetUbicadorUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO
@ -40,7 +42,7 @@ class ReposicionViewModel(context: Context) : BaseViewModel() {
val responseCode: LiveData<ResponseItemVO> val responseCode: LiveData<ResponseItemVO>
get() = _responseCode get() = _responseCode
fun itemPlacementSupplyGetOrder(usuario:String,password:String,sectorFk:String){ fun itemPlacementSupplyGetOrder(usuario:String,password:String,sectorFk:String,callFunction:String){
getPreSacadorUseCase.itemPlacementSupplyGetOrder(usuario,password,sectorFk).enqueue(object : getPreSacadorUseCase.itemPlacementSupplyGetOrder(usuario,password,sectorFk).enqueue(object :
Callback<List<PreSacadorItemVO>> { Callback<List<PreSacadorItemVO>> {
override fun onFailure(call: Call<List<PreSacadorItemVO>>, t: Throwable) { override fun onFailure(call: Call<List<PreSacadorItemVO>>, t: Throwable) {
@ -59,15 +61,15 @@ class ReposicionViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun parking(usuario: String,password: String,ticketFk: String,parking:String){ fun parking(usuario: String,password: String,ticketFk: String,parking:String,callFunction:String){
getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).enqueue(object : Callback<String>{ getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -75,12 +77,12 @@ class ReposicionViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String){ fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String,callFunction:String){
getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object : getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object :
Callback<List<PlacementSupplyVO>> { Callback<List<PlacementSupplyVO>> {
override fun onFailure(call: Call<List<PlacementSupplyVO>>, t: Throwable) { override fun onFailure(call: Call<List<PlacementSupplyVO>>, t: Throwable) {
val listError:ArrayList<PlacementSupplyVO> = ArrayList() val listError:ArrayList<PlacementSupplyVO> = ArrayList()
listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!)) listError.add(PlacementSupplyVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)))
_placementSuppleyList.value = PlacementSupplyListVO(listError) _placementSuppleyList.value = PlacementSupplyListVO(listError)
} }
override fun onResponse( override fun onResponse(
@ -91,22 +93,22 @@ class ReposicionViewModel(context: Context) : BaseViewModel() {
_placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) }
}else{ }else{
val listError:ArrayList<PlacementSupplyVO> = ArrayList() val listError:ArrayList<PlacementSupplyVO> = ArrayList()
listError.add(PlacementSupplyVO(isError = true,errorMessage = "Error en la llamada de itemPlacementSupplyAiming")) listError.add(PlacementSupplyVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_placementSuppleyList.value = PlacementSupplyListVO(listError) _placementSuppleyList.value = PlacementSupplyListVO(listError)
} }
} }
}) })
} }
fun getIdFromCode(usuario:String,password:String,code: String){ fun getIdFromCode(usuario:String,password:String,code: String,callFunction:String){
getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback<String>{ getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_responseCode.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) _responseCode.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_responseCode.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada barcodeToItem") _responseCode.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_responseCode.value = ResponseItemVO(isError = false,response = response.body()!!) _responseCode.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -115,15 +117,15 @@ class ReposicionViewModel(context: Context) : BaseViewModel() {
} }
fun itemShelvingPlacementSupplyAdd(usuario:String,password:String,itemShelvingFk:String,itemPlacementSupplyFk:String,quantity:String){ fun itemShelvingPlacementSupplyAdd(usuario:String,password:String,itemShelvingFk:String,itemPlacementSupplyFk:String,quantity:String,callFunction:String){
getSacadorControladorUserCase.itemShelvingPlacementSupplyAdd(usuario,password,itemShelvingFk,itemPlacementSupplyFk,quantity).enqueue(object : Callback<String>{ getSacadorControladorUserCase.itemShelvingPlacementSupplyAdd(usuario,password,itemShelvingFk,itemPlacementSupplyFk,quantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingPlacementSupplyAdd") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -131,15 +133,15 @@ class ReposicionViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemPlacementSupplyCloseOrder(usuario:String,password:String,id:String,quantity:String){ fun itemPlacementSupplyCloseOrder(usuario:String,password:String,id:String,quantity:String,callFunction:String){
getPreSacadorUseCase.itemPlacementSupplyCloseOrder(usuario,password,id,quantity).enqueue(object : Callback<String>{ getPreSacadorUseCase.itemPlacementSupplyCloseOrder(usuario,password,id,quantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_responseClose.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) _responseClose.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_responseClose.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemPlacementSupplyCloseOrder") _responseClose.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_responseClose.value = ResponseItemVO(isError = false,response = response.body()!!) _responseClose.value = ResponseItemVO(isError = false,response = response.body()!!)
} }

View File

@ -85,7 +85,7 @@ class SacadorFragment :
toolbar_title.text = getString(R.string.getcollection) toolbar_title.text = getString(R.string.getcollection)
setToolBar() setToolBar()
setEvents() setEvents()
viewModel.collectionGet(user, password) viewModel.collectionGet(user, password,"collection_get")
super.init() super.init()
} }
@ -114,7 +114,7 @@ class SacadorFragment :
if (item == iconAdd) { if (item == iconAdd) {
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
//viewModel.collectionNew(user, password, sectorFk, wagons) //viewModel.collectionNew(user, password, sectorFk, wagons)
viewModel.collectionNew(user,password,sectorFk,wagons,getTagsType()) viewModel.collectionNew(user,password,sectorFk,wagons,getTagsType(),"collection_new_wagon")
//checkTagsMode() //checkTagsMode()
} }
@ -130,7 +130,7 @@ class SacadorFragment :
private fun setEvents() { private fun setEvents() {
sacador_swipe.setOnRefreshListener { sacador_swipe.setOnRefreshListener {
viewModel.collectionGet(user, password) viewModel.collectionGet(user, password,"collection_get")
sacador_swipe.isRefreshing = false sacador_swipe.isRefreshing = false
} }
} }
@ -143,11 +143,11 @@ class SacadorFragment :
if (getTagsType().equals("Stickers")) { if (getTagsType().equals("Stickers")) {
//viewModel.collectionNew(user, password, sectorFk, wagons, "Stickers") //viewModel.collectionNew(user, password, sectorFk, wagons, "Stickers")
viewModel.collectionNew(user, password, sectorFk, wagons) viewModel.collectionNew(user, password, sectorFk, wagons,"collection_new_wagon")
} else { } else {
// Log.i("VERDNATURA:", " el resultTagmode es ${resultTagMode}") // Log.i("VERDNATURA:", " el resultTagmode es ${resultTagMode}")
if (resultTagMode.equals("complete")) { if (resultTagMode.equals("complete")) {
viewModel.collectionNew(user, password, sectorFk, wagons, getTagsType()) viewModel.collectionNew(user, password, sectorFk, wagons, getTagsType(),"collection_new_wagon")
} else { } else {
requireActivity().addFragment( requireActivity().addFragment(
AssociateSmartTagsFragment.newInstance(AssociateSmartTagsFragment.TAG), AssociateSmartTagsFragment.newInstance(AssociateSmartTagsFragment.TAG),
@ -197,7 +197,7 @@ class SacadorFragment :
} }
goBack = false goBack = false
//sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta. //sergio:para asegurarnos que aparece en pantalla. En mi movil personal y trabajo no hacia falta.
viewModel.collectionGet(user,password) viewModel.collectionGet(user,password,"collection_get")
}) })
} }
} }

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.sacador.mapper.toDateFormat import es.verdnatura.presentation.view.feature.sacador.mapper.toDateFormat
@ -43,7 +45,7 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
collectionFk: String, collectionFk: String,
sectorFk: String, sectorFk: String,
print: String, print: String,
type:String type:String,callFunction:String
){ ){
getSacadorControladorUserCase.collectionTicketGet( getSacadorControladorUserCase.collectionTicketGet(
usuario, usuario,
@ -57,7 +59,7 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
override fun onFailure(call: Call<CollectionVO>, t: Throwable) { override fun onFailure(call: Call<CollectionVO>, t: Throwable) {
_collectionTicketList.value = CollectionVO( _collectionTicketList.value = CollectionVO(
isError = true, isError = true,
errorMessage = t.message!! errorMessage =getMessageFromAllResponse(callFunction,t.message!!)
) )
} }
@ -70,21 +72,21 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
} else { } else {
_collectionTicketList.value = CollectionVO( _collectionTicketList.value = CollectionVO(
isError = true, isError = true,
errorMessage = "No hay tickets para sacar" errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
} }
} }
}) })
} }
fun collectionNew(usuario: String, password: String, sectorFk: String, wagons: String){ fun collectionNew(usuario: String, password: String, sectorFk: String, wagons: String,callFunction:String){
getSacadorControladorUserCase.collectionNew(usuario, password, sectorFk, wagons).enqueue( getSacadorControladorUserCase.collectionNew(usuario, password, sectorFk, wagons).enqueue(
object : object :
Callback<String> { Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = _response.value =
ResponseItemVO(isError = true, errorMessage = "" + t.message!!) ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
//////Log.i("VERDNATURA:",t.message.toString())
} }
@ -96,12 +98,10 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
_response.value = _response.value =
ResponseItemVO(isError = false, response = response.body()!!) ResponseItemVO(isError = false, response = response.body()!!)
} else { } else {
// val error=response.message()
//Log.i("VERDNATURA:",""+ error)
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
isError = true, isError = true,
// errorMessage = "Error en la llamada collectionNew" errorMessage = getMessageFromAllResponse(callFunction,response.message())
errorMessage = "No hay tickets para sacar"
) )
} }
@ -109,13 +109,13 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun collectionNew(usuario: String, password: String, sectorFk: String, wagons: String,tagtype:String){ fun collectionNew(usuario: String, password: String, sectorFk: String, wagons: String,tagtype:String,callFunction:String){
getSacadorControladorUserCase.collectionNew(usuario, password, sectorFk, wagons,tagtype).enqueue( getSacadorControladorUserCase.collectionNew(usuario, password, sectorFk, wagons,tagtype).enqueue(
object : object :
Callback<String> { Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = _response.value =
ResponseItemVO(isError = true, errorMessage = "" + t.message!!) ResponseItemVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
@ -128,12 +128,10 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
_response.value = _response.value =
ResponseItemVO(isError = false, response = response.body()!!) ResponseItemVO(isError = false, response = response.body()!!)
} else { } else {
// val error=response.message()
//Log.i("VERDNATURA:",""+ error)
_response.value = ResponseItemVO( _response.value = ResponseItemVO(
isError = true, isError = true,
// errorMessage = "Error en la llamada collectionNew" errorMessage = getMessageFromAllResponse(callFunction,response.message())
errorMessage = "No hay tickets para sacar"
) )
} }
@ -142,13 +140,13 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
} }
fun collectionGet(usuario: String, password: String){ fun collectionGet(usuario: String, password: String,callFunction:String){
//////Log.i("VERDNATURA:","collectionGet para coger tickets") //////Log.i("VERDNATURA:","collectionGet para coger tickets")
getSacadorControladorUserCase.collectionGet(usuario, password).enqueue(object : getSacadorControladorUserCase.collectionGet(usuario, password).enqueue(object :
Callback<List<CollectionVO>> { Callback<List<CollectionVO>> {
override fun onFailure(call: Call<List<CollectionVO>>, t: Throwable) { override fun onFailure(call: Call<List<CollectionVO>>, t: Throwable) {
val listError: ArrayList<CollectionVO> = ArrayList() val listError: ArrayList<CollectionVO> = ArrayList()
listError.add(CollectionVO(isError = true, errorMessage = t.message!!)) listError.add(CollectionVO(isError = true, errorMessage = getMessageFromAllResponse(callFunction,t.message!!)))
_collectionList.value = CollectionListVO(listError) _collectionList.value = CollectionListVO(listError)
} }
@ -165,7 +163,7 @@ class SacadorViewModel(context: Context) : BaseViewModel() {
listError.add( listError.add(
CollectionVO( CollectionVO(
isError = true, isError = true,
errorMessage = "Error en la llamada de collection_get" errorMessage = getMessageFromAllResponse(callFunction,response.message())
) )
) )
_collectionList.value = CollectionListVO(listError) _collectionList.value = CollectionListVO(listError)

View File

@ -67,7 +67,7 @@ class ShelvingParkingFragment : BaseFragment<FragmentShelvingParkingBinding, She
if (!shelvingText.text.toString().isNullOrEmpty()){ if (!shelvingText.text.toString().isNullOrEmpty()){
toolbar_title.text = shelvingText.text.toString() toolbar_title.text = shelvingText.text.toString()
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.shelvingParking_get(user,password,shelvingText.text.toString(),warehouseFk,dayrange.text.toString()) viewModel.shelvingParking_get(user,password,shelvingText.text.toString(),warehouseFk,dayrange.text.toString(),"shelvingParking_get")
} }
shelvingText.setText("") shelvingText.setText("")
@ -86,7 +86,7 @@ class ShelvingParkingFragment : BaseFragment<FragmentShelvingParkingBinding, She
shelvingText.requestFocus() shelvingText.requestFocus()
toolbar_title.text = shelvingText.text.toString() toolbar_title.text = shelvingText.text.toString()
viewModel.shelvingParking_get(user,password,shelvingText.text.toString(),warehouseFk,dayrange.text.toString()) viewModel.shelvingParking_get(user,password,shelvingText.text.toString(),warehouseFk,dayrange.text.toString(),"shelvingParking_get")
shelvingText.setText("") shelvingText.setText("")
(activity as MainActivity).hideKeyboard(dayrange) (activity as MainActivity).hideKeyboard(dayrange)
return@setOnEditorActionListener true return@setOnEditorActionListener true

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetShelvingParkingUserCase import es.verdnatura.domain.GetShelvingParkingUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingListVO import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingListVO
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
@ -28,12 +30,12 @@ class ShelvingParkingViewModel(context: Context) : BaseViewModel() {
val loadShelvingList = Transformations.map(_shelvingList) { Event(it) } val loadShelvingList = Transformations.map(_shelvingList) { Event(it) }
fun shelvingParking_get(usuario:String,password:String,vShelvingFk:String,vWarehouseFk:String,vDayRange:String){ fun shelvingParking_get(usuario:String,password:String,vShelvingFk:String,vWarehouseFk:String,vDayRange:String,callFunction:String){
getShelvingParkingUserCase.shelvingParking_get(usuario,password,vShelvingFk.uppercase(),vWarehouseFk,vDayRange).enqueue(object : getShelvingParkingUserCase.shelvingParking_get(usuario,password,vShelvingFk.uppercase(),vWarehouseFk,vDayRange).enqueue(object :
Callback<List<ItemShelvingParkingVO>> { Callback<List<ItemShelvingParkingVO>> {
override fun onFailure(call: Call<List<ItemShelvingParkingVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemShelvingParkingVO>>, t: Throwable) {
val listError:ArrayList<ItemShelvingParkingVO> = ArrayList() val listError:ArrayList<ItemShelvingParkingVO> = ArrayList()
listError.add(ItemShelvingParkingVO(isError = true,errorMessage = t.message!!)) listError.add(ItemShelvingParkingVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!)))
_shelvingList.value = ItemShelvingParkingListVO(listError) _shelvingList.value = ItemShelvingParkingListVO(listError)
} }
@ -45,7 +47,7 @@ class ShelvingParkingViewModel(context: Context) : BaseViewModel() {
_shelvingList.value = response.body()?.let { ItemShelvingParkingListVO(it) } _shelvingList.value = response.body()?.let { ItemShelvingParkingListVO(it) }
}else{ }else{
val listError:ArrayList<ItemShelvingParkingVO> = ArrayList() val listError:ArrayList<ItemShelvingParkingVO> = ArrayList()
listError.add(ItemShelvingParkingVO(isError = true,errorMessage = "Error en la llamada de shelvingParking_get")) listError.add(ItemShelvingParkingVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_shelvingList.value = ItemShelvingParkingListVO(listError) _shelvingList.value = ItemShelvingParkingListVO(listError)
} }
} }

View File

@ -101,23 +101,7 @@ class SmartTagsViewModel(context: Context) : BaseViewModel() {
} }
/* fun smartTag_nextLevel(usuario:String,password:String, vShelvingFk :String){
GetSmarttagsUserCase.smartTag_nextLevel(usuario,password,vShelvingFk ).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseadd.value = ResponseItemVO(isError = true,errorMessage = "Error al llamar a workerShelving_add")
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responselevel.value = ResponseItemVO(isError = true,errorMessage = "Error al escanear matrícula o etiqueta")
}else{
_responselevel.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}*/
} }

View File

@ -22,7 +22,7 @@ class TransferenciaViewModel(context: Context) : BaseViewModel() {
getUbicadorUserCase.itemShelvingTransfer(usuario,password,itemFk,shelvingFk).enqueue(object : getUbicadorUserCase.itemShelvingTransfer(usuario,password,itemFk,shelvingFk).enqueue(object :
Callback<String> { Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage ="Error en llamada itemShelvingTransfer."+t.message!!)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){

View File

@ -23,7 +23,7 @@ class AutomaticAddItemViewModel (context: Context): BaseViewModel() {
getUbicadorUserCase.itemShelvingMake_multi(usuario,password,shelving,items,deep,warehouse,level).enqueue(object : getUbicadorUserCase.itemShelvingMake_multi(usuario,password,shelving,items,deep,warehouse,level).enqueue(object :
Callback<String> { Callback<String> {
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar items. Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar items itemShelvingMake."+t.message!!)
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {

View File

@ -84,7 +84,7 @@ class UbicadorFragment(
if (!shelvingFk.isNullOrEmpty()){ if (!shelvingFk.isNullOrEmpty()){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
toolbar_title.text = shelvingFk toolbar_title.text = shelvingFk
viewModel.itemShelvingList(user,password,shelvingFk) viewModel.itemShelvingList(user,password,shelvingFk,"itemShelvingList")
} }
super.init() super.init()
} }
@ -107,7 +107,7 @@ class UbicadorFragment(
showAddItem("","","","",false,ItemUbicadorVO()) showAddItem("","","","",false,ItemUbicadorVO())
}else if(item == iconReload){ }else if(item == iconReload){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.itemShelvingList(user,password,shelvingFk) viewModel.itemShelvingList(user,password,shelvingFk,"itemShelvingList")
} }
} }
@ -127,7 +127,7 @@ class UbicadorFragment(
toolbar_title.text = edit_matricula.text.toString() toolbar_title.text = edit_matricula.text.toString()
shelvingFk = edit_matricula.text.toString() shelvingFk = edit_matricula.text.toString()
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
viewModel.itemShelvingList(user,password,edit_matricula.text.toString()) viewModel.itemShelvingList(user,password,edit_matricula.text.toString(),"itemShelvingList")
} }
edit_matricula.setText("") edit_matricula.setText("")
@ -141,7 +141,7 @@ class UbicadorFragment(
edit_prioridad.setOnEditorActionListener { v, actionId, event -> edit_prioridad.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 (!edit_prioridad.text.toString().isNullOrEmpty()){ if (!edit_prioridad.text.toString().isNullOrEmpty()){
viewModel.shelvingPriorityUpdate(user,password,edit_prioridad.text.toString(),shelvingFk) viewModel.shelvingPriorityUpdate(user,password,edit_prioridad.text.toString(),shelvingFk,"shelvingPriority_update")
} }
(activity as MainActivity).hideKeyboard(edit_prioridad) (activity as MainActivity).hideKeyboard(edit_prioridad)
@ -161,7 +161,7 @@ class UbicadorFragment(
parking_img.setOnClickListener { parking_img.setOnClickListener {
customDialogInput.setTitle("Aparcar carro").setValue("").setOkButton("Aparcar"){ customDialogInput.setTitle("Aparcar carro").setValue("").setOkButton("Aparcar"){
viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue()) viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue(),"shelvingPark")
parking = customDialogInput.getValue() parking = customDialogInput.getValue()
toolbar_title.text = shelvingFk.uppercase() + " P: "+parking + " E: "+etiquetas toolbar_title.text = shelvingFk.uppercase() + " P: "+parking + " E: "+etiquetas
if(mpok != null) mpok!!.start() if(mpok != null) mpok!!.start()
@ -175,7 +175,7 @@ class UbicadorFragment(
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue()) viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue(),"shelvingPark")
customDialogInput.dismiss() customDialogInput.dismiss()
parking = customDialogInput.getValue() parking = customDialogInput.getValue()
if (toolbar_title != null && shelvingFk != null && parking != null && etiquetas != null){ if (toolbar_title != null && shelvingFk != null && parking != null && etiquetas != null){
@ -196,7 +196,7 @@ class UbicadorFragment(
edit_img.setOnClickListener { edit_img.setOnClickListener {
customDialogInput.setTitle("Cambiar matrícula").setValue("").setOkButton("Guardar"){ customDialogInput.setTitle("Cambiar matrícula").setValue("").setOkButton("Guardar"){
viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue()) viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue(),"shelvingChange")
shelvingFk = customDialogInput.getValue() shelvingFk = customDialogInput.getValue()
toolbar_title.text = shelvingFk.uppercase() + " P: "+parking+ " E: "+etiquetas toolbar_title.text = shelvingFk.uppercase() + " P: "+parking+ " E: "+etiquetas
if(mpok != null) mpok!!.start() if(mpok != null) mpok!!.start()
@ -210,7 +210,7 @@ class UbicadorFragment(
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue()) viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue(),"shelvingChange")
shelvingFk = customDialogInput.getValue() shelvingFk = customDialogInput.getValue()
toolbar_title.text = shelvingFk.uppercase() + " P: "+parking+ " E: "+etiquetas toolbar_title.text = shelvingFk.uppercase() + " P: "+parking+ " E: "+etiquetas
if(mpok != null) mpok!!.start() if(mpok != null) mpok!!.start()
@ -224,7 +224,7 @@ class UbicadorFragment(
delete_img.setOnClickListener { delete_img.setOnClickListener {
customDialog.setTitle("Vaciar carro").setDescription("Esta operación no se puede rectificar.").setOkButton("Vaciar"){ customDialog.setTitle("Vaciar carro").setDescription("Esta operación no se puede rectificar.").setOkButton("Vaciar"){
viewModel.clearShelvingList(user,password,shelvingFk) viewModel.clearShelvingList(user,password,shelvingFk,"clearShelvingList")
listItems.forEach { listItems.forEach {
it.stickers = "0" it.stickers = "0"
it.visible = "0" it.visible = "0"
@ -294,7 +294,7 @@ class UbicadorFragment(
if (!shelvingFk.isNullOrEmpty()){ if (!shelvingFk.isNullOrEmpty()){
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
toolbar_title.text = shelvingFk toolbar_title.text = shelvingFk
viewModel.itemShelvingList(user,password,shelvingFk) viewModel.itemShelvingList(user,password,shelvingFk,"itemShelvingList")
} }
}) })
} }
@ -346,7 +346,7 @@ class UbicadorFragment(
if (!packing.isNullOrEmpty()){ if (!packing.isNullOrEmpty()){
if (updatePacking == null){ if (updatePacking == null){
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){ if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1") viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1","itemShelvingMake")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing)) changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus() customDialogUbicador.getEditItem().requestFocus()
@ -355,7 +355,7 @@ class UbicadorFragment(
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){ }else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString() val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1") viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1","itemShelvingMake")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas)) changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus() customDialogUbicador.getEditItem().requestFocus()
@ -367,7 +367,7 @@ class UbicadorFragment(
} }
}else{ }else{
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty() && !updatePacking){ if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty() && !updatePacking){
viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1",itemShelvingFk) viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1",itemShelvingFk,"itemShelvingMakeEdit")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing)) changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus() customDialogUbicador.getEditItem().requestFocus()
@ -379,7 +379,7 @@ class UbicadorFragment(
try{ try{
visible_calc = (etiquetas.toInt() * packing.toInt()).toString() visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
}catch (e:Exception){} }catch (e:Exception){}
viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1",itemShelvingFk) viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1",itemShelvingFk,"itemShelvingMakeEdit")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas)) changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus() customDialogUbicador.getEditItem().requestFocus()
@ -399,14 +399,14 @@ class UbicadorFragment(
private fun editItem(itemFk:String,etiquetas:String,packing:String,visible:String){ private fun editItem(itemFk:String,etiquetas:String,packing:String,visible:String){
if (!packing.isNullOrEmpty()){ if (!packing.isNullOrEmpty()){
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){ if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1") viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1","itemShelvingMake")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing)) changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus() customDialogUbicador.getEditItem().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem()) (activity as MainActivity).hideKeyboard(customDialogUbicador.getEditItem())
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){ }else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty()){
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString() val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1") viewModel.itemShelvingMake(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1","itemShelvingMake")
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas)) changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("") customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus() customDialogUbicador.getEditItem().requestFocus()
@ -429,7 +429,7 @@ class UbicadorFragment(
customDialogTwoButtons.setTitle(item.item).setDescription("Selecciona una acción").setOkButton("Transferir"){ customDialogTwoButtons.setTitle(item.item).setDescription("Selecciona una acción").setOkButton("Transferir"){
customDialogInput.setTitle("Nueva matrícula").setDescription("Introduce el destino para item: "+item.item).setValue("").setOkButton("Transferir"){ customDialogInput.setTitle("Nueva matrícula").setDescription("Introduce el destino para item: "+item.item).setValue("").setOkButton("Transferir"){
if (customDialogInput.getValue().isNotEmpty()){ if (customDialogInput.getValue().isNotEmpty()){
viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue()) viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue(),"itemShelvingTransfer")
listItems.remove(item) listItems.remove(item)
adapter!!.notifyDataSetChanged() adapter!!.notifyDataSetChanged()
customDialogInput.dismiss() customDialogInput.dismiss()
@ -446,7 +446,7 @@ class UbicadorFragment(
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText()) (activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue()) viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue(),"itemShelvingTransfer")
listItems.remove(item) listItems.remove(item)
adapter!!.notifyDataSetChanged() adapter!!.notifyDataSetChanged()
customDialogInput.dismiss() customDialogInput.dismiss()
@ -459,7 +459,7 @@ class UbicadorFragment(
customDialog.setTitle("Confirmar").setDescription("Confirmas eliminar el artículo: "+item.item+"?").setOkButton("Eliminar"){ customDialog.setTitle("Confirmar").setDescription("Confirmas eliminar el artículo: "+item.item+"?").setOkButton("Eliminar"){
listItems.remove(item) listItems.remove(item)
adapter!!.notifyDataSetChanged() adapter!!.notifyDataSetChanged()
viewModel.itemShelvingDelete(user,password,item.id) viewModel.itemShelvingDelete(user,password,item.id,"itemShelvingDelete")
customDialogTwoButtons.dismiss() customDialogTwoButtons.dismiss()
customDialog.dismiss() customDialog.dismiss()
}.setKoButton("Cancelar"){ }.setKoButton("Cancelar"){

View File

@ -6,6 +6,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations import androidx.lifecycle.Transformations
import es.verdnatura.domain.GetUbicadorUserCase import es.verdnatura.domain.GetUbicadorUserCase
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageError
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorListVO
@ -33,12 +35,12 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
val loadShelvingList = Transformations.map(_shelvingList) { Event(it) } val loadShelvingList = Transformations.map(_shelvingList) { Event(it) }
fun itemShelvingList(usuario:String,password:String,vShelvingFk:String){ fun itemShelvingList(usuario:String,password:String,vShelvingFk:String,callFunction:String){
getUbicadorUserCase.itemShelvingList(usuario,password,vShelvingFk.uppercase()).enqueue(object : getUbicadorUserCase.itemShelvingList(usuario,password,vShelvingFk.uppercase()).enqueue(object :
Callback<List<ItemUbicadorVO>> { Callback<List<ItemUbicadorVO>> {
override fun onFailure(call: Call<List<ItemUbicadorVO>>, t: Throwable) { override fun onFailure(call: Call<List<ItemUbicadorVO>>, t: Throwable) {
val listError:ArrayList<ItemUbicadorVO> = ArrayList() val listError:ArrayList<ItemUbicadorVO> = ArrayList()
listError.add(ItemUbicadorVO(isError = true,errorMessage = t.message!!)) listError.add(ItemUbicadorVO(isError = true,errorMessage =getMessageFromAllResponse(callFunction,t.message!!)))
_shelvingList.value = ItemUbicadorListVO(listError) _shelvingList.value = ItemUbicadorListVO(listError)
} }
@ -50,7 +52,7 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
_shelvingList.value = response.body()?.let { ItemUbicadorListVO(it) } _shelvingList.value = response.body()?.let { ItemUbicadorListVO(it) }
}else{ }else{
val listError:ArrayList<ItemUbicadorVO> = ArrayList() val listError:ArrayList<ItemUbicadorVO> = ArrayList()
listError.add(ItemUbicadorVO(isError = true,errorMessage = "Error en la llamada de itemShelvingList")) listError.add(ItemUbicadorVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message())))
_shelvingList.value = ItemUbicadorListVO(listError) _shelvingList.value = ItemUbicadorListVO(listError)
} }
} }
@ -58,15 +60,15 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun shelvingPriorityUpdate(usuario:String,password:String,priority:String,shelving:String){ fun shelvingPriorityUpdate(usuario:String,password:String,priority:String,shelving:String,callFunction:String){
getUbicadorUserCase.shelvingPriorityUpdate(usuario,password,priority,shelving).enqueue(object : Callback<String>{ getUbicadorUserCase.shelvingPriorityUpdate(usuario,password,priority,shelving).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPriorityUpdate") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPriorityUpdate") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -77,15 +79,15 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
} }
fun itemShelvingMake(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String){ fun itemShelvingMake(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,callFunction:String){
getUbicadorUserCase.itemShelvingMake(usuario,password,shelving,item,deep,quantity,packing,warehouse,level).enqueue(object : Callback<String>{ getUbicadorUserCase.itemShelvingMake(usuario,password,shelving,item,deep,quantity,packing,warehouse,level).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_responseMake.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+item+ " Respuesta:"+t.message!!) _responseMake.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_responseMake.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingMake") _responseMake.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_responseMake.value = ResponseItemVO(isError = false,response = response.body()!!) _responseMake.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -95,15 +97,15 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,itemShelvingFk:String){ fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,itemShelvingFk:String,callFunction:String){
getUbicadorUserCase.itemShelvingMakeEdit(usuario,password,shelving,item,deep,quantity,packing,warehouse,level,itemShelvingFk).enqueue(object : Callback<String>{ getUbicadorUserCase.itemShelvingMakeEdit(usuario,password,shelving,item,deep,quantity,packing,warehouse,level,itemShelvingFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_responseMake.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+item+ " Respuesta:"+t.message!!) _responseMake.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_responseMake.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingMakeEdit") _responseMake.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_responseMake.value = ResponseItemVO(isError = false,response = response.body()!!) _responseMake.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -113,14 +115,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun shelvingPark(usuario:String,password:String,shelving:String,parking:String){ fun shelvingPark(usuario:String,password:String,shelving:String,parking:String,callFunction:String){
getUbicadorUserCase.shelvingPark(usuario,password,shelving,parking).enqueue(object : Callback<String>{ getUbicadorUserCase.shelvingPark(usuario,password,shelving,parking).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+shelving+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingPark") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -128,14 +130,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun shelvingChange(usuario:String,password:String,origen:String,destino:String){ fun shelvingChange(usuario:String,password:String,origen:String,destino:String,callFunction:String){
getUbicadorUserCase.shelvingChange(usuario,password,origen,destino).enqueue(object : Callback<String>{ getUbicadorUserCase.shelvingChange(usuario,password,origen,destino).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+origen+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada shelvingChange") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -143,14 +145,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun clearShelvingList(usuario:String,password:String,shelvingFk:String){ fun clearShelvingList(usuario:String,password:String,shelvingFk:String,callFunction:String){
getUbicadorUserCase.clearShelvingList(usuario,password,shelvingFk).enqueue(object : Callback<String>{ getUbicadorUserCase.clearShelvingList(usuario,password,shelvingFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+shelvingFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada clearShelvingList") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -158,14 +160,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemShelvingTransfer(usuario:String,password:String,itemFk:String,shelvingFk:String){ fun itemShelvingTransfer(usuario:String,password:String,itemFk:String,shelvingFk:String,callFunction:String){
getUbicadorUserCase.itemShelvingTransfer(usuario,password,itemFk,shelvingFk).enqueue(object : Callback<String>{ getUbicadorUserCase.itemShelvingTransfer(usuario,password,itemFk,shelvingFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingTransfer") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }
@ -173,14 +175,14 @@ class UbicadorViewModel(context: Context) : BaseViewModel() {
}) })
} }
fun itemShelvingDelete(usuario:String,password:String,itemFk:String){ fun itemShelvingDelete(usuario:String,password:String,itemFk:String,callFunction:String){
getUbicadorUserCase.itemShelvingDelete(usuario,password,itemFk).enqueue(object : Callback<String>{ getUbicadorUserCase.itemShelvingDelete(usuario,password,itemFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) { override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+itemFk+ " Respuesta:"+t.message!!) _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,t.message!!))
} }
override fun onResponse(call: Call<String>, response: Response<String>) { override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){ if (response.body() == null){
_response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingDelete") _response.value = ResponseItemVO(isError = true,errorMessage = getMessageFromAllResponse(callFunction,response.message()))
}else{ }else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!) _response.value = ResponseItemVO(isError = false,response = response.body()!!)
} }

View File

@ -0,0 +1,8 @@
<!-- drawable/point_of_sale.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#F7931E" android:pathData="M20,5C19.4,5 19,5.5 19,6.1V16C19,16.6 19.4,17 20,17.1C20.6,17.1 21,16.6 21,16V6.1C21,5.5 20.6,5 20,5M16.4,2H4.6C3.7,2 3,2.7 3,3.6V17.4C3,18.3 3.7,19 4.6,19H6V21C6,21.6 6.4,22 7,22H13C13.6,22 14,21.6 14,21V19H16.4C17.3,19 18,18.3 18,17.4V3.6C18,2.7 17.3,2 16.4,2M5,8H8V10H5V8M12,11V13H9V11H12M9,10V8H12V10H9M12,14V16H9V14H12M5,11H8V13H5V11M5,16V14H8V16H5M8,21H7V19H8V21M13,21H10V19H13V21M16,16H13V14H16V16M16,13H13V11H16V13M16,10H13V8H16V10M16,6H5V4H16V6Z" />
</vector>

View File

@ -24,7 +24,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:backgroundTint="@android:color/white" android:backgroundTint="@android:color/white"
android:hint="@string/Escaner" android:hint="@string/Escaner"
android:inputType="text" android:inputType="textVisiblePassword"
android:lines="1" android:lines="1"
android:maxLines="1" android:maxLines="1"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"

View File

@ -29,7 +29,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:backgroundTint="@android:color/white" android:backgroundTint="@android:color/white"
android:hint="@string/Escaneaetiqueta" android:hint="@string/Escaneaetiqueta"
android:inputType="text" android:inputType="textVisiblePassword"
android:lines="1" android:lines="1"
android:maxLines="1" android:maxLines="1"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"

View File

@ -0,0 +1,166 @@
<?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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scroll_view"
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_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@android:color/darker_gray"
android:layout_marginTop="@dimen/toolbar_height">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_itemFk"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="@string/Escaneaetiqueta"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/layout_margin_min"
android:layout_marginBottom="@dimen/layout_margin_1"
android:paddingLeft="@dimen/layout_margin_min"
android:paddingRight="@dimen/layout_margin_min">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ItemFk"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="left"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Nombre"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="left"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Fecha"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cantidad"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Stock"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:id="@+id/itemcard_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="vertical"
tools:ignore="ExtraText">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/itemexpeditionstate_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:visibility="visible"
tools:listitem="@layout/item_expeditionstate_row" />
</RelativeLayout>>
</LinearLayout>
</LinearLayout>
</ScrollView>
<include
android:id="@+id/main_toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/splash_progress"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/verdnatura_black_8_alpha_6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center">
<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>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@ -0,0 +1,125 @@
<?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">
<data>
<variable
name="viewModel"
type="es.verdnatura.presentation.view.feature.diadeventa.fragment.DayOfSaleViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:paddingTop="@dimen/toolbar_height">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/layout_margin_min"
android:layout_marginBottom="@dimen/layout_margin_1"
android:paddingLeft="@dimen/layout_margin_min"
android:paddingRight="@dimen/layout_margin_min">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ItemFk"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="left"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="vDated"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="left"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="atShelving"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="balance"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/itemshelvingdayofsale_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
tools:listitem="@layout/item_shelvingdayofsale_row"/>
</LinearLayout>
<include
android:id="@+id/main_toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/splash_progress"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/verdnatura_black_8_alpha_6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center">
<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>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@ -30,7 +30,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:backgroundTint="@android:color/white" android:backgroundTint="@android:color/white"
android:hint="@string/Escaneaetiqueta" android:hint="@string/Escaneaetiqueta"
android:inputType="text" android:inputType="textVisiblePassword"
android:lines="1" android:lines="1"
android:maxLines="1" android:maxLines="1"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools">
<data>
<variable
name="item"
type="es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/item_row_layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/verdnatura_black_5"
android:paddingLeft="@dimen/layout_margin_min"
android:paddingRight="@dimen/layout_margin_min"
android:paddingTop="@dimen/pasilleros_margin_main_menu"
android:paddingBottom="@dimen/pasilleros_margin_main_menu">
<TextView
android:id="@+id/historico_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{item.itemFk}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:gravity="center"
android:layout_marginRight="@dimen/layout_margin_min"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.longName}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:id="@+id/saledate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.dated}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.amount}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.stock}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/verdnatura_black_9"/>
</LinearLayout>
</layout>

View File

@ -147,4 +147,6 @@
<string name="producer">Productor</string> <string name="producer">Productor</string>
<string name="controlticket">Controlar ticket</string> <string name="controlticket">Controlar ticket</string>
<string name="ExpeditionScan">Escanear expedición</string> <string name="ExpeditionScan">Escanear expedición</string>
<string name="dayofSale">Día de venta</string>
<string name="wagon">Carro</string>
</resources> </resources>

View File

@ -145,5 +145,7 @@
<string name="producer">Producer</string> <string name="producer">Producer</string>
<string name="controlticket">Control ticket</string> <string name="controlticket">Control ticket</string>
<string name="ExpeditionScan">Scan expedition</string> <string name="ExpeditionScan">Scan expedition</string>
<string name="dayofSale">Day of sale</string>
<string name="wagon">Wagon</string>
</resources> </resources>