feat roadMap #refs 7195

This commit is contained in:
Sergio De la torre 2024-07-02 12:19:22 +02:00
parent 8eb5866fad
commit 1f81ac53cb
5 changed files with 74 additions and 34 deletions

View File

@ -48,6 +48,7 @@ class StopMapPalletListAdapter(
binding.apply { binding.apply {
if (action == TruckAction.UNLOAD) { if (action == TruckAction.UNLOAD) {
binding.printNewRoutePallet.visibility = GONE
binding.printNewRoutePallet.setOnClickListener { binding.printNewRoutePallet.setOnClickListener {
onPrintClickListener.onPrintClickListener(item, "") onPrintClickListener.onPrintClickListener(item, "")
} }
@ -67,6 +68,7 @@ class StopMapPalletListAdapter(
) )
) )
this.item = item this.item = item
} }

View File

@ -17,7 +17,6 @@ import es.verdnatura.presentation.view.feature.roadmap.adapter.RoadMapListAdapte
import es.verdnatura.presentation.view.feature.roadmap.model.RoadMapTruck import es.verdnatura.presentation.view.feature.roadmap.model.RoadMapTruck
import es.verdnatura.presentation.view.feature.roadmap.model.RoadMapTruckList import es.verdnatura.presentation.view.feature.roadmap.model.RoadMapTruckList
import java.time.LocalDate import java.time.LocalDate
import java.time.LocalTime
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
class RoadMapListFragment( class RoadMapListFragment(
@ -50,11 +49,12 @@ class RoadMapListFragment(
} }
setToolBar() setToolBar()
viewModel.roadMapTruckList( viewModel.roadMapTruckList(
"""{"where": { "etd": { """{"where":{"or":[{"kmStart":null},{"kmEnd":null}]}}"""
/* """{"where": { "etd": {
"between": ["${LocalDate.now().atTime(LocalTime.MIN)}", "between": ["${LocalDate.now().atTime(LocalTime.MIN)}",
"${ "${
LocalDate.now().atTime(LocalTime.MAX) LocalDate.now().atTime(LocalTime.MAX)
}"]}},"order": "etd ASC"}""" }"]}},"order": "etd ASC"}"""*/
) )
super.init() super.init()
} }
@ -96,11 +96,7 @@ class RoadMapListFragment(
iconReload -> { iconReload -> {
binding.filterTxt.setText("") binding.filterTxt.setText("")
viewModel.roadMapTruckList( viewModel.roadMapTruckList(
"""{"where": { "etd": { """{"where":{"or":[{"kmStart":null},{"kmEnd":null}]}}"""
"between": ["${LocalDate.now().atTime(LocalTime.MIN)}",
"${
LocalDate.now().atTime(LocalTime.MAX)
}"]}},"order": "etd ASC"}"""
) )
} }
} }

View File

@ -63,14 +63,34 @@ class RoadMapListViewModel(val context: Context) : BaseViewModel(context) {
fun getStopMapTruckList(roadMap: Int) { fun getStopMapTruckList(roadMap: Int) {
salix.getStopMapTruckList( salix.getStopMapTruckList(
"""{ "where":{"roadMapFk":$roadMap}, """{
| "fields": [ "id","eta","description","warehouseFk"], "where": {
| "include": [ { "relation": "warehouse", "roadmapFk": $roadMap
| "scope": { "fields": ["name","addressFk"], },
"fields": ["id", "eta", "description", "addressFk"],
"include": [
{
"relation": "address",
"scope": {
"fields": ["id","nickname", "street", "city", "postalCode", "latitude", "longitude", "mobile", "phone", "address", "clientFk"],
"include": [
{
"relation": "client",
"scope": {
"fields": ["phone"]
}
}
]
}
}
]
}"""
/* """{ "where":{"roadMapFk":$roadMap},
| "fields": [ "id","eta","description","addressFk"],
| "include": [ { "relation": "address", | "include": [ { "relation": "address",
| "scope":{ "fields": ["nickname","street","city","postalCode","latitude","longitude","mobile","phone","address","clientFk"], | "scope":{ "fields": ["nickname","street","city","postalCode","latitude","longitude","mobile","phone","address","clientFk"],
| "include":[{ "relation":"client", | "include":[{ "relation":"client",
| "scope":{ "fields": ["phone"] } } ]} } ] } } ] }""".trimMargin() | "scope":{ "fields": ["phone"] } } ]} } ] } } ] }""".trimMargin()*/
// """{"where": { "roadMapFk":$roadMap},"order": "eta ASC"}""" // """{"where": { "roadMapFk":$roadMap},"order": "eta ASC"}"""
/* """{"where": { "eta": { /* """{"where": { "eta": {
"between": ["${LocalDate.now().atTime(LocalTime.MIN)}", "between": ["${LocalDate.now().atTime(LocalTime.MIN)}",

View File

@ -137,7 +137,18 @@ class StopMapListFragment(
override fun observeViewModel() { override fun observeViewModel() {
with(viewModel) { with(viewModel) {
loadStopMapTruckList.observe(viewLifecycleOwner) { event -> loadStopMapTruckList.observe(viewLifecycleOwner) { event ->
event.getContentIfNotHandled().notNull { showRoadMapList(it) } event.getContentIfNotHandled().notNull {
for (item in it.list )
{
println("llista")
println("llista $item")
println("llista addressFk ${item.addressFk}")
println("llista id" + item.id)
println("llista address" +item.address)
println("llista client id" +item.address?.client)
println("llista mobile " +item.address?.mobile)
}
showRoadMapList(it) }
} }
} }
@ -178,9 +189,10 @@ class StopMapListFragment(
} }
TruckAction.GOTOMAPS -> { TruckAction.GOTOMAPS -> {
println("locationMaps")
val uri = val uri =
"geo:0,0?q=" + item.warehouse?.address?.nickname + " " + item.warehouse?.address?.street + " " + item.warehouse?.address?.city + " " + item.warehouse?.address?.postalCode "geo:0,0?q=" + item.address?.nickname + " " + item.address?.street + " " + item.address?.city + " " + item.address?.postalCode
val locationIntent = Intent(Intent.ACTION_VIEW, Uri.parse(uri)) val locationIntent = Intent(Intent.ACTION_VIEW, Uri.parse(uri))
startActivity(locationIntent) startActivity(locationIntent)
} }
@ -197,15 +209,24 @@ class StopMapListFragment(
popupMenu.setOnMenuItemClickListener { itemOption -> popupMenu.setOnMenuItemClickListener { itemOption ->
when (itemOption.itemId) { when (itemOption.itemId) {
R.id.maps -> { R.id.maps -> {
val uri:String
if (item.warehouse?.address?.street == null) { if (item.address?.street != null) {
getString(R.string.errorLocation).toast(requireContext()) getString(R.string.errorLocation).toast(requireContext())
val uri = uri = "geo:0,0?q=" + item.address?.nickname + " " + item.address?.street + " " + item.address?.city + " " + item.address?.postalCode
"geo:0,0?q=" + item.warehouse?.address?.nickname + " " + item.warehouse?.address?.street + " " + item.warehouse?.address?.city + " " + item.warehouse?.address?.postalCode
val locationIntent = val locationIntent =
Intent(Intent.ACTION_VIEW, Uri.parse(uri)) Intent(Intent.ACTION_VIEW, Uri.parse(uri))
startActivity(locationIntent) startActivity(locationIntent)
}else{
if (item.address?.latitude == null || item.address?.longitude == null){
getString(R.string.errorLocation).toast(requireContext())
}else{
uri = "geo:${item.address?.latitude},${item.address?.longitude}"
val locationIntent =
Intent(Intent.ACTION_VIEW, Uri.parse(uri))
startActivity(locationIntent)}
} }
true true
} }
@ -238,27 +259,27 @@ class StopMapListFragment(
val phones: MutableList<GeneralItem> = mutableListOf() val phones: MutableList<GeneralItem> = mutableListOf()
//Tarea 6275 //Tarea 6275
if (!item.warehouse?.address?.mobile.isNullOrBlank()) { if (!item.address?.mobile.isNullOrBlank()) {
phones.add( phones.add(
GeneralItem( GeneralItem(
text = "${item.warehouse?.address?.mobile}", text = "${item.address?.mobile}",
code = item.warehouse?.address?.mobile code = item.address?.mobile
) )
) )
} }
if (!item.warehouse?.address?.phone.isNullOrBlank()) { if (!item.address?.phone.isNullOrBlank()) {
phones.add( phones.add(
GeneralItem( GeneralItem(
text = "${item.warehouse?.address?.phone}", text = "${item.address?.phone}",
code = item.warehouse?.address?.phone code = item.address?.phone
) )
) )
} }
if (!item.warehouse?.address?.client?.phone.isNullOrBlank()) { if (!item.address?.client?.phone.isNullOrBlank()) {
phones.add( phones.add(
GeneralItem( GeneralItem(
text = "${item.warehouse?.address?.client?.phone}", text = "${item.address?.client?.phone}",
code = item.warehouse?.address?.client?.phone code = item.address?.client?.phone
) )
) )
} }

View File

@ -39,8 +39,9 @@ data class RoadMapTruckList(
data class RoadStopMapTruck( data class RoadStopMapTruck(
var id: Int, var id: Int,
var description: String?, var description: String?,
var warehouseFk: Int?, var addressFk: Int?,
var warehouse:Warehouse?, // var warehouse:Warehouse?,
var address:Address?
) { ) {
var eta: String? = null var eta: String? = null
@ -49,16 +50,16 @@ data class RoadStopMapTruck(
} }
override fun toString(): String { override fun toString(): String {
return "$description$id$warehouse$" return "$description$id${address?.nickname}$"
} }
} }
data class Warehouse( /*data class Warehouse(
var name:String?, var name:String?,
var address:Address? var address:Address?
) )*/
data class Address( data class Address(
var nickname:String?, var nickname:String?,