refs #5339
This commit is contained in:
parent
39135845da
commit
5bdf4ab290
|
@ -3,12 +3,15 @@ package es.verdnatura.domain
|
||||||
import es.verdnatura.presentation.common.itemBarCodeSalix
|
import es.verdnatura.presentation.common.itemBarCodeSalix
|
||||||
import es.verdnatura.presentation.common.itemPackingTypeSalix
|
import es.verdnatura.presentation.common.itemPackingTypeSalix
|
||||||
import es.verdnatura.presentation.common.packingSiteSalix
|
import es.verdnatura.presentation.common.packingSiteSalix
|
||||||
|
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.SectorItemVO
|
||||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||||
import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity
|
import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity
|
||||||
import es.verdnatura.presentation.view.feature.collection.listSaleSalix
|
import es.verdnatura.presentation.view.feature.collection.listSaleSalix
|
||||||
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix
|
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix
|
||||||
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
|
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.OperatorUpdate
|
||||||
import es.verdnatura.presentation.view.feature.login.model.SalixGrupo
|
import es.verdnatura.presentation.view.feature.login.model.SalixGrupo
|
||||||
import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
|
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.ItemSupplier
|
||||||
|
@ -191,6 +194,21 @@ interface SalixService {
|
||||||
):
|
):
|
||||||
Call<Any>
|
Call<Any>
|
||||||
|
|
||||||
|
@POST("Operators/udpate")
|
||||||
|
fun update_operator(
|
||||||
|
@Body params: Any,
|
||||||
|
@Query("") update:String
|
||||||
|
|
||||||
|
):
|
||||||
|
Call<Void>
|
||||||
|
@GET("Operators")//NO SALIX
|
||||||
|
fun operator_getData(
|
||||||
|
@Query("filter") filter:String
|
||||||
|
):
|
||||||
|
Call<List<OperatorSalix>>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,4 +219,7 @@ interface SalixServiceSend {
|
||||||
@Body params: SalixGrupo
|
@Body params: SalixGrupo
|
||||||
):
|
):
|
||||||
Call<Boolean>
|
Call<Boolean>
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ interface VerdnaturaService {
|
||||||
Call<List<Train>>
|
Call<List<Train>>
|
||||||
|
|
||||||
@POST("almacennew/worker_getPrinter")//NO SALIX
|
@POST("almacennew/worker_getPrinter")//NO SALIX
|
||||||
|
|
||||||
fun worker_getPrinter(
|
fun worker_getPrinter(
|
||||||
):
|
):
|
||||||
Call<List<Printers>>
|
Call<List<Printers>>
|
||||||
|
|
|
@ -417,6 +417,9 @@ class AjustesFragment :
|
||||||
editor.apply()
|
editor.apply()
|
||||||
|
|
||||||
viewModel.ajustesitem.get(2).selected = it.name
|
viewModel.ajustesitem.get(2).selected = it.name
|
||||||
|
/* viewModel.worker_updatePrinterSalix(
|
||||||
|
it.id!!, getDataInt(USERFK)
|
||||||
|
)*/
|
||||||
viewModel.worker_updatePrinter(
|
viewModel.worker_updatePrinter(
|
||||||
it.id!!
|
it.id!!
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,6 +18,8 @@ import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
import es.verdnatura.presentation.view.feature.ajustes.model.*
|
import es.verdnatura.presentation.view.feature.ajustes.model.*
|
||||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
|
||||||
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList
|
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.OperatorPrinter
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.OperatorUpdate
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
|
|
||||||
|
|
||||||
|
@ -476,6 +478,22 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
fun worker_updatePrinterSalix(printerFk: Int, workerFk : Int) {
|
||||||
|
ProgressLoading(VISIBLE)
|
||||||
|
salix.update_operator(OperatorPrinter(printerFk), "[workerFk]=19591")
|
||||||
|
.enqueue(object : SilexCallback<Void>(context) {
|
||||||
|
override fun onError(t: Throwable) {
|
||||||
|
ProgressLoading(GONE)
|
||||||
|
throw t
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess(response: Response<Void>) {
|
||||||
|
ProgressLoading(GONE)
|
||||||
|
super.onSuccess(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun operator_updateTrain(trainFk: Int) {
|
fun operator_updateTrain(trainFk: Int) {
|
||||||
ProgressLoading(VISIBLE)
|
ProgressLoading(VISIBLE)
|
||||||
|
|
|
@ -320,6 +320,7 @@ class LoginFragment(var imageUri: Uri?) :
|
||||||
viewModel.worker_getId()
|
viewModel.worker_getId()
|
||||||
viewModel.worker_getSector()
|
viewModel.worker_getSector()
|
||||||
viewModel.worker_getPrinter()
|
viewModel.worker_getPrinter()
|
||||||
|
//viewModel.operator_getDataSalix("{\"where\": {\"workerFk\":${getDataInt(USERFK)}}}")
|
||||||
deviceLog_add(
|
deviceLog_add(
|
||||||
getString(R.string.logAppName),
|
getString(R.string.logAppName),
|
||||||
getInfoVersionNameApp(),
|
getInfoVersionNameApp(),
|
||||||
|
@ -419,6 +420,33 @@ class LoginFragment(var imageUri: Uri?) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* loadOperatorList.observe(viewLifecycleOwner, Observer { event ->
|
||||||
|
//binding.splashProgress.visibility = View.GONE
|
||||||
|
|
||||||
|
event.getContentIfNotHandled().notNull {
|
||||||
|
|
||||||
|
if (it.list.isEmpty()) {
|
||||||
|
"No se han podido obtener datos de Salix".toast(context)
|
||||||
|
removePrinter()
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (!it.list.get(0).isError) {
|
||||||
|
saveDataInt(NUMBEROFWAGONS, it.list[0].numberOfWagons)
|
||||||
|
saveDataInt(PRINTERFK, it.list[0].labelerFk!!)
|
||||||
|
saveDataInt(TRAINFK, it.list[0].trainFk)
|
||||||
|
saveData(ITEMPACKINGFK, it.list[0].itemPackingTypeFk)
|
||||||
|
|
||||||
|
//saveData(PRINTERNAME, it.list.get(0).name)
|
||||||
|
} else {
|
||||||
|
it.list.get(0).errorMessage.toast(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})*/
|
||||||
|
|
||||||
|
|
||||||
loadWorkerPrintList.observe(viewLifecycleOwner, Observer { event ->
|
loadWorkerPrintList.observe(viewLifecycleOwner, Observer { event ->
|
||||||
//binding.splashProgress.visibility = View.GONE
|
//binding.splashProgress.visibility = View.GONE
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
|
||||||
import es.verdnatura.presentation.view.feature.ajustes.model.WorkerPrintersList
|
import es.verdnatura.presentation.view.feature.ajustes.model.WorkerPrintersList
|
||||||
import es.verdnatura.presentation.view.feature.login.model.LoginDevice
|
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.LoginSalixVO
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.OperatorList
|
||||||
|
import es.verdnatura.presentation.view.feature.login.model.OperatorSalix
|
||||||
import es.verdnatura.presentation.view.feature.login.model.versionApp
|
import es.verdnatura.presentation.view.feature.login.model.versionApp
|
||||||
import es.verdnatura.presentation.view.feature.login.model.workerId
|
import es.verdnatura.presentation.view.feature.login.model.workerId
|
||||||
import es.verdnatura.presentation.view.feature.paletizador.model.itemsExpeditionDynamics
|
import es.verdnatura.presentation.view.feature.paletizador.model.itemsExpeditionDynamics
|
||||||
|
@ -66,8 +68,10 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
|
|
||||||
|
|
||||||
private val _workerPrintList by lazy { MutableLiveData<WorkerPrintersList>() }
|
private val _workerPrintList by lazy { MutableLiveData<WorkerPrintersList>() }
|
||||||
|
private val _workerOperatorList by lazy { MutableLiveData<OperatorList>() }
|
||||||
|
|
||||||
val loadWorkerPrintList = Transformations.map(_workerPrintList) { Event(it) }
|
val loadWorkerPrintList = Transformations.map(_workerPrintList) { Event(it) }
|
||||||
|
val loadOperatorList = Transformations.map(_workerOperatorList) { Event(it) }
|
||||||
|
|
||||||
fun loginSalix(user: String, password: String) {
|
fun loginSalix(user: String, password: String) {
|
||||||
salix.login(LoginSalixVO(user, password)).enqueue(
|
salix.login(LoginSalixVO(user, password)).enqueue(
|
||||||
|
@ -168,6 +172,7 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
val prefs = app.getPrefs()
|
val prefs = app.getPrefs()
|
||||||
response.body()?.let { prefs.putInt("userFk", it) }
|
response.body()?.let { prefs.putInt("userFk", it) }
|
||||||
prefs.commit()
|
prefs.commit()
|
||||||
|
operator_getDataSalix("{\"where\": {\"workerFk\":${response.body()?.let {it}}}}")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,4 +419,50 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
fun operator_getDataSalix(
|
||||||
|
workerId:String
|
||||||
|
) {
|
||||||
|
|
||||||
|
salix.operator_getData(workerId)
|
||||||
|
.enqueue(object : SilexCallback<List<OperatorSalix>>(context) {
|
||||||
|
override fun onError(t: Throwable) {
|
||||||
|
val listError: ArrayList<OperatorSalix> = ArrayList()
|
||||||
|
listError.add(
|
||||||
|
OperatorSalix(
|
||||||
|
isError = true,
|
||||||
|
errorMessage = getMessageFromAllResponse(
|
||||||
|
nameofFunction(this),
|
||||||
|
t.message!!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_workerOperatorList.value = OperatorList(listError)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess(response: Response<List<OperatorSalix>>) {
|
||||||
|
if (response.body() != null) {
|
||||||
|
_workerOperatorList.value = response.body()?.let {
|
||||||
|
OperatorList(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
val listError: ArrayList<OperatorSalix> = ArrayList()
|
||||||
|
listError.add(
|
||||||
|
OperatorSalix(
|
||||||
|
isError = true,
|
||||||
|
errorMessage = getMessageFromAllResponse(
|
||||||
|
nameofFunction(this),
|
||||||
|
response.message()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
_workerOperatorList.value = OperatorList(listError)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,33 @@ class SalixGrupo(
|
||||||
val message: String = ""
|
val message: String = ""
|
||||||
|
|
||||||
)
|
)
|
||||||
|
class OperatorSalix(
|
||||||
|
val workerFk: Int = 0,
|
||||||
|
val sectorFk: Int = 0,
|
||||||
|
val labelerFk: Int = 0,
|
||||||
|
val numberOfWagons: Int = 0,
|
||||||
|
val trainFk: Int = 0,
|
||||||
|
val warehouseFk: Int = 0,
|
||||||
|
var itemPackingTypeFk: String = "",
|
||||||
|
val isError: Boolean = false,
|
||||||
|
var errorMessage: String = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
class OperatorList(
|
||||||
|
var list: List<OperatorSalix> = listOf()
|
||||||
|
)
|
||||||
|
|
||||||
|
class OperatorSector(
|
||||||
|
val sectorFk: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
class OperatorPrinter(
|
||||||
|
val labelerFk: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
class OperatorUpdate(
|
||||||
|
val update: String
|
||||||
|
)
|
||||||
|
|
||||||
class versionApp(
|
class versionApp(
|
||||||
val appname: String = "",
|
val appname: String = "",
|
||||||
|
|
Loading…
Reference in New Issue