tango-app-api-store-builder 1.0.0-beta-134 → 1.0.0-beta-136
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 +52 -14
- package/src/controllers/managePlano.controller.js +205 -268
- package/src/controllers/planoLibrary.controller.js +142 -99
- package/src/controllers/script.controller.js +149 -46
- package/src/controllers/storeBuilder.controller.js +410 -28
- package/src/controllers/task.controller.js +5 -2
- package/src/routes/script.routes.js +1 -0
- package/src/routes/storeBuilder.routes.js +5 -4
- package/src/service/fixtureShelf.service.js +4 -0
- package/src/service/planoTask.service.js +3 -0
|
@@ -2644,7 +2644,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2644
2644
|
{ storeId: { $in: req.body.id } },
|
|
2645
2645
|
],
|
|
2646
2646
|
},
|
|
2647
|
-
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1, scanType: 1, clientId: 1, validateShelfSections: 1 },
|
|
2647
|
+
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1, scanType: 1, clientId: 1, validateShelfSections: 1, planoProgress: 1 },
|
|
2648
2648
|
);
|
|
2649
2649
|
|
|
2650
2650
|
if ( !planograms?.length ) return res.sendError( 'No data found', 204 );
|
|
@@ -2669,7 +2669,6 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2669
2669
|
floorId: floor._id,
|
|
2670
2670
|
associatedElementType: element.elementType,
|
|
2671
2671
|
associatedElementNumber: element.elementNumber,
|
|
2672
|
-
fixtureType: 'wall',
|
|
2673
2672
|
}, { shelfcount: 0 }, { fixtureNumber: 1 } );
|
|
2674
2673
|
|
|
2675
2674
|
const fixturesWithStatus = await Promise.all(
|
|
@@ -2765,7 +2764,10 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2765
2764
|
|
|
2766
2765
|
const centerFixtures = await storeFixtureService.find( {
|
|
2767
2766
|
floorId: floor._id,
|
|
2768
|
-
|
|
2767
|
+
$and: [
|
|
2768
|
+
{ associatedElementType: { $exists: false } },
|
|
2769
|
+
{ associatedElementNumber: { $exists: false } },
|
|
2770
|
+
],
|
|
2769
2771
|
} );
|
|
2770
2772
|
|
|
2771
2773
|
const centerFixturesWithStatus = await Promise.all(
|
|
@@ -2990,7 +2992,6 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
2990
2992
|
floorId: floor._id,
|
|
2991
2993
|
associatedElementType: element.elementType,
|
|
2992
2994
|
associatedElementNumber: element.elementNumber,
|
|
2993
|
-
fixtureType: 'wall',
|
|
2994
2995
|
}, { shelfcount: 0 }, { fixtureNumber: 1 } );
|
|
2995
2996
|
|
|
2996
2997
|
const fixturesWithStatus = await Promise.all(
|
|
@@ -3012,7 +3013,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3012
3013
|
|
|
3013
3014
|
const compliance = await planoTaskComplianceService.findOne( {
|
|
3014
3015
|
fixtureId: fixture._id,
|
|
3015
|
-
type: req.body?.type ? req.body.type : 'fixture',
|
|
3016
|
+
type: req.body?.type ? req.body.type : 'fixture', date_string: req.body.date,
|
|
3016
3017
|
}, { status: 1, answers: 1, taskType: 1 } );
|
|
3017
3018
|
|
|
3018
3019
|
const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
|
|
@@ -3048,10 +3049,13 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3048
3049
|
issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
|
|
3049
3050
|
),
|
|
3050
3051
|
);
|
|
3051
|
-
if ( hasDisagree
|
|
3052
|
+
if ( hasDisagree ) {
|
|
3052
3053
|
redoCount++;
|
|
3053
3054
|
disabled = false;
|
|
3054
3055
|
}
|
|
3056
|
+
if ( compliance?.taskType == 'redo' ) {
|
|
3057
|
+
disabled = false;
|
|
3058
|
+
}
|
|
3055
3059
|
}
|
|
3056
3060
|
|
|
3057
3061
|
return {
|
|
@@ -3084,7 +3088,10 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3084
3088
|
|
|
3085
3089
|
const centerFixtures = await storeFixtureService.find( {
|
|
3086
3090
|
floorId: floor._id,
|
|
3087
|
-
|
|
3091
|
+
$and: [
|
|
3092
|
+
{ associatedElementType: { $exists: false } },
|
|
3093
|
+
{ associatedElementNumber: { $exists: false } },
|
|
3094
|
+
],
|
|
3088
3095
|
} );
|
|
3089
3096
|
|
|
3090
3097
|
const centerFixturesWithStatus = await Promise.all(
|
|
@@ -3106,7 +3113,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3106
3113
|
|
|
3107
3114
|
const compliance = await planoTaskComplianceService.findOne( {
|
|
3108
3115
|
fixtureId: fixture._id,
|
|
3109
|
-
type: req.body?.type ? req.body.type : 'fixture',
|
|
3116
|
+
type: req.body?.type ? req.body.type : 'fixture', date_string: req.body.date,
|
|
3110
3117
|
}, { status: 1, answers: 1, taskType: 1 } );
|
|
3111
3118
|
|
|
3112
3119
|
const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
|
|
@@ -3142,10 +3149,13 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3142
3149
|
),
|
|
3143
3150
|
);
|
|
3144
3151
|
|
|
3145
|
-
if ( hasDisagree
|
|
3152
|
+
if ( hasDisagree ) {
|
|
3146
3153
|
redoCount++;
|
|
3147
3154
|
disabled = false;
|
|
3148
3155
|
}
|
|
3156
|
+
if ( compliance.taskType == 'redo' ) {
|
|
3157
|
+
disabled = false;
|
|
3158
|
+
}
|
|
3149
3159
|
}
|
|
3150
3160
|
|
|
3151
3161
|
return {
|
|
@@ -3288,6 +3298,7 @@ export async function planoList( req, res ) {
|
|
|
3288
3298
|
dateString: { $last: '$date_string' },
|
|
3289
3299
|
checklistStatus: { $last: '$checklistStatus' },
|
|
3290
3300
|
taskId: { $last: '$_id' },
|
|
3301
|
+
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
3291
3302
|
},
|
|
3292
3303
|
},
|
|
3293
3304
|
{
|
|
@@ -3299,6 +3310,16 @@ export async function planoList( req, res ) {
|
|
|
3299
3310
|
status: '$checklistStatus',
|
|
3300
3311
|
date: '$dateString',
|
|
3301
3312
|
floorId: '$_id.floorId',
|
|
3313
|
+
endTime: '$scheduleEndTime_iso',
|
|
3314
|
+
breach: {
|
|
3315
|
+
$cond: {
|
|
3316
|
+
if: {
|
|
3317
|
+
$gte: [ '$scheduleEndTime_iso', new Date() ],
|
|
3318
|
+
},
|
|
3319
|
+
then: false,
|
|
3320
|
+
else: true,
|
|
3321
|
+
},
|
|
3322
|
+
},
|
|
3302
3323
|
},
|
|
3303
3324
|
},
|
|
3304
3325
|
taskIds: { $push: '$taskId' },
|
|
@@ -3555,28 +3576,31 @@ export async function planoList( req, res ) {
|
|
|
3555
3576
|
},
|
|
3556
3577
|
} );
|
|
3557
3578
|
}
|
|
3558
|
-
if ( inputData?.filter?.taskPending?.length && inputData?.filter?.taskPending
|
|
3559
|
-
let andQuery = [
|
|
3579
|
+
if ( inputData?.filter?.taskPending?.length && inputData?.filter?.taskPending !== 'all' ) {
|
|
3580
|
+
let andQuery = [ {
|
|
3581
|
+
'planoTask.taskStatus': {
|
|
3582
|
+
$elemMatch: {
|
|
3583
|
+
type: inputData.filter.taskPending,
|
|
3584
|
+
status: 'submit',
|
|
3585
|
+
},
|
|
3586
|
+
},
|
|
3587
|
+
} ];
|
|
3560
3588
|
|
|
3561
|
-
if ( inputData.filter.taskPending
|
|
3589
|
+
if ( inputData.filter.taskPending === 'layout' ) {
|
|
3562
3590
|
andQuery.push(
|
|
3563
|
-
{ 'planoTask.taskStatus.type': 'layout' },
|
|
3564
|
-
{ 'planoTask.taskStatus.status': 'submit' },
|
|
3565
3591
|
{ 'taskDetails.layoutStatus': 'pending' },
|
|
3566
3592
|
);
|
|
3567
3593
|
}
|
|
3568
|
-
|
|
3594
|
+
|
|
3595
|
+
if ( inputData.filter.taskPending === 'fixture' ) {
|
|
3569
3596
|
andQuery.push(
|
|
3570
|
-
{ 'planoTask.taskStatus.type': 'fixture' },
|
|
3571
|
-
{ 'planoTask.taskStatus.status': 'submit' },
|
|
3572
3597
|
{ 'taskDetails.fixtureStatus': 'pending' },
|
|
3573
3598
|
);
|
|
3574
3599
|
}
|
|
3575
|
-
|
|
3600
|
+
|
|
3601
|
+
if ( inputData.filter.taskPending === 'vm' ) {
|
|
3576
3602
|
andQuery.push(
|
|
3577
|
-
{ 'planoTask.taskStatus.type': 'vm' },
|
|
3578
3603
|
{ 'taskDetails.vmStatus': 'pending' },
|
|
3579
|
-
{ 'planoTask.taskStatus.status': 'submit' },
|
|
3580
3604
|
);
|
|
3581
3605
|
}
|
|
3582
3606
|
|
|
@@ -3587,6 +3611,27 @@ export async function planoList( req, res ) {
|
|
|
3587
3611
|
} );
|
|
3588
3612
|
}
|
|
3589
3613
|
|
|
3614
|
+
if ( inputData?.filter?.flag?.length ) {
|
|
3615
|
+
let andQuery = [];
|
|
3616
|
+
andQuery.push(
|
|
3617
|
+
{
|
|
3618
|
+
'planoTask.taskStatus': {
|
|
3619
|
+
$elemMatch: {
|
|
3620
|
+
type: { $in: inputData.filter.flag },
|
|
3621
|
+
status: { $ne: 'submit' },
|
|
3622
|
+
breach: true,
|
|
3623
|
+
},
|
|
3624
|
+
},
|
|
3625
|
+
},
|
|
3626
|
+
{ 'taskDetails.layoutStatus': 'pending' },
|
|
3627
|
+
);
|
|
3628
|
+
query.push( {
|
|
3629
|
+
$match: {
|
|
3630
|
+
$and: andQuery,
|
|
3631
|
+
},
|
|
3632
|
+
} );
|
|
3633
|
+
}
|
|
3634
|
+
|
|
3590
3635
|
let orQuery = [];
|
|
3591
3636
|
|
|
3592
3637
|
if ( inputData.filter.status.length ) {
|
|
@@ -3598,10 +3643,8 @@ export async function planoList( req, res ) {
|
|
|
3598
3643
|
orQuery.push( { $and: [ { 'taskDetails.fixtureStatus': 'pending' }, { 'planoTask.taskStatus.type': 'fixture' }, { 'planoTask.taskStatus.status': 'submit' } ] } );
|
|
3599
3644
|
orQuery.push( { $and: [ { 'taskDetails.vmStatus': 'pending' }, { 'planoTask.taskStatus.type': 'vm' }, { 'planoTask.taskStatus.status': 'submit' } ] } );
|
|
3600
3645
|
}
|
|
3601
|
-
if ( inputData.filter.status.includes( '
|
|
3602
|
-
orQuery.push( { 'taskDetails.layoutStatus': 'complete' } );
|
|
3603
|
-
orQuery.push( { 'taskDetails.fixtureStatus': 'complete' } );
|
|
3604
|
-
orQuery.push( { 'taskDetails.vmStatus': 'complete' } );
|
|
3646
|
+
if ( inputData.filter.status.includes( 'completed' ) ) {
|
|
3647
|
+
orQuery.push( { $and: [ { 'taskDetails.layoutStatus': 'complete' }, { 'taskDetails.fixtureStatus': 'complete' }, { 'taskDetails.vmStatus': 'complete' } ] } );
|
|
3605
3648
|
}
|
|
3606
3649
|
if ( inputData.filter.status.includes( 'yetToAssign' ) ) {
|
|
3607
3650
|
orQuery.push( { $expr: { $eq: [ { $size: '$planoTask' }, 0 ] } } );
|
|
@@ -3643,16 +3686,23 @@ export async function planoList( req, res ) {
|
|
|
3643
3686
|
},
|
|
3644
3687
|
} );
|
|
3645
3688
|
|
|
3646
|
-
|
|
3689
|
+
const [ planoDetails, planoIdList ] = await Promise.all( [
|
|
3690
|
+
|
|
3691
|
+
await planoService.aggregate( query ),
|
|
3692
|
+
await planoService.find( { clientId: inputData.clientId,
|
|
3693
|
+
storeId: { $in: storeDetails } }, { _id: 1 } ),
|
|
3694
|
+
] );
|
|
3695
|
+
|
|
3647
3696
|
|
|
3648
3697
|
if ( !planoDetails[0].data.length ) {
|
|
3649
3698
|
return res.sendError( 'No data found', 204 );
|
|
3650
3699
|
}
|
|
3651
3700
|
|
|
3701
|
+
|
|
3652
3702
|
let taskQuery = [
|
|
3653
3703
|
{
|
|
3654
3704
|
$match: {
|
|
3655
|
-
planoId: { $in:
|
|
3705
|
+
planoId: { $in: planoIdList.map( ( ele ) => ele._id ) },
|
|
3656
3706
|
isPlano: true,
|
|
3657
3707
|
date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
3658
3708
|
},
|
|
@@ -3789,11 +3839,11 @@ export async function planoList( req, res ) {
|
|
|
3789
3839
|
},
|
|
3790
3840
|
];
|
|
3791
3841
|
|
|
3792
|
-
pendingDetails = await planoTaskComplianceService.aggregate(
|
|
3842
|
+
pendingDetails = await planoTaskComplianceService.aggregate( taskQuery );
|
|
3793
3843
|
let result = {
|
|
3794
3844
|
data: planoDetails[0].data,
|
|
3795
3845
|
count: planoDetails?.[0]?.count?.[0]?.total || 0,
|
|
3796
|
-
pendingDetails: [ { ...pendingDetails?.[0], allStores:
|
|
3846
|
+
pendingDetails: [ { ...pendingDetails?.[0], allStores: planoIdList?.length || 0 } ],
|
|
3797
3847
|
};
|
|
3798
3848
|
return res.sendSuccess( result );
|
|
3799
3849
|
} catch ( e ) {
|
|
@@ -3801,3 +3851,335 @@ export async function planoList( req, res ) {
|
|
|
3801
3851
|
return res.sendError( e, 500 );
|
|
3802
3852
|
}
|
|
3803
3853
|
}
|
|
3854
|
+
|
|
3855
|
+
export async function getTaskDetails( req, res ) {
|
|
3856
|
+
try {
|
|
3857
|
+
if ( !req.query.planoId ) {
|
|
3858
|
+
return res.sendError( 'PlanoId is required', 400 );
|
|
3859
|
+
}
|
|
3860
|
+
let query = [
|
|
3861
|
+
{
|
|
3862
|
+
$match: {
|
|
3863
|
+
planoId: new mongoose.Types.ObjectId( req.query.planoId ),
|
|
3864
|
+
isPlano: true,
|
|
3865
|
+
date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
3866
|
+
},
|
|
3867
|
+
},
|
|
3868
|
+
{
|
|
3869
|
+
$group: {
|
|
3870
|
+
_id: { type: '$planoType', floorId: '$floorId' },
|
|
3871
|
+
dateString: { $last: '$date_string' },
|
|
3872
|
+
checklistStatus: { $last: '$checklistStatus' },
|
|
3873
|
+
taskId: { $last: '$_id' },
|
|
3874
|
+
redoStatus: { $last: '$redoStatus' },
|
|
3875
|
+
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
3876
|
+
},
|
|
3877
|
+
},
|
|
3878
|
+
{
|
|
3879
|
+
$group: {
|
|
3880
|
+
_id: null,
|
|
3881
|
+
taskStatus: {
|
|
3882
|
+
$push: {
|
|
3883
|
+
type: '$_id.type',
|
|
3884
|
+
status: '$checklistStatus',
|
|
3885
|
+
date: '$dateString',
|
|
3886
|
+
floorId: '$_id.floorId',
|
|
3887
|
+
redoStatus: '$redoStatus',
|
|
3888
|
+
endTime: '$scheduleEndTime_iso',
|
|
3889
|
+
breach: {
|
|
3890
|
+
$cond: {
|
|
3891
|
+
if: {
|
|
3892
|
+
$gte: [ '$scheduleEndTime_iso', new Date() ],
|
|
3893
|
+
},
|
|
3894
|
+
then: false,
|
|
3895
|
+
else: true,
|
|
3896
|
+
},
|
|
3897
|
+
},
|
|
3898
|
+
},
|
|
3899
|
+
},
|
|
3900
|
+
taskIds: { $push: '$taskId' },
|
|
3901
|
+
},
|
|
3902
|
+
},
|
|
3903
|
+
{
|
|
3904
|
+
$lookup: {
|
|
3905
|
+
from: 'planotaskcompliances',
|
|
3906
|
+
let: {
|
|
3907
|
+
task: '$taskIds',
|
|
3908
|
+
},
|
|
3909
|
+
pipeline: [
|
|
3910
|
+
{
|
|
3911
|
+
$match: {
|
|
3912
|
+
$expr: {
|
|
3913
|
+
$and: [
|
|
3914
|
+
{ $eq: [ '$planoId', new mongoose.Types.ObjectId( req.query.planoId ) ] },
|
|
3915
|
+
{ $in: [ '$taskId', '$$task' ] },
|
|
3916
|
+
{ $eq: [ '$status', 'incomplete' ] },
|
|
3917
|
+
],
|
|
3918
|
+
},
|
|
3919
|
+
},
|
|
3920
|
+
},
|
|
3921
|
+
{ $sort: { _id: -1 } },
|
|
3922
|
+
{
|
|
3923
|
+
$set: {
|
|
3924
|
+
hasPendingIssues: {
|
|
3925
|
+
$anyElementTrue: {
|
|
3926
|
+
$map: {
|
|
3927
|
+
input: {
|
|
3928
|
+
$reduce: {
|
|
3929
|
+
input: '$answers',
|
|
3930
|
+
initialValue: [],
|
|
3931
|
+
in: {
|
|
3932
|
+
$concatArrays: [
|
|
3933
|
+
'$$value',
|
|
3934
|
+
{
|
|
3935
|
+
$reduce: {
|
|
3936
|
+
input: { $ifNull: [ '$$this.issues', [] ] },
|
|
3937
|
+
initialValue: [],
|
|
3938
|
+
in: {
|
|
3939
|
+
$concatArrays: [
|
|
3940
|
+
'$$value',
|
|
3941
|
+
{ $ifNull: [ '$$this.Details', [] ] },
|
|
3942
|
+
],
|
|
3943
|
+
},
|
|
3944
|
+
},
|
|
3945
|
+
},
|
|
3946
|
+
],
|
|
3947
|
+
},
|
|
3948
|
+
},
|
|
3949
|
+
},
|
|
3950
|
+
as: 'detail',
|
|
3951
|
+
in: {
|
|
3952
|
+
$or: [
|
|
3953
|
+
{ $eq: [ '$$detail.status', 'pending' ] },
|
|
3954
|
+
],
|
|
3955
|
+
},
|
|
3956
|
+
},
|
|
3957
|
+
},
|
|
3958
|
+
},
|
|
3959
|
+
},
|
|
3960
|
+
},
|
|
3961
|
+
{
|
|
3962
|
+
$group: {
|
|
3963
|
+
_id: '$floorId',
|
|
3964
|
+
layoutCount: {
|
|
3965
|
+
$sum: { $cond: [ { $eq: [ '$type', 'layout' ] }, 1, 0 ] },
|
|
3966
|
+
},
|
|
3967
|
+
fixtureCount: {
|
|
3968
|
+
$sum: { $cond: [ { $eq: [ '$type', 'fixture' ] }, 1, 0 ] },
|
|
3969
|
+
},
|
|
3970
|
+
vmCount: {
|
|
3971
|
+
$sum: { $cond: [ { $eq: [ '$type', 'vm' ] }, 1, 0 ] },
|
|
3972
|
+
},
|
|
3973
|
+
layoutPending: {
|
|
3974
|
+
$sum: {
|
|
3975
|
+
$cond: [
|
|
3976
|
+
{ $and: [ { $eq: [ '$type', 'layout' ] }, '$hasPendingIssues' ] },
|
|
3977
|
+
1,
|
|
3978
|
+
0,
|
|
3979
|
+
],
|
|
3980
|
+
},
|
|
3981
|
+
},
|
|
3982
|
+
fixturePending: {
|
|
3983
|
+
$sum: {
|
|
3984
|
+
$cond: [
|
|
3985
|
+
{ $and: [ { $eq: [ '$type', 'fixture' ] }, '$hasPendingIssues' ] },
|
|
3986
|
+
1,
|
|
3987
|
+
0,
|
|
3988
|
+
],
|
|
3989
|
+
},
|
|
3990
|
+
},
|
|
3991
|
+
vmPending: {
|
|
3992
|
+
$sum: {
|
|
3993
|
+
$cond: [
|
|
3994
|
+
{ $and: [ { $eq: [ '$type', 'vm' ] }, '$hasPendingIssues' ] },
|
|
3995
|
+
1,
|
|
3996
|
+
0,
|
|
3997
|
+
],
|
|
3998
|
+
},
|
|
3999
|
+
},
|
|
4000
|
+
},
|
|
4001
|
+
},
|
|
4002
|
+
{
|
|
4003
|
+
$group: {
|
|
4004
|
+
_id: null,
|
|
4005
|
+
layoutCount: { $sum: '$layoutCount' },
|
|
4006
|
+
fixtureCount: { $sum: '$fixtureCount' },
|
|
4007
|
+
vmCount: { $sum: '$vmCount' },
|
|
4008
|
+
completeLayout: {
|
|
4009
|
+
$sum: {
|
|
4010
|
+
$cond: {
|
|
4011
|
+
if: {
|
|
4012
|
+
$and: [
|
|
4013
|
+
{ '$gt': [ '$layoutCount', 0 ] },
|
|
4014
|
+
{ '$gt': [ '$layoutPending', 0 ] },
|
|
4015
|
+
{ '$gt': [ '$fixtureCount', 0 ] },
|
|
4016
|
+
{ '$gt': [ '$fixturePending', 0 ] },
|
|
4017
|
+
{ '$gt': [ '$vmCount', 0 ] },
|
|
4018
|
+
{ '$gt': [ '$fixturePending', 0 ] },
|
|
4019
|
+
],
|
|
4020
|
+
},
|
|
4021
|
+
then: 1,
|
|
4022
|
+
else: 0,
|
|
4023
|
+
},
|
|
4024
|
+
},
|
|
4025
|
+
},
|
|
4026
|
+
layoutPending: { $sum: '$layoutPending' },
|
|
4027
|
+
fixturePending: { $sum: '$fixturePending' },
|
|
4028
|
+
vmPending: { $sum: '$vmPending' },
|
|
4029
|
+
},
|
|
4030
|
+
},
|
|
4031
|
+
{
|
|
4032
|
+
$project: {
|
|
4033
|
+
_id: 0,
|
|
4034
|
+
layoutStatus: {
|
|
4035
|
+
$cond: {
|
|
4036
|
+
if: {
|
|
4037
|
+
$and: [
|
|
4038
|
+
{ $gt: [ '$layoutCount', 0 ] },
|
|
4039
|
+
{ $eq: [ '$layoutPending', 0 ] },
|
|
4040
|
+
],
|
|
4041
|
+
},
|
|
4042
|
+
then: 'complete',
|
|
4043
|
+
else: {
|
|
4044
|
+
$cond: {
|
|
4045
|
+
if: {
|
|
4046
|
+
$and: [
|
|
4047
|
+
{
|
|
4048
|
+
$gt: [ '$layoutCount', 0 ],
|
|
4049
|
+
},
|
|
4050
|
+
{
|
|
4051
|
+
$gt: [
|
|
4052
|
+
'$layoutPending',
|
|
4053
|
+
0,
|
|
4054
|
+
],
|
|
4055
|
+
},
|
|
4056
|
+
],
|
|
4057
|
+
},
|
|
4058
|
+
then: 'pending',
|
|
4059
|
+
else: '',
|
|
4060
|
+
},
|
|
4061
|
+
},
|
|
4062
|
+
},
|
|
4063
|
+
},
|
|
4064
|
+
fixtureStatus: {
|
|
4065
|
+
$cond: {
|
|
4066
|
+
if: {
|
|
4067
|
+
$and: [
|
|
4068
|
+
{ $gt: [ '$fixtureCount', 0 ] },
|
|
4069
|
+
{
|
|
4070
|
+
$eq: [ '$fixturePending', 0 ],
|
|
4071
|
+
},
|
|
4072
|
+
],
|
|
4073
|
+
},
|
|
4074
|
+
then: 'complete',
|
|
4075
|
+
else: {
|
|
4076
|
+
$cond: {
|
|
4077
|
+
if: {
|
|
4078
|
+
$and: [
|
|
4079
|
+
{
|
|
4080
|
+
$gt: [
|
|
4081
|
+
'$fixtureCount',
|
|
4082
|
+
0,
|
|
4083
|
+
],
|
|
4084
|
+
},
|
|
4085
|
+
{
|
|
4086
|
+
$gt: [
|
|
4087
|
+
'$fixturePending',
|
|
4088
|
+
0,
|
|
4089
|
+
],
|
|
4090
|
+
},
|
|
4091
|
+
],
|
|
4092
|
+
},
|
|
4093
|
+
then: 'pending',
|
|
4094
|
+
else: '',
|
|
4095
|
+
},
|
|
4096
|
+
},
|
|
4097
|
+
},
|
|
4098
|
+
},
|
|
4099
|
+
vmStatus: {
|
|
4100
|
+
$cond: {
|
|
4101
|
+
if: {
|
|
4102
|
+
$and: [
|
|
4103
|
+
{ $gt: [ '$vmCount', 0 ] },
|
|
4104
|
+
{ $eq: [ '$vmPending', 0 ] },
|
|
4105
|
+
],
|
|
4106
|
+
},
|
|
4107
|
+
then: 'complete',
|
|
4108
|
+
else: {
|
|
4109
|
+
$cond: {
|
|
4110
|
+
if: {
|
|
4111
|
+
$and: [
|
|
4112
|
+
{ $gt: [ '$vmCount', 0 ] },
|
|
4113
|
+
{ $gt: [ '$vmPending', 0 ] },
|
|
4114
|
+
],
|
|
4115
|
+
},
|
|
4116
|
+
then: 'pending',
|
|
4117
|
+
else: '',
|
|
4118
|
+
},
|
|
4119
|
+
},
|
|
4120
|
+
},
|
|
4121
|
+
},
|
|
4122
|
+
layoutPending: 1,
|
|
4123
|
+
fixturePending: 1,
|
|
4124
|
+
vmPending: 1,
|
|
4125
|
+
layoutCount: 1,
|
|
4126
|
+
fixtureCount: 1,
|
|
4127
|
+
vmCount: 1,
|
|
4128
|
+
completeLayout: 1,
|
|
4129
|
+
},
|
|
4130
|
+
},
|
|
4131
|
+
],
|
|
4132
|
+
as: 'taskDetails',
|
|
4133
|
+
},
|
|
4134
|
+
},
|
|
4135
|
+
{
|
|
4136
|
+
$project: {
|
|
4137
|
+
_id: 0,
|
|
4138
|
+
taskStatus: {
|
|
4139
|
+
$map: {
|
|
4140
|
+
input: '$taskStatus',
|
|
4141
|
+
as: 'task',
|
|
4142
|
+
in: {
|
|
4143
|
+
type: '$$task.type',
|
|
4144
|
+
status: '$$task.status',
|
|
4145
|
+
date: '$$task.date',
|
|
4146
|
+
floorId: '$$task.floorId',
|
|
4147
|
+
redoStatus: '$$task.redoStatus',
|
|
4148
|
+
endTime: '$$task.endTime',
|
|
4149
|
+
breach: '$$task.breach',
|
|
4150
|
+
feedbackStatus: {
|
|
4151
|
+
$switch: {
|
|
4152
|
+
branches: [
|
|
4153
|
+
{
|
|
4154
|
+
case: { $eq: [ '$$task.type', 'layout' ] },
|
|
4155
|
+
then: { $arrayElemAt: [ '$taskDetails.layoutStatus', 0 ] },
|
|
4156
|
+
},
|
|
4157
|
+
{
|
|
4158
|
+
case: { $eq: [ '$$task.type', 'fixture' ] },
|
|
4159
|
+
then: { $arrayElemAt: [ '$taskDetails.fixtureStatus', 0 ] },
|
|
4160
|
+
},
|
|
4161
|
+
{
|
|
4162
|
+
case: { $eq: [ '$$task.type', 'vm' ] },
|
|
4163
|
+
then: { $arrayElemAt: [ '$taskDetails.vmStatus', 0 ] },
|
|
4164
|
+
},
|
|
4165
|
+
],
|
|
4166
|
+
default: '',
|
|
4167
|
+
},
|
|
4168
|
+
},
|
|
4169
|
+
},
|
|
4170
|
+
},
|
|
4171
|
+
},
|
|
4172
|
+
},
|
|
4173
|
+
},
|
|
4174
|
+
|
|
4175
|
+
];
|
|
4176
|
+
|
|
4177
|
+
let taskInfo = await planotaskService.aggregate( query );
|
|
4178
|
+
let disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ele.feedbackStatus != 'complete' ) || ele.status != 'submit' ) && !ele?.breach );
|
|
4179
|
+
console.log( disabledInfo );
|
|
4180
|
+
return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus, disabled: disabledInfo?.length ? true : false } );
|
|
4181
|
+
} catch ( e ) {
|
|
4182
|
+
logger.error( { functionName: 'getTaskDetails', error: e } );
|
|
4183
|
+
return res.sendError( e, 500 );
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
@@ -301,7 +301,11 @@ export async function createTask( req, res ) {
|
|
|
301
301
|
}
|
|
302
302
|
await planoService.updateOne( { _id: planoDetails?._id }, { $set: { planoProgress } } );
|
|
303
303
|
let currDate = dayjs().add( j, 'day' );
|
|
304
|
-
let
|
|
304
|
+
let time = '12:00 AM';
|
|
305
|
+
if ( currDate.format( 'YYYY-MM-DD' ) == dayjs().format( 'YYYY-MM-DD' ) ) {
|
|
306
|
+
time = dayjs().format( 'hh:mm A' );
|
|
307
|
+
}
|
|
308
|
+
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() };
|
|
305
309
|
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 );
|
|
306
310
|
}
|
|
307
311
|
}
|
|
@@ -589,7 +593,6 @@ export async function updateAnswers( req, res ) {
|
|
|
589
593
|
export async function updateAnswersv2( req, res ) {
|
|
590
594
|
try {
|
|
591
595
|
let taskDetails = await processedService.findOne( { _id: new mongoose.Types.ObjectId( req.body.taskId ) } );
|
|
592
|
-
console.log( taskDetails );
|
|
593
596
|
if ( !taskDetails ) {
|
|
594
597
|
return res.sendError( 'No data found', 204 );
|
|
595
598
|
}
|
|
@@ -31,4 +31,5 @@ scriptRouter
|
|
|
31
31
|
.post( '/updateExcelPlanogram', scriptController.updateExcelPlanogram )
|
|
32
32
|
.post( '/recorrectTaskData', scriptController.recorrectTaskData )
|
|
33
33
|
.post( '/migrateCrest', scriptController.migrateCrestv1 )
|
|
34
|
+
.post( '/updatePlanoMappings', scriptController.updatePlanoMappings )
|
|
34
35
|
;
|
|
@@ -44,9 +44,10 @@ storeBuilderRouter
|
|
|
44
44
|
.post( '/checkPlanoExist', isAllowedSessionHandler, storeBuilderController.checkPlanoExist )
|
|
45
45
|
.post( '/storeLayoutElements', isAllowedSessionHandler, storeBuilderController.storeLayoutElements )
|
|
46
46
|
.post( '/qrScan', storeBuilderController.qrScan )
|
|
47
|
-
.post( '/storeFixturesV2', validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
|
|
48
|
-
.post( '/fixtureShelfDetailsv2', validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
|
|
49
|
-
.post( '/storeFixturesTaskv2', storeBuilderController.storeFixturesTaskv2 );
|
|
47
|
+
.post( '/storeFixturesV2', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
|
|
48
|
+
.post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
|
|
49
|
+
.post( '/storeFixturesTaskv2', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv2 );
|
|
50
50
|
|
|
51
51
|
storeBuilderRouter
|
|
52
|
-
.post( '/planoList', isAllowedSessionHandler, storeBuilderController.planoList )
|
|
52
|
+
.post( '/planoList', isAllowedSessionHandler, storeBuilderController.planoList )
|
|
53
|
+
.get( '/taskDetails', isAllowedSessionHandler, storeBuilderController.getTaskDetails );
|
|
@@ -7,6 +7,9 @@ export async function create( data ) {
|
|
|
7
7
|
export async function updateOne( query={}, record={} ) {
|
|
8
8
|
return model.planoTaskCompliance.updateOne( query, { $set: record }, { upsert: true } );
|
|
9
9
|
}
|
|
10
|
+
export async function updateMany( query={}, record={} ) {
|
|
11
|
+
return model.planoTaskCompliance.updateMany( query, { $set: record } );
|
|
12
|
+
}
|
|
10
13
|
export async function updateOnefilters( query={}, record={}, arrayfilter=[] ) {
|
|
11
14
|
return model.planoTaskCompliance.findOneAndUpdate( query, record, { arrayFilters: arrayfilter, returnDocument: 'after' } );
|
|
12
15
|
}
|