tango-app-api-trax 3.8.30 → 3.9.0-nike
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 +2 -2
- package/src/controllers/download.controller.js +19 -19
- package/src/controllers/gallery.controller.js +25 -71
- package/src/controllers/handlebar-helper.js +1 -0
- package/src/controllers/internalTrax.controller.js +16 -11
- package/src/controllers/mobileTrax.controller.js +15 -28
- package/src/controllers/teaxFlag.controller.js +5 -5
- package/src/controllers/trax.controller.js +6 -2
- package/src/hbs/flag.hbs +248 -248
- package/src/hbs/login-otp.hbs +943 -943
- package/src/hbs/recurringFlag.hbs +250 -250
- package/src/hbs/weeklyWrap.hbs +218 -218
- package/src/routes/mobileTrax.routes.js +1 -0
- package/src/utils/visitChecklistPdf.utils.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0-nike",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"nodemon": "^3.1.4",
|
|
30
30
|
"path": "^0.12.7",
|
|
31
31
|
"puppeteer": "^24.39.1",
|
|
32
|
-
"tango-api-schema": "^2.5.
|
|
32
|
+
"tango-api-schema": "^2.5.98",
|
|
33
33
|
"tango-app-api-middleware": "^3.5.2",
|
|
34
34
|
"url": "^0.11.4",
|
|
35
35
|
"winston": "^3.13.1",
|
|
@@ -53,31 +53,31 @@ async function getBrandInfo( clientId ) {
|
|
|
53
53
|
return brandInfo;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
async function streamChecklistZip( res, checklistList, brandInfo, zipBaseName ) {
|
|
57
|
-
|
|
56
|
+
// async function streamChecklistZip( res, checklistList, brandInfo, zipBaseName ) {
|
|
57
|
+
// const zipName = `${sanitizeFilenamePart( zipBaseName, 'visit-checklists' )}_${dayjs().format( 'YYYY-MM-DD_HH-mm' )}.zip`;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
// res.status( 200 );
|
|
60
|
+
// res.setHeader( 'Content-Type', 'application/zip' );
|
|
61
|
+
// res.setHeader( 'Content-Disposition', `attachment; filename="${zipName.replace( /"/g, '\\"' )}"` );
|
|
62
|
+
// res.setHeader( 'Cache-Control', 'private, no-cache' );
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
// const archive = archiver( 'zip', { zlib: { level: 9 } } );
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
// archive.on( 'error', ( err ) => {
|
|
67
|
+
// throw err;
|
|
68
|
+
// } );
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
// archive.pipe( res );
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
// for ( const checklistDetails of checklistList ) {
|
|
73
|
+
// const templateData = buildVisitChecklistTemplateData( checklistDetails, brandInfo );
|
|
74
|
+
// const pdfBuffer = await generateVisitChecklistPDF( templateData );
|
|
75
|
+
// const pdfName = `${sanitizeFilenamePart( checklistDetails.storeName || checklistDetails.store_id || checklistDetails._id, 'store' )}_${sanitizeFilenamePart( checklistDetails.checkListName || 'Visit Checklist' )}.pdf`;
|
|
76
|
+
// archive.append( Buffer.isBuffer( pdfBuffer ) ? pdfBuffer : Buffer.from( pdfBuffer ), { name: pdfName } );
|
|
77
|
+
// }
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
}
|
|
79
|
+
// await archive.finalize();
|
|
80
|
+
// }
|
|
81
81
|
|
|
82
82
|
async function createChecklistZipBuffer( checklistList, brandInfo ) {
|
|
83
83
|
const output = new PassThrough();
|
|
@@ -139,6 +139,7 @@ export async function getcustomerunattendedlist( req, res ) {
|
|
|
139
139
|
}
|
|
140
140
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
141
141
|
let resultData = await LamdaServiceCall( url.customerUnattended, req.body );
|
|
142
|
+
console.log( '🚀 ~ getcustomerunattendedlist ~ url.customerUnattended:', url.customerUnattended );
|
|
142
143
|
if ( resultData ) {
|
|
143
144
|
if ( resultData.status_code == '200' ) {
|
|
144
145
|
return res.sendSuccess( resultData );
|
|
@@ -451,83 +452,37 @@ export async function redoChecklist( req, res ) {
|
|
|
451
452
|
let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.payload.qno );
|
|
452
453
|
|
|
453
454
|
let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
let element = { ...question[sectionIndex].questions[eleIndex], redo: true, redoComment: '', linkquestionenabled: false };
|
|
464
|
-
question[sectionIndex].questions[eleIndex] = element;
|
|
465
|
-
question[sectionIndex].questions[eleIndex].userAnswer = [];
|
|
466
|
-
question[sectionIndex].questions[eleIndex].remarks = '';
|
|
467
|
-
} );
|
|
468
|
-
}
|
|
469
|
-
} );
|
|
470
|
-
// data.answers.forEach( ( item ) => {
|
|
471
|
-
// if ( item.showLinked ) {
|
|
472
|
-
// item.nestedQuestion = [];
|
|
473
|
-
// item.showLinked = false;
|
|
474
|
-
// item.linkedQuestion = 0;
|
|
475
|
-
// }
|
|
476
|
-
// } );
|
|
477
|
-
// }
|
|
478
|
-
}
|
|
479
|
-
let userAnswer = Array.isArray( data.userAnswer ) ? [ ...data.userAnswer ] : [];
|
|
480
|
-
|
|
481
|
-
question[sectionIndex].questions[findQuestion] = data;
|
|
482
|
-
if ( isSingleAnswerRedo ) {
|
|
483
|
-
let targetQuestion = question[sectionIndex].questions[findQuestion];
|
|
484
|
-
let targetUserAnswerIndex = targetQuestion.userAnswer?.findIndex( ( ele ) => ele.answer == req.body.payload.answerName );
|
|
485
|
-
let targetUserAnswer = targetQuestion.userAnswer[targetUserAnswerIndex];
|
|
486
|
-
if ( targetUserAnswer && Array.isArray( targetQuestion.answers ) ) {
|
|
487
|
-
let matchedAnsIdx = targetQuestion.answers.findIndex( ( ans ) => {
|
|
488
|
-
// if ( targetUserAnswer.no !== undefined && ans.index === targetUserAnswer.no ) return true;
|
|
489
|
-
// if ( targetUserAnswer.index !== undefined && ans.index === targetUserAnswer.index ) return true;
|
|
490
|
-
// if ( targetUserAnswer.answeroptionNumber !== undefined && ans.answeroptionNumber === targetUserAnswer.answeroptionNumber ) return true;
|
|
491
|
-
return ans.answer === targetUserAnswer.answer;
|
|
455
|
+
// if ( checklistDetails.client_id == '458' ) {
|
|
456
|
+
data.answers.forEach( ( item ) => {
|
|
457
|
+
if ( item.showLinked ) {
|
|
458
|
+
item.nestedQuestion.forEach( ( ele ) => {
|
|
459
|
+
let eleIndex = question[sectionIndex].questions.findIndex( ( qn ) => qn.qno == parseInt( ele ) );
|
|
460
|
+
let element = { ...question[sectionIndex].questions[eleIndex], redo: true, redoComment: '', linkquestionenabled: false };
|
|
461
|
+
question[sectionIndex].questions[eleIndex] = element;
|
|
462
|
+
question[sectionIndex].questions[eleIndex].userAnswer = [];
|
|
463
|
+
question[sectionIndex].questions[eleIndex].remarks = '';
|
|
492
464
|
} );
|
|
493
|
-
if ( matchedAnsIdx !== -1 ) {
|
|
494
|
-
targetQuestion.answers[matchedAnsIdx].redo = true;
|
|
495
|
-
targetQuestion.answers[matchedAnsIdx].validationAnswer = '';
|
|
496
|
-
targetQuestion.remarks = '';
|
|
497
|
-
}
|
|
498
|
-
targetQuestion.userAnswer.splice( targetUserAnswerIndex, 1 );
|
|
499
465
|
}
|
|
466
|
+
} );
|
|
467
|
+
// data.answers.forEach( ( item ) => {
|
|
468
|
+
// if ( item.showLinked ) {
|
|
469
|
+
// item.nestedQuestion = [];
|
|
470
|
+
// item.showLinked = false;
|
|
471
|
+
// item.linkedQuestion = 0;
|
|
472
|
+
// }
|
|
473
|
+
// } );
|
|
474
|
+
// }
|
|
475
|
+
let userAnswer = data.userAnswer;
|
|
500
476
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
for ( let i = 0; i < question[sectionIndex].questions.length; i++ ) {
|
|
505
|
-
let parentAnswers = question[sectionIndex].questions[i].answers || [];
|
|
506
|
-
let foundAnsIdx = parentAnswers.findIndex( ( ans ) => Array.isArray( ans?.nestedQuestion ) && ans.nestedQuestion.some( ( ele ) => parseInt( ele ) == currentQno ) );
|
|
507
|
-
if ( foundAnsIdx !== -1 ) {
|
|
508
|
-
parentQIndex = i;
|
|
509
|
-
// parentAnsIndex = foundAnsIdx;
|
|
510
|
-
break;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
if ( parentQIndex !== -1 ) {
|
|
514
|
-
let parentQno = question[sectionIndex].questions[parentQIndex].qno;
|
|
515
|
-
question[sectionIndex].questions[findQuestion].parentQno = parentQno;
|
|
516
|
-
// question[sectionIndex].questions[findQuestion].remarks = '';
|
|
517
|
-
// question[sectionIndex].questions[parentQIndex].answers[parentAnsIndex].redo = true;
|
|
518
|
-
// question[sectionIndex].questions[parentQIndex].answers[parentAnsIndex].validationAnswer = '';
|
|
519
|
-
}
|
|
520
|
-
} else {
|
|
521
|
-
question[sectionIndex].questions[findQuestion].userAnswer = [];
|
|
522
|
-
question[sectionIndex].questions[findQuestion].remarks = '';
|
|
523
|
-
}
|
|
477
|
+
question[sectionIndex].questions[findQuestion] = data;
|
|
478
|
+
question[sectionIndex].questions[findQuestion].userAnswer = [];
|
|
479
|
+
question[sectionIndex].questions[findQuestion].remarks = '';
|
|
524
480
|
checklistDetails.questionAnswers = question;
|
|
525
481
|
let updateData = {
|
|
526
|
-
checklistStatus:
|
|
482
|
+
checklistStatus: 'open',
|
|
527
483
|
redoStatus: true,
|
|
528
484
|
reinitiateStatus: true,
|
|
529
485
|
questionAnswers: question,
|
|
530
|
-
...( checklistDetails.checklistStatus != 'submit' && checklistDetails.redoStatus ) ? { redoEdit: true } : {},
|
|
531
486
|
};
|
|
532
487
|
|
|
533
488
|
let response = await processedChecklist.updateOne( { _id: req.body.payload._id }, updateData );
|
|
@@ -786,9 +741,8 @@ export async function getLogs( req, res ) {
|
|
|
786
741
|
let initiatedstatus = {
|
|
787
742
|
actionType: 'initation',
|
|
788
743
|
userName: data.initiatedBy,
|
|
789
|
-
Timestamp: data.initiatedTime,
|
|
744
|
+
Timestamp: dayjs.utc( data.initiatedTime ),
|
|
790
745
|
description: data.checklistDescription,
|
|
791
|
-
|
|
792
746
|
};
|
|
793
747
|
response.push( initiatedstatus );
|
|
794
748
|
response.push( userAnswer );
|
|
@@ -325,7 +325,7 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
325
325
|
},
|
|
326
326
|
} );
|
|
327
327
|
let getSections = await CLquestions.aggregate( sectionQuery );
|
|
328
|
-
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', '
|
|
328
|
+
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'storehygienemonitoring', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
|
|
329
329
|
if ( getSections.length ) {
|
|
330
330
|
for ( let element3 of getSections ) {
|
|
331
331
|
let collectQuestions = {};
|
|
@@ -650,11 +650,11 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
650
650
|
// }
|
|
651
651
|
}
|
|
652
652
|
} else {
|
|
653
|
-
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', '
|
|
653
|
+
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert' ].includes( getCLconfig.checkListType ) ) {
|
|
654
654
|
let storeNameList = allQuestion.map( ( item ) => item.store_id );
|
|
655
|
-
let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
|
|
655
|
+
let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
|
|
656
656
|
let storeList = storeDetails.map( ( store ) => store.storeId );
|
|
657
|
-
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
|
|
657
|
+
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
|
|
658
658
|
allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
|
|
659
659
|
} else {
|
|
660
660
|
allQuestion = storeDetails.map( ( item ) => {
|
|
@@ -688,7 +688,7 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
688
688
|
client_id: getCLconfig.client_id,
|
|
689
689
|
aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
|
|
690
690
|
};
|
|
691
|
-
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
|
|
691
|
+
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
|
|
692
692
|
let processData = {
|
|
693
693
|
aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
|
|
694
694
|
return { storeName: store.storeName, storeId: store.store_id, events: store.events };
|
|
@@ -929,7 +929,7 @@ async function insertData( requestData ) {
|
|
|
929
929
|
},
|
|
930
930
|
} );
|
|
931
931
|
let getSections = await CLquestions.aggregate( sectionQuery );
|
|
932
|
-
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', '
|
|
932
|
+
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
|
|
933
933
|
if ( getSections.length ) {
|
|
934
934
|
for ( let element3 of getSections ) {
|
|
935
935
|
let collectQuestions = {};
|
|
@@ -1224,11 +1224,11 @@ async function insertData( requestData ) {
|
|
|
1224
1224
|
// }
|
|
1225
1225
|
}
|
|
1226
1226
|
} else {
|
|
1227
|
-
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', '
|
|
1227
|
+
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
|
|
1228
1228
|
let storeNameList = allQuestion.map( ( item ) => item.store_id );
|
|
1229
|
-
let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
|
|
1229
|
+
let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
|
|
1230
1230
|
let storeList = storeDetails.map( ( store ) => store.storeId );
|
|
1231
|
-
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
|
|
1231
|
+
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
|
|
1232
1232
|
allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
|
|
1233
1233
|
} else {
|
|
1234
1234
|
allQuestion = storeDetails.map( ( item ) => {
|
|
@@ -1262,7 +1262,7 @@ async function insertData( requestData ) {
|
|
|
1262
1262
|
client_id: getCLconfig.client_id,
|
|
1263
1263
|
aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
|
|
1264
1264
|
};
|
|
1265
|
-
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( getCLconfig.checkListType ) ) {
|
|
1265
|
+
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( getCLconfig.checkListType ) ) {
|
|
1266
1266
|
let processData = {
|
|
1267
1267
|
aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
|
|
1268
1268
|
return { storeName: store.storeName, storeId: store.store_id, events: store.events };
|
|
@@ -2643,6 +2643,9 @@ export async function updateRunAI( req, res ) {
|
|
|
2643
2643
|
if ( !req.body.qName ) {
|
|
2644
2644
|
return res.sendError( 'Question name is required', 400 );
|
|
2645
2645
|
}
|
|
2646
|
+
if ( !req.body.userAnswer ) {
|
|
2647
|
+
return res.sendError( 'answer is required', 400 );
|
|
2648
|
+
}
|
|
2646
2649
|
let getDetails = await processedchecklist.findOne( { _id: req.body.id } );
|
|
2647
2650
|
if ( !getDetails ) {
|
|
2648
2651
|
return res.sendError( 'No data found', 204 );
|
|
@@ -2651,7 +2654,7 @@ export async function updateRunAI( req, res ) {
|
|
|
2651
2654
|
let updateData = {};
|
|
2652
2655
|
|
|
2653
2656
|
for ( let k of Object.keys( req.body.data ) ) {
|
|
2654
|
-
let keyPath = `questionAnswers.$[section].questions.$[question].userAnswer
|
|
2657
|
+
let keyPath = `questionAnswers.$[section].questions.$[question].userAnswer.$[userAnswer].${k}`;
|
|
2655
2658
|
updateData[keyPath] = req.body.data[k];
|
|
2656
2659
|
}
|
|
2657
2660
|
|
|
@@ -2662,7 +2665,9 @@ export async function updateRunAI( req, res ) {
|
|
|
2662
2665
|
arrayFilters: [
|
|
2663
2666
|
{ 'section.section_id': new ObjectId( req.body.sectionId ) },
|
|
2664
2667
|
{ 'question.qname': req.body.qName },
|
|
2668
|
+
{ 'userAnswer.answer': req.body.userAnswer },
|
|
2665
2669
|
],
|
|
2670
|
+
strict: false,
|
|
2666
2671
|
},
|
|
2667
2672
|
);
|
|
2668
2673
|
return res.sendSuccess( 'RunAI details updated successfully' );
|
|
@@ -1082,15 +1082,12 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1082
1082
|
try {
|
|
1083
1083
|
let requestData = req.body;
|
|
1084
1084
|
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
1085
|
-
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1
|
|
1085
|
+
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
|
|
1086
1086
|
let reqAnswers = requestData.questionAnswers;
|
|
1087
1087
|
logger.error( { functionName: 'updatedPayload', message: reqAnswers } );
|
|
1088
1088
|
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
1089
1089
|
|
|
1090
1090
|
if ( requestData.submittype == 'submit' ) {
|
|
1091
|
-
if ( getChecklistQA?.redoEdit ) {
|
|
1092
|
-
requestData.submittype = 'draft';
|
|
1093
|
-
}
|
|
1094
1091
|
reqAnswers.forEach( ( reqA ) => {
|
|
1095
1092
|
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && ( reqA.answerType == 'dropDown' && !reqA.allowMultiple ) ) {
|
|
1096
1093
|
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
@@ -1310,35 +1307,27 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1310
1307
|
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1311
1308
|
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1312
1309
|
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1313
|
-
if (
|
|
1314
|
-
if (
|
|
1315
|
-
if (
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1323
|
-
}
|
|
1310
|
+
if ( separatedArray[s].answer == qaans[k].answer ) {
|
|
1311
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1312
|
+
if ( separatedArray[s].validationAnswer ) {
|
|
1313
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1314
|
+
if ( validationAnswer.length ) {
|
|
1315
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1316
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1317
|
+
splitImgUrl.splice( 0, 3 );
|
|
1318
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1324
1319
|
}
|
|
1325
1320
|
}
|
|
1326
|
-
} else {
|
|
1327
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1328
|
-
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1329
1321
|
}
|
|
1322
|
+
} else {
|
|
1323
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1324
|
+
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1330
1325
|
}
|
|
1331
1326
|
|
|
1332
1327
|
mcmo.push( qaans[k] );
|
|
1333
1328
|
}
|
|
1334
1329
|
}
|
|
1335
1330
|
}
|
|
1336
|
-
qaAnswers[j].answers.forEach( ( ele ) => {
|
|
1337
|
-
if ( typeof ele?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1338
|
-
ele.redo = false;
|
|
1339
|
-
}
|
|
1340
|
-
} );
|
|
1341
|
-
|
|
1342
1331
|
let structure = {};
|
|
1343
1332
|
structure.qno = qaAnswers[j].qno;
|
|
1344
1333
|
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
@@ -2183,7 +2172,6 @@ export async function submitChecklist( req, res ) {
|
|
|
2183
2172
|
let flagCount = QuestionFlag( req, res );
|
|
2184
2173
|
updateData.questionFlag = flagCount;
|
|
2185
2174
|
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2186
|
-
updateData.redoEdit = false;
|
|
2187
2175
|
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
2188
2176
|
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
2189
2177
|
}
|
|
@@ -2456,8 +2444,7 @@ export async function submitTask( req, res ) {
|
|
|
2456
2444
|
'storeResponseTime': currentDateTime.format( 'HH:mm:ss - MMM DD, YYYY' ),
|
|
2457
2445
|
'message_mode': 'retriggered',
|
|
2458
2446
|
};
|
|
2459
|
-
|
|
2460
|
-
console.log( sqsResponse );
|
|
2447
|
+
sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2461
2448
|
}
|
|
2462
2449
|
if ( !excludedChecklists.includes( checklist.checkListName ) ) {
|
|
2463
2450
|
const query1 = [
|
|
@@ -3633,7 +3620,7 @@ export async function questionList( req, res ) {
|
|
|
3633
3620
|
checkvalidation = answer.validationAnswer;
|
|
3634
3621
|
}
|
|
3635
3622
|
}
|
|
3636
|
-
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation
|
|
3623
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
3637
3624
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
3638
3625
|
}
|
|
3639
3626
|
|
|
@@ -608,7 +608,7 @@ export const flagCardsV1 = async ( req, res ) => {
|
|
|
608
608
|
{
|
|
609
609
|
client_id: clientId,
|
|
610
610
|
publish: true,
|
|
611
|
-
checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] },
|
|
611
|
+
checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] },
|
|
612
612
|
},
|
|
613
613
|
{ checkListType: 1 },
|
|
614
614
|
);
|
|
@@ -2743,7 +2743,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
|
|
|
2743
2743
|
$or: [
|
|
2744
2744
|
{ questionFlag: { $gte: 1 } },
|
|
2745
2745
|
{ timeFlag: { $gte: 1 } },
|
|
2746
|
-
{ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } },
|
|
2746
|
+
{ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] } },
|
|
2747
2747
|
{
|
|
2748
2748
|
runAIQuestionCount: { $gte: 1 },
|
|
2749
2749
|
},
|
|
@@ -2945,7 +2945,7 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
|
|
|
2945
2945
|
{
|
|
2946
2946
|
client_id: requestData.clientId,
|
|
2947
2947
|
publish: true,
|
|
2948
|
-
checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] },
|
|
2948
|
+
checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] },
|
|
2949
2949
|
},
|
|
2950
2950
|
{ checkListType: 1 },
|
|
2951
2951
|
);
|
|
@@ -3047,7 +3047,7 @@ export const flagTablesV2 = async ( req, res ) => {
|
|
|
3047
3047
|
}
|
|
3048
3048
|
|
|
3049
3049
|
if ( requestData?.filter === 'all' ) {
|
|
3050
|
-
findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } } ] } );
|
|
3050
|
+
findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] } } ] } );
|
|
3051
3051
|
} else if ( requestData?.filter === 'question' ) {
|
|
3052
3052
|
findAndQuery.push( { checkListType: 'custom' } );
|
|
3053
3053
|
findAndQuery.push( { questionFlag: { $gte: 1 } } );
|
|
@@ -3055,7 +3055,7 @@ export const flagTablesV2 = async ( req, res ) => {
|
|
|
3055
3055
|
findAndQuery.push( { checkListType: 'custom' } );
|
|
3056
3056
|
findAndQuery.push( { timeFlag: { $gte: 1 } } );
|
|
3057
3057
|
} else if ( requestData?.filter === 'detection' ) {
|
|
3058
|
-
findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } } );
|
|
3058
|
+
findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] } } );
|
|
3059
3059
|
} else if ( requestData?.filter === 'runAI' ) {
|
|
3060
3060
|
if ( req.body.runAIChecklistName ) {
|
|
3061
3061
|
findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
|
|
@@ -1729,6 +1729,7 @@ export const updateConfigure = async ( req, res ) => {
|
|
|
1729
1729
|
owner: inputBody?.checkListDetails?.owner || [],
|
|
1730
1730
|
restrictAttendance: inputBody?.checkListDetails?.restrictAttendance || false,
|
|
1731
1731
|
enableNewDeployedStore: inputBody?.checkListDetails?.enableNewDeployedStore || false,
|
|
1732
|
+
redoValidity: inputBody?.checkListDetails?.redoValidity || 7,
|
|
1732
1733
|
};
|
|
1733
1734
|
|
|
1734
1735
|
if ( inputBody?.checkListDetails?.approver.length ) {
|
|
@@ -3907,6 +3908,8 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3907
3908
|
}
|
|
3908
3909
|
}
|
|
3909
3910
|
getsubmitDetails[0].questionAnswers = sectionList;
|
|
3911
|
+
getsubmitDetails[0].scheduleEndTime = getCLconfig.scheduleEndTime;
|
|
3912
|
+
getsubmitDetails[0].scheduleEndTime_iso = endTimeIso.format();
|
|
3910
3913
|
if ( modifiedCount ) {
|
|
3911
3914
|
getsubmitDetails[0].checklistStatus = 'inprogress';
|
|
3912
3915
|
getsubmitDetails[0].date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
|
|
@@ -4030,6 +4033,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
4030
4033
|
}, { userId: 1, store_id: 1 } );
|
|
4031
4034
|
|
|
4032
4035
|
if ( inprogressData.length ) {
|
|
4036
|
+
await processedchecklist.updateMany( { _id: { $in: inprogressData.map( ( ele ) => new ObjectId( ele._id ) ) } }, { scheduleEndTime: getCLconfig.scheduleEndTime, scheduleEndTime_iso: endTimeIso.format() } );
|
|
4033
4037
|
inprogressData.forEach( ( item ) => {
|
|
4034
4038
|
let checkData = assignUserList.find( ( ele ) => ele.userId.toString() == item.userId.toString() && ele.store_id == item.store_id );
|
|
4035
4039
|
if ( !checkData ) {
|
|
@@ -4127,7 +4131,7 @@ async function updateOpenSearch( user, data ) {
|
|
|
4127
4131
|
export const aiChecklist = async ( req, res ) => {
|
|
4128
4132
|
try {
|
|
4129
4133
|
let storeDetails = await storeService.count( { clientId: req.query.clientId, status: 'active' } );
|
|
4130
|
-
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', '
|
|
4134
|
+
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ];
|
|
4131
4135
|
let checklistDetails = [];
|
|
4132
4136
|
let publishList = [];
|
|
4133
4137
|
let unpublishList = [];
|
|
@@ -4140,7 +4144,7 @@ export const aiChecklist = async ( req, res ) => {
|
|
|
4140
4144
|
checklistDetails = [ ...publishList, ...unpublishList ];
|
|
4141
4145
|
|
|
4142
4146
|
checklistDetails.forEach( ( item ) => {
|
|
4143
|
-
if ( ![ 'mobileusagedetection', 'storeopenandclose', 'cleaning', 'scrum', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( item.checkListType ) ) {
|
|
4147
|
+
if ( ![ 'mobileusagedetection', 'storeopenandclose', 'cleaning', 'scrum', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( item.checkListType ) ) {
|
|
4144
4148
|
item.storeCount = storeDetails;
|
|
4145
4149
|
}
|
|
4146
4150
|
} );
|