tango-app-api-audit 3.4.48 → 3.4.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { checkFileExist, chunkArray, download, getDate, getDateWithCustomizeTime, getObject, getOpenSearchData, getUTC, insertOpenSearchData, listFileByPath, logger, signedUrl, sqsReceive, updateOpenSearchData } from 'tango-app-api-middleware';
|
|
2
|
-
import { aggregateBinaryAudit,
|
|
2
|
+
import { aggregateBinaryAudit, findOneBinaryAudit, updateOneBinaryAuditModel, updateOneUpsertBinaryAudit } from '../service/binaryAudit.service.js';
|
|
3
3
|
import { countDocumentsStore, findOneStore } from '../service/store.service.js';
|
|
4
4
|
import { findOneUser } from '../service/user.service.js';
|
|
5
5
|
import { aggregateUserEmpDetection, countDocumentsUserEmpDetection, createUserEmpDetection, updateOneUserEmpDetection } from '../service/userEmpDetection.service.js';
|
|
@@ -543,14 +543,6 @@ export async function getAuditFile( req, res ) {
|
|
|
543
543
|
moduleType: userDetails[0].moduleType,
|
|
544
544
|
};
|
|
545
545
|
break;
|
|
546
|
-
case 'uniform-detection':
|
|
547
|
-
query ={
|
|
548
|
-
storeId: userDetails[0].storeId,
|
|
549
|
-
fileDate: userDetails[0].fileDate,
|
|
550
|
-
// tempId: userDetails[0].tempId,
|
|
551
|
-
moduleType: userDetails[0].moduleType,
|
|
552
|
-
};
|
|
553
|
-
break;
|
|
554
546
|
case 'camera-angle-change':
|
|
555
547
|
query ={
|
|
556
548
|
storeId: userDetails[0].storeId,
|
|
@@ -569,12 +561,6 @@ export async function getAuditFile( req, res ) {
|
|
|
569
561
|
};
|
|
570
562
|
break;
|
|
571
563
|
case 'cleaning':
|
|
572
|
-
query ={
|
|
573
|
-
storeId: userDetails[0].storeId,
|
|
574
|
-
fileDate: userDetails[0].fileDate,
|
|
575
|
-
moduleType: userDetails[0].moduleType,
|
|
576
|
-
};
|
|
577
|
-
break;
|
|
578
564
|
case 'scrum':
|
|
579
565
|
query ={
|
|
580
566
|
storeId: userDetails[0].storeId,
|
|
@@ -630,33 +616,6 @@ export async function getAuditFile( req, res ) {
|
|
|
630
616
|
file_path: msg.changed } ) : '',
|
|
631
617
|
},
|
|
632
618
|
];
|
|
633
|
-
break;
|
|
634
|
-
case 'uniform-detection':
|
|
635
|
-
const files = [];
|
|
636
|
-
|
|
637
|
-
const params ={
|
|
638
|
-
Bucket: msg.inputBucketName,
|
|
639
|
-
Key: msg?.filePath,
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
const isExists = await checkFileExist( params );
|
|
643
|
-
|
|
644
|
-
if ( isExists ) {
|
|
645
|
-
const signedParams ={
|
|
646
|
-
Bucket: msg.inputBucketName,
|
|
647
|
-
file_path: msg?.filePath,
|
|
648
|
-
};
|
|
649
|
-
const data = await signedUrl( signedParams );
|
|
650
|
-
|
|
651
|
-
files.push(
|
|
652
|
-
data,
|
|
653
|
-
);
|
|
654
|
-
}
|
|
655
|
-
result.push( {
|
|
656
|
-
type: 'image',
|
|
657
|
-
file: files,
|
|
658
|
-
} );
|
|
659
|
-
|
|
660
619
|
break;
|
|
661
620
|
case 'unattended-customer':
|
|
662
621
|
case 'left-in-middle':
|
|
@@ -749,9 +708,7 @@ export async function getAuditFile( req, res ) {
|
|
|
749
708
|
|
|
750
709
|
const record = {
|
|
751
710
|
userId: req.user._id,
|
|
752
|
-
storeId: msg.storeId,
|
|
753
711
|
clientId: storeInfo?.clientId,
|
|
754
|
-
fileDate: msg.fileDate,
|
|
755
712
|
queueName: inputData.queueName,
|
|
756
713
|
auditStatus: 'inprogress',
|
|
757
714
|
auditType: 'Audit',
|
|
@@ -760,7 +717,6 @@ export async function getAuditFile( req, res ) {
|
|
|
760
717
|
startTime: new Date(),
|
|
761
718
|
tempId: msg.tempId,
|
|
762
719
|
fileDetails: msg.fileDetails,
|
|
763
|
-
moduleType: inputData.moduleType,
|
|
764
720
|
inputBucketName: msg.inputBucketName,
|
|
765
721
|
question: msg.question,
|
|
766
722
|
questionType: msg.questionType,
|
|
@@ -775,7 +731,48 @@ export async function getAuditFile( req, res ) {
|
|
|
775
731
|
'inspectHourCount': msg.inspectHourCount,
|
|
776
732
|
'endHourCount': msg.inspectHourCount,
|
|
777
733
|
} : {};
|
|
778
|
-
|
|
734
|
+
|
|
735
|
+
let getQuery = {};
|
|
736
|
+
switch ( inputData.moduleType ) {
|
|
737
|
+
case 'unattended-customer':
|
|
738
|
+
getQuery ={
|
|
739
|
+
storeId: msg.storeId,
|
|
740
|
+
fileDate: msg.fileDate,
|
|
741
|
+
tempId: msg.tempId,
|
|
742
|
+
moduleType: inputData.moduleType,
|
|
743
|
+
};
|
|
744
|
+
break;
|
|
745
|
+
case 'left-in-middle':
|
|
746
|
+
getQuery ={
|
|
747
|
+
storeId: msg.storeId,
|
|
748
|
+
fileDate: msg.fileDate,
|
|
749
|
+
question: msg.question,
|
|
750
|
+
moduleType: inputData.moduleType,
|
|
751
|
+
};
|
|
752
|
+
break;
|
|
753
|
+
case 'camera-angle-change':
|
|
754
|
+
case 'eye-test-camera':
|
|
755
|
+
getQuery ={
|
|
756
|
+
storeId: msg.storeId,
|
|
757
|
+
fileDate: msg.fileDate,
|
|
758
|
+
streamName: msg.streamName,
|
|
759
|
+
moduleType: inputData.moduleType,
|
|
760
|
+
};
|
|
761
|
+
break;
|
|
762
|
+
case 'cleaning':
|
|
763
|
+
case 'scrum':
|
|
764
|
+
getQuery ={
|
|
765
|
+
storeId: msg.storeId,
|
|
766
|
+
fileDate: msg.fileDate,
|
|
767
|
+
moduleType: inputData.moduleType,
|
|
768
|
+
};
|
|
769
|
+
break;
|
|
770
|
+
default:
|
|
771
|
+
return res.sendError( 'Please give valid moduleType', 400 );
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
await updateOneUpsertBinaryAudit( getQuery, record );
|
|
775
|
+
insertData = await findOneBinaryAudit( getQuery );
|
|
779
776
|
} else {
|
|
780
777
|
insertData = userDetails[0];
|
|
781
778
|
}
|
|
@@ -1090,6 +1087,7 @@ export async function saveBinary( req, res ) {
|
|
|
1090
1087
|
fileDate: inputData.fileDate,
|
|
1091
1088
|
moduleType: inputData.moduleType,
|
|
1092
1089
|
Answer: inputData.answer,
|
|
1090
|
+
configTime: getFilePath?.sqs?.Body?.configTime,
|
|
1093
1091
|
inputBucketName: getFilePath?.sqs?.Body?.inputBucketName,
|
|
1094
1092
|
folderPath: [ 'cleaning', 'scrum' ].includes( inputData.moduleType ) ? getFilePath?.sqs?.Body?.fileDetails[0]?.outputFilePath : folderPath.split( '/' ).slice( 0, -1 ).join( '/' ) + '/',
|
|
1095
1093
|
createdAt: new Date(),
|
|
@@ -1452,6 +1450,124 @@ export async function userAuditHistory( req, res ) {
|
|
|
1452
1450
|
} );
|
|
1453
1451
|
}
|
|
1454
1452
|
|
|
1453
|
+
let traxAuditDataQuery={};
|
|
1454
|
+
let traxAuditDataFilter = [];
|
|
1455
|
+
switch ( inputData.moduleType ) {
|
|
1456
|
+
case 'unattended-customer':
|
|
1457
|
+
traxAuditDataQuery= {
|
|
1458
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
1459
|
+
};
|
|
1460
|
+
traxAuditDataFilter=[ {
|
|
1461
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1465
|
+
},
|
|
1466
|
+
{
|
|
1467
|
+
$eq: [ '$tempId', '$$tempId' ],
|
|
1468
|
+
},
|
|
1469
|
+
{
|
|
1470
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
1471
|
+
},
|
|
1472
|
+
];
|
|
1473
|
+
break;
|
|
1474
|
+
case 'left-in-middle':
|
|
1475
|
+
traxAuditDataQuery= {
|
|
1476
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
1477
|
+
};
|
|
1478
|
+
traxAuditDataFilter=[ {
|
|
1479
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1480
|
+
},
|
|
1481
|
+
{
|
|
1482
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
$eq: [ '$question', '$$question' ],
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
1489
|
+
},
|
|
1490
|
+
];
|
|
1491
|
+
break;
|
|
1492
|
+
case 'uniform-detection':
|
|
1493
|
+
case 'mobile-detection':
|
|
1494
|
+
case 'scrum':
|
|
1495
|
+
case 'cleaning':
|
|
1496
|
+
traxAuditDataQuery= {
|
|
1497
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType',
|
|
1498
|
+
};
|
|
1499
|
+
traxAuditDataFilter=[ {
|
|
1500
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1501
|
+
},
|
|
1502
|
+
{
|
|
1503
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
1507
|
+
},
|
|
1508
|
+
];
|
|
1509
|
+
break;
|
|
1510
|
+
case 'camera-angle-change':
|
|
1511
|
+
traxAuditDataQuery= {
|
|
1512
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
1513
|
+
};
|
|
1514
|
+
traxAuditDataFilter=[ {
|
|
1515
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
1525
|
+
},
|
|
1526
|
+
];
|
|
1527
|
+
break;
|
|
1528
|
+
case 'hygiene':
|
|
1529
|
+
traxAuditDataQuery= {
|
|
1530
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', zoneName: '$zoneName',
|
|
1531
|
+
};
|
|
1532
|
+
traxAuditDataFilter=[ {
|
|
1533
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1534
|
+
},
|
|
1535
|
+
{
|
|
1536
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1537
|
+
},
|
|
1538
|
+
{
|
|
1539
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
1540
|
+
},
|
|
1541
|
+
{
|
|
1542
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
1543
|
+
},
|
|
1544
|
+
];
|
|
1545
|
+
break;
|
|
1546
|
+
case 'eye-test-camera':
|
|
1547
|
+
traxAuditDataQuery= {
|
|
1548
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', question: '$question', streamName: '$streamName',
|
|
1549
|
+
};
|
|
1550
|
+
traxAuditDataFilter=[ {
|
|
1551
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1555
|
+
},
|
|
1556
|
+
{
|
|
1557
|
+
$eq: [ '$question', '$$question' ],
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
1561
|
+
},
|
|
1562
|
+
{
|
|
1563
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
1564
|
+
},
|
|
1565
|
+
];
|
|
1566
|
+
break;
|
|
1567
|
+
default:
|
|
1568
|
+
return res.sendError( 'Please give valid modueType', 400 );
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1455
1571
|
const query = [
|
|
1456
1572
|
{
|
|
1457
1573
|
$match: {
|
|
@@ -1512,24 +1628,12 @@ export async function userAuditHistory( req, res ) {
|
|
|
1512
1628
|
{
|
|
1513
1629
|
$lookup: {
|
|
1514
1630
|
from: 'traxAuditData',
|
|
1515
|
-
let:
|
|
1516
|
-
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
1517
|
-
},
|
|
1631
|
+
let: traxAuditDataQuery,
|
|
1518
1632
|
pipeline: [
|
|
1519
1633
|
{
|
|
1520
1634
|
$match: {
|
|
1521
1635
|
$expr: {
|
|
1522
|
-
$and:
|
|
1523
|
-
{
|
|
1524
|
-
$eq: [ '$fileDate', '$$fileDate' ],
|
|
1525
|
-
},
|
|
1526
|
-
{
|
|
1527
|
-
$eq: [ '$storeId', '$$storeId' ],
|
|
1528
|
-
},
|
|
1529
|
-
{
|
|
1530
|
-
$eq: [ '$zoneName', '$$zoneName' ],
|
|
1531
|
-
},
|
|
1532
|
-
],
|
|
1636
|
+
$and: traxAuditDataFilter,
|
|
1533
1637
|
},
|
|
1534
1638
|
},
|
|
1535
1639
|
},
|
|
@@ -4207,7 +4311,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4207
4311
|
} else {
|
|
4208
4312
|
logger.error( {
|
|
4209
4313
|
error: { folderPath: folderPath, nextQuery: nextQuery },
|
|
4210
|
-
function: `
|
|
4314
|
+
function: `geDetectiontAuditFile - ${inputData.moduleType }`,
|
|
4211
4315
|
message: 'Bucket image data not availale',
|
|
4212
4316
|
} );
|
|
4213
4317
|
return res.sendError( 'Bucket is Empty', 204 );
|
|
@@ -16,3 +16,7 @@ export function findOneBinaryAudit( query ) {
|
|
|
16
16
|
export function updateOneBinaryAuditModel( query, record ) {
|
|
17
17
|
return binaryAuditModel.updateOne( query, { $set: record } );
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
export function updateOneUpsertBinaryAudit( query, record ) {
|
|
21
|
+
return binaryAuditModel.updateOne( query, { $set: record }, { upsert: true } );
|
|
22
|
+
}
|