tango-app-api-store-builder 1.0.0-beta-203 → 1.0.0-beta-204
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
|
@@ -1473,6 +1473,12 @@ export async function getTreeList( req, res ) {
|
|
|
1473
1473
|
...( req.query?.masterId ) ? { masterTemplateId: new ObjectId( req.query.masterId ) } :{ clientId: req.query.clientId, templateType: 'master' },
|
|
1474
1474
|
},
|
|
1475
1475
|
},
|
|
1476
|
+
{
|
|
1477
|
+
$sort: {
|
|
1478
|
+
'header.label': 1,
|
|
1479
|
+
},
|
|
1480
|
+
},
|
|
1481
|
+
|
|
1476
1482
|
];
|
|
1477
1483
|
|
|
1478
1484
|
let fixtureDetails = await fixtureConfigService.aggregate( query );
|
|
@@ -9549,147 +9549,148 @@ async function updateHeaders() {
|
|
|
9549
9549
|
} );
|
|
9550
9550
|
}
|
|
9551
9551
|
|
|
9552
|
-
export async function productMappings(req, res) {
|
|
9552
|
+
export async function productMappings( req, res ) {
|
|
9553
9553
|
try {
|
|
9554
9554
|
const CLEAR_COL_BEFORE_INSERT = false;
|
|
9555
|
-
if (req?.headers?.authorization?.split(
|
|
9556
|
-
return res.sendError(
|
|
9555
|
+
if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
|
|
9556
|
+
return res.sendError( 'Unauthorized', 401 );
|
|
9557
9557
|
}
|
|
9558
9558
|
|
|
9559
|
-
if (!req.files?.file) {
|
|
9560
|
-
return res.sendError(
|
|
9559
|
+
if ( !req.files?.file ) {
|
|
9560
|
+
return res.sendError( 'Excel file is required', 400 );
|
|
9561
9561
|
}
|
|
9562
9562
|
|
|
9563
|
-
const payload = JSON.parse(req.body.payload);
|
|
9563
|
+
const payload = JSON.parse( req.body.payload );
|
|
9564
9564
|
|
|
9565
9565
|
const { fixtureId, Top, Mid, Bottom } = payload;
|
|
9566
9566
|
|
|
9567
|
-
const storeName =
|
|
9568
|
-
const storeId =
|
|
9567
|
+
const storeName = 'LKST98';
|
|
9568
|
+
const storeId = '11-4';
|
|
9569
9569
|
|
|
9570
|
-
if (!fixtureId) {
|
|
9571
|
-
return res.sendError(
|
|
9570
|
+
if ( !fixtureId ) {
|
|
9571
|
+
return res.sendError( 'fixtureId is required', 400 );
|
|
9572
9572
|
}
|
|
9573
9573
|
|
|
9574
9574
|
const fixtureData = { Top, Mid, Bottom };
|
|
9575
9575
|
|
|
9576
|
-
const workbook = xlsx.read(req.files.file.data, { type:
|
|
9577
|
-
const sheetName =
|
|
9578
|
-
const raw = xlsx.utils.sheet_to_json(workbook.Sheets[sheetName]);
|
|
9576
|
+
const workbook = xlsx.read( req.files.file.data, { type: 'buffer' } );
|
|
9577
|
+
const sheetName = 'Unique Mapping';
|
|
9578
|
+
const raw = xlsx.utils.sheet_to_json( workbook.Sheets[sheetName] );
|
|
9579
9579
|
|
|
9580
|
-
const pidsList = Object.values(fixtureData).flat();
|
|
9580
|
+
const pidsList = Object.values( fixtureData ).flat();
|
|
9581
9581
|
|
|
9582
9582
|
let pDetailsList = [];
|
|
9583
|
-
for (const pid of pidsList) {
|
|
9584
|
-
const pDetails = raw.find((pd) => pd[
|
|
9585
|
-
if (pDetails) {
|
|
9586
|
-
pDetailsList.push({
|
|
9587
|
-
clientId:
|
|
9583
|
+
for ( const pid of pidsList ) {
|
|
9584
|
+
const pDetails = raw.find( ( pd ) => pd['product_id'] == pid );
|
|
9585
|
+
if ( pDetails ) {
|
|
9586
|
+
pDetailsList.push( {
|
|
9587
|
+
clientId: '11',
|
|
9588
9588
|
productId: pDetails.product_id,
|
|
9589
9589
|
productName: pDetails.parent_brand,
|
|
9590
9590
|
pid: pDetails.product_id,
|
|
9591
9591
|
rfId: pDetails.barcode,
|
|
9592
9592
|
productImageUrl: pDetails.image_front,
|
|
9593
|
-
productType: pDetails.classification_name ??
|
|
9594
|
-
brandName: pDetails.collection ??
|
|
9595
|
-
category: pDetails.collection_group ??
|
|
9596
|
-
subCategory: pDetails.sub_collection ??
|
|
9597
|
-
type:
|
|
9598
|
-
});
|
|
9593
|
+
productType: pDetails.classification_name ?? '',
|
|
9594
|
+
brandName: pDetails.collection ?? '',
|
|
9595
|
+
category: pDetails.collection_group ?? '',
|
|
9596
|
+
subCategory: pDetails.sub_collection ?? '',
|
|
9597
|
+
type: 'product',
|
|
9598
|
+
} );
|
|
9599
9599
|
}
|
|
9600
9600
|
}
|
|
9601
9601
|
|
|
9602
|
-
if(CLEAR_COL_BEFORE_INSERT) await planoProductService.deleteMany({});
|
|
9602
|
+
if ( CLEAR_COL_BEFORE_INSERT ) await planoProductService.deleteMany( {} );
|
|
9603
9603
|
|
|
9604
9604
|
// const uniqueProducts = await fixtureShelfService.find();
|
|
9605
|
-
|
|
9606
|
-
const fixtureTemplateData = await fixtureShelfService.find({ fixtureId });
|
|
9607
9605
|
|
|
9608
|
-
|
|
9609
|
-
|
|
9606
|
+
const fixtureTemplateData = await fixtureShelfService.find( { fixtureId } );
|
|
9607
|
+
|
|
9608
|
+
if ( !fixtureTemplateData?.length ) {
|
|
9609
|
+
return res.sendError( 'No shelves found for fixtureId', 404 );
|
|
9610
9610
|
}
|
|
9611
9611
|
|
|
9612
9612
|
const planoId = fixtureTemplateData[0].planoId;
|
|
9613
9613
|
const floorId = fixtureTemplateData[0].floorId;
|
|
9614
9614
|
|
|
9615
|
-
const fixtureShelve = fixtureTemplateData.map((f) => ({
|
|
9615
|
+
const fixtureShelve = fixtureTemplateData.map( ( f ) => ( {
|
|
9616
9616
|
id: f._id,
|
|
9617
9617
|
zone: f.zone,
|
|
9618
|
-
}));
|
|
9619
|
-
|
|
9620
|
-
const result = await planoProductService.insertMany(pDetailsList);
|
|
9618
|
+
} ) );
|
|
9619
|
+
|
|
9620
|
+
const result = await planoProductService.insertMany( pDetailsList );
|
|
9621
9621
|
|
|
9622
|
-
let planoMappings = result.map((pd) => ({
|
|
9623
|
-
clientId:
|
|
9622
|
+
let planoMappings = result.map( ( pd ) => ( {
|
|
9623
|
+
clientId: '11',
|
|
9624
9624
|
storeName: storeName,
|
|
9625
9625
|
storeId: storeId,
|
|
9626
|
-
type:
|
|
9626
|
+
type: 'product',
|
|
9627
9627
|
productId: pd._id,
|
|
9628
9628
|
pid: pd.pid,
|
|
9629
|
+
rfId: pd.rfId,
|
|
9629
9630
|
planoId,
|
|
9630
9631
|
floorId,
|
|
9631
9632
|
fixtureId,
|
|
9632
|
-
shelfId:
|
|
9633
|
-
}));
|
|
9633
|
+
shelfId: 'temp', // will be reassigned in transformProducts
|
|
9634
|
+
} ) );
|
|
9634
9635
|
|
|
9635
|
-
if(CLEAR_COL_BEFORE_INSERT) await planoMappingService.deleteMany({});
|
|
9636
|
+
if ( CLEAR_COL_BEFORE_INSERT ) await planoMappingService.deleteMany( {} );
|
|
9636
9637
|
|
|
9637
9638
|
const shelfGroups = {
|
|
9638
|
-
Top: fixtureShelve.filter((f) => f.zone ===
|
|
9639
|
-
Mid: fixtureShelve.filter((f) => f.zone ===
|
|
9640
|
-
Bottom: fixtureShelve.filter((f) => f.zone ===
|
|
9639
|
+
Top: fixtureShelve.filter( ( f ) => f.zone === 'Top' ).map( ( f ) => f.id ),
|
|
9640
|
+
Mid: fixtureShelve.filter( ( f ) => f.zone === 'Mid' ).map( ( f ) => f.id ),
|
|
9641
|
+
Bottom: fixtureShelve.filter( ( f ) => f.zone === 'Bottom' ).map( ( f ) => f.id ),
|
|
9641
9642
|
};
|
|
9642
9643
|
|
|
9643
|
-
const transformed = transformProducts(planoMappings, shelfGroups, fixtureData);
|
|
9644
|
+
const transformed = transformProducts( planoMappings, shelfGroups, fixtureData );
|
|
9644
9645
|
|
|
9645
|
-
const result2 = await planoMappingService.insertMany(transformed);
|
|
9646
|
+
const result2 = await planoMappingService.insertMany( transformed );
|
|
9646
9647
|
|
|
9647
|
-
res.sendSuccess({
|
|
9648
|
+
res.sendSuccess( {
|
|
9648
9649
|
fixtureData,
|
|
9649
9650
|
shelfGroups,
|
|
9650
9651
|
planoMappings: result2,
|
|
9651
|
-
});
|
|
9652
|
-
} catch (error) {
|
|
9653
|
-
console.log(
|
|
9654
|
-
res.sendError(
|
|
9652
|
+
} );
|
|
9653
|
+
} catch ( error ) {
|
|
9654
|
+
console.log( '@@ ~ error:', error );
|
|
9655
|
+
res.sendError( 'Internal Server Error', 500 );
|
|
9655
9656
|
}
|
|
9656
9657
|
}
|
|
9657
9658
|
|
|
9658
|
-
function transformProducts(products, shelvesByZone, fixtureData) {
|
|
9659
|
+
function transformProducts( products, shelvesByZone, fixtureData ) {
|
|
9659
9660
|
const result = [];
|
|
9660
9661
|
|
|
9661
9662
|
// Build lookup: pid → zone
|
|
9662
9663
|
const pidToZone = {};
|
|
9663
|
-
for (const [zone, pids] of Object.entries(fixtureData)) {
|
|
9664
|
-
pids.forEach(pid => {
|
|
9664
|
+
for ( const [ zone, pids ] of Object.entries( fixtureData ) ) {
|
|
9665
|
+
pids.forEach( ( pid ) => {
|
|
9665
9666
|
pidToZone[pid] = zone;
|
|
9666
|
-
});
|
|
9667
|
+
} );
|
|
9667
9668
|
}
|
|
9668
9669
|
|
|
9669
9670
|
// Group products by zone
|
|
9670
9671
|
const productsByZone = {};
|
|
9671
|
-
for (const doc of products) {
|
|
9672
|
+
for ( const doc of products ) {
|
|
9672
9673
|
const zone = pidToZone[doc.pid];
|
|
9673
|
-
if (!zone) continue;
|
|
9674
|
-
if (!productsByZone[zone]) productsByZone[zone] = [];
|
|
9675
|
-
productsByZone[zone].push(doc);
|
|
9674
|
+
if ( !zone ) continue;
|
|
9675
|
+
if ( !productsByZone[zone] ) productsByZone[zone] = [];
|
|
9676
|
+
productsByZone[zone].push( doc );
|
|
9676
9677
|
}
|
|
9677
9678
|
|
|
9678
9679
|
// Round-robin distribute products across shelves
|
|
9679
|
-
for (const [zone, docs] of Object.entries(productsByZone)) {
|
|
9680
|
+
for ( const [ zone, docs ] of Object.entries( productsByZone ) ) {
|
|
9680
9681
|
const shelves = shelvesByZone[zone] || [];
|
|
9681
|
-
if (shelves.length === 0) {
|
|
9682
|
-
result.push(...docs);
|
|
9682
|
+
if ( shelves.length === 0 ) {
|
|
9683
|
+
result.push( ...docs );
|
|
9683
9684
|
continue;
|
|
9684
9685
|
}
|
|
9685
9686
|
|
|
9686
|
-
docs.forEach((doc, idx) => {
|
|
9687
|
+
docs.forEach( ( doc, idx ) => {
|
|
9687
9688
|
const shelfId = shelves[idx % shelves.length]; // cycle through shelves
|
|
9688
|
-
result.push({
|
|
9689
|
+
result.push( {
|
|
9689
9690
|
...doc,
|
|
9690
|
-
shelfId
|
|
9691
|
-
});
|
|
9692
|
-
});
|
|
9691
|
+
shelfId,
|
|
9692
|
+
} );
|
|
9693
|
+
} );
|
|
9693
9694
|
}
|
|
9694
9695
|
|
|
9695
9696
|
return result;
|
|
@@ -2717,9 +2717,9 @@ export async function qrScan1( req, res ) {
|
|
|
2717
2717
|
const fm = await getFixtureMetrics( fixture, currentDate );
|
|
2718
2718
|
|
|
2719
2719
|
|
|
2720
|
-
return res.sendSuccess( { data:
|
|
2720
|
+
return res.sendSuccess( { data: productMapping, fixtureMetrics: fm, status: 'proper' } );
|
|
2721
2721
|
} else if ( fixture.productResolutionLevel === 'L3' ) {
|
|
2722
|
-
const sectionShelves = await fixtureShelfService.find( { fixtureId: fixture._id,
|
|
2722
|
+
const sectionShelves = await fixtureShelfService.find( { fixtureId: fixture._id, zone: req.body.sectionName } );
|
|
2723
2723
|
|
|
2724
2724
|
if ( !sectionShelves.length ) return res.sendError( 'No shelves found for the Section', 400 );
|
|
2725
2725
|
|
|
@@ -2744,7 +2744,7 @@ export async function qrScan1( req, res ) {
|
|
|
2744
2744
|
const fm = await getFixtureMetrics( fixture, currentDate );
|
|
2745
2745
|
|
|
2746
2746
|
|
|
2747
|
-
return res.sendSuccess( { data:
|
|
2747
|
+
return res.sendSuccess( { data: locatePlano, fixtureMetrics: fm, status: 'misplaced' } );
|
|
2748
2748
|
}
|
|
2749
2749
|
|
|
2750
2750
|
planoMapping.forEach( async ( ele ) => {
|
|
@@ -5568,3 +5568,46 @@ export async function getRolloutTaskDetails( req, res ) {
|
|
|
5568
5568
|
return res.sendError( e, 500 );
|
|
5569
5569
|
}
|
|
5570
5570
|
}
|
|
5571
|
+
|
|
5572
|
+
export async function getPlanoStoreList( req, res ) {
|
|
5573
|
+
try {
|
|
5574
|
+
let storeDetails = await storeService.find( { status: 'active', clientId: req.query.clientId }, { storeId: 1 } );
|
|
5575
|
+
if ( !storeDetails.length ) {
|
|
5576
|
+
return res.sendError( 'No data found', 204 );
|
|
5577
|
+
}
|
|
5578
|
+
let query = [
|
|
5579
|
+
{
|
|
5580
|
+
$match: {
|
|
5581
|
+
storeId: { $in: storeDetails.map( ( ele ) => ele.storeId ) },
|
|
5582
|
+
},
|
|
5583
|
+
},
|
|
5584
|
+
{
|
|
5585
|
+
$group: {
|
|
5586
|
+
_id: '$storeId',
|
|
5587
|
+
storeName: { $first: '$storeName' },
|
|
5588
|
+
planoId: { $first: '$planoId' },
|
|
5589
|
+
floorId: { $first: '$_id' },
|
|
5590
|
+
},
|
|
5591
|
+
},
|
|
5592
|
+
];
|
|
5593
|
+
let planoDetails = await storeBuilderService.aggregate( query );
|
|
5594
|
+
return res.sendSuccess( planoDetails );
|
|
5595
|
+
} catch ( e ) {
|
|
5596
|
+
logger.error( { functionName: 'getPlanoStoreList', error: e } );
|
|
5597
|
+
return res.sendError( e, 500 );
|
|
5598
|
+
}
|
|
5599
|
+
}
|
|
5600
|
+
|
|
5601
|
+
|
|
5602
|
+
export async function getScandid( req, res ) {
|
|
5603
|
+
try {
|
|
5604
|
+
let getScanId = await planoStaticData.findOne( { type: 'app' } );
|
|
5605
|
+
if ( !getScanId ) {
|
|
5606
|
+
return res.sendError( 'No data found', 204 );
|
|
5607
|
+
}
|
|
5608
|
+
return res.sendSuccess( getScanId );
|
|
5609
|
+
} catch ( e ) {
|
|
5610
|
+
logger.error( { functionName: 'getScandid', error: e } );
|
|
5611
|
+
return res.sendError( e, 500 );
|
|
5612
|
+
}
|
|
5613
|
+
}
|
|
@@ -54,4 +54,6 @@ storeBuilderRouter
|
|
|
54
54
|
.get( '/taskDetails', isAllowedSessionHandler, storeBuilderController.getTaskDetails )
|
|
55
55
|
.get( '/getPlanoUser', isAllowedSessionHandler, storeBuilderController.getPlanoUser )
|
|
56
56
|
.post( '/planoRolloutList', isAllowedSessionHandler, storeBuilderController.getRolloutDetails )
|
|
57
|
-
.get( '/getRolloutTaskDetails', isAllowedSessionHandler, storeBuilderController.getRolloutTaskDetails )
|
|
57
|
+
.get( '/getRolloutTaskDetails', isAllowedSessionHandler, storeBuilderController.getRolloutTaskDetails )
|
|
58
|
+
.get( '/getScandid', storeBuilderController.getScandid )
|
|
59
|
+
.get( '/getPlanoStoreList', isAllowedSessionHandler, storeBuilderController.getPlanoStoreList );
|