feat(app): 重构应用为发盘机app,界面布局优化、移除无用代码
- 将应用名称从 SmartPlateCabinet 更改为 SmartTakePlate - 更新初始化页面背景图片为 bg_collect_page3 - 替换 View 组件为 Space 组件以优化布局权重分配 - 调整取盘按钮尺寸和文字大小提升用户体验 - 简化人脸识别登录页面布局结构 - 更新应用图标资源为 logo_launcher - 移除未使用的权限声明和活动注册 - 优化人脸识别相关 API 接口调用 - 调整时间显示逻辑仅保留时间部分 - 移除扫描枪事件监听相关功能代码 - 重构人脸识别数据更新逻辑 - 移除余额不足对话框相关代码
This commit is contained in:
@@ -3,9 +3,7 @@ package com.sw.platecabinet.viewmodel
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.platecabinet.GlobalData
|
||||
import com.sw.platecabinet.model.response.ApiResponse
|
||||
import com.sw.platecabinet.model.response.EquipmentInfo
|
||||
import com.sw.platecabinet.network.ApiClient
|
||||
import com.sw.platecabinet.repository.RemoteRepository
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -65,12 +63,12 @@ abstract class BaseViewModel() : ViewModel() {
|
||||
Timber.d("handleError ${exception.message}")
|
||||
}
|
||||
|
||||
fun parseEquipmentInfo(equipmentInfo: EquipmentInfo) {
|
||||
// GlobalData.appBaseUrl = equipmentInfo.appPackageUrl!!
|
||||
// GlobalData.appBaseUrl="https://vip.shuziweidao.com"
|
||||
// GlobalData.sdkKey = equipmentInfo.arcsoftSdkKey!!
|
||||
// GlobalData.appId = equipmentInfo.arcsoftAppId!!
|
||||
// GlobalData.activeKey = equipmentInfo.arcsoftActiveKey!!
|
||||
// GlobalData.restId = equipmentInfo.canteenId!!
|
||||
}
|
||||
// fun parseEquipmentInfo(equipmentInfo: EquipmentInfo) {
|
||||
//// GlobalData.appBaseUrl = equipmentInfo.appPackageUrl!!
|
||||
//// GlobalData.appBaseUrl="https://vip.shuziweidao.com"
|
||||
//// GlobalData.sdkKey = equipmentInfo.arcsoftSdkKey!!
|
||||
//// GlobalData.appId = equipmentInfo.arcsoftAppId!!
|
||||
//// GlobalData.activeKey = equipmentInfo.arcsoftActiveKey!!
|
||||
//// GlobalData.restId = equipmentInfo.canteenId!!
|
||||
// }
|
||||
}
|
||||
@@ -1,250 +1,62 @@
|
||||
package com.sw.platecabinet.viewmodel
|
||||
|
||||
import com.sw.platecabinet.GlobalData.globalEquipmentCode
|
||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
||||
import com.sw.platecabinet.model.response.SearchResult
|
||||
import com.sw.platecabinet.model.response.UserFaceModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 管理员操作viewmodel
|
||||
*/
|
||||
class SettingViewModel : BaseViewModel() {
|
||||
// 设备绑定列表
|
||||
// private val _equipmentList = MutableStateFlow<List<EquipmentUserInfo>>(emptyList())
|
||||
// val equipmentList: StateFlow<List<EquipmentUserInfo>> = _equipmentList
|
||||
|
||||
private val _searchMemberList = MutableStateFlow<List<SearchResult.Member>>(emptyList())
|
||||
val searchMemberList: StateFlow<List<SearchResult.Member>> = _searchMemberList
|
||||
|
||||
private val _searchUserInfo = MutableStateFlow<EquipmentUserInfo?>(null)
|
||||
val searchUserInfo: StateFlow<EquipmentUserInfo?> = _searchUserInfo
|
||||
|
||||
var currentPage = 1
|
||||
var isLoading = false
|
||||
var canLoadMore = true
|
||||
|
||||
/**
|
||||
* 绑定/解绑状态 <绑定/解绑, 错误信息,>
|
||||
*/
|
||||
// private val _bindStateChange = MutableStateFlow<Pair<Boolean?, ErrorInfo>>(null to ErrorInfo())
|
||||
// val bindStateChange: StateFlow<Pair<Boolean?, ErrorInfo>> = _bindStateChange
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备绑定用户信息列表
|
||||
*/
|
||||
// fun getEquipmentList(equipmentCode: String = globalEquipmentCode) {
|
||||
// launchWithLoading {
|
||||
// val param =
|
||||
// EquipmentParam(appVersion = GlobalData.appVersion, equipmentCode = equipmentCode)
|
||||
// val response = repository.getEquipmentList(param)
|
||||
// if (parseResponse(response)) {
|
||||
// _equipmentList.value = response.data ?: emptyList()
|
||||
// }
|
||||
// }
|
||||
//// val list = mutableListOf<EquipmentUserInfo>()
|
||||
//// for (i in 1 .. 30){
|
||||
//// list.add(EquipmentUserInfo(id = i, equipmentBoxCode = i.toString()))
|
||||
//// }
|
||||
//// _equipmentList.value = list
|
||||
//package com.sw.platecabinet.viewmodel
|
||||
//
|
||||
//import com.sw.platecabinet.model.response.UserFaceModel
|
||||
//import kotlinx.coroutines.Dispatchers
|
||||
//import kotlinx.coroutines.withContext
|
||||
//import java.io.File
|
||||
//
|
||||
///**
|
||||
// * 管理员操作viewmodel
|
||||
// */
|
||||
//class SettingViewModel : BaseViewModel() {
|
||||
//
|
||||
// companion object {
|
||||
// const val PAGE_SIZE = 100
|
||||
// }
|
||||
// fun getEquipmentList(block: (List<EquipmentUserInfo>) -> Unit) {
|
||||
// launchWithLoading {
|
||||
// val response = repository.getEquipmentList()
|
||||
// if (parseResponse(response)) {
|
||||
// val list = response.data ?: emptyList()
|
||||
// block(list)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 搜索会员信息列表
|
||||
// * 获取人脸数据
|
||||
// */
|
||||
// fun getSearchMemberList(param:String, pageNum: Int = 1, pageSize: Int = 50) {
|
||||
// if (TextUtils.isEmpty(param)) return
|
||||
// currentPage = pageNum
|
||||
// var name =""
|
||||
// var phone =""
|
||||
// val num = param.toIntOrNull()
|
||||
// if (num != null) {
|
||||
// phone = param
|
||||
// } else {
|
||||
// name = param
|
||||
// }
|
||||
// fun getFaceIncrementList(
|
||||
// pageNo: Int = 1,
|
||||
// pageSize: Int = PAGE_SIZE,
|
||||
// timestamp: Long,
|
||||
// block: (List<UserFaceModel>) -> Unit
|
||||
// ) {
|
||||
// launch {
|
||||
// val searchParam = SearchParam(
|
||||
//// appVersion = GlobalData.appVersion,
|
||||
// name = name,
|
||||
// phone = phone,
|
||||
// pageNum = pageNum,
|
||||
// pageSize = pageSize
|
||||
// val response = repository.getFaceIncrementList(
|
||||
// pageNum = pageNo.toLong(),
|
||||
// pageSize = pageSize.toLong(),
|
||||
// timestamp = timestamp
|
||||
// )
|
||||
// isLoading = true
|
||||
// val response = repository.searchUser(searchParam)
|
||||
// isLoading = false
|
||||
// if (parseResponse(response)) {
|
||||
// response.data?.let { list ->
|
||||
// if (pageNum == 1) {
|
||||
// _searchMemberList.value = list
|
||||
// } else {
|
||||
// _searchMemberList.value = _searchMemberList.value.plus(list)
|
||||
// }
|
||||
// if (list.size >= pageSize) currentPage++
|
||||
// withContext(Dispatchers.Default) {
|
||||
// val list: List<UserFaceModel> = response.data ?: emptyList()
|
||||
// block(list)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// fun bindPlate(
|
||||
// equipmentBoxCode: String,
|
||||
// equipmentCode: String = globalEquipmentCode,
|
||||
// memberId: Int,
|
||||
// plateNumber: String
|
||||
// ) {
|
||||
// _bindStateChange.value = null to ErrorInfo()
|
||||
// launchWithLoading {
|
||||
// val bindParam = BindParam(
|
||||
// appVersion = GlobalData.appVersion,
|
||||
// equipmentBoxCode = equipmentBoxCode,
|
||||
// equipmentCode = equipmentCode,
|
||||
// memberId = memberId,
|
||||
// plateNumber = plateNumber
|
||||
// )
|
||||
// val response = repository.bindEquipment(bindParam)
|
||||
// if (parseResponse(response)) {
|
||||
// var userInfo = response.data
|
||||
// if (userInfo == null) {
|
||||
// userInfo = EquipmentUserInfo()
|
||||
// userInfo.equipmentBoxCode = equipmentBoxCode
|
||||
// userInfo.plateNumber = plateNumber
|
||||
// userInfo.equipmentCode = equipmentCode
|
||||
// }
|
||||
// _bindStateChange.value = true to ErrorInfo(equipmentUserInfo = userInfo)
|
||||
// } else {
|
||||
// _bindStateChange.value = true to ErrorInfo(response.code, response.msg.toString())
|
||||
//
|
||||
// /**
|
||||
// * 添加人脸数据
|
||||
// */
|
||||
// fun addUserFace(faceData: String, imageFile: File, block: (Boolean, UserFaceModel?) -> Unit) {
|
||||
// launch {
|
||||
// val imageResp = repository.uploadImage(imageFile)
|
||||
// val imageUrl = imageResp.data ?: ""
|
||||
// if (imageUrl.isBlank()) {
|
||||
// block(false, null)
|
||||
// return@launch
|
||||
// }
|
||||
// val faceResp = repository.addUserFace(faceData, imageUrl)
|
||||
// val status = parseResponse(faceResp)
|
||||
// if (status.not()) {
|
||||
// block(false, null)
|
||||
// return@launch
|
||||
// }
|
||||
// block(true, faceResp.data)
|
||||
// }
|
||||
// }
|
||||
// fun unbindPlate(
|
||||
// equipmentBoxCode: String,
|
||||
// equipmentCode: String = globalEquipmentCode
|
||||
// ) {
|
||||
// launchWithLoading {
|
||||
// val bindParam = BindParam(
|
||||
// appVersion = GlobalData.appVersion,
|
||||
// equipmentBoxCode = equipmentBoxCode,
|
||||
// equipmentCode = equipmentCode
|
||||
// )
|
||||
// val response = repository.bindEquipment(bindParam)
|
||||
// if (parseResponse(response)) {
|
||||
// _bindStateChange.value = false to ErrorInfo()
|
||||
// } else {
|
||||
// _bindStateChange.value = false to ErrorInfo(response.code, response.msg.toString())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// fun unbindPlate(id: Long?, block:(Pair<Boolean?, ErrorInfo>)-> Unit) {
|
||||
// block(null to ErrorInfo())
|
||||
// launchWithLoading {
|
||||
// val response = repository.plateUnbind(id)
|
||||
// if (parseResponse(response)) {
|
||||
// block(false to ErrorInfo())
|
||||
// } else {
|
||||
// block(false to ErrorInfo(response.code, response.msg.toString()))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// fun bindPlate(bindParam: BindParam, block:(Pair<Boolean?, ErrorInfo>)-> Unit) {
|
||||
// launchWithLoading {
|
||||
//// val response = repository.plateBind(bindParam)
|
||||
//// if (parseResponse(response)) {
|
||||
//// var userInfo = response.data
|
||||
//// if (userInfo == null) {
|
||||
//// userInfo = EquipmentUserInfo()
|
||||
//// userInfo.equipmentBoxCode = bindParam.equipmentBoxCode
|
||||
//// userInfo.plateNumber = bindParam.plateNumber
|
||||
//// userInfo.equipmentCode = bindParam.equipmentCode
|
||||
//// }
|
||||
//// block(true to ErrorInfo(equipmentUserInfo = userInfo))
|
||||
//// } else {
|
||||
//// block(true to ErrorInfo(response.code, response.msg.toString()))
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
|
||||
fun findByPlateNumber(
|
||||
plateNumber: String,
|
||||
equipmentCode: String = globalEquipmentCode
|
||||
) {
|
||||
// _searchUserInfo.value = null
|
||||
// launchWithLoading {
|
||||
//// val bindParam = BindParam(plateNumber = plateNumber)
|
||||
// val response = repository.findByPlateNumber(plateNumber)
|
||||
// if (response.code == "00000") {
|
||||
// _searchUserInfo.value = response.data
|
||||
// } else {
|
||||
// _searchUserInfo.value = EquipmentUserInfo(
|
||||
// plateNumber = plateNumber,
|
||||
// equipmentCode = equipmentCode,
|
||||
// updateTime = DateTimeUtils.getDateTimeString()
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
val PAGE_SIZE = 100
|
||||
|
||||
/**
|
||||
* 获取人脸数据
|
||||
*/
|
||||
fun getFaceIncrementList(
|
||||
pageNo: Int = 1,
|
||||
pageSize: Int = PAGE_SIZE,
|
||||
timestamp: Long,
|
||||
block: (List<UserFaceModel>) -> Unit
|
||||
) {
|
||||
launch {
|
||||
val response = repository.getFaceIncrementList(
|
||||
pageNum = pageNo.toLong(),
|
||||
pageSize = pageSize.toLong(),
|
||||
timestamp = timestamp
|
||||
)
|
||||
if (parseResponse(response)) {
|
||||
withContext(Dispatchers.Default) {
|
||||
val list: List<UserFaceModel> = response.data ?: emptyList()
|
||||
block(list)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加人脸数据
|
||||
*/
|
||||
fun addUserFace(faceData: String, imageFile: File, block: (Boolean, UserFaceModel?) -> Unit) {
|
||||
launch {
|
||||
val imageResp = repository.uploadImage(imageFile)
|
||||
val imageUrl = imageResp.data?:""
|
||||
if (imageUrl.isBlank()) {
|
||||
block(false, null)
|
||||
return@launch
|
||||
}
|
||||
val faceResp = repository.addUserFace(faceData, imageUrl)
|
||||
val status = parseResponse(faceResp)
|
||||
if (status.not()) {
|
||||
block(false, null)
|
||||
return@launch
|
||||
}
|
||||
block(true, faceResp.data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
//}
|
||||
@@ -11,13 +11,13 @@ import com.sw.plate.utils.arcface.facedb.entity.FaceEntity
|
||||
import com.sw.platecabinet.GlobalData
|
||||
import com.sw.platecabinet.GlobalKey
|
||||
import com.sw.platecabinet.model.DeviceConfig
|
||||
import com.sw.platecabinet.model.request.LoginParam
|
||||
import com.sw.platecabinet.model.response.UserFaceModel
|
||||
import com.sw.platecabinet.utils.SpTool
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 用户viewmodel
|
||||
@@ -28,38 +28,18 @@ class UserViewModel : BaseViewModel() {
|
||||
const val PAGE_SIZE = 100
|
||||
}
|
||||
|
||||
// 通过人脸获取到的用户信息
|
||||
// private val _currentUserInfo = MutableStateFlow<EquipmentUserInfo?>(null)
|
||||
// val currentUserInfo: StateFlow<EquipmentUserInfo?> = _currentUserInfo
|
||||
|
||||
private val faceApi: FaceApi = FaceApi()
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*/
|
||||
// fun generateToken(deviceId: String = "SWSN:88:12:AC:4E:D9:CC") {
|
||||
// launchWithLoading {
|
||||
// val response = repository.generateToken(deviceId)
|
||||
// if (parseResponse(response)) {
|
||||
// // 缓存token
|
||||
// SPUtil.getInstance().put(GlobalKey.KEY_TOKEN, response.data)
|
||||
// // 首次运行获取人脸数据
|
||||
// if (SPUtil.getInstance().get(GlobalKey.KEY_FIRST_RUN, false) != true) {
|
||||
// getUserFaceCache()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
fun getUserFace(
|
||||
pageNo: Int,
|
||||
pageSize: Int,
|
||||
callback: (List<UserFaceModel>) -> Unit
|
||||
) {
|
||||
launchWithLoading{
|
||||
launchWithLoading {
|
||||
val response = repository.getUserFaceCache(pageNum = pageNo, pageSize = pageSize)
|
||||
val status = parseResponse(response)
|
||||
if (status) callback(response.data?:emptyList())
|
||||
if (status) callback(response.data ?: emptyList())
|
||||
else emptyList<UserFaceModel>()
|
||||
}
|
||||
}
|
||||
@@ -159,40 +139,6 @@ class UserViewModel : BaseViewModel() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验码登录
|
||||
*/
|
||||
fun loginWithPwd(loginParam: LoginParam) {
|
||||
// launchWithLoading {
|
||||
// val response = repository.equipmentBoxLogin(loginParam)
|
||||
// if (parseResponse(response)) {
|
||||
// _currentUserInfo.value = response.data
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户id获取用户信息
|
||||
*/
|
||||
// fun getUserInfoById(memberId: String?, action: (EquipmentUserInfo?) -> Unit = {}) {
|
||||
// _currentUserInfo.value = null
|
||||
// launchWithLoading {
|
||||
// val loginParam = LoginParam(faceId = memberId)
|
||||
// val response = repository.equipmentBoxLogin(loginParam)
|
||||
// if (parseResponse(response)) {
|
||||
// _currentUserInfo.value = response.data
|
||||
// action(response.data)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 重置用户信息
|
||||
*/
|
||||
fun resetUserInfo() {
|
||||
Timber.d("resetUserInfo")
|
||||
// _currentUserInfo.value = null
|
||||
}
|
||||
|
||||
fun getDeviceConfig(block: (DeviceConfig?) -> Unit) {
|
||||
// Timber.tag(TAG).d("getDeviceConfig")
|
||||
@@ -206,4 +152,50 @@ class UserViewModel : BaseViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取人脸数据
|
||||
*/
|
||||
fun getFaceIncrementList(
|
||||
pageNo: Int = 1,
|
||||
pageSize: Int = PAGE_SIZE,
|
||||
timestamp: Long,
|
||||
block: (List<UserFaceModel>) -> Unit
|
||||
) {
|
||||
launch {
|
||||
val response = repository.getFaceIncrementList(
|
||||
pageNum = pageNo.toLong(),
|
||||
pageSize = pageSize.toLong(),
|
||||
timestamp = timestamp
|
||||
)
|
||||
if (parseResponse(response)) {
|
||||
withContext(Dispatchers.Default) {
|
||||
val list: List<UserFaceModel> = response.data ?: emptyList()
|
||||
block(list)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加人脸数据
|
||||
*/
|
||||
fun addUserFace(faceData: String, imageFile: File, block: (Boolean, UserFaceModel?) -> Unit) {
|
||||
launch {
|
||||
val imageResp = repository.uploadImage(imageFile)
|
||||
val imageUrl = imageResp.data ?: ""
|
||||
if (imageUrl.isBlank()) {
|
||||
block(false, null)
|
||||
return@launch
|
||||
}
|
||||
val faceResp = repository.addUserFace(faceData, imageUrl)
|
||||
val status = parseResponse(faceResp)
|
||||
if (status.not()) {
|
||||
block(false, null)
|
||||
return@launch
|
||||
}
|
||||
block(true, faceResp.data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user