feat: 出港计重 开始计重
This commit is contained in:
@@ -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,30 +144,28 @@ class GjcWeighingStartViewModel : BaseViewModel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载运单数据
|
||||
* 加载运单详情数据
|
||||
*/
|
||||
private fun loadWeighingData() {
|
||||
val params = mapOf(
|
||||
"maWbId" to maWbId
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({ NetApply.api.getIntExpCheckInWbById(maWbId) }) {
|
||||
onSuccess = { result ->
|
||||
maWbBean.value = result.data ?: GjcMaWb()
|
||||
// 更新航班日期字符串
|
||||
flightDate.value = result.data?.fdate?.formatDate() ?: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 ""
|
||||
}
|
||||
/**
|
||||
* 加载实时计重数据 (仅调用一次)
|
||||
*/
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,11 +174,12 @@ class GjcWeighingStartViewModel : BaseViewModel() {
|
||||
* 航班日期点击
|
||||
*/
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user