tango-app-api-task 3.7.32 → 3.7.33
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/task.controller.js +280 -281
package/package.json
CHANGED
|
@@ -7339,161 +7339,160 @@ export async function AITaskCreation( req, res ) {
|
|
|
7339
7339
|
}
|
|
7340
7340
|
|
|
7341
7341
|
// Check this Task Already Exist////
|
|
7342
|
-
let checkTask = await taskService.findOne( { checkListName: inputBody.taskName } );
|
|
7343
|
-
if ( checkTask ) {
|
|
7344
|
-
let singleInsert = await insertAItaskProcessedTaskCreation( checkTask, inputBody, date, time, storeData, finduser, answer, userAdmin );
|
|
7345
|
-
if ( singleInsert ) {
|
|
7346
|
-
return res.sendSuccess( 'Task created successfully' );
|
|
7347
|
-
} else {
|
|
7348
|
-
return res.sendError( 'something went wrong, please try again', 500 );
|
|
7349
|
-
}
|
|
7350
|
-
} else {
|
|
7351
|
-
let data = {
|
|
7352
|
-
// checkListName: `${inputBody.taskName}(${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.zoneName ? inputBody.zoneName : ''})`,
|
|
7353
|
-
checkListName: inputBody.taskName,
|
|
7354
|
-
checkListDescription: inputBody.taskDescription,
|
|
7355
|
-
createdBy: creator[0]._id,
|
|
7356
|
-
createdByName: creator[0].userName,
|
|
7357
|
-
publish: true,
|
|
7358
|
-
questionCount: 1,
|
|
7359
|
-
storeCount: 1,
|
|
7360
|
-
scheduleDate: date,
|
|
7361
|
-
scheduleEndTime: time,
|
|
7362
|
-
scheduleEndTimeISO: scheduleEndData,
|
|
7363
|
-
priorityType: 'high',
|
|
7364
|
-
client_id: inputBody.clientId,
|
|
7365
|
-
checkListType: 'task',
|
|
7366
|
-
publishDate: new Date(),
|
|
7367
|
-
locationCount: 1,
|
|
7368
|
-
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
7369
|
-
coverage: 'store',
|
|
7370
|
-
checkListFrom: 'api',
|
|
7371
|
-
zoneName: inputBody.zoneName || '',
|
|
7372
|
-
checkListType: 'task',
|
|
7373
|
-
};
|
|
7374
|
-
data['approver'] = userAdmin;
|
|
7375
7342
|
|
|
7376
|
-
|
|
7377
|
-
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
7378
|
-
let optionsResult = [];
|
|
7379
|
-
let optionList = inputBody?.options.split( ',' );
|
|
7380
|
-
for ( let option of optionList ) {
|
|
7381
|
-
let optiondata = {
|
|
7382
|
-
'answer': '',
|
|
7383
|
-
'sopFlag': false,
|
|
7384
|
-
'validation': false,
|
|
7385
|
-
'validationType': '',
|
|
7386
|
-
'referenceImage': [],
|
|
7387
|
-
'runAI': false,
|
|
7388
|
-
'allowUploadfromGallery': false,
|
|
7389
|
-
'descriptivetype': '',
|
|
7390
|
-
'showLinked': false,
|
|
7391
|
-
'linkedQuestion': 0,
|
|
7392
|
-
'nestedQuestion': [],
|
|
7393
|
-
'reason': inputBody.reason,
|
|
7394
|
-
'detectionTime': inputBody.detectionTime,
|
|
7395
|
-
};
|
|
7396
|
-
optiondata.answer = option;
|
|
7397
|
-
optionsResult.push( optiondata );
|
|
7398
|
-
}
|
|
7399
|
-
answer = optionsResult;
|
|
7400
|
-
} else {
|
|
7401
|
-
return res.sendError( 'please enter Valid Options', 500 );
|
|
7402
|
-
}
|
|
7403
|
-
}
|
|
7404
|
-
let clientDetails = await clientService.findOne( { clientId: inputBody?.clientId }, { traxVideoUploadTimeLimit: 1 } );
|
|
7405
|
-
data['videoUploadTimeLimit'] = clientDetails?.traxVideoUploadTimeLimit || 0;
|
|
7406
|
-
let response = await taskService.create( data );
|
|
7407
|
-
if ( response?.approver.length ) {
|
|
7408
|
-
let inputData = [];
|
|
7409
|
-
response?.approver.forEach( ( ele ) => {
|
|
7410
|
-
inputData.push( {
|
|
7411
|
-
userEmail: ele.email,
|
|
7412
|
-
checkListId: response._id,
|
|
7413
|
-
type: 'task',
|
|
7414
|
-
client_id: inputBody.clientId,
|
|
7415
|
-
checkListName: data?.checkListName || '',
|
|
7416
|
-
} );
|
|
7417
|
-
} );
|
|
7418
|
-
await traxApprover.insertMany( inputData );
|
|
7419
|
-
}
|
|
7343
|
+
let taskDetails = await taskService.findOne( { checkListName: inputBody.taskName, client_id: req.body.clientId } );
|
|
7420
7344
|
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7345
|
+
let data = {
|
|
7346
|
+
// checkListName: `${inputBody.taskName}(${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.zoneName ? inputBody.zoneName : ''})`,
|
|
7347
|
+
checkListName: inputBody.taskName,
|
|
7348
|
+
checkListDescription: inputBody.taskDescription,
|
|
7349
|
+
createdBy: creator[0]._id,
|
|
7350
|
+
createdByName: creator[0].userName,
|
|
7351
|
+
publish: true,
|
|
7352
|
+
questionCount: 1,
|
|
7353
|
+
storeCount: 1,
|
|
7354
|
+
scheduleDate: date,
|
|
7355
|
+
scheduleEndTime: time,
|
|
7356
|
+
scheduleEndTimeISO: inputBody['scheduleEndData'],
|
|
7357
|
+
priorityType: 'high',
|
|
7358
|
+
client_id: inputBody.clientId,
|
|
7359
|
+
checkListType: 'task',
|
|
7360
|
+
publishDate: new Date(),
|
|
7361
|
+
locationCount: 1,
|
|
7362
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
7363
|
+
coverage: 'store',
|
|
7364
|
+
checkListFrom: 'api',
|
|
7365
|
+
zoneName: inputBody.zoneName || '',
|
|
7366
|
+
checkListType: 'task',
|
|
7367
|
+
};
|
|
7368
|
+
data['approver'] = userAdmin;
|
|
7369
|
+
|
|
7370
|
+
if ( [ 'multiplechoicesingle', 'multiplechoicemultiple', 'dropdown' ].includes( inputBody?.answerType ) ) {
|
|
7371
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
7372
|
+
let optionsResult = [];
|
|
7373
|
+
let optionList = inputBody?.options.split( ',' );
|
|
7374
|
+
for ( let option of optionList ) {
|
|
7375
|
+
let optiondata = {
|
|
7376
|
+
'answer': '',
|
|
7377
|
+
'sopFlag': false,
|
|
7378
|
+
'validation': false,
|
|
7379
|
+
'validationType': '',
|
|
7380
|
+
'referenceImage': [],
|
|
7427
7381
|
'runAI': false,
|
|
7428
|
-
'runAIDescription': '',
|
|
7429
7382
|
'allowUploadfromGallery': false,
|
|
7430
|
-
'
|
|
7431
|
-
'
|
|
7432
|
-
'
|
|
7433
|
-
'
|
|
7434
|
-
'
|
|
7435
|
-
|
|
7436
|
-
];
|
|
7437
|
-
|
|
7438
|
-
let images = [];
|
|
7439
|
-
for ( let imgpath of req.body.referenceImage ) {
|
|
7440
|
-
let configURL = JSON.parse( process.env.BUCKET );
|
|
7441
|
-
let inputData = {
|
|
7442
|
-
Bucket: configURL.aiTraxoutput,
|
|
7443
|
-
Key: imgpath,
|
|
7444
|
-
};
|
|
7445
|
-
let output = await getObject( inputData );
|
|
7446
|
-
// / Check Bucket
|
|
7447
|
-
let image = {
|
|
7448
|
-
data: output.Body,
|
|
7449
|
-
name: imgpath,
|
|
7450
|
-
mimetype: output.ContentType,
|
|
7383
|
+
'descriptivetype': '',
|
|
7384
|
+
'showLinked': false,
|
|
7385
|
+
'linkedQuestion': 0,
|
|
7386
|
+
'nestedQuestion': [],
|
|
7387
|
+
'reason': inputBody.reason,
|
|
7388
|
+
'detectionTime': inputBody.detectionTime,
|
|
7451
7389
|
};
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
let url = imgUrl.split( '/' );
|
|
7455
|
-
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
7456
|
-
url.splice( 0, 3 );
|
|
7457
|
-
}
|
|
7458
|
-
images.push( url.join( '/' ) );
|
|
7390
|
+
optiondata.answer = option;
|
|
7391
|
+
optionsResult.push( optiondata );
|
|
7459
7392
|
}
|
|
7460
|
-
|
|
7393
|
+
answer = optionsResult;
|
|
7394
|
+
} else {
|
|
7395
|
+
return res.sendError( 'please enter Valid Options', 500 );
|
|
7396
|
+
}
|
|
7397
|
+
}
|
|
7398
|
+
let clientDetails = await clientService.findOne( { clientId: inputBody?.clientId }, { traxVideoUploadTimeLimit: 1 } );
|
|
7399
|
+
data['videoUploadTimeLimit'] = clientDetails?.traxVideoUploadTimeLimit || 0;
|
|
7400
|
+
let response = await taskService.updateOne( { checkListName: inputBody.taskName, client_id: req.body.clientId }, data );
|
|
7401
|
+
if ( inputBody.approver.length ) {
|
|
7402
|
+
let inputData = [];
|
|
7403
|
+
inputBody.approver.forEach( ( ele ) => {
|
|
7404
|
+
inputData.push( {
|
|
7405
|
+
userEmail: ele.email,
|
|
7406
|
+
checkListId: response?.upsertedId ?? taskDetails._id,
|
|
7407
|
+
type: 'task',
|
|
7408
|
+
client_id: inputBody.clientId,
|
|
7409
|
+
checkListName: data?.checkListName || '',
|
|
7410
|
+
} );
|
|
7411
|
+
} );
|
|
7412
|
+
await traxApprover.insertMany( inputData );
|
|
7413
|
+
}
|
|
7461
7414
|
|
|
7462
|
-
|
|
7463
|
-
|
|
7415
|
+
if ( response?.upsertedId ?? taskDetails._id ) {
|
|
7416
|
+
let question = [
|
|
7417
|
+
{
|
|
7418
|
+
'qno': 1,
|
|
7419
|
+
'qname': inputBody.question,
|
|
7420
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
7421
|
+
'runAI': false,
|
|
7422
|
+
'runAIDescription': '',
|
|
7423
|
+
'allowUploadfromGallery': false,
|
|
7424
|
+
'linkType': false,
|
|
7425
|
+
'questionReferenceImage': [],
|
|
7426
|
+
'answers': answer,
|
|
7427
|
+
'descriptivetype': 'text',
|
|
7428
|
+
'allowMultiple': inputBody.multi,
|
|
7429
|
+
},
|
|
7430
|
+
];
|
|
7431
|
+
|
|
7432
|
+
let images = [];
|
|
7433
|
+
for ( let imgpath of req.body.referenceImage ) {
|
|
7434
|
+
let configURL = JSON.parse( process.env.BUCKET );
|
|
7435
|
+
let inputData = {
|
|
7436
|
+
Bucket: configURL.aiTraxoutput,
|
|
7437
|
+
Key: imgpath,
|
|
7438
|
+
};
|
|
7439
|
+
let output = await getObject( inputData );
|
|
7440
|
+
// / Check Bucket
|
|
7441
|
+
let image = {
|
|
7442
|
+
data: output.Body,
|
|
7443
|
+
name: imgpath,
|
|
7444
|
+
mimetype: output.ContentType,
|
|
7445
|
+
};
|
|
7446
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
7447
|
+
let imgUrl = decodeURIComponent( uplaodedImage?.imgUrl.split( '?' )[0] );
|
|
7448
|
+
let url = imgUrl.split( '/' );
|
|
7449
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
7450
|
+
url.splice( 0, 3 );
|
|
7464
7451
|
}
|
|
7452
|
+
images.push( url.join( '/' ) );
|
|
7453
|
+
}
|
|
7454
|
+
question[0].questionReferenceImage = images;
|
|
7465
7455
|
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7456
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
7457
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
7458
|
+
}
|
|
7459
|
+
|
|
7460
|
+
question = {
|
|
7461
|
+
checkListId: response?.upsertedId ?? taskDetails._id,
|
|
7462
|
+
question: question,
|
|
7463
|
+
section: 'Section 1',
|
|
7464
|
+
checkList: data.checkListName,
|
|
7465
|
+
client_id: inputBody.clientId,
|
|
7466
|
+
};
|
|
7467
|
+
|
|
7468
|
+
if ( taskDetails ) {
|
|
7469
|
+
await taskQuestionService.deleteMany( { checkListId: taskDetails._id } );
|
|
7470
|
+
}
|
|
7471
|
+
await taskQuestionService.create( question );
|
|
7472
|
+
let userDetails = [];
|
|
7473
|
+
finduser.forEach( ( ele ) => {
|
|
7474
|
+
userDetails = {
|
|
7475
|
+
userName: ele.userName,
|
|
7476
|
+
userEmail: ele.userEmail,
|
|
7477
|
+
store_id: storeData.storeId,
|
|
7478
|
+
storeName: storeData.storeName,
|
|
7479
|
+
city: storeData?.storeProfile?.city,
|
|
7480
|
+
checkFlag: true,
|
|
7481
|
+
checkListId: response?.upsertedId ?? taskDetails._id,
|
|
7482
|
+
checkListName: data.checkListName,
|
|
7471
7483
|
client_id: inputBody.clientId,
|
|
7484
|
+
userId: ele.userId,
|
|
7485
|
+
assignId: storeData?._id,
|
|
7486
|
+
country: storeData?.storeProfile?.country,
|
|
7487
|
+
state: storeData?.storeProfile?.state,
|
|
7472
7488
|
};
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
userDetails = {
|
|
7477
|
-
userName: ele.userName,
|
|
7478
|
-
userEmail: ele.userEmail,
|
|
7479
|
-
store_id: storeData.storeId,
|
|
7480
|
-
storeName: storeData.storeName,
|
|
7481
|
-
city: storeData?.storeProfile?.city,
|
|
7482
|
-
checkFlag: true,
|
|
7483
|
-
checkListId: response?._id,
|
|
7484
|
-
checkListName: data.checkListName,
|
|
7485
|
-
client_id: inputBody.clientId,
|
|
7486
|
-
userId: ele.userId,
|
|
7487
|
-
assignId: storeData?._id,
|
|
7488
|
-
country: storeData?.storeProfile?.country,
|
|
7489
|
-
state: storeData?.storeProfile?.state,
|
|
7490
|
-
};
|
|
7491
|
-
} );
|
|
7492
|
-
|
|
7493
|
-
await taskAssignService.insertMany( userDetails );
|
|
7494
|
-
await insertSingleProcessData( response?._id, false, { aiTask: true, aiType: inputBody.aiType } );
|
|
7495
|
-
return res.sendSuccess( 'Task created successfully' );
|
|
7489
|
+
} );
|
|
7490
|
+
if ( taskDetails ) {
|
|
7491
|
+
await taskAssignService.deleteMany( { checkListId: taskDetails._id } );
|
|
7496
7492
|
}
|
|
7493
|
+
await taskAssignService.insertMany( userDetails );
|
|
7494
|
+
await insertSingleProcessData( response?.upsertedId ?? taskDetails._id, false, { aiTask: true, aiType: inputBody.aiType } );
|
|
7495
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
7497
7496
|
}
|
|
7498
7497
|
} catch ( e ) {
|
|
7499
7498
|
console.log( 'e =>', e );
|
|
@@ -7502,144 +7501,144 @@ export async function AITaskCreation( req, res ) {
|
|
|
7502
7501
|
}
|
|
7503
7502
|
}
|
|
7504
7503
|
|
|
7505
|
-
async function insertAItaskProcessedTaskCreation( checkTask, inputBody, date, time, storeDetails, finduser, answer, userAdmin ) {
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
}
|
|
7504
|
+
// async function insertAItaskProcessedTaskCreation( checkTask, inputBody, date, time, storeDetails, finduser, answer, userAdmin ) {
|
|
7505
|
+
// try {
|
|
7506
|
+
// let getquestion = await taskQuestionService.findOne( { checkListId: checkTask._id } );
|
|
7507
|
+
// let getolddata = await taskProcessedService.findOne( { sourceCheckList_id: checkTask._id } );
|
|
7508
|
+
// let getoldConfigdata = await taskService.findOne( { _id: checkTask._id } );
|
|
7509
|
+
|
|
7510
|
+
// const uniqueUsers = mergeUnique( getoldConfigdata.approver, userAdmin, '_id' );
|
|
7511
|
+
// // Question Patten Making
|
|
7512
|
+
// let question = [
|
|
7513
|
+
// {
|
|
7514
|
+
// 'qno': 1,
|
|
7515
|
+
// 'qname': inputBody.question,
|
|
7516
|
+
// 'answerType': inputBody?.answerType || 'yes/no',
|
|
7517
|
+
// 'runAI': false,
|
|
7518
|
+
// 'runAIDescription': '',
|
|
7519
|
+
// 'allowUploadfromGallery': false,
|
|
7520
|
+
// 'linkType': false,
|
|
7521
|
+
// 'questionReferenceImage': [],
|
|
7522
|
+
// 'answers': answer,
|
|
7523
|
+
// 'descriptivetype': 'text',
|
|
7524
|
+
// 'allowMultiple': inputBody.multi,
|
|
7525
|
+
// },
|
|
7526
|
+
// ];
|
|
7527
|
+
|
|
7528
|
+
// let images = [];
|
|
7529
|
+
// for ( let imgpath of inputBody.referenceImage ) {
|
|
7530
|
+
// let configURL = JSON.parse( process.env.BUCKET );
|
|
7531
|
+
// let inputData = {
|
|
7532
|
+
// Bucket: configURL.aiTraxoutput,
|
|
7533
|
+
// Key: imgpath,
|
|
7534
|
+
// };
|
|
7535
|
+
// let output = await getObject( inputData );
|
|
7536
|
+
// let image = {
|
|
7537
|
+
// data: output.Body,
|
|
7538
|
+
// name: imgpath,
|
|
7539
|
+
// mimetype: output.ContentType,
|
|
7540
|
+
// };
|
|
7541
|
+
// let uplaodedImage = await uploadmultiImage( image );
|
|
7542
|
+
// let imgUrl = decodeURIComponent( uplaodedImage?.imgUrl.split( '?' )[0] );
|
|
7543
|
+
// let url = imgUrl.split( '/' );
|
|
7544
|
+
// if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
7545
|
+
// url.splice( 0, 3 );
|
|
7546
|
+
// }
|
|
7547
|
+
// images.push( url.join( '/' ) );
|
|
7548
|
+
// }
|
|
7549
|
+
// question[0].questionReferenceImage = images;
|
|
7550
|
+
|
|
7551
|
+
// if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
7552
|
+
// answer[0].referenceImage = question[0].questionReferenceImage;
|
|
7553
|
+
// }
|
|
7554
|
+
|
|
7555
|
+
// let questions = {
|
|
7556
|
+
// questions: question,
|
|
7557
|
+
// sectionName: getquestion.section,
|
|
7558
|
+
// section_id: getquestion._id,
|
|
7559
|
+
// };
|
|
7560
|
+
|
|
7561
|
+
// let oldData = getolddata.toObject();
|
|
7562
|
+
// delete oldData._id;
|
|
7563
|
+
// delete oldData.submitTime_string;
|
|
7564
|
+
// delete oldData.startTime_string;
|
|
7565
|
+
// delete oldData.submitTime;
|
|
7566
|
+
// delete oldData.startTime;
|
|
7567
|
+
// delete oldData.submitMobileTime;
|
|
7568
|
+
// delete oldData.startMobileTime;
|
|
7569
|
+
// oldData.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
|
|
7570
|
+
// oldData.date_string = dayjs( date ).format( 'YYYY-MM-DD' );
|
|
7571
|
+
// oldData.scheduleStartTime_iso = date;
|
|
7572
|
+
// oldData.scheduleEndTime_iso = dayjs.utc( inputBody.scheduleEndData, 'YYYY-MM-DD hh:mm A' ).format();
|
|
7573
|
+
// oldData.scheduleEndTime = dayjs.utc( inputBody.scheduleEndData, 'YYYY-MM-DD hh:mm A' ).format( 'hh:mm A' );
|
|
7574
|
+
// oldData.scheduleStartTime = dayjs.utc().format( 'hh:mm A' );
|
|
7575
|
+
// oldData.store_id = storeDetails.storeId;
|
|
7576
|
+
// oldData.storeName = storeDetails.storeName;
|
|
7577
|
+
// oldData.country = storeDetails.storeProfile.country;
|
|
7578
|
+
// oldData.checklistStatus = 'open';
|
|
7579
|
+
// oldData.timeFlagStatus = true;
|
|
7580
|
+
// oldData.checkListFrom = 'api';
|
|
7581
|
+
// oldData.createdAt = new Date();
|
|
7582
|
+
// oldData.updatedAt = new Date();
|
|
7583
|
+
// oldData.approvalStatus = false;
|
|
7584
|
+
// oldData.approvalEnable = true;
|
|
7585
|
+
// oldData.approvalTime = '';
|
|
7586
|
+
// oldData.approvalTime_string = '';
|
|
7587
|
+
// oldData.redoStatus = false;
|
|
7588
|
+
// oldData.approvalByName = '';
|
|
7589
|
+
// oldData.approvalByEmail = '';
|
|
7590
|
+
// oldData.questionAnswers = [ questions ];
|
|
7591
|
+
// oldData.zoneName = inputBody.zoneName || '';
|
|
7592
|
+
// oldData.checkListType = 'task' || '';
|
|
7593
|
+
// if ( inputBody.aiType ) {
|
|
7594
|
+
// oldData.aiType = inputBody.aiType;
|
|
7595
|
+
// }
|
|
7596
|
+
// let configDetails = await taskProcessedConfigService.insert( oldData );
|
|
7597
|
+
// let insertData = [];
|
|
7598
|
+
// finduser.forEach( ( user ) => {
|
|
7599
|
+
// let newData = { ...oldData };
|
|
7600
|
+
// newData.userId = user.userId;
|
|
7601
|
+
// newData.userName = user.userName;
|
|
7602
|
+
// newData.userEmail = user.userEmail;
|
|
7603
|
+
// newData.checkListId = configDetails._id;
|
|
7604
|
+
// insertData.push( { ...newData } );
|
|
7605
|
+
// } );
|
|
7606
|
+
// let insertprocessdata = await taskProcessedService.insertMany( insertData );
|
|
7607
|
+
// console.log( '🚀 ~ insertAItaskSingleProcessedTask ~ insertprocessdata:', insertprocessdata );
|
|
7608
|
+
// if ( insertprocessdata ) {
|
|
7609
|
+
// if ( uniqueUsers && uniqueUsers.length>0 ) {
|
|
7610
|
+
// // updated Task Approver//
|
|
7611
|
+
// await taskService.updateOne( { _id: oldData.sourceCheckList_id }, { approver: uniqueUsers } );
|
|
7612
|
+
// for ( let k = 0; k < uniqueUsers.length; k++ ) {
|
|
7613
|
+
// let checkapprover = {
|
|
7614
|
+
// userEmail: uniqueUsers[k].email,
|
|
7615
|
+
// checkListId: oldData.sourceCheckList_id,
|
|
7616
|
+
// type: 'task',
|
|
7617
|
+
// client_id: oldData.client_id,
|
|
7618
|
+
// isDeleted: false,
|
|
7619
|
+
// };
|
|
7620
|
+
// let getapproverData = await traxApprover.findOne( checkapprover );
|
|
7621
|
+
// if ( !getapproverData ) {
|
|
7622
|
+
// let inserApproverData = {
|
|
7623
|
+
// userEmail: uniqueUsers[k].email,
|
|
7624
|
+
// checkListId: oldData.sourceCheckList_id,
|
|
7625
|
+
// type: 'task',
|
|
7626
|
+
// client_id: oldData.client_id,
|
|
7627
|
+
// isDeleted: false,
|
|
7628
|
+
// };
|
|
7629
|
+
// await traxApprover.create( inserApproverData );
|
|
7630
|
+
// }
|
|
7631
|
+
// }
|
|
7632
|
+
// }
|
|
7633
|
+
// return true;
|
|
7634
|
+
// } else {
|
|
7635
|
+
// return false;
|
|
7636
|
+
// }
|
|
7637
|
+
// } catch ( error ) {
|
|
7638
|
+
// logger.error( { error: error, function: 'insertSingleProcessedTask' } );
|
|
7639
|
+
// return false;
|
|
7640
|
+
// }
|
|
7641
|
+
// }
|
|
7643
7642
|
|
|
7644
7643
|
function mergeUnique( arr1 = [], arr2 = [], key = '_id' ) {
|
|
7645
7644
|
const merged = [ ...arr1, ...arr2 ];
|