feat: 新增日志查询页面及操作日志详情页
废弃旧日志查询页面,新建日志查询列表页和操作日志详情页。 详情页包含运单信息、流转状态进度条和操作详情时间线。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
package com.lukouguoji.aerologic.page.log.detail
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.google.gson.Gson
|
||||
import com.lukouguoji.aerologic.R
|
||||
import com.lukouguoji.aerologic.databinding.ActivityLogDetailBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.bean.LogBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_LOG_DETAIL)
|
||||
class LogDetailActivity : BaseBindingActivity<ActivityLogDetailBinding, LogDetailViewModel>() {
|
||||
|
||||
private val timelineAdapter = LogDetailTimelineAdapter()
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_log_detail
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<LogDetailViewModel> {
|
||||
return LogDetailViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("操作日志详情")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 配置操作详情 RecyclerView(垂直时间线)
|
||||
binding.rvTimeline.adapter = timelineAdapter
|
||||
|
||||
// 观察流转状态变化,程序化构建步骤进度条
|
||||
viewModel.currentStepIndex.observe(this) { index ->
|
||||
buildStepProgressBar(viewModel.allSteps, index)
|
||||
}
|
||||
|
||||
viewModel.statusLogList.observe(this) { list ->
|
||||
timelineAdapter.setData(list)
|
||||
}
|
||||
|
||||
viewModel.initOnCreated(intent)
|
||||
}
|
||||
|
||||
private fun buildStepProgressBar(steps: List<String>, currentIndex: Int) {
|
||||
val container = binding.llSteps
|
||||
container.removeAllViews()
|
||||
|
||||
val colorBlue = 0xFF1C8CF5.toInt()
|
||||
val colorGray = 0xFFCCCCCC.toInt()
|
||||
val colorGreen = 0xFF4CAF50.toInt()
|
||||
val dotSize = dp(10)
|
||||
val lineHeight = dp(2)
|
||||
|
||||
for (i in steps.indices) {
|
||||
val isCompleted = i <= currentIndex
|
||||
val isCurrent = i == currentIndex
|
||||
val isFirst = i == 0
|
||||
val isLast = i == steps.size - 1
|
||||
|
||||
// 每个步骤的根容器(等宽)
|
||||
val stepLayout = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
gravity = Gravity.CENTER_HORIZONTAL
|
||||
layoutParams = LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)
|
||||
}
|
||||
|
||||
// 步骤名称(所有步骤统一 padding 确保高度一致)
|
||||
val tvName = TextView(this).apply {
|
||||
text = steps[i]
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f)
|
||||
gravity = Gravity.CENTER
|
||||
setPadding(dp(6), dp(2), dp(6), dp(2))
|
||||
if (isCurrent) {
|
||||
setBackgroundResource(R.drawable.bg_step_current_badge)
|
||||
setTextColor(0xFFFFFFFF.toInt())
|
||||
} else {
|
||||
setTextColor(if (isCompleted) 0xFF333333.toInt() else 0xFF999999.toInt())
|
||||
}
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
}
|
||||
stepLayout.addView(tvName)
|
||||
|
||||
// 圆点和连线区域(FrameLayout 叠加)
|
||||
val dotLineContainer = FrameLayout(this).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT, dp(20)
|
||||
).apply { topMargin = dp(8) }
|
||||
}
|
||||
|
||||
// 左半连线(从左边缘到中心,略超过中心以避免断层)
|
||||
if (!isFirst) {
|
||||
val lineLeft = View(this).apply {
|
||||
setBackgroundColor(if (isCompleted) colorBlue else colorGray)
|
||||
layoutParams = FrameLayout.LayoutParams(0, lineHeight).apply {
|
||||
gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
||||
}
|
||||
}
|
||||
dotLineContainer.addView(lineLeft)
|
||||
dotLineContainer.post {
|
||||
lineLeft.layoutParams = FrameLayout.LayoutParams(
|
||||
dotLineContainer.width / 2 + dotSize / 2, lineHeight
|
||||
).apply { gravity = Gravity.CENTER_VERTICAL or Gravity.START }
|
||||
}
|
||||
}
|
||||
|
||||
// 右半连线(从中心到右边缘,略超过中心以避免断层)
|
||||
if (!isLast) {
|
||||
val rightLineColor = if (isCompleted && !isCurrent) colorBlue else colorGray
|
||||
val lineRight = View(this).apply {
|
||||
setBackgroundColor(rightLineColor)
|
||||
layoutParams = FrameLayout.LayoutParams(0, lineHeight).apply {
|
||||
gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
||||
}
|
||||
}
|
||||
dotLineContainer.addView(lineRight)
|
||||
dotLineContainer.post {
|
||||
lineRight.layoutParams = FrameLayout.LayoutParams(
|
||||
dotLineContainer.width / 2 + dotSize / 2, lineHeight
|
||||
).apply { gravity = Gravity.CENTER_VERTICAL or Gravity.END }
|
||||
}
|
||||
}
|
||||
|
||||
// 圆点(叠加在连线之上)
|
||||
val dot = View(this).apply {
|
||||
setBackgroundResource(
|
||||
when {
|
||||
isCurrent -> R.drawable.bg_step_dot_green
|
||||
isCompleted -> R.drawable.bg_step_dot_blue
|
||||
else -> R.drawable.bg_step_dot_gray
|
||||
}
|
||||
)
|
||||
layoutParams = FrameLayout.LayoutParams(dotSize, dotSize).apply {
|
||||
gravity = Gravity.CENTER
|
||||
}
|
||||
}
|
||||
dotLineContainer.addView(dot)
|
||||
|
||||
stepLayout.addView(dotLineContainer)
|
||||
container.addView(stepLayout)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dp(value: Int): Int {
|
||||
return TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP, value.toFloat(), resources?.displayMetrics
|
||||
).toInt()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, bean: LogBean) {
|
||||
val starter = Intent(context, LogDetailActivity::class.java)
|
||||
starter.putExtra(Constant.Key.DATA, Gson().toJson(bean))
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.lukouguoji.aerologic.page.log.detail
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.aerologic.R
|
||||
|
||||
class LogDetailStepAdapter : RecyclerView.Adapter<LogDetailStepAdapter.StepViewHolder>() {
|
||||
|
||||
private var steps: List<String> = emptyList()
|
||||
private var currentIndex: Int = -1
|
||||
|
||||
fun setData(steps: List<String>, currentIndex: Int) {
|
||||
this.steps = steps
|
||||
this.currentIndex = currentIndex
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StepViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.item_log_step, parent, false)
|
||||
return StepViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: StepViewHolder, position: Int) {
|
||||
val step = steps[position]
|
||||
val isCompleted = position <= currentIndex
|
||||
val isCurrent = position == currentIndex
|
||||
val isFirst = position == 0
|
||||
val isLast = position == steps.size - 1
|
||||
|
||||
// 步骤名称
|
||||
if (isCurrent) {
|
||||
holder.tvStepName.setBackgroundResource(R.drawable.bg_step_current_badge)
|
||||
holder.tvStepName.setTextColor(0xFFFFFFFF.toInt())
|
||||
} else {
|
||||
holder.tvStepName.setBackgroundResource(0)
|
||||
holder.tvStepName.setTextColor(
|
||||
if (isCompleted) 0xFF333333.toInt() else 0xFF999999.toInt()
|
||||
)
|
||||
}
|
||||
holder.tvStepName.text = step
|
||||
|
||||
// 圆点
|
||||
holder.dotView.setBackgroundResource(
|
||||
when {
|
||||
isCurrent -> R.drawable.bg_step_dot_green
|
||||
isCompleted -> R.drawable.bg_step_dot_blue
|
||||
else -> R.drawable.bg_step_dot_gray
|
||||
}
|
||||
)
|
||||
|
||||
// 左侧连线
|
||||
holder.lineLeft.visibility = if (isFirst) View.INVISIBLE else View.VISIBLE
|
||||
holder.lineLeft.setBackgroundColor(
|
||||
if (isCompleted) 0xFF1C8CF5.toInt() else 0xFFCCCCCC.toInt()
|
||||
)
|
||||
|
||||
// 右侧连线
|
||||
holder.lineRight.visibility = if (isLast) View.INVISIBLE else View.VISIBLE
|
||||
holder.lineRight.setBackgroundColor(
|
||||
if (isCompleted && position < currentIndex) 0xFF1C8CF5.toInt() else 0xFFCCCCCC.toInt()
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = steps.size
|
||||
|
||||
class StepViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val tvStepName: TextView = view.findViewById(R.id.tv_step_name)
|
||||
val dotView: View = view.findViewById(R.id.view_dot)
|
||||
val lineLeft: View = view.findViewById(R.id.view_line_left)
|
||||
val lineRight: View = view.findViewById(R.id.view_line_right)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.lukouguoji.aerologic.page.log.detail
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.aerologic.R
|
||||
import com.lukouguoji.module_base.bean.StatusLogBean
|
||||
|
||||
class LogDetailTimelineAdapter : RecyclerView.Adapter<LogDetailTimelineAdapter.TimelineViewHolder>() {
|
||||
|
||||
private var items: List<StatusLogBean> = emptyList()
|
||||
|
||||
fun setData(list: List<StatusLogBean>) {
|
||||
items = list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TimelineViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.item_log_timeline, parent, false)
|
||||
return TimelineViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: TimelineViewHolder, position: Int) {
|
||||
val item = items[position]
|
||||
val isFirst = position == 0
|
||||
val isLast = position == items.size - 1
|
||||
|
||||
holder.tvContent.text = item.content
|
||||
holder.tvTime.text = item.opDate
|
||||
|
||||
// 最后一项(当前步骤)用绿色圆点
|
||||
holder.dotView.setBackgroundResource(
|
||||
if (isLast) R.drawable.bg_timeline_dot_green
|
||||
else R.drawable.bg_timeline_dot_gray
|
||||
)
|
||||
|
||||
// 第一项不显示顶部连线
|
||||
holder.lineTop.visibility = if (isFirst) View.INVISIBLE else View.VISIBLE
|
||||
|
||||
// 最后一项不显示底部连线
|
||||
holder.lineBottom.visibility = if (isLast) View.INVISIBLE else View.VISIBLE
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = items.size
|
||||
|
||||
class TimelineViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val dotView: View = view.findViewById(R.id.view_dot)
|
||||
val lineTop: View = view.findViewById(R.id.view_line_top)
|
||||
val lineBottom: View = view.findViewById(R.id.view_line_bottom)
|
||||
val tvContent: TextView = view.findViewById(R.id.tv_content)
|
||||
val tvTime: TextView = view.findViewById(R.id.tv_time)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.lukouguoji.aerologic.page.log.detail
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.google.gson.Gson
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.LogBean
|
||||
import com.lukouguoji.module_base.bean.StatusLogBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
|
||||
class LogDetailViewModel : BaseViewModel() {
|
||||
|
||||
val waybillNo = MutableLiveData("")
|
||||
val waybillType = MutableLiveData("")
|
||||
|
||||
val statusLogList = MutableLiveData<List<StatusLogBean>>(emptyList())
|
||||
|
||||
// 流转状态步骤定义
|
||||
val allSteps = listOf(
|
||||
"预录入", "完成收运", "运抵申报", "海关放行",
|
||||
"完成组装", "完成复磅", "装载申报", "航班关闭", "理货申报"
|
||||
)
|
||||
|
||||
// 当前完成到哪一步(索引)
|
||||
val currentStepIndex = MutableLiveData(-1)
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
val json = intent.getStringExtra(Constant.Key.DATA) ?: ""
|
||||
if (json.isNotEmpty()) {
|
||||
val bean = Gson().fromJson(json, LogBean::class.java)
|
||||
waybillNo.value = bean.key
|
||||
waybillType.value = getAwbTypeName(bean.logType)
|
||||
loadStatusList(bean.key, bean.logType)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadStatusList(key: String, logType: String) {
|
||||
if (key.isEmpty()) {
|
||||
loadMockData()
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api.getLogStatusList(
|
||||
mapOf(
|
||||
"key" to key,
|
||||
"awbType" to logType
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val list = it.data ?: emptyList()
|
||||
if (list.isNotEmpty()) {
|
||||
statusLogList.value = list
|
||||
val lastStatus = list.last().content
|
||||
val index = allSteps.indexOfFirst { step ->
|
||||
lastStatus.contains(step)
|
||||
}
|
||||
currentStepIndex.value = if (index >= 0) index else list.size - 1
|
||||
} else {
|
||||
loadMockData()
|
||||
}
|
||||
}
|
||||
onFailed = { _, _ ->
|
||||
loadMockData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadMockData() {
|
||||
// Mock 数据:模拟到"装载申报"步骤
|
||||
currentStepIndex.value = 6 // "装载申报" 在 allSteps 中的索引
|
||||
|
||||
statusLogList.value = listOf(
|
||||
StatusLogBean(content = "托书录入", opDate = "2017-04-01 12:00:00"),
|
||||
StatusLogBean(content = "完成收运", opDate = "2017-04-01 12:00:00"),
|
||||
StatusLogBean(content = "完成组装", opDate = "2017-04-01 12:00:00"),
|
||||
StatusLogBean(content = "已复磅", opDate = "2017-04-01 12:00:00"),
|
||||
StatusLogBean(content = "海关已放行", opDate = "2017-04-01 12:00:00"),
|
||||
StatusLogBean(content = "装载申报", opDate = "2017-04-01 12:00:00")
|
||||
)
|
||||
}
|
||||
|
||||
private fun getAwbTypeName(logType: String): String {
|
||||
return when (logType) {
|
||||
"CI" -> "国内进港"
|
||||
"CO" -> "国内出港"
|
||||
"II" -> "国际进港"
|
||||
"IO" -> "国际出港"
|
||||
else -> logType
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.lukouguoji.aerologic.page.log.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.aerologic.R
|
||||
import com.lukouguoji.aerologic.databinding.ActivityLogQueryBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_LOG_QUERY)
|
||||
class LogQueryActivity : BaseBindingActivity<ActivityLogQueryBinding, LogQueryViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_log_query
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<LogQueryViewModel> {
|
||||
return LogQueryViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("日志查询")
|
||||
binding.viewModel = viewModel
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, LogQueryActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.lukouguoji.aerologic.page.log.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.aerologic.databinding.ItemLogQueryBinding
|
||||
import com.lukouguoji.aerologic.page.log.detail.LogDetailActivity
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.LogBean
|
||||
|
||||
class LogQueryViewHolder(view: View) : BaseViewHolder<LogBean, ItemLogQueryBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)
|
||||
binding.bean = bean
|
||||
itemView.setOnClickListener {
|
||||
bean?.let { LogDetailActivity.start(itemView.context, it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.lukouguoji.aerologic.page.log.list
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.aerologic.R
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.LogBean
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import dev.utils.common.DateUtils
|
||||
|
||||
class LogQueryViewModel : BasePageViewModel() {
|
||||
|
||||
val startDate = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val endDate = MutableLiveData("")
|
||||
|
||||
val keyWord = MutableLiveData("")
|
||||
val operatorId = MutableLiveData("")
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_log_query
|
||||
val itemViewHolder = LogQueryViewHolder::class.java
|
||||
|
||||
fun searchClick() {
|
||||
refresh()
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getLogList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"startTime" to startDate.value,
|
||||
"endTime" to endDate.value,
|
||||
"key" to keyWord.value,
|
||||
"opId" to operatorId.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.lukouguoji.aerologic.page.gnj.query.list.GnjQueryListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.stash.list.GnjStashListActivity
|
||||
import com.lukouguoji.aerologic.page.gnj.unload.list.GnjUnloadListActivity
|
||||
import com.lukouguoji.aerologic.page.log.list.LogListActivity
|
||||
import com.lukouguoji.aerologic.page.log.list.LogQueryActivity
|
||||
import com.lukouguoji.aerologic.page.message.list.MessageListActivity
|
||||
import com.lukouguoji.aerologic.page.telegram.list.TelegramListActivity
|
||||
import com.lukouguoji.aerologic.page.test.PrintActivity
|
||||
@@ -550,7 +551,7 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
// 日志查询
|
||||
Constant.AuthName.ComprehensiveLog -> {
|
||||
LogListActivity.start(requireContext())
|
||||
LogQueryActivity.start(requireContext())
|
||||
}
|
||||
// ULD管理
|
||||
Constant.AuthName.ComprehensiveUld -> {
|
||||
|
||||
Reference in New Issue
Block a user