refs #6276 feat:silex →salix

This commit is contained in:
Sergio De la torre 2024-03-14 07:10:36 +01:00
parent 817ac7750b
commit 38d940fde4
14 changed files with 137 additions and 85 deletions

View File

@ -36,8 +36,8 @@ 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.RenewToken
import es.verdnatura.presentation.view.feature.login.model.SalixGrupo
import es.verdnatura.presentation.view.feature.login.model.VersionApp
import es.verdnatura.presentation.view.feature.login.model.accessConfigSalix
import es.verdnatura.presentation.view.feature.login.model.versionApp
import es.verdnatura.presentation.view.feature.main.model.WorkerActionSalix
import es.verdnatura.presentation.view.feature.packaging.model.EntrySalix
import es.verdnatura.presentation.view.feature.packaging.model.ItemSupplier
@ -45,6 +45,7 @@ import es.verdnatura.presentation.view.feature.packaging.model.Supplier
import es.verdnatura.presentation.view.feature.packaging.model.notificationQueue
import es.verdnatura.presentation.view.feature.packaging.model.obervationEntry
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionScanVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckSalix
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletViewVO
@ -276,8 +277,15 @@ interface SalixService {
@Query("expeditionFk") expeditionFk: Number,
): Call<ItemExpeditionTruckVO>
@GET("Operators/getPrinter")//NO SALIX
fun getprinters():
@GET("ExpeditionPallets")//REVISADA
fun expeditionPalletGet(
@Query("filter") filter: Any?,
): Call<List<ItemExpeditionTruckSalix>>
@GET("Printers")//NO SALIX
fun getprinters(
@Query("filter") filter: Any?
):
Call<List<Printers>>
@GET("Collections/getSalesFromTicketOrCollection")//REVISADA
@ -303,8 +311,8 @@ interface SalixService {
):
Call<List<PreSacadorItemVO>>
@POST("Collections/addItem")//REVISADA
fun collectionAddItem(
@POST("Tickets/addSaleByCode")//REVISADA
fun addSaleByCode(
@Body params: Any
):
Call<Any>
@ -362,15 +370,21 @@ interface SalixService {
):
Call<ArrayList<Reubication>>
@GET("ItemShelvings/getAlternative")
fun itemShelvingAlternative(
@Query("shelvingFk") shelvingFk: String
):
Call<ArrayList<Reubication>>
@GET("MobileAppVersionControls/getVersion")//REVISADA
fun getVersion(
@Query("app") app: String
):
Call<versionApp>
Call<VersionApp>
@GET("Items/card")//NO SALIX
@GET("Items/get")//NO SALIX
fun getCard(
@Query("itemFk") itemFk: Number,
@Query("barcode") barcode: Number,
@Query("warehouseFk") warehouseFk: Int
):
Call<ItemCardVO>
@ -709,7 +723,6 @@ interface SalixService {
):
Call<EntrySalix>
@POST("tickets/{idTicket}/transferSales") //-->saleMove en Silex
fun transferSalesSalix(
@Path("idTicket") idTicket: String, @Body params: listSaleSalix
@ -819,18 +832,18 @@ interface SalixService {
fun getSuppliers(
//@Query("filter") filter:String="""{"fields":{"id":true,"name":true}}"""
//@Body params:JSONObject=JSONObject("""filter"={"fields":{"id":true,"name":true},"include":[{"relation":"contacts","scope":{"fields":["email"],"order":"id DESC","limit":1,"where":{"email":{"neq":null}}}}]}""")
@Query("filter") filter:String = """{"fields":{"id":true,"name":true},"order":"name ASC","where":{"isActive":1,"name":{"neq":null}}, "include":[{"relation":"contacts","scope":{"fields":["email"],"where":{"email":{"neq":null}}}}]}"""
/* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," +
"\"scope\":{" +
"\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," +
"\"where\":{ \"email\":{\"neq\":null } }}}]})"*/
//@Query("filter") filter:String? = """""\"order\":\"name DESC\""""
@Query("filter") filter: String = """{"fields":{"id":true,"name":true},"order":"name ASC","where":{"isActive":1,"name":{"neq":null}}, "include":[{"relation":"contacts","scope":{"fields":["email"],"where":{"email":{"neq":null}}}}]}"""
/* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," +
"\"scope\":{" +
"\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," +
"\"where\":{ \"email\":{\"neq\":null } }}}]})"*/
//@Query("filter") filter:String? = """""\"order\":\"name DESC\""""
): Call<List<Supplier>>
/* fun getEntries(
//@Body params:JSONObject=JSONObject("""filter"={"fields":{"id":true,"name":true},"include":[{"relation":"contacts","scope":{"fields":["email"],"order":"id DESC","limit":1,"where":{"email":{"neq":null}}}}]}""")
*//* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," +
/* fun getEntries(
//@Body params:JSONObject=JSONObject("""filter"={"fields":{"id":true,"name":true},"include":[{"relation":"contacts","scope":{"fields":["email"],"order":"id DESC","limit":1,"where":{"email":{"neq":null}}}}]}""")
*//* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," +
"\"scope\":{" +
"\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," +
"\"where\":{ \"email\":{\"neq\":null } }}}]})"*//*
@ -846,20 +859,19 @@ interface SalixService {
@GET("Entries")//REVISADA
fun getEntries_fromSupplier(
@Query("filter") filter:String
@Query("filter") filter: String
):
Call<List<EntrySalix>>
@GET("Entries")//REVISADA
fun add_entry(
@Body entry:EntrySalix
@Body entry: EntrySalix
):
Call<EntrySalix>
@PATCH("Entries/{entryId}")//REVISADA
fun entry_updateObserv(
@Path("entryId") entryId:Int,
@Path("entryId") entryId: Int,
@Body entry: obervationEntry
):
Call<EntrySalix>

View File

@ -58,7 +58,7 @@ data class BackSalixCall(
)
data class CollectionItemSalix(
var code: Int,
var barcode: String,
var quantity: Int,
var ticketFk: Int,
var warehouseFk: Int

View File

@ -86,7 +86,8 @@ class AjustesFragment :
getString(R.string.closeSession) -> ma.onMyBackPressed()
getString(R.string.printerLabel) -> {
messagePrinter = getString(R.string.SelectPrinter)
viewModel.printerGet()
viewModel.printerGet(mobileApplication.dataStoreApp.readDataStoreKey(
SECTORFK))
}
getString(R.string.vehicleControl) -> ma.onPasillerosItemClickListener(
@ -132,7 +133,7 @@ class AjustesFragment :
messagePrinter =
getString(R.string.SelectPrinter) + "\n" + getString(R.string.printerRemoved)
viewModel.printerGet()
viewModel.printerGet(mobileApplication.dataStoreApp.readDataStoreKey(SECTORFK))
}
}

View File

@ -174,10 +174,12 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun printerGet() {
fun printerGet(sectorFk:Int) {
//Tarea 6276
//salix.getprinters().enqueue(object : SalixCallback<List<Printers>>(context) {
silex.printer_get().enqueue(object : SalixCallback<List<Printers>>(context) {
salix.getprinters(
"""{"fields":["id","name"],"where":{"sectorFk":$sectorFk,"isLabeler":{"neq":false}}}"""
).enqueue(object : SalixCallback<List<Printers>>(context) {
//silex.printer_get().enqueue(object : SalixCallback<List<Printers>>(context) {
override fun onSuccess(response: Response<List<Printers>>) {
_printerList.value = response.body()?.let { PrintersList(it) }
}

View File

@ -17,7 +17,13 @@ import es.verdnatura.databinding.FragmentItemCardBinding
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnClickDynamic
import es.verdnatura.presentation.common.OnItemCardRowClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.common.loadUrl
import es.verdnatura.presentation.view.component.CustomDialogDynamicButtons
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogList
@ -678,6 +684,8 @@ class ItemCardFragment(
}
listBarcodes.removeAt(posDelete)
//Tarea 6276
viewModel.barcodesEdit(
itemFk = itemInfoG!!.id,
value = code,

View File

@ -55,7 +55,7 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
warehouseFk: Int,
) {
//Tarea 6276
// salix.getCard(itemFk = itemFk, warehouseFk = warehouseFk)
//salix.getCard(barcode = itemFk, warehouseFk = warehouseFk)
silex.getItemCard(itemFk, warehouseFk)
.enqueue(object : SalixCallback<ItemCardVO>(context) {
override fun onError(t: Throwable) {
@ -247,9 +247,9 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
value: String,
delete: Boolean
) {
//Tarea 6276
//Tarea 6276 OK
//salix.barcodesDelete(itemFk = itemFk, barcode = value)
silex.barcodes_edit(value, itemFk, delete)
silex.barcodes_edit(value, itemFk, delete)
.enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) {
_response.value = ResponseItemVO(

View File

@ -39,7 +39,7 @@ import es.verdnatura.presentation.view.feature.login.adapter.WorkFormAdapter
import es.verdnatura.presentation.view.feature.login.model.WorkForms
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import kotlinx.coroutines.runBlocking
import java.util.*
import java.util.Date
import kotlin.system.exitProcess
class LoginFragment(var imageUri: Uri?) :
@ -75,7 +75,17 @@ class LoginFragment(var imageUri: Uri?) :
if (mobileApplication.dataStoreApp.readDataStoreKey<String>(TOKEN)
.isNotBlank() && binding.switchRemember.isChecked
) {
viewModel.operator_add()
//viewModel.operator_add()
if (getDevicePDA() != null) {
viewModel.getSerialNumber(getDevicePDA()!!)
} else {
viewModel.getCurrentUserData(
getString(R.string.logAppName),
getInfoVersionNameApp(),
mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID),
)
}
}
binding.textviewRememberPassword.setOnClickListener {
@ -342,7 +352,7 @@ class LoginFragment(var imageUri: Uri?) :
}
}
if (it.IsVersionCritical == 1) {
if (it.isVersionCritical == 1) {
customDialog.setDescription(getString(R.string.updatecritical))
} else {
customDialog.setKoButton(getString(R.string.cancel)) {
@ -440,17 +450,6 @@ class LoginFragment(var imageUri: Uri?) :
}.show()
}
//Retrocompatibilidad y asegurarnos que no se meten strings
if (getDevicePDA() != null) {
viewModel.getSerialNumber(getDevicePDA()!!)
} else {
viewModel.getCurrentUserData(
getString(R.string.logAppName),
getInfoVersionNameApp(),
mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID),
)
}
}
devicelogresponse.observe(viewLifecycleOwner) {
@ -516,7 +515,17 @@ class LoginFragment(var imageUri: Uri?) :
)
}
viewModel.operator_add()
// viewModel.operator_add()
if (getDevicePDA() != null) {
viewModel.getSerialNumber(getDevicePDA()!!)
} else {
viewModel.getCurrentUserData(
getString(R.string.logAppName),
getInfoVersionNameApp(),
mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID),
)
}
} else {
it.list[0].errorMessage.toast(context)

View File

@ -25,9 +25,9 @@ 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.OperatorSalix
import es.verdnatura.presentation.view.feature.login.model.RenewToken
import es.verdnatura.presentation.view.feature.login.model.VersionApp
import es.verdnatura.presentation.view.feature.login.model.accessConfigSalix
import es.verdnatura.presentation.view.feature.login.model.accessConfigSalixList
import es.verdnatura.presentation.view.feature.login.model.versionApp
import es.verdnatura.presentation.view.feature.paletizador.model.itemsExpeditionDynamics
import kotlinx.coroutines.runBlocking
import retrofit2.Response
@ -49,8 +49,8 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
private val _serialNumber by lazy { MutableLiveData<String?>() }
val serialNumber: LiveData<String?> = _serialNumber
private val _versionappitem by lazy { MutableLiveData<versionApp>() }
val versionappitem: LiveData<versionApp>
private val _versionappitem by lazy { MutableLiveData<VersionApp>() }
val versionappitem: LiveData<VersionApp>
get() = _versionappitem
private val _logindevice by lazy { MutableLiveData<LoginDevice>() }
@ -157,6 +157,7 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
serialnumber = serialNumber
)
//Tarea 5870
operator_add(app.userId)
operator_getDataSalix(app.userId!!)
deviceCheckLogin(app.userId!!, androidId)
}
@ -199,16 +200,19 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
}
fun checkVersion(nameApp: String) {
//Tarea 6276
// salix.getVersion(nameApp)
silex.getVersion(nameApp).enqueue(object : SilexCallback<versionApp>(context) {
override fun onSuccess(response: Response<versionApp>) {
//Tarea 6276 Modificado back
//cambiar "isVersionCritical": false a Boolean
//salix.getVersion(nameApp)
silex.getVersion(nameApp)
//.enqueue(object : SalixCallback<versionApp>(context) {
.enqueue(object : SilexCallback<VersionApp>(context) {
override fun onSuccess(response: Response<VersionApp>) {
if (response.body() != null) {
_versionappitem.value = response.body()?.let {
versionApp(
VersionApp(
it.appname,
it.version,
it.IsVersionCritical,
it.isVersionCritical,
it.url,
isError = false,
errorMessage = ""
@ -217,7 +221,7 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
}
} else {
_versionappitem.value = versionApp(
_versionappitem.value = VersionApp(
"", "", isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), response.message()
)
@ -226,7 +230,7 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
}
override fun onError(t: Throwable) {
_versionappitem.value = versionApp(
_versionappitem.value = VersionApp(
nameApp, "", isError = true, errorMessage = getMessageFromAllResponse(
nameofFunction(this), t.message!!
)
@ -248,11 +252,13 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
return list
}
fun operator_add() {
fun operator_add(workerFk:Int? = null) {
//Tarea 6276
//salix.operatorAdd().enqueue(object : SalixCallback<Any>(context) {
silex.operator_add().enqueue(object : SilexCallback<Any>(context) {
salix.operatorAdd(hashMapOf("workerFk" to workerFk))
.enqueue(object : SalixCallback<Any>(context) {
override fun onError(t: Throwable) {
if (!(t.message!!.contains("ER_DUP_ENTRY")))
_operatorAdd.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
@ -355,7 +361,7 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
TOKEN, renewToken!!.id
)
(context).dataStoreApp.editDataStoreKey(
TTL, renewToken!!.ttl
TTL, renewToken.ttl
)
(context).dataStoreApp.editDataStoreKey(
TOKENCREATED, Date().time

View File

@ -75,10 +75,10 @@ class Operator(
)
class versionApp(
class VersionApp(
val appname: String = "",
val version: String = "",
var IsVersionCritical: Int = 0,
var isVersionCritical: Int = 0,
var url: String? = null,
var isError: Boolean = false,
var errorMessage: String = ""

View File

@ -8,6 +8,7 @@ import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
class PalletScanFragment(
@ -72,7 +73,7 @@ class PalletScanFragment(
ma.messageWithSound(getString(R.string.palletScanned) + itemScaned, false, true)
ma.onComprobarPalletFromPalletScan(
it, ItemPalletVO(Pallet = itemScaned)
ItemExpeditionTruckVO(it.truckFk), ItemPalletVO(Pallet = itemScaned)
)
customDialogList.dismiss()

View File

@ -9,7 +9,7 @@ import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.base.getMessageFromAllResponse
import es.verdnatura.presentation.base.nameofFunction
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckSalix
import retrofit2.Response
class PalletScanViewModel(val context: Context) : BaseViewModel(context) {
@ -18,8 +18,8 @@ class PalletScanViewModel(val context: Context) : BaseViewModel(context) {
val responseScan: LiveData<ResponseItemVO>
get() = _responseScan
private val _responsePalletGet by lazy { MutableLiveData<ItemExpeditionTruckVO>() }
val responsePalletGet: LiveData<ItemExpeditionTruckVO>
private val _responsePalletGet by lazy { MutableLiveData<ItemExpeditionTruckSalix>() }
val responsePalletGet: LiveData<ItemExpeditionTruckSalix>
get() = _responsePalletGet
fun expeditionStateAddByPallet(
@ -52,14 +52,13 @@ class PalletScanViewModel(val context: Context) : BaseViewModel(context) {
fun expeditionPalletGet(vPalletId: Int) {
//Tarea 6276
//salix.expeditionPalletGetPallet(vPalletId)
salix.expeditionPalletGet("""{"fields": ["truckFk"], "where": {"id": $vPalletId}, "include": [{"relation": "expeditionTruck", "scope": {"fields": ["eta", "description"]}}]}""")
// silex.expeditionPallet_get(vPalletId)
.enqueue(object : SalixCallback<List<ItemExpeditionTruckSalix>>(context) {
silex.expeditionPallet_get(vPalletId)
.enqueue(object : SalixCallback<ItemExpeditionTruckVO>(context) {
override fun onSuccess(response: Response<ItemExpeditionTruckVO>) {
_responsePalletGet.value =
response.body()!!
override fun onSuccess(response: Response<List<ItemExpeditionTruckSalix>>) {
_responsePalletGet.value =
response.body()!![0]
}

View File

@ -13,6 +13,17 @@ class ItemExpeditionTruckVO(
var isError: Boolean = false,
var errorMessage: String = ""
)
data class ItemExpeditionTruckSalix(
var truckFk: Int,
var expeditionTruck:ItemExpedition)
data class ItemExpedition (
var id: Int,
var eta: String? = "",
var description: String = ""
)
data class ExpeditionTruckSalix(val eta:String,val description: String)
class ItemExpeditionTruckList(

View File

@ -1,5 +1,6 @@
package es.verdnatura.presentation.view.feature.reubication.model
import com.google.gson.annotations.SerializedName
class ReubicationList(
var list: ArrayList<Reubication> = arrayListOf()
@ -12,6 +13,7 @@ class Reubication(
var itemFk: String = "",//ok
var longName: String = "",//ok
var quantity: String = "", //=quantity
@SerializedName(value = "carros", alternate = ["shelvings"])
var carros: MutableList<PlacementReubication> = mutableListOf(),//placements
var pickingOrder:Int=0,//no
var isError: Boolean=false,

View File

@ -214,7 +214,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
shelving: String,
parking: String
) {
salix.hasItemOlder(shelving,parking)
salix.hasItemOlder(shelving, parking)
.enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
@ -264,16 +264,17 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
fun shelvinLog_add(
code: String
) {
//Tarea 6276
// salix.shelvingLogAdd(hashMapOf("code" to code))
silex.shelvingLog_add(code).enqueue(object : SalixCallback<Any>(context) {
//Tarea 6276 OK
//salix.shelvingLogAdd(hashMapOf("code" to code))
silex.shelvingLog_add(code)
.enqueue(object : SalixCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_responseLog.value =
ResponseItemVO(isError = false, response = response.message()!!)
}
override fun onSuccess(response: Response<Any>) {
_responseLog.value =
ResponseItemVO(isError = false, response = response.message()!!)
}
})
})
}
fun itemShelving_return(
@ -281,7 +282,7 @@ class UbicadorViewModel(val context: Context) : BaseViewModel(context) {
) {
//Tarea 6276
// salix.itemShelvingReturn(shelvingFk)
// salix.itemShelvingAlternative(shelvingFk)
silex.itemShelving_return(shelvingFk)
.enqueue(object : SilexCallback<ArrayList<Reubication>>(context) {
override fun onError(t: Throwable) {