feat: 出港计重 开始计重

This commit is contained in:
2025-12-08 14:14:47 +08:00
parent 2be3cf5251
commit 5fc51e7af3
5 changed files with 109 additions and 61 deletions

View File

@@ -642,6 +642,23 @@ interface Api {
@POST("IntExpCheckIn/pageQueryTotal")
suspend fun getGjcWeighingStatistics(@Body data: RequestBody): BaseResultBean<GjcWeighingStatisticsBean>
/**
* 国际出港待计重-开始计重-根据wbId查询详情
* 接口路径: /IntExpCheckIn/queryWbById
* @param maWbId 运单主键ID
*/
@POST("IntExpCheckIn/queryWbById")
suspend fun getIntExpCheckInWbById(@Query("maWbId") maWbId: Long): BaseResultBean<GjcMaWb>
/**
* 国际出港待计重-开始计重-根据运单id查询实时计重数据
* 接口路径: /IntExpCheckIn/queryRecordByWh
* @param maWbId 运单主键ID
* @return 返回GjcCheckInRecord,包含实时的pc、weight、volume
*/
@POST("IntExpCheckIn/queryRecordByWh")
suspend fun getIntExpRealTimeRecord(@Query("maWbId") maWbId: Long): BaseResultBean<GjcCheckInRecord>
/**
* 国际出港计重记录-分页搜索
* 接口路径: /IntExpCheckIn/checked/pageQuery

View File

@@ -205,7 +205,6 @@ fun setSearchLayoutDataValueNew(
layout.value = value
}
}
@BindingAdapter(
"enable",
requireAll = false

View File

@@ -1,12 +1,9 @@
package com.lukouguoji.module_base.util
import androidx.lifecycle.MutableLiveData
import com.lukouguoji.module_base.bean.DictBean
import com.lukouguoji.module_base.bean.DictListBean
import com.lukouguoji.module_base.http.net.NetApply
import com.lukouguoji.module_base.ktx.launchCollect
import com.lukouguoji.module_base.ktx.toMap
import com.lukouguoji.module_base.ktx.toRequestBody
import dev.utils.app.info.KeyValue
import java.util.Collections.emptyList
@@ -179,7 +176,7 @@ object DictUtils {
) {
launchCollect({
NetApply.api
.getSpecialCodeList(flag, ieFlag,parentcode)
.getSpecialCodeList(flag, ieFlag, parentcode)
}) {
onSuccess = {
handleCallBack(it, checkedValue, addAll, callBack)
@@ -404,6 +401,22 @@ object DictUtils {
}
}
/**
* 国际出港通道号列表
*/
fun getGjcChannelList(
callBack: (List<KeyValue>) -> Unit
) {
launchCollect({
NetApply.api
.getDictList("GJCPASSAGEWAY")
}) {
onSuccess = {
callBack((it.data ?: emptyList()).map { b -> b.toKeyValue() })
}
}
}
/**
* 货物类型
@@ -510,7 +523,7 @@ object DictUtils {
.getDictList("DGRDETAIL")
}) {
onSuccess = {
callBack((it.data ?: emptyList()).map { b -> KeyValue(b.value,b.value) })
callBack((it.data ?: emptyList()).map { b -> KeyValue(b.value, b.value) })
}
}
}
@@ -629,12 +642,14 @@ object DictUtils {
NetApply.api.getUserByRoleId("6")
}) {
onSuccess = {
val jbDrivers = (it.data ?: emptyList()).map { b -> KeyValue(b.username, b.username) }
val jbDrivers =
(it.data ?: emptyList()).map { b -> KeyValue(b.username, b.username) }
launchCollect({
NetApply.api.getUserByRoleId("7")
}) {
onSuccess = {iit ->
val shDrivers = (iit.data ?: emptyList()).map { b -> KeyValue(b.username, b.username) }
onSuccess = { iit ->
val shDrivers =
(iit.data ?: emptyList()).map { b -> KeyValue(b.username, b.username) }
callBack(jbDrivers + shDrivers)
}
}

View File

@@ -7,6 +7,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.lukouguoji.module_base.base.BaseViewModel
import com.lukouguoji.module_base.bean.GjcMaWb
import com.lukouguoji.module_base.bean.GjcWeighingBean
import com.lukouguoji.module_base.common.Constant
import com.lukouguoji.module_base.common.ConstantEvent
@@ -37,8 +38,11 @@ class GjcWeighingStartViewModel : BaseViewModel() {
// 运单ID从列表页传入
var maWbId: Long = 0
// 数据Bean
val dataBean = MutableLiveData(GjcWeighingBean())
// 运单数据Bean
val maWbBean = MutableLiveData(GjcMaWb())
// 航班日期格式化为字符串用于DataBinding
val flightDate = MutableLiveData("")
// 地磅集成
val diBangModel = DiBangWeightModel()
@@ -91,24 +95,30 @@ class GjcWeighingStartViewModel : BaseViewModel() {
// 加载运单数据
if (maWbId > 0) {
loadWeighingData()
loadRealTimeRecord() // 新增: 加载实时计重数据
}
}
/**
* 加载通道号列表
* 加载通道号列表 (国际出港专用)
*/
private fun loadChannelList() {
DictUtils.getChannelList {
DictUtils.getGjcChannelList {
channelList.value = it
}
}
/**
* 加载代理人列表
* 加载代理人列表 (国际出港专用)
*/
private fun loadAgentList() {
DictUtils.getAgentList {
agentList.value = it
launchCollect({
NetApply.api.getIntExpAgentList()
}) {
onSuccess = { result ->
val list = (result.data ?: emptyList()).map { it.toKeyValue() }
agentList.value = list
}
}
}
@@ -116,8 +126,13 @@ class GjcWeighingStartViewModel : BaseViewModel() {
* 加载特码列表
*/
private fun loadSpCodeList() {
// TODO: 从字典获取特码列表
spCodeList.value = listOf()
DictUtils.getSpecialCodeList(
flag = 1, // 国际
ieFlag = "", // 空字符串
parentcode = "" // 无父级
) {
spCodeList.value = it
}
}
/**
@@ -129,43 +144,42 @@ class GjcWeighingStartViewModel : BaseViewModel() {
}
/**
* 加载运单数据
* 加载运单详情数据
*/
private fun loadWeighingData() {
val params = mapOf(
"maWbId" to maWbId
).toRequestBody()
launchCollect({
// 使用查询接口获取运单详情暂时使用列表接口传入maWbId过滤
NetApply.api.getGjcWeighingList(params)
}) {
onSuccess = {
if (it.list?.isNotEmpty() == true) {
val bean = it.list!![0]
dataBean.value = bean
// 填充可编辑字段
realTimePc.value = if (bean.pc > 0) bean.pc.toString() else ""
realTimeWeight.value = if (bean.weight > 0) bean.weight.toString() else ""
realTimeVolume.value = if (bean.volume > 0) bean.volume.toString() else ""
arrivePc.value = if (bean.arrivePc > 0) bean.arrivePc.toString() else ""
arriveWeight.value = if (bean.arriveWeight > 0) bean.arriveWeight.toString() else ""
arriveVolume.value = if (bean.arriveVolume > 0) bean.arriveVolume.toString() else ""
launchLoadingCollect({ NetApply.api.getIntExpCheckInWbById(maWbId) }) {
onSuccess = { result ->
maWbBean.value = result.data ?: GjcMaWb()
// 更新航班日期字符串
flightDate.value = result.data?.fdate?.formatDate() ?: ""
}
}
}
/**
* 加载实时计重数据 (仅调用一次)
*/
private fun loadRealTimeRecord() {
launchCollect({ NetApply.api.getIntExpRealTimeRecord(maWbId) }) {
onSuccess = { result ->
val record = result.data
realTimePc.value = (record?.pc ?: 0).toString()
realTimeWeight.value = String.format("%.2f", record?.weight ?: 0.0)
realTimeVolume.value = String.format("%.3f", record?.volume ?: 0.0)
}
}
}
/**
* 航班日期点击
*/
fun flightDateClick(view: View) {
Common.onYearMonthDay(view.context.getActivity(), dataBean.value?.fdate) { year, month, day ->
Common.onYearMonthDay(view.context.getActivity(), maWbBean.value?.fdate?.formatDate()) { year, month, day ->
val calendar = Calendar.getInstance()
calendar.set(year, month - 1, day)
val date = calendar.time.formatDate()
dataBean.value = dataBean.value?.apply { fdate = date }
val date = calendar.time
maWbBean.value = maWbBean.value?.apply { fdate = date }
flightDate.value = date.formatDate()
}
}
@@ -227,7 +241,7 @@ class GjcWeighingStartViewModel : BaseViewModel() {
* 完成计重按钮点击
*/
fun completeCheckInClick() {
val bean = dataBean.value ?: return
val bean = maWbBean.value ?: return
// 验证必填字段
if (bean.no.verifyNullOrEmpty("请输入运单号")) return
@@ -299,13 +313,13 @@ class GjcWeighingStartViewModel : BaseViewModel() {
val content = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
when (requestCode) {
Constant.RequestCode.WAYBILL -> {
dataBean.value = dataBean.value?.apply { no = content }
maWbBean.value = maWbBean.value?.apply { no = content }
}
Constant.RequestCode.FLIGHT_NO -> {
dataBean.value = dataBean.value?.apply { fno = content }
maWbBean.value = maWbBean.value?.apply { fno = content }
}
Constant.RequestCode.CAR -> {
dataBean.value = dataBean.value?.apply { carId = content }
maWbBean.value = maWbBean.value?.apply { carId = content }
// 查询托盘车自重
queryCarWeight(content)
}

View File

@@ -62,7 +62,7 @@
title='@{"运单号"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.dataBean.no}'
value='@={viewModel.maWbBean.no}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
@@ -94,7 +94,7 @@
title='@{"代 理 人"}'
titleLength="@{5}"
type="@{DataLayoutType.SPINNER}"
value='@={viewModel.dataBean.agentCode}'
value='@={viewModel.maWbBean.agentCode}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
@@ -105,7 +105,7 @@
title='@{"特 码"}'
titleLength="@{5}"
type="@{DataLayoutType.SPINNER}"
value='@={viewModel.dataBean.spCode}'
value='@={viewModel.maWbBean.spCode}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
@@ -182,7 +182,7 @@
title='@{"航班日期"}'
titleLength="@{5}"
type="@{DataLayoutType.DATE}"
value='@={viewModel.dataBean.fdate}'
value='@={viewModel.flightDate}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
@@ -192,7 +192,7 @@
title='@{"航 班 号"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.dataBean.fno}'
value='@={viewModel.maWbBean.fno}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
@@ -203,7 +203,7 @@
title='@{"航 程"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.dataBean.range}'
value='@={viewModel.maWbBean.range}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
@@ -223,7 +223,7 @@
title='@{"预配件数"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@{String.valueOf(viewModel.dataBean.pc)}'
value='@{String.valueOf(viewModel.maWbBean.pc)}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
@@ -233,7 +233,7 @@
title='@{"预配重量"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@{String.valueOf(viewModel.dataBean.weight)}'
value='@{String.valueOf(viewModel.maWbBean.weight)}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
@@ -244,7 +244,7 @@
title='@{"预配体积"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@{String.valueOf(viewModel.dataBean.volume)}'
value='@{String.valueOf(viewModel.maWbBean.volume)}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
@@ -260,32 +260,35 @@
android:orientation="horizontal">
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}"
hint='@{"请输入实时件数"}'
title='@{"实时件数"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.realTimePc}'
value='@{viewModel.realTimePc}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}"
hint='@{"请输入实时重量"}'
title='@{"实时重量"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.realTimeWeight}'
value='@{viewModel.realTimeWeight}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_weight="1" />
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}"
hint='@{"请输入实时体积"}'
title='@{"实时体积"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.realTimeVolume}'
value='@{viewModel.realTimeVolume}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
@@ -346,7 +349,7 @@
title='@{"托盘车号"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.dataBean.carId}'
value='@={viewModel.maWbBean.carId}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
@@ -368,7 +371,7 @@
title='@{"业务类型"}'
titleLength="@{5}"
type="@{DataLayoutType.SPINNER}"
value='@={viewModel.dataBean.businessType}'
value='@={viewModel.maWbBean.businessType}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
@@ -383,7 +386,7 @@
title='@{"备 注"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.dataBean.remark}'
value='@={viewModel.maWbBean.remark}'
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp" />