tango-app-api-store-builder 1.0.0-beta-199 → 1.0.0-beta-200
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-store-builder",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-200",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"path": "^0.12.7",
|
|
33
33
|
"selenium-webdriver": "^4.31.0",
|
|
34
34
|
"sharp": "^0.34.1",
|
|
35
|
-
"tango-api-schema": "^2.3.
|
|
35
|
+
"tango-api-schema": "^2.3.32",
|
|
36
36
|
"tango-app-api-middleware": "3.1.48",
|
|
37
37
|
"url": "^0.11.4",
|
|
38
38
|
"winston": "^3.17.0",
|
|
@@ -2634,6 +2634,142 @@ export async function qrScan( req, res ) {
|
|
|
2634
2634
|
}
|
|
2635
2635
|
}
|
|
2636
2636
|
|
|
2637
|
+
export async function qrScan1( req, res ) {
|
|
2638
|
+
try {
|
|
2639
|
+
if ( !req.body.floorId ) return res.sendError( 'Floor id is required', 400 );
|
|
2640
|
+
|
|
2641
|
+
if ( !req.body.fixtureId ) return res.sendError( 'Fixture id is required', 400 );
|
|
2642
|
+
|
|
2643
|
+
if ( !req.body.rfId.length ) return res.sendError( 'RFID is required', 400 );
|
|
2644
|
+
const fixture = await storeFixtureService.findOne(
|
|
2645
|
+
{ _id: new mongoose.Types.ObjectId( req.body.fixtureId ) },
|
|
2646
|
+
{ storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1 },
|
|
2647
|
+
);
|
|
2648
|
+
|
|
2649
|
+
if ( !fixture ) return res.sendError( 'No data found', 204 );
|
|
2650
|
+
|
|
2651
|
+
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
2652
|
+
|
|
2653
|
+
async function getFixtureMetrics( fixture, currentDate ) {
|
|
2654
|
+
const [ totalProducts, scannedProducts, misplacedProducts, properProducts, missingProducts ] = await Promise.all( [
|
|
2655
|
+
planoMappingService.count( { fixtureId: fixture.toObject()._id } ),
|
|
2656
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate } ),
|
|
2657
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'misplaced' } ),
|
|
2658
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'proper' } ),
|
|
2659
|
+
planoComplianceService.count( { fixtureId: fixture.toObject()._id, date: currentDate, compliance: 'missing' } ),
|
|
2660
|
+
] );
|
|
2661
|
+
|
|
2662
|
+
const fixtureMetrics = {
|
|
2663
|
+
total: totalProducts,
|
|
2664
|
+
scanned: scannedProducts,
|
|
2665
|
+
misplaced: misplacedProducts,
|
|
2666
|
+
proper: properProducts,
|
|
2667
|
+
missing: missingProducts,
|
|
2668
|
+
};
|
|
2669
|
+
|
|
2670
|
+
return fixtureMetrics;
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
|
|
2674
|
+
if ( fixture.productResolutionLevel === 'L1' ) {
|
|
2675
|
+
const mappingQuery = {
|
|
2676
|
+
planoId: req.body.planoId,
|
|
2677
|
+
floorId: req.body.floorId,
|
|
2678
|
+
fixtureId: req.body.fixtureId,
|
|
2679
|
+
rfId: { $in: req.body.rfId },
|
|
2680
|
+
};
|
|
2681
|
+
|
|
2682
|
+
const productMapping = await planoMappingService.find( mappingQuery );
|
|
2683
|
+
|
|
2684
|
+
if ( !productMapping.length ) {
|
|
2685
|
+
const misplacedQuery = {
|
|
2686
|
+
planoId: req.body.planoId,
|
|
2687
|
+
floorId: req.body.floorId,
|
|
2688
|
+
rfId: { $in: req.body.rfId },
|
|
2689
|
+
};
|
|
2690
|
+
const misplacedProductMapping = await planoMappingService.find( misplacedQuery );
|
|
2691
|
+
|
|
2692
|
+
if ( !misplacedProductMapping.length ) {
|
|
2693
|
+
return res.sendSuccess( { data: null, status: 'missing' } );
|
|
2694
|
+
}
|
|
2695
|
+
misplacedProductMapping.forEach( ( ele ) => {
|
|
2696
|
+
const complianceData={ ...ele.toObject(), planoMappingId: ele._id, compliance: 'misplaced' };
|
|
2697
|
+
delete complianceData._id;
|
|
2698
|
+
planoComplianceService.updateOne( { ...misplacedQuery, date: currentDate }, complianceData );
|
|
2699
|
+
} );
|
|
2700
|
+
|
|
2701
|
+
// const complianceData = { ...misplacedProductMapping.toObject(), planoMappingId: misplacedProductMapping.toObject()._id, compliance: 'misplaced' };
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
const fm = await getFixtureMetrics( fixture, currentDate );
|
|
2705
|
+
|
|
2706
|
+
return res.sendSuccess( { data: misplacedProductMapping, fixtureMetrics: fm, status: 'misplaced' } );
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
productMapping.forEach( async ( ele ) => {
|
|
2710
|
+
const complianceData = { ...ele.toObject(), planoMappingId: ele._id, compliance: 'proper' };
|
|
2711
|
+
delete complianceData._id;
|
|
2712
|
+
|
|
2713
|
+
await planoComplianceService.updateOne( { ...mappingQuery, date: currentDate }, complianceData );
|
|
2714
|
+
} );
|
|
2715
|
+
|
|
2716
|
+
|
|
2717
|
+
const fm = await getFixtureMetrics( fixture, currentDate );
|
|
2718
|
+
|
|
2719
|
+
|
|
2720
|
+
return res.sendSuccess( { data: { ...productMapping.toObject() }, fixtureMetrics: fm, status: 'proper' } );
|
|
2721
|
+
} else if ( fixture.productResolutionLevel === 'L3' ) {
|
|
2722
|
+
const sectionShelves = await fixtureShelfService.find( { fixtureId: fixture._id, sectionName: req.body.sectionName } );
|
|
2723
|
+
|
|
2724
|
+
if ( !sectionShelves.length ) return res.sendError( 'No shelves found for the Section', 400 );
|
|
2725
|
+
|
|
2726
|
+
const shelfIds = sectionShelves.map( ( shelf ) => shelf.toObject()._id );
|
|
2727
|
+
|
|
2728
|
+
const planoMapping = await planoMappingService.find( { rfId: { $in: req.body.rfId }, shelfId: { $in: shelfIds } } );
|
|
2729
|
+
|
|
2730
|
+
if ( !planoMapping.length ) {
|
|
2731
|
+
const locatePlano = await planoMappingService.find( { rfId: { $in: req.body.rfId }, floorId: req.body.floorId } );
|
|
2732
|
+
|
|
2733
|
+
if ( !locatePlano.length ) {
|
|
2734
|
+
return res.sendSuccess( { data: null, fixtureMetrics: null, status: 'missing' } );
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
locatePlano.forEach( ( ele ) => {
|
|
2738
|
+
const complianceData = { ...ele.toObject(), planoMappingId: ele.toObject()._id, compliance: 'misplaced' };
|
|
2739
|
+
delete complianceData._id;
|
|
2740
|
+
planoComplianceService.updateOne( { date: currentDate, planoMappingId: ele.toObject()._id }, complianceData );
|
|
2741
|
+
} );
|
|
2742
|
+
|
|
2743
|
+
|
|
2744
|
+
const fm = await getFixtureMetrics( fixture, currentDate );
|
|
2745
|
+
|
|
2746
|
+
|
|
2747
|
+
return res.sendSuccess( { data: { ...locatePlano.toObject() }, fixtureMetrics: fm, status: 'misplaced' } );
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
planoMapping.forEach( async ( ele ) => {
|
|
2751
|
+
const complianceData = { ...ele.toObject(), planoMappingId: ele.toObject()._id, compliance: 'proper' };
|
|
2752
|
+
delete complianceData._id;
|
|
2753
|
+
await planoComplianceService.updateOne( { date: currentDate, planoMappingId: ele.toObject()._id }, complianceData );
|
|
2754
|
+
} );
|
|
2755
|
+
|
|
2756
|
+
// const mapingData = planoMapping.toObject();
|
|
2757
|
+
|
|
2758
|
+
// delete mapingData._id;
|
|
2759
|
+
|
|
2760
|
+
|
|
2761
|
+
const fm = await getFixtureMetrics( fixture, currentDate );
|
|
2762
|
+
|
|
2763
|
+
return res.sendSuccess( { data: planoMapping, fixtureMetrics: fm, status: 'proper' } );
|
|
2764
|
+
} else {
|
|
2765
|
+
return res.sendError( 'Incorrect resolution level', 400 );
|
|
2766
|
+
}
|
|
2767
|
+
} catch ( e ) {
|
|
2768
|
+
logger.error( { functionName: 'scanv1', error: e, message: req.body } );
|
|
2769
|
+
return res.sendError( e, 500 );
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2637
2773
|
export async function storeFixturesv2( req, res ) {
|
|
2638
2774
|
try {
|
|
2639
2775
|
const planoIds = req.body.id
|
|
@@ -44,6 +44,7 @@ storeBuilderRouter
|
|
|
44
44
|
.post( '/checkPlanoExist', isAllowedSessionHandler, storeBuilderController.checkPlanoExist )
|
|
45
45
|
.post( '/storeLayoutElements', isAllowedSessionHandler, storeBuilderController.storeLayoutElements )
|
|
46
46
|
.post( '/qrScan', storeBuilderController.qrScan )
|
|
47
|
+
.post( '/qrScan1', storeBuilderController.qrScan1 )
|
|
47
48
|
.post( '/storeFixturesV2', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
|
|
48
49
|
.post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
|
|
49
50
|
.post( '/storeFixturesTaskv2', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv2 );
|