tango-app-api-trax 3.5.2-alpha-12 → 3.6.0-inditech-1
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 +1 -1
- package/src/controllers/gallery.controller.js +43 -24
- package/src/controllers/internalTrax.controller.js +118 -1
- package/src/controllers/traxDashboard.controllers.js +75 -6
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/gallery.routes.js +8 -8
- package/src/routes/internalTraxApi.router.js +2 -1
- package/src/services/notification.service.js +31 -0
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import { aggregate } from '../services/user.service.js';
|
|
|
16
16
|
// import axios from 'axios';
|
|
17
17
|
import timeZone from 'dayjs/plugin/timezone.js';
|
|
18
18
|
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
19
|
+
import * as notificationModel from '../services/notification.service.js';
|
|
19
20
|
|
|
20
21
|
dayjs.extend( customParseFormat );
|
|
21
22
|
dayjs.extend( timeZone );
|
|
@@ -483,8 +484,8 @@ export async function redoChecklist( req, res ) {
|
|
|
483
484
|
sectionName: question[sectionIndex].sectionName,
|
|
484
485
|
questionName: question[sectionIndex].questions[findQuestion].qname,
|
|
485
486
|
action: 'redo',
|
|
486
|
-
store_id: checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
487
|
-
storeName: checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
487
|
+
store_id: checklistDetails?.store_id ? checklistDetails?.store_id : '',
|
|
488
|
+
storeName: checklistDetails?.storeName ? checklistDetails?.storeName : '',
|
|
488
489
|
client_id: checklistDetails.client_id,
|
|
489
490
|
processedChecklistId: checklistDetails._id,
|
|
490
491
|
type: checklistDetails.checkListType,
|
|
@@ -507,16 +508,16 @@ export async function redoChecklist( req, res ) {
|
|
|
507
508
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
508
509
|
let searchResponse = await fetch( url.redoChecklist, requestOptions );
|
|
509
510
|
// console.log( searchResponse.ok );
|
|
510
|
-
let logData= {
|
|
511
|
+
let logData = {
|
|
511
512
|
'client_id': checklistDetails.client_id,
|
|
512
513
|
'createAt': new Date(),
|
|
513
514
|
'sourceCheckList_id': checklistDetails.sourceCheckList_id,
|
|
514
515
|
'checkListName': checklistDetails.checkListName,
|
|
515
516
|
'fromCheckListName': checklistDetails.checkListName,
|
|
516
517
|
'type': 'checklist',
|
|
517
|
-
'action': checklistDetails.redoStatus?'multiredo': 'redo',
|
|
518
|
-
'storeName': checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
519
|
-
'store_id': checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
518
|
+
'action': checklistDetails.redoStatus ? 'multiredo' : 'redo',
|
|
519
|
+
'storeName': checklistDetails?.storeName ? checklistDetails?.storeName : '',
|
|
520
|
+
'store_id': checklistDetails?.store_id ? checklistDetails?.store_id : '',
|
|
520
521
|
'userName': checklistDetails.userName,
|
|
521
522
|
'userEmail': checklistDetails.userEmail,
|
|
522
523
|
'createdByEmail': req.user.email,
|
|
@@ -544,7 +545,7 @@ export async function redoChecklist( req, res ) {
|
|
|
544
545
|
|
|
545
546
|
export async function redomultiChecklist( req, res ) {
|
|
546
547
|
try {
|
|
547
|
-
let inputData = req.body.payload.coverage==='user'?req.body.payload.userEmail:req.body.payload.storeName;
|
|
548
|
+
let inputData = req.body.payload.coverage === 'user' ? req.body.payload.userEmail : req.body.payload.storeName;
|
|
548
549
|
|
|
549
550
|
|
|
550
551
|
for ( let originalData of inputData ) {
|
|
@@ -625,8 +626,8 @@ export async function redomultiChecklist( req, res ) {
|
|
|
625
626
|
sectionName: question[sectionIndex].sectionName,
|
|
626
627
|
questionName: question[sectionIndex].questions[findQuestion].qname,
|
|
627
628
|
action: 'redo',
|
|
628
|
-
store_id: checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
629
|
-
storeName: checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
629
|
+
store_id: checklistDetails?.store_id ? checklistDetails?.store_id : '',
|
|
630
|
+
storeName: checklistDetails?.storeName ? checklistDetails?.storeName : '',
|
|
630
631
|
client_id: checklistDetails.client_id,
|
|
631
632
|
processedChecklistId: checklistDetails._id,
|
|
632
633
|
type: checklistDetails.checkListType,
|
|
@@ -640,9 +641,9 @@ export async function redomultiChecklist( req, res ) {
|
|
|
640
641
|
await checklistLogs.create( data );
|
|
641
642
|
|
|
642
643
|
|
|
643
|
-
req.body.payload._id=originalData.checklistId;
|
|
644
|
-
req.body.payload.section_id=originalData.section_id;
|
|
645
|
-
req.body.payload.uniqueNo=originalData.uniqueNo;
|
|
644
|
+
req.body.payload._id = originalData.checklistId;
|
|
645
|
+
req.body.payload.section_id = originalData.section_id;
|
|
646
|
+
req.body.payload.uniqueNo = originalData.uniqueNo;
|
|
646
647
|
// console.log( req.body );
|
|
647
648
|
|
|
648
649
|
|
|
@@ -656,16 +657,16 @@ export async function redomultiChecklist( req, res ) {
|
|
|
656
657
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
657
658
|
let searchResponse = await fetch( url.redoChecklist, requestOptions );
|
|
658
659
|
console.log( searchResponse.ok );
|
|
659
|
-
let logData= {
|
|
660
|
+
let logData = {
|
|
660
661
|
'client_id': checklistDetails.client_id,
|
|
661
662
|
'createAt': new Date(),
|
|
662
663
|
'sourceCheckList_id': checklistDetails.sourceCheckList_id,
|
|
663
664
|
'checkListName': checklistDetails.checkListName,
|
|
664
665
|
'fromCheckListName': checklistDetails.checkListName,
|
|
665
666
|
'type': 'checklist',
|
|
666
|
-
'action': checklistDetails.redoStatus?'multiredo': 'redo',
|
|
667
|
-
'storeName': checklistDetails?.storeName?checklistDetails?.storeName:'',
|
|
668
|
-
'store_id': checklistDetails?.store_id?checklistDetails?.store_id:'',
|
|
667
|
+
'action': checklistDetails.redoStatus ? 'multiredo' : 'redo',
|
|
668
|
+
'storeName': checklistDetails?.storeName ? checklistDetails?.storeName : '',
|
|
669
|
+
'store_id': checklistDetails?.store_id ? checklistDetails?.store_id : '',
|
|
669
670
|
'userName': checklistDetails.userName,
|
|
670
671
|
'userEmail': checklistDetails.userEmail,
|
|
671
672
|
'createdByEmail': req.user.email,
|
|
@@ -769,6 +770,7 @@ export async function approvalstatus( req, res ) {
|
|
|
769
770
|
export const headerStoresV2 = async ( req, res ) => {
|
|
770
771
|
try {
|
|
771
772
|
let reqestData = req.body;
|
|
773
|
+
|
|
772
774
|
let getUserEmail = req.user.email;
|
|
773
775
|
let getUserType = req.user.userType;
|
|
774
776
|
let getRole = req.user.role;
|
|
@@ -1048,7 +1050,7 @@ export async function teamsList( req, res ) {
|
|
|
1048
1050
|
];
|
|
1049
1051
|
|
|
1050
1052
|
|
|
1051
|
-
if ( req.user&&req.user.userType==='client'&&req.user.role!='superadmin' ) {
|
|
1053
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
1052
1054
|
query.push( {
|
|
1053
1055
|
$match: {
|
|
1054
1056
|
Teamlead: {
|
|
@@ -1088,14 +1090,16 @@ export async function userList( req, res ) {
|
|
|
1088
1090
|
},
|
|
1089
1091
|
},
|
|
1090
1092
|
];
|
|
1091
|
-
if ( req.user&&req.user.userType==='client'&&req.user.role!='superadmin' ) {
|
|
1092
|
-
let findTeams = await findteams( {
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1093
|
+
if ( req.user && req.user.userType === 'client' && req.user.role != 'superadmin' ) {
|
|
1094
|
+
let findTeams = await findteams( {
|
|
1095
|
+
Teamlead: {
|
|
1096
|
+
$elemMatch: {
|
|
1097
|
+
email: req.user.email,
|
|
1098
|
+
},
|
|
1099
|
+
}, clientId: req.body.clientId,
|
|
1100
|
+
} );
|
|
1097
1101
|
req.body.teams = findTeams.map( ( data ) => data.teamName );
|
|
1098
|
-
if ( req.body.teams.length===0 ) {
|
|
1102
|
+
if ( req.body.teams.length === 0 ) {
|
|
1099
1103
|
query.push( {
|
|
1100
1104
|
$match: {
|
|
1101
1105
|
userEmail: { $in: [ req.user.email ] },
|
|
@@ -1129,3 +1133,18 @@ export async function userList( req, res ) {
|
|
|
1129
1133
|
return res.sendError( { error: error }, 500 );
|
|
1130
1134
|
}
|
|
1131
1135
|
}
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
export async function checkNotificationCount( req, res ) {
|
|
1139
|
+
try {
|
|
1140
|
+
console.log( req.user._id );
|
|
1141
|
+
let notifyRecord = await notificationModel.findnotification( { 'userId': new mongoose.Types.ObjectId( req.user._id ), 'status': 'unsend' } );
|
|
1142
|
+
let findRecord = notifyRecord.map( ( data ) => data._id );
|
|
1143
|
+
console.log( findRecord );
|
|
1144
|
+
await notificationModel.updateManynotification( { _id: { $in: findRecord } }, { $set: { 'status': 'send' } } );
|
|
1145
|
+
return res.sendSuccess( notifyRecord );
|
|
1146
|
+
} catch ( error ) {
|
|
1147
|
+
logger.error( { error: error, function: 'checkNotificationCount' } );
|
|
1148
|
+
return res.sendError( { error: error }, 500 );
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
@@ -22,7 +22,7 @@ import { sendPushNotification, sendAiPushNotification } from 'tango-app-api-midd
|
|
|
22
22
|
// import * as planoService from '../services/planogram.service.js';
|
|
23
23
|
import * as clusterServices from '../services/cluster.service.js';
|
|
24
24
|
import * as teamsServices from '../services/teams.service.js';
|
|
25
|
-
|
|
25
|
+
import * as notificationModel from '../services/notification.service.js';
|
|
26
26
|
|
|
27
27
|
const ObjectId = mongoose.Types.ObjectId;
|
|
28
28
|
dayjs.extend( customParseFormat );
|
|
@@ -2345,3 +2345,120 @@ export async function getLiveChecklistClients( req, res ) {
|
|
|
2345
2345
|
else res.sendError( error, 500 );
|
|
2346
2346
|
}
|
|
2347
2347
|
}
|
|
2348
|
+
|
|
2349
|
+
|
|
2350
|
+
export async function notificationCreate( req, res ) {
|
|
2351
|
+
try {
|
|
2352
|
+
let insertData= [];
|
|
2353
|
+
let findAllUser = await userService.find( { clientId: '464', isActive: true } );
|
|
2354
|
+
for ( let user of findAllUser ) {
|
|
2355
|
+
for ( let store of req.body ) {
|
|
2356
|
+
let data= {};
|
|
2357
|
+
data.userId = user._id;
|
|
2358
|
+
data.storeId = store.storeId;
|
|
2359
|
+
data.storeName = store.storeName;
|
|
2360
|
+
data.captureTime = store.captureTime;
|
|
2361
|
+
data.slotNo = store.slotNo;
|
|
2362
|
+
let payload = {
|
|
2363
|
+
userType: user.userType,
|
|
2364
|
+
role: user.role,
|
|
2365
|
+
assignedStores: user.assignedStores,
|
|
2366
|
+
clientId: user.clientId,
|
|
2367
|
+
email: user.email,
|
|
2368
|
+
};
|
|
2369
|
+
let result = await storecheckExists( payload );
|
|
2370
|
+
if ( result ) {
|
|
2371
|
+
insertData.push( data );
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
let create = await notificationModel.insertManynotificationModel( insertData );
|
|
2376
|
+
// console.log( create );
|
|
2377
|
+
if ( create ) {
|
|
2378
|
+
return res.sendSuccess( 'updated successfully' );
|
|
2379
|
+
}
|
|
2380
|
+
} catch ( e ) {
|
|
2381
|
+
logger.error( { error: e, function: 'notificationCreate' } );
|
|
2382
|
+
if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
|
|
2383
|
+
else res.sendError( e, 500 );
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
export async function storecheckExists( data ) {
|
|
2389
|
+
try {
|
|
2390
|
+
if ( data && data.userType === 'client' && data.role !== 'superadmin' ) {
|
|
2391
|
+
let storeIds = new Set( data.assignedStores.map( ( store ) => store.storeId ) );
|
|
2392
|
+
|
|
2393
|
+
|
|
2394
|
+
// Fetch clusters and teams in parallel
|
|
2395
|
+
const [ clustersList, teamsList ] = await Promise.all( [
|
|
2396
|
+
clusterServices.findcluster( { clientId: data.clientId, Teamlead: { $elemMatch: { email: data.email } } } ),
|
|
2397
|
+
teamsServices.findteams( { clientId: data.clientId, Teamlead: { $elemMatch: { email: data.email } } } ),
|
|
2398
|
+
] );
|
|
2399
|
+
|
|
2400
|
+
// Process clusters
|
|
2401
|
+
if ( clustersList.length > 0 ) {
|
|
2402
|
+
for ( let cluster of clustersList ) {
|
|
2403
|
+
cluster.stores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
// Process teams
|
|
2408
|
+
if ( teamsList.length > 0 ) {
|
|
2409
|
+
for ( let team of teamsList ) {
|
|
2410
|
+
for ( let user of team.users ) {
|
|
2411
|
+
let findUser = await userService.findOne( { _id: user.userId } );
|
|
2412
|
+
if ( findUser && findUser.assignedStores?.length > 0 ) {
|
|
2413
|
+
findUser.assignedStores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
// Fetch clusters for the user
|
|
2417
|
+
let userClustersList = await clusterServices.findcluster( { clientId: data.clientId, Teamlead: { $elemMatch: { email: findUser.email } } } );
|
|
2418
|
+
if ( userClustersList.length > 0 ) {
|
|
2419
|
+
for ( let cluster of userClustersList ) {
|
|
2420
|
+
cluster.stores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
let TeamMember = await teamsServices.findteams( { clientId: data.clientId, users: { $elemMatch: { email: data.email } } } );
|
|
2427
|
+
if ( TeamMember&&TeamMember.length>0 ) {
|
|
2428
|
+
for ( let team of TeamMember ) {
|
|
2429
|
+
let clusterList = await clusterServices.findcluster( { clientId: data.clientId, teams: { $elemMatch: { name: team.teamName } } } );
|
|
2430
|
+
if ( clusterList.length > 0 ) {
|
|
2431
|
+
for ( let cluster of clusterList ) {
|
|
2432
|
+
cluster.stores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
let TeamLeader = await teamsServices.findteams( { clientId: data.clientId, Teamlead: { $elemMatch: { email: data.email } } } );
|
|
2438
|
+
if ( TeamLeader&&TeamLeader.length>0 ) {
|
|
2439
|
+
for ( let team of TeamLeader ) {
|
|
2440
|
+
let clusterList = await clusterServices.findcluster( { clientId: data.clientId, teams: { $elemMatch: { name: team.teamName } } } );
|
|
2441
|
+
if ( clusterList.length > 0 ) {
|
|
2442
|
+
for ( let cluster of clusterList ) {
|
|
2443
|
+
cluster.stores.forEach( ( store ) => storeIds.add( store.storeId ) );
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
// Convert Set back to Array if needed
|
|
2449
|
+
|
|
2450
|
+
let resultStores = Array.from( storeIds );
|
|
2451
|
+
resultStores.filter( ( ele ) => ele.storeId===data.storeId );
|
|
2452
|
+
|
|
2453
|
+
if ( resultStores.length>0 ) {
|
|
2454
|
+
return true;
|
|
2455
|
+
} else {
|
|
2456
|
+
return false;
|
|
2457
|
+
}
|
|
2458
|
+
} else {
|
|
2459
|
+
return true;
|
|
2460
|
+
}
|
|
2461
|
+
} catch ( error ) {
|
|
2462
|
+
logger.error( { error: error, function: 'internalAISendPushNotification' } );
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, download, getChecklistUsers } from 'tango-app-api-middleware';
|
|
1
|
+
import { logger, download, getChecklistUsers, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
2
2
|
import * as processedchecklistService from '../services/processedchecklist.services.js';
|
|
3
3
|
import * as processedchecklistconfigService from '../services/processedchecklistconfig.services.js';
|
|
4
4
|
import * as checklistconfigService from '../services/checklist.service.js';
|
|
@@ -1595,6 +1595,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1595
1595
|
} },
|
|
1596
1596
|
approvalByEmail: 1,
|
|
1597
1597
|
approvalTime_string: 1,
|
|
1598
|
+
_id: 1,
|
|
1598
1599
|
},
|
|
1599
1600
|
} );
|
|
1600
1601
|
|
|
@@ -1645,6 +1646,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1645
1646
|
submitCount: 1,
|
|
1646
1647
|
approvalByEmail: 1,
|
|
1647
1648
|
approvalTime_string: 1,
|
|
1649
|
+
_id: 1,
|
|
1648
1650
|
},
|
|
1649
1651
|
} );
|
|
1650
1652
|
|
|
@@ -3827,7 +3829,6 @@ export const reinitiatechecklist = async ( req, res ) => {
|
|
|
3827
3829
|
let requestData = req.body;
|
|
3828
3830
|
let findQuery = [];
|
|
3829
3831
|
let findAndQuery = [];
|
|
3830
|
-
|
|
3831
3832
|
if ( requestData._id ) {
|
|
3832
3833
|
findAndQuery.push(
|
|
3833
3834
|
{ _id: new mongoose.Types.ObjectId( requestData._id ) },
|
|
@@ -3837,6 +3838,15 @@ export const reinitiatechecklist = async ( req, res ) => {
|
|
|
3837
3838
|
$project: {
|
|
3838
3839
|
_id: 1,
|
|
3839
3840
|
reinitiateStatus: 1,
|
|
3841
|
+
store_id: 1,
|
|
3842
|
+
storeName: 1,
|
|
3843
|
+
userEmail: 1,
|
|
3844
|
+
action: 1,
|
|
3845
|
+
sourceCheckList_id: 1,
|
|
3846
|
+
checkListName: 1,
|
|
3847
|
+
client_id: 1,
|
|
3848
|
+
date_iso: 1,
|
|
3849
|
+
coverage: 1,
|
|
3840
3850
|
},
|
|
3841
3851
|
} );
|
|
3842
3852
|
let getChecklist = await processedchecklistService.aggregate( findQuery );
|
|
@@ -3844,7 +3854,26 @@ export const reinitiatechecklist = async ( req, res ) => {
|
|
|
3844
3854
|
let updateChecklist = await processedchecklistService.updateOne( { _id: new mongoose.Types.ObjectId( requestData._id ) }, { reinitiateStatus: true } );
|
|
3845
3855
|
if ( updateChecklist ) {
|
|
3846
3856
|
// Delete Time Flag Detection //
|
|
3847
|
-
|
|
3857
|
+
const data = getChecklist[0];
|
|
3858
|
+
let logObj = {
|
|
3859
|
+
client_id: data.client_id,
|
|
3860
|
+
createAt: new Date(),
|
|
3861
|
+
sourceCheckList_id: data.sourceCheckList_id,
|
|
3862
|
+
checkListName: data.checkListName,
|
|
3863
|
+
fromCheckListName: '',
|
|
3864
|
+
type: 'checklist',
|
|
3865
|
+
action: 'reinitiated',
|
|
3866
|
+
storeName: data.storeName,
|
|
3867
|
+
store_id: data.store_id,
|
|
3868
|
+
userEmail: data.userEmail,
|
|
3869
|
+
createdByEmail: req.user.email,
|
|
3870
|
+
createdBy: req.user.userName,
|
|
3871
|
+
coverage: data.coverage,
|
|
3872
|
+
logDetails: {},
|
|
3873
|
+
userType: req.user.userType,
|
|
3874
|
+
processedChecklistId: data._id,
|
|
3875
|
+
};
|
|
3876
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
3848
3877
|
return res.sendSuccess( 'Reinitiate Successfully' );
|
|
3849
3878
|
} else {
|
|
3850
3879
|
return res.sendError( { error: 'Something Went wrong Please Try Again' }, 400 );
|
|
@@ -3854,25 +3883,65 @@ export const reinitiatechecklist = async ( req, res ) => {
|
|
|
3854
3883
|
}
|
|
3855
3884
|
} else if ( requestData.sourceCheckList_id ) {
|
|
3856
3885
|
findAndQuery.push(
|
|
3857
|
-
{
|
|
3886
|
+
{
|
|
3887
|
+
reinitiateStatus: false,
|
|
3888
|
+
sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ),
|
|
3889
|
+
},
|
|
3858
3890
|
);
|
|
3859
3891
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
3860
3892
|
findQuery.push( {
|
|
3861
3893
|
$project: {
|
|
3862
3894
|
_id: 1,
|
|
3863
3895
|
reinitiateStatus: 1,
|
|
3896
|
+
store_id: 1,
|
|
3897
|
+
storeName: 1,
|
|
3898
|
+
userEmail: 1,
|
|
3899
|
+
action: 1,
|
|
3900
|
+
sourceCheckList_id: 1,
|
|
3901
|
+
checkListName: 1,
|
|
3902
|
+
client_id: 1,
|
|
3903
|
+
date_iso: 1,
|
|
3904
|
+
coverage: 1,
|
|
3864
3905
|
},
|
|
3865
3906
|
} );
|
|
3866
3907
|
let getChecklist = await processedchecklistService.aggregate( findQuery );
|
|
3867
3908
|
if ( getChecklist.length>0 ) {
|
|
3868
3909
|
let updateQuery = {
|
|
3869
|
-
|
|
3910
|
+
sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ),
|
|
3870
3911
|
timeFlag: { $gt: 0 },
|
|
3912
|
+
reinitiateStatus: false,
|
|
3871
3913
|
};
|
|
3872
3914
|
let updateChecklist = await processedchecklistService.updateMany( updateQuery, { reinitiateStatus: true } );
|
|
3873
3915
|
if ( updateChecklist ) {
|
|
3874
3916
|
// Delete Time Flag Detection //
|
|
3875
|
-
|
|
3917
|
+
const data = getChecklist[0];
|
|
3918
|
+
// let stores = getChecklist.map( ( item ) => ( {
|
|
3919
|
+
// // store_id: item.store_id,
|
|
3920
|
+
// storeName: item.storeName,
|
|
3921
|
+
// } ) );
|
|
3922
|
+
|
|
3923
|
+
// let users = getChecklist.map( ( item ) => ( {
|
|
3924
|
+
// userEmail: item.userEmail,
|
|
3925
|
+
// } ) );
|
|
3926
|
+
let logObj = {
|
|
3927
|
+
client_id: data.client_id,
|
|
3928
|
+
createAt: new Date(),
|
|
3929
|
+
sourceCheckList_id: data.sourceCheckList_id,
|
|
3930
|
+
checkListName: data.checkListName,
|
|
3931
|
+
fromCheckListName: '',
|
|
3932
|
+
type: 'checklist',
|
|
3933
|
+
action: 'reinitiated',
|
|
3934
|
+
storeName: data.storeName,
|
|
3935
|
+
store_id: data.store_id,
|
|
3936
|
+
userEmail: data.userEmail,
|
|
3937
|
+
createdByEmail: req.user.email,
|
|
3938
|
+
createdBy: req.user.userName,
|
|
3939
|
+
coverage: data.coverage,
|
|
3940
|
+
logDetails: {},
|
|
3941
|
+
userType: req.user.userType,
|
|
3942
|
+
processedChecklistId: data._id,
|
|
3943
|
+
};
|
|
3944
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
3876
3945
|
return res.sendSuccess( 'Reinitiate Successfully' );
|
|
3877
3946
|
} else {
|
|
3878
3947
|
return res.sendError( { error: 'Something Went wrong Please Try Again' }, 400 );
|