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"
|
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,19 +399,22 @@ abstract class GoodsListActivity : BaseActivity() {
|
|||||||
// readBitmap(it)
|
// readBitmap(it)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
ImageUtil.uriToBitmap(this, uri)?.let { bitmap ->
|
val bitmap = ImageUtil.uriToBitmap(this, uri)
|
||||||
val newBmp = BitmapCropper.cropCenter(
|
if (bitmap == null) {
|
||||||
original = bitmap,
|
Loading.dismiss()
|
||||||
targetWidth = 1000, targetHeight = 1300,
|
return
|
||||||
offsetX = 30, offsetY = 100
|
}
|
||||||
)
|
val newBmp = BitmapCropper.cropCenter(
|
||||||
readBitmap(newBmp)
|
original = bitmap,
|
||||||
if (newBmp.isRecycled.not()) {
|
targetWidth = 1000, targetHeight = 1300,
|
||||||
newBmp.recycle()
|
offsetX = 30, offsetY = 100
|
||||||
}
|
)
|
||||||
if (bitmap.isRecycled.not()) {
|
readBitmap(newBmp)
|
||||||
bitmap.recycle()
|
if (newBmp.isRecycled.not()) {
|
||||||
}
|
newBmp.recycle()
|
||||||
|
}
|
||||||
|
if (bitmap.isRecycled.not()) {
|
||||||
|
bitmap.recycle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,27 +357,28 @@ class GoodsStoreDialog(
|
|||||||
context.toast("入库金额不能为0")
|
context.toast("入库金额不能为0")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (funcType == 1) {
|
// if (funcType == 1) {
|
||||||
activity?.let { Loading.show(it) }
|
//无论是否识别到物品,都上传图片增加样本数据
|
||||||
cameraUtils.takePhoto { uri ->
|
activity?.let { Loading.show(it) }
|
||||||
//imageUri = uri
|
cameraUtils.takePhoto { uri ->
|
||||||
collectGoodsVector(uri) {
|
//imageUri = uri
|
||||||
activity?.uploadImage(goods.id!!, goods.goodsName!!, imageFile)
|
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({
|
||||||
binding.root.postDelayed({
|
Loading.dismiss()
|
||||||
Loading.dismiss()
|
confirm(unitName, count, price, totalPrice)
|
||||||
confirm(unitName, count, price, totalPrice)
|
}, 500)
|
||||||
}, 500)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
confirm(unitName, count, price, totalPrice)
|
|
||||||
}
|
}
|
||||||
|
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?) {
|
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,19 +475,19 @@ 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) {
|
transformations(RoundedCornersTransformation(radius = 10.dp.toFloat()))
|
||||||
transformations(RoundedCornersTransformation(radius = 10.dp.toFloat()))
|
}
|
||||||
}
|
binding.flContainer.let {
|
||||||
binding.flContainer.let {
|
it.setBackgroundResource(R.drawable.bg_white_radius10_stroke2)
|
||||||
it.setBackgroundResource(R.drawable.bg_white_radius10_stroke2)
|
it.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||||
it.updateLayoutParams<LinearLayout.LayoutParams> {
|
width = 488.dp
|
||||||
width = 488.dp
|
height = 356.dp
|
||||||
height = 356.dp
|
bottomMargin = 35.dp
|
||||||
bottomMargin = 35.dp
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ data class UploadInfo(
|
|||||||
* 供应商id
|
* 供应商id
|
||||||
*/
|
*/
|
||||||
var supplierId: String? = null,
|
var supplierId: String? = null,
|
||||||
|
/**
|
||||||
|
* 采购单号
|
||||||
|
*/
|
||||||
|
var purCode: String? = null,
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 物品信息 【全部收货使用】
|
* 物品信息 【全部收货使用】
|
||||||
|
|||||||
@@ -212,17 +212,25 @@ abstract class BaseViewModel(
|
|||||||
callback: (List<SearchGoodsInfo.Record>) -> Unit
|
callback: (List<SearchGoodsInfo.Record>) -> Unit
|
||||||
) {
|
) {
|
||||||
launch {
|
launch {
|
||||||
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) return@launch
|
try {
|
||||||
val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList
|
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) {
|
||||||
val response = repository.recognizeGoodsList(paramList)
|
callback(listOf())
|
||||||
val list = if (parseResponse(response)) response.data ?: listOf() else listOf()
|
return@launch
|
||||||
if (scoreList.isNullOrEmpty().not()) {
|
|
||||||
list.forEach { record ->
|
|
||||||
val item = scoreList.firstOrNull { it.name == record.goodsName }
|
|
||||||
record.score = ((1 - (item?.score ?: 0.0)) * 10000).roundToInt()
|
|
||||||
}
|
}
|
||||||
|
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 {
|
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?:"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user