tango-app-api-audit 3.4.58 → 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 );
|
|
@@ -1722,6 +1856,8 @@ export async function userAuditHistory( req, res ) {
|
|
|
1722
1856
|
case 'mobile-detection':
|
|
1723
1857
|
case 'scrum':
|
|
1724
1858
|
case 'cleaning':
|
|
1859
|
+
case 'open-time':
|
|
1860
|
+
case 'close-time':
|
|
1725
1861
|
traxAuditDataQuery= {
|
|
1726
1862
|
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType',
|
|
1727
1863
|
};
|
|
@@ -1736,6 +1872,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1736
1872
|
},
|
|
1737
1873
|
];
|
|
1738
1874
|
break;
|
|
1875
|
+
case 'anomaly-audit':
|
|
1739
1876
|
case 'camera-angle-change':
|
|
1740
1877
|
traxAuditDataQuery= {
|
|
1741
1878
|
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
@@ -1923,9 +2060,6 @@ export async function userAuditHistory( req, res ) {
|
|
|
1923
2060
|
timezone: 'Asia/Kolkata',
|
|
1924
2061
|
},
|
|
1925
2062
|
},
|
|
1926
|
-
// timeSpent: { $round: [
|
|
1927
|
-
// { $divide: [ '$timeSpent', 60 ] }, 2,
|
|
1928
|
-
// ] },
|
|
1929
2063
|
timeSpent: {
|
|
1930
2064
|
|
|
1931
2065
|
$cond: [
|
|
@@ -1988,7 +2122,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1988
2122
|
},
|
|
1989
2123
|
);
|
|
1990
2124
|
}
|
|
1991
|
-
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2125
|
+
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1992
2126
|
if ( count.length == 0 ) {
|
|
1993
2127
|
return res.sendError( 'No Data Found', 204 );
|
|
1994
2128
|
}
|
|
@@ -2016,6 +2150,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
2016
2150
|
|
|
2017
2151
|
};
|
|
2018
2152
|
switch ( inputData.moduleType ) {
|
|
2153
|
+
case 'anomaly-audit':
|
|
2019
2154
|
case 'camera-angle-change':
|
|
2020
2155
|
temp['stream Name'] = element.streamName;
|
|
2021
2156
|
temp['Result'] = element.answer;
|
|
@@ -2040,6 +2175,8 @@ export async function userAuditHistory( req, res ) {
|
|
|
2040
2175
|
temp['Accuracy'] = element.accuracy || '';
|
|
2041
2176
|
break;
|
|
2042
2177
|
case 'mobile-detection':
|
|
2178
|
+
case 'open-time':
|
|
2179
|
+
case 'close-time':
|
|
2043
2180
|
temp['Before Count'] = element.beforeCount;
|
|
2044
2181
|
temp['After Count'] = element.afterCount;
|
|
2045
2182
|
temp['Accuracy'] = element.accuracy || '';
|
|
@@ -2069,7 +2206,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
2069
2206
|
}
|
|
2070
2207
|
|
|
2071
2208
|
|
|
2072
|
-
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2209
|
+
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2073
2210
|
|
|
2074
2211
|
return res.sendSuccess( { result: result, count: count.length } );
|
|
2075
2212
|
} catch ( error ) {
|
|
@@ -2104,7 +2241,7 @@ export async function clientMetrics( req, res ) {
|
|
|
2104
2241
|
);
|
|
2105
2242
|
}
|
|
2106
2243
|
let query = [];
|
|
2107
|
-
if ( [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType ) ) {
|
|
2244
|
+
if ( [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType ) ) {
|
|
2108
2245
|
query =[
|
|
2109
2246
|
{
|
|
2110
2247
|
$match: {
|
|
@@ -2440,12 +2577,130 @@ export async function storeMetrics( req, res ) {
|
|
|
2440
2577
|
}
|
|
2441
2578
|
|
|
2442
2579
|
if ( inputData.filterByStatus && inputData.filterByStatus?.length > 0 ) {
|
|
2443
|
-
[ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )? filter.push( { status: { $in: inputData.filterByStatus } } ) : filter.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
2580
|
+
[ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )? filter.push( { status: { $in: inputData.filterByStatus } } ) : filter.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
2444
2581
|
}
|
|
2445
2582
|
|
|
2446
2583
|
if ( inputData.filterByAuditType && inputData.filterByAuditType?.length > 0 ) {
|
|
2447
2584
|
filter.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
2448
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
|
+
}
|
|
2449
2704
|
|
|
2450
2705
|
|
|
2451
2706
|
const query = [
|
|
@@ -2485,24 +2740,12 @@ export async function storeMetrics( req, res ) {
|
|
|
2485
2740
|
{
|
|
2486
2741
|
$lookup: {
|
|
2487
2742
|
from: 'traxAuditData',
|
|
2488
|
-
let:
|
|
2489
|
-
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
2490
|
-
},
|
|
2743
|
+
let: traxAuditDataQuery,
|
|
2491
2744
|
pipeline: [
|
|
2492
2745
|
{
|
|
2493
2746
|
$match: {
|
|
2494
2747
|
$expr: {
|
|
2495
|
-
$and:
|
|
2496
|
-
{
|
|
2497
|
-
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2498
|
-
},
|
|
2499
|
-
{
|
|
2500
|
-
$eq: [ '$storeId', '$$storeId' ],
|
|
2501
|
-
},
|
|
2502
|
-
{
|
|
2503
|
-
$eq: [ '$zoneName', '$$zoneName' ],
|
|
2504
|
-
},
|
|
2505
|
-
],
|
|
2748
|
+
$and: traxAuditDataFilter,
|
|
2506
2749
|
},
|
|
2507
2750
|
},
|
|
2508
2751
|
},
|
|
@@ -2911,7 +3154,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2911
3154
|
},
|
|
2912
3155
|
);
|
|
2913
3156
|
}
|
|
2914
|
-
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
3157
|
+
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
2915
3158
|
|
|
2916
3159
|
|
|
2917
3160
|
if ( count.length == 0 ) {
|
|
@@ -2935,7 +3178,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2935
3178
|
$limit: limit,
|
|
2936
3179
|
} );
|
|
2937
3180
|
}
|
|
2938
|
-
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
3181
|
+
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
2939
3182
|
if ( result.length == 0 ) {
|
|
2940
3183
|
return res.sendError( 'No data Found', 204 );
|
|
2941
3184
|
}
|
|
@@ -2954,6 +3197,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2954
3197
|
};
|
|
2955
3198
|
switch ( inputData.moduleType ) {
|
|
2956
3199
|
case 'camera-angle-change':
|
|
3200
|
+
case 'anomaly-audit':
|
|
2957
3201
|
temp['stream Name'] = element.streamName;
|
|
2958
3202
|
temp['User Comments'] = element.userComments;
|
|
2959
3203
|
temp['Status'] = toCamelCase( element.auditStatus );
|
|
@@ -2981,6 +3225,8 @@ export async function storeMetrics( req, res ) {
|
|
|
2981
3225
|
temp['Accuracy'] = element.accuracy;
|
|
2982
3226
|
break;
|
|
2983
3227
|
case 'uniform-detection':
|
|
3228
|
+
case 'open-time':
|
|
3229
|
+
case 'close-time':
|
|
2984
3230
|
temp['Before Count'] = element.beforeCount;
|
|
2985
3231
|
temp['After Count'] = element.afterCount;
|
|
2986
3232
|
temp['Status'] = toCamelCase( element.status );
|
|
@@ -3261,7 +3507,7 @@ export async function userMetrics( req, res ) {
|
|
|
3261
3507
|
);
|
|
3262
3508
|
}
|
|
3263
3509
|
|
|
3264
|
-
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3510
|
+
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3265
3511
|
if ( count.length == 0 ) {
|
|
3266
3512
|
return res.sendError( 'No Data Found', 204 );
|
|
3267
3513
|
}
|
|
@@ -3310,7 +3556,7 @@ export async function userMetrics( req, res ) {
|
|
|
3310
3556
|
}
|
|
3311
3557
|
|
|
3312
3558
|
|
|
3313
|
-
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3559
|
+
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3314
3560
|
if ( result.length == 0 ) {
|
|
3315
3561
|
return res.sendError( 'No Data Found', 204 );
|
|
3316
3562
|
}
|
|
@@ -3348,7 +3594,125 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3348
3594
|
if ( inputData.filterByStatus.length > 0 ) {
|
|
3349
3595
|
filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
3350
3596
|
}
|
|
3351
|
-
|
|
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 =[
|
|
3352
3716
|
{
|
|
3353
3717
|
$match: {
|
|
3354
3718
|
$and: filters,
|
|
@@ -3358,24 +3722,12 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3358
3722
|
{
|
|
3359
3723
|
$lookup: {
|
|
3360
3724
|
from: 'traxAuditData',
|
|
3361
|
-
let:
|
|
3362
|
-
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
3363
|
-
},
|
|
3725
|
+
let: traxAuditDataQuery,
|
|
3364
3726
|
pipeline: [
|
|
3365
3727
|
{
|
|
3366
3728
|
$match: {
|
|
3367
3729
|
$expr: {
|
|
3368
|
-
$and:
|
|
3369
|
-
{
|
|
3370
|
-
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3371
|
-
},
|
|
3372
|
-
{
|
|
3373
|
-
$eq: [ '$storeId', '$$storeId' ],
|
|
3374
|
-
},
|
|
3375
|
-
{
|
|
3376
|
-
$eq: [ '$zoneName', '$$zoneName' ],
|
|
3377
|
-
},
|
|
3378
|
-
],
|
|
3730
|
+
$and: traxAuditDataFilter,
|
|
3379
3731
|
},
|
|
3380
3732
|
},
|
|
3381
3733
|
},
|
|
@@ -3486,7 +3838,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3486
3838
|
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3487
3839
|
{ userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3488
3840
|
{ value: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3489
|
-
{ question: { $regex: inputData.
|
|
3841
|
+
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3490
3842
|
],
|
|
3491
3843
|
|
|
3492
3844
|
},
|
|
@@ -3500,7 +3852,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3500
3852
|
},
|
|
3501
3853
|
);
|
|
3502
3854
|
}
|
|
3503
|
-
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3855
|
+
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3504
3856
|
if ( count.length == 0 ) {
|
|
3505
3857
|
return res.sendError( 'No Data Found', 204 );
|
|
3506
3858
|
}
|
|
@@ -3516,7 +3868,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3516
3868
|
} );
|
|
3517
3869
|
}
|
|
3518
3870
|
|
|
3519
|
-
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3871
|
+
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3520
3872
|
if ( inputData.isExport ) {
|
|
3521
3873
|
const exportdata = [];
|
|
3522
3874
|
result.forEach( ( element ) => {
|
|
@@ -3531,6 +3883,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3531
3883
|
'Status': toCamelCase( element.auditStatus ),
|
|
3532
3884
|
};
|
|
3533
3885
|
switch ( inputData.moduleType ) {
|
|
3886
|
+
case 'anomaly-audit':
|
|
3534
3887
|
case 'camera-angle-change':
|
|
3535
3888
|
temp['stream Name'] = element.streamName;
|
|
3536
3889
|
break;
|
|
@@ -3546,6 +3899,8 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3546
3899
|
case 'mobile-detection':
|
|
3547
3900
|
temp['Before Count'] = element.beforeCount;
|
|
3548
3901
|
break;
|
|
3902
|
+
case 'open-time':
|
|
3903
|
+
case 'close-time':
|
|
3549
3904
|
case 'uniform-detection':
|
|
3550
3905
|
temp['Before Count'] = element.beforeCount;
|
|
3551
3906
|
break;
|
|
@@ -3716,7 +4071,7 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
3716
4071
|
},
|
|
3717
4072
|
];
|
|
3718
4073
|
|
|
3719
|
-
const storeAudit = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( storeAuditQuery ) : await aggregateBinaryAudit( binaryAuditQuery );
|
|
4074
|
+
const storeAudit = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( storeAuditQuery ) : await aggregateBinaryAudit( binaryAuditQuery );
|
|
3720
4075
|
if ( storeAudit.length > 0 ) {
|
|
3721
4076
|
temp.inprogressStores= storeAudit[0].inprogressStores;
|
|
3722
4077
|
temp.completedStores = storeAudit[0].completedStores;
|
|
@@ -3908,7 +4263,7 @@ export async function summarySplit( req, res ) {
|
|
|
3908
4263
|
},
|
|
3909
4264
|
];
|
|
3910
4265
|
|
|
3911
|
-
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryAuditQuery );
|
|
4266
|
+
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryAuditQuery );
|
|
3912
4267
|
result[0].totalCount = totalCount[0]?.total;
|
|
3913
4268
|
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
3914
4269
|
} catch ( error ) {
|
|
@@ -3937,7 +4292,7 @@ export async function overviewTable( req, res ) {
|
|
|
3937
4292
|
}
|
|
3938
4293
|
|
|
3939
4294
|
if ( inputData.filterByStatus.length > 0 ) {
|
|
3940
|
-
[ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )? filters.push( { status: { $in: inputData.filterByStatus } } ):filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
4295
|
+
[ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )? filters.push( { status: { $in: inputData.filterByStatus } } ):filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
3941
4296
|
}
|
|
3942
4297
|
let traxAuditDataQuery={};
|
|
3943
4298
|
let traxAuditDataFilter = [];
|
|
@@ -3982,6 +4337,8 @@ export async function overviewTable( req, res ) {
|
|
|
3982
4337
|
case 'mobile-detection':
|
|
3983
4338
|
case 'scrum':
|
|
3984
4339
|
case 'cleaning':
|
|
4340
|
+
case 'open-time':
|
|
4341
|
+
case 'close-time':
|
|
3985
4342
|
traxAuditDataQuery= {
|
|
3986
4343
|
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType',
|
|
3987
4344
|
};
|
|
@@ -3996,6 +4353,7 @@ export async function overviewTable( req, res ) {
|
|
|
3996
4353
|
},
|
|
3997
4354
|
];
|
|
3998
4355
|
break;
|
|
4356
|
+
case 'anomaly-audit':
|
|
3999
4357
|
case 'camera-angle-change':
|
|
4000
4358
|
traxAuditDataQuery= {
|
|
4001
4359
|
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
@@ -4053,6 +4411,7 @@ export async function overviewTable( req, res ) {
|
|
|
4053
4411
|
},
|
|
4054
4412
|
];
|
|
4055
4413
|
break;
|
|
4414
|
+
|
|
4056
4415
|
default:
|
|
4057
4416
|
return res.sendError( 'Please give valid modueType', 400 );
|
|
4058
4417
|
}
|
|
@@ -4167,7 +4526,7 @@ export async function overviewTable( req, res ) {
|
|
|
4167
4526
|
},
|
|
4168
4527
|
);
|
|
4169
4528
|
}
|
|
4170
|
-
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
4529
|
+
const count = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
4171
4530
|
if ( count.length == 0 ) {
|
|
4172
4531
|
return res.sendError( 'No Data Found', 204 );
|
|
4173
4532
|
}
|
|
@@ -4182,7 +4541,7 @@ export async function overviewTable( req, res ) {
|
|
|
4182
4541
|
$limit: limit,
|
|
4183
4542
|
} );
|
|
4184
4543
|
}
|
|
4185
|
-
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
4544
|
+
const result = [ 'mobile-detection', 'uniform-detection', 'hygiene', 'open-time', 'close-time' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
4186
4545
|
if ( inputData.isExport ) {
|
|
4187
4546
|
const exportdata = [];
|
|
4188
4547
|
result.forEach( ( element ) => {
|
|
@@ -4193,6 +4552,7 @@ export async function overviewTable( req, res ) {
|
|
|
4193
4552
|
};
|
|
4194
4553
|
|
|
4195
4554
|
switch ( inputData.moduleType ) {
|
|
4555
|
+
case 'anomaly-audit':
|
|
4196
4556
|
case 'camera-angle-change':
|
|
4197
4557
|
temp['stream Name'] = element.streamName;
|
|
4198
4558
|
temp['User Comments'] = element.userComments;
|
|
@@ -4220,6 +4580,8 @@ export async function overviewTable( req, res ) {
|
|
|
4220
4580
|
temp['Audit Type'] = element.auditType;
|
|
4221
4581
|
temp['Status'] = toCamelCase( element.status );
|
|
4222
4582
|
break;
|
|
4583
|
+
case 'open-time':
|
|
4584
|
+
case 'close-time':
|
|
4223
4585
|
case 'uniform-detection':
|
|
4224
4586
|
temp['Before Count'] = element.beforeCount;
|
|
4225
4587
|
temp['After Count'] = element.afterCount;
|
|
@@ -4532,12 +4894,12 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4532
4894
|
const mapimg = {
|
|
4533
4895
|
img_path: data,
|
|
4534
4896
|
img_name: time,
|
|
4535
|
-
img_id: `${item?.file_path}
|
|
4897
|
+
img_id: `${item?.file_path}__${time}`,
|
|
4536
4898
|
};
|
|
4537
4899
|
files.push( {
|
|
4538
4900
|
img_path: data,
|
|
4539
4901
|
img_name: time,
|
|
4540
|
-
img_id: `${item?.file_path}
|
|
4902
|
+
img_id: `${item?.file_path}__${time}`,
|
|
4541
4903
|
selected: false,
|
|
4542
4904
|
dropped: false,
|
|
4543
4905
|
singleDetection: false,
|
|
@@ -4782,6 +5144,7 @@ export async function getDraftedData( req, res ) {
|
|
|
4782
5144
|
export async function save( req, res ) {
|
|
4783
5145
|
try {
|
|
4784
5146
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
5147
|
+
const bucket = JSON.parse( process.env.BUCKET );
|
|
4785
5148
|
const sqs = JSON.parse( process.env.SQS );
|
|
4786
5149
|
const inputData = req.body;
|
|
4787
5150
|
const isoDate = req.userAudit?.startTime;
|
|
@@ -4811,12 +5174,7 @@ export async function save( req, res ) {
|
|
|
4811
5174
|
|
|
4812
5175
|
logger.info( { userUpdate: userUpdate, storeUpdate: storeUpdate, function: 'saveUpdate' } );
|
|
4813
5176
|
const getFilePath = await findOneTraxAuditData(
|
|
4814
|
-
|
|
4815
|
-
fileDate: inputData.fileDate,
|
|
4816
|
-
storeId: inputData.storeId,
|
|
4817
|
-
zoneName: inputData.zoneName,
|
|
4818
|
-
moduleType: inputData.moduleType,
|
|
4819
|
-
},
|
|
5177
|
+
query,
|
|
4820
5178
|
);
|
|
4821
5179
|
if ( !getFilePath ) {
|
|
4822
5180
|
return res.sendError( 'SQS is not sent due to Inserted Data is not there', 400 );
|
|
@@ -4858,7 +5216,7 @@ export async function save( req, res ) {
|
|
|
4858
5216
|
}
|
|
4859
5217
|
}
|
|
4860
5218
|
|
|
4861
|
-
const outputFilePath = tempId[0]?.split( '
|
|
5219
|
+
const outputFilePath = tempId[0]?.split( '__' );
|
|
4862
5220
|
// trax output in open serach
|
|
4863
5221
|
const folderPath = getFilePath?.sqs?.Body?.folderPath;
|
|
4864
5222
|
const output = {
|
|
@@ -4877,9 +5235,9 @@ export async function save( req, res ) {
|
|
|
4877
5235
|
inputBucketName: getFilePath?.sqs?.Body?.inputBucketName,
|
|
4878
5236
|
tempId: tempId,
|
|
4879
5237
|
count: inputData.employeeCount,
|
|
4880
|
-
time: [ 'open-time', 'close-time' ].includes( inputData?.moduleType )?outputFilePath[1]:'',
|
|
5238
|
+
time: [ 'open-time', 'close-time' ].includes( inputData?.moduleType )?outputFilePath?outputFilePath[1]:'':'',
|
|
4881
5239
|
bufferTime: [ 'open-time', 'close-time' ].includes( inputData?.moduleType )? getFilePath?.sqs?.Body?.bufferTime : '',
|
|
4882
|
-
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( '/' ) + '/',
|
|
4883
5241
|
createdAt: new Date(),
|
|
4884
5242
|
};
|
|
4885
5243
|
let filter= [
|
|
@@ -4919,6 +5277,17 @@ export async function save( req, res ) {
|
|
|
4919
5277
|
await insertOpenSearchData( openSearch.traxDetectionOutput, output );
|
|
4920
5278
|
}
|
|
4921
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
|
+
|
|
4922
5291
|
const logData = {
|
|
4923
5292
|
userId: req.user._id,
|
|
4924
5293
|
userName: req.user.userName,
|
|
@@ -4942,6 +5311,7 @@ export async function save( req, res ) {
|
|
|
4942
5311
|
},
|
|
4943
5312
|
createdAt: Date.now(),
|
|
4944
5313
|
};
|
|
5314
|
+
|
|
4945
5315
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
4946
5316
|
return res.sendSuccess( { result: 'Updated Successfully' } );
|
|
4947
5317
|
} else {
|
|
@@ -4983,8 +5353,8 @@ export async function reTrigger( req, res ) {
|
|
|
4983
5353
|
default:
|
|
4984
5354
|
return res.sendError( 'Please give valid module type' );
|
|
4985
5355
|
}
|
|
4986
|
-
if ( !getQueueName ||
|
|
4987
|
-
return res.sendError(
|
|
5356
|
+
if ( !getQueueName || [ null, '', undefined ].includes( queueName ) ) {
|
|
5357
|
+
return res.sendError( `The queueName ${queueName} does not create`, 400 );
|
|
4988
5358
|
}
|
|
4989
5359
|
let getQuery ={
|
|
4990
5360
|
storeId: message.storeId,
|