feat: 开始计重新增托盘信息并自动计算运抵重量

国际出港开始计重页面新增托盘数量、托盘自重输入框(自重默认18可编辑),
运抵重量自动按“地磅称重 -(托盘数量 × 托盘自重)”计算;
分托计重与完成计重提交均携带 trayNumber、trayTotalWeight;
“托盘车号”“托盘车自重”标签改为“平板车”“平板车自重”。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-02 13:11:17 +08:00
parent b57a3cd133
commit ea298ec322
3 changed files with 88 additions and 11 deletions

View File

@@ -57,6 +57,8 @@ data class GjcMaWb(
var arriveWeight: Double? = null, // 运抵重量 var arriveWeight: Double? = null, // 运抵重量
var arriveVolume: Double? = null, // 运抵体积 var arriveVolume: Double? = null, // 运抵体积
var arriveFlag: String? = null, // 运抵状态0正常运抵1提前运抵 var arriveFlag: String? = null, // 运抵状态0正常运抵1提前运抵
var trayNumber: Int? = null, // 托盘数量
var trayTotalWeight: Double? = null, // 托盘重量(托盘数量 × 托盘自重)
// ==================== 特码与收货人 ==================== // ==================== 特码与收货人 ====================
var spCode: String? = null, // 特码 var spCode: String? = null, // 特码

View File

@@ -66,6 +66,10 @@ class GjcWeighingStartViewModel : BaseViewModel() {
val pageRemark = MutableLiveData("") // 备注 val pageRemark = MutableLiveData("") // 备注
// 托盘信息(运抵重量 = 地磅称重 - 托盘数量 × 托盘自重)
val trayNumber = MutableLiveData("") // 托盘数量
val trayWeight = MutableLiveData("18") // 托盘自重默认18可编辑
// 下拉选择数据源 // 下拉选择数据源
val channelList = MutableLiveData<List<KeyValue>>() // 通道号列表 val channelList = MutableLiveData<List<KeyValue>>() // 通道号列表
val agentList = MutableLiveData<List<KeyValue>>() // 代理人列表 val agentList = MutableLiveData<List<KeyValue>>() // 代理人列表
@@ -82,11 +86,10 @@ class GjcWeighingStartViewModel : BaseViewModel() {
// 获取传入的运单ID // 获取传入的运单ID
maWbId = intent.getLongExtra(Constant.Key.MAWB_ID, 0) maWbId = intent.getLongExtra(Constant.Key.MAWB_ID, 0)
// 监听地磅称重输入,单向同步到运抵重量 // 监听地磅称重、托盘数量、托盘自重输入,自动计算运抵重量
diBangWeight.observe(activity as LifecycleOwner) { weight -> diBangWeight.observe(activity as LifecycleOwner) { recalculateArriveWeight() }
// 同步到运抵重量(单向,不做反向同步) trayNumber.observe(activity as LifecycleOwner) { recalculateArriveWeight() }
arriveWeight.value = weight ?: "0" trayWeight.observe(activity as LifecycleOwner) { recalculateArriveWeight() }
}
// 监听运抵重量变化,自动计算运抵体积 // 监听运抵重量变化,自动计算运抵体积
arriveWeight.observe(activity as LifecycleOwner) { weightStr -> arriveWeight.observe(activity as LifecycleOwner) { weightStr ->
@@ -113,6 +116,32 @@ class GjcWeighingStartViewModel : BaseViewModel() {
} }
} }
/**
* 自动计算运抵重量:地磅称重 - (托盘数量 × 托盘自重)
*/
private fun recalculateArriveWeight() {
val gross = diBangWeight.value?.toDoubleOrNull() ?: 0.0
val trayTotal = getTrayTotalWeight()
val net = gross - trayTotal
arriveWeight.value = if (net > 0) formatWeight(net) else "0"
}
/**
* 托盘总重量 = 托盘数量 × 托盘自重
*/
private fun getTrayTotalWeight(): Double {
val num = trayNumber.value?.toIntOrNull() ?: 0
val weight = trayWeight.value?.toDoubleOrNull() ?: 0.0
return num * weight
}
/**
* 重量格式化最多保留两位小数去掉多余的0
*/
private fun formatWeight(value: Double): String {
return String.format("%.2f", value).trimEnd('0').trimEnd('.')
}
/** /**
* 加载通道号列表 (国际出港专用) * 加载通道号列表 (国际出港专用)
*/ */
@@ -391,6 +420,10 @@ class GjcWeighingStartViewModel : BaseViewModel() {
passageWay = this@GjcWeighingStartViewModel.channelList.value?.firstOrNull{ it.value == channel.value }?.key ?: "" passageWay = this@GjcWeighingStartViewModel.channelList.value?.firstOrNull{ it.value == channel.value }?.key ?: ""
passageWayId = this@GjcWeighingStartViewModel.channel.value passageWayId = this@GjcWeighingStartViewModel.channel.value
// 托盘信息
trayNumber = this@GjcWeighingStartViewModel.trayNumber.value?.toIntOrNull()
trayTotalWeight = getTrayTotalWeight()
remark = pageRemark.value remark = pageRemark.value
} }
@@ -417,6 +450,8 @@ class GjcWeighingStartViewModel : BaseViewModel() {
arrivePc.value = "" arrivePc.value = ""
arriveWeight.value = "" arriveWeight.value = ""
arriveVolume.value = "" arriveVolume.value = ""
trayNumber.value = ""
trayWeight.value = "18"
pageRemark.value = "" pageRemark.value = ""
@@ -499,6 +534,8 @@ class GjcWeighingStartViewModel : BaseViewModel() {
"goodsCn" to bean.goodsCn, "goodsCn" to bean.goodsCn,
"businessType" to bean.businessType, "businessType" to bean.businessType,
"carId" to bean.carId, "carId" to bean.carId,
"trayNumber" to trayNumber.value?.toIntOrNull(),
"trayTotalWeight" to getTrayTotalWeight(),
"remark" to pageRemark.value, "remark" to pageRemark.value,
"checkIn" to "1", // 收运状态设置为已收运 "checkIn" to "1", // 收运状态设置为已收运
"passageWayId" to channel.value, // 通道号参数 "passageWayId" to channel.value, // 通道号参数

View File

@@ -313,7 +313,45 @@
</LinearLayout> </LinearLayout>
<!-- 第6行运抵件数、运抵重量、运抵体积 --> <!-- 第6行托盘数量、托盘自重(用于自动计算运抵重量) -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
hint='@{"请输入托盘数量"}'
inputType="@{android.text.InputType.TYPE_CLASS_NUMBER}"
title='@{"托盘数量"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.trayNumber}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
hint='@{"请输入托盘自重"}'
inputType="@{android.text.InputType.TYPE_CLASS_NUMBER | android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL}"
title='@{"托盘自重"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
value='@={viewModel.trayWeight}'
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_weight="1" />
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_weight="1" />
</LinearLayout>
<!-- 第7行运抵件数、运抵重量、运抵体积 -->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -356,7 +394,7 @@
</LinearLayout> </LinearLayout>
<!--7行:托盘车号、托盘车自重、业务类型 --> <!--8行:平板车、平板车自重、业务类型 -->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -364,9 +402,9 @@
android:orientation="horizontal"> android:orientation="horizontal">
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
hint='@{"请输入托盘车号"}' hint='@{"请输入平板车号"}'
setRefreshCallBack="@{viewModel::onCarIdInputComplete}" setRefreshCallBack="@{viewModel::onCarIdInputComplete}"
title='@{"托盘车号"}' title='@{"平 板 车"}'
titleLength="@{5}" titleLength="@{5}"
type="@{DataLayoutType.INPUT}" type="@{DataLayoutType.INPUT}"
value='@={viewModel.maWbBean.carId}' value='@={viewModel.maWbBean.carId}'
@@ -376,7 +414,7 @@
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
enable="@{false}" enable="@{false}"
title='@{"托盘车自重"}' title='@{"平板车自重"}'
titleLength="@{5}" titleLength="@{5}"
type="@{DataLayoutType.INPUT}" type="@{DataLayoutType.INPUT}"
value='@{viewModel.carWeight}' value='@{viewModel.carWeight}'
@@ -399,7 +437,7 @@
</LinearLayout> </LinearLayout>
<!--8行:备注 --> <!--9行:备注 -->
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew <com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
hint='@{"请输入备注"}' hint='@{"请输入备注"}'
inputHeight="@{80}" inputHeight="@{80}"