feat: opt 板箱过磅 add
This commit is contained in:
@@ -15,6 +15,7 @@ import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.getActivity
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
@@ -40,6 +41,9 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
// val diBangModel = DiBangWeightModel()
|
||||
val channel = MutableLiveData("") // 通道号(用于控制地磅key)
|
||||
|
||||
// 地磅称重输入(独立字段,单向同步到总重)
|
||||
val diBangWeight = MutableLiveData("0")
|
||||
|
||||
// 计算字段显示
|
||||
val totalWeight = MutableLiveData("0") // 总重(红色)
|
||||
val netWeight = MutableLiveData("0") // 装机重(蓝色)
|
||||
@@ -70,6 +74,22 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
// diBangModel.key = it ?: ""
|
||||
// }
|
||||
|
||||
// 监听地磅称重输入,单向同步到总重
|
||||
diBangWeight.observe(activity as LifecycleOwner) { weight ->
|
||||
val w = weight?.toDoubleOrNull() ?: 0.0
|
||||
totalWeight.value = w.toString()
|
||||
dataBean.value = dataBean.value?.apply { totalWeight = w }
|
||||
// 实时计算装机重和货重
|
||||
calculateWeights()
|
||||
}
|
||||
|
||||
// 监听总重变化,实时计算装机重和货重
|
||||
totalWeight.observe(activity as LifecycleOwner) {
|
||||
val w = it?.toDoubleOrNull() ?: 0.0
|
||||
dataBean.value = dataBean.value?.apply { totalWeight = w }
|
||||
calculateWeights()
|
||||
}
|
||||
|
||||
// 加载下拉列表数据
|
||||
loadPassagewayList()
|
||||
loadPiCloseList()
|
||||
@@ -82,8 +102,12 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
* 加载通道号列表
|
||||
*/
|
||||
private fun loadPassagewayList() {
|
||||
DictUtils.getChannelList {
|
||||
passagewayList.value = it
|
||||
launchCollect({
|
||||
NetApply.api.getDictList("GJPASSAGEWAY")
|
||||
}) {
|
||||
onSuccess = {
|
||||
passagewayList.value = (it.data ?: emptyList()).map { b -> b.toKeyValue() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +175,7 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
dataBean.value = GjcUldUseBean().apply {
|
||||
fdate = Date().formatDate()
|
||||
}
|
||||
diBangWeight.value = "0"
|
||||
totalWeight.value = "0"
|
||||
netWeight.value = "0"
|
||||
cargoWeight.value = "0"
|
||||
@@ -217,9 +242,53 @@ class GjcBoxWeighingAddViewModel : BaseViewModel() {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.ULD -> {
|
||||
dataBean.value = dataBean.value?.apply { uld = content }
|
||||
// 查询ULD信息,获取ULD自重
|
||||
queryUldInfo(content)
|
||||
}
|
||||
Constant.RequestCode.CAR -> {
|
||||
dataBean.value = dataBean.value?.apply { carId = content }
|
||||
// 查询架子车信息,获取架子车自重
|
||||
queryFlatcarInfo(content)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询ULD信息
|
||||
*/
|
||||
private fun queryUldInfo(uldNo: String) {
|
||||
launchCollect({ NetApply.api.getUldDetails(uldNo) }) {
|
||||
onSuccess = { result ->
|
||||
val uldBean = result.data
|
||||
if (uldBean != null) {
|
||||
val weight = uldBean.uldWeight.toDoubleOrNull() ?: 0.0
|
||||
dataBean.value = dataBean.value?.apply {
|
||||
uldWeight = weight
|
||||
maxWeight = uldBean.maxWeight.toDoubleOrNull() ?: 0.0
|
||||
maxVolume = uldBean.maxVolume.toDoubleOrNull() ?: 0.0
|
||||
}
|
||||
// 触发重量计算
|
||||
calculateWeights()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询架子车信息
|
||||
*/
|
||||
private fun queryFlatcarInfo(carId: String) {
|
||||
launchCollect({ NetApply.api.getFlatcarInfo(carId) }) {
|
||||
onSuccess = { result ->
|
||||
val flatcarBean = result.data
|
||||
if (flatcarBean != null) {
|
||||
val weight = flatcarBean.carWeight.toDoubleOrNull() ?: 0.0
|
||||
dataBean.value = dataBean.value?.apply {
|
||||
carWeight = weight
|
||||
}
|
||||
// 触发重量计算
|
||||
calculateWeights()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,13 +138,18 @@
|
||||
android:background="@drawable/bg_shouyun_dbzl"
|
||||
android:minHeight="60dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWeight"
|
||||
<EditText
|
||||
android:id="@+id/etWeight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="@{viewModel.totalWeight}"
|
||||
android:background="@null"
|
||||
android:gravity="center"
|
||||
android:hint="0"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@={viewModel.diBangWeight}"
|
||||
android:textColor="@color/text_red"
|
||||
android:textColorHint="@color/text_red"
|
||||
android:textSize="45sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="1655" />
|
||||
@@ -152,9 +157,9 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/tvWeight"
|
||||
android:layout_alignBaseline="@id/etWeight"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/tvWeight"
|
||||
android:layout_toEndOf="@id/etWeight"
|
||||
android:text="kg"
|
||||
android:textColor="@color/text_red"
|
||||
android:textSize="24sp"
|
||||
@@ -195,11 +200,10 @@
|
||||
android:layout_weight="1" />
|
||||
|
||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||
enable="@{false}"
|
||||
title='@{"总重"}'
|
||||
titleLength="@{5}"
|
||||
type="@{DataLayoutType.INPUT}"
|
||||
value='@{viewModel.totalWeight}'
|
||||
value='@={viewModel.totalWeight}'
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
|
||||
Reference in New Issue
Block a user