tango-app-api-store-builder 1.0.0-beta-153 → 1.0.0-beta-155
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 +2 -2
- package/src/controllers/managePlano.controller.js +100 -129
- package/src/controllers/planoLibrary.controller.js +2 -2
- package/src/controllers/script.controller.js +19 -4
- package/src/controllers/storeBuilder.controller.js +59 -103
- package/src/controllers/task.controller.js +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-store-builder",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-155",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"path": "^0.12.7",
|
|
33
33
|
"selenium-webdriver": "^4.31.0",
|
|
34
34
|
"sharp": "^0.34.1",
|
|
35
|
-
"tango-api-schema": "^2.2.
|
|
35
|
+
"tango-api-schema": "^2.2.192",
|
|
36
36
|
"tango-app-api-middleware": "3.1.48",
|
|
37
37
|
"url": "^0.11.4",
|
|
38
38
|
"winston": "^3.17.0",
|
|
@@ -20,7 +20,7 @@ export async function getplanoFeedback( req, res ) {
|
|
|
20
20
|
try {
|
|
21
21
|
const taskTypes = req.body.filterByTask && req.body.filterByTask.length > 0 ? req.body.filterByTask : [ 'layout', 'fixture', 'vm' ];
|
|
22
22
|
const filterByStatus = req.body.filterByStatus || [];
|
|
23
|
-
const filterByApprovalStatus = req.body.filterByApprovalStatus ||
|
|
23
|
+
const filterByApprovalStatus = req.body.filterByApprovalStatus || '';
|
|
24
24
|
const resultMap = {};
|
|
25
25
|
const commentMap = {};
|
|
26
26
|
console.log( taskTypes );
|
|
@@ -28,8 +28,25 @@ export async function getplanoFeedback( req, res ) {
|
|
|
28
28
|
taskTypes.map( async ( type, index ) => {
|
|
29
29
|
const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask );
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
let data = await planoTaskService.aggregate( pipeline );
|
|
32
|
+
if ( filterByApprovalStatus && filterByApprovalStatus !== '' ) {
|
|
33
|
+
console.log( '-------------1', filterByApprovalStatus );
|
|
34
|
+
data.forEach( ( element ) => {
|
|
35
|
+
element.answers?.forEach( ( ans ) => {
|
|
36
|
+
ans.issues = ans.issues?.filter(
|
|
37
|
+
( issue ) => issue.Details && issue.Details.length > 0,
|
|
38
|
+
);
|
|
39
|
+
} );
|
|
40
|
+
element.answers = element.answers?.filter(
|
|
41
|
+
( ans ) => ans.issues && ans.issues.length > 0,
|
|
42
|
+
);
|
|
43
|
+
} );
|
|
44
|
+
data = data.filter(
|
|
45
|
+
( element ) => element.answers && element.answers.length > 0,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
33
50
|
resultMap[type] = data;
|
|
34
51
|
|
|
35
52
|
const comments = await planoGlobalCommentService.find( {
|
|
@@ -67,29 +84,38 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
67
84
|
},
|
|
68
85
|
};
|
|
69
86
|
|
|
70
|
-
|
|
87
|
+
|
|
88
|
+
const conditionalMatchExpr = showtask ?
|
|
89
|
+
{
|
|
90
|
+
$eq: [ '$_id', '$$taskId' ],
|
|
91
|
+
} :
|
|
92
|
+
{
|
|
93
|
+
$and: [
|
|
94
|
+
{
|
|
95
|
+
$eq: [ '$_id', '$$taskId' ],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
$or: [
|
|
99
|
+
{ $eq: [ '$redoStatus', true ] },
|
|
100
|
+
{
|
|
101
|
+
$and: [
|
|
102
|
+
{ $eq: [ '$redoStatus', false ] },
|
|
103
|
+
{ $eq: [ '$checklistStatus', 'submit' ] },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const taskLookup = {
|
|
71
112
|
$lookup: {
|
|
72
113
|
from: 'processedtasks',
|
|
73
114
|
let: { taskId: '$taskId' },
|
|
74
115
|
pipeline: [
|
|
75
116
|
{
|
|
76
117
|
$match: {
|
|
77
|
-
$expr:
|
|
78
|
-
$and: [
|
|
79
|
-
{ $eq: [ '$_id', '$$taskId' ] },
|
|
80
|
-
{
|
|
81
|
-
$or: [
|
|
82
|
-
{ $eq: [ '$redoStatus', true ] },
|
|
83
|
-
{
|
|
84
|
-
$and: [
|
|
85
|
-
{ $eq: [ '$redoStatus', false ] },
|
|
86
|
-
{ $eq: [ '$checklistStatus', 'submit' ] },
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
},
|
|
118
|
+
$expr: conditionalMatchExpr,
|
|
93
119
|
},
|
|
94
120
|
},
|
|
95
121
|
{
|
|
@@ -104,34 +130,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
104
130
|
as: 'taskData',
|
|
105
131
|
},
|
|
106
132
|
};
|
|
107
|
-
|
|
108
|
-
taskLookup = {
|
|
109
|
-
$lookup: {
|
|
110
|
-
from: 'processedtasks',
|
|
111
|
-
let: { taskId: '$taskId' },
|
|
112
|
-
pipeline: [
|
|
113
|
-
{
|
|
114
|
-
$match: {
|
|
115
|
-
$expr: {
|
|
116
|
-
$and: [
|
|
117
|
-
{ $eq: [ '$_id', '$$taskId' ] },
|
|
118
|
-
],
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
$project: {
|
|
124
|
-
userName: 1,
|
|
125
|
-
createdAt: 1,
|
|
126
|
-
createdByName: 1,
|
|
127
|
-
submitTime_string: 1,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
as: 'taskData',
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
}
|
|
133
|
+
|
|
135
134
|
|
|
136
135
|
const unwindTask = { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: false } };
|
|
137
136
|
|
|
@@ -258,98 +257,54 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
258
257
|
{ $sort: { _id: -1 } },
|
|
259
258
|
];
|
|
260
259
|
if ( filterByApprovalStatus && filterByApprovalStatus != '' ) {
|
|
261
|
-
let filterByApprovalCond = { $eq: filterByApprovalStatus };
|
|
262
|
-
|
|
263
|
-
console.log( '*********************', filterByApprovalCond );
|
|
264
260
|
pipeline = [];
|
|
265
261
|
pipeline.push( matchStage );
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
{
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
{
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
],
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
],
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
);
|
|
306
|
-
} else {
|
|
307
|
-
pipeline.push(
|
|
308
|
-
{
|
|
309
|
-
$addFields: {
|
|
310
|
-
answers: {
|
|
311
|
-
$map: {
|
|
312
|
-
input: '$answers',
|
|
313
|
-
as: 'ans',
|
|
314
|
-
in: {
|
|
315
|
-
$mergeObjects: [
|
|
316
|
-
'$$ans',
|
|
317
|
-
{
|
|
318
|
-
issues: {
|
|
319
|
-
$map: {
|
|
320
|
-
input: '$$ans.issues',
|
|
321
|
-
as: 'issue',
|
|
322
|
-
in: {
|
|
323
|
-
$mergeObjects: [
|
|
324
|
-
'$$issue',
|
|
325
|
-
{
|
|
326
|
-
Details: {
|
|
327
|
-
$filter: {
|
|
328
|
-
input: '$$issue.Details',
|
|
329
|
-
as: 'detail',
|
|
330
|
-
cond: { $ne: [ '$$detail.status', 'pending' ] },
|
|
331
|
-
},
|
|
262
|
+
pipeline.push(
|
|
263
|
+
{
|
|
264
|
+
$addFields: {
|
|
265
|
+
answers: {
|
|
266
|
+
$map: {
|
|
267
|
+
input: '$answers',
|
|
268
|
+
as: 'ans',
|
|
269
|
+
in: {
|
|
270
|
+
$mergeObjects: [
|
|
271
|
+
'$$ans',
|
|
272
|
+
{
|
|
273
|
+
issues: {
|
|
274
|
+
$map: {
|
|
275
|
+
input: '$$ans.issues',
|
|
276
|
+
as: 'issue',
|
|
277
|
+
in: {
|
|
278
|
+
$mergeObjects: [
|
|
279
|
+
'$$issue',
|
|
280
|
+
{
|
|
281
|
+
Details: {
|
|
282
|
+
$filter: {
|
|
283
|
+
input: '$$issue.Details',
|
|
284
|
+
as: 'detail',
|
|
285
|
+
cond: filterByApprovalStatus === 'pending' ?
|
|
286
|
+
{ $eq: [ '$$detail.status', 'pending' ] } :
|
|
287
|
+
{ $ne: [ '$$detail.status', 'pending' ] },
|
|
332
288
|
},
|
|
333
289
|
},
|
|
334
|
-
|
|
335
|
-
|
|
290
|
+
},
|
|
291
|
+
],
|
|
336
292
|
},
|
|
337
293
|
},
|
|
338
294
|
},
|
|
339
|
-
|
|
340
|
-
|
|
295
|
+
},
|
|
296
|
+
],
|
|
341
297
|
},
|
|
342
298
|
},
|
|
343
299
|
},
|
|
344
300
|
},
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
);
|
|
348
|
-
}
|
|
301
|
+
},
|
|
302
|
+
);
|
|
349
303
|
pipeline.push( taskLookup );
|
|
350
304
|
pipeline.push( unwindTask );
|
|
351
305
|
pipeline.push( ...commonLookups );
|
|
352
306
|
pipeline.push( ...vmStages );
|
|
307
|
+
pipeline.push( { $sort: { _id: -1 } } );
|
|
353
308
|
}
|
|
354
309
|
|
|
355
310
|
|
|
@@ -448,7 +403,8 @@ export async function updateStorePlano( req, res ) {
|
|
|
448
403
|
} );
|
|
449
404
|
|
|
450
405
|
await floorService.updateOne( { _id: new mongoose.Types.ObjectId( floorId ) },
|
|
451
|
-
{
|
|
406
|
+
{
|
|
407
|
+
layoutPolygon: layoutPolygon,
|
|
452
408
|
...( req.body?.editMode === true && { isEdited: true } ),
|
|
453
409
|
} );
|
|
454
410
|
|
|
@@ -519,7 +475,7 @@ export async function updateStorePlano( req, res ) {
|
|
|
519
475
|
}
|
|
520
476
|
} );
|
|
521
477
|
|
|
522
|
-
await planoService.updateOne( { _id: floorData.toObject()
|
|
478
|
+
await planoService.updateOne( { _id: floorData.toObject()?.planoId }, { $set: { updatedAt: new Date() } } );
|
|
523
479
|
|
|
524
480
|
res.sendSuccess( 'Updated Successfully' );
|
|
525
481
|
} catch ( e ) {
|
|
@@ -676,7 +632,7 @@ export async function updateFixtureStatus( req, res ) {
|
|
|
676
632
|
},
|
|
677
633
|
|
|
678
634
|
);
|
|
679
|
-
if ( vmTask.length>0 ) {
|
|
635
|
+
if ( vmTask.length > 0 ) {
|
|
680
636
|
let allTaskDone = vmTask.filter( ( data ) => data.status === 'incomplete' );
|
|
681
637
|
if ( allTaskDone.length === 0 ) {
|
|
682
638
|
await floorService.updateOne( { _id: new mongoose.Types.ObjectId( req.body.floorId ) }, { planoProgress: 100 } );
|
|
@@ -700,9 +656,21 @@ export async function updateStoreFixture( req, res ) {
|
|
|
700
656
|
const productCategory = new Set();
|
|
701
657
|
const productSubCategory = new Set();
|
|
702
658
|
|
|
659
|
+
let fixtureCapacity = 0;
|
|
660
|
+
|
|
703
661
|
data.shelfConfig.forEach( ( shelf ) => {
|
|
704
662
|
const { productBrandName: brand, productCategory: category, productSubCategory: subCategory } = shelf;
|
|
705
663
|
|
|
664
|
+
if ( typeof shelf?.productPerShelf === 'number' ) {
|
|
665
|
+
if ( shelf?.shelfType === 'shelf' ) {
|
|
666
|
+
fixtureCapacity+=shelf.productPerShelf;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
if ( shelf?.shelfType === 'tray' ) {
|
|
670
|
+
fixtureCapacity+=( shelf?.productPerShelf * shelf?.trayRows );
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
706
674
|
if ( Array.isArray( brand ) ) {
|
|
707
675
|
brand.forEach( ( b ) => productBrandName.add( b ) );
|
|
708
676
|
}
|
|
@@ -723,6 +691,7 @@ export async function updateStoreFixture( req, res ) {
|
|
|
723
691
|
...currentFixtureDoc,
|
|
724
692
|
...newTemplate.toObject(),
|
|
725
693
|
fixtureConfigId: newTemplate.toObject()._id,
|
|
694
|
+
fixtureCapacity: fixtureCapacity,
|
|
726
695
|
productBrandName: [ ...productBrandName ],
|
|
727
696
|
productCategory: [ ...productCategory ],
|
|
728
697
|
productSubCategory: [ ...productSubCategory ],
|
|
@@ -731,6 +700,7 @@ export async function updateStoreFixture( req, res ) {
|
|
|
731
700
|
currentFixtureDoc = {
|
|
732
701
|
...currentFixtureDoc,
|
|
733
702
|
...data,
|
|
703
|
+
fixtureCapacity: fixtureCapacity,
|
|
734
704
|
productBrandName: [ ...productBrandName ],
|
|
735
705
|
productCategory: [ ...productCategory ],
|
|
736
706
|
productSubCategory: [ ...productSubCategory ],
|
|
@@ -767,6 +737,7 @@ export async function updateStoreFixture( req, res ) {
|
|
|
767
737
|
await fixtureShelfService.create( { ...additionalMeta, ...shelf } );
|
|
768
738
|
} );
|
|
769
739
|
}
|
|
740
|
+
await planoService.updateOne( { _id: currentFixtureDoc?.planoId }, { $set: { updatedAt: new Date() } } );
|
|
770
741
|
|
|
771
742
|
res.sendSuccess( 'Updated Successfully' );
|
|
772
743
|
} catch ( e ) {
|
|
@@ -816,7 +787,7 @@ export async function updateredostatus( req, res ) {
|
|
|
816
787
|
|
|
817
788
|
export async function updateGlobalComment( req, res ) {
|
|
818
789
|
try {
|
|
819
|
-
let payload ={
|
|
790
|
+
let payload = {
|
|
820
791
|
userId: req.user._id,
|
|
821
792
|
userName: req.user.userName,
|
|
822
793
|
comment: req.body.comment,
|
|
@@ -808,8 +808,8 @@ export async function uploadBrandList( req, res ) {
|
|
|
808
808
|
acc[ele['Brand Name']] = {
|
|
809
809
|
brandName: ele['Brand Name'],
|
|
810
810
|
clientId: inputData.clientId,
|
|
811
|
-
category: [ ...new Set( category?.filter( ( ele ) => ele ).map( ( ele ) => ele ) ) ],
|
|
812
|
-
subCategory: [ ...new Set( subCategory?.filter( ( ele ) => ele ).map( ( ele ) => ele ) ) ],
|
|
811
|
+
category: [ ...new Set( category?.filter( ( ele ) => ele.trim() ).map( ( ele ) => ele.trim() ) ) ],
|
|
812
|
+
subCategory: [ ...new Set( subCategory?.filter( ( ele ) => ele.trim() ).map( ( ele ) => ele.trim() ) ) ],
|
|
813
813
|
};
|
|
814
814
|
} else {
|
|
815
815
|
category.forEach( ( cat ) => {
|
|
@@ -7630,6 +7630,7 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7630
7630
|
|
|
7631
7631
|
let fixtureCounter = 1;
|
|
7632
7632
|
|
|
7633
|
+
let leftAssociatedElementFixtureNumber = 1;
|
|
7633
7634
|
|
|
7634
7635
|
for ( let index = 0; index < leftFixtures.length; index++ ) {
|
|
7635
7636
|
const fixture = leftFixtures[index];
|
|
@@ -7879,10 +7880,12 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7879
7880
|
// 'y': 0,
|
|
7880
7881
|
// 'unit': 'ft',
|
|
7881
7882
|
// },
|
|
7882
|
-
'associatedElementFixtureNumber':
|
|
7883
|
+
'associatedElementFixtureNumber': leftAssociatedElementFixtureNumber,
|
|
7883
7884
|
'fixtureConfigId': fixtureTemplate.toObject()._id,
|
|
7884
7885
|
};
|
|
7885
7886
|
|
|
7887
|
+
leftAssociatedElementFixtureNumber += 1;
|
|
7888
|
+
|
|
7886
7889
|
delete fixtureData._id;
|
|
7887
7890
|
delete fixtureData.shelfConfig;
|
|
7888
7891
|
|
|
@@ -7925,6 +7928,8 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7925
7928
|
} );
|
|
7926
7929
|
}
|
|
7927
7930
|
|
|
7931
|
+
let backAssociatedElementFixtureNumber = 1;
|
|
7932
|
+
|
|
7928
7933
|
for ( let index = 0; index < backFixtures.length; index++ ) {
|
|
7929
7934
|
const fixture = backFixtures[index];
|
|
7930
7935
|
|
|
@@ -8172,10 +8177,12 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8172
8177
|
// 'y': roundToTwo( ( ( index * ( ( constantDetailedFixtureWidth/mmToFeet ) ) ) + ( ( leftFixtures.length ? 1 : 0 ) * constantDetailedFixtureWidth/mmToFeet ) ) ),
|
|
8173
8178
|
// 'unit': 'ft',
|
|
8174
8179
|
// },
|
|
8175
|
-
'associatedElementFixtureNumber':
|
|
8180
|
+
'associatedElementFixtureNumber': backAssociatedElementFixtureNumber,
|
|
8176
8181
|
'fixtureConfigId': fixtureTemplate.toObject()._id,
|
|
8177
8182
|
};
|
|
8178
8183
|
|
|
8184
|
+
backAssociatedElementFixtureNumber += 1;
|
|
8185
|
+
|
|
8179
8186
|
delete fixtureData._id;
|
|
8180
8187
|
delete fixtureData.shelfConfig;
|
|
8181
8188
|
|
|
@@ -8218,6 +8225,8 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8218
8225
|
} );
|
|
8219
8226
|
}
|
|
8220
8227
|
|
|
8228
|
+
let rightAssociatedElementFixtureNumber = 1;
|
|
8229
|
+
|
|
8221
8230
|
for ( let index = 0; index < rightFixtures.length; index++ ) {
|
|
8222
8231
|
const fixture = rightFixtures[index];
|
|
8223
8232
|
|
|
@@ -8465,10 +8474,12 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8465
8474
|
// 'y': roundToTwo( ( finalYDetailedDistance - ( constantDetailedFixtureWidth / mmToFeet ) ) ),
|
|
8466
8475
|
// 'unit': 'ft',
|
|
8467
8476
|
// },
|
|
8468
|
-
'associatedElementFixtureNumber':
|
|
8477
|
+
'associatedElementFixtureNumber': rightAssociatedElementFixtureNumber,
|
|
8469
8478
|
'fixtureConfigId': fixtureTemplate.toObject()._id,
|
|
8470
8479
|
};
|
|
8471
8480
|
|
|
8481
|
+
rightAssociatedElementFixtureNumber += 1;
|
|
8482
|
+
|
|
8472
8483
|
delete fixtureData._id;
|
|
8473
8484
|
delete fixtureData.shelfConfig;
|
|
8474
8485
|
|
|
@@ -8511,6 +8522,8 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8511
8522
|
} );
|
|
8512
8523
|
}
|
|
8513
8524
|
|
|
8525
|
+
let centerAssociatedElementFixtureNumber = 1;
|
|
8526
|
+
|
|
8514
8527
|
for ( let index = 0; index < floorFixtures.length; index++ ) {
|
|
8515
8528
|
const fixture = floorFixtures[index];
|
|
8516
8529
|
|
|
@@ -8746,10 +8759,12 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8746
8759
|
// 'y': detailedYPos,
|
|
8747
8760
|
// 'unit': 'ft',
|
|
8748
8761
|
// },
|
|
8749
|
-
'associatedElementFixtureNumber':
|
|
8762
|
+
'associatedElementFixtureNumber': centerAssociatedElementFixtureNumber,
|
|
8750
8763
|
'fixtureConfigId': fixtureTemplate.toObject()._id,
|
|
8751
8764
|
};
|
|
8752
8765
|
|
|
8766
|
+
centerAssociatedElementFixtureNumber += 1;
|
|
8767
|
+
|
|
8753
8768
|
delete fixtureData._id;
|
|
8754
8769
|
delete fixtureData.shelfConfig;
|
|
8755
8770
|
|
|
@@ -3349,8 +3349,6 @@ export async function planoList( req, res ) {
|
|
|
3349
3349
|
$lookup: {
|
|
3350
3350
|
from: 'planotaskcompliances',
|
|
3351
3351
|
let: {
|
|
3352
|
-
// plano: '$_id',
|
|
3353
|
-
task: { $ifNull: [ '$taskIds', [] ] },
|
|
3354
3352
|
floor: '$layout.id',
|
|
3355
3353
|
},
|
|
3356
3354
|
pipeline: [
|
|
@@ -3358,10 +3356,8 @@ export async function planoList( req, res ) {
|
|
|
3358
3356
|
$match: {
|
|
3359
3357
|
$expr: {
|
|
3360
3358
|
$and: [
|
|
3361
|
-
// { $eq: [ '$planoId', '$$plano' ] },
|
|
3362
3359
|
{ $eq: [ '$floorId', '$$floor' ] },
|
|
3363
|
-
|
|
3364
|
-
// { $eq: [ '$taskType', 'initial' ] },
|
|
3360
|
+
{ $eq: [ '$status', 'incomplete' ] },
|
|
3365
3361
|
],
|
|
3366
3362
|
},
|
|
3367
3363
|
},
|
|
@@ -3443,7 +3439,7 @@ export async function planoList( req, res ) {
|
|
|
3443
3439
|
},
|
|
3444
3440
|
{
|
|
3445
3441
|
$group: {
|
|
3446
|
-
_id: '',
|
|
3442
|
+
_id: '$floorId',
|
|
3447
3443
|
layoutCount: {
|
|
3448
3444
|
$sum: { $cond: [ { $eq: [ '$type', 'layout' ] }, 1, 0 ] },
|
|
3449
3445
|
},
|
|
@@ -3509,38 +3505,6 @@ export async function planoList( req, res ) {
|
|
|
3509
3505
|
},
|
|
3510
3506
|
},
|
|
3511
3507
|
},
|
|
3512
|
-
// {
|
|
3513
|
-
// $group: {
|
|
3514
|
-
// _id: null,
|
|
3515
|
-
// layoutCount: { $sum: '$layoutCount' },
|
|
3516
|
-
// fixtureCount: { $sum: '$fixtureCount' },
|
|
3517
|
-
// vmCount: { $sum: '$vmCount' },
|
|
3518
|
-
// completeLayout: {
|
|
3519
|
-
// $sum: {
|
|
3520
|
-
// $cond: {
|
|
3521
|
-
// if: {
|
|
3522
|
-
// $and: [
|
|
3523
|
-
// { '$gt': [ '$layoutCount', 0 ] },
|
|
3524
|
-
// { '$gt': [ '$layoutPending', 0 ] },
|
|
3525
|
-
// { '$gt': [ '$fixtureCount', 0 ] },
|
|
3526
|
-
// { '$gt': [ '$fixturePending', 0 ] },
|
|
3527
|
-
// { '$gt': [ '$vmCount', 0 ] },
|
|
3528
|
-
// { '$gt': [ '$fixturePending', 0 ] },
|
|
3529
|
-
// ],
|
|
3530
|
-
// },
|
|
3531
|
-
// then: 1,
|
|
3532
|
-
// else: 0,
|
|
3533
|
-
// },
|
|
3534
|
-
// },
|
|
3535
|
-
// },
|
|
3536
|
-
// layoutPending: { $sum: '$layoutPending' },
|
|
3537
|
-
// fixturePending: { $sum: '$fixturePending' },
|
|
3538
|
-
// vmPending: { $sum: '$vmPending' },
|
|
3539
|
-
// layoutDisagree: { $sum: '$layoutDisagree' },
|
|
3540
|
-
// fixtureDisagree: { $sum: '$fixtureDisagree' },
|
|
3541
|
-
// vmDisagree: { $sum: '$vmDisagree' },
|
|
3542
|
-
// },
|
|
3543
|
-
// },
|
|
3544
3508
|
{
|
|
3545
3509
|
$project: {
|
|
3546
3510
|
_id: 0,
|
|
@@ -3601,7 +3565,9 @@ export async function planoList( req, res ) {
|
|
|
3601
3565
|
{
|
|
3602
3566
|
$eq: [ '$fixturePending', 0 ],
|
|
3603
3567
|
},
|
|
3604
|
-
{
|
|
3568
|
+
{
|
|
3569
|
+
$eq: [ '$fixtureDisagree', 0 ],
|
|
3570
|
+
},
|
|
3605
3571
|
],
|
|
3606
3572
|
},
|
|
3607
3573
|
then: 'complete',
|
|
@@ -3629,39 +3595,18 @@ export async function planoList( req, res ) {
|
|
|
3629
3595
|
if: {
|
|
3630
3596
|
$and: [
|
|
3631
3597
|
{
|
|
3632
|
-
$gt: [
|
|
3633
|
-
'$fixtureCount',
|
|
3634
|
-
0,
|
|
3635
|
-
],
|
|
3598
|
+
$gt: [ '$fixtureCount', 0 ],
|
|
3636
3599
|
},
|
|
3637
3600
|
{
|
|
3638
3601
|
$gt: [
|
|
3639
|
-
'$
|
|
3602
|
+
'$fixtureDisagree',
|
|
3640
3603
|
0,
|
|
3641
3604
|
],
|
|
3642
3605
|
},
|
|
3643
3606
|
],
|
|
3644
3607
|
},
|
|
3645
|
-
then: '
|
|
3646
|
-
else:
|
|
3647
|
-
$cond: {
|
|
3648
|
-
if: {
|
|
3649
|
-
$and: [
|
|
3650
|
-
{
|
|
3651
|
-
$gt: [ '$fixtureCount', 0 ],
|
|
3652
|
-
},
|
|
3653
|
-
{
|
|
3654
|
-
$gt: [
|
|
3655
|
-
'$fixtureDisagree',
|
|
3656
|
-
0,
|
|
3657
|
-
],
|
|
3658
|
-
},
|
|
3659
|
-
],
|
|
3660
|
-
},
|
|
3661
|
-
then: 'disagree',
|
|
3662
|
-
else: '',
|
|
3663
|
-
},
|
|
3664
|
-
},
|
|
3608
|
+
then: 'disagree',
|
|
3609
|
+
else: '',
|
|
3665
3610
|
},
|
|
3666
3611
|
},
|
|
3667
3612
|
},
|
|
@@ -3716,7 +3661,7 @@ export async function planoList( req, res ) {
|
|
|
3716
3661
|
layoutCount: 1,
|
|
3717
3662
|
fixtureCount: 1,
|
|
3718
3663
|
vmCount: 1,
|
|
3719
|
-
completeLayout: 1,
|
|
3664
|
+
// completeLayout: 1,
|
|
3720
3665
|
layoutDisagree: 1,
|
|
3721
3666
|
fixtureDisagree: 1,
|
|
3722
3667
|
vmDisagree: 1,
|
|
@@ -3739,9 +3684,20 @@ export async function planoList( req, res ) {
|
|
|
3739
3684
|
planoProgress: 1,
|
|
3740
3685
|
createdAt: 1,
|
|
3741
3686
|
lastUpdate: '$updatedAt',
|
|
3742
|
-
taskDetails: { $ifNull: [ { $arrayElemAt: [ '$taskDetails', 0 ] }, {} ] },
|
|
3743
3687
|
planoTask: { $ifNull: [ '$planoTask', [] ] },
|
|
3744
3688
|
layoutCount: 1,
|
|
3689
|
+
taskDetails: {
|
|
3690
|
+
$let: {
|
|
3691
|
+
vars: {
|
|
3692
|
+
task: { $arrayElemAt: [ '$taskDetails', 0 ] },
|
|
3693
|
+
},
|
|
3694
|
+
in: {
|
|
3695
|
+
layoutStatus: { $ifNull: [ '$$task.layoutStatus', '' ] },
|
|
3696
|
+
fixtureStatus: { $ifNull: [ '$$task.fixtureStatus', '' ] },
|
|
3697
|
+
vmStatus: { $ifNull: [ '$$task.vmStatus', '' ] },
|
|
3698
|
+
},
|
|
3699
|
+
},
|
|
3700
|
+
},
|
|
3745
3701
|
},
|
|
3746
3702
|
},
|
|
3747
3703
|
];
|
|
@@ -3850,7 +3806,7 @@ export async function planoList( req, res ) {
|
|
|
3850
3806
|
} );
|
|
3851
3807
|
}
|
|
3852
3808
|
if ( inputData.filter.status.includes( 'completed' ) ) {
|
|
3853
|
-
orQuery.push( { $and: [ { 'taskDetails.layoutStatus': '
|
|
3809
|
+
orQuery.push( { $and: [ { 'taskDetails.layoutStatus': '' }, { 'taskDetails.fixtureStatus': '' }, { 'taskDetails.vmStatus': '' } ] } );
|
|
3854
3810
|
}
|
|
3855
3811
|
if ( inputData.filter.status.includes( 'yetToAssign' ) ) {
|
|
3856
3812
|
orQuery.push( { $expr: { $eq: [ { $size: '$planoTask' }, 0 ] } } );
|
|
@@ -4283,41 +4239,41 @@ export async function getTaskDetails( req, res ) {
|
|
|
4283
4239
|
},
|
|
4284
4240
|
},
|
|
4285
4241
|
},
|
|
4286
|
-
{
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
},
|
|
4242
|
+
// {
|
|
4243
|
+
// $group: {
|
|
4244
|
+
// _id: null,
|
|
4245
|
+
// layoutCount: { $sum: '$layoutCount' },
|
|
4246
|
+
// fixtureCount: { $sum: '$fixtureCount' },
|
|
4247
|
+
// vmCount: { $sum: '$vmCount' },
|
|
4248
|
+
// completeLayout: {
|
|
4249
|
+
// $sum: {
|
|
4250
|
+
// $cond: {
|
|
4251
|
+
// if: {
|
|
4252
|
+
// $and: [
|
|
4253
|
+
// { '$gt': [ '$layoutCount', 0 ] },
|
|
4254
|
+
// { '$eq': [ '$layoutPending', 0 ] },
|
|
4255
|
+
// { '$eq': [ '$layoutDisagree', 0 ] },
|
|
4256
|
+
// { '$gt': [ '$fixtureCount', 0 ] },
|
|
4257
|
+
// { '$eq': [ '$fixturePending', 0 ] },
|
|
4258
|
+
// { '$eq': [ '$fixtureDisagree', 0 ] },
|
|
4259
|
+
// { '$gt': [ '$vmCount', 0 ] },
|
|
4260
|
+
// { '$eq': [ '$vmPending', 0 ] },
|
|
4261
|
+
// { '$eq': [ '$vmDisagree', 0 ] },
|
|
4262
|
+
// ],
|
|
4263
|
+
// },
|
|
4264
|
+
// then: 1,
|
|
4265
|
+
// else: 0,
|
|
4266
|
+
// },
|
|
4267
|
+
// },
|
|
4268
|
+
// },
|
|
4269
|
+
// layoutPending: { $sum: '$layoutPending' },
|
|
4270
|
+
// fixturePending: { $sum: '$fixturePending' },
|
|
4271
|
+
// vmPending: { $sum: '$vmPending' },
|
|
4272
|
+
// layoutDisagree: { $sum: '$layoutDisagree' },
|
|
4273
|
+
// fixtureDisagree: { $sum: '$fixtureDisagree' },
|
|
4274
|
+
// vmDisagree: { $sum: '$vmDisagree' },
|
|
4275
|
+
// },
|
|
4276
|
+
// },
|
|
4321
4277
|
{
|
|
4322
4278
|
$project: {
|
|
4323
4279
|
_id: 0,
|
|
@@ -4474,7 +4430,7 @@ export async function getTaskDetails( req, res ) {
|
|
|
4474
4430
|
layoutCount: 1,
|
|
4475
4431
|
fixtureCount: 1,
|
|
4476
4432
|
vmCount: 1,
|
|
4477
|
-
completeLayout: 1,
|
|
4433
|
+
// completeLayout: 1,
|
|
4478
4434
|
layoutDisagree: 1,
|
|
4479
4435
|
fixtureDisagree: 1,
|
|
4480
4436
|
vmDisagree: 1,
|
|
@@ -4,7 +4,7 @@ import * as storeService from '../service/store.service.js';
|
|
|
4
4
|
import * as processedChecklistService from '../service/processedchecklist.service.js';
|
|
5
5
|
import * as userService from '../service/user.service.js';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
|
-
import { logger, fileUpload, signedUrl, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
7
|
+
import { logger, fileUpload, signedUrl, insertOpenSearchData, sendMessageToQueue } from 'tango-app-api-middleware';
|
|
8
8
|
import * as planoTaskService from '../service/planoTask.service.js';
|
|
9
9
|
import * as planoService from '../service/planogram.service.js';
|
|
10
10
|
import * as checklistService from '../service/checklist.service.js';
|
|
@@ -145,7 +145,8 @@ export async function createTask( req, res ) {
|
|
|
145
145
|
if ( req.body?.endTime ) {
|
|
146
146
|
scheduleEndTime = req.body.endTime;
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
let days = req.body.days -1;
|
|
149
|
+
endDate = dayjs().add( days, 'day' ).format( 'YYYY-MM-DD' );
|
|
149
150
|
endDate = `${endDate} ${scheduleEndTime}`;
|
|
150
151
|
if ( !req.body?.stores?.length ) {
|
|
151
152
|
let assignQuery = [
|
|
@@ -646,6 +647,17 @@ export async function updateAnswersv2( req, res ) {
|
|
|
646
647
|
}
|
|
647
648
|
|
|
648
649
|
await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).planotaskcompliances, data );
|
|
650
|
+
if ( req.body.type==='layout' ) {
|
|
651
|
+
let sqsData = {
|
|
652
|
+
bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
653
|
+
date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
654
|
+
storeName: data?.storeName,
|
|
655
|
+
videoPath: data?.answers[0]?.video,
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
const sqs = JSON.parse( process.env.SQS );
|
|
659
|
+
await sendMessageToQueue( `${sqs.url}${sqs.storeBuilder}`, JSON.stringify( sqsData ) );
|
|
660
|
+
}
|
|
649
661
|
|
|
650
662
|
return res.sendSuccess( 'Fixture details updated successfully' );
|
|
651
663
|
} catch ( e ) {
|