tango-app-api-store-builder 1.0.0-beta-134 → 1.0.0-beta-135
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 +45 -4
- package/src/controllers/managePlano.controller.js +16 -2
- package/src/controllers/planoLibrary.controller.js +142 -99
- package/src/controllers/script.controller.js +149 -46
- package/src/controllers/storeBuilder.controller.js +385 -27
- 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,7 @@ export async function planoList( req, res ) {
|
|
|
3299
3310
|
status: '$checklistStatus',
|
|
3300
3311
|
date: '$dateString',
|
|
3301
3312
|
floorId: '$_id.floorId',
|
|
3313
|
+
endTime: '$scheduleEndTime_iso',
|
|
3302
3314
|
},
|
|
3303
3315
|
},
|
|
3304
3316
|
taskIds: { $push: '$taskId' },
|
|
@@ -3555,28 +3567,48 @@ export async function planoList( req, res ) {
|
|
|
3555
3567
|
},
|
|
3556
3568
|
} );
|
|
3557
3569
|
}
|
|
3558
|
-
if ( inputData?.filter?.taskPending?.length && inputData?.filter?.taskPending
|
|
3570
|
+
if ( inputData?.filter?.taskPending?.length && inputData?.filter?.taskPending !== 'all' ) {
|
|
3559
3571
|
let andQuery = [];
|
|
3560
3572
|
|
|
3561
|
-
if ( inputData.filter.taskPending
|
|
3573
|
+
if ( inputData.filter.taskPending === 'layout' ) {
|
|
3562
3574
|
andQuery.push(
|
|
3563
|
-
{
|
|
3564
|
-
|
|
3575
|
+
{
|
|
3576
|
+
'planoTask.taskStatus': {
|
|
3577
|
+
$elemMatch: {
|
|
3578
|
+
type: 'layout',
|
|
3579
|
+
status: 'submit',
|
|
3580
|
+
},
|
|
3581
|
+
},
|
|
3582
|
+
},
|
|
3565
3583
|
{ 'taskDetails.layoutStatus': 'pending' },
|
|
3566
3584
|
);
|
|
3567
3585
|
}
|
|
3568
|
-
|
|
3586
|
+
|
|
3587
|
+
if ( inputData.filter.taskPending === 'fixture' ) {
|
|
3569
3588
|
andQuery.push(
|
|
3570
|
-
{
|
|
3571
|
-
|
|
3589
|
+
{
|
|
3590
|
+
'planoTask.taskStatus': {
|
|
3591
|
+
$elemMatch: {
|
|
3592
|
+
type: 'fixture',
|
|
3593
|
+
status: 'submit',
|
|
3594
|
+
},
|
|
3595
|
+
},
|
|
3596
|
+
},
|
|
3572
3597
|
{ 'taskDetails.fixtureStatus': 'pending' },
|
|
3573
3598
|
);
|
|
3574
3599
|
}
|
|
3575
|
-
|
|
3600
|
+
|
|
3601
|
+
if ( inputData.filter.taskPending === 'vm' ) {
|
|
3576
3602
|
andQuery.push(
|
|
3577
|
-
{
|
|
3603
|
+
{
|
|
3604
|
+
'planoTask.taskStatus': {
|
|
3605
|
+
$elemMatch: {
|
|
3606
|
+
type: 'vm',
|
|
3607
|
+
status: 'submit',
|
|
3608
|
+
},
|
|
3609
|
+
},
|
|
3610
|
+
},
|
|
3578
3611
|
{ 'taskDetails.vmStatus': 'pending' },
|
|
3579
|
-
{ 'planoTask.taskStatus.status': 'submit' },
|
|
3580
3612
|
);
|
|
3581
3613
|
}
|
|
3582
3614
|
|
|
@@ -3598,10 +3630,8 @@ export async function planoList( req, res ) {
|
|
|
3598
3630
|
orQuery.push( { $and: [ { 'taskDetails.fixtureStatus': 'pending' }, { 'planoTask.taskStatus.type': 'fixture' }, { 'planoTask.taskStatus.status': 'submit' } ] } );
|
|
3599
3631
|
orQuery.push( { $and: [ { 'taskDetails.vmStatus': 'pending' }, { 'planoTask.taskStatus.type': 'vm' }, { 'planoTask.taskStatus.status': 'submit' } ] } );
|
|
3600
3632
|
}
|
|
3601
|
-
if ( inputData.filter.status.includes( '
|
|
3602
|
-
orQuery.push( { 'taskDetails.layoutStatus': 'complete' } );
|
|
3603
|
-
orQuery.push( { 'taskDetails.fixtureStatus': 'complete' } );
|
|
3604
|
-
orQuery.push( { 'taskDetails.vmStatus': 'complete' } );
|
|
3633
|
+
if ( inputData.filter.status.includes( 'completed' ) ) {
|
|
3634
|
+
orQuery.push( { $and: [ { 'taskDetails.layoutStatus': 'complete' }, { 'taskDetails.fixtureStatus': 'complete' }, { 'taskDetails.vmStatus': 'complete' } ] } );
|
|
3605
3635
|
}
|
|
3606
3636
|
if ( inputData.filter.status.includes( 'yetToAssign' ) ) {
|
|
3607
3637
|
orQuery.push( { $expr: { $eq: [ { $size: '$planoTask' }, 0 ] } } );
|
|
@@ -3643,16 +3673,23 @@ export async function planoList( req, res ) {
|
|
|
3643
3673
|
},
|
|
3644
3674
|
} );
|
|
3645
3675
|
|
|
3646
|
-
|
|
3676
|
+
const [ planoDetails, planoIdList ] = await Promise.all( [
|
|
3677
|
+
|
|
3678
|
+
await planoService.aggregate( query ),
|
|
3679
|
+
await planoService.find( { clientId: inputData.clientId,
|
|
3680
|
+
storeId: { $in: storeDetails } }, { _id: 1 } ),
|
|
3681
|
+
] );
|
|
3682
|
+
|
|
3647
3683
|
|
|
3648
3684
|
if ( !planoDetails[0].data.length ) {
|
|
3649
3685
|
return res.sendError( 'No data found', 204 );
|
|
3650
3686
|
}
|
|
3651
3687
|
|
|
3688
|
+
|
|
3652
3689
|
let taskQuery = [
|
|
3653
3690
|
{
|
|
3654
3691
|
$match: {
|
|
3655
|
-
planoId: { $in:
|
|
3692
|
+
planoId: { $in: planoIdList.map( ( ele ) => ele._id ) },
|
|
3656
3693
|
isPlano: true,
|
|
3657
3694
|
date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
3658
3695
|
},
|
|
@@ -3789,11 +3826,11 @@ export async function planoList( req, res ) {
|
|
|
3789
3826
|
},
|
|
3790
3827
|
];
|
|
3791
3828
|
|
|
3792
|
-
pendingDetails = await planoTaskComplianceService.aggregate(
|
|
3829
|
+
pendingDetails = await planoTaskComplianceService.aggregate( taskQuery );
|
|
3793
3830
|
let result = {
|
|
3794
3831
|
data: planoDetails[0].data,
|
|
3795
3832
|
count: planoDetails?.[0]?.count?.[0]?.total || 0,
|
|
3796
|
-
pendingDetails: [ { ...pendingDetails?.[0], allStores:
|
|
3833
|
+
pendingDetails: [ { ...pendingDetails?.[0], allStores: planoIdList?.length || 0 } ],
|
|
3797
3834
|
};
|
|
3798
3835
|
return res.sendSuccess( result );
|
|
3799
3836
|
} catch ( e ) {
|
|
@@ -3801,3 +3838,324 @@ export async function planoList( req, res ) {
|
|
|
3801
3838
|
return res.sendError( e, 500 );
|
|
3802
3839
|
}
|
|
3803
3840
|
}
|
|
3841
|
+
|
|
3842
|
+
export async function getTaskDetails( req, res ) {
|
|
3843
|
+
try {
|
|
3844
|
+
if ( !req.query.planoId ) {
|
|
3845
|
+
return res.sendError( 'PlanoId is required', 400 );
|
|
3846
|
+
}
|
|
3847
|
+
let query = [
|
|
3848
|
+
{
|
|
3849
|
+
$match: {
|
|
3850
|
+
planoId: new mongoose.Types.ObjectId( req.query.planoId ),
|
|
3851
|
+
isPlano: true,
|
|
3852
|
+
date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
3853
|
+
},
|
|
3854
|
+
},
|
|
3855
|
+
{
|
|
3856
|
+
$group: {
|
|
3857
|
+
_id: { type: '$planoType', floorId: '$floorId' },
|
|
3858
|
+
dateString: { $last: '$date_string' },
|
|
3859
|
+
checklistStatus: { $last: '$checklistStatus' },
|
|
3860
|
+
taskId: { $last: '$_id' },
|
|
3861
|
+
redoStatus: { $last: '$redoStatus' },
|
|
3862
|
+
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
3863
|
+
},
|
|
3864
|
+
},
|
|
3865
|
+
{
|
|
3866
|
+
$group: {
|
|
3867
|
+
_id: null,
|
|
3868
|
+
taskStatus: {
|
|
3869
|
+
$push: {
|
|
3870
|
+
type: '$_id.type',
|
|
3871
|
+
status: '$checklistStatus',
|
|
3872
|
+
date: '$dateString',
|
|
3873
|
+
floorId: '$_id.floorId',
|
|
3874
|
+
redoStatus: '$redoStatus',
|
|
3875
|
+
endTime: '$scheduleEndTime_iso',
|
|
3876
|
+
},
|
|
3877
|
+
},
|
|
3878
|
+
taskIds: { $push: '$taskId' },
|
|
3879
|
+
},
|
|
3880
|
+
},
|
|
3881
|
+
{
|
|
3882
|
+
$lookup: {
|
|
3883
|
+
from: 'planotaskcompliances',
|
|
3884
|
+
let: {
|
|
3885
|
+
task: '$taskIds',
|
|
3886
|
+
},
|
|
3887
|
+
pipeline: [
|
|
3888
|
+
{
|
|
3889
|
+
$match: {
|
|
3890
|
+
$expr: {
|
|
3891
|
+
$and: [
|
|
3892
|
+
{ $eq: [ '$planoId', new mongoose.Types.ObjectId( req.query.planoId ) ] },
|
|
3893
|
+
{ $in: [ '$taskId', '$$task' ] },
|
|
3894
|
+
{ $eq: [ '$status', 'incomplete' ] },
|
|
3895
|
+
],
|
|
3896
|
+
},
|
|
3897
|
+
},
|
|
3898
|
+
},
|
|
3899
|
+
{ $sort: { _id: -1 } },
|
|
3900
|
+
{
|
|
3901
|
+
$set: {
|
|
3902
|
+
hasPendingIssues: {
|
|
3903
|
+
$anyElementTrue: {
|
|
3904
|
+
$map: {
|
|
3905
|
+
input: {
|
|
3906
|
+
$reduce: {
|
|
3907
|
+
input: '$answers',
|
|
3908
|
+
initialValue: [],
|
|
3909
|
+
in: {
|
|
3910
|
+
$concatArrays: [
|
|
3911
|
+
'$$value',
|
|
3912
|
+
{
|
|
3913
|
+
$reduce: {
|
|
3914
|
+
input: { $ifNull: [ '$$this.issues', [] ] },
|
|
3915
|
+
initialValue: [],
|
|
3916
|
+
in: {
|
|
3917
|
+
$concatArrays: [
|
|
3918
|
+
'$$value',
|
|
3919
|
+
{ $ifNull: [ '$$this.Details', [] ] },
|
|
3920
|
+
],
|
|
3921
|
+
},
|
|
3922
|
+
},
|
|
3923
|
+
},
|
|
3924
|
+
],
|
|
3925
|
+
},
|
|
3926
|
+
},
|
|
3927
|
+
},
|
|
3928
|
+
as: 'detail',
|
|
3929
|
+
in: {
|
|
3930
|
+
$or: [
|
|
3931
|
+
{ $eq: [ '$$detail.status', 'pending' ] },
|
|
3932
|
+
],
|
|
3933
|
+
},
|
|
3934
|
+
},
|
|
3935
|
+
},
|
|
3936
|
+
},
|
|
3937
|
+
},
|
|
3938
|
+
},
|
|
3939
|
+
{
|
|
3940
|
+
$group: {
|
|
3941
|
+
_id: '$floorId',
|
|
3942
|
+
layoutCount: {
|
|
3943
|
+
$sum: { $cond: [ { $eq: [ '$type', 'layout' ] }, 1, 0 ] },
|
|
3944
|
+
},
|
|
3945
|
+
fixtureCount: {
|
|
3946
|
+
$sum: { $cond: [ { $eq: [ '$type', 'fixture' ] }, 1, 0 ] },
|
|
3947
|
+
},
|
|
3948
|
+
vmCount: {
|
|
3949
|
+
$sum: { $cond: [ { $eq: [ '$type', 'vm' ] }, 1, 0 ] },
|
|
3950
|
+
},
|
|
3951
|
+
layoutPending: {
|
|
3952
|
+
$sum: {
|
|
3953
|
+
$cond: [
|
|
3954
|
+
{ $and: [ { $eq: [ '$type', 'layout' ] }, '$hasPendingIssues' ] },
|
|
3955
|
+
1,
|
|
3956
|
+
0,
|
|
3957
|
+
],
|
|
3958
|
+
},
|
|
3959
|
+
},
|
|
3960
|
+
fixturePending: {
|
|
3961
|
+
$sum: {
|
|
3962
|
+
$cond: [
|
|
3963
|
+
{ $and: [ { $eq: [ '$type', 'fixture' ] }, '$hasPendingIssues' ] },
|
|
3964
|
+
1,
|
|
3965
|
+
0,
|
|
3966
|
+
],
|
|
3967
|
+
},
|
|
3968
|
+
},
|
|
3969
|
+
vmPending: {
|
|
3970
|
+
$sum: {
|
|
3971
|
+
$cond: [
|
|
3972
|
+
{ $and: [ { $eq: [ '$type', 'vm' ] }, '$hasPendingIssues' ] },
|
|
3973
|
+
1,
|
|
3974
|
+
0,
|
|
3975
|
+
],
|
|
3976
|
+
},
|
|
3977
|
+
},
|
|
3978
|
+
},
|
|
3979
|
+
},
|
|
3980
|
+
{
|
|
3981
|
+
$group: {
|
|
3982
|
+
_id: null,
|
|
3983
|
+
layoutCount: { $sum: '$layoutCount' },
|
|
3984
|
+
fixtureCount: { $sum: '$fixtureCount' },
|
|
3985
|
+
vmCount: { $sum: '$vmCount' },
|
|
3986
|
+
completeLayout: {
|
|
3987
|
+
$sum: {
|
|
3988
|
+
$cond: {
|
|
3989
|
+
if: {
|
|
3990
|
+
$and: [
|
|
3991
|
+
{ '$gt': [ '$layoutCount', 0 ] },
|
|
3992
|
+
{ '$gt': [ '$layoutPending', 0 ] },
|
|
3993
|
+
{ '$gt': [ '$fixtureCount', 0 ] },
|
|
3994
|
+
{ '$gt': [ '$fixturePending', 0 ] },
|
|
3995
|
+
{ '$gt': [ '$vmCount', 0 ] },
|
|
3996
|
+
{ '$gt': [ '$fixturePending', 0 ] },
|
|
3997
|
+
],
|
|
3998
|
+
},
|
|
3999
|
+
then: 1,
|
|
4000
|
+
else: 0,
|
|
4001
|
+
},
|
|
4002
|
+
},
|
|
4003
|
+
},
|
|
4004
|
+
layoutPending: { $sum: '$layoutPending' },
|
|
4005
|
+
fixturePending: { $sum: '$fixturePending' },
|
|
4006
|
+
vmPending: { $sum: '$vmPending' },
|
|
4007
|
+
},
|
|
4008
|
+
},
|
|
4009
|
+
{
|
|
4010
|
+
$project: {
|
|
4011
|
+
_id: 0,
|
|
4012
|
+
layoutStatus: {
|
|
4013
|
+
$cond: {
|
|
4014
|
+
if: {
|
|
4015
|
+
$and: [
|
|
4016
|
+
{ $gt: [ '$layoutCount', 0 ] },
|
|
4017
|
+
{ $eq: [ '$layoutPending', 0 ] },
|
|
4018
|
+
],
|
|
4019
|
+
},
|
|
4020
|
+
then: 'complete',
|
|
4021
|
+
else: {
|
|
4022
|
+
$cond: {
|
|
4023
|
+
if: {
|
|
4024
|
+
$and: [
|
|
4025
|
+
{
|
|
4026
|
+
$gt: [ '$layoutCount', 0 ],
|
|
4027
|
+
},
|
|
4028
|
+
{
|
|
4029
|
+
$gt: [
|
|
4030
|
+
'$layoutPending',
|
|
4031
|
+
0,
|
|
4032
|
+
],
|
|
4033
|
+
},
|
|
4034
|
+
],
|
|
4035
|
+
},
|
|
4036
|
+
then: 'pending',
|
|
4037
|
+
else: '',
|
|
4038
|
+
},
|
|
4039
|
+
},
|
|
4040
|
+
},
|
|
4041
|
+
},
|
|
4042
|
+
fixtureStatus: {
|
|
4043
|
+
$cond: {
|
|
4044
|
+
if: {
|
|
4045
|
+
$and: [
|
|
4046
|
+
{ $gt: [ '$fixtureCount', 0 ] },
|
|
4047
|
+
{
|
|
4048
|
+
$eq: [ '$fixturePending', 0 ],
|
|
4049
|
+
},
|
|
4050
|
+
],
|
|
4051
|
+
},
|
|
4052
|
+
then: 'complete',
|
|
4053
|
+
else: {
|
|
4054
|
+
$cond: {
|
|
4055
|
+
if: {
|
|
4056
|
+
$and: [
|
|
4057
|
+
{
|
|
4058
|
+
$gt: [
|
|
4059
|
+
'$fixtureCount',
|
|
4060
|
+
0,
|
|
4061
|
+
],
|
|
4062
|
+
},
|
|
4063
|
+
{
|
|
4064
|
+
$gt: [
|
|
4065
|
+
'$fixturePending',
|
|
4066
|
+
0,
|
|
4067
|
+
],
|
|
4068
|
+
},
|
|
4069
|
+
],
|
|
4070
|
+
},
|
|
4071
|
+
then: 'pending',
|
|
4072
|
+
else: '',
|
|
4073
|
+
},
|
|
4074
|
+
},
|
|
4075
|
+
},
|
|
4076
|
+
},
|
|
4077
|
+
vmStatus: {
|
|
4078
|
+
$cond: {
|
|
4079
|
+
if: {
|
|
4080
|
+
$and: [
|
|
4081
|
+
{ $gt: [ '$vmCount', 0 ] },
|
|
4082
|
+
{ $eq: [ '$vmPending', 0 ] },
|
|
4083
|
+
],
|
|
4084
|
+
},
|
|
4085
|
+
then: 'complete',
|
|
4086
|
+
else: {
|
|
4087
|
+
$cond: {
|
|
4088
|
+
if: {
|
|
4089
|
+
$and: [
|
|
4090
|
+
{ $gt: [ '$vmCount', 0 ] },
|
|
4091
|
+
{ $gt: [ '$vmPending', 0 ] },
|
|
4092
|
+
],
|
|
4093
|
+
},
|
|
4094
|
+
then: 'pending',
|
|
4095
|
+
else: '',
|
|
4096
|
+
},
|
|
4097
|
+
},
|
|
4098
|
+
},
|
|
4099
|
+
},
|
|
4100
|
+
layoutPending: 1,
|
|
4101
|
+
fixturePending: 1,
|
|
4102
|
+
vmPending: 1,
|
|
4103
|
+
layoutCount: 1,
|
|
4104
|
+
fixtureCount: 1,
|
|
4105
|
+
vmCount: 1,
|
|
4106
|
+
completeLayout: 1,
|
|
4107
|
+
},
|
|
4108
|
+
},
|
|
4109
|
+
],
|
|
4110
|
+
as: 'taskDetails',
|
|
4111
|
+
},
|
|
4112
|
+
},
|
|
4113
|
+
{
|
|
4114
|
+
$project: {
|
|
4115
|
+
_id: 0,
|
|
4116
|
+
taskStatus: {
|
|
4117
|
+
$map: {
|
|
4118
|
+
input: '$taskStatus',
|
|
4119
|
+
as: 'task',
|
|
4120
|
+
in: {
|
|
4121
|
+
type: '$$task.type',
|
|
4122
|
+
status: '$$task.status',
|
|
4123
|
+
date: '$$task.date',
|
|
4124
|
+
floorId: '$$task.floorId',
|
|
4125
|
+
redoStatus: '$$task.redoStatus',
|
|
4126
|
+
endTime: '$$task.endTime',
|
|
4127
|
+
feedbackStatus: {
|
|
4128
|
+
$switch: {
|
|
4129
|
+
branches: [
|
|
4130
|
+
{
|
|
4131
|
+
case: { $eq: [ '$$task.type', 'layout' ] },
|
|
4132
|
+
then: { $arrayElemAt: [ '$taskDetails.layoutStatus', 0 ] },
|
|
4133
|
+
},
|
|
4134
|
+
{
|
|
4135
|
+
case: { $eq: [ '$$task.type', 'fixture' ] },
|
|
4136
|
+
then: { $arrayElemAt: [ '$taskDetails.fixtureStatus', 0 ] },
|
|
4137
|
+
},
|
|
4138
|
+
{
|
|
4139
|
+
case: { $eq: [ '$$task.type', 'vm' ] },
|
|
4140
|
+
then: { $arrayElemAt: [ '$taskDetails.vmStatus', 0 ] },
|
|
4141
|
+
},
|
|
4142
|
+
],
|
|
4143
|
+
default: '',
|
|
4144
|
+
},
|
|
4145
|
+
},
|
|
4146
|
+
},
|
|
4147
|
+
},
|
|
4148
|
+
},
|
|
4149
|
+
},
|
|
4150
|
+
},
|
|
4151
|
+
|
|
4152
|
+
];
|
|
4153
|
+
|
|
4154
|
+
let taskInfo = await planotaskService.aggregate( query );
|
|
4155
|
+
let disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ele.feedbackStatus != 'complete' ) || ele.status != 'submit' ) && dayjs( ele.endTime ).format( 'YYYY-MM-DD' ) >= dayjs().format( 'YYYY-MM-DD' ) );
|
|
4156
|
+
return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus, disabled: disabledInfo?.length ? true : false } );
|
|
4157
|
+
} catch ( e ) {
|
|
4158
|
+
logger.error( { functionName: 'getTaskDetails', error: e } );
|
|
4159
|
+
return res.sendError( e, 500 );
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
@@ -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
|
}
|