diff --git a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt index bc0002b..e320cb9 100644 --- a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt @@ -1,5 +1,6 @@ package com.casic.br.ktd.fragment +import android.annotation.SuppressLint import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -37,6 +38,7 @@ import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton import org.json.JSONObject +@SuppressLint("SetTextI18n") class HomePageFragment : KotlinBaseFragment(), AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, Handler.Callback { @@ -50,7 +52,6 @@ private var taskModels: MutableList = ArrayList() private val handlerVehicleCode = 2023082501 private val handlerDeviceCode = 2023082502 - private val handlerTaskCode = 2023082503 override fun initViewBinding( inflater: LayoutInflater, container: ViewGroup? @@ -117,11 +118,39 @@ } } } - - // val message = weakReferenceHandler.obtainMessage() -// message.what = handlerTaskCode -// message.obj = it -// weakReferenceHandler.sendMessage(message) + taskViewModel.detailResult.observe(this) { + if (it.code == 200) { + //设置起点 + val first = it.data.first() + addMarker( + LatLng(first.lagitude.toDouble(), first.longitude.toDouble()), + "", + R.mipmap.start + ) + //设置终点 + val last = it.data.last() + addMarker( + LatLng(last.lagitude.toDouble(), last.longitude.toDouble()), + "", + R.mipmap.end + ) + it.data.forEach { task -> + if (task.lagitude.isNotEmpty() && task.longitude.isNotEmpty()) { + //瞄点画线 + val latLngPoints = ArrayList() + latLngPoints.add( + LatLng(task.lagitude.toDouble(), task.longitude.toDouble()) + ) + aMap.addPolyline( + PolylineOptions() + .addAll(latLngPoints) + .width(10.toFloat()) + .color(Color.RED) + ) + } + } + } + } } override fun handleMessage(msg: Message): Boolean { @@ -149,6 +178,11 @@ addMarker(latLng, hashMap.toJson(), marker) + //移动到巡检车经纬度 + val cameraPosition = CameraPosition(latLng, 16f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + /** * 地图PopupWindow数据绑定 * ****/ @@ -177,14 +211,6 @@ deviceModelView.text = "云台型号:${deviceModel.deviceModel}" } } - - handlerTaskCode -> { - if (isInfoWindowShow) { - routeView.setOnClickListener { - - } - } - } } return true } @@ -206,7 +232,6 @@ private lateinit var deviceModelView: TextView private lateinit var timeView: TextView private lateinit var locationView: TextView - private lateinit var routeView: QMUIRoundButton override fun getInfoWindow(marker: Marker?): View { isInfoWindowShow = true @@ -220,7 +245,7 @@ deviceModelView = v.findViewById(R.id.deviceModelView) timeView = v.findViewById(R.id.timeView) locationView = v.findViewById(R.id.locationView) - routeView = v.findViewById(R.id.routeView) + val routeView = v.findViewById(R.id.routeView) if (!marker?.snippet.isNullOrEmpty()) { val hashMapJson = marker?.snippet!! @@ -248,6 +273,10 @@ locationView.text = "结束时间:${task.endDate}" } } + + routeView.setOnClickListener { + taskViewModel.getTaskDetail(id) + } } } @@ -259,34 +288,7 @@ } override fun initEvent() { - //移动到巡检起始经纬度 - val cameraPosition = CameraPosition(LatLng(39.914199, 116.265785), 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) - //设置起点 - addMarker(LatLng(39.914885, 116.272312), "", R.mipmap.start) - //设置终点 - addMarker(LatLng(39.914716, 116.265097), "", R.mipmap.end) - //瞄点画线 - val latLngPoints = ArrayList() - latLngPoints.add(LatLng(39.914885, 116.272312)) - latLngPoints.add(LatLng(39.915148, 116.272312)) - latLngPoints.add(LatLng(39.915399, 116.272302)) - latLngPoints.add(LatLng(39.915436, 116.271787)) - latLngPoints.add(LatLng(39.915477, 116.270886)) - latLngPoints.add(LatLng(39.915477, 116.269968)) - latLngPoints.add(LatLng(39.915469, 116.269544)) - latLngPoints.add(LatLng(39.915481, 116.269196)) - latLngPoints.add(LatLng(39.915452, 116.268472)) - latLngPoints.add(LatLng(39.915444, 116.267722)) - latLngPoints.add(LatLng(39.915415, 116.266755)) - latLngPoints.add(LatLng(39.915403, 116.266165)) - latLngPoints.add(LatLng(39.915395, 116.265703)) - latLngPoints.add(LatLng(39.915366, 116.265119)) - latLngPoints.add(LatLng(39.914716, 116.265097)) - aMap.addPolyline( - PolylineOptions().addAll(latLngPoints).width(10.toFloat()).color(Color.RED) - ) + } diff --git a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt index bc0002b..e320cb9 100644 --- a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt @@ -1,5 +1,6 @@ package com.casic.br.ktd.fragment +import android.annotation.SuppressLint import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -37,6 +38,7 @@ import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton import org.json.JSONObject +@SuppressLint("SetTextI18n") class HomePageFragment : KotlinBaseFragment(), AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, Handler.Callback { @@ -50,7 +52,6 @@ private var taskModels: MutableList = ArrayList() private val handlerVehicleCode = 2023082501 private val handlerDeviceCode = 2023082502 - private val handlerTaskCode = 2023082503 override fun initViewBinding( inflater: LayoutInflater, container: ViewGroup? @@ -117,11 +118,39 @@ } } } - - // val message = weakReferenceHandler.obtainMessage() -// message.what = handlerTaskCode -// message.obj = it -// weakReferenceHandler.sendMessage(message) + taskViewModel.detailResult.observe(this) { + if (it.code == 200) { + //设置起点 + val first = it.data.first() + addMarker( + LatLng(first.lagitude.toDouble(), first.longitude.toDouble()), + "", + R.mipmap.start + ) + //设置终点 + val last = it.data.last() + addMarker( + LatLng(last.lagitude.toDouble(), last.longitude.toDouble()), + "", + R.mipmap.end + ) + it.data.forEach { task -> + if (task.lagitude.isNotEmpty() && task.longitude.isNotEmpty()) { + //瞄点画线 + val latLngPoints = ArrayList() + latLngPoints.add( + LatLng(task.lagitude.toDouble(), task.longitude.toDouble()) + ) + aMap.addPolyline( + PolylineOptions() + .addAll(latLngPoints) + .width(10.toFloat()) + .color(Color.RED) + ) + } + } + } + } } override fun handleMessage(msg: Message): Boolean { @@ -149,6 +178,11 @@ addMarker(latLng, hashMap.toJson(), marker) + //移动到巡检车经纬度 + val cameraPosition = CameraPosition(latLng, 16f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + /** * 地图PopupWindow数据绑定 * ****/ @@ -177,14 +211,6 @@ deviceModelView.text = "云台型号:${deviceModel.deviceModel}" } } - - handlerTaskCode -> { - if (isInfoWindowShow) { - routeView.setOnClickListener { - - } - } - } } return true } @@ -206,7 +232,6 @@ private lateinit var deviceModelView: TextView private lateinit var timeView: TextView private lateinit var locationView: TextView - private lateinit var routeView: QMUIRoundButton override fun getInfoWindow(marker: Marker?): View { isInfoWindowShow = true @@ -220,7 +245,7 @@ deviceModelView = v.findViewById(R.id.deviceModelView) timeView = v.findViewById(R.id.timeView) locationView = v.findViewById(R.id.locationView) - routeView = v.findViewById(R.id.routeView) + val routeView = v.findViewById(R.id.routeView) if (!marker?.snippet.isNullOrEmpty()) { val hashMapJson = marker?.snippet!! @@ -248,6 +273,10 @@ locationView.text = "结束时间:${task.endDate}" } } + + routeView.setOnClickListener { + taskViewModel.getTaskDetail(id) + } } } @@ -259,34 +288,7 @@ } override fun initEvent() { - //移动到巡检起始经纬度 - val cameraPosition = CameraPosition(LatLng(39.914199, 116.265785), 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) - //设置起点 - addMarker(LatLng(39.914885, 116.272312), "", R.mipmap.start) - //设置终点 - addMarker(LatLng(39.914716, 116.265097), "", R.mipmap.end) - //瞄点画线 - val latLngPoints = ArrayList() - latLngPoints.add(LatLng(39.914885, 116.272312)) - latLngPoints.add(LatLng(39.915148, 116.272312)) - latLngPoints.add(LatLng(39.915399, 116.272302)) - latLngPoints.add(LatLng(39.915436, 116.271787)) - latLngPoints.add(LatLng(39.915477, 116.270886)) - latLngPoints.add(LatLng(39.915477, 116.269968)) - latLngPoints.add(LatLng(39.915469, 116.269544)) - latLngPoints.add(LatLng(39.915481, 116.269196)) - latLngPoints.add(LatLng(39.915452, 116.268472)) - latLngPoints.add(LatLng(39.915444, 116.267722)) - latLngPoints.add(LatLng(39.915415, 116.266755)) - latLngPoints.add(LatLng(39.915403, 116.266165)) - latLngPoints.add(LatLng(39.915395, 116.265703)) - latLngPoints.add(LatLng(39.915366, 116.265119)) - latLngPoints.add(LatLng(39.914716, 116.265097)) - aMap.addPolyline( - PolylineOptions().addAll(latLngPoints).width(10.toFloat()).color(Color.RED) - ) + } diff --git a/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java new file mode 100644 index 0000000..62736d1 --- /dev/null +++ b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java @@ -0,0 +1,154 @@ +package com.casic.br.ktd.model; + +import java.util.List; + +public class TaskDetailModel { + + private Integer code; + private List data; + private String message; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private String alarmCode; + private String deviceStatus; + private String direction; + private String gas; + private String id; + private String isAlarm; + private String lagitude; + private String longitude; + private String pitch; + private String position; + private String speed; + private String taskId; + private String ts; + + public String getAlarmCode() { + return alarmCode; + } + + public void setAlarmCode(String alarmCode) { + this.alarmCode = alarmCode; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getGas() { + return gas; + } + + public void setGas(String gas) { + this.gas = gas; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsAlarm() { + return isAlarm; + } + + public void setIsAlarm(String isAlarm) { + this.isAlarm = isAlarm; + } + + public String getLagitude() { + return lagitude; + } + + public void setLagitude(String lagitude) { + this.lagitude = lagitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getPitch() { + return pitch; + } + + public void setPitch(String pitch) { + this.pitch = pitch; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + } +} diff --git a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt index bc0002b..e320cb9 100644 --- a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt @@ -1,5 +1,6 @@ package com.casic.br.ktd.fragment +import android.annotation.SuppressLint import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -37,6 +38,7 @@ import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton import org.json.JSONObject +@SuppressLint("SetTextI18n") class HomePageFragment : KotlinBaseFragment(), AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, Handler.Callback { @@ -50,7 +52,6 @@ private var taskModels: MutableList = ArrayList() private val handlerVehicleCode = 2023082501 private val handlerDeviceCode = 2023082502 - private val handlerTaskCode = 2023082503 override fun initViewBinding( inflater: LayoutInflater, container: ViewGroup? @@ -117,11 +118,39 @@ } } } - - // val message = weakReferenceHandler.obtainMessage() -// message.what = handlerTaskCode -// message.obj = it -// weakReferenceHandler.sendMessage(message) + taskViewModel.detailResult.observe(this) { + if (it.code == 200) { + //设置起点 + val first = it.data.first() + addMarker( + LatLng(first.lagitude.toDouble(), first.longitude.toDouble()), + "", + R.mipmap.start + ) + //设置终点 + val last = it.data.last() + addMarker( + LatLng(last.lagitude.toDouble(), last.longitude.toDouble()), + "", + R.mipmap.end + ) + it.data.forEach { task -> + if (task.lagitude.isNotEmpty() && task.longitude.isNotEmpty()) { + //瞄点画线 + val latLngPoints = ArrayList() + latLngPoints.add( + LatLng(task.lagitude.toDouble(), task.longitude.toDouble()) + ) + aMap.addPolyline( + PolylineOptions() + .addAll(latLngPoints) + .width(10.toFloat()) + .color(Color.RED) + ) + } + } + } + } } override fun handleMessage(msg: Message): Boolean { @@ -149,6 +178,11 @@ addMarker(latLng, hashMap.toJson(), marker) + //移动到巡检车经纬度 + val cameraPosition = CameraPosition(latLng, 16f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + /** * 地图PopupWindow数据绑定 * ****/ @@ -177,14 +211,6 @@ deviceModelView.text = "云台型号:${deviceModel.deviceModel}" } } - - handlerTaskCode -> { - if (isInfoWindowShow) { - routeView.setOnClickListener { - - } - } - } } return true } @@ -206,7 +232,6 @@ private lateinit var deviceModelView: TextView private lateinit var timeView: TextView private lateinit var locationView: TextView - private lateinit var routeView: QMUIRoundButton override fun getInfoWindow(marker: Marker?): View { isInfoWindowShow = true @@ -220,7 +245,7 @@ deviceModelView = v.findViewById(R.id.deviceModelView) timeView = v.findViewById(R.id.timeView) locationView = v.findViewById(R.id.locationView) - routeView = v.findViewById(R.id.routeView) + val routeView = v.findViewById(R.id.routeView) if (!marker?.snippet.isNullOrEmpty()) { val hashMapJson = marker?.snippet!! @@ -248,6 +273,10 @@ locationView.text = "结束时间:${task.endDate}" } } + + routeView.setOnClickListener { + taskViewModel.getTaskDetail(id) + } } } @@ -259,34 +288,7 @@ } override fun initEvent() { - //移动到巡检起始经纬度 - val cameraPosition = CameraPosition(LatLng(39.914199, 116.265785), 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) - //设置起点 - addMarker(LatLng(39.914885, 116.272312), "", R.mipmap.start) - //设置终点 - addMarker(LatLng(39.914716, 116.265097), "", R.mipmap.end) - //瞄点画线 - val latLngPoints = ArrayList() - latLngPoints.add(LatLng(39.914885, 116.272312)) - latLngPoints.add(LatLng(39.915148, 116.272312)) - latLngPoints.add(LatLng(39.915399, 116.272302)) - latLngPoints.add(LatLng(39.915436, 116.271787)) - latLngPoints.add(LatLng(39.915477, 116.270886)) - latLngPoints.add(LatLng(39.915477, 116.269968)) - latLngPoints.add(LatLng(39.915469, 116.269544)) - latLngPoints.add(LatLng(39.915481, 116.269196)) - latLngPoints.add(LatLng(39.915452, 116.268472)) - latLngPoints.add(LatLng(39.915444, 116.267722)) - latLngPoints.add(LatLng(39.915415, 116.266755)) - latLngPoints.add(LatLng(39.915403, 116.266165)) - latLngPoints.add(LatLng(39.915395, 116.265703)) - latLngPoints.add(LatLng(39.915366, 116.265119)) - latLngPoints.add(LatLng(39.914716, 116.265097)) - aMap.addPolyline( - PolylineOptions().addAll(latLngPoints).width(10.toFloat()).color(Color.RED) - ) + } diff --git a/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java new file mode 100644 index 0000000..62736d1 --- /dev/null +++ b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java @@ -0,0 +1,154 @@ +package com.casic.br.ktd.model; + +import java.util.List; + +public class TaskDetailModel { + + private Integer code; + private List data; + private String message; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private String alarmCode; + private String deviceStatus; + private String direction; + private String gas; + private String id; + private String isAlarm; + private String lagitude; + private String longitude; + private String pitch; + private String position; + private String speed; + private String taskId; + private String ts; + + public String getAlarmCode() { + return alarmCode; + } + + public void setAlarmCode(String alarmCode) { + this.alarmCode = alarmCode; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getGas() { + return gas; + } + + public void setGas(String gas) { + this.gas = gas; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsAlarm() { + return isAlarm; + } + + public void setIsAlarm(String isAlarm) { + this.isAlarm = isAlarm; + } + + public String getLagitude() { + return lagitude; + } + + public void setLagitude(String lagitude) { + this.lagitude = lagitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getPitch() { + return pitch; + } + + public void setPitch(String pitch) { + this.pitch = pitch; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + } +} diff --git a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt index 519ab45..2eefdda 100644 --- a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt @@ -62,6 +62,15 @@ ): String /** + * 任务详情 + */ + @POST("/system/busPatrolTask/detail") + suspend fun getTaskDetail( + @Header("token") token: String, + @Body requestBody: RequestBody + ): String + + /** * TODO 接口地址待完善 * 新增任务 */ diff --git a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt index bc0002b..e320cb9 100644 --- a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt @@ -1,5 +1,6 @@ package com.casic.br.ktd.fragment +import android.annotation.SuppressLint import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -37,6 +38,7 @@ import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton import org.json.JSONObject +@SuppressLint("SetTextI18n") class HomePageFragment : KotlinBaseFragment(), AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, Handler.Callback { @@ -50,7 +52,6 @@ private var taskModels: MutableList = ArrayList() private val handlerVehicleCode = 2023082501 private val handlerDeviceCode = 2023082502 - private val handlerTaskCode = 2023082503 override fun initViewBinding( inflater: LayoutInflater, container: ViewGroup? @@ -117,11 +118,39 @@ } } } - - // val message = weakReferenceHandler.obtainMessage() -// message.what = handlerTaskCode -// message.obj = it -// weakReferenceHandler.sendMessage(message) + taskViewModel.detailResult.observe(this) { + if (it.code == 200) { + //设置起点 + val first = it.data.first() + addMarker( + LatLng(first.lagitude.toDouble(), first.longitude.toDouble()), + "", + R.mipmap.start + ) + //设置终点 + val last = it.data.last() + addMarker( + LatLng(last.lagitude.toDouble(), last.longitude.toDouble()), + "", + R.mipmap.end + ) + it.data.forEach { task -> + if (task.lagitude.isNotEmpty() && task.longitude.isNotEmpty()) { + //瞄点画线 + val latLngPoints = ArrayList() + latLngPoints.add( + LatLng(task.lagitude.toDouble(), task.longitude.toDouble()) + ) + aMap.addPolyline( + PolylineOptions() + .addAll(latLngPoints) + .width(10.toFloat()) + .color(Color.RED) + ) + } + } + } + } } override fun handleMessage(msg: Message): Boolean { @@ -149,6 +178,11 @@ addMarker(latLng, hashMap.toJson(), marker) + //移动到巡检车经纬度 + val cameraPosition = CameraPosition(latLng, 16f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + /** * 地图PopupWindow数据绑定 * ****/ @@ -177,14 +211,6 @@ deviceModelView.text = "云台型号:${deviceModel.deviceModel}" } } - - handlerTaskCode -> { - if (isInfoWindowShow) { - routeView.setOnClickListener { - - } - } - } } return true } @@ -206,7 +232,6 @@ private lateinit var deviceModelView: TextView private lateinit var timeView: TextView private lateinit var locationView: TextView - private lateinit var routeView: QMUIRoundButton override fun getInfoWindow(marker: Marker?): View { isInfoWindowShow = true @@ -220,7 +245,7 @@ deviceModelView = v.findViewById(R.id.deviceModelView) timeView = v.findViewById(R.id.timeView) locationView = v.findViewById(R.id.locationView) - routeView = v.findViewById(R.id.routeView) + val routeView = v.findViewById(R.id.routeView) if (!marker?.snippet.isNullOrEmpty()) { val hashMapJson = marker?.snippet!! @@ -248,6 +273,10 @@ locationView.text = "结束时间:${task.endDate}" } } + + routeView.setOnClickListener { + taskViewModel.getTaskDetail(id) + } } } @@ -259,34 +288,7 @@ } override fun initEvent() { - //移动到巡检起始经纬度 - val cameraPosition = CameraPosition(LatLng(39.914199, 116.265785), 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) - //设置起点 - addMarker(LatLng(39.914885, 116.272312), "", R.mipmap.start) - //设置终点 - addMarker(LatLng(39.914716, 116.265097), "", R.mipmap.end) - //瞄点画线 - val latLngPoints = ArrayList() - latLngPoints.add(LatLng(39.914885, 116.272312)) - latLngPoints.add(LatLng(39.915148, 116.272312)) - latLngPoints.add(LatLng(39.915399, 116.272302)) - latLngPoints.add(LatLng(39.915436, 116.271787)) - latLngPoints.add(LatLng(39.915477, 116.270886)) - latLngPoints.add(LatLng(39.915477, 116.269968)) - latLngPoints.add(LatLng(39.915469, 116.269544)) - latLngPoints.add(LatLng(39.915481, 116.269196)) - latLngPoints.add(LatLng(39.915452, 116.268472)) - latLngPoints.add(LatLng(39.915444, 116.267722)) - latLngPoints.add(LatLng(39.915415, 116.266755)) - latLngPoints.add(LatLng(39.915403, 116.266165)) - latLngPoints.add(LatLng(39.915395, 116.265703)) - latLngPoints.add(LatLng(39.915366, 116.265119)) - latLngPoints.add(LatLng(39.914716, 116.265097)) - aMap.addPolyline( - PolylineOptions().addAll(latLngPoints).width(10.toFloat()).color(Color.RED) - ) + } diff --git a/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java new file mode 100644 index 0000000..62736d1 --- /dev/null +++ b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java @@ -0,0 +1,154 @@ +package com.casic.br.ktd.model; + +import java.util.List; + +public class TaskDetailModel { + + private Integer code; + private List data; + private String message; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private String alarmCode; + private String deviceStatus; + private String direction; + private String gas; + private String id; + private String isAlarm; + private String lagitude; + private String longitude; + private String pitch; + private String position; + private String speed; + private String taskId; + private String ts; + + public String getAlarmCode() { + return alarmCode; + } + + public void setAlarmCode(String alarmCode) { + this.alarmCode = alarmCode; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getGas() { + return gas; + } + + public void setGas(String gas) { + this.gas = gas; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsAlarm() { + return isAlarm; + } + + public void setIsAlarm(String isAlarm) { + this.isAlarm = isAlarm; + } + + public String getLagitude() { + return lagitude; + } + + public void setLagitude(String lagitude) { + this.lagitude = lagitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getPitch() { + return pitch; + } + + public void setPitch(String pitch) { + this.pitch = pitch; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + } +} diff --git a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt index 519ab45..2eefdda 100644 --- a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt @@ -62,6 +62,15 @@ ): String /** + * 任务详情 + */ + @POST("/system/busPatrolTask/detail") + suspend fun getTaskDetail( + @Header("token") token: String, + @Body requestBody: RequestBody + ): String + + /** * TODO 接口地址待完善 * 新增任务 */ diff --git a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt index fd9624c..ef9cab2 100644 --- a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt @@ -130,6 +130,18 @@ } /** + * 任务详情 + */ + suspend fun getTaskDetail(taskId: String): String { + val param = JsonObject() + param.addProperty("id", taskId) + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + return api.getTaskDetail(AuthenticationHelper.token, requestBody) + } + + /** * 获取巡检车列表 */ suspend fun getVehicles(): String { diff --git a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt index bc0002b..e320cb9 100644 --- a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt @@ -1,5 +1,6 @@ package com.casic.br.ktd.fragment +import android.annotation.SuppressLint import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -37,6 +38,7 @@ import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton import org.json.JSONObject +@SuppressLint("SetTextI18n") class HomePageFragment : KotlinBaseFragment(), AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, Handler.Callback { @@ -50,7 +52,6 @@ private var taskModels: MutableList = ArrayList() private val handlerVehicleCode = 2023082501 private val handlerDeviceCode = 2023082502 - private val handlerTaskCode = 2023082503 override fun initViewBinding( inflater: LayoutInflater, container: ViewGroup? @@ -117,11 +118,39 @@ } } } - - // val message = weakReferenceHandler.obtainMessage() -// message.what = handlerTaskCode -// message.obj = it -// weakReferenceHandler.sendMessage(message) + taskViewModel.detailResult.observe(this) { + if (it.code == 200) { + //设置起点 + val first = it.data.first() + addMarker( + LatLng(first.lagitude.toDouble(), first.longitude.toDouble()), + "", + R.mipmap.start + ) + //设置终点 + val last = it.data.last() + addMarker( + LatLng(last.lagitude.toDouble(), last.longitude.toDouble()), + "", + R.mipmap.end + ) + it.data.forEach { task -> + if (task.lagitude.isNotEmpty() && task.longitude.isNotEmpty()) { + //瞄点画线 + val latLngPoints = ArrayList() + latLngPoints.add( + LatLng(task.lagitude.toDouble(), task.longitude.toDouble()) + ) + aMap.addPolyline( + PolylineOptions() + .addAll(latLngPoints) + .width(10.toFloat()) + .color(Color.RED) + ) + } + } + } + } } override fun handleMessage(msg: Message): Boolean { @@ -149,6 +178,11 @@ addMarker(latLng, hashMap.toJson(), marker) + //移动到巡检车经纬度 + val cameraPosition = CameraPosition(latLng, 16f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + /** * 地图PopupWindow数据绑定 * ****/ @@ -177,14 +211,6 @@ deviceModelView.text = "云台型号:${deviceModel.deviceModel}" } } - - handlerTaskCode -> { - if (isInfoWindowShow) { - routeView.setOnClickListener { - - } - } - } } return true } @@ -206,7 +232,6 @@ private lateinit var deviceModelView: TextView private lateinit var timeView: TextView private lateinit var locationView: TextView - private lateinit var routeView: QMUIRoundButton override fun getInfoWindow(marker: Marker?): View { isInfoWindowShow = true @@ -220,7 +245,7 @@ deviceModelView = v.findViewById(R.id.deviceModelView) timeView = v.findViewById(R.id.timeView) locationView = v.findViewById(R.id.locationView) - routeView = v.findViewById(R.id.routeView) + val routeView = v.findViewById(R.id.routeView) if (!marker?.snippet.isNullOrEmpty()) { val hashMapJson = marker?.snippet!! @@ -248,6 +273,10 @@ locationView.text = "结束时间:${task.endDate}" } } + + routeView.setOnClickListener { + taskViewModel.getTaskDetail(id) + } } } @@ -259,34 +288,7 @@ } override fun initEvent() { - //移动到巡检起始经纬度 - val cameraPosition = CameraPosition(LatLng(39.914199, 116.265785), 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) - //设置起点 - addMarker(LatLng(39.914885, 116.272312), "", R.mipmap.start) - //设置终点 - addMarker(LatLng(39.914716, 116.265097), "", R.mipmap.end) - //瞄点画线 - val latLngPoints = ArrayList() - latLngPoints.add(LatLng(39.914885, 116.272312)) - latLngPoints.add(LatLng(39.915148, 116.272312)) - latLngPoints.add(LatLng(39.915399, 116.272302)) - latLngPoints.add(LatLng(39.915436, 116.271787)) - latLngPoints.add(LatLng(39.915477, 116.270886)) - latLngPoints.add(LatLng(39.915477, 116.269968)) - latLngPoints.add(LatLng(39.915469, 116.269544)) - latLngPoints.add(LatLng(39.915481, 116.269196)) - latLngPoints.add(LatLng(39.915452, 116.268472)) - latLngPoints.add(LatLng(39.915444, 116.267722)) - latLngPoints.add(LatLng(39.915415, 116.266755)) - latLngPoints.add(LatLng(39.915403, 116.266165)) - latLngPoints.add(LatLng(39.915395, 116.265703)) - latLngPoints.add(LatLng(39.915366, 116.265119)) - latLngPoints.add(LatLng(39.914716, 116.265097)) - aMap.addPolyline( - PolylineOptions().addAll(latLngPoints).width(10.toFloat()).color(Color.RED) - ) + } diff --git a/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java new file mode 100644 index 0000000..62736d1 --- /dev/null +++ b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java @@ -0,0 +1,154 @@ +package com.casic.br.ktd.model; + +import java.util.List; + +public class TaskDetailModel { + + private Integer code; + private List data; + private String message; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private String alarmCode; + private String deviceStatus; + private String direction; + private String gas; + private String id; + private String isAlarm; + private String lagitude; + private String longitude; + private String pitch; + private String position; + private String speed; + private String taskId; + private String ts; + + public String getAlarmCode() { + return alarmCode; + } + + public void setAlarmCode(String alarmCode) { + this.alarmCode = alarmCode; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getGas() { + return gas; + } + + public void setGas(String gas) { + this.gas = gas; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsAlarm() { + return isAlarm; + } + + public void setIsAlarm(String isAlarm) { + this.isAlarm = isAlarm; + } + + public String getLagitude() { + return lagitude; + } + + public void setLagitude(String lagitude) { + this.lagitude = lagitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getPitch() { + return pitch; + } + + public void setPitch(String pitch) { + this.pitch = pitch; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + } +} diff --git a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt index 519ab45..2eefdda 100644 --- a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt @@ -62,6 +62,15 @@ ): String /** + * 任务详情 + */ + @POST("/system/busPatrolTask/detail") + suspend fun getTaskDetail( + @Header("token") token: String, + @Body requestBody: RequestBody + ): String + + /** * TODO 接口地址待完善 * 新增任务 */ diff --git a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt index fd9624c..ef9cab2 100644 --- a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt @@ -130,6 +130,18 @@ } /** + * 任务详情 + */ + suspend fun getTaskDetail(taskId: String): String { + val param = JsonObject() + param.addProperty("id", taskId) + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + return api.getTaskDetail(AuthenticationHelper.token, requestBody) + } + + /** * 获取巡检车列表 */ suspend fun getVehicles(): String { diff --git a/app/src/main/java/com/casic/br/ktd/vm/TaskViewModel.kt b/app/src/main/java/com/casic/br/ktd/vm/TaskViewModel.kt index 768925b..bbf00af 100644 --- a/app/src/main/java/com/casic/br/ktd/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/br/ktd/vm/TaskViewModel.kt @@ -5,6 +5,7 @@ import com.casic.br.ktd.extensions.separateResponseCode import com.casic.br.ktd.extensions.toErrorMessage import com.casic.br.ktd.model.ActionResultModel +import com.casic.br.ktd.model.TaskDetailModel import com.casic.br.ktd.model.TaskListModel import com.casic.br.ktd.retrofit.RetrofitServiceManager import com.google.gson.Gson @@ -22,6 +23,7 @@ private val gson by lazy { Gson() } val taskList = MutableLiveData() val addTaskResult = MutableLiveData() + val detailResult = MutableLiveData() fun getTasksByPage( beginDate: String, endDate: String, taskName: String, taskCode: String, offset: Int @@ -71,4 +73,16 @@ }, { loadState.value = LoadState.Fail }) + + fun getTaskDetail(taskId: String) = launch({ + val response = RetrofitServiceManager.getTaskDetail(taskId) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + addTaskResult.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } + }, { + it.printStackTrace() + }) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt index bc0002b..e320cb9 100644 --- a/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/br/ktd/fragment/HomePageFragment.kt @@ -1,5 +1,6 @@ package com.casic.br.ktd.fragment +import android.annotation.SuppressLint import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -37,6 +38,7 @@ import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton import org.json.JSONObject +@SuppressLint("SetTextI18n") class HomePageFragment : KotlinBaseFragment(), AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, Handler.Callback { @@ -50,7 +52,6 @@ private var taskModels: MutableList = ArrayList() private val handlerVehicleCode = 2023082501 private val handlerDeviceCode = 2023082502 - private val handlerTaskCode = 2023082503 override fun initViewBinding( inflater: LayoutInflater, container: ViewGroup? @@ -117,11 +118,39 @@ } } } - - // val message = weakReferenceHandler.obtainMessage() -// message.what = handlerTaskCode -// message.obj = it -// weakReferenceHandler.sendMessage(message) + taskViewModel.detailResult.observe(this) { + if (it.code == 200) { + //设置起点 + val first = it.data.first() + addMarker( + LatLng(first.lagitude.toDouble(), first.longitude.toDouble()), + "", + R.mipmap.start + ) + //设置终点 + val last = it.data.last() + addMarker( + LatLng(last.lagitude.toDouble(), last.longitude.toDouble()), + "", + R.mipmap.end + ) + it.data.forEach { task -> + if (task.lagitude.isNotEmpty() && task.longitude.isNotEmpty()) { + //瞄点画线 + val latLngPoints = ArrayList() + latLngPoints.add( + LatLng(task.lagitude.toDouble(), task.longitude.toDouble()) + ) + aMap.addPolyline( + PolylineOptions() + .addAll(latLngPoints) + .width(10.toFloat()) + .color(Color.RED) + ) + } + } + } + } } override fun handleMessage(msg: Message): Boolean { @@ -149,6 +178,11 @@ addMarker(latLng, hashMap.toJson(), marker) + //移动到巡检车经纬度 + val cameraPosition = CameraPosition(latLng, 16f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + /** * 地图PopupWindow数据绑定 * ****/ @@ -177,14 +211,6 @@ deviceModelView.text = "云台型号:${deviceModel.deviceModel}" } } - - handlerTaskCode -> { - if (isInfoWindowShow) { - routeView.setOnClickListener { - - } - } - } } return true } @@ -206,7 +232,6 @@ private lateinit var deviceModelView: TextView private lateinit var timeView: TextView private lateinit var locationView: TextView - private lateinit var routeView: QMUIRoundButton override fun getInfoWindow(marker: Marker?): View { isInfoWindowShow = true @@ -220,7 +245,7 @@ deviceModelView = v.findViewById(R.id.deviceModelView) timeView = v.findViewById(R.id.timeView) locationView = v.findViewById(R.id.locationView) - routeView = v.findViewById(R.id.routeView) + val routeView = v.findViewById(R.id.routeView) if (!marker?.snippet.isNullOrEmpty()) { val hashMapJson = marker?.snippet!! @@ -248,6 +273,10 @@ locationView.text = "结束时间:${task.endDate}" } } + + routeView.setOnClickListener { + taskViewModel.getTaskDetail(id) + } } } @@ -259,34 +288,7 @@ } override fun initEvent() { - //移动到巡检起始经纬度 - val cameraPosition = CameraPosition(LatLng(39.914199, 116.265785), 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) - //设置起点 - addMarker(LatLng(39.914885, 116.272312), "", R.mipmap.start) - //设置终点 - addMarker(LatLng(39.914716, 116.265097), "", R.mipmap.end) - //瞄点画线 - val latLngPoints = ArrayList() - latLngPoints.add(LatLng(39.914885, 116.272312)) - latLngPoints.add(LatLng(39.915148, 116.272312)) - latLngPoints.add(LatLng(39.915399, 116.272302)) - latLngPoints.add(LatLng(39.915436, 116.271787)) - latLngPoints.add(LatLng(39.915477, 116.270886)) - latLngPoints.add(LatLng(39.915477, 116.269968)) - latLngPoints.add(LatLng(39.915469, 116.269544)) - latLngPoints.add(LatLng(39.915481, 116.269196)) - latLngPoints.add(LatLng(39.915452, 116.268472)) - latLngPoints.add(LatLng(39.915444, 116.267722)) - latLngPoints.add(LatLng(39.915415, 116.266755)) - latLngPoints.add(LatLng(39.915403, 116.266165)) - latLngPoints.add(LatLng(39.915395, 116.265703)) - latLngPoints.add(LatLng(39.915366, 116.265119)) - latLngPoints.add(LatLng(39.914716, 116.265097)) - aMap.addPolyline( - PolylineOptions().addAll(latLngPoints).width(10.toFloat()).color(Color.RED) - ) + } diff --git a/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java new file mode 100644 index 0000000..62736d1 --- /dev/null +++ b/app/src/main/java/com/casic/br/ktd/model/TaskDetailModel.java @@ -0,0 +1,154 @@ +package com.casic.br.ktd.model; + +import java.util.List; + +public class TaskDetailModel { + + private Integer code; + private List data; + private String message; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public static class DataModel { + private String alarmCode; + private String deviceStatus; + private String direction; + private String gas; + private String id; + private String isAlarm; + private String lagitude; + private String longitude; + private String pitch; + private String position; + private String speed; + private String taskId; + private String ts; + + public String getAlarmCode() { + return alarmCode; + } + + public void setAlarmCode(String alarmCode) { + this.alarmCode = alarmCode; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getGas() { + return gas; + } + + public void setGas(String gas) { + this.gas = gas; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getIsAlarm() { + return isAlarm; + } + + public void setIsAlarm(String isAlarm) { + this.isAlarm = isAlarm; + } + + public String getLagitude() { + return lagitude; + } + + public void setLagitude(String lagitude) { + this.lagitude = lagitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getPitch() { + return pitch; + } + + public void setPitch(String pitch) { + this.pitch = pitch; + } + + public String getPosition() { + return position; + } + + public void setPosition(String position) { + this.position = position; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + } +} diff --git a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt index 519ab45..2eefdda 100644 --- a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitService.kt @@ -62,6 +62,15 @@ ): String /** + * 任务详情 + */ + @POST("/system/busPatrolTask/detail") + suspend fun getTaskDetail( + @Header("token") token: String, + @Body requestBody: RequestBody + ): String + + /** * TODO 接口地址待完善 * 新增任务 */ diff --git a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt index fd9624c..ef9cab2 100644 --- a/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/br/ktd/retrofit/RetrofitServiceManager.kt @@ -130,6 +130,18 @@ } /** + * 任务详情 + */ + suspend fun getTaskDetail(taskId: String): String { + val param = JsonObject() + param.addProperty("id", taskId) + val requestBody = param.toString().toRequestBody( + "application/json;charset=UTF-8".toMediaType() + ) + return api.getTaskDetail(AuthenticationHelper.token, requestBody) + } + + /** * 获取巡检车列表 */ suspend fun getVehicles(): String { diff --git a/app/src/main/java/com/casic/br/ktd/vm/TaskViewModel.kt b/app/src/main/java/com/casic/br/ktd/vm/TaskViewModel.kt index 768925b..bbf00af 100644 --- a/app/src/main/java/com/casic/br/ktd/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/br/ktd/vm/TaskViewModel.kt @@ -5,6 +5,7 @@ import com.casic.br.ktd.extensions.separateResponseCode import com.casic.br.ktd.extensions.toErrorMessage import com.casic.br.ktd.model.ActionResultModel +import com.casic.br.ktd.model.TaskDetailModel import com.casic.br.ktd.model.TaskListModel import com.casic.br.ktd.retrofit.RetrofitServiceManager import com.google.gson.Gson @@ -22,6 +23,7 @@ private val gson by lazy { Gson() } val taskList = MutableLiveData() val addTaskResult = MutableLiveData() + val detailResult = MutableLiveData() fun getTasksByPage( beginDate: String, endDate: String, taskName: String, taskCode: String, offset: Int @@ -71,4 +73,16 @@ }, { loadState.value = LoadState.Fail }) + + fun getTaskDetail(taskId: String) = launch({ + val response = RetrofitServiceManager.getTaskDetail(taskId) + val responseCode = response.separateResponseCode() + if (responseCode == 200) { + addTaskResult.value = gson.fromJson( + response, object : TypeToken() {}.type + ) + } + }, { + it.printStackTrace() + }) } \ No newline at end of file diff --git a/app/src/main/res/layout/popu_map_car_window.xml b/app/src/main/res/layout/popu_map_car_window.xml index e0dbcae..71ba8b7 100644 --- a/app/src/main/res/layout/popu_map_car_window.xml +++ b/app/src/main/res/layout/popu_map_car_window.xml @@ -8,7 +8,7 @@ android:padding="@dimen/dp_10">