搜索菜品入库改为自动拍照保存,取消手动拍照操作;增加向量数据库相关日志
This commit is contained in:
@@ -32,9 +32,13 @@ class GoodsSearchDialog(
|
||||
override fun initView() {
|
||||
activity = getReceiptActivity()
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
binding.ivGoodsSearch.setOnClickListener { searchGoods() }
|
||||
binding.ivGoodsSearch.setOnClickListener {
|
||||
pageNo = 1
|
||||
searchGoods()
|
||||
}
|
||||
binding.etInputGoods.let { v ->
|
||||
v.addOnActionSearchListener {
|
||||
pageNo = 1
|
||||
searchGoods()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,10 +284,10 @@ class GoodsStoreDialog(
|
||||
}
|
||||
|
||||
private fun confirmInputData() {
|
||||
if (funcType == 1 && imageUri == null) {
|
||||
context.toast("请采集图片")
|
||||
return
|
||||
}
|
||||
// if (funcType == 1 && imageUri == null) {
|
||||
// context.toast("请采集图片")
|
||||
// return
|
||||
// }
|
||||
val unitName = binding.tvProcurementUnit.text.trim().toString()
|
||||
if (unitName.isBlank()) {
|
||||
context.toast("请选择入库单位")
|
||||
@@ -328,11 +328,31 @@ class GoodsStoreDialog(
|
||||
return
|
||||
}
|
||||
if (funcType == 1) {
|
||||
collectGoodsVector()
|
||||
activity?.let { Loading.show(it) }
|
||||
cameraUtils.takePhoto { uri ->
|
||||
//imageUri = uri
|
||||
collectGoodsVector(uri) {
|
||||
activity?.uploadImage(goods.id!!, goods.goodsName!!, imageFile)
|
||||
}
|
||||
binding.root.postDelayed({
|
||||
Loading.dismiss()
|
||||
confirm(unitName, count, price, totalPrice)
|
||||
}, 500)
|
||||
}
|
||||
cameraUtils.addFailCallback {
|
||||
binding.root.postDelayed({
|
||||
Loading.dismiss()
|
||||
confirm(unitName, count, price, totalPrice)
|
||||
}, 500)
|
||||
}
|
||||
} else {
|
||||
confirm(unitName, count, price, totalPrice)
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirm(unitName:String, count:Double, price:Double, totalPrice:Double?) {
|
||||
val id = binding.tvProcurementUnit.tag.toString()
|
||||
val unitVo = goods.unitVoList!!.first { it.businessUnitId == id }
|
||||
activity?.uploadImage(goods.id!!, goods.goodsName!!, imageFile)
|
||||
confirmBlock(
|
||||
GoodsInfo(
|
||||
goodId = goods.id,
|
||||
@@ -389,15 +409,15 @@ class GoodsStoreDialog(
|
||||
}, 2600)
|
||||
}
|
||||
|
||||
private var imageUri: Uri? = null
|
||||
private val takePhotoCallback: (Uri) -> Unit = { uri ->
|
||||
takePhotoBinding?.let {
|
||||
imageUri = uri
|
||||
it.flCameraPreview.gone()
|
||||
it.cvImageBg.visible()
|
||||
it.ivGoodsImage.load(uri)
|
||||
}
|
||||
}
|
||||
// private var imageUri: Uri? = null
|
||||
// private val takePhotoCallback: (Uri) -> Unit = { uri ->
|
||||
// takePhotoBinding?.let {
|
||||
// imageUri = uri
|
||||
// it.flCameraPreview.gone()
|
||||
// it.cvImageBg.visible()
|
||||
// it.ivGoodsImage.load(uri)
|
||||
// }
|
||||
// }
|
||||
|
||||
private var previewView: PreviewView? = null
|
||||
private var takePhotoBinding: LayoutTakePhotoBinding? = null
|
||||
@@ -416,13 +436,13 @@ class GoodsStoreDialog(
|
||||
previewView = it.previewView
|
||||
it.flCameraPreview.visible()
|
||||
it.cvImageBg.gone()
|
||||
it.btnStartPreview.setOnClickListener { _ ->
|
||||
it.cvImageBg.gone()
|
||||
it.flCameraPreview.visible()
|
||||
}
|
||||
it.btnTakePhoto.setOnClickListener { _ ->
|
||||
cameraUtils.takePhoto(takePhotoCallback)
|
||||
}
|
||||
// it.btnStartPreview.setOnClickListener { _ ->
|
||||
// it.cvImageBg.gone()
|
||||
// it.flCameraPreview.visible()
|
||||
// }
|
||||
// it.btnTakePhoto.setOnClickListener { _ ->
|
||||
// cameraUtils.takePhoto(takePhotoCallback)
|
||||
// }
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -444,9 +464,9 @@ class GoodsStoreDialog(
|
||||
private var imageFile: File? = null
|
||||
|
||||
// private var box: Box<Food>? = null
|
||||
private fun collectGoodsVector() {
|
||||
private fun collectGoodsVector(imageUri:Uri, block: ()-> Unit = {}) {
|
||||
try {
|
||||
ImageUtil.uriToBitmap(context, imageUri!!)?.let { bitmap ->
|
||||
ImageUtil.uriToBitmap(context, imageUri)?.let { bitmap ->
|
||||
val cropBitmap = BitmapCropper.cropCenter(
|
||||
original = bitmap,
|
||||
targetWidth = 1000,
|
||||
@@ -477,18 +497,7 @@ class GoodsStoreDialog(
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
// Thread {
|
||||
// try {
|
||||
// val imageVector = FoodModule.bitmap2FloatArray(bitmap, true)
|
||||
// if (imageVector != null) {
|
||||
// ObjectBox.boxStore.runInTx {
|
||||
// box?.put(Food(name = goods.goodsName + goods.goodsCode, foodIdx = 0, foodVector = imageVector))
|
||||
// }
|
||||
// }
|
||||
// } catch (e: Exception) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }.start()
|
||||
block()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
Reference in New Issue
Block a user