Author SHA1 Message Date
mazengfei 23149aa131 隐藏cvImageBg 2026-06-01 09:54:26 +08:00
mazengfei 1092a7c43d 接口报错显示具体信息 2026-05-25 10:33:33 +08:00
mazengfei 0c0aba2aeb 接口报错显示具体信息 2026-05-20 14:21:03 +08:00
mazengfei e81df4f55c 优化 2026-05-13 09:55:11 +08:00
lvmeng 07e0a1996f 入库单数据提交入库新增采购单号字段purCode 2026-05-11 18:20:35 +08:00
lvmeng 79f58a36e3 fix(activity): 修复拿走物品后识别弹窗未自动关闭的问题
- 将关闭阈值从 weight < 10 调整为 weight < 20,覆盖轻微零点漂移
- 将 size == 1 判断改为 none { isShowing && it != goodsRecognizeDialog },避免 DialogManager 中存在幽灵条目时导致关闭逻辑失效
- GoodsStoreDialog:无论 funcType 值,均拍照上传图片以增加样本数据
- BaseViewModel:recognizeGoodsList 增加异常捕获,异常时回调空列表
2026-05-09 15:44:05 +08:00
6 changed files with 91 additions and 69 deletions
@@ -78,6 +78,7 @@ abstract class GoodsListActivity : BaseActivity() {
private const val TAG = "GoodsListActivity" private const val TAG = "GoodsListActivity"
public const val ID = "id" public const val ID = "id"
public const val SUPPLIER_ID = "supplierId" public const val SUPPLIER_ID = "supplierId"
public const val PUR_CODE = "purCode"
public const val IS_RECEIPT_PAGE = "isReceiptPage" public const val IS_RECEIPT_PAGE = "isReceiptPage"
// public const val IS_NEW_RECEIPT = "isNewReceipt" // public const val IS_NEW_RECEIPT = "isNewReceipt"
@@ -91,6 +92,7 @@ abstract class GoodsListActivity : BaseActivity() {
// var isNewReceipt: Boolean = false // var isNewReceipt: Boolean = false
var id: String = "" var id: String = ""
var supplierId: String = "" var supplierId: String = ""
var purCode: String = ""
lateinit var binding: ActivityGoodsListBinding lateinit var binding: ActivityGoodsListBinding
val receiptViewModel: ReceiptViewModel by viewModels() val receiptViewModel: ReceiptViewModel by viewModels()
val userViewModel: UserViewModel by viewModels() val userViewModel: UserViewModel by viewModels()
@@ -116,6 +118,7 @@ abstract class GoodsListActivity : BaseActivity() {
//isNewReceipt = intent.getBooleanExtra(IS_NEW_RECEIPT, false) //isNewReceipt = intent.getBooleanExtra(IS_NEW_RECEIPT, false)
id = intent.getStringExtra(ID) ?: "" id = intent.getStringExtra(ID) ?: ""
supplierId = intent.getStringExtra(SUPPLIER_ID) ?: "" supplierId = intent.getStringExtra(SUPPLIER_ID) ?: ""
purCode = intent.getStringExtra(PUR_CODE) ?: ""
replaceIncludeContent() replaceIncludeContent()
initRecyclerView() initRecyclerView()
@@ -210,13 +213,13 @@ abstract class GoodsListActivity : BaseActivity() {
binding.tvTotalWeight.text = "重量:${weight}" binding.tvTotalWeight.text = "重量:${weight}"
} }
if (weight < 200) { if (weight < 200) {
if (weight < 10) { if (weight < 20) {
// val clazzName = DialogManager.getDialogList() // val clazzName = DialogManager.getDialogList()
// .map { it.javaClass.simpleName } // .map { it.javaClass.simpleName }
// .joinToString(",") // .joinToString(",")
// Timber.tag(TAG).d(clazzName) // Timber.tag(TAG).d(clazzName)
if (DialogManager.getDialogList().size == 1 && // 无其他弹窗正在显示时(过滤幽灵条目),自动关闭识别弹窗
DialogManager.contains("GoodsRecognizeDialog") && if (DialogManager.getDialogList().none { it.isShowing && it != goodsRecognizeDialog } &&
goodsRecognizeDialog?.isShowing == true goodsRecognizeDialog?.isShowing == true
) { ) {
goodsRecognizeDialog?.dismiss() goodsRecognizeDialog?.dismiss()
@@ -253,8 +256,9 @@ abstract class GoodsListActivity : BaseActivity() {
searchFood(uri) searchFood(uri)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
Loading.dismiss()
}
} }
}.start()
} }
private val delayHandler by lazy { private val delayHandler by lazy {
@@ -395,7 +399,11 @@ abstract class GoodsListActivity : BaseActivity() {
// readBitmap(it) // readBitmap(it)
// } // }
// } // }
ImageUtil.uriToBitmap(this, uri)?.let { bitmap -> val bitmap = ImageUtil.uriToBitmap(this, uri)
if (bitmap == null) {
Loading.dismiss()
return
}
val newBmp = BitmapCropper.cropCenter( val newBmp = BitmapCropper.cropCenter(
original = bitmap, original = bitmap,
targetWidth = 1000, targetHeight = 1300, targetWidth = 1000, targetHeight = 1300,
@@ -409,7 +417,6 @@ abstract class GoodsListActivity : BaseActivity() {
bitmap.recycle() bitmap.recycle()
} }
} }
}
private fun recognizeGoodsList(foodList: List<IdNameScore>) { private fun recognizeGoodsList(foodList: List<IdNameScore>) {
receiptViewModel.recognizeGoodsList( receiptViewModel.recognizeGoodsList(
@@ -643,11 +650,12 @@ abstract class GoodsListActivity : BaseActivity() {
val uploadInfo = UploadInfo( val uploadInfo = UploadInfo(
id = id, id = id,
supplierId = supplierId, supplierId = supplierId,
purCode = purCode,
receiveGoodsInfos = goodsList receiveGoodsInfos = goodsList
) )
logInfo("receiptSubmit确认收货提交数据:${uploadInfo.toJsonString()}") logInfo("receiptSubmit确认收货提交数据:${uploadInfo.toJsonString()}")
showWaitingDialog2("加载中") showWaitingDialog2("加载中")
receiptViewModel.confirmReceipt(uploadInfo) { success -> receiptViewModel.confirmReceipt(uploadInfo) { success, msg ->
hideWaitingDialog() hideWaitingDialog()
if (success) { if (success) {
userViewModel.deleteKey(localGoodsKey) userViewModel.deleteKey(localGoodsKey)
@@ -656,7 +664,7 @@ abstract class GoodsListActivity : BaseActivity() {
finish() finish()
}, 200) }, 200)
} else { } else {
toast("确认收货失败") toast("确认收货失败$msg")
} }
} }
} }
@@ -686,7 +694,7 @@ abstract class GoodsListActivity : BaseActivity() {
} }
logInfo("selfProcurementSubmit自采入库提交数据:${submitData.toJsonString()}") logInfo("selfProcurementSubmit自采入库提交数据:${submitData.toJsonString()}")
showWaitingDialog2("加载中") showWaitingDialog2("加载中")
receiptViewModel.addToWarehouse(submitData) { success -> receiptViewModel.addToWarehouse(submitData) { success, msg ->
hideWaitingDialog() hideWaitingDialog()
if (success) { if (success) {
toast("提交入库成功") toast("提交入库成功")
@@ -695,7 +703,7 @@ abstract class GoodsListActivity : BaseActivity() {
finish() finish()
}, 200) }, 200)
} else { } else {
toast("提交入库失败") toast("提交入库失败$msg")
} }
} }
} }
@@ -41,6 +41,7 @@ class PurchaseOrderActivity : BaseActivity() {
startActivity<ReceiptActivity> { startActivity<ReceiptActivity> {
putExtra(GoodsListActivity.ID, item.id) putExtra(GoodsListActivity.ID, item.id)
putExtra(GoodsListActivity.SUPPLIER_ID, item.supplierId) putExtra(GoodsListActivity.SUPPLIER_ID, item.supplierId)
putExtra(GoodsListActivity.PUR_CODE, item.purCode)
putExtra(GoodsListActivity.IS_RECEIPT_PAGE, true) putExtra(GoodsListActivity.IS_RECEIPT_PAGE, true)
//putExtra(GoodsListActivity.IS_NEW_RECEIPT, false) //putExtra(GoodsListActivity.IS_NEW_RECEIPT, false)
} }
@@ -357,7 +357,8 @@ class GoodsStoreDialog(
context.toast("入库金额不能为0") context.toast("入库金额不能为0")
return return
} }
if (funcType == 1) { // if (funcType == 1) {
//无论是否识别到物品,都上传图片增加样本数据
activity?.let { Loading.show(it) } activity?.let { Loading.show(it) }
cameraUtils.takePhoto { uri -> cameraUtils.takePhoto { uri ->
//imageUri = uri //imageUri = uri
@@ -375,9 +376,9 @@ class GoodsStoreDialog(
confirm(unitName, count, price, totalPrice) confirm(unitName, count, price, totalPrice)
}, 500) }, 500)
} }
} else { // } else {
confirm(unitName, count, price, totalPrice) // confirm(unitName, count, price, totalPrice)
} // }
} }
private fun confirm(unitName: String, count: Double, price: Double, totalPrice: Double?) { private fun confirm(unitName: String, count: Double, price: Double, totalPrice: Double?) {
@@ -423,7 +424,7 @@ class GoodsStoreDialog(
override fun show() { override fun show() {
super.show() super.show()
if (funcType == 1) { // if (funcType == 1) {
takePhotoBinding?.let { takePhotoBinding?.let {
cameraUtils.setPreviewController(previewView) cameraUtils.setPreviewController(previewView)
cameraUtils.bind() cameraUtils.bind()
@@ -433,7 +434,7 @@ class GoodsStoreDialog(
}, 1000) }, 1000)
} }
} }
} // }
binding.root.postDelayed({ binding.root.postDelayed({
SensorScaleUtils.startScale() SensorScaleUtils.startScale()
}, 2600) }, 2600)
@@ -454,7 +455,7 @@ class GoodsStoreDialog(
private var imagePreviewBinding: LayoutImagePreviewBinding? = null private var imagePreviewBinding: LayoutImagePreviewBinding? = null
private fun addChildToContainer() { private fun addChildToContainer() {
val inflater = LayoutInflater.from(context) val inflater = LayoutInflater.from(context)
if (funcType == 1) { // if (funcType == 1) {
//预览及拍照 //预览及拍照
takePhotoBinding = LayoutTakePhotoBinding.inflate(inflater, binding.flContainer, true) takePhotoBinding = LayoutTakePhotoBinding.inflate(inflater, binding.flContainer, true)
activity?.unBindCamera() activity?.unBindCamera()
@@ -474,8 +475,7 @@ class GoodsStoreDialog(
// cameraUtils.takePhoto(takePhotoCallback) // cameraUtils.takePhoto(takePhotoCallback)
// } // }
} }
return if(funcType != 1){
}
//只显示原始图片 //只显示原始图片
imagePreviewBinding = LayoutImagePreviewBinding.inflate(inflater, binding.flContainer) imagePreviewBinding = LayoutImagePreviewBinding.inflate(inflater, binding.flContainer)
imagePreviewBinding?.imageView?.load(goods.relativeUrl) { imagePreviewBinding?.imageView?.load(goods.relativeUrl) {
@@ -490,6 +490,7 @@ class GoodsStoreDialog(
} }
} }
} }
}
private var imageFile: File? = null private var imageFile: File? = null
@@ -18,6 +18,10 @@ data class UploadInfo(
* 供应商id * 供应商id
*/ */
var supplierId: String? = null, var supplierId: String? = null,
/**
* 采购单号
*/
var purCode: String? = null,
/** /**
* *
* 物品信息 【全部收货使用】 * 物品信息 【全部收货使用】
@@ -212,7 +212,11 @@ abstract class BaseViewModel(
callback: (List<SearchGoodsInfo.Record>) -> Unit callback: (List<SearchGoodsInfo.Record>) -> Unit
) { ) {
launch { launch {
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) return@launch try {
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) {
callback(listOf())
return@launch
}
val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList
val response = repository.recognizeGoodsList(paramList) val response = repository.recognizeGoodsList(paramList)
val list = if (parseResponse(response)) response.data ?: listOf() else listOf() val list = if (parseResponse(response)) response.data ?: listOf() else listOf()
@@ -223,6 +227,10 @@ abstract class BaseViewModel(
} }
} }
callback(list) callback(list)
} catch (e: Exception) {
Timber.e(e)
callback(listOf())
}
} }
} }
@@ -323,17 +323,17 @@ class ReceiptViewModel @Inject constructor(
// } // }
// } // }
fun confirmReceipt(uploadInfo: UploadInfo, callback: (Boolean) -> Unit) { fun confirmReceipt(uploadInfo: UploadInfo, callback: (Boolean, String) -> Unit) {
launchWithLoading { launchWithLoading {
val resp = repository.confirmReceipt(uploadInfo) val resp = repository.confirmReceipt(uploadInfo)
callback(resp.data == true) callback(resp.isSuccess(), resp.msg?:"")
} }
} }
fun addToWarehouse(list: List<PurchaseWarehouseParam>, callback: (Boolean) -> Unit) { fun addToWarehouse(list: List<PurchaseWarehouseParam>, callback: (Boolean, String) -> Unit) {
launchWithLoading { launchWithLoading {
val resp = repository.selfPurchaseWarehousing(list) val resp = repository.selfPurchaseWarehousing(list)
callback(resp.data == true) callback(resp.isSuccess(), resp.msg?:"")
} }
} }