diff --git a/app/src/main/java/es/verdnatura/domain/SalixCallback.kt b/app/src/main/java/es/verdnatura/domain/SalixCallback.kt index d38c951c..50cc58fa 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixCallback.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixCallback.kt @@ -3,6 +3,8 @@ package es.verdnatura.domain import android.app.ActivityManager import android.content.Context import android.content.Intent +import com.google.gson.Gson +import com.google.gson.JsonObject import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.view.feature.login.activity.LoginActivity import org.json.JSONObject @@ -32,17 +34,9 @@ abstract class SalixCallback(val context: Context) : Callback { onError(Error(response.message().toString())) } } else { - println("message:"+response.errorBody()!!.source()) - println("message::"+response.errorBody() as okhttp3.ResponseBody) - var m= response.errorBody() as okhttp3.ResponseBody - println("Message2::"+m.source().toString()) - /* var r = response as okhttp3.Response - println("message" + r.body() ) - println("message" + r.message() ) - println(response.raw().message().toString()) - println(response.raw().message())*/ - onError(Error(response.message().toString())) + onError(Error(errorSalixMessage(response))) + // onError(Error(response.message().toString())) } } catch (t: Throwable) { defaultErrorHandler(t) @@ -86,4 +80,17 @@ abstract class SalixCallback(val context: Context) : Callback { return false } + private fun errorSalixMessage(response: Response): String { + + val messageResponse = response.errorBody()!!.string() + return try { + + val jsonObject = Gson().fromJson(messageResponse, JsonObject::class.java) + jsonObject?.getAsJsonObject("error")?.get("message")?.asString.toString() + + } catch (ex: Exception) { + response.message() + } + + } } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/domain/SalixService.kt b/app/src/main/java/es/verdnatura/domain/SalixService.kt index b39f16a4..6187ea6d 100644 --- a/app/src/main/java/es/verdnatura/domain/SalixService.kt +++ b/app/src/main/java/es/verdnatura/domain/SalixService.kt @@ -2,12 +2,12 @@ package es.verdnatura.domain import com.google.gson.JsonObject import es.verdnatura.presentation.common.itemBarCodeSalix -import es.verdnatura.presentation.common.itemPackingTypeSalix import es.verdnatura.presentation.common.packingSiteSalix import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity import es.verdnatura.presentation.view.feature.collection.listSaleSalix +import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.model.DeviceId import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix import es.verdnatura.presentation.view.feature.inventario.model.ItemInventoryParking @@ -20,8 +20,13 @@ import es.verdnatura.presentation.view.feature.login.model.accessConfigSalix import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier import es.verdnatura.presentation.view.feature.packaging.model.Supplier +import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake +import es.verdnatura.presentation.view.feature.workermistake.model.ExpeditionMistakeSalix +import es.verdnatura.presentation.view.feature.workermistake.model.MistakeType +import es.verdnatura.presentation.view.feature.workermistake.model.WorkerMistakeSalix import okhttp3.MultipartBody import retrofit2.Call import retrofit2.http.* @@ -31,13 +36,11 @@ interface SalixService { @POST("Accounts/login") fun login( @Body params: LoginSalixVO - ): - Call + ): Call @GET("VnUsers/getCurrentUserData") fun getCurrentUserData( - ): - Call + ): Call /* @POST("chats/sendCheckingPresence") fun sendChekingPresence( @@ -53,25 +56,21 @@ interface SalixService { @GET("collections/getSectors") fun getSectorsSalix( - ): - Call> + ): Call> @GET("collections/getCollection") fun getCollectionSalix( - ): - Call> + ): Call> @GET("collections/sectorCollection_get") fun sectorCollection_get( - ): - Call> + ): Call> @POST("collections/setSaleQuantity") fun collectionIncreaseQuantitySalix( @Body params: SalixSaleQuantity - ): - Call + ): Call @Multipart @POST("Entries/{id}/uploadFile") @@ -84,8 +83,7 @@ interface SalixService { @Query("description") description: String, @Query("hasFile") hasFile: Boolean, @Part file: MultipartBody.Part, - ): - Call + ): Call @Multipart @POST("dms/uploadFile") @@ -97,14 +95,12 @@ interface SalixService { @Query("description") description: String, @Query("hasFile") hasFile: Boolean, @Part file: MultipartBody.Part, - ): - Call + ): Call @Multipart @POST("/api/Tickets/saveSign") fun saveSign( - @Part file: MultipartBody.Part?, - @QueryMap(encoded = true) queryMap: Map + @Part file: MultipartBody.Part?, @QueryMap(encoded = true) queryMap: Map ): Call @@ -113,68 +109,105 @@ interface SalixService { @Path("id") id: Number, @Query("item") item: Number, @Query("printedStickers") printedStickers: Number - ): - Call + ): Call @POST("tickets/{idTicket}/transferSales") //-->saleMove en Silex fun transferSalesSalix( - @Path("idTicket") idTicket: String, - @Body params: listSaleSalix - ): - Call + @Path("idTicket") idTicket: String, @Body params: listSaleSalix + ): Call - - //https://test-salix.verdnatura.es/api/Departments?filter={"fields": {"id": true, "name": true},"where": {"name": "COMPRAS"}} - // http://test-salix.verdnatura.es/api/Departments?filter={"fields": {"id": true, "name": true},"where": {"hasToMistake": "FALSE"}} - - // @GET("api/Departments?filter={\"fields\": {\"id\": true, \"name\": true},\"where\": {\"hasToMistake\": \"FALSE\"}}") @GET("Departments") fun department_getHasMistake( - @Query("filter") filter: String = "{\"fields\": {\"id\": true, \"name\": true},\"where\": {\"name\": \"INFORMATICA\"}}" - // @Query("name") name:String ="COMPRAS" - ): - Call> + @Query("filter") filter:String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}""" + ): Call> + + @DELETE("ExpeditionPallets/{id}") + fun expeditionPalletDel( + @Path("id") id: Number + ): Call + + @DELETE("ExpeditionScans/{id}") + fun expeditionScanDel( + @Path("id") id: Number + ): Call + + @DELETE("ItemShelvings/{id}") + fun itemShelvingsDelete( + @Path("id") id: Number + ): Call @GET("Workers/{idWorker}/sip") fun sip_getExtension( @Path("idWorker") idWorker: Int, - ): - Call + ): Call @PATCH("Items/{itemFk}") fun update_ItemPackingType( @Path("itemFk") itemFk: String, - @Body params: itemPackingTypeSalix - ): - Call + @Body params: Any + ): Call + @PATCH("Items/{itemFk}") + fun updateItem( + @Path("itemFk") itemFk: Int, + @Body params: Any + ): Call + + @POST("Shelvings/upsertWithWhere") + fun updateShelvingPriority( + @Query("where") where: String, + @Body params: Any + ): Call + + //DE MOMENTO NO FUNCIONA, SE QUERÍA AÑADIR POR INSERTIGNORE + @POST("Operators/upsertWithWhere") + fun operatorAdd( + @Query("where") where: String, + @Body params: Any + ): Call + + @PUT("DeviceLogs") + fun deviceLogInsert( + @Body params: Any + ): Call + + @POST("ExpeditionTrucks") + fun expeditionTrucksInsert( + @Body params: Any + ): Call @GET("ItemPackingTypes") fun get_ItemPackingType( + @Query("filter") filter:String = """{"where": {"isActive": true}}""" + ): Call> - ): - Call> + @GET("ExpeditionTrucks") + fun expeditionTruckGet( + @Query("filter") filter:String + ): Call> @POST("PackingSiteAdvanceds") fun ticket_advancePackaging( @Body parms: packingSiteSalix - ): - Call + ): Call @PUT("ItemBarCodes")//REVISADA fun barcodes_edit( @Body params: itemBarCodeSalix - ): - Call + ): Call + + @DELETE("ItemBarCodes")//REVISADA + fun deleteItemBarCode( + @Body params: itemBarCodeSalix + ): Call @GET("ItemBarCodes/{barCodeValue}/toItem")//REVISADA fun barcodes_toitem( @Path("barCodeValue") barCodeValue: String - ): - Call + ): Call @GET("Suppliers")//REVISADA fun getSuppliers( @@ -184,36 +217,34 @@ interface SalixService { "\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," + "\"where\":{ \"email\":{\"neq\":null } }}}]})"*/ - ): - Call> + ): Call> @PUT("Entries")//REVISADA fun Entries( @Body entry: EntrySalix - ): - Call + ): Call @GET("Shelvings") fun Shelvings( @Query("filter") filter: String - ): - Call> + ): Call> + + @GET("DeviceProductions") + fun deviceProductionsGetName( + @Query("filter") filter: String + ): Call> @GET("Suppliers/{supplierId}/getItemsPackaging") fun getItemsPackaging( - @Path("supplierId") supplierId: Int, - @Query("entry") entry: Int + @Path("supplierId") supplierId: Int, @Query("entry") entry: Int - ): - Call> + ): Call> @POST("Entries/addFromPackaging") fun addFromPackaging( - @Query("supplier") supplier: Int, - @Query("isTravelReception") isTravelReception: Boolean + @Query("supplier") supplier: Int, @Query("isTravelReception") isTravelReception: Boolean - ): - Call + ): Call @POST("Images/upload") @Multipart @@ -221,64 +252,65 @@ interface SalixService { @Query("collection") collection: String, @Query("id") id: Int, @Part filePart: MultipartBody.Part, - ): - Call + ): Call @PATCH("Operators/{id}") fun update_operator( - @Path("id") id: Number, - @Body params: Any + @Path("id") id: Number, @Body params: Any - ): - Call + ): Call @GET("Operators") fun operator_getData( @Query("filter") filter: String - ): - Call> + ): Call> @GET("AccessTokenConfigs") fun getAccessTokenConfigs( - ): - Call> + ): Call> @POST("vnusers/renewToken") fun renewToken( - ): - Call + ): Call @PATCH("ItemShelvings/{id}") fun itemShelvingUpdate( - @Path("id") id: Number, - @Body params: Any - ): - Call + @Path("id") id: Number, @Body params: Any + ): Call @POST("ItemShelvings/update") fun itemShelvingsUpdate( @Query("where") id: JsonObject, @Body params: Any - ): - Call + ): Call @POST("ItemShelvings/getInventory") fun getInventoryParking( - @Query("parkingFrom") parkingFrom: String, - @Query("parkingTo") parkingTo: String - ): - Call> + @Query("parkingFrom") parkingFrom: String, @Query("parkingTo") parkingTo: String + ): Call> @PATCH("Routes/{id}") fun routeUpdate( @Path("id") id: Number, @Body route: RouteInfo, - ): - Call + ): Call + @GET("ExpeditionMistakeTypes") + fun getExpeditionMistakeTypes( + ): Call> + @POST("ExpeditionMistakes") + fun expeditionMistakesAdd(expeditionMistake:ExpeditionMistakeSalix + ): Call + @POST("WorkerMistakes") + fun workerMistakesAdd(workerMistake: WorkerMistakeSalix + ): Call + + @GET("MistakeTypes") + fun getMistakeTypes( + ): Call> } @@ -287,8 +319,7 @@ interface SalixServiceSend { @POST("chats/send") fun sendGroup( @Body params: SalixGrupo - ): - Call + ): Call } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt index ac490f1b..95d81d05 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt @@ -74,7 +74,7 @@ class AjustesFragment : binding.androididText.text = getData(ANDROID_ID) // Tarea 4815 - // binding.serialNumber.text = getData("SERIALNUMBER") + /*binding.serialNumber.text = mobileApplication.serialNumber*/ binding.txtserver.setText(getData(getString(R.string.baseurl))) super.init() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt index 09a370cf..b9760728 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt @@ -8,6 +8,7 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.R +import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.getMessageFromAllResponse @@ -202,7 +203,7 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) { fun getItemPackingTypeSalix() { salix.get_ItemPackingType().enqueue(object : - SilexCallback>(context) { + SalixCallback>(context) { override fun onError(t: Throwable) { val listError: ArrayList = ArrayList() @@ -324,31 +325,6 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) { }) } - fun worker_updateSector(sectorFk: Int) { - - silex.worker_updateSector(sectorFk) - .enqueue(object : SilexCallback(context) { - override fun onError(t: Throwable) { - - _actionUpdate.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) - ) - } - - override fun onSuccess(response: Response) { - _actionUpdate.value = ResponseItemVO( - response = response.message(), - isError = false, - errorMessage = "" - - ) - - } - - }) - } - fun operator_updateItemPackingType(itemPackingTypeFk: String) { silex.operator_updateItemPackingType(itemPackingTypeFk) @@ -466,24 +442,6 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) { }) } - - fun worker_updatePrinter(printerFk: Int) { - ProgressLoading(VISIBLE) - silex.worker_updatePrinter(printerFk) - .enqueue(object : SilexCallback(context) { - override fun onError(t: Throwable) { - ProgressLoading(GONE) - throw t - } - - override fun onSuccess(response: Response) { - ProgressLoading(GONE) - super.onSuccess(response) - } - - }) - } - fun worker_updateOperatorSalix(entity: String, workerFk: Int, sectorFk: Int?, labelerFk: Int?) { ProgressLoading(VISIBLE) salix.update_operator(id = workerFk, Operator(sectorFk, labelerFk)) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/model/AjustesItemVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/model/AjustesItemVO.kt index 3c761eb5..47847a89 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/model/AjustesItemVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/model/AjustesItemVO.kt @@ -1,52 +1,52 @@ package es.verdnatura.presentation.view.feature.ajustes.model -import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType - -class AjustesItemVO ( +class AjustesItemVO( var id: Int, var title: String = "", var selected: String? = "", - var sectorFk : Int?, + var sectorFk: Int?, var warehouse: Int?, - var printerFk:Int?, - var printerSelected:String="", - var action:Boolean + var printerFk: Int?, + var printerSelected: String = "", + var action: Boolean ) -class SectorItemVO ( +class SectorItemVO( var id: Int, - var description:String = "", - val warehouseFk:Int?, - val isError : Boolean = false, - var errorMessage : String = "" + var description: String = "", + val warehouseFk: Int?, + val isError: Boolean = false, + var errorMessage: String = "" ) -class SectorListVO ( +class SectorListVO( var list: List = listOf() ) -class PrintersList ( + +class PrintersList( var list: List = listOf() ) + class Printers( - var id: Int?=null, - var name: String="", - val isError : Boolean = false, - var errorMessage : String = "" + var id: Int, + var name: String, + val isError: Boolean = false, + var errorMessage: String = "" ) class WorkerPrintersList( - var list:List = listOf() + var list: List = listOf() ) class Train( - var id: Int?=null, - var name: String="", - val isError : Boolean = false, - var errorMessage : String = "" + var id: Int, + var name: String, + val isError: Boolean = false, + var errorMessage: String = "" ) -class TrainList ( +class TrainList( var list: List = listOf() ) \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt index 75a53977..1267c02b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt @@ -4,7 +4,6 @@ import android.app.AlertDialog import android.content.Intent import android.graphics.drawable.Drawable import android.os.Build -import android.util.Log.d import android.view.View import android.view.View.GONE import android.view.inputmethod.EditorInfo @@ -15,6 +14,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import com.google.gson.Gson import es.verdnatura.R import es.verdnatura.databinding.FragmentItemCardBinding +import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.* import es.verdnatura.presentation.view.component.CustomDialogDynamicButtons @@ -434,7 +434,23 @@ class ItemCardFragment( ) .setOkButton(getString(R.string.save)) { ma.hideKeyboard(customDialogInput.getEditText()) - editItemCardRow(item, customDialogInput.getValue().toInt()) + + //Tarea 6182 + try { + editItemCardRow(item, customDialogInput.getValue().toInt()) + } catch (ex: Exception) { + if (item.action == "itemSaveStem" && customDialogInput.getValue() + .isNullOrBlank() + ) + viewModel.item_saveStems( + itemFk = itemInfoG!!.id, + value = null + ) else { + getString(R.string.errorInput).toast(requireContext()) + } + + } + customDialogInput.dismiss() }.setKoButton(getString(R.string.cancel)) { @@ -699,7 +715,6 @@ class ItemCardFragment( } private fun updateBarcode(code: String, delete: Boolean) { - d("VERDNATURA::", "El bacode se va actualizar" + code + delete) if (delete) { var i = 0 var posDelete = 0 @@ -750,8 +765,8 @@ class ItemCardFragment( private fun updateItemPackingType(itemPackingType: String) { binding.splashProgress.visibility = View.VISIBLE viewModel.updatePackingTypeSalix( - itemInfoG!!.id.toString(), - itemPackingTypeSalix(itemPackingType) + itemInfoG!!.id, + itemPackingType ) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt index 6219421f..66cbedf5 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt @@ -3,15 +3,13 @@ package es.verdnatura.presentation.view.feature.articulo.fragment import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations +import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.nameofFunction -import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.itemBarCodeSalix -import es.verdnatura.presentation.common.itemPackingTypeSalix import es.verdnatura.presentation.view.feature.articulo.model.AddressLoses import es.verdnatura.presentation.view.feature.articulo.model.AddressLosesList import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO @@ -23,8 +21,6 @@ import okhttp3.MultipartBody import okhttp3.RequestBody import retrofit2.Response import java.io.File -import java.util.* -import kotlin.collections.ArrayList class ItemCardViewModel(var context: Context) : BaseViewModel(context) { @@ -207,8 +203,8 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) { }) } - fun updatePackingTypeSalix(itemFk: String, itemPackingType: itemPackingTypeSalix) { - salix.update_ItemPackingType(itemFk, itemPackingType) + fun updatePackingTypeSalix(itemFk: Int, itemPackingTypeFk: String) { + salix.updateItem(itemFk, hashMapOf("itemPackingTypeFk" to itemPackingTypeFk)) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { _response.value = ResponseItemVO( @@ -228,11 +224,11 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) { fun item_saveStems( itemFk: Int, - value: Int + value: Int? ) { - silex.item_saveStems(itemFk, value) - .enqueue(object : SilexCallback(context) { + salix.updateItem(itemFk, hashMapOf("stems" to value)) + .enqueue(object : SalixCallback(context) { override fun onError(t: Throwable) { _response.value = ResponseItemVO( isError = true, @@ -252,8 +248,8 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) { value: Int ) { - silex.item_saveReference(itemFk, value) - .enqueue(object : SilexCallback(context) { + salix.updateItem(itemFk, hashMapOf("comment" to value)) + .enqueue(object : SalixCallback(context) { override fun onError(t: Throwable) { _response.value = ResponseItemVO( isError = true, @@ -272,7 +268,8 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) { itemFk: Int, value: String, delete: Boolean - ) { + ) {//Tarea 5134 cambiar Silex para obtener el id y así poder hacer un DELETE y un PATCH + // salix.barcodes_edit(idBarcode:Int, ) silex.barcodes_edit(value, itemFk, delete) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { @@ -317,20 +314,23 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) { } - private val _responseinsert by lazy { MutableLiveData() } val responseinsert: LiveData get() = _responseinsert fun uploadPhoto( - urlImage:String, - itemFK:Int, + urlImage: String, + itemFK: Int, file: File = File("$urlImage"), fileRequestBody: RequestBody = RequestBody.create(MediaType.parse("image/jpeg"), file), - filePart: MultipartBody.Part = MultipartBody.Part.createFormData("file", file.name, fileRequestBody), - ) { - salix.uploadImage("catalog",itemFK,filePart) + filePart: MultipartBody.Part = MultipartBody.Part.createFormData( + "file", + file.name, + fileRequestBody + ), + ) { + salix.uploadImage("catalog", itemFK, filePart) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { _responseinsert.value = ResponseItemVO( @@ -361,8 +361,8 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) { AddressLoses(7475, "MERMA: RECLAMACION TALLER", "BASURA"), AddressLoses(43432, "MERMA: TRANSPORTE", "BASURA") ) -println("Vamos a a lista") - _addressLosesList.value= AddressLosesList(mermaRecords) + println("Vamos a a lista") + _addressLosesList.value = AddressLosesList(mermaRecords) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/model/ItemPackingType.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/model/ItemPackingType.kt index a6f45b78..cc76951b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/model/ItemPackingType.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/model/ItemPackingType.kt @@ -6,6 +6,7 @@ class ItemPackingType ( var code:String= "", var description:String = "", + var isActive:Boolean = false, var isError: Boolean = false, var errorMessage:String = "" ) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt index cf5055d2..6b5b5c05 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buffer/fragment/BufferFragmentViewModel.kt @@ -27,7 +27,7 @@ class BufferFragmentViewModel(val context: Context) : BaseViewModel(context) { fun buffer_setTypeByName(vBufferFk: Int, vType: String) { silex.buffer_setTypeByName(vBufferFk, vType) - .enqueue(object : SilexCallback(context) { + .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { _itembuffertype.value = ResponseItemVO( isError = true, @@ -35,8 +35,8 @@ class BufferFragmentViewModel(val context: Context) : BaseViewModel(context) { ) } - override fun onSuccess(response: Response) { - if (response.body() as Boolean) { + override fun onSuccess(response: Response) { + if (response.body() == true ) { _itembuffertype.value = ResponseItemVO( isError = false, diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index 88dcb77e..8499c538 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -2440,84 +2440,6 @@ class CollectionFragment( customDialogThreeButtons.setFocusDialogValue() } -/* private fun checkAndCall(position: Int, value: String, action: String) { - if (value.trim().isNullOrEmpty()) { - getString(R.string.Indicanuevacantidad).toast(requireContext()) - } else { - - when (action) { - getString(R.string.Agregar) -> increaseQuantity(position, value.toInt()) - getString(R.string.BasuraRechazar) -> TrashMissingReject( - position, - value.toInt(), - "TRUE" - ) - getString(R.string.titleFaults) -> TrashMissingReject( - position, - value.toInt(), - "FALSE" - ) - getString(R.string.Reject) -> TrashMissingReject( - position, - value.toInt(), - "reject" - ) - getString(R.string.Split) -> split(position, value.toInt()) - - } - - scanRequest() - customDialogThreeButtons.dismiss() - } - }*/ - -/* private fun split(position: Int, quantity: Int) { - - //sergio: SPLIT SALIX - - quantityCollectionSplit = quantity - positionCollectionSplit = position - - var totalQuantity: Int = 0 - try { - totalQuantity = sales[position].quantity!!.toInt() - quantity.toInt() - } catch (e: Exception) { - } - - - viewModel.transferSalesSalix( - ticketFk = sales[position].ticketFk, - saleFk = sales[position].saleFk, - quantity = totalQuantity.toString() - ) - - }*/ - -/* private fun TrashMissingReject( - position: Int, - quantity: Int, - typeCollectionTrashMissingReject: String - ) { - typeCollectionMissing = typeCollectionTrashMissingReject - positionCollectionMissing = position - quantityCollectionMissing = quantity - - var totalQuantity: Int = 0 - try { - totalQuantity = sales[position].quantity!!.toInt() - quantity.toInt() - } catch (e: Exception) { - } - - viewModel.collectionMissingTrash( - saleFk = sales[position].saleFk, - quantity = totalQuantity.toString(), - warehouseFk = getData(WAREHOUSEFK), - type = typeCollectionTrashMissingReject, - originalQuantity = quantity - ) - - }*/ - private fun missingTrashSuccesful() { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt index e5b239fe..57fc268a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt @@ -2539,85 +2539,6 @@ import org.json.JSONObject customDialogThreeButtons.setFocusDialogValue() } -/* private fun checkAndCall(position: Int, value: String, action: String) { - if (value.trim().isNullOrEmpty()) { - getString(R.string.Indicanuevacantidad).toast(requireContext()) - } else { - - when (action) { - getString(R.string.Agregar) -> increaseQuantity(position, value.toInt()) - getString(R.string.BasuraRechazar) -> TrashMissingReject( - position, - value.toInt(), - "TRUE" - ) - getString(R.string.titleFaults) -> TrashMissingReject( - position, - value.toInt(), - "FALSE" - ) - getString(R.string.Reject) -> TrashMissingReject( - position, - value.toInt(), - "reject" - ) - getString(R.string.Split) -> split(position, value.toInt()) - - } - - scanRequest() - customDialogThreeButtons.dismiss() - } - }*/ - -/* private fun split(position: Int, quantity: Int) { - - //sergio: SPLIT SALIX - - quantityCollectionSplit = quantity - positionCollectionSplit = position - - var totalQuantity: Int = 0 - try { - totalQuantity = sales[position].quantity!!.toInt() - quantity.toInt() - } catch (e: Exception) { - } - - - viewModel.transferSalesSalix( - ticketFk = sales[position].ticketFk, - saleFk = sales[position].saleFk, - quantity = totalQuantity.toString() - ) - - }*/ - -/* private fun TrashMissingReject( - position: Int, - quantity: Int, - typeCollectionTrashMissingReject: String - ) { - typeCollectionMissing = typeCollectionTrashMissingReject - positionCollectionMissing = position - quantityCollectionMissing = quantity - - var totalQuantity: Int = 0 - try { - totalQuantity = sales[position].quantity!!.toInt() - quantity.toInt() - } catch (e: Exception) { - } - - viewModel.collectionMissingTrash( - saleFk = sales[position].saleFk, - quantity = totalQuantity.toString(), - warehouseFk = getData(WAREHOUSEFK), - type = typeCollectionTrashMissingReject, - originalQuantity = quantity - ) - - }*/ - - private fun missingTrashSuccesful() { var message = "" diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt index 306d289c..2d592230 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPreChecker.kt @@ -2463,84 +2463,6 @@ class CollectionFragmentPreChecker( customDialogThreeButtons.setFocusDialogValue() } -/* private fun checkAndCall(position: Int, value: String, action: String) { - if (value.trim().isNullOrEmpty()) { - getString(R.string.Indicanuevacantidad).toast(requireContext()) - } else { - - when (action) { - getString(R.string.Agregar) -> increaseQuantity(position, value.toInt()) - getString(R.string.BasuraRechazar) -> TrashMissingReject( - position, - value.toInt(), - "TRUE" - ) - getString(R.string.titleFaults) -> TrashMissingReject( - position, - value.toInt(), - "FALSE" - ) - getString(R.string.Reject) -> TrashMissingReject( - position, - value.toInt(), - "reject" - ) - getString(R.string.Split) -> split(position, value.toInt()) - - } - - scanRequest() - customDialogThreeButtons.dismiss() - } - }*/ - -/* private fun split(position: Int, quantity: Int) { - - //sergio: SPLIT SALIX - - quantityCollectionSplit = quantity - positionCollectionSplit = position - - var totalQuantity: Int = 0 - try { - totalQuantity = sales[position].quantity!!.toInt() - quantity.toInt() - } catch (e: Exception) { - } - - - viewModel.transferSalesSalix( - ticketFk = sales[position].ticketFk, - saleFk = sales[position].saleFk, - quantity = totalQuantity.toString() - ) - - }*/ - -/* private fun TrashMissingReject( - position: Int, - quantity: Int, - typeCollectionTrashMissingReject: String - ) { - typeCollectionMissing = typeCollectionTrashMissingReject - positionCollectionMissing = position - quantityCollectionMissing = quantity - - var totalQuantity: Int = 0 - try { - totalQuantity = sales[position].quantity!!.toInt() - quantity.toInt() - } catch (e: Exception) { - } - - viewModel.collectionMissingTrash( - saleFk = sales[position].saleFk, - quantity = totalQuantity.toString(), - warehouseFk = getData(WAREHOUSEFK), - type = typeCollectionTrashMissingReject, - originalQuantity = quantity - ) - - }*/ - private fun missingTrashSuccesful() { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt index d3737bde..a89e92ec 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt @@ -12,6 +12,7 @@ import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.collection.* import es.verdnatura.presentation.view.feature.collection.mapper.map +import es.verdnatura.presentation.view.feature.collection.mapper.proposal import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO import es.verdnatura.presentation.view.feature.sacador.model.* import retrofit2.Call @@ -331,7 +332,11 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { response: Response> ) { if (response.body() != null) { - _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } + val mappedList = response.body()?.map { it.proposal(context) } + _placementSuppleyList.value = PlacementSupplyListVO(mappedList.orEmpty()) + + + // _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } } else { val listError: ArrayList = ArrayList() listError.add( @@ -576,34 +581,6 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { }) } -/* fun collectionMissingTrash( - saleFk: Int, - quantity: String, - type: String, - warehouseFk: String, - originalQuantity: Int - ) { - silex.collectionMissingTrash( - saleFk, - quantity, - type, - warehouseFk, - originalQuantity - ).enqueue(object : SilexCallback(context) { - override fun onError(t: Throwable) { - _responseMissingTrash.value = ResponseItemVO( - isError = true, - errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!) - ) - } - - override fun onSuccess(response: Response) { - _responseMissingTrash.value = - ResponseItemVO(isError = false, response = response.message()) - } - }) - }*/ - fun saleTrackingDel(saleFk: Int) { silex.saleTrackingDel(saleFk) @@ -693,6 +670,8 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { buyFk: String, message: String ) { + //TAREA 5134 + //Borrar silex.debug_add(buyFk, message) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { @@ -851,6 +830,9 @@ class CollectionViewModel(val context: Context) : BaseViewModel(context) { } fun mistakeType() { + + //Tarea 5134 + // salix.getMistakeTypes() silex.mistakeType() .enqueue(object : SilexCallback>(context) { override fun onError(t: Throwable) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt index 77cd7efd..be8fcd02 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt @@ -4,6 +4,7 @@ import android.content.Context import es.verdnatura.R import es.verdnatura.presentation.common.convertToDateString import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO import java.text.SimpleDateFormat import java.util.* @@ -67,4 +68,12 @@ private fun getCalendarFromDate(date: String,context:Context): Calendar { val cal = Calendar.getInstance() cal.time = sdf.parse(date)!! return cal +} +// para cuando se pase a Salix el modelo +//Tarea 5134 +fun PlacementSupplyVO.proposal(context: Context): PlacementSupplyVO { + try { + }catch (ex:Exception){ + } + return this } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt index b8ef2d8f..5846b0ae 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlvehiculo/fragment/ControlVehiculoViewModel.kt @@ -3,12 +3,16 @@ package es.verdnatura.presentation.view.feature.controlvehiculo.fragment import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData +import com.google.gson.Gson +import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback +import es.verdnatura.domain.model.Filter import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.getMessageFromAllResponse import es.verdnatura.presentation.base.nameofFunction import es.verdnatura.presentation.common.ResponseItemMachineControl import es.verdnatura.presentation.common.ResponseItemVO +import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.model.DeviceId import org.json.JSONObject import retrofit2.Response @@ -131,10 +135,20 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) { fun deviceProduction_getnameDevice(android_id: String) { - silex.deviceProduction_getnameDevice( - android_id + + /* silex.deviceProduction_getnameDevice( + android_id + )*/ + + salix.deviceProductionsGetName( + Gson().toJson( + Filter( + mapOf("id" to true), + mapOf("android_id" to mapOf("eq" to android_id)) + ) + ) ) - .enqueue(object : SilexCallback(context) { + .enqueue(object : SalixCallback>(context) { override fun onError(t: Throwable) { _responsemachine.value = ResponseItemMachineControl( isError = true, @@ -143,13 +157,17 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) { ) } - override fun onSuccess(response: Response) { + override fun onSuccess(response: Response>) { if (response.body() != null) { _responsemachine.value = ResponseItemMachineControl( isError = false, - response = response.body()!!.toString(), + response = if (response.body()!!.isEmpty()) { + "" + } else { + response.body()!![0].id.toString() + }, type = "getnameDevice" ) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt index c306ef32..3b87996a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt @@ -5,6 +5,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import com.google.gson.JsonObject +import es.verdnatura.MobileApplication +import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.getMessageFromAllResponse @@ -18,8 +20,10 @@ import es.verdnatura.presentation.view.feature.inventario.model.InventoryParking import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO import es.verdnatura.presentation.view.feature.inventario.model.ItemInventoryParking import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake -import es.verdnatura.presentation.view.feature.workermistake.model.MistakeWorkerType +import es.verdnatura.presentation.view.feature.workermistake.model.ExpeditionMistakeSalix +import es.verdnatura.presentation.view.feature.workermistake.model.MistakeType import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake +import es.verdnatura.presentation.view.feature.workermistake.model.WorkerMistakeSalix import es.verdnatura.presentation.view.feature.workermistake.model.departmentMistakeList import es.verdnatura.presentation.view.feature.workermistake.model.workerFromMistakeList import es.verdnatura.presentation.view.feature.workermistake.model.workerMistakeTypeList @@ -228,47 +232,11 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { }) } - //En test encara,no provat en Salix - /* fun department_getHasMistakeSalix(token: String) { - - getWorkerMistakeUserCase.department_getHasMistakeSalix(token) - - .enqueue(object : Callback> { - override fun onFailure(call: Call>, t: Throwable) { - val listError: ArrayList = ArrayList() - listError.add( - DepartmentMistake( - isError = true, - errorMessage = getMessageFromAllResponse( - nameofFunction(this), - t.message!! - ) - ) - ) - _mistakeDepartmentList.value = departmentMistakeList(listError) - } - - override fun onResponse( - call: Call>, - response: Response> - ) { - if (response.body() != null) { - _mistakeDepartmentList.value = - response.body()?.let { departmentMistakeList(it) } - } else { - val listError: ArrayList = ArrayList() - listError.add(DepartmentMistake(0, "")) - _mistakeDepartmentList.value = departmentMistakeList(listError) - } - } - - }) - }*/ fun department_getHasMistake() { - silex.department_getHasMistake() - .enqueue(object : SilexCallback>(context) { + salix.department_getHasMistake() + .enqueue(object : SalixCallback>(context) { override fun onError(t: Throwable) { val listError: ArrayList = ArrayList() listError.add( @@ -289,7 +257,7 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { response.body()?.let { departmentMistakeList(it) } } else { val listError: ArrayList = ArrayList() - listError.add(DepartmentMistake(0, "")) + listError.add(DepartmentMistake()) _mistakeDepartmentList.value = departmentMistakeList(listError) } } @@ -339,38 +307,38 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { } fun workerMistakeType_get() { + //Tarea 5134 + //salix.getWorkerMistakeTypes() silex.workerMistakeType_get() - .enqueue(object : SilexCallback>(context) { + .enqueue(object : SilexCallback>(context) { override fun onError(t: Throwable) { - val listError: ArrayList = ArrayList() + val listError: ArrayList = ArrayList() listError.add( - MistakeWorkerType( + MistakeType( isError = true, errorMessage = getMessageFromAllResponse( nameofFunction(this), t.message!! ), - id = "0", description = "" ) ) _mistakeWorkerList.value = workerMistakeTypeList(listError) } - override fun onSuccess(response: Response>) { + override fun onSuccess(response: Response>) { if (response.body() != null) { _mistakeWorkerList.value = response.body()?.let { workerMistakeTypeList(it) } } else { - val listError: ArrayList = ArrayList() + val listError: ArrayList = ArrayList() listError.add( - MistakeWorkerType( + MistakeType( isError = true, errorMessage = getMessageFromAllResponse( nameofFunction(this), response.message() ), - id = "0", description = "" ) ) @@ -387,6 +355,8 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { vUserFk: Int, vTypeFk: String ) { + //Tarea 5134 + //salix.workerMistakesAdd(WorkerMistakeSalix(vUserFk,vTypeFk)) silex.workerMistake_Add(vUserFk, vTypeFk) .enqueue(object : SilexCallback(context) { @@ -411,8 +381,11 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { fun expeditionMistake_add( vExpeditionFk: Int, - vTypeFk: String + vTypeFk: String, + // userId:Int= (context as MobileApplication).userId!! ) { + //Tarea 5134 + //salix.expeditionMistakesAdd(ExpeditionMistakeSalix(expeditionFk = vExpeditionFk, typeFk = vTypeFk, workerFk = (context as MobileApplication).userId!!) silex.expeditionMistake_add(vExpeditionFk, vTypeFk) .enqueue(object : SilexCallback(context) { @@ -642,39 +615,39 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) { } fun expeditionMistakeType_get() { + // Tarea 5134 pasar a salix + //salix.getExpeditionMistakeTypes() silex.expeditionMistakeType_get() - .enqueue(object : SilexCallback>(context) { + .enqueue(object : SilexCallback>(context) { override fun onError(t: Throwable) { - val listError: ArrayList = ArrayList() + val listError: ArrayList = ArrayList() listError.add( - MistakeWorkerType( + MistakeType( isError = true, errorMessage = getMessageFromAllResponse( nameofFunction(this), t.message!! ), - id = "0", description = "" ) ) _mistakeWorkerList.value = workerMistakeTypeList(listError) } - override fun onSuccess(response: Response>) { + override fun onSuccess(response: Response>) { if (response.body() != null) { _mistakeWorkerList.value = response.body()?.let { workerMistakeTypeList(it) } } else { - val listError: ArrayList = ArrayList() + val listError: ArrayList = ArrayList() listError.add( - MistakeWorkerType( + MistakeType( isError = true, errorMessage = getMessageFromAllResponse( nameofFunction(this), response.message() ), - id = "0", description = "" ) ) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt index 4932c1c8..e0c5cdbc 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt @@ -17,6 +17,7 @@ import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.view.feature.ajustes.model.Printers import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO import es.verdnatura.presentation.view.feature.ajustes.model.WorkerPrintersList +import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.DeviceLogSalix import es.verdnatura.presentation.view.feature.login.model.DataUserSalix import es.verdnatura.presentation.view.feature.login.model.LoginDevice import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO @@ -203,6 +204,8 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) { fun deviceLog_add( app: String, versionApp: String, android_id: String ) { + //Tarea 4815 + // salix.deviceLogInsert(DeviceLogSalix(androidId = android_id,userFk,nameApp= app,versionApp= versionApp)) silex.deviceLog_add(app, versionApp, android_id) .enqueue(object : SilexCallback(context) { @@ -381,7 +384,9 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) { } fun operator_add() { - + //Tarea 5134 no se puede modificar directamente con un upsertWith, hay que modificar front. Y si al hacer login en Salix hacer el insertIgnore en -> operator_add, back de Salix sabe + //si es de app? + //salix.operatorAdd() silex.operator_add().enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { _operatorAdd.value = ResponseItemVO( @@ -403,7 +408,7 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) { override fun onError(t: Throwable) { val listError: ArrayList = ArrayList() listError.add( - Printers( + Printers(0,"", isError = true, errorMessage = getMessageFromAllResponse( nameofFunction(this), @@ -424,7 +429,7 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) { } else { val listError: ArrayList = ArrayList() listError.add( - Printers( + Printers(0,"", isError = true, errorMessage = getMessageFromAllResponse( nameofFunction(this), diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt index 2a4c565d..de0bf473 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt @@ -69,6 +69,8 @@ class ExpeditionPalletDetailViewModel(var context: Context) : BaseViewModel(cont } fun expeditionPalletDel(vPalletFk: Int) { + //Tarea 5134 + //salix.expeditionPalletDel(vPalletFk).enqueue(object : SalixCallback(context) { silex.expeditionPalletDel(vPalletFk).enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { _response.value = ResponseItemVO( diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt index 4670842d..1e71a07a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletFragment.kt @@ -257,7 +257,7 @@ class ExpeditionPalletFragment( ) ////Log.i("VERDNATURA:"," palletizando ${it.list.get(0).palletFk} expedi: ${customDialogList.getValue()}") viewModel.checkRouteExpeditionScanPut( - it.list.get(0).palletFk, + it.list[0].palletFk, customDialogList.getValue().toInt() ) } else { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt index d4c9bc59..2217fad6 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt @@ -179,6 +179,8 @@ class ExpeditionScanViewModel(val context: Context) : BaseViewModel(context) { fun expeditionScanDel( vScanFk: Int) { + //Tarea 5134 + //salix.expeditionScanDel(vScanFk).enqueue(object : SalixCallback (context){ silex.expeditionScanDel(vScanFk) .enqueue(object : SilexCallback (context){ override fun onError(t: Throwable) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt index 4480071f..87460748 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListFragment.kt @@ -4,8 +4,10 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment import android.annotation.SuppressLint import android.content.Context import android.graphics.drawable.Drawable +import android.os.Build import android.view.View import android.view.inputmethod.EditorInfo +import androidx.annotation.RequiresApi import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R @@ -43,6 +45,7 @@ class ExpeditionTruckListFragment : BaseFragment @@ -117,6 +122,7 @@ class ExpeditionTruckListFragment : BaseFragment>(context) { + // Tarea 5134 modificar fecha para que se vea correctamente y no con 0.00Z + /* salix.expeditionTruckGet( + """{"where": { "eta": { + "between": ["${LocalDate.now().atTime(LocalTime.MIN)}", "${LocalDate.now().atTime(LocalTime.MAX)}"]}}}""" + ).enqueue(object : SalixCallback>(context) {*/ + silex.expeditionTruckList().enqueue(object : + SilexCallback>(context) { override fun onError(t: Throwable) { val listError: ArrayList = ArrayList() listError.add( @@ -63,8 +74,14 @@ class ExpeditionTruckListViewModel(val context: Context) : BaseViewModel(context }) } + @RequiresApi(Build.VERSION_CODES.O) fun expeditionTruckAdd(vHour: String, vDescription: String) { - silex.expeditionTruckAdd(vHour, vDescription).enqueue(object : Callback { + salix.expeditionTrucksInsert( + ExpeditionTruckSalix( + eta = "${LocalDate.now()} $vHour", + description = vDescription + ) + ).enqueue(object : SalixCallback(context) { override fun onFailure(call: Call, t: Throwable) { _response.value = ResponseItemVO( isError = true, diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/model/ItemExpeditionTruckVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/model/ItemExpeditionTruckVO.kt index 949b2987..ed7739f4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/model/ItemExpeditionTruckVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/model/ItemExpeditionTruckVO.kt @@ -13,7 +13,7 @@ class ItemExpeditionTruckVO( var isError: Boolean = false, var errorMessage: String = "" ) - +data class ExpeditionTruckSalix(val eta:String,val description: String) class ItemExpeditionTruckList( var list: List = listOf() diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/EndSacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/EndSacadorFragment.kt index f44fcb46..83fd8648 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/EndSacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/EndSacadorFragment.kt @@ -1230,67 +1230,6 @@ class EndSacadorFragment( } } - /*private fun checkAndCall(position: Int, value: Int, action: String) { - - when (action) { - getString(R.string.Agregar) -> increaseQuantity(position, value) - *//* getString(R.string.BasuraRechazar) -> TrashMissingReject(position, value, "TRUE") - getString(R.string.titleFaults) -> TrashMissingReject(position, value, "FALSE") - getString(R.string.Reject) -> TrashMissingReject(position, value, "reject") - getString(R.string.Split) -> split(position, value)*//* - - } - scanRequest() - customDialogThreeButtons.dismiss() - }*/ - -/* private fun TrashMissingReject( - position: Int, - quantity: Int, - typeCollectionTrashMissingReject: String - ) { - typeCollectionMissing = typeCollectionTrashMissingReject - positionCollectionMissing = position - quantityCollectionMissing = quantity - - var totalQuantity: Int = 0 - try { - totalQuantity = sales[position].saldo.toInt() - quantity.toInt() - } catch (e: Exception) { - } - - viewModel.collectionMissingTrash( - saleFk = sales[position].idMovimiento, - quantity = totalQuantity.toString(), - warehouseFk = getDataInt(WAREHOUSEFK), - type = "FALSE", - originalQuantity = quantity - ) - - } - - private fun split(position: Int, quantity: Int) { - - positionCollectionSplit = position - quantityCollectionSplit = quantity - - var totalQuantity: Int = 0 - try { - totalQuantity = sales[position].saldo.toInt() - quantity.toInt() - } catch (e: Exception) { - } - - binding.splashProgress.visibility = VISIBLE - - viewModel.transferSalesSalix( - ticketFk = sales[position].id, - saleFk = sales[position].idMovimiento, - quantity = totalQuantity.toString() - ) - - - }*/ - private fun increaseQuantity(position: Int, quantity: Int) { positionIncreaseQuantity = position diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt index da774bb0..04120137 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt @@ -4,6 +4,8 @@ import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations +import com.google.gson.JsonObject +import es.verdnatura.domain.SalixCallback import es.verdnatura.domain.SilexCallback import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.getMessageFromAllResponse @@ -47,7 +49,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { val loadResponseCode = Transformations.map(_responseCode) { Event(it) } private val _responseAddList by lazy { MutableLiveData() } - val responseAddList: LiveData = _responseAddList + val responseAddList: LiveData = _responseAddList val loadAddList = Transformations.map(_responseAddList) { Event(it) } @@ -104,7 +106,8 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { shelving: String ) { - silex.shelvingPriorityUpdate(priority, shelving) + //Tarea 5134 ok + salix.updateShelvingPriority("""{"code": "$shelving"}""", hashMapOf("priority" to priority)) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { _responsepriority.value = ResponseItemVO( @@ -119,6 +122,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { } }) } + fun itemShelving_addList( shelving: String, items: Any, @@ -147,6 +151,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { } }) } + fun itemShelvingMake( shelving: String, item: Int, @@ -185,6 +190,10 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { grouping: Int? ) { + /* salix.itemShelvingUpdate( + params = , + id = , + ).enqueue(object : SalixCallback(context) {*/ silex.itemShelvingMakeEdit( quantity, packing, @@ -262,6 +271,8 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { vShelvingFk: String ) { + /*salix.itemShelvingUpdate() + .enqueue(object : SilexCallback(context) {*/ silex.itemShelving_merge(vShelf, vShelvingFk) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { @@ -369,8 +380,13 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { shelvingFk: String ) { - silex.clearShelvingList(shelvingFk) - .enqueue(object : SilexCallback(context) { + + // silex.clearShelvingList(shelvingFk) + salix.itemShelvingsUpdate( + id = JsonObject().apply { addProperty("shelvingFk", shelvingFk) }, + hashMapOf("visible" to 0) + ) + .enqueue(object : SalixCallback(context) { override fun onError(t: Throwable) { _response.value = ResponseItemVO( isError = true, @@ -407,8 +423,10 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { } fun itemShelvingDelete(itemFk: Int) { - silex.itemShelvingDelete(itemFk) - .enqueue(object : SilexCallback(context) { + salix.itemShelvingsDelete(itemFk) + .enqueue(object : SalixCallback(context) { + /*silex.itemShelvingDelete(itemFk) + .enqueue(object : SilexCallback(context) {*/ override fun onError(t: Throwable) { _response.value = ResponseItemVO( @@ -425,7 +443,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) { }) } - fun itemShelving_selfConsumption(shelvingFk:String, itemFk: Int, quantity: Int) { + fun itemShelving_selfConsumption(shelvingFk: String, itemFk: Int, quantity: Int) { silex.itemShelving_selfConsumption(shelvingFk, itemFk, quantity) .enqueue(object : SilexCallback(context) { override fun onError(t: Throwable) { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/WorkermistakeFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/WorkermistakeFragment.kt index f225491a..102c7616 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/WorkermistakeFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/fragment/WorkermistakeFragment.kt @@ -19,7 +19,7 @@ import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO import es.verdnatura.presentation.view.feature.inventario.fragment.InventaryViewModel import es.verdnatura.presentation.view.feature.inventario.fragment.SearchDepartmentModel import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake -import es.verdnatura.presentation.view.feature.workermistake.model.MistakeWorkerType +import es.verdnatura.presentation.view.feature.workermistake.model.MistakeType import es.verdnatura.presentation.view.feature.workermistake.model.WorkerFromMistake import ir.mirrajabi.searchdialog.SimpleSearchDialogCompat @@ -62,15 +62,7 @@ class WorkermistakeFragment( override fun onCreate(savedInstanceState: Bundle?) { - - var working_in_test = false //sergio:No posar a true fins que Salix puje versió 8.3 - - if (!working_in_test) { - viewModel.department_getHasMistake( - ) - } else { - // viewModel.department_getHasMistakeSalix(getData(TOKEN)) - } + viewModel.department_getHasMistake() super.onCreate(savedInstanceState) } @@ -237,7 +229,7 @@ class WorkermistakeFragment( } - private fun showMistakeList(list: List) { + private fun showMistakeList(list: List) { binding.splashProgress.visibility = View.GONE listMistakes = ArrayList() list.forEach { diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/model/mistakeWorkerType.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/model/mistakeWorkerType.kt index 14f58251..16d0fa36 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/model/mistakeWorkerType.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/workermistake/model/mistakeWorkerType.kt @@ -1,38 +1,49 @@ package es.verdnatura.presentation.view.feature.workermistake.model -class MistakeWorkerType ( - var id: String = "", - var code:String = "", - var description: String = "", - var isError:Boolean = false, - var errorMessage:String = "" - ) +class MistakeType( + var code: String = "", + var description: String = "", + var isError: Boolean = false, + var errorMessage: String = "" +) -class DepartmentMistake( +class ExpeditionMistakeSalix( + var expeditionFk: Int, + var typeFk: String, + var workerFk: Int - var id:Int? =null, - var name:String="", - var isError:Boolean = false, - var errorMessage:String = "" +) + +class DepartmentMistake( + + var id: Int? = null, + var name: String = "", + var isError: Boolean = false, + var errorMessage: String = "" ) class WorkerFromMistake( - var id:Int?=null, - var firstName: String="", - var lastName: String="", - var isError:Boolean = false, - var errorMessage:String = "" + var id: Int? = null, + var firstName: String = "", + var lastName: String = "", + var isError: Boolean = false, + var errorMessage: String = "" ) +class WorkerMistakeSalix( + var userFk: Int, + var workerMistakeTypeFk: String, +) class workerMistakeTypeList( - var list: List = listOf() + var list: List = listOf() ) class departmentMistakeList( var list: List = listOf() ) + class workerFromMistakeList( var list: List = listOf() ) diff --git a/app/src/main/res/layout/item_route_row.xml b/app/src/main/res/layout/item_route_row.xml index 9200faf1..f1c6c45a 100644 --- a/app/src/main/res/layout/item_route_row.xml +++ b/app/src/main/res/layout/item_route_row.xml @@ -54,7 +54,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - android:background="@color/verdnatura_black_9"> + android:background="@color/verdnatura_black_1"> @@ -66,11 +66,21 @@ android:paddingRight="5dp" android:layout_marginBottom="5dp" > +