tango-app-api-audit 3.4.59 → 3.4.60
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.60",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"mongodb": "^6.7.0",
|
|
27
27
|
"nodemon": "^3.1.3",
|
|
28
28
|
"swagger-ui-express": "^5.0.1",
|
|
29
|
-
"tango-api-schema": "^2.2.
|
|
30
|
-
"tango-app-api-middleware": "^3.1.
|
|
29
|
+
"tango-api-schema": "^2.2.95",
|
|
30
|
+
"tango-app-api-middleware": "^3.1.71",
|
|
31
31
|
"winston": "^3.13.0",
|
|
32
32
|
"winston-daily-rotate-file": "^5.0.0"
|
|
33
33
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkFileExist, chunkArray, download, getDate, getDateWithCustomizeTime, getJsonFileData, getObject, getOpenSearchData, getUTC, insertOpenSearchData, listFileByPath, logger, signedUrl, sqsReceive, updateOpenSearchData } from 'tango-app-api-middleware';
|
|
1
|
+
import { checkFileExist, chunkArray, download, getDate, getDateWithCustomizeTime, getJsonFileData, getObject, getOpenSearchData, getUTC, insertOpenSearchData, listFileByPath, logger, signedUrl, sqsReceive, updateOpenSearchData, sendMessageToQueue, listQueue, copyImage } from 'tango-app-api-middleware';
|
|
2
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';
|
|
@@ -8,7 +8,6 @@ import { aggregateClient, findOneClient } from '../service/client.service.js';
|
|
|
8
8
|
import dayjs from 'dayjs';
|
|
9
9
|
import { aggregateAssignAudit } from '../service/assignAudit.service.js';
|
|
10
10
|
import { aggregateStoreEmpDetection, updateManyStoreEmpDetection, updateOneStoreEmpDetection } from '../service/storeEmpDetection.service.js';
|
|
11
|
-
import { listQueue, sendMessageToQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
12
11
|
import _ from 'lodash';
|
|
13
12
|
import mongoose from 'mongoose';
|
|
14
13
|
import { findOneAuditLog, createAuditLog,
|
|
@@ -19,7 +18,6 @@ import {
|
|
|
19
18
|
import { updateOneEmpDetectionOutput } from '../service/empDetectionOutput.service.js';
|
|
20
19
|
import axios from 'axios';
|
|
21
20
|
import FormData from 'form-data';
|
|
22
|
-
|
|
23
21
|
export async function workSpace( req, res ) {
|
|
24
22
|
try {
|
|
25
23
|
const inputData = req.body;
|
|
@@ -547,6 +545,7 @@ export async function getAuditFile( req, res ) {
|
|
|
547
545
|
};
|
|
548
546
|
break;
|
|
549
547
|
case 'camera-angle-change':
|
|
548
|
+
case 'anomaly-audit':
|
|
550
549
|
query ={
|
|
551
550
|
storeId: userDetails[0].storeId,
|
|
552
551
|
fileDate: userDetails[0].fileDate,
|
|
@@ -714,6 +713,19 @@ export async function getAuditFile( req, res ) {
|
|
|
714
713
|
file: eyeTestfiles,
|
|
715
714
|
} );
|
|
716
715
|
break;
|
|
716
|
+
case 'anomaly-audit':
|
|
717
|
+
for ( let i =0; i< msg.fileDetails.length; i++ ) {
|
|
718
|
+
const files = [];
|
|
719
|
+
const data = msg.fileDetails[i].folderPath;
|
|
720
|
+
files.push(
|
|
721
|
+
data,
|
|
722
|
+
);
|
|
723
|
+
result.push( {
|
|
724
|
+
type: msg.fileDetails[i].type,
|
|
725
|
+
file: files,
|
|
726
|
+
} );
|
|
727
|
+
}
|
|
728
|
+
break;
|
|
717
729
|
default:
|
|
718
730
|
return res.sendError( 'Please given valid moduleType', 400 );
|
|
719
731
|
}
|
|
@@ -753,7 +765,7 @@ export async function getAuditFile( req, res ) {
|
|
|
753
765
|
questionType: msg.questionType,
|
|
754
766
|
streamName: msg.streamName,
|
|
755
767
|
};
|
|
756
|
-
record.streamName =
|
|
768
|
+
record.streamName =[ 'camera-angle-change', 'eye-test-camera', 'anomaly-audit', 'scrum' ].includes( inputData.moduleType )? msg.streamName : '';
|
|
757
769
|
record.videoDetails = inputData.moduleType == 'left-in-middle'? {
|
|
758
770
|
'startHour': msg.startHour,
|
|
759
771
|
'inspectHour': msg.inspectHour,
|
|
@@ -783,6 +795,7 @@ export async function getAuditFile( req, res ) {
|
|
|
783
795
|
break;
|
|
784
796
|
case 'camera-angle-change':
|
|
785
797
|
case 'eye-test-camera':
|
|
798
|
+
case 'anomaly-audit':
|
|
786
799
|
getQuery ={
|
|
787
800
|
storeId: msg.storeId,
|
|
788
801
|
fileDate: msg.fileDate,
|
|
@@ -1009,6 +1022,19 @@ export async function getUpdatedFile( req, res ) {
|
|
|
1009
1022
|
file: eyeTestfiles,
|
|
1010
1023
|
} );
|
|
1011
1024
|
break;
|
|
1025
|
+
case 'anomaly-audit':
|
|
1026
|
+
for ( let i =0; i< msg.fileDetails.length; i++ ) {
|
|
1027
|
+
const files = [];
|
|
1028
|
+
const data = msg.fileDetails[i].folderPath;
|
|
1029
|
+
files.push(
|
|
1030
|
+
data,
|
|
1031
|
+
);
|
|
1032
|
+
result.push( {
|
|
1033
|
+
type: msg.fileDetails[i].type,
|
|
1034
|
+
file: files,
|
|
1035
|
+
} );
|
|
1036
|
+
}
|
|
1037
|
+
break;
|
|
1012
1038
|
default:
|
|
1013
1039
|
return res.sendError( 'Please given valid moduleType', 400 );
|
|
1014
1040
|
}
|
|
@@ -1294,12 +1320,6 @@ export async function saveBinary( req, res ) {
|
|
|
1294
1320
|
streamName: req.userAudit?.streamName,
|
|
1295
1321
|
},
|
|
1296
1322
|
);
|
|
1297
|
-
logger.info( { getScrumFilePath: getScrumFilePath, data: {
|
|
1298
|
-
fileDate: inputData.fileDate,
|
|
1299
|
-
storeId: inputData.storeId,
|
|
1300
|
-
moduleType: inputData.moduleType,
|
|
1301
|
-
streamName: req.userAudit?.streamName,
|
|
1302
|
-
}, mesage: '.............1' } );
|
|
1303
1323
|
const scrumOutput = {
|
|
1304
1324
|
clientId: req.userAudit?.clientId,
|
|
1305
1325
|
clientName: getClient1?.clientName,
|
|
@@ -1622,6 +1642,120 @@ export async function saveBinary( req, res ) {
|
|
|
1622
1642
|
return res.sendSuccess( `Successfully updated in ${value}` );
|
|
1623
1643
|
}
|
|
1624
1644
|
|
|
1645
|
+
case 'anomaly-audit':
|
|
1646
|
+
let anomalyQury ={
|
|
1647
|
+
_id: inputData.auditId,
|
|
1648
|
+
storeId: inputData.storeId,
|
|
1649
|
+
fileDate: inputData.fileDate,
|
|
1650
|
+
tempId: inputData.tempId,
|
|
1651
|
+
moduleType: inputData.moduleType,
|
|
1652
|
+
};
|
|
1653
|
+
|
|
1654
|
+
let anomalyRecord={
|
|
1655
|
+
auditStatus: 'completed',
|
|
1656
|
+
answer: inputData.answer,
|
|
1657
|
+
userComments: inputData.userComments || '',
|
|
1658
|
+
endTime: new Date(),
|
|
1659
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1660
|
+
};
|
|
1661
|
+
let updatedAnomaly= await updateOneBinaryAuditModel( anomalyQury, anomalyRecord );
|
|
1662
|
+
if ( updatedAnomaly==0 ) {
|
|
1663
|
+
return res.sendError( 'Update failed, it may be invalid request', 400 );
|
|
1664
|
+
}
|
|
1665
|
+
let anomalyFilter= [
|
|
1666
|
+
{
|
|
1667
|
+
'term': {
|
|
1668
|
+
'storeId.keyword': inputData.storeId,
|
|
1669
|
+
},
|
|
1670
|
+
},
|
|
1671
|
+
{
|
|
1672
|
+
'term': {
|
|
1673
|
+
'fileDate.keyword': inputData.fileDate,
|
|
1674
|
+
},
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
'term': {
|
|
1678
|
+
'moduleType.keyword': inputData.moduleType,
|
|
1679
|
+
},
|
|
1680
|
+
},
|
|
1681
|
+
{
|
|
1682
|
+
'term': {
|
|
1683
|
+
'moduleType.keyword': inputData.streamName,
|
|
1684
|
+
},
|
|
1685
|
+
},
|
|
1686
|
+
];
|
|
1687
|
+
let anomalySearchQuery={
|
|
1688
|
+
'size': 1,
|
|
1689
|
+
'query': {
|
|
1690
|
+
'bool': {
|
|
1691
|
+
'must': anomalyFilter,
|
|
1692
|
+
},
|
|
1693
|
+
},
|
|
1694
|
+
};
|
|
1695
|
+
const [ getStore2, getClient2 ] = await Promise.all( [ findOneStore( { storeId: inputData.storeId }, { storeName: 1, storeProfile: 1, spocDetails: 1 } ), findOneClient( { clientId: req.userAudit?.clientId }, { clientName: 1 } ) ] );
|
|
1696
|
+
const getData = await findOneTraxAuditData(
|
|
1697
|
+
{
|
|
1698
|
+
fileDate: inputData.fileDate,
|
|
1699
|
+
storeId: inputData.storeId,
|
|
1700
|
+
moduleType: inputData.moduleType,
|
|
1701
|
+
streamName: req.userAudit?.streamName,
|
|
1702
|
+
},
|
|
1703
|
+
);
|
|
1704
|
+
const anomalyOutput = {
|
|
1705
|
+
clientId: req.userAudit?.clientId,
|
|
1706
|
+
clientName: getClient2?.clientName,
|
|
1707
|
+
storeId: inputData.storeId,
|
|
1708
|
+
storeName: getStore2?.storeName,
|
|
1709
|
+
question: getData?.sqs?.Body?.question,
|
|
1710
|
+
spocName: getStore2?.spocDetails? getStore2?.spocDetails[0]?.name : '',
|
|
1711
|
+
spocEmail: getStore2?.spocDetails? getStore2?.spocDetails[0]?.email:'',
|
|
1712
|
+
spocContact: getStore2?.spocDetails? getStore2?.spocDetails[0].contact:'',
|
|
1713
|
+
address: getStore2?.storeProfile?.address,
|
|
1714
|
+
fileDate: inputData.fileDate,
|
|
1715
|
+
moduleType: inputData.moduleType,
|
|
1716
|
+
Answer: inputData.answer,
|
|
1717
|
+
configTime: getData?.sqs?.Body?.configTime,
|
|
1718
|
+
inputBucketName: getData?.sqs?.Body?.inputBucketName,
|
|
1719
|
+
incidentType: getData?.sqs?.Body?.incidentType,
|
|
1720
|
+
incidentId: getData?.sqs?.Body?.incidentId,
|
|
1721
|
+
incidentTime: getData?.sqs?.Body?.incidentTime,
|
|
1722
|
+
thumnailImage: getData?.sqs?.Body?.thumnailImage,
|
|
1723
|
+
folderPath: getData?.sqs?.Body?.fileDetails[0]?.outputFilePath,
|
|
1724
|
+
createdAt: new Date(),
|
|
1725
|
+
};
|
|
1726
|
+
const anomalySearchData= await getOpenSearchData( openSearch.traxDetectionOutput, anomalySearchQuery );
|
|
1727
|
+
logger.info( { length: anomalySearchData?.body?.hits?.hits?.length, _id: anomalySearchData?.body?.hits?.hits[0]?._id, output: anomalyOutput } );
|
|
1728
|
+
if ( anomalySearchData?.body?.hits?.hits?.length >0 ) {
|
|
1729
|
+
await updateOpenSearchData( openSearch.traxDetectionOutput, anomalySearchData?.body?.hits?.hits[0]?._id, { doc: anomalyOutput } );
|
|
1730
|
+
} else {
|
|
1731
|
+
await insertOpenSearchData( openSearch.traxDetectionOutput, anomalyOutput );
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
const logData4 = {
|
|
1735
|
+
userId: req.user._id,
|
|
1736
|
+
userName: req.user.userName,
|
|
1737
|
+
logType: 'traxAudit',
|
|
1738
|
+
logSubType: 'auditDone',
|
|
1739
|
+
logData: {
|
|
1740
|
+
fileDate: req.userAudit?.fileDate,
|
|
1741
|
+
auditType: req.userAudit?.auditType,
|
|
1742
|
+
storeId: req.userAudit?.storeId,
|
|
1743
|
+
moduleType: req.userAudit?.moduleType,
|
|
1744
|
+
queueName: req.userAudit?.queueName,
|
|
1745
|
+
clientId: req.userAudit?.clientId,
|
|
1746
|
+
startTime: req.userAudit?.startTime,
|
|
1747
|
+
streamName: req.userAudit?.streamName,
|
|
1748
|
+
tempId: req.userAudit?.tempId,
|
|
1749
|
+
question: req.userAudit?.question,
|
|
1750
|
+
result: req.userAudit?.answer,
|
|
1751
|
+
endTime: Date.now(),
|
|
1752
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1753
|
+
auditId: new mongoose.Types.ObjectId( inputData.auditId ),
|
|
1754
|
+
},
|
|
1755
|
+
createdAt: Date.now(),
|
|
1756
|
+
};
|
|
1757
|
+
await insertOpenSearchData( openSearch.auditLog, logData4 );
|
|
1758
|
+
return res.sendSuccess( `Successfully updated in ${value}` );
|
|
1625
1759
|
|
|
1626
1760
|
default:
|
|
1627
1761
|
res.sendError( 'No Data', 204 );
|
|
@@ -1738,6 +1872,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1738
1872
|
},
|
|
1739
1873
|
];
|
|
1740
1874
|
break;
|
|
1875
|
+
case 'anomaly-audit':
|
|
1741
1876
|
case 'camera-angle-change':
|
|
1742
1877
|
traxAuditDataQuery= {
|
|
1743
1878
|
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
@@ -1925,9 +2060,6 @@ export async function userAuditHistory( req, res ) {
|
|
|
1925
2060
|
timezone: 'Asia/Kolkata',
|
|
1926
2061
|
},
|
|
1927
2062
|
},
|
|
1928
|
-
// timeSpent: { $round: [
|
|
1929
|
-
// { $divide: [ '$timeSpent', 60 ] }, 2,
|
|
1930
|
-
// ] },
|
|
1931
2063
|
timeSpent: {
|
|
1932
2064
|
|
|
1933
2065
|
$cond: [
|
|
@@ -2018,6 +2150,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
2018
2150
|
|
|
2019
2151
|
};
|
|
2020
2152
|
switch ( inputData.moduleType ) {
|
|
2153
|
+
case 'anomaly-audit':
|
|
2021
2154
|
case 'camera-angle-change':
|
|
2022
2155
|
temp['stream Name'] = element.streamName;
|
|
2023
2156
|
temp['Result'] = element.answer;
|
|
@@ -2450,6 +2583,124 @@ export async function storeMetrics( req, res ) {
|
|
|
2450
2583
|
if ( inputData.filterByAuditType && inputData.filterByAuditType?.length > 0 ) {
|
|
2451
2584
|
filter.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
2452
2585
|
}
|
|
2586
|
+
let traxAuditDataQuery ={};
|
|
2587
|
+
let traxAuditDataFilter = [];
|
|
2588
|
+
switch ( inputData.moduleType ) {
|
|
2589
|
+
case 'unattended-customer':
|
|
2590
|
+
traxAuditDataQuery= {
|
|
2591
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
2592
|
+
};
|
|
2593
|
+
traxAuditDataFilter=[ {
|
|
2594
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2595
|
+
},
|
|
2596
|
+
{
|
|
2597
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2598
|
+
},
|
|
2599
|
+
{
|
|
2600
|
+
$eq: [ '$tempId', '$$tempId' ],
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2604
|
+
},
|
|
2605
|
+
];
|
|
2606
|
+
break;
|
|
2607
|
+
case 'left-in-middle':
|
|
2608
|
+
traxAuditDataQuery= {
|
|
2609
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
2610
|
+
};
|
|
2611
|
+
traxAuditDataFilter=[ {
|
|
2612
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2613
|
+
},
|
|
2614
|
+
{
|
|
2615
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2616
|
+
},
|
|
2617
|
+
{
|
|
2618
|
+
$eq: [ '$question', '$$question' ],
|
|
2619
|
+
},
|
|
2620
|
+
{
|
|
2621
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2622
|
+
},
|
|
2623
|
+
];
|
|
2624
|
+
break;
|
|
2625
|
+
case 'uniform-detection':
|
|
2626
|
+
case 'mobile-detection':
|
|
2627
|
+
case 'scrum':
|
|
2628
|
+
case 'cleaning':
|
|
2629
|
+
traxAuditDataQuery= {
|
|
2630
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType',
|
|
2631
|
+
};
|
|
2632
|
+
traxAuditDataFilter=[ {
|
|
2633
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2637
|
+
},
|
|
2638
|
+
{
|
|
2639
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2640
|
+
},
|
|
2641
|
+
];
|
|
2642
|
+
break;
|
|
2643
|
+
case 'anomaly-audit':
|
|
2644
|
+
case 'camera-angle-change':
|
|
2645
|
+
traxAuditDataQuery= {
|
|
2646
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
2647
|
+
};
|
|
2648
|
+
traxAuditDataFilter=[ {
|
|
2649
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2650
|
+
},
|
|
2651
|
+
{
|
|
2652
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2653
|
+
},
|
|
2654
|
+
{
|
|
2655
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
2656
|
+
},
|
|
2657
|
+
{
|
|
2658
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2659
|
+
},
|
|
2660
|
+
];
|
|
2661
|
+
break;
|
|
2662
|
+
case 'hygiene':
|
|
2663
|
+
traxAuditDataQuery= {
|
|
2664
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', zoneName: '$zoneName',
|
|
2665
|
+
};
|
|
2666
|
+
traxAuditDataFilter=[ {
|
|
2667
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2668
|
+
},
|
|
2669
|
+
{
|
|
2670
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2671
|
+
},
|
|
2672
|
+
{
|
|
2673
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
2674
|
+
},
|
|
2675
|
+
{
|
|
2676
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2677
|
+
},
|
|
2678
|
+
];
|
|
2679
|
+
break;
|
|
2680
|
+
case 'eye-test-camera':
|
|
2681
|
+
traxAuditDataQuery= {
|
|
2682
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', question: '$question', streamName: '$streamName',
|
|
2683
|
+
};
|
|
2684
|
+
traxAuditDataFilter=[ {
|
|
2685
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2686
|
+
},
|
|
2687
|
+
{
|
|
2688
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2689
|
+
},
|
|
2690
|
+
{
|
|
2691
|
+
$eq: [ '$question', '$$question' ],
|
|
2692
|
+
},
|
|
2693
|
+
{
|
|
2694
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
2695
|
+
},
|
|
2696
|
+
{
|
|
2697
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2698
|
+
},
|
|
2699
|
+
];
|
|
2700
|
+
break;
|
|
2701
|
+
default:
|
|
2702
|
+
return res.sendError( 'Please give valid modueType', 400 );
|
|
2703
|
+
}
|
|
2453
2704
|
|
|
2454
2705
|
|
|
2455
2706
|
const query = [
|
|
@@ -2489,24 +2740,12 @@ export async function storeMetrics( req, res ) {
|
|
|
2489
2740
|
{
|
|
2490
2741
|
$lookup: {
|
|
2491
2742
|
from: 'traxAuditData',
|
|
2492
|
-
let:
|
|
2493
|
-
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
2494
|
-
},
|
|
2743
|
+
let: traxAuditDataQuery,
|
|
2495
2744
|
pipeline: [
|
|
2496
2745
|
{
|
|
2497
2746
|
$match: {
|
|
2498
2747
|
$expr: {
|
|
2499
|
-
$and:
|
|
2500
|
-
{
|
|
2501
|
-
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2502
|
-
},
|
|
2503
|
-
{
|
|
2504
|
-
$eq: [ '$storeId', '$$storeId' ],
|
|
2505
|
-
},
|
|
2506
|
-
{
|
|
2507
|
-
$eq: [ '$zoneName', '$$zoneName' ],
|
|
2508
|
-
},
|
|
2509
|
-
],
|
|
2748
|
+
$and: traxAuditDataFilter,
|
|
2510
2749
|
},
|
|
2511
2750
|
},
|
|
2512
2751
|
},
|
|
@@ -2958,6 +3197,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2958
3197
|
};
|
|
2959
3198
|
switch ( inputData.moduleType ) {
|
|
2960
3199
|
case 'camera-angle-change':
|
|
3200
|
+
case 'anomaly-audit':
|
|
2961
3201
|
temp['stream Name'] = element.streamName;
|
|
2962
3202
|
temp['User Comments'] = element.userComments;
|
|
2963
3203
|
temp['Status'] = toCamelCase( element.auditStatus );
|
|
@@ -3354,7 +3594,125 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3354
3594
|
if ( inputData.filterByStatus.length > 0 ) {
|
|
3355
3595
|
filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
3356
3596
|
}
|
|
3357
|
-
|
|
3597
|
+
|
|
3598
|
+
let traxAuditDataQuery={};
|
|
3599
|
+
let traxAuditDataFilter = [];
|
|
3600
|
+
switch ( inputData.moduleType ) {
|
|
3601
|
+
case 'unattended-customer':
|
|
3602
|
+
traxAuditDataQuery= {
|
|
3603
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
3604
|
+
};
|
|
3605
|
+
traxAuditDataFilter=[ {
|
|
3606
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3607
|
+
},
|
|
3608
|
+
{
|
|
3609
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3610
|
+
},
|
|
3611
|
+
{
|
|
3612
|
+
$eq: [ '$tempId', '$$tempId' ],
|
|
3613
|
+
},
|
|
3614
|
+
{
|
|
3615
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3616
|
+
},
|
|
3617
|
+
];
|
|
3618
|
+
break;
|
|
3619
|
+
case 'left-in-middle':
|
|
3620
|
+
traxAuditDataQuery= {
|
|
3621
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
3622
|
+
};
|
|
3623
|
+
traxAuditDataFilter=[ {
|
|
3624
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3625
|
+
},
|
|
3626
|
+
{
|
|
3627
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3628
|
+
},
|
|
3629
|
+
{
|
|
3630
|
+
$eq: [ '$question', '$$question' ],
|
|
3631
|
+
},
|
|
3632
|
+
{
|
|
3633
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3634
|
+
},
|
|
3635
|
+
];
|
|
3636
|
+
break;
|
|
3637
|
+
case 'uniform-detection':
|
|
3638
|
+
case 'mobile-detection':
|
|
3639
|
+
case 'scrum':
|
|
3640
|
+
case 'cleaning':
|
|
3641
|
+
traxAuditDataQuery= {
|
|
3642
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType',
|
|
3643
|
+
};
|
|
3644
|
+
traxAuditDataFilter=[ {
|
|
3645
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3646
|
+
},
|
|
3647
|
+
{
|
|
3648
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3649
|
+
},
|
|
3650
|
+
{
|
|
3651
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3652
|
+
},
|
|
3653
|
+
];
|
|
3654
|
+
break;
|
|
3655
|
+
case 'anomaly-audit':
|
|
3656
|
+
case 'camera-angle-change':
|
|
3657
|
+
traxAuditDataQuery= {
|
|
3658
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
3659
|
+
};
|
|
3660
|
+
traxAuditDataFilter=[ {
|
|
3661
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3662
|
+
},
|
|
3663
|
+
{
|
|
3664
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3665
|
+
},
|
|
3666
|
+
{
|
|
3667
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
3668
|
+
},
|
|
3669
|
+
{
|
|
3670
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3671
|
+
},
|
|
3672
|
+
];
|
|
3673
|
+
break;
|
|
3674
|
+
case 'hygiene':
|
|
3675
|
+
traxAuditDataQuery= {
|
|
3676
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', zoneName: '$zoneName',
|
|
3677
|
+
};
|
|
3678
|
+
traxAuditDataFilter=[ {
|
|
3679
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3680
|
+
},
|
|
3681
|
+
{
|
|
3682
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3683
|
+
},
|
|
3684
|
+
{
|
|
3685
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3689
|
+
},
|
|
3690
|
+
];
|
|
3691
|
+
break;
|
|
3692
|
+
case 'eye-test-camera':
|
|
3693
|
+
traxAuditDataQuery= {
|
|
3694
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', question: '$question', streamName: '$streamName',
|
|
3695
|
+
};
|
|
3696
|
+
traxAuditDataFilter=[ {
|
|
3697
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3698
|
+
},
|
|
3699
|
+
{
|
|
3700
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3701
|
+
},
|
|
3702
|
+
{
|
|
3703
|
+
$eq: [ '$question', '$$question' ],
|
|
3704
|
+
},
|
|
3705
|
+
{
|
|
3706
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
3707
|
+
},
|
|
3708
|
+
{
|
|
3709
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3710
|
+
},
|
|
3711
|
+
];
|
|
3712
|
+
break;
|
|
3713
|
+
default:
|
|
3714
|
+
return res.sendError( 'Please give valid modueType', 400 );
|
|
3715
|
+
} const query =[
|
|
3358
3716
|
{
|
|
3359
3717
|
$match: {
|
|
3360
3718
|
$and: filters,
|
|
@@ -3364,24 +3722,12 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3364
3722
|
{
|
|
3365
3723
|
$lookup: {
|
|
3366
3724
|
from: 'traxAuditData',
|
|
3367
|
-
let:
|
|
3368
|
-
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
3369
|
-
},
|
|
3725
|
+
let: traxAuditDataQuery,
|
|
3370
3726
|
pipeline: [
|
|
3371
3727
|
{
|
|
3372
3728
|
$match: {
|
|
3373
3729
|
$expr: {
|
|
3374
|
-
$and:
|
|
3375
|
-
{
|
|
3376
|
-
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3377
|
-
},
|
|
3378
|
-
{
|
|
3379
|
-
$eq: [ '$storeId', '$$storeId' ],
|
|
3380
|
-
},
|
|
3381
|
-
{
|
|
3382
|
-
$eq: [ '$zoneName', '$$zoneName' ],
|
|
3383
|
-
},
|
|
3384
|
-
],
|
|
3730
|
+
$and: traxAuditDataFilter,
|
|
3385
3731
|
},
|
|
3386
3732
|
},
|
|
3387
3733
|
},
|
|
@@ -3492,7 +3838,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3492
3838
|
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3493
3839
|
{ userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3494
3840
|
{ value: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3495
|
-
{ question: { $regex: inputData.
|
|
3841
|
+
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3496
3842
|
],
|
|
3497
3843
|
|
|
3498
3844
|
},
|
|
@@ -3537,6 +3883,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3537
3883
|
'Status': toCamelCase( element.auditStatus ),
|
|
3538
3884
|
};
|
|
3539
3885
|
switch ( inputData.moduleType ) {
|
|
3886
|
+
case 'anomaly-audit':
|
|
3540
3887
|
case 'camera-angle-change':
|
|
3541
3888
|
temp['stream Name'] = element.streamName;
|
|
3542
3889
|
break;
|
|
@@ -4006,6 +4353,7 @@ export async function overviewTable( req, res ) {
|
|
|
4006
4353
|
},
|
|
4007
4354
|
];
|
|
4008
4355
|
break;
|
|
4356
|
+
case 'anomaly-audit':
|
|
4009
4357
|
case 'camera-angle-change':
|
|
4010
4358
|
traxAuditDataQuery= {
|
|
4011
4359
|
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
@@ -4063,6 +4411,7 @@ export async function overviewTable( req, res ) {
|
|
|
4063
4411
|
},
|
|
4064
4412
|
];
|
|
4065
4413
|
break;
|
|
4414
|
+
|
|
4066
4415
|
default:
|
|
4067
4416
|
return res.sendError( 'Please give valid modueType', 400 );
|
|
4068
4417
|
}
|
|
@@ -4203,6 +4552,7 @@ export async function overviewTable( req, res ) {
|
|
|
4203
4552
|
};
|
|
4204
4553
|
|
|
4205
4554
|
switch ( inputData.moduleType ) {
|
|
4555
|
+
case 'anomaly-audit':
|
|
4206
4556
|
case 'camera-angle-change':
|
|
4207
4557
|
temp['stream Name'] = element.streamName;
|
|
4208
4558
|
temp['User Comments'] = element.userComments;
|
|
@@ -4544,12 +4894,12 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4544
4894
|
const mapimg = {
|
|
4545
4895
|
img_path: data,
|
|
4546
4896
|
img_name: time,
|
|
4547
|
-
img_id: `${item?.file_path}
|
|
4897
|
+
img_id: `${item?.file_path}__${time}`,
|
|
4548
4898
|
};
|
|
4549
4899
|
files.push( {
|
|
4550
4900
|
img_path: data,
|
|
4551
4901
|
img_name: time,
|
|
4552
|
-
img_id: `${item?.file_path}
|
|
4902
|
+
img_id: `${item?.file_path}__${time}`,
|
|
4553
4903
|
selected: false,
|
|
4554
4904
|
dropped: false,
|
|
4555
4905
|
singleDetection: false,
|
|
@@ -4794,6 +5144,7 @@ export async function getDraftedData( req, res ) {
|
|
|
4794
5144
|
export async function save( req, res ) {
|
|
4795
5145
|
try {
|
|
4796
5146
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
5147
|
+
const bucket = JSON.parse( process.env.BUCKET );
|
|
4797
5148
|
const sqs = JSON.parse( process.env.SQS );
|
|
4798
5149
|
const inputData = req.body;
|
|
4799
5150
|
const isoDate = req.userAudit?.startTime;
|
|
@@ -4823,12 +5174,7 @@ export async function save( req, res ) {
|
|
|
4823
5174
|
|
|
4824
5175
|
logger.info( { userUpdate: userUpdate, storeUpdate: storeUpdate, function: 'saveUpdate' } );
|
|
4825
5176
|
const getFilePath = await findOneTraxAuditData(
|
|
4826
|
-
|
|
4827
|
-
fileDate: inputData.fileDate,
|
|
4828
|
-
storeId: inputData.storeId,
|
|
4829
|
-
zoneName: inputData.zoneName,
|
|
4830
|
-
moduleType: inputData.moduleType,
|
|
4831
|
-
},
|
|
5177
|
+
query,
|
|
4832
5178
|
);
|
|
4833
5179
|
if ( !getFilePath ) {
|
|
4834
5180
|
return res.sendError( 'SQS is not sent due to Inserted Data is not there', 400 );
|
|
@@ -4870,7 +5216,7 @@ export async function save( req, res ) {
|
|
|
4870
5216
|
}
|
|
4871
5217
|
}
|
|
4872
5218
|
|
|
4873
|
-
const outputFilePath = tempId[0]?.split( '
|
|
5219
|
+
const outputFilePath = tempId[0]?.split( '__' );
|
|
4874
5220
|
// trax output in open serach
|
|
4875
5221
|
const folderPath = getFilePath?.sqs?.Body?.folderPath;
|
|
4876
5222
|
const output = {
|
|
@@ -4889,9 +5235,9 @@ export async function save( req, res ) {
|
|
|
4889
5235
|
inputBucketName: getFilePath?.sqs?.Body?.inputBucketName,
|
|
4890
5236
|
tempId: tempId,
|
|
4891
5237
|
count: inputData.employeeCount,
|
|
4892
|
-
time: [ 'open-time', 'close-time' ].includes( inputData?.moduleType )?outputFilePath[1]:'',
|
|
5238
|
+
time: [ 'open-time', 'close-time' ].includes( inputData?.moduleType )?outputFilePath?outputFilePath[1]:'':'',
|
|
4893
5239
|
bufferTime: [ 'open-time', 'close-time' ].includes( inputData?.moduleType )? getFilePath?.sqs?.Body?.bufferTime : '',
|
|
4894
|
-
folderPath: [ 'open-time', 'close-time' ].includes( inputData?.moduleType )? outputFilePath[0]: folderPath.split( '/' ).slice( 0, -1 ).join( '/' ) + '/',
|
|
5240
|
+
folderPath: [ 'open-time', 'close-time' ].includes( inputData?.moduleType )?outputFilePath? outputFilePath[0]:'': folderPath.split( '/' ).slice( 0, -1 ).join( '/' ) + '/',
|
|
4895
5241
|
createdAt: new Date(),
|
|
4896
5242
|
};
|
|
4897
5243
|
let filter= [
|
|
@@ -4931,6 +5277,17 @@ export async function save( req, res ) {
|
|
|
4931
5277
|
await insertOpenSearchData( openSearch.traxDetectionOutput, output );
|
|
4932
5278
|
}
|
|
4933
5279
|
|
|
5280
|
+
if ( [ 'open-time', 'close-time' ].includes( inputData.moduleType ) && outputFilePath ) {
|
|
5281
|
+
const temp = inputData.moduleType.split( '-' );
|
|
5282
|
+
const copyParams = {
|
|
5283
|
+
Bucket: bucket.outputSnap,
|
|
5284
|
+
CopySource: `/${getFilePath?.sqs?.Body?.inputBucketName}/${outputFilePath[0]}`,
|
|
5285
|
+
Key: `${inputData.storeId}/${ inputData.fileDate}/operation_snaps/${temp[0]}.jpeg`,
|
|
5286
|
+
};
|
|
5287
|
+
|
|
5288
|
+
await copyImage( copyParams );
|
|
5289
|
+
}
|
|
5290
|
+
|
|
4934
5291
|
const logData = {
|
|
4935
5292
|
userId: req.user._id,
|
|
4936
5293
|
userName: req.user.userName,
|
|
@@ -4954,6 +5311,7 @@ export async function save( req, res ) {
|
|
|
4954
5311
|
},
|
|
4955
5312
|
createdAt: Date.now(),
|
|
4956
5313
|
};
|
|
5314
|
+
|
|
4957
5315
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
4958
5316
|
return res.sendSuccess( { result: 'Updated Successfully' } );
|
|
4959
5317
|
} else {
|
|
@@ -4995,8 +5353,8 @@ export async function reTrigger( req, res ) {
|
|
|
4995
5353
|
default:
|
|
4996
5354
|
return res.sendError( 'Please give valid module type' );
|
|
4997
5355
|
}
|
|
4998
|
-
if ( !getQueueName ||
|
|
4999
|
-
return res.sendError(
|
|
5356
|
+
if ( !getQueueName || [ null, '', undefined ].includes( queueName ) ) {
|
|
5357
|
+
return res.sendError( `The queueName ${queueName} does not create`, 400 );
|
|
5000
5358
|
}
|
|
5001
5359
|
let getQuery ={
|
|
5002
5360
|
storeId: message.storeId,
|