refs #6275 modify call

This commit is contained in:
Sergio De la torre 2023-12-05 09:57:16 +01:00
parent c24d5b56d8
commit 20539a1c09
10 changed files with 198 additions and 50 deletions

View File

@ -11,10 +11,10 @@ import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
import java.util.Locale import java.util.Locale
fun List<Any?>.formatWithQuotes(): String { fun List<Any?>.formatWithQuotes(): String {
return "[" + joinToString(", ") { if (it is String) "\"$it\"" else it.toString() } + "]" return "[" + joinToString(", ") { if (it is String) "\"$it\"" else it.toString() } + "]"
} }
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
fun Any.toast( fun Any.toast(
context: Context?, context: Context?,
@ -38,10 +38,22 @@ fun <T : Any> T?.notNull(f: (it: T) -> Unit) {
fun EditText.toInt(): Int { fun EditText.toInt(): Int {
return this.text.toString().toInt() return this.text.toString().toInt()
} }
fun EditText.toLong(): Long { fun EditText.toLong(): Long {
return this.text.toString().toLong() return this.text.toString().toLong()
} }
fun toDateString(date: Date):String{
val format = SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()) fun toDateString(date: Date): String {
return format.format(date) val format = SimpleDateFormat("dd-MM-yyyy", Locale.getDefault())
return format.format(date)
}
fun String?.isoToString(): String {
return if (!this.isNullOrEmpty() && this!!.contains("T")) {
this.replace("T", " ").substring(0, 10)
} else if (!this.isNullOrEmpty() && !this!!.contains("T")) {
this
} else {
""
}
} }

View File

@ -13,9 +13,12 @@ import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO
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.controlvehiculo.fragment.model.DeviceId import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.model.DeviceId
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket
import es.verdnatura.presentation.view.feature.delivery.model.DeliveryInfo import es.verdnatura.presentation.view.feature.delivery.model.DeliveryInfo
import es.verdnatura.presentation.view.feature.delivery.model.Expedition
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLog
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
import es.verdnatura.presentation.view.feature.delivery.model.RouteDelivery
import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo
import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate import es.verdnatura.presentation.view.feature.diadeventa.model.ItemShelvingSaleDate
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO
@ -106,6 +109,22 @@ interface SalixService {
@Query("schema") schema: String = "vn" @Query("schema") schema: String = "vn"
): Call<String> ): Call<String>
@GET("ExpeditionStates/filter")
fun getExpeditionStates(
@Query("filter") filter: Any,
): Call<List<ExpeditionInfoLog>>
@GET("Expeditions")
fun getRoutesFromExpedition(
@Query("filter") filter: Any,
): Call<List<RouteDelivery>>
@GET("Routes/getTickets")
fun getTickets(
@Query("filter") filter: Any,
): Call<MutableList<ClientTicket>>
@POST("Applications/{routine}/execute-proc") @POST("Applications/{routine}/execute-proc")
fun executeProc( fun executeProc(
@Path("routine") routine: String, @Path("routine") routine: String,
@ -113,6 +132,11 @@ interface SalixService {
@Query("params") params: Any? = null @Query("params") params: Any? = null
): Call<Any> ): Call<Any>
@GET("Routes/getExpeditionSummary")
fun routeGetExpeditionSummary(
@Query("routeFk") params: Int,
): Call<List<ExpeditionInfoSummary>>
@POST("Applications/addNoteFromDelivery/execute-proc") @POST("Applications/addNoteFromDelivery/execute-proc")
fun addNote( fun addNote(
@Query("params") params: Any? = null, @Query("params") params: Any? = null,

View File

@ -4,6 +4,7 @@ import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemExpeditionlogRowBinding import es.verdnatura.databinding.ItemExpeditionlogRowBinding
import es.verdnatura.domain.isoToString
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLog import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLog
@ -34,6 +35,7 @@ class ExpeditionLogAdapter(
private val res = binding.root.context.resources private val res = binding.root.context.resources
fun bind(item: ExpeditionInfoLog) { fun bind(item: ExpeditionInfoLog) {
binding.apply { binding.apply {
item.created = item.created.isoToString()
this.item = item this.item = item
} }
} }

View File

@ -13,6 +13,7 @@ import androidx.annotation.RequiresApi
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentExpeditionLogDeliveryBinding import es.verdnatura.databinding.FragmentExpeditionLogDeliveryBinding
import es.verdnatura.domain.isoToString
import es.verdnatura.domain.toInt import es.verdnatura.domain.toInt
import es.verdnatura.domain.toast import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
@ -120,7 +121,7 @@ class LogExpeditionFragment(
binding.splashProgress.visibility = View.VISIBLE binding.splashProgress.visibility = View.VISIBLE
try { try {
viewModel.expedition_getLog(binding.scanInput.toInt()) viewModel.expeditionGetLog(binding.scanInput.toInt())
originalItem = binding.scanInput.toInt() originalItem = binding.scanInput.toInt()
binding.mainToolbar.toolbarTitle.text = binding.mainToolbar.toolbarTitle.text =
"""${getString(R.string.expedition)} ${binding.scanInput.text}""" """${getString(R.string.expedition)} ${binding.scanInput.text}"""
@ -159,7 +160,7 @@ class LogExpeditionFragment(
} }
responseStateAdd.observe(viewLifecycleOwner) { responseStateAdd.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = View.GONE binding.splashProgress.visibility = View.GONE
viewModel.expedition_getLog(originalItem) viewModel.expeditionGetLog(originalItem)
} }
} }
} }
@ -198,9 +199,9 @@ class LogExpeditionFragment(
private fun setInfoText(routeDelivery: RouteDelivery) { private fun setInfoText(routeDelivery: RouteDelivery) {
binding.routeLayout.visibility = View.VISIBLE binding.routeLayout.visibility = View.VISIBLE
binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE binding.mainToolbar.toolbarIcons.visibility = View.VISIBLE
binding.route.text = routeDelivery.id.toString() binding.route.text = routeDelivery.ticket.routeFk.toString()
binding.date.text = routeDelivery.created binding.date.text = routeDelivery.ticket.route.created.isoToString()
binding.agency.text = routeDelivery.name binding.agency.text = routeDelivery.ticket.route.agencyMode.agency.name ?: ""
binding.scanInput.setText("") binding.scanInput.setText("")
} }

View File

@ -547,8 +547,37 @@ class TicketsFragment(
} }
fun showPhones(clientClicked: ClientTicket) { fun showPhones(clientClicked: ClientTicket) {
val phones: MutableList<GeneralItem> = mutableListOf() val phones: MutableList<GeneralItem> = mutableListOf()
//Tarea 6275
/*if (clientClicked.clientPhone!=null){
phones.add(
GeneralItem(
text = "${getString(R.string.Cliente)}:$clientClicked.clientPhone",
code =clientClicked.clientMobile
))
}
if (clientClicked.addressMobile!=null){
phones.add(
GeneralItem(
text = "${getString(R.string.Cliente)}:$clientClicked.addressPhone",
code =clientClicked.addressMobile
))
}
if (clientClicked.addressPhone!=null){
phones.add(
GeneralItem(
text = "${getString(R.string.Cliente)}:$clientClicked.addressPhone",
code =clientClicked.addressPhone
))
}
if (!clientClicked.salePersonPhone.isNullOrEmpty())
phones.add(
GeneralItem(
text = "${getString(R.string.comercial)}:${clientClicked.salePersonPhone}",
code =
clientClicked.salePersonPhone.toString()
)
)*/
if (clientClicked.Phones != null && clientClicked.Phones!!.isNotEmpty()) { if (clientClicked.Phones != null && clientClicked.Phones!!.isNotEmpty()) {
for (t in clientClicked.Phones!!) { for (t in clientClicked.Phones!!) {

View File

@ -38,26 +38,44 @@ class ExpeditionInfoList(
var list: List<ExpeditionInfoLog> = listOf() var list: List<ExpeditionInfoLog> = listOf()
) )
data class ExpeditionInfoLog( data class ExpeditionInfoLog(
var description: String, var state: String,
var name: String, var name: String,
var created: String var created: String,
var routeSalix: RouteSalix
) )
class RouteDeliveryList( class RouteDeliveryList(
var list: List<RouteDelivery> = listOf() var list: List<RouteDelivery> = listOf()
) )
data class RouteSalix(
var agencyMode: AgencyModeSalix,
var created: String?
)
data class AgencyModeSalix(
val agency: Agency
)
data class Agency(
var name: String?
)
class TicketSalix(
var id: Int,
var routeFk: Int?,
var route: RouteSalix,
)
class RouteDelivery( class RouteDelivery(
var id: Int, var id: Int,
var created: String, var created: String,
var name: String var name: String?,
var ticket: TicketSalix,
) )
class class
Expedition( Expedition(
@ -97,7 +115,6 @@ class ExpeditionInfoPending(
) : Serializable ) : Serializable
class ExpeditionSummaryList( class ExpeditionSummaryList(
var list: List<ExpeditionInfoSummary> = listOf() var list: List<ExpeditionInfoSummary> = listOf()
) )

View File

@ -102,11 +102,33 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun expedition_getLog( fun expeditionGetLog(
expedition: Int expedition: Int
) { ) {
salix.getExpeditionStates(
silex.expedition_getLog(expedition) """{
"where": {
"expeditionFk": $expedition
},
"include": [
{
"relation": "expeditionStateType",
"scope": {
"fields": [
"id",
"description"
]
}
}
],
"fields": {
"id": true,
"created": true,
"typeFk": true
}
}""".trim()
)
// silex.expedition_getLog(expedition)
.enqueue(object : SilexCallback<List<ExpeditionInfoLog>>(context) { .enqueue(object : SilexCallback<List<ExpeditionInfoLog>>(context) {
override fun onSuccess(response: Response<List<ExpeditionInfoLog>>) { override fun onSuccess(response: Response<List<ExpeditionInfoLog>>) {
@ -147,10 +169,59 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
fun get_routesFromExpedition( fun get_routesFromExpedition(
expedition: Int expedition: Int
) { ) {
salix.getRoutesFromExpedition(
silex.get_routesFromExpedition(expedition) filter = """{
.enqueue(object : SilexCallback<List<RouteDelivery>>(context) { "where": {
"id": $expedition
},
"fields": [
"id",
"ticketFk"
],
"include": [
{
"relation": "ticket",
"scope": {
"include": {
"relation": "route",
"scope": {
"fields": [
"id",
"created",
"agencyModeFk",
"routeFk"
],
"include": {
"relation": "agencyMode",
"scope": {
"include": {
"relation": "agency",
"scope": {
"fields": [
"name"
]
}
},
"fields": [
"id",
"agencyFk"
]
}
}
}
},
"fields": [
"id",
"nickname",
"routeFk"
]
}
}
]
}""".trim()
)
// silex.get_routesFromExpedition(expedition)
.enqueue(object : SalixCallback<List<RouteDelivery>>(context) {
override fun onSuccess(response: Response<List<RouteDelivery>>) { override fun onSuccess(response: Response<List<RouteDelivery>>) {
if (response.body() != null) { if (response.body() != null) {
_routeInfoList.value = _routeInfoList.value =
@ -231,8 +302,10 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
fun route_getExpeditionSummary( fun route_getExpeditionSummary(
route: Int route: Int
) { ) {
silex.route_getExpeditionSummary(route) //Tarea 6275
.enqueue(object : SilexCallback<List<ExpeditionInfoSummary>>(context) { //salix.routeGetExpeditionSummary(route)
silex.route_getExpeditionSummary(route)
.enqueue(object : SalixCallback<List<ExpeditionInfoSummary>>(context) {
override fun onSuccess(response: Response<List<ExpeditionInfoSummary>>) { override fun onSuccess(response: Response<List<ExpeditionInfoSummary>>) {
@ -280,23 +353,17 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
fun getTickets( fun getTickets(
routeId: Long routeId: Long
) { ) {
//Tarea 6275
// salix.getTickets("""{"id":$routeId}""")
silex.getTickets(routeId) silex.getTickets(routeId)
.enqueue(object : SilexCallback<MutableList<ClientTicket>>(context) { .enqueue(object : SalixCallback<MutableList<ClientTicket>>(context) {
override fun onSuccess(response: Response<MutableList<ClientTicket>>) { override fun onSuccess(response: Response<MutableList<ClientTicket>>) {
_clientTicketList.value =
if (response.body() != null) { response.body()?.let { ClientTicketList(it) }
_clientTicketList.value =
response.body()?.let { ClientTicketList(it) }
} else {
_clientTicketList.value = ClientTicketList()
}
} }
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
// _clientTicketList.value = ClientTicketList()
_responseLoadList.value = ResponseItemVO("", true, t.message.toString(), 0) _responseLoadList.value = ResponseItemVO("", true, t.message.toString(), 0)
// super.onError(t)
} }
}) })
@ -308,12 +375,10 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
) { ) {
salix.driverRouteEmail(id = routeId, hashMapOf("recipient" to email)) salix.driverRouteEmail(id = routeId, hashMapOf("recipient" to email))
.enqueue(object : SilexCallback<Any>(context) { .enqueue(object : SilexCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) { override fun onSuccess(response: Response<Any>) {
_response.value = ResponseItemVO(context.getString(R.string.sendRouteOk)) _response.value = ResponseItemVO(context.getString(R.string.sendRouteOk))
} }
override fun onError(t: Throwable) { override fun onError(t: Throwable) {
_response.value = ResponseItemVO() _response.value = ResponseItemVO()
super.onError(t) super.onError(t)

View File

@ -11,6 +11,7 @@ import es.verdnatura.R
import es.verdnatura.R.color.verdnatura_pumpkin_orange import es.verdnatura.R.color.verdnatura_pumpkin_orange
import es.verdnatura.R.color.verdnatura_white import es.verdnatura.R.color.verdnatura_white
import es.verdnatura.databinding.FragmentHistoricoBinding import es.verdnatura.databinding.FragmentHistoricoBinding
import es.verdnatura.domain.isoToString
import es.verdnatura.domain.notNull import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -169,8 +170,7 @@ class HistoricoArticuloFragment(
listHistoryAux.clear() listHistoryAux.clear()
lista.forEach { lista.forEach {
if (it.shipped != null) { if (it.shipped != null) {
it.shipped = it.shipped = it.shipped!!.isoToString()
it.shipped!!.replace("T", " ").substring(0, it.shipped!!.length - 5)
} }
if (filter.equals("all")) { if (filter.equals("all")) {
listHistoric.add(it) listHistoric.add(it)

View File

@ -11,6 +11,7 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentExpeditionTruckListBinding import es.verdnatura.databinding.FragmentExpeditionTruckListBinding
import es.verdnatura.domain.isoToString
import es.verdnatura.domain.notNull import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -115,10 +116,8 @@ class ExpeditionTruckListFragment :
private fun printExpeditionList(it: ItemExpeditionTruckList) { private fun printExpeditionList(it: ItemExpeditionTruckList) {
binding.splashProgress.visibility = View.GONE binding.splashProgress.visibility = View.GONE
val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
// Tarea#4125 Refactor Destino por description
it.list.filter { it.eta != null } it.list.filter { it.eta != null }
.map { it.eta = it.eta.replace("T", " ").substring(0, it.eta.length - 5) } .map { it.eta = it.eta.isoToString()}
adapter = ExpeditionListAdapter(it.list, onTruckClickListener!!) adapter = ExpeditionListAdapter(it.list, onTruckClickListener!!)
binding.expeditionTruckRecyclerview.adapter = adapter binding.expeditionTruckRecyclerview.adapter = adapter
binding.expeditionTruckRecyclerview.layoutManager = lm binding.expeditionTruckRecyclerview.layoutManager = lm
@ -133,7 +132,6 @@ class ExpeditionTruckListFragment :
.isNotEmpty() .isNotEmpty()
) { ) {
customDialogActionTruck() customDialogActionTruck()
} }
ma.hideKeyboard(customDialogHor.getDestinoEditText()) ma.hideKeyboard(customDialogHor.getDestinoEditText())
customDialogHor.dismiss() customDialogHor.dismiss()

View File

@ -47,7 +47,7 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="@{item.description}" android:text="@{item.state}"
android:textSize="@dimen/body2" android:textSize="@dimen/body2"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
android:layout_weight="1.25" android:layout_weight="1.25"