tango-app-api-store-builder 1.1.1 → 1.1.2
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.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"path": "^0.12.7",
|
|
34
34
|
"selenium-webdriver": "^4.31.0",
|
|
35
35
|
"sharp": "^0.34.1",
|
|
36
|
-
"tango-api-schema": "^2.5.
|
|
36
|
+
"tango-api-schema": "^2.5.41",
|
|
37
37
|
"tango-app-api-middleware": "3.1.48",
|
|
38
38
|
"url": "^0.11.4",
|
|
39
39
|
"winston": "^3.17.0",
|
|
@@ -1930,7 +1930,8 @@ export async function getPlanoRevisionById( req, res ) {
|
|
|
1930
1930
|
},
|
|
1931
1931
|
];
|
|
1932
1932
|
let complianceStatus = await planoComplianceService.aggregate( complianceQuery );
|
|
1933
|
-
|
|
1933
|
+
let productCount = shelf.shelfType == 'tray' ? shelf.productPerShelf * shelf.trayRows : shelf.productPerShelf;
|
|
1934
|
+
shelf.compliance = complianceStatus?.[0]?.status.length ? ( ( complianceStatus?.[0]?.status?.length < productCount ) || complianceStatus?.[0]?.status?.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
|
|
1934
1935
|
return shelf;
|
|
1935
1936
|
} ) );
|
|
1936
1937
|
fixture.vmConfig = await Promise.all( fixture.vmConfig.map( async ( vm ) => {
|
|
@@ -1971,7 +1972,8 @@ export async function getPlanoRevisionById( req, res ) {
|
|
|
1971
1972
|
},
|
|
1972
1973
|
];
|
|
1973
1974
|
let complianceStatus = await planoComplianceService.aggregate( complianceQuery );
|
|
1974
|
-
|
|
1975
|
+
let productCount = shelf.shelfType == 'tray' ? shelf.productPerShelf * shelf.trayRows : shelf.productPerShelf;
|
|
1976
|
+
shelf.compliance = complianceStatus?.[0]?.status.length ? ( ( complianceStatus?.[0]?.status?.length < productCount ) || complianceStatus?.[0]?.status?.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
|
|
1975
1977
|
return shelf;
|
|
1976
1978
|
} ) );
|
|
1977
1979
|
return fixture;
|
|
@@ -8328,11 +8328,19 @@ export async function calculateCompliance( req, res ) {
|
|
|
8328
8328
|
{
|
|
8329
8329
|
$group: {
|
|
8330
8330
|
_id: '$createdAt',
|
|
8331
|
+
productCount: { $sum: {
|
|
8332
|
+
$cond: {
|
|
8333
|
+
if: { $eq: [ '$type', 'product' ] },
|
|
8334
|
+
then: 1,
|
|
8335
|
+
else: 0,
|
|
8336
|
+
} },
|
|
8337
|
+
},
|
|
8331
8338
|
},
|
|
8332
8339
|
},
|
|
8333
8340
|
{
|
|
8334
8341
|
$project: {
|
|
8335
8342
|
_id: 0,
|
|
8343
|
+
productCount: 1,
|
|
8336
8344
|
date: '$_id',
|
|
8337
8345
|
count: 1,
|
|
8338
8346
|
time: {
|
|
@@ -8446,6 +8454,7 @@ export async function calculateCompliance( req, res ) {
|
|
|
8446
8454
|
lastCheck: null,
|
|
8447
8455
|
missedCount: getCompliance?.[0]?.missedCount,
|
|
8448
8456
|
misplacedCount: getCompliance?.[0]?.misplacedCount,
|
|
8457
|
+
productCount: getCompliance?.[0]?.productCount,
|
|
8449
8458
|
};
|
|
8450
8459
|
if ( getCompliance.length ) {
|
|
8451
8460
|
// let productCountQuery = [
|
|
@@ -9518,13 +9527,107 @@ export async function getFixtureShelfRfidDetails( req, res ) {
|
|
|
9518
9527
|
export async function getFixtureFootfall( req, res ) {
|
|
9519
9528
|
try {
|
|
9520
9529
|
let inputData = req.body;
|
|
9521
|
-
let
|
|
9530
|
+
let response = await fetch( JSON.parse( process.env.LAMBDAURL )?.footfallLambda, {
|
|
9522
9531
|
method: 'POST',
|
|
9523
9532
|
body: JSON.stringify( inputData ),
|
|
9524
9533
|
} );
|
|
9525
|
-
|
|
9534
|
+
if ( response.status == 200 ) {
|
|
9535
|
+
let data = await response.json();
|
|
9536
|
+
return res.sendSuccess( data );
|
|
9537
|
+
}
|
|
9538
|
+
return res.sendError( 'Something went wrong', 400 );
|
|
9526
9539
|
} catch ( e ) {
|
|
9527
9540
|
logger.error( { functionName: 'getFixtureFootfall', error: e } );
|
|
9528
9541
|
return res.sendError( e, 500 );
|
|
9529
9542
|
}
|
|
9530
9543
|
}
|
|
9544
|
+
|
|
9545
|
+
export async function getTopPerformingZones( req, res ) {
|
|
9546
|
+
try {
|
|
9547
|
+
let inputData = req.body;
|
|
9548
|
+
let planoDetails = await planoService.findOne( { storeName: 'LKST4487' } );
|
|
9549
|
+
let storeFixtureDetails = await storeFixtureService.find( { planoId: planoDetails._id, fixtureType: { $ne: 'other' } }, { _id: 1, header: 1, associatedElementNumber: 1, associatedElementFixtureNumber: 1 } );
|
|
9550
|
+
let shelfDetails = await fixtureShelfService.find( { planoId: planoDetails._id } );
|
|
9551
|
+
storeFixtureDetails.forEach( ( ele ) => {
|
|
9552
|
+
ele['productName'] = [ ...new Set( shelfDetails.filter( ( shelf ) => shelf.fixtureId.toString() == ele?._id?.toString() )?.flatMap( ( shelf ) => shelf.productBrandName ) ) ];
|
|
9553
|
+
} );
|
|
9554
|
+
let response = await fetch( JSON.parse( process.env.LAMBDAURL )?.zoneLambda, {
|
|
9555
|
+
method: 'POST',
|
|
9556
|
+
body: JSON.stringify( inputData ),
|
|
9557
|
+
} );
|
|
9558
|
+
if ( response.status == 200 ) {
|
|
9559
|
+
let data = await response.json();
|
|
9560
|
+
data?.topPerformingZones?.forEach( ( ele ) => {
|
|
9561
|
+
let fixturedetails = storeFixtureDetails.filter( ( fixt ) => fixt.header.label == ele.zoneName );
|
|
9562
|
+
ele.zoneProduct = [ ...new Set( fixturedetails?.flatMap( ( fixt ) => fixt.productName ) ) ];
|
|
9563
|
+
ele.wallNumber = fixturedetails?.[0]?.associatedElementNumber;
|
|
9564
|
+
ele.position = fixturedetails?.[0]?.associatedElementFixtureNumber;
|
|
9565
|
+
} );
|
|
9566
|
+
return res.sendSuccess( data );
|
|
9567
|
+
}
|
|
9568
|
+
return res.sendError( 'Something went wrong', 400 );
|
|
9569
|
+
} catch ( e ) {
|
|
9570
|
+
logger.error( { functionName: 'getFixtureZoneDetails', error: e } );
|
|
9571
|
+
return res.sendError( e, 500 );
|
|
9572
|
+
}
|
|
9573
|
+
}
|
|
9574
|
+
|
|
9575
|
+
export async function getStoreEngagers( req, res ) {
|
|
9576
|
+
try {
|
|
9577
|
+
let inputData = req.body;
|
|
9578
|
+
let response = await fetch( JSON.parse( process.env.LAMBDAURL )?.engagersLambda, {
|
|
9579
|
+
method: 'POST',
|
|
9580
|
+
body: JSON.stringify( inputData ),
|
|
9581
|
+
} );
|
|
9582
|
+
if ( response.status == 200 ) {
|
|
9583
|
+
let fixtureData = await response.json();
|
|
9584
|
+
let result = {};
|
|
9585
|
+
await Promise.all( Object.keys( fixtureData?.data ).map( async ( ele ) => {
|
|
9586
|
+
result[`${ele}`] = [];
|
|
9587
|
+
fixtureData.data.ele = await Promise.all( fixtureData?.data?.[ele].map( async ( product ) => {
|
|
9588
|
+
let productDetails = await planoProductService.findOne( { brandGroup: product.Brandname, productImageUrl: { $ne: '' } } );
|
|
9589
|
+
if ( productDetails ) {
|
|
9590
|
+
product.imageUrl = productDetails.productImageUrl;
|
|
9591
|
+
}
|
|
9592
|
+
result[ele].push( product );
|
|
9593
|
+
} ) );
|
|
9594
|
+
result[`${ele}`].sort( ( a, b ) => b.count - a.count );
|
|
9595
|
+
} ) );
|
|
9596
|
+
return res.sendSuccess( result );
|
|
9597
|
+
}
|
|
9598
|
+
return res.sendError( 'Something went wrong', 400 );
|
|
9599
|
+
} catch ( e ) {
|
|
9600
|
+
logger.error( { functionName: 'getFixtureEngagersList', error: e } );
|
|
9601
|
+
return res.sendError( e, 500 );
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
|
|
9605
|
+
export async function getStoreFixtureEngagers( req, res ) {
|
|
9606
|
+
try {
|
|
9607
|
+
let inputData = req.body;
|
|
9608
|
+
let response = await fetch( JSON.parse( process.env.LAMBDAURL )?.fixtureEngagers, {
|
|
9609
|
+
method: 'POST',
|
|
9610
|
+
body: JSON.stringify( inputData ),
|
|
9611
|
+
} );
|
|
9612
|
+
if ( response.status == 200 ) {
|
|
9613
|
+
let fixtureData = await response.json();
|
|
9614
|
+
let result = {};
|
|
9615
|
+
await Promise.all( Object.keys( fixtureData?.data ).map( async ( ele ) => {
|
|
9616
|
+
result[`${ele}`] = [];
|
|
9617
|
+
fixtureData.data.ele = await Promise.all( fixtureData?.data?.[ele].map( async ( product ) => {
|
|
9618
|
+
let productDetails = await planoProductService.findOne( { brandGroup: product.Brandname, productImageUrl: { $ne: '' } } );
|
|
9619
|
+
if ( productDetails ) {
|
|
9620
|
+
product.imageUrl = productDetails.productImageUrl;
|
|
9621
|
+
}
|
|
9622
|
+
result[ele].push( product );
|
|
9623
|
+
} ) );
|
|
9624
|
+
result[`${ele}`].sort( ( a, b ) => a.count - b.count );
|
|
9625
|
+
} ) );
|
|
9626
|
+
return res.sendSuccess( fixtureData );
|
|
9627
|
+
}
|
|
9628
|
+
return res.sendError( 'Something went wrong', 400 );
|
|
9629
|
+
} catch ( e ) {
|
|
9630
|
+
logger.error( { functionName: 'getFixtureEngagersDetails', error: e } );
|
|
9631
|
+
return res.sendError( e, 500 );
|
|
9632
|
+
}
|
|
9633
|
+
}
|
|
@@ -610,6 +610,50 @@ export async function updateStatus( req, res ) {
|
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
|
|
613
|
+
if ( req.body.status == 'submit' && taskDetails.planoType == 'fixture' ) {
|
|
614
|
+
let fixtureData = await storeFixtureService.find( { planoId: taskDetails.planoId, floorId: taskDetails.floorId } );
|
|
615
|
+
let fixtureList = [];
|
|
616
|
+
await Promise.all( fixtureData.map( async ( fixt ) => {
|
|
617
|
+
let fixtureTask = await planoTaskService.findOne(
|
|
618
|
+
{
|
|
619
|
+
planoId: new mongoose.Types.ObjectId( fixt.planoId ),
|
|
620
|
+
floorId: new mongoose.Types.ObjectId( fixt.floorId ),
|
|
621
|
+
taskId: new mongoose.Types.ObjectId( taskDetails._id ),
|
|
622
|
+
fixtureId: new mongoose.Types.ObjectId( fixt._id ),
|
|
623
|
+
type: 'fixture',
|
|
624
|
+
approvalStatus: 'pending',
|
|
625
|
+
},
|
|
626
|
+
);
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
fixt = fixt?.toObject();
|
|
630
|
+
|
|
631
|
+
let fixtureShelves = await fixtureShelfService.find( { fixtureId: fixt._id } );
|
|
632
|
+
|
|
633
|
+
if ( fixtureShelves.length ) {
|
|
634
|
+
fixtureShelves = fixtureShelves.map( ( shelf ) => shelf?.toObject() );
|
|
635
|
+
fixt.shelfConfig = fixtureShelves;
|
|
636
|
+
}
|
|
637
|
+
if ( fixtureTask ) {
|
|
638
|
+
fixtureList.push( {
|
|
639
|
+
imagePath: fixtureTask?.answers[0]?.image,
|
|
640
|
+
fixtureId: fixt._id,
|
|
641
|
+
fixtureData: fixt,
|
|
642
|
+
} );
|
|
643
|
+
}
|
|
644
|
+
} ) );
|
|
645
|
+
let sqsData = {
|
|
646
|
+
bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
647
|
+
date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
648
|
+
storeName: taskDetails?.storeName,
|
|
649
|
+
taskId: taskDetails?._id,
|
|
650
|
+
fixtureList: fixtureList,
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
const sqs = JSON.parse( process.env.SQS );
|
|
654
|
+
await sendMessageToQueue( `${sqs.url}${sqs.fixtureImageProcess}`, JSON.stringify( sqsData ) );
|
|
655
|
+
}
|
|
656
|
+
|
|
613
657
|
// if ( req.body.status == 'submit' && [ 'merchRollout', 'vmRollout' ].includes( taskDetails.planoType ) ) {
|
|
614
658
|
// let merchVmTaskDetails = await planoTaskService.find(
|
|
615
659
|
// {
|
|
@@ -734,33 +778,34 @@ export async function updateAnswersv2( req, res ) {
|
|
|
734
778
|
await sendMessageToQueue( `${sqs.url}${sqs.storeBuilder}`, JSON.stringify( sqsData ) );
|
|
735
779
|
}
|
|
736
780
|
|
|
737
|
-
if ( req.body.type === 'fixture' ) {
|
|
738
|
-
|
|
781
|
+
// if ( req.body.type === 'fixture' ) {
|
|
782
|
+
// let fixtureData = await storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( req.body.fixtureId ) } );
|
|
739
783
|
|
|
740
|
-
|
|
741
|
-
|
|
784
|
+
// if ( fixtureData ) {
|
|
785
|
+
// fixtureData = fixtureData?.toObject();
|
|
742
786
|
|
|
743
|
-
|
|
787
|
+
// let fixtureShelves = await fixtureShelfService.find( { fixtureId: fixtureData._id } );
|
|
744
788
|
|
|
745
|
-
|
|
746
|
-
|
|
789
|
+
// if ( fixtureShelves.length ) {
|
|
790
|
+
// fixtureShelves = fixtureShelves.map( ( shelf ) => shelf?.toObject() );
|
|
747
791
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
792
|
+
// fixtureData.shelfConfig = fixtureShelves;
|
|
793
|
+
// }
|
|
794
|
+
// }
|
|
751
795
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
796
|
+
// let sqsData = {
|
|
797
|
+
// bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
798
|
+
// date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
799
|
+
// storeName: data?.storeName,
|
|
800
|
+
// fixtureList:[]
|
|
801
|
+
// imagePath: data?.answers[0]?.image,
|
|
802
|
+
// fixtureId: req.body.fixtureId,
|
|
803
|
+
// fixtureData: fixtureData,
|
|
804
|
+
// };
|
|
760
805
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
}
|
|
806
|
+
// const sqs = JSON.parse( process.env.SQS );
|
|
807
|
+
// await sendMessageToQueue( `${sqs.url}${sqs.fixtureImageProcess}`, JSON.stringify( sqsData ) );
|
|
808
|
+
// }
|
|
764
809
|
|
|
765
810
|
|
|
766
811
|
return res.sendSuccess( 'Fixture details updated successfully' );
|
|
@@ -1136,3 +1181,21 @@ export async function revokeTask( req, res ) {
|
|
|
1136
1181
|
return res.sendError( e, 500 );
|
|
1137
1182
|
}
|
|
1138
1183
|
}
|
|
1184
|
+
|
|
1185
|
+
export async function validateTask( req, res ) {
|
|
1186
|
+
try {
|
|
1187
|
+
if ( !req.body.fixtureList?.length ) {
|
|
1188
|
+
return res.sendError( 'fixtureId is required', 400 );
|
|
1189
|
+
}
|
|
1190
|
+
if ( !req.body.taskId ) {
|
|
1191
|
+
return res.sendError( 'TaskId is required', 400 );
|
|
1192
|
+
}
|
|
1193
|
+
req.body.fixtureList = req.body.fixtureList.map( ( ele ) => new mongoose.Types.ObjectId( ele ) );
|
|
1194
|
+
await planoTaskService.updateMany( { taskId: req.body.taskId, fixtureId: { $in: req.body.fixtureList }, type: 'fixture' }, { 'answers.0.status': 'disagree', 'approvalStatus': 'approved', 'answers.0.userAction': 'redo' } );
|
|
1195
|
+
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: 'open', redoStatus: true, autoRedo: true } );
|
|
1196
|
+
return res.sendSuccess( 'Redo task created successfully' );
|
|
1197
|
+
} catch ( e ) {
|
|
1198
|
+
logger.error( { functionName: 'validateTask', error: e } );
|
|
1199
|
+
return res.sendError( e, 400 );
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
@@ -74,5 +74,9 @@ storeBuilderRouter
|
|
|
74
74
|
.get( '/getStoreFloorsList', isAllowedSessionHandler, storeBuilderController.getStoreFloorsList )
|
|
75
75
|
.post( '/getShelfDetails', isAllowedInternalAPIHandler, storeBuilderController.getShelfDetails )
|
|
76
76
|
.post( '/getFixtureShelfRfidDetails', isAllowedInternalAPIHandler, storeBuilderController.getFixtureShelfRfidDetails )
|
|
77
|
+
.post( '/getFixtureFootfall', isAllowedSessionHandler, storeBuilderController.getFixtureFootfall )
|
|
78
|
+
.post( '/getTopPerformingZones', isAllowedSessionHandler, storeBuilderController.getTopPerformingZones )
|
|
79
|
+
.post( '/getStoreEngagers', isAllowedSessionHandler, storeBuilderController.getStoreEngagers )
|
|
80
|
+
.post( '/getStoreFixtureEngagers', isAllowedSessionHandler, storeBuilderController.getStoreFixtureEngagers )
|
|
77
81
|
// .get( '/migrationScript', isAllowedInternalAPIHandler, storeBuilderController.migrationScript )
|
|
78
82
|
;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
2
|
+
import { isAllowedSessionHandler, isAllowedInternalAPIHandler } from 'tango-app-api-middleware';
|
|
3
3
|
import * as taskController from '../controllers/task.controller.js';
|
|
4
4
|
|
|
5
5
|
export const storeBuilderTaskRouter = express.Router();
|
|
@@ -19,4 +19,5 @@ storeBuilderTaskRouter
|
|
|
19
19
|
.post( '/redoTask', isAllowedSessionHandler, taskController.redoTask )
|
|
20
20
|
.post( '/revokeTask', isAllowedSessionHandler, taskController.revokeTask )
|
|
21
21
|
.get( '/planoTaskDetails', isAllowedSessionHandler, taskController.getPlanoTaskDetails )
|
|
22
|
+
.post( '/validateTask', isAllowedInternalAPIHandler, taskController.validateTask )
|
|
22
23
|
;
|