tango-app-api-store-builder 1.0.0-beta-152 → 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as floorService from '../service/storeBuilder.service.js';
|
|
2
2
|
import { logger, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
3
3
|
// import * as storeService from '../service/store.service.js';
|
|
4
|
-
|
|
4
|
+
import * as planoService from '../service/planogram.service.js';
|
|
5
5
|
import * as storeFixtureService from '../service/storeFixture.service.js';
|
|
6
6
|
import * as fixtureShelfService from '../service/fixtureShelf.service.js';
|
|
7
7
|
// import * as planoProductService from '../service/planoProduct.service.js';
|
|
@@ -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,6 +475,8 @@ export async function updateStorePlano( req, res ) {
|
|
|
519
475
|
}
|
|
520
476
|
} );
|
|
521
477
|
|
|
478
|
+
await planoService.updateOne( { _id: floorData.toObject()?.planoId }, { $set: { updatedAt: new Date() } } );
|
|
479
|
+
|
|
522
480
|
res.sendSuccess( 'Updated Successfully' );
|
|
523
481
|
} catch ( e ) {
|
|
524
482
|
logger.error( { functionName: 'updateStorePlano', error: e } );
|
|
@@ -674,7 +632,7 @@ export async function updateFixtureStatus( req, res ) {
|
|
|
674
632
|
},
|
|
675
633
|
|
|
676
634
|
);
|
|
677
|
-
if ( vmTask.length>0 ) {
|
|
635
|
+
if ( vmTask.length > 0 ) {
|
|
678
636
|
let allTaskDone = vmTask.filter( ( data ) => data.status === 'incomplete' );
|
|
679
637
|
if ( allTaskDone.length === 0 ) {
|
|
680
638
|
await floorService.updateOne( { _id: new mongoose.Types.ObjectId( req.body.floorId ) }, { planoProgress: 100 } );
|
|
@@ -698,9 +656,21 @@ export async function updateStoreFixture( req, res ) {
|
|
|
698
656
|
const productCategory = new Set();
|
|
699
657
|
const productSubCategory = new Set();
|
|
700
658
|
|
|
659
|
+
let fixtureCapacity = 0;
|
|
660
|
+
|
|
701
661
|
data.shelfConfig.forEach( ( shelf ) => {
|
|
702
662
|
const { productBrandName: brand, productCategory: category, productSubCategory: subCategory } = shelf;
|
|
703
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
|
+
|
|
704
674
|
if ( Array.isArray( brand ) ) {
|
|
705
675
|
brand.forEach( ( b ) => productBrandName.add( b ) );
|
|
706
676
|
}
|
|
@@ -721,6 +691,7 @@ export async function updateStoreFixture( req, res ) {
|
|
|
721
691
|
...currentFixtureDoc,
|
|
722
692
|
...newTemplate.toObject(),
|
|
723
693
|
fixtureConfigId: newTemplate.toObject()._id,
|
|
694
|
+
fixtureCapacity: fixtureCapacity,
|
|
724
695
|
productBrandName: [ ...productBrandName ],
|
|
725
696
|
productCategory: [ ...productCategory ],
|
|
726
697
|
productSubCategory: [ ...productSubCategory ],
|
|
@@ -729,6 +700,7 @@ export async function updateStoreFixture( req, res ) {
|
|
|
729
700
|
currentFixtureDoc = {
|
|
730
701
|
...currentFixtureDoc,
|
|
731
702
|
...data,
|
|
703
|
+
fixtureCapacity: fixtureCapacity,
|
|
732
704
|
productBrandName: [ ...productBrandName ],
|
|
733
705
|
productCategory: [ ...productCategory ],
|
|
734
706
|
productSubCategory: [ ...productSubCategory ],
|
|
@@ -765,6 +737,7 @@ export async function updateStoreFixture( req, res ) {
|
|
|
765
737
|
await fixtureShelfService.create( { ...additionalMeta, ...shelf } );
|
|
766
738
|
} );
|
|
767
739
|
}
|
|
740
|
+
await planoService.updateOne( { _id: currentFixtureDoc?.planoId }, { $set: { updatedAt: new Date() } } );
|
|
768
741
|
|
|
769
742
|
res.sendSuccess( 'Updated Successfully' );
|
|
770
743
|
} catch ( e ) {
|
|
@@ -814,7 +787,7 @@ export async function updateredostatus( req, res ) {
|
|
|
814
787
|
|
|
815
788
|
export async function updateGlobalComment( req, res ) {
|
|
816
789
|
try {
|
|
817
|
-
let payload ={
|
|
790
|
+
let payload = {
|
|
818
791
|
userId: req.user._id,
|
|
819
792
|
userName: req.user.userName,
|
|
820
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 = [
|