新接口调试
This commit is contained in:
@@ -9,7 +9,6 @@ import com.chad.library.adapter4.viewholder.QuickViewHolder
|
||||
import com.shuwei.dish.match.R
|
||||
import com.shuwei.dish.match.entity.FoodRecord
|
||||
import com.shuwei.dish.match.databinding.ListItemDishBinding
|
||||
import com.shuwei.dish.match.utils.ext.gone
|
||||
import com.shuwei.dish.match.utils.ext.visible
|
||||
import java.text.DecimalFormat
|
||||
|
||||
@@ -28,9 +27,9 @@ class SamplingAdapter(list: MutableList<FoodRecord>) :
|
||||
holder.binding.run {
|
||||
val isCooking = item!!.isCooking
|
||||
clBlock.setBackgroundResource(R.drawable.shape_white_fb_15_corners)
|
||||
val totalWeight = item!!.totalWeight ?: 0.toDouble()
|
||||
val totalWeight = item.totalWeight ?: 0.toDouble()
|
||||
tvDishName.run {
|
||||
text = item!!.foodName
|
||||
text = (item.foodName?:"").ifBlank { "--" }
|
||||
setTextColor(
|
||||
ContextCompat.getColor(
|
||||
holder.itemView.context,
|
||||
@@ -41,11 +40,16 @@ class SamplingAdapter(list: MutableList<FoodRecord>) :
|
||||
tvDishCount.visible()
|
||||
if (isCooking) {
|
||||
tvDishCount.text = "制作统计:-kg"
|
||||
tvShowState.text = "烹饪中"
|
||||
tvShowState.text = "烹饪中"
|
||||
} else {
|
||||
val useWeight = if (totalWeight > 0.toDouble()) totalWeight else (item.foodWeight ?: 0.toDouble())
|
||||
tvDishCount.text = "累计统计:${df.format(useWeight / 1000.0F)}kg(${item.count}次)"
|
||||
tvShowState.text = "${df.format((item.foodWeight ?: 0.toDouble()) / 1000.0F)}kg"
|
||||
val realTotalWeight = if (totalWeight > 0.toDouble()) totalWeight else (item.foodWeight
|
||||
?: 0.toDouble())
|
||||
val showTotalWeight =
|
||||
if (realTotalWeight == 0.toDouble()) "-" else df.format(realTotalWeight / 1000.0F)
|
||||
tvDishCount.text = "累计统计:${showTotalWeight}kg(${item.count ?: "-"}次)"
|
||||
val foodWeight = item.foodWeight ?: 0.toDouble()
|
||||
val showFoodWeight = if (foodWeight == 0.toDouble()) "-" else df.format(foodWeight / 1000.0F)
|
||||
tvShowState.text = "${showFoodWeight}kg"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ class BaseApp : Application() {
|
||||
|
||||
// const val canteenId = "1678234139391512577"
|
||||
var canteenId = "0"
|
||||
var configUrl = ""
|
||||
// var configUrl = ""
|
||||
|
||||
var token: String? = null
|
||||
var deviceId: String? = null
|
||||
// var token: String? = null
|
||||
// var deviceId: String? = null
|
||||
var appVersion: String = "1"
|
||||
@Volatile
|
||||
private var sharedPref: SharedPreferences? = null
|
||||
|
||||
@@ -138,7 +138,7 @@ class FoodSearchDialog(
|
||||
}
|
||||
|
||||
private var pageNo = 1
|
||||
private val pageSize = 120
|
||||
private val pageSize = 50
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -204,22 +204,27 @@ class FoodSearchDialog(
|
||||
"pageSize" to pageSize
|
||||
)
|
||||
if (goodsName.isNullOrBlank().not()) {
|
||||
param.put("name", goodsName!!)
|
||||
param.put("goodsName", goodsName!!)
|
||||
}
|
||||
activity?.queryGoodsList(param = param, onSuccess = {
|
||||
loadGoodsList(it)
|
||||
}, onFailure = { code, msg ->
|
||||
activity?.toast(msg)
|
||||
if (pageNo == 1) {
|
||||
binding.refreshLayout.finishRefresh(1200)
|
||||
} else {
|
||||
binding.refreshLayout.finishLoadMore(1200)
|
||||
}
|
||||
finishRefresh()
|
||||
})
|
||||
}
|
||||
|
||||
private fun finishRefresh() {
|
||||
if (pageNo == 1) {
|
||||
binding.refreshLayout.finishRefresh()
|
||||
} else {
|
||||
binding.refreshLayout.finishLoadMore()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun loadGoodsList(records: MutableList<CookFoodGoodsEntity>?) {
|
||||
finishRefresh()
|
||||
if (records.isNullOrEmpty()) {
|
||||
activity?.toast("暂未搜索到食材信息")
|
||||
return
|
||||
@@ -229,11 +234,6 @@ class FoodSearchDialog(
|
||||
}
|
||||
list.addAll(records)
|
||||
searchAdapter.notifyDataSetChanged()
|
||||
if (pageNo == 1) {
|
||||
binding.refreshLayout.finishRefresh(1200)
|
||||
} else {
|
||||
binding.refreshLayout.finishLoadMore(1200)
|
||||
}
|
||||
val isLoadMoreEnable = records.size >= pageSize
|
||||
binding.refreshLayout.setEnableLoadMore(isLoadMoreEnable)
|
||||
if (isLoadMoreEnable) {
|
||||
|
||||
@@ -167,6 +167,7 @@ class SeasoningSearchDialog(
|
||||
}
|
||||
}
|
||||
binding.refreshLayout.setEnableRefresh(false)
|
||||
binding.refreshLayout.setEnableLoadMore(false)
|
||||
binding.tvClear.setOnClickListener {
|
||||
Log.d(TAG, "show: weighAddress=$weighAddress")
|
||||
WeightUtil.tareTwo(weighAddress)
|
||||
@@ -204,7 +205,7 @@ class SeasoningSearchDialog(
|
||||
|
||||
private var currentWeight = 0.toDouble()
|
||||
private var pageNo = 1
|
||||
private val pageSize = 120
|
||||
private val pageSize = 50
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -271,7 +272,7 @@ class SeasoningSearchDialog(
|
||||
"pageSize" to pageSize
|
||||
)
|
||||
if (goodsName.isNullOrBlank().not()) {
|
||||
param.put("name", goodsName!!)
|
||||
param.put("goodsName", goodsName!!)
|
||||
}
|
||||
activity?.querySeasoningList(
|
||||
param = param,
|
||||
@@ -280,17 +281,14 @@ class SeasoningSearchDialog(
|
||||
},
|
||||
onFailure = { code, msg ->
|
||||
activity?.toast(msg)
|
||||
if (pageNo == 1) {
|
||||
binding.refreshLayout.finishRefresh(1200)
|
||||
} else {
|
||||
binding.refreshLayout.finishLoadMore(1200)
|
||||
}
|
||||
finishRefresh()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun loadGoodsList(records: MutableList<SeasoningEntity>?) {
|
||||
finishRefresh()
|
||||
if (records.isNullOrEmpty()) {
|
||||
activity?.toast("暂未搜索到调料信息")
|
||||
return
|
||||
@@ -300,11 +298,6 @@ class SeasoningSearchDialog(
|
||||
}
|
||||
list.addAll(records)
|
||||
searchAdapter.notifyDataSetChanged()
|
||||
if (pageNo == 1) {
|
||||
binding.refreshLayout.finishRefresh(1200)
|
||||
} else {
|
||||
binding.refreshLayout.finishLoadMore(1200)
|
||||
}
|
||||
val isLoadMoreEnable = records.size >= pageSize
|
||||
binding.refreshLayout.setEnableLoadMore(isLoadMoreEnable)
|
||||
if (isLoadMoreEnable) {
|
||||
@@ -312,6 +305,13 @@ class SeasoningSearchDialog(
|
||||
}
|
||||
}
|
||||
|
||||
private fun finishRefresh() {
|
||||
if (pageNo == 1) {
|
||||
binding.refreshLayout.finishRefresh()
|
||||
} else {
|
||||
binding.refreshLayout.finishLoadMore()
|
||||
}
|
||||
}
|
||||
|
||||
fun getTextSpan(weight: Double): SpannableStringBuilder {
|
||||
var topWeight = "$weight"
|
||||
|
||||
@@ -13,14 +13,6 @@ import retrofit2.http.Url
|
||||
|
||||
interface ApiService {
|
||||
|
||||
// @GET("/food/stFoodInfoMatching/list")
|
||||
// suspend fun getFoodList(
|
||||
// @Query("dinnerType") dinnerType: String,
|
||||
// @Query("canteenId") canteenId: String = BaseApp.canteenId,
|
||||
// @Query("pageNo") pageNo: Int,
|
||||
// @Query("pageSize") pageSize: Int
|
||||
// ): ApiResponse<FoodRecordBean?>
|
||||
|
||||
/**
|
||||
* 查询菜品详情
|
||||
*/
|
||||
@@ -67,8 +59,8 @@ interface ApiService {
|
||||
@Body param: MutableMap<String, Any>
|
||||
): ApiResponse<MutableList<CookFoodGoodsEntity>?>
|
||||
|
||||
/**
|
||||
* 物品信息
|
||||
/**
|
||||
* 调料信息
|
||||
*/
|
||||
@POST
|
||||
suspend fun querySeasoningList(
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
//package com.shuwei.dish.match.net
|
||||
//
|
||||
//import com.shuwei.dish.match.base.BaseApp
|
||||
//import com.shuwei.dish.match.base.BaseReq
|
||||
//import com.shuwei.dish.match.entity.FoodRecordBean
|
||||
//import com.shuwei.dish.match.http.UrlConfig
|
||||
//import retrofit2.http.Body
|
||||
//import retrofit2.http.GET
|
||||
//import retrofit2.http.POST
|
||||
//import retrofit2.http.Query
|
||||
//import retrofit2.http.Url
|
||||
//
|
||||
//interface ApiService2 {
|
||||
//
|
||||
// @GET("food/stFoodInfoMatching/list")
|
||||
// suspend fun getDishList(
|
||||
// @Query("dinnerType") dinnerType: String,
|
||||
// @Query("canteenId") canteenId: String = BaseApp.canteenId,
|
||||
// @Query("pageNo") pageNo: Int,
|
||||
// @Query("pageSize") pageSize: Int
|
||||
// ): BaseReq<FoodRecordBean?>
|
||||
//
|
||||
//// /**
|
||||
//// * device获取token
|
||||
//// */
|
||||
//// @GET("/sys/getEquipmentToken")
|
||||
//// suspend fun getDeviceToken(
|
||||
//// @Query("qrcodeId") qrcodeId: String,
|
||||
//// @Query("appVersion") appVersion: String = App.appVersion
|
||||
//// ): ApiResponse<String>
|
||||
////
|
||||
//// /**
|
||||
//// *获取配置信息
|
||||
//// */
|
||||
//// @GET("/equipment/stEquipment/queryByEquipmentCode")
|
||||
//// suspend fun getDeviceInfo(
|
||||
//// @Query("equipmentCode") equipmentCode: String,
|
||||
//// @Query("appVersion") appVersion: String = App.appVersion
|
||||
//// ): ApiResponse<DeviceConfigInfo>
|
||||
////
|
||||
//// @GET
|
||||
//// suspend fun getAccessToken(
|
||||
//// @Url url: String = UrlConfig.GET_ACCESS_TOKEN,
|
||||
//// @Query("qrcodeId") qrcodeId: String
|
||||
//// ): ApiResponse<String?>
|
||||
////
|
||||
//// @GET
|
||||
//// suspend fun getShelfList(
|
||||
//// @Url url: String = UrlConfig.GET_SHELF_LIST,
|
||||
//// @Query("deviceId") deviceId: String
|
||||
//// ): ApiResponse<ShelfResult>
|
||||
////
|
||||
//// @GET
|
||||
//// suspend fun getGoodsList(
|
||||
//// @Url url: String = UrlConfig.GET_GOODS_LIST,
|
||||
//// @Query("canteenId") canteenId: String = "0",
|
||||
//// @Query("goodsName") goodsName: String? = null,
|
||||
//// @Query("pageNo") pageNo: Int = 1,
|
||||
//// @Query("pageSize") pageSize: Int = 50
|
||||
//// ): ApiResponse<MutableList<GoodsModel>?>
|
||||
////
|
||||
//// @POST
|
||||
//// suspend fun saveShelfGoodsList(
|
||||
//// @Url url: String = UrlConfig.SAVE_SHELF_GOODS_LIST,
|
||||
//// @Body body: ShelfBody
|
||||
//// ): ApiResponse<Any?>
|
||||
//
|
||||
//}
|
||||
@@ -10,36 +10,6 @@ import kotlinx.coroutines.launch
|
||||
|
||||
class NetViewModel : ViewModel() {
|
||||
|
||||
// fun getFoodList(
|
||||
// dinnerType: String,
|
||||
// pageNo: Int,
|
||||
// pageSize: Int,
|
||||
// onSuccess: (FoodRecordBean?) -> Unit,
|
||||
// onFailure: (String, String) -> Unit
|
||||
// ) {
|
||||
// viewModelScope.launch {
|
||||
// apiRequest(
|
||||
// onRequest = {
|
||||
// apiService2.getDishList(
|
||||
// dinnerType = dinnerType,
|
||||
// pageNo = pageNo,
|
||||
// pageSize = pageSize
|
||||
// )
|
||||
// },
|
||||
// onSuccess = {
|
||||
// if (it.code == 200) {
|
||||
// onSuccess(it.data)
|
||||
// return@apiRequest
|
||||
// }
|
||||
// onFailure("${it.code}", it.msg ?: "")
|
||||
// },
|
||||
// onFailure = {
|
||||
// onFailure("-1", it.errorMsg)
|
||||
// }
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
|
||||
fun submitCookFood(
|
||||
entity: CookFoodEntity,
|
||||
onSuccess: (Any?) -> Unit,
|
||||
|
||||
@@ -197,8 +197,8 @@ class FoodSearchActivity : BaseActivity() {
|
||||
|
||||
val map = mutableMapOf<String, Any>(
|
||||
"foodName" to input.trim(),
|
||||
"pageNum" to "$pageNo",
|
||||
"pageSize" to "$pageSize",
|
||||
"pageNum" to pageNo,
|
||||
"pageSize" to pageSize,
|
||||
"placeId" to BaseApp.canteenId,
|
||||
"dinnerType" to getDinnerTypeText()
|
||||
)
|
||||
@@ -207,10 +207,7 @@ class FoodSearchActivity : BaseActivity() {
|
||||
onSuccess = {
|
||||
delayDismissLoading()
|
||||
finishRefresh()
|
||||
binding.refreshLayout.run {
|
||||
setEnableRefresh(true)
|
||||
}
|
||||
// if (it == null || it.records.isNullOrEmpty()) {
|
||||
binding.refreshLayout.setEnableRefresh(true)
|
||||
if (it.isNullOrEmpty()) {
|
||||
// toast("暂未搜索到相关菜品信息")
|
||||
if (pageNo == 1) {
|
||||
@@ -218,7 +215,6 @@ class FoodSearchActivity : BaseActivity() {
|
||||
}
|
||||
return@searchFoodList
|
||||
}
|
||||
// val records = it.records
|
||||
if (pageNo == 1) {
|
||||
list.clear()
|
||||
}
|
||||
|
||||
@@ -44,12 +44,11 @@ class InitActivity : BaseActivity() {
|
||||
BaseApp.appVersion = AppUtil.getAppVersionCode(this).toString()
|
||||
|
||||
// 获取 ANDROID_ID
|
||||
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
|
||||
// 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
|
||||
BaseApp.canteenId = "0"
|
||||
// // TODO: 以上保存deviceId用于临时使用,后续改为下面注释方式
|
||||
|
||||
@@ -150,18 +149,18 @@ class InitActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun initConfig() {
|
||||
binding.ivQrCode.setImageBitmap(
|
||||
QRCodeUtil.generateQRCode(
|
||||
content = BaseApp.deviceId ?: "",
|
||||
size = 200.dp
|
||||
)
|
||||
)
|
||||
binding.btnInit.setOnClickListener {
|
||||
// HttpUtil.loopGetToken = false
|
||||
// getDeviceConfig()
|
||||
}
|
||||
}
|
||||
// private fun initConfig() {
|
||||
// binding.ivQrCode.setImageBitmap(
|
||||
// QRCodeUtil.generateQRCode(
|
||||
// content = BaseApp.deviceId ?: "",
|
||||
// size = 200.dp
|
||||
// )
|
||||
// )
|
||||
// binding.btnInit.setOnClickListener {
|
||||
//// HttpUtil.loopGetToken = false
|
||||
//// getDeviceConfig()
|
||||
// }
|
||||
// }
|
||||
|
||||
// private fun getDeviceConfig() {
|
||||
// val tokenUrl =
|
||||
@@ -203,18 +202,18 @@ class InitActivity : BaseActivity() {
|
||||
var canteenId: String? = null
|
||||
)
|
||||
|
||||
private fun checkConfigData(data: String): Boolean {
|
||||
if (data.isBlank()) {
|
||||
return false
|
||||
}
|
||||
val config = data.toObject<DeviceConfigBean?>()
|
||||
if (config == null) {
|
||||
return false
|
||||
}
|
||||
BaseApp.configUrl = config.appPackageUrl ?: ""
|
||||
BaseApp.canteenId = config.canteenId ?: ""
|
||||
return true
|
||||
}
|
||||
// private fun checkConfigData(data: String): Boolean {
|
||||
// if (data.isBlank()) {
|
||||
// return false
|
||||
// }
|
||||
// val config = data.toObject<DeviceConfigBean?>()
|
||||
// if (config == null) {
|
||||
// return false
|
||||
// }
|
||||
// BaseApp.configUrl = config.appPackageUrl ?: ""
|
||||
// BaseApp.canteenId = config.canteenId ?: ""
|
||||
// return true
|
||||
// }
|
||||
|
||||
override fun onDestroy() {
|
||||
WeightUtil.stopContinuousRead()
|
||||
|
||||
@@ -156,10 +156,10 @@ class DishListFragment : BaseFragment<FragmentDishListBinding>() {
|
||||
"placeId" to BaseApp.canteenId,
|
||||
"dinnerType" to getDinnerTypeText()
|
||||
),
|
||||
onSuccess = { recordBean ->
|
||||
onSuccess = { records ->
|
||||
activity.delayDismissLoading()
|
||||
finishRefresh()
|
||||
loadDishList(recordBean)
|
||||
loadDishList(records)
|
||||
},
|
||||
onFailure = { code, msg ->
|
||||
if (isAdded.not()) {
|
||||
|
||||
Reference in New Issue
Block a user