feat:人脸管理优化
This commit is contained in:
1 parent
88e73ad950
commit
2490d4f9a0
9 files changed
+175
-40
No files matched your search
@@ -1,12 +1,43 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
class SyncFaceTool {
|
||||
static const _tag = "sync人脸工具";
|
||||
|
||||
// 同步人脸
|
||||
static Future<void> syncFace({
|
||||
bool isAll = false,
|
||||
VoidCallback? onSyncGroup,
|
||||
}) async {
|
||||
final appSetting = await AppSettingTool.getSysSetting();
|
||||
final merchantDeptId = appSetting.merchantDeptId;
|
||||
// 人脸存储路径
|
||||
final storagePath = await AppFileTool.getFacePath();
|
||||
if (ObjectUtil.isEmpty(storagePath)) {
|
||||
logger.e("|$_tag|同步人脸错误,创建人脸存储路径错误");
|
||||
return;
|
||||
}
|
||||
// 同步没有的人脸
|
||||
int pageNo = 1;
|
||||
bool isNext = true;
|
||||
while (isNext) {
|
||||
final bool = await syncGroupFace(
|
||||
pageNo: pageNo,
|
||||
merchantDeptId: isAll ? "" : merchantDeptId!,
|
||||
storagePath: storagePath!,
|
||||
);
|
||||
if (isNext != bool) isNext = bool;
|
||||
if (!bool) break;
|
||||
pageNo += 1;
|
||||
onSyncGroup?.call();
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> syncGroupFace({
|
||||
required int pageNo,
|
||||
required String merchantDeptId,
|
||||
@@ -16,7 +47,7 @@ class SyncFaceTool {
|
||||
}) async {
|
||||
final app = Get.find<AppControl>();
|
||||
final faceDao = app.dataBase.getFaceDao;
|
||||
const size = 20;
|
||||
const size = 50;
|
||||
var pa = {
|
||||
"current": pageNo,
|
||||
"size": size,
|
||||
@@ -166,7 +197,7 @@ class SyncFaceTool {
|
||||
required String facePath,
|
||||
}) {
|
||||
if (ObjectUtil.isEmpty(facePath)) return null;
|
||||
return "${userId}_${sampleId}_$username$facePath";
|
||||
return "${userId}_${sampleId}_$username${AppFileTool.getFileExtension(facePath)}";
|
||||
}
|
||||
|
||||
/// 写入人脸头像到本地磁盘
|
||||
|
||||
Reference in new issue
Block a user