Переглянути джерело

Update verifcation interfaces and payload information and java response

enzo 2 місяців тому
батько
коміт
f4ecc8ea01

+ 5 - 0
apps/fis-fingerprint/src/fis-fingerprint.controller.ts

@@ -24,4 +24,9 @@ export class FisFingerprintController {
   handleMessage(message: any): void {
     this.fisFingerprintService.verifyFingeprint(message)
   }
+
+  @EventPattern(`verification`)
+  handleVerification(message: any): void {
+    //  put int service and pass to sampleapp to redirect the response back to UI
+  }
 }

+ 3 - 3
apps/fis-verification/src/fis-verification.module.ts

@@ -27,13 +27,13 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
         inject: [ConfigService]
       },
       {
-        name: `JAVA_AFIS`,
+        name: `FINGERPRINT_SERVICE`,
         imports: [ConfigModule],
         useFactory: async (configService: ConfigService) => ({
           transport: Transport.TCP,
           options: {
-            host: configService.get<string>(`afis.host`) as string,
-            port: configService.get<number>(`afis.tcpPort`) as number,
+            host: configService.get<string>(`fingerprint.host`) as string,
+            port: configService.get<number>(`fingerprint.tcpPort`) as number,
             retryAttempts: 5,
             retryDelay: 5000
           }

+ 24 - 0
apps/fis-verification/src/fis-verification.service.ts

@@ -17,15 +17,39 @@ export class FisVerificationService {
 
   constructor(
     @Inject(`SAMPLEAPP_SERVICE`) private sampleClient: ClientProxy,
+    @Inject(`FINGERPRINT_SERVICE`) private fingerprintClient: ClientProxy,
     private configService: ConfigService
   ) {
+    // Set up incoming responses or messages from TCP Java
     this.port = this.configService.get<number>('afis.tcpPort') as number
     this.host = this.configService.get<string>('afis.host') as string
 
     this.javaClient = connectToAfisJava(this.host, this.port)
     this.javaClient.on(`data`, (data) => {
       let message: JavaResponse = JSON.parse(data.toString())
+      console.log(message)
       console.log(`Java server response: ${message.message}`)
+      if (message.operation == `QualityAssurance`) {
+        let response: FisMessage = {
+          header: {
+            messageID: uuid(),
+            messageName: `Verification Response`
+          },
+          data: {
+            id: uuid(),
+            cmd: `QualityAssurance`,
+            message: `${message.data.name} finger position ${message.data.fingerprints[0].fpPosition} edge score is ${(message.edgeScore > 250 ? `good` : `bad`)}`,
+            data: {
+              score: message.score,
+              person: message.data.name,
+              fpPosition: message.data.fingerprints[0].fpPosition,
+              fpQuality: (message.score > 250 ? `good` : `bad`)
+            }
+          }
+        }
+        this.fingerprintClient.emit(`message`, response)
+      }
+
       if (message.operation == `Registration` && message.status == `Success`) {
         this.registeredFingerprintData.push((message.data as PersonFingerprintData).fingerprints[0] as Fingerprint)
         console.log(message.data)

+ 4 - 4
libs/types/interface.ts

@@ -31,7 +31,7 @@ export interface FisMessage {
 
 export interface FingerprintPayloadUI {
     id: string,
-    cmd: `Registration` | `Verification`,
+    cmd: `Registration` | `Verification` | `QualityAssurance`,
     date: Date,
     personInfo: PersonInfo,
     fpScan: string,
@@ -43,11 +43,12 @@ export interface FingerprintPayload extends FingerprintPayloadUI {
 
 export interface JavaResponse {
     id: string,
-    operation: `Registration` | `Verification`,
+    operation: `Registration` | `Verification` | `QualityAssurance`,
     status: `Failed` | `Success` | `Registered` | `Not Registered`,
     message: string,
     data: PersonFingerprintData,
-    score?: number
+    edgeScore: number,
+    score: number 
 }
 export interface PersonFingerprintData {
     id: string,
@@ -69,4 +70,3 @@ export interface PersonInfo {
     org: string,
     code: number
 }
-