tango-app-api-store-builder 1.0.0-beta-187 → 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';
|
|
@@ -691,14 +692,40 @@ export async function TemplateStoresList( req, res ) {
|
|
|
691
692
|
},
|
|
692
693
|
{
|
|
693
694
|
$group: {
|
|
694
|
-
_id: '$storeId',
|
|
695
|
+
_id: { store: '$storeId', floor: '$floorId' },
|
|
695
696
|
storeName: { $first: '$storeName' },
|
|
696
697
|
planoId: { $first: '$planoId' },
|
|
697
698
|
storeId: { $first: '$storeId' },
|
|
698
699
|
floorId: { $first: '$floorId' },
|
|
699
700
|
},
|
|
700
701
|
},
|
|
701
|
-
|
|
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
|
+
},
|
|
702
729
|
|
|
703
730
|
);
|
|
704
731
|
if ( inputData.showlookup ) {
|
|
@@ -727,6 +754,8 @@ export async function TemplateStoresList( req, res ) {
|
|
|
727
754
|
floorId: 1,
|
|
728
755
|
spocName: { $ifNull: [ '$storeData.spocDetails.name', '' ] },
|
|
729
756
|
spocEmail: { $ifNull: [ '$storeData.spocDetails.email', '' ] },
|
|
757
|
+
floorDetails: 1,
|
|
758
|
+
_id: '$_id.store',
|
|
730
759
|
},
|
|
731
760
|
},
|
|
732
761
|
);
|
|
@@ -787,8 +816,34 @@ export async function TemplateStoresList( req, res ) {
|
|
|
787
816
|
);
|
|
788
817
|
}
|
|
789
818
|
|
|
790
|
-
|
|
791
|
-
|
|
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
|
+
] );
|
|
792
847
|
|
|
793
848
|
if ( !req.body.export && !response.length ) {
|
|
794
849
|
return res.sendError( 'No data found', 204 );
|
|
@@ -796,6 +851,7 @@ export async function TemplateStoresList( req, res ) {
|
|
|
796
851
|
let result = {
|
|
797
852
|
count: count.length || 0,
|
|
798
853
|
data: response || [],
|
|
854
|
+
doubleStore: floorDetails?.map( ( ele ) => ele.store ) ?? [],
|
|
799
855
|
};
|
|
800
856
|
if ( !req.body.export ) {
|
|
801
857
|
return res.sendSuccess( result );
|
|
@@ -1401,18 +1457,46 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1401
1457
|
},
|
|
1402
1458
|
{
|
|
1403
1459
|
$group: {
|
|
1404
|
-
_id: '$storeName',
|
|
1460
|
+
_id: { store: '$storeName', floor: '$floorId' },
|
|
1405
1461
|
storeId: { $first: '$storeId' },
|
|
1406
1462
|
updatedAt: { $first: '$updatedAt' },
|
|
1407
|
-
planoId: { $
|
|
1463
|
+
planoId: { $first: '$planoId' },
|
|
1408
1464
|
},
|
|
1409
1465
|
},
|
|
1410
1466
|
{
|
|
1411
1467
|
$project: {
|
|
1412
|
-
storeName: '$_id',
|
|
1468
|
+
storeName: '$_id.store',
|
|
1413
1469
|
storeId: 1,
|
|
1414
1470
|
updatedAt: 1,
|
|
1415
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,
|
|
1416
1500
|
},
|
|
1417
1501
|
},
|
|
1418
1502
|
{
|
|
@@ -1473,7 +1557,8 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1473
1557
|
planoId: 1,
|
|
1474
1558
|
storeDetails: { $ifNull: [ { $arrayElemAt: [ '$storeDetails.storeProfile', 0 ] }, {} ] },
|
|
1475
1559
|
clusterDetails: { $ifNull: [ { $arrayElemAt: [ '$clusterDetails.clusterName', 0 ] }, {} ] },
|
|
1476
|
-
|
|
1560
|
+
floorId: 1,
|
|
1561
|
+
floorName: { $ifNull: [ '$floorDetails.floorName', '' ] },
|
|
1477
1562
|
},
|
|
1478
1563
|
},
|
|
1479
1564
|
];
|
|
@@ -1501,14 +1586,36 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1501
1586
|
},
|
|
1502
1587
|
},
|
|
1503
1588
|
);
|
|
1504
|
-
|
|
1505
|
-
|
|
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
|
+
] );
|
|
1506
1612
|
if ( !getStoreDetails[0].data.length ) {
|
|
1507
1613
|
return res.sendError( 'No data found', 204 );
|
|
1508
1614
|
}
|
|
1509
1615
|
let result = {
|
|
1510
1616
|
count: getStoreDetails?.[0]?.count?.[0]?.total || 0,
|
|
1511
1617
|
data: getStoreDetails?.[0]?.data || [],
|
|
1618
|
+
doubleFloorStores: floorDetails?.map( ( ele ) => ele.store ) || [],
|
|
1512
1619
|
};
|
|
1513
1620
|
let status = templateDetails.isEdited ? 'Yet to publish' : 'Published';
|
|
1514
1621
|
result.data.forEach( ( ele ) => {
|
|
@@ -1155,10 +1155,12 @@ export async function getRolloutFeedbackv2( req, res ) {
|
|
|
1155
1155
|
}
|
|
1156
1156
|
response.vmRolloutData = await Promise.all( response.vmRolloutData.map( async ( ele ) => {
|
|
1157
1157
|
ele.storeFixtureList = await Promise.all( ele.storeFixtureList.map( async ( fixt ) => {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
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
|
+
}
|
|
1162
1164
|
return fixt;
|
|
1163
1165
|
} ) );
|
|
1164
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
|
|