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