From 5fc51e7af338d8ad09532420fe5cf18f2fa0beb3 Mon Sep 17 00:00:00 2001 From: YANGJIANKUAN Date: Mon, 8 Dec 2025 14:14:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=87=BA=E6=B8=AF=E8=AE=A1=E9=87=8D=20?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E8=AE=A1=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lukouguoji/module_base/http/net/Api.kt | 17 ++++ .../ui/weight/data/layout/DataLayoutKtx.kt | 1 - .../lukouguoji/module_base/util/DictUtils.kt | 31 +++++-- .../viewModel/GjcWeighingStartViewModel.kt | 88 +++++++++++-------- .../layout/activity_gjc_weighing_start.xml | 33 +++---- 5 files changed, 109 insertions(+), 61 deletions(-) diff --git a/module_base/src/main/java/com/lukouguoji/module_base/http/net/Api.kt b/module_base/src/main/java/com/lukouguoji/module_base/http/net/Api.kt index fa8aba3..55a6755 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/http/net/Api.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/http/net/Api.kt @@ -642,6 +642,23 @@ interface Api { @POST("IntExpCheckIn/pageQueryTotal") suspend fun getGjcWeighingStatistics(@Body data: RequestBody): BaseResultBean + /** + * 国际出港待计重-开始计重-根据wbId查询详情 + * 接口路径: /IntExpCheckIn/queryWbById + * @param maWbId 运单主键ID + */ + @POST("IntExpCheckIn/queryWbById") + suspend fun getIntExpCheckInWbById(@Query("maWbId") maWbId: Long): BaseResultBean + + /** + * 国际出港待计重-开始计重-根据运单id查询实时计重数据 + * 接口路径: /IntExpCheckIn/queryRecordByWh + * @param maWbId 运单主键ID + * @return 返回GjcCheckInRecord,包含实时的pc、weight、volume + */ + @POST("IntExpCheckIn/queryRecordByWh") + suspend fun getIntExpRealTimeRecord(@Query("maWbId") maWbId: Long): BaseResultBean + /** * 国际出港计重记录-分页搜索 * 接口路径: /IntExpCheckIn/checked/pageQuery diff --git a/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/DataLayoutKtx.kt b/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/DataLayoutKtx.kt index 9754fe1..7bec010 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/DataLayoutKtx.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/ui/weight/data/layout/DataLayoutKtx.kt @@ -205,7 +205,6 @@ fun setSearchLayoutDataValueNew( layout.value = value } } - @BindingAdapter( "enable", requireAll = false diff --git a/module_base/src/main/java/com/lukouguoji/module_base/util/DictUtils.kt b/module_base/src/main/java/com/lukouguoji/module_base/util/DictUtils.kt index 4e0fb19..ffb54f4 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/util/DictUtils.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/util/DictUtils.kt @@ -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) -> 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) } } diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingStartViewModel.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingStartViewModel.kt index 31b3f4d..10f414d 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingStartViewModel.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/GjcWeighingStartViewModel.kt @@ -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) } diff --git a/module_gjc/src/main/res/layout/activity_gjc_weighing_start.xml b/module_gjc/src/main/res/layout/activity_gjc_weighing_start.xml index 392c8da..43a37bf 100644 --- a/module_gjc/src/main/res/layout/activity_gjc_weighing_start.xml +++ b/module_gjc/src/main/res/layout/activity_gjc_weighing_start.xml @@ -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"> @@ -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" />