调整了餐盘柜3种情况处理
This commit is contained in:
@@ -4,7 +4,8 @@ object GlobalData {
|
||||
/**
|
||||
* 同一设备全局使用的设备编号
|
||||
*/
|
||||
var globalEquipmentCode: String = "202501171634"
|
||||
// var globalEquipmentCode: String = "202501171634"
|
||||
var globalEquipmentCode: String = "202507231144"
|
||||
|
||||
/**
|
||||
* app版本号
|
||||
@@ -30,7 +31,17 @@ object GlobalData {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 全局常量
|
||||
*/
|
||||
object Constants {
|
||||
/**
|
||||
* 自动关闭时间
|
||||
*/
|
||||
const val AUTO_CLOSE_TIME: Long = 3
|
||||
}
|
||||
|
||||
/**
|
||||
* key
|
||||
*/
|
||||
object GlobalKey {
|
||||
const val KEY_TOKEN = "tokenKey"
|
||||
|
||||
@@ -20,7 +20,7 @@ class MyApp : App() {
|
||||
* 初始化全局数据
|
||||
*/
|
||||
private fun initGlobalData() {
|
||||
GlobalData.appVersion = AppUtil.getAppVersionName(this)
|
||||
GlobalData.appVersion = AppUtil.getAppVersionCode(this).toString()
|
||||
GlobalData.globalEquipmentCode = "202501171634"
|
||||
}
|
||||
}
|
||||
@@ -306,13 +306,22 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
* @param isAdmin true 管理员 执行绑盘此操作 false 用户,提示错误
|
||||
*/
|
||||
fun handleLoginSuccess(equipmentUserInfo: EquipmentUserInfo, isAdmin: Boolean) {
|
||||
Timber.d("handleLoginSuccess isAdmin = $isAdmin")
|
||||
viewModel.resetUserInfo()
|
||||
if (equipmentUserInfo.isOtherEquipment()) {
|
||||
MainActivity.start(
|
||||
context,
|
||||
pageType = PageType.PLATE_TIP,
|
||||
equipmentUserInfo = equipmentUserInfo
|
||||
)
|
||||
return
|
||||
}
|
||||
if (equipmentUserInfo.equipmentBoxCode?.isNotEmpty() == true) {
|
||||
SerialApi.openPlate(
|
||||
equipmentUserInfo.equipmentBoxCode.toInt(),
|
||||
object : SerialPortManager.SendCallback {
|
||||
override fun onSuccess() {
|
||||
MainActivity.start(context, pageType = PageType.PLATE_OPEN)
|
||||
MainActivity.start(context, pageType = PageType.PLATE_TIP)
|
||||
}
|
||||
|
||||
override fun onFail(e: Exception?) {
|
||||
@@ -323,7 +332,12 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
if (isAdmin) {
|
||||
settingViewModel.getEquipmentList()
|
||||
} else {
|
||||
ToastUtils.showToast("无餐盘信息")
|
||||
Timber.d("无餐盘信息")
|
||||
MainActivity.start(
|
||||
context,
|
||||
pageType = PageType.PLATE_TIP,
|
||||
equipmentUserInfo = equipmentUserInfo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
val page = when (pageType) {
|
||||
PageType.SETTING_LIST -> SettingListFragment()
|
||||
PageType.BIND_PLATE -> BindPlateFragment.newInstance(equipmentUserInfo)
|
||||
PageType.PLATE_OPEN -> PlateOpenFragment()
|
||||
PageType.PLATE_TIP -> PlateOpenFragment.newInstance(equipmentUserInfo)
|
||||
PageType.UNBIND_PLATE -> UnBindPlateFragment.newInstance(equipmentUserInfo)
|
||||
PageType.PLATE_CABINET_FULL -> PlateCabinetFullFragment()
|
||||
}
|
||||
@@ -90,9 +90,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
*/
|
||||
enum class PageType {
|
||||
/**
|
||||
* 餐盘柜打开
|
||||
* 提示
|
||||
*/
|
||||
PLATE_OPEN,
|
||||
PLATE_TIP,
|
||||
|
||||
/**
|
||||
* 设置列表
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.platecabinet.R
|
||||
import com.sw.platecabinet.activity.MainActivity
|
||||
import com.sw.platecabinet.activity.PageType
|
||||
import com.sw.platecabinet.adapter.GenericItemAdapter
|
||||
import com.sw.platecabinet.adapter.GridSpacingItemDecoration
|
||||
import com.sw.platecabinet.adapter.dpToPx
|
||||
@@ -34,24 +35,24 @@ class BindPlateFragment : BaseFragment<FragmentBindPlateBinding>(
|
||||
FragmentBindPlateBinding::inflate
|
||||
) {
|
||||
private lateinit var adapter: GenericItemAdapter<SearchResult.Member, ItemSearchUserInfoBinding>
|
||||
internal val ARG_PARAM1 = "param1"
|
||||
internal val KEY_ACTION_TYPE = "actionType"
|
||||
private var info: EquipmentUserInfo? = null
|
||||
private var checkedItem: SearchResult.Member? = null
|
||||
private var lastText = ""
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(param1: EquipmentUserInfo?) =
|
||||
fun newInstance(userInfo: EquipmentUserInfo?) =
|
||||
BindPlateFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(ARG_PARAM1, param1)
|
||||
putParcelable(KEY_ACTION_TYPE, userInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun initialize() {
|
||||
arguments?.let {
|
||||
info = it.getParcelable(ARG_PARAM1)
|
||||
info = it.getParcelable(KEY_ACTION_TYPE)
|
||||
info?.let {
|
||||
binding.tvNum.text = "${it.equipmentName}-${it.equipmentBoxCode}"
|
||||
if (!TextUtils.isEmpty(it.plateNumber)) {
|
||||
@@ -175,8 +176,16 @@ class BindPlateFragment : BaseFragment<FragmentBindPlateBinding>(
|
||||
if (it.first == null) return@collect // 解绑状态过滤
|
||||
val errorInfo = it.second
|
||||
if (errorInfo.isSuccess()) {
|
||||
if (errorInfo.equipmentUserInfo?.isOtherEquipment() == true) {
|
||||
MainActivity.start(
|
||||
requireContext(),
|
||||
pageType = PageType.PLATE_TIP,
|
||||
equipmentUserInfo = errorInfo.equipmentUserInfo
|
||||
)
|
||||
} else {
|
||||
ToastUtils.showToast("绑定成功")
|
||||
activity?.finish()
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showToast(errorInfo.msg)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sw.platecabinet.fragment
|
||||
|
||||
import android.os.CountDownTimer
|
||||
import com.sw.platecabinet.Constants
|
||||
import com.sw.platecabinet.databinding.FragmentPlateCabinetFullBinding
|
||||
import timber.log.Timber
|
||||
|
||||
@@ -9,7 +10,7 @@ import timber.log.Timber
|
||||
*/
|
||||
class PlateCabinetFullFragment :
|
||||
BaseFragment<FragmentPlateCabinetFullBinding>(FragmentPlateCabinetFullBinding::inflate) {
|
||||
private var totalTimeInMillis: Long = 5 * 1000
|
||||
private var totalTimeInMillis: Long = Constants.AUTO_CLOSE_TIME * 1000
|
||||
|
||||
override fun initialize() {
|
||||
Timber.d("initialize")
|
||||
|
||||
@@ -1,16 +1,54 @@
|
||||
package com.sw.platecabinet.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import com.sw.platecabinet.Constants
|
||||
import com.sw.platecabinet.R
|
||||
import com.sw.platecabinet.databinding.FragmentPlateOpenBinding
|
||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
||||
|
||||
/**
|
||||
* 餐盘柜打开界面
|
||||
* 餐盘柜提示界面
|
||||
*/
|
||||
class PlateOpenFragment :
|
||||
BaseFragment<FragmentPlateOpenBinding>(FragmentPlateOpenBinding::inflate) {
|
||||
private var totalTimeInMillis: Long = 5 * 1000
|
||||
private var totalTimeInMillis: Long = Constants.AUTO_CLOSE_TIME * 1000
|
||||
internal val KEY_ACTION_TYPE = "actionType"
|
||||
private var info: EquipmentUserInfo? = null
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(userInfo: EquipmentUserInfo?) =
|
||||
PlateOpenFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(KEY_ACTION_TYPE, userInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun initialize() {
|
||||
arguments?.let {
|
||||
info = it.getParcelable(KEY_ACTION_TYPE)
|
||||
info?.let {
|
||||
if (!it.isBound()) {
|
||||
binding.ivType.setImageResource(R.drawable.ic_tip_warn)
|
||||
binding.tvTitle.text = "暂无餐盘信息"
|
||||
binding.tvSubTitle.text = "请联系管理员"
|
||||
binding.tvTitle.setTextColor(requireContext().getColor(R.color.tip_title_fail))
|
||||
} else if (it.isOtherEquipment()) {
|
||||
binding.ivType.setImageResource(R.drawable.ic_tip_warn)
|
||||
binding.tvTitle.text = "暂无餐盘信息"
|
||||
binding.tvSubTitle.text = "您的餐盘绑定在${it.equipmentName ?: " "}号柜上"
|
||||
binding.tvTitle.setTextColor(requireContext().getColor(R.color.tip_title_fail))
|
||||
} else {
|
||||
binding.ivType.setImageResource(R.drawable.ic_tip_success)
|
||||
binding.tvTitle.text = "柜门开启"
|
||||
binding.tvSubTitle.text = "餐盘取出后请关闭柜门"
|
||||
binding.tvTitle.setTextColor(requireContext().getColor(R.color.tip_title_success))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initCountTime()
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ class SettingListFragment :
|
||||
SerialApi.openPlate(equipmentBoxCode, object : SerialPortManager.SendCallback {
|
||||
override fun onSuccess() {
|
||||
hideWaitingDialog()
|
||||
MainActivity.start(requireContext(), pageType = PageType.PLATE_OPEN)
|
||||
MainActivity.start(requireContext(), pageType = PageType.PLATE_TIP)
|
||||
}
|
||||
|
||||
override fun onFail(e: Exception?) {
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package com.sw.platecabinet.model
|
||||
|
||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
||||
|
||||
/**
|
||||
* 错误信息 code == 200 成功
|
||||
*/
|
||||
data class ErrorInfo(val code: Int = 200, val msg: String = "") {
|
||||
data class ErrorInfo(
|
||||
val code: Int = 200,
|
||||
val msg: String = "",
|
||||
val equipmentUserInfo: EquipmentUserInfo? = null
|
||||
) {
|
||||
fun isSuccess(): Boolean {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.sw.platecabinet.viewmodel
|
||||
|
||||
import com.sw.inbound.utils.DateTimeUtils
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.platecabinet.GlobalData
|
||||
import com.sw.platecabinet.GlobalData.globalEquipmentCode
|
||||
import com.sw.platecabinet.model.ErrorInfo
|
||||
@@ -96,13 +95,7 @@ class SettingViewModel : BaseViewModel() {
|
||||
val response = repository.bindEquipment(bindParam)
|
||||
if (parseResponse(response)) {
|
||||
val userInfo = response.data
|
||||
userInfo?.let {
|
||||
if (it.isOtherEquipment()) {
|
||||
ToastUtils.showToast("餐盘已在${it.equipmentName}绑定")
|
||||
return@launchWithLoading
|
||||
}
|
||||
}
|
||||
_bindStateChange.value = true to ErrorInfo()
|
||||
_bindStateChange.value = true to ErrorInfo(equipmentUserInfo = userInfo)
|
||||
} else {
|
||||
_bindStateChange.value = true to ErrorInfo(response.code, response.msg.toString())
|
||||
}
|
||||
@@ -140,14 +133,6 @@ class SettingViewModel : BaseViewModel() {
|
||||
)
|
||||
val response = repository.findByPlateNumber(bindParam)
|
||||
if (response.code == 200) {
|
||||
val userInfo = response.data
|
||||
userInfo?.let {
|
||||
if (it.isOtherEquipment()) {
|
||||
ToastUtils.showToast("餐盘已在${it.equipmentName}绑定")
|
||||
return@launchWithLoading
|
||||
}
|
||||
}
|
||||
|
||||
_searchUserInfo.value = response.data
|
||||
} else {
|
||||
_searchUserInfo.value = EquipmentUserInfo(
|
||||
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
@@ -28,11 +28,13 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_plate_open" />
|
||||
android:src="@drawable/ic_tip_success" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
@@ -41,10 +43,14 @@
|
||||
android:textSize="36sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sub_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="23dp"
|
||||
android:text="餐盘取出后请关闭柜门"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:textColor="#ff887872"
|
||||
android:textSize="24sp" />
|
||||
|
||||
|
||||
@@ -12,4 +12,7 @@
|
||||
<color name="unbind_32283C">#32283C</color>
|
||||
|
||||
<color name="divColor">#4c91ceff</color>
|
||||
<color name="tip_title_success">#ff02f1be</color>
|
||||
<color name="tip_title_fail">#FF9933</color>
|
||||
<color name="tip_sub_title">#887872</color>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user