tango-app-api-store-builder 1.0.0-beta-54 → 1.0.0-beta-56
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
|
@@ -1636,3 +1636,96 @@ export async function lk98lK1993Update( req, res ) {
|
|
|
1636
1636
|
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1637
1637
|
}
|
|
1638
1638
|
}
|
|
1639
|
+
|
|
1640
|
+
export async function updateInventory( req, res ) {
|
|
1641
|
+
try {
|
|
1642
|
+
if ( !req.files.file ) {
|
|
1643
|
+
return res.sendError( 'Invalid or missing Excel file', 400 );
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
const workbook = xlsx.read( req.files.file.data, { type: 'buffer' } );
|
|
1647
|
+
const sheetName = 'Sheet1';
|
|
1648
|
+
if ( !workbook.Sheets[sheetName] ) {
|
|
1649
|
+
return res.sendError( `Sheet "${sheetName}" not found`, 400 );
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
const raw = xlsx.utils.sheet_to_json( workbook.Sheets[sheetName] );
|
|
1653
|
+
|
|
1654
|
+
for ( let i = 0; i < raw.length; i++ ) {
|
|
1655
|
+
const element = raw[i];
|
|
1656
|
+
|
|
1657
|
+
const updateData = {
|
|
1658
|
+
productBrand: element.parent_brand,
|
|
1659
|
+
productType: element.parent_category,
|
|
1660
|
+
productId: element.barcode,
|
|
1661
|
+
type: 'product',
|
|
1662
|
+
storeName: 'LKST1193',
|
|
1663
|
+
clientId: '11',
|
|
1664
|
+
};
|
|
1665
|
+
|
|
1666
|
+
console.log( updateData );
|
|
1667
|
+
|
|
1668
|
+
const product = await planoProductService.create( updateData );
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
return res.sendSuccess( { message: 'Product inventory updated successfully' } );
|
|
1673
|
+
} catch ( e ) {
|
|
1674
|
+
logger.error( { functionName: 'createPlanoAPI', error: e } );
|
|
1675
|
+
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
export async function updateRfidProduct( req, res ) {
|
|
1680
|
+
try {
|
|
1681
|
+
const productMappings = await planoMappingService.find( { fixtureId: req.body.fixtureId } );
|
|
1682
|
+
|
|
1683
|
+
console.log( productMappings );
|
|
1684
|
+
|
|
1685
|
+
for ( let i = 0; i < productMappings.length; i++ ) {
|
|
1686
|
+
const mapping = productMappings[i].toObject();
|
|
1687
|
+
|
|
1688
|
+
const product = await planoProductService.findOne( { productId: mapping.rfId } );
|
|
1689
|
+
|
|
1690
|
+
if ( product ) {
|
|
1691
|
+
await planoMappingService.updateOne( { _id: mapping._id }, { productId: product.toObject()._id } );
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
console.log( product );
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
|
|
1698
|
+
return res.sendSuccess( { message: 'Product inventory updated successfully' } );
|
|
1699
|
+
} catch ( e ) {
|
|
1700
|
+
logger.error( { functionName: 'createPlanoAPI', error: e } );
|
|
1701
|
+
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
export async function updateRfidProduct2( req, res ) {
|
|
1706
|
+
try {
|
|
1707
|
+
const data = req.body.data;
|
|
1708
|
+
|
|
1709
|
+
for ( let i = 0; i < data.length; i++ ) {
|
|
1710
|
+
const section = data[i];
|
|
1711
|
+
|
|
1712
|
+
for ( let j = 0; j < section.products.length; j++ ) {
|
|
1713
|
+
const product = section.products[j];
|
|
1714
|
+
|
|
1715
|
+
const productDetail = await planoProductService.findOne( { productId: product.qr } );
|
|
1716
|
+
|
|
1717
|
+
if ( productDetail ) {
|
|
1718
|
+
await planoMappingService.updateOne( { rfId: product.rfId }, { productId: productDetail.toObject()._id } );
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
console.log( productDetail );
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
return res.sendSuccess( { message: 'Product inventory updated successfully' } );
|
|
1727
|
+
} catch ( e ) {
|
|
1728
|
+
logger.error( { functionName: 'createPlanoAPI', error: e } );
|
|
1729
|
+
return res.sendError( e.message || 'Internal Server Error', 500 );
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
@@ -1782,6 +1782,8 @@ export async function bulkFixtureUpload( req, res ) {
|
|
|
1782
1782
|
'shelfCapacity': 2,
|
|
1783
1783
|
'shelfType': 'middle',
|
|
1784
1784
|
'sectionName': req.body.data[i].sectionName,
|
|
1785
|
+
'sectionZone': req.body.data[i]?.sectionZone,
|
|
1786
|
+
// 'rfId':req.body.data[i].sectionName
|
|
1785
1787
|
};
|
|
1786
1788
|
|
|
1787
1789
|
const createdShelf = await fixtureShelfService.create( shelfData );
|
|
@@ -1808,6 +1810,21 @@ export async function bulkFixtureUpload( req, res ) {
|
|
|
1808
1810
|
}
|
|
1809
1811
|
}
|
|
1810
1812
|
|
|
1813
|
+
const productMappings = await planoMappingService.find( { fixtureId: req.body.id } );
|
|
1814
|
+
|
|
1815
|
+
|
|
1816
|
+
for ( let i = 0; i < productMappings.length; i++ ) {
|
|
1817
|
+
const mapping = productMappings[i].toObject();
|
|
1818
|
+
|
|
1819
|
+
const product = await planoProductService.findOne( { productId: mapping.rfId } );
|
|
1820
|
+
|
|
1821
|
+
if ( product ) {
|
|
1822
|
+
await planoMappingService.updateOne( { _id: mapping._id }, { productId: product.toObject()._id } );
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
console.log( product );
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1811
1828
|
res.sendSuccess( fixture );
|
|
1812
1829
|
} catch ( e ) {
|
|
1813
1830
|
logger.error( { functionName: 'bulkAdd', error: e, message: req.body } );
|
|
@@ -2454,3 +2471,58 @@ export const upsertFixtures = async ( req, res ) => {
|
|
|
2454
2471
|
return res.sendError( 'Internal Server Error', 500 );
|
|
2455
2472
|
}
|
|
2456
2473
|
};
|
|
2474
|
+
|
|
2475
|
+
export const getShelfSections = async ( req, res ) => {
|
|
2476
|
+
try {
|
|
2477
|
+
const pipeline = [
|
|
2478
|
+
{
|
|
2479
|
+
'$match': {
|
|
2480
|
+
'clientId': req.body.clientId,
|
|
2481
|
+
},
|
|
2482
|
+
},
|
|
2483
|
+
{
|
|
2484
|
+
$project:
|
|
2485
|
+
{
|
|
2486
|
+
sectionName: 1,
|
|
2487
|
+
sectionZone: 1,
|
|
2488
|
+
},
|
|
2489
|
+
},
|
|
2490
|
+
{
|
|
2491
|
+
'$match': {
|
|
2492
|
+
'sectionName': { '$ne': null },
|
|
2493
|
+
},
|
|
2494
|
+
},
|
|
2495
|
+
{
|
|
2496
|
+
$group: {
|
|
2497
|
+
_id: '$sectionName',
|
|
2498
|
+
},
|
|
2499
|
+
},
|
|
2500
|
+
{
|
|
2501
|
+
$group: {
|
|
2502
|
+
'_id': null,
|
|
2503
|
+
'sectionNames': { '$push': '$_id' },
|
|
2504
|
+
},
|
|
2505
|
+
},
|
|
2506
|
+
{
|
|
2507
|
+
$project: {
|
|
2508
|
+
_id: 0,
|
|
2509
|
+
sectionNames: 1,
|
|
2510
|
+
},
|
|
2511
|
+
},
|
|
2512
|
+
];
|
|
2513
|
+
|
|
2514
|
+
const sections = await fixtureShelfService.aggregate( pipeline );
|
|
2515
|
+
|
|
2516
|
+
if ( !sections.length ) {
|
|
2517
|
+
return res.sendError( 'No data found', 204 );
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
const [ data ] = sections;
|
|
2521
|
+
|
|
2522
|
+
return res.sendSuccess( data?.sectionNames );
|
|
2523
|
+
} catch ( error ) {
|
|
2524
|
+
logger.error( 'upsertFixtures =>', error );
|
|
2525
|
+
return res.sendError( 'Internal Server Error', 500 );
|
|
2526
|
+
}
|
|
2527
|
+
};
|
|
2528
|
+
|
|
@@ -12,4 +12,7 @@ scriptRouter
|
|
|
12
12
|
.post( '/bulkIinsertVmTemplateData', scriptController.createVmData )
|
|
13
13
|
.post( '/bulkIinsertFixturesShelvesVmsData', scriptController.createFixturesShelves )
|
|
14
14
|
.post( '/updateFixturesShelvesVms', scriptController.updateFixturesShelves )
|
|
15
|
-
.post( '/lk98lK1993Update', scriptController.lk98lK1993Update )
|
|
15
|
+
.post( '/lk98lK1993Update', scriptController.lk98lK1993Update )
|
|
16
|
+
.post( '/updateinventory', scriptController.updateInventory )
|
|
17
|
+
.post( '/updateRfidProduct', scriptController.updateRfidProduct )
|
|
18
|
+
.post( '/updateRfidProduct2', scriptController.updateRfidProduct2 );
|
|
@@ -35,4 +35,5 @@ storeBuilderRouter
|
|
|
35
35
|
.post( '/getQrCvProcessRequest', storeBuilderController.getQrCvProcessRequest )
|
|
36
36
|
.post( '/fixtureQrUpdate', storeBuilderController.fixtureQrUpdate )
|
|
37
37
|
.post( '/updateDeatailedDistance', storeBuilderController.updateDetailedDistance )
|
|
38
|
-
.post( '/upsertFixture', storeBuilderController.upsertFixtures )
|
|
38
|
+
.post( '/upsertFixture', storeBuilderController.upsertFixtures )
|
|
39
|
+
.post( '/getshelfSections', storeBuilderController.getShelfSections );
|