feat nameWorker refs #7597

This commit is contained in:
Sergio De la torre 2024-06-27 07:04:33 +02:00
parent f48aea9414
commit fb421bd6cb
8 changed files with 59 additions and 15 deletions

View File

@ -38,6 +38,7 @@ import es.verdnatura.presentation.view.feature.login.model.LoginApp
import es.verdnatura.presentation.view.feature.login.model.LoginAppData
import es.verdnatura.presentation.view.feature.login.model.LoginDevice
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
import es.verdnatura.presentation.view.feature.login.model.NameWorker
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
import es.verdnatura.presentation.view.feature.login.model.RenewToken
import es.verdnatura.presentation.view.feature.login.model.SalixGrupo
@ -169,6 +170,11 @@ interface SalixService {
fun getRoutes(
): Call<MutableList<RouteInfo>>
@GET("Workers/findOne")
fun getNameWorker(
@Query("filter") filter: String
): Call<NameWorker>
@POST("Applications/{routine}/execute-proc")
fun executeProc(
@Path("routine") routine: String,

View File

@ -80,6 +80,7 @@ class ControlVehiculoUsuarioFragment(
private fun setControlVehicleUser() {
userFk = mobileApplication.userId!!
println("userFK $userFk")
if (userFk == vUserFK) {
val androidId: String = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID)
@ -96,6 +97,7 @@ class ControlVehiculoUsuarioFragment(
binding.nameVehiclecontrol.visibility = INVISIBLE
binding.userImage.setOnClickListener { binding.mainToolbar.backButton.performClick() }
viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
viewModel.getNameWorker(userFk)
}
binding.userImage.loadUrl(
@ -127,30 +129,29 @@ class ControlVehiculoUsuarioFragment(
responsemachine.observe(viewLifecycleOwner) {
if (it.response == "false") {
if (it.type == "getWorker") {
binding.assignedDevicename.text =
getString(R.string.noAssigned)
}
} else {
if (it.response == "false") {
if (it.type == "getWorker") {
binding.assignedDevicename.text =
getString(R.string.noAssigned)
}
} else {
when (it.type) {
"getnameDevice" -> binding.deviceName.text = it.response
"getWorker" -> binding.assignedDevicename.text =
it.response
"getWorkerPlate" -> binding.registeredVehiclecontrol.text = it.response
}
when (it.type) {
"getnameDevice" -> binding.deviceName.text = it.response
"getWorker" -> binding.assignedDevicename.text =
it.response
"getWorkerPlate" -> binding.registeredVehiclecontrol.text = it.response
}
}
}
responseGetExtensionFromUserId.observe(viewLifecycleOwner) {
if (it!="") {
if (it != "") {
ma.messageWithSound(
getString(R.string.noSIP) +"."+ getString(R.string.user) + vUserFK,
getString(R.string.noSIP) + "." + getString(R.string.user) + vUserFK,
isError = true,
true
)
@ -160,6 +161,16 @@ class ControlVehiculoUsuarioFragment(
}
}
responseGetName.observe(viewLifecycleOwner) {
binding.nameVehiclecontrol.text =
getString(
R.string.txtName,
it.firstName,
it.lastName
)
binding.nameVehiclecontrol.visibility = VISIBLE
}
}

View File

@ -13,6 +13,7 @@ import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.ResponseItemMachineControl
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.model.DeviceId
import es.verdnatura.presentation.view.feature.login.model.NameWorker
import org.json.JSONObject
import retrofit2.Response
@ -33,6 +34,9 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) {
private val _responseGetExtensionFromUserId by lazy { MutableLiveData<Any>() }
val responseGetExtensionFromUserId: LiveData<Any>
get() = _responseGetExtensionFromUserId
private val _responseGetName by lazy { MutableLiveData<NameWorker>() }
val responseGetName: LiveData<NameWorker> = _responseGetName
fun machineWorkerUpdate(
plate: String
) {
@ -188,6 +192,24 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun getNameWorker(
workerId: Int
) {
salix.getNameWorker(
"""{"fields": ["firstName","lastName"],"where": {"id":$workerId}}"""
).enqueue(object : SalixCallback<NameWorker>(context) {
override fun onSuccess(response: Response<NameWorker>) {
_responseGetName.value = response.body()
}
override fun onError(t: Throwable) {
}
})
}
fun sipGetExtensionSalix(
workerId: Int
) {

View File

@ -32,6 +32,7 @@
android:layout_marginTop="@dimen/toolbar_height"
android:hint="@string/nameUser"
android:textColor="@color/verdnatura_white"
android:gravity="center"
android:textSize="@dimen/h5"
android:textStyle="bold" />

View File

@ -834,5 +834,6 @@
<string name="reviewBoxPicking">Revisar sacado por cajas</string>
<string name="pendingAmount">Hoy quedan por salir %1$x unidades</string>
<string name="errorInputQuantity">Error al introducir cantidad</string>
<string name="txtName">%1$s %2$s</string>
</resources>

View File

@ -834,5 +834,6 @@
<string name="reviewBoxPicking">Revisar sacado por cajas</string>
<string name="pendingAmount">Hoy quedan por salir %1$x unidades</string>
<string name="errorInputQuantity">Error al introducir cantidad</string>
<string name="txtName">%1$s %2$s</string>
</resources>

View File

@ -834,5 +834,6 @@
<string name="reviewBoxPicking">Revisar sacado por cajas</string>
<string name="pendingAmount">Hoy quedan por salir %1$x unidades</string>
<string name="errorInputQuantity">Error al introducir cantidad</string>
<string name="txtName">%1$s %2$s</string>
</resources>

View File

@ -836,5 +836,6 @@
<string name="reviewBoxPicking">Revisar sacado por cajas</string>
<string name="pendingAmount">Hoy quedan por salir %1$x unidades</string>
<string name="errorInputQuantity">Error al introducir cantidad</string>
<string name="txtName">%1$s %2$s</string>
</resources>