tango-app-api-store-builder 1.1.10 → 1.1.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable quotes */
|
|
2
2
|
// import { writeFileSync } from 'fs';
|
|
3
3
|
import xlsx from 'xlsx';
|
|
4
|
-
import { logger, fileUpload, download, chunkArray } from 'tango-app-api-middleware';
|
|
4
|
+
import { logger, fileUpload, download, chunkArray, sendMessageToQueue } from 'tango-app-api-middleware';
|
|
5
5
|
import * as storeBuilderService from '../service/storeBuilder.service.js';
|
|
6
6
|
import * as storeService from '../service/store.service.js';
|
|
7
7
|
import * as planoService from '../service/planogram.service.js';
|
|
@@ -18192,3 +18192,47 @@ export async function updateProductInventory( req, res ) {
|
|
|
18192
18192
|
}
|
|
18193
18193
|
|
|
18194
18194
|
// updateProductInventory();
|
|
18195
|
+
|
|
18196
|
+
|
|
18197
|
+
export async function updateTaskQueue( req, res ) {
|
|
18198
|
+
try {
|
|
18199
|
+
if ( !req.body?.storeName?.length ) {
|
|
18200
|
+
return res.sendError( 'StoreName is required', 400 );
|
|
18201
|
+
}
|
|
18202
|
+
await Promise.all( req.body?.storeName.map( async ( ele ) => {
|
|
18203
|
+
let planoDetails = await planoService.findOne( { storeName: ele }, { _id: 1 } );
|
|
18204
|
+
if ( planoDetails ) {
|
|
18205
|
+
let storeFixtureDetails = await storeFixtureService.find( { planoId: planoDetails._id } );
|
|
18206
|
+
if ( storeFixtureDetails.length ) {
|
|
18207
|
+
let fixtureList = [];
|
|
18208
|
+
let taskId;
|
|
18209
|
+
for ( let fixture of storeFixtureDetails ) {
|
|
18210
|
+
let complianceDetails = await planoTaskService.findOne( { fixtureId: fixture._id, type: 'fixture' } );
|
|
18211
|
+
if ( complianceDetails ) {
|
|
18212
|
+
taskId = complianceDetails.taskId;
|
|
18213
|
+
fixtureList.push( {
|
|
18214
|
+
imagePath: complianceDetails?.answers[0]?.image,
|
|
18215
|
+
fixtureId: fixture._id,
|
|
18216
|
+
fixtureData: fixture,
|
|
18217
|
+
} );
|
|
18218
|
+
}
|
|
18219
|
+
}
|
|
18220
|
+
let queueData = {
|
|
18221
|
+
bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
18222
|
+
date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
18223
|
+
storeName: ele,
|
|
18224
|
+
taskId: taskId,
|
|
18225
|
+
fixtureList: fixtureList,
|
|
18226
|
+
};
|
|
18227
|
+
|
|
18228
|
+
const sqs = JSON.parse( process.env.SQS );
|
|
18229
|
+
await sendMessageToQueue( `${sqs.url}${sqs.fixtureImageProcess}`, JSON.stringify( queueData ) );
|
|
18230
|
+
}
|
|
18231
|
+
}
|
|
18232
|
+
} ) );
|
|
18233
|
+
return res.sendSuccess( 'message pushed successfully' );
|
|
18234
|
+
} catch ( e ) {
|
|
18235
|
+
logger.error( { functionName: "updateTaskQueue", error: e } );
|
|
18236
|
+
return res.sendError( e, 500 );
|
|
18237
|
+
}
|
|
18238
|
+
}
|
|
@@ -9659,3 +9659,27 @@ export async function getStoreFixtureFootfall( req, res ) {
|
|
|
9659
9659
|
return res.sendError( e, 500 );
|
|
9660
9660
|
}
|
|
9661
9661
|
}
|
|
9662
|
+
|
|
9663
|
+
export async function getRfidProductDetails( req, res ) {
|
|
9664
|
+
try {
|
|
9665
|
+
if ( !req.body.storeName ) {
|
|
9666
|
+
return res.sendError( 'Store name is required', 400 );
|
|
9667
|
+
}
|
|
9668
|
+
if ( !req.body.pid ) {
|
|
9669
|
+
return res.sendError( 'Pid is required', 400 );
|
|
9670
|
+
}
|
|
9671
|
+
|
|
9672
|
+
let productDetails = await planoProductService.findOne( { pid: req.body.pid, storeName: req.body.storeName } );
|
|
9673
|
+
if ( !productDetails ) {
|
|
9674
|
+
return res.sendError( 'No data found', 204 );
|
|
9675
|
+
}
|
|
9676
|
+
let mappingDetails = await planoMappingService.findOne( { productId: productDetails._id } );
|
|
9677
|
+
if ( mappingDetails ) {
|
|
9678
|
+
productDetails = { ...productDetails.toObject(), fixtureId: mappingDetails.fixtureId };
|
|
9679
|
+
}
|
|
9680
|
+
return res.sendSuccess( productDetails );
|
|
9681
|
+
} catch ( e ) {
|
|
9682
|
+
logger.error( { functionName: 'getRfidProductDetails', error: e } );
|
|
9683
|
+
return res.sendError( e, 500 );
|
|
9684
|
+
}
|
|
9685
|
+
}
|
|
@@ -53,4 +53,5 @@ scriptRouter
|
|
|
53
53
|
.get( '/4487FixtureDetails', scriptController.get4487FixtureDetails )
|
|
54
54
|
.post( '/getstoreMBQFixtureExcel', scriptController.getstoreMBQFixtureExcel )
|
|
55
55
|
.get( '/getRfidFixtureData', isAllowedInternalAPIHandler, scriptController.getRfidFixtureData )
|
|
56
|
+
.post( '/updateTaskQueue', scriptController.updateTaskQueue )
|
|
56
57
|
;
|
|
@@ -79,5 +79,6 @@ storeBuilderRouter
|
|
|
79
79
|
.post( '/getStoreEngagers', isAllowedSessionHandler, storeBuilderController.getStoreEngagers )
|
|
80
80
|
.post( '/getStoreFixtureEngagers', isAllowedSessionHandler, storeBuilderController.getStoreFixtureEngagers )
|
|
81
81
|
.post( '/getStoreFixtureFootfall', isAllowedSessionHandler, storeBuilderController.getStoreFixtureFootfall )
|
|
82
|
+
.post( '/getRfidProductDetails', isAllowedInternalAPIHandler, storeBuilderController.getRfidProductDetails )
|
|
82
83
|
// .get( '/migrationScript', isAllowedInternalAPIHandler, storeBuilderController.migrationScript )
|
|
83
84
|
;
|