tango-app-api-store-builder 1.0.0-beta-198 → 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",
|
|
@@ -866,7 +866,6 @@ export async function TemplateStoresList( req, res ) {
|
|
|
866
866
|
export async function replaceFixtureDetails( req, res ) {
|
|
867
867
|
try {
|
|
868
868
|
let inputData = req.body;
|
|
869
|
-
console.log( inputData );
|
|
870
869
|
let replaceFixtureData = await fixtureConfigService.findOne( { _id: inputData.replaceFixture } );
|
|
871
870
|
|
|
872
871
|
if ( !replaceFixtureData ) {
|
|
@@ -908,6 +907,16 @@ export async function replaceFixtureDetails( req, res ) {
|
|
|
908
907
|
await templateLogService.create( data );
|
|
909
908
|
}
|
|
910
909
|
if ( inputData.storeList.length ) {
|
|
910
|
+
let storeList = inputData.storeList.map( ( ele ) => ele.storeId );
|
|
911
|
+
let getDetails = await storeFixtureService.find( { storeId: { $in: storeList }, fixtureConfigId: inputData.findFixture, $or: [ { isMerchEdited: true }, { isVmEdited: true } ] }, { storeId: 1 } );
|
|
912
|
+
if ( getDetails.length ) {
|
|
913
|
+
await Promise.all( getDetails.map( async ( ele ) => {
|
|
914
|
+
let taskDetails = await processedTaskService.findOne( { store_id: ele.storeId, isPlano: true, planoType: [ 'merchRollout', 'vmRollout' ] }, {}, { _id: -1 } );
|
|
915
|
+
if ( taskDetails ) {
|
|
916
|
+
await processedTaskService.deleteOne( { _id: taskDetails._id } );
|
|
917
|
+
}
|
|
918
|
+
} ) );
|
|
919
|
+
}
|
|
911
920
|
const updateData = {
|
|
912
921
|
...replaceFixtureData.toObject(),
|
|
913
922
|
fixtureConfigId: replaceFixtureData._id,
|
|
@@ -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
|
|
@@ -3240,7 +3376,7 @@ export async function planoList( req, res ) {
|
|
|
3240
3376
|
let page = inputData?.offset - 1 || 0;
|
|
3241
3377
|
let skip = limit * page;
|
|
3242
3378
|
|
|
3243
|
-
let storeDetails = await storeService.find( { clientId: inputData.clientId, status: 'active' }, { storeId: 1 } );
|
|
3379
|
+
let storeDetails = await storeService.find( { clientId: inputData.clientId, status: 'active', ...( inputData?.stores?.length && { storeId: { $in: inputData.stores } } ) }, { storeId: 1 } );
|
|
3244
3380
|
storeDetails = storeDetails.map( ( ele ) => ele.storeId );
|
|
3245
3381
|
|
|
3246
3382
|
let query = [
|
|
@@ -4553,7 +4689,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4553
4689
|
let page = req?.body?.offset || 1;
|
|
4554
4690
|
let limit = req.body?.limit || 10;
|
|
4555
4691
|
let skip = ( page -1 ) * limit;
|
|
4556
|
-
let storeDetails = await storeService.find( { clientId: req.body.clientId, status: 'active' }, { storeId: 1 } );
|
|
4692
|
+
let storeDetails = await storeService.find( { clientId: req.body.clientId, status: 'active', ...( req.body?.stores?.length && { storeId: { $in: req.body.stores } } ) }, { storeId: 1 } );
|
|
4557
4693
|
storeDetails = storeDetails.map( ( ele ) => ele.storeId );
|
|
4558
4694
|
let query = [
|
|
4559
4695
|
{
|
|
@@ -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 );
|
|
@@ -16,6 +16,10 @@ export async function deleteMany( query = {} ) {
|
|
|
16
16
|
return model.taskProcessedModel.deleteMany( query );
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
export async function deleteOne( query = {} ) {
|
|
20
|
+
return model.taskProcessedModel.deleteOne( query );
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
export async function aggregate( query = {} ) {
|
|
20
24
|
return model.taskProcessedModel.aggregate( query );
|
|
21
25
|
}
|