tango-app-api-task 3.2.1-beta-16 → 3.2.1-beta-17
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 +243 -36
- package/src/dtos/task.dto.js +19 -4
- package/src/routes/task.routes.js +3 -2
package/package.json
CHANGED
|
@@ -1420,9 +1420,9 @@ export async function createChecklistTask( req, res ) {
|
|
|
1420
1420
|
body: JSON.stringify( params ),
|
|
1421
1421
|
};
|
|
1422
1422
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1423
|
-
|
|
1423
|
+
|
|
1424
1424
|
let searchResponse = await fetch( url.redoChecklist, requestOptions );
|
|
1425
|
-
|
|
1425
|
+
|
|
1426
1426
|
|
|
1427
1427
|
if ( !searchResponse.ok ) {
|
|
1428
1428
|
return res.sendError( 'Something went wrong', 500 );
|
|
@@ -1456,7 +1456,7 @@ export async function approveTask( req, res ) {
|
|
|
1456
1456
|
let updateResponse = await taskProcessedService.updateMany( { _id: { $in: idList } }, { approvalStatus: true } );
|
|
1457
1457
|
if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
|
|
1458
1458
|
let inputstores = taskDetails.filter( ( data ) => data.checklistStatus == 'submit' );
|
|
1459
|
-
|
|
1459
|
+
|
|
1460
1460
|
let params = {
|
|
1461
1461
|
'payload': {
|
|
1462
1462
|
sourceCheckList_id: req.body.sourceCheckList_id,
|
|
@@ -1468,7 +1468,7 @@ export async function approveTask( req, res ) {
|
|
|
1468
1468
|
approvalStatus: true,
|
|
1469
1469
|
},
|
|
1470
1470
|
};
|
|
1471
|
-
|
|
1471
|
+
|
|
1472
1472
|
|
|
1473
1473
|
const requestOptions = {
|
|
1474
1474
|
method: 'POST',
|
|
@@ -1478,9 +1478,9 @@ export async function approveTask( req, res ) {
|
|
|
1478
1478
|
body: JSON.stringify( params ),
|
|
1479
1479
|
};
|
|
1480
1480
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1481
|
-
|
|
1481
|
+
|
|
1482
1482
|
let searchResponse = await fetch( url.approveTask, requestOptions );
|
|
1483
|
-
|
|
1483
|
+
|
|
1484
1484
|
if ( searchResponse.ok ) {
|
|
1485
1485
|
let pendingstores = taskDetails.filter( ( data ) => data.checklistStatus != 'submit' );
|
|
1486
1486
|
if ( pendingstores && pendingstores.length > 0 ) {
|
|
@@ -1526,7 +1526,7 @@ export async function redoTask( req, res ) {
|
|
|
1526
1526
|
}
|
|
1527
1527
|
let data = { ...question[sectionIndex].questions[req.body.payload.qno - 1], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
|
|
1528
1528
|
let userAnswer = data.userAnswer;
|
|
1529
|
-
|
|
1529
|
+
|
|
1530
1530
|
question[sectionIndex].questions[req.body.payload.qno - 1] = data;
|
|
1531
1531
|
question[sectionIndex].questions[req.body.payload.qno - 1].remarks = '';
|
|
1532
1532
|
question[sectionIndex].questions[req.body.payload.qno - 1].userAnswer = [];
|
|
@@ -1567,7 +1567,7 @@ export async function redoTask( req, res ) {
|
|
|
1567
1567
|
submitedBy: taskDetails.userName,
|
|
1568
1568
|
submitTime: taskDetails.submitTime,
|
|
1569
1569
|
};
|
|
1570
|
-
|
|
1570
|
+
|
|
1571
1571
|
await checklistLogs.create( data );
|
|
1572
1572
|
const requestOptions = {
|
|
1573
1573
|
method: 'POST',
|
|
@@ -1762,7 +1762,6 @@ export async function approvalstatus( req, res ) {
|
|
|
1762
1762
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1763
1763
|
let resultData = await LamdaServiceCall( url.approvalstatustask, req.body );
|
|
1764
1764
|
if ( resultData ) {
|
|
1765
|
-
console.log( resultData.status_code );
|
|
1766
1765
|
if ( resultData.status_code == '200' ) {
|
|
1767
1766
|
return res.sendSuccess( resultData );
|
|
1768
1767
|
}
|
|
@@ -1775,7 +1774,7 @@ export async function approvalstatus( req, res ) {
|
|
|
1775
1774
|
|
|
1776
1775
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1777
1776
|
let resultData = await LamdaServiceCall( url.approvalstatustask, req.body );
|
|
1778
|
-
|
|
1777
|
+
|
|
1779
1778
|
if ( resultData ) {
|
|
1780
1779
|
if ( resultData.status_code == '200' ) {
|
|
1781
1780
|
return res.sendSuccess( resultData );
|
|
@@ -2101,11 +2100,9 @@ export async function teamMigrations( req, res ) {
|
|
|
2101
2100
|
store: findStore._id,
|
|
2102
2101
|
},
|
|
2103
2102
|
];
|
|
2104
|
-
console.log( user.userEmail );
|
|
2105
|
-
console.log( '***********' );
|
|
2106
|
-
console.log( updateStore );
|
|
2107
2103
|
let updateUser = await userService.updateOne( { email: user.userEmail }, { assignedStores: updateStore } );
|
|
2108
2104
|
console.log( updateUser );
|
|
2105
|
+
|
|
2109
2106
|
let leamexits = await userService.findOne( { email: user.AomMailId } );
|
|
2110
2107
|
if ( leamexits ) {
|
|
2111
2108
|
let teamsExist = await findOneTeams( { 'teamName': user.AomUserName } );
|
|
@@ -2232,7 +2229,7 @@ export async function createAiChecklist( req, res ) {
|
|
|
2232
2229
|
}
|
|
2233
2230
|
|
|
2234
2231
|
let userAdmin = await userService.findOne( { clientId: inputBody.clientId, role: 'superadmin', isActive: true } );
|
|
2235
|
-
|
|
2232
|
+
|
|
2236
2233
|
|
|
2237
2234
|
let data = {
|
|
2238
2235
|
checkListName: `${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`,
|
|
@@ -2356,10 +2353,10 @@ export async function createAiChecklist( req, res ) {
|
|
|
2356
2353
|
return res.sendError( e, 500 );
|
|
2357
2354
|
}
|
|
2358
2355
|
}
|
|
2359
|
-
export async function
|
|
2356
|
+
export async function StoreHygienetask( req, res ) {
|
|
2360
2357
|
try {
|
|
2361
2358
|
let inputBody = req.body;
|
|
2362
|
-
|
|
2359
|
+
|
|
2363
2360
|
inputBody.clientId = 11;
|
|
2364
2361
|
inputBody.taskDescription = '';
|
|
2365
2362
|
let userId;
|
|
@@ -2375,7 +2372,7 @@ export async function createAiTaskNew( req, res ) {
|
|
|
2375
2372
|
if ( !finduser ) {
|
|
2376
2373
|
return res.sendError( 'No user Found For this store', 500 );
|
|
2377
2374
|
}
|
|
2378
|
-
|
|
2375
|
+
|
|
2379
2376
|
userId = finduser.userId;
|
|
2380
2377
|
inputBody.userName = finduser.userName;
|
|
2381
2378
|
inputBody.userEmail = finduser.userEmail;
|
|
@@ -2420,14 +2417,11 @@ export async function createAiTaskNew( req, res ) {
|
|
|
2420
2417
|
return res.sendError( 'Invalid Creator Details', 500 );
|
|
2421
2418
|
}
|
|
2422
2419
|
|
|
2423
|
-
console.log( req.body.referenceImage );
|
|
2424
|
-
req.body.referenceImage = req.body.referenceImage.split( ',' );
|
|
2425
|
-
console.log( req.body.referenceImage );
|
|
2426
2420
|
if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
|
|
2427
2421
|
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
2428
2422
|
}
|
|
2429
2423
|
let data = {
|
|
2430
|
-
checkListName: `${inputBody.taskName}
|
|
2424
|
+
checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.count})`,
|
|
2431
2425
|
checkListDescription: inputBody.taskDescription,
|
|
2432
2426
|
createdBy: creator[0]._id,
|
|
2433
2427
|
createdByName: creator[0].userName,
|
|
@@ -2523,9 +2517,8 @@ export async function createAiTaskNew( req, res ) {
|
|
|
2523
2517
|
Key: imgpath,
|
|
2524
2518
|
};
|
|
2525
2519
|
|
|
2526
|
-
|
|
2520
|
+
|
|
2527
2521
|
let output = await getObject( inputData );
|
|
2528
|
-
console.log( output );
|
|
2529
2522
|
|
|
2530
2523
|
|
|
2531
2524
|
let image = {
|
|
@@ -2534,7 +2527,7 @@ export async function createAiTaskNew( req, res ) {
|
|
|
2534
2527
|
mimetype: output.ContentType,
|
|
2535
2528
|
};
|
|
2536
2529
|
let uplaodedImage = await uploadmultiImage( image );
|
|
2537
|
-
|
|
2530
|
+
|
|
2538
2531
|
let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
|
|
2539
2532
|
let url = imgUrl.split( '/' );
|
|
2540
2533
|
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
@@ -2575,7 +2568,224 @@ export async function createAiTaskNew( req, res ) {
|
|
|
2575
2568
|
return res.sendSuccess( 'Task created successfully' );
|
|
2576
2569
|
}
|
|
2577
2570
|
} catch ( e ) {
|
|
2578
|
-
logger.error( { function: '
|
|
2571
|
+
logger.error( { function: 'StoreHygienetask', error: e } );
|
|
2572
|
+
return res.sendError( e, 500 );
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
export async function eyeTesttask( req, res ) {
|
|
2576
|
+
try {
|
|
2577
|
+
let inputBody = req.body;
|
|
2578
|
+
inputBody.clientId = 11;
|
|
2579
|
+
inputBody.taskDescription = '';
|
|
2580
|
+
let userId;
|
|
2581
|
+
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
|
|
2582
|
+
if ( !storeDetails ) {
|
|
2583
|
+
return res.sendError( 'Store Not Found', 500 );
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
2587
|
+
let checklistId = url.dailystoreChecklistId;
|
|
2588
|
+
let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
|
|
2589
|
+
|
|
2590
|
+
if ( !finduser ) {
|
|
2591
|
+
return res.sendError( 'No user Found For this store', 500 );
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
userId = finduser.userId;
|
|
2595
|
+
inputBody.userName = finduser.userName;
|
|
2596
|
+
inputBody.userEmail = finduser.userEmail;
|
|
2597
|
+
|
|
2598
|
+
|
|
2599
|
+
let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
|
|
2600
|
+
|
|
2601
|
+
inputBody.approver = '';
|
|
2602
|
+
for ( let team of teamList ) {
|
|
2603
|
+
for ( let user of team.Teamlead ) {
|
|
2604
|
+
inputBody.approver = user.email + ',' + inputBody.approver;
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
inputBody.approver = inputBody.approver.replace( /,$/, '' );
|
|
2608
|
+
|
|
2609
|
+
|
|
2610
|
+
// let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
2611
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
2612
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
2613
|
+
// let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
2614
|
+
// if ( userDetails&&userDetails.fcmToken ) {
|
|
2615
|
+
// const fcmToken = userDetails.fcmToken;
|
|
2616
|
+
// await sendPushNotification( title, description, fcmToken );
|
|
2617
|
+
// }
|
|
2618
|
+
const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
|
|
2619
|
+
const currentTime = dayjs.utc();
|
|
2620
|
+
if ( inputDateTime.isBefore( currentTime ) ) {
|
|
2621
|
+
return res.sendError( 'The input date-time is before the current time.', 500 );
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
let approverList = inputBody?.approver.split( ',' );
|
|
2625
|
+
|
|
2626
|
+
|
|
2627
|
+
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
2628
|
+
|
|
2629
|
+
if ( userAdmin && userAdmin.length === 0 ) {
|
|
2630
|
+
userAdmin = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
let creator = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true } );
|
|
2634
|
+
if ( creator && creator.length === 0 ) {
|
|
2635
|
+
return res.sendError( 'Invalid Creator Details', 500 );
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
|
|
2639
|
+
if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
|
|
2640
|
+
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
2641
|
+
}
|
|
2642
|
+
let data = {
|
|
2643
|
+
checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.count})`,
|
|
2644
|
+
checkListDescription: inputBody.taskDescription,
|
|
2645
|
+
createdBy: creator[0]._id,
|
|
2646
|
+
createdByName: creator[0].userName,
|
|
2647
|
+
publish: true,
|
|
2648
|
+
questionCount: 1,
|
|
2649
|
+
storeCount: 1,
|
|
2650
|
+
scheduleDate: date,
|
|
2651
|
+
scheduleEndTime: time,
|
|
2652
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
2653
|
+
priorityType: 'high',
|
|
2654
|
+
client_id: inputBody.clientId,
|
|
2655
|
+
checkListType: 'task',
|
|
2656
|
+
publishDate: new Date(),
|
|
2657
|
+
locationCount: 1,
|
|
2658
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
2659
|
+
};
|
|
2660
|
+
|
|
2661
|
+
|
|
2662
|
+
data['approver'] = userAdmin;
|
|
2663
|
+
|
|
2664
|
+
|
|
2665
|
+
let answer = await findAnswer( inputBody?.answerType );
|
|
2666
|
+
if ( answer.length == 0 ) {
|
|
2667
|
+
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
2668
|
+
}
|
|
2669
|
+
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
2670
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
2671
|
+
let optionsResult = [];
|
|
2672
|
+
let optionList = inputBody?.options.split( ',' );
|
|
2673
|
+
for ( let option of optionList ) {
|
|
2674
|
+
let optiondata = {
|
|
2675
|
+
'answer': '',
|
|
2676
|
+
'sopFlag': false,
|
|
2677
|
+
'validation': false,
|
|
2678
|
+
'validationType': '',
|
|
2679
|
+
'referenceImage': [],
|
|
2680
|
+
'runAI': false,
|
|
2681
|
+
'allowUploadfromGallery': false,
|
|
2682
|
+
'descriptivetype': '',
|
|
2683
|
+
'showLinked': false,
|
|
2684
|
+
'linkedQuestion': 0,
|
|
2685
|
+
'nestedQuestion': [],
|
|
2686
|
+
};
|
|
2687
|
+
optiondata.answer = option;
|
|
2688
|
+
optionsResult.push( optiondata );
|
|
2689
|
+
}
|
|
2690
|
+
answer = optionsResult;
|
|
2691
|
+
} else {
|
|
2692
|
+
return res.sendError( 'please enter Valid Options', 500 );
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
|
|
2697
|
+
let response = await taskService.create( data );
|
|
2698
|
+
if ( response?.approver.length ) {
|
|
2699
|
+
let inputData = [];
|
|
2700
|
+
response?.approver.forEach( ( ele ) => {
|
|
2701
|
+
inputData.push( {
|
|
2702
|
+
userEmail: ele.email,
|
|
2703
|
+
checkListId: response._id,
|
|
2704
|
+
type: 'task',
|
|
2705
|
+
client_id: inputBody.clientId,
|
|
2706
|
+
checkListName: data?.checkListName || '',
|
|
2707
|
+
} );
|
|
2708
|
+
} );
|
|
2709
|
+
|
|
2710
|
+
await traxApprover.insertMany( inputData );
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
if ( response?._id ) {
|
|
2714
|
+
let question = [
|
|
2715
|
+
{
|
|
2716
|
+
'qno': 1,
|
|
2717
|
+
'qname': inputBody.question,
|
|
2718
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
2719
|
+
'runAI': false,
|
|
2720
|
+
'runAIDescription': '',
|
|
2721
|
+
'allowUploadfromGallery': false,
|
|
2722
|
+
'linkType': false,
|
|
2723
|
+
'questionReferenceImage': [],
|
|
2724
|
+
'answers': answer,
|
|
2725
|
+
'descriptivetype': 'text',
|
|
2726
|
+
},
|
|
2727
|
+
];
|
|
2728
|
+
|
|
2729
|
+
|
|
2730
|
+
if ( req.files && req.files.referenceImage && req.files.referenceImage.length ) {
|
|
2731
|
+
let images = [];
|
|
2732
|
+
|
|
2733
|
+
|
|
2734
|
+
for ( let image of req.files.referenceImage ) {
|
|
2735
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
2736
|
+
let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
|
|
2737
|
+
let url = imgUrl.split( '/' );
|
|
2738
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
2739
|
+
url.splice( 0, 3 );
|
|
2740
|
+
}
|
|
2741
|
+
images.push( url.join( '/' ) );
|
|
2742
|
+
}
|
|
2743
|
+
question[0].questionReferenceImage = images;
|
|
2744
|
+
} else {
|
|
2745
|
+
let images = [];
|
|
2746
|
+
let uplaodedImage = await uploadmultiImage( req.files.referenceImage );
|
|
2747
|
+
let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
|
|
2748
|
+
let url = imgUrl.split( '/' );
|
|
2749
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
2750
|
+
url.splice( 0, 3 );
|
|
2751
|
+
}
|
|
2752
|
+
images.push( url.join( '/' ) );
|
|
2753
|
+
|
|
2754
|
+
question[0].questionReferenceImage = images;
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
2758
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
|
|
2762
|
+
question = {
|
|
2763
|
+
checkListId: response?._id,
|
|
2764
|
+
question: question,
|
|
2765
|
+
section: 'Section 1',
|
|
2766
|
+
checkList: data.checkListName,
|
|
2767
|
+
client_id: inputBody.clientId,
|
|
2768
|
+
};
|
|
2769
|
+
await taskQuestionService.create( question );
|
|
2770
|
+
|
|
2771
|
+
let userDetails = {
|
|
2772
|
+
userName: inputBody.userName,
|
|
2773
|
+
userEmail: inputBody.userEmail,
|
|
2774
|
+
store_id: storeDetails.storeId,
|
|
2775
|
+
storeName: storeDetails.storeName,
|
|
2776
|
+
city: storeDetails?.storeProfile?.city,
|
|
2777
|
+
checkFlag: true,
|
|
2778
|
+
checkListId: response?._id,
|
|
2779
|
+
checkListName: data.checkListName,
|
|
2780
|
+
client_id: inputBody.clientId,
|
|
2781
|
+
userId: userId,
|
|
2782
|
+
};
|
|
2783
|
+
await taskAssignService.create( userDetails );
|
|
2784
|
+
await insertSingleProcessData( response?._id );
|
|
2785
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
2786
|
+
}
|
|
2787
|
+
} catch ( e ) {
|
|
2788
|
+
logger.error( { function: 'eyeTesttask', error: e } );
|
|
2579
2789
|
return res.sendError( e, 500 );
|
|
2580
2790
|
}
|
|
2581
2791
|
}
|
|
@@ -2589,11 +2799,11 @@ export async function createAiTask( req, res ) {
|
|
|
2589
2799
|
if ( !storeDetails ) {
|
|
2590
2800
|
return res.sendError( 'Store Not Found', 500 );
|
|
2591
2801
|
}
|
|
2592
|
-
|
|
2802
|
+
|
|
2593
2803
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
2594
2804
|
let checklistId = url.dailystoreChecklistId;
|
|
2595
2805
|
let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
|
|
2596
|
-
|
|
2806
|
+
|
|
2597
2807
|
if ( !finduser ) {
|
|
2598
2808
|
return res.sendError( 'No user Found For this store', 500 );
|
|
2599
2809
|
}
|
|
@@ -2617,10 +2827,10 @@ export async function createAiTask( req, res ) {
|
|
|
2617
2827
|
}
|
|
2618
2828
|
|
|
2619
2829
|
let approverList = inputBody?.approver.split( ',' );
|
|
2620
|
-
|
|
2830
|
+
|
|
2621
2831
|
|
|
2622
2832
|
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
2623
|
-
|
|
2833
|
+
|
|
2624
2834
|
if ( userAdmin && userAdmin.length === 0 ) {
|
|
2625
2835
|
return res.sendError( 'Invalid Approver Details', 500 );
|
|
2626
2836
|
}
|
|
@@ -2654,14 +2864,13 @@ export async function createAiTask( req, res ) {
|
|
|
2654
2864
|
|
|
2655
2865
|
|
|
2656
2866
|
data['approver'] = userAdmin;
|
|
2657
|
-
|
|
2867
|
+
|
|
2658
2868
|
|
|
2659
2869
|
let answer = await findAnswer( inputBody?.answerType );
|
|
2660
2870
|
if ( answer.length == 0 ) {
|
|
2661
2871
|
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
2662
2872
|
}
|
|
2663
2873
|
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
2664
|
-
console.log( inputBody?.options );
|
|
2665
2874
|
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
2666
2875
|
let optionsResult = [];
|
|
2667
2876
|
let optionList = inputBody?.options.split( ',' );
|
|
@@ -2693,7 +2902,6 @@ export async function createAiTask( req, res ) {
|
|
|
2693
2902
|
if ( response?.approver.length ) {
|
|
2694
2903
|
let inputData = [];
|
|
2695
2904
|
response?.approver.forEach( ( ele ) => {
|
|
2696
|
-
console.log( data );
|
|
2697
2905
|
inputData.push( {
|
|
2698
2906
|
userEmail: ele.email,
|
|
2699
2907
|
checkListId: response._id,
|
|
@@ -2702,7 +2910,7 @@ export async function createAiTask( req, res ) {
|
|
|
2702
2910
|
checkListName: data?.checkListName || '',
|
|
2703
2911
|
} );
|
|
2704
2912
|
} );
|
|
2705
|
-
|
|
2913
|
+
|
|
2706
2914
|
await traxApprover.insertMany( inputData );
|
|
2707
2915
|
}
|
|
2708
2916
|
|
|
@@ -2725,7 +2933,6 @@ export async function createAiTask( req, res ) {
|
|
|
2725
2933
|
|
|
2726
2934
|
if ( req.files && req.files.referenceImage && req.files.referenceImage.length ) {
|
|
2727
2935
|
let images = [];
|
|
2728
|
-
console.log( req.files.referenceImage.length );
|
|
2729
2936
|
|
|
2730
2937
|
|
|
2731
2938
|
for ( let image of req.files.referenceImage ) {
|
|
@@ -2765,7 +2972,7 @@ export async function createAiTask( req, res ) {
|
|
|
2765
2972
|
client_id: inputBody.clientId,
|
|
2766
2973
|
userId: userId,
|
|
2767
2974
|
};
|
|
2768
|
-
|
|
2975
|
+
|
|
2769
2976
|
await taskAssignService.create( userDetails );
|
|
2770
2977
|
await insertSingleProcessData( response?._id );
|
|
2771
2978
|
return res.sendSuccess( 'Task created successfully' );
|
|
@@ -3066,7 +3273,7 @@ export async function customertrial( params ) {
|
|
|
3066
3273
|
Key: 'hygiene/16-01-2025/11-2212/11-2212_13d76f2dd3ea3123aa476a885893c9fd_labelled.jpeg',
|
|
3067
3274
|
};
|
|
3068
3275
|
|
|
3069
|
-
|
|
3276
|
+
|
|
3070
3277
|
let url = await getObject( inputData );
|
|
3071
3278
|
console.log( url );
|
|
3072
3279
|
} catch ( e ) {
|
package/src/dtos/task.dto.js
CHANGED
|
@@ -12,7 +12,7 @@ export const aitaskvalidationSchema = Joi.object().keys( {
|
|
|
12
12
|
scheduleDate: Joi.string().optional(),
|
|
13
13
|
scheduleEndTime: Joi.string().optional(),
|
|
14
14
|
} );
|
|
15
|
-
export const
|
|
15
|
+
export const StoreHygienetaskSchema = Joi.object().keys( {
|
|
16
16
|
storeName: Joi.string().required(),
|
|
17
17
|
taskName: Joi.string().required(),
|
|
18
18
|
question: Joi.string().required(),
|
|
@@ -20,12 +20,27 @@ export const aitaskvalidationSchemanew = Joi.object().keys( {
|
|
|
20
20
|
options: Joi.string().optional(),
|
|
21
21
|
scheduleDate: Joi.string().optional(),
|
|
22
22
|
scheduleEndTime: Joi.string().optional(),
|
|
23
|
-
referenceImage: Joi.
|
|
23
|
+
referenceImage: Joi.array().required(),
|
|
24
|
+
count: Joi.number().required(),
|
|
25
|
+
} );
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export const eyeTesttaskSchema = Joi.object().keys( {
|
|
29
|
+
storeName: Joi.string().required(),
|
|
30
|
+
taskName: Joi.string().required(),
|
|
31
|
+
question: Joi.string().required(),
|
|
32
|
+
answerType: Joi.string().required(),
|
|
33
|
+
scheduleDate: Joi.string().required(),
|
|
34
|
+
scheduleEndTime: Joi.string().required(),
|
|
35
|
+
referenceImage: Joi.any().optional(),
|
|
24
36
|
} );
|
|
25
37
|
|
|
26
38
|
export const aitaskvalidation = {
|
|
27
39
|
body: aitaskvalidationSchema,
|
|
28
40
|
};
|
|
29
|
-
export const
|
|
30
|
-
body:
|
|
41
|
+
export const StoreHygienetaskvalidation = {
|
|
42
|
+
body: StoreHygienetaskSchema,
|
|
43
|
+
};
|
|
44
|
+
export const eyeTesttaskvalidation = {
|
|
45
|
+
body: eyeTesttaskSchema,
|
|
31
46
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as taskController from '../controllers/task.controller.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient, isAllowedInternalAPIHandler } from 'tango-app-api-middleware';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
import { aitaskvalidation,
|
|
5
|
+
import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation } from '../dtos/task.dto.js';
|
|
6
6
|
export const taskRouter = express.Router();
|
|
7
7
|
|
|
8
8
|
taskRouter
|
|
@@ -29,7 +29,8 @@ taskRouter
|
|
|
29
29
|
.get( '/clusterMigrations', taskController.clusterMigrations )
|
|
30
30
|
.post( '/createaiChecklist', isAllowedInternalAPIHandler, taskController.createAiChecklist )
|
|
31
31
|
.post( '/createaiTask', isAllowedInternalAPIHandler, validate( aitaskvalidation ), taskController.createAiTask )
|
|
32
|
-
.post( '/
|
|
32
|
+
.post( '/StoreHygienetask', isAllowedInternalAPIHandler, validate( StoreHygienetaskvalidation ), taskController.StoreHygienetask )
|
|
33
|
+
.post( '/eyeTesttask', isAllowedInternalAPIHandler, validate( eyeTesttaskvalidation ), taskController.eyeTesttask )
|
|
33
34
|
.get( '/getcoustemer', taskController.customertrial );
|
|
34
35
|
|
|
35
36
|
|