feat roadMap #refs 7195
This commit is contained in:
parent
8eb5866fad
commit
1f81ac53cb
|
@ -48,6 +48,7 @@ class StopMapPalletListAdapter(
|
|||
binding.apply {
|
||||
|
||||
if (action == TruckAction.UNLOAD) {
|
||||
binding.printNewRoutePallet.visibility = GONE
|
||||
binding.printNewRoutePallet.setOnClickListener {
|
||||
onPrintClickListener.onPrintClickListener(item, "")
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ class StopMapPalletListAdapter(
|
|||
)
|
||||
)
|
||||
|
||||
|
||||
this.item = item
|
||||
|
||||
}
|
||||
|
|
|
@ -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.RoadMapTruckList
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
class RoadMapListFragment(
|
||||
|
@ -50,11 +49,12 @@ class RoadMapListFragment(
|
|||
}
|
||||
setToolBar()
|
||||
viewModel.roadMapTruckList(
|
||||
"""{"where": { "etd": {
|
||||
"""{"where":{"or":[{"kmStart":null},{"kmEnd":null}]}}"""
|
||||
/* """{"where": { "etd": {
|
||||
"between": ["${LocalDate.now().atTime(LocalTime.MIN)}",
|
||||
"${
|
||||
LocalDate.now().atTime(LocalTime.MAX)
|
||||
}"]}},"order": "etd ASC"}"""
|
||||
}"]}},"order": "etd ASC"}"""*/
|
||||
)
|
||||
super.init()
|
||||
}
|
||||
|
@ -96,11 +96,7 @@ class RoadMapListFragment(
|
|||
iconReload -> {
|
||||
binding.filterTxt.setText("")
|
||||
viewModel.roadMapTruckList(
|
||||
"""{"where": { "etd": {
|
||||
"between": ["${LocalDate.now().atTime(LocalTime.MIN)}",
|
||||
"${
|
||||
LocalDate.now().atTime(LocalTime.MAX)
|
||||
}"]}},"order": "etd ASC"}"""
|
||||
"""{"where":{"or":[{"kmStart":null},{"kmEnd":null}]}}"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,14 +63,34 @@ class RoadMapListViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
fun getStopMapTruckList(roadMap: Int) {
|
||||
salix.getStopMapTruckList(
|
||||
"""{ "where":{"roadMapFk":$roadMap},
|
||||
| "fields": [ "id","eta","description","warehouseFk"],
|
||||
| "include": [ { "relation": "warehouse",
|
||||
| "scope": { "fields": ["name","addressFk"],
|
||||
| "include":[{ "relation":"address",
|
||||
"""{
|
||||
"where": {
|
||||
"roadmapFk": $roadMap
|
||||
},
|
||||
"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",
|
||||
| "scope":{ "fields": ["nickname","street","city","postalCode","latitude","longitude","mobile","phone","address","clientFk"],
|
||||
| "include":[{ "relation":"client",
|
||||
| "scope":{ "fields": ["phone"] } } ]} } ] } } ] }""".trimMargin()
|
||||
| "scope":{ "fields": ["phone"] } } ]} } ] } } ] }""".trimMargin()*/
|
||||
// """{"where": { "roadMapFk":$roadMap},"order": "eta ASC"}"""
|
||||
/* """{"where": { "eta": {
|
||||
"between": ["${LocalDate.now().atTime(LocalTime.MIN)}",
|
||||
|
|
|
@ -137,7 +137,18 @@ class StopMapListFragment(
|
|||
override fun observeViewModel() {
|
||||
with(viewModel) {
|
||||
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 -> {
|
||||
println("locationMaps")
|
||||
|
||||
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))
|
||||
startActivity(locationIntent)
|
||||
}
|
||||
|
@ -197,15 +209,24 @@ class StopMapListFragment(
|
|||
popupMenu.setOnMenuItemClickListener { itemOption ->
|
||||
when (itemOption.itemId) {
|
||||
R.id.maps -> {
|
||||
|
||||
if (item.warehouse?.address?.street == null) {
|
||||
val uri:String
|
||||
|
||||
if (item.address?.street != null) {
|
||||
getString(R.string.errorLocation).toast(requireContext())
|
||||
val uri =
|
||||
"geo:0,0?q=" + item.warehouse?.address?.nickname + " " + item.warehouse?.address?.street + " " + item.warehouse?.address?.city + " " + item.warehouse?.address?.postalCode
|
||||
uri = "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))
|
||||
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
|
||||
|
||||
}
|
||||
|
@ -238,27 +259,27 @@ class StopMapListFragment(
|
|||
|
||||
val phones: MutableList<GeneralItem> = mutableListOf()
|
||||
//Tarea 6275
|
||||
if (!item.warehouse?.address?.mobile.isNullOrBlank()) {
|
||||
if (!item.address?.mobile.isNullOrBlank()) {
|
||||
phones.add(
|
||||
GeneralItem(
|
||||
text = "${item.warehouse?.address?.mobile}",
|
||||
code = item.warehouse?.address?.mobile
|
||||
text = "${item.address?.mobile}",
|
||||
code = item.address?.mobile
|
||||
)
|
||||
)
|
||||
}
|
||||
if (!item.warehouse?.address?.phone.isNullOrBlank()) {
|
||||
if (!item.address?.phone.isNullOrBlank()) {
|
||||
phones.add(
|
||||
GeneralItem(
|
||||
text = "${item.warehouse?.address?.phone}",
|
||||
code = item.warehouse?.address?.phone
|
||||
text = "${item.address?.phone}",
|
||||
code = item.address?.phone
|
||||
)
|
||||
)
|
||||
}
|
||||
if (!item.warehouse?.address?.client?.phone.isNullOrBlank()) {
|
||||
if (!item.address?.client?.phone.isNullOrBlank()) {
|
||||
phones.add(
|
||||
GeneralItem(
|
||||
text = "${item.warehouse?.address?.client?.phone}",
|
||||
code = item.warehouse?.address?.client?.phone
|
||||
text = "${item.address?.client?.phone}",
|
||||
code = item.address?.client?.phone
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -39,8 +39,9 @@ data class RoadMapTruckList(
|
|||
data class RoadStopMapTruck(
|
||||
var id: Int,
|
||||
var description: String?,
|
||||
var warehouseFk: Int?,
|
||||
var warehouse:Warehouse?,
|
||||
var addressFk: Int?,
|
||||
// var warehouse:Warehouse?,
|
||||
var address:Address?
|
||||
|
||||
) {
|
||||
var eta: String? = null
|
||||
|
@ -49,16 +50,16 @@ data class RoadStopMapTruck(
|
|||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "$description$id$warehouse$"
|
||||
return "$description$id${address?.nickname}$"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
data class Warehouse(
|
||||
/*data class Warehouse(
|
||||
var name:String?,
|
||||
var address:Address?
|
||||
)
|
||||
)*/
|
||||
|
||||
data class Address(
|
||||
var nickname:String?,
|
||||
|
|
Loading…
Reference in New Issue