refactor(user): 重构司机信息存储逻辑
- 将司机信息从 MMKV 迁移到 Room 数据库 - 新增 DriverInfoBean 实体类和 DriverInfoDao接口 - 更新 GlobalData 中的 driverInfo 相关逻辑- 修改相关 Activity 和 ViewModel 中的代码,使用新的数据库存储方式- 优化了司机信息的获取和更新流程
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<uses-sdk tools:overrideLibrary="androidx.camera.view,androidx.camera:camera-camera2,androidx.camera.camera2,androidx.camera.lifecycle,androidx.camera.core" />
|
<uses-sdk tools:overrideLibrary="androidx.camera.view,androidx.camera:camera-camera2,androidx.camera.camera2,androidx.camera.lifecycle,androidx.camera.core" />
|
||||||
<permission
|
<permission
|
||||||
android:name="${applicationId}.permission.JPUSH_MESSAGE"
|
android:name="com.za.rescue.dealer.permission.JPUSH_MESSAGE"
|
||||||
android:protectionLevel="signature" /> <!-- 位置相关权限 -->
|
android:protectionLevel="signature" /> <!-- 位置相关权限 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
@ -243,7 +243,10 @@
|
|||||||
<category android:name="${applicationId}" />
|
<category android:name="${applicationId}" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
<service
|
||||||
|
android:name="cn.jpush.android.service.DaemonService"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -78,9 +78,9 @@ object AppConfig {
|
|||||||
*/
|
*/
|
||||||
fun getTrainUrl(keyWord: String = ""): String {
|
fun getTrainUrl(keyWord: String = ""): String {
|
||||||
if (keyWord.isEmpty()) {
|
if (keyWord.isEmpty()) {
|
||||||
return TRAIN_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfo?.userId}"
|
return TRAIN_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfoBean?.userId}"
|
||||||
}
|
}
|
||||||
return TRAIN_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfo?.userId}&keyword=$keyWord"
|
return TRAIN_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfoBean?.userId}&keyword=$keyWord"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,8 +91,8 @@ object AppConfig {
|
|||||||
*/
|
*/
|
||||||
fun getDocmentUrl(keyWord: String = ""): String {
|
fun getDocmentUrl(keyWord: String = ""): String {
|
||||||
if (keyWord.isEmpty()) {
|
if (keyWord.isEmpty()) {
|
||||||
return DOCMENT_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfo?.userId}"
|
return DOCMENT_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfoBean?.userId}"
|
||||||
}
|
}
|
||||||
return DOCMENT_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfo?.userId}&keyword=$keyWord"
|
return DOCMENT_URL + "?token=${GlobalData.token}&driverId=${GlobalData.driverInfoBean?.userId}&keyword=$keyWord"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,64 +12,14 @@ data class DriverInfo(
|
|||||||
var userName : String? = null, //用户姓名
|
var userName : String? = null, //用户姓名
|
||||||
var userPhone : String? = null, //用户手机号
|
var userPhone : String? = null, //用户手机号
|
||||||
var callphone : String? = null,
|
var callphone : String? = null,
|
||||||
var supplierId : String? = null, //经销商id
|
var supplierId : Int? = null, //经销商id
|
||||||
var supplierName : String? = null, //经销商名称
|
var supplierName : String? = null, //经销商名称
|
||||||
var supplierType : Int? = null, //经销商类型 1子公司 2供应商
|
var supplierType : Int? = null, //经销商类型 1子公司 2供应商
|
||||||
var loginLogId : Int? = null,
|
var loginLogId : Int? = null,
|
||||||
var serviceList : List<String>? = null, //车辆服务列表
|
var serviceList : List<String>? = null, //车辆服务列表
|
||||||
var assistUserCode : String? = null,
|
var assistUserCode : String? = null,
|
||||||
val authStatus : Int? = null, // 0 未认证 1 已认证
|
val authStatus : Int? = null, // 0 未认证 1 已认证
|
||||||
) : Parcelable {
|
)
|
||||||
constructor(parcel : Parcel) : this(parcel.readString(),
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readValue(Int::class.java.classLoader) as? Int,
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readValue(Int::class.java.classLoader) as? Int,
|
|
||||||
parcel.readValue(Int::class.java.classLoader) as? Int,
|
|
||||||
parcel.createStringArrayList(),
|
|
||||||
parcel.readString(),
|
|
||||||
parcel.readValue(Int::class.java.classLoader) as? Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun writeToParcel(parcel : Parcel, flags : Int) {
|
|
||||||
parcel.writeString(userPortrait)
|
|
||||||
parcel.writeString(token)
|
|
||||||
parcel.writeString(rongyunToken)
|
|
||||||
parcel.writeString(logTime)
|
|
||||||
parcel.writeValue(userId)
|
|
||||||
parcel.writeString(userName)
|
|
||||||
parcel.writeString(userPhone)
|
|
||||||
parcel.writeString(callphone)
|
|
||||||
parcel.writeString(supplierId)
|
|
||||||
parcel.writeString(supplierName)
|
|
||||||
parcel.writeValue(supplierType)
|
|
||||||
parcel.writeValue(loginLogId)
|
|
||||||
parcel.writeStringList(serviceList)
|
|
||||||
parcel.writeString(assistUserCode)
|
|
||||||
parcel.writeValue(authStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents() : Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<DriverInfo> {
|
|
||||||
override fun createFromParcel(parcel : Parcel) : DriverInfo {
|
|
||||||
return DriverInfo(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size : Int) : Array<DriverInfo?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
data class GeneralInfo(
|
data class GeneralInfo(
|
||||||
var userId : Int? = null, //用户id
|
var userId : Int? = null, //用户id
|
||||||
@ -214,3 +164,56 @@ data class LoginWithTaskBean(val supplierName : String? = null,
|
|||||||
val jobNumber : String? = null,
|
val jobNumber : String? = null,
|
||||||
val vehicleId : Int? = null,
|
val vehicleId : Int? = null,
|
||||||
val supplierType : Int? = null)
|
val supplierType : Int? = null)
|
||||||
|
|
||||||
|
data class AppNewDriverInfoDTO(val userId : Int? = null,
|
||||||
|
val userName : String? = null,
|
||||||
|
val userPhone : String? = null,
|
||||||
|
val supplierCode : String? = null,
|
||||||
|
val appLoginCode : String? = null,
|
||||||
|
val supplierId : Int? = null,
|
||||||
|
val supplierName : String? = null,
|
||||||
|
val supplierType : Int? = null,
|
||||||
|
val authStatus : Int? = null,
|
||||||
|
val tiedVehicle : VehicleInfo? = null, //绑定的车辆,如果该服务商下面绑定的有车辆,则返回绑定车辆信息
|
||||||
|
val loginTime : String? = null) : Parcelable {
|
||||||
|
constructor(parcel : Parcel) : this(parcel.readValue(Int::class.java.classLoader) as? Int,
|
||||||
|
parcel.readString(),
|
||||||
|
parcel.readString(),
|
||||||
|
parcel.readString(),
|
||||||
|
parcel.readString(),
|
||||||
|
parcel.readValue(Int::class.java.classLoader) as? Int,
|
||||||
|
parcel.readString(),
|
||||||
|
parcel.readValue(Int::class.java.classLoader) as? Int,
|
||||||
|
parcel.readValue(Int::class.java.classLoader) as? Int,
|
||||||
|
parcel.readParcelable(VehicleInfo::class.java.classLoader),
|
||||||
|
parcel.readString()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun writeToParcel(parcel : Parcel, flags : Int) {
|
||||||
|
parcel.writeValue(userId)
|
||||||
|
parcel.writeString(userName)
|
||||||
|
parcel.writeString(userPhone)
|
||||||
|
parcel.writeString(supplierCode)
|
||||||
|
parcel.writeString(appLoginCode)
|
||||||
|
parcel.writeValue(supplierId)
|
||||||
|
parcel.writeString(supplierName)
|
||||||
|
parcel.writeValue(supplierType)
|
||||||
|
parcel.writeValue(authStatus)
|
||||||
|
parcel.writeParcelable(tiedVehicle, flags)
|
||||||
|
parcel.writeString(loginTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun describeContents() : Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object CREATOR : Parcelable.Creator<AppNewDriverInfoDTO> {
|
||||||
|
override fun createFromParcel(parcel : Parcel) : AppNewDriverInfoDTO {
|
||||||
|
return AppNewDriverInfoDTO(parcel)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun newArray(size : Int) : Array<AppNewDriverInfoDTO?> {
|
||||||
|
return arrayOfNulls(size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,16 +4,16 @@ import android.os.Parcel
|
|||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
|
||||||
data class VehicleInfo(
|
data class VehicleInfo(
|
||||||
var vehicleId: Int? = null, //车辆id
|
var vehicleId : Int? = null, //车辆id
|
||||||
var vehicleName: String? = null,//车辆名称(车牌号)
|
var vehicleName : String? = null, //车辆名称(车牌号)
|
||||||
var userName: String? = null, //当前用车司机姓名(工号)
|
var userName : String? = null, //当前用车司机姓名(工号)
|
||||||
var userPhone: String? = null, //当前用车司机电话
|
var userPhone : String? = null, //当前用车司机电话
|
||||||
var status: Int? = null, //车辆状态 0 不在线 1 在线
|
var status : Int? = null, //车辆状态 0 不在线 1 在线
|
||||||
val plateNumber: String? = null, //车牌号
|
val plateNumber : String? = null, //车牌号
|
||||||
var vehicleState: Int? = null, //车辆是否空闲 0 空闲 1 忙碌 2置忙 8维修
|
var vehicleState : Int? = null, //车辆是否空闲 0 空闲 1 忙碌 2置忙 8维修
|
||||||
var terminalId: Long? = null, //车辆高德tid
|
var terminalId : Long? = null, //车辆高德tid
|
||||||
var exitMileage: Int? = null, //上次退出公里数
|
var exitMileage : Int? = null, //上次退出公里数
|
||||||
var supplierType: Int? = null, //经销商类型
|
var supplierType : Int? = null, //经销商类型
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
constructor(parcel : Parcel) : this(parcel.readValue(Int::class.java.classLoader) as? Int,
|
constructor(parcel : Parcel) : this(parcel.readValue(Int::class.java.classLoader) as? Int,
|
||||||
parcel.readString(),
|
parcel.readString(),
|
||||||
@ -54,3 +54,33 @@ data class VehicleInfo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
data class LastLoginBean(val phone : String? = null,
|
||||||
|
val supplierId : Int? = null,
|
||||||
|
val vehicleId : Int?):Parcelable {
|
||||||
|
constructor(parcel : Parcel) : this(parcel.readString(),
|
||||||
|
parcel.readValue(Int::class.java.classLoader) as? Int,
|
||||||
|
parcel.readValue(Int::class.java.classLoader) as? Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun writeToParcel(parcel : Parcel, flags : Int) {
|
||||||
|
parcel.writeString(phone)
|
||||||
|
parcel.writeValue(supplierId)
|
||||||
|
parcel.writeValue(vehicleId)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun describeContents() : Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object CREATOR : Parcelable.Creator<LastLoginBean> {
|
||||||
|
override fun createFromParcel(parcel : Parcel) : LastLoginBean {
|
||||||
|
return LastLoginBean(parcel)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun newArray(size : Int) : Array<LastLoginBean?> {
|
||||||
|
return arrayOfNulls(size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
package com.za.bean.request
|
||||||
|
|
||||||
|
data class AppNewOrderVoiceRequest(var voiceWords : String? = null)
|
@ -4,10 +4,9 @@ import android.app.Application
|
|||||||
import com.amap.api.location.AMapLocation
|
import com.amap.api.location.AMapLocation
|
||||||
import com.blankj.utilcode.util.AppUtils
|
import com.blankj.utilcode.util.AppUtils
|
||||||
import com.tencent.mmkv.MMKV
|
import com.tencent.mmkv.MMKV
|
||||||
import com.za.bean.DriverInfo
|
|
||||||
import com.za.bean.VehicleInfo
|
|
||||||
import com.za.bean.db.order.OrderInfo
|
import com.za.bean.db.order.OrderInfo
|
||||||
import com.za.room.RoomHelper
|
import com.za.room.RoomHelper
|
||||||
|
import com.za.room.db.user.DriverInfoBean
|
||||||
|
|
||||||
object GlobalData {
|
object GlobalData {
|
||||||
lateinit var application : Application
|
lateinit var application : Application
|
||||||
@ -16,20 +15,19 @@ object GlobalData {
|
|||||||
|
|
||||||
var token : String? = null
|
var token : String? = null
|
||||||
get() {
|
get() {
|
||||||
return MMKV.defaultMMKV().decodeString("TOKEN", null)
|
return MMKV.defaultMMKV().decodeString("ZD_TOKEN", null)
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
MMKV.defaultMMKV().encode("TOKEN", value)
|
MMKV.defaultMMKV().encode("ZD_TOKEN", value)
|
||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
//记录上次登录的手机号
|
var regid : String? = null
|
||||||
var lastLoginPhone : String? = null
|
|
||||||
get() {
|
get() {
|
||||||
return MMKV.defaultMMKV().decodeString("lastLoginPhone", null)
|
return MMKV.defaultMMKV().decodeString("regid", null)
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
MMKV.defaultMMKV().encode("lastLoginPhone", value)
|
MMKV.defaultMMKV().encode("regid", value)
|
||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,25 +40,19 @@ object GlobalData {
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
var driverInfo : DriverInfo? = null
|
//新订单是否已经被处理
|
||||||
|
var isHandlerNewOrder : Boolean? = false
|
||||||
|
|
||||||
|
var driverInfoBean : DriverInfoBean? = null
|
||||||
get() {
|
get() {
|
||||||
return MMKV.defaultMMKV().decodeParcelable("driverInfo", DriverInfo::class.java)
|
val driverInfoBean = RoomHelper.db?.driverInfoDao()?.getDriverInfoFromUserId()
|
||||||
|
field = driverInfoBean
|
||||||
|
return driverInfoBean
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
MMKV.defaultMMKV().encode("driverInfo", value)
|
RoomHelper.db?.driverInfoDao()?.updateDriverInfo(value)
|
||||||
field = value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var vehicleInfo : VehicleInfo? = null
|
|
||||||
get() {
|
|
||||||
return MMKV.defaultMMKV().decodeParcelable("vehicleInfo", VehicleInfo::class.java)
|
|
||||||
}
|
|
||||||
set(value) {
|
|
||||||
MMKV.defaultMMKV().encode("vehicleInfo", value)
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var currentOrder : OrderInfo? = null
|
var currentOrder : OrderInfo? = null
|
||||||
get() {
|
get() {
|
||||||
return MMKV.defaultMMKV().decodeParcelable("currentOrder", OrderInfo::class.java)
|
return MMKV.defaultMMKV().decodeParcelable("currentOrder", OrderInfo::class.java)
|
||||||
@ -77,11 +69,10 @@ object GlobalData {
|
|||||||
|
|
||||||
var currentLocation : AMapLocation? = null
|
var currentLocation : AMapLocation? = null
|
||||||
get() {
|
get() {
|
||||||
return MMKV.defaultMMKV().decodeParcelable("currentLocation", AMapLocation::class.java)
|
return field
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.time = System.currentTimeMillis()
|
value?.time = System.currentTimeMillis()
|
||||||
MMKV.defaultMMKV().encode("currentLocation", value)
|
|
||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +88,6 @@ object GlobalData {
|
|||||||
fun clearUserCache() {
|
fun clearUserCache() {
|
||||||
token = null
|
token = null
|
||||||
aesKey = null
|
aesKey = null
|
||||||
driverInfo = null
|
|
||||||
vehicleInfo = null
|
|
||||||
currentLocation = null
|
currentLocation = null
|
||||||
loginTime = null
|
loginTime = null
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.za.common
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.tencent.bugly.Bugly
|
import com.tencent.bugly.Bugly
|
||||||
import com.tencent.mmkv.MMKV
|
import com.tencent.mmkv.MMKV
|
||||||
import com.tencent.mmkv.MMKVLogLevel
|
|
||||||
import com.za.base.AppConfig
|
import com.za.base.AppConfig
|
||||||
import com.za.common.log.LogUtil
|
import com.za.common.log.LogUtil
|
||||||
import com.za.room.RoomHelper
|
import com.za.room.RoomHelper
|
||||||
@ -11,6 +10,7 @@ import com.za.service.location.ZdLocationManager
|
|||||||
|
|
||||||
object ZDManager {
|
object ZDManager {
|
||||||
lateinit var application : Application
|
lateinit var application : Application
|
||||||
|
|
||||||
fun init(application : Application, isRelease : Boolean = false) {
|
fun init(application : Application, isRelease : Boolean = false) {
|
||||||
this.application = application
|
this.application = application
|
||||||
thirdSdkInit(isRelease)
|
thirdSdkInit(isRelease)
|
||||||
@ -22,8 +22,9 @@ object ZDManager {
|
|||||||
} else {
|
} else {
|
||||||
AppConfig.crm1()
|
AppConfig.crm1()
|
||||||
}
|
}
|
||||||
GlobalData.application = application
|
GlobalData.application = application // 在 Application 中初始化 MMKV,所有进程共享同一存储路径
|
||||||
MMKV.initialize(application, MMKVLogLevel.LevelInfo)
|
val rootDir = application.filesDir.absolutePath + "/mmkv"
|
||||||
|
MMKV.initialize(application, rootDir)
|
||||||
Bugly.init(application, "6972a6b56d", true)
|
Bugly.init(application, "6972a6b56d", true)
|
||||||
LogUtil.init(application)
|
LogUtil.init(application)
|
||||||
RoomHelper.init(application)
|
RoomHelper.init(application)
|
||||||
|
@ -15,7 +15,6 @@ import com.blankj.utilcode.util.FileUtils
|
|||||||
import com.blankj.utilcode.util.TimeUtils
|
import com.blankj.utilcode.util.TimeUtils
|
||||||
import com.za.common.GlobalData
|
import com.za.common.GlobalData
|
||||||
import com.za.common.util.AppFileManager
|
import com.za.common.util.AppFileManager
|
||||||
import com.za.servicing.BuildConfig
|
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -40,53 +39,49 @@ import java.util.concurrent.atomic.AtomicBoolean
|
|||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
|
||||||
object LogUtil {
|
object LogUtil {
|
||||||
private var context: Application? = null
|
private var context : Application? = null
|
||||||
private var logDestinationPath: String? = null
|
private var logDestinationPath : String? = null
|
||||||
private var orderLogDirPath: String? = null
|
private var orderLogDirPath : String? = null
|
||||||
private var normalLogDirPath: String? = null
|
private var normalLogDirPath : String? = null
|
||||||
private val coroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
private val coroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||||
private val logBuffer = StringBuilder()
|
private val logBuffer = StringBuilder()
|
||||||
private val isWriting = AtomicBoolean(false)
|
private val isWriting = AtomicBoolean(false)
|
||||||
|
|
||||||
fun init(context: Application) {
|
fun init(context : Application) {
|
||||||
this.context = context
|
this.context = context
|
||||||
|
|
||||||
logDestinationPath = AppFileManager.getLogPath(context).also { path ->
|
logDestinationPath = AppFileManager.getLogPath(context).also { path ->
|
||||||
createDirectoryIfNotExists(path)
|
createDirectoryIfNotExists(path)
|
||||||
orderLogDirPath = "$path${File.separator}order_log".also { createDirectoryIfNotExists(it) }
|
orderLogDirPath =
|
||||||
normalLogDirPath = "$path${File.separator}normal_log".also { createDirectoryIfNotExists(it) }
|
"$path${File.separator}order_log".also { createDirectoryIfNotExists(it) }
|
||||||
|
normalLogDirPath =
|
||||||
|
"$path${File.separator}normal_log".also { createDirectoryIfNotExists(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeWorkManager(context)
|
initializeWorkManager(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createDirectoryIfNotExists(path: String) {
|
private fun createDirectoryIfNotExists(path : String) {
|
||||||
File(path).apply { if (!exists()) mkdir() }
|
File(path).apply { if (! exists()) mkdir() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initializeWorkManager(context: Application) {
|
private fun initializeWorkManager(context : Application) {
|
||||||
if (!WorkManager.isInitialized()) {
|
if (! WorkManager.isInitialized()) {
|
||||||
WorkManager.initialize(context, Configuration.Builder()
|
WorkManager.initialize(context,
|
||||||
.setMinimumLoggingLevel(Log.INFO)
|
Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build())
|
||||||
.build())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkManager.getInstance(context).apply {
|
WorkManager.getInstance(context).apply {
|
||||||
cancelAllWorkByTag("logWorkRequest")
|
cancelAllWorkByTag("logWorkRequest")
|
||||||
enqueue(PeriodicWorkRequest.Builder(LogTask::class.java, 20, TimeUnit.MINUTES)
|
enqueue(PeriodicWorkRequest.Builder(LogTask::class.java, 20, TimeUnit.MINUTES)
|
||||||
.addTag("logWorkRequest")
|
.addTag("logWorkRequest").build())
|
||||||
.build())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print(tag: String, content: String) {
|
fun print(tag : String, content : String) {
|
||||||
val time = getCurrentTime()
|
val time = getCurrentTime()
|
||||||
val logEntry = "$time---$tag---$content\n"
|
val logEntry = "$time---$tag---$content\n"
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
Log.e("normal", "$tag---$content")
|
Log.e("normal", "$tag---$content")
|
||||||
}
|
|
||||||
|
|
||||||
synchronized(logBuffer) {
|
synchronized(logBuffer) {
|
||||||
logBuffer.append(logEntry)
|
logBuffer.append(logEntry)
|
||||||
}
|
}
|
||||||
@ -98,7 +93,7 @@ object LogUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print(tag: String, throwable: Throwable) {
|
fun print(tag : String, throwable : Throwable) {
|
||||||
val content = StringWriter()
|
val content = StringWriter()
|
||||||
val printWriter = PrintWriter(content)
|
val printWriter = PrintWriter(content)
|
||||||
throwable.printStackTrace(printWriter)
|
throwable.printStackTrace(printWriter)
|
||||||
@ -106,9 +101,9 @@ object LogUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun flushBuffer() = withContext(Dispatchers.IO) {
|
private suspend fun flushBuffer() = withContext(Dispatchers.IO) {
|
||||||
if (!isWriting.compareAndSet(false, true)) return@withContext
|
if (! isWriting.compareAndSet(false, true)) return@withContext
|
||||||
|
|
||||||
val logContent: String
|
val logContent : String
|
||||||
synchronized(logBuffer) {
|
synchronized(logBuffer) {
|
||||||
if (logBuffer.isEmpty()) {
|
if (logBuffer.isEmpty()) {
|
||||||
isWriting.set(false)
|
isWriting.set(false)
|
||||||
@ -124,7 +119,7 @@ object LogUtil {
|
|||||||
|
|
||||||
logFile.parentFile?.mkdirs()
|
logFile.parentFile?.mkdirs()
|
||||||
|
|
||||||
if (!logFile.exists()) {
|
if (! logFile.exists()) {
|
||||||
logFile.createNewFile()
|
logFile.createNewFile()
|
||||||
addLogHead(logFile, getCurrentTime())
|
addLogHead(logFile, getCurrentTime())
|
||||||
}
|
}
|
||||||
@ -137,24 +132,24 @@ object LogUtil {
|
|||||||
if (logFile.length() >= 8 * MemoryConstants.MB) {
|
if (logFile.length() >= 8 * MemoryConstants.MB) {
|
||||||
rotateLogFile(logFile)
|
rotateLogFile(logFile)
|
||||||
}
|
}
|
||||||
} catch (e: IOException) {
|
} catch (e : IOException) {
|
||||||
Log.e("LogUtil", "Error in flushBuffer: ${e.message}")
|
Log.e("LogUtil", "Error in flushBuffer: ${e.message}")
|
||||||
} catch (e: Exception) {
|
} catch (e : Exception) {
|
||||||
Log.e("LogUtil", "Error in flushBuffer: ${e.message}")
|
Log.e("LogUtil", "Error in flushBuffer: ${e.message}")
|
||||||
} finally {
|
} finally {
|
||||||
isWriting.set(false)
|
isWriting.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun rotateLogFile(file: File) {
|
private fun rotateLogFile(file : File) {
|
||||||
if (!file.exists()) return
|
if (! file.exists()) return
|
||||||
|
|
||||||
val newFileName = buildString {
|
val newFileName = buildString {
|
||||||
append(AppUtils.getAppVersionCode())
|
append(AppUtils.getAppVersionCode())
|
||||||
append("_")
|
append("_")
|
||||||
append(GlobalData.vehicleInfo?.vehicleName ?: "unknown")
|
append(GlobalData.driverInfoBean?.vehicleName ?: "unknown")
|
||||||
append("_")
|
append("_")
|
||||||
append(GlobalData.driverInfo?.userName ?: "unknown")
|
append(GlobalData.driverInfoBean?.userName ?: "unknown")
|
||||||
append("_")
|
append("_")
|
||||||
append(TimeUtils.getNowString())
|
append(TimeUtils.getNowString())
|
||||||
append(".txt")
|
append(".txt")
|
||||||
@ -164,32 +159,31 @@ object LogUtil {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (file.renameTo(newFile)) {
|
if (file.renameTo(newFile)) {
|
||||||
compressAndUploadLog(newFile)
|
compressAndUploadLog(newFile) // 创建新的日志文件
|
||||||
// 创建新的日志文件
|
|
||||||
file.createNewFile()
|
file.createNewFile()
|
||||||
addLogHead(file, getCurrentTime())
|
addLogHead(file, getCurrentTime())
|
||||||
} else {
|
} else {
|
||||||
print("LogUtil", "Failed to rename log file")
|
print("LogUtil", "Failed to rename log file")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e : Exception) {
|
||||||
print("LogUtil", "Error during log rotation: ${e.message}")
|
print("LogUtil", "Error during log rotation: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun compressAndUploadLog(logFile: File) = coroutineScope.launch {
|
private fun compressAndUploadLog(logFile : File) = coroutineScope.launch {
|
||||||
try {
|
try {
|
||||||
val compressedFile = File("${logFile.absolutePath}.7z")
|
val compressedFile = File("${logFile.absolutePath}.7z")
|
||||||
compress(logFile, compressedFile.absolutePath)
|
compress(logFile, compressedFile.absolutePath)
|
||||||
upload(logFile, compressedFile)
|
upload(logFile, compressedFile)
|
||||||
} catch (e: Exception) {
|
} catch (e : Exception) {
|
||||||
print("LogUtil", e.toString())
|
print("LogUtil", e.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteLog(file: File) {
|
private fun deleteLog(file : File) {
|
||||||
try {
|
try {
|
||||||
FileUtils.delete(file.absolutePath)
|
FileUtils.delete(file.absolutePath)
|
||||||
} catch (e: Exception) {
|
} catch (e : Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,7 +195,8 @@ object LogUtil {
|
|||||||
}
|
}
|
||||||
val fileName = "normal_log.txt"
|
val fileName = "normal_log.txt"
|
||||||
val file = File("$normalLogDirPath${File.separator}$fileName")
|
val file = File("$normalLogDirPath${File.separator}$fileName")
|
||||||
val reName = "${AppUtils.getAppVersionCode()}_${GlobalData.vehicleInfo?.vehicleName}_${GlobalData.driverInfo?.userName}_${TimeUtils.getNowString()}.txt"
|
val reName =
|
||||||
|
"${AppUtils.getAppVersionCode()}_${GlobalData.driverInfoBean?.vehicleName}_${GlobalData.driverInfoBean?.userName}_${TimeUtils.getNowString()}.txt"
|
||||||
val reNamePath = "$normalLogDirPath${File.separator}$reName"
|
val reNamePath = "$normalLogDirPath${File.separator}$reName"
|
||||||
file.renameTo(File(reNamePath))
|
file.renameTo(File(reNamePath))
|
||||||
normalLogDirPath?.let { it ->
|
normalLogDirPath?.let { it ->
|
||||||
@ -210,16 +205,16 @@ object LogUtil {
|
|||||||
deleteLog(it)
|
deleteLog(it)
|
||||||
return@thread
|
return@thread
|
||||||
}
|
}
|
||||||
if (it.exists() && !it.name.contains("normal_log")) {
|
if (it.exists() && ! it.name.contains("normal_log")) {
|
||||||
if (it.name.contains("7z")) {
|
if (it.name.contains("7z")) {
|
||||||
upload(null, desFile = it)
|
upload(null, desFile = it)
|
||||||
} else {
|
} else {
|
||||||
val zipNamePath = it.absolutePath + ".7z"
|
val zipNamePath = it.absolutePath + ".7z"
|
||||||
val zipFile = File(zipNamePath)
|
val zipFile = File(zipNamePath)
|
||||||
if (!zipFile.exists()) {
|
if (! zipFile.exists()) {
|
||||||
try {
|
try {
|
||||||
zipFile.createNewFile()
|
zipFile.createNewFile()
|
||||||
} catch (e: IOException) {
|
} catch (e : IOException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,63 +226,60 @@ object LogUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun compress(srcFile: File, desFilePath: String) {
|
private fun compress(srcFile : File, desFilePath : String) {
|
||||||
try {
|
try {
|
||||||
val out = XZCompressorOutputStream(FileOutputStream(desFilePath))
|
val out = XZCompressorOutputStream(FileOutputStream(desFilePath))
|
||||||
addToArchiveCompression(out, srcFile, File(desFilePath))
|
addToArchiveCompression(out, srcFile, File(desFilePath))
|
||||||
} catch (e: Exception) {
|
} catch (e : Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addToArchiveCompression(
|
private fun addToArchiveCompression(sevenZOutputFile : XZCompressorOutputStream,
|
||||||
sevenZOutputFile: XZCompressorOutputStream,
|
srcFile : File,
|
||||||
srcFile: File, desFile: File
|
desFile : File) {
|
||||||
) {
|
|
||||||
if (srcFile.isFile) {
|
if (srcFile.isFile) {
|
||||||
var inputStream: FileInputStream? = null
|
var inputStream : FileInputStream? = null
|
||||||
try {
|
try {
|
||||||
inputStream = FileInputStream(srcFile)
|
inputStream = FileInputStream(srcFile)
|
||||||
val b = ByteArray(2048)
|
val b = ByteArray(2048)
|
||||||
var count: Int
|
var count : Int
|
||||||
while (inputStream.read(b).also { count = it } != -1) {
|
while (inputStream.read(b).also { count = it } != - 1) {
|
||||||
sevenZOutputFile.write(b, 0, count)
|
sevenZOutputFile.write(b, 0, count)
|
||||||
}
|
}
|
||||||
sevenZOutputFile.close()
|
sevenZOutputFile.close()
|
||||||
inputStream.close()
|
inputStream.close()
|
||||||
upload(srcFile, desFile)
|
upload(srcFile, desFile)
|
||||||
} catch (e: Exception) {
|
} catch (e : Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
sevenZOutputFile.close()
|
sevenZOutputFile.close()
|
||||||
inputStream!!.close()
|
inputStream !!.close()
|
||||||
} catch (e: Exception) {
|
} catch (e : Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun upload(srcFile: File?, desFile: File) {
|
private fun upload(srcFile : File?, desFile : File) {
|
||||||
val requestBody: RequestBody = desFile.asRequestBody("multipart/form-data".toMediaType())
|
val requestBody : RequestBody = desFile.asRequestBody("multipart/form-data".toMediaType())
|
||||||
val part = MultipartBody.Part.createFormData("file", desFile.name, requestBody)
|
val part = MultipartBody.Part.createFormData("file", desFile.name, requestBody)
|
||||||
|
|
||||||
val disposable = LogRetrofitHelper.getDefaultService()
|
val disposable =
|
||||||
.uploadLog(part, desFile.name, "rescue-app")
|
LogRetrofitHelper.getDefaultService().uploadLog(part, desFile.name, "rescue-app")
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io()).subscribe({ it ->
|
||||||
.subscribe({ it ->
|
|
||||||
if (it.code == 200) {
|
if (it.code == 200) {
|
||||||
deleteLog(desFile)
|
deleteLog(desFile)
|
||||||
}
|
}
|
||||||
srcFile?.let {
|
srcFile?.let {
|
||||||
deleteLog(it)
|
deleteLog(it)
|
||||||
}
|
}
|
||||||
}, {
|
}, {}, {})
|
||||||
}, {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addLogHead(file: File, time: String) {
|
private fun addLogHead(file : File, time : String) {
|
||||||
file.appendBytes("${time}---应用版本---${AppUtils.getAppVersionName()}".toByteArray())
|
file.appendBytes("${time}---应用版本---${AppUtils.getAppVersionName()}".toByteArray())
|
||||||
file.appendBytes("\n".toByteArray())
|
file.appendBytes("\n".toByteArray())
|
||||||
file.appendBytes("$time---系统版本---Android${DeviceUtils.getSDKVersionName()} ${DeviceUtils.getSDKVersionCode()}".toByteArray())
|
file.appendBytes("$time---系统版本---Android${DeviceUtils.getSDKVersionName()} ${DeviceUtils.getSDKVersionCode()}".toByteArray())
|
||||||
@ -298,18 +290,19 @@ object LogUtil {
|
|||||||
file.appendBytes("\n".toByteArray())
|
file.appendBytes("\n".toByteArray())
|
||||||
file.appendBytes("$time---APP名称---中道救援-司机端".toByteArray())
|
file.appendBytes("$time---APP名称---中道救援-司机端".toByteArray())
|
||||||
file.appendBytes("\n".toByteArray())
|
file.appendBytes("\n".toByteArray())
|
||||||
file.appendBytes("$time---车辆名称---${GlobalData.vehicleInfo?.vehicleName}".toByteArray())
|
file.appendBytes("$time---车辆名称---${GlobalData.driverInfoBean?.vehicleName}".toByteArray())
|
||||||
file.appendBytes("\n".toByteArray())
|
file.appendBytes("\n".toByteArray())
|
||||||
file.appendBytes("$time---司机名称---${GlobalData.driverInfo?.userName ?: GlobalData.vehicleInfo?.userName}".toByteArray())
|
file.appendBytes("$time---司机名称---${GlobalData.driverInfoBean?.userName ?: GlobalData.driverInfoBean?.userName}".toByteArray())
|
||||||
file.appendBytes("\n".toByteArray())
|
file.appendBytes("\n".toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCurrentTime(): String {
|
private fun getCurrentTime() : String {
|
||||||
return TimeUtils.millis2String(System.currentTimeMillis(), "yyyy/MM/dd HH:mm:ss.SSS")
|
return TimeUtils.millis2String(System.currentTimeMillis(), "yyyy/MM/dd HH:mm:ss.SSS")
|
||||||
}
|
}
|
||||||
|
|
||||||
class LogTask(appContext: Context, workerParams: WorkerParameters) : Worker(appContext, workerParams) {
|
class LogTask(appContext : Context, workerParams : WorkerParameters) :
|
||||||
override fun doWork(): Result {
|
Worker(appContext, workerParams) {
|
||||||
|
override fun doWork() : Result {
|
||||||
updateNormalLog()
|
updateNormalLog()
|
||||||
return Result.success()
|
return Result.success()
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import android.content.pm.PackageManager
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
|
import com.blankj.utilcode.util.ActivityUtils
|
||||||
import com.blankj.utilcode.util.ToastUtils
|
import com.blankj.utilcode.util.ToastUtils
|
||||||
import com.za.call.CallLogManager
|
import com.za.call.CallLogManager
|
||||||
import com.za.call.ContactRecordBean
|
import com.za.call.ContactRecordBean
|
||||||
|
@ -26,26 +26,35 @@ fun Any?.toJson() : String? {
|
|||||||
return JSON.toJSON(this).toString()
|
return JSON.toJSON(this).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun OrderInfo.goStatusPage(context : Context) {
|
fun OrderInfo.goStatusPage(context : Context, isFinishActivity : Boolean? = true) {
|
||||||
when (this.taskState) { //等待发车
|
when (this.taskState) { //等待发车
|
||||||
"START" -> {
|
"START" -> {
|
||||||
if (! RoomHelper.db?.photoTemplateDao()
|
if (! RoomHelper.db?.photoTemplateDao()
|
||||||
?.getOrderPhotoTemplateFromTaskNode(10100, userOrderId ?: 0).isNullOrEmpty()
|
?.getOrderPhotoTemplateFromTaskNode(10100, userOrderId ?: 0).isNullOrEmpty()
|
||||||
) {
|
) {
|
||||||
context.navigationActivity(DeparturePhotoActivity::class.java)
|
context.navigationActivity(DeparturePhotoActivity::class.java,
|
||||||
|
isFinish = isFinishActivity)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
context.navigationActivity(WaitToStartActivity::class.java)
|
context.navigationActivity(WaitToStartActivity::class.java, isFinish = isFinishActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
"GOTO" -> context.navigationActivity(GoAccidentSiteActivity::class.java) //验证服务资格
|
"GOTO" -> context.navigationActivity(GoAccidentSiteActivity::class.java,
|
||||||
"VERIFY" -> context.navigationActivity(VerifyOrderActivity::class.java) //检查车辆
|
isFinish = isFinishActivity) //验证服务资格
|
||||||
"EXAMINE" -> context.navigationActivity(CheckVehicleActivity::class.java) //作业中
|
"VERIFY" -> context.navigationActivity(VerifyOrderActivity::class.java,
|
||||||
"OPERATION" -> context.navigationActivity(InOperationActivity::class.java) //前往目的地
|
isFinish = isFinishActivity) //检查车辆
|
||||||
"SENDTO" -> context.navigationActivity(GoToDestinationActivity::class.java) //目的地照片
|
"EXAMINE" -> context.navigationActivity(CheckVehicleActivity::class.java,
|
||||||
"DESTPHOTO" -> context.navigationActivity(DestinationPhotoActivity::class.java) //结算中
|
isFinish = isFinishActivity) //作业中
|
||||||
"SETTLEMENT" -> context.navigationActivity(OrderConfirmActivity::class.java) //任务结束
|
"OPERATION" -> context.navigationActivity(InOperationActivity::class.java,
|
||||||
"FINISH" -> context.navigationActivity(WaitToStartActivity::class.java)
|
isFinish = isFinishActivity) //前往目的地
|
||||||
|
"SENDTO" -> context.navigationActivity(GoToDestinationActivity::class.java,
|
||||||
|
isFinish = isFinishActivity) //目的地照片
|
||||||
|
"DESTPHOTO" -> context.navigationActivity(DestinationPhotoActivity::class.java,
|
||||||
|
isFinish = isFinishActivity) //结算中
|
||||||
|
"SETTLEMENT" -> context.navigationActivity(OrderConfirmActivity::class.java,
|
||||||
|
isFinish = isFinishActivity) //任务结束
|
||||||
|
"FINISH" -> context.navigationActivity(WaitToStartActivity::class.java,
|
||||||
|
isFinish = isFinishActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,25 +70,34 @@ fun OrderInfo.getNextStatus() : String? {
|
|||||||
return flowStr
|
return flowStr
|
||||||
}
|
}
|
||||||
|
|
||||||
fun goNextPage(status : String?, context : Context) {
|
fun goNextPage(status : String?, context : Context, isFinishActivity : Boolean? = true) {
|
||||||
when (status) { //等待发车
|
when (status) { //等待发车
|
||||||
"START" -> {
|
"START" -> {
|
||||||
if (! RoomHelper.db?.photoTemplateDao()?.getOrderPhotoTemplateFromTaskNode(10100,
|
if (! RoomHelper.db?.photoTemplateDao()?.getOrderPhotoTemplateFromTaskNode(10100,
|
||||||
GlobalData.currentOrder?.userOrderId ?: 0).isNullOrEmpty()
|
GlobalData.currentOrder?.userOrderId ?: 0).isNullOrEmpty()
|
||||||
) {
|
) {
|
||||||
context.navigationActivity(DeparturePhotoActivity::class.java)
|
context.navigationActivity(DeparturePhotoActivity::class.java,
|
||||||
|
isFinish = isFinishActivity)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
context.navigationActivity(WaitToStartActivity::class.java)
|
context.navigationActivity(WaitToStartActivity::class.java, isFinish = isFinishActivity)
|
||||||
} //前往事发地
|
} //前往事发地
|
||||||
"GOTO" -> context.navigationActivity(GoAccidentSiteActivity::class.java) //验证服务资格
|
"GOTO" -> context.navigationActivity(GoAccidentSiteActivity::class.java,
|
||||||
"VERIFY" -> context.navigationActivity(VerifyOrderActivity::class.java) //检查车辆
|
isFinish = isFinishActivity) //验证服务资格
|
||||||
"EXAMINE" -> context.navigationActivity(CheckVehicleActivity::class.java) //作业中
|
"VERIFY" -> context.navigationActivity(VerifyOrderActivity::class.java,
|
||||||
"OPERATION" -> context.navigationActivity(InOperationActivity::class.java) //前往目的地
|
isFinish = isFinishActivity) //检查车辆
|
||||||
"SENDTO" -> context.navigationActivity(GoToDestinationActivity::class.java) //目的地照片
|
"EXAMINE" -> context.navigationActivity(CheckVehicleActivity::class.java,
|
||||||
"DESTPHOTO" -> context.navigationActivity(DestinationPhotoActivity::class.java) //结算中
|
isFinish = isFinishActivity) //作业中
|
||||||
"SETTLEMENT" -> context.navigationActivity(OrderConfirmActivity::class.java) //任务结束
|
"OPERATION" -> context.navigationActivity(InOperationActivity::class.java,
|
||||||
"FINISH" -> context.navigationActivity(WaitToStartActivity::class.java)
|
isFinish = true) //前往目的地
|
||||||
|
"SENDTO" -> context.navigationActivity(GoToDestinationActivity::class.java,
|
||||||
|
isFinish = isFinishActivity) //目的地照片
|
||||||
|
"DESTPHOTO" -> context.navigationActivity(DestinationPhotoActivity::class.java,
|
||||||
|
isFinish = isFinishActivity) //结算中
|
||||||
|
"SETTLEMENT" -> context.navigationActivity(OrderConfirmActivity::class.java,
|
||||||
|
isFinish = isFinishActivity) //任务结束
|
||||||
|
"FINISH" -> context.navigationActivity(WaitToStartActivity::class.java,
|
||||||
|
isFinish = isFinishActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.za.net
|
package com.za.net
|
||||||
|
|
||||||
|
import com.za.bean.AppNewDriverInfoDTO
|
||||||
import com.za.bean.BaseResponse
|
import com.za.bean.BaseResponse
|
||||||
import com.za.bean.BatteryCostQueryBean
|
import com.za.bean.BatteryCostQueryBean
|
||||||
import com.za.bean.BatteryCostQueryRequest
|
import com.za.bean.BatteryCostQueryRequest
|
||||||
@ -30,6 +31,7 @@ import com.za.bean.VehicleInfo
|
|||||||
import com.za.bean.db.order.OrderInfo
|
import com.za.bean.db.order.OrderInfo
|
||||||
import com.za.bean.db.order.PhotoTemplateInfo
|
import com.za.bean.db.order.PhotoTemplateInfo
|
||||||
import com.za.bean.request.AcceptOrderRequest
|
import com.za.bean.request.AcceptOrderRequest
|
||||||
|
import com.za.bean.request.AppNewOrderVoiceRequest
|
||||||
import com.za.bean.request.CustomerPaymentCreateBean
|
import com.za.bean.request.CustomerPaymentCreateBean
|
||||||
import com.za.bean.request.CustomerPaymentCreateRequest
|
import com.za.bean.request.CustomerPaymentCreateRequest
|
||||||
import com.za.bean.request.DriverFaceCompareBean
|
import com.za.bean.request.DriverFaceCompareBean
|
||||||
@ -114,6 +116,10 @@ interface ApiService {
|
|||||||
@POST("/driverApp/task/login")
|
@POST("/driverApp/task/login")
|
||||||
fun login(@Body info : LoginRequest) : Observable<BaseResponse<DriverInfo?>>
|
fun login(@Body info : LoginRequest) : Observable<BaseResponse<DriverInfo?>>
|
||||||
|
|
||||||
|
//获取该手机号下面服务商列表
|
||||||
|
@POST("/driverApp/supplier/getDriverListInfo")
|
||||||
|
fun getDriverListInfo(@Body info : VerifyCodeRequest) : Observable<BaseResponse<List<AppNewDriverInfoDTO>>>
|
||||||
|
|
||||||
@POST("/driverApp/task/loginWithTask")
|
@POST("/driverApp/task/loginWithTask")
|
||||||
fun loginWithTask(@Body loginWithTaskRequest : LoginWithTaskRequest) : Observable<BaseResponse<LoginWithTaskBean>>
|
fun loginWithTask(@Body loginWithTaskRequest : LoginWithTaskRequest) : Observable<BaseResponse<LoginWithTaskBean>>
|
||||||
|
|
||||||
@ -262,4 +268,7 @@ interface ApiService {
|
|||||||
//获取车辆维修历史
|
//获取车辆维修历史
|
||||||
@POST("/driverApp/supplier/v2/vehicleMaintenanceList")
|
@POST("/driverApp/supplier/v2/vehicleMaintenanceList")
|
||||||
fun vehicleMaintenanceList(@Body info : FetchVehicleMaintenanceSubmitHistoryRequestBean) : Observable<BaseResponse<List<VehicleMaintenanceHistoryBean>>>
|
fun vehicleMaintenanceList(@Body info : FetchVehicleMaintenanceSubmitHistoryRequestBean) : Observable<BaseResponse<List<VehicleMaintenanceHistoryBean>>>
|
||||||
|
|
||||||
|
@POST("driverApp/base/getVoiceUrl")
|
||||||
|
fun getVoiceUrl(@Body info : AppNewOrderVoiceRequest) : Observable<BaseResponse<String>>
|
||||||
}
|
}
|
@ -5,12 +5,10 @@ import android.graphics.BitmapFactory
|
|||||||
import com.blankj.utilcode.util.ActivityUtils
|
import com.blankj.utilcode.util.ActivityUtils
|
||||||
import com.blankj.utilcode.util.ImageUtils
|
import com.blankj.utilcode.util.ImageUtils
|
||||||
import com.za.base.Const
|
import com.za.base.Const
|
||||||
import com.za.bean.DriverInfo
|
|
||||||
import com.za.bean.GeneralInfo
|
import com.za.bean.GeneralInfo
|
||||||
import com.za.bean.ImageBean
|
import com.za.bean.ImageBean
|
||||||
import com.za.bean.JpushBean
|
import com.za.bean.JpushBean
|
||||||
import com.za.bean.NewOrderRequestBean
|
import com.za.bean.NewOrderRequestBean
|
||||||
import com.za.bean.VehicleInfo
|
|
||||||
import com.za.bean.db.ele.EleCarDamagePhotoBean
|
import com.za.bean.db.ele.EleCarDamagePhotoBean
|
||||||
import com.za.bean.db.ele.EleWorkOrderBean
|
import com.za.bean.db.ele.EleWorkOrderBean
|
||||||
import com.za.bean.db.order.OrderInfo
|
import com.za.bean.db.order.OrderInfo
|
||||||
@ -120,8 +118,8 @@ object CommonMethod {
|
|||||||
success : (GeneralInfo) -> Unit = {},
|
success : (GeneralInfo) -> Unit = {},
|
||||||
failed : (String?) -> Unit = {}) {
|
failed : (String?) -> Unit = {}) {
|
||||||
val generalInfoRequest =
|
val generalInfoRequest =
|
||||||
GeneralInfoRequest(vehicleId = vehicleId ?: GlobalData.vehicleInfo?.vehicleId,
|
GeneralInfoRequest(vehicleId = vehicleId ?: GlobalData.driverInfoBean?.vehicleId,
|
||||||
driverId = userId ?: GlobalData.driverInfo?.userId,
|
driverId = userId ?: GlobalData.driverInfoBean?.userId,
|
||||||
deviceId = DeviceUtil.getAndroidId(ActivityUtils.getTopActivity()))
|
deviceId = DeviceUtil.getAndroidId(ActivityUtils.getTopActivity()))
|
||||||
RetrofitHelper.getDefaultService().generalInfo(generalInfoRequest)
|
RetrofitHelper.getDefaultService().generalInfo(generalInfoRequest)
|
||||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -129,51 +127,27 @@ object CommonMethod {
|
|||||||
override fun doSuccess(it : GeneralInfo?) {
|
override fun doSuccess(it : GeneralInfo?) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
failed("获取车辆信息失败")
|
failed("获取车辆信息失败")
|
||||||
|
LogUtil.print("getGenerateInfo", "获取车辆信息失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (GlobalData.vehicleInfo == null) {
|
val driverInfoBean = GlobalData.driverInfoBean
|
||||||
GlobalData.vehicleInfo = VehicleInfo(vehicleId = it.vehicleId,
|
GlobalData.driverInfoBean = driverInfoBean?.copy(vehicleId = it.vehicleId,
|
||||||
vehicleName = it.vehicleName,
|
vehicleName = it.vehicleName,
|
||||||
userName = it.userName,
|
userName = it.userName,
|
||||||
userPhone = it.userPhone,
|
userPhone = it.userPhone,
|
||||||
status = it.vehicleState,
|
|
||||||
plateNumber = it.plateNumber,
|
plateNumber = it.plateNumber,
|
||||||
vehicleState = it.vehicleState,
|
vehicleState = it.vehicleState,
|
||||||
supplierType = it.supplierType)
|
supplierType = it.supplierType,
|
||||||
} else {
|
userPortrait = it.userPortrait,
|
||||||
GlobalData.vehicleInfo =
|
userId = it.userId,
|
||||||
GlobalData.vehicleInfo?.copy(vehicleId = it.vehicleId,
|
supplierId = it.supplierId,
|
||||||
vehicleName = it.vehicleName,
|
deviceId = it.deviceId,
|
||||||
userName = it.userName,
|
supplierName = it.supplierName,
|
||||||
userPhone = it.userPhone,
|
authStatus = it.authStatus,
|
||||||
status = it.vehicleState,
|
serviceList = it.serviceList?.toString())
|
||||||
plateNumber = it.plateNumber,
|
|
||||||
vehicleState = it.vehicleState,
|
|
||||||
supplierType = it.supplierType)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GlobalData.driverInfo == null) {
|
LogUtil.print("GlobalData.driverInfoBean",
|
||||||
GlobalData.driverInfo = DriverInfo(userPortrait = it.userPortrait,
|
"${GlobalData.driverInfoBean?.toJson()}}")
|
||||||
userName = it.userName,
|
|
||||||
userId = it.userId,
|
|
||||||
userPhone = it.userPhone,
|
|
||||||
supplierId = it.supplierId.toString(),
|
|
||||||
supplierName = it.supplierName,
|
|
||||||
authStatus = it.authStatus,
|
|
||||||
supplierType = it.supplierType,
|
|
||||||
serviceList = it.serviceList)
|
|
||||||
} else {
|
|
||||||
GlobalData.driverInfo =
|
|
||||||
GlobalData.driverInfo?.copy(userPortrait = it.userPortrait,
|
|
||||||
userName = it.userName,
|
|
||||||
userId = it.userId,
|
|
||||||
userPhone = it.userPhone,
|
|
||||||
supplierId = it.supplierId.toString(),
|
|
||||||
supplierName = it.supplierName,
|
|
||||||
authStatus = it.authStatus,
|
|
||||||
supplierType = it.supplierType,
|
|
||||||
serviceList = it.serviceList)
|
|
||||||
}
|
|
||||||
|
|
||||||
success(it)
|
success(it)
|
||||||
}
|
}
|
||||||
@ -187,7 +161,7 @@ object CommonMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getNewOrder(context : Context) {
|
fun getNewOrder(context : Context) {
|
||||||
val newOrderRequestBean = NewOrderRequestBean(GlobalData.vehicleInfo?.vehicleId)
|
val newOrderRequestBean = NewOrderRequestBean(GlobalData.driverInfoBean?.vehicleId)
|
||||||
RetrofitHelper.getDefaultService().getNewOrder(newOrderRequestBean)
|
RetrofitHelper.getDefaultService().getNewOrder(newOrderRequestBean)
|
||||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : BaseObserver<JpushBean>() {
|
.subscribe(object : BaseObserver<JpushBean>() {
|
||||||
@ -229,7 +203,7 @@ object CommonMethod {
|
|||||||
success : (OrderInfo?, List<OrderInfo>?) -> Unit,
|
success : (OrderInfo?, List<OrderInfo>?) -> Unit,
|
||||||
failed : (String?) -> Unit) {
|
failed : (String?) -> Unit) {
|
||||||
RetrofitHelper.getDefaultService()
|
RetrofitHelper.getDefaultService()
|
||||||
.queryOrderList(OrderListRequest(vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
.queryOrderList(OrderListRequest(vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
deviceId = DeviceUtil.getAndroidId(ActivityUtils.getTopActivity())))
|
deviceId = DeviceUtil.getAndroidId(ActivityUtils.getTopActivity())))
|
||||||
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : BaseObserver<List<OrderInfo>?>() {
|
.subscribe(object : BaseObserver<List<OrderInfo>?>() {
|
||||||
@ -246,33 +220,6 @@ object CommonMethod {
|
|||||||
val waitServiceOrders = it.filter { it.isCurrent == false }
|
val waitServiceOrders = it.filter { it.isCurrent == false }
|
||||||
|
|
||||||
if (inServicingOrder == null) {
|
if (inServicingOrder == null) {
|
||||||
context?.let { context ->
|
|
||||||
val order = it[0]
|
|
||||||
NewOrderActivity.goNewOrderActivity(context,
|
|
||||||
jpushBean = JpushBean(taskId = order.taskId,
|
|
||||||
taskCode = order.taskCode,
|
|
||||||
customerName = order.customerName,
|
|
||||||
customerPhone = order.customerPhone,
|
|
||||||
carBrand = order.carBrand,
|
|
||||||
carModel = order.carModel,
|
|
||||||
carNo = order.carNo,
|
|
||||||
taskState = order.taskState,
|
|
||||||
address = order.address,
|
|
||||||
addressProperty = order.addressProperty,
|
|
||||||
hotline = order.hotline,
|
|
||||||
expectArriveTime = order.expectArriveTime,
|
|
||||||
serviceTypeName = order.serviceTypeName,
|
|
||||||
dispatchTime = order.dispatchTime,
|
|
||||||
lat = order.lat,
|
|
||||||
lng = order.lng,
|
|
||||||
distLat = order.distLat,
|
|
||||||
distLng = order.distLng,
|
|
||||||
importantTip = order.importantTip,
|
|
||||||
hasReplaceBatteryCapable = order.hasReplaceBatteryCapable,
|
|
||||||
distAddress = order.distAddress,
|
|
||||||
distAddressRemark = order.distAddressRemark,
|
|
||||||
addressRemark = order.addressRemark))
|
|
||||||
}
|
|
||||||
success(null, waitServiceOrders)
|
success(null, waitServiceOrders)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.za.net
|
|||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.za.base.AppConfig
|
import com.za.base.AppConfig
|
||||||
|
import com.za.common.log.LogUtil
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
@ -12,26 +13,16 @@ import java.net.URLDecoder
|
|||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
object RetrofitHelper {
|
object RetrofitHelper {
|
||||||
private var retrofit: Retrofit? = null
|
private var retrofit : Retrofit? = null
|
||||||
private var apiService: ApiService? = null
|
private var apiService : ApiService? = null
|
||||||
private val loggerInterceptor = HttpLoggingInterceptor {
|
private val loggerInterceptor = HttpLoggingInterceptor {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (it.contains("image/*") || it.contains("form-data; name=\"file\"")
|
if (it.contains("image/*") || it.contains("form-data; name=\"file\"") || it.startsWith("Content-Type") || it.startsWith(
|
||||||
|| it.startsWith("Content-Type")
|
"Content-Length") || it.startsWith("Server") || it.startsWith("Date") || it.startsWith(
|
||||||
|| it.startsWith("Content-Length")
|
"Transfer-Encoding") || it.startsWith("Connection") || it.startsWith("X-") || it.startsWith(
|
||||||
|| it.startsWith("Server")
|
"token") || it.startsWith("Cache-Control") || it.startsWith("Expires") || it.startsWith(
|
||||||
|| it.startsWith("Date")
|
"Accept") || it.startsWith("Vary") || it.isEmpty() || it.startsWith("Pragma")
|
||||||
|| it.startsWith("Transfer-Encoding")
|
|
||||||
|| it.startsWith("Connection")
|
|
||||||
|| it.startsWith("X-")
|
|
||||||
|| it.startsWith("token")
|
|
||||||
|| it.startsWith("Cache-Control")
|
|
||||||
|| it.startsWith("Expires")
|
|
||||||
|| it.startsWith("Accept")
|
|
||||||
|| it.startsWith("Vary")
|
|
||||||
|| it.isEmpty()
|
|
||||||
|| it.startsWith("Pragma")
|
|
||||||
) {
|
) {
|
||||||
return@HttpLoggingInterceptor
|
return@HttpLoggingInterceptor
|
||||||
}
|
}
|
||||||
@ -39,45 +30,38 @@ object RetrofitHelper {
|
|||||||
if (it.contains("name=\"file\"; filename")) {
|
if (it.contains("name=\"file\"; filename")) {
|
||||||
return@HttpLoggingInterceptor
|
return@HttpLoggingInterceptor
|
||||||
}
|
}
|
||||||
Log.e(
|
LogUtil.print("--network--",
|
||||||
"--network--",
|
URLDecoder.decode(it.replace(Regex("%(?![0-9a-fA-F]{2})"), ""), "utf-8"))
|
||||||
URLDecoder.decode(it.replace(Regex("%(?![0-9a-fA-F]{2})"), ""), "utf-8")
|
} catch (e : UnsupportedEncodingException) {
|
||||||
)
|
|
||||||
} catch (e: UnsupportedEncodingException) {
|
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|
||||||
}.setLevel(HttpLoggingInterceptor.Level.BODY)
|
}.setLevel(HttpLoggingInterceptor.Level.BODY)
|
||||||
|
|
||||||
fun getDefaultService(): ApiService {
|
fun getDefaultService() : ApiService {
|
||||||
return if (apiService == null) {
|
return if (apiService == null) {
|
||||||
apiService = getDefaultRetrofit().create(ApiService::class.java)
|
apiService = getDefaultRetrofit().create(ApiService::class.java)
|
||||||
apiService!!
|
apiService !!
|
||||||
} else {
|
} else {
|
||||||
apiService!!
|
apiService !!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDefaultRetrofit(): Retrofit {
|
private fun getDefaultRetrofit() : Retrofit {
|
||||||
return if (retrofit == null) {
|
return if (retrofit == null) {
|
||||||
retrofit = Retrofit.Builder().baseUrl(AppConfig.BASE_URL)
|
retrofit = Retrofit.Builder().baseUrl(AppConfig.BASE_URL)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
.addCallAdapterFactory(RxJava3CallAdapterFactory.create()).client(getOkHttpClient())
|
||||||
.client(getOkHttpClient())
|
|
||||||
.build()
|
.build()
|
||||||
retrofit!!
|
retrofit !!
|
||||||
} else {
|
} else {
|
||||||
retrofit!!
|
retrofit !!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getOkHttpClient(): OkHttpClient {
|
private fun getOkHttpClient() : OkHttpClient {
|
||||||
return OkHttpClient.Builder()
|
return OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS)
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
.writeTimeout(60, TimeUnit.SECONDS).readTimeout(60, TimeUnit.SECONDS)
|
||||||
.writeTimeout(60, TimeUnit.SECONDS)
|
.addInterceptor(RequestEncryptInterceptor()).addInterceptor(loggerInterceptor).build()
|
||||||
.readTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.addInterceptor(RequestEncryptInterceptor())
|
|
||||||
.addInterceptor(loggerInterceptor)
|
|
||||||
.build()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -176,7 +176,7 @@ object OfflineManager {
|
|||||||
lng = offlineUpdateTaskBean.imageLng.toDouble(),
|
lng = offlineUpdateTaskBean.imageLng.toDouble(),
|
||||||
address = it,
|
address = it,
|
||||||
time = offlineUpdateTaskBean.time,
|
time = offlineUpdateTaskBean.time,
|
||||||
driverName = GlobalData.driverInfo?.userName,
|
driverName = GlobalData.driverInfoBean?.userName,
|
||||||
taskCode = offlineUpdateTaskBean.taskCode)
|
taskCode = offlineUpdateTaskBean.taskCode)
|
||||||
val offlineTemp = offlineUpdateTaskBean.copy(imageAddress = it)
|
val offlineTemp = offlineUpdateTaskBean.copy(imageAddress = it)
|
||||||
file = File(PhotoMarkerManager.addPhotoMarker(ActivityUtils.getTopActivity(),
|
file = File(PhotoMarkerManager.addPhotoMarker(ActivityUtils.getTopActivity(),
|
||||||
|
@ -11,7 +11,7 @@ import com.za.room.db.GlobalRoom
|
|||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
object RoomHelper {
|
object RoomHelper {
|
||||||
const val VERSION: Int = 35
|
const val VERSION: Int = 37
|
||||||
private lateinit var mContext: Context
|
private lateinit var mContext: Context
|
||||||
var db: GlobalRoom? = null
|
var db: GlobalRoom? = null
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.za.room.db
|
|||||||
|
|
||||||
import androidx.room.Database
|
import androidx.room.Database
|
||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
import androidx.room.TypeConverters
|
|
||||||
import com.za.bean.db.ChangeBatteryPhoto
|
import com.za.bean.db.ChangeBatteryPhoto
|
||||||
import com.za.bean.db.NewPhotoTemplateBean
|
import com.za.bean.db.NewPhotoTemplateBean
|
||||||
import com.za.bean.db.ele.EleCarDamagePhotoBean
|
import com.za.bean.db.ele.EleCarDamagePhotoBean
|
||||||
@ -11,7 +10,6 @@ import com.za.bean.db.order.OrderInfo
|
|||||||
import com.za.bean.db.order.PhotoTemplateInfo
|
import com.za.bean.db.order.PhotoTemplateInfo
|
||||||
import com.za.bean.db.water_marker.WaterMarkerItemBean
|
import com.za.bean.db.water_marker.WaterMarkerItemBean
|
||||||
import com.za.bean.db.water_marker.WaterMarkerTemplateBean
|
import com.za.bean.db.water_marker.WaterMarkerTemplateBean
|
||||||
import com.za.offline.InspectionConverter
|
|
||||||
import com.za.offline.OfflineDao
|
import com.za.offline.OfflineDao
|
||||||
import com.za.offline.OfflineUpdateTaskBean
|
import com.za.offline.OfflineUpdateTaskBean
|
||||||
import com.za.room.RoomHelper
|
import com.za.room.RoomHelper
|
||||||
@ -20,30 +18,32 @@ import com.za.room.db.ele_work.EleWorkOrderDao
|
|||||||
import com.za.room.db.order.ChangeBatteryDao
|
import com.za.room.db.order.ChangeBatteryDao
|
||||||
import com.za.room.db.order.OrderDao
|
import com.za.room.db.order.OrderDao
|
||||||
import com.za.room.db.order.PhotoTemplateDao
|
import com.za.room.db.order.PhotoTemplateDao
|
||||||
|
import com.za.room.db.user.DriverInfoBean
|
||||||
|
import com.za.room.db.user.DriverInfoDao
|
||||||
|
import com.za.room.db.user.LocalResourceBean
|
||||||
|
import com.za.room.db.user.LocalResourceDao
|
||||||
import com.za.room.db.water_marker.WaterMarkerDao
|
import com.za.room.db.water_marker.WaterMarkerDao
|
||||||
|
|
||||||
|
|
||||||
@Database(entities = [EleWorkOrderBean::class,
|
@Database(entities = [EleWorkOrderBean::class, EleCarDamagePhotoBean::class, LocalResourceBean::class, WaterMarkerTemplateBean::class, WaterMarkerItemBean::class, ChangeBatteryPhoto::class, NewPhotoTemplateBean::class, OrderInfo::class, OfflineUpdateTaskBean::class, DriverInfoBean::class, PhotoTemplateInfo::class],
|
||||||
EleCarDamagePhotoBean::class,
|
version = RoomHelper.VERSION,
|
||||||
WaterMarkerTemplateBean::class,
|
exportSchema = false)
|
||||||
WaterMarkerItemBean::class,
|
|
||||||
ChangeBatteryPhoto::class,
|
|
||||||
NewPhotoTemplateBean::class,
|
|
||||||
OrderInfo::class,
|
|
||||||
OfflineUpdateTaskBean::class,
|
|
||||||
PhotoTemplateInfo::class], version = RoomHelper.VERSION, exportSchema = false)
|
|
||||||
abstract class GlobalRoom : RoomDatabase() {
|
abstract class GlobalRoom : RoomDatabase() {
|
||||||
abstract fun eleWorkOrderDao(): EleWorkOrderDao
|
abstract fun eleWorkOrderDao() : EleWorkOrderDao
|
||||||
|
|
||||||
abstract fun eleCarDamagePhotoDao(): EleCarDamagePhotoDao
|
abstract fun eleCarDamagePhotoDao() : EleCarDamagePhotoDao
|
||||||
|
|
||||||
abstract fun waterMarkerDao(): WaterMarkerDao
|
abstract fun waterMarkerDao() : WaterMarkerDao
|
||||||
|
|
||||||
abstract fun changeBatteryDao(): ChangeBatteryDao
|
abstract fun changeBatteryDao() : ChangeBatteryDao
|
||||||
|
|
||||||
abstract fun orderDao(): OrderDao
|
abstract fun orderDao() : OrderDao
|
||||||
|
|
||||||
abstract fun photoTemplateDao(): PhotoTemplateDao
|
abstract fun photoTemplateDao() : PhotoTemplateDao
|
||||||
|
|
||||||
abstract fun offlineTaskDao(): OfflineDao
|
abstract fun offlineTaskDao() : OfflineDao
|
||||||
|
|
||||||
|
abstract fun driverInfoDao() : DriverInfoDao
|
||||||
|
|
||||||
|
abstract fun localResourceDao() : LocalResourceDao
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.za.room.db.user
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(tableName = "driver_info")
|
||||||
|
data class DriverInfoBean(
|
||||||
|
@PrimaryKey(autoGenerate = false) val userId : Int? = null, //用户id
|
||||||
|
val userName : String? = null, //用户姓名
|
||||||
|
val userPhone : String? = null, //用户手机号
|
||||||
|
val userPortrait : String? = null, //用户头像
|
||||||
|
val rongyunToken : String? = null,
|
||||||
|
val logTime : String? = null,
|
||||||
|
val supplierId : Int? = null, //经销商id
|
||||||
|
val supplierName : String? = null, //经销商名称
|
||||||
|
val supplierType : Int? = null, //经销商类型 1子公司 2供应商
|
||||||
|
val loginLogId : Int? = null,
|
||||||
|
val serviceList : String? = null, //车辆服务列表
|
||||||
|
val assistUserCode : String? = null,
|
||||||
|
val authStatus : Int? = null, // 0 未认证 1 已认证
|
||||||
|
val vehicleId : Int? = null,
|
||||||
|
val vehicleName : String? = null,
|
||||||
|
val vehicleState : Int? = null, //车辆状态 0 空闲 1 忙碌
|
||||||
|
val plateNumber : String? = null, //车牌号
|
||||||
|
val deviceId : String? = null,
|
||||||
|
)
|
40
servicing/src/main/java/com/za/room/db/user/DriverInfoDao.kt
Normal file
40
servicing/src/main/java/com/za/room/db/user/DriverInfoDao.kt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package com.za.room.db.user
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.OnConflictStrategy
|
||||||
|
import androidx.room.Query
|
||||||
|
import androidx.room.Transaction
|
||||||
|
import androidx.room.Update
|
||||||
|
import com.za.common.log.LogUtil
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface DriverInfoDao {
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
fun insert(driverInfoBean : DriverInfoBean)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM driver_info")
|
||||||
|
fun getDriverInfoFromUserId() : DriverInfoBean?
|
||||||
|
|
||||||
|
|
||||||
|
@Query("DELETE FROM driver_info")
|
||||||
|
fun deleteAll()
|
||||||
|
|
||||||
|
@Update(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
fun update(driverInfoBean : DriverInfoBean)
|
||||||
|
|
||||||
|
@Transaction
|
||||||
|
fun updateDriverInfo(driverInfoBean : DriverInfoBean?) {
|
||||||
|
if (driverInfoBean == null) {
|
||||||
|
LogUtil.print("DriverInfoDao", "updateDriverInfo driverInfoBean is null")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val driverInfo = getDriverInfoFromUserId()
|
||||||
|
if (driverInfo != null && driverInfo.userId == driverInfoBean.userId) {
|
||||||
|
update(driverInfoBean)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
deleteAll()
|
||||||
|
insert(driverInfoBean)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.za.room.db.user
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(tableName = "local_resource_bean")
|
||||||
|
data class LocalResourceBean(@PrimaryKey val resourceName : String,
|
||||||
|
val resourceType : Int = 0,
|
||||||
|
val resourceUrl : String? = null,
|
||||||
|
val resourceDescription : String? = null)
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.za.room.db.user
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Delete
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import androidx.room.Update
|
||||||
|
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface LocalResourceDao {
|
||||||
|
@Insert
|
||||||
|
fun insert(localResourceBean : LocalResourceBean)
|
||||||
|
|
||||||
|
@Update
|
||||||
|
fun update(localResourceBean : LocalResourceBean)
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
fun delete(localResourceBean : LocalResourceBean)
|
||||||
|
|
||||||
|
@get:Query("SELECT * FROM local_resource_bean")
|
||||||
|
val allLocalResources : List<LocalResourceBean?>?
|
||||||
|
|
||||||
|
@Query("SELECT * FROM local_resource_bean WHERE resourceName = :resourceName")
|
||||||
|
fun getLocalResourceByName(resourceName : String?) : LocalResourceBean?
|
||||||
|
|
||||||
|
@Query("SELECT * FROM local_resource_bean WHERE resourceType = :resourceType")
|
||||||
|
fun getLocalResourcesByType(resourceType : Int) : List<LocalResourceBean>?
|
||||||
|
|
||||||
|
@Query("DELETE FROM local_resource_bean")
|
||||||
|
fun deleteAllLocalResources()
|
||||||
|
}
|
@ -4,6 +4,7 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import cn.jpush.android.api.JPushInterface
|
import cn.jpush.android.api.JPushInterface
|
||||||
|
import com.za.common.GlobalData
|
||||||
import com.za.common.log.LogUtil
|
import com.za.common.log.LogUtil
|
||||||
import com.za.service.ServiceManager
|
import com.za.service.ServiceManager
|
||||||
|
|
||||||
@ -11,19 +12,24 @@ import com.za.service.ServiceManager
|
|||||||
* Created by zhangj on 2019/4/4.
|
* Created by zhangj on 2019/4/4.
|
||||||
*/
|
*/
|
||||||
class JPushReceiver : BroadcastReceiver() {
|
class JPushReceiver : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context : Context, intent : Intent) {
|
||||||
val bundle = intent.extras
|
val bundle = intent.extras
|
||||||
LogUtil.print("JpushMessage ", "onReceive==" + "action:" + intent.action)
|
LogUtil.print("JpushMessage ", "onReceive==" + "action:" + intent.action)
|
||||||
if (intent.action == null || bundle == null) { return }
|
if (intent.action == null || bundle == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
JPushInterface.ACTION_REGISTRATION_ID -> {
|
JPushInterface.ACTION_REGISTRATION_ID -> {
|
||||||
val regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID)
|
val regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID)
|
||||||
|
GlobalData.regid = regId
|
||||||
LogUtil.print("JpushMessage ", "Registration successful: $regId")
|
LogUtil.print("JpushMessage ", "Registration successful: $regId")
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushInterface.ACTION_MESSAGE_RECEIVED -> {
|
JPushInterface.ACTION_MESSAGE_RECEIVED -> {
|
||||||
val msg = bundle.getString(JPushInterface.EXTRA_MESSAGE)
|
val msg = bundle.getString(JPushInterface.EXTRA_MESSAGE)
|
||||||
if (msg.isNullOrBlank()) { return }
|
if (msg.isNullOrBlank()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
ServiceManager.handlerPushMsg(msg)
|
ServiceManager.handlerPushMsg(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ object ZdLocationManager : AMapLocationListener {
|
|||||||
val request = UploadGpsRequest().apply {
|
val request = UploadGpsRequest().apply {
|
||||||
lat = location.latitude
|
lat = location.latitude
|
||||||
lng = location.longitude
|
lng = location.longitude
|
||||||
userId = GlobalData.driverInfo?.userId
|
userId = GlobalData.driverInfoBean?.userId
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId
|
vehicleId = GlobalData.driverInfoBean?.vehicleId
|
||||||
working = GlobalData.currentOrder != null
|
working = GlobalData.currentOrder != null
|
||||||
direction = location.bearing.toDouble()
|
direction = location.bearing.toDouble()
|
||||||
speed = location.speed.toDouble()
|
speed = location.speed.toDouble()
|
||||||
|
@ -103,8 +103,8 @@ class CommonH5Activity : BaseActivity() {
|
|||||||
append("/training/training.html")
|
append("/training/training.html")
|
||||||
append("?id=").append(articleId)
|
append("?id=").append(articleId)
|
||||||
append("&source=driverApp")
|
append("&source=driverApp")
|
||||||
append("&driverId=").append(GlobalData.driverInfo?.userId)
|
append("&driverId=").append(GlobalData.driverInfoBean?.userId)
|
||||||
append("&userId=").append(GlobalData.driverInfo?.userId)
|
append("&userId=").append(GlobalData.driverInfoBean?.userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
@ -170,7 +170,6 @@ class ServiceLauncherActivity : BaseActivity() {
|
|||||||
private fun navigateToNextScreen() {
|
private fun navigateToNextScreen() {
|
||||||
if (GlobalData.isMaster) {
|
if (GlobalData.isMaster) {
|
||||||
GlobalData.currentOrder?.goStatusPage(this)
|
GlobalData.currentOrder?.goStatusPage(this)
|
||||||
finish()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val driverName = intent.getStringExtra("driverName")
|
val driverName = intent.getStringExtra("driverName")
|
||||||
|
@ -81,7 +81,6 @@ private fun ServicingMainScreen(jobCode : String? = null,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GlobalData.currentOrder?.goStatusPage(ActivityUtils.getTopActivity())
|
GlobalData.currentOrder?.goStatusPage(ActivityUtils.getTopActivity())
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -86,9 +86,15 @@ class NewOrderActivity : BaseActivity() {
|
|||||||
} else {
|
} else {
|
||||||
intent.getSerializableExtra("jpushBean")
|
intent.getSerializableExtra("jpushBean")
|
||||||
}
|
}
|
||||||
|
GlobalData.isHandlerNewOrder = false
|
||||||
AcceptOrderScreen(jpushBean = jpushBean as JpushBean)
|
AcceptOrderScreen(jpushBean = jpushBean as JpushBean)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStop() {
|
||||||
|
super.onStop()
|
||||||
|
GlobalData.isHandlerNewOrder = true
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun goNewOrderActivity(context : Context, jpushBean : JpushBean) {
|
fun goNewOrderActivity(context : Context, jpushBean : JpushBean) {
|
||||||
val intent = Intent(context, NewOrderActivity::class.java)
|
val intent = Intent(context, NewOrderActivity::class.java)
|
||||||
@ -423,7 +429,7 @@ private fun AcceptOrderScreen(jpushBean : JpushBean?, vm : NewOrderVm = viewMode
|
|||||||
// 添加当前位置标记
|
// 添加当前位置标记
|
||||||
currentLocation?.let {
|
currentLocation?.let {
|
||||||
mapView.map.addMarker(MarkerOptions().position(it).title("当前位置")
|
mapView.map.addMarker(MarkerOptions().position(it).title("当前位置")
|
||||||
.icon(ImageUtil.vectorToBitmap(context,R.drawable.ic_current_location))
|
.icon(ImageUtil.vectorToBitmap(context, R.drawable.ic_current_location))
|
||||||
.anchor(0.5f, 0.5f).visible(true))
|
.anchor(0.5f, 0.5f).visible(true))
|
||||||
allPoints.add(it)
|
allPoints.add(it)
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,8 @@ class NewOrderVm : BaseVm<NewOrderVm.Action, NewOrderVm.UiState>() {
|
|||||||
val orderInfo = uiState.value.jpushBean
|
val orderInfo = uiState.value.jpushBean
|
||||||
val acceptOrderRequest = AcceptOrderRequest()
|
val acceptOrderRequest = AcceptOrderRequest()
|
||||||
acceptOrderRequest.taskId = orderInfo?.taskId
|
acceptOrderRequest.taskId = orderInfo?.taskId
|
||||||
acceptOrderRequest.vehicleId = GlobalData.vehicleInfo?.vehicleId
|
acceptOrderRequest.vehicleId = GlobalData.driverInfoBean?.vehicleId
|
||||||
acceptOrderRequest.userId = GlobalData.driverInfo?.userId
|
acceptOrderRequest.userId = GlobalData.driverInfoBean?.userId
|
||||||
acceptOrderRequest.taskCode = orderInfo?.taskCode
|
acceptOrderRequest.taskCode = orderInfo?.taskCode
|
||||||
acceptOrderRequest.deviceId = DeviceUtil.getAndroidId(ActivityUtils.getTopActivity())
|
acceptOrderRequest.deviceId = DeviceUtil.getAndroidId(ActivityUtils.getTopActivity())
|
||||||
acceptOrderRequest.lat = it.latitude
|
acceptOrderRequest.lat = it.latitude
|
||||||
@ -123,9 +123,9 @@ class NewOrderVm : BaseVm<NewOrderVm.Action, NewOrderVm.UiState>() {
|
|||||||
private fun refuseOrder() {
|
private fun refuseOrder() {
|
||||||
LoadingManager.showLoading()
|
LoadingManager.showLoading()
|
||||||
RetrofitHelper.getDefaultService().refuseOrder(RefuseOrderRequest(taskId = uiState.value.jpushBean?.taskId,
|
RetrofitHelper.getDefaultService().refuseOrder(RefuseOrderRequest(taskId = uiState.value.jpushBean?.taskId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
taskCode = uiState.value.jpushBean?.taskCode,
|
taskCode = uiState.value.jpushBean?.taskCode,
|
||||||
userId = GlobalData.driverInfo?.userId))
|
userId = GlobalData.driverInfoBean?.userId))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : BaseObserver<String>() {
|
.subscribe(object : BaseObserver<String>() {
|
||||||
@ -147,7 +147,7 @@ class NewOrderVm : BaseVm<NewOrderVm.Action, NewOrderVm.UiState>() {
|
|||||||
timerJob?.cancel()
|
timerJob?.cancel()
|
||||||
timerJob = viewModelScope.launch {
|
timerJob = viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
var timeLeft = 50
|
var timeLeft = 120
|
||||||
while (timeLeft > 0 && isActive) {
|
while (timeLeft > 0 && isActive) {
|
||||||
delay(1000)
|
delay(1000)
|
||||||
timeLeft--
|
timeLeft--
|
||||||
|
@ -108,7 +108,7 @@ private fun handlerInServicingPhoto(
|
|||||||
lng = localPhotoTemplateInfo.lng?.toDouble(),
|
lng = localPhotoTemplateInfo.lng?.toDouble(),
|
||||||
address = localPhotoTemplateInfo.address,
|
address = localPhotoTemplateInfo.address,
|
||||||
time = localPhotoTemplateInfo.time,
|
time = localPhotoTemplateInfo.time,
|
||||||
driverName = GlobalData.driverInfo?.userName,
|
driverName = GlobalData.driverInfoBean?.userName,
|
||||||
taskCode = localPhotoTemplateInfo.taskCode)
|
taskCode = localPhotoTemplateInfo.taskCode)
|
||||||
File(PhotoMarkerManager.addPhotoMarker(context = context, photoMarkerInfo))
|
File(PhotoMarkerManager.addPhotoMarker(context = context, photoMarkerInfo))
|
||||||
} else {
|
} else {
|
||||||
@ -188,7 +188,7 @@ private fun handlerChangeBatteryPhoto(context : Context,
|
|||||||
lng = localPhotoTemplateInfo.lng?.toDouble(),
|
lng = localPhotoTemplateInfo.lng?.toDouble(),
|
||||||
address = localPhotoTemplateInfo.address,
|
address = localPhotoTemplateInfo.address,
|
||||||
time = localPhotoTemplateInfo.time,
|
time = localPhotoTemplateInfo.time,
|
||||||
driverName = GlobalData.driverInfo?.userName,
|
driverName = GlobalData.driverInfoBean?.userName,
|
||||||
taskCode = localPhotoTemplateInfo.taskCode)
|
taskCode = localPhotoTemplateInfo.taskCode)
|
||||||
File(PhotoMarkerManager.addPhotoMarker(context = context, photoMarkerInfo))
|
File(PhotoMarkerManager.addPhotoMarker(context = context, photoMarkerInfo))
|
||||||
} else {
|
} else {
|
||||||
@ -270,7 +270,7 @@ private fun handlerNormalPhoto(context : Context,
|
|||||||
lng = localPhotoTemplateInfo.lng?.toDouble(),
|
lng = localPhotoTemplateInfo.lng?.toDouble(),
|
||||||
address = localPhotoTemplateInfo.address,
|
address = localPhotoTemplateInfo.address,
|
||||||
time = localPhotoTemplateInfo.time,
|
time = localPhotoTemplateInfo.time,
|
||||||
driverName = GlobalData.driverInfo?.userName,
|
driverName = GlobalData.driverInfoBean?.userName,
|
||||||
taskCode = localPhotoTemplateInfo.taskCode)
|
taskCode = localPhotoTemplateInfo.taskCode)
|
||||||
File(PhotoMarkerManager.addPhotoMarker(context = context, photoMarkerInfo))
|
File(PhotoMarkerManager.addPhotoMarker(context = context, photoMarkerInfo))
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,7 +42,6 @@ fun CheckVehicleScreen(vm: CheckVehicleVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.isGoNextPageDialog == true) {
|
if (uiState.value.isGoNextPageDialog == true) {
|
||||||
|
@ -97,8 +97,8 @@ class CheckVehicleVm : IServicingVm<CheckVehicleVm.Action, CheckVehicleVm.UiStat
|
|||||||
private fun doUploadOfflineTask(it : AMapLocation?, tempPhotoList : ArrayList<String?>) {
|
private fun doUploadOfflineTask(it : AMapLocation?, tempPhotoList : ArrayList<String?>) {
|
||||||
val taskRequest = UpdateTaskRequest(type = "CHECK_VEHICLE",
|
val taskRequest = UpdateTaskRequest(type = "CHECK_VEHICLE",
|
||||||
taskId = getCurrentOrder()?.taskId,
|
taskId = getCurrentOrder()?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = "EXAMINE",
|
currentState = "EXAMINE",
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
@ -197,8 +197,8 @@ class CheckVehicleVm : IServicingVm<CheckVehicleVm.Action, CheckVehicleVm.UiStat
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val taskRequest = UpdateTaskRequest(type = "CHECK_VEHICLE",
|
val taskRequest = UpdateTaskRequest(type = "CHECK_VEHICLE",
|
||||||
taskId = getCurrentOrder()?.taskId,
|
taskId = getCurrentOrder()?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = "EXAMINE",
|
currentState = "EXAMINE",
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
|
@ -42,7 +42,6 @@ fun DeparturePhotoScreen(vm : DeparturePhotoVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.isGoNextPageDialog == true) {
|
if (uiState.value.isGoNextPageDialog == true) {
|
||||||
|
@ -91,8 +91,8 @@ class DeparturePhotoVm : IServicingVm<DeparturePhotoVm.Action, DeparturePhotoVm.
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val taskRequest = UpdateTaskRequest(type = "START",
|
val taskRequest = UpdateTaskRequest(type = "START",
|
||||||
taskId = getCurrentOrder()?.taskId,
|
taskId = getCurrentOrder()?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = GlobalData.currentOrder?.taskState,
|
currentState = GlobalData.currentOrder?.taskState,
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
|
@ -42,7 +42,6 @@ fun DestinationPhotoScreen(vm: DestinationPhotoVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.isGoNextPageDialog == true) {
|
if (uiState.value.isGoNextPageDialog == true) {
|
||||||
|
@ -103,9 +103,9 @@ class DestinationPhotoVm : IServicingVm<DestinationPhotoVm.Action, DestinationPh
|
|||||||
private fun doUploadOfflineTask(it: AMapLocation?, tempPhotoList: ArrayList<String?>) {
|
private fun doUploadOfflineTask(it: AMapLocation?, tempPhotoList: ArrayList<String?>) {
|
||||||
val taskRequest = UpdateTaskRequest(type = "DEST_PHOTO",
|
val taskRequest = UpdateTaskRequest(type = "DEST_PHOTO",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
flowType = GlobalData.currentOrder?.flowType,
|
flowType = GlobalData.currentOrder?.flowType,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = "DESTPHOTO",
|
currentState = "DESTPHOTO",
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
@ -198,9 +198,9 @@ class DestinationPhotoVm : IServicingVm<DestinationPhotoVm.Action, DestinationPh
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val taskRequest = UpdateTaskRequest(type = "DEST_PHOTO",
|
val taskRequest = UpdateTaskRequest(type = "DEST_PHOTO",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
flowType = GlobalData.currentOrder?.flowType,
|
flowType = GlobalData.currentOrder?.flowType,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = "DESTPHOTO",
|
currentState = "DESTPHOTO",
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
|
@ -87,7 +87,6 @@ fun EleSignCheckScreen(vm: EleSignCheckVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
uiState.value.orderInfo?.goStatusPage(context)
|
uiState.value.orderInfo?.goStatusPage(context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.showCallPhoneDialog == true) {
|
if (uiState.value.showCallPhoneDialog == true) {
|
||||||
|
@ -107,7 +107,6 @@ fun GoAccidentSiteScreen(vm : GoAccidentSiteVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.isGoNextPageDialog == true) {
|
if (uiState.value.isGoNextPageDialog == true) {
|
||||||
|
@ -59,8 +59,8 @@ class GoAccidentSiteVm : IServicingVm<GoAccidentSiteVm.Action, GoAccidentSiteVm.
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val temp = taskRequest ?: UpdateTaskRequest(type = "VERIFY",
|
val temp = taskRequest ?: UpdateTaskRequest(type = "VERIFY",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = GlobalData.currentOrder?.taskState,
|
currentState = GlobalData.currentOrder?.taskState,
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
@ -97,8 +97,8 @@ class GoAccidentSiteVm : IServicingVm<GoAccidentSiteVm.Action, GoAccidentSiteVm.
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val taskRequest = UpdateTaskRequest(type = "VERIFY",
|
val taskRequest = UpdateTaskRequest(type = "VERIFY",
|
||||||
taskId = getCurrentOrder()?.taskId,
|
taskId = getCurrentOrder()?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = getCurrentOrder()?.taskState,
|
currentState = getCurrentOrder()?.taskState,
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
|
@ -39,7 +39,6 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.toArgb
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -131,7 +130,6 @@ fun GoToDestinationScreen(vm: GoToDestinationVm = viewModel()) {
|
|||||||
// 对话框处理
|
// 对话框处理
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.isGoNextPageDialog == true) {
|
if (uiState.value.isGoNextPageDialog == true) {
|
||||||
|
@ -60,8 +60,8 @@ class GoToDestinationVm : IServicingVm<GoToDestinationVm.Action, GoToDestination
|
|||||||
val temp = taskRequest ?: UpdateTaskRequest(
|
val temp = taskRequest ?: UpdateTaskRequest(
|
||||||
type = "ARRIVE_DEST",
|
type = "ARRIVE_DEST",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
flowType = GlobalData.currentOrder?.flowType,
|
flowType = GlobalData.currentOrder?.flowType,
|
||||||
currentState = GlobalData.currentOrder?.taskState,
|
currentState = GlobalData.currentOrder?.taskState,
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
@ -102,8 +102,8 @@ class GoToDestinationVm : IServicingVm<GoToDestinationVm.Action, GoToDestination
|
|||||||
val taskRequest = UpdateTaskRequest(
|
val taskRequest = UpdateTaskRequest(
|
||||||
type = "ARRIVE_DEST",
|
type = "ARRIVE_DEST",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
flowType = GlobalData.currentOrder?.flowType,
|
flowType = GlobalData.currentOrder?.flowType,
|
||||||
currentState = GlobalData.currentOrder?.taskState,
|
currentState = GlobalData.currentOrder?.taskState,
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
|
@ -34,7 +34,6 @@ fun InOperationScreen(vm: InOperationVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.isGoNextPageDialog == true) {
|
if (uiState.value.isGoNextPageDialog == true) {
|
||||||
|
@ -104,9 +104,9 @@ class InOperationVm : IServicingVm<InOperationVm.Action, InOperationVm.UiState>(
|
|||||||
private fun doUploadOfflineTask(it: AMapLocation?, tempPhotoList: ArrayList<String?>) {
|
private fun doUploadOfflineTask(it: AMapLocation?, tempPhotoList: ArrayList<String?>) {
|
||||||
val taskRequest = UpdateTaskRequest(type = "OPERATION",
|
val taskRequest = UpdateTaskRequest(type = "OPERATION",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
flowType = GlobalData.currentOrder?.flowType,
|
flowType = GlobalData.currentOrder?.flowType,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = "OPERATION",
|
currentState = "OPERATION",
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
@ -202,9 +202,9 @@ class InOperationVm : IServicingVm<InOperationVm.Action, InOperationVm.UiState>(
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val taskRequest = UpdateTaskRequest(type = "OPERATION",
|
val taskRequest = UpdateTaskRequest(type = "OPERATION",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
flowType = GlobalData.currentOrder?.flowType,
|
flowType = GlobalData.currentOrder?.flowType,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = "OPERATION",
|
currentState = "OPERATION",
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
|
@ -42,7 +42,6 @@ fun ChangeBatteryScreen(vm: ChangeBatteryVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
uiState.value.orderInfo?.goStatusPage(context)
|
uiState.value.orderInfo?.goStatusPage(context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Scaffold(topBar = {
|
Scaffold(topBar = {
|
||||||
|
@ -78,10 +78,8 @@ fun ConfirmEleScreen(vm : ConfirmEleVm = viewModel()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.isGoNextPageDialog == true) {
|
if (uiState.value.isGoNextPageDialog == true) {
|
||||||
|
@ -48,7 +48,6 @@ import com.za.base.view.CommonDialog
|
|||||||
import com.za.base.view.HeadView
|
import com.za.base.view.HeadView
|
||||||
import com.za.base.view.LoadingState
|
import com.za.base.view.LoadingState
|
||||||
import com.za.common.log.LogUtil
|
import com.za.common.log.LogUtil
|
||||||
import com.za.ext.finish
|
|
||||||
import com.za.ext.getEleOrderH5Url
|
import com.za.ext.getEleOrderH5Url
|
||||||
import com.za.ext.goStatusPage
|
import com.za.ext.goStatusPage
|
||||||
import com.za.servicing.R
|
import com.za.servicing.R
|
||||||
@ -115,7 +114,6 @@ fun ConfirmH5SuccessScreen(vm : ConfirmH5SuccessVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage == true) {
|
if (uiState.value.goNextPage == true) {
|
||||||
uiState.value.orderInfo?.goStatusPage(context)
|
uiState.value.orderInfo?.goStatusPage(context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.showSignDialog != null) {
|
if (uiState.value.showSignDialog != null) {
|
||||||
|
@ -84,11 +84,12 @@ val gradientColors = listOf(Color(0xFF3B82F6), Color(0xFF60A5FA))
|
|||||||
class InputMoneyActivity : BaseActivity() {
|
class InputMoneyActivity : BaseActivity() {
|
||||||
@Composable
|
@Composable
|
||||||
override fun ContentView() {
|
override fun ContentView() {
|
||||||
InputMoneyScreen(userOrderId = intent.getIntExtra("userOrderId", 0), taskId = intent.getIntExtra("taskId", 0))
|
InputMoneyScreen(userOrderId = intent.getIntExtra("userOrderId", 0),
|
||||||
|
taskId = intent.getIntExtra("taskId", 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun goInputMoney(context: Context, userOrderId: Int, taskId: Int) {
|
fun goInputMoney(context : Context, userOrderId : Int, taskId : Int) {
|
||||||
context.startActivity(Intent(context, InputMoneyActivity::class.java).apply {
|
context.startActivity(Intent(context, InputMoneyActivity::class.java).apply {
|
||||||
putExtra("userOrderId", userOrderId)
|
putExtra("userOrderId", userOrderId)
|
||||||
putExtra("taskId", taskId)
|
putExtra("taskId", taskId)
|
||||||
@ -104,8 +105,7 @@ fun PreviewInputMoneyScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun InputMoneyScreen(userOrderId: Int, taskId: Int,
|
fun InputMoneyScreen(userOrderId : Int, taskId : Int, vm : InputMoneyVm = viewModel()) {
|
||||||
vm: InputMoneyVm = viewModel()) {
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val uiState = vm.uiState.collectAsStateWithLifecycle()
|
val uiState = vm.uiState.collectAsStateWithLifecycle()
|
||||||
var showSuccessDialog by remember { mutableStateOf(false) }
|
var showSuccessDialog by remember { mutableStateOf(false) }
|
||||||
@ -124,66 +124,48 @@ fun InputMoneyScreen(userOrderId: Int, taskId: Int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (showSuccessDialog) {
|
if (showSuccessDialog) {
|
||||||
SuccessDialog(
|
SuccessDialog(amount = "${uiState.value.paymentInfoBean?.amount ?: 0.00}", onDismiss = {
|
||||||
amount = "${uiState.value.paymentInfoBean?.amount ?: 0.00}",
|
|
||||||
onDismiss = {
|
|
||||||
showSuccessDialog = false
|
showSuccessDialog = false
|
||||||
context.finish()
|
context.finish()
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uiState.value.payState == 3) {
|
|
||||||
CommonDialog(title = "收款成功", message = "收款成功", cancelEnable = false,
|
|
||||||
confirm = {
|
|
||||||
goNextPage(GlobalData.currentOrder?.taskState, context)
|
|
||||||
context.finish()
|
|
||||||
}, dismiss = {
|
|
||||||
goNextPage(GlobalData.currentOrder?.taskState, context)
|
|
||||||
context.finish()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Scaffold(
|
if (uiState.value.payState == 3) {
|
||||||
topBar = { HeadView(title = "客户收款", onBack = { context.finish() }) },
|
CommonDialog(title = "收款成功", message = "收款成功", cancelEnable = false, confirm = {
|
||||||
bottomBar = {
|
goNextPage(GlobalData.currentOrder?.taskState, context)
|
||||||
Surface(
|
}, dismiss = {
|
||||||
modifier = Modifier
|
goNextPage(GlobalData.currentOrder?.taskState, context)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Scaffold(topBar = { HeadView(title = "客户收款", onBack = { context.finish() }) }, bottomBar = {
|
||||||
|
Surface(modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
tonalElevation = 8.dp,
|
tonalElevation = 8.dp,
|
||||||
shadowElevation = 8.dp,
|
shadowElevation = 8.dp,
|
||||||
color = backgroundColor,
|
color = backgroundColor,
|
||||||
shape = RoundedCornerShape(24.dp)
|
shape = RoundedCornerShape(24.dp)) {
|
||||||
) {
|
Row(modifier = Modifier
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||||
) {
|
Button(onClick = {
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
goNextPage(GlobalData.currentOrder?.taskState, context)
|
goNextPage(GlobalData.currentOrder?.taskState, context)
|
||||||
context.finish()
|
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.height(48.dp)
|
.height(48.dp)
|
||||||
.animateContentSize(),
|
.animateContentSize(),
|
||||||
shape = RoundedCornerShape(24.dp),
|
shape = RoundedCornerShape(24.dp),
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF64748B),
|
||||||
containerColor = Color(0xFF64748B),
|
contentColor = Color.White),
|
||||||
contentColor = Color.White
|
|
||||||
),
|
|
||||||
elevation = ButtonDefaults.buttonElevation(4.dp),
|
elevation = ButtonDefaults.buttonElevation(4.dp),
|
||||||
interactionSource = remember { MutableInteractionSource() }
|
interactionSource = remember { MutableInteractionSource() }) {
|
||||||
) {
|
|
||||||
Text("无须收款", fontSize = 12.sp, fontWeight = FontWeight.Medium)
|
Text("无须收款", fontSize = 12.sp, fontWeight = FontWeight.Medium)
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(
|
Button(onClick = {
|
||||||
onClick = {
|
|
||||||
if (uiState.value.receiveMoney == null || uiState.value.receiveMoney == 0f) {
|
if (uiState.value.receiveMoney == null || uiState.value.receiveMoney == 0f) {
|
||||||
ToastUtils.showLong("请输入收款金额")
|
ToastUtils.showLong("请输入收款金额")
|
||||||
return@Button
|
return@Button
|
||||||
@ -199,69 +181,52 @@ fun InputMoneyScreen(userOrderId: Int, taskId: Int,
|
|||||||
.height(48.dp)
|
.height(48.dp)
|
||||||
.weight(1f),
|
.weight(1f),
|
||||||
shape = RoundedCornerShape(24.dp),
|
shape = RoundedCornerShape(24.dp),
|
||||||
colors = ButtonDefaults.buttonColors(
|
colors = ButtonDefaults.buttonColors(containerColor = primaryColor),
|
||||||
containerColor = primaryColor
|
elevation = ButtonDefaults.buttonElevation(4.dp)) {
|
||||||
),
|
Text("发送短信链接".takeIf { uiState.value.isOnSite != 1 } ?: "生成收款二维码",
|
||||||
elevation = ButtonDefaults.buttonElevation(4.dp)
|
fontSize = 12.sp,
|
||||||
) {
|
fontWeight = FontWeight.Medium)
|
||||||
Text("发送短信链接".takeIf { uiState.value.isOnSite != 1 }
|
|
||||||
?: "生成收款二维码", fontSize = 12.sp, fontWeight = FontWeight.Medium)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}, containerColor = backgroundColor) {
|
||||||
containerColor = backgroundColor
|
Column(modifier = Modifier
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(it)
|
.padding(it)
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.padding(16.dp)
|
.padding(16.dp)) {
|
||||||
) {
|
|
||||||
Column(modifier = Modifier.fillMaxWidth(),
|
Column(modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
) {
|
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
Text("收款金额",
|
Text("收款金额",
|
||||||
color = Color.Gray,
|
color = Color.Gray,
|
||||||
fontSize = 18.sp,
|
fontSize = 18.sp,
|
||||||
fontWeight = FontWeight.Medium,
|
fontWeight = FontWeight.Medium,
|
||||||
modifier = Modifier.padding(bottom = 16.dp)
|
modifier = Modifier.padding(bottom = 16.dp))
|
||||||
)
|
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(value = uiState.value.receiveMoneyText ?: "",
|
||||||
value = uiState.value.receiveMoneyText ?: "",
|
|
||||||
onValueChange = { newValue ->
|
onValueChange = { newValue ->
|
||||||
vm.updateState(uiState.value.copy(receiveMoney = newValue.toFloatOrNull(), receiveMoneyText = newValue))
|
vm.updateState(uiState.value.copy(receiveMoney = newValue.toFloatOrNull(),
|
||||||
|
receiveMoneyText = newValue))
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal),
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal),
|
||||||
prefix = { Text("¥") },
|
prefix = { Text("¥") },
|
||||||
shape = RoundedCornerShape(12.dp),
|
shape = RoundedCornerShape(12.dp),
|
||||||
colors = OutlinedTextFieldDefaults.colors(
|
colors = OutlinedTextFieldDefaults.colors(focusedBorderColor = primaryColor,
|
||||||
focusedBorderColor = primaryColor,
|
|
||||||
unfocusedBorderColor = Color.Gray.copy(alpha = 0.5f),
|
unfocusedBorderColor = Color.Gray.copy(alpha = 0.5f),
|
||||||
focusedLabelColor = primaryColor,
|
focusedLabelColor = primaryColor,
|
||||||
unfocusedLabelColor = Color.Gray
|
unfocusedLabelColor = Color.Gray))
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(15.dp))
|
Spacer(modifier = Modifier.height(15.dp)) // Action Buttons
|
||||||
// Action Buttons
|
Row(modifier = Modifier.fillMaxWidth(),
|
||||||
Row(
|
horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||||
modifier = Modifier.fillMaxWidth(),
|
Row(modifier = if (uiState.value.isOnSite == 1) {
|
||||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
modifier = if (uiState.value.isOnSite == 1) {
|
|
||||||
Modifier
|
Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.background(
|
.background(brush = Brush.linearGradient(gradientColors),
|
||||||
brush = Brush.linearGradient(gradientColors),
|
shape = RoundedCornerShape(12.dp))
|
||||||
shape = RoundedCornerShape(12.dp)
|
|
||||||
)
|
|
||||||
.padding(vertical = 16.dp)
|
.padding(vertical = 16.dp)
|
||||||
} else {
|
} else {
|
||||||
Modifier
|
Modifier
|
||||||
@ -271,19 +236,21 @@ fun InputMoneyScreen(userOrderId: Int, taskId: Int,
|
|||||||
.padding(vertical = 16.dp)
|
.padding(vertical = 16.dp)
|
||||||
},
|
},
|
||||||
horizontalArrangement = Arrangement.Center,
|
horizontalArrangement = Arrangement.Center,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically) {
|
||||||
) {
|
|
||||||
if (uiState.value.isOnSite == 1) {
|
if (uiState.value.isOnSite == 1) {
|
||||||
Icon(imageVector = Icons.Default.LocationOn, contentDescription = null, tint = Color.White)
|
Icon(imageVector = Icons.Default.LocationOn,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = Color.White)
|
||||||
Text(text = "在现场", color = Color.White)
|
Text(text = "在现场", color = Color.White)
|
||||||
} else {
|
} else {
|
||||||
Icon(imageVector = Icons.Default.LocationOn, contentDescription = null, tint = Color.Gray)
|
Icon(imageVector = Icons.Default.LocationOn,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = Color.Gray)
|
||||||
Text(text = "在现场", color = Color.Gray)
|
Text(text = "在现场", color = Color.Gray)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(modifier = if (uiState.value.isOnSite == 2) {
|
||||||
modifier = if (uiState.value.isOnSite == 2) {
|
|
||||||
Modifier
|
Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.background(color = primaryColor, shape = RoundedCornerShape(3.dp))
|
.background(color = primaryColor, shape = RoundedCornerShape(3.dp))
|
||||||
@ -296,56 +263,57 @@ fun InputMoneyScreen(userOrderId: Int, taskId: Int,
|
|||||||
}
|
}
|
||||||
.border(1.dp, color = Color.Gray, shape = RoundedCornerShape(3.dp))
|
.border(1.dp, color = Color.Gray, shape = RoundedCornerShape(3.dp))
|
||||||
.padding(vertical = 15.dp)
|
.padding(vertical = 15.dp)
|
||||||
},
|
}, horizontalArrangement = Arrangement.Center) {
|
||||||
horizontalArrangement = Arrangement.Center
|
|
||||||
) {
|
|
||||||
if (uiState.value.isOnSite == 2) {
|
if (uiState.value.isOnSite == 2) {
|
||||||
Icon(imageVector = Icons.Default.Notifications, contentDescription = null, tint = Color.White)
|
Icon(imageVector = Icons.Default.Notifications,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = Color.White)
|
||||||
Text(text = "不在现场", color = Color.White)
|
Text(text = "不在现场", color = Color.White)
|
||||||
} else {
|
} else {
|
||||||
Icon(imageVector = Icons.Default.Notifications, contentDescription = null, tint = Color.Gray)
|
Icon(imageVector = Icons.Default.Notifications,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = Color.Gray)
|
||||||
Text(text = "不在现场", color = Color.Gray)
|
Text(text = "不在现场", color = Color.Gray)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimatedVisibility(visible = uiState.value.isOnSite == 1) {
|
AnimatedVisibility(visible = uiState.value.isOnSite == 1) {
|
||||||
QRCodeSection(uiState.value.qrCode
|
QRCodeSection(uiState.value.qrCode ?: "",
|
||||||
?: "", createPayment = { vm.dispatch(InputMoneyVm.Action.CreatePaymentInfo) })
|
createPayment = { vm.dispatch(InputMoneyVm.Action.CreatePaymentInfo) })
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimatedVisibility(visible = uiState.value.isOnSite == 2) {
|
AnimatedVisibility(visible = uiState.value.isOnSite == 2) {
|
||||||
Box(modifier = Modifier
|
Box(modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 10.dp, vertical = 15.dp)) {
|
.padding(horizontal = 10.dp, vertical = 15.dp)) {
|
||||||
OutlinedTextField(
|
OutlinedTextField(value = uiState.value.userPhone ?: "",
|
||||||
value = uiState.value.userPhone ?: "",
|
|
||||||
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Phone),
|
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Phone),
|
||||||
onValueChange = { vm.updateState(uiState.value.copy(userPhone = it)) },
|
onValueChange = { vm.updateState(uiState.value.copy(userPhone = it)) },
|
||||||
label = { Text("请输入客户手机号") },
|
label = { Text("请输入客户手机号") },
|
||||||
leadingIcon = {
|
leadingIcon = {
|
||||||
Icon(
|
Icon(imageVector = Icons.Rounded.Phone,
|
||||||
imageVector = Icons.Rounded.Phone,
|
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = primaryColor
|
tint = primaryColor)
|
||||||
)
|
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
shape = RoundedCornerShape(12.dp),
|
shape = RoundedCornerShape(12.dp),
|
||||||
colors = OutlinedTextFieldDefaults.colors(
|
colors = OutlinedTextFieldDefaults.colors(focusedBorderColor = primaryColor,
|
||||||
focusedBorderColor = primaryColor,
|
|
||||||
unfocusedBorderColor = Color.Gray,
|
unfocusedBorderColor = Color.Gray,
|
||||||
focusedLabelColor = primaryColor,
|
focusedLabelColor = primaryColor,
|
||||||
unfocusedLabelColor = Color.Gray),
|
unfocusedLabelColor = Color.Gray),
|
||||||
singleLine = true
|
singleLine = true)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.payState == 1) {
|
if (uiState.value.payState == 1) {
|
||||||
Column {
|
Column {
|
||||||
Spacer(modifier = Modifier.height(15.dp))
|
Spacer(modifier = Modifier.height(15.dp))
|
||||||
CountdownRing { vm.updateState(uiState.value.copy(payState = 4, qrCode = null, qrCodeOutTime = true)) }
|
CountdownRing {
|
||||||
|
vm.updateState(uiState.value.copy(payState = 4,
|
||||||
|
qrCode = null,
|
||||||
|
qrCodeOutTime = true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,39 +321,33 @@ fun InputMoneyScreen(userOrderId: Int, taskId: Int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun QRCodeSection(qrCode: String? = null, isOutTime: Boolean? = null, createPayment: () -> Unit = {}) {
|
private fun QRCodeSection(qrCode : String? = null,
|
||||||
Column(
|
isOutTime : Boolean? = null,
|
||||||
modifier = Modifier
|
createPayment : () -> Unit = {}) {
|
||||||
|
Column(modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(12.dp),
|
.padding(12.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
) {
|
if (! qrCode.isNullOrEmpty()) {
|
||||||
if (!qrCode.isNullOrEmpty()) {
|
|
||||||
Surface(modifier = Modifier
|
Surface(modifier = Modifier
|
||||||
.size(200.dp)
|
.size(200.dp)
|
||||||
.border(2.dp, primaryColor.copy(alpha = 0.1f), RoundedCornerShape(16.dp)),
|
.border(2.dp, primaryColor.copy(alpha = 0.1f), RoundedCornerShape(16.dp)),
|
||||||
color = backgroundColor,
|
color = backgroundColor,
|
||||||
shape = RoundedCornerShape(16.dp)
|
shape = RoundedCornerShape(16.dp)) {
|
||||||
) {
|
|
||||||
Box(modifier = Modifier
|
Box(modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center) {
|
||||||
) {
|
AsyncImage(model = qrCode,
|
||||||
AsyncImage(
|
|
||||||
model = qrCode,
|
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.fillMaxSize(0.8f)
|
modifier = Modifier.fillMaxSize(0.8f))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
Text(
|
Text("请顾客扫码支付",
|
||||||
"请顾客扫码支付",
|
|
||||||
color = Color.Gray,
|
color = Color.Gray,
|
||||||
fontSize = 16.sp,
|
fontSize = 16.sp,
|
||||||
fontWeight = FontWeight.Medium
|
fontWeight = FontWeight.Medium)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOutTime == true) {
|
if (isOutTime == true) {
|
||||||
@ -396,17 +358,15 @@ private fun QRCodeSection(qrCode: String? = null, isOutTime: Boolean? = null, cr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun CountdownRing(outTime: () -> Unit) {
|
private fun CountdownRing(outTime : () -> Unit) {
|
||||||
var countdown by remember { mutableIntStateOf(5 * 60) }
|
var countdown by remember { mutableIntStateOf(5 * 60) }
|
||||||
val progress by animateFloatAsState(
|
val progress by animateFloatAsState(targetValue = (countdown / 5 * 60) * 360f,
|
||||||
targetValue = (countdown / 5 * 60) * 360f,
|
animationSpec = remember { androidx.compose.animation.core.tween(1000) })
|
||||||
animationSpec = remember { androidx.compose.animation.core.tween(1000) }
|
|
||||||
)
|
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
while (countdown > 0) {
|
while (countdown > 0) {
|
||||||
delay(1000)
|
delay(1000)
|
||||||
countdown--
|
countdown --
|
||||||
if (countdown == 0) {
|
if (countdown == 0) {
|
||||||
outTime()
|
outTime()
|
||||||
}
|
}
|
||||||
@ -416,64 +376,42 @@ private fun CountdownRing(outTime: () -> Unit) {
|
|||||||
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
||||||
Box(modifier = Modifier.size(50.dp), contentAlignment = Alignment.Center) {
|
Box(modifier = Modifier.size(50.dp), contentAlignment = Alignment.Center) {
|
||||||
Canvas(modifier = Modifier.fillMaxSize()) {
|
Canvas(modifier = Modifier.fillMaxSize()) {
|
||||||
drawArc(
|
drawArc(brush = Brush.sweepGradient(0f to primaryColor, 1f to Color.LightGray),
|
||||||
brush = Brush.sweepGradient(
|
startAngle = - 90f,
|
||||||
0f to primaryColor,
|
|
||||||
1f to Color.LightGray
|
|
||||||
),
|
|
||||||
startAngle = -90f,
|
|
||||||
sweepAngle = progress,
|
sweepAngle = progress,
|
||||||
useCenter = false,
|
useCenter = false,
|
||||||
style = Stroke(width = 8.dp.toPx(), cap = StrokeCap.Round)
|
style = Stroke(width = 8.dp.toPx(), cap = StrokeCap.Round))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Surface(
|
Surface(color = Color.White, shape = CircleShape, modifier = Modifier.size(50.dp)) {}
|
||||||
color = Color.White,
|
Text(text = countdown.toString(),
|
||||||
shape = CircleShape,
|
|
||||||
modifier = Modifier.size(50.dp)) {}
|
|
||||||
Text(
|
|
||||||
text = countdown.toString(),
|
|
||||||
fontSize = 20.sp,
|
fontSize = 20.sp,
|
||||||
color = black90,
|
color = black90,
|
||||||
fontWeight = FontWeight.Medium
|
fontWeight = FontWeight.Medium)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SuccessDialog(amount: String, onDismiss: () -> Unit) {
|
private fun SuccessDialog(amount : String, onDismiss : () -> Unit) {
|
||||||
Dialog(onDismissRequest = onDismiss) {
|
Dialog(onDismissRequest = onDismiss) {
|
||||||
Surface(
|
Surface(shape = RoundedCornerShape(16.dp), color = Color.White) {
|
||||||
shape = RoundedCornerShape(16.dp),
|
Column(modifier = Modifier.padding(24.dp),
|
||||||
color = Color.White
|
horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
) {
|
Box(modifier = Modifier
|
||||||
Column(
|
|
||||||
modifier = Modifier.padding(24.dp),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(64.dp)
|
.size(64.dp)
|
||||||
.background(primaryColor.copy(alpha = 0.1f), CircleShape)
|
.background(primaryColor.copy(alpha = 0.1f), CircleShape)
|
||||||
.clip(CircleShape),
|
.clip(CircleShape),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center) {
|
||||||
) {
|
Icon(Icons.Default.Check,
|
||||||
Icon(
|
|
||||||
Icons.Default.Check,
|
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = primaryColor,
|
tint = primaryColor,
|
||||||
modifier = Modifier.size(32.dp)
|
modifier = Modifier.size(32.dp))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
Text("收款成功", fontWeight = FontWeight.Medium, fontSize = 18.sp)
|
Text("收款成功", fontWeight = FontWeight.Medium, fontSize = 18.sp)
|
||||||
Text("已收款 ¥$amount", color = Color.Gray, fontSize = 14.sp)
|
Text("已收款 ¥$amount", color = Color.Gray, fontSize = 14.sp)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
Button(
|
Button(onClick = onDismiss, modifier = Modifier.fillMaxWidth()) {
|
||||||
onClick = onDismiss,
|
|
||||||
modifier = Modifier.fillMaxWidth()
|
|
||||||
) {
|
|
||||||
Text("完成")
|
Text("完成")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ fun BaseFeeView(flowType : Int,
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 5.dp),
|
.padding(vertical = 5.dp),
|
||||||
color = black5)
|
color = black5)
|
||||||
if (GlobalData.driverInfo?.supplierType == Const.CHILD_COMPANY) {
|
if (GlobalData.driverInfoBean?.supplierType == Const.CHILD_COMPANY) {
|
||||||
Spacer(modifier = Modifier.height(5.dp))
|
Spacer(modifier = Modifier.height(5.dp))
|
||||||
OrderConfirmEditView(title = "起步价", value = "${startPrice ?: ""}", onValueChanged = {
|
OrderConfirmEditView(title = "起步价", value = "${startPrice ?: ""}", onValueChanged = {
|
||||||
dispatch(OrderConfirmVm.Action.UpdateStartPrice(it.toIntOrNull() ?: 0))
|
dispatch(OrderConfirmVm.Action.UpdateStartPrice(it.toIntOrNull() ?: 0))
|
||||||
@ -204,7 +204,7 @@ fun AuxiliaryFeeView(dilemmaFee : Int?,
|
|||||||
color = black5,
|
color = black5,
|
||||||
thickness = 0.5.dp)
|
thickness = 0.5.dp)
|
||||||
|
|
||||||
if (GlobalData.driverInfo?.supplierType == Const.CHILD_COMPANY) {
|
if (GlobalData.driverInfoBean?.supplierType == Const.CHILD_COMPANY) {
|
||||||
Column(modifier = Modifier
|
Column(modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(bottom = 12.dp),
|
.padding(bottom = 12.dp),
|
||||||
|
@ -82,7 +82,7 @@ class OrderConfirmVm : IServicingVm<OrderConfirmVm.Action, OrderConfirmVm.UiStat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlobalData.driverInfo?.supplierType != Const.CHILD_COMPANY) {
|
if (GlobalData.driverInfoBean?.supplierType != Const.CHILD_COMPANY) {
|
||||||
|
|
||||||
// AB段不为0 BC段拖车流程不为0
|
// AB段不为0 BC段拖车流程不为0
|
||||||
if (uiState.value.abKm == null || uiState.value.abKm == 0) {
|
if (uiState.value.abKm == null || uiState.value.abKm == 0) {
|
||||||
@ -118,11 +118,11 @@ class OrderConfirmVm : IServicingVm<OrderConfirmVm.Action, OrderConfirmVm.UiStat
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val orderConfirmTaskRequest = UpdateOrderConfirmTaskRequest(type = "SETTLEMENT",
|
val orderConfirmTaskRequest = UpdateOrderConfirmTaskRequest(type = "SETTLEMENT",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = uiState.value.orderInfo?.taskState,
|
currentState = uiState.value.orderInfo?.taskState,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
supplierType = GlobalData.driverInfo?.supplierType,
|
supplierType = GlobalData.driverInfoBean?.supplierType,
|
||||||
settleType = GlobalData.currentOrder?.settleType,
|
settleType = GlobalData.currentOrder?.settleType,
|
||||||
carryMileage = uiState.value.bcKm,
|
carryMileage = uiState.value.bcKm,
|
||||||
startMileage = uiState.value.abKm,
|
startMileage = uiState.value.abKm,
|
||||||
@ -130,10 +130,10 @@ class OrderConfirmVm : IServicingVm<OrderConfirmVm.Action, OrderConfirmVm.UiStat
|
|||||||
carryRoadFee = uiState.value.bcRoadFee,
|
carryRoadFee = uiState.value.bcRoadFee,
|
||||||
dilemmaFee = uiState.value.dilemmaFee,
|
dilemmaFee = uiState.value.dilemmaFee,
|
||||||
basementFee = uiState.value.basementFee,
|
basementFee = uiState.value.basementFee,
|
||||||
basePrice = if (GlobalData.driverInfo?.supplierType == Const.CHILD_COMPANY) {
|
basePrice = if (GlobalData.driverInfoBean?.supplierType == Const.CHILD_COMPANY) {
|
||||||
computerBaseFee()
|
computerBaseFee()
|
||||||
} else null,
|
} else null,
|
||||||
assistFee = if (GlobalData.driverInfo?.supplierType == Const.CHILD_COMPANY) {
|
assistFee = if (GlobalData.driverInfoBean?.supplierType == Const.CHILD_COMPANY) {
|
||||||
computerAssistantsFee()
|
computerAssistantsFee()
|
||||||
} else null,
|
} else null,
|
||||||
totalFee = computerTotalFee(),
|
totalFee = computerTotalFee(),
|
||||||
|
@ -125,10 +125,8 @@ fun ReceiveMoneyScreen(userOrderId: Int,
|
|||||||
CommonDialog(title = "收款成功", message = "收款成功", cancelEnable = false,
|
CommonDialog(title = "收款成功", message = "收款成功", cancelEnable = false,
|
||||||
confirm = {
|
confirm = {
|
||||||
goNextPage(GlobalData.currentOrder?.taskState, context)
|
goNextPage(GlobalData.currentOrder?.taskState, context)
|
||||||
context.finish()
|
|
||||||
}, dismiss = {
|
}, dismiss = {
|
||||||
goNextPage(GlobalData.currentOrder?.taskState, context)
|
goNextPage(GlobalData.currentOrder?.taskState, context)
|
||||||
context.finish()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +164,8 @@ class OrderGiveUpVm : BaseVm<OrderGiveUpVm.Action, OrderGiveUpVm.UiState>() {
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val taskRequest = GiveUpTaskRequest(
|
val taskRequest = GiveUpTaskRequest(
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
lat = it.latitude,
|
lat = it.latitude,
|
||||||
address = it.address,
|
address = it.address,
|
||||||
pushGiveUpFlag = 1,
|
pushGiveUpFlag = 1,
|
||||||
@ -215,8 +215,8 @@ class OrderGiveUpVm : BaseVm<OrderGiveUpVm.Action, OrderGiveUpVm.UiState>() {
|
|||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val taskRequest = GiveUpTaskRequest(
|
val taskRequest = GiveUpTaskRequest(
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
lat = it.latitude,
|
lat = it.latitude,
|
||||||
address = it.address,
|
address = it.address,
|
||||||
lng = it.longitude,
|
lng = it.longitude,
|
||||||
|
@ -80,7 +80,6 @@ fun VerifyOrderScreen(vm: VerifyOrderVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.showCallPhoneDialog == true) {
|
if (uiState.value.showCallPhoneDialog == true) {
|
||||||
|
@ -59,8 +59,8 @@ class VerifyOrderVm : IServicingVm<VerifyOrderVm.Action, VerifyOrderVm.UiState>(
|
|||||||
val temp = UpdateTaskRequest(
|
val temp = UpdateTaskRequest(
|
||||||
type = "VERIFY",
|
type = "VERIFY",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = GlobalData.currentOrder?.taskState,
|
currentState = GlobalData.currentOrder?.taskState,
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
newCarCode = if (uiState.value.orderInfo?.verifyType == 5) {
|
newCarCode = if (uiState.value.orderInfo?.verifyType == 5) {
|
||||||
@ -113,8 +113,8 @@ class VerifyOrderVm : IServicingVm<VerifyOrderVm.Action, VerifyOrderVm.UiState>(
|
|||||||
val taskRequest = UpdateTaskRequest(
|
val taskRequest = UpdateTaskRequest(
|
||||||
type = "VERIFY",
|
type = "VERIFY",
|
||||||
taskId = GlobalData.currentOrder?.taskId,
|
taskId = GlobalData.currentOrder?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = GlobalData.currentOrder?.taskState,
|
currentState = GlobalData.currentOrder?.taskState,
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
newCarCode = if (uiState.value.orderInfo?.verifyType == 5) {
|
newCarCode = if (uiState.value.orderInfo?.verifyType == 5) {
|
||||||
|
@ -115,7 +115,6 @@ fun WaitToStartScreen(vm: WaitToStartVm = viewModel()) {
|
|||||||
|
|
||||||
if (uiState.value.goNextPage != null) {
|
if (uiState.value.goNextPage != null) {
|
||||||
goNextPage(uiState.value.goNextPage?.nextState, context)
|
goNextPage(uiState.value.goNextPage?.nextState, context)
|
||||||
context.finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.value.isGoNextPageDialog == true) {
|
if (uiState.value.isGoNextPageDialog == true) {
|
||||||
@ -188,7 +187,7 @@ fun WaitToStartScreen(vm: WaitToStartVm = viewModel()) {
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = if (uiState.value.remainingDistance > 0)
|
text = if (uiState.value.remainingDistance > 0)
|
||||||
"总里程: %.1fkm".format(uiState.value.remainingDistance / 1000f)
|
"距离救援地: %.1fkm".format(uiState.value.remainingDistance / 1000f)
|
||||||
else
|
else
|
||||||
"计算中...",
|
"计算中...",
|
||||||
color = Color(0xFFFF4D4F),
|
color = Color(0xFFFF4D4F),
|
||||||
|
@ -30,17 +30,17 @@ import kotlinx.coroutines.flow.update
|
|||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>() {
|
class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>() {
|
||||||
private val _uiState = MutableStateFlow(UiState())
|
private val _uiState = MutableStateFlow(UiState())
|
||||||
val uiState get() = _uiState
|
val uiState get() = _uiState
|
||||||
override fun updateState(uiState: UiState) {
|
override fun updateState(uiState : UiState) {
|
||||||
_uiState.value = uiState
|
_uiState.value = uiState
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispatch(action: Action) {
|
override fun dispatch(action : Action) {
|
||||||
when (action) {
|
when (action) {
|
||||||
is Action.Init -> init()
|
is Action.Init -> init()
|
||||||
is Action.UpdateTask -> updateTask()
|
is Action.UpdateTask -> updateTask()
|
||||||
@ -54,11 +54,10 @@ class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>(
|
|||||||
LoadingManager.showLoading()
|
LoadingManager.showLoading()
|
||||||
ZdLocationManager.getSingleLocation(success = {
|
ZdLocationManager.getSingleLocation(success = {
|
||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
val taskRequest = UpdateTaskRequest(
|
val taskRequest = UpdateTaskRequest(type = "START",
|
||||||
type = "START",
|
|
||||||
taskId = getCurrentOrder()?.taskId,
|
taskId = getCurrentOrder()?.taskId,
|
||||||
userId = GlobalData.driverInfo?.userId,
|
userId = GlobalData.driverInfoBean?.userId,
|
||||||
vehicleId = GlobalData.vehicleInfo?.vehicleId,
|
vehicleId = GlobalData.driverInfoBean?.vehicleId,
|
||||||
currentState = getCurrentOrder()?.taskState,
|
currentState = getCurrentOrder()?.taskState,
|
||||||
offlineMode = 0,
|
offlineMode = 0,
|
||||||
operateTime = System.currentTimeMillis().toString(),
|
operateTime = System.currentTimeMillis().toString(),
|
||||||
@ -71,7 +70,7 @@ class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doUploadTask(request: UpdateTaskRequest) {
|
private fun doUploadTask(request : UpdateTaskRequest) {
|
||||||
LoadingManager.showLoading()
|
LoadingManager.showLoading()
|
||||||
CommonMethod.updateTask(request, success = { data ->
|
CommonMethod.updateTask(request, success = { data ->
|
||||||
LoadingManager.hideLoading()
|
LoadingManager.hideLoading()
|
||||||
@ -92,39 +91,28 @@ class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>(
|
|||||||
dispatch(Action.StartTimer)
|
dispatch(Action.StartTimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildMarkers(orderInfo: OrderInfo?) {
|
private fun buildMarkers(orderInfo : OrderInfo?) {
|
||||||
val markers = arrayListOf<MarkerOptions>()
|
val markers = arrayListOf<MarkerOptions>()
|
||||||
|
|
||||||
// 添加救援地点标记
|
// 添加救援地点标记
|
||||||
if (orderInfo?.lat != null && orderInfo.lat != 0.0 &&
|
if (orderInfo?.lat != null && orderInfo.lat != 0.0 && orderInfo.lng != null && orderInfo.lng != 0.0) {
|
||||||
orderInfo.lng != null && orderInfo.lng != 0.0
|
|
||||||
) {
|
|
||||||
|
|
||||||
val startMarker = MarkerOptions()
|
val startMarker = MarkerOptions().position(LatLng(orderInfo.lat !!, orderInfo.lng !!))
|
||||||
.position(LatLng(orderInfo.lat!!, orderInfo.lng!!))
|
.title(orderInfo.address).snippet("救援地点")
|
||||||
.title(orderInfo.address)
|
|
||||||
.snippet("救援地点")
|
|
||||||
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.sv_rescuing_map))
|
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.sv_rescuing_map))
|
||||||
.anchor(0.5f, 0.5f)
|
.anchor(0.5f, 0.5f).zIndex(2f).visible(true)
|
||||||
.zIndex(2f)
|
|
||||||
.visible(true)
|
|
||||||
|
|
||||||
markers.add(startMarker)
|
markers.add(startMarker)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加目的地标记
|
// 添加目的地标记
|
||||||
if (orderInfo?.distLat != null && orderInfo.distLat != 0.0 &&
|
if (orderInfo?.distLat != null && orderInfo.distLat != 0.0 && orderInfo.distLng != null && orderInfo.distLng != 0.0) {
|
||||||
orderInfo.distLng != null && orderInfo.distLng != 0.0
|
|
||||||
) {
|
|
||||||
|
|
||||||
val destMarker = MarkerOptions()
|
val destMarker =
|
||||||
.position(LatLng(orderInfo.distLat!!, orderInfo.distLng!!))
|
MarkerOptions().position(LatLng(orderInfo.distLat !!, orderInfo.distLng !!))
|
||||||
.title(orderInfo.distAddress)
|
.title(orderInfo.distAddress).snippet("目的地")
|
||||||
.snippet("目的地")
|
|
||||||
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.sv_dist_map))
|
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.sv_dist_map))
|
||||||
.anchor(0.5f, 0.5f)
|
.anchor(0.5f, 0.5f).zIndex(2f).visible(true)
|
||||||
.zIndex(2f)
|
|
||||||
.visible(true)
|
|
||||||
|
|
||||||
markers.add(destMarker)
|
markers.add(destMarker)
|
||||||
}
|
}
|
||||||
@ -132,40 +120,28 @@ class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>(
|
|||||||
updateState(uiState.value.copy(markers = markers))
|
updateState(uiState.value.copy(markers = markers))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun searchDrivingRoute(orderInfo: OrderInfo?) {
|
private fun searchDrivingRoute(orderInfo : OrderInfo?) { // 如果没有当前位置,则不进行路径规划
|
||||||
// 如果没有当前位置,则不进行路径规划
|
|
||||||
if (GlobalData.currentLocation == null) return
|
if (GlobalData.currentLocation == null) return
|
||||||
|
|
||||||
val startPoint = LatLonPoint(
|
val startPoint = LatLonPoint(GlobalData.currentLocation?.latitude ?: 0.0,
|
||||||
GlobalData.currentLocation?.latitude ?: 0.0,
|
GlobalData.currentLocation?.longitude ?: 0.0)
|
||||||
GlobalData.currentLocation?.longitude ?: 0.0
|
|
||||||
)
|
|
||||||
|
|
||||||
// 确定终点:如果有目的地,否则用救援地点
|
// 获取救援地点坐标
|
||||||
val endPoint = when {
|
val rescuePoint =
|
||||||
// 优先使用目的地
|
if (orderInfo?.lat != null && orderInfo.lat != 0.0 && orderInfo.lng != null && orderInfo.lng != 0.0) {
|
||||||
orderInfo?.distLat != null && orderInfo.distLat != 0.0 &&
|
LatLonPoint(orderInfo.lat !!, orderInfo.lng !!)
|
||||||
orderInfo.distLng != null && orderInfo.distLng != 0.0 -> {
|
} else null
|
||||||
LatLonPoint(orderInfo.distLat!!, orderInfo.distLng!!)
|
|
||||||
|
// 如果没有救援地点,则不进行规划
|
||||||
|
if (rescuePoint == null) {
|
||||||
|
LogUtil.print("searchDrivingRoute", "没有有效的终点")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// 其次使用救援地点
|
|
||||||
orderInfo?.lat != null && orderInfo.lat != 0.0 &&
|
|
||||||
orderInfo.lng != null && orderInfo.lng != 0.0 -> {
|
|
||||||
LatLonPoint(orderInfo.lat!!, orderInfo.lng!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endPoint == null) return
|
|
||||||
|
|
||||||
val fromAndTo = RouteSearch.FromAndTo(startPoint, endPoint)
|
|
||||||
val query = RouteSearch.DriveRouteQuery(fromAndTo, RouteSearch.DrivingDefault, null, null, "")
|
|
||||||
|
|
||||||
// 使用 Application Context
|
// 使用 Application Context
|
||||||
RouteSearch(GlobalData.application).apply {
|
RouteSearch(GlobalData.application).apply {
|
||||||
setRouteSearchListener(object : RouteSearch.OnRouteSearchListener {
|
setRouteSearchListener(object : RouteSearch.OnRouteSearchListener {
|
||||||
override fun onDriveRouteSearched(result: DriveRouteResult?, errorCode: Int) {
|
override fun onDriveRouteSearched(result : DriveRouteResult?, errorCode : Int) {
|
||||||
if (errorCode == 1000 && result != null && result.paths.isNotEmpty()) {
|
if (errorCode == 1000 && result != null && result.paths.isNotEmpty()) {
|
||||||
val path = result.paths[0]
|
val path = result.paths[0]
|
||||||
val points = path.steps.flatMap { step ->
|
val points = path.steps.flatMap { step ->
|
||||||
@ -177,58 +153,52 @@ class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBusRouteSearched(p0: BusRouteResult?, p1: Int) {}
|
override fun onBusRouteSearched(p0 : BusRouteResult?, p1 : Int) {}
|
||||||
override fun onWalkRouteSearched(p0: WalkRouteResult?, p1: Int) {}
|
override fun onWalkRouteSearched(p0 : WalkRouteResult?, p1 : Int) {}
|
||||||
override fun onRideRouteSearched(p0: RideRouteResult?, p1: Int) {}
|
override fun onRideRouteSearched(p0 : RideRouteResult?, p1 : Int) {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
val fromAndTo = RouteSearch.FromAndTo(startPoint, rescuePoint)
|
||||||
|
val query =
|
||||||
|
RouteSearch.DriveRouteQuery(fromAndTo, RouteSearch.DrivingDefault, null, null, "")
|
||||||
calculateDriveRouteAsyn(query)
|
calculateDriveRouteAsyn(query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var timerJob: Job? = null
|
private var timerJob : Job? = null
|
||||||
|
|
||||||
private fun startTimer() {
|
private fun startTimer() {
|
||||||
timerJob?.cancel()
|
timerJob?.cancel()
|
||||||
timerJob = viewModelScope.launch {
|
timerJob = viewModelScope.launch {
|
||||||
while (isActive) {
|
while (isActive) { // 计算从当前位置到目标点的距离和到达时间
|
||||||
// 计算从当前位置到目标点的距离和到达时间
|
|
||||||
val (distance, arrivalTime) = calculateRemainingDistance()
|
val (distance, arrivalTime) = calculateRemainingDistance()
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
it.copy(
|
it.copy(remainingDistance = distance, estimatedArrivalTime = arrivalTime)
|
||||||
remainingDistance = distance,
|
|
||||||
estimatedArrivalTime = arrivalTime
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
delay(1000) // 每秒更新一次
|
delay(1000) // 每秒更新一次
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateRemainingDistance(): Pair<Float, String> {
|
private fun calculateRemainingDistance() : Pair<Float, String> {
|
||||||
val currentLocation = GlobalData.currentLocation ?: return Pair(0f, "")
|
val currentLocation = GlobalData.currentLocation ?: return Pair(0f, "")
|
||||||
val orderInfo = _uiState.value.orderInfo ?: return Pair(0f, "")
|
val orderInfo = _uiState.value.orderInfo ?: return Pair(0f, "")
|
||||||
|
|
||||||
// 计算到救援地点的距离
|
// 计算到救援地点的距离
|
||||||
val rescueDistance = if (orderInfo.lat != null && orderInfo.lng != null) {
|
val rescueDistance = if (orderInfo.lat != null && orderInfo.lng != null) {
|
||||||
AMapUtils.calculateLineDistance(
|
AMapUtils.calculateLineDistance(LatLng(currentLocation.latitude,
|
||||||
LatLng(currentLocation.latitude, currentLocation.longitude),
|
currentLocation.longitude), LatLng(orderInfo.lat !!, orderInfo.lng !!))
|
||||||
LatLng(orderInfo.lat!!, orderInfo.lng!!)
|
|
||||||
)
|
|
||||||
} else 0f
|
} else 0f
|
||||||
|
|
||||||
// 计算到目的地的距离
|
// 计算到目的地的距离
|
||||||
val destDistance = if (orderInfo.distLat != null && orderInfo.distLng != null) {
|
val destDistance = if (orderInfo.distLat != null && orderInfo.distLng != null) {
|
||||||
AMapUtils.calculateLineDistance(
|
AMapUtils.calculateLineDistance(LatLng(currentLocation.latitude,
|
||||||
LatLng(currentLocation.latitude, currentLocation.longitude),
|
currentLocation.longitude), LatLng(orderInfo.distLat !!, orderInfo.distLng !!))
|
||||||
LatLng(orderInfo.distLat!!, orderInfo.distLng!!)
|
|
||||||
)
|
|
||||||
} else 0f
|
} else 0f
|
||||||
|
|
||||||
// 取较短的距离
|
// 取较短的距离
|
||||||
val shortestDistance = minOf(
|
val shortestDistance = minOf(rescueDistance.takeIf { it > 0f } ?: Float.MAX_VALUE,
|
||||||
rescueDistance.takeIf { it > 0f } ?: Float.MAX_VALUE,
|
destDistance.takeIf { it > 0f } ?: Float.MAX_VALUE)
|
||||||
destDistance.takeIf { it > 0f } ?: Float.MAX_VALUE
|
|
||||||
)
|
|
||||||
|
|
||||||
if (shortestDistance == Float.MAX_VALUE) {
|
if (shortestDistance == Float.MAX_VALUE) {
|
||||||
return Pair(0f, "")
|
return Pair(0f, "")
|
||||||
@ -243,8 +213,7 @@ class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>(
|
|||||||
return Pair(shortestDistance, arrivalTime)
|
return Pair(shortestDistance, arrivalTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTimer() {
|
private fun updateTimer() { // 在这里处理倒计时更新逻辑
|
||||||
// 在这里处理倒计时更新逻辑
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
@ -255,19 +224,17 @@ class WaitToStartVm : IServicingVm<WaitToStartVm.Action, WaitToStartVm.UiState>(
|
|||||||
sealed class Action {
|
sealed class Action {
|
||||||
data object Init : Action()
|
data object Init : Action()
|
||||||
data object UpdateTask : Action()
|
data object UpdateTask : Action()
|
||||||
data class UpdateState(val uiState: UiState) : Action()
|
data class UpdateState(val uiState : UiState) : Action()
|
||||||
data object StartTimer : Action()
|
data object StartTimer : Action()
|
||||||
data object UpdateTimer : Action()
|
data object UpdateTimer : Action()
|
||||||
}
|
}
|
||||||
|
|
||||||
data class UiState(
|
data class UiState(val orderInfo : OrderInfo? = null,
|
||||||
val orderInfo: OrderInfo? = null,
|
val showCallPhoneDialog : Boolean? = false,
|
||||||
val showCallPhoneDialog: Boolean? = false,
|
val markers : ArrayList<MarkerOptions>? = null,
|
||||||
val markers: ArrayList<MarkerOptions>? = null,
|
val goNextPage : UpdateTaskBean? = null,
|
||||||
val goNextPage: UpdateTaskBean? = null,
|
val isGoNextPageDialog : Boolean? = null,
|
||||||
val isGoNextPageDialog: Boolean? = null,
|
val routePoints : List<LatLng>? = null,
|
||||||
val routePoints: List<LatLng>? = null,
|
val remainingDistance : Float = 0f,
|
||||||
val remainingDistance: Float = 0f,
|
val estimatedArrivalTime : String = "")
|
||||||
val estimatedArrivalTime: String = ""
|
|
||||||
)
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user