优化提交菜品时重量累加问题、其它优化

This commit is contained in:
2025-09-16 08:49:14 +08:00
parent 3ddf9a2663
commit e269e75bc6
8 changed files with 50 additions and 34 deletions
+8 -5
View File
@@ -17,11 +17,14 @@ android {
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// ndk {
// //设置支持的SO库架构
// abiFilters.addAll(listOf("armeabi", "armeabi-v7a"))
// //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
// }
ndk {
//设置支持的SO库架构
abiFilters.addAll(listOf("armeabi-v7a"))
//, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
// 设置输出APK文件名格式
setProperty("archivesBaseName", "菜品配比终端v${versionName}")
}
signingConfigs {
create("debug_507") {
+3 -3
View File
@@ -13,7 +13,7 @@
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
"outputFile": "菜品配比终端v1.0-release.apk"
}
],
"elementType": "File",
@@ -22,14 +22,14 @@
"minApi": 28,
"maxApi": 30,
"baselineProfiles": [
"baselineProfiles/1/app-release.dm"
"baselineProfiles/1/菜品配比终端v1.0-release.dm"
]
},
{
"minApi": 31,
"maxApi": 2147483647,
"baselineProfiles": [
"baselineProfiles/0/app-release.dm"
"baselineProfiles/0/菜品配比终端v1.0-release.dm"
]
}
],
@@ -13,12 +13,12 @@ object UrlConfig {
*/
const val DEVICE_CONFIG = "${DEVICE_BASE_URL}/equipment/stEquipment/queryByEquipmentCode"
const val BASE_URL = "http://vip.shuziweidao.com/shuwei-zhct"
// const val BASE_URL = "http://vip.shuziweidao.com/shuwei-zhct"
// const val DISH_DETAIL = "$BASE_URL/scales/goodsUseList?foodId={foodId}&foodWeight={foodWeight}"
// const val DISH_LIST = "$BASE_URL/scales/getRestInfoFoods?eaId=99&type=0&foodName"
// const val BASE_URL = "http://192.168.1.207:9102"
// const val BASE_URL = "https://yyjk.shuziweidao.com/gateway"
const val BASE_URL = "https://yyjk.shuziweidao.com/gateway"
// const val DISH_LIST = "$BASE_URL/scales/getRestInfoFoods?eaId=99&type=0&foodName"
@@ -156,34 +156,18 @@ class DishSamplingActivity : BaseActivity() {
LinearLayoutManager(this@DishSamplingActivity, LinearLayoutManager.VERTICAL, false)
adapter = dishAdapter
}
binding.etInputDishType.addOnActionSearchListener {
searchDishType()
}
binding.ivDishTypeSearch.setOnClickListener {
val inputText = binding.etInputDishType.text.toString().trim()
BottomDialog(goodsType = 0, defGoodsName = inputText).show(this@DishSamplingActivity) { item ->
val filterResult = list.firstOrNull { it.goodsName == item.goodsName }
if (filterResult != null) {
toast("不允许重复添加同一食材")
return@show
}
binding.etInputDishType.setText(item.goodsName)
tempDishEntity = CookFoodGoodsEntity().apply {
goodsId = item.goodsId
goodsName = item.goodsName
relateionType = item.relateionType ?: 0
goodsOrRelationCode = item.goodsOrRelationCode
// TODO: 待定
//allEdible = item.allEdible
}
}
searchDishType()
}
binding.ivWeightClear.setOnClickListener {
WeightUtil.tareTwo(AddressUtil.ONE)
}
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
//Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
if (address == AddressUtil.ONE) {
tempDishEntity?.useWeight = weight.toDouble()
binding.tvDishPartWeight.text = "${weight}"
@@ -276,4 +260,27 @@ class DishSamplingActivity : BaseActivity() {
}
KeyboardUtil.hideKeyboard(v.context, v)
}
private fun searchDishType() {
val inputText = binding.etInputDishType.text.toString().trim()
BottomDialog(goodsType = 0, defGoodsName = inputText).show(this@DishSamplingActivity) { item ->
val filterResult = list.firstOrNull { it.goodsName == item.goodsName }
if (filterResult != null) {
toast("不允许重复添加同一食材")
return@show
}
binding.etInputDishType.setText(item.goodsName)
tempDishEntity = CookFoodGoodsEntity().apply {
goodsId = item.goodsId
goodsName = item.goodsName
relateionType = item.relateionType ?: 0
goodsOrRelationCode = item.goodsOrRelationCode
// TODO: 待定
//allEdible = item.allEdible
}
}
}
}
@@ -46,8 +46,9 @@ class InitActivity : BaseActivity() {
setHeaderBackground(isHomePage = true)
// 获取 ANDROID_ID
val androidId =
var androidId =
Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
androidId = "39a7abdd06b3c7ab"
BaseApp.deviceId = androidId
SpTool.put(SpTool.DEVICE_ID, androidId)
BaseApp.configUrl = UrlConfig.BASE_URL
@@ -77,7 +77,7 @@ class PrepareCookActivity : BaseActivity() {
WeightUtil.tareTwo(AddressUtil.ONE)
}
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
//Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
if (address == AddressUtil.ONE) {
binding.tvDishPartWeight.text = "${weight}"
}
@@ -212,7 +212,8 @@ class SubmitFoodActivity : BaseActivity() {
private fun getCookingSeasoning(address: Int): Double {
if (isCooking.not()) return 0.toDouble()
if (seasoningItems.isEmpty()) return 0.toDouble()
val weight = seasoningItems[weightRelateArray2.get(address)].useWeight ?: 0.toDouble()
// val weight = seasoningItems[weightRelateArray2.get(address)].useWeight ?: 0.toDouble()
val weight = seasoningCookingItems?.get(weightRelateArray2.get(address))?.useWeight ?: 0.toDouble()
//Log.i(TAG, "getCookingSeasoning: weight[${address}]=$weight,seasoningList=${seasoningList.toJsonString()}")
return weight
}
@@ -408,11 +409,13 @@ class SubmitFoodActivity : BaseActivity() {
}
private var seasoningItems = mutableListOf<SeasoningEntity>()
private var seasoningCookingItems: List<SeasoningEntity> ?= null
private fun loadTextCell(list: MutableList<SeasoningEntity>) {
seasoningItems.clear()
seasoningItems.addAll(list)
initConfigData()
setGridData(list)
seasoningCookingItems = seasoningItems.map { it.copy() }.toList()
}
private fun initConfigData() {
@@ -83,6 +83,8 @@
android:hint="@string/dish_search_hint2"
android:textColor="@color/black333"
android:textColorHint="@color/gray_c8"
android:imeOptions="actionSearch"
android:inputType="text"
android:textSize="28sp"
android:maxLines="1"
android:paddingEnd="6dp"