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.Locale
fun List<Any?>.formatWithQuotes(): String {
return "[" + joinToString(", ") { if (it is String) "\"$it\"" else it.toString() } + "]"
}
@RequiresApi(Build.VERSION_CODES.N)
fun Any.toast(
context: Context?,
@ -38,10 +38,22 @@ fun <T : Any> T?.notNull(f: (it: T) -> Unit) {
fun EditText.toInt(): Int {
return this.text.toString().toInt()
}
fun EditText.toLong(): Long {
return this.text.toString().toLong()
}
fun toDateString(date: Date):String{
val format = SimpleDateFormat("dd-MM-yyyy", Locale.getDefault())
return format.format(date)
}
fun toDateString(date: Date): String {
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.listSaleSalix
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.Expedition
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.diadeventa.model.ItemShelvingSaleDate
import es.verdnatura.presentation.view.feature.historicoarticulo.model.ItemHistoricoVO
@ -106,6 +109,22 @@ interface SalixService {
@Query("schema") schema: String = "vn"
): 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")
fun executeProc(
@Path("routine") routine: String,
@ -113,6 +132,11 @@ interface SalixService {
@Query("params") params: Any? = null
): Call<Any>
@GET("Routes/getExpeditionSummary")
fun routeGetExpeditionSummary(
@Query("routeFk") params: Int,
): Call<List<ExpeditionInfoSummary>>
@POST("Applications/addNoteFromDelivery/execute-proc")
fun addNote(
@Query("params") params: Any? = null,

View File

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

View File

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

View File

@ -547,8 +547,37 @@ class TicketsFragment(
}
fun showPhones(clientClicked: ClientTicket) {
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()) {
for (t in clientClicked.Phones!!) {

View File

@ -38,26 +38,44 @@ class ExpeditionInfoList(
var list: List<ExpeditionInfoLog> = listOf()
)
data class ExpeditionInfoLog(
var description: String,
var state: String,
var name: String,
var created: String
var created: String,
var routeSalix: RouteSalix
)
class RouteDeliveryList(
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(
var id: Int,
var created: String,
var name: String
var name: String?,
var ticket: TicketSalix,
)
)
class
Expedition(
@ -97,7 +115,6 @@ class ExpeditionInfoPending(
) : Serializable
class ExpeditionSummaryList(
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
) {
silex.expedition_getLog(expedition)
salix.getExpeditionStates(
"""{
"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) {
override fun onSuccess(response: Response<List<ExpeditionInfoLog>>) {
@ -147,10 +169,59 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
fun get_routesFromExpedition(
expedition: Int
) {
silex.get_routesFromExpedition(expedition)
.enqueue(object : SilexCallback<List<RouteDelivery>>(context) {
salix.getRoutesFromExpedition(
filter = """{
"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>>) {
if (response.body() != null) {
_routeInfoList.value =
@ -231,8 +302,10 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
fun route_getExpeditionSummary(
route: Int
) {
silex.route_getExpeditionSummary(route)
.enqueue(object : SilexCallback<List<ExpeditionInfoSummary>>(context) {
//Tarea 6275
//salix.routeGetExpeditionSummary(route)
silex.route_getExpeditionSummary(route)
.enqueue(object : SalixCallback<List<ExpeditionInfoSummary>>(context) {
override fun onSuccess(response: Response<List<ExpeditionInfoSummary>>) {
@ -280,23 +353,17 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
fun getTickets(
routeId: Long
) {
//Tarea 6275
// salix.getTickets("""{"id":$routeId}""")
silex.getTickets(routeId)
.enqueue(object : SilexCallback<MutableList<ClientTicket>>(context) {
.enqueue(object : SalixCallback<MutableList<ClientTicket>>(context) {
override fun onSuccess(response: Response<MutableList<ClientTicket>>) {
if (response.body() != null) {
_clientTicketList.value =
response.body()?.let { ClientTicketList(it) }
} else {
_clientTicketList.value = ClientTicketList()
}
_clientTicketList.value =
response.body()?.let { ClientTicketList(it) }
}
override fun onError(t: Throwable) {
// _clientTicketList.value = ClientTicketList()
_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))
.enqueue(object : SilexCallback<Any>(context) {
override fun onSuccess(response: Response<Any>) {
_response.value = ResponseItemVO(context.getString(R.string.sendRouteOk))
}
override fun onError(t: Throwable) {
_response.value = ResponseItemVO()
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_white
import es.verdnatura.databinding.FragmentHistoricoBinding
import es.verdnatura.domain.isoToString
import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -169,8 +170,7 @@ class HistoricoArticuloFragment(
listHistoryAux.clear()
lista.forEach {
if (it.shipped != null) {
it.shipped =
it.shipped!!.replace("T", " ").substring(0, it.shipped!!.length - 5)
it.shipped = it.shipped!!.isoToString()
}
if (filter.equals("all")) {
listHistoric.add(it)

View File

@ -11,6 +11,7 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentExpeditionTruckListBinding
import es.verdnatura.domain.isoToString
import es.verdnatura.domain.notNull
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -115,10 +116,8 @@ class ExpeditionTruckListFragment :
private fun printExpeditionList(it: ItemExpeditionTruckList) {
binding.splashProgress.visibility = View.GONE
val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
// Tarea#4125 Refactor Destino por description
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!!)
binding.expeditionTruckRecyclerview.adapter = adapter
binding.expeditionTruckRecyclerview.layoutManager = lm
@ -133,7 +132,6 @@ class ExpeditionTruckListFragment :
.isNotEmpty()
) {
customDialogActionTruck()
}
ma.hideKeyboard(customDialogHor.getDestinoEditText())
customDialogHor.dismiss()

View File

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