|
@@ -358,101 +358,96 @@ class IdCardScanController extends GetxController with WidgetsBindingObserver {
|
|
|
if (result.isSuccess) {
|
|
|
PromptBox.toast('身份证识别成功');
|
|
|
idCardInfo.localCardImagePath = file.path;
|
|
|
- idCardInfo.idCardName = result.patientName ?? "";
|
|
|
- idCardInfo.idCardGender =
|
|
|
- result.patientGender == GenderEnum.Male ? "男" : "女";
|
|
|
- idCardInfo.idCardNation = result.nationality ?? "";
|
|
|
- idCardInfo.idCardBirthDate =
|
|
|
- DataTimeUtils.formatDateString(result.birthday!);
|
|
|
- idCardInfo.idCardAddress = result.patientAddress ?? "";
|
|
|
- idCardInfo.idCardNumber = result.cardNo ?? "";
|
|
|
- state.isShowIdCardInfoSwitch = true;
|
|
|
- state.isIdCardInfoShow = true;
|
|
|
- state.isInFaceInput = true;
|
|
|
- await _createPatient(result);
|
|
|
- openBackCamera();
|
|
|
- } else {
|
|
|
- PromptBox.toast('身份证识别失败: ${result.errorMessage}');
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- logger.e("getPatientBaseByImageAsync failed: $e", e);
|
|
|
- }
|
|
|
- }
|
|
|
- state.isIdCardScanning = false;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /// 发生人脸录入事件
|
|
|
- void onCaptureFaceButtonPressed() async {
|
|
|
- state.isRunningFaceInput = true;
|
|
|
- if (kCameraController == null) {
|
|
|
- state.isRunningFaceInput = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- try {
|
|
|
- final XFile? file = await takePicture();
|
|
|
- if (file != null) {
|
|
|
- faceDetector = FaceDetector(options: FaceDetectorOptions());
|
|
|
- // faceDetector =
|
|
|
- // FaceDetector(options: FaceDetectorOptions(enableContours: true));
|
|
|
- int faceNum = 1; // max 分辨率下检测用时大约 100ms
|
|
|
- // int faceNum =
|
|
|
- // await doDetection(faceDetector, file.path); // max 分辨率下检测用时大约 100ms
|
|
|
-
|
|
|
- if (faceNum == 0) {
|
|
|
- PromptBox.toast('请将面部保持在识别框内');
|
|
|
- return;
|
|
|
- } else if (faceNum > 1) {
|
|
|
- PromptBox.toast('请保持只有一张面部在识别范围内');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- /// TODO 上传图像到云然后传给后端
|
|
|
- final url = await rpc.storage.upload(
|
|
|
- file,
|
|
|
- fileType: 'png',
|
|
|
- );
|
|
|
- print('⭐⭐⭐⭐⭐⭐⭐⭐ url: $url');
|
|
|
- try {
|
|
|
- SavePersonDTO result =
|
|
|
- await rpc.patient.savePatientBaseByFaceImageAsync(
|
|
|
- SavePatientBaseByFaceImageRequest(
|
|
|
- cardNo: idCardInfo.idCardNumber,
|
|
|
- token: Store.user.token,
|
|
|
- image: url,
|
|
|
- ),
|
|
|
- );
|
|
|
- print(result);
|
|
|
- if (result.success) {
|
|
|
- PromptBox.toast('人脸数据存入成功');
|
|
|
final idCardScanResult = IdCardScanResult(
|
|
|
success: true,
|
|
|
- cardNo: idCardInfo.idCardNumber,
|
|
|
- name: idCardInfo.idCardName,
|
|
|
- nation: idCardInfo.idCardNation,
|
|
|
- gender: idCardInfo.idCardGender == '男'
|
|
|
- ? GenderEnum.Male
|
|
|
- : GenderEnum.Female,
|
|
|
- birthday: DateTime.parse(idCardInfo.idCardBirthDate),
|
|
|
- address: idCardInfo.idCardAddress,
|
|
|
+ patientBaseDTO: result,
|
|
|
);
|
|
|
|
|
|
Get.back<IdCardScanResult>(
|
|
|
result: idCardScanResult,
|
|
|
);
|
|
|
} else {
|
|
|
- PromptBox.toast('人脸数据存入失败');
|
|
|
+ PromptBox.toast('身份证识别失败: ${result.errorMessage}');
|
|
|
}
|
|
|
} catch (e) {
|
|
|
- logger.e("savePatientBaseByFaceImageAsync failed: $e", e);
|
|
|
+ logger.e("getPatientBaseByImageAsync failed: $e", e);
|
|
|
}
|
|
|
}
|
|
|
- } catch (e) {
|
|
|
- logger.e("doDetection failed: $e", e);
|
|
|
- }
|
|
|
- state.isRunningFaceInput = false;
|
|
|
+ state.isIdCardScanning = false;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+ /// 发生人脸录入事件
|
|
|
+ // void onCaptureFaceButtonPressed() async {
|
|
|
+ // state.isRunningFaceInput = true;
|
|
|
+ // if (kCameraController == null) {
|
|
|
+ // state.isRunningFaceInput = false;
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // try {
|
|
|
+ // final XFile? file = await takePicture();
|
|
|
+ // if (file != null) {
|
|
|
+ // faceDetector = FaceDetector(options: FaceDetectorOptions());
|
|
|
+ // // faceDetector =
|
|
|
+ // // FaceDetector(options: FaceDetectorOptions(enableContours: true));
|
|
|
+ // int faceNum = 1; // max 分辨率下检测用时大约 100ms
|
|
|
+ // // int faceNum =
|
|
|
+ // // await doDetection(faceDetector, file.path); // max 分辨率下检测用时大约 100ms
|
|
|
+
|
|
|
+ // if (faceNum == 0) {
|
|
|
+ // PromptBox.toast('请将面部保持在识别框内');
|
|
|
+ // return;
|
|
|
+ // } else if (faceNum > 1) {
|
|
|
+ // PromptBox.toast('请保持只有一张面部在识别范围内');
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // /// TODO 上传图像到云然后传给后端
|
|
|
+ // final url = await rpc.storage.upload(
|
|
|
+ // file,
|
|
|
+ // fileType: 'png',
|
|
|
+ // );
|
|
|
+ // print('⭐⭐⭐⭐⭐⭐⭐⭐ url: $url');
|
|
|
+ // try {
|
|
|
+ // SavePersonDTO result =
|
|
|
+ // await rpc.patient.savePatientBaseByFaceImageAsync(
|
|
|
+ // SavePatientBaseByFaceImageRequest(
|
|
|
+ // cardNo: idCardInfo.idCardNumber,
|
|
|
+ // token: Store.user.token,
|
|
|
+ // image: url,
|
|
|
+ // ),
|
|
|
+ // );
|
|
|
+ // print(result);
|
|
|
+ // if (result.success) {
|
|
|
+ // PromptBox.toast('人脸数据存入成功');
|
|
|
+ // final idCardScanResult = IdCardScanResult(
|
|
|
+ // success: true,
|
|
|
+ // cardNo: idCardInfo.idCardNumber,
|
|
|
+ // name: idCardInfo.idCardName,
|
|
|
+ // nation: idCardInfo.idCardNation,
|
|
|
+ // gender: idCardInfo.idCardGender == '男'
|
|
|
+ // ? GenderEnum.Male
|
|
|
+ // : GenderEnum.Female,
|
|
|
+ // birthday: DateTime.parse(idCardInfo.idCardBirthDate),
|
|
|
+ // address: idCardInfo.idCardAddress,
|
|
|
+ // );
|
|
|
+
|
|
|
+ // Get.back<IdCardScanResult>(
|
|
|
+ // result: idCardScanResult,
|
|
|
+ // );
|
|
|
+ // } else {
|
|
|
+ // PromptBox.toast('人脸数据存入失败');
|
|
|
+ // }
|
|
|
+ // } catch (e) {
|
|
|
+ // logger.e("savePatientBaseByFaceImageAsync failed: $e", e);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } catch (e) {
|
|
|
+ // logger.e("doDetection failed: $e", e);
|
|
|
+ // }
|
|
|
+ // state.isRunningFaceInput = false;
|
|
|
+ // }
|
|
|
+
|
|
|
/// 发生结束录制视频事件
|
|
|
void onStopButtonPressed() {
|
|
|
stopVideoRecording().then((XFile? file) {
|
|
@@ -617,20 +612,20 @@ class IdCardScanController extends GetxController with WidgetsBindingObserver {
|
|
|
|
|
|
/// 完成人脸识别
|
|
|
void finishFaceDetection() {
|
|
|
- final result = IdCardScanResult(
|
|
|
- success: true,
|
|
|
- cardNo: idCardInfo.idCardNumber,
|
|
|
- name: idCardInfo.idCardName,
|
|
|
- nation: idCardInfo.idCardNation,
|
|
|
- gender:
|
|
|
- idCardInfo.idCardGender == '男' ? GenderEnum.Male : GenderEnum.Female,
|
|
|
- birthday: DateTime.now(),
|
|
|
- address: idCardInfo.idCardAddress,
|
|
|
- );
|
|
|
-
|
|
|
- Get.back<IdCardScanResult>(
|
|
|
- result: result,
|
|
|
- );
|
|
|
+ // final result = IdCardScanResult(
|
|
|
+ // success: true,
|
|
|
+ // cardNo: idCardInfo.idCardNumber,
|
|
|
+ // name: idCardInfo.idCardName,
|
|
|
+ // nation: idCardInfo.idCardNation,
|
|
|
+ // gender:
|
|
|
+ // idCardInfo.idCardGender == '男' ? GenderEnum.Male : GenderEnum.Female,
|
|
|
+ // birthday: DateTime.now(),
|
|
|
+ // address: idCardInfo.idCardAddress,
|
|
|
+ // );
|
|
|
+
|
|
|
+ // Get.back<IdCardScanResult>(
|
|
|
+ // result: result,
|
|
|
+ // );
|
|
|
}
|
|
|
|
|
|
/// WIP
|
|
@@ -790,31 +785,11 @@ class IdCardScanController extends GetxController with WidgetsBindingObserver {
|
|
|
class IdCardScanResult {
|
|
|
bool success;
|
|
|
|
|
|
- /// 身份证号
|
|
|
- String cardNo;
|
|
|
-
|
|
|
- /// 姓名
|
|
|
- String name;
|
|
|
-
|
|
|
- /// 性别
|
|
|
- GenderEnum gender;
|
|
|
-
|
|
|
- /// 民族
|
|
|
- String nation;
|
|
|
-
|
|
|
- /// 出生日期
|
|
|
- DateTime birthday;
|
|
|
-
|
|
|
- /// 地址
|
|
|
- String address;
|
|
|
+ /// 身份证信息
|
|
|
+ PatientBaseDTO patientBaseDTO;
|
|
|
|
|
|
IdCardScanResult({
|
|
|
required this.success,
|
|
|
- required this.cardNo,
|
|
|
- required this.name,
|
|
|
- required this.gender,
|
|
|
- required this.nation,
|
|
|
- required this.birthday,
|
|
|
- required this.address,
|
|
|
+ required this.patientBaseDTO,
|
|
|
});
|
|
|
}
|