refs #5134 Refactor silex→salix

This commit is contained in:
Sergio De la torre 2023-09-19 07:16:22 +02:00
parent eed96ea4eb
commit 8618425413
30 changed files with 394 additions and 631 deletions

View File

@ -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<T>(val context: Context) : Callback<T> {
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<T>(val context: Context) : Callback<T> {
return false
}
private fun errorSalixMessage(response: Response<T>): 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()
}
}
}

View File

@ -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<LoginSalixVO>
): Call<LoginSalixVO>
@GET("VnUsers/getCurrentUserData")
fun getCurrentUserData(
):
Call<DataUserSalix>
): Call<DataUserSalix>
/* @POST("chats/sendCheckingPresence")
fun sendChekingPresence(
@ -53,25 +56,21 @@ interface SalixService {
@GET("collections/getSectors")
fun getSectorsSalix(
):
Call<List<SectorItemVO>>
): Call<List<SectorItemVO>>
@GET("collections/getCollection")
fun getCollectionSalix(
):
Call<List<CollectionVO>>
): Call<List<CollectionVO>>
@GET("collections/sectorCollection_get")
fun sectorCollection_get(
):
Call<List<CollectionVO>>
): Call<List<CollectionVO>>
@POST("collections/setSaleQuantity")
fun collectionIncreaseQuantitySalix(
@Body params: SalixSaleQuantity
):
Call<Any>
): Call<Any>
@Multipart
@POST("Entries/{id}/uploadFile")
@ -84,8 +83,7 @@ interface SalixService {
@Query("description") description: String,
@Query("hasFile") hasFile: Boolean,
@Part file: MultipartBody.Part,
):
Call<Any>
): Call<Any>
@Multipart
@POST("dms/uploadFile")
@ -97,14 +95,12 @@ interface SalixService {
@Query("description") description: String,
@Query("hasFile") hasFile: Boolean,
@Part file: MultipartBody.Part,
):
Call<Any>
): Call<Any>
@Multipart
@POST("/api/Tickets/saveSign")
fun saveSign(
@Part file: MultipartBody.Part?,
@QueryMap(encoded = true) queryMap: Map<String?, String?>
@Part file: MultipartBody.Part?, @QueryMap(encoded = true) queryMap: Map<String?, String?>
): Call<Any>
@ -113,68 +109,105 @@ interface SalixService {
@Path("id") id: Number,
@Query("item") item: Number,
@Query("printedStickers") printedStickers: Number
):
Call<Any>
): Call<Any>
@POST("tickets/{idTicket}/transferSales") //-->saleMove en Silex
fun transferSalesSalix(
@Path("idTicket") idTicket: String,
@Body params: listSaleSalix
):
Call<Any>
@Path("idTicket") idTicket: String, @Body params: listSaleSalix
): Call<Any>
//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<List<DepartmentMistake>>
@Query("filter") filter:String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}"""
): Call<List<DepartmentMistake>>
@DELETE("ExpeditionPallets/{id}")
fun expeditionPalletDel(
@Path("id") id: Number
): Call<Any>
@DELETE("ExpeditionScans/{id}")
fun expeditionScanDel(
@Path("id") id: Number
): Call<Any>
@DELETE("ItemShelvings/{id}")
fun itemShelvingsDelete(
@Path("id") id: Number
): Call<Any>
@GET("Workers/{idWorker}/sip")
fun sip_getExtension(
@Path("idWorker") idWorker: Int,
):
Call<Any>
): Call<Any>
@PATCH("Items/{itemFk}")
fun update_ItemPackingType(
@Path("itemFk") itemFk: String,
@Body params: itemPackingTypeSalix
):
Call<Any>
@Body params: Any
): Call<Any>
@PATCH("Items/{itemFk}")
fun updateItem(
@Path("itemFk") itemFk: Int,
@Body params: Any
): Call<Any>
@POST("Shelvings/upsertWithWhere")
fun updateShelvingPriority(
@Query("where") where: String,
@Body params: Any
): Call<Any>
//DE MOMENTO NO FUNCIONA, SE QUERÍA AÑADIR POR INSERTIGNORE
@POST("Operators/upsertWithWhere")
fun operatorAdd(
@Query("where") where: String,
@Body params: Any
): Call<Any>
@PUT("DeviceLogs")
fun deviceLogInsert(
@Body params: Any
): Call<Any>
@POST("ExpeditionTrucks")
fun expeditionTrucksInsert(
@Body params: Any
): Call<Any>
@GET("ItemPackingTypes")
fun get_ItemPackingType(
@Query("filter") filter:String = """{"where": {"isActive": true}}"""
): Call<List<ItemPackingType>>
):
Call<List<ItemPackingType>>
@GET("ExpeditionTrucks")
fun expeditionTruckGet(
@Query("filter") filter:String
): Call<List<ItemExpeditionTruckVO>>
@POST("PackingSiteAdvanceds")
fun ticket_advancePackaging(
@Body parms: packingSiteSalix
):
Call<Void>
): Call<Void>
@PUT("ItemBarCodes")//REVISADA
fun barcodes_edit(
@Body params: itemBarCodeSalix
):
Call<Any>
): Call<Any>
@DELETE("ItemBarCodes")//REVISADA
fun deleteItemBarCode(
@Body params: itemBarCodeSalix
): Call<Any>
@GET("ItemBarCodes/{barCodeValue}/toItem")//REVISADA
fun barcodes_toitem(
@Path("barCodeValue") barCodeValue: String
):
Call<String>
): Call<String>
@GET("Suppliers")//REVISADA
fun getSuppliers(
@ -184,36 +217,34 @@ interface SalixService {
"\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," +
"\"where\":{ \"email\":{\"neq\":null } }}}]})"*/
):
Call<List<Supplier>>
): Call<List<Supplier>>
@PUT("Entries")//REVISADA
fun Entries(
@Body entry: EntrySalix
):
Call<EntrySalix>
): Call<EntrySalix>
@GET("Shelvings")
fun Shelvings(
@Query("filter") filter: String
):
Call<List<ShelvingLogSalix>>
): Call<List<ShelvingLogSalix>>
@GET("DeviceProductions")
fun deviceProductionsGetName(
@Query("filter") filter: String
): Call<List<DeviceId>>
@GET("Suppliers/{supplierId}/getItemsPackaging")
fun getItemsPackaging(
@Path("supplierId") supplierId: Int,
@Query("entry") entry: Int
@Path("supplierId") supplierId: Int, @Query("entry") entry: Int
):
Call<List<ItemSupplier>>
): Call<List<ItemSupplier>>
@POST("Entries/addFromPackaging")
fun addFromPackaging(
@Query("supplier") supplier: Int,
@Query("isTravelReception") isTravelReception: Boolean
@Query("supplier") supplier: Int, @Query("isTravelReception") isTravelReception: Boolean
):
Call<EntrySalix>
): Call<EntrySalix>
@POST("Images/upload")
@Multipart
@ -221,64 +252,65 @@ interface SalixService {
@Query("collection") collection: String,
@Query("id") id: Int,
@Part filePart: MultipartBody.Part,
):
Call<Any>
): Call<Any>
@PATCH("Operators/{id}")
fun update_operator(
@Path("id") id: Number,
@Body params: Any
@Path("id") id: Number, @Body params: Any
):
Call<Void>
): Call<Void>
@GET("Operators")
fun operator_getData(
@Query("filter") filter: String
):
Call<List<OperatorSalix>>
): Call<List<OperatorSalix>>
@GET("AccessTokenConfigs")
fun getAccessTokenConfigs(
):
Call<List<accessConfigSalix>>
): Call<List<accessConfigSalix>>
@POST("vnusers/renewToken")
fun renewToken(
):
Call<RenewToken>
): Call<RenewToken>
@PATCH("ItemShelvings/{id}")
fun itemShelvingUpdate(
@Path("id") id: Number,
@Body params: Any
):
Call<Any>
@Path("id") id: Number, @Body params: Any
): Call<Any>
@POST("ItemShelvings/update")
fun itemShelvingsUpdate(
@Query("where") id: JsonObject,
@Body params: Any
):
Call<Any>
): Call<Any>
@POST("ItemShelvings/getInventory")
fun getInventoryParking(
@Query("parkingFrom") parkingFrom: String,
@Query("parkingTo") parkingTo: String
):
Call<List<ItemInventoryParking>>
@Query("parkingFrom") parkingFrom: String, @Query("parkingTo") parkingTo: String
): Call<List<ItemInventoryParking>>
@PATCH("Routes/{id}")
fun routeUpdate(
@Path("id") id: Number,
@Body route: RouteInfo,
):
Call<Any>
): Call<Any>
@GET("ExpeditionMistakeTypes")
fun getExpeditionMistakeTypes(
): Call<List<MistakeType>>
@POST("ExpeditionMistakes")
fun expeditionMistakesAdd(expeditionMistake:ExpeditionMistakeSalix
): Call<Any>
@POST("WorkerMistakes")
fun workerMistakesAdd(workerMistake: WorkerMistakeSalix
): Call<Any>
@GET("MistakeTypes")
fun getMistakeTypes(
): Call<List<MistakeTypeVO>>
}
@ -287,8 +319,7 @@ interface SalixServiceSend {
@POST("chats/send")
fun sendGroup(
@Body params: SalixGrupo
):
Call<Boolean>
): Call<Boolean>
}

View File

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

View File

@ -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<List<ItemPackingType>>(context) {
SalixCallback<List<ItemPackingType>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<ItemPackingType> = ArrayList()
@ -324,31 +325,6 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun worker_updateSector(sectorFk: Int) {
silex.worker_updateSector(sectorFk)
.enqueue(object : SilexCallback<Unit>(context) {
override fun onError(t: Throwable) {
_actionUpdate.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Unit>) {
_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<Unit>(context) {
override fun onError(t: Throwable) {
ProgressLoading(GONE)
throw t
}
override fun onSuccess(response: Response<Unit>) {
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))

View File

@ -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<SectorItemVO> = listOf()
)
class PrintersList (
class PrintersList(
var list: List<Printers> = 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<Printers> = listOf()
var list: List<Printers> = 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<Train> = listOf()
)

View File

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

View File

@ -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<Any>(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<Any>(context) {
salix.updateItem(itemFk, hashMapOf("stems" to value))
.enqueue(object : SalixCallback<Any>(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<Any>(context) {
salix.updateItem(itemFk, hashMapOf("comment" to value))
.enqueue(object : SalixCallback<Any>(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<Any>(context) {
override fun onError(t: Throwable) {
@ -317,20 +314,23 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
}
private val _responseinsert by lazy { MutableLiveData<ResponseItemVO>() }
val responseinsert: LiveData<ResponseItemVO>
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<Any>(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)
}

View File

@ -6,6 +6,7 @@ class ItemPackingType (
var code:String= "",
var description:String = "",
var isActive:Boolean = false,
var isError: Boolean = false,
var errorMessage:String = ""
)

View File

@ -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<Any>(context) {
.enqueue(object : SilexCallback<Boolean>(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<Any>) {
if (response.body() as Boolean) {
override fun onSuccess(response: Response<Boolean>) {
if (response.body() == true ) {
_itembuffertype.value = ResponseItemVO(
isError = false,

View File

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

View File

@ -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 = ""

View File

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

View File

@ -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<List<PlacementSupplyVO>>
) {
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<PlacementSupplyVO> = 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<Any>(context) {
override fun onError(t: Throwable) {
_responseMissingTrash.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
_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<Any>(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<List<MistakeTypeVO>>(context) {
override fun onError(t: Throwable) {

View File

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

View File

@ -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<Any>(context) {
.enqueue(object : SalixCallback<List<DeviceId>>(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<Any>) {
override fun onSuccess(response: Response<List<DeviceId>>) {
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"
)
}

View File

@ -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<List<DepartmentMistake>> {
override fun onFailure(call: Call<List<DepartmentMistake>>, t: Throwable) {
val listError: ArrayList<DepartmentMistake> = ArrayList()
listError.add(
DepartmentMistake(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
t.message!!
)
)
)
_mistakeDepartmentList.value = departmentMistakeList(listError)
}
override fun onResponse(
call: Call<List<DepartmentMistake>>,
response: Response<List<DepartmentMistake>>
) {
if (response.body() != null) {
_mistakeDepartmentList.value =
response.body()?.let { departmentMistakeList(it) }
} else {
val listError: ArrayList<DepartmentMistake> = ArrayList()
listError.add(DepartmentMistake(0, ""))
_mistakeDepartmentList.value = departmentMistakeList(listError)
}
}
})
}*/
fun department_getHasMistake() {
silex.department_getHasMistake()
.enqueue(object : SilexCallback<List<DepartmentMistake>>(context) {
salix.department_getHasMistake()
.enqueue(object : SalixCallback<List<DepartmentMistake>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<DepartmentMistake> = ArrayList()
listError.add(
@ -289,7 +257,7 @@ class InventaryViewModel(val context: Context) : BaseViewModel(context) {
response.body()?.let { departmentMistakeList(it) }
} else {
val listError: ArrayList<DepartmentMistake> = 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<List<MistakeWorkerType>>(context) {
.enqueue(object : SilexCallback<List<MistakeType>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<MistakeWorkerType> = ArrayList()
val listError: ArrayList<MistakeType> = 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<List<MistakeWorkerType>>) {
override fun onSuccess(response: Response<List<MistakeType>>) {
if (response.body() != null) {
_mistakeWorkerList.value =
response.body()?.let { workerMistakeTypeList(it) }
} else {
val listError: ArrayList<MistakeWorkerType> = ArrayList()
val listError: ArrayList<MistakeType> = 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<Any>(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<Any>(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<List<MistakeWorkerType>>(context) {
.enqueue(object : SilexCallback<List<MistakeType>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<MistakeWorkerType> = ArrayList()
val listError: ArrayList<MistakeType> = 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<List<MistakeWorkerType>>) {
override fun onSuccess(response: Response<List<MistakeType>>) {
if (response.body() != null) {
_mistakeWorkerList.value =
response.body()?.let { workerMistakeTypeList(it) }
} else {
val listError: ArrayList<MistakeWorkerType> = ArrayList()
val listError: ArrayList<MistakeType> = ArrayList()
listError.add(
MistakeWorkerType(
MistakeType(
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),
response.message()
),
id = "0",
description = ""
)
)

View File

@ -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<Void>(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<Any>(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<Printers> = 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<Printers> = ArrayList()
listError.add(
Printers(
Printers(0,"",
isError = true,
errorMessage = getMessageFromAllResponse(
nameofFunction(this),

View File

@ -69,6 +69,8 @@ class ExpeditionPalletDetailViewModel(var context: Context) : BaseViewModel(cont
}
fun expeditionPalletDel(vPalletFk: Int) {
//Tarea 5134
//salix.expeditionPalletDel(vPalletFk).enqueue(object : SalixCallback<Any>(context) {
silex.expeditionPalletDel(vPalletFk).enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) {
_response.value = ResponseItemVO(

View File

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

View File

@ -179,6 +179,8 @@ class ExpeditionScanViewModel(val context: Context) : BaseViewModel(context) {
fun expeditionScanDel( vScanFk: Int) {
//Tarea 5134
//salix.expeditionScanDel(vScanFk).enqueue(object : SalixCallback<Any> (context){
silex.expeditionScanDel(vScanFk)
.enqueue(object : SilexCallback<Any> (context){
override fun onError(t: Throwable) {

View File

@ -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<FragmentExpeditionTruckListBin
override fun getLayoutId(): Int = R.layout.fragment_expedition_truck_list
@RequiresApi(Build.VERSION_CODES.O)
@SuppressLint("SetTextI18n")
override fun init() {
customDialogHor = CustomDialogHour(requireContext())
@ -70,6 +73,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
binding.mainToolbar.toolbarIcons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
@RequiresApi(Build.VERSION_CODES.O)
override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){
binding.splashProgress.visibility = View.VISIBLE
@ -91,6 +95,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
return df.format(c)
}
@RequiresApi(Build.VERSION_CODES.O)
override fun observeViewModel() {
with(viewModel){
loadExpeditionTruckList.observe(viewLifecycleOwner, Observer { event ->
@ -117,6 +122,7 @@ class ExpeditionTruckListFragment : BaseFragment<FragmentExpeditionTruckListBin
////Log.i("VERDNATURA:","2-Rellenamos adapter")
}
@RequiresApi(Build.VERSION_CODES.O)
private fun addTruck(){
customDialogHor.setTitle(getString(R.string.newTruck)).setOkButton(getString(R.string.save)){
ma.hideKeyboard(customDialogHor.getDestinoEditText())

View File

@ -2,19 +2,24 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
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.view.feature.paletizador.model.ExpeditionTruckSalix
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckList
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import java.time.LocalDate
import java.time.LocalTime
class ExpeditionTruckListViewModel(val context: Context) : BaseViewModel(context) {
@ -25,9 +30,15 @@ class ExpeditionTruckListViewModel(val context: Context) : BaseViewModel(context
val loadResponseExpeditionAdd = Transformations.map(_response) { Event(it) }
@RequiresApi(Build.VERSION_CODES.O)
fun expeditionTruckList() {
silex.expeditionTruckList().enqueue(object :
SilexCallback<List<ItemExpeditionTruckVO>>(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<List<ItemExpeditionTruckVO>>(context) {*/
silex.expeditionTruckList().enqueue(object :
SilexCallback<List<ItemExpeditionTruckVO>>(context) {
override fun onError(t: Throwable) {
val listError: ArrayList<ItemExpeditionTruckVO> = 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<Any> {
salix.expeditionTrucksInsert(
ExpeditionTruckSalix(
eta = "${LocalDate.now()} $vHour",
description = vDescription
)
).enqueue(object : SalixCallback<Any>(context) {
override fun onFailure(call: Call<Any>, t: Throwable) {
_response.value = ResponseItemVO(
isError = true,

View File

@ -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<ItemExpeditionTruckVO> = listOf()

View File

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

View File

@ -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<ResponseItemVO>() }
val responseAddList: LiveData<ResponseItemVO> = _responseAddList
val responseAddList: LiveData<ResponseItemVO> = _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<Any>(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<Any>(context) {*/
silex.itemShelvingMakeEdit(
quantity,
packing,
@ -262,6 +271,8 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
vShelvingFk: String
) {
/*salix.itemShelvingUpdate()
.enqueue(object : SilexCallback<Any>(context) {*/
silex.itemShelving_merge(vShelf, vShelvingFk)
.enqueue(object : SilexCallback<Any>(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<Any>(context) {
// silex.clearShelvingList(shelvingFk)
salix.itemShelvingsUpdate(
id = JsonObject().apply { addProperty("shelvingFk", shelvingFk) },
hashMapOf("visible" to 0)
)
.enqueue(object : SalixCallback<Any>(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<Any>(context) {
salix.itemShelvingsDelete(itemFk)
.enqueue(object : SalixCallback<Any>(context) {
/*silex.itemShelvingDelete(itemFk)
.enqueue(object : SilexCallback<Any>(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<Any>(context) {
override fun onError(t: Throwable) {

View File

@ -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<MistakeWorkerType>) {
private fun showMistakeList(list: List<MistakeType>) {
binding.splashProgress.visibility = View.GONE
listMistakes = ArrayList()
list.forEach {

View File

@ -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<MistakeWorkerType> = listOf()
var list: List<MistakeType> = listOf()
)
class departmentMistakeList(
var list: List<DepartmentMistake> = listOf()
)
class workerFromMistakeList(
var list: List<WorkerFromMistake> = listOf()
)

View File

@ -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"
>
<LinearLayout
android:id="@+id/lateralLayout"
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@color/verdnatura_warm_grey"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/linearLayout"
@ -82,6 +92,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{item.driver}"
android:textSize="16sp"
android:textColor="@color/verdnatura_white" />
<TextView
@ -89,6 +100,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{String.valueOf(item.id)}"
android:textSize="16sp"
android:textColor="@color/verdnatura_white" />
<LinearLayout

View File

@ -41,7 +41,7 @@
android:text="@{item.longName}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:layout_weight="0.85"
android:gravity="center"/>
<TextView
android:id="@+id/saledate"
@ -50,7 +50,7 @@
android:text="@{item.dated}"
android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white"
android:layout_weight="1"
android:layout_weight="0.85"
android:gravity="center"/>
<TextView
android:layout_width="match_parent"

View File

@ -62,7 +62,7 @@
android:id="@+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{String.valueOf(item.id)}"
android:text="@{String.valueOf(item.client)}"
app:autoSizeMaxTextSize="18sp"
android:textSize="18sp"
android:textColor="@color/verdnatura_white"