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