app/src/main/java/com/xw/yunwei/model/CertificateAuditInfo.kt
@@ -12,6 +12,7 @@ var idCardFront: String? = null,//身份证正面 var operationsUserId: String? = null,//运维人员id var trainingGraduationCertificate: String? = null,//培训结业证 var isUpdateAuditing: String? = null,//是否更新资料审核中 1是 ) { //是否有效 fun isEffective() = !auditStatus.isNullOrEmpty() @@ -24,4 +25,7 @@ //是否审核失败 fun hadAuditFail() = auditStatus == "3" //是否在更新资料审核中 fun isInUpdateWaitAudit() = isUpdateAuditing == "1" } app/src/main/java/com/xw/yunwei/model/TaskModel.kt
@@ -33,6 +33,7 @@ * 1 = 待处理 * 2 = 已完成 * 3 = 已取消 * 4 = 改派中 */ @SerializedName("status") val status: Int? = null, app/src/main/java/com/xw/yunwei/model/VehicleLocationInfo.kt
@@ -5,4 +5,5 @@ val longitude: String? = null,//经度 val latitude: String? = null,//纬度 val address: String? = null,//地址 val tips: String? = null,//提示语 ) app/src/main/java/com/xw/yunwei/net/TaskApi.kt
@@ -11,6 +11,7 @@ import com.xw.yunwei.model.TaskNormalModel import com.xw.yunwei.model.TaskNormalRepairModel import com.xw.yunwei.model.TaskStatisticInfo import com.xw.yunwei.model.VehicleLocationInfo import com.xw.yunwei.model.XpErrorType import okhttp3.RequestBody import retrofit2.Call @@ -93,4 +94,8 @@ /*任务中心状态统计*/ @POST("maintenance/maintenance-app/api/v1/task/statistic") fun statistic(@Body body: RequestBody): Call<HttpResponse<TaskStatisticInfo>> /*查询车辆新位置信息*/ @POST("maintenance/maintenance-app/api/v1/task/queryVehicleNewPoint") fun queryVehicleNewPoint(@Body body: RequestBody): Call<HttpResponse<VehicleLocationInfo>> } app/src/main/java/com/xw/yunwei/net/TaskRepository.kt
@@ -1,8 +1,10 @@ package com.xw.yunwei.net import com.xw.common.Constants import com.xw.common.net.BaseHttpManager.Companion.getBody import com.xw.common.net.interceptAwait import com.xw.yunwei.model.TaskStatisticInfo import com.xw.yunwei.model.VehicleLocationInfo class TaskRepository(private val api: TaskApi) { @@ -66,4 +68,14 @@ ) return api.statistic(getBody(map)).interceptAwait() } /*查询车辆新位置信息*/ suspend fun queryVehicleNewPoint(vehicleId: String?): VehicleLocationInfo? { val map = mapOf( "vehicleId" to vehicleId, "longitude" to Constants.longitude, "latitude" to Constants.latitude ) return api.queryVehicleNewPoint(getBody(map)).interceptAwait() } } app/src/main/java/com/xw/yunwei/ui/task/TaskFragment.kt
@@ -125,6 +125,7 @@ override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.viewPager.adapter = adapter binding.viewPager.offscreenPageLimit = 5 // 默认值,可根据需要调整 tabLayoutMediator = TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position -> tab.text = tabTitles[position] @@ -561,17 +562,28 @@ * 根据 position 返回对应状态的任务列表 Fragment */ inner class PagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) { private val pages = listOf( viewModel.allTaskFragment, viewModel.togoTaskFragment, viewModel.todoTaskFragment, viewModel.finishTaskFragment, viewModel.reassignmentTaskFragment ) override fun getItemCount(): Int = tabTitles.size override fun createFragment(position: Int): TaskListFragment { return when (position) { 0 -> viewModel.allTaskFragment 1 -> viewModel.togoTaskFragment 2 -> viewModel.todoTaskFragment 3 -> viewModel.finishTaskFragment 4 -> viewModel.reassignmentTaskFragment else -> error("Wrong position $position") } return pages[position] } // 返回唯一的 ID,推荐使用数据的哈希值 override fun getItemId(position: Int): Long { return pages[position].hashCode().toLong() } // 告诉 ViewPager2 某个 ID 是否仍然有效 override fun containsItem(itemId: Long): Boolean { return pages.any { it.hashCode().toLong() == itemId } } } app/src/main/java/com/xw/yunwei/ui/task/accident/detail/AccidentDetailVM.kt
@@ -9,6 +9,7 @@ import androidx.core.os.bundleOf import androidx.lifecycle.MutableLiveData import androidx.lifecycle.map import androidx.lifecycle.viewModelScope import com.amap.api.location.AMapLocation import com.amap.api.maps.model.LatLng import com.xw.common.base.BaseViewModel @@ -21,6 +22,7 @@ import com.xw.yunwei.model.SwitchTabMain import com.xw.yunwei.model.SwitchTabTask import com.xw.yunwei.model.TaskAccidentModel import com.xw.yunwei.model.VehicleLocationInfo import com.xw.yunwei.net.TaskRepository import com.xw.yunwei.net.UserRepository import com.xw.yunwei.net.WorkRepository @@ -28,6 +30,7 @@ import com.xw.yunwei.ui.task.accident.handle.AccidentProcessActivity import com.xw.yunwei.ui.task.list.TaskListAdapter.Companion.MSG_COUNTDOWN import kotlinx.coroutines.delay import kotlinx.coroutines.launch import org.greenrobot.eventbus.EventBus import org.koin.core.component.inject import java.time.Duration @@ -117,6 +120,12 @@ /** 当前定位信息 */ var location: AMapLocation? = null //是否已经循环检测车辆位置 var hadLoopRefreshCarLocation = false //车辆位置 val carLocation = MutableLiveData<VehicleLocationInfo>() /** 页面点击事件统一监听 */ var onClick = View.OnClickListener { when (it.id) { @@ -138,8 +147,24 @@ taskDetail.postValue(it) if (it.status == 0) { startCountdown() carLocation.postValue( VehicleLocationInfo( it.vehicleLon?.toString(), it.vehicleLat?.toString(), it.vehicleLocation ) ) loopRefreshCarLocation() } else if (it.status == 1) { stopCountdown() carLocation.postValue( VehicleLocationInfo( it.vehicleLon?.toString(), it.vehicleLat?.toString(), it.vehicleLocation ) ) loopRefreshCarLocation() } } } @@ -372,4 +397,27 @@ finish() } } //循环刷新车辆位置 private fun loopRefreshCarLocation() { if (hadLoopRefreshCarLocation) { return } hadLoopRefreshCarLocation = true viewModelScope.launch { while (true) { delay(60 * 1000) launchRequest(showLoading = false, error = { code, msg -> LogUtils.e(TAG, "launchRequest: code = $code msg = $msg") }) { taskDetail.value?.also { it -> taskRepository.queryVehicleNewPoint(it.vehicleId?.toString())?.also { carLocation.postValue(it) } } } } } } } app/src/main/java/com/xw/yunwei/ui/task/list/TaskListAdapter.kt
@@ -164,7 +164,7 @@ levelId?.let { bind.level.setImageResource(levelId) } // 事故类待到达任务显示倒计时布局 if (item.status == 0 && item.taskCategory == 2) { if ((item.status == 0 || item.status == 4) && item.taskCategory == 2) { bind.countdownLayout.isVisible = true val list = calculateTimeDifference(item.endTime) updateTime(bind, list) app/src/main/java/com/xw/yunwei/ui/task/normal/NormalTaskDetailVM.kt
@@ -7,6 +7,7 @@ import androidx.core.os.bundleOf import androidx.lifecycle.MutableLiveData import androidx.lifecycle.map import androidx.lifecycle.viewModelScope import com.amap.api.location.AMapLocation import com.blankj.utilcode.util.GsonUtils import com.xw.common.base.BaseViewModel @@ -26,6 +27,7 @@ import com.xw.yunwei.model.TaskNormalMaintainModel import com.xw.yunwei.model.TaskNormalModel import com.xw.yunwei.model.TaskNormalRepairModel import com.xw.yunwei.model.VehicleLocationInfo import com.xw.yunwei.net.CommonRepository import com.xw.yunwei.net.TaskRepository import com.xw.yunwei.net.WorkRepository @@ -36,6 +38,7 @@ import com.xw.yunwei.ui.work.car.detail.operations.maintain.MaintainCarActivity import com.xw.yunwei.ui.work.car.detail.operations.repair.RepairCarActivity import kotlinx.coroutines.delay import kotlinx.coroutines.launch import okhttp3.MediaType.Companion.toMediaType import okhttp3.MultipartBody import okhttp3.RequestBody.Companion.asRequestBody @@ -130,6 +133,12 @@ /** 维修任务子详情 */ val repairModel: MutableLiveData<TaskNormalRepairModel> = MutableLiveData() //是否已经循环检测车辆位置 var hadLoopRefreshCarLocation = false //车辆位置 val carLocation = MutableLiveData<VehicleLocationInfo>() /** 统一点击事件处理:查看标准说明、提交任务 */ val onClick = View.OnClickListener { when (it.id) { @@ -175,6 +184,14 @@ } if (it.status == 1) { // 待处理 queryDoingTaskStatusByType() carLocation.postValue( VehicleLocationInfo( it.vehicleLon?.toString(), it.vehicleLat?.toString(), it.vehicleLocation ) ) loopRefreshCarLocation() } else if (it.status == 2) { // 已处理 queryFinishTaskByType() } @@ -443,4 +460,27 @@ finish() } } //循环刷新车辆位置 private fun loopRefreshCarLocation() { if (hadLoopRefreshCarLocation) { return } hadLoopRefreshCarLocation = true viewModelScope.launch { while (true) { delay(60 * 1000) launchRequest(showLoading = false, error = { code, msg -> LogUtils.e(TAG, "launchRequest: code = $code msg = $msg") }) { taskDetail.value?.also { it -> taskRepository.queryVehicleNewPoint(it.vehicleId?.toString())?.also { carLocation.postValue(it) } } } } } } } app/src/main/java/com/xw/yunwei/ui/user/mine/scheduling/SchedulingActivity.kt
@@ -157,13 +157,13 @@ setStatus( binding.clockIntStatus, getResColor(if (it.xpClockIn?.hadLostWorkCheckedIn() == true) R.color.red_5 else if (it.clockIn == true) R.color.gray_7 else if (!isToday) R.color.gray_8 else R.color.orange_5), if (it.xpClockIn?.hadLostWorkCheckedIn() == true) R.color.red_1 else if (it.clockIn == true) R.color.gray_3 else if (!isToday) R.color.gray_3 else R.color.orange_1, if (it.xpClockIn?.hadLostWorkCheckedIn() == true) R.color.red_1 else if (it.clockIn == true) R.color.gray_3 else if (!isToday) com.xw.yunwei.R.drawable.shape_gray_4_bg_4 else R.color.orange_1, if (it.xpClockIn?.hadLostWorkCheckedIn() == true) "缺卡" else if (it.clockIn == true) "已打卡" else if (!isToday) "不在打卡时间范围内" else "未打卡" ) setStatus( binding.clockOutStatus, getResColor(if (it.xpClockIn?.hadLostOffWorkCheckedIn() == true) R.color.red_5 else if (it.clockOut == true) R.color.gray_7 else if (!isToday) R.color.gray_8 else R.color.orange_5), if (it.xpClockIn?.hadLostOffWorkCheckedIn() == true) R.color.red_1 else if (it.clockOut == true) R.color.gray_3 else if (!isToday) R.color.gray_3 else R.color.orange_1, if (it.xpClockIn?.hadLostOffWorkCheckedIn() == true) R.color.red_1 else if (it.clockOut == true) R.color.gray_3 else if (!isToday) com.xw.yunwei.R.drawable.shape_gray_4_bg_4 else R.color.orange_1, if (it.xpClockIn?.hadLostOffWorkCheckedIn() == true) "缺卡" else if (it.clockOut == true) "已打卡" else if (!isToday) "不在打卡时间范围内" else "未打卡" ) // 未上班打卡或缺卡 可上班打卡 app/src/main/java/com/xw/yunwei/ui/user/mine/upload/CertUploadVM.kt
@@ -163,7 +163,7 @@ refresh.forEach { refresh -> refresh.postValue(false) } hadAuditHistory.postValue(auditInfo.hadAuditSuccess() || !userInfo?.idCardFront.isNullOrEmpty()) hadAuditHistory.postValue(auditInfo.isInUpdateWaitAudit()) } else { hadAuditHistory.postValue(false) } app/src/main/res/layout/activity_accident_detail.xml
@@ -251,7 +251,7 @@ android:layout_gravity="center_vertical" android:layout_marginStart="@dimen/dp_12" android:layout_weight="1" android:text="@{viewModel.taskDetail.vehicleLocation}" android:text="@{viewModel.carLocation.address}" android:textColor="@color/gray_9" android:textSize="@dimen/sp_14" android:textStyle="bold" @@ -266,6 +266,20 @@ android:src="@drawable/svg_map_nav" /> </LinearLayout> <TextView android:id="@+id/tv_notice" show='@{viewModel.carLocation.tips != "" && viewModel.carLocation.tips != null}' android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_4" android:text="@{viewModel.carLocation.tips}" android:textColor="@color/red_5" android:textSize="@dimen/sp_11" android:visibility="gone" app:layout_constraintStart_toStartOf="@id/et_input" app:layout_constraintTop_toBottomOf="@id/et_input" tools:visibility="visible" /> <LinearLayout android:layout_width="match_parent" @@ -324,7 +338,7 @@ android:layout_weight="1" android:gravity="end" android:singleLine="true" android:text="@{viewModel.taskDetail.vehicleLocation}" android:text="@{viewModel.carLocation.address}" android:textColor="@color/gray_7" android:textSize="@dimen/sp_14" tools:text="深圳市南山区南大街龙葵小区7栋1701" /> app/src/main/res/layout/activity_accident_process.xml
@@ -71,7 +71,7 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_20" android:layout_marginHorizontal="@dimen/dp_28" android:layout_marginTop="@dimen/dp_12" android:background="@drawable/shape_f9f9f9_bg_4" android:orientation="vertical" @@ -279,7 +279,7 @@ <androidx.appcompat.widget.AppCompatTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_20" android:layout_marginHorizontal="@dimen/dp_28" android:layout_marginTop="@dimen/dp_8" android:text="初版(交警)责任判断" android:textColor="@color/gray_9" @@ -289,7 +289,7 @@ android:id="@+id/stllZrpd" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_20" android:layout_marginHorizontal="@dimen/dp_28" android:layout_marginTop="@dimen/dp_12" android:orientation="vertical" app:layout_constraintTop_toBottomOf="@+id/tv1" @@ -306,7 +306,7 @@ <androidx.appcompat.widget.AppCompatTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_20" android:layout_marginHorizontal="@dimen/dp_28" android:layout_marginTop="@dimen/dp_12" android:text="交警判责照片" android:textColor="@color/gray_9" @@ -316,7 +316,7 @@ android:id="@+id/rv1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_15" android:layout_marginHorizontal="@dimen/dp_23" android:layout_marginTop="@dimen/dp_12" android:orientation="horizontal" tools:layout_height="@dimen/dp_63" /> @@ -361,7 +361,7 @@ <androidx.appcompat.widget.AppCompatTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/dp_6" android:layout_margin="@dimen/dp_12" android:text="@{viewModel.siteNums}" android:textColor="@color/gray_6" android:textSize="@dimen/sp_14" @@ -374,7 +374,7 @@ <androidx.appcompat.widget.AppCompatTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_20" android:layout_marginHorizontal="@dimen/dp_28" android:layout_marginTop="@dimen/dp_12" android:text="现场照片" android:textColor="@color/gray_9" @@ -384,7 +384,7 @@ android:id="@+id/rv2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_15" android:layout_marginHorizontal="@dimen/dp_23" android:layout_marginTop="@dimen/dp_12" android:orientation="horizontal" tools:layout_height="@dimen/dp_63" /> @@ -429,7 +429,7 @@ <androidx.appcompat.widget.AppCompatTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/dp_6" android:layout_margin="@dimen/dp_12" android:text="@{viewModel.disposalNums}" android:textColor="@color/gray_6" android:textSize="@dimen/sp_14" @@ -442,7 +442,7 @@ <androidx.appcompat.widget.AppCompatTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_20" android:layout_marginHorizontal="@dimen/dp_28" android:layout_marginTop="@dimen/dp_12" android:text="处置照片" android:textColor="@color/gray_9" @@ -452,7 +452,7 @@ android:id="@+id/rv3" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/dp_15" android:layout_marginHorizontal="@dimen/dp_23" android:layout_marginTop="@dimen/dp_12" android:orientation="horizontal" tools:layout_height="@dimen/dp_63" /> @@ -477,7 +477,7 @@ android:layout_width="match_parent" android:layout_height="@dimen/dp_40" android:layout_centerVertical="true" android:layout_marginHorizontal="@dimen/dp_20" android:layout_marginHorizontal="@dimen/dp_28" android:background="@drawable/shape_blue_5_bg_4" android:gravity="center" android:onClick="@{viewModel.onClick}" app/src/main/res/layout/activity_scheduling.xml
@@ -266,7 +266,7 @@ <com.google.android.material.button.MaterialButton android:id="@+id/clockIn" show="@{viewModel.selectTime.equals(viewModel.today) && (viewModel.clockModel.clockIn != true || viewModel.clockModel.xpClockIn.clockInResult == 3)}" show="@{viewModel.selectTime.equals(viewModel.today) && (viewModel.clockModel.clockIn != true && viewModel.clockModel.xpClockIn.clockInResult != 3)}" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_8" @@ -348,7 +348,7 @@ <com.google.android.material.button.MaterialButton android:id="@+id/clockOut" show="@{viewModel.selectTime.equals(viewModel.today) && (viewModel.clockModel.clockOut != true || viewModel.clockModel.xpClockIn.clockOutResult == 3)}" show="@{viewModel.selectTime.equals(viewModel.today) && (viewModel.clockModel.clockOut != true && viewModel.clockModel.xpClockIn.clockOutResult != 3)}" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_8" app/src/main/res/layout/layout_normal_task_status1.xml
@@ -107,6 +107,20 @@ </LinearLayout> <TextView android:id="@+id/tv_notice" show='@{viewModel.carLocation.tips != "" && viewModel.carLocation.tips != null}' android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_4" android:text="@{viewModel.carLocation.tips}" android:textColor="@color/red_5" android:textSize="@dimen/sp_11" android:visibility="gone" app:layout_constraintStart_toStartOf="@id/et_input" app:layout_constraintTop_toBottomOf="@id/et_input" tools:visibility="visible" /> <!--车辆信息--> <LinearLayout android:layout_width="match_parent" @@ -164,7 +178,7 @@ android:layout_marginStart="@dimen/dp_16" android:layout_weight="1" android:gravity="end" android:text="@{viewModel.taskDetail.vehicleLocation}" android:text="@{viewModel.carLocation.address}" android:textColor="@color/gray_7" android:textSize="@dimen/sp_14" tools:text="深圳市南山区南大街龙葵小区7栋1701" />