Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23149aa131 | ||
|
|
1092a7c43d | ||
|
|
0c0aba2aeb | ||
|
|
e81df4f55c | ||
|
|
07e0a1996f | ||
|
|
79f58a36e3 |
@@ -78,6 +78,7 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
private const val TAG = "GoodsListActivity"
|
||||
public const val ID = "id"
|
||||
public const val SUPPLIER_ID = "supplierId"
|
||||
public const val PUR_CODE = "purCode"
|
||||
|
||||
public const val IS_RECEIPT_PAGE = "isReceiptPage"
|
||||
// public const val IS_NEW_RECEIPT = "isNewReceipt"
|
||||
@@ -91,6 +92,7 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
// var isNewReceipt: Boolean = false
|
||||
var id: String = ""
|
||||
var supplierId: String = ""
|
||||
var purCode: String = ""
|
||||
lateinit var binding: ActivityGoodsListBinding
|
||||
val receiptViewModel: ReceiptViewModel by viewModels()
|
||||
val userViewModel: UserViewModel by viewModels()
|
||||
@@ -116,6 +118,7 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
//isNewReceipt = intent.getBooleanExtra(IS_NEW_RECEIPT, false)
|
||||
id = intent.getStringExtra(ID) ?: ""
|
||||
supplierId = intent.getStringExtra(SUPPLIER_ID) ?: ""
|
||||
purCode = intent.getStringExtra(PUR_CODE) ?: ""
|
||||
|
||||
replaceIncludeContent()
|
||||
initRecyclerView()
|
||||
@@ -210,13 +213,13 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
binding.tvTotalWeight.text = "重量:${weight}克"
|
||||
}
|
||||
if (weight < 200) {
|
||||
if (weight < 10) {
|
||||
if (weight < 20) {
|
||||
// val clazzName = DialogManager.getDialogList()
|
||||
// .map { it.javaClass.simpleName }
|
||||
// .joinToString(",")
|
||||
// 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?.dismiss()
|
||||
@@ -253,8 +256,9 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
searchFood(uri)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Loading.dismiss()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
|
||||
private val delayHandler by lazy {
|
||||
@@ -395,19 +399,22 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
// readBitmap(it)
|
||||
// }
|
||||
// }
|
||||
ImageUtil.uriToBitmap(this, uri)?.let { bitmap ->
|
||||
val newBmp = BitmapCropper.cropCenter(
|
||||
original = bitmap,
|
||||
targetWidth = 1000, targetHeight = 1300,
|
||||
offsetX = 30, offsetY = 100
|
||||
)
|
||||
readBitmap(newBmp)
|
||||
if (newBmp.isRecycled.not()) {
|
||||
newBmp.recycle()
|
||||
}
|
||||
if (bitmap.isRecycled.not()) {
|
||||
bitmap.recycle()
|
||||
}
|
||||
val bitmap = ImageUtil.uriToBitmap(this, uri)
|
||||
if (bitmap == null) {
|
||||
Loading.dismiss()
|
||||
return
|
||||
}
|
||||
val newBmp = BitmapCropper.cropCenter(
|
||||
original = bitmap,
|
||||
targetWidth = 1000, targetHeight = 1300,
|
||||
offsetX = 30, offsetY = 100
|
||||
)
|
||||
readBitmap(newBmp)
|
||||
if (newBmp.isRecycled.not()) {
|
||||
newBmp.recycle()
|
||||
}
|
||||
if (bitmap.isRecycled.not()) {
|
||||
bitmap.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,11 +650,12 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
val uploadInfo = UploadInfo(
|
||||
id = id,
|
||||
supplierId = supplierId,
|
||||
purCode = purCode,
|
||||
receiveGoodsInfos = goodsList
|
||||
)
|
||||
logInfo("receiptSubmit确认收货提交数据:${uploadInfo.toJsonString()}")
|
||||
showWaitingDialog2("加载中")
|
||||
receiptViewModel.confirmReceipt(uploadInfo) { success ->
|
||||
receiptViewModel.confirmReceipt(uploadInfo) { success, msg ->
|
||||
hideWaitingDialog()
|
||||
if (success) {
|
||||
userViewModel.deleteKey(localGoodsKey)
|
||||
@@ -656,7 +664,7 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
finish()
|
||||
}, 200)
|
||||
} else {
|
||||
toast("确认收货失败")
|
||||
toast("确认收货失败:$msg")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -686,7 +694,7 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
}
|
||||
logInfo("selfProcurementSubmit自采入库提交数据:${submitData.toJsonString()}")
|
||||
showWaitingDialog2("加载中")
|
||||
receiptViewModel.addToWarehouse(submitData) { success ->
|
||||
receiptViewModel.addToWarehouse(submitData) { success, msg ->
|
||||
hideWaitingDialog()
|
||||
if (success) {
|
||||
toast("提交入库成功")
|
||||
@@ -695,7 +703,7 @@ abstract class GoodsListActivity : BaseActivity() {
|
||||
finish()
|
||||
}, 200)
|
||||
} else {
|
||||
toast("提交入库失败")
|
||||
toast("提交入库失败:$msg")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class PurchaseOrderActivity : BaseActivity() {
|
||||
startActivity<ReceiptActivity> {
|
||||
putExtra(GoodsListActivity.ID, item.id)
|
||||
putExtra(GoodsListActivity.SUPPLIER_ID, item.supplierId)
|
||||
putExtra(GoodsListActivity.PUR_CODE, item.purCode)
|
||||
putExtra(GoodsListActivity.IS_RECEIPT_PAGE, true)
|
||||
//putExtra(GoodsListActivity.IS_NEW_RECEIPT, false)
|
||||
}
|
||||
|
||||
@@ -357,27 +357,28 @@ class GoodsStoreDialog(
|
||||
context.toast("入库金额不能为0")
|
||||
return
|
||||
}
|
||||
if (funcType == 1) {
|
||||
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)
|
||||
// if (funcType == 1) {
|
||||
//无论是否识别到物品,都上传图片增加样本数据
|
||||
activity?.let { Loading.show(it) }
|
||||
cameraUtils.takePhoto { uri ->
|
||||
//imageUri = uri
|
||||
collectGoodsVector(uri) {
|
||||
activity?.uploadImage(goods.id!!, goods.goodsName!!, imageFile)
|
||||
}
|
||||
cameraUtils.addFailCallback {
|
||||
binding.root.postDelayed({
|
||||
Loading.dismiss()
|
||||
confirm(unitName, count, price, totalPrice)
|
||||
}, 500)
|
||||
}
|
||||
} else {
|
||||
confirm(unitName, count, price, totalPrice)
|
||||
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?) {
|
||||
@@ -423,7 +424,7 @@ class GoodsStoreDialog(
|
||||
|
||||
override fun show() {
|
||||
super.show()
|
||||
if (funcType == 1) {
|
||||
// if (funcType == 1) {
|
||||
takePhotoBinding?.let {
|
||||
cameraUtils.setPreviewController(previewView)
|
||||
cameraUtils.bind()
|
||||
@@ -433,7 +434,7 @@ class GoodsStoreDialog(
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
binding.root.postDelayed({
|
||||
SensorScaleUtils.startScale()
|
||||
}, 2600)
|
||||
@@ -454,7 +455,7 @@ class GoodsStoreDialog(
|
||||
private var imagePreviewBinding: LayoutImagePreviewBinding? = null
|
||||
private fun addChildToContainer() {
|
||||
val inflater = LayoutInflater.from(context)
|
||||
if (funcType == 1) {
|
||||
// if (funcType == 1) {
|
||||
//预览及拍照
|
||||
takePhotoBinding = LayoutTakePhotoBinding.inflate(inflater, binding.flContainer, true)
|
||||
activity?.unBindCamera()
|
||||
@@ -474,19 +475,19 @@ class GoodsStoreDialog(
|
||||
// cameraUtils.takePhoto(takePhotoCallback)
|
||||
// }
|
||||
}
|
||||
return
|
||||
}
|
||||
//只显示原始图片
|
||||
imagePreviewBinding = LayoutImagePreviewBinding.inflate(inflater, binding.flContainer)
|
||||
imagePreviewBinding?.imageView?.load(goods.relativeUrl) {
|
||||
transformations(RoundedCornersTransformation(radius = 10.dp.toFloat()))
|
||||
}
|
||||
binding.flContainer.let {
|
||||
it.setBackgroundResource(R.drawable.bg_white_radius10_stroke2)
|
||||
it.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||
width = 488.dp
|
||||
height = 356.dp
|
||||
bottomMargin = 35.dp
|
||||
if(funcType != 1){
|
||||
//只显示原始图片
|
||||
imagePreviewBinding = LayoutImagePreviewBinding.inflate(inflater, binding.flContainer)
|
||||
imagePreviewBinding?.imageView?.load(goods.relativeUrl) {
|
||||
transformations(RoundedCornersTransformation(radius = 10.dp.toFloat()))
|
||||
}
|
||||
binding.flContainer.let {
|
||||
it.setBackgroundResource(R.drawable.bg_white_radius10_stroke2)
|
||||
it.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||
width = 488.dp
|
||||
height = 356.dp
|
||||
bottomMargin = 35.dp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ data class UploadInfo(
|
||||
* 供应商id
|
||||
*/
|
||||
var supplierId: String? = null,
|
||||
/**
|
||||
* 采购单号
|
||||
*/
|
||||
var purCode: String? = null,
|
||||
/**
|
||||
*
|
||||
* 物品信息 【全部收货使用】
|
||||
|
||||
@@ -212,17 +212,25 @@ abstract class BaseViewModel(
|
||||
callback: (List<SearchGoodsInfo.Record>) -> Unit
|
||||
) {
|
||||
launch {
|
||||
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) return@launch
|
||||
val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList
|
||||
val response = repository.recognizeGoodsList(paramList)
|
||||
val list = if (parseResponse(response)) response.data ?: listOf() else listOf()
|
||||
if (scoreList.isNullOrEmpty().not()) {
|
||||
list.forEach { record ->
|
||||
val item = scoreList.firstOrNull { it.name == record.goodsName }
|
||||
record.score = ((1 - (item?.score ?: 0.0)) * 10000).roundToInt()
|
||||
try {
|
||||
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) {
|
||||
callback(listOf())
|
||||
return@launch
|
||||
}
|
||||
val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList
|
||||
val response = repository.recognizeGoodsList(paramList)
|
||||
val list = if (parseResponse(response)) response.data ?: listOf() else listOf()
|
||||
if (scoreList.isNullOrEmpty().not()) {
|
||||
list.forEach { record ->
|
||||
val item = scoreList.firstOrNull { it.name == record.goodsName }
|
||||
record.score = ((1 - (item?.score ?: 0.0)) * 10000).roundToInt()
|
||||
}
|
||||
}
|
||||
callback(list)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
callback(listOf())
|
||||
}
|
||||
callback(list)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -323,17 +323,17 @@ class ReceiptViewModel @Inject constructor(
|
||||
// }
|
||||
// }
|
||||
|
||||
fun confirmReceipt(uploadInfo: UploadInfo, callback: (Boolean) -> Unit) {
|
||||
fun confirmReceipt(uploadInfo: UploadInfo, callback: (Boolean, String) -> Unit) {
|
||||
launchWithLoading {
|
||||
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 {
|
||||
val resp = repository.selfPurchaseWarehousing(list)
|
||||
callback(resp.data == true)
|
||||
callback(resp.isSuccess(), resp.msg?:"")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user