Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8735db27b | ||
|
|
e1e4bc5123 | ||
|
|
18f45e7821 | ||
|
|
1826ac0f60 | ||
|
|
d81381ae6f | ||
|
|
f35411a8a0 | ||
|
|
93b46e38d4 | ||
|
|
ba1a364ee8 | ||
|
|
50b1023a44 | ||
|
|
385ada4a0d | ||
|
|
ae708eeeed | ||
|
|
2886e7d4a3 | ||
|
|
66a0c399ec | ||
|
|
4cbe318ab2 | ||
|
|
1cbad71eaf | ||
|
|
0a193ed84e | ||
|
|
df9212d2dd | ||
|
|
cc16fcecff | ||
|
|
83f9654987 | ||
|
|
536b1b98b4 | ||
|
|
7d2bf08023 |
Generated
+1
-1
@@ -1 +1 @@
|
|||||||
SmartPlateCabinet
|
SmartTakePlate
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="com.codeverse.userSettings.MarscodeWorkspaceAppSettingsState">
|
||||||
|
<option name="progress" value="1.0" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AppInsightsSettings">
|
||||||
|
<option name="selectedTabId" value="Firebase Crashlytics" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+2
-2
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2026-02-05T08:42:12.462597100Z">
|
<DropdownSelection timestamp="2026-03-18T06:09:00.079142300Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="Default" identifier="serial=192.168.3.114:5555;connection=a41f05a9" />
|
<DeviceId pluginId="Default" identifier="serial=192.168.1.161:5555;connection=2c537abb" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
Generated
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DeviceTable">
|
||||||
|
<option name="columnSorters">
|
||||||
|
<list>
|
||||||
|
<ColumnSorterState>
|
||||||
|
<option name="column" value="Name" />
|
||||||
|
<option name="order" value="ASCENDING" />
|
||||||
|
</ColumnSorterState>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -18,7 +18,7 @@ android {
|
|||||||
compileSdk = 35
|
compileSdk = 35
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.sw.platecabinet"
|
applicationId = "com.sw.take.plate"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
@@ -59,7 +59,10 @@ dependencies {
|
|||||||
implementation(libs.material)
|
implementation(libs.material)
|
||||||
implementation(libs.androidx.activity)
|
implementation(libs.androidx.activity)
|
||||||
implementation(libs.androidx.constraintlayout)
|
implementation(libs.androidx.constraintlayout)
|
||||||
implementation(project(":lib_face"))
|
implementation(project(":lib_face")) {
|
||||||
|
exclude(group = "com.licheedev", module = "android-serialport")
|
||||||
|
}
|
||||||
|
implementation(files("libs/plc_aar_104.aar"))
|
||||||
testImplementation(libs.junit)
|
testImplementation(libs.junit)
|
||||||
androidTestImplementation(libs.androidx.junit)
|
androidTestImplementation(libs.androidx.junit)
|
||||||
androidTestImplementation(libs.androidx.espresso.core)
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
|||||||
Binary file not shown.
@@ -10,7 +10,8 @@
|
|||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
android:maxSdkVersion="32" />
|
android:maxSdkVersion="32"
|
||||||
|
tools:ignore="ScopedStorage" />
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||||
android:maxSdkVersion="32" />
|
android:maxSdkVersion="32" />
|
||||||
@@ -21,9 +22,9 @@
|
|||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
android:icon="@mipmap/ic_logo512"
|
android:icon="@drawable/logo_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_logo512"
|
android:roundIcon="@drawable/logo_launcher"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.SmartPlateCabinet"
|
android:theme="@style/Theme.SmartPlateCabinet"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
@@ -38,19 +39,13 @@
|
|||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<activity
|
|
||||||
android:name=".activity.UnBindDialogActivity"
|
|
||||||
android:exported="false"
|
|
||||||
android:theme="@style/DialogActivity" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.InitActivity"
|
android:name=".activity.InitActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name=".activity.LoginByPwdActivity"
|
|
||||||
android:exported="false"
|
|
||||||
android:launchMode="singleTask"/>
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.LoginByFaceActivity"
|
android:name=".activity.LoginByFaceActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@@ -69,7 +64,10 @@
|
|||||||
android:name=".activity.MainActivity"
|
android:name=".activity.MainActivity"
|
||||||
android:exported="false">
|
android:exported="false">
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.sw.platecabinet.activity.FunActivity" />
|
<activity
|
||||||
|
android:name=".activity.PlcSettingActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<!-- <activity android:name="com.sw.platecabinet.activity.FunActivity" />-->
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -33,7 +33,14 @@ object GlobalData {
|
|||||||
/**
|
/**
|
||||||
* 具体业务baseurl
|
* 具体业务baseurl
|
||||||
*/
|
*/
|
||||||
var appBaseUrl: String = "https://dev.yixiong-tech.com:8081"
|
var appBaseUrl: String = ""
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 具体业务 BaseUrl
|
||||||
|
*/
|
||||||
|
const val TEST_BASE_URL: String = "http://192.168.1.201:14801"
|
||||||
|
const val UAT_BASE_URL: String = "https://dev.yixiong-tech.com:8083"
|
||||||
|
const val PROD_BASE_URL: String = "https://api.dm.yixiong-tech.com:8443"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备id
|
* 设备id
|
||||||
@@ -61,4 +68,5 @@ object GlobalKey {
|
|||||||
const val KEY_FIRST_RUN = "firstRun"
|
const val KEY_FIRST_RUN = "firstRun"
|
||||||
const val KEY_USER_INFO = "userInfoKey"
|
const val KEY_USER_INFO = "userInfoKey"
|
||||||
const val PARAM_EQUIPMENT_INFO = "equipmentUserInfo"
|
const val PARAM_EQUIPMENT_INFO = "equipmentUserInfo"
|
||||||
|
const val KEY_BASE_URL = "baseUrlKey"
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
package com.sw.platecabinet
|
package com.sw.platecabinet
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.sw.plate.App
|
import com.sw.plate.App
|
||||||
import com.sw.plate.utils.AppUtil
|
import com.sw.plate.utils.AppUtil
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
import com.sw.platecabinet.utils.CrashHandler
|
import com.sw.platecabinet.utils.CrashHandler
|
||||||
|
import com.sw.platecabinet.utils.SpTool
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
class MyApp : App() {
|
class MyApp : App() {
|
||||||
companion object {
|
companion object {
|
||||||
const val DEBUG: Boolean = true
|
const val DEBUG: Boolean = true
|
||||||
var instance: MyApp? = null
|
var instance: MyApp? = null
|
||||||
var plateList: List<EquipmentUserInfo>? = null
|
// var plateList: List<EquipmentUserInfo>? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
@@ -28,12 +29,24 @@ class MyApp : App() {
|
|||||||
/**
|
/**
|
||||||
* 初始化全局数据
|
* 初始化全局数据
|
||||||
*/
|
*/
|
||||||
|
@SuppressLint("LogNotTimber")
|
||||||
private fun initGlobalData() {
|
private fun initGlobalData() {
|
||||||
var deviceId = AppUtil.getUDID(this)
|
val deviceId = AppUtil.getUDID(this)
|
||||||
// deviceId = "be154831-3466-3ba2-a2ea-57652c919fed"
|
// deviceId = "be154831-3466-3ba2-a2ea-57652c919fed"
|
||||||
Log.d("MyApp", "initialize: deviceId=$deviceId")
|
Log.d("MyApp", "initialize: deviceId=$deviceId")
|
||||||
GlobalData.deviceId = deviceId
|
GlobalData.deviceId = deviceId
|
||||||
|
|
||||||
|
val url = SpTool.baseUrl
|
||||||
|
if (url.isNotBlank()) {
|
||||||
|
GlobalData.appBaseUrl = url
|
||||||
|
} else {
|
||||||
|
GlobalData.appBaseUrl =
|
||||||
|
if ("14d2dad5-7d33-3ced-8a59-f14cb1ef2d21" == deviceId)
|
||||||
|
GlobalData.TEST_BASE_URL
|
||||||
|
else
|
||||||
|
GlobalData.PROD_BASE_URL
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: 临时测试----------------
|
// TODO: 临时测试----------------
|
||||||
// if ("2987f0c5-5754-33e9-b00a-251db5e2e55f" == deviceId) {
|
// if ("2987f0c5-5754-33e9-b00a-251db5e2e55f" == deviceId) {
|
||||||
// GlobalData.deviceId = "79814f20-f253-397c-9da7-8430ffa5ef00"
|
// GlobalData.deviceId = "79814f20-f253-397c-9da7-8430ffa5ef00"
|
||||||
|
|||||||
@@ -1,46 +1,39 @@
|
|||||||
package com.sw.platecabinet.activity
|
package com.sw.platecabinet.activity
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.Log
|
|
||||||
import android.view.KeyEvent
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowInsetsController
|
import android.view.WindowInsetsController
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.sw.inbound.utils.DateTimeUtils
|
import com.sw.inbound.utils.DateTimeUtils
|
||||||
import com.sw.plate.App
|
import com.sw.plate.App
|
||||||
import com.sw.plate.utils.Base64
|
import com.sw.plate.utils.Base64
|
||||||
import com.sw.plate.utils.ScanGunKeyEventHelper
|
|
||||||
import com.sw.plate.utils.arcface.facedb.FaceDatabase
|
import com.sw.plate.utils.arcface.facedb.FaceDatabase
|
||||||
import com.sw.plate.utils.arcface.facedb.entity.FaceEntity
|
import com.sw.plate.utils.arcface.facedb.entity.FaceEntity
|
||||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||||
import com.sw.platecabinet.MyApp
|
|
||||||
import com.sw.platecabinet.R
|
import com.sw.platecabinet.R
|
||||||
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
||||||
import com.sw.platecabinet.ext.clickWithCoroutines
|
import com.sw.platecabinet.ext.clickWithCoroutines
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
import com.sw.platecabinet.model.response.UserFaceModel
|
import com.sw.platecabinet.model.response.UserFaceModel
|
||||||
import com.sw.platecabinet.utils.IntervalExecutor
|
import com.sw.platecabinet.utils.IntervalExecutor
|
||||||
import com.sw.platecabinet.utils.PermissionHelper
|
|
||||||
import com.sw.platecabinet.utils.PlateUtils
|
|
||||||
import com.sw.platecabinet.utils.SpTool
|
import com.sw.platecabinet.utils.SpTool
|
||||||
import com.sw.platecabinet.view.CustomLoadingDialog
|
import com.sw.platecabinet.view.CustomLoadingDialog
|
||||||
import com.sw.platecabinet.viewmodel.SettingViewModel
|
|
||||||
import com.sw.platecabinet.viewmodel.UserViewModel
|
import com.sw.platecabinet.viewmodel.UserViewModel
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,15 +45,14 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
protected lateinit var context: Context
|
protected lateinit var context: Context
|
||||||
private var timeJob: Job? = null
|
private var timeJob: Job? = null
|
||||||
private var mDialogWaiting: CustomLoadingDialog? = null
|
private var mDialogWaiting: CustomLoadingDialog? = null
|
||||||
private val permissionHelpers = mutableMapOf<Int, PermissionHelper>()
|
// private val permissionHelpers = mutableMapOf<Int, PermissionHelper>()
|
||||||
protected var keyEventHelper: ScanGunKeyEventHelper? = null
|
// protected var keyEventHelper: ScanGunKeyEventHelper? = null
|
||||||
|
|
||||||
// 管理员对应的viewmodel
|
|
||||||
val settingViewModel by viewModels<SettingViewModel>()
|
|
||||||
|
|
||||||
// 用户对应的viewModel
|
// 用户对应的viewModel
|
||||||
protected val userViewModel by viewModels<UserViewModel>()
|
protected val userViewModel by viewModels<UserViewModel>()
|
||||||
|
|
||||||
|
public val recognizeViewModel by viewModels<RecognizeViewModel>()
|
||||||
|
|
||||||
private var startTime: Long = 0
|
private var startTime: Long = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -81,62 +73,62 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
updateTime()
|
updateTime()
|
||||||
registerDataChange()
|
registerDataChange()
|
||||||
initialize()
|
initialize()
|
||||||
registerKeyEvent()
|
// registerKeyEvent()
|
||||||
val durationTime = System.currentTimeMillis() - startTime
|
val durationTime = System.currentTimeMillis() - startTime
|
||||||
Timber.d("启动时间:$durationTime")
|
Timber.d("启动时间:$durationTime")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 监听扫描枪扫描事件
|
// * 监听扫描枪扫描事件
|
||||||
*/
|
// */
|
||||||
protected fun registerKeyEvent() {
|
// protected fun registerKeyEvent() {
|
||||||
keyEventHelper =
|
// keyEventHelper =
|
||||||
ScanGunKeyEventHelper(context, object : ScanGunKeyEventHelper.OnScanSuccessListener {
|
// ScanGunKeyEventHelper(context, object : ScanGunKeyEventHelper.OnScanSuccessListener {
|
||||||
override fun onScanSuccess(barcode: String?) {
|
// override fun onScanSuccess(barcode: String?) {
|
||||||
Timber.d("onScanSuccess barcode = $barcode")
|
// Timber.d("onScanSuccess barcode = $barcode")
|
||||||
if (barcode == null) return
|
// if (barcode == null) return
|
||||||
handleScanKeyInfo(barcode)
|
// handleScanKeyInfo(barcode)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理扫描枪数据
|
* 处理扫描枪数据
|
||||||
*/
|
*/
|
||||||
protected open fun handleScanKeyInfo(scanInfo: String) {
|
protected open fun handleScanKeyInfo(scanInfo: String) {
|
||||||
// settingViewModel.findByPlateNumber(plateNumber = scanInfo)
|
//// settingViewModel.findByPlateNumber(plateNumber = scanInfo)
|
||||||
var plateNumber = scanInfo
|
// var plateNumber = scanInfo
|
||||||
if (scanInfo.length > 6) {
|
// if (scanInfo.length > 6) {
|
||||||
plateNumber = scanInfo.take(6)
|
// plateNumber = scanInfo.take(6)
|
||||||
}
|
// }
|
||||||
Log.d("TAG", "handleScanKeyInfo: " + Gson().toJson(MyApp.plateList))
|
// Log.d("TAG", "handleScanKeyInfo: " + Gson().toJson(MyApp.plateList))
|
||||||
if (MyApp.plateList == null) {
|
// if (MyApp.plateList == null) {
|
||||||
initPlateList()
|
// initPlateList()
|
||||||
}
|
// }
|
||||||
//柜子未关联该餐盘,直接找空位置放入盘子
|
// //柜子未关联该餐盘,直接找空位置放入盘子
|
||||||
val item = MyApp.plateList?.firstOrNull { it.plateNumber.isNullOrBlank() }
|
// val item = MyApp.plateList?.firstOrNull { it.plateNumber.isNullOrBlank() }
|
||||||
if (item == null) {
|
// if (item == null) {
|
||||||
//柜子已满
|
// //柜子已满
|
||||||
MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
|
// MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
//找到位置,放入餐盘,清除已有id和时间
|
// //找到位置,放入餐盘,清除已有id和时间
|
||||||
item.plateNumber = plateNumber
|
// item.plateNumber = plateNumber
|
||||||
item.faceId = null
|
// item.faceId = null
|
||||||
item.updateTime = null
|
// item.updateTime = null
|
||||||
PlateUtils.open(this, item.equipmentBoxCode, true)
|
// PlateUtils.open(this, item.equipmentBoxCode, true)
|
||||||
SpTool.savePlateData(MyApp.plateList!!)
|
// SpTool.savePlateData(MyApp.plateList!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
// override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||||
if (keyEventHelper != null) {
|
// if (keyEventHelper != null) {
|
||||||
if (keyEventHelper!!.isScanGunEvent(event)) {
|
// if (keyEventHelper!!.isScanGunEvent(event)) {
|
||||||
keyEventHelper!!.analysisKeyEvent(event)
|
// keyEventHelper!!.analysisKeyEvent(event)
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return super.dispatchKeyEvent(event)
|
// return super.dispatchKeyEvent(event)
|
||||||
}
|
// }
|
||||||
|
|
||||||
fun updateTime() {
|
fun updateTime() {
|
||||||
headerBinding?.let {
|
headerBinding?.let {
|
||||||
@@ -150,12 +142,10 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
onRightDoubleClick()
|
onRightDoubleClick()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
val scope = CoroutineScope(Dispatchers.Main)
|
timeJob = lifecycleScope.launch {
|
||||||
timeJob = scope.launch {
|
|
||||||
DateTimeUtils.realTimeChineseDateFlow()
|
DateTimeUtils.realTimeChineseDateFlow()
|
||||||
.collect { (date, time) ->
|
.collect { date ->
|
||||||
it.tvLeftDate.text = date
|
it.tvRightTime.text = date
|
||||||
it.tvRightTime.text = time
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,36 +162,36 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
* 右侧时间双击
|
* 右侧时间双击
|
||||||
*/
|
*/
|
||||||
open fun onRightDoubleClick() {
|
open fun onRightDoubleClick() {
|
||||||
MainActivity.start(context, pageType = PageType.SETTING_LIST)
|
//MainActivity.start(context, pageType = PageType.SETTING_LIST)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(
|
// override fun onRequestPermissionsResult(
|
||||||
requestCode: Int,
|
// requestCode: Int,
|
||||||
permissions: Array<out String>,
|
// permissions: Array<out String>,
|
||||||
grantResults: IntArray
|
// grantResults: IntArray
|
||||||
) {
|
// ) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
// super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
|
//
|
||||||
val helper = permissionHelpers[requestCode]
|
// val helper = permissionHelpers[requestCode]
|
||||||
val allGranted = PermissionHelper.handlePermissionResult(
|
// val allGranted = PermissionHelper.handlePermissionResult(
|
||||||
this,
|
// this,
|
||||||
requestCode,
|
// requestCode,
|
||||||
permissions,
|
// permissions,
|
||||||
grantResults,
|
// grantResults,
|
||||||
permissionHelper = helper
|
// permissionHelper = helper
|
||||||
)
|
// )
|
||||||
|
//
|
||||||
if (allGranted) {
|
// if (allGranted) {
|
||||||
permissionHelpers.remove(requestCode)
|
// permissionHelpers.remove(requestCode)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 注册PermissionHelper以便处理结果
|
// * 注册PermissionHelper以便处理结果
|
||||||
*/
|
// */
|
||||||
fun registerPermissionHelper(helper: PermissionHelper) {
|
// fun registerPermissionHelper(helper: PermissionHelper) {
|
||||||
permissionHelpers[helper.requestCode] = helper
|
// permissionHelpers[helper.requestCode] = helper
|
||||||
}
|
// }
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
@@ -266,6 +256,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
mDialogWaiting = CustomLoadingDialog(this, view, R.style.MyDialog)
|
mDialogWaiting = CustomLoadingDialog(this, view, R.style.MyDialog)
|
||||||
mDialogWaiting!!.show()
|
mDialogWaiting!!.show()
|
||||||
mDialogWaiting!!.setCancelable(true)
|
mDialogWaiting!!.setCancelable(true)
|
||||||
|
mDialogWaiting!!.setCanceledOnTouchOutside(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,125 +281,12 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
*/
|
*/
|
||||||
protected open fun registerDataChange() {
|
protected open fun registerDataChange() {
|
||||||
Timber.d("registerDataChange")
|
Timber.d("registerDataChange")
|
||||||
// lifecycleScope.launch {
|
|
||||||
// viewModel.showLoading.collect {
|
|
||||||
// Timber.d("registerDataChange 用户 showLoading = $it")
|
|
||||||
// if (it) {
|
|
||||||
// showWaitingDialog("")
|
|
||||||
// } else {
|
|
||||||
// hideWaitingDialog()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// lifecycleScope.launch {
|
|
||||||
// viewModel.currentUserInfo.collect {
|
|
||||||
// if (it == null) return@collect
|
|
||||||
//// it.showBalanceNotEnoughDialog = true
|
|
||||||
// handleLoginSuccess(it, false)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// lifecycleScope.launch {
|
|
||||||
// settingViewModel.showLoading.collect {
|
|
||||||
// Timber.d("registerDataChange 管理员 showLoading = $it")
|
|
||||||
// if (it) {
|
|
||||||
// showWaitingDialog("")
|
|
||||||
// } else {
|
|
||||||
// hideWaitingDialog()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// lifecycleScope.launch {
|
|
||||||
// settingViewModel.searchUserInfo.collect {
|
|
||||||
// Timber.d("registerDataChange 管理员 currentUserInfo = $it")
|
|
||||||
// if (it == null) return@collect
|
|
||||||
// handleLoginSuccess(it, true)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// lifecycleScope.launch {
|
|
||||||
// settingViewModel.equipmentList.collect {
|
|
||||||
// loadEquipmentList(it)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun loadEquipmentList(items: List<EquipmentUserInfo>) {
|
|
||||||
// if (items.isEmpty()) return
|
|
||||||
// val unbindList = items.filter { !it.isBound() }
|
|
||||||
// if (unbindList.isEmpty()) {
|
|
||||||
// MainActivity.start(context = context, pageType = PageType.PLATE_CABINET_FULL)
|
|
||||||
// } else {
|
|
||||||
// val firstInfo = unbindList[0]
|
|
||||||
// val currentUserInfo = settingViewModel.searchUserInfo.value
|
|
||||||
// firstInfo.plateNumber = currentUserInfo?.plateNumber ?: ""
|
|
||||||
// MainActivity.start(
|
|
||||||
// context = context,
|
|
||||||
// pageType = PageType.BIND_PLATE,
|
|
||||||
// equipmentUserInfo = firstInfo
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理登录成功操作
|
|
||||||
* @param isAdmin true 管理员 执行绑盘此操作 false 用户,提示错误
|
|
||||||
*/
|
|
||||||
open fun handleLoginSuccess(equipmentUserInfo: EquipmentUserInfo, isAdmin: Boolean) {
|
|
||||||
// Timber.d("handleLoginSuccess isAdmin = $isAdmin")
|
|
||||||
// equipmentUserInfo.isIntercept = false
|
|
||||||
// val cardBalance = equipmentUserInfo.cardBalance ?: 0.toDouble()
|
|
||||||
// val balanceIsNotEnough = cardBalance <= 0.toDouble()
|
|
||||||
// if (balanceIsNotEnough && equipmentUserInfo.showBalanceNotEnoughDialog) {
|
|
||||||
// //提示余额不足弹窗
|
|
||||||
// equipmentUserInfo.isIntercept = true
|
|
||||||
// BalanceNotEnoughDialog(this).show()
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// viewModel.resetUserInfo()
|
|
||||||
//// if (equipmentUserInfo.isOtherEquipment()) {
|
|
||||||
//// MainActivity.start(
|
|
||||||
//// context,
|
|
||||||
//// pageType = PageType.PLATE_TIP,
|
|
||||||
//// equipmentUserInfo = equipmentUserInfo,
|
|
||||||
//// isAdmin
|
|
||||||
//// )
|
|
||||||
//// return
|
|
||||||
//// }
|
|
||||||
// if (equipmentUserInfo.equipmentBoxCode?.isNotEmpty() == true) {
|
|
||||||
// SerialApi.openPlate(
|
|
||||||
// equipmentUserInfo.equipmentBoxCode!!.toInt(),
|
|
||||||
// object : SerialPortManager.SendCallback {
|
|
||||||
// override fun onSuccess() {
|
|
||||||
// MainActivity.start(
|
|
||||||
// context,
|
|
||||||
// pageType = PageType.PLATE_TIP,
|
|
||||||
// isAdmin = isAdmin
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onFail(e: Exception?) {
|
|
||||||
// ToastUtils.showToast("柜门打开失败")
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// } else {
|
|
||||||
// if (isAdmin) {
|
|
||||||
// settingViewModel.getEquipmentList {
|
|
||||||
// loadEquipmentList(it)
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// Timber.d("无餐盘信息")
|
|
||||||
// MainActivity.start(
|
|
||||||
// context,
|
|
||||||
// pageType = PageType.PLATE_TIP,
|
|
||||||
// equipmentUserInfo = equipmentUserInfo,
|
|
||||||
// isAdmin = isAdmin
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
timeJob?.cancel()
|
timeJob?.cancel()
|
||||||
keyEventHelper?.onDestroy()
|
// keyEventHelper?.onDestroy()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,35 +308,19 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
private var faceTimestamp = 0L
|
private var faceTimestamp = 0L
|
||||||
|
|
||||||
//private var taskPageNo = 1
|
//private var taskPageNo = 1
|
||||||
private fun getFaceIncrementList(pageNo: Int = 1, action:(List<String?>)-> Unit) {
|
private fun getFaceIncrementList(pageNo: Int = 1, action: (List<String?>) -> Unit) {
|
||||||
val timestamp = SpTool.lastFaceTimestamp
|
val timestamp = SpTool.lastFaceTimestamp
|
||||||
// if (timestamp == 0L) {
|
userViewModel.getFaceIncrementList(
|
||||||
// return
|
|
||||||
// }
|
|
||||||
settingViewModel.getFaceIncrementList(
|
|
||||||
pageNo = pageNo,
|
pageNo = pageNo,
|
||||||
timestamp = timestamp
|
timestamp = timestamp
|
||||||
) { list ->
|
) { list ->
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (pageNo == 1 && list.isEmpty()) {
|
if (pageNo == 1 && list.isEmpty()) {
|
||||||
//未查询到增量数据
|
|
||||||
// Thread{
|
|
||||||
// val faceDao = FaceDatabase.getInstance(this).faceDao()
|
|
||||||
// if (faceDao.getFaceCount() == 0) {
|
|
||||||
// FaceEntity("-1", null, byteArrayOf(-1)).also { it.userType = "-1" }
|
|
||||||
// }
|
|
||||||
// }.start()
|
|
||||||
return@runOnUiThread
|
return@runOnUiThread
|
||||||
}
|
}
|
||||||
updateFaceData(list)
|
updateFaceData(list)
|
||||||
val userIdList = list.map { it.userId }
|
val userIdList = list.map { it.userId }
|
||||||
action(userIdList)
|
action(userIdList)
|
||||||
//if (list.size >= settingViewModel.PAGE_SIZE) {
|
|
||||||
// faceTimestamp = list.last().faceUpdateTimestamp ?: 0
|
|
||||||
// taskPageNo++
|
|
||||||
// getFaceIncrementList(taskPageNo)
|
|
||||||
// return@runOnUiThread
|
|
||||||
//}
|
|
||||||
if (list.isNotEmpty()) {
|
if (list.isNotEmpty()) {
|
||||||
faceTimestamp = list.last().faceUpdateTimestamp ?: 0
|
faceTimestamp = list.last().faceUpdateTimestamp ?: 0
|
||||||
}
|
}
|
||||||
@@ -467,7 +329,6 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public val recognizeViewModel by viewModels<RecognizeViewModel>()
|
|
||||||
private fun updateFaceData(list: List<UserFaceModel>) {
|
private fun updateFaceData(list: List<UserFaceModel>) {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val faceList = mutableListOf<FaceEntity>()
|
val faceList = mutableListOf<FaceEntity>()
|
||||||
@@ -477,18 +338,18 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
if (model.faceDeleted == true) {
|
if (model.faceDeleted == true) {
|
||||||
//删除数据
|
//删除数据
|
||||||
faceDao.deleteFaceById(model.userId)
|
faceDao.deleteFaceById(model.userId)
|
||||||
// if (faceDao.getFaceCount() == 0) {
|
|
||||||
// FaceEntity("-1", null, byteArrayOf(-1)).also { it.userType = "-1" }
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
// 获取该用户所有已存特征,判断当前特征是否已存在
|
// 获取该用户所有已存特征,判断当前特征是否已存在
|
||||||
val existList = faceDao.queryAllByUserName(model.userId)
|
val existList = faceDao.queryAllByUserName(model.userId)
|
||||||
val featureMatches = existList.map { Base64.encode(it.featureData) == model.faceFeatureStr }
|
val featureMatches =
|
||||||
|
existList.map { Base64.encode(it.featureData) == model.faceFeatureStr }
|
||||||
Timber.d("userId=${model.userId}, 已存记录数=${existList.size}, 各条特征是否与服务器一致=$featureMatches")
|
Timber.d("userId=${model.userId}, 已存记录数=${existList.size}, 各条特征是否与服务器一致=$featureMatches")
|
||||||
val alreadyExists = featureMatches.any { it }
|
val alreadyExists = featureMatches.any { it }
|
||||||
if (!alreadyExists) {
|
if (!alreadyExists) {
|
||||||
//当前特征不存在,保存
|
//当前特征不存在,保存
|
||||||
faceList.add(getNewFaceEntity(model))
|
runCatching { getNewFaceEntity(model) }
|
||||||
|
.onSuccess { faceList.add(it) }
|
||||||
|
.onFailure { Timber.e(it, "人脸特征解码失败: userId=${model.userId}") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -506,7 +367,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getNewFaceEntity(model: UserFaceModel) : FaceEntity {
|
private fun getNewFaceEntity(model: UserFaceModel): FaceEntity {
|
||||||
return FaceEntity(
|
return FaceEntity(
|
||||||
model.userId,
|
model.userId,
|
||||||
null,
|
null,
|
||||||
@@ -518,29 +379,41 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initPlateList() {
|
|
||||||
// SpTool.putString(SpTool.PLATE_BOX_DATA, "")
|
|
||||||
// var list = SpTool.getPlateData()
|
|
||||||
val list: MutableList<EquipmentUserInfo> = mutableListOf()
|
|
||||||
repeat(22) { index ->
|
|
||||||
list.add(
|
|
||||||
EquipmentUserInfo(equipmentBoxCode = "${index + 1}")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
MyApp.plateList = list
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearAllFace(block: () -> Unit) {
|
fun clearAllFace(block: () -> Unit) {
|
||||||
Thread {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val faceDao = FaceDatabase.getInstance(App.getContext()).faceDao()
|
val faceDao = FaceDatabase.getInstance(App.getContext()).faceDao()
|
||||||
faceDao.deleteAll()
|
faceDao.deleteAll()
|
||||||
faceDao.resetId()
|
faceDao.resetId()
|
||||||
// faceDao.insert(
|
|
||||||
// FaceEntity("-1", null, byteArrayOf(-1)).also { it.userType = "-1" }
|
|
||||||
// )
|
|
||||||
recognizeViewModel.refreshFaceList()
|
recognizeViewModel.refreshFaceList()
|
||||||
runOnUiThread { block() }
|
withContext(Dispatchers.Main) { block() }
|
||||||
}.start()
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var permissionCallback: ((isGranted: Boolean) -> Unit)? = null
|
||||||
|
private var activityCallback: ((intent: Intent?) -> Unit)? = null
|
||||||
|
|
||||||
|
fun requestPermission(permission: String, callback: (isGranted: Boolean) -> Unit) {
|
||||||
|
this.permissionCallback = callback
|
||||||
|
requestPermissionLauncher.launch(permission)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 权限请求回调
|
||||||
|
val requestPermissionLauncher = registerForActivityResult(
|
||||||
|
ActivityResultContracts.RequestPermission()
|
||||||
|
) { isGranted ->
|
||||||
|
permissionCallback?.invoke(isGranted)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun startActivity(intent: Intent, callback: (Intent?) -> Unit) {
|
||||||
|
this.activityCallback = callback
|
||||||
|
startActivityLauncher.launch(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
// activity页面返回的回调
|
||||||
|
private val startActivityLauncher = registerForActivityResult(
|
||||||
|
ActivityResultContracts.StartActivityForResult()
|
||||||
|
) {
|
||||||
|
activityCallback?.invoke(it.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,26 +26,6 @@ class DeviceInitActivity : BaseActivity<ActivityDeviceInitBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun initialize() {
|
override fun initialize() {
|
||||||
// val isSuccess = deviceViewModel.checkEquipmentInfo()
|
|
||||||
// if (isSuccess) {
|
|
||||||
// goLoginActivity()
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// binding.ivQrCode.setImageBitmap(
|
|
||||||
// QRCodeUtil.generateQRCode(
|
|
||||||
// content = GlobalData.deviceId,
|
|
||||||
// size = 200
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// binding.btnInit.setOnClickListener {
|
|
||||||
// deviceViewModel.getDeviceToken()
|
|
||||||
// }
|
|
||||||
// binding.btnInit.gone()
|
|
||||||
// binding.ivQrCode.invisible()
|
|
||||||
// binding.root.postDelayed({
|
|
||||||
// goLoginActivity()
|
|
||||||
// }, 1000)
|
|
||||||
initPlateList()
|
|
||||||
showWaitingDialog("加载中……")
|
showWaitingDialog("加载中……")
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
|
|||||||
@@ -1,152 +1,152 @@
|
|||||||
package com.sw.platecabinet.activity
|
//package com.sw.platecabinet.activity
|
||||||
|
//
|
||||||
import androidx.activity.viewModels
|
//import androidx.activity.viewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
//import androidx.lifecycle.lifecycleScope
|
||||||
import com.sw.plate.utils.Base64
|
//import com.sw.plate.utils.Base64
|
||||||
import com.sw.plate.utils.ToastUtils
|
//import com.sw.plate.utils.ToastUtils
|
||||||
import com.sw.plate.utils.arcface.facedb.FaceDatabase
|
//import com.sw.plate.utils.arcface.facedb.FaceDatabase
|
||||||
import com.sw.platecabinet.MyApp
|
//import com.sw.platecabinet.MyApp
|
||||||
import com.sw.platecabinet.databinding.ActivityFunBinding
|
//import com.sw.platecabinet.databinding.ActivityFunBinding
|
||||||
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
//import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
||||||
import com.sw.platecabinet.dialog.CustomDialog
|
//import com.sw.platecabinet.dialog.CustomDialog
|
||||||
import com.sw.platecabinet.ext.clickWithDebounce
|
//import com.sw.platecabinet.ext.clickWithDebounce
|
||||||
import com.sw.platecabinet.utils.PlateUtils
|
//import com.sw.platecabinet.utils.PlateUtils
|
||||||
import com.sw.platecabinet.utils.SpTool
|
//import com.sw.platecabinet.utils.SpTool
|
||||||
import com.sw.platecabinet.viewmodel.UserViewModel
|
//import com.sw.platecabinet.viewmodel.UserViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
//import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
//import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
//import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
//import kotlinx.coroutines.withContext
|
||||||
import kotlin.getValue
|
//import kotlin.getValue
|
||||||
|
//
|
||||||
class FunActivity : BaseActivity<ActivityFunBinding>() {
|
//class FunActivity : BaseActivity<ActivityFunBinding>() {
|
||||||
|
//
|
||||||
override fun inflateTitleBinding(): ItemTitleTimeBinding? {
|
// override fun inflateTitleBinding(): ItemTitleTimeBinding? {
|
||||||
return binding.includeHeader
|
// return binding.includeHeader
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun inflateViewBinding() = ActivityFunBinding.inflate(layoutInflater)
|
// override fun inflateViewBinding() = ActivityFunBinding.inflate(layoutInflater)
|
||||||
|
//
|
||||||
override fun initialize() {
|
// override fun initialize() {
|
||||||
binding.btnClearFace.clickWithDebounce { clearFace() }
|
// binding.btnClearFace.clickWithDebounce { clearFace() }
|
||||||
binding.btnClearAndGetAll.clickWithDebounce { clearFaceAndGetAll() }
|
// binding.btnClearAndGetAll.clickWithDebounce { clearFaceAndGetAll() }
|
||||||
binding.btnOpenAllPlate.clickWithDebounce {
|
// binding.btnOpenAllPlate.clickWithDebounce {
|
||||||
lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
openAllPlate()
|
// openAllPlate()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
binding.btnPutPlate.clickWithDebounce { putPlate() }
|
// binding.btnPutPlate.clickWithDebounce { putPlate() }
|
||||||
|
//
|
||||||
queryUserCount()
|
// queryUserCount()
|
||||||
|
//
|
||||||
binding.btnTestFeature.clickWithDebounce {
|
// binding.btnTestFeature.clickWithDebounce {
|
||||||
testFeature()
|
// testFeature()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
private fun testFeature() {
|
// private fun testFeature() {
|
||||||
userViewModel.getUserFace(1, 1) {list ->
|
// userViewModel.getUserFace(1, 1) {list ->
|
||||||
lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
withContext(Dispatchers.IO) {
|
// withContext(Dispatchers.IO) {
|
||||||
if (list.isEmpty()) return@withContext
|
// if (list.isEmpty()) return@withContext
|
||||||
val userId = list[0].userId
|
// val userId = list[0].userId
|
||||||
val base64Feature = list[0].faceFeatureStr
|
// val base64Feature = list[0].faceFeatureStr
|
||||||
val faceDao = FaceDatabase.getInstance(this@FunActivity).faceDao()
|
// val faceDao = FaceDatabase.getInstance(this@FunActivity).faceDao()
|
||||||
val entityList = faceDao.queryAllByUserName(userId)
|
// val entityList = faceDao.queryAllByUserName(userId)
|
||||||
val resultList = entityList.map { base64Feature == Base64.encode(it.featureData) }
|
// val resultList = entityList.map { base64Feature == Base64.encode(it.featureData) }
|
||||||
val isEqual = resultList.any { true }
|
// val isEqual = resultList.any { true }
|
||||||
ToastUtils.showToast("比较结果:$isEqual")
|
// ToastUtils.showToast("比较结果:$isEqual")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun clearFace() {
|
// private fun clearFace() {
|
||||||
loadClearDialog("请确认是否清除本地所有数据?") {
|
// loadClearDialog("请确认是否清除本地所有数据?") {
|
||||||
showWaitingDialog("加载中……")
|
// showWaitingDialog("加载中……")
|
||||||
clearAllFace {
|
// clearAllFace {
|
||||||
binding.root.postDelayed(
|
// binding.root.postDelayed(
|
||||||
{
|
// {
|
||||||
hideWaitingDialog()
|
// hideWaitingDialog()
|
||||||
ToastUtils.showToast("已清除")
|
// ToastUtils.showToast("已清除")
|
||||||
queryUserCount()
|
// queryUserCount()
|
||||||
}, 500
|
// }, 500
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun clearFaceAndGetAll() {
|
// private fun clearFaceAndGetAll() {
|
||||||
loadClearDialog("请确认是否清除本地所有数据,并重新拉取全量人脸数据?") {
|
// loadClearDialog("请确认是否清除本地所有数据,并重新拉取全量人脸数据?") {
|
||||||
showWaitingDialog("加载中……")
|
// showWaitingDialog("加载中……")
|
||||||
clearAllFace {
|
// clearAllFace {
|
||||||
userViewModel.getUserFaceCache { status, msg ->
|
// userViewModel.getUserFaceCache { status, msg ->
|
||||||
hideWaitingDialog()
|
// hideWaitingDialog()
|
||||||
ToastUtils.showToast(
|
// ToastUtils.showToast(
|
||||||
if (status) "请求成功,$msg" else "请求失败,$msg"
|
// if (status) "请求成功,$msg" else "请求失败,$msg"
|
||||||
)
|
// )
|
||||||
queryUserCount()
|
// queryUserCount()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private suspend fun openAllPlate() {
|
// private suspend fun openAllPlate() {
|
||||||
MyApp.plateList?.let { plateList ->
|
// MyApp.plateList?.let { plateList ->
|
||||||
val boxCodeList = plateList.filter { it.equipmentBoxCode.isNullOrBlank().not() }
|
// val boxCodeList = plateList.filter { it.equipmentBoxCode.isNullOrBlank().not() }
|
||||||
.map { it.equipmentBoxCode }
|
// .map { it.equipmentBoxCode }
|
||||||
boxCodeList.forEach { boxCode ->
|
// boxCodeList.forEach { boxCode ->
|
||||||
withContext(Dispatchers.Default) {
|
// withContext(Dispatchers.Default) {
|
||||||
PlateUtils.openDirect(boxCode)
|
// PlateUtils.openDirect(boxCode)
|
||||||
delay(500)
|
// delay(500)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun putPlate() {
|
// private fun putPlate() {
|
||||||
showWaitingDialog("加载中……")
|
// showWaitingDialog("加载中……")
|
||||||
MyApp.plateList?.forEachIndexed { index, item ->
|
// MyApp.plateList?.forEachIndexed { index, item ->
|
||||||
val num = index + 1
|
// val num = index + 1
|
||||||
val realNum = if (num < 10) "0${num}" else "${num}"
|
// val realNum = if (num < 10) "0${num}" else "${num}"
|
||||||
item.plateNumber = realNum + realNum + realNum
|
// item.plateNumber = realNum + realNum + realNum
|
||||||
item.faceId = null
|
// item.faceId = null
|
||||||
item.updateTime = null
|
// item.updateTime = null
|
||||||
}
|
// }
|
||||||
SpTool.savePlateData(MyApp.plateList!!)
|
// SpTool.savePlateData(MyApp.plateList!!)
|
||||||
binding.root.postDelayed({
|
// binding.root.postDelayed({
|
||||||
hideWaitingDialog()
|
// hideWaitingDialog()
|
||||||
ToastUtils.showToast("已完成")
|
// ToastUtils.showToast("已完成")
|
||||||
}, 1000)
|
// }, 1000)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 加载清除数据弹窗
|
// * 加载清除数据弹窗
|
||||||
*/
|
// */
|
||||||
private fun loadClearDialog(msg: String, callback: () -> Unit) {
|
// private fun loadClearDialog(msg: String, callback: () -> Unit) {
|
||||||
CustomDialog(
|
// CustomDialog(
|
||||||
activity = this,
|
// activity = this,
|
||||||
content = msg,
|
// content = msg,
|
||||||
onConfirm = {
|
// onConfirm = {
|
||||||
callback()
|
// callback()
|
||||||
}).show()
|
// }).show()
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onLeftDoubleClick() {
|
// override fun onLeftDoubleClick() {
|
||||||
finish()
|
// finish()
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onRightDoubleClick() {
|
// override fun onRightDoubleClick() {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun queryUserCount() {
|
// private fun queryUserCount() {
|
||||||
lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
val faceDao = FaceDatabase.getInstance(this@FunActivity).faceDao()
|
// val faceDao = FaceDatabase.getInstance(this@FunActivity).faceDao()
|
||||||
val memberUserCount = withContext(Dispatchers.IO) { faceDao.getFaceCount("1") }
|
// val memberUserCount = withContext(Dispatchers.IO) { faceDao.getFaceCount("1") }
|
||||||
val tempUserCount = withContext(Dispatchers.IO) { faceDao.getFaceCount("2") }
|
// val tempUserCount = withContext(Dispatchers.IO) { faceDao.getFaceCount("2") }
|
||||||
binding.tvMemberUserCount.text = "会员用户:${memberUserCount}人"
|
// binding.tvMemberUserCount.text = "会员用户:${memberUserCount}人"
|
||||||
binding.tvTempUserCount.text = "临时用户:${tempUserCount}人"
|
// binding.tvTempUserCount.text = "临时用户:${tempUserCount}人"
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
@@ -41,4 +41,8 @@ class InitActivity : BaseActivity<ActivityInitBinding>() {
|
|||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onRightDoubleClick() {
|
||||||
|
PlcSettingActivity.start(this)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,12 +7,15 @@ import android.content.Intent
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Point
|
import android.graphics.Point
|
||||||
import android.hardware.Camera
|
import android.hardware.Camera
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.DisplayMetrics
|
import android.provider.Settings
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
|
import android.widget.FrameLayout
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.arcsoft.face.ErrorInfo
|
import com.arcsoft.face.ErrorInfo
|
||||||
@@ -39,24 +42,23 @@ import com.sw.plate.utils.arcface.facedb.entity.FaceEntity
|
|||||||
import com.sw.plate.utils.arcface.model.UserFaceInfo
|
import com.sw.plate.utils.arcface.model.UserFaceInfo
|
||||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel.REGISTER_STATUS_READY
|
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel.REGISTER_STATUS_READY
|
||||||
import com.sw.platecabinet.MyApp
|
|
||||||
import com.sw.platecabinet.R
|
import com.sw.platecabinet.R
|
||||||
import com.sw.platecabinet.databinding.ActivityLoginFaceBinding
|
import com.sw.platecabinet.databinding.ActivityLoginFaceBinding
|
||||||
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
||||||
|
import com.sw.platecabinet.dialog.CustomDialog
|
||||||
import com.sw.platecabinet.ext.clickWithDebounce
|
import com.sw.platecabinet.ext.clickWithDebounce
|
||||||
import com.sw.platecabinet.ext.gone
|
import com.sw.platecabinet.ext.gone
|
||||||
import com.sw.platecabinet.ext.visible
|
import com.sw.platecabinet.ext.visible
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
import com.sw.platecabinet.model.response.UserFaceModel
|
import com.sw.platecabinet.model.response.UserFaceModel
|
||||||
import com.sw.platecabinet.utils.BitmapSaver
|
import com.sw.platecabinet.utils.BitmapSaver
|
||||||
import com.sw.platecabinet.utils.CountDownUtil
|
import com.sw.platecabinet.utils.CountDownUtil
|
||||||
import com.sw.platecabinet.utils.Debouncer
|
import com.sw.platecabinet.utils.Debouncer
|
||||||
import com.sw.platecabinet.utils.LogFileUtil
|
import com.sw.platecabinet.utils.LogFileUtil
|
||||||
import com.sw.platecabinet.utils.PermissionHelper
|
|
||||||
import com.sw.platecabinet.utils.PlateUtils
|
|
||||||
import com.sw.platecabinet.utils.RegisterCallbackHandler
|
import com.sw.platecabinet.utils.RegisterCallbackHandler
|
||||||
import com.sw.platecabinet.utils.SoundPoolUtil
|
import com.sw.platecabinet.utils.SoundPoolUtil
|
||||||
import com.sw.platecabinet.utils.SpTool
|
import com.sw.platecabinet.utils.mego.PlcCallback
|
||||||
|
import com.sw.platecabinet.utils.mego.PlcHelper
|
||||||
|
import com.sw.platecabinet.utils.mego.PlcStatus
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@@ -73,13 +75,6 @@ import java.util.concurrent.atomic.AtomicBoolean
|
|||||||
class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
||||||
ViewTreeObserver.OnGlobalLayoutListener {
|
ViewTreeObserver.OnGlobalLayoutListener {
|
||||||
|
|
||||||
private val CAMERA_PERMISSION_REQUEST_CODE = 100
|
|
||||||
private val REQUIRED_PERMISSIONS: Array<String> = arrayOf(
|
|
||||||
Manifest.permission.CAMERA,
|
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun inflateViewBinding(): ActivityLoginFaceBinding {
|
override fun inflateViewBinding(): ActivityLoginFaceBinding {
|
||||||
return ActivityLoginFaceBinding.inflate(layoutInflater)
|
return ActivityLoginFaceBinding.inflate(layoutInflater)
|
||||||
}
|
}
|
||||||
@@ -99,6 +94,17 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
override fun initialize() {
|
override fun initialize() {
|
||||||
userViewModel.activeEngine()
|
userViewModel.activeEngine()
|
||||||
|
|
||||||
|
PlcHelper.getInstance(this@LoginByFaceActivity)
|
||||||
|
.openSerialPort(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
ToastUtils.showToast("打开串口 → 成功: ${result}")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
ToastUtils.showToast("打开串口 → 失败: $message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
initArcViewModel()
|
initArcViewModel()
|
||||||
initArcView()
|
initArcView()
|
||||||
openRectInfoDraw = true
|
openRectInfoDraw = true
|
||||||
@@ -132,22 +138,53 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
resetRecognizeState()
|
resetRecognizeState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 检查相机权限
|
||||||
|
|
||||||
private fun checkCameraPermission() {
|
private fun checkCameraPermission() {
|
||||||
Timber.i("checkCameraPermission")
|
Timber.i("checkCameraPermission")
|
||||||
val permissionHelper =
|
val hasCameraPermission = ContextCompat.checkSelfPermission(
|
||||||
PermissionHelper.with(this, REQUIRED_PERMISSIONS, CAMERA_PERMISSION_REQUEST_CODE)
|
this,
|
||||||
.onGranted {
|
Manifest.permission.CAMERA
|
||||||
loadLogInfo("checkCameraPermission 权限已允许")
|
) == android.content.pm.PackageManager.PERMISSION_GRANTED
|
||||||
// 权限已授予
|
|
||||||
recognizeViewModel.init()
|
if (hasCameraPermission) {
|
||||||
initRgbCamera()
|
// 权限已授予
|
||||||
resumeCamera()
|
loadLogInfo("checkCameraPermission 权限已允许")
|
||||||
}
|
recognizeViewModel.init()
|
||||||
.build()
|
initRgbCamera()
|
||||||
registerPermissionHelper(permissionHelper)
|
resumeCamera()
|
||||||
permissionHelper.checkAndRequest()
|
} else {
|
||||||
|
// 无权限,请求相机权限
|
||||||
|
requestCameraPermission()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun requestCameraPermission() {
|
||||||
|
requestPermission(Manifest.permission.CAMERA) { isGranted ->
|
||||||
|
if (isGranted) {
|
||||||
|
// 权限已授予
|
||||||
|
loadLogInfo("checkCameraPermission 权限已允许")
|
||||||
|
recognizeViewModel.init()
|
||||||
|
initRgbCamera()
|
||||||
|
resumeCamera()
|
||||||
|
} else {
|
||||||
|
// 权限被拒绝
|
||||||
|
loadLogInfo("checkCameraPermission 权限被拒绝")
|
||||||
|
CustomDialog(
|
||||||
|
activity = this,
|
||||||
|
content = "请在设置中开启相机权限",
|
||||||
|
onConfirm = {
|
||||||
|
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
|
||||||
|
data = Uri.fromParts("package", context.packageName, null)
|
||||||
|
}
|
||||||
|
startActivity(intent) {
|
||||||
|
checkCameraPermission()
|
||||||
|
}
|
||||||
|
}, onCancel = {
|
||||||
|
|
||||||
|
}).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
@@ -161,6 +198,10 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onRightDoubleClick() {
|
||||||
|
PlcSettingActivity.start(this)
|
||||||
|
}
|
||||||
|
|
||||||
private var isRecognition = false
|
private var isRecognition = false
|
||||||
private var rgbCameraHelper: DualCameraHelper? = null
|
private var rgbCameraHelper: DualCameraHelper? = null
|
||||||
private var rgbFaceRectTransformer: FaceRectTransformer? = null
|
private var rgbFaceRectTransformer: FaceRectTransformer? = null
|
||||||
@@ -180,6 +221,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
private fun isFitData(userFaceInfo: UserFaceInfo?): Boolean {
|
private fun isFitData(userFaceInfo: UserFaceInfo?): Boolean {
|
||||||
if (userFaceInfo == null) return false
|
if (userFaceInfo == null) return false
|
||||||
val headBmp = userFaceInfo.headBmp
|
val headBmp = userFaceInfo.headBmp
|
||||||
|
loadLogInfo("collectFace,isFitData:w=${headBmp?.width},height=${headBmp?.height}")
|
||||||
if (headBmp == null) return false
|
if (headBmp == null) return false
|
||||||
// if (headBmp.width <= 200 || headBmp.height <= 200) {
|
// if (headBmp.width <= 200 || headBmp.height <= 200) {
|
||||||
// loadLogInfo("collectFace,isFitData:拿到人脸提取特征数据照片过小-----------")
|
// loadLogInfo("collectFace,isFitData:拿到人脸提取特征数据照片过小-----------")
|
||||||
@@ -193,11 +235,17 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
recognizeViewModel.prepareRegister()
|
recognizeViewModel.prepareRegister()
|
||||||
recognizeViewModel.setOnRegisterFinishedCallback { facePreviewInfo, userFaceInfo ->
|
recognizeViewModel.setOnRegisterFinishedCallback { facePreviewInfo, userFaceInfo ->
|
||||||
registerHandler?.setCallback {
|
registerHandler?.setCallback {
|
||||||
|
loadLogInfo("collectFace,registerHandler?.setCallback")
|
||||||
if (!isCollectFace || !isCollecting.get()) {
|
if (!isCollectFace || !isCollecting.get()) {
|
||||||
|
loadLogInfo("collectFace,isCollectFace=${isCollectFace},isCollecting=${isCollecting.get()}")
|
||||||
return@setCallback
|
return@setCallback
|
||||||
}
|
}
|
||||||
|
loadLogInfo("collectFace,userFaceInfo==null:${userFaceInfo==null}")
|
||||||
if (this.userFaceInfo == null && isFitData(userFaceInfo)) {
|
if (this.userFaceInfo == null && isFitData(userFaceInfo)) {
|
||||||
val headBmp = userFaceInfo.headBmp
|
val headBmp = userFaceInfo.headBmp ?: run {
|
||||||
|
loadLogInfo("collectFace,isFitData:headBmp 为 null,跳过")
|
||||||
|
return@setCallback
|
||||||
|
}
|
||||||
if (headBmp.width <= 200 || headBmp.height <= 200) {
|
if (headBmp.width <= 200 || headBmp.height <= 200) {
|
||||||
loadLogInfo("collectFace,isFitData:拿到人脸提取特征数据照片过小w:${headBmp.width},h:${headBmp.height}-----------")
|
loadLogInfo("collectFace,isFitData:拿到人脸提取特征数据照片过小w:${headBmp.width},h:${headBmp.height}-----------")
|
||||||
binding.llCollectButton.visible()
|
binding.llCollectButton.visible()
|
||||||
@@ -212,30 +260,30 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
recognizeViewModel.ftInitCode.observe(this) { ftInitCode: Int? ->
|
recognizeViewModel.ftInitCode.observe(this) { ftInitCode: Int? ->
|
||||||
if (ftInitCode != ErrorInfo.MOK) {
|
if (ftInitCode != null && ftInitCode != ErrorInfo.MOK) {
|
||||||
val error: String? = getString(
|
val error: String? = getString(
|
||||||
R.string.specific_engine_init_failed, "ftEngine",
|
R.string.specific_engine_init_failed, "ftEngine",
|
||||||
ftInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(ftInitCode!!)
|
ftInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(ftInitCode)
|
||||||
)
|
)
|
||||||
Timber.e("ftInitCode observe = $error")
|
Timber.e("ftInitCode observe = $error")
|
||||||
ToastUtils.showToast(error)
|
ToastUtils.showToast(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recognizeViewModel.frInitCode.observe(this) { frInitCode: Int? ->
|
recognizeViewModel.frInitCode.observe(this) { frInitCode: Int? ->
|
||||||
if (frInitCode != ErrorInfo.MOK) {
|
if (frInitCode != null && frInitCode != ErrorInfo.MOK) {
|
||||||
val error: String? = getString(
|
val error: String? = getString(
|
||||||
R.string.specific_engine_init_failed, "frEngine",
|
R.string.specific_engine_init_failed, "frEngine",
|
||||||
frInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(frInitCode!!)
|
frInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(frInitCode)
|
||||||
)
|
)
|
||||||
Timber.e("frInitCode observe = $error")
|
Timber.e("frInitCode observe = $error")
|
||||||
ToastUtils.showToast(error)
|
ToastUtils.showToast(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recognizeViewModel.flInitCode.observe(this) { flInitCode: Int? ->
|
recognizeViewModel.flInitCode.observe(this) { flInitCode: Int? ->
|
||||||
if (flInitCode != ErrorInfo.MOK) {
|
if (flInitCode != null && flInitCode != ErrorInfo.MOK) {
|
||||||
val error: String? = getString(
|
val error: String? = getString(
|
||||||
R.string.specific_engine_init_failed, "flEngine",
|
R.string.specific_engine_init_failed, "flEngine",
|
||||||
flInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(flInitCode!!)
|
flInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(flInitCode)
|
||||||
)
|
)
|
||||||
Timber.e("flInitCode observe = $error")
|
Timber.e("flInitCode observe = $error")
|
||||||
ToastUtils.showToast(error)
|
ToastUtils.showToast(error)
|
||||||
@@ -251,7 +299,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
recognizeViewModel.recognizeUserId.observe(this) { result: CompareResult? ->
|
recognizeViewModel.recognizeUserId.observe(this) { result: CompareResult? ->
|
||||||
loadLogInfo("collectFace,recognizeUserId observe userId = ${result?.faceEntity?.userName}")
|
loadLogInfo("collectFace,recognizeUserId observe userId=${result?.faceEntity?.userName},similar=${result?.similar},userType=${result?.faceEntity?.userType}")
|
||||||
loadFaceRecognizeResult3(result)
|
loadFaceRecognizeResult3(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +323,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
*/
|
*/
|
||||||
private val faceSuccessThreshold by lazy { ConfigUtil.getRecognizeThreshold(this) }
|
private val faceSuccessThreshold by lazy { ConfigUtil.getRecognizeThreshold(this) }
|
||||||
|
|
||||||
private val openPlateDebouncer = Debouncer(5000)
|
private val openPlateDebouncer = Debouncer(3000)
|
||||||
private val isCollecting = AtomicBoolean(false)
|
private val isCollecting = AtomicBoolean(false)
|
||||||
|
|
||||||
private fun loadFaceRecognizeResult3(result: CompareResult?) {
|
private fun loadFaceRecognizeResult3(result: CompareResult?) {
|
||||||
@@ -319,11 +367,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
loadLogInfo("collectFace,recognizeUserId 识别成功但 userId 为空,忽略")
|
loadLogInfo("collectFace,recognizeUserId 识别成功但 userId 为空,忽略")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
loadLogInfo("collectFace,recognizeUserId 识别成功 userId=$userId, time=${DateTimeUtils.getDateTimeString()}")
|
||||||
loadLogInfo(
|
|
||||||
"collectFace,recognizeUserId 识别成功 userId=$userId, time=${DateTimeUtils.getDateTimeString()}"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 成功后必须重置状态
|
// 成功后必须重置状态
|
||||||
retryFailCount = 0
|
retryFailCount = 0
|
||||||
isCollecting.set(false)
|
isCollecting.set(false)
|
||||||
@@ -331,7 +375,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
currentUserId = userId
|
currentUserId = userId
|
||||||
|
|
||||||
// 防抖,防止重复开闸
|
// 防抖,防止重复开闸
|
||||||
openPlateDebouncer.debounce {
|
openPlateDebouncer.debounce("openPlateDebouncer") {
|
||||||
openPlate(userId)
|
openPlate(userId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,61 +404,73 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
text = "新用户采集"
|
text = "新用户采集"
|
||||||
}
|
}
|
||||||
binding.ivCollectPhoto.gone()
|
binding.ivCollectPhoto.gone()
|
||||||
|
openPlateDebouncer.reset()
|
||||||
|
plateEnable = true
|
||||||
resumeCamera()
|
resumeCamera()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询餐盘数据
|
|
||||||
*/
|
|
||||||
private fun getPlateData(block: (List<EquipmentUserInfo>) -> Unit) {
|
|
||||||
MyApp.plateList?.let {
|
|
||||||
block(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var currentPlateInfo: EquipmentUserInfo? = null
|
|
||||||
private var plateEnable = false
|
private var plateEnable = false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开餐盘柜
|
* 打开餐盘柜:执行出盘,出盘后查询剩余餐盘状态并播放对应提示音
|
||||||
*/
|
*/
|
||||||
private fun openPlate(userId: String?) {
|
private fun openPlate(userId: String?) {
|
||||||
|
loadLogInfo("collectFace,openPlate: userId=$userId,plateEnable=$plateEnable")
|
||||||
if (plateEnable.not()) return
|
if (plateEnable.not()) return
|
||||||
loadLogInfo("collectFace,openPlate: userId=$userId")
|
|
||||||
getPlateData { items ->
|
PlcHelper.getInstance(this@LoginByFaceActivity)
|
||||||
loadLogInfo("collectFace,openPlate: items:${Gson().toJson(items)}")
|
.outPlate(object : PlcCallback<String> {
|
||||||
// 未查询到当前用户,查询第一个未绑定的餐盘
|
override fun onSuccess(result: String) {
|
||||||
val item = items.firstOrNull { it.plateNumber.isNullOrEmpty().not() }
|
plateEnable = false
|
||||||
loadLogInfo("collectFace,openPlate: item2:${item}")
|
recognizeCountDownUtil.cancelCountDown()
|
||||||
if (item == null) {
|
// result 为 false 时表示出盘后无餐盘,直接播放无盘提示音
|
||||||
//暂无餐盘
|
if (result.equals("false", ignoreCase = true)) {
|
||||||
loadLogInfo("collectFace,openPlate: 暂无餐盘,请联系管理人员,isCollectFace=$isCollectFace")
|
loadLogInfo("collectFace,openPlate: result=false,餐盘已空")
|
||||||
//ToastUtils.showToast("暂无餐盘,请联系管理人员")
|
SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0)
|
||||||
SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0)
|
goInitActivity()
|
||||||
goInitActivity()
|
return
|
||||||
return@getPlateData
|
}
|
||||||
}
|
loadLogInfo("collectFace,openPlate: 出盘完成,result=$result,开始查询剩余餐盘")
|
||||||
// if (tempUserId != currentUserId) {
|
// result 为 true,出盘成功,再查询是否还有剩余餐盘
|
||||||
SoundPoolUtil.getInstance().play(RECOGNIZE_SUCCESS, 0)
|
SoundPoolUtil.getInstance().play(RECOGNIZE_SUCCESS, 0)
|
||||||
// } else {
|
checkRemainingPlate()
|
||||||
// SoundPoolUtil.getInstance().play(COLLECT_SUCCESS, 0)
|
}
|
||||||
// }
|
|
||||||
loadLogInfo("collectFace,openPlate: item3:${item}")
|
override fun onError(message: String) {
|
||||||
item.faceId = userId
|
ToastUtils.showToast("出盘失败,message=$message")
|
||||||
item.updateTime = DateTimeUtils.getDateTimeString()
|
loadLogInfo("collectFace,openPlate: 出盘失败,message=$message")
|
||||||
item.plateNumber = null
|
|
||||||
plateEnable = false
|
|
||||||
openDebouncer.debounce {
|
|
||||||
//打开柜子
|
|
||||||
PlateUtils.open(this, item.equipmentBoxCode, false) {
|
|
||||||
goInitActivity()
|
goInitActivity()
|
||||||
}
|
}
|
||||||
recognizeCountDownUtil.cancelCountDown()
|
})
|
||||||
}
|
}
|
||||||
currentPlateInfo = item
|
|
||||||
MyApp.plateList = items
|
/**
|
||||||
SpTool.savePlateData(items)
|
* 出盘成功后查询剩余餐盘状态,无盘则播放提示音
|
||||||
}
|
*/
|
||||||
|
private fun checkRemainingPlate() {
|
||||||
|
PlcHelper.getInstance(this@LoginByFaceActivity)
|
||||||
|
.getStatus(object : PlcCallback<PlcStatus> {
|
||||||
|
override fun onSuccess(result: PlcStatus) {
|
||||||
|
if (isFinishing || isDestroyed) return
|
||||||
|
loadLogInfo("collectFace,checkRemainingPlate: isEmptyPlate=${result.isEmptyPlate}")
|
||||||
|
if (result.isEmptyPlate) {
|
||||||
|
// 餐盘已空,播放无盘提示音
|
||||||
|
SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0)
|
||||||
|
//跳转到餐盘设置页面
|
||||||
|
PlcSettingActivity.start(this@LoginByFaceActivity, showTips = true)
|
||||||
|
} else {
|
||||||
|
loadLogInfo("collectFace,checkRemainingPlate: 剩余餐盘,继续使用")
|
||||||
|
goInitActivity()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
if (isFinishing || isDestroyed) return
|
||||||
|
// 状态查询失败,不影响主流程,直接跳转
|
||||||
|
loadLogInfo("collectFace,checkRemainingPlate: 获取PLC状态失败,message=$message")
|
||||||
|
goInitActivity()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private val openDebouncer by lazy { Debouncer(5000) }
|
private val openDebouncer by lazy { Debouncer(5000) }
|
||||||
@@ -433,6 +489,8 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
|
|
||||||
recognizeViewModel.destroy()
|
recognizeViewModel.destroy()
|
||||||
|
|
||||||
|
PlcHelper.getInstance(this@LoginByFaceActivity).release()
|
||||||
|
|
||||||
EventBus.getDefault().unregister(this)
|
EventBus.getDefault().unregister(this)
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
@@ -457,43 +515,45 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
displayOrientation: Int,
|
displayOrientation: Int,
|
||||||
scale: Float
|
scale: Float
|
||||||
): ViewGroup.LayoutParams {
|
): ViewGroup.LayoutParams {
|
||||||
val layoutParams = previewView.layoutParams
|
// val layoutParams = previewView.layoutParams
|
||||||
val measuredWidth = previewView.measuredWidth
|
// val measuredWidth = previewView.measuredWidth
|
||||||
val measuredHeight = previewView.measuredHeight
|
// val measuredHeight = previewView.measuredHeight
|
||||||
var ratio = (previewSize.height.toFloat()) / previewSize.width.toFloat()
|
// var ratio = (previewSize.height.toFloat()) / previewSize.width.toFloat()
|
||||||
if (ratio > 1) {
|
// if (ratio > 1) {
|
||||||
ratio = 1 / ratio
|
// ratio = 1 / ratio
|
||||||
}
|
// }
|
||||||
if (displayOrientation % 180 == 0) {
|
// if (displayOrientation % 180 == 0) {
|
||||||
layoutParams.width = measuredWidth
|
// layoutParams.width = measuredWidth
|
||||||
layoutParams.height = (measuredWidth * ratio).toInt()
|
// layoutParams.height = (measuredWidth * ratio).toInt()
|
||||||
} else {
|
// } else {
|
||||||
layoutParams.height = measuredHeight
|
// layoutParams.height = measuredHeight
|
||||||
layoutParams.width = (measuredHeight * ratio).toInt()
|
// layoutParams.width = (measuredHeight * ratio).toInt()
|
||||||
}
|
// }
|
||||||
if (scale < 1f) {
|
// if (scale < 1f) {
|
||||||
val rgbParam = rgbPreview.layoutParams
|
// val rgbParam = rgbPreview.layoutParams
|
||||||
layoutParams.width = (rgbParam.width * scale).toInt()
|
// layoutParams.width = (rgbParam.width * scale).toInt()
|
||||||
layoutParams.height = (rgbParam.height * scale).toInt()
|
// layoutParams.height = (rgbParam.height * scale).toInt()
|
||||||
} else {
|
// } else {
|
||||||
layoutParams.width = (layoutParams.width * scale).toInt()
|
// layoutParams.width = (layoutParams.width * scale).toInt()
|
||||||
layoutParams.height = (layoutParams.height * scale).toInt()
|
// layoutParams.height = (layoutParams.height * scale).toInt()
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
val metrics = DisplayMetrics()
|
// val metrics = DisplayMetrics()
|
||||||
windowManager.defaultDisplay.getMetrics(metrics)
|
// windowManager.defaultDisplay.getMetrics(metrics)
|
||||||
|
//
|
||||||
if (layoutParams.width >= metrics.widthPixels) {
|
// if (layoutParams.width >= metrics.widthPixels) {
|
||||||
val viewRatio = layoutParams.width / (metrics.widthPixels.toFloat())
|
// val viewRatio = layoutParams.width / (metrics.widthPixels.toFloat())
|
||||||
layoutParams.width = (layoutParams.width / viewRatio).toInt()
|
// layoutParams.width = (layoutParams.width / viewRatio).toInt()
|
||||||
layoutParams.height = (layoutParams.height / viewRatio).toInt()
|
// layoutParams.height = (layoutParams.height / viewRatio).toInt()
|
||||||
}
|
// }
|
||||||
if (layoutParams.height >= metrics.heightPixels) {
|
// if (layoutParams.height >= metrics.heightPixels) {
|
||||||
val viewRatio = layoutParams.height / (metrics.heightPixels.toFloat())
|
// val viewRatio = layoutParams.height / (metrics.heightPixels.toFloat())
|
||||||
layoutParams.width = (layoutParams.width / viewRatio).toInt()
|
// layoutParams.width = (layoutParams.width / viewRatio).toInt()
|
||||||
layoutParams.height = (layoutParams.height / viewRatio).toInt()
|
// layoutParams.height = (layoutParams.height / viewRatio).toInt()
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
val layoutParams = FrameLayout.LayoutParams(776, 582);
|
||||||
|
Timber.d("adjustPreviewViewSize,${layoutParams.width},${layoutParams.height}}")
|
||||||
previewView.setLayoutParams(layoutParams)
|
previewView.setLayoutParams(layoutParams)
|
||||||
faceRectView.setLayoutParams(layoutParams)
|
faceRectView.setLayoutParams(layoutParams)
|
||||||
return layoutParams
|
return layoutParams
|
||||||
@@ -534,11 +594,11 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
previewSizeRgb.height,
|
previewSizeRgb.height,
|
||||||
layoutParams.width,
|
layoutParams.width,
|
||||||
layoutParams.height,
|
layoutParams.height,
|
||||||
90,
|
0,
|
||||||
cameraId,
|
cameraId,
|
||||||
isMirror,
|
isMirror,
|
||||||
true,
|
false,
|
||||||
true
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
recognizeViewModel.onRgbCameraOpened(camera)
|
recognizeViewModel.onRgbCameraOpened(camera)
|
||||||
@@ -557,15 +617,15 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
drawPreviewInfo(facePreviewInfoList)
|
drawPreviewInfo(facePreviewInfoList)
|
||||||
}
|
}
|
||||||
if (facePreviewInfoList.isNullOrEmpty()) {
|
if (facePreviewInfoList.isNullOrEmpty()) {
|
||||||
currentPlateInfo = null
|
|
||||||
currentUserId = null
|
currentUserId = null
|
||||||
userFaceInfo = null
|
userFaceInfo = null
|
||||||
binding.btnCollect.tag = ""
|
binding.btnCollect.tag = ""
|
||||||
binding.tvSimilarValue.text = ""
|
binding.tvSimilarValue.text = ""
|
||||||
retryFailCount = 0
|
retryFailCount = 0
|
||||||
|
// 人脸离开时,发送空帧清除 ViewModel 内部识别缓存,防止再次进入时使用旧数据
|
||||||
|
recognizeViewModel.onPreviewFrame(emptyFrame, true)
|
||||||
if (binding.llCollectButton.isVisible) {
|
if (binding.llCollectButton.isVisible) {
|
||||||
leftDebouncer.debounce { leftCountDown() }
|
leftDebouncer.debounce("leftDebouncer") { leftCountDown() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recognizeViewModel.clearLeftFace(facePreviewInfoList)
|
recognizeViewModel.clearLeftFace(facePreviewInfoList)
|
||||||
@@ -583,7 +643,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
override fun onCameraConfigurationChanged(cameraID: Int, displayOrientation: Int) {
|
override fun onCameraConfigurationChanged(cameraID: Int, displayOrientation: Int) {
|
||||||
Timber.i("initRgbCamera onCameraConfigurationChanged: threadName = ${Thread.currentThread().name}")
|
Timber.i("initRgbCamera onCameraConfigurationChanged: threadName = ${Thread.currentThread().name}")
|
||||||
if (rgbFaceRectTransformer != null) {
|
if (rgbFaceRectTransformer != null) {
|
||||||
rgbFaceRectTransformer!!.cameraDisplayOrientation = displayOrientation
|
rgbFaceRectTransformer?.cameraDisplayOrientation = displayOrientation
|
||||||
}
|
}
|
||||||
Timber.i("initRgbCamera onCameraConfigurationChanged: $cameraID $displayOrientation")
|
Timber.i("initRgbCamera onCameraConfigurationChanged: $cameraID $displayOrientation")
|
||||||
}
|
}
|
||||||
@@ -601,6 +661,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
.additionalRotation(0) // 角度
|
.additionalRotation(0) // 角度
|
||||||
.previewSize(recognizeViewModel.loadPreviewSize())
|
.previewSize(recognizeViewModel.loadPreviewSize())
|
||||||
.specificCameraId(previewConfig.rgbCameraId)
|
.specificCameraId(previewConfig.rgbCameraId)
|
||||||
|
// .isMirror(true)
|
||||||
.isMirror(true)
|
.isMirror(true)
|
||||||
.previewOn(binding.dualCameraTexturePreviewRgb)
|
.previewOn(binding.dualCameraTexturePreviewRgb)
|
||||||
.cameraListener(cameraListener)
|
.cameraListener(cameraListener)
|
||||||
@@ -639,10 +700,11 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
|
|
||||||
private fun resumeCamera() {
|
private fun resumeCamera() {
|
||||||
// isRecognition = true
|
// isRecognition = true
|
||||||
if (rgbCameraHelper != null && rgbCameraHelper!!.isStopped) {
|
val helper = rgbCameraHelper
|
||||||
|
if (helper != null && helper.isStopped) {
|
||||||
loadLogInfo("collectFace,resumeCamera: ")
|
loadLogInfo("collectFace,resumeCamera: ")
|
||||||
isRecognition = true
|
isRecognition = true
|
||||||
rgbCameraHelper!!.start()
|
helper.start()
|
||||||
} else {
|
} else {
|
||||||
//recognizeViewModel.onPreviewFrame(ByteArray(1382400), true)
|
//recognizeViewModel.onPreviewFrame(ByteArray(1382400), true)
|
||||||
|
|
||||||
@@ -687,6 +749,7 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
// private var tempUserId: String = ""
|
// private var tempUserId: String = ""
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
plateEnable = true
|
||||||
try {
|
try {
|
||||||
if (isFirstOpen) {
|
if (isFirstOpen) {
|
||||||
isFirstOpen = false
|
isFirstOpen = false
|
||||||
@@ -727,6 +790,9 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
plateEnable = true
|
plateEnable = true
|
||||||
collectCount = 0
|
collectCount = 0
|
||||||
// tempUserId = "${System.currentTimeMillis()}"
|
// tempUserId = "${System.currentTimeMillis()}"
|
||||||
|
openPlateDebouncer.reset()
|
||||||
|
// 清空上次识别结果和 FaceHelper 内部状态,防止短时间内再次识别无法触发
|
||||||
|
recognizeViewModel.resetFaceState()
|
||||||
resumeCamera()
|
resumeCamera()
|
||||||
registerHandler = RegisterCallbackHandler()
|
registerHandler = RegisterCallbackHandler()
|
||||||
|
|
||||||
@@ -735,13 +801,13 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
lifecycleScope = lifecycleScope,
|
lifecycleScope = lifecycleScope,
|
||||||
onTick = { remaining ->
|
onTick = { remaining ->
|
||||||
loadLogInfo("resetRecognizeState剩余时间:$remaining 秒")
|
loadLogInfo("resetRecognizeState剩余时间:$remaining 秒")
|
||||||
if (judgeRecognizeState()) return@startCountDown
|
// if (judgeRecognizeState()) return@startCountDown
|
||||||
loadLogInfo("initCountTime onTick = $remaining")
|
loadLogInfo("initCountTime onTick = $remaining")
|
||||||
binding.tvToInit.text = "$remaining"
|
binding.tvToInit.text = "$remaining"
|
||||||
},
|
},
|
||||||
onFinish = {
|
onFinish = {
|
||||||
loadLogInfo("resetRecognizeState倒计时结束")
|
loadLogInfo("resetRecognizeState倒计时结束")
|
||||||
if (judgeRecognizeState()) return@startCountDown
|
// if (judgeRecognizeState()) return@startCountDown
|
||||||
if (facePreviewInfoList.isNullOrEmpty()) {
|
if (facePreviewInfoList.isNullOrEmpty()) {
|
||||||
goInitActivity()
|
goInitActivity()
|
||||||
} else {
|
} else {
|
||||||
@@ -762,23 +828,23 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
|
|
||||||
private fun pauseCamera() {
|
private fun pauseCamera() {
|
||||||
isRecognition = false
|
isRecognition = false
|
||||||
// recognizeViewModel.onPreviewFrame(emptyFrame, true)
|
recognizeViewModel.onPreviewFrame(emptyFrame, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun judgeRecognizeState(): Boolean {
|
// private fun judgeRecognizeState(): Boolean {
|
||||||
val rectColor = binding.dualCameraFaceRectView.rectColor
|
// val rectColor = binding.dualCameraFaceRectView.rectColor
|
||||||
if (rectColor == RecognizeColor.COLOR_SUCCESS && currentUserId.isNullOrBlank()
|
// if (rectColor == RecognizeColor.COLOR_SUCCESS && currentUserId.isNullOrBlank()
|
||||||
.not() && facePreviewInfoList.isNullOrEmpty().not()
|
// .not() && facePreviewInfoList.isNullOrEmpty().not()
|
||||||
) {
|
// ) {
|
||||||
//人未离开,再次识别
|
// //人未离开,再次识别
|
||||||
loadLogInfo("userId=$currentUserId")
|
// loadLogInfo("userId=$currentUserId")
|
||||||
openPlateDebouncer.debounce {
|
// openPlateDebouncer.debounce {
|
||||||
openPlate(currentUserId)
|
// openPlate(currentUserId)
|
||||||
}
|
// }
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
|
|
||||||
fun goInitActivity() {
|
fun goInitActivity() {
|
||||||
val intent = Intent(context, InitActivity::class.java)
|
val intent = Intent(context, InitActivity::class.java)
|
||||||
@@ -815,13 +881,13 @@ class LoginByFaceActivity : BaseActivity<ActivityLoginFaceBinding>(),
|
|||||||
ToastUtils.showToast("获取人脸照片失败")
|
ToastUtils.showToast("获取人脸照片失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uploadFaceDebouncer.debounce {
|
uploadFaceDebouncer.debounce("uploadFaceDebouncer") {
|
||||||
addUserFace(faceData, imageFile)
|
addUserFace(faceData, imageFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addUserFace(faceData: String, imageFile: File) {
|
private fun addUserFace(faceData: String, imageFile: File) {
|
||||||
settingViewModel.addUserFace(faceData, imageFile) { status, faceModel ->
|
userViewModel.addUserFace(faceData, imageFile) { status, faceModel ->
|
||||||
loadLogInfo("collectFace,saveFaceInfo: ----------12,人脸数据发送完成时间:${DateTimeUtils.getDateTimeString()},结果:$status-----------")
|
loadLogInfo("collectFace,saveFaceInfo: ----------12,人脸数据发送完成时间:${DateTimeUtils.getDateTimeString()},结果:$status-----------")
|
||||||
if (status.not()) {
|
if (status.not()) {
|
||||||
ToastUtils.showToast("新增数据失败")
|
ToastUtils.showToast("新增数据失败")
|
||||||
|
|||||||
@@ -1,946 +0,0 @@
|
|||||||
//package com.sw.platecabinet.activity
|
|
||||||
//
|
|
||||||
//import android.Manifest
|
|
||||||
//import android.content.Intent
|
|
||||||
//import android.graphics.Bitmap
|
|
||||||
//import android.graphics.Point
|
|
||||||
//import android.hardware.Camera
|
|
||||||
//import android.os.Build
|
|
||||||
//import android.os.CountDownTimer
|
|
||||||
//import android.util.DisplayMetrics
|
|
||||||
//import android.view.View
|
|
||||||
//import android.view.ViewGroup
|
|
||||||
//import android.view.ViewTreeObserver
|
|
||||||
//import androidx.annotation.RequiresApi
|
|
||||||
//import androidx.lifecycle.Observer
|
|
||||||
//import com.arcsoft.face.ErrorInfo
|
|
||||||
//import com.google.gson.Gson
|
|
||||||
//import com.sw.inbound.utils.DateTimeUtils
|
|
||||||
//import com.sw.plate.utils.Base64
|
|
||||||
//import com.sw.plate.utils.ToastUtils
|
|
||||||
//import com.sw.plate.utils.arcface.ConfigUtil
|
|
||||||
//import com.sw.plate.utils.arcface.ErrorCodeUtil
|
|
||||||
//import com.sw.plate.utils.arcface.FaceRectTransformer
|
|
||||||
//import com.sw.plate.utils.arcface.FaceRectView
|
|
||||||
//import com.sw.plate.utils.arcface.FaceRectView.DrawInfo
|
|
||||||
//import com.sw.plate.utils.arcface.PreviewConfig
|
|
||||||
//import com.sw.plate.utils.arcface.camera.CameraListener
|
|
||||||
//import com.sw.plate.utils.arcface.camera.DualCameraHelper
|
|
||||||
//import com.sw.plate.utils.arcface.face.constants.LivenessType
|
|
||||||
//import com.sw.plate.utils.arcface.face.model.CompareResult
|
|
||||||
//import com.sw.plate.utils.arcface.face.model.FacePreviewInfo
|
|
||||||
//import com.sw.plate.utils.arcface.face.model.RecognizeConfiguration
|
|
||||||
//import com.sw.plate.utils.arcface.facedb.FaceDatabase
|
|
||||||
//import com.sw.plate.utils.arcface.facedb.entity.FaceEntity
|
|
||||||
//import com.sw.plate.utils.arcface.model.UserFaceInfo
|
|
||||||
//import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
|
||||||
//import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel.REGISTER_STATUS_READY
|
|
||||||
//import com.sw.platecabinet.MyApp
|
|
||||||
//import com.sw.platecabinet.R
|
|
||||||
//import com.sw.platecabinet.databinding.ActivityLoginFaceBinding
|
|
||||||
//import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
|
||||||
//import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
//import com.sw.platecabinet.model.response.UserFaceModel
|
|
||||||
//import com.sw.platecabinet.utils.BitmapSaver
|
|
||||||
//import com.sw.platecabinet.utils.Debouncer
|
|
||||||
//import com.sw.platecabinet.utils.LogFileUtil
|
|
||||||
//import com.sw.platecabinet.utils.PermissionHelper
|
|
||||||
//import com.sw.platecabinet.utils.PlateUtils
|
|
||||||
//import com.sw.platecabinet.utils.RegisterCallbackHandler
|
|
||||||
//import com.sw.platecabinet.utils.SoundPoolUtil
|
|
||||||
//import com.sw.platecabinet.utils.SpTool
|
|
||||||
//import org.greenrobot.eventbus.EventBus
|
|
||||||
//import org.greenrobot.eventbus.Subscribe
|
|
||||||
//import org.greenrobot.eventbus.ThreadMode
|
|
||||||
//import timber.log.Timber
|
|
||||||
//import java.io.File
|
|
||||||
//import java.util.concurrent.atomic.AtomicBoolean
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 人脸识别
|
|
||||||
// */
|
|
||||||
//class LoginByFaceActivityBak : BaseActivity<ActivityLoginFaceBinding>(),
|
|
||||||
// ViewTreeObserver.OnGlobalLayoutListener {
|
|
||||||
// // private val recognizeViewModel by viewModels<RecognizeViewModel>()
|
|
||||||
// private var countDownTimer: CountDownTimer? = null
|
|
||||||
//
|
|
||||||
// private val CAMERA_PERMISSION_REQUEST_CODE = 100
|
|
||||||
// private val REQUIRED_PERMISSIONS: Array<String> = arrayOf(
|
|
||||||
// Manifest.permission.CAMERA,
|
|
||||||
// Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
||||||
// Manifest.permission.READ_EXTERNAL_STORAGE
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// override fun inflateViewBinding(): ActivityLoginFaceBinding {
|
|
||||||
// return ActivityLoginFaceBinding.inflate(layoutInflater)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun inflateTitleBinding(): ItemTitleTimeBinding {
|
|
||||||
// return binding.includeHeader
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// companion object {
|
|
||||||
// private const val TAG = "LoginByFaceActivity"
|
|
||||||
// private var instance: LoginByFaceActivityBak? = null
|
|
||||||
//
|
|
||||||
// private const val COLLECT_SUCCESS = "collect_success"
|
|
||||||
// private const val RECOGNIZE_SUCCESS = "recognize_success"
|
|
||||||
// private const val NO_PLATE_REMIND = "no_plate_remind";
|
|
||||||
//
|
|
||||||
// fun goInitActivity() {
|
|
||||||
// instance?.goInitActivity()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// private var logList: MutableList<String> = mutableListOf()
|
|
||||||
//// private val logAdapter by lazy { LogAdapter(logList) }
|
|
||||||
//
|
|
||||||
// override fun initialize() {
|
|
||||||
// instance = this
|
|
||||||
// userViewModel.activeEngine()
|
|
||||||
//// addSocketListener()
|
|
||||||
// initCountTime()
|
|
||||||
// initArcViewModel()
|
|
||||||
// initArcView()
|
|
||||||
// openRectInfoDraw = true
|
|
||||||
// recognizeViewModel.setDrawRectInfoTextValue(true)
|
|
||||||
// //viewModel.generateToken()
|
|
||||||
//
|
|
||||||
//// binding.llToPwd.setOnClickListener {
|
|
||||||
//// val intent = Intent(this, LoginByPwdActivity::class.java)
|
|
||||||
//// startActivity(intent)
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
//// TaskManager.startTask()
|
|
||||||
//
|
|
||||||
// EventBus.getDefault().register(this)
|
|
||||||
//
|
|
||||||
//// binding.btnCollectFace.setOnClickListener { collectFace() }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//// binding.rvLogInfo.let {
|
|
||||||
//// it.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true)
|
|
||||||
//// it.adapter = logAdapter
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// binding.btnLogState.let {
|
|
||||||
//// it.tag = false
|
|
||||||
//// it.setImageResource(R.drawable.ic_log_show)
|
|
||||||
//// it.setOnClickListener { v ->
|
|
||||||
//// binding.rvLogInfo.run {
|
|
||||||
//// val state = it.tag.toString().toBooleanStrictOrNull() ?: false
|
|
||||||
//// if (state) visible() else gone()
|
|
||||||
//// }
|
|
||||||
//// val state = it.tag.toString().toBooleanStrictOrNull() ?: false
|
|
||||||
//// it.tag = state
|
|
||||||
//// it.setImageResource(
|
|
||||||
//// if (state) R.drawable.ic_log_hide else R.drawable.ic_log_show
|
|
||||||
//// )
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// //开启人脸增量数据定时任务
|
|
||||||
// startFaceTask {
|
|
||||||
// loadLogInfo("collectFace增量接口数据用户id:${Gson().toJson(it)}")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// val soundMap = hashMapOf<String, Int>()
|
|
||||||
// soundMap[COLLECT_SUCCESS] = R.raw.collect_success
|
|
||||||
// soundMap[RECOGNIZE_SUCCESS] = R.raw.recognize_success
|
|
||||||
// soundMap[NO_PLATE_REMIND] = R.raw.no_plate_remind
|
|
||||||
// SoundPoolUtil.getInstance().loadR(this, soundMap);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private fun checkCameraPermission() {
|
|
||||||
// Timber.i("checkCameraPermission")
|
|
||||||
// val permissionHelper =
|
|
||||||
// PermissionHelper.with(this, REQUIRED_PERMISSIONS, CAMERA_PERMISSION_REQUEST_CODE)
|
|
||||||
// .onGranted {
|
|
||||||
// loadLogInfo("checkCameraPermission 权限已允许")
|
|
||||||
// // 权限已授予
|
|
||||||
// recognizeViewModel.init()
|
|
||||||
// initRgbCamera()
|
|
||||||
// resumeCamera()
|
|
||||||
// }
|
|
||||||
// .build()
|
|
||||||
// registerPermissionHelper(permissionHelper)
|
|
||||||
// permissionHelper.checkAndRequest()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
// fun getFaceEntity(insertEntity: FaceEntity) {
|
|
||||||
// Timber.tag("performSync").e("-time=%s", insertEntity.registerTime)
|
|
||||||
// recognizeViewModel.addFace(insertEntity)
|
|
||||||
// Timber.tag("performSync over").e("-time=%s", insertEntity.registerTime)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onLeftDoubleClick() {
|
|
||||||
// finish()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private var isRecognition = false
|
|
||||||
// private var rgbCameraHelper: DualCameraHelper? = null
|
|
||||||
// private var rgbFaceRectTransformer: FaceRectTransformer? = null
|
|
||||||
// private val livenessType = LivenessType.RGB
|
|
||||||
// private var openRectInfoDraw = false
|
|
||||||
// private val regDebouncer = Debouncer(3000)
|
|
||||||
// private var registerHandler: RegisterCallbackHandler? = null
|
|
||||||
//
|
|
||||||
// private fun initArcViewModel() {
|
|
||||||
// recognizeViewModel.setLiveType(livenessType)
|
|
||||||
// recognizeViewModel.prepareRegister()
|
|
||||||
// recognizeViewModel.setOnRegisterFinishedCallback { facePreviewInfo, userFaceInfo ->
|
|
||||||
// registerHandler?.setCallback {
|
|
||||||
// if (!isCollectFace) {
|
|
||||||
// return@setCallback
|
|
||||||
// }
|
|
||||||
// if (this.userFaceInfo == null && userFaceInfo != null) {
|
|
||||||
// recognizeViewModel.updateRegisterStatus(RecognizeViewModel.REGISTER_STATUS_DONE)
|
|
||||||
// this.userFaceInfo = userFaceInfo
|
|
||||||
// getFaceDataBlock { faceData, headBmp ->
|
|
||||||
// isCollecting.set(false)
|
|
||||||
// isCollectFace = false
|
|
||||||
// sendFaceData(faceData, headBmp)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// recognizeViewModel.ftInitCode.observe(this, Observer { ftInitCode: Int? ->
|
|
||||||
// if (ftInitCode != ErrorInfo.MOK) {
|
|
||||||
// val error: String? = getString(
|
|
||||||
// R.string.specific_engine_init_failed, "ftEngine",
|
|
||||||
// ftInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(ftInitCode!!)
|
|
||||||
// )
|
|
||||||
// Timber.e("ftInitCode observe = $error")
|
|
||||||
// ToastUtils.showToast(error)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// recognizeViewModel.frInitCode.observe(this, Observer { frInitCode: Int? ->
|
|
||||||
// if (frInitCode != ErrorInfo.MOK) {
|
|
||||||
// val error: String? = getString(
|
|
||||||
// R.string.specific_engine_init_failed, "frEngine",
|
|
||||||
// frInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(frInitCode!!)
|
|
||||||
// )
|
|
||||||
// Timber.e("frInitCode observe = $error")
|
|
||||||
// ToastUtils.showToast(error)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// recognizeViewModel.flInitCode.observe(this, Observer { flInitCode: Int? ->
|
|
||||||
// if (flInitCode != ErrorInfo.MOK) {
|
|
||||||
// val error: String? = getString(
|
|
||||||
// R.string.specific_engine_init_failed, "flEngine",
|
|
||||||
// flInitCode, ErrorCodeUtil.arcFaceErrorCodeToFieldName(flInitCode!!)
|
|
||||||
// )
|
|
||||||
// Timber.e("flInitCode observe = $error")
|
|
||||||
// ToastUtils.showToast(error)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
//
|
|
||||||
// recognizeViewModel.recognizeConfiguration
|
|
||||||
// .observe(this, Observer { recognizeConfiguration: RecognizeConfiguration? ->
|
|
||||||
// Timber.i("recognizeConfiguration: observe = ${recognizeConfiguration.toString()}")
|
|
||||||
// })
|
|
||||||
// recognizeViewModel.recognizeNotice.observe(this, Observer { notice: String? ->
|
|
||||||
// Timber.i("recognizeNotice observe notice = $notice")
|
|
||||||
// })
|
|
||||||
//
|
|
||||||
// recognizeViewModel.recognizeUserId.observe(this, Observer { result: CompareResult? ->
|
|
||||||
// loadLogInfo("collectFace,recognizeUserId observe userId = ${result?.faceEntity?.userName}")
|
|
||||||
// if (faceUseSwitch) {
|
|
||||||
// loadFaceRecognizeResult2(result)
|
|
||||||
// return@Observer
|
|
||||||
// }
|
|
||||||
// loadFaceRecognizeResult(result)
|
|
||||||
// })
|
|
||||||
//
|
|
||||||
// recognizeViewModel.drawRectInfoText.observe(this, Observer { info ->
|
|
||||||
// Timber.i("drawRectInfoText observe info = $info")
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 人脸识别开关,true-loadFaceRecognizeResult2,false-loadFaceRecognizeResult
|
|
||||||
// */
|
|
||||||
// private var faceUseSwitch = true
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 识别失败重试次数
|
|
||||||
// */
|
|
||||||
// private var retryFailCount = 0
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 识别失败最大次数
|
|
||||||
// */
|
|
||||||
// private val maxFailCount = 5
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 人脸失败阈值
|
|
||||||
// */
|
|
||||||
// private val faceFailThreshold = 0.3
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 配置阈值,默认值为0.8
|
|
||||||
// */
|
|
||||||
// private val faceSuccessThreshold by lazy { ConfigUtil.getRecognizeThreshold(this) }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private val openPlateDebouncer = Debouncer(5000)
|
|
||||||
// private val isCollecting = AtomicBoolean(false)
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 根据相似度similar>设定阈值0.8作为识别成功判断,
|
|
||||||
// * 如果similar<0.3作为识别失败判断,
|
|
||||||
// * 如果similar>=0.3&&similar<=0.8时,暂时不作为失败情况,再识别5次如果similar<0.8则作为识别失败处理
|
|
||||||
// */
|
|
||||||
// private fun loadFaceRecognizeResult2(result: CompareResult?) {
|
|
||||||
// // 无有效结果直接忽略
|
|
||||||
// val similar = result?.similar ?: return
|
|
||||||
//
|
|
||||||
// binding.tvSimilarValue.text = "$similar,${retryFailCount}次"
|
|
||||||
// loadLogInfo(
|
|
||||||
// "collectFace,recognizeUserId 阈值 success=$faceSuccessThreshold, " +
|
|
||||||
// "fail=$faceFailThreshold, similar=$similar, retry=$retryFailCount"
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// if (similar >= faceSuccessThreshold) {
|
|
||||||
// val userId = result.faceEntity?.userName
|
|
||||||
// if (userId.isNullOrBlank()) {
|
|
||||||
// loadLogInfo("collectFace,recognizeUserId 识别成功但 userId 为空,忽略")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// loadLogInfo(
|
|
||||||
// "collectFace,recognizeUserId 识别成功 userId=$userId, time=${DateTimeUtils.getDateTimeString()}"
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// // 成功后必须重置状态
|
|
||||||
// retryFailCount = 0
|
|
||||||
// isCollecting.set(false)
|
|
||||||
// isCollectFace = false
|
|
||||||
// currentUserId = userId
|
|
||||||
//
|
|
||||||
// // 防抖,防止重复开闸
|
|
||||||
// openPlateDebouncer.debounce {
|
|
||||||
// openPlate(userId)
|
|
||||||
// }
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (isCollectFace) {
|
|
||||||
// loadLogInfo("collectFace,recognizeUserId 正在采集中,忽略失败结果 similar=$similar")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (similar <= faceFailThreshold || retryFailCount >= maxFailCount) {
|
|
||||||
// loadLogInfo(
|
|
||||||
// "collectFace,recognizeUserId 识别失败,开始采集 similar=$similar, " +
|
|
||||||
// "retry=$retryFailCount, time=${DateTimeUtils.getDateTimeString()}"
|
|
||||||
// )
|
|
||||||
// if (!isCollecting.compareAndSet(false, true)) {
|
|
||||||
// loadLogInfo("collectFace 已在采集中,忽略重复触发")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// retryFailCount = 0
|
|
||||||
// isCollectFace = true
|
|
||||||
// collectFace()//采集人脸
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// retryFailCount++
|
|
||||||
// loadLogInfo("collectFace,recognizeUserId 中间态重试,retryFailCount=$retryFailCount")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// private fun loadFaceRecognizeResult2(result: CompareResult?) {
|
|
||||||
////
|
|
||||||
//// if(isCollectFace){
|
|
||||||
//// return
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// val similar = result?.similar ?: 0f
|
|
||||||
//// binding.tvSimilarValue.text = "$similar,${retryFailCount}次"
|
|
||||||
//// loadLogInfo("collectFace,recognizeUserId 人脸识别配置阈值为:${faceSuccessThreshold},失败阈值为:${faceFailThreshold},相似度为:${similar},失败次数为:${retryFailCount}")
|
|
||||||
//// if (similar > faceSuccessThreshold) {
|
|
||||||
//// loadLogInfo("collectFace,recognizeUserId 相似度为:${similar},识别成功时间:${DateTimeUtils.getDateTimeString()}")
|
|
||||||
//// //大 于识别阈值,作为识别成功判断
|
|
||||||
//// currentUserId = result?.faceEntity?.userName
|
|
||||||
//// Debouncer(5000).debounce { openPlate(currentUserId) }
|
|
||||||
//// return
|
|
||||||
//// }
|
|
||||||
//// loadLogInfo("collectFace,recognizeUserId 人脸识别相似度为:${similar},失败次数为:${retryFailCount}")
|
|
||||||
//// if (similar < faceFailThreshold || retryFailCount >= maxFailCount) {
|
|
||||||
//// //相似度低于识别错误阈值进行采集、识别失败次数大于等于最大失败次数,作为识别失败判断
|
|
||||||
//// if (isCollectFace.not()) {
|
|
||||||
//// //非采集中
|
|
||||||
//// loadLogInfo("collectFace,recognizeUserId 未识别到人脸信息,相似度为:${similar},开始采集时间:${DateTimeUtils.getDateTimeString()}")
|
|
||||||
//// isCollectFace = true
|
|
||||||
//// collectFace()
|
|
||||||
//// return
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// //满足similar >= faceFailThreshold && similar <= successThreshold时进行重试
|
|
||||||
//// retryFailCount++
|
|
||||||
//// loadLogInfo("collectFace,recognizeUserId 人脸识别失败次数为:${retryFailCount}")
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 根据相似度similar>设定阈值0.8作为识别是否成功来加载人脸识别结果
|
|
||||||
// */
|
|
||||||
// private fun loadFaceRecognizeResult(result: CompareResult?) {
|
|
||||||
// val similar = result?.similar ?: 0f
|
|
||||||
// binding.tvSimilarValue.text = "$similar"
|
|
||||||
// val similarPass = result?.isSimilarPass ?: false
|
|
||||||
// if (similarPass.not()) {
|
|
||||||
// loadLogInfo("collectFace,recognizeUserId 未识别到人脸信息,开始采集")
|
|
||||||
// isCollectFace = true
|
|
||||||
// collectFace()
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// currentUserId = result?.faceEntity?.userName
|
|
||||||
// if (tempUserId != currentUserId) {
|
|
||||||
// SoundPoolUtil.getInstance().play("success", 0)
|
|
||||||
// }
|
|
||||||
//// plateEnable = true
|
|
||||||
// Debouncer(5000).debounce { openPlate(currentUserId) }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 查询餐盘数据
|
|
||||||
// */
|
|
||||||
// private fun getPlateData(block: (List<EquipmentUserInfo>) -> Unit) {
|
|
||||||
// MyApp.plateList?.let {
|
|
||||||
// block(it)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private var currentPlateInfo: EquipmentUserInfo? = null
|
|
||||||
// private var plateEnable = false
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 打开餐盘柜
|
|
||||||
// */
|
|
||||||
// private fun openPlate(userId: String?) {
|
|
||||||
// if (plateEnable.not()) return
|
|
||||||
// loadLogInfo("collectFace,openPlate: userId=$userId")
|
|
||||||
// getPlateData { items ->
|
|
||||||
// loadLogInfo("collectFace,openPlate: items:${Gson().toJson(items)}")
|
|
||||||
// // 未查询到当前用户,查询第一个未绑定的餐盘
|
|
||||||
// val item = items.firstOrNull { it.plateNumber.isNullOrEmpty().not() }
|
|
||||||
// loadLogInfo("collectFace,openPlate: item2:${item}")
|
|
||||||
// if (item == null) {
|
|
||||||
// //暂无餐盘
|
|
||||||
// loadLogInfo("collectFace,openPlate: 暂无餐盘,请联系管理人员,isCollectFace=$isCollectFace")
|
|
||||||
// //ToastUtils.showToast("暂无餐盘,请联系管理人员")
|
|
||||||
// SoundPoolUtil.getInstance().play(NO_PLATE_REMIND, 0)
|
|
||||||
// goInitActivity()
|
|
||||||
// return@getPlateData
|
|
||||||
// }
|
|
||||||
//// if (tempUserId != currentUserId) {
|
|
||||||
// SoundPoolUtil.getInstance().play(RECOGNIZE_SUCCESS, 0)
|
|
||||||
//// } else {
|
|
||||||
//// SoundPoolUtil.getInstance().play(COLLECT_SUCCESS, 0)
|
|
||||||
//// }
|
|
||||||
// loadLogInfo("collectFace,openPlate: item3:${item}")
|
|
||||||
// item.faceId = userId
|
|
||||||
// item.updateTime = DateTimeUtils.getDateTimeString()
|
|
||||||
// item.plateNumber = null
|
|
||||||
// plateEnable = false
|
|
||||||
// Debouncer(5000).debounce {
|
|
||||||
// //打开柜子
|
|
||||||
// PlateUtils.open(this, item.equipmentBoxCode, false)
|
|
||||||
// }
|
|
||||||
// currentPlateInfo = item
|
|
||||||
// MyApp.plateList = items
|
|
||||||
// SpTool.savePlateData(items)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// private val debouncer by lazy { Debouncer(3000) }
|
|
||||||
//
|
|
||||||
// private fun initArcView() {
|
|
||||||
// //在布局结束后才做初始化操作
|
|
||||||
// binding.dualCameraTexturePreviewRgb.getViewTreeObserver().addOnGlobalLayoutListener(this)
|
|
||||||
// recognizeViewModel.getCompareResultList().getValue()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onDestroy() {
|
|
||||||
// loadLogInfo("onDestroy")
|
|
||||||
// instance = null
|
|
||||||
// if (rgbCameraHelper != null) {
|
|
||||||
// rgbCameraHelper!!.release()
|
|
||||||
// rgbCameraHelper = null
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// recognizeViewModel.destroy()
|
|
||||||
//
|
|
||||||
// EventBus.getDefault().unregister(this)
|
|
||||||
// super.onDestroy()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 调整View的宽高,使预览显示正常且采集框固定为380x380
|
|
||||||
// *
|
|
||||||
// * @param rgbPreview RGB预览View
|
|
||||||
// * @param previewView 显示预览数据的view
|
|
||||||
// * @param faceRectView 画框的view (380x380)
|
|
||||||
// * @param previewSize 预览大小
|
|
||||||
// * @param displayOrientation 相机旋转角度
|
|
||||||
// * @param scale 缩放比例
|
|
||||||
// * @return 调整后的LayoutParams
|
|
||||||
// */
|
|
||||||
// private fun adjustPreviewViewSize(
|
|
||||||
// rgbPreview: View,
|
|
||||||
// previewView: View,
|
|
||||||
// faceRectView: FaceRectView,
|
|
||||||
// previewSize: Camera.Size,
|
|
||||||
// displayOrientation: Int,
|
|
||||||
// scale: Float
|
|
||||||
// ): ViewGroup.LayoutParams {
|
|
||||||
// val layoutParams = previewView.layoutParams
|
|
||||||
// val measuredWidth = previewView.measuredWidth
|
|
||||||
// val measuredHeight = previewView.measuredHeight
|
|
||||||
// var ratio = (previewSize.height.toFloat()) / previewSize.width.toFloat()
|
|
||||||
// if (ratio > 1) {
|
|
||||||
// ratio = 1 / ratio
|
|
||||||
// }
|
|
||||||
// if (displayOrientation % 180 == 0) {
|
|
||||||
// layoutParams.width = measuredWidth
|
|
||||||
// layoutParams.height = (measuredWidth * ratio).toInt()
|
|
||||||
// } else {
|
|
||||||
// layoutParams.height = measuredHeight
|
|
||||||
// layoutParams.width = (measuredHeight * ratio).toInt()
|
|
||||||
// }
|
|
||||||
// if (scale < 1f) {
|
|
||||||
// val rgbParam = rgbPreview.getLayoutParams()
|
|
||||||
// layoutParams.width = (rgbParam.width * scale).toInt()
|
|
||||||
// layoutParams.height = (rgbParam.height * scale).toInt()
|
|
||||||
// } else {
|
|
||||||
// layoutParams.width = (layoutParams.width * scale).toInt()
|
|
||||||
// layoutParams.height = (layoutParams.height * scale).toInt()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// val metrics = DisplayMetrics()
|
|
||||||
// windowManager.defaultDisplay.getMetrics(metrics)
|
|
||||||
//
|
|
||||||
// if (layoutParams.width >= metrics.widthPixels) {
|
|
||||||
// val viewRatio = layoutParams.width / (metrics.widthPixels.toFloat())
|
|
||||||
// layoutParams.width = (layoutParams.width / viewRatio).toInt()
|
|
||||||
// layoutParams.height = (layoutParams.height / viewRatio).toInt()
|
|
||||||
// }
|
|
||||||
// if (layoutParams.height >= metrics.heightPixels) {
|
|
||||||
// val viewRatio = layoutParams.height / (metrics.heightPixels.toFloat())
|
|
||||||
// layoutParams.width = (layoutParams.width / viewRatio).toInt()
|
|
||||||
// layoutParams.height = (layoutParams.height / viewRatio).toInt()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// previewView.setLayoutParams(layoutParams)
|
|
||||||
// faceRectView.setLayoutParams(layoutParams)
|
|
||||||
// return layoutParams
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun initRgbCamera() {
|
|
||||||
// val cameraListener: CameraListener = object : CameraListener {
|
|
||||||
// override fun onCameraOpened(
|
|
||||||
// camera: Camera,
|
|
||||||
// cameraId: Int,
|
|
||||||
// displayOrientation: Int,
|
|
||||||
// isMirror: Boolean
|
|
||||||
// ) {
|
|
||||||
// loadLogInfo("initRgbCamera Rgb onCameraOpened: cameraId = $cameraId, displayOrientation = $displayOrientation")
|
|
||||||
// runOnUiThread({
|
|
||||||
// val previewSizeRgb = camera.getParameters().getPreviewSize()
|
|
||||||
// val layoutParams = adjustPreviewViewSize(
|
|
||||||
// binding.dualCameraTexturePreviewRgb,
|
|
||||||
// binding.dualCameraTexturePreviewRgb, binding.dualCameraFaceRectView,
|
|
||||||
// previewSizeRgb, displayOrientation, 0.6f
|
|
||||||
// )
|
|
||||||
// loadLogInfo("initRgbCamera previewSizeRgb = ${previewSizeRgb.width}-${previewSizeRgb.height}")
|
|
||||||
// loadLogInfo("initRgbCamera layoutParams = ${layoutParams.width}-${layoutParams.height}")
|
|
||||||
// loadLogInfo(
|
|
||||||
// "initRgbCamera isMirror = ${isMirror}, isDrawRgbRectHorizontalMirror = ${
|
|
||||||
// ConfigUtil.isDrawRgbRectHorizontalMirror(
|
|
||||||
// context
|
|
||||||
// )
|
|
||||||
// }, isDrawRgbRectVerticalMirror = ${
|
|
||||||
// ConfigUtil.isDrawRgbRectVerticalMirror(
|
|
||||||
// context
|
|
||||||
// )
|
|
||||||
// }"
|
|
||||||
// )
|
|
||||||
// rgbFaceRectTransformer = FaceRectTransformer(
|
|
||||||
// previewSizeRgb.width,
|
|
||||||
// previewSizeRgb.height,
|
|
||||||
// layoutParams.width,
|
|
||||||
// layoutParams.height,
|
|
||||||
// 90,
|
|
||||||
// cameraId,
|
|
||||||
// isMirror,
|
|
||||||
// true,
|
|
||||||
// true
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// recognizeViewModel.onRgbCameraOpened(camera)
|
|
||||||
// recognizeViewModel.setRgbFaceRectTransformer(rgbFaceRectTransformer)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @RequiresApi(api = Build.VERSION_CODES.Q)
|
|
||||||
// override fun onPreview(nv21: ByteArray?, camera: Camera?) {
|
|
||||||
// if (!isRecognition) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// binding.dualCameraFaceRectView.clearFaceInfo()
|
|
||||||
// facePreviewInfoList = recognizeViewModel.onPreviewFrame(nv21, true)
|
|
||||||
// if (facePreviewInfoList != null && rgbFaceRectTransformer != null) {
|
|
||||||
// drawPreviewInfo(facePreviewInfoList)
|
|
||||||
// }
|
|
||||||
// if (facePreviewInfoList.isNullOrEmpty()) {
|
|
||||||
// currentPlateInfo = null
|
|
||||||
// currentUserId = null
|
|
||||||
// userFaceInfo = null
|
|
||||||
// }
|
|
||||||
// recognizeViewModel.clearLeftFace(facePreviewInfoList)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onCameraClosed() {
|
|
||||||
// Timber.i("initRgbCamera onCameraClosed: ")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onCameraError(e: java.lang.Exception) {
|
|
||||||
// Timber.i("initRgbCamera onCameraError: %s", e.message)
|
|
||||||
// e.printStackTrace()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onCameraConfigurationChanged(cameraID: Int, displayOrientation: Int) {
|
|
||||||
// Timber.i("initRgbCamera onCameraConfigurationChanged: threadName = ${Thread.currentThread().name}")
|
|
||||||
// if (rgbFaceRectTransformer != null) {
|
|
||||||
// rgbFaceRectTransformer!!.cameraDisplayOrientation = displayOrientation
|
|
||||||
// }
|
|
||||||
// Timber.i("initRgbCamera onCameraConfigurationChanged: $cameraID $displayOrientation")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// val previewConfig: PreviewConfig = recognizeViewModel.previewConfig
|
|
||||||
// rgbCameraHelper = DualCameraHelper.Builder()
|
|
||||||
// .previewViewSize(
|
|
||||||
// Point(
|
|
||||||
// binding.dualCameraTexturePreviewRgb.measuredWidth,
|
|
||||||
// binding.dualCameraTexturePreviewRgb.measuredHeight
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// .rotation(windowManager.defaultDisplay.rotation)
|
|
||||||
// .additionalRotation(0) // 角度
|
|
||||||
// .previewSize(recognizeViewModel.loadPreviewSize())
|
|
||||||
// .specificCameraId(previewConfig.rgbCameraId)
|
|
||||||
// .isMirror(true)
|
|
||||||
// .previewOn(binding.dualCameraTexturePreviewRgb)
|
|
||||||
// .cameraListener(cameraListener)
|
|
||||||
// .build()
|
|
||||||
// rgbCameraHelper!!.init()
|
|
||||||
// rgbCameraHelper!!.start()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 绘制RGB、IR画面的实时人脸信息
|
|
||||||
// *
|
|
||||||
// * @param facePreviewInfoList RGB画面的实时人脸信息
|
|
||||||
// */
|
|
||||||
// private fun drawPreviewInfo(facePreviewInfoList: MutableList<FacePreviewInfo>?) {
|
|
||||||
// if (rgbFaceRectTransformer != null) {
|
|
||||||
// val rgbDrawInfoList: MutableList<DrawInfo>? = recognizeViewModel.getDrawInfo(
|
|
||||||
// facePreviewInfoList, LivenessType.RGB, openRectInfoDraw
|
|
||||||
// )
|
|
||||||
// // 识别成功
|
|
||||||
// binding.dualCameraFaceRectView.drawRealtimeFaceInfo(rgbDrawInfoList)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fun openRectInfoDraw(view: View?) {
|
|
||||||
// openRectInfoDraw = !openRectInfoDraw
|
|
||||||
// recognizeViewModel.setDrawRectInfoTextValue(openRectInfoDraw)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// override fun onGlobalLayout() {
|
|
||||||
// loadLogInfo("onGlobalLayout")
|
|
||||||
// binding.dualCameraTexturePreviewRgb.getViewTreeObserver().removeOnGlobalLayoutListener(this)
|
|
||||||
// // 请求权限
|
|
||||||
// checkCameraPermission()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun resumeCamera() {
|
|
||||||
// isRecognition = true
|
|
||||||
// if (rgbCameraHelper != null && rgbCameraHelper!!.isStopped) {
|
|
||||||
// loadLogInfo("collectFace,resumeCamera: ")
|
|
||||||
// rgbCameraHelper!!.start()
|
|
||||||
// } else {
|
|
||||||
// recognizeViewModel.onPreviewFrame(ByteArray(1382400), true)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 临时用户id
|
|
||||||
// */
|
|
||||||
// private var tempUserId: String = ""
|
|
||||||
// override fun onResume() {
|
|
||||||
// super.onResume()
|
|
||||||
// registerHandler = RegisterCallbackHandler()
|
|
||||||
// try {
|
|
||||||
// if (isFirstOpen) {
|
|
||||||
// goInitActivity()
|
|
||||||
// binding.root.postDelayed({
|
|
||||||
// isFirstOpen = false
|
|
||||||
// }, 1000)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// retryFailCount = 0
|
|
||||||
// binding.tvSimilarValue.text = ""
|
|
||||||
// isCollecting.set(false)
|
|
||||||
// isCollectFace = false
|
|
||||||
// plateEnable = true
|
|
||||||
// collectCount = 0
|
|
||||||
// tempUserId = "${System.currentTimeMillis()}"
|
|
||||||
// resumeCamera()
|
|
||||||
// userViewModel.resetUserInfo()
|
|
||||||
// countDownTimer?.let {
|
|
||||||
// it.cancel()
|
|
||||||
// it.start()
|
|
||||||
// }
|
|
||||||
//// initFaceScheduler()
|
|
||||||
//// checkFaceState()
|
|
||||||
// } catch (e: Exception) {
|
|
||||||
// e.printStackTrace()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private var isFirstOpen = true
|
|
||||||
//
|
|
||||||
// protected override fun onPause() {
|
|
||||||
// pauseCamera()
|
|
||||||
// super.onPause()
|
|
||||||
// countDownTimer?.cancel()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun pauseCamera() {
|
|
||||||
// isRecognition = false
|
|
||||||
// recognizeViewModel.onPreviewFrame(ByteArray(1382400), true)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun handleLoginSuccess(equipmentUserInfo: EquipmentUserInfo, isAdmin: Boolean) {
|
|
||||||
// super.handleLoginSuccess(equipmentUserInfo, isAdmin)
|
|
||||||
//// goInitActivity()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private val totalTimeInMillis = 15 * 1000L
|
|
||||||
// fun initCountTime() {
|
|
||||||
// countDownTimer = object : CountDownTimer(totalTimeInMillis, 1000) {
|
|
||||||
// override fun onTick(millisUntilFinished: Long) {
|
|
||||||
// loadLogInfo("initCountTime onTick = ${(millisUntilFinished / 1000).toInt()}")
|
|
||||||
// binding.tvToInit.text = "${(millisUntilFinished / 1000).toInt() + 1}"
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onFinish() {
|
|
||||||
// goInitActivity()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fun goInitActivity() {
|
|
||||||
// val intent = Intent(context, InitActivity::class.java)
|
|
||||||
// startActivity(intent)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 采集人脸
|
|
||||||
// */
|
|
||||||
// private fun collectFace() {
|
|
||||||
// loadLogInfo("collectFace: -----------1,开始采集人脸,开始时间:${DateTimeUtils.getDateTimeString()}----------")
|
|
||||||
// if (isFirstOpen) return
|
|
||||||
// loadLogInfo("collectFace: ----------2,isFirstOpen=false-----------")
|
|
||||||
// loadLogInfo("collectFace: ----------4,检测到人脸信息-----------")
|
|
||||||
// currentUserId = null
|
|
||||||
// userFaceInfo = null
|
|
||||||
// recognizeViewModel.updateRegisterStatus(REGISTER_STATUS_READY)
|
|
||||||
// loadLogInfo("collectFace: ----------5,人脸采集中-----------")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private val uploadFaceDebouncer = Debouncer(10000)
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 改为上传人脸数据,不需要发生人脸数据到收银端
|
|
||||||
// */
|
|
||||||
// private fun sendFaceData(faceData: String, headBmp: Bitmap) {
|
|
||||||
// loadLogInfo("collectFace,sendFaceData: ----------11,发送人脸数据-----------")
|
|
||||||
//
|
|
||||||
// val imageFile = BitmapSaver.saveToAppFilesDir(
|
|
||||||
// headBmp, this, "IMG_CROP_${System.currentTimeMillis()}.jpg"
|
|
||||||
// )
|
|
||||||
// loadLogInfo("collectFace,sendFaceData:${imageFile?.absolutePath}")
|
|
||||||
// if (imageFile == null) {
|
|
||||||
// ToastUtils.showToast("获取人脸照片失败")
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// uploadFaceDebouncer.debounce {
|
|
||||||
// addUserFace(faceData, imageFile)
|
|
||||||
// }
|
|
||||||
//// // 给某个客户端发送
|
|
||||||
//// val jsonObject = JSONObject().also {
|
|
||||||
//// it.put("type", "faceFeature")
|
|
||||||
//// it.put("content", faceData)
|
|
||||||
//// }
|
|
||||||
//// tcpClient?.send(jsonObject)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun addUserFace(faceData: String, imageFile: File) {
|
|
||||||
// settingViewModel.addUserFace(faceData, imageFile) { status, faceModel ->
|
|
||||||
// loadLogInfo("collectFace,saveFaceInfo: ----------12,人脸数据发送完成时间:${DateTimeUtils.getDateTimeString()},结果:$status-----------")
|
|
||||||
// if (status.not()) {
|
|
||||||
// ToastUtils.showToast("新增数据失败")
|
|
||||||
// loadLogInfo("collectFace,sendFaceData: ----------12,发送人脸数据失败,faceData=${faceData}")
|
|
||||||
// return@addUserFace
|
|
||||||
// }
|
|
||||||
// if (faceModel == null) {
|
|
||||||
// ToastUtils.showToast("新增数据成功,但未拿到接口数据")
|
|
||||||
// loadLogInfo("collectFace,sendFaceData: ----------12,发送人脸数据成功但接口返回为null,faceData=${faceData}")
|
|
||||||
// return@addUserFace
|
|
||||||
// }
|
|
||||||
// Thread {
|
|
||||||
// saveFaceInfo(faceModel)
|
|
||||||
// uploadFaceDebouncer.reset()
|
|
||||||
// }.start()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private fun getFaceDataBlock(block: (String, Bitmap) -> Unit) {
|
|
||||||
// if (userFaceInfo == null || userFaceInfo?.faceFeature?.featureData == null) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// val faceData: String? = Base64.encode(userFaceInfo?.faceFeature?.featureData)
|
|
||||||
// if (faceData.isNullOrBlank()) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// loadLogInfo("collectFace,getFaceData: ----------7,拿到人脸提取特征数据时间:${DateTimeUtils.getDateTimeString()}-----------")
|
|
||||||
// block(faceData, userFaceInfo!!.headBmp)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 加载日志
|
|
||||||
// * @param msg 日志内容
|
|
||||||
// */
|
|
||||||
// private fun loadLogInfo(msg: String) {
|
|
||||||
// Timber.tag(TAG).d(msg)
|
|
||||||
// LogFileUtil.saveLog(msg)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private var facePreviewInfoList: MutableList<FacePreviewInfo>? = null
|
|
||||||
// private var userFaceInfo: UserFaceInfo? = null
|
|
||||||
//
|
|
||||||
// private var currentUserId: String? = null
|
|
||||||
//
|
|
||||||
// private fun saveFaceInfo(faceModel: UserFaceModel) {
|
|
||||||
// try {
|
|
||||||
// loadLogInfo("collectFace,saveFaceInfo: ----------8,保存人脸取特征数据-----------")
|
|
||||||
// val faceDao = FaceDatabase.getInstance(this).faceDao()
|
|
||||||
// val faceEntity = FaceEntity(
|
|
||||||
// faceModel.userId,
|
|
||||||
// null,
|
|
||||||
// Base64.decode(faceModel.faceFeatureStr)
|
|
||||||
// ).also {
|
|
||||||
// //1-会员、2-临时用户
|
|
||||||
// it.userType = if (faceModel.isMember) "1" else "2"
|
|
||||||
// }
|
|
||||||
// faceDao.insert(faceEntity)
|
|
||||||
// loadLogInfo("collectFace,saveFaceInfo: ----------10,人脸数据保存完成-----------")
|
|
||||||
// recognizeViewModel.refreshFaceList()
|
|
||||||
// loadLogInfo("collectFace,saveFaceInfo: ----------11,刷新人脸数据-----------")
|
|
||||||
// runOnUiThread { recognizeViewModel.onPreviewFrame(ByteArray(1382400), true) }
|
|
||||||
// loadLogInfo("---------------------------------")
|
|
||||||
// collectCount = 0
|
|
||||||
// } catch (e: Exception) {
|
|
||||||
// e.printStackTrace()
|
|
||||||
// loadLogInfo("collectFace,saveFaceInfo: ----------13,人脸采集异常:${e.message}-----------")
|
|
||||||
// collectCount++
|
|
||||||
// loadLogInfo("collectFace,saveFaceInfo: ----------14,${collectCount}次人脸采集异常:${e.message}-----------")
|
|
||||||
// ToastUtils.showToast("人脸采集异常:${e.message}")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private var collectCount = 0
|
|
||||||
//
|
|
||||||
//// private var tcpClient: TcpClient? = null
|
|
||||||
////
|
|
||||||
//// private fun addSocketListener() {
|
|
||||||
////// val ipAddress = NetworkUtils.getIPAddress(true)
|
|
||||||
////// loadLogInfo( "addSocketListener,ipAddress: $ipAddress");
|
|
||||||
//// tcpClient = TcpClient(
|
|
||||||
//// "192.168.1.95",
|
|
||||||
//// 5000,
|
|
||||||
//// GlobalData.deviceId, // clientId
|
|
||||||
//// 5000, // connectTimeoutMs
|
|
||||||
//// 10 * 1000, // heartbeatIntervalMs
|
|
||||||
//// 30 * 1000 // heartbeatTimeoutMs
|
|
||||||
//// )
|
|
||||||
////
|
|
||||||
//// tcpClient?.setListener(object : TcpClientListenerImpl() {
|
|
||||||
//// override fun onSendSuccess(json: JSONObject?) {
|
|
||||||
//// super.onSendSuccess(json)
|
|
||||||
//// loadLogInfo("collectFace,TcpClientListener发送成功:$json")
|
|
||||||
////// toast("发送成功")
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// override fun onSendFailed(json: JSONObject?, e: java.lang.Exception?) {
|
|
||||||
//// super.onSendFailed(json, e)
|
|
||||||
//// ToastUtils.showToast("发送失败${e?.message}")
|
|
||||||
//// loadLogInfo("collectFace,TcpClientListener人脸数据发送失败:${e?.message}")
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// override fun onMessage(json: JSONObject?) {
|
|
||||||
//// super.onMessage(json)
|
|
||||||
//// loadLogInfo("collectFace,TcpClientListener收到消息:$json")
|
|
||||||
//// val type = json?.getInt("type")
|
|
||||||
//// // 根据服务端消息类型处理删除新增临时用户人脸数据---------------------
|
|
||||||
//// when (type) {
|
|
||||||
//// LanServer.TYPE_ADD_FACE_DATA -> {
|
|
||||||
//// //采集设备id自己生成,不接收服务端的,在本地只判断是否存在同一人脸数据
|
|
||||||
//// loadLogInfo("collectFace,TcpClientListener收到消息,新增用户:采集设备id自己生成,不接收服务端的,在本地只判断是否存在同一人脸数据")
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// LanServer.TYPE_CLEAR_FACE_DATA -> {
|
|
||||||
//// clearFaceData()
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// else -> {}
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// })
|
|
||||||
//// tcpClient?.start()
|
|
||||||
////
|
|
||||||
//// try {
|
|
||||||
//// LanServer.getInstance().let {
|
|
||||||
//// it.setListener(object : LanServerListenerImpl() {
|
|
||||||
//// override fun onMessageReceived(clientId: String?, message: JSONObject?) {
|
|
||||||
//// super.onMessageReceived(clientId, message)
|
|
||||||
//// ToastUtils.showToast("收到消息clientId=$clientId")
|
|
||||||
//// }
|
|
||||||
//// })
|
|
||||||
//// it.start()
|
|
||||||
//// }
|
|
||||||
//// } catch (e: Exception) {
|
|
||||||
//// e.printStackTrace()
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// private fun clearFaceData() {
|
|
||||||
// Thread {
|
|
||||||
// val faceDao = FaceDatabase.getInstance(this).faceDao()
|
|
||||||
// faceDao.deleteTempUserFaceData()
|
|
||||||
// recognizeViewModel.refreshFaceList()
|
|
||||||
// loadLogInfo("collectFace,TcpClientListener收到消息,已删除并刷新人脸数据")
|
|
||||||
// }.start()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private var isCollectFace = false
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
//package com.sw.platecabinet.activity
|
|
||||||
//
|
|
||||||
//import android.content.Intent
|
|
||||||
//import com.sw.plate.utils.ToastUtils
|
|
||||||
//import com.sw.platecabinet.databinding.ActivityLoginByPwdBinding
|
|
||||||
//import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
|
||||||
//import com.sw.platecabinet.dialog.BalanceNotEnoughDialog
|
|
||||||
//import com.sw.platecabinet.model.request.LoginParam
|
|
||||||
//import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
//import com.sw.platecabinet.utils.KeyboardUtils
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 密码登录
|
|
||||||
// */
|
|
||||||
//class LoginByPwdActivity : BaseActivity<ActivityLoginByPwdBinding>() {
|
|
||||||
//
|
|
||||||
// override fun inflateViewBinding(): ActivityLoginByPwdBinding {
|
|
||||||
// return ActivityLoginByPwdBinding.inflate(layoutInflater)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun inflateTitleBinding(): ItemTitleTimeBinding {
|
|
||||||
// return binding.includeHeader
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun initialize() {
|
|
||||||
// binding.btnLogin.setOnClickListener {
|
|
||||||
// val phone = binding.etPhone.text.toString()
|
|
||||||
// val pwd = binding.etPwd.text.toString()
|
|
||||||
// if (phone.isEmpty() || pwd.isEmpty()) {
|
|
||||||
// ToastUtils.showToast("手机或校验码不能为空")
|
|
||||||
// return@setOnClickListener
|
|
||||||
// }
|
|
||||||
// val loginParam = LoginParam(
|
|
||||||
// //equipmentId = equipmentId,
|
|
||||||
// phone = phone,
|
|
||||||
// password = pwd
|
|
||||||
// )
|
|
||||||
// viewModel.loginWithPwd(loginParam)
|
|
||||||
// KeyboardUtils.hideKeyboard(this)
|
|
||||||
// }
|
|
||||||
// binding.tvFaceRec.setOnClickListener {
|
|
||||||
// val intent = Intent(this, LoginByFaceActivity::class.java)
|
|
||||||
// startActivity(intent)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onResume() {
|
|
||||||
// super.onResume()
|
|
||||||
// viewModel.resetUserInfo()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun handleLoginSuccess(equipmentUserInfo: EquipmentUserInfo, isAdmin: Boolean) {
|
|
||||||
// super.handleLoginSuccess(equipmentUserInfo, isAdmin)
|
|
||||||
//// val cardBalance = equipmentUserInfo.cardBalance?:0.toDouble()
|
|
||||||
//// val balanceIsNotEnough = cardBalance <= 0.toDouble()
|
|
||||||
// if (equipmentUserInfo.isIntercept) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// LoginByFaceActivity.goInitActivity()
|
|
||||||
// finish()
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -2,14 +2,11 @@ package com.sw.platecabinet.activity
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import com.sw.plate.utils.ToastUtils
|
|
||||||
import com.sw.platecabinet.R
|
import com.sw.platecabinet.R
|
||||||
import com.sw.platecabinet.databinding.ActivityMainBinding
|
import com.sw.platecabinet.databinding.ActivityMainBinding
|
||||||
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
||||||
import com.sw.platecabinet.dialog.CustomDialog
|
|
||||||
import com.sw.platecabinet.fragment.PlateCabinetFullFragment
|
import com.sw.platecabinet.fragment.PlateCabinetFullFragment
|
||||||
import com.sw.platecabinet.fragment.PlateOpenFragment
|
import com.sw.platecabinet.fragment.PlateOpenFragment
|
||||||
import com.sw.platecabinet.fragment.SettingListFragment
|
|
||||||
import com.sw.platecabinet.utils.FragmentHelper
|
import com.sw.platecabinet.utils.FragmentHelper
|
||||||
|
|
||||||
typealias Callback = (String) -> Unit
|
typealias Callback = (String) -> Unit
|
||||||
@@ -65,7 +62,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
pageType = param?.let { PageType.valueOf(param) } ?: PageType.SETTING_LIST
|
pageType = param?.let { PageType.valueOf(param) } ?: PageType.SETTING_LIST
|
||||||
fragmentHelper = FragmentHelper(supportFragmentManager, R.id.fragment_container)
|
fragmentHelper = FragmentHelper(supportFragmentManager, R.id.fragment_container)
|
||||||
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_TIP -> PlateOpenFragment.newInstance(equipmentUserInfo, isAdmin)
|
// PageType.PLATE_TIP -> PlateOpenFragment.newInstance(equipmentUserInfo, isAdmin)
|
||||||
PageType.PLATE_TIP -> PlateOpenFragment.newInstance(isScanCode)
|
PageType.PLATE_TIP -> PlateOpenFragment.newInstance(isScanCode)
|
||||||
@@ -86,7 +83,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
|
|
||||||
override fun onRightDoubleClick() {
|
override fun onRightDoubleClick() {
|
||||||
if (pageType == PageType.SETTING_LIST) {
|
if (pageType == PageType.SETTING_LIST) {
|
||||||
startActivity(Intent(this, FunActivity::class.java))
|
// startActivity(Intent(this, FunActivity::class.java))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,362 @@
|
|||||||
|
package com.sw.platecabinet.activity
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import com.sw.plate.utils.ToastUtils
|
||||||
|
import com.sw.plate.utils.arcface.faceserver.FaceServer
|
||||||
|
import com.sw.platecabinet.databinding.ActivityPlcSettingBinding
|
||||||
|
import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
||||||
|
import com.sw.platecabinet.dialog.EnvSwitchDialog
|
||||||
|
import com.sw.platecabinet.ext.clickWithDebounce
|
||||||
|
import com.sw.platecabinet.utils.mego.PlcCallback
|
||||||
|
import com.sw.platecabinet.utils.mego.PlcHelper
|
||||||
|
import com.sw.platecabinet.utils.mego.PlcStatus
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PLC 控制设置界面
|
||||||
|
* 通过右侧时间双击(onRightDoubleClick)打开,提供全套 PLC 控制操作入口
|
||||||
|
*/
|
||||||
|
class PlcSettingActivity : BaseActivity<ActivityPlcSettingBinding>() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/** Intent Extra 键:是否显示 tips 界面 */
|
||||||
|
private const val EXTRA_SHOW_TIPS = "extra_show_tips"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动 PlcSettingActivity
|
||||||
|
* @param showTips 是否显示 tips 界面(暂无餐盘提示)
|
||||||
|
*/
|
||||||
|
fun start(context: Context, showTips: Boolean = false) {
|
||||||
|
val intent = Intent(context, PlcSettingActivity::class.java)
|
||||||
|
intent.putExtra(EXTRA_SHOW_TIPS, showTips)
|
||||||
|
context.startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun inflateViewBinding(): ActivityPlcSettingBinding {
|
||||||
|
return ActivityPlcSettingBinding.inflate(layoutInflater)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun inflateTitleBinding(): ItemTitleTimeBinding {
|
||||||
|
return binding.includeHeader
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun initialize() {
|
||||||
|
// 根据传入参数控制 tips 界面显示
|
||||||
|
val showTips = intent.getBooleanExtra(EXTRA_SHOW_TIPS, false)
|
||||||
|
binding.layoutTips.visibility =
|
||||||
|
if (showTips) android.view.View.VISIBLE else android.view.View.GONE
|
||||||
|
|
||||||
|
initConnectButtons()
|
||||||
|
initOutPlateButton()
|
||||||
|
initPlatformButtons()
|
||||||
|
initPlatformResetButton()
|
||||||
|
initAlarmButton()
|
||||||
|
initParamButtons()
|
||||||
|
initStatusButton()
|
||||||
|
binding.btnSwitchEnv.setOnClickListener {
|
||||||
|
EnvSwitchDialog(context = this, onEnvChanged = {
|
||||||
|
showWaitingDialog("重置人脸数据中……")
|
||||||
|
lifecycleScope.launch {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
FaceServer.getInstance().clearAllFaces()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
userViewModel.getUserFaceCache(pageNo = 1, callback = { state, errMsg ->
|
||||||
|
hideWaitingDialog()
|
||||||
|
if (state) {
|
||||||
|
recognizeViewModel.refreshFaceList()
|
||||||
|
ToastUtils.showToast("人脸数据已更新")
|
||||||
|
} else {
|
||||||
|
ToastUtils.showToast(errMsg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.tvTips.clickWithDebounce {
|
||||||
|
binding.layoutTips.visibility = android.view.View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 连接控制 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化连接控制区按钮:打开串口、打开自动模式
|
||||||
|
*/
|
||||||
|
private fun initConnectButtons() {
|
||||||
|
binding.btnOpenSerialPort.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在打开串口……")
|
||||||
|
PlcHelper.getInstance(this).openSerialPort(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("打开串口成功:$result")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("打开串口失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.btnOpenAutoMode.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在打开自动模式……")
|
||||||
|
PlcHelper.getInstance(this).openAutoMode(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("打开自动模式成功:$result")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("打开自动模式失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 出盘操作 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化出盘操作按钮
|
||||||
|
*/
|
||||||
|
private fun initOutPlateButton() {
|
||||||
|
binding.btnOutPlate.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在出盘……")
|
||||||
|
PlcHelper.getInstance(this).outPlate(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("出盘成功:$result")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("出盘失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 平台控制 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化平台控制区按钮:平台下降、平台上升、返回营业
|
||||||
|
*/
|
||||||
|
private fun initPlatformButtons() {
|
||||||
|
binding.btnPlatformDown.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在执行平台下降……")
|
||||||
|
PlcHelper.getInstance(this).platformDown(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("平台下降成功:$result")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("平台下降失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.btnPlatformUp.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在执行平台上升……")
|
||||||
|
PlcHelper.getInstance(this).platformUp(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("平台上升成功:$result")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("平台上升失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.btnBackToBusiness.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在返回营业状态……")
|
||||||
|
PlcHelper.getInstance(this).backToBusiness(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("返回营业成功:$result")
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("返回营业失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 故障处理 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化平台复位按钮:先执行平台上升,成功后自动执行返回营业
|
||||||
|
*/
|
||||||
|
private fun initPlatformResetButton() {
|
||||||
|
binding.btnPlatformReset.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在复位平台……")
|
||||||
|
PlcHelper.getInstance(this).platformUp(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
// 平台上升完成,继续执行返回营业
|
||||||
|
PlcHelper.getInstance(this@PlcSettingActivity)
|
||||||
|
.backToBusiness(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("平台复位成功")
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("返回营业失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("平台上升失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化故障复位按钮
|
||||||
|
*/
|
||||||
|
private fun initAlarmButton() {
|
||||||
|
binding.btnAlarmReset.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在故障复位……")
|
||||||
|
PlcHelper.getInstance(this).alarmReset(object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("故障复位成功:$result")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("故障复位失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 参数设置 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化参数设置按钮
|
||||||
|
* 读取参数类型和参数值输入框内容,调用 setParams
|
||||||
|
*/
|
||||||
|
private fun initParamButtons() {
|
||||||
|
binding.btnSetParams.clickWithDebounce {
|
||||||
|
val paramType = binding.etParamType.text.toString().trim()
|
||||||
|
val paramValueStr = binding.etParamValue.text.toString().trim()
|
||||||
|
|
||||||
|
if (paramType.isEmpty()) {
|
||||||
|
ToastUtils.showToast("请输入参数类型")
|
||||||
|
return@clickWithDebounce
|
||||||
|
}
|
||||||
|
if (paramValueStr.isEmpty()) {
|
||||||
|
ToastUtils.showToast("请输入参数值")
|
||||||
|
return@clickWithDebounce
|
||||||
|
}
|
||||||
|
val paramValue = paramValueStr.toIntOrNull()
|
||||||
|
if (paramValue == null) {
|
||||||
|
ToastUtils.showToast("参数值须为整数")
|
||||||
|
return@clickWithDebounce
|
||||||
|
}
|
||||||
|
|
||||||
|
// 隐藏键盘
|
||||||
|
hideKeyboard()
|
||||||
|
|
||||||
|
showWaitingDialog("正在设置参数……")
|
||||||
|
PlcHelper.getInstance(this).setParams(
|
||||||
|
paramType,
|
||||||
|
paramValue,
|
||||||
|
object : PlcCallback<String> {
|
||||||
|
override fun onSuccess(result: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("参数设置成功:$result")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
ToastUtils.showToast("参数设置失败:$message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 状态显示 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化状态刷新按钮,获取 PLC 状态并格式化展示
|
||||||
|
*/
|
||||||
|
private fun initStatusButton() {
|
||||||
|
binding.btnRefreshStatus.clickWithDebounce {
|
||||||
|
showWaitingDialog("正在获取状态……")
|
||||||
|
PlcHelper.getInstance(this).getStatus(object : PlcCallback<PlcStatus> {
|
||||||
|
override fun onSuccess(result: PlcStatus) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
binding.tvStatusInfo.text = buildStatusText(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(message: String) {
|
||||||
|
hideWaitingDialog()
|
||||||
|
binding.tvStatusInfo.text = "获取状态失败:$message"
|
||||||
|
ToastUtils.showToast("获取状态失败:$message")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 PlcStatus 格式化为多行可读文本
|
||||||
|
*/
|
||||||
|
private fun buildStatusText(status: PlcStatus): String {
|
||||||
|
return """
|
||||||
|
空盘状态:${if (status.isEmptyPlate) "是(无餐盘)" else "否(有餐盘)"}
|
||||||
|
平台下位:${if (status.isPlateformDown) "是" else "否"}
|
||||||
|
平台上位:${if (status.isPlateformUp) "是" else "否"}
|
||||||
|
取盘红外:${if (status.isTakePlateInfrared) "已触发" else "未触发"}
|
||||||
|
报警代码:${if (status.alarmCode == 0) "正常(0)" else "异常(${status.alarmCode})"}
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 生命周期 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 左侧日期双击 → 关闭设置界面
|
||||||
|
*/
|
||||||
|
override fun onLeftDoubleClick() {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 右侧时间双击 → 不做操作,防止循环打开
|
||||||
|
*/
|
||||||
|
override fun onRightDoubleClick() {
|
||||||
|
// 空实现,避免在设置页再次触发跳转
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 工具方法 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐藏软键盘
|
||||||
|
*/
|
||||||
|
private fun hideKeyboard() {
|
||||||
|
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
imm.hideSoftInputFromWindow(currentFocus?.windowToken, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
package com.sw.platecabinet.activity
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.sw.platecabinet.R
|
|
||||||
import kotlin.math.ceil
|
|
||||||
|
|
||||||
class TestActivity : AppCompatActivity() {
|
|
||||||
private lateinit var parentRecyclerView: RecyclerView
|
|
||||||
private lateinit var pageAdapter: PageAdapter
|
|
||||||
private val itemsPerPage = 22 // 每行2个,每列11个,共22个
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.activity_test)
|
|
||||||
|
|
||||||
parentRecyclerView = findViewById(R.id.parentRecyclerView)
|
|
||||||
parentRecyclerView.layoutManager = LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)
|
|
||||||
|
|
||||||
// 假设有100个数据项
|
|
||||||
val allItems = (1..30).map { "Item $it" }
|
|
||||||
val pages = allItems.chunked(itemsPerPage)
|
|
||||||
|
|
||||||
pageAdapter = PageAdapter(pages)
|
|
||||||
parentRecyclerView.adapter = pageAdapter
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun convertToColumnFirst(original: List<String>, cols: Int): List<String> {
|
|
||||||
val rows = ceil(original.size.toDouble() / cols).toInt()
|
|
||||||
return List(original.size) { pos ->
|
|
||||||
val row = pos % rows
|
|
||||||
val col = pos / rows
|
|
||||||
val originalPos = col + row * cols
|
|
||||||
original.getOrElse(originalPos) { "" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class PageAdapter(private val pages: List<List<String>>) :
|
|
||||||
RecyclerView.Adapter<PageAdapter.PageViewHolder>() {
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PageViewHolder {
|
|
||||||
val view = LayoutInflater.from(parent.context)
|
|
||||||
.inflate(R.layout.page_item_layout, parent, false)
|
|
||||||
return PageViewHolder(view)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: PageViewHolder, position: Int) {
|
|
||||||
holder.bind(pages[position])
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int = pages.size
|
|
||||||
|
|
||||||
inner class PageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|
||||||
private val childRecyclerView: RecyclerView =
|
|
||||||
itemView.findViewById(R.id.childRecyclerView)
|
|
||||||
|
|
||||||
fun bind(items: List<String>) {
|
|
||||||
childRecyclerView.layoutManager = GridLayoutManager(itemView.context, 2)
|
|
||||||
childRecyclerView.adapter = ChildAdapter(items)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class ChildAdapter(private val items: List<String>) :
|
|
||||||
RecyclerView.Adapter<ChildAdapter.ItemViewHolder>() {
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
|
|
||||||
val view = LayoutInflater.from(parent.context)
|
|
||||||
.inflate(R.layout.item_bind_view, parent, false)
|
|
||||||
return ItemViewHolder(view)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
|
|
||||||
holder.bind(position, items[position])
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int = items.size
|
|
||||||
|
|
||||||
inner class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|
||||||
private val llRoot: LinearLayout = itemView.findViewById(R.id.ll_root)
|
|
||||||
private val tvNum: TextView = itemView.findViewById(R.id.tv_num)
|
|
||||||
|
|
||||||
fun bind(position: Int, item: String) {
|
|
||||||
tvNum.text = item
|
|
||||||
llRoot.setBackgroundResource(if (position % 3 == 0) R.drawable.grid_item_bind else R.drawable.grid_item_unbind)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
//package com.sw.platecabinet.activity
|
|
||||||
//
|
|
||||||
//import android.graphics.Color
|
|
||||||
//import android.view.Gravity
|
|
||||||
//import android.view.ViewGroup
|
|
||||||
//import androidx.core.graphics.drawable.toDrawable
|
|
||||||
//import androidx.core.view.WindowCompat
|
|
||||||
//import com.sw.platecabinet.GlobalKey
|
|
||||||
//import com.sw.platecabinet.databinding.ActivityUnbindDialogBinding
|
|
||||||
//import com.sw.platecabinet.databinding.ItemTitleTimeBinding
|
|
||||||
//import com.sw.platecabinet.ext.dp
|
|
||||||
//import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 解绑确认弹窗界面
|
|
||||||
// */
|
|
||||||
//class UnBindDialogActivity : BaseActivity<ActivityUnbindDialogBinding>() {
|
|
||||||
// private var equipmentUserInfo: EquipmentUserInfo? = null
|
|
||||||
//
|
|
||||||
// override fun inflateViewBinding(): ActivityUnbindDialogBinding {
|
|
||||||
// return ActivityUnbindDialogBinding.inflate(layoutInflater)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun inflateTitleBinding(): ItemTitleTimeBinding? {
|
|
||||||
// return null
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun initialize() {
|
|
||||||
// window?.apply {
|
|
||||||
// WindowCompat.setDecorFitsSystemWindows(this, false)
|
|
||||||
// setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
|
|
||||||
//
|
|
||||||
// attributes = attributes.apply {
|
|
||||||
// y = 314.dp
|
|
||||||
// width = (context.resources.displayMetrics.widthPixels * 0.8).toInt()
|
|
||||||
// height = ViewGroup.LayoutParams.MATCH_PARENT
|
|
||||||
// gravity = Gravity.CENTER
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// equipmentUserInfo =
|
|
||||||
// intent.getParcelableExtra<EquipmentUserInfo>(GlobalKey.PARAM_EQUIPMENT_INFO)
|
|
||||||
// if (equipmentUserInfo == null) return
|
|
||||||
// binding.tvTipInfo.text = "即将解除【${equipmentUserInfo!!.name}】的餐盘"
|
|
||||||
// binding.tvCancel.setOnClickListener {
|
|
||||||
// finish()
|
|
||||||
// }
|
|
||||||
// binding.tvConfirm.setOnClickListener {
|
|
||||||
// setResult(RESULT_OK)
|
|
||||||
// finish()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun finish() {
|
|
||||||
// super.finish()
|
|
||||||
// overridePendingTransition(0, 0) // 确保退出也无动画
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,36 +1,36 @@
|
|||||||
package com.sw.platecabinet.dialog
|
//package com.sw.platecabinet.dialog
|
||||||
|
//
|
||||||
import android.app.Dialog
|
//import android.app.Dialog
|
||||||
import android.graphics.drawable.ColorDrawable
|
//import android.graphics.drawable.ColorDrawable
|
||||||
import android.os.Bundle
|
//import android.os.Bundle
|
||||||
import android.view.Window
|
//import android.view.Window
|
||||||
import androidx.fragment.app.FragmentActivity
|
//import androidx.fragment.app.FragmentActivity
|
||||||
import com.sw.platecabinet.databinding.DialogBalanceNotEnoughBinding
|
//import com.sw.platecabinet.databinding.DialogBalanceNotEnoughBinding
|
||||||
import com.sw.platecabinet.ext.dp
|
//import com.sw.platecabinet.ext.dp
|
||||||
|
//
|
||||||
open class BalanceNotEnoughDialog(
|
//open class BalanceNotEnoughDialog(
|
||||||
private var activity: FragmentActivity
|
// private var activity: FragmentActivity
|
||||||
) : Dialog(activity) {
|
//) : Dialog(activity) {
|
||||||
|
//
|
||||||
private lateinit var binding: DialogBalanceNotEnoughBinding
|
// private lateinit var binding: DialogBalanceNotEnoughBinding
|
||||||
|
//
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
// override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
// super.onCreate(savedInstanceState)
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
// requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
binding = DialogBalanceNotEnoughBinding.inflate(layoutInflater)
|
// binding = DialogBalanceNotEnoughBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
// setContentView(binding.root)
|
||||||
window?.run {
|
// window?.run {
|
||||||
attributes = attributes.apply {
|
// attributes = attributes.apply {
|
||||||
width = 480.dp
|
// width = 480.dp
|
||||||
}
|
// }
|
||||||
setBackgroundDrawable(ColorDrawable())
|
// setBackgroundDrawable(ColorDrawable())
|
||||||
setCancelable(false)
|
// setCancelable(false)
|
||||||
}
|
// }
|
||||||
addListener()
|
// addListener()
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun addListener() {
|
// private fun addListener() {
|
||||||
binding.tvConfirm.setOnClickListener { dismiss() }
|
// binding.tvConfirm.setOnClickListener { dismiss() }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.sw.platecabinet.dialog
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.drawable.ColorDrawable
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.view.View
|
||||||
|
import com.sw.platecabinet.R
|
||||||
|
import com.sw.platecabinet.ext.dp
|
||||||
|
import com.sw.platecabinet.ext.hideKeyboard
|
||||||
|
|
||||||
|
abstract class BaseDialog(
|
||||||
|
context: Context,
|
||||||
|
var defWidth: Int = 400.dp,
|
||||||
|
var defHeight: Int = 300.dp
|
||||||
|
) : Dialog(context, R.style.MyDialog) {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
val rootView = getRootView()
|
||||||
|
setContentView(rootView)
|
||||||
|
setCancelable(false)
|
||||||
|
setCanceledOnTouchOutside(false)
|
||||||
|
window?.apply {
|
||||||
|
setLayout(defWidth, defHeight)
|
||||||
|
setBackgroundDrawable(ColorDrawable())
|
||||||
|
setGravity(Gravity.CENTER)
|
||||||
|
}
|
||||||
|
rootView.setOnClickListener { it.hideKeyboard() }
|
||||||
|
initView()
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract fun getRootView(): View
|
||||||
|
|
||||||
|
abstract fun initView()
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.sw.platecabinet.dialog
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.WindowManager
|
||||||
|
import com.sw.plate.utils.ToastUtils
|
||||||
|
import com.sw.platecabinet.GlobalData
|
||||||
|
import com.sw.platecabinet.databinding.DialogEnvSwitchBinding
|
||||||
|
import com.sw.platecabinet.ext.dp
|
||||||
|
import com.sw.platecabinet.utils.SpTool
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环境切换弹窗
|
||||||
|
*
|
||||||
|
* 提供 TEST / UAT / PROD 三套环境的切换功能,
|
||||||
|
* 初始化时自动根据 [GlobalData.appBaseUrl] 选中当前环境,
|
||||||
|
* 确认后更新 [GlobalData.appBaseUrl] 并通过 [onEnvChanged] 回调通知外部。
|
||||||
|
*
|
||||||
|
* @param context 上下文
|
||||||
|
* @param onEnvChanged 确认切换后的回调,参数为新的 baseUrl
|
||||||
|
*/
|
||||||
|
class EnvSwitchDialog(
|
||||||
|
context: Context,
|
||||||
|
private val onEnvChanged: (newBaseUrl: String) -> Unit = {}
|
||||||
|
) : BaseDialog(
|
||||||
|
context,
|
||||||
|
defWidth = 600.dp,
|
||||||
|
defHeight = WindowManager.LayoutParams.WRAP_CONTENT
|
||||||
|
) {
|
||||||
|
|
||||||
|
private lateinit var binding: DialogEnvSwitchBinding
|
||||||
|
|
||||||
|
override fun getRootView(): View {
|
||||||
|
binding = DialogEnvSwitchBinding.inflate(LayoutInflater.from(context))
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun initView() {
|
||||||
|
// 根据当前 appBaseUrl 预选对应 RadioButton,不匹配则不选
|
||||||
|
when (GlobalData.appBaseUrl) {
|
||||||
|
GlobalData.TEST_BASE_URL -> binding.rbTest.isChecked = true
|
||||||
|
GlobalData.UAT_BASE_URL -> binding.rbUat.isChecked = true
|
||||||
|
GlobalData.PROD_BASE_URL -> binding.rbProd.isChecked = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
binding.btnCancel.setOnClickListener { dismiss() }
|
||||||
|
|
||||||
|
// 确认按钮
|
||||||
|
binding.btnConfirm.setOnClickListener {
|
||||||
|
// 未选中任何选项时提示用户
|
||||||
|
if (binding.rgEnv.checkedRadioButtonId == -1) {
|
||||||
|
ToastUtils.showToast("请选择环境")
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
val newUrl = when (binding.rgEnv.checkedRadioButtonId) {
|
||||||
|
binding.rbTest.id -> GlobalData.TEST_BASE_URL
|
||||||
|
binding.rbUat.id -> GlobalData.UAT_BASE_URL
|
||||||
|
binding.rbProd.id -> GlobalData.PROD_BASE_URL
|
||||||
|
else -> return@setOnClickListener
|
||||||
|
}
|
||||||
|
GlobalData.appBaseUrl = newUrl
|
||||||
|
SpTool.baseUrl = newUrl
|
||||||
|
onEnvChanged(newUrl)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,38 +1,38 @@
|
|||||||
package com.sw.platecabinet.dialog
|
//package com.sw.platecabinet.dialog
|
||||||
|
//
|
||||||
import android.app.Dialog
|
//import android.app.Dialog
|
||||||
import android.graphics.drawable.ColorDrawable
|
//import android.graphics.drawable.ColorDrawable
|
||||||
import android.os.Bundle
|
//import android.os.Bundle
|
||||||
import android.view.Window
|
//import android.view.Window
|
||||||
import androidx.fragment.app.FragmentActivity
|
//import androidx.fragment.app.FragmentActivity
|
||||||
import com.sw.platecabinet.databinding.DialogUserBindRemindBinding
|
//import com.sw.platecabinet.databinding.DialogUserBindRemindBinding
|
||||||
import com.sw.platecabinet.ext.dp
|
//import com.sw.platecabinet.ext.dp
|
||||||
|
//
|
||||||
open class UserBindRemindDialog(
|
//open class UserBindRemindDialog(
|
||||||
private var activity: FragmentActivity,
|
// private var activity: FragmentActivity,
|
||||||
var content:String
|
// var content:String
|
||||||
) : Dialog(activity) {
|
//) : Dialog(activity) {
|
||||||
|
//
|
||||||
private lateinit var binding: DialogUserBindRemindBinding
|
// private lateinit var binding: DialogUserBindRemindBinding
|
||||||
|
//
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
// override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
// super.onCreate(savedInstanceState)
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
// requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
binding = DialogUserBindRemindBinding.inflate(layoutInflater)
|
// binding = DialogUserBindRemindBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
// setContentView(binding.root)
|
||||||
window?.run {
|
// window?.run {
|
||||||
attributes = attributes.apply {
|
// attributes = attributes.apply {
|
||||||
width = 480.dp
|
// width = 480.dp
|
||||||
}
|
// }
|
||||||
setBackgroundDrawable(ColorDrawable())
|
// setBackgroundDrawable(ColorDrawable())
|
||||||
setCancelable(false)
|
// setCancelable(false)
|
||||||
}
|
// }
|
||||||
binding.tvBindContent.text = content
|
// binding.tvBindContent.text = content
|
||||||
addListener()
|
// addListener()
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun addListener() {
|
// private fun addListener() {
|
||||||
binding.tvConfirm.setOnClickListener { dismiss() }
|
// binding.tvConfirm.setOnClickListener { dismiss() }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.sw.platecabinet.ext
|
package com.sw.platecabinet.ext
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.annotation.Dimension
|
import androidx.annotation.Dimension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,4 +65,12 @@ fun View.invisible() {
|
|||||||
|
|
||||||
fun View.gone() {
|
fun View.gone() {
|
||||||
visibility = View.GONE
|
visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐藏软键盘
|
||||||
|
*/
|
||||||
|
fun View.hideKeyboard() {
|
||||||
|
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
imm.hideSoftInputFromWindow(windowToken, 0)
|
||||||
}
|
}
|
||||||
@@ -8,21 +8,16 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.sw.platecabinet.R
|
import com.sw.platecabinet.R
|
||||||
import com.sw.platecabinet.view.CustomLoadingDialog
|
import com.sw.platecabinet.view.CustomLoadingDialog
|
||||||
import com.sw.platecabinet.viewmodel.SettingViewModel
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
abstract class BaseFragment<VB : ViewBinding>(
|
abstract class BaseFragment<VB : ViewBinding>(
|
||||||
private val bindingInflater: (inflater: LayoutInflater, parent: ViewGroup?, attachToParent: Boolean) -> VB
|
private val bindingInflater: (inflater: LayoutInflater, parent: ViewGroup?, attachToParent: Boolean) -> VB
|
||||||
) : Fragment() {
|
) : Fragment() {
|
||||||
private var _binding: VB? = null
|
protected var _binding: VB? = null
|
||||||
protected val binding get() = _binding!!
|
protected val binding get() = _binding!!
|
||||||
private var mDialogWaiting: CustomLoadingDialog? = null
|
private var mDialogWaiting: CustomLoadingDialog? = null
|
||||||
protected val viewModel by viewModels<SettingViewModel>()
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
@@ -39,15 +34,7 @@ abstract class BaseFragment<VB : ViewBinding>(
|
|||||||
* 注册数据变化监听
|
* 注册数据变化监听
|
||||||
*/
|
*/
|
||||||
open fun registerDataChange() {
|
open fun registerDataChange() {
|
||||||
lifecycleScope.launch {
|
|
||||||
viewModel.showLoading.collect {
|
|
||||||
if (it) {
|
|
||||||
showWaitingDialog("")
|
|
||||||
} else {
|
|
||||||
hideWaitingDialog()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun initialize()
|
abstract fun initialize()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import timber.log.Timber
|
|||||||
class PlateCabinetFullFragment :
|
class PlateCabinetFullFragment :
|
||||||
BaseFragment<FragmentPlateCabinetFullBinding>(FragmentPlateCabinetFullBinding::inflate) {
|
BaseFragment<FragmentPlateCabinetFullBinding>(FragmentPlateCabinetFullBinding::inflate) {
|
||||||
private var totalTimeInMillis: Long = Constants.AUTO_CLOSE_TIME * 1000
|
private var totalTimeInMillis: Long = Constants.AUTO_CLOSE_TIME * 1000
|
||||||
|
private var countDownTimer: CountDownTimer? = null
|
||||||
|
|
||||||
override fun initialize() {
|
override fun initialize() {
|
||||||
Timber.d("initialize")
|
Timber.d("initialize")
|
||||||
@@ -18,15 +19,22 @@ class PlateCabinetFullFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun initCountTime() {
|
fun initCountTime() {
|
||||||
object : CountDownTimer(totalTimeInMillis, 1000) {
|
countDownTimer = object : CountDownTimer(totalTimeInMillis, 1000) {
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
binding.tvAutoClose.text = "${(millisUntilFinished / 1000).toInt() + 1}秒后返回主屏"
|
_binding?.tvAutoClose?.text = "${(millisUntilFinished / 1000).toInt() + 1}秒后返回主屏"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinish() {
|
override fun onFinish() {
|
||||||
activity?.finish()
|
activity?.finish()
|
||||||
}
|
}
|
||||||
}.start()
|
}
|
||||||
|
countDownTimer?.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
countDownTimer?.cancel()
|
||||||
|
countDownTimer = null
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ import com.sw.platecabinet.Constants
|
|||||||
import com.sw.platecabinet.R
|
import com.sw.platecabinet.R
|
||||||
import com.sw.platecabinet.activity.InitActivity
|
import com.sw.platecabinet.activity.InitActivity
|
||||||
import com.sw.platecabinet.databinding.FragmentPlateOpenBinding
|
import com.sw.platecabinet.databinding.FragmentPlateOpenBinding
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 餐盘柜提示界面
|
* 餐盘柜提示界面
|
||||||
@@ -21,6 +20,7 @@ class PlateOpenFragment :
|
|||||||
// private var isAdmin: Boolean = false
|
// private var isAdmin: Boolean = false
|
||||||
|
|
||||||
private var isScanCode = false
|
private var isScanCode = false
|
||||||
|
private var countDownTimer: CountDownTimer? = null
|
||||||
companion object {
|
companion object {
|
||||||
const val IS_SCAN_CODE = "isScanCode"
|
const val IS_SCAN_CODE = "isScanCode"
|
||||||
// @JvmStatic
|
// @JvmStatic
|
||||||
@@ -76,19 +76,23 @@ class PlateOpenFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun initCountTime() {
|
fun initCountTime() {
|
||||||
object : CountDownTimer(totalTimeInMillis, 1000) {
|
countDownTimer = object : CountDownTimer(totalTimeInMillis, 1000) {
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
binding.tvAutoClose.text = ((millisUntilFinished / 1000).toInt() + 1).toString()
|
_binding?.tvAutoClose?.text = ((millisUntilFinished / 1000).toInt() + 1).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinish() {
|
override fun onFinish() {
|
||||||
|
val ctx = context ?: return
|
||||||
activity?.finish()
|
activity?.finish()
|
||||||
// if (!isAdmin) {
|
ctx.startActivity(Intent(ctx, InitActivity::class.java))
|
||||||
val intent = Intent(context, InitActivity::class.java)
|
|
||||||
startActivity(intent)
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}.start()
|
}
|
||||||
|
countDownTimer?.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
countDownTimer?.cancel()
|
||||||
|
countDownTimer = null
|
||||||
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,241 +1,241 @@
|
|||||||
package com.sw.platecabinet.fragment
|
//package com.sw.platecabinet.fragment
|
||||||
|
//
|
||||||
import android.view.View
|
//import android.view.View
|
||||||
import androidx.core.view.isVisible
|
//import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.lifecycleScope
|
//import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
//import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
//import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
//import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.sw.inbound.utils.DateTimeUtils
|
//import com.sw.inbound.utils.DateTimeUtils
|
||||||
import com.sw.plate.utils.ToastUtils
|
//import com.sw.plate.utils.ToastUtils
|
||||||
import com.sw.plate.utils.comn.SerialApi
|
//import com.sw.plate.utils.comn.SerialApi
|
||||||
import com.sw.plate.utils.comn.SerialPortManager
|
//import com.sw.plate.utils.comn.SerialPortManager
|
||||||
import com.sw.platecabinet.GlobalData
|
//import com.sw.platecabinet.GlobalData
|
||||||
import com.sw.platecabinet.MyApp
|
//import com.sw.platecabinet.MyApp
|
||||||
import com.sw.platecabinet.R
|
//import com.sw.platecabinet.R
|
||||||
import com.sw.platecabinet.activity.BaseActivity
|
//import com.sw.platecabinet.activity.BaseActivity
|
||||||
import com.sw.platecabinet.activity.MainActivity
|
//import com.sw.platecabinet.activity.MainActivity
|
||||||
import com.sw.platecabinet.activity.PageType
|
//import com.sw.platecabinet.activity.PageType
|
||||||
import com.sw.platecabinet.adapter.GenericItemAdapter
|
//import com.sw.platecabinet.adapter.GenericItemAdapter
|
||||||
import com.sw.platecabinet.adapter.GenericPageAdapter
|
//import com.sw.platecabinet.adapter.GenericPageAdapter
|
||||||
import com.sw.platecabinet.adapter.GridSpacingItemDecoration
|
//import com.sw.platecabinet.adapter.GridSpacingItemDecoration
|
||||||
import com.sw.platecabinet.adapter.dpToPx
|
//import com.sw.platecabinet.adapter.dpToPx
|
||||||
import com.sw.platecabinet.databinding.FragmentSettingListBinding
|
//import com.sw.platecabinet.databinding.FragmentSettingListBinding
|
||||||
import com.sw.platecabinet.databinding.ItemBindViewBinding
|
//import com.sw.platecabinet.databinding.ItemBindViewBinding
|
||||||
import com.sw.platecabinet.ext.formatNumber
|
//import com.sw.platecabinet.ext.formatNumber
|
||||||
import com.sw.platecabinet.ext.maskName
|
//import com.sw.platecabinet.ext.maskName
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
//import com.sw.platecabinet.model.response.EquipmentUserInfo
|
||||||
import com.sw.platecabinet.utils.ListArrangementUtil
|
//import com.sw.platecabinet.utils.ListArrangementUtil
|
||||||
import com.sw.platecabinet.utils.PlateUtils
|
//import com.sw.platecabinet.utils.PlateUtils
|
||||||
import com.sw.platecabinet.utils.SpTool
|
//import com.sw.platecabinet.utils.SpTool
|
||||||
import kotlinx.coroutines.Dispatchers
|
//import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
//import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
//import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
//import timber.log.Timber
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 餐盘柜绑定的用户列表界面
|
// * 餐盘柜绑定的用户列表界面
|
||||||
*/
|
// */
|
||||||
class SettingListFragment :
|
//class SettingListFragment :
|
||||||
BaseFragment<FragmentSettingListBinding>(FragmentSettingListBinding::inflate) {
|
// BaseFragment<FragmentSettingListBinding>(FragmentSettingListBinding::inflate) {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 需要横向滚动的adapter
|
// * 需要横向滚动的adapter
|
||||||
*/
|
// */
|
||||||
private var pageAdapter: GenericPageAdapter<EquipmentUserInfo, ItemBindViewBinding>? = null
|
// private var pageAdapter: GenericPageAdapter<EquipmentUserInfo, ItemBindViewBinding>? = null
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 垂直滚动的adapter
|
// * 垂直滚动的adapter
|
||||||
*/
|
// */
|
||||||
private var itemAdapter: GenericItemAdapter<EquipmentUserInfo, ItemBindViewBinding>? = null
|
// private var itemAdapter: GenericItemAdapter<EquipmentUserInfo, ItemBindViewBinding>? = null
|
||||||
|
//
|
||||||
override fun registerDataChange() {
|
// override fun registerDataChange() {
|
||||||
super.registerDataChange()
|
// super.registerDataChange()
|
||||||
// lifecycleScope.launch {
|
//// lifecycleScope.launch {
|
||||||
// viewModel.equipmentList.collect { it ->
|
//// viewModel.equipmentList.collect { it ->
|
||||||
// Timber.d("registerDateChange updateAdapter it = $it")
|
//// Timber.d("registerDateChange updateAdapter it = $it")
|
||||||
// updateAdapter(it)
|
//// updateAdapter(it)
|
||||||
// }
|
//// }
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun initialize() {
|
|
||||||
binding.mainRecyclerView.apply {
|
|
||||||
if (GlobalData.arrayCross > 2) {
|
|
||||||
layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
|
||||||
pageAdapter = createPageAdapter()
|
|
||||||
adapter = pageAdapter
|
|
||||||
} else {
|
|
||||||
layoutManager = GridLayoutManager(context, 2)
|
|
||||||
// 添加间距装饰(12dp)
|
|
||||||
addItemDecoration(
|
|
||||||
GridSpacingItemDecoration(
|
|
||||||
spanCount = 2,
|
|
||||||
spacing = requireContext().dpToPx(12),
|
|
||||||
includeEdge = true // 包含边缘间距
|
|
||||||
)
|
|
||||||
)
|
|
||||||
itemAdapter = createItemAdapter()
|
|
||||||
adapter = itemAdapter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
|
||||||
super.onResume()
|
|
||||||
// viewModel.getEquipmentList{
|
|
||||||
// updateAdapter(it)
|
|
||||||
// }
|
|
||||||
MyApp.plateList?.let {
|
|
||||||
updateAdapter(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// private fun getPlateData(block: (List<EquipmentUserInfo>) -> Unit) {
|
|
||||||
// MyApp.plateList?.let {
|
|
||||||
// block(it)
|
|
||||||
// }
|
|
||||||
//// viewModel.getEquipmentList { items ->
|
|
||||||
//// block(items)
|
|
||||||
//// }
|
//// }
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
private fun createItemAdapter(): GenericItemAdapter<EquipmentUserInfo, ItemBindViewBinding> {
|
// override fun initialize() {
|
||||||
return GenericItemAdapter(
|
// binding.mainRecyclerView.apply {
|
||||||
items = emptyList(),
|
// if (GlobalData.arrayCross > 2) {
|
||||||
bindingInflater = ItemBindViewBinding::inflate,
|
// layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
||||||
bindCallback = { item, position ->
|
// pageAdapter = createPageAdapter()
|
||||||
setItemInfo(item, position)
|
// adapter = pageAdapter
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createPageAdapter(): GenericPageAdapter<EquipmentUserInfo, ItemBindViewBinding> {
|
|
||||||
return GenericPageAdapter(
|
|
||||||
pages = emptyList(),
|
|
||||||
pageLayoutId = R.layout.page_item_layout,
|
|
||||||
itemBindingInflater = ItemBindViewBinding::inflate,
|
|
||||||
itemBindCallback = { item, position ->
|
|
||||||
setItemInfo(item, position)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ItemBindViewBinding.setItemInfo(
|
|
||||||
item: EquipmentUserInfo,
|
|
||||||
position: Int
|
|
||||||
) {
|
|
||||||
// if (item.isPlaceholder()) {
|
|
||||||
// this.llRoot.isVisible = false
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
this.llRoot.isVisible = true
|
|
||||||
this.tvNum.text = formatNumber(item.equipmentBoxCode ?: "")
|
|
||||||
if (item.plateNumber.isNullOrBlank().not()) {
|
|
||||||
// val date = DateTimeUtils.parseDateTime(item.updateTime)
|
|
||||||
// val timeInMillis = date?.time ?: 0L
|
|
||||||
// val isOldTime = DateTimeUtils.isMoreThanHoursFromNow(timeInMillis)
|
|
||||||
|
|
||||||
this.llRoot.setBackgroundResource(R.drawable.grid_item_bind)
|
|
||||||
this.tvNum.setTextColor(resources.getColor(R.color.bind_4E535D))
|
|
||||||
// this.tvLastTime.setTextColor(
|
|
||||||
// if (isOldTime) resources.getColor(R.color.bind_time_old) else resources.getColor(
|
|
||||||
// R.color.bind_585868
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
this.llOpen.setBackgroundResource(R.drawable.grid_button_bind)
|
|
||||||
this.tvOpen.setTextColor(resources.getColor(R.color.bind_FFCC99))
|
|
||||||
this.llBindInfo.visibility = View.VISIBLE
|
|
||||||
this.tvUnbind.visibility = View.GONE
|
|
||||||
|
|
||||||
// this.tvName.text = item.name.maskName()
|
|
||||||
this.tvName.text = item.plateNumber
|
|
||||||
|
|
||||||
// this.tvLastTime.text = DateTimeUtils.getTimeAgo(date)
|
|
||||||
} else {
|
|
||||||
this.llRoot.setBackgroundResource(R.drawable.grid_item_unbind)
|
|
||||||
this.tvNum.setTextColor(resources.getColor(R.color.bind_FFCC99))
|
|
||||||
this.llOpen.setBackgroundResource(R.drawable.grid_button_unbind)
|
|
||||||
this.tvOpen.setTextColor(resources.getColor(R.color.unbind_32283C))
|
|
||||||
this.llBindInfo.visibility = View.GONE
|
|
||||||
this.tvUnbind.visibility = View.VISIBLE
|
|
||||||
// this.tvUnbind.text = "未绑定"
|
|
||||||
}
|
|
||||||
// this.llRoot.setOnClickListener {
|
|
||||||
//// Timber.d("itemClick llRoot ${item.name}, position = $position")
|
|
||||||
// if (item.isBound()) {
|
|
||||||
// MainActivity.start(
|
|
||||||
// requireContext(),
|
|
||||||
// pageType = PageType.UNBIND_PLATE,
|
|
||||||
// equipmentUserInfo = item
|
|
||||||
// )
|
|
||||||
// } else {
|
// } else {
|
||||||
// MainActivity.start(
|
// layoutManager = GridLayoutManager(context, 2)
|
||||||
// requireContext(),
|
// // 添加间距装饰(12dp)
|
||||||
// pageType = PageType.BIND_PLATE,
|
// addItemDecoration(
|
||||||
// equipmentUserInfo = item
|
// GridSpacingItemDecoration(
|
||||||
|
// spanCount = 2,
|
||||||
|
// spacing = requireContext().dpToPx(12),
|
||||||
|
// includeEdge = true // 包含边缘间距
|
||||||
|
// )
|
||||||
// )
|
// )
|
||||||
|
// itemAdapter = createItemAdapter()
|
||||||
|
// adapter = itemAdapter
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
this.llOpen.setOnClickListener {
|
//
|
||||||
// item.faceId = null
|
// }
|
||||||
PlateUtils.open(
|
//
|
||||||
fragmentActivity = requireActivity(),
|
// override fun onResume() {
|
||||||
code = item.equipmentBoxCode,
|
// super.onResume()
|
||||||
isScanCode = false,
|
//// viewModel.getEquipmentList{
|
||||||
isSetting = true
|
//// updateAdapter(it)
|
||||||
)
|
//// }
|
||||||
}
|
// MyApp.plateList?.let {
|
||||||
}
|
// updateAdapter(it)
|
||||||
|
// }
|
||||||
fun updateAdapter(items: List<EquipmentUserInfo>) {
|
// }
|
||||||
val itemsPerPage = 2 * GlobalData.arrayVertical // 每行2个,每列11个,共22个
|
//
|
||||||
if (GlobalData.arrayCross > 2) {
|
//// private fun getPlateData(block: (List<EquipmentUserInfo>) -> Unit) {
|
||||||
lifecycleScope.launch(Dispatchers.Default) {
|
//// MyApp.plateList?.let {
|
||||||
// 多recyclerview
|
//// block(it)
|
||||||
var pages = if (items.size > itemsPerPage) {
|
//// }
|
||||||
if (GlobalData.arrayMode == 0) {
|
////// viewModel.getEquipmentList { items ->
|
||||||
val pageList = items.chunked(itemsPerPage)
|
////// block(items)
|
||||||
pageList.mapIndexed { index, it ->
|
////// }
|
||||||
var itemList: MutableList<EquipmentUserInfo> = it.toMutableList()
|
//// }
|
||||||
if (index == pageList.size - 1) {
|
//
|
||||||
// 补全剩余item
|
// private fun createItemAdapter(): GenericItemAdapter<EquipmentUserInfo, ItemBindViewBinding> {
|
||||||
itemList = (itemList + List(itemsPerPage - itemList.size) {
|
// return GenericItemAdapter(
|
||||||
EquipmentUserInfo()
|
// items = emptyList(),
|
||||||
}) as MutableList<EquipmentUserInfo>
|
// bindingInflater = ItemBindViewBinding::inflate,
|
||||||
}
|
// bindCallback = { item, position ->
|
||||||
ListArrangementUtil.convertToColumnFirst(
|
// setItemInfo(item, position)
|
||||||
itemList,
|
// }
|
||||||
GlobalData.arrayVertical
|
// )
|
||||||
)
|
// }
|
||||||
}
|
//
|
||||||
} else {
|
// private fun createPageAdapter(): GenericPageAdapter<EquipmentUserInfo, ItemBindViewBinding> {
|
||||||
val newItems =
|
// return GenericPageAdapter(
|
||||||
ListArrangementUtil.horizontalSortPageItem(items, GlobalData.arrayCross)
|
// pages = emptyList(),
|
||||||
newItems.chunked(itemsPerPage)
|
// pageLayoutId = R.layout.page_item_layout,
|
||||||
}
|
// itemBindingInflater = ItemBindViewBinding::inflate,
|
||||||
} else {
|
// itemBindCallback = { item, position ->
|
||||||
listOf(
|
// setItemInfo(item, position)
|
||||||
items
|
// }
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
withContext(Dispatchers.Main) {
|
//
|
||||||
pageAdapter?.updatePages(pages)
|
// private fun ItemBindViewBinding.setItemInfo(
|
||||||
}
|
// item: EquipmentUserInfo,
|
||||||
}
|
// position: Int
|
||||||
} else {
|
// ) {
|
||||||
// 单 recyclerview
|
//// if (item.isPlaceholder()) {
|
||||||
lifecycleScope.launch(Dispatchers.Default) {
|
//// this.llRoot.isVisible = false
|
||||||
var pages = items
|
//// return
|
||||||
if (GlobalData.arrayMode == 0) {
|
//// }
|
||||||
pages = ListArrangementUtil.verticalSortItem(pages)
|
// this.llRoot.isVisible = true
|
||||||
}
|
// this.tvNum.text = formatNumber(item.equipmentBoxCode ?: "")
|
||||||
withContext(Dispatchers.Main) {
|
// if (item.plateNumber.isNullOrBlank().not()) {
|
||||||
itemAdapter?.updateData(pages)
|
//// val date = DateTimeUtils.parseDateTime(item.updateTime)
|
||||||
}
|
//// val timeInMillis = date?.time ?: 0L
|
||||||
}
|
//// val isOldTime = DateTimeUtils.isMoreThanHoursFromNow(timeInMillis)
|
||||||
}
|
//
|
||||||
binding.mainRecyclerView.scrollToPosition(0)
|
// this.llRoot.setBackgroundResource(R.drawable.grid_item_bind)
|
||||||
}
|
// this.tvNum.setTextColor(resources.getColor(R.color.bind_4E535D))
|
||||||
}
|
//// this.tvLastTime.setTextColor(
|
||||||
|
//// if (isOldTime) resources.getColor(R.color.bind_time_old) else resources.getColor(
|
||||||
|
//// R.color.bind_585868
|
||||||
|
//// )
|
||||||
|
//// )
|
||||||
|
// this.llOpen.setBackgroundResource(R.drawable.grid_button_bind)
|
||||||
|
// this.tvOpen.setTextColor(resources.getColor(R.color.bind_FFCC99))
|
||||||
|
// this.llBindInfo.visibility = View.VISIBLE
|
||||||
|
// this.tvUnbind.visibility = View.GONE
|
||||||
|
//
|
||||||
|
//// this.tvName.text = item.name.maskName()
|
||||||
|
// this.tvName.text = item.plateNumber
|
||||||
|
//
|
||||||
|
//// this.tvLastTime.text = DateTimeUtils.getTimeAgo(date)
|
||||||
|
// } else {
|
||||||
|
// this.llRoot.setBackgroundResource(R.drawable.grid_item_unbind)
|
||||||
|
// this.tvNum.setTextColor(resources.getColor(R.color.bind_FFCC99))
|
||||||
|
// this.llOpen.setBackgroundResource(R.drawable.grid_button_unbind)
|
||||||
|
// this.tvOpen.setTextColor(resources.getColor(R.color.unbind_32283C))
|
||||||
|
// this.llBindInfo.visibility = View.GONE
|
||||||
|
// this.tvUnbind.visibility = View.VISIBLE
|
||||||
|
//// this.tvUnbind.text = "未绑定"
|
||||||
|
// }
|
||||||
|
//// this.llRoot.setOnClickListener {
|
||||||
|
////// Timber.d("itemClick llRoot ${item.name}, position = $position")
|
||||||
|
//// if (item.isBound()) {
|
||||||
|
//// MainActivity.start(
|
||||||
|
//// requireContext(),
|
||||||
|
//// pageType = PageType.UNBIND_PLATE,
|
||||||
|
//// equipmentUserInfo = item
|
||||||
|
//// )
|
||||||
|
//// } else {
|
||||||
|
//// MainActivity.start(
|
||||||
|
//// requireContext(),
|
||||||
|
//// pageType = PageType.BIND_PLATE,
|
||||||
|
//// equipmentUserInfo = item
|
||||||
|
//// )
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
// this.llOpen.setOnClickListener {
|
||||||
|
//// item.faceId = null
|
||||||
|
// PlateUtils.open(
|
||||||
|
// fragmentActivity = requireActivity(),
|
||||||
|
// code = item.equipmentBoxCode,
|
||||||
|
// isScanCode = false,
|
||||||
|
// isSetting = true
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fun updateAdapter(items: List<EquipmentUserInfo>) {
|
||||||
|
// val itemsPerPage = 2 * GlobalData.arrayVertical // 每行2个,每列11个,共22个
|
||||||
|
// if (GlobalData.arrayCross > 2) {
|
||||||
|
// lifecycleScope.launch(Dispatchers.Default) {
|
||||||
|
// // 多recyclerview
|
||||||
|
// var pages = if (items.size > itemsPerPage) {
|
||||||
|
// if (GlobalData.arrayMode == 0) {
|
||||||
|
// val pageList = items.chunked(itemsPerPage)
|
||||||
|
// pageList.mapIndexed { index, it ->
|
||||||
|
// var itemList: MutableList<EquipmentUserInfo> = it.toMutableList()
|
||||||
|
// if (index == pageList.size - 1) {
|
||||||
|
// // 补全剩余item
|
||||||
|
// itemList = (itemList + List(itemsPerPage - itemList.size) {
|
||||||
|
// EquipmentUserInfo()
|
||||||
|
// }) as MutableList<EquipmentUserInfo>
|
||||||
|
// }
|
||||||
|
// ListArrangementUtil.convertToColumnFirst(
|
||||||
|
// itemList,
|
||||||
|
// GlobalData.arrayVertical
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// val newItems =
|
||||||
|
// ListArrangementUtil.horizontalSortPageItem(items, GlobalData.arrayCross)
|
||||||
|
// newItems.chunked(itemsPerPage)
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// listOf(
|
||||||
|
// items
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// withContext(Dispatchers.Main) {
|
||||||
|
// pageAdapter?.updatePages(pages)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // 单 recyclerview
|
||||||
|
// lifecycleScope.launch(Dispatchers.Default) {
|
||||||
|
// var pages = items
|
||||||
|
// if (GlobalData.arrayMode == 0) {
|
||||||
|
// pages = ListArrangementUtil.verticalSortItem(pages)
|
||||||
|
// }
|
||||||
|
// withContext(Dispatchers.Main) {
|
||||||
|
// itemAdapter?.updateData(pages)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// binding.mainRecyclerView.scrollToPosition(0)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -1,19 +1,17 @@
|
|||||||
package com.sw.platecabinet.model
|
package com.sw.platecabinet.model
|
||||||
|
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误信息 code == 200 成功
|
* 错误信息 code == 200 成功
|
||||||
*/
|
*/
|
||||||
data class ErrorInfo(
|
//data class ErrorInfo(
|
||||||
val code: String = "00000",
|
// val code: String = "00000",
|
||||||
val msg: String = "",
|
// val msg: String = "",
|
||||||
val equipmentUserInfo: EquipmentUserInfo? = null
|
// val equipmentUserInfo: EquipmentUserInfo? = null
|
||||||
) {
|
//) {
|
||||||
fun isSuccess(): Boolean {
|
// fun isSuccess(): Boolean {
|
||||||
return code == "00000"
|
// return code == "00000"
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
data class DeviceConfig(
|
data class DeviceConfig(
|
||||||
var arcsoftAppId: String? = null,
|
var arcsoftAppId: String? = null,
|
||||||
|
|||||||
@@ -1,72 +1,72 @@
|
|||||||
package com.sw.platecabinet.model.response
|
//package com.sw.platecabinet.model.response
|
||||||
|
//
|
||||||
|
//
|
||||||
import android.os.Parcelable
|
//import android.os.Parcelable
|
||||||
import com.google.gson.annotations.SerializedName
|
//import com.google.gson.annotations.SerializedName
|
||||||
import kotlinx.parcelize.Parcelize
|
//import kotlinx.parcelize.Parcelize
|
||||||
|
//
|
||||||
@Parcelize
|
//@Parcelize
|
||||||
data class EquipmentInfo(
|
//data class EquipmentInfo(
|
||||||
@SerializedName("appPackageLocalUrl")
|
// @SerializedName("appPackageLocalUrl")
|
||||||
val appPackageLocalUrl: String? = "",
|
// val appPackageLocalUrl: String? = "",
|
||||||
@SerializedName("appPackageUrl")
|
// @SerializedName("appPackageUrl")
|
||||||
val appPackageUrl: String? = "",
|
// val appPackageUrl: String? = "",
|
||||||
@SerializedName("arcsoftActiveKey")
|
// @SerializedName("arcsoftActiveKey")
|
||||||
val arcsoftActiveKey: String? = "",
|
// val arcsoftActiveKey: String? = "",
|
||||||
@SerializedName("arcsoftAppId")
|
// @SerializedName("arcsoftAppId")
|
||||||
val arcsoftAppId: String? = "",
|
// val arcsoftAppId: String? = "",
|
||||||
@SerializedName("arcsoftSdkKey")
|
// @SerializedName("arcsoftSdkKey")
|
||||||
val arcsoftSdkKey: String? = "",
|
// val arcsoftSdkKey: String? = "",
|
||||||
@SerializedName("arrayCross")
|
// @SerializedName("arrayCross")
|
||||||
val arrayCross: Int? = 0,
|
// val arrayCross: Int? = 0,
|
||||||
@SerializedName("arrayMode")
|
// @SerializedName("arrayMode")
|
||||||
val arrayMode: String? = "",
|
// val arrayMode: String? = "",
|
||||||
@SerializedName("arrayVertical")
|
// @SerializedName("arrayVertical")
|
||||||
val arrayVertical: Int? = 0,
|
// val arrayVertical: Int? = 0,
|
||||||
@SerializedName("canteenId")
|
// @SerializedName("canteenId")
|
||||||
val canteenId: String? = "",
|
// val canteenId: String? = "",
|
||||||
@SerializedName("canteenName")
|
// @SerializedName("canteenName")
|
||||||
val canteenName: String? = "",
|
// val canteenName: String? = "",
|
||||||
@SerializedName("clientServerIp")
|
// @SerializedName("clientServerIp")
|
||||||
val clientServerIp: String? = "",
|
// val clientServerIp: String? = "",
|
||||||
@SerializedName("createBy")
|
// @SerializedName("createBy")
|
||||||
val createBy: String? = "",
|
// val createBy: String? = "",
|
||||||
@SerializedName("createTime")
|
// @SerializedName("createTime")
|
||||||
val createTime: String? = "",
|
// val createTime: String? = "",
|
||||||
@SerializedName("customerName")
|
// @SerializedName("customerName")
|
||||||
val customerName: String? = "",
|
// val customerName: String? = "",
|
||||||
@SerializedName("equipmentCode")
|
// @SerializedName("equipmentCode")
|
||||||
val equipmentCode: String? = "",
|
// val equipmentCode: String? = "",
|
||||||
@SerializedName("equipmentName")
|
// @SerializedName("equipmentName")
|
||||||
val equipmentName: String? = "",
|
// val equipmentName: String? = "",
|
||||||
@SerializedName("equipmentName_dictText")
|
// @SerializedName("equipmentName_dictText")
|
||||||
val equipmentNameDictText: String? = "",
|
// val equipmentNameDictText: String? = "",
|
||||||
@SerializedName("id")
|
// @SerializedName("id")
|
||||||
val id: String? = "",
|
// val id: String? = "",
|
||||||
@SerializedName("isSync")
|
// @SerializedName("isSync")
|
||||||
val isSync: Int? = 0,
|
// val isSync: Int? = 0,
|
||||||
@SerializedName("mqName")
|
// @SerializedName("mqName")
|
||||||
val mqName: String? = "",
|
// val mqName: String? = "",
|
||||||
@SerializedName("mqPassword")
|
// @SerializedName("mqPassword")
|
||||||
val mqPassword: String? = "",
|
// val mqPassword: String? = "",
|
||||||
@SerializedName("orgCode")
|
// @SerializedName("orgCode")
|
||||||
val orgCode: String? = "",
|
// val orgCode: String? = "",
|
||||||
@SerializedName("owningTrack")
|
// @SerializedName("owningTrack")
|
||||||
val owningTrack: Int? = 0,
|
// val owningTrack: Int? = 0,
|
||||||
@SerializedName("owningTrackOrder")
|
// @SerializedName("owningTrackOrder")
|
||||||
val owningTrackOrder: Int? = 0,
|
// val owningTrackOrder: Int? = 0,
|
||||||
@SerializedName("screenHtml")
|
// @SerializedName("screenHtml")
|
||||||
val screenHtml: String? = "",
|
// val screenHtml: String? = "",
|
||||||
@SerializedName("serviceRequestAddress")
|
// @SerializedName("serviceRequestAddress")
|
||||||
val serviceRequestAddress: String? = "",
|
// val serviceRequestAddress: String? = "",
|
||||||
@SerializedName("status")
|
// @SerializedName("status")
|
||||||
val status: Int? = 0,
|
// val status: Int? = 0,
|
||||||
@SerializedName("sysOrgCode")
|
// @SerializedName("sysOrgCode")
|
||||||
val sysOrgCode: String? = "",
|
// val sysOrgCode: String? = "",
|
||||||
@SerializedName("updateBy")
|
// @SerializedName("updateBy")
|
||||||
val updateBy: String? = "",
|
// val updateBy: String? = "",
|
||||||
@SerializedName("updateTime")
|
// @SerializedName("updateTime")
|
||||||
val updateTime: String? = "",
|
// val updateTime: String? = "",
|
||||||
@SerializedName("zhstServerIp")
|
// @SerializedName("zhstServerIp")
|
||||||
val zhstServerIp: String? = ""
|
// val zhstServerIp: String? = ""
|
||||||
) : Parcelable
|
//) : Parcelable
|
||||||
@@ -1,90 +1,90 @@
|
|||||||
package com.sw.platecabinet.model.response
|
//package com.sw.platecabinet.model.response
|
||||||
|
//
|
||||||
import android.os.Parcelable
|
//import android.os.Parcelable
|
||||||
import android.text.TextUtils
|
//import android.text.TextUtils
|
||||||
//import com.google.gson.annotations.SerializedName
|
////import com.google.gson.annotations.SerializedName
|
||||||
import com.sw.platecabinet.GlobalData
|
//import com.sw.platecabinet.GlobalData
|
||||||
import kotlinx.parcelize.Parcelize
|
//import kotlinx.parcelize.Parcelize
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 设备绑定用户信息
|
// * 设备绑定用户信息
|
||||||
*/
|
// */
|
||||||
@Parcelize
|
//@Parcelize
|
||||||
data class EquipmentUserInfo(
|
//data class EquipmentUserInfo(
|
||||||
|
//// /**
|
||||||
|
//// * 主键
|
||||||
|
//// */
|
||||||
|
//// val id: Long? = 0,
|
||||||
|
//// /**
|
||||||
|
//// *
|
||||||
|
//// * 设备Id
|
||||||
|
//// */
|
||||||
|
//// val equipmentId: String? = "",
|
||||||
|
//// /**
|
||||||
|
//// * 设备编号
|
||||||
|
//// */
|
||||||
|
//// var equipmentCode: String? = "",
|
||||||
// /**
|
// /**
|
||||||
// * 主键
|
// * 设备盒子编号
|
||||||
// */
|
// */
|
||||||
// val id: Long? = 0,
|
// var equipmentBoxCode: String? = "",
|
||||||
|
// /**
|
||||||
|
// * 会员Id
|
||||||
|
// */
|
||||||
|
// var faceId: String? = "",
|
||||||
|
// /**
|
||||||
|
// * 餐盘编号
|
||||||
|
// */
|
||||||
|
// var plateNumber: String? = "",
|
||||||
|
//// /**
|
||||||
|
//// * 设备名称
|
||||||
|
//// */
|
||||||
|
//// val equipmentName: String? = "",
|
||||||
|
//
|
||||||
|
//// val orderNo: String? = "",
|
||||||
// /**
|
// /**
|
||||||
// *
|
// *
|
||||||
// * 设备Id
|
// * 更新时间
|
||||||
// */
|
// */
|
||||||
// val equipmentId: String? = "",
|
// var updateTime: String? = "",
|
||||||
// /**
|
|
||||||
// * 设备编号
|
|
||||||
// */
|
|
||||||
// var equipmentCode: String? = "",
|
|
||||||
/**
|
|
||||||
* 设备盒子编号
|
|
||||||
*/
|
|
||||||
var equipmentBoxCode: String? = "",
|
|
||||||
/**
|
|
||||||
* 会员Id
|
|
||||||
*/
|
|
||||||
var faceId: String? = "",
|
|
||||||
/**
|
|
||||||
* 餐盘编号
|
|
||||||
*/
|
|
||||||
var plateNumber: String? = "",
|
|
||||||
// /**
|
|
||||||
// * 设备名称
|
|
||||||
// */
|
|
||||||
// val equipmentName: String? = "",
|
|
||||||
|
|
||||||
// val orderNo: String? = "",
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
var updateTime: String? = "",
|
|
||||||
|
|
||||||
// val name: String? = "",
|
|
||||||
// val phone: String? = "",
|
|
||||||
// val faceUrl: String? = "",
|
|
||||||
// val mealTime: String? = "",
|
|
||||||
// val mealTimeInterval: String? = "",
|
|
||||||
// val openTime: String? = "",
|
|
||||||
// val openTimeInterval: String? = "",
|
|
||||||
// val eatCount: Int? = 0,
|
|
||||||
//
|
//
|
||||||
// var cardBalance: Double? = 0.toDouble(),
|
//// val name: String? = "",
|
||||||
|
//// val phone: String? = "",
|
||||||
// /**
|
//// val faceUrl: String? = "",
|
||||||
// * 用于cardBalance后续拦截判断
|
//// val mealTime: String? = "",
|
||||||
// */
|
//// val mealTimeInterval: String? = "",
|
||||||
// var showBalanceNotEnoughDialog: Boolean = false,
|
//// val openTime: String? = "",
|
||||||
// var isIntercept: Boolean = false
|
//// val openTimeInterval: String? = "",
|
||||||
) : Parcelable {
|
//// val eatCount: Int? = 0,
|
||||||
|
////
|
||||||
// /**
|
//// var cardBalance: Double? = 0.toDouble(),
|
||||||
// * 是否已绑定
|
|
||||||
// */
|
|
||||||
// fun isBound(): Boolean {
|
|
||||||
// return faceId.isNullOrBlank().not()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 是否是其他设备
|
|
||||||
// */
|
|
||||||
// fun isOtherEquipment(): Boolean {
|
|
||||||
// return equipmentCode != null && equipmentCode != "" && GlobalData.globalEquipmentCode != equipmentCode
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fun hasEquipmentBox(): Boolean {
|
|
||||||
// return !TextUtils.isEmpty(equipmentBoxCode)
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// fun isPlaceholder(): Boolean {
|
//// /**
|
||||||
// return equipmentBoxCode.isNullOrBlank()
|
//// * 用于cardBalance后续拦截判断
|
||||||
// }
|
//// */
|
||||||
}
|
//// var showBalanceNotEnoughDialog: Boolean = false,
|
||||||
|
//// var isIntercept: Boolean = false
|
||||||
|
//) : Parcelable {
|
||||||
|
//
|
||||||
|
//// /**
|
||||||
|
//// * 是否已绑定
|
||||||
|
//// */
|
||||||
|
//// fun isBound(): Boolean {
|
||||||
|
//// return faceId.isNullOrBlank().not()
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//// /**
|
||||||
|
//// * 是否是其他设备
|
||||||
|
//// */
|
||||||
|
//// fun isOtherEquipment(): Boolean {
|
||||||
|
//// return equipmentCode != null && equipmentCode != "" && GlobalData.globalEquipmentCode != equipmentCode
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//// fun hasEquipmentBox(): Boolean {
|
||||||
|
//// return !TextUtils.isEmpty(equipmentBoxCode)
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// fun isPlaceholder(): Boolean {
|
||||||
|
//// return equipmentBoxCode.isNullOrBlank()
|
||||||
|
//// }
|
||||||
|
//}
|
||||||
@@ -1,85 +1,85 @@
|
|||||||
package com.sw.platecabinet.model.response
|
//package com.sw.platecabinet.model.response
|
||||||
|
//
|
||||||
|
//
|
||||||
import android.os.Parcelable
|
//import android.os.Parcelable
|
||||||
import com.google.gson.annotations.SerializedName
|
//import com.google.gson.annotations.SerializedName
|
||||||
import kotlinx.parcelize.Parcelize
|
//import kotlinx.parcelize.Parcelize
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 搜索会员信息结果
|
// * 搜索会员信息结果
|
||||||
*/
|
// */
|
||||||
@Parcelize
|
//@Parcelize
|
||||||
data class SearchResult(
|
//data class SearchResult(
|
||||||
@SerializedName("endRow")
|
// @SerializedName("endRow")
|
||||||
val endRow: Int? = 0,
|
// val endRow: Int? = 0,
|
||||||
@SerializedName("hasNextPage")
|
// @SerializedName("hasNextPage")
|
||||||
val hasNextPage: Boolean? = false,
|
// val hasNextPage: Boolean? = false,
|
||||||
@SerializedName("hasPreviousPage")
|
// @SerializedName("hasPreviousPage")
|
||||||
val hasPreviousPage: Boolean? = false,
|
// val hasPreviousPage: Boolean? = false,
|
||||||
@SerializedName("isFirstPage")
|
// @SerializedName("isFirstPage")
|
||||||
val isFirstPage: Boolean? = false,
|
// val isFirstPage: Boolean? = false,
|
||||||
@SerializedName("isLastPage")
|
// @SerializedName("isLastPage")
|
||||||
val isLastPage: Boolean? = false,
|
// val isLastPage: Boolean? = false,
|
||||||
@SerializedName("list")
|
// @SerializedName("list")
|
||||||
val list: List<Member>? = listOf(),
|
// val list: List<Member>? = listOf(),
|
||||||
@SerializedName("navigateFirstPage")
|
// @SerializedName("navigateFirstPage")
|
||||||
val navigateFirstPage: Int? = 0,
|
// val navigateFirstPage: Int? = 0,
|
||||||
@SerializedName("navigateLastPage")
|
// @SerializedName("navigateLastPage")
|
||||||
val navigateLastPage: Int? = 0,
|
// val navigateLastPage: Int? = 0,
|
||||||
@SerializedName("navigatePages")
|
// @SerializedName("navigatePages")
|
||||||
val navigatePages: Int? = 0,
|
// val navigatePages: Int? = 0,
|
||||||
@SerializedName("navigatepageNums")
|
// @SerializedName("navigatepageNums")
|
||||||
val navigatepageNums: List<Int?>? = listOf(),
|
// val navigatepageNums: List<Int?>? = listOf(),
|
||||||
@SerializedName("nextPage")
|
// @SerializedName("nextPage")
|
||||||
val nextPage: Int? = 0,
|
// val nextPage: Int? = 0,
|
||||||
@SerializedName("pageNum")
|
// @SerializedName("pageNum")
|
||||||
val pageNum: Int? = 0,
|
// val pageNum: Int? = 0,
|
||||||
@SerializedName("pageSize")
|
// @SerializedName("pageSize")
|
||||||
val pageSize: Int? = 0,
|
// val pageSize: Int? = 0,
|
||||||
@SerializedName("pages")
|
// @SerializedName("pages")
|
||||||
val pages: Int? = 0,
|
// val pages: Int? = 0,
|
||||||
@SerializedName("prePage")
|
// @SerializedName("prePage")
|
||||||
val prePage: Int? = 0,
|
// val prePage: Int? = 0,
|
||||||
@SerializedName("size")
|
// @SerializedName("size")
|
||||||
val size: Int? = 0,
|
// val size: Int? = 0,
|
||||||
@SerializedName("startRow")
|
// @SerializedName("startRow")
|
||||||
val startRow: Int? = 0,
|
// val startRow: Int? = 0,
|
||||||
@SerializedName("total")
|
// @SerializedName("total")
|
||||||
val total: Int? = 0
|
// val total: Int? = 0
|
||||||
) : Parcelable {
|
//) : Parcelable {
|
||||||
@Parcelize
|
// @Parcelize
|
||||||
data class Member(
|
// data class Member(
|
||||||
// @SerializedName("cardBalance")
|
//// @SerializedName("cardBalance")
|
||||||
// val cardBalance: String? = "",
|
//// val cardBalance: String? = "",
|
||||||
// @SerializedName("cardCode")
|
//// @SerializedName("cardCode")
|
||||||
// val cardCode: String? = "",
|
//// val cardCode: String? = "",
|
||||||
// @SerializedName("consumptionCount")
|
//// @SerializedName("consumptionCount")
|
||||||
// val consumptionCount: Int? = 0,
|
//// val consumptionCount: Int? = 0,
|
||||||
// @SerializedName("consumptionTotal")
|
//// @SerializedName("consumptionTotal")
|
||||||
// val consumptionTotal: String? = "",
|
//// val consumptionTotal: String? = "",
|
||||||
// @SerializedName("createTime")
|
//// @SerializedName("createTime")
|
||||||
// val createTime: String? = "",
|
//// val createTime: String? = "",
|
||||||
// @SerializedName("firstTopUpTime")
|
//// @SerializedName("firstTopUpTime")
|
||||||
// val firstTopUpTime: String? = "",
|
//// val firstTopUpTime: String? = "",
|
||||||
// @SerializedName("id")
|
//// @SerializedName("id")
|
||||||
// val id: Int? = 0,
|
//// val id: Int? = 0,
|
||||||
// @SerializedName("integralBalance")
|
//// @SerializedName("integralBalance")
|
||||||
// val integralBalance: Int? = 0,
|
//// val integralBalance: Int? = 0,
|
||||||
// @SerializedName("lastConsumptionTime")
|
//// @SerializedName("lastConsumptionTime")
|
||||||
// val lastConsumptionTime: String? = "",
|
//// val lastConsumptionTime: String? = "",
|
||||||
// @SerializedName("memberFrom")
|
//// @SerializedName("memberFrom")
|
||||||
// val memberFrom: Int? = 0,
|
//// val memberFrom: Int? = 0,
|
||||||
// @SerializedName("name")
|
//// @SerializedName("name")
|
||||||
|
//// val name: String? = "",
|
||||||
|
//// @SerializedName("phone")
|
||||||
|
//// val phone: String? = "",
|
||||||
|
//// @SerializedName("rewardBalance")
|
||||||
|
//// val rewardBalance: String? = "",
|
||||||
|
//// @SerializedName("topUpBalance")
|
||||||
|
//// val topUpBalance: String? = ""
|
||||||
|
// val id: String? = "",
|
||||||
|
// val faceId: String? = "",
|
||||||
// val name: String? = "",
|
// val name: String? = "",
|
||||||
// @SerializedName("phone")
|
|
||||||
// val phone: String? = "",
|
// val phone: String? = "",
|
||||||
// @SerializedName("rewardBalance")
|
// ) : Parcelable
|
||||||
// val rewardBalance: String? = "",
|
//}
|
||||||
// @SerializedName("topUpBalance")
|
|
||||||
// val topUpBalance: String? = ""
|
|
||||||
val id: String? = "",
|
|
||||||
val faceId: String? = "",
|
|
||||||
val name: String? = "",
|
|
||||||
val phone: String? = "",
|
|
||||||
) : Parcelable
|
|
||||||
}
|
|
||||||
@@ -2,173 +2,28 @@ package com.sw.platecabinet.network.api
|
|||||||
|
|
||||||
import com.sw.platecabinet.GlobalData
|
import com.sw.platecabinet.GlobalData
|
||||||
import com.sw.platecabinet.model.DeviceConfig
|
import com.sw.platecabinet.model.DeviceConfig
|
||||||
import com.sw.platecabinet.model.request.BindParam
|
|
||||||
import com.sw.platecabinet.model.request.EquipmentParam
|
|
||||||
import com.sw.platecabinet.model.request.LoginParam
|
|
||||||
import com.sw.platecabinet.model.request.SearchParam
|
|
||||||
import com.sw.platecabinet.model.response.ApiResponse
|
import com.sw.platecabinet.model.response.ApiResponse
|
||||||
import com.sw.platecabinet.model.response.EquipmentInfo
|
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
import com.sw.platecabinet.model.response.SearchResult
|
|
||||||
import com.sw.platecabinet.model.response.UserFaceModel
|
import com.sw.platecabinet.model.response.UserFaceModel
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
import retrofit2.http.Body
|
import retrofit2.http.Body
|
||||||
import retrofit2.http.Field
|
import retrofit2.http.Field
|
||||||
import retrofit2.http.FormUrlEncoded
|
import retrofit2.http.FormUrlEncoded
|
||||||
import retrofit2.http.GET
|
import retrofit2.http.GET
|
||||||
import retrofit2.http.Header
|
|
||||||
import retrofit2.http.Multipart
|
import retrofit2.http.Multipart
|
||||||
import retrofit2.http.POST
|
import retrofit2.http.POST
|
||||||
import retrofit2.http.Part
|
import retrofit2.http.Part
|
||||||
import retrofit2.http.Query
|
|
||||||
import retrofit2.http.Url
|
import retrofit2.http.Url
|
||||||
|
|
||||||
interface ApiService {
|
interface ApiService {
|
||||||
// /**
|
|
||||||
// * device获取token
|
|
||||||
// */
|
|
||||||
// @GET("sys/getEquipmentToken")
|
|
||||||
// suspend fun getDeviceToken(
|
|
||||||
// @Query("qrcodeId") qrcodeId: String,
|
|
||||||
// @Query("appVersion") appVersion: String = GlobalData.appVersion
|
|
||||||
// ): ApiResponse<String>
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// *获取配置信息
|
|
||||||
// */
|
|
||||||
// @GET("equipment/stEquipment/queryByEquipmentCode")
|
|
||||||
// suspend fun getDeviceInfo(
|
|
||||||
// @Query("equipmentCode") equipmentCode: String,
|
|
||||||
// @Query("appVersion") appVersion: String = GlobalData.appVersion,
|
|
||||||
// @Header("X-Access-Token") token: String
|
|
||||||
// ): ApiResponse<EquipmentInfo>
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 生成token
|
|
||||||
// */
|
|
||||||
// @GET//("/shuwei-zhct/scales/generateToken")
|
|
||||||
// suspend fun generateToken(
|
|
||||||
// @Url url: String = "${GlobalData.appBaseUrl}/shuwei-zhct/scales/generateToken",
|
|
||||||
// @Query("deviceId") deviceId: String,
|
|
||||||
// @Query("appVersion") appVersion: String,
|
|
||||||
// @Query("equipmentCode") equipmentCode: String
|
|
||||||
// ): ApiResponse<String>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取人脸数据
|
* 获取人脸缓存数据
|
||||||
*/
|
*/
|
||||||
// @GET//("/shuwei-zhct/scales/getUserFaceCache")
|
|
||||||
// suspend fun getUserFaceCache(
|
|
||||||
// @Url url: String = "${GlobalData.appBaseUrl}/shuwei-zhct/scales/getUserFaceCache",
|
|
||||||
// @Query("appVersion") appVersion: String,
|
|
||||||
// @Query("equipmentCode") equipmentCode: String
|
|
||||||
// ): ApiResponse<List<UserFaceModel>>
|
|
||||||
@POST
|
@POST
|
||||||
suspend fun getUserFaceCache(
|
suspend fun getUserFaceCache(
|
||||||
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/common/app/faceFeature/list",
|
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/common/app/faceFeature/list",
|
||||||
@Body param: Map<String, Int>
|
@Body param: Map<String, Int>
|
||||||
): ApiResponse<List<UserFaceModel>>
|
): ApiResponse<List<UserFaceModel>>
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 餐盘用户信息获取
|
|
||||||
// */
|
|
||||||
// @POST//("/shuwei-zhct/swEquipmentRelUser/equipmentBoxLogin")
|
|
||||||
// suspend fun equipmentBoxLogin(
|
|
||||||
// @Url url: String = "${GlobalData.appBaseUrl}/shuwei-zhct/swEquipmentRelUser/equipmentBoxLogin",
|
|
||||||
// @Body param: LoginParam
|
|
||||||
// ): ApiResponse<EquipmentUserInfo>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 餐盘用户信息获取
|
|
||||||
*/
|
|
||||||
@POST//("/shuwei-zhct/swEquipmentRelUser/equipmentBoxLogin")
|
|
||||||
suspend fun equipmentBoxLogin(
|
|
||||||
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/sideboard/app/getPlateBoxUserInfo",
|
|
||||||
@Body param: LoginParam
|
|
||||||
): ApiResponse<EquipmentUserInfo>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 餐盘用户信息列表查询
|
|
||||||
*/
|
|
||||||
// @POST//("/shuwei-zhct/swEquipmentRelUser/list")
|
|
||||||
// suspend fun getEquipmentList(
|
|
||||||
// @Url url: String = "${GlobalData.appBaseUrl}/shuwei-zhct/swEquipmentRelUser/list",
|
|
||||||
// @Body param: EquipmentParam
|
|
||||||
// ): ApiResponse<List<EquipmentUserInfo>>
|
|
||||||
|
|
||||||
@GET
|
|
||||||
suspend fun getEquipmentList(
|
|
||||||
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/sideboard/app/getYxMemberRefPlateByEquipmentCode",
|
|
||||||
): ApiResponse<List<EquipmentUserInfo>>
|
|
||||||
// /**
|
|
||||||
// * 餐盘用户信息绑定解绑
|
|
||||||
// */
|
|
||||||
// @POST//("/shuwei-zhct/swEquipmentRelUser/addOrEdit")
|
|
||||||
// suspend fun bindEquipment(
|
|
||||||
// @Url url: String = "${GlobalData.appBaseUrl}/shuwei-zhct/swEquipmentRelUser/addOrEdit",
|
|
||||||
// @Body param: BindParam
|
|
||||||
// ): ApiResponse<EquipmentUserInfo?>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 餐盘绑定
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
suspend fun plateBind(
|
|
||||||
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/sideboard/app/plateBinding",
|
|
||||||
@Body param: BindParam
|
|
||||||
): ApiResponse<EquipmentUserInfo?>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 餐盘解绑
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@FormUrlEncoded
|
|
||||||
suspend fun plateUnbind(
|
|
||||||
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/sideboard/app/plateUnbind",
|
|
||||||
@Field("id") id: Long?
|
|
||||||
): ApiResponse<Any?>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户信息模糊搜索
|
|
||||||
*/
|
|
||||||
@POST//("/shuwei-user/swclientUserInfoShop/selectList")
|
|
||||||
suspend fun searchUser(
|
|
||||||
// @Url url: String = "${GlobalData.appBaseUrl}/shuwei-user/swclientUserInfoShop/selectList",
|
|
||||||
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/common/app/getUserInfoByNameOrPhone",
|
|
||||||
@Body param: SearchParam
|
|
||||||
): ApiResponse<List<SearchResult.Member>?>
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 通过餐盘号获取信息
|
|
||||||
// */
|
|
||||||
// @POST//("/shuwei-zhct/swEquipmentRelUser/findByPlateNumber")
|
|
||||||
// suspend fun findByPlateNumber(
|
|
||||||
// @Url url: String = "${GlobalData.appBaseUrl}/shuwei-zhct/swEquipmentRelUser/findByPlateNumber",
|
|
||||||
// @Body param: BindParam
|
|
||||||
// ): ApiResponse<EquipmentUserInfo>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过餐盘号获取信息
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
suspend fun findByPlateNumber(
|
|
||||||
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/sideboard/app/getMemberRefPlateByPlateNumber",
|
|
||||||
@Query("plateNumber") plateNumber: String
|
|
||||||
): ApiResponse<EquipmentUserInfo>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取人脸增量数据
|
|
||||||
*
|
|
||||||
* @param timeDate 时间戳(毫秒级)
|
|
||||||
*/
|
|
||||||
// @GET//("/shuwei-zhct/scales/getHeartbeatInterface")
|
|
||||||
// suspend fun getHeartbeatInterface(
|
|
||||||
// @Url url: String = "${GlobalData.appBaseUrl}/shuwei-zhct/scales/getHeartbeatInterface",
|
|
||||||
// @Query("timeDate") timeDate: Long
|
|
||||||
// ): ApiResponse<List<UserFaceModel>>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取人脸增量数据
|
* 获取人脸增量数据
|
||||||
*/
|
*/
|
||||||
@@ -193,10 +48,13 @@ interface ApiService {
|
|||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
suspend fun addUserFace(
|
suspend fun addUserFace(
|
||||||
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/common/app/addUserByFace",
|
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/common/app/addUserByFace",
|
||||||
@Field("featureChar") faceData:String,
|
@Field("featureChar") faceData: String,
|
||||||
@Field("url") imageUr:String
|
@Field("url") imageUr: String
|
||||||
): ApiResponse<UserFaceModel?>
|
): ApiResponse<UserFaceModel?>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传图片
|
||||||
|
*/
|
||||||
@Multipart
|
@Multipart
|
||||||
@POST
|
@POST
|
||||||
suspend fun uploadImage(
|
suspend fun uploadImage(
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.sw.platecabinet.repository
|
package com.sw.platecabinet.repository
|
||||||
|
|
||||||
import com.sw.platecabinet.model.DeviceConfig
|
import com.sw.platecabinet.model.DeviceConfig
|
||||||
import com.sw.platecabinet.model.request.SearchParam
|
|
||||||
import com.sw.platecabinet.model.response.ApiResponse
|
import com.sw.platecabinet.model.response.ApiResponse
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
import com.sw.platecabinet.model.response.SearchResult
|
|
||||||
import com.sw.platecabinet.model.response.UserFaceModel
|
import com.sw.platecabinet.model.response.UserFaceModel
|
||||||
import com.sw.platecabinet.network.api.ApiService
|
import com.sw.platecabinet.network.api.ApiService
|
||||||
import com.sw.platecabinet.utils.FileUtils
|
import com.sw.platecabinet.utils.FileUtils
|
||||||
@@ -17,42 +14,6 @@ class RemoteRepository constructor(
|
|||||||
private val apiService: ApiService
|
private val apiService: ApiService
|
||||||
) : BaseRepository() {
|
) : BaseRepository() {
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 生成token
|
|
||||||
// */
|
|
||||||
// suspend fun getDeviceToken(qrcodeId: String): ApiResponse<String> {
|
|
||||||
// return safeApiCall {
|
|
||||||
// apiService.getDeviceToken(
|
|
||||||
// qrcodeId
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 获取设备信息
|
|
||||||
// */
|
|
||||||
// suspend fun getDeviceInfo(equipmentCode: String, token: String): ApiResponse<EquipmentInfo> {
|
|
||||||
// return safeApiCall {
|
|
||||||
// apiService.getDeviceInfo(
|
|
||||||
// equipmentCode,
|
|
||||||
// token = token
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 生成token
|
|
||||||
// */
|
|
||||||
// suspend fun generateToken(deviceId: String): ApiResponse<String> {
|
|
||||||
// return safeApiCall {
|
|
||||||
// apiService.generateToken(
|
|
||||||
// deviceId = deviceId,
|
|
||||||
// appVersion = GlobalData.appVersion,
|
|
||||||
// equipmentCode = GlobalData.globalEquipmentCode
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取人脸数据
|
* 获取人脸数据
|
||||||
*/
|
*/
|
||||||
@@ -70,57 +31,6 @@ class RemoteRepository constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 登录
|
|
||||||
// */
|
|
||||||
// suspend fun equipmentBoxLogin(param: LoginParam): ApiResponse<EquipmentUserInfo> {
|
|
||||||
// return safeApiCall { apiService.equipmentBoxLogin(param = param) }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 获取设备绑定用户列表
|
|
||||||
// */
|
|
||||||
// suspend fun getEquipmentList(): ApiResponse<List<EquipmentUserInfo>> {
|
|
||||||
// return safeApiCall { apiService.getEquipmentList() }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 餐盘用户信息绑定解绑
|
|
||||||
// */
|
|
||||||
// suspend fun bindEquipment(param: BindParam): ApiResponse<EquipmentUserInfo?> {
|
|
||||||
// return safeApiCall { apiService.bindEquipment(param = param) }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// suspend fun plateBind(param: BindParam): ApiResponse<EquipmentUserInfo?> {
|
|
||||||
// return safeApiCall { apiService.plateBind(param = param) }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// suspend fun plateUnbind(id: Long?): ApiResponse<Any?> {
|
|
||||||
// return safeApiCall { apiService.plateUnbind(id = id) }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户信息模糊搜索
|
|
||||||
*/
|
|
||||||
suspend fun searchUser(param: SearchParam): ApiResponse<List<SearchResult.Member>?> {
|
|
||||||
return safeApiCall { apiService.searchUser(param = param) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过餐盘编号获取绑定信息
|
|
||||||
*/
|
|
||||||
suspend fun findByPlateNumber(plateNumber: String): ApiResponse<EquipmentUserInfo> {
|
|
||||||
return safeApiCall { apiService.findByPlateNumber(plateNumber = plateNumber) }
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 获取人脸增量数据
|
|
||||||
// *
|
|
||||||
// * @param timeDate 时间戳(毫秒级)
|
|
||||||
// */
|
|
||||||
// suspend fun getHeartbeatInterface(timeDate: Long): ApiResponse<List<UserFaceModel>> {
|
|
||||||
// return safeApiCall { apiService.getHeartbeatInterface(timeDate = timeDate) }
|
|
||||||
// }
|
|
||||||
|
|
||||||
suspend fun getFaceIncrementList(
|
suspend fun getFaceIncrementList(
|
||||||
pageNum: Long,
|
pageNum: Long,
|
||||||
@@ -142,7 +52,7 @@ class RemoteRepository constructor(
|
|||||||
return safeApiCall { apiService.getDeviceConfig() }
|
return safeApiCall { apiService.getDeviceConfig() }
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun addUserFace(faceData: String, imageUr:String): ApiResponse<UserFaceModel?> {
|
suspend fun addUserFace(faceData: String, imageUr: String): ApiResponse<UserFaceModel?> {
|
||||||
return safeApiCall { apiService.addUserFace(faceData = faceData, imageUr = imageUr) }
|
return safeApiCall { apiService.addUserFace(faceData = faceData, imageUr = imageUr) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class CrashHandler private constructor(private val context: Context) :
|
|||||||
// 设备信息
|
// 设备信息
|
||||||
sb.append("Vendor: ${Build.MANUFACTURER}\n")
|
sb.append("Vendor: ${Build.MANUFACTURER}\n")
|
||||||
sb.append("Model: ${Build.MODEL}\n")
|
sb.append("Model: ${Build.MODEL}\n")
|
||||||
sb.append("CPU ABI: ${Build.SUPPORTED_ABIS[0]}\n")
|
sb.append("CPU ABI: ${Build.SUPPORTED_ABIS.firstOrNull() ?: "unknown"}\n")
|
||||||
|
|
||||||
// 其他信息
|
// 其他信息
|
||||||
sb.append("Locale: ${Locale.getDefault()}\n")
|
sb.append("Locale: ${Locale.getDefault()}\n")
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ object DateTimeUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取带时间的完整中文格式(示例:2025年6月11日 星期三 14:30)
|
* 获取带时间的完整中文格式(示例:2025年06月11日 星期三 14:30)
|
||||||
*/
|
*/
|
||||||
fun getChineseDateTimeString(date: Date = Date()): String {
|
fun getChineseDateTimeString(date: Date = Date()): String {
|
||||||
return SimpleDateFormat("yyyy年M月d日 EEEE HH:mm:ss", Locale.CHINA).format(date)
|
return SimpleDateFormat("yyyy年MM月dd日 EEEE HH:mm", Locale.CHINA).format(date)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用线程安全的日期格式化(避免 SimpleDateFormat 的线程安全问题)
|
// 使用线程安全的日期格式化(避免 SimpleDateFormat 的线程安全问题)
|
||||||
@@ -52,7 +52,7 @@ object DateTimeUtils {
|
|||||||
*/
|
*/
|
||||||
fun realTimeChineseDateFlow(intervalMillis: Long = 1000) = flow {
|
fun realTimeChineseDateFlow(intervalMillis: Long = 1000) = flow {
|
||||||
while (true) {
|
while (true) {
|
||||||
emit(getChineseDateTimePair())
|
emit(getChineseDateTimeString())
|
||||||
delay(intervalMillis)
|
delay(intervalMillis)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package com.sw.platecabinet.utils
|
package com.sw.platecabinet.utils
|
||||||
|
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
class Debouncer(private val delayMillis: Long) {
|
class Debouncer(private val delayMillis: Long) {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "Debouncer"
|
||||||
|
}
|
||||||
private var lastActionTime = 0L
|
private var lastActionTime = 0L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,13 +13,15 @@ class Debouncer(private val delayMillis: Long) {
|
|||||||
* @param action 要执行的操作
|
* @param action 要执行的操作
|
||||||
* @return Boolean 是否执行了操作 (true=已执行, false=被防抖)
|
* @return Boolean 是否执行了操作 (true=已执行, false=被防抖)
|
||||||
*/
|
*/
|
||||||
fun debounce(action: () -> Unit): Boolean {
|
fun debounce(tag:String = TAG, action: () -> Unit): Boolean {
|
||||||
val currentTime = System.currentTimeMillis()
|
val currentTime = System.currentTimeMillis()
|
||||||
if (currentTime - lastActionTime >= delayMillis) {
|
if (currentTime - lastActionTime >= delayMillis) {
|
||||||
|
Timber.tag(tag).d("collectFace,recognizeUserId防止重复操作:执行action回调")
|
||||||
lastActionTime = currentTime
|
lastActionTime = currentTime
|
||||||
action()
|
action()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Timber.tag(tag).d("collectFace,recognizeUserId防止重复操作-----------------------")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,88 +1,88 @@
|
|||||||
package com.sw.platecabinet.utils
|
//package com.sw.platecabinet.utils
|
||||||
|
//
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
//import com.sw.platecabinet.model.response.EquipmentUserInfo
|
||||||
import timber.log.Timber
|
//import timber.log.Timber
|
||||||
import kotlin.math.ceil
|
//import kotlin.math.ceil
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 列表排序工具类
|
// * 列表排序工具类
|
||||||
*/
|
// */
|
||||||
object ListArrangementUtil {
|
//object ListArrangementUtil {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* page item水平排序
|
// * page item水平排序
|
||||||
*/
|
// */
|
||||||
fun horizontalSortPageItem(
|
// fun horizontalSortPageItem(
|
||||||
list: List<EquipmentUserInfo>,
|
// list: List<EquipmentUserInfo>,
|
||||||
columns: Int,
|
// columns: Int,
|
||||||
defaultValue: EquipmentUserInfo = EquipmentUserInfo()
|
// defaultValue: EquipmentUserInfo = EquipmentUserInfo()
|
||||||
): List<EquipmentUserInfo> {
|
// ): List<EquipmentUserInfo> {
|
||||||
Timber.d("horizontalSortPageItem")
|
// Timber.d("horizontalSortPageItem")
|
||||||
require(columns > 0) { "Columns must be positive" }
|
// require(columns > 0) { "Columns must be positive" }
|
||||||
|
//
|
||||||
val filledList = list.padToMultiple(columns, defaultValue)
|
// val filledList = list.padToMultiple(columns, defaultValue)
|
||||||
val chunks = filledList.chunked(columns)
|
// val chunks = filledList.chunked(columns)
|
||||||
|
//
|
||||||
return (0 until columns)
|
// return (0 until columns)
|
||||||
.windowed(2, 2, partialWindows = true)
|
// .windowed(2, 2, partialWindows = true)
|
||||||
.flatMap { group ->
|
// .flatMap { group ->
|
||||||
when (group.size) {
|
// when (group.size) {
|
||||||
2 -> chunks.flatMap { listOf(it[group[0]], it[group[1]]) }
|
// 2 -> chunks.flatMap { listOf(it[group[0]], it[group[1]]) }
|
||||||
1 -> chunks.flatMap {
|
// 1 -> chunks.flatMap {
|
||||||
listOf(it[group[0]], EquipmentUserInfo(equipmentBoxCode = null))
|
// listOf(it[group[0]], EquipmentUserInfo(equipmentBoxCode = null))
|
||||||
}.dropLast(1)
|
// }.dropLast(1)
|
||||||
else -> error("Unexpected group size")
|
// else -> error("Unexpected group size")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* item 垂直排序
|
// * item 垂直排序
|
||||||
*/
|
// */
|
||||||
fun verticalSortItem(list: List<EquipmentUserInfo>): List<EquipmentUserInfo> {
|
// fun verticalSortItem(list: List<EquipmentUserInfo>): List<EquipmentUserInfo> {
|
||||||
Timber.d("verticalSortItem")
|
// Timber.d("verticalSortItem")
|
||||||
val users = list.padToEvenSize()
|
// val users = list.padToEvenSize()
|
||||||
val half = users.size / 2
|
// val half = users.size / 2
|
||||||
|
//
|
||||||
return users.take(half)
|
// return users.take(half)
|
||||||
.zip(users.drop(half)) { a, b -> listOf(a, b) }
|
// .zip(users.drop(half)) { a, b -> listOf(a, b) }
|
||||||
.flatten()
|
// .flatten()
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* page item垂直排序
|
// * page item垂直排序
|
||||||
*/
|
// */
|
||||||
fun convertToColumnFirst(
|
// fun convertToColumnFirst(
|
||||||
original: List<EquipmentUserInfo>,
|
// original: List<EquipmentUserInfo>,
|
||||||
cols: Int
|
// cols: Int
|
||||||
): List<EquipmentUserInfo> {
|
// ): List<EquipmentUserInfo> {
|
||||||
Timber.d("convertToColumnFirst")
|
// Timber.d("convertToColumnFirst")
|
||||||
require(cols > 0) { "Columns must be positive" }
|
// require(cols > 0) { "Columns must be positive" }
|
||||||
|
//
|
||||||
val rows = ceil(original.size.toDouble() / cols).toInt()
|
// val rows = ceil(original.size.toDouble() / cols).toInt()
|
||||||
return List(original.size) { pos ->
|
// return List(original.size) { pos ->
|
||||||
original.getOrNull(pos % rows * cols + pos / rows) ?: EquipmentUserInfo()
|
// original.getOrNull(pos % rows * cols + pos / rows) ?: EquipmentUserInfo()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 提取的扩展函数
|
// // 提取的扩展函数
|
||||||
private fun List<EquipmentUserInfo>.padToMultiple(
|
// private fun List<EquipmentUserInfo>.padToMultiple(
|
||||||
multiple: Int,
|
// multiple: Int,
|
||||||
defaultValue: EquipmentUserInfo
|
// defaultValue: EquipmentUserInfo
|
||||||
): List<EquipmentUserInfo> {
|
// ): List<EquipmentUserInfo> {
|
||||||
return if (size % multiple != 0) {
|
// return if (size % multiple != 0) {
|
||||||
this + List(multiple - (size % multiple)) { defaultValue }
|
// this + List(multiple - (size % multiple)) { defaultValue }
|
||||||
} else {
|
// } else {
|
||||||
this
|
// this
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun List<EquipmentUserInfo>.padToEvenSize(): List<EquipmentUserInfo> {
|
// private fun List<EquipmentUserInfo>.padToEvenSize(): List<EquipmentUserInfo> {
|
||||||
return if (size % 2 != 0) {
|
// return if (size % 2 != 0) {
|
||||||
Timber.d("列表长度必须是偶数")
|
// Timber.d("列表长度必须是偶数")
|
||||||
this + EquipmentUserInfo()
|
// this + EquipmentUserInfo()
|
||||||
} else {
|
// } else {
|
||||||
this
|
// this
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
@@ -19,10 +19,15 @@ import java.io.StringReader;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
public class LogFileUtil {
|
public class LogFileUtil {
|
||||||
private static boolean isSaveLog = true;
|
private static boolean isSaveLog = true;
|
||||||
public static final String FILE_STR_PATH = App.getContext().getExternalCacheDir().getAbsolutePath();
|
// 使用内部存储,不会被系统缓存清理策略影响
|
||||||
|
public static final String FILE_STR_PATH = new File(App.getContext().getFilesDir(), "logs").getAbsolutePath();
|
||||||
|
// 单线程执行器,保证日志串行写入,避免多线程并发竞争
|
||||||
|
private static final ExecutorService LOG_EXECUTOR = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
public static final int SIZETYPE_B = 1;//获取文件大小单位为B的double值
|
public static final int SIZETYPE_B = 1;//获取文件大小单位为B的double值
|
||||||
public static final int SIZETYPE_KB = 2;//获取文件大小单位为KB的double值
|
public static final int SIZETYPE_KB = 2;//获取文件大小单位为KB的double值
|
||||||
@@ -610,24 +615,20 @@ public class LogFileUtil {
|
|||||||
if (!isSaveLog) {
|
if (!isSaveLog) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new Thread() {
|
// 提交到单线程队列,串行执行,避免并发写入竞争
|
||||||
@Override
|
LOG_EXECUTOR.execute(() -> {
|
||||||
public void run() {
|
StringBuilder sb = new StringBuilder();
|
||||||
super.run();
|
for (String log : logs) {
|
||||||
StringBuilder sb = new StringBuilder();
|
sb.append("===")
|
||||||
for (String log : logs) {
|
.append((AppUtil.formatDateGetCurrentTime()))
|
||||||
sb.append("===")
|
.append("===")
|
||||||
.append((AppUtil.formatDateGetCurrentTime()))
|
.append("\n")
|
||||||
.append("===")
|
.append(log)
|
||||||
.append("\n")
|
.append("\n");
|
||||||
.append(log)
|
|
||||||
.append("\n");
|
|
||||||
}
|
|
||||||
String fileName = "log" + AppUtil.formatDateGetDay(System.currentTimeMillis()) + ".txt";
|
|
||||||
LogFileUtil.saveStrFile(sb.toString(), fileName, FILE_STR_PATH, true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}.start();
|
String fileName = "log" + AppUtil.formatDateGetDay(System.currentTimeMillis()) + ".txt";
|
||||||
|
LogFileUtil.saveStrFile(sb.toString(), fileName, FILE_STR_PATH, true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[][] MIME_MapTable = {
|
private static final String[][] MIME_MapTable = {
|
||||||
|
|||||||
@@ -77,11 +77,7 @@ class PermissionHelper private constructor(
|
|||||||
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
|
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
|
||||||
data = Uri.fromParts("package", context.packageName, null)
|
data = Uri.fromParts("package", context.packageName, null)
|
||||||
}
|
}
|
||||||
if (context is Activity) {
|
context.startActivity(intent)
|
||||||
context.startActivity(intent)
|
|
||||||
} else if (context is Fragment) {
|
|
||||||
context.startActivity(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
package com.sw.platecabinet.utils
|
package com.sw.platecabinet.utils
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.sw.plate.utils.ToastUtils
|
|
||||||
import com.sw.plate.utils.comn.SerialApi
|
|
||||||
import com.sw.plate.utils.comn.SerialPortManager
|
|
||||||
import com.sw.platecabinet.activity.BaseActivity
|
import com.sw.platecabinet.activity.BaseActivity
|
||||||
import com.sw.platecabinet.activity.MainActivity
|
|
||||||
import com.sw.platecabinet.activity.PageType
|
|
||||||
import timber.log.Timber
|
|
||||||
|
|
||||||
object PlateUtils {
|
object PlateUtils {
|
||||||
|
|
||||||
@@ -19,48 +13,54 @@ object PlateUtils {
|
|||||||
callback: () -> Unit = {}
|
callback: () -> Unit = {}
|
||||||
) {
|
) {
|
||||||
val activity = fragmentActivity as BaseActivity<*>
|
val activity = fragmentActivity as BaseActivity<*>
|
||||||
Timber.d("itemClick llOpen equipmentBoxCode = ${code}")
|
|
||||||
val equipmentBoxCode: Int = code?.toInt() ?: -1
|
|
||||||
if (equipmentBoxCode < 0) {
|
|
||||||
ToastUtils.showToast("餐盘柜编号错误")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
activity.showWaitingDialog("请稍等")
|
|
||||||
SerialApi.openPlate(equipmentBoxCode, object : SerialPortManager.SendCallback {
|
|
||||||
override fun onSuccess() {
|
|
||||||
activity.hideWaitingDialog()
|
|
||||||
if (isSetting.not()) {
|
|
||||||
MainActivity.start(
|
|
||||||
activity,
|
|
||||||
pageType = PageType.PLATE_TIP,
|
|
||||||
isScanCode = isScanCode
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
ToastUtils.showToast("柜门打开成功")
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFail(e: Exception?) {
|
activity.window.decorView.postDelayed({
|
||||||
activity.hideWaitingDialog()
|
callback()
|
||||||
ToastUtils.showToast("柜门打开失败")
|
}, 1500)
|
||||||
callback()
|
|
||||||
}
|
// activity.showWaitingDialog("请稍等")
|
||||||
})
|
// Timber.d("itemClick llOpen equipmentBoxCode = ${code}")
|
||||||
|
// val equipmentBoxCode: Int = code?.toInt() ?: -1
|
||||||
|
// if (equipmentBoxCode < 0) {
|
||||||
|
// ToastUtils.showToast("餐盘柜编号错误")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// activity.showWaitingDialog("请稍等")
|
||||||
|
// SerialApi.openPlate(equipmentBoxCode, object : SerialPortManager.SendCallback {
|
||||||
|
// override fun onSuccess() {
|
||||||
|
// activity.hideWaitingDialog()
|
||||||
|
// if (isSetting.not()) {
|
||||||
|
// MainActivity.start(
|
||||||
|
// activity,
|
||||||
|
// pageType = PageType.PLATE_TIP,
|
||||||
|
// isScanCode = isScanCode
|
||||||
|
// )
|
||||||
|
// } else {
|
||||||
|
// ToastUtils.showToast("柜门打开成功")
|
||||||
|
// callback()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun onFail(e: Exception?) {
|
||||||
|
// activity.hideWaitingDialog()
|
||||||
|
// ToastUtils.showToast("柜门打开失败")
|
||||||
|
// callback()
|
||||||
|
// }
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openDirect(boxCode: String?) {
|
// fun openDirect(boxCode: String?) {
|
||||||
val boxNumber = boxCode?.toIntOrNull() ?: -1
|
// val boxNumber = boxCode?.toIntOrNull() ?: -1
|
||||||
if (boxNumber < 0) return
|
// if (boxNumber < 0) return
|
||||||
SerialApi.openPlate(boxNumber, object : SerialPortManager.SendCallback {
|
// SerialApi.openPlate(boxNumber, object : SerialPortManager.SendCallback {
|
||||||
override fun onSuccess() {
|
// override fun onSuccess() {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onFail(e: Exception?) {
|
// override fun onFail(e: Exception?) {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
package com.sw.platecabinet.utils
|
package com.sw.platecabinet.utils
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.sw.inbound.utils.GsonUtils
|
|
||||||
import com.sw.inbound.utils.SPUtil
|
import com.sw.inbound.utils.SPUtil
|
||||||
import com.sw.inbound.utils.SPUtil.Companion.getInstance
|
import com.sw.inbound.utils.SPUtil.Companion.getInstance
|
||||||
|
import com.sw.platecabinet.GlobalKey
|
||||||
import com.sw.platecabinet.MyApp
|
import com.sw.platecabinet.MyApp
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
||||||
import kotlin.text.get
|
|
||||||
|
|
||||||
object SpTool {
|
object SpTool {
|
||||||
const val LAST_FACE_TIMESTAMP: String = "faceTimestamp"
|
const val LAST_FACE_TIMESTAMP: String = "faceTimestamp"
|
||||||
@@ -30,18 +27,18 @@ object SpTool {
|
|||||||
spUtil?.put(LAST_FACE_TIMESTAMP, timestamp)
|
spUtil?.put(LAST_FACE_TIMESTAMP, timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun savePlateData(items: List<EquipmentUserInfo>) {
|
// fun savePlateData(items: List<EquipmentUserInfo>) {
|
||||||
val jsonData = Gson().toJson(items)
|
// val jsonData = Gson().toJson(items)
|
||||||
putString(PLATE_BOX_DATA, jsonData)
|
// putString(PLATE_BOX_DATA, jsonData)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
fun getPlateData(): List<EquipmentUserInfo>? {
|
// fun getPlateData(): List<EquipmentUserInfo>? {
|
||||||
val jsonData = spUtil?.get(PLATE_BOX_DATA, "")
|
// val jsonData = spUtil?.get(PLATE_BOX_DATA, "")
|
||||||
if (jsonData.isNullOrBlank()) {
|
// if (jsonData.isNullOrBlank()) {
|
||||||
return null
|
// return null
|
||||||
}
|
// }
|
||||||
return GsonUtils.fromJsonList(jsonData, EquipmentUserInfo::class.java)
|
// return GsonUtils.fromJsonList(jsonData, EquipmentUserInfo::class.java)
|
||||||
}
|
// }
|
||||||
|
|
||||||
var firstGetFace: Boolean
|
var firstGetFace: Boolean
|
||||||
get() = spUtil?.get(IS_FIRST_GET_FACE, true)?:true
|
get() = spUtil?.get(IS_FIRST_GET_FACE, true)?:true
|
||||||
@@ -49,4 +46,10 @@ object SpTool {
|
|||||||
spUtil?.boolean(IS_FIRST_GET_FACE, value)
|
spUtil?.boolean(IS_FIRST_GET_FACE, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var baseUrl: String
|
||||||
|
get() = spUtil?.get(GlobalKey.KEY_BASE_URL, "") ?: ""
|
||||||
|
set(value) {
|
||||||
|
spUtil?.put(GlobalKey.KEY_BASE_URL, value)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.sw.platecabinet.utils.mego
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PLC 操作统一回调接口
|
||||||
|
*/
|
||||||
|
interface PlcCallback<T> {
|
||||||
|
/**
|
||||||
|
* 操作成功回调(主线程)
|
||||||
|
*/
|
||||||
|
fun onSuccess(result: T)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作失败回调(主线程)
|
||||||
|
*/
|
||||||
|
fun onError(message: String)
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
package com.sw.platecabinet.utils.mego
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import com.megoai.plc_aar.SDK
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PLC 操作工具类(单例)
|
||||||
|
* 封装 SDK 所有接口,统一回调到主线程
|
||||||
|
*/
|
||||||
|
class PlcHelper private constructor(context: Context) {
|
||||||
|
|
||||||
|
private val sdk: SDK = SDK.getInstance(context)
|
||||||
|
private val mainHandler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Volatile
|
||||||
|
private var instance: PlcHelper? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单例实例
|
||||||
|
*/
|
||||||
|
fun getInstance(context: Context): PlcHelper {
|
||||||
|
return instance ?: synchronized(this) {
|
||||||
|
instance ?: PlcHelper(context.applicationContext).also { instance = it }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 连接与模式 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开出盘串口(应用启动时调用)
|
||||||
|
*/
|
||||||
|
fun openSerialPort(callback: PlcCallback<String>) {
|
||||||
|
sdk.openPlcSerialPort { result ->
|
||||||
|
mainHandler.post { callback.onSuccess(result.toString()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开自动模式(应用启动时调用一次)
|
||||||
|
*/
|
||||||
|
fun openAutoMode(callback: PlcCallback<String>) {
|
||||||
|
sdk.actionOpenAutoMode { result ->
|
||||||
|
mainHandler.post { callback.onSuccess(result.toString()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障复位(出现 alarmCode 或补盘完成后调用)
|
||||||
|
*/
|
||||||
|
fun alarmReset(callback: PlcCallback<String>) {
|
||||||
|
sdk.actionAlarmReset { result ->
|
||||||
|
mainHandler.post { callback.onSuccess(result.toString()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 出盘操作 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出盘
|
||||||
|
*/
|
||||||
|
fun outPlate(callback: PlcCallback<String>) {
|
||||||
|
sdk.actionOutPlate { result ->
|
||||||
|
mainHandler.post { callback.onSuccess(result.toString()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 平台控制 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台下降(开始补盘)
|
||||||
|
*/
|
||||||
|
fun platformDown(callback: PlcCallback<String>) {
|
||||||
|
sdk.actionPlatformDown { result ->
|
||||||
|
mainHandler.post { callback.onSuccess(result.toString()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台上升(补盘完成)
|
||||||
|
*/
|
||||||
|
fun platformUp(callback: PlcCallback<String>) {
|
||||||
|
sdk.actionPlatformDownStop { result ->
|
||||||
|
mainHandler.post { callback.onSuccess(result.toString()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补盘完成返回营业(自动模式 + 故障复位)
|
||||||
|
*/
|
||||||
|
fun backToBusiness(callback: PlcCallback<String>) {
|
||||||
|
sdk.actionOpenAutoModeAndActionAlarmReset { result ->
|
||||||
|
mainHandler.post { callback.onSuccess(result.toString()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 状态查询 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 PLC 状态(解析为 PlcStatus 对象)
|
||||||
|
*/
|
||||||
|
fun getStatus(callback: PlcCallback<PlcStatus>) {
|
||||||
|
sdk.getPlcStatus { json ->
|
||||||
|
mainHandler.post {
|
||||||
|
if (json != null) {
|
||||||
|
callback.onSuccess(PlcStatus.Companion.fromJson(json.toString()))
|
||||||
|
} else {
|
||||||
|
callback.onError("获取状态失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 PLC 状态(原始 JSON 字符串)
|
||||||
|
*/
|
||||||
|
fun getStatusJson(callback: PlcCallback<String>) {
|
||||||
|
sdk.getPlcStatus { json ->
|
||||||
|
mainHandler.post {
|
||||||
|
if (json != null) callback.onSuccess(json.toString())
|
||||||
|
else callback.onError("获取状态失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 参数设置 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 PLC 参数
|
||||||
|
* @param paramType 参数类型(如 "18FD" 表示主电机运行最长时间)
|
||||||
|
* @param paramValue 参数值(int,单位 0.1s)
|
||||||
|
*/
|
||||||
|
fun setParams(paramType: String, paramValue: Int, callback: PlcCallback<String>) {
|
||||||
|
sdk.setPLCParams(
|
||||||
|
{ result -> mainHandler.post { callback.onSuccess(result.toString()) } },
|
||||||
|
paramType,
|
||||||
|
paramValue
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 生命周期 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 释放资源,清除单例
|
||||||
|
*/
|
||||||
|
fun release() {
|
||||||
|
instance = null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.sw.platecabinet.utils.mego
|
||||||
|
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PLC 状态数据类
|
||||||
|
*/
|
||||||
|
data class PlcStatus(
|
||||||
|
val isEmptyPlate: Boolean = false, // 是否空盘
|
||||||
|
val isPlateformDown: Boolean = false, // 平台是否在下位
|
||||||
|
val isPlateformUp: Boolean = false, // 平台是否在上位
|
||||||
|
val isTakePlateInfrared: Boolean = false, // 取盘红外是否触发
|
||||||
|
val alarmCode: Int = 0 // 报警代码
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
/**
|
||||||
|
* 从 JSON 字符串解析状态
|
||||||
|
*/
|
||||||
|
fun fromJson(json: String): PlcStatus {
|
||||||
|
return try {
|
||||||
|
val obj = JSONObject(json)
|
||||||
|
PlcStatus(
|
||||||
|
isEmptyPlate = obj.optBoolean("isEmptyPlate", false),
|
||||||
|
isPlateformDown = obj.optBoolean("isPlateformDown", false),
|
||||||
|
isPlateformUp = obj.optBoolean("isPlateformUp", false),
|
||||||
|
isTakePlateInfrared = obj.optBoolean("isTakePlateInfrared", false),
|
||||||
|
alarmCode = obj.optInt("alarmCode", 0)
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
PlcStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,7 @@ package com.sw.platecabinet.viewmodel
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.sw.plate.utils.ToastUtils
|
import com.sw.plate.utils.ToastUtils
|
||||||
import com.sw.platecabinet.GlobalData
|
|
||||||
import com.sw.platecabinet.model.response.ApiResponse
|
import com.sw.platecabinet.model.response.ApiResponse
|
||||||
import com.sw.platecabinet.model.response.EquipmentInfo
|
|
||||||
import com.sw.platecabinet.network.ApiClient
|
import com.sw.platecabinet.network.ApiClient
|
||||||
import com.sw.platecabinet.repository.RemoteRepository
|
import com.sw.platecabinet.repository.RemoteRepository
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
@@ -65,12 +63,12 @@ abstract class BaseViewModel() : ViewModel() {
|
|||||||
Timber.d("handleError ${exception.message}")
|
Timber.d("handleError ${exception.message}")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseEquipmentInfo(equipmentInfo: EquipmentInfo) {
|
// fun parseEquipmentInfo(equipmentInfo: EquipmentInfo) {
|
||||||
// GlobalData.appBaseUrl = equipmentInfo.appPackageUrl!!
|
//// GlobalData.appBaseUrl = equipmentInfo.appPackageUrl!!
|
||||||
// GlobalData.appBaseUrl="https://vip.shuziweidao.com"
|
//// GlobalData.appBaseUrl="https://vip.shuziweidao.com"
|
||||||
// GlobalData.sdkKey = equipmentInfo.arcsoftSdkKey!!
|
//// GlobalData.sdkKey = equipmentInfo.arcsoftSdkKey!!
|
||||||
// GlobalData.appId = equipmentInfo.arcsoftAppId!!
|
//// GlobalData.appId = equipmentInfo.arcsoftAppId!!
|
||||||
// GlobalData.activeKey = equipmentInfo.arcsoftActiveKey!!
|
//// GlobalData.activeKey = equipmentInfo.arcsoftActiveKey!!
|
||||||
// GlobalData.restId = equipmentInfo.canteenId!!
|
//// GlobalData.restId = equipmentInfo.canteenId!!
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -1,250 +1,62 @@
|
|||||||
package com.sw.platecabinet.viewmodel
|
//package com.sw.platecabinet.viewmodel
|
||||||
|
//
|
||||||
import com.sw.platecabinet.GlobalData.globalEquipmentCode
|
//import com.sw.platecabinet.model.response.UserFaceModel
|
||||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
//import kotlinx.coroutines.Dispatchers
|
||||||
import com.sw.platecabinet.model.response.SearchResult
|
//import kotlinx.coroutines.withContext
|
||||||
import com.sw.platecabinet.model.response.UserFaceModel
|
//import java.io.File
|
||||||
import kotlinx.coroutines.Dispatchers
|
//
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
///**
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
// * 管理员操作viewmodel
|
||||||
import kotlinx.coroutines.withContext
|
// */
|
||||||
import java.io.File
|
//class SettingViewModel : BaseViewModel() {
|
||||||
|
//
|
||||||
/**
|
// companion object {
|
||||||
* 管理员操作viewmodel
|
// const val PAGE_SIZE = 100
|
||||||
*/
|
|
||||||
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
|
|
||||||
// }
|
// }
|
||||||
// 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) {
|
// fun getFaceIncrementList(
|
||||||
// if (TextUtils.isEmpty(param)) return
|
// pageNo: Int = 1,
|
||||||
// currentPage = pageNum
|
// pageSize: Int = PAGE_SIZE,
|
||||||
// var name =""
|
// timestamp: Long,
|
||||||
// var phone =""
|
// block: (List<UserFaceModel>) -> Unit
|
||||||
// val num = param.toIntOrNull()
|
// ) {
|
||||||
// if (num != null) {
|
|
||||||
// phone = param
|
|
||||||
// } else {
|
|
||||||
// name = param
|
|
||||||
// }
|
|
||||||
// launch {
|
// launch {
|
||||||
// val searchParam = SearchParam(
|
// val response = repository.getFaceIncrementList(
|
||||||
//// appVersion = GlobalData.appVersion,
|
// pageNum = pageNo.toLong(),
|
||||||
// name = name,
|
// pageSize = pageSize.toLong(),
|
||||||
// phone = phone,
|
// timestamp = timestamp
|
||||||
// pageNum = pageNum,
|
|
||||||
// pageSize = pageSize
|
|
||||||
// )
|
// )
|
||||||
// isLoading = true
|
|
||||||
// val response = repository.searchUser(searchParam)
|
|
||||||
// isLoading = false
|
|
||||||
// if (parseResponse(response)) {
|
// if (parseResponse(response)) {
|
||||||
// response.data?.let { list ->
|
// withContext(Dispatchers.Default) {
|
||||||
// if (pageNum == 1) {
|
// val list: List<UserFaceModel> = response.data ?: emptyList()
|
||||||
// _searchMemberList.value = list
|
// block(list)
|
||||||
// } else {
|
|
||||||
// _searchMemberList.value = _searchMemberList.value.plus(list)
|
|
||||||
// }
|
|
||||||
// if (list.size >= pageSize) currentPage++
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
// fun bindPlate(
|
// /**
|
||||||
// equipmentBoxCode: String,
|
// * 添加人脸数据
|
||||||
// equipmentCode: String = globalEquipmentCode,
|
// */
|
||||||
// memberId: Int,
|
// fun addUserFace(faceData: String, imageFile: File, block: (Boolean, UserFaceModel?) -> Unit) {
|
||||||
// plateNumber: String
|
// launch {
|
||||||
// ) {
|
// val imageResp = repository.uploadImage(imageFile)
|
||||||
// _bindStateChange.value = null to ErrorInfo()
|
// val imageUrl = imageResp.data ?: ""
|
||||||
// launchWithLoading {
|
// if (imageUrl.isBlank()) {
|
||||||
// val bindParam = BindParam(
|
// block(false, null)
|
||||||
// appVersion = GlobalData.appVersion,
|
// return@launch
|
||||||
// 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())
|
|
||||||
// }
|
// }
|
||||||
|
// 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.GlobalData
|
||||||
import com.sw.platecabinet.GlobalKey
|
import com.sw.platecabinet.GlobalKey
|
||||||
import com.sw.platecabinet.model.DeviceConfig
|
import com.sw.platecabinet.model.DeviceConfig
|
||||||
import com.sw.platecabinet.model.request.LoginParam
|
|
||||||
import com.sw.platecabinet.model.response.UserFaceModel
|
import com.sw.platecabinet.model.response.UserFaceModel
|
||||||
import com.sw.platecabinet.utils.SpTool
|
import com.sw.platecabinet.utils.SpTool
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户viewmodel
|
* 用户viewmodel
|
||||||
@@ -28,38 +28,18 @@ class UserViewModel : BaseViewModel() {
|
|||||||
const val PAGE_SIZE = 100
|
const val PAGE_SIZE = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过人脸获取到的用户信息
|
|
||||||
// private val _currentUserInfo = MutableStateFlow<EquipmentUserInfo?>(null)
|
|
||||||
// val currentUserInfo: StateFlow<EquipmentUserInfo?> = _currentUserInfo
|
|
||||||
|
|
||||||
private val faceApi: FaceApi = FaceApi()
|
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(
|
fun getUserFace(
|
||||||
pageNo: Int,
|
pageNo: Int,
|
||||||
pageSize: Int,
|
pageSize: Int,
|
||||||
callback: (List<UserFaceModel>) -> Unit
|
callback: (List<UserFaceModel>) -> Unit
|
||||||
) {
|
) {
|
||||||
launchWithLoading{
|
launchWithLoading {
|
||||||
val response = repository.getUserFaceCache(pageNum = pageNo, pageSize = pageSize)
|
val response = repository.getUserFaceCache(pageNum = pageNo, pageSize = pageSize)
|
||||||
val status = parseResponse(response)
|
val status = parseResponse(response)
|
||||||
if (status) callback(response.data?:emptyList())
|
if (status) callback(response.data ?: emptyList())
|
||||||
else emptyList<UserFaceModel>()
|
else emptyList<UserFaceModel>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,7 +64,7 @@ class UserViewModel : BaseViewModel() {
|
|||||||
SPUtil.getInstance().put(GlobalKey.KEY_FIRST_RUN, true)
|
SPUtil.getInstance().put(GlobalKey.KEY_FIRST_RUN, true)
|
||||||
val list: List<UserFaceModel> = response.data ?: emptyList()
|
val list: List<UserFaceModel> = response.data ?: emptyList()
|
||||||
if (pageNo == 1 && list.isEmpty()) {
|
if (pageNo == 1 && list.isEmpty()) {
|
||||||
callback(true, "暂无数据")
|
callback(false, "暂无数据")
|
||||||
return@launchWithLoading
|
return@launchWithLoading
|
||||||
}
|
}
|
||||||
val faceEntityList = list.map {
|
val faceEntityList = list.map {
|
||||||
@@ -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) {
|
fun getDeviceConfig(block: (DeviceConfig?) -> Unit) {
|
||||||
// Timber.tag(TAG).d("getDeviceConfig")
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="#30000000">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
|
||||||
|
<solid android:color="@color/white" />
|
||||||
|
<corners android:radius="8dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="#5C77F7" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="#30000000">
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
|
||||||
|
<solid android:color="#5C77F7" />
|
||||||
|
<corners android:radius="8dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
@@ -2,34 +2,20 @@
|
|||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:width="600dp"
|
android:width="1920px"
|
||||||
android:height="1024dp">
|
android:height="1080px">
|
||||||
<bitmap android:src="@drawable/bg" />
|
<bitmap
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/bg_collect_page3" />
|
||||||
</item>
|
</item>
|
||||||
<item
|
<item
|
||||||
android:width="337dp"
|
android:width="506dp"
|
||||||
android:height="322dp"
|
android:height="483dp"
|
||||||
android:gravity="top|center_horizontal"
|
android:gravity="top|center_horizontal"
|
||||||
android:top="112dp">
|
android:top="150dp">
|
||||||
<bitmap
|
<bitmap
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:src="@drawable/img_init" />
|
android:src="@drawable/img_init" />
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<!-- TODO 临时测试 -->
|
|
||||||
<!-- <item-->
|
|
||||||
<!-- android:width="828dp"-->
|
|
||||||
<!-- android:height="1768dp">-->
|
|
||||||
<!-- <bitmap android:src="@drawable/bg" />-->
|
|
||||||
<!-- </item>-->
|
|
||||||
|
|
||||||
<!-- <item-->
|
|
||||||
<!-- android:width="337dp"-->
|
|
||||||
<!-- android:height="322dp"-->
|
|
||||||
<!-- android:gravity="top|center_horizontal"-->
|
|
||||||
<!-- android:top="360dp">-->
|
|
||||||
<!-- <bitmap-->
|
|
||||||
<!-- android:scaleType="fitCenter"-->
|
|
||||||
<!-- android:src="@drawable/img_init" />-->
|
|
||||||
<!-- </item>-->
|
|
||||||
</layer-list>
|
</layer-list>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@color/white"/>
|
||||||
|
<corners android:radius="12dp"/>
|
||||||
|
</shape>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<corners android:radius="12dp" />
|
<corners android:radius="16dp" />
|
||||||
<stroke
|
<stroke
|
||||||
android:width="2dp"
|
android:width="3dp"
|
||||||
android:color="#FFCC99" />
|
android:color="#FFC08A6F" />
|
||||||
</shape>
|
</shape>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/bg"
|
android:background="@drawable/bg_collect_page3"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".activity.InitActivity">
|
tools:context=".activity.InitActivity">
|
||||||
|
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
android:id="@+id/includeHeader"
|
android:id="@+id/includeHeader"
|
||||||
layout="@layout/item_title_time" />
|
layout="@layout/item_title_time" />
|
||||||
|
|
||||||
<View
|
<Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="2"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -26,34 +26,28 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="142dp"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_init_text"
|
android:src="@drawable/ic_init_text"
|
||||||
android:adjustViewBounds="true"/>
|
android:adjustViewBounds="true"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="345dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="90dp"
|
android:layout_marginTop="60dp"
|
||||||
android:src="@drawable/ic_init_img"
|
android:src="@drawable/ic_init_img"
|
||||||
android:adjustViewBounds="true" />
|
android:adjustViewBounds="true" />
|
||||||
|
|
||||||
<!-- <ImageView-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginTop="20dp"-->
|
|
||||||
<!-- android:src="@drawable/ic_init_press" />-->
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/takeButton"
|
android:id="@+id/takeButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="-35dp">
|
android:layout_marginTop="-35dp">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="360dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="110dp"
|
||||||
android:text="点击取盘"
|
android:text="点击取盘"
|
||||||
android:textColor="#FFCC99"
|
android:textColor="#FFCC99"
|
||||||
android:textSize="24sp"
|
android:textSize="36sp"
|
||||||
android:layout_marginHorizontal="60dp"
|
android:layout_marginHorizontal="60dp"
|
||||||
android:layout_marginVertical="50dp"
|
android:layout_marginVertical="50dp"
|
||||||
android:paddingHorizontal="45dp"
|
android:paddingHorizontal="45dp"
|
||||||
@@ -63,7 +57,7 @@
|
|||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|||||||
@@ -1,226 +1,125 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/bg"
|
|
||||||
android:fitsSystemWindows="false"
|
android:fitsSystemWindows="false"
|
||||||
android:orientation="vertical"
|
tools:context=".activity.LoginByFaceActivity"
|
||||||
tools:context=".activity.LoginByFaceActivity">
|
tools:ignore="HardcodedText,ContentDescription,PxUsage">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="776px"
|
||||||
|
android:layout_height="582px"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
<TextureView
|
||||||
|
android:id="@+id/dual_camera_texture_preview_rgb"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<com.sw.plate.utils.arcface.FaceRectView
|
||||||
|
android:id="@+id/dual_camera_face_rect_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:src="@drawable/bg_face_area" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/includeHeader"
|
android:id="@+id/includeHeader"
|
||||||
layout="@layout/item_title_time" />
|
layout="@layout/item_title_time" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="165dp"
|
||||||
|
android:layout_gravity="center_horizontal|top"
|
||||||
|
android:layout_marginTop="95dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<FrameLayout
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/tv_tip"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="visible">
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="请正视屏幕"
|
||||||
|
android:textColor="#FFF0C8B4"
|
||||||
|
android:textSize="48sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<FrameLayout
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/tvSimilarValue"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_height="20dp"
|
||||||
android:layout_marginTop="0dp"
|
android:layout_gravity="center_horizontal"
|
||||||
android:paddingTop="1dp">
|
android:layout_marginTop="0dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="12sp"
|
||||||
|
tools:text="0.618,3次" />
|
||||||
|
|
||||||
<TextureView
|
<TextView
|
||||||
android:id="@+id/dual_camera_texture_preview_rgb"
|
android:id="@+id/tv_to_init"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="visible" />
|
android:layout_marginTop="0dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="#FFF0C8B4"
|
||||||
|
android:textSize="48sp"
|
||||||
|
tools:text="30" />
|
||||||
|
|
||||||
<com.sw.plate.utils.arcface.FaceRectView
|
|
||||||
android:id="@+id/dual_camera_face_rect_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="visible" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginTop="0dp"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/bg_face"
|
|
||||||
android:visibility="visible" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_tip"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="129dp"
|
|
||||||
android:text="请正视屏幕"
|
|
||||||
android:textColor="#FFCC99"
|
|
||||||
android:textSize="36sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvSimilarValue"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="26sp"
|
|
||||||
android:layout_marginTop="80dp"
|
|
||||||
tools:text="0.618,3次"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:textColor="@color/white"/>
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:id="@+id/ll_to_pwd"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginStart="208dp"-->
|
|
||||||
<!-- android:layout_marginTop="730dp"-->
|
|
||||||
<!-- android:background="@drawable/btn_outline"-->
|
|
||||||
<!-- android:gravity="center"-->
|
|
||||||
<!-- android:paddingHorizontal="45dp"-->
|
|
||||||
<!-- android:paddingVertical="18dp"-->
|
|
||||||
<!-- android:visibility="gone">-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:text="密码登录"-->
|
|
||||||
<!-- android:textColor="#FFCC99"-->
|
|
||||||
<!-- android:textSize="24sp" />-->
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_to_init"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="185dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:textColor="#FFCC99"
|
|
||||||
android:textSize="36sp"
|
|
||||||
tools:text="30" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/llCollectButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:layout_marginBottom="100dp"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/btnRetry"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="60dp"
|
|
||||||
android:text="再次重试"
|
|
||||||
android:textColor="#FFCC99"
|
|
||||||
android:textSize="24sp"
|
|
||||||
android:layout_marginHorizontal="12dp"
|
|
||||||
android:layout_marginVertical="10dp"
|
|
||||||
android:paddingHorizontal="45dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:background="@drawable/btn_outline"
|
|
||||||
tools:ignore="HardcodedText" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/btnCollect"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="60dp"
|
|
||||||
android:text="新用户采集"
|
|
||||||
android:textColor="#FFCC99"
|
|
||||||
android:textSize="24sp"
|
|
||||||
android:layout_marginHorizontal="12dp"
|
|
||||||
android:layout_marginVertical="10dp"
|
|
||||||
android:paddingHorizontal="45dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:background="@drawable/btn_outline"
|
|
||||||
tools:ignore="HardcodedText" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:gravity="center_horizontal"-->
|
|
||||||
<!-- android:layout_gravity="bottom|center_horizontal"-->
|
|
||||||
<!-- android:layout_marginBottom="130dp"-->
|
|
||||||
<!-- android:orientation="vertical">-->
|
|
||||||
|
|
||||||
<!-- <LinearLayout-->
|
|
||||||
<!-- android:id="@+id/layoutState"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="50dp"-->
|
|
||||||
<!-- android:gravity="center_vertical"-->
|
|
||||||
<!-- android:orientation="horizontal"-->
|
|
||||||
<!-- android:visibility="invisible">-->
|
|
||||||
|
|
||||||
<!-- <ProgressBar-->
|
|
||||||
<!-- android:id="@+id/pbCollectLoading"-->
|
|
||||||
<!-- android:layout_width="32dp"-->
|
|
||||||
<!-- android:layout_height="32dp"-->
|
|
||||||
<!-- android:indeterminateTint="@color/white" />-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:id="@+id/tvCollectState"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:layout_marginStart="10dp"-->
|
|
||||||
<!-- android:text="采集中......"-->
|
|
||||||
<!-- android:textColor="@color/white"-->
|
|
||||||
<!-- android:textSize="24sp" />-->
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<!-- <TextView-->
|
|
||||||
<!-- android:id="@+id/btnCollectFace"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="60dp"-->
|
|
||||||
<!-- android:background="@drawable/btn_outline"-->
|
|
||||||
<!-- android:gravity="center"-->
|
|
||||||
<!-- android:layout_marginTop="10dp"-->
|
|
||||||
<!-- android:paddingHorizontal="45dp"-->
|
|
||||||
<!-- android:text="开始采集"-->
|
|
||||||
<!-- android:textColor="#FFCC99"-->
|
|
||||||
<!-- android:textSize="24sp"-->
|
|
||||||
<!-- tools:ignore="HardcodedText" />-->
|
|
||||||
<!-- </LinearLayout>-->
|
|
||||||
|
|
||||||
<!-- <androidx.recyclerview.widget.RecyclerView-->
|
|
||||||
<!-- android:id="@+id/rvLogInfo"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="match_parent"-->
|
|
||||||
<!-- android:layout_gravity="bottom"-->
|
|
||||||
<!-- android:overScrollMode="never"-->
|
|
||||||
<!-- android:visibility="gone"-->
|
|
||||||
<!-- android:background="@color/black"-->
|
|
||||||
<!-- tools:listitem="@layout/list_item_log_info" />-->
|
|
||||||
|
|
||||||
<!-- <ImageView-->
|
|
||||||
<!-- android:id="@+id/btnLogState"-->
|
|
||||||
<!-- android:layout_width="60dp"-->
|
|
||||||
<!-- android:layout_height="60dp"-->
|
|
||||||
<!-- android:layout_gravity="bottom|end"-->
|
|
||||||
<!-- android:background="@drawable/shape_white_circle"-->
|
|
||||||
<!-- android:padding="10dp"-->
|
|
||||||
<!-- android:layout_marginEnd="10dp"-->
|
|
||||||
<!-- android:layout_marginBottom="10dp"-->
|
|
||||||
<!-- android:src="@drawable/ic_log_show"-->
|
|
||||||
<!-- android:textSize="16sp" />-->
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivCollectPhoto"
|
|
||||||
android:layout_width="200dp"
|
|
||||||
android:layout_height="200dp"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:layout_gravity="top|start"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/llCollectButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="265dp"
|
||||||
|
android:layout_gravity="center_horizontal|bottom"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnRetry"
|
||||||
|
android:layout_width="360dp"
|
||||||
|
android:layout_height="110dp"
|
||||||
|
android:layout_marginHorizontal="20dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="再次重试"
|
||||||
|
android:textColor="#FFC08A6F"
|
||||||
|
android:textSize="36sp"
|
||||||
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnCollect"
|
||||||
|
android:layout_width="360dp"
|
||||||
|
android:layout_height="110dp"
|
||||||
|
android:layout_marginHorizontal="20dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="新用户采集"
|
||||||
|
android:textColor="#FFC08A6F"
|
||||||
|
android:textSize="36sp"
|
||||||
|
tools:ignore="HardcodedText" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivCollectPhoto"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="64dp"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:src="@drawable/logo_launcher" />
|
||||||
|
</FrameLayout>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@drawable/bg"
|
android:background="@drawable/bg_collect_page3"
|
||||||
tools:context=".activity.MainActivity">
|
tools:context=".activity.MainActivity">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
|||||||
@@ -0,0 +1,330 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/bg"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".activity.PlcSettingActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/includeHeader"
|
||||||
|
layout="@layout/item_title_time" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/layout_tips"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:src="@mipmap/img_error_tips"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
<TextView android:id="@+id/tv_tips"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="144dp"
|
||||||
|
android:text="暂无餐盘 请联系管理人员"
|
||||||
|
android:textColor="#fff0c8b4"
|
||||||
|
android:textSize="32sp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingHorizontal="50dp"
|
||||||
|
android:paddingVertical="20dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!-- ===== 连接控制 ===== -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="连接控制"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnOpenSerialPort"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="打开串口"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="1dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnOpenAutoMode"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="打开自动模式"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- ===== 出盘操作 ===== -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="出盘操作"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnOutPlate"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="出盘"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<!-- ===== 平台控制 ===== -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="平台控制"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnPlatformDown"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="平台下降"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="1dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnPlatformUp"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="平台上升"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnBackToBusiness"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="返回营业(补盘完成)"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnPlatformReset"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="餐盘平台复位"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
<!-- ===== 故障处理 ===== -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="故障处理"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnAlarmReset"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="故障复位"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<!-- ===== 参数设置 ===== -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="参数设置"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etParamType"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:hint="参数类型(如 18FD)"
|
||||||
|
android:inputType="text"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textColorHint="#99885566"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="1dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etParamValue"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:hint="参数值(整数)"
|
||||||
|
android:inputType="number"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textColorHint="#99885566"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnSetParams"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="设置参数"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<!-- ===== 状态显示 ===== -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="PLC 状态"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnRefreshStatus"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="刷新状态"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvStatusInfo"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:paddingHorizontal="16dp"
|
||||||
|
android:paddingVertical="14dp"
|
||||||
|
android:text="暂无状态数据"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="16sp"
|
||||||
|
tools:text="空盘:false | 平台下位:false | 平台上位:true | 取盘红外:false | 报警码:0" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- ===== 出盘操作 ===== -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="环境"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnSwitchEnv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:background="@drawable/btn_outline"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="切换环境"
|
||||||
|
android:textColor="#FFCC99"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="600dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_white_radius12"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingHorizontal="40dp"
|
||||||
|
android:paddingVertical="36dp">
|
||||||
|
|
||||||
|
<!-- 标题 -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="环境切换"
|
||||||
|
android:textColor="#ff141428"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<!-- 分割线 -->
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:background="#FFDCDCF0" />
|
||||||
|
|
||||||
|
<!-- 环境选项 -->
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/rgEnv"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbTest"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="72dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:text="测试环境"
|
||||||
|
android:textColor="#ff141428"
|
||||||
|
android:textSize="28sp" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbUat"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="72dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:text="UAT 环境"
|
||||||
|
android:textColor="#ff141428"
|
||||||
|
android:textSize="28sp" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbProd"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="72dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:text="生产环境"
|
||||||
|
android:textColor="#ff141428"
|
||||||
|
android:textSize="28sp" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<!-- 分割线 -->
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:background="#FFDCDCF0" />
|
||||||
|
|
||||||
|
<!-- 底部按钮 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="88dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatButton
|
||||||
|
android:id="@+id/btnCancel"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/bg_cancel"
|
||||||
|
android:text="取消"
|
||||||
|
android:textColor="#5C77F7"
|
||||||
|
android:textSize="28sp" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatButton
|
||||||
|
android:id="@+id/btnConfirm"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/bg_confirm"
|
||||||
|
android:text="确认"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="28sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -4,15 +4,16 @@
|
|||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="240dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
android:maxWidth="200dp"
|
||||||
android:background="@drawable/dialog_waiting">
|
android:background="@drawable/dialog_waiting">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="50dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="50dp"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="10dp"
|
||||||
android:indeterminateTint="@color/teal_200"
|
android:indeterminateTint="@color/teal_200"
|
||||||
android:indeterminateTintMode="src_atop" />
|
android:indeterminateTintMode="src_atop" />
|
||||||
|
|
||||||
@@ -20,10 +21,10 @@
|
|||||||
android:id="@+id/tvTip"
|
android:id="@+id/tvTip"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="30dp"
|
android:layout_marginHorizontal="10dp"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:text="请稍等"
|
android:text="请稍等"
|
||||||
android:textSize="22sp" />
|
android:textSize="26sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -3,30 +3,44 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="100dp"
|
||||||
android:paddingHorizontal="24dp">
|
android:paddingHorizontal="65dp"
|
||||||
|
tools:ignore="HardcodedText,ContentDescription,UseCompoundDrawables">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/tvLeftDate"
|
android:id="@+id/tvLeftDate"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:textColor="#FFCC99"
|
|
||||||
android:textSize="18sp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
tools:text="2025年6月18日 星期三" />
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:src="@drawable/logo_launcher" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_marginStart="25dp"
|
||||||
|
android:textColor="#FFF0C8B4"
|
||||||
|
android:textSize="30sp"
|
||||||
|
android:text="欢迎光临数味餐厅" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvRightTime"
|
android:id="@+id/tvRightTime"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:textColor="#FFCC99"
|
android:textColor="#FFF0C8B4"
|
||||||
android:textSize="18sp"
|
android:textSize="24sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/tvLeftDate"
|
app:layout_constraintTop_toTopOf="@id/tvLeftDate"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/tvLeftDate"
|
app:layout_constraintBottom_toBottomOf="@id/tvLeftDate"
|
||||||
tools:text="14:02:39" />
|
tools:text="2026年03月27日 星期五 12:08" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 179 KiB |
@@ -1,5 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">餐盘柜</string>
|
<string name="app_name">发盘机</string>
|
||||||
<!-- TODO: Remove or change this placeholder text -->
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
|
||||||
|
|||||||
@@ -87,10 +87,10 @@ public class ConfigUtil {
|
|||||||
/**
|
/**
|
||||||
* 默认相机分辨率
|
* 默认相机分辨率
|
||||||
*/
|
*/
|
||||||
private static final String DEFAULT_PREVIEW_SIZE = "1280x720";
|
// private static final String DEFAULT_PREVIEW_SIZE = "1280x720";
|
||||||
|
private static final String DEFAULT_PREVIEW_SIZE = "1024x768";
|
||||||
// private static final String DEFAULT_PREVIEW_SIZE = "400x640";
|
// private static final String DEFAULT_PREVIEW_SIZE = "400x640";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取String类型的preference
|
* 获取String类型的preference
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -343,6 +343,14 @@ public class FaceHelper implements FaceListener {
|
|||||||
refreshTrackId(faceInfoList);
|
refreshTrackId(faceInfoList);
|
||||||
if (faceInfoList.isEmpty()) {
|
if (faceInfoList.isEmpty()) {
|
||||||
return facePreviewInfoList;
|
return facePreviewInfoList;
|
||||||
|
} else {
|
||||||
|
FaceInfo currentFaceInfo = faceInfoList.get(0);
|
||||||
|
// L.e("currentFaceInfo width=" + currentFaceInfo.getRect().width() +
|
||||||
|
// "---height" + currentFaceInfo.getRect().height());
|
||||||
|
if (currentFaceInfo.getRect().width() < 200) {//距离远(人脸小),不识别
|
||||||
|
clearLeftFace(facePreviewInfoList);
|
||||||
|
return facePreviewInfoList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!onlyDetectLiveness) {
|
if (!onlyDetectLiveness) {
|
||||||
code = ftEngine.process(rgbNv21, previewSize.width, previewSize.height, FaceEngine.CP_PAF_NV21, faceInfoList,
|
code = ftEngine.process(rgbNv21, previewSize.width, previewSize.height, FaceEngine.CP_PAF_NV21, faceInfoList,
|
||||||
|
|||||||
@@ -397,6 +397,20 @@ public class RecognizeViewModel extends ViewModel implements RecognizeCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置人脸识别状态:清空上次识别结果及 FaceHelper 内部的 recognizeInfoMap,
|
||||||
|
* 使下一帧进入时能重新触发识别流程。
|
||||||
|
* 适用场景:短时间内再次识别、点击重试按钮等需要重新开始识别的时机。
|
||||||
|
*/
|
||||||
|
public void resetFaceState() {
|
||||||
|
// 清空粘性 LiveData,防止旧结果被重新投递给 observer
|
||||||
|
recognizeUserId.postValue(null);
|
||||||
|
// 清空 FaceHelper 内部所有人脸状态,让 trackId 对应的状态回到 TO_RETRY
|
||||||
|
if (faceHelper != null) {
|
||||||
|
faceHelper.clearFacePreviewInfoList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 释放操作
|
* 释放操作
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-1
@@ -25,6 +25,6 @@ dependencyResolutionManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = "SmartPlateCabinet"
|
rootProject.name = "SmartTakePlate"
|
||||||
include(":app")
|
include(":app")
|
||||||
include(":lib_face")
|
include(":lib_face")
|
||||||
|
|||||||
Reference in New Issue
Block a user