tango-app-api-store-builder 1.0.0-beta-3 → 1.0.0-beta-5
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
|
@@ -417,8 +417,58 @@ export async function storeList( req, res ) {
|
|
|
417
417
|
for ( let floor of layout.floor ) {
|
|
418
418
|
for ( let polygon of floor.layoutPolygon ) {
|
|
419
419
|
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 );
|
|
420
|
-
|
|
420
|
+
let fixtures = [];
|
|
421
|
+
for ( let fixture of polygonfixtureDetails ) {
|
|
422
|
+
let data = { ...fixture._doc, status: '' };
|
|
423
|
+
let query = [
|
|
424
|
+
{
|
|
425
|
+
$match: {
|
|
426
|
+
fixtureId: fixture._id,
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
$group: {
|
|
431
|
+
_id: '',
|
|
432
|
+
count: { $sum: '$shelfCapacity' },
|
|
433
|
+
fixtureId: { $first: '$fixtureId' },
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
$lookup: {
|
|
438
|
+
from: 'planocompliances',
|
|
439
|
+
let: { 'id': '$fixtureId' },
|
|
440
|
+
pipeline: [
|
|
441
|
+
{
|
|
442
|
+
$match: {
|
|
443
|
+
$expr: {
|
|
444
|
+
$and: [
|
|
445
|
+
{ createdAt: { $gte: dayjs().startOf( 'day' ).format(), $lte: dayjs().endOf( 'day' ).format() } },
|
|
446
|
+
{ $eq: [ '$fixtureId', '$$id' ] },
|
|
447
|
+
{ $eq: [ '$compliance', 'proper' ] },
|
|
448
|
+
],
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
$group: {
|
|
454
|
+
_id: '',
|
|
455
|
+
count: { $sum: 1 },
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
as: 'planoCompliance',
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
];
|
|
463
|
+
let fixtureDetails = await fixtureShelfService.aggregate( query );
|
|
464
|
+
if ( fixtureDetails.length ) {
|
|
465
|
+
data.status = fixtureDetails[0]?.planoCompliance?.length ? fixtureDetails[0].count == fixtureDetails[0]?.planoCompliance?.count ? 'complete' : 'incomplete' : '';
|
|
466
|
+
}
|
|
467
|
+
fixtures.push( data );
|
|
468
|
+
}
|
|
469
|
+
polygon.fixture = fixtures;
|
|
421
470
|
}
|
|
471
|
+
floor.centerFixture = fixtureDetails.filter( ( ele ) => layout.planoId.toString() == ele.planoId.toString() && ele.floorId.toString() == floor.id.toString() && ele.fixtureType == 'floor' );
|
|
422
472
|
}
|
|
423
473
|
}
|
|
424
474
|
return res.sendSuccess( { FloorDetails: getStoreList, productResolutionLevel: getPlanoDetails?.productResolutionLevel || '', productResolutionFilters: getPlanoDetails?.productResolutionFilters || [] } );
|
|
@@ -529,7 +579,7 @@ export async function fixtureShelfProduct( req, res ) {
|
|
|
529
579
|
let productDetails = await planoProductService.find( { _id: productIdList } );
|
|
530
580
|
query = {
|
|
531
581
|
...query,
|
|
532
|
-
...(['L3','L4'].includes(planoDetails.productResolutionLevel)) ? {shelfId:shelf._id} : {},
|
|
582
|
+
...( [ 'L3', 'L4' ].includes( planoDetails.productResolutionLevel ) ) ? { shelfId: shelf._id } : {},
|
|
533
583
|
productId: { $in: productIdList },
|
|
534
584
|
createdAt: { $gte: dayjs().startOf( 'day' ).format(), $lte: dayjs().endOf( 'day' ).format() },
|
|
535
585
|
};
|
|
@@ -537,9 +587,14 @@ export async function fixtureShelfProduct( req, res ) {
|
|
|
537
587
|
let product = [];
|
|
538
588
|
productDetails.forEach( ( item ) => {
|
|
539
589
|
let data = { ...item._doc, status: 'missing' };
|
|
590
|
+
let getPosition = productMappingDetails.find( ( ele ) => ele.productId.toString() == item._id.toString() );
|
|
540
591
|
let findCompliance = productComplianceDetails.find( ( ele ) => {
|
|
541
|
-
if()
|
|
542
|
-
|
|
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
|
+
} );
|
|
543
598
|
if ( findCompliance ) {
|
|
544
599
|
data.status = findCompliance.compliance;
|
|
545
600
|
}
|
|
@@ -568,6 +623,23 @@ export async function scan( req, res ) {
|
|
|
568
623
|
if ( !planoDetails ) {
|
|
569
624
|
return res.sendError( 'No data found', 204 );
|
|
570
625
|
}
|
|
626
|
+
if ( ![ 'L1', 'L2' ].includes( planoDetails.productResolutionLevel ) ) {
|
|
627
|
+
if ( !req.body.shelfId ) {
|
|
628
|
+
let shelfDetails = await fixtureShelfService.findOne( { rfId: req.body.rfId } );
|
|
629
|
+
if ( !shelfDetails ) {
|
|
630
|
+
return res.sendError( 'Please scan shelf first', 400 );
|
|
631
|
+
}
|
|
632
|
+
return res.sendSuccess( shelfDetails._id );
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if ( planoDetails.productResolutionLevel == 'L5' ) {
|
|
636
|
+
let shelfDetails = await fixtureShelfService.findOne( { _id: req.body.shelfId } );
|
|
637
|
+
if ( !shelfDetails ) {
|
|
638
|
+
return res.sendError( 'No data found', 204 );
|
|
639
|
+
}
|
|
640
|
+
shelfDetails = await fixtureShelfService.find( { sectionName: shelfDetails?.sectionName } );
|
|
641
|
+
req.body.shelfId = shelfDetails.map( ( ele ) => ele._id );
|
|
642
|
+
}
|
|
571
643
|
let productCheck= await planoMappingService.findOne( { rfId: req.body.rfId } );
|
|
572
644
|
if ( !productCheck ) {
|
|
573
645
|
return res.sendError( 'Product not found', 400 );
|
|
@@ -616,7 +688,20 @@ export async function scan( req, res ) {
|
|
|
616
688
|
}
|
|
617
689
|
query = { floorId: req.body.floorId, fixtureId: req.body.fixtureId, shelfId: req.body.shelfId, shelfPosition: req.body.shelfPosition };
|
|
618
690
|
break;
|
|
691
|
+
case 'L5':
|
|
692
|
+
if ( !req.body.floorId ) {
|
|
693
|
+
return res.sendError( 'Floor id is required', 400 );
|
|
694
|
+
}
|
|
695
|
+
if ( !req.body.fixtureId ) {
|
|
696
|
+
return res.sendError( 'Fixture id is required', 400 );
|
|
697
|
+
}
|
|
698
|
+
if ( !req.body.shelfId ) {
|
|
699
|
+
return res.sendError( 'Shelf id is required', 400 );
|
|
700
|
+
}
|
|
701
|
+
query = { floorId: req.body.floorId, fixtureId: req.body.fixtureId, shelfId: { $in: req.body.shelfId } };
|
|
702
|
+
break;
|
|
619
703
|
default:
|
|
704
|
+
return res.sendError( 'Product not found', 400 );
|
|
620
705
|
break;
|
|
621
706
|
}
|
|
622
707
|
query = { ...query, rfId: req.body.rfId };
|
|
@@ -626,9 +711,11 @@ export async function scan( req, res ) {
|
|
|
626
711
|
...( planoProductDetails ) ? { ...planoProductDetails._doc } : { planoId: req.body?.planoId, floorId: req.body?.floorId, fixtureId: req.body?.fixtureId, shelfId: req.body?.shelfId, clientId: planoDetails.clientId, storeName: planoDetails.storeName, storeId: planoDetails.storeId, shelfPosition: req.body?.shelfPosition },
|
|
627
712
|
rfId: req.body.rfId,
|
|
628
713
|
compliance: !planoProductDetails ? 'misplaced' : 'proper',
|
|
714
|
+
date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
629
715
|
};
|
|
630
716
|
delete data._id;
|
|
631
|
-
|
|
717
|
+
query = { ...query, date: new Date( dayjs().format( 'YYYY-MM-DD' ) ) };
|
|
718
|
+
await planoComplianceService.updateOne( query, data );
|
|
632
719
|
if ( !planoProductDetails ) {
|
|
633
720
|
return res.sendSuccess( false );
|
|
634
721
|
}
|
|
@@ -21,5 +21,9 @@ export async function aggregate( query ) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export async function updateOne( query, record ) {
|
|
24
|
-
return model.planoComplianceModel.updateOne( query, { $set: record } );
|
|
24
|
+
return model.planoComplianceModel.updateOne( query, { $set: record }, { upsert: true } );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function count( data ) {
|
|
28
|
+
return model.planoComplianceModel.countDocuments( data );
|
|
25
29
|
}
|