tango-app-api-store-builder 1.0.0-beta-9 → 1.0.0-beta-11
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 || [] } );
|
|
@@ -705,17 +729,31 @@ export async function scan( req, res ) {
|
|
|
705
729
|
break;
|
|
706
730
|
}
|
|
707
731
|
query = { ...query, rfId: req.body.rfId };
|
|
708
|
-
console.log( query );
|
|
709
732
|
|
|
710
733
|
let planoProductDetails = await planoMappingService.findOne( query );
|
|
734
|
+
console.log( query, 'query' );
|
|
735
|
+
// let data = {
|
|
736
|
+
// ...( 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 },
|
|
737
|
+
// rfId: req.body.rfId,
|
|
738
|
+
// compliance: !planoProductDetails ? 'misplaced' : 'proper',
|
|
739
|
+
// date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
740
|
+
// };
|
|
711
741
|
let data = {
|
|
712
|
-
|
|
742
|
+
planoId: req.body?.planoId,
|
|
743
|
+
floorId: req.body?.floorId,
|
|
744
|
+
fixtureId: req.body?.fixtureId,
|
|
745
|
+
shelfId: shelfId,
|
|
746
|
+
clientId: planoDetails.clientId,
|
|
747
|
+
storeName: planoDetails.storeName,
|
|
748
|
+
storeId: planoDetails.storeId,
|
|
749
|
+
shelfPosition: req.body?.shelfPosition,
|
|
713
750
|
rfId: req.body.rfId,
|
|
714
751
|
compliance: !planoProductDetails ? 'misplaced' : 'proper',
|
|
715
752
|
date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
716
753
|
};
|
|
717
754
|
delete data._id;
|
|
718
|
-
|
|
755
|
+
delete query.rfId;
|
|
756
|
+
query = { ...query, date: new Date( dayjs().format( 'YYYY-MM-DD' ) ), shelfPosition: req.body.shelfPosition };
|
|
719
757
|
await planoComplianceService.updateOne( query, data );
|
|
720
758
|
if ( !planoProductDetails ) {
|
|
721
759
|
return res.sendSuccess( false );
|