tango-app-api-store-builder 1.0.0-beta-215 → 1.0.0-beta-217
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
|
@@ -1362,9 +1362,12 @@ export async function updateStoreFixture( req, res ) {
|
|
|
1362
1362
|
let getMaxTemp = await fixtureConfigService.aggregate( tempQuery );
|
|
1363
1363
|
templateIndex = getMaxTemp?.[0]?.tempId + 1;
|
|
1364
1364
|
}
|
|
1365
|
-
templateData.fixtureName= `${header}-${data.fixtureCategory}-
|
|
1365
|
+
templateData.fixtureName= `${header}-${data.fixtureCategory}-variant-${templateIndex}`,
|
|
1366
1366
|
templateData.templateType = 'sub';
|
|
1367
1367
|
templateData.masterTemplateId = fixtureMasterTemplate._id;
|
|
1368
|
+
templateData.templateIndex = templateIndex;
|
|
1369
|
+
templateData.createdAt = new Date();
|
|
1370
|
+
templateData.updatedAt = new Date();
|
|
1368
1371
|
let subTemplate = await fixtureConfigService.create( templateData );
|
|
1369
1372
|
configId = subTemplate._id;
|
|
1370
1373
|
|
|
@@ -9698,44 +9698,45 @@ function transformProducts( products, shelvesByZone, fixtureData ) {
|
|
|
9698
9698
|
|
|
9699
9699
|
// ---------------------Plano Migrate-------------------------
|
|
9700
9700
|
|
|
9701
|
-
export async function getAllPlanoIds(
|
|
9701
|
+
export async function getAllPlanoIds(req, res){
|
|
9702
9702
|
try {
|
|
9703
|
-
|
|
9704
|
-
|
|
9703
|
+
|
|
9704
|
+
if (!req.query?.clientId) {
|
|
9705
|
+
return res.sendError('Client id is required', 400);
|
|
9705
9706
|
}
|
|
9706
|
-
const floorsData = await storeBuilderService.aggregate(
|
|
9707
|
+
const floorsData = await storeBuilderService.aggregate([
|
|
9707
9708
|
{
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
}, {
|
|
9712
|
-
'$group': {
|
|
9713
|
-
'_id': '$planoId',
|
|
9714
|
-
'storeName': {
|
|
9715
|
-
'$first': '$storeName',
|
|
9716
|
-
},
|
|
9717
|
-
'storeId': {
|
|
9718
|
-
'$first': '$storeId',
|
|
9719
|
-
},
|
|
9720
|
-
},
|
|
9709
|
+
'$match': {
|
|
9710
|
+
'clientId': '11'
|
|
9711
|
+
}
|
|
9721
9712
|
}, {
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9713
|
+
'$group': {
|
|
9714
|
+
'_id': '$planoId',
|
|
9715
|
+
'storeName': {
|
|
9716
|
+
'$first': '$storeName'
|
|
9726
9717
|
},
|
|
9718
|
+
'storeId': {
|
|
9719
|
+
'$first': '$storeId'
|
|
9720
|
+
}
|
|
9721
|
+
}
|
|
9722
|
+
}, {
|
|
9723
|
+
'$project': {
|
|
9724
|
+
'planoId': '$_id',
|
|
9725
|
+
'storeName': 1,
|
|
9726
|
+
'storeId': 1
|
|
9727
|
+
}
|
|
9727
9728
|
}, {
|
|
9728
|
-
|
|
9729
|
-
}
|
|
9730
|
-
]
|
|
9729
|
+
'$sort': { storeName: 1 }
|
|
9730
|
+
}
|
|
9731
|
+
]);
|
|
9731
9732
|
|
|
9732
|
-
if (
|
|
9733
|
-
return res.sendSuccess(
|
|
9733
|
+
if (floorsData) {
|
|
9734
|
+
return res.sendSuccess(floorsData);
|
|
9734
9735
|
} else {
|
|
9735
|
-
return res.sendError(
|
|
9736
|
+
return res.sendError("No floor data found", 204)
|
|
9736
9737
|
}
|
|
9737
|
-
} catch (
|
|
9738
|
-
console.log(
|
|
9739
|
-
return res.sendError(
|
|
9738
|
+
} catch (error) {
|
|
9739
|
+
console.log("@@ ~ getAllPlanoIds [ERR]:", error);
|
|
9740
|
+
return res.sendError(e, 500);
|
|
9740
9741
|
}
|
|
9741
|
-
}
|
|
9742
|
+
}
|
|
@@ -2849,14 +2849,19 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2849
2849
|
|
|
2850
2850
|
const shelfDetails = await Promise.all(
|
|
2851
2851
|
shelves.map( async ( shelf ) => {
|
|
2852
|
-
const
|
|
2852
|
+
const productDetails = await planoMappingService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'product' }, { _id: 1 } );
|
|
2853
|
+
let productIdList = productDetails.map( ( ele ) => ele._id );
|
|
2854
|
+
let status = await planoComplianceService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), planoMappingId: { $in: productIdList } }, { compliance: 1 } );
|
|
2855
|
+
status = status.map( ( ele ) => ele?.compliance );
|
|
2856
|
+
const compliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'imProper' : 'proper' : '';
|
|
2853
2857
|
|
|
2854
2858
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'vm' } );
|
|
2855
2859
|
|
|
2856
2860
|
return {
|
|
2857
2861
|
...shelf.toObject(),
|
|
2858
|
-
productCount:
|
|
2862
|
+
productCount: productDetails.length,
|
|
2859
2863
|
vmCount: vmCount,
|
|
2864
|
+
compliance,
|
|
2860
2865
|
};
|
|
2861
2866
|
} ),
|
|
2862
2867
|
);
|
|
@@ -2953,14 +2958,20 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2953
2958
|
|
|
2954
2959
|
const shelfDetails = await Promise.all(
|
|
2955
2960
|
shelves.map( async ( shelf ) => {
|
|
2956
|
-
const
|
|
2961
|
+
const productDetails = await planoMappingService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'product' }, { _id: 1 } );
|
|
2962
|
+
let productIdList = productDetails.map( ( ele ) => ele._id );
|
|
2963
|
+
let status = await planoComplianceService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), planoMappingId: { $in: productIdList } }, { compliance: 1 } );
|
|
2964
|
+
status = status.map( ( ele ) => ele?.compliance );
|
|
2965
|
+
const compliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'imProper' : 'proper' : '';
|
|
2966
|
+
|
|
2957
2967
|
|
|
2958
2968
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'vm' } );
|
|
2959
2969
|
|
|
2960
2970
|
return {
|
|
2961
2971
|
...shelf.toObject(),
|
|
2962
|
-
productCount:
|
|
2972
|
+
productCount: productDetails.length,
|
|
2963
2973
|
vmCount: vmCount,
|
|
2974
|
+
compliance,
|
|
2964
2975
|
};
|
|
2965
2976
|
} ),
|
|
2966
2977
|
);
|
|
@@ -3527,14 +3538,18 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3527
3538
|
|
|
3528
3539
|
const shelfDetails = await Promise.all(
|
|
3529
3540
|
shelves.map( async ( shelf ) => {
|
|
3530
|
-
const
|
|
3531
|
-
|
|
3541
|
+
const productDetails = await planoMappingService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'product' }, { _id: 1 } );
|
|
3542
|
+
let productIdList = productDetails.map( ( ele ) => ele._id );
|
|
3543
|
+
let status = await planoComplianceService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), planoMappingId: { $in: productIdList } }, { compliance: 1 } );
|
|
3544
|
+
status = status.map( ( ele ) => ele?.compliance );
|
|
3545
|
+
const compliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'imProper' : 'proper' : '';
|
|
3532
3546
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'vm' } );
|
|
3533
3547
|
|
|
3534
3548
|
return {
|
|
3535
3549
|
...shelf.toObject(),
|
|
3536
|
-
productCount:
|
|
3550
|
+
productCount: productDetails.length,
|
|
3537
3551
|
vmCount: vmCount,
|
|
3552
|
+
compliance,
|
|
3538
3553
|
};
|
|
3539
3554
|
} ),
|
|
3540
3555
|
);
|
|
@@ -3631,14 +3646,17 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3631
3646
|
|
|
3632
3647
|
const shelfDetails = await Promise.all(
|
|
3633
3648
|
shelves.map( async ( shelf ) => {
|
|
3634
|
-
const productCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'product' } );
|
|
3635
|
-
|
|
3636
3649
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'vm' } );
|
|
3637
|
-
|
|
3650
|
+
const productDetails = await planoMappingService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'product' }, { _id: 1 } );
|
|
3651
|
+
let productIdList = productDetails.map( ( ele ) => ele._id );
|
|
3652
|
+
let status = await planoComplianceService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), planoMappingId: { $in: productIdList } }, { compliance: 1 } );
|
|
3653
|
+
status = status.map( ( ele ) => ele?.compliance );
|
|
3654
|
+
const compliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'imProper' : 'proper' : '';
|
|
3638
3655
|
return {
|
|
3639
3656
|
...shelf.toObject(),
|
|
3640
|
-
productCount:
|
|
3657
|
+
productCount: productDetails.length,
|
|
3641
3658
|
vmCount: vmCount,
|
|
3659
|
+
compliance,
|
|
3642
3660
|
};
|
|
3643
3661
|
} ),
|
|
3644
3662
|
);
|
|
@@ -6295,3 +6313,37 @@ export async function getFixtureAIDetails( req, res ) {
|
|
|
6295
6313
|
return res.sendError( e, 500 );
|
|
6296
6314
|
}
|
|
6297
6315
|
}
|
|
6316
|
+
|
|
6317
|
+
export async function searchProduct( req, res ) {
|
|
6318
|
+
try {
|
|
6319
|
+
if ( !req.body?.planoId ) {
|
|
6320
|
+
return res.sendError( 'PlanoId is required', 400 );
|
|
6321
|
+
}
|
|
6322
|
+
if ( !req.body.floorId ) {
|
|
6323
|
+
return res.sendError( 'FloorId is required', 400 );
|
|
6324
|
+
}
|
|
6325
|
+
if ( !req.body.pid ) {
|
|
6326
|
+
return res.sendError( 'Pid is required', 400 );
|
|
6327
|
+
}
|
|
6328
|
+
let getProductDetails = await planoMappingService.find( { $or: [ { pid: { $regex: req.body.pid, $options: 'i' } }, { rfId: { $regex: req.body.pid, $options: 'i' } } ], planoId: req.body.planoId, floorId: req.body.floorId } );
|
|
6329
|
+
if ( !getProductDetails.length ) {
|
|
6330
|
+
return res.sendError( 'No data found', 204 );
|
|
6331
|
+
}
|
|
6332
|
+
let result = await Promise.all( getProductDetails.map( async ( ele ) => {
|
|
6333
|
+
let productDetails = await planoProductService.findOne( { _id: ele.productId }, { _id: 0, productName: 1, productImageUrl: 1, productType: 1 } );
|
|
6334
|
+
let fixtureDetails = await storeFixtureService.findOne( { _id: ele.fixtureId }, { _id: 0, associatedElementFixtureNumber: 1, associatedElementNumber: 1, fixtureType: 1 } );
|
|
6335
|
+
let shelfDetails = await fixtureShelfService.findOne( { _id: ele.shelfId }, { _id: 0, shelfNumber: 1 } );
|
|
6336
|
+
|
|
6337
|
+
return {
|
|
6338
|
+
...ele.toObject(),
|
|
6339
|
+
...productDetails?.toObject(),
|
|
6340
|
+
...fixtureDetails?.toObject(),
|
|
6341
|
+
...shelfDetails?.toObject(),
|
|
6342
|
+
};
|
|
6343
|
+
} ) );
|
|
6344
|
+
return res.sendSuccess( result );
|
|
6345
|
+
} catch ( e ) {
|
|
6346
|
+
logger.error( { functionName: 'searchProduct', error: e } );
|
|
6347
|
+
return res.sendError( e, 500 );
|
|
6348
|
+
}
|
|
6349
|
+
}
|
|
@@ -50,7 +50,8 @@ storeBuilderRouter
|
|
|
50
50
|
.post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
|
|
51
51
|
.post( '/fixtureShelfDetailsv3', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv3 )
|
|
52
52
|
.post( '/storeFixturesTaskv2', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv2 )
|
|
53
|
-
.post( '/storeFixturesTaskv3', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv3 )
|
|
53
|
+
.post( '/storeFixturesTaskv3', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv3 )
|
|
54
|
+
.post( '/searchProduct', isAllowedSessionHandler, storeBuilderController.searchProduct );
|
|
54
55
|
|
|
55
56
|
storeBuilderRouter
|
|
56
57
|
.post( '/planoList', isAllowedSessionHandler, storeBuilderController.planoList )
|