tango-app-api-store-builder 1.0.0-beta-158 → 1.0.0-beta-159
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/fixtureTemplate.controller.js +1 -0
- package/src/controllers/managePlano.controller.js +56 -1
- package/src/controllers/planoLibrary.controller.js +3 -20
- package/src/controllers/script.controller.js +8 -8
- package/src/controllers/storeBuilder.controller.js +838 -10
- package/src/controllers/task.controller.js +132 -114
- package/src/dtos/validation.dtos.js +1 -0
- package/src/routes/managePlano.routes.js +2 -1
- package/src/routes/storeBuilder.routes.js +3 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as taskService from '../service/task.service.js';
|
|
2
1
|
import * as processedService from '../service/processedTaskservice.js';
|
|
3
2
|
import * as storeService from '../service/store.service.js';
|
|
4
3
|
import * as processedChecklistService from '../service/processedchecklist.service.js';
|
|
@@ -11,7 +10,7 @@ import * as checklistService from '../service/checklist.service.js';
|
|
|
11
10
|
import timeZone from 'dayjs/plugin/timezone.js';
|
|
12
11
|
import * as planoProductService from '../service/planoProduct.service.js';
|
|
13
12
|
import mongoose from 'mongoose';
|
|
14
|
-
|
|
13
|
+
const ObjectId = mongoose.Types.ObjectId;
|
|
15
14
|
import * as floorService from '../service/storeBuilder.service.js';
|
|
16
15
|
import * as planoStaticService from '../service/planoStaticData.service.js';
|
|
17
16
|
import * as assignService from '../service/assignService.service.js';
|
|
@@ -128,10 +127,13 @@ export async function createTask( req, res ) {
|
|
|
128
127
|
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: 'open', redoStatus: true, date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( '12:00 AM', 'hh:mm A' ).format(), scheduleEndTime_iso: dayjs.utc( scheduleEndTime, 'hh:mm A' ).format(), date_string: dayjs().format( 'YYYY-MM-DD' ), date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } );
|
|
129
128
|
return res.sendSuccess( 'Task redo triggered successfully' );
|
|
130
129
|
} else {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return res.sendError( 'No data found', 204 );
|
|
130
|
+
if ( !req.body?.checkListName ) {
|
|
131
|
+
return res.sendError( 'ChecklistName is required', 400 );
|
|
134
132
|
}
|
|
133
|
+
// let taskDetails = await taskService.find( { isPlano: true, ...( req.body.checkListName )? { checkListName: req.body.checkListName } : {} } );
|
|
134
|
+
// if ( !taskDetails.length ) {
|
|
135
|
+
// return res.sendError( 'No data found', 204 );
|
|
136
|
+
// }
|
|
135
137
|
let userDetails;
|
|
136
138
|
let storeList;
|
|
137
139
|
let endDate;
|
|
@@ -200,104 +202,113 @@ export async function createTask( req, res ) {
|
|
|
200
202
|
await createUser( userData );
|
|
201
203
|
}
|
|
202
204
|
}
|
|
203
|
-
await Promise.all( taskDetails.map( async ( task ) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
205
|
+
// await Promise.all( taskDetails.map( async ( task ) => {
|
|
206
|
+
let taskId = new ObjectId();
|
|
207
|
+
let [ first ] = req.body?.checkListName.split( ' ' );
|
|
208
|
+
first = first.toLowerCase();
|
|
209
|
+
if ( req.body?.checkListName.toLowerCase().includes( 'rollout' ) ) {
|
|
210
|
+
if ( req.body.checkListName.toLowerCase().includes( 'visual' ) ) {
|
|
211
|
+
first = 'vmRollout';
|
|
212
|
+
} else {
|
|
213
|
+
first = 'merchRollout';
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
let data = {
|
|
217
|
+
client_id: req.body.clientId,
|
|
218
|
+
date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
219
|
+
date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
220
|
+
sourceCheckList_id: taskId,
|
|
221
|
+
checkListName: req.body.checkListName,
|
|
222
|
+
checkListId: taskId,
|
|
223
|
+
scheduleStartTime: '12:00 AM',
|
|
224
|
+
scheduleEndTime: scheduleEndTime,
|
|
225
|
+
scheduleStartTime_iso: dayjs.utc( '12:00 AM', 'hh:mm A' ).format(),
|
|
226
|
+
scheduleEndTime_iso: dayjs.utc( endDate, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
227
|
+
allowedOverTime: false,
|
|
228
|
+
allowedStoreLocation: req.body?.geoFencing || false,
|
|
229
|
+
createdBy: req?.user?._id,
|
|
230
|
+
createdByName: req?.user?.userName,
|
|
231
|
+
questionAnswers: [],
|
|
232
|
+
isdeleted: false,
|
|
233
|
+
questionCount: 0,
|
|
234
|
+
storeCount: 0,
|
|
235
|
+
locationCount: 0,
|
|
236
|
+
checkListType: 'task',
|
|
237
|
+
country: '',
|
|
238
|
+
store_id: '',
|
|
239
|
+
storeName: '',
|
|
240
|
+
userId: '',
|
|
241
|
+
userName: '',
|
|
242
|
+
userEmail: '',
|
|
243
|
+
checklistStatus: 'open',
|
|
244
|
+
timeFlagStatus: true,
|
|
245
|
+
timeFlag: 0,
|
|
246
|
+
questionFlag: 0,
|
|
247
|
+
mobileDetectionFlag: 0,
|
|
248
|
+
storeOpenCloseFlag: 0,
|
|
249
|
+
reinitiateStatus: false,
|
|
250
|
+
markasread: false,
|
|
251
|
+
uniformDetectionFlag: 0,
|
|
252
|
+
scheduleRepeatedType: 'daily',
|
|
253
|
+
approvalStatus: false,
|
|
254
|
+
approvalEnable: false,
|
|
255
|
+
redoStatus: false,
|
|
256
|
+
isPlano: true,
|
|
257
|
+
planoType: first,
|
|
258
|
+
};
|
|
259
|
+
let query = [
|
|
260
|
+
{
|
|
261
|
+
$addFields: {
|
|
262
|
+
store: { $toLower: '$storeName' },
|
|
254
263
|
},
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
},
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
$match: {
|
|
267
|
+
clientId: req.body.clientId,
|
|
268
|
+
store: { $in: storeList },
|
|
260
269
|
},
|
|
261
|
-
|
|
270
|
+
},
|
|
271
|
+
];
|
|
262
272
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
},
|
|
273
|
+
let storeDetails = await storeService.aggregate( query );
|
|
274
|
+
await Promise.all( storeDetails.map( async ( store ) => {
|
|
275
|
+
let getUserEmail = req.body.stores.find( ( ele ) => ele.store.toLowerCase() == store.storeName.toLowerCase() );
|
|
276
|
+
let planoDetails = await planoService.findOne( { storeName: store.storeName } );
|
|
277
|
+
if ( planoDetails ) {
|
|
278
|
+
const [ floorDetails, floorCount ] = await Promise.all( [
|
|
279
|
+
await floorService.find( { planoId: planoDetails._id, ...( req.body?.floorId ) ? { _id: req.body?.floorId }:{} }, { _id: 1, floorName: 1 } ),
|
|
280
|
+
await floorService.count( { planoId: planoDetails._id } ),
|
|
281
|
+
] );
|
|
282
|
+
for ( let i=0; i<floorDetails.length; i++ ) {
|
|
283
|
+
if ( getUserEmail ) {
|
|
284
|
+
let query = [
|
|
285
|
+
{
|
|
286
|
+
$addFields: {
|
|
287
|
+
emailLower: { $toLower: '$email' },
|
|
279
288
|
},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
$match: {
|
|
292
|
+
clientId: req.body.clientId,
|
|
293
|
+
emailLower: getUserEmail.email.toLowerCase(),
|
|
285
294
|
},
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
295
|
+
},
|
|
296
|
+
];
|
|
297
|
+
userDetails = await userService.aggregate( query );
|
|
298
|
+
userDetails = userDetails[0];
|
|
299
|
+
}
|
|
300
|
+
let taskData = { ...data };
|
|
301
|
+
if ( floorCount > 1 ) {
|
|
302
|
+
taskData.checkListName = taskData.checkListName +' - '+ floorDetails[i].floorName;
|
|
303
|
+
}
|
|
304
|
+
taskData.floorId = floorDetails[i]._id;
|
|
305
|
+
taskData.store_id = store.storeId;
|
|
306
|
+
taskData.storeName = store.storeName;
|
|
307
|
+
taskData.userId = userDetails._id;
|
|
308
|
+
taskData.userName = userDetails.userName;
|
|
309
|
+
taskData.userEmail = userDetails.email;
|
|
310
|
+
taskData.planoId = planoDetails?._id;
|
|
311
|
+
if ( !req.body?.checkListName.toLowerCase().includes( 'rollout' ) ) {
|
|
301
312
|
let planoProgress = req.body.checkListName == 'Fixture Verification' ? 50 : req.body.checkListName == 'VM Verification' ? 75 : 25;
|
|
302
313
|
if ( req.body?.checkListName && req.body.checkListName == 'Layout Verification' ) {
|
|
303
314
|
await planoTaskService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId } );
|
|
@@ -308,19 +319,17 @@ export async function createTask( req, res ) {
|
|
|
308
319
|
await planoTaskService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId, type: type } );
|
|
309
320
|
}
|
|
310
321
|
await floorService.updateOne( { _id: taskData?.floorId }, { planoProgress } );
|
|
311
|
-
for ( let j=0; j<req.body.days; j++ ) {
|
|
312
|
-
let currDate = dayjs().add( j, 'day' );
|
|
313
|
-
let time = '12:00 AM';
|
|
314
|
-
if ( currDate.format( 'YYYY-MM-DD' ) == dayjs().format( 'YYYY-MM-DD' ) ) {
|
|
315
|
-
time = dayjs().format( 'hh:mm A' );
|
|
316
|
-
}
|
|
317
|
-
let insertData = { ...taskData, date_string: currDate.format( 'YYYY-MM-DD' ), date_iso: new Date( currDate.format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( `${currDate.format( 'YYYY-MM-DD' )} ${time}`, 'YYYY-MM-DD hh:mm A' ).format() };
|
|
318
|
-
await processedService.updateOne( { date_string: currDate.format( 'YYYY-MM-DD' ), store_id: insertData.store_id, userEmail: insertData.userEmail, planoId: insertData.planoId, sourceCheckList_id: task._id, ...( taskData?.floorId ) ? { floorId: taskData.floorId }:{} }, insertData );
|
|
319
|
-
}
|
|
320
322
|
}
|
|
323
|
+
// for ( let j=0; j<req.body.days; j++ ) {
|
|
324
|
+
let currDate = dayjs();
|
|
325
|
+
let time = dayjs().format( 'hh:mm A' );
|
|
326
|
+
let insertData = { ...taskData, date_string: currDate.format( 'YYYY-MM-DD' ), date_iso: new Date( currDate.format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( `${currDate.format( 'YYYY-MM-DD' )} ${time}`, 'YYYY-MM-DD hh:mm A' ).format() };
|
|
327
|
+
await processedService.updateOne( { date_string: currDate.format( 'YYYY-MM-DD' ), store_id: insertData.store_id, userEmail: insertData.userEmail, planoId: insertData.planoId, planoType: taskData.planoType, ...( taskData?.floorId ) ? { floorId: taskData.floorId }:{} }, insertData );
|
|
328
|
+
// }
|
|
321
329
|
}
|
|
322
|
-
}
|
|
330
|
+
}
|
|
323
331
|
} ) );
|
|
332
|
+
// } ) );
|
|
324
333
|
return res.sendSuccess( 'Task created successfully' );
|
|
325
334
|
}
|
|
326
335
|
} catch ( e ) {
|
|
@@ -528,13 +537,13 @@ export async function updateStatus( req, res ) {
|
|
|
528
537
|
email: req.user.email,
|
|
529
538
|
comment: req.body.comments,
|
|
530
539
|
};
|
|
531
|
-
if ( req.body.status == 'inprogress' ) {
|
|
532
|
-
|
|
533
|
-
}
|
|
540
|
+
// if ( req.body.status == 'inprogress' ) {
|
|
541
|
+
// await processedService.updateOne( { planoId: taskDetails.planoId, userEmail: taskDetails.userEmail, store_id: taskDetails.store_id, ...( taskDetails?.floorId ) ? { floorId: taskDetails.floorId } : {}, date_iso: { $gt: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } }, { checklistStatus: 'inprogress', startTime_string: timeString } );
|
|
542
|
+
// }
|
|
534
543
|
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: req.body.status, ...( req.body.status == 'inprogress' ) ? { startTime_string: timeString } : { submitTime_string: timeString }, comments: { $push: comments } } );
|
|
535
|
-
if ( req.body.status == 'submit' ) {
|
|
536
|
-
|
|
537
|
-
}
|
|
544
|
+
// if ( req.body.status == 'submit' ) {
|
|
545
|
+
// await processedService.deleteMany( { planoId: taskDetails.planoId, userEmail: taskDetails.userEmail, store_id: taskDetails.store_id, ...( taskDetails?.floorId ) ? { floorId: taskDetails.floorId } : {}, date_iso: { $gt: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } } );
|
|
546
|
+
// }
|
|
538
547
|
let vmTask = await planoTaskService.find(
|
|
539
548
|
{
|
|
540
549
|
planoId: new mongoose.Types.ObjectId( taskDetails.planoId ),
|
|
@@ -1019,3 +1028,12 @@ export async function redoTask( req, res ) {
|
|
|
1019
1028
|
return res.sendError( e, 500 );
|
|
1020
1029
|
}
|
|
1021
1030
|
}
|
|
1031
|
+
|
|
1032
|
+
export async function revokeTask( req, res ) {
|
|
1033
|
+
try {
|
|
1034
|
+
await processedService.deleteMany( { checklistName: req.body.checkListName, date_string: dayjs().format( 'YYYY-MM-DD' ), planoId: req.body.planoId, floorId: req.body.floorId } );
|
|
1035
|
+
} catch ( e ) {
|
|
1036
|
+
logger.error( { functionName: 'revokeTask', error: e } );
|
|
1037
|
+
return res.sendError( e, 500 );
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
@@ -110,6 +110,7 @@ export const updateFixtureSchema = joi.object( {
|
|
|
110
110
|
status: joi.string().required(),
|
|
111
111
|
fixtureCapacity: joi.number().required(),
|
|
112
112
|
isBodyEnabled: joi.boolean().required(),
|
|
113
|
+
clientId: joi.string().required(),
|
|
113
114
|
} );
|
|
114
115
|
|
|
115
116
|
export const fixtureIdSchema = joi.object( {
|
|
@@ -20,4 +20,5 @@ managePlanoRouter
|
|
|
20
20
|
.post( '/getGlobalComment', isAllowedSessionHandler, managePlanoController.getGlobalComment )
|
|
21
21
|
.post( '/createRevision', managePlanoController.createPlanoRevision )
|
|
22
22
|
.post( '/getRevisions', managePlanoController.getAllPlanoRevisions )
|
|
23
|
-
.post( '/getRevisionData', managePlanoController.getPlanoRevisionById )
|
|
23
|
+
.post( '/getRevisionData', managePlanoController.getPlanoRevisionById )
|
|
24
|
+
.post( '/getRolloutFeedback', managePlanoController.getRolloutFeedback );
|
|
@@ -51,4 +51,6 @@ storeBuilderRouter
|
|
|
51
51
|
storeBuilderRouter
|
|
52
52
|
.post( '/planoList', isAllowedSessionHandler, storeBuilderController.planoList )
|
|
53
53
|
.get( '/taskDetails', isAllowedSessionHandler, storeBuilderController.getTaskDetails )
|
|
54
|
-
.get( '/getPlanoUser', isAllowedSessionHandler, storeBuilderController.getPlanoUser )
|
|
54
|
+
.get( '/getPlanoUser', isAllowedSessionHandler, storeBuilderController.getPlanoUser )
|
|
55
|
+
.post( '/planoRolloutList', isAllowedSessionHandler, storeBuilderController.getRolloutDetails )
|
|
56
|
+
.get( '/getRolloutTaskDetails', isAllowedSessionHandler, storeBuilderController.getRolloutTaskDetails );
|