tango-app-api-store-builder 1.0.0-beta-186 → 1.0.0-beta-188
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
|
@@ -8,6 +8,7 @@ import * as processedTaskService from '../service/processedTaskservice.js';
|
|
|
8
8
|
import * as fixtureShelfService from '../service/fixtureShelf.service.js';
|
|
9
9
|
import * as vmService from '../service/planoVm.service.js';
|
|
10
10
|
import * as templateLogService from '../service/templateLog.service.js';
|
|
11
|
+
import * as storeLayoutService from '../service/storeBuilder.service.js';
|
|
11
12
|
import { createTask } from './task.controller.js';
|
|
12
13
|
import mongoose from 'mongoose';
|
|
13
14
|
import dayjs from 'dayjs';
|
|
@@ -79,6 +80,8 @@ export async function updateTemplate( req, res ) {
|
|
|
79
80
|
let checkstoreMapped = await storeFixtureService.findOne( { fixtureConfigId: req.params.templateId } );
|
|
80
81
|
if ( checkstoreMapped ) {
|
|
81
82
|
inputData.isEdited = true;
|
|
83
|
+
} else {
|
|
84
|
+
inputData.isEdited = false;
|
|
82
85
|
}
|
|
83
86
|
await fixtureConfigService.updateOne( { _id: req.params.templateId }, inputData );
|
|
84
87
|
return res.sendSuccess( 'Fixture template details updated successfully' );
|
|
@@ -689,14 +692,40 @@ export async function TemplateStoresList( req, res ) {
|
|
|
689
692
|
},
|
|
690
693
|
{
|
|
691
694
|
$group: {
|
|
692
|
-
_id: '$storeId',
|
|
695
|
+
_id: { store: '$storeId', floor: '$floorId' },
|
|
693
696
|
storeName: { $first: '$storeName' },
|
|
694
697
|
planoId: { $first: '$planoId' },
|
|
695
698
|
storeId: { $first: '$storeId' },
|
|
696
699
|
floorId: { $first: '$floorId' },
|
|
697
700
|
},
|
|
698
701
|
},
|
|
699
|
-
|
|
702
|
+
{
|
|
703
|
+
$lookup: {
|
|
704
|
+
from: 'storelayouts',
|
|
705
|
+
let: { floor: '$floorId' },
|
|
706
|
+
pipeline: [
|
|
707
|
+
{
|
|
708
|
+
$match: {
|
|
709
|
+
$expr: {
|
|
710
|
+
$eq: [ '$_id', '$$floor' ],
|
|
711
|
+
},
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
$project: {
|
|
716
|
+
floorName: 1,
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
],
|
|
720
|
+
as: 'floorDetails',
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
$unwind: {
|
|
725
|
+
path: '$floorDetails',
|
|
726
|
+
preserveNullAndEmptyArrays: true,
|
|
727
|
+
},
|
|
728
|
+
},
|
|
700
729
|
|
|
701
730
|
);
|
|
702
731
|
if ( inputData.showlookup ) {
|
|
@@ -725,6 +754,8 @@ export async function TemplateStoresList( req, res ) {
|
|
|
725
754
|
floorId: 1,
|
|
726
755
|
spocName: { $ifNull: [ '$storeData.spocDetails.name', '' ] },
|
|
727
756
|
spocEmail: { $ifNull: [ '$storeData.spocDetails.email', '' ] },
|
|
757
|
+
floorDetails: 1,
|
|
758
|
+
_id: '$_id.store',
|
|
728
759
|
},
|
|
729
760
|
},
|
|
730
761
|
);
|
|
@@ -785,8 +816,34 @@ export async function TemplateStoresList( req, res ) {
|
|
|
785
816
|
);
|
|
786
817
|
}
|
|
787
818
|
|
|
788
|
-
|
|
789
|
-
|
|
819
|
+
let floorQuery = [
|
|
820
|
+
{
|
|
821
|
+
$match: {
|
|
822
|
+
clientId: req.body.clientId,
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
$group: {
|
|
827
|
+
_id: '$storeId',
|
|
828
|
+
count: { $sum: 1 },
|
|
829
|
+
},
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
$match: {
|
|
833
|
+
count: { $gt: 1 },
|
|
834
|
+
},
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
$project: {
|
|
838
|
+
_id: 0,
|
|
839
|
+
store: '$_id',
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
];
|
|
843
|
+
const [ response, floorDetails ] = await Promise.all( [
|
|
844
|
+
storeFixtureService.aggregate( query ),
|
|
845
|
+
storeLayoutService.aggregate( floorQuery ),
|
|
846
|
+
] );
|
|
790
847
|
|
|
791
848
|
if ( !req.body.export && !response.length ) {
|
|
792
849
|
return res.sendError( 'No data found', 204 );
|
|
@@ -794,6 +851,7 @@ export async function TemplateStoresList( req, res ) {
|
|
|
794
851
|
let result = {
|
|
795
852
|
count: count.length || 0,
|
|
796
853
|
data: response || [],
|
|
854
|
+
doubleStore: floorDetails?.map( ( ele ) => ele.store ) ?? [],
|
|
797
855
|
};
|
|
798
856
|
if ( !req.body.export ) {
|
|
799
857
|
return res.sendSuccess( result );
|
|
@@ -1399,18 +1457,46 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1399
1457
|
},
|
|
1400
1458
|
{
|
|
1401
1459
|
$group: {
|
|
1402
|
-
_id: '$storeName',
|
|
1460
|
+
_id: { store: '$storeName', floor: '$floorId' },
|
|
1403
1461
|
storeId: { $first: '$storeId' },
|
|
1404
1462
|
updatedAt: { $first: '$updatedAt' },
|
|
1405
|
-
planoId: { $
|
|
1463
|
+
planoId: { $first: '$planoId' },
|
|
1406
1464
|
},
|
|
1407
1465
|
},
|
|
1408
1466
|
{
|
|
1409
1467
|
$project: {
|
|
1410
|
-
storeName: '$_id',
|
|
1468
|
+
storeName: '$_id.store',
|
|
1411
1469
|
storeId: 1,
|
|
1412
1470
|
updatedAt: 1,
|
|
1413
1471
|
planoId: 1,
|
|
1472
|
+
floorId: '$_id.floor',
|
|
1473
|
+
},
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
$lookup: {
|
|
1477
|
+
from: 'storelayouts',
|
|
1478
|
+
let: { floor: '$floorId' },
|
|
1479
|
+
pipeline: [
|
|
1480
|
+
{
|
|
1481
|
+
$match: {
|
|
1482
|
+
$expr: {
|
|
1483
|
+
$eq: [ '$_id', '$$floor' ],
|
|
1484
|
+
},
|
|
1485
|
+
},
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
$project: {
|
|
1489
|
+
floorName: 1,
|
|
1490
|
+
},
|
|
1491
|
+
},
|
|
1492
|
+
],
|
|
1493
|
+
as: 'floorDetails',
|
|
1494
|
+
},
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
$unwind: {
|
|
1498
|
+
path: '$floorDetails',
|
|
1499
|
+
preserveNullAndEmptyArrays: true,
|
|
1414
1500
|
},
|
|
1415
1501
|
},
|
|
1416
1502
|
{
|
|
@@ -1471,7 +1557,8 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1471
1557
|
planoId: 1,
|
|
1472
1558
|
storeDetails: { $ifNull: [ { $arrayElemAt: [ '$storeDetails.storeProfile', 0 ] }, {} ] },
|
|
1473
1559
|
clusterDetails: { $ifNull: [ { $arrayElemAt: [ '$clusterDetails.clusterName', 0 ] }, {} ] },
|
|
1474
|
-
|
|
1560
|
+
floorId: 1,
|
|
1561
|
+
floorName: { $ifNull: [ '$floorDetails.floorName', '' ] },
|
|
1475
1562
|
},
|
|
1476
1563
|
},
|
|
1477
1564
|
];
|
|
@@ -1499,14 +1586,36 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1499
1586
|
},
|
|
1500
1587
|
},
|
|
1501
1588
|
);
|
|
1502
|
-
|
|
1503
|
-
|
|
1589
|
+
let floorQuery = [
|
|
1590
|
+
{
|
|
1591
|
+
$group: {
|
|
1592
|
+
_id: '$storeId',
|
|
1593
|
+
count: { $sum: 1 },
|
|
1594
|
+
},
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
$match: {
|
|
1598
|
+
count: { $gt: 1 },
|
|
1599
|
+
},
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
$project: {
|
|
1603
|
+
_id: 0,
|
|
1604
|
+
store: '$_id',
|
|
1605
|
+
},
|
|
1606
|
+
},
|
|
1607
|
+
];
|
|
1608
|
+
const [ getStoreDetails, floorDetails ] = await Promise.all( [
|
|
1609
|
+
storeFixtureService.aggregate( query ),
|
|
1610
|
+
storeLayoutService.aggregate( floorQuery ),
|
|
1611
|
+
] );
|
|
1504
1612
|
if ( !getStoreDetails[0].data.length ) {
|
|
1505
1613
|
return res.sendError( 'No data found', 204 );
|
|
1506
1614
|
}
|
|
1507
1615
|
let result = {
|
|
1508
1616
|
count: getStoreDetails?.[0]?.count?.[0]?.total || 0,
|
|
1509
1617
|
data: getStoreDetails?.[0]?.data || [],
|
|
1618
|
+
doubleFloorStores: floorDetails?.map( ( ele ) => ele.store ) || [],
|
|
1510
1619
|
};
|
|
1511
1620
|
let status = templateDetails.isEdited ? 'Yet to publish' : 'Published';
|
|
1512
1621
|
result.data.forEach( ( ele ) => {
|
|
@@ -1052,10 +1052,18 @@ export async function getRolloutFeedback( req, res ) {
|
|
|
1052
1052
|
|
|
1053
1053
|
resultMap[type] = data;
|
|
1054
1054
|
|
|
1055
|
+
let taskId = [];
|
|
1056
|
+
if ( req.body.taskId ) {
|
|
1057
|
+
taskId.push( new mongoose.Types.ObjectId( req.body.taskId ) );
|
|
1058
|
+
}
|
|
1059
|
+
if ( req.body.refTaskId ) {
|
|
1060
|
+
taskId.push( new mongoose.Types.ObjectId( req.body.refTaskId ) );
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1055
1063
|
const comments = await planoGlobalCommentService.find( {
|
|
1056
1064
|
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
1057
1065
|
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
1058
|
-
taskId: { $in:
|
|
1066
|
+
...( taskId.length && { taskId: { $in: taskId } } ),
|
|
1059
1067
|
taskType: type,
|
|
1060
1068
|
} );
|
|
1061
1069
|
commentMap[type] = comments;
|
|
@@ -1147,10 +1155,12 @@ export async function getRolloutFeedbackv2( req, res ) {
|
|
|
1147
1155
|
}
|
|
1148
1156
|
response.vmRolloutData = await Promise.all( response.vmRolloutData.map( async ( ele ) => {
|
|
1149
1157
|
ele.storeFixtureList = await Promise.all( ele.storeFixtureList.map( async ( fixt ) => {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1158
|
+
if ( fixt?.FixtureData?.vmConfig?.length ) {
|
|
1159
|
+
fixt.FixtureData.vmConfig = await Promise.all( fixt?.FixtureData?.vmConfig?.map( async ( config ) => {
|
|
1160
|
+
let vmDetails = await planoVmService.findOne( { _id: config.vmId }, { vmType: 1, vmName: 1 } );
|
|
1161
|
+
return { ...config, vmType: vmDetails.vmType, vmName: vmDetails.vmName };
|
|
1162
|
+
} ) );
|
|
1163
|
+
}
|
|
1154
1164
|
return fixt;
|
|
1155
1165
|
} ) );
|
|
1156
1166
|
return ele;
|
|
@@ -2657,7 +2657,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2657
2657
|
const storeLayout = await Promise.all(
|
|
2658
2658
|
planograms.map( async ( planogram ) => {
|
|
2659
2659
|
const floors = await storeBuilderService.find(
|
|
2660
|
-
{ planoId: planogram._id },
|
|
2660
|
+
{ planoId: planogram._id, ...( req.body?.floorId && { _id: req.body.floorId } ) },
|
|
2661
2661
|
{ floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress: 1 },
|
|
2662
2662
|
);
|
|
2663
2663
|
|
|
@@ -5011,33 +5011,50 @@ export async function getRolloutDetails( req, res ) {
|
|
|
5011
5011
|
const orCondition = [];
|
|
5012
5012
|
|
|
5013
5013
|
if ( req.body.filter.status.includes( 'yetToAssign' ) ) {
|
|
5014
|
-
orCondition.push(
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5014
|
+
orCondition.push(
|
|
5015
|
+
{
|
|
5016
|
+
$or: [
|
|
5017
|
+
{
|
|
5018
|
+
$and: [
|
|
5019
|
+
{ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
|
|
5020
|
+
{ merchEditedCount: { $ne: 0 } },
|
|
5021
|
+
],
|
|
5022
|
+
},
|
|
5023
|
+
{
|
|
5024
|
+
$and: [
|
|
5025
|
+
{ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
|
|
5026
|
+
{ vmEditedCount: { $ne: 0 } },
|
|
5027
|
+
],
|
|
5028
|
+
},
|
|
5029
|
+
{
|
|
5030
|
+
$expr: {
|
|
5031
|
+
$lt: [ { $size: '$taskDetails' }, 2 ],
|
|
5032
|
+
},
|
|
5033
|
+
},
|
|
5034
|
+
],
|
|
5035
|
+
},
|
|
5036
|
+
{
|
|
5037
|
+
$and: [
|
|
5038
|
+
{ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
|
|
5039
|
+
{ $or: [
|
|
5040
|
+
{ 'taskFeedback.fixtureStatus': 'disagree' },
|
|
5041
|
+
{ $and: [ { merchEditedCount: { $ne: 0 } }, { $expr: {
|
|
5042
|
+
$eq: [ { $size: { $objectToArray: '$taskFeedback' } }, 0 ],
|
|
5043
|
+
} } ] },
|
|
5044
|
+
] },
|
|
5045
|
+
],
|
|
5046
|
+
},
|
|
5047
|
+
{
|
|
5048
|
+
$and: [
|
|
5049
|
+
{ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
|
|
5050
|
+
{ $or: [
|
|
5051
|
+
{ 'taskFeedback.vmStatus': 'disagree' },
|
|
5052
|
+
{ $and: [ { vmEditedCount: { $ne: 0 } }, { $expr: {
|
|
5053
|
+
$eq: [ { $size: { $objectToArray: '$taskFeedback' } }, 0 ],
|
|
5054
|
+
} } ] },
|
|
5055
|
+
] },
|
|
5056
|
+
],
|
|
5057
|
+
},
|
|
5041
5058
|
);
|
|
5042
5059
|
}
|
|
5043
5060
|
|
|
@@ -45,7 +45,9 @@ export const updateFloor = {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export const storeListSchema = joi.object( {
|
|
48
|
-
id: joi.array().items( joi.any() ).min( 1 ).
|
|
48
|
+
id: joi.array().items( joi.any() ).min( 1 ).optional(),
|
|
49
|
+
planoId: joi.string().optional(),
|
|
50
|
+
floorId: joi.string().optional(),
|
|
49
51
|
treeView: joi.boolean().optional(),
|
|
50
52
|
} );
|
|
51
53
|
|