tango-app-api-store-builder 1.0.0-beta-8 → 1.0.0-beta-10
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
|
@@ -413,62 +413,86 @@ export async function storeLayout( req, res ) {
|
|
|
413
413
|
return res.sendError( 'No data found', 204 );
|
|
414
414
|
}
|
|
415
415
|
let fixtureDetails = await storeFixtureService.find( { planoId: { $in: idList } } );
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
416
|
+
let fixtureList = fixtureDetails.map( ( ele ) => ele._id );
|
|
417
|
+
let fixtureQuery = [
|
|
418
|
+
{
|
|
419
|
+
$match: {
|
|
420
|
+
fixtureId: { $in: fixtureList },
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
$group: {
|
|
425
|
+
_id: '$fixtureId',
|
|
426
|
+
count: { $sum: '$shelfCapacity' },
|
|
427
|
+
fixtureId: { $first: '$fixtureId' },
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
$lookup: {
|
|
432
|
+
from: 'planocompliances',
|
|
433
|
+
let: { 'id': '$fixtureId' },
|
|
434
|
+
pipeline: [
|
|
435
|
+
{
|
|
436
|
+
$match: {
|
|
437
|
+
$expr: {
|
|
438
|
+
$and: [
|
|
439
|
+
{ date: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
440
|
+
{ $eq: [ '$fixtureId', '$$id' ] },
|
|
441
|
+
],
|
|
434
442
|
},
|
|
435
443
|
},
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
$group: {
|
|
447
|
+
_id: '$fixtureId',
|
|
448
|
+
properCount: { $sum: {
|
|
449
|
+
$cond: [
|
|
441
450
|
{
|
|
442
|
-
$
|
|
443
|
-
$
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
},
|
|
450
|
-
},
|
|
451
|
-
},
|
|
451
|
+
$and: [
|
|
452
|
+
{ $eq: [ '$compliance', 'proper' ] },
|
|
453
|
+
],
|
|
454
|
+
}, 1, 0 ],
|
|
455
|
+
} },
|
|
456
|
+
misPlacedCount: { $sum: {
|
|
457
|
+
$cond: [
|
|
452
458
|
{
|
|
453
|
-
$
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
],
|
|
459
|
-
as: 'planoCompliance',
|
|
460
|
-
},
|
|
459
|
+
$and: [
|
|
460
|
+
{ $ne: [ '$compliance', 'proper' ] },
|
|
461
|
+
],
|
|
462
|
+
}, 1, 0 ],
|
|
463
|
+
} },
|
|
461
464
|
},
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
465
|
+
},
|
|
466
|
+
],
|
|
467
|
+
as: 'planoCompliance',
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
];
|
|
471
|
+
let fixtureStatus = await fixtureShelfService.aggregate( fixtureQuery );
|
|
472
|
+
for ( let layout of getStoreList ) {
|
|
473
|
+
for ( let floor of layout.floor ) {
|
|
474
|
+
for ( let polygon of floor.layoutPolygon ) {
|
|
475
|
+
let polygonfixtureDetails = fixtureDetails.filter( ( ele ) => layout.planoId.toString() == ele.planoId.toString() && ele.floorId.toString() == floor.id.toString() && ele.associatedElementType == polygon.elementType && ele.associatedElementNumber == polygon.elementNumber );
|
|
476
|
+
polygonfixtureDetails.forEach( ( fixtureEle, index ) => {
|
|
477
|
+
let updateFixture = { ...fixtureEle._doc, status: '' };
|
|
478
|
+
let getFixtureStatus = fixtureStatus.find( ( statusElem ) => statusElem.fixtureId.toString() == fixtureEle._id.toString() );
|
|
479
|
+
if ( getFixtureStatus && getFixtureStatus?.planoCompliance?.length ) {
|
|
480
|
+
updateFixture.status = getFixtureStatus.count == getFixtureStatus?.planoCompliance?.properCount ? 'complete' : 'incomplete';
|
|
466
481
|
}
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
|
|
482
|
+
polygonfixtureDetails[index] = updateFixture;
|
|
483
|
+
} );
|
|
484
|
+
|
|
485
|
+
polygon.fixture = polygonfixtureDetails;
|
|
470
486
|
}
|
|
471
487
|
floor.centerFixture = fixtureDetails.filter( ( ele ) => layout.planoId.toString() == ele.planoId.toString() && ele.floorId.toString() == floor.id.toString() && ele.fixtureType == 'floor' );
|
|
488
|
+
floor.centerFixture.forEach( ( centerFixture, index ) => {
|
|
489
|
+
let centerList = { ...centerFixture._doc, status: '' };
|
|
490
|
+
let getFixtureStatus = fixtureStatus.find( ( statusElem ) => statusElem.fixtureId.toString() == centerFixture._id.toString() );
|
|
491
|
+
if ( getFixtureStatus && getFixtureStatus?.planoCompliance?.length ) {
|
|
492
|
+
centerList.status = getFixtureStatus.count == getFixtureStatus?.planoCompliance?.properCount ? 'complete' : 'incomplete';
|
|
493
|
+
}
|
|
494
|
+
floor.centerFixture[index] = centerList;
|
|
495
|
+
} );
|
|
472
496
|
}
|
|
473
497
|
}
|
|
474
498
|
return res.sendSuccess( { FloorDetails: getStoreList, productResolutionLevel: getPlanoDetails?.productResolutionLevel || '', productResolutionFilters: getPlanoDetails?.productResolutionFilters || [] } );
|
|
@@ -560,41 +584,35 @@ export async function fixtureShelfProduct( req, res ) {
|
|
|
560
584
|
if ( !fixtureDetails ) {
|
|
561
585
|
return res.sendError( 'Fixture not found', 204 );
|
|
562
586
|
}
|
|
563
|
-
let planoDetails = await planoService.findOne( { _id: fixtureDetails.planoId } );
|
|
587
|
+
// let planoDetails = await planoService.findOne( { _id: fixtureDetails.planoId } );
|
|
564
588
|
let shelfDetails = await fixtureShelfService.find( { fixtureId: req.body.fixtureId } );
|
|
565
|
-
let query;
|
|
566
|
-
switch ( planoDetails.productResolutionLevel ) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
589
|
+
// let query;
|
|
590
|
+
// switch ( planoDetails.productResolutionLevel ) {
|
|
591
|
+
// case 'L1':
|
|
592
|
+
// query = { floorId: fixtureDetails.floorId };
|
|
593
|
+
// break;
|
|
594
|
+
// default:
|
|
595
|
+
// query = { floorId: fixtureDetails.floorId, fixtureId: req.body.fixtureId };
|
|
596
|
+
// break;
|
|
597
|
+
// }
|
|
598
|
+
// query = {
|
|
599
|
+
// ...query,
|
|
600
|
+
// ...( [ 'L3', 'L4' ].includes( planoDetails.productResolutionLevel ) ) ? { shelfId: shelf._id } : {},
|
|
601
|
+
// productId: { $in: productIdList },
|
|
602
|
+
// date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
603
|
+
// };
|
|
574
604
|
let shelfList = [];
|
|
575
605
|
for ( let shelf of shelfDetails ) {
|
|
576
606
|
let data = { ...shelf._doc, products: [] };
|
|
577
607
|
let productMappingDetails = await planoMappingService.find( { shelfId: shelf._id } );
|
|
578
608
|
let productIdList = productMappingDetails.map( ( item ) => item.productId );
|
|
579
609
|
let productDetails = await planoProductService.find( { _id: productIdList } );
|
|
580
|
-
|
|
581
|
-
...query,
|
|
582
|
-
...( [ 'L3', 'L4' ].includes( planoDetails.productResolutionLevel ) ) ? { shelfId: shelf._id } : {},
|
|
583
|
-
productId: { $in: productIdList },
|
|
584
|
-
date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
585
|
-
};
|
|
586
|
-
let productComplianceDetails = await planoComplianceService.find( query );
|
|
610
|
+
let productComplianceDetails = await planoComplianceService.find( { date: new Date( dayjs().format( 'YYYY-MM-DD' ) ), shelfId: shelf._id } );
|
|
587
611
|
let product = [];
|
|
588
612
|
productDetails.forEach( ( item ) => {
|
|
589
613
|
let data = { ...item._doc, status: 'missing', rfId: '' };
|
|
590
614
|
let getPosition = productMappingDetails.find( ( ele ) => ele.productId.toString() == item._id.toString() );
|
|
591
|
-
let findCompliance = productComplianceDetails.find( ( ele ) =>
|
|
592
|
-
if ( planoDetails.productResolutionLevel == 'L4' && getPosition ) {
|
|
593
|
-
return ( item._id.toString() == ele.productId.toString() && ele.shelfPosition == getPosition.shelfPosition );
|
|
594
|
-
} else {
|
|
595
|
-
return ( item._id.toString() == ele.productId.toString() );
|
|
596
|
-
}
|
|
597
|
-
} );
|
|
615
|
+
let findCompliance = productComplianceDetails.find( ( ele ) => ele.shelfPosition == getPosition.shelfPosition );
|
|
598
616
|
if ( findCompliance ) {
|
|
599
617
|
data.status = findCompliance.compliance;
|
|
600
618
|
}
|
|
@@ -614,6 +632,7 @@ export async function fixtureShelfProduct( req, res ) {
|
|
|
614
632
|
|
|
615
633
|
export async function scan( req, res ) {
|
|
616
634
|
try {
|
|
635
|
+
let shelfId;
|
|
617
636
|
if ( !req.body.planoId ) {
|
|
618
637
|
return res.sendError( 'Plano id is required', 400 );
|
|
619
638
|
}
|
|
@@ -638,7 +657,11 @@ export async function scan( req, res ) {
|
|
|
638
657
|
if ( !shelfDetails ) {
|
|
639
658
|
return res.sendError( 'No data found', 204 );
|
|
640
659
|
}
|
|
660
|
+
if ( shelfDetails.shelfCapacity < req.body.shelfPosition ) {
|
|
661
|
+
return res.sendError( 'Shelf capacity exceeded', 400 );
|
|
662
|
+
}
|
|
641
663
|
shelfDetails = await fixtureShelfService.find( { sectionName: shelfDetails?.sectionName } );
|
|
664
|
+
shelfId = req.body.shelfId;
|
|
642
665
|
req.body.shelfId = shelfDetails.map( ( ele ) => ele._id );
|
|
643
666
|
}
|
|
644
667
|
let productCheck= await planoMappingService.findOne( { rfId: req.body.rfId } );
|
|
@@ -709,13 +732,13 @@ export async function scan( req, res ) {
|
|
|
709
732
|
|
|
710
733
|
let planoProductDetails = await planoMappingService.findOne( query );
|
|
711
734
|
let data = {
|
|
712
|
-
...( planoProductDetails ) ? { ...planoProductDetails._doc } : { planoId: req.body?.planoId, floorId: req.body?.floorId, fixtureId: req.body?.fixtureId, shelfId:
|
|
735
|
+
...( planoProductDetails ) ? { ...planoProductDetails._doc } : { planoId: req.body?.planoId, floorId: req.body?.floorId, fixtureId: req.body?.fixtureId, shelfId: shelfId, clientId: planoDetails.clientId, storeName: planoDetails.storeName, storeId: planoDetails.storeId, shelfPosition: req.body?.shelfPosition },
|
|
713
736
|
rfId: req.body.rfId,
|
|
714
737
|
compliance: !planoProductDetails ? 'misplaced' : 'proper',
|
|
715
738
|
date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
716
739
|
};
|
|
717
740
|
delete data._id;
|
|
718
|
-
query = { ...query, date: new Date( dayjs().format( 'YYYY-MM-DD' ) ) };
|
|
741
|
+
query = { ...query, date: new Date( dayjs().format( 'YYYY-MM-DD' ) ), shelfPosition: planoProductDetails?.shelfPosition || req.body.shelfPosition };
|
|
719
742
|
await planoComplianceService.updateOne( query, data );
|
|
720
743
|
if ( !planoProductDetails ) {
|
|
721
744
|
return res.sendSuccess( false );
|