解决菜品配比终端接口食堂id、字段类型等变化导致的问题
This commit is contained in:
@@ -122,6 +122,9 @@ class DishSamplingActivity : BaseActivity() {
|
||||
onLeftClick = { dismiss() }
|
||||
onRightClick = {
|
||||
dismiss()
|
||||
if (pageFrom == HOME) {
|
||||
startActivity<SamplingListActivity>()
|
||||
}
|
||||
finish()
|
||||
}
|
||||
onDismiss = { hideStatusBar() }
|
||||
@@ -180,7 +183,7 @@ class DishSamplingActivity : BaseActivity() {
|
||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||
Log.d(TAG, "addViewClickListener: address=$address,state=$state,weight=$weight")
|
||||
if (address == 2) {
|
||||
tempDishEntity?.useWeight = weight
|
||||
tempDishEntity?.useWeight = weight.toDouble()
|
||||
binding.tvDishPartWeight.text = "${weight}"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.shuwei.dish.match.R
|
||||
import com.shuwei.dish.match.adapter.FoodRecordAdapter
|
||||
import com.shuwei.dish.match.base.BaseActivity
|
||||
import com.shuwei.dish.match.base.BaseApp
|
||||
import com.shuwei.dish.match.databinding.ActivityFoodSearchBinding
|
||||
import com.shuwei.dish.match.databinding.LayoutEmptyViewBinding
|
||||
|
||||
@@ -138,7 +139,7 @@ class FoodSearchActivity : BaseActivity() {
|
||||
"foodName" to input.trim(),
|
||||
"pageNo" to "$pageNo",
|
||||
"pageSize" to "$pageSize",
|
||||
"canteenId" to "0"
|
||||
"canteenId" to BaseApp.canteenId
|
||||
)
|
||||
val sb = StringBuilder(UrlConfig.QUERY_FOOD_LIST).apply {
|
||||
append("?")
|
||||
|
||||
@@ -100,7 +100,7 @@ class PrepareCookActivity : BaseActivity() {
|
||||
}
|
||||
Log.d(TAG, "addViewClickListener->useRealWeight=$weight")
|
||||
clickItem.run {
|
||||
useWeight = weight
|
||||
useWeight = weight.toDouble()
|
||||
isSetFinished = true
|
||||
dishPartAdapter.notifyItemChanged(clickIndex)
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class PrepareCookActivity : BaseActivity() {
|
||||
allEdible = it.allEdible
|
||||
goodsName = it.goodsName
|
||||
materialType = it.materialType
|
||||
useWeight = it.useWeight ?: 0
|
||||
useWeight = it.useWeight ?: 0.toDouble()
|
||||
goodsOrRelationCode = it.goodsOrRelationCode
|
||||
})
|
||||
}
|
||||
@@ -217,7 +217,7 @@ class PrepareCookActivity : BaseActivity() {
|
||||
//筛选出主材和辅材
|
||||
val tempDate = voList.filter { it.materialType == 1 || it.materialType == 2 }
|
||||
.apply {
|
||||
forEach { it.useWeight = 0 }
|
||||
forEach { it.useWeight = 0.toDouble() }
|
||||
}
|
||||
list.clear()
|
||||
list.addAll(tempDate)
|
||||
@@ -287,7 +287,7 @@ class PrepareCookActivity : BaseActivity() {
|
||||
saveDataRemindDialog()
|
||||
return
|
||||
}
|
||||
val filterResult = list.firstOrNull { (it.useWeight ?: 0) > 0 }
|
||||
val filterResult = list.firstOrNull { (it.useWeight ?: 0.toDouble()) > 0.toDouble() }
|
||||
if (filterResult != null) {
|
||||
//说明有称重的数据
|
||||
saveDataRemindDialog()
|
||||
|
||||
@@ -209,7 +209,7 @@ class SamplingListActivity : BaseActivity() {
|
||||
// "foodName" to input,
|
||||
"pageNo" to "$pageNo",
|
||||
"pageSize" to "$pageSize",
|
||||
"canteenId" to "0"
|
||||
"canteenId" to BaseApp.canteenId
|
||||
)
|
||||
val sb = StringBuilder(UrlConfig.SAMPLING_LIST).apply {
|
||||
append("?")
|
||||
|
||||
@@ -58,7 +58,7 @@ class SubmitDishActivity : BaseActivity() {
|
||||
foodName = it.foodName
|
||||
cookMode = it.cookMode
|
||||
}
|
||||
canteenId = 0
|
||||
canteenId = BaseApp.canteenId
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class SubmitDishActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
private val seasoningArray by lazy {
|
||||
SparseArray<Int>()
|
||||
SparseArray<Double>()
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ class SubmitDishActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
binding.btnSubmit.clickWithDebounce {
|
||||
if (cookFoodEntity.foodWeight <= 0) {
|
||||
if (cookFoodEntity.foodWeight <= 0.toDouble()) {
|
||||
toast("未识别到菜品熟重")
|
||||
return@clickWithDebounce
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class SubmitDishActivity : BaseActivity() {
|
||||
private fun addWeightListener() {
|
||||
WeightUtil.addWeightListener(getWeight = { address, state, weight ->
|
||||
if (address == 1) {
|
||||
cookFoodEntity.foodWeight = weight
|
||||
cookFoodEntity.foodWeight = weight.toDouble()
|
||||
binding.tvTotalWeight.text = "${weight / 1000f}"
|
||||
}
|
||||
// if (state != SensorScale.STATE_STABLE) {
|
||||
@@ -196,7 +196,7 @@ class SubmitDishActivity : BaseActivity() {
|
||||
// TAG,
|
||||
// "addViewListener: state=$state,address=$address,总共使用重量:$realUseWeight"
|
||||
// )
|
||||
seasoningArray.put(address, realUseWeight)
|
||||
seasoningArray.put(address, realUseWeight.toDouble())
|
||||
|
||||
refreshSeasoningWeight()
|
||||
})
|
||||
@@ -209,7 +209,7 @@ class SubmitDishActivity : BaseActivity() {
|
||||
adapter.list.let { items ->
|
||||
weightRelateArray.forEach { key, value ->
|
||||
items[key].useWeight =
|
||||
(seasoningArray.get(value) ?: 0) + getCookingSeasoning(value)
|
||||
(seasoningArray.get(value) ?: 0.toDouble()) + getCookingSeasoning(value)
|
||||
}
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
@@ -218,10 +218,10 @@ class SubmitDishActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCookingSeasoning(address: Int): Int {
|
||||
if (isCooking.not()) return 0
|
||||
if (seasoningList.isEmpty()) return 0
|
||||
val weight = seasoningList[weightRelateArray2.get(address)].useWeight ?: 0
|
||||
private fun getCookingSeasoning(address: Int): Double {
|
||||
if (isCooking.not()) return 0.toDouble()
|
||||
if (seasoningList.isEmpty()) return 0.toDouble()
|
||||
val weight = seasoningList[weightRelateArray2.get(address)].useWeight ?: 0.toDouble()
|
||||
//Log.i(TAG, "getCookingSeasoning: weight[${address}]=$weight,seasoningList=${seasoningList.toJsonString()}")
|
||||
return weight
|
||||
}
|
||||
@@ -263,6 +263,10 @@ class SubmitDishActivity : BaseActivity() {
|
||||
toast("未获取到调料信息")
|
||||
return
|
||||
}
|
||||
if (realSeasoningData.isNotEmpty()&&realSeasoningData[0].goodsId.isNullOrBlank()) {
|
||||
toast("还未设置调料信息,请去设置页面操作")
|
||||
return
|
||||
}
|
||||
showLoading()
|
||||
//只有制作和采样列表页面才能进入设置页面,提交页面无法进行设置,不存在调料数据被修改的问题
|
||||
val seasoningJson = realSeasoningData.toJsonString()
|
||||
@@ -303,16 +307,20 @@ class SubmitDishActivity : BaseActivity() {
|
||||
toast("未获取到调料信息")
|
||||
return
|
||||
}
|
||||
if (realSeasoningData.isNotEmpty()&&realSeasoningData[0].goodsId.isNullOrBlank()) {
|
||||
toast("还未设置调料信息,请去设置页面操作")
|
||||
return
|
||||
}
|
||||
showLoading()
|
||||
//只有制作和采样列表页面才能进入设置页面,提交页面无法进行设置,不存在调料数据被修改的问题
|
||||
val seasoningJson = realSeasoningData.toJsonString()
|
||||
val typeToken = object : TypeToken<List<CookFoodGoodsEntity>>() {}
|
||||
val tempSeasoningList = seasoningJson.toType(typeToken = typeToken)
|
||||
tempSeasoningList.forEach { entity ->
|
||||
val realWeight = entity.useWeight ?: 0
|
||||
val realWeight = entity.useWeight ?: 0.toDouble()
|
||||
val filterData = goodsList?.firstOrNull { it.goodsId == entity.goodsId }
|
||||
//确保重量大于0,且无重复数据
|
||||
if (realWeight > 0 && filterData == null) {
|
||||
if (realWeight > 0.toDouble() && filterData == null) {
|
||||
goodsList?.add(entity)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.shuwei.dish.match.adapter.DishShowAdapter
|
||||
import com.shuwei.dish.match.base.BaseApp
|
||||
import com.shuwei.dish.match.databinding.FragmentDishListBinding
|
||||
import com.shuwei.dish.match.databinding.LayoutEmptyViewBinding
|
||||
|
||||
@@ -141,7 +142,7 @@ class DishListFragment : Fragment() {
|
||||
"dinnerType" to activity.dinnerType,
|
||||
"pageNo" to "$pageNo",
|
||||
"pageSize" to "$pageSize",
|
||||
"canteenId" to "0"
|
||||
"canteenId" to BaseApp.canteenId
|
||||
)
|
||||
val sb = StringBuilder(UrlConfig.QUERY_FOOD_LIST).apply {
|
||||
append("?")
|
||||
|
||||
Reference in New Issue
Block a user