feat: 出港组装 开始组装 卸货、装货 api
This commit is contained in:
@@ -13,6 +13,7 @@ import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
@@ -165,6 +166,7 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
flight = warehouse.flight
|
||||
fno = warehouse.fno
|
||||
fdate = warehouse.fdate
|
||||
whId = warehouse.whId // 添加运单ID
|
||||
isMarked = false
|
||||
}
|
||||
}.toMutableList()
|
||||
@@ -201,6 +203,7 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
flight = warehouse.flight
|
||||
fno = warehouse.fno
|
||||
fdate = warehouse.fdate
|
||||
whId = warehouse.whId // 添加运单ID
|
||||
isMarked = false
|
||||
}
|
||||
}.toMutableList()
|
||||
@@ -291,13 +294,122 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
||||
* 卸货按钮点击
|
||||
*/
|
||||
fun onUnloadClick() {
|
||||
showToast("卸货操作(静态页面暂不实现)")
|
||||
performAssembleOperation(isLoad = false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 装货按钮点击
|
||||
*/
|
||||
fun onLoadClick() {
|
||||
showToast("装货操作(静态页面暂不实现)")
|
||||
performAssembleOperation(isLoad = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行组装操作(卸货或装货)
|
||||
* @param isLoad true-装货,false-卸货
|
||||
*/
|
||||
private fun performAssembleOperation(isLoad: Boolean) {
|
||||
// 1. 验证必填字段
|
||||
val uldNo = uldInfo.value?.uldNo?.trim() ?: ""
|
||||
if (uldNo.isEmpty()) {
|
||||
showToast("请输入ULD编号")
|
||||
return
|
||||
}
|
||||
|
||||
val materialWeight = uldInfo.value?.materialWeight?.trim() ?: ""
|
||||
if (materialWeight.isEmpty()) {
|
||||
showToast("请输入耗材重量")
|
||||
return
|
||||
}
|
||||
|
||||
val waybillNo = waybillInfo.value?.waybillNo?.trim() ?: ""
|
||||
if (waybillNo.isEmpty()) {
|
||||
showToast("请选择运单")
|
||||
return
|
||||
}
|
||||
|
||||
val assembleCount = waybillInfo.value?.assembleCount?.trim() ?: ""
|
||||
if (assembleCount.isEmpty()) {
|
||||
showToast("请输入组装件数")
|
||||
return
|
||||
}
|
||||
|
||||
val assembleWeight = waybillInfo.value?.assembleWeight?.trim() ?: ""
|
||||
// 组装重量为非必填,不进行验证
|
||||
|
||||
val operator = waybillInfo.value?.operator?.trim() ?: ""
|
||||
if (operator.isEmpty()) {
|
||||
showToast("请选择组装人")
|
||||
return
|
||||
}
|
||||
|
||||
val loadArea = selectedPosition.value?.positionName?.trim() ?: ""
|
||||
if (loadArea.isEmpty()) {
|
||||
showToast("请选择组装位置")
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 获取选中的运单Bean
|
||||
val currentWaybillList = waybillList.value ?: return
|
||||
val selectedWaybill = currentWaybillList.firstOrNull { it.isSelected.get() }
|
||||
if (selectedWaybill == null) {
|
||||
showToast("请选择运单")
|
||||
return
|
||||
}
|
||||
|
||||
// 3. 构建useInfo(ULD信息)
|
||||
val useInfo = mapOf(
|
||||
"uld" to uldNo,
|
||||
"consumeWeight" to materialWeight.toDoubleOrNull(),
|
||||
"status" to when (uldInfo.value?.uldStatus) {
|
||||
"正常" -> "0"
|
||||
"故障" -> "1"
|
||||
else -> ""
|
||||
},
|
||||
"loadArea" to loadArea
|
||||
)
|
||||
|
||||
// 4. 构建wbInfo(运单信息)
|
||||
val wbInfo = mapOf(
|
||||
"wbNo" to selectedWaybill.waybillNo,
|
||||
"pc" to selectedWaybill.pieces.toLongOrNull(),
|
||||
"weight" to selectedWaybill.weight.toDoubleOrNull(),
|
||||
"fdate" to selectedWaybill.fdate,
|
||||
"fno" to selectedWaybill.fno,
|
||||
"whId" to selectedWaybill.whId
|
||||
)
|
||||
|
||||
// 5. 构建完整请求参数
|
||||
val params = mapOf(
|
||||
"abPc" to assembleCount.toLongOrNull(),
|
||||
"abWeight" to assembleWeight.toDoubleOrNull(),
|
||||
"consumeWeight" to materialWeight.toDoubleOrNull(),
|
||||
"ldId" to operator,
|
||||
"loadArea" to loadArea,
|
||||
"useInfo" to useInfo,
|
||||
"wbInfo" to wbInfo,
|
||||
"userId" to SharedPreferenceUtil.getString(Constant.Share.account)
|
||||
).toRequestBody()
|
||||
|
||||
// 6. 调用接口
|
||||
val operationName = if (isLoad) "装货" else "卸货"
|
||||
launchLoadingCollect({
|
||||
if (isLoad) {
|
||||
NetApply.api.assembleLoadCargo(params)
|
||||
} else {
|
||||
NetApply.api.assembleDropCargo(params)
|
||||
}
|
||||
}) {
|
||||
onSuccess = { result ->
|
||||
showToast("${operationName}成功")
|
||||
// 刷新运单列表
|
||||
loadInitialWaitingAssemble()
|
||||
// 清空运单信息
|
||||
waybillInfo.value = WaybillInfoBean()
|
||||
}
|
||||
onFailed = { code, message ->
|
||||
showToast("${operationName}失败: $message")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
<!-- 搜索框 -->
|
||||
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayoutNew
|
||||
android:id="@+id/tvWbSearch"
|
||||
hint='@{"请输入原单号"}'
|
||||
hint='@{"请输入运单号"}'
|
||||
icon="@{@drawable/img_search}"
|
||||
setOnSearchListener="@{viewModel::loadWaitingAssembleWaybills}"
|
||||
setSearchIconClickListener="@{viewModel::loadWaitingAssembleWaybills}"
|
||||
@@ -364,6 +364,7 @@
|
||||
|
||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||
enable="@{true}"
|
||||
required="@{false}"
|
||||
title='@{"组装重量:"}'
|
||||
titleLength="@{5}"
|
||||
type="@{DataLayoutType.INPUT}"
|
||||
@@ -410,7 +411,7 @@
|
||||
style="@style/tv_bottom_btn"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:background="@drawable/bg_red_radius_4"
|
||||
android:onClick="@{() -> viewModel.onLoadClick()}"
|
||||
android:text="装货"
|
||||
|
||||
Reference in New Issue
Block a user