refs #6275 feat: back to Salix

This commit is contained in:
Sergio De la torre 2024-01-09 08:47:16 +01:00
parent ec6d1fd4af
commit c264406f0e
11 changed files with 145 additions and 122 deletions

View File

@ -4,7 +4,7 @@ import android.content.Context
import androidx.room.* import androidx.room.*
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix
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.ExpeditionInfoPending import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoPending
import es.verdnatura.presentation.view.feature.delivery.model.MyLocation import es.verdnatura.presentation.view.feature.delivery.model.MyLocation
@ -17,7 +17,7 @@ import java.util.Date
// Clase que representa la base de datos // Clase que representa la base de datos
@Database( @Database(
entities = [ExpeditionInfoLoadUnload::class, ExpeditionInfoPending::class, SignedTickets::class, RouteInfo::class, ClientTicket::class, RouteLoaded::class], entities = [ExpeditionInfoLoadUnload::class, ExpeditionInfoPending::class, SignedTickets::class, RouteInfo::class, ClientTicketSalix::class, RouteLoaded::class],
version = 1 version = 1
) )
@TypeConverters(MapTypeConverter::class) @TypeConverters(MapTypeConverter::class)
@ -114,10 +114,10 @@ interface RoutesDao {
@Dao @Dao
interface ClientTicketDao { interface ClientTicketDao {
@Query("SELECT * FROM clientTickets ") @Query("SELECT * FROM clientTickets ")
suspend fun getAll(): List<ClientTicket> suspend fun getAll(): List<ClientTicketSalix>
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(routes: List<ClientTicket>) suspend fun insert(routes: List<ClientTicketSalix>)
@Query("DELETE FROM clientTickets ") @Query("DELETE FROM clientTickets ")
suspend fun delete() suspend fun delete()

View File

@ -15,7 +15,7 @@ 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.ClientTicketSalix
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.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.ExpeditionInfoLog
@ -129,7 +129,7 @@ interface SalixService {
@GET("Routes/getTickets") @GET("Routes/getTickets")
fun getTickets( fun getTickets(
@Query("filter") filter: Any, @Query("filter") filter: Any,
): Call<MutableList<ClientTicket>> ): Call<MutableList<ClientTicketSalix>>
@GET("Routes/getByWorker") @GET("Routes/getByWorker")
fun getRoutes( fun getRoutes(

View File

@ -1,7 +1,6 @@
package es.verdnatura.presentation.view.feature.delivery.activity package es.verdnatura.presentation.view.feature.delivery.activity
import android.Manifest import android.Manifest
import android.content.DialogInterface
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.graphics.Bitmap import android.graphics.Bitmap
import android.location.Location import android.location.Location
@ -21,7 +20,7 @@ import es.verdnatura.presentation.base.BaseActivity
import es.verdnatura.presentation.base.LocationUpdateCallback import es.verdnatura.presentation.base.LocationUpdateCallback
import es.verdnatura.presentation.base.database import es.verdnatura.presentation.base.database
import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix
import es.verdnatura.presentation.view.feature.delivery.model.MyLocation import es.verdnatura.presentation.view.feature.delivery.model.MyLocation
import es.verdnatura.presentation.view.feature.delivery.model.SignedTickets import es.verdnatura.presentation.view.feature.delivery.model.SignedTickets
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
@ -44,7 +43,7 @@ class SignedActivity : BaseActivity<ActivitySignBinding>(), LocationUpdateCallba
private lateinit var fusedLocationClient: com.google.android.gms.location.FusedLocationProviderClient private lateinit var fusedLocationClient: com.google.android.gms.location.FusedLocationProviderClient
private var lastLocationCurrent: MyLocation = MyLocation(0.0, 0.0) private var lastLocationCurrent: MyLocation = MyLocation(0.0, 0.0)
private lateinit var ticketsSet: HashSet<Long> private lateinit var ticketsSet: HashSet<Long>
private lateinit var clientTicket: ClientTicket private lateinit var clientTicket: ClientTicketSalix
private lateinit var db: DeliveryDatabase private lateinit var db: DeliveryDatabase
override fun init() { override fun init() {
@ -53,7 +52,7 @@ class SignedActivity : BaseActivity<ActivitySignBinding>(), LocationUpdateCallba
"ticket" -> { "ticket" -> {
binding.mainToolbar.toolbarTitle.text = getString(R.string.sign) binding.mainToolbar.toolbarTitle.text = getString(R.string.sign)
clientTicket = intent.extras!!.getSerializable("clientTicketList") as ClientTicket clientTicket = intent.extras!!.getSerializable("clientTicketList") as ClientTicketSalix
setViews(clientTicket) setViews(clientTicket)
setLocation() setLocation()
} }
@ -91,12 +90,12 @@ class SignedActivity : BaseActivity<ActivitySignBinding>(), LocationUpdateCallba
this.longitude = lastLocationCurrent.Longitude this.longitude = lastLocationCurrent.Longitude
} }
val locationClient = Location("").apply { val locationClient = Location("").apply {
this.latitude = clientTicket.Latitude ?: 0.0 this.latitude = clientTicket.latitude ?: 0.0
this.longitude = clientTicket.Longitude ?: 0.0 this.longitude = clientTicket.longitude ?: 0.0
} }
if (clientTicket.Latitude != null && clientTicket.Longitude != null) { if (clientTicket.latitude != null && clientTicket.longitude != null) {
if (locationCurrent.distanceTo(locationClient) > 100 ) { if (locationCurrent.distanceTo(locationClient) > 100 ) {
val customDialogDistance = CustomDialog(this) val customDialogDistance = CustomDialog(this)
@ -154,11 +153,11 @@ class SignedActivity : BaseActivity<ActivitySignBinding>(), LocationUpdateCallba
} }
private fun setViews(clientTicketList: ClientTicket) { private fun setViews(clientTicketList: ClientTicketSalix) {
if (clientTicketList != null) { if (clientTicketList != null) {
binding.nameAddress.text = clientTicketList.ClientName binding.nameAddress.text = clientTicketList.nickname
ticketsSet = HashSet() ticketsSet = HashSet()
var sum = 0 var sum = 0
for (exp in clientTicketList.tickets) { for (exp in clientTicketList.tickets) {

View File

@ -11,11 +11,10 @@ import es.verdnatura.R
import es.verdnatura.databinding.ItemTicketRowBinding import es.verdnatura.databinding.ItemTicketRowBinding
import es.verdnatura.presentation.common.OnItemButtonCMRRowClickListener import es.verdnatura.presentation.common.OnItemButtonCMRRowClickListener
import es.verdnatura.presentation.common.OnItemButtonTicketRowClickListener import es.verdnatura.presentation.common.OnItemButtonTicketRowClickListener
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix
class TicketAdapter( class TicketAdapter(
private var items: MutableList<ClientTicket>, private var items: MutableList<ClientTicketSalix>,
private val onItemButtonTicketRowClickListener: OnItemButtonTicketRowClickListener, private val onItemButtonTicketRowClickListener: OnItemButtonTicketRowClickListener,
private val onItemButtonCMRRowClickListener: OnItemButtonCMRRowClickListener private val onItemButtonCMRRowClickListener: OnItemButtonCMRRowClickListener
@ -33,7 +32,7 @@ class TicketAdapter(
) )
} }
fun setHeaders(list: MutableList<ClientTicket>): MutableList<ClientTicket> { fun setHeaders(list: MutableList<ClientTicketSalix>): MutableList<ClientTicketSalix> {
/* var prevCreated = "" /* var prevCreated = ""
for (route in list) { for (route in list) {
@ -45,7 +44,7 @@ class TicketAdapter(
return list return list
} }
fun updateList(newList: MutableList<ClientTicket>) { fun updateList(newList: MutableList<ClientTicketSalix>) {
items = newList items = newList
notifyDataSetChanged() notifyDataSetChanged()
} }
@ -89,10 +88,10 @@ class TicketAdapter(
val binding: ItemTicketRowBinding val binding: ItemTicketRowBinding
) : RecyclerView.ViewHolder(binding.root) { ) : RecyclerView.ViewHolder(binding.root) {
private val res = binding.root.context.resources private val res = binding.root.context.resources
fun bind(item: ClientTicket) { fun bind(item: ClientTicketSalix) {
binding.apply { binding.apply {
if (!item.Note.isNullOrEmpty()) { if (!item.ticketObservation.isNullOrEmpty()) {
note.setColorFilter( note.setColorFilter(
ContextCompat.getColor( ContextCompat.getColor(
note.context, note.context,

View File

@ -313,7 +313,13 @@ class LoadUnloadFragment(
if (binding.mainToolbar.switchButton.isChecked) { if (binding.mainToolbar.switchButton.isChecked) {
counterCalls = 1 counterCalls = 1
binding.splashProgress.visibility = View.VISIBLE binding.splashProgress.visibility = View.VISIBLE
viewModel.expeditionState_add(myList.filter { it.code == state }, state) val pendingExpeditionSend = myList.map { l ->
ExpeditionSalix(
expeditionFk = l.id,
stateCode = l.code
)
}
viewModel.expeditionStateAddSalix( hashMapOf("expeditions" to pendingExpeditionSend.filter { it.stateCode == state }))
} else { } else {
updateCount(myList, state) updateCount(myList, state)
} }

View File

@ -24,6 +24,7 @@ import es.verdnatura.presentation.base.database
import es.verdnatura.presentation.common.* import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.feature.delivery.adapters.RouteAdapter import es.verdnatura.presentation.view.feature.delivery.adapters.RouteAdapter
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.ExpeditionSalix
import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo
import es.verdnatura.presentation.view.feature.delivery.model.RouteLoaded import es.verdnatura.presentation.view.feature.delivery.model.RouteLoaded
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
@ -64,6 +65,7 @@ class RoutesFragment(
} }
private fun pendingOperations() { private fun pendingOperations() {
db = database(requireContext().applicationContext) db = database(requireContext().applicationContext)
if (mobileApplication.hasNetwork) { if (mobileApplication.hasNetwork) {
lifecycleScope.launch { lifecycleScope.launch {
@ -75,31 +77,35 @@ class RoutesFragment(
val pendingExpedition = val pendingExpedition =
db.expedicionDao().getAllPendingExpeditions() db.expedicionDao().getAllPendingExpeditions()
if (pendingExpedition.filter { it.code == "DELIVERED" }.isNotEmpty()) {
viewModel.expeditionState_add( val pendingExpeditionSend = pendingExpedition.map { l ->
pendingExpedition.filter { it.code == "DELIVERED" }, ExpeditionSalix(
"DELIVERED" expeditionFk = l.id,
stateCode = l.code
) )
} }
if (pendingExpedition.filter { it.code == "ON DELIVERY" }.isNotEmpty()) { if (pendingExpeditionSend.filter{ it.stateCode == "DELIVERED" }.isNotEmpty()) {
viewModel.expeditionState_add( viewModel.expeditionStateAddSalix(
pendingExpedition.filter { it.code == "ON DELIVERY" }, hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "DELIVERED" })
"ON DELIVERY"
) )
} }
if (pendingExpedition.filter { it.code == "LOST" }.isNotEmpty()) { if (pendingExpeditionSend.filter{ it.stateCode == "ON DELIVERY" }.isNotEmpty()) {
viewModel.expeditionState_add( viewModel.expeditionStateAddSalix(
pendingExpedition.filter { it.code == "LOST" }, hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "ON DELIVERY" })
"LOST"
) )
} }
if (pendingExpedition.filter { it.code == "FOUND" }.isNotEmpty()) { if (pendingExpeditionSend.filter{ it.stateCode == "LOST" }.isNotEmpty()) {
viewModel.expeditionState_add( viewModel.expeditionStateAddSalix(
pendingExpedition.filter { it.code == "FOUND" }, hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "LOST" })
"FOUND"
) )
} }
if (pendingExpeditionSend.filter{ it.stateCode == "FOUND" }.isNotEmpty()) {
viewModel.expeditionStateAddSalix(
hashMapOf("expeditions" to pendingExpeditionSend.filter{ it.stateCode == "FOUND" })
)
}
} }
db.routesDao().deleteLoaded(toDateString(Date())) db.routesDao().deleteLoaded(toDateString(Date()))
myListRouteLoaded = db.routesDao().getAllLoaded() myListRouteLoaded = db.routesDao().getAllLoaded()
@ -132,6 +138,7 @@ class RoutesFragment(
return callBackEndPoint return callBackEndPoint
} }
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
private fun setToolBar() { private fun setToolBar() {
ma.hideBottomNavigation(View.GONE) ma.hideBottomNavigation(View.GONE)

View File

@ -21,10 +21,10 @@ import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.feature.delivery.adapters.ExpeditionSummaryAdapter import es.verdnatura.presentation.view.feature.delivery.adapters.ExpeditionSummaryAdapter
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.ExpeditionInfoSummary import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoSummary
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionSalix
import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel import es.verdnatura.presentation.view.feature.delivery.viewmodels.DeliveryViewModel
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
class SummaryFragment( class SummaryFragment(
var title: String = "", var title: String = "",
var state: String = "", var state: String = "",
@ -46,7 +46,6 @@ class SummaryFragment(
private var isScanning = false private var isScanning = false
private var positionSelected = -1 private var positionSelected = -1
companion object { companion object {
fun newInstance(title: String, state: String, route: Int) = fun newInstance(title: String, state: String, route: Int) =
SummaryFragment(title, state, route) SummaryFragment(title, state, route)
@ -126,7 +125,7 @@ class SummaryFragment(
} }
iconExit.drawable -> { iconExit.drawable -> {
requireActivity().finish() requireActivity().finish()
} }
} }
@ -158,14 +157,27 @@ class SummaryFragment(
state: String, state: String,
address: Int address: Int
) { ) {
val listExpedition = list.filter { it.addressFk == address }.map { l ->
ExpeditionSalix(
expeditionFk = l.id,
stateCode = if (l.code == state) {
state
} else {
"FOUND"
}
)
}
if (list.filter { it.addressFk == address } if (list.filter { it.addressFk == address }
.filter { it.code == state }.size == list.filter { it.addressFk == address }.size) { .filter { it.code == state }.size == list.filter { it.addressFk == address }.size) {
binding.splashProgress.visibility = View.VISIBLE
callBack(viewModel.expeditionState_add(list.filter { it.addressFk == address }
.filter { it.code == state }, state))
counterCalls = 1 counterCalls = 1
callBack(
viewModel.expeditionStateAddSalix(
hashMapOf("expeditions" to listExpedition.filter { it.stateCode == state })
)
)
/* callBack(viewModel.expeditionState_add(list.filter { it.addressFk == address }
.filter { it.code == state }, state))*/
isScanning = false isScanning = false
} else { } else {
@ -175,13 +187,18 @@ class SummaryFragment(
alertDialog.setButton( alertDialog.setButton(
android.app.AlertDialog.BUTTON_POSITIVE, getString(R.string.save) android.app.AlertDialog.BUTTON_POSITIVE, getString(R.string.save)
) { dialog, which -> ) { dialog, which ->
counterCalls = 2
binding.splashProgress.visibility = View.VISIBLE binding.splashProgress.visibility = View.VISIBLE
viewModel.expeditionState_add(list.filter { it.addressFk == address }
.filter { it.code == state }, state) counterCalls = 1
viewModel.expeditionState_add(list.filter { it.addressFk == address } viewModel.expeditionStateAddSalix(hashMapOf("expeditions" to listExpedition.filter { it.stateCode == state }))
.filter { it.code != state }, "LOST")
/*
viewModel.expeditionState_add(list.filter { it.addressFk == address }
.filter { it.code == state }, state)
viewModel.expeditionState_add(list.filter { it.addressFk == address }
.filter { it.code != state }, "LOST")*/
} }
alertDialog.setButton( alertDialog.setButton(
android.app.AlertDialog.BUTTON_NEUTRAL, getString(R.string.find) android.app.AlertDialog.BUTTON_NEUTRAL, getString(R.string.find)
@ -191,7 +208,6 @@ class SummaryFragment(
alertDialog.show() alertDialog.show()
} }
} }
private fun openAppDelivery() { private fun openAppDelivery() {
@ -271,7 +287,6 @@ class SummaryFragment(
updateCount(myList, state) updateCount(myList, state)
} }
} }
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
@ -382,7 +397,6 @@ class SummaryFragment(
} }
private fun createList(list: MutableList<ExpeditionInfoLoadUnload>) { private fun createList(list: MutableList<ExpeditionInfoLoadUnload>) {
myList = list myList = list
@ -399,7 +413,6 @@ class SummaryFragment(
} }
} }
private fun updateCount(list: MutableList<ExpeditionInfoLoadUnload>, state: String) { private fun updateCount(list: MutableList<ExpeditionInfoLoadUnload>, state: String) {
val countMarked = val countMarked =
list.filter { it.addressFk == addressFkSelected }.filter { it.code == state }.size list.filter { it.addressFk == addressFkSelected }.filter { it.code == state }.size
@ -424,5 +437,4 @@ class SummaryFragment(
} }
} }
} }

View File

@ -31,7 +31,7 @@ import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.component.CustomDialogInputNotes import es.verdnatura.presentation.view.component.CustomDialogInputNotes
import es.verdnatura.presentation.view.component.CustomDialogList import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.feature.delivery.adapters.TicketAdapter import es.verdnatura.presentation.view.feature.delivery.adapters.TicketAdapter
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix
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.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo
import es.verdnatura.presentation.view.feature.delivery.model.Ticket import es.verdnatura.presentation.view.feature.delivery.model.Ticket
@ -52,7 +52,7 @@ class TicketsFragment(
private var adapter: TicketAdapter? = null private var adapter: TicketAdapter? = null
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private lateinit var myListClientTicket: MutableList<ClientTicket> private lateinit var myListClientTicket: MutableList<ClientTicketSalix>
private var showSigned = false private var showSigned = false
private var showSettings = false private var showSettings = false
private lateinit var db: DeliveryDatabase private lateinit var db: DeliveryDatabase
@ -84,7 +84,7 @@ class TicketsFragment(
binding.mainToolbar.toolbarSubtitle.text = binding.mainToolbar.toolbarSubtitle.text =
if (::myListClientTicket.isInitialized) { if (::myListClientTicket.isInitialized) {
myListClientTicket.filter { it.Signed == 1 }.size.toString() + "/" + myListClientTicket.size myListClientTicket.filter { it.signed == 1 }.size.toString() + "/" + myListClientTicket.size
} else { } else {
"0/0" "0/0"
} }
@ -170,9 +170,9 @@ class TicketsFragment(
if (::myListClientTicket.isInitialized) { if (::myListClientTicket.isInitialized) {
adapter!!.updateList( adapter!!.updateList(
if (showSigned) { if (showSigned) {
myListClientTicket.filter { it.Signed == 1 } as MutableList<ClientTicket> myListClientTicket.filter { it.signed == 1 } as MutableList<ClientTicketSalix>
} else { } else {
myListClientTicket.filter { it.Signed == 0 } as MutableList<ClientTicket> myListClientTicket.filter { it.signed == 0 } as MutableList<ClientTicketSalix>
}) })
} }
changeColorIcon(iconSigned.drawable, showSigned) changeColorIcon(iconSigned.drawable, showSigned)
@ -359,9 +359,9 @@ class TicketsFragment(
} }
private fun createLisTickets(list: MutableList<ClientTicket>, getSaved: Boolean = false) { private fun createLisTickets(list: MutableList<ClientTicketSalix>, getSaved: Boolean = false) {
var myListClientTicketAux: MutableList<ClientTicket> = mutableListOf() var myListClientTicketAux: MutableList<ClientTicketSalix> = mutableListOf()
lifecycleScope.launch { lifecycleScope.launch {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
@ -371,17 +371,17 @@ class TicketsFragment(
.toMutableList() .toMutableList()
} else { } else {
myListClientTicketAux = myListClientTicketAux =
list.distinctBy { it.Address } as MutableList<ClientTicket> list.distinctBy { it.addressFk } as MutableList<ClientTicketSalix>
for (clientTicket in myListClientTicketAux) { for (clientTicket in myListClientTicketAux) {
val addressId = clientTicket.Address val addressId = clientTicket.addressFk
val ticketsForClient = list.filter { it.Address == addressId } val ticketsForClient = list.filter { it.addressFk == addressId }
val mappedTickets = ticketsForClient.map { ticket -> val mappedTickets = ticketsForClient.map { ticket ->
Ticket( Ticket(
ticket.Id, ticket.id,
ticket.Packages, ticket.packages,
ticket.PackingType, ticket.ipt,
ticket.Note, ticket.ticketObservation,
ticket.cmrFk ticket.cmrFk
) )
} }
@ -399,16 +399,16 @@ class TicketsFragment(
myListClientTicket = myListClientTicketAux myListClientTicket = myListClientTicketAux
val myListFiltered = if (showSigned) { val myListFiltered = if (showSigned) {
myListClientTicket.filter { it.Signed == 1 } myListClientTicket.filter { it.signed == 1 }
} else { } else {
myListClientTicket.filter { it.Signed == 0 } myListClientTicket.filter { it.signed == 0 }
} }
adapter = TicketAdapter( adapter = TicketAdapter(
myListFiltered as MutableList<ClientTicket>, myListFiltered as MutableList<ClientTicketSalix>,
object : OnItemButtonTicketRowClickListener { object : OnItemButtonTicketRowClickListener {
override fun onItemButtonTicketRowClickListener( override fun onItemButtonTicketRowClickListener(
item: ClientTicket, item: ClientTicketSalix,
action: String action: String
) { ) {
when (action) { when (action) {
@ -417,12 +417,12 @@ class TicketsFragment(
val entryPoint = Gson().toJson( val entryPoint = Gson().toJson(
mutableMapOf( mutableMapOf(
"route" to route.id.toString(), "route" to route.id.toString(),
"address" to item.Address "address" to item.addressFk
) )
) )
ma.onPasillerosItemClickListener( ma.onPasillerosItemClickListener(
PasillerosItemVO(title = getString(R.string.titleUnLoadTruck)), PasillerosItemVO(title = getString(R.string.titleUnLoadTruck)),
entryPoint, myListClientTicket.filter { it.Id == item.Id } entryPoint, myListClientTicket.filter { it.id == item.id }
) )
} }
@ -486,7 +486,7 @@ class TicketsFragment(
} }
} }
private fun addNotes(itemClient: ClientTicket) { private fun addNotes(itemClient: ClientTicketSalix) {
val customDialogInput = CustomDialogInputNotes(requireContext()) val customDialogInput = CustomDialogInputNotes(requireContext())
customDialogInput.setTitle("Notas") customDialogInput.setTitle("Notas")
@ -526,11 +526,11 @@ class TicketsFragment(
} }
private fun showNotes(item: ClientTicket) { private fun showNotes(item: ClientTicketSalix) {
val alertDialog = AlertDialog.Builder(requireContext()).create() val alertDialog = AlertDialog.Builder(requireContext()).create()
alertDialog.setTitle(getString(R.string.info)) alertDialog.setTitle(getString(R.string.info))
alertDialog.setMessage(item.Note) alertDialog.setMessage(item.ticketObservation)
alertDialog.setButton( alertDialog.setButton(
AlertDialog.BUTTON_NEUTRAL, getString(R.string.close) AlertDialog.BUTTON_NEUTRAL, getString(R.string.close)
) { dialog, _ -> dialog.dismiss() } ) { dialog, _ -> dialog.dismiss() }
@ -546,28 +546,28 @@ class TicketsFragment(
} }
} }
fun showPhones(clientClicked: ClientTicket) { fun showPhones(clientClicked: ClientTicketSalix) {
val phones: MutableList<GeneralItem> = mutableListOf() val phones: MutableList<GeneralItem> = mutableListOf()
//Tarea 6275 //Tarea 6275
/*if (clientClicked.clientPhone!=null){ if (clientClicked.clientPhone!=null){
phones.add( phones.add(
GeneralItem( GeneralItem(
text = "${getString(R.string.Cliente)}:$clientClicked.clientPhone", text = "${getString(R.string.Cliente)}:${clientClicked.clientPhone}",
code =clientClicked.clientMobile code =clientClicked.clientMobile.toString()
)) ))
} }
if (clientClicked.addressMobile!=null){ if (clientClicked.clientMobile!=null){
phones.add( phones.add(
GeneralItem( GeneralItem(
text = "${getString(R.string.Cliente)}:$clientClicked.addressPhone", text = "${getString(R.string.Cliente)}:${clientClicked.clientMobile}",
code =clientClicked.addressMobile code =clientClicked.clientMobile.toString()
)) ))
} }
if (clientClicked.addressPhone!=null){ if (clientClicked.addressPhone!=null){
phones.add( phones.add(
GeneralItem( GeneralItem(
text = "${getString(R.string.Cliente)}:$clientClicked.addressPhone", text = "${getString(R.string.Cliente)}:${clientClicked.addressPhone}",
code =clientClicked.addressPhone code =clientClicked.addressPhone.toString()
)) ))
} }
if (!clientClicked.salePersonPhone.isNullOrEmpty()) if (!clientClicked.salePersonPhone.isNullOrEmpty())
@ -577,9 +577,9 @@ class TicketsFragment(
code = code =
clientClicked.salePersonPhone.toString() 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!!) {
phones.add( phones.add(
GeneralItem( GeneralItem(
@ -597,7 +597,7 @@ class TicketsFragment(
code = code =
clientClicked.SalePersonPhone.toString() clientClicked.SalePersonPhone.toString()
) )
) )*/
customDialogList.setValueVisibility(View.GONE) customDialogList.setValueVisibility(View.GONE)
customDialogList.setTitle(getString(R.string.phones)) customDialogList.setTitle(getString(R.string.phones))
.setKoButton( .setKoButton(
@ -645,22 +645,22 @@ class TicketsFragment(
} }
fun goMaps(item: ClientTicket) { fun goMaps(item: ClientTicketSalix) {
if (isGoogleMapsInstalled()) { if (isGoogleMapsInstalled()) {
val uri: String val uri: String
if (item.Latitude != null) { if (item.latitude != null) {
uri = "geo:${item.Latitude},${item.Longitude}?q=" + item.ClientName + uri = "geo:${item.latitude},${item.longitude}?q=" + item.nickname +
" " + item.AddressName + " " + item.street +
" " + item.City + " " + item.city +
" " + item.PostalCode " " + item.postalCode
} else { } else {
uri = "geo:0,0?q=" + item.ClientName + uri = "geo:0,0?q=" + item.nickname +
" " + item.AddressName + " " + item.street +
" " + item.City + " " + item.city +
" " + item.PostalCode " " + item.postalCode
} }
val locationIntent = Intent(Intent.ACTION_VIEW, Uri.parse(uri)) val locationIntent = Intent(Intent.ACTION_VIEW, Uri.parse(uri))
startActivity(locationIntent) startActivity(locationIntent)

View File

@ -7,7 +7,7 @@ import es.verdnatura.db.MapTypeConverter
import java.io.Serializable import java.io.Serializable
class ClientTicketList( class ClientTicketList(
var list: MutableList<ClientTicket> = mutableListOf() var list: MutableList<ClientTicketSalix> = mutableListOf()
) )
@Entity(tableName = "clientTickets") @Entity(tableName = "clientTickets")
@ -38,6 +38,7 @@ data class ClientTicket(
) : Serializable ) : Serializable
//Tarea 6275 //Tarea 6275
@Entity(tableName = "clientTickets")
data class ClientTicketSalix( data class ClientTicketSalix(
@PrimaryKey var id: Long, @PrimaryKey var id: Long,
var clientFk: Int, var clientFk: Int,

View File

@ -11,8 +11,8 @@ import es.verdnatura.domain.formatWithQuotes
import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.Event
import es.verdnatura.presentation.common.ResponseItemVO import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicket
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketList import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketList
import es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix
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.ExpeditionInfoList import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoList
import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload import es.verdnatura.presentation.view.feature.delivery.model.ExpeditionInfoLoadUnload
@ -217,8 +217,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
} }
fun expeditionState_add(expeditions: Any?, state: String) { /* fun expeditionState_add(expeditions: Any?, state: String) {
silex.expeditionState_add(expeditions, state) silex.expeditionState_add(expeditions, state)
.enqueue(object : SilexCallback<Unit>(context) { .enqueue(object : SilexCallback<Unit>(context) {
override fun onSuccess(response: Response<Unit>) { override fun onSuccess(response: Response<Unit>) {
@ -235,7 +234,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
} }
}) })
} }*/
fun expeditionStateAddSalix(expeditions: Any) { fun expeditionStateAddSalix(expeditions: Any) {
@ -282,8 +281,8 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
route: Int route: Int
) { ) {
//Tarea 6275 //Tarea 6275
//salix.routeGetExpeditionSummary(route) salix.routeGetExpeditionSummary(route)
silex.route_getExpeditionSummary(route) // silex.route_getExpeditionSummary(route)
.enqueue(object : SalixCallback<List<ExpeditionInfoSummary>>(context) { .enqueue(object : SalixCallback<List<ExpeditionInfoSummary>>(context) {
override fun onSuccess(response: Response<List<ExpeditionInfoSummary>>) { override fun onSuccess(response: Response<List<ExpeditionInfoSummary>>) {
@ -308,9 +307,9 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
workerFk: Int workerFk: Int
) { ) {
//Redmine 6028 falta que le pongan el email y PR //Redmine 6028 falta que le pongan el email y PR
//salix.getRoutes() salix.getRoutes()
silex.getRoutes(workerFk) // silex.getRoutes(workerFk)
.enqueue(object : SilexCallback<MutableList<RouteInfo>>(context) { .enqueue(object : SalixCallback<MutableList<RouteInfo>>(context) {
override fun onSuccess(response: Response<MutableList<RouteInfo>>) { override fun onSuccess(response: Response<MutableList<RouteInfo>>) {
@ -335,10 +334,10 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
routeId: Long routeId: Long
) { ) {
//Tarea 6275 //Tarea 6275
// salix.getTickets("""{"id":$routeId}""") salix.getTickets("""{"id":$routeId}""")
silex.getTickets(routeId) // silex.getTickets(routeId)
.enqueue(object : SalixCallback<MutableList<ClientTicket>>(context) { .enqueue(object : SalixCallback<MutableList<ClientTicketSalix>>(context) {
override fun onSuccess(response: Response<MutableList<ClientTicket>>) { override fun onSuccess(response: Response<MutableList<ClientTicketSalix>>) {
_clientTicketList.value = _clientTicketList.value =
response.body()?.let { ClientTicketList(it) } response.body()?.let { ClientTicketList(it) }
} }
@ -369,7 +368,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
}) })
} }
fun addNote( /* fun addNote(
ticketFk: Int ticketFk: Int
) { ) {
silex.addNotes(ticketFk) silex.addNotes(ticketFk)
@ -386,7 +385,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) {
} }
}) })
} }*/
fun routeUpdate( fun routeUpdate(
route: RouteInfo route: RouteInfo

View File

@ -7,7 +7,7 @@
<variable <variable
name="item" name="item"
type="es.verdnatura.presentation.view.feature.delivery.model.ClientTicket" /> type="es.verdnatura.presentation.view.feature.delivery.model.ClientTicketSalix" />
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
@ -62,7 +62,7 @@
android:id="@+id/textView21" android:id="@+id/textView21"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{String.valueOf(item.client)}" android:text="@{String.valueOf(item.clientFk)}"
app:autoSizeMaxTextSize="18sp" app:autoSizeMaxTextSize="18sp"
android:textSize="18sp" android:textSize="18sp"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
@ -83,7 +83,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@{String.valueOf(item.address)}" android:text="@{String.valueOf(item.addressFk)}"
android:textAlignment="center" android:textAlignment="center"
android:maxLines="1" android:maxLines="1"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
@ -104,7 +104,7 @@
android:id="@+id/textView25" android:id="@+id/textView25"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{item.clientName}" android:text="@{item.nickname}"
android:textColor="@color/verdnatura_white" android:textColor="@color/verdnatura_white"
android:textSize="18sp" android:textSize="18sp"
tools:text="LA FLOR VALENCIA"/> tools:text="LA FLOR VALENCIA"/>
@ -113,7 +113,7 @@
android:id="@+id/textView24" android:id="@+id/textView24"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@{item.addressName}" android:text="@{item.street}"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="@color/colorPrimary" android:textColor="@color/colorPrimary"
tools:text="C/ Les flors,1"/> tools:text="C/ Les flors,1"/>