fix:人脸模型为空导致注册识别引擎出错的问题

This commit is contained in:
dzc committed 2025-04-22 15:27:05 +08:00
1 parent b370be9111
commit 17914f5d10
5 files changed
+41

No files matched your search

@@ -74,4 +74,9 @@ abstract class FaceDao {
SELECT DISTINCT a.deptId FROM face a WHERE a.deptId IS NOT NULL
''')
Future<List<String>> findAllUserIds();
@Query('''
SELECT * FROM face WHERE faceModel = '' OR faceModel IS NULL
''')
Future<List<FaceEntity>?> getEmptyFaceList();
}
@@ -1624,6 +1624,26 @@ class _$FaceDao extends FaceDao {
mapper: (Map<String, Object?> row) => row.values.first as String);
}
@override
Future<List<FaceEntity>?> getEmptyFaceList() async {
return _queryAdapter.queryList(
'SELECT * FROM face WHERE faceModel = \'\' OR faceModel IS NULL',
mapper: (Map<String, Object?> row) => FaceEntity(
id: row['id'] as int?,
userId: row['userId'] as String,
sampleId: row['sampleId'] as String,
userName: row['userName'] as String,
deptId: row['deptId'] as String?,
deptName: row['deptName'] as String?,
imagePath: row['imagePath'] as String,
path: row['path'] as String?,
faceModel: _listIntConverter.decode(row['faceModel'] as String),
createTime:
_dateTimeEmptyConverter.decode(row['createTime'] as String),
updateTime:
_dateTimeEmptyConverter.decode(row['updateTime'] as String)));
}
@override
Future<int> save(FaceEntity entity) {
return _faceEntityInsertionAdapter.insertAndReturnId(
+14
View File
@@ -9,6 +9,20 @@ import 'package:pj_supermarket_cloud/common/index.dart';
class SyncFaceTool {
static const _tag = "sync人脸工具";
// 删除数据库中为空的人脸
static Future<void> delEmptyFace() async {
final app = Get.find<AppControl>();
final faceDao = app.dataBase.getFaceDao;
final faceList = await faceDao.getEmptyFaceList();
if (ObjectUtil.isEmptyList(faceList)) return;
for (final v in faceList!) {
if (ObjectUtil.isNotEmpty(v.path)) {
await delFaceByStorage(filePath: v.path!);
}
await faceDao.delById(v.id!);
}
}
// 同步人脸
static Future<void> syncFace({
bool isAll = false,
@@ -327,6 +327,7 @@ class SelectPayTypeDialogController extends GetxController {
}
final faceCount = await FaceDiscernPlugs.getFaceCount();
if (faceCount == 0) {
await SyncFaceTool.delEmptyFace();
await AppFaceTool.faceRegister();
}
final isJump = await AppFaceTool.jumpFacePage();
@@ -100,6 +100,7 @@ class FaceManageController extends GetxController {
maskType: EasyLoadingMaskType.black,
);
try {
await SyncFaceTool.delEmptyFace();
await SyncFaceTool.syncFace(
isAll: isAll,
onSyncGroup: () {