tango-app-api-store-builder 1.0.0-beta-153 → 1.0.0-beta-154
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
CHANGED
|
@@ -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 ) => {
|
|
@@ -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 = [
|