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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user