tango-app-api-store-builder 1.0.0-beta-223 → 1.0.0-beta-225
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
|
@@ -3322,7 +3322,7 @@ export async function storeFixturesv3( req, res ) {
|
|
|
3322
3322
|
export async function fixtureShelfProductv2( req, res ) {
|
|
3323
3323
|
try {
|
|
3324
3324
|
const { planoId, fixtureId } = req.body;
|
|
3325
|
-
let shelfMapping =
|
|
3325
|
+
let shelfMapping = {};
|
|
3326
3326
|
|
|
3327
3327
|
const [ planogram, fixture ] = await Promise.all( [
|
|
3328
3328
|
planoService.findOne(
|
|
@@ -3335,27 +3335,28 @@ export async function fixtureShelfProductv2( req, res ) {
|
|
|
3335
3335
|
if ( !planogram ) return res.sendError( 'Planogram not found', 204 );
|
|
3336
3336
|
if ( !fixture ) return res.sendError( 'Fixture not found', 204 );
|
|
3337
3337
|
|
|
3338
|
+
if ( req.body?.compliance ) {
|
|
3339
|
+
let getAllFixtures = await fixtureShelfService.find( { planoId: fixture.planoId, floorId: fixture.floorId, fixtureId: { $ne: fixtureId } } );
|
|
3338
3340
|
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
];
|
|
3341
|
+
shelfMapping = getAllFixtures.reduce( ( acc, ele ) => {
|
|
3342
|
+
let productList = ele.productBrandName?.toString()?.toLowerCase();
|
|
3343
|
+
if ( !acc?.[productList] ) {
|
|
3344
|
+
let findZone = acc?.[productList]?.find( ( prod ) => prod.zone == ele.zone && prod.shelfId.toString() == ele._id.toString() );
|
|
3345
|
+
if ( !findZone ) {
|
|
3346
|
+
acc[productList] = [
|
|
3347
|
+
{
|
|
3348
|
+
zone: ele.zone,
|
|
3349
|
+
shelfId: ele._id,
|
|
3350
|
+
fixtureId: ele.fixtureId,
|
|
3351
|
+
fixtureName: fixture.fixtureName,
|
|
3352
|
+
brandName: ele.productBrandName,
|
|
3353
|
+
},
|
|
3354
|
+
];
|
|
3355
|
+
}
|
|
3355
3356
|
}
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
}
|
|
3357
|
+
return acc;
|
|
3358
|
+
}, {} );
|
|
3359
|
+
}
|
|
3359
3360
|
|
|
3360
3361
|
|
|
3361
3362
|
const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
|
|
@@ -3369,7 +3370,7 @@ export async function fixtureShelfProductv2( req, res ) {
|
|
|
3369
3370
|
mappings.map( async ( mapping ) => {
|
|
3370
3371
|
const productData = productMap.get( mapping?.productId?.toString() ) || {};
|
|
3371
3372
|
delete productData._id;
|
|
3372
|
-
let mappingCompliance = await planoComplianceService.
|
|
3373
|
+
let mappingCompliance = await planoComplianceService.findLean( {
|
|
3373
3374
|
planoMappingId: mapping._id,
|
|
3374
3375
|
date: currentDate,
|
|
3375
3376
|
} );
|
|
@@ -3377,7 +3378,7 @@ export async function fixtureShelfProductv2( req, res ) {
|
|
|
3377
3378
|
Object.keys( shelfMapping ).forEach( ( ele ) => {
|
|
3378
3379
|
let eleArr = ele.split( ',' );
|
|
3379
3380
|
if ( eleArr.includes( productData.brandName.toLowerCase() ) ) {
|
|
3380
|
-
mappingCompliance = { ...mappingCompliance
|
|
3381
|
+
mappingCompliance = { ...mappingCompliance, fixtureDetails: shelfMapping[ele]?.[0] || {} };
|
|
3381
3382
|
}
|
|
3382
3383
|
} );
|
|
3383
3384
|
}
|
|
@@ -3408,13 +3409,15 @@ export async function fixtureShelfProductv2( req, res ) {
|
|
|
3408
3409
|
fixtureShelves.map( async ( shelf ) => {
|
|
3409
3410
|
const productMappings = await planoMappingService.find( { shelfId: shelf._id, type: 'product' } );
|
|
3410
3411
|
const productDetails = await getProducts( productMappings );
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3412
|
+
if ( req.body?.compliance ) {
|
|
3413
|
+
let count = shelf.shelfType == 'tray' ? ( shelf.productPerShelf * shelf.trayRows ) : shelf.productPerShelf;
|
|
3414
|
+
if ( count > productMappings.length ) {
|
|
3415
|
+
let extraProduct = count- productMappings.length;
|
|
3416
|
+
for ( let i=0; i<extraProduct; i++ ) {
|
|
3417
|
+
productDetails.unshift( {
|
|
3418
|
+
status: 'missing',
|
|
3419
|
+
} );
|
|
3420
|
+
}
|
|
3418
3421
|
}
|
|
3419
3422
|
}
|
|
3420
3423
|
return { ...shelf.toObject(), products: productDetails };
|
|
@@ -3427,6 +3430,7 @@ export async function fixtureShelfProductv2( req, res ) {
|
|
|
3427
3430
|
|
|
3428
3431
|
return res.sendError( 'Incorrect resolution level', 400 );
|
|
3429
3432
|
} catch ( e ) {
|
|
3433
|
+
console.log( e );
|
|
3430
3434
|
logger.error( { functionName: 'fixtureShelfProductv1', error: e, message: req.body } );
|
|
3431
3435
|
return res.sendError( e, 500 );
|
|
3432
3436
|
}
|
|
@@ -3575,14 +3579,14 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3575
3579
|
let productIdList = productDetails.map( ( ele ) => ele._id );
|
|
3576
3580
|
let status = await planoComplianceService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), planoMappingId: { $in: productIdList } }, { compliance: 1 } );
|
|
3577
3581
|
status = status.map( ( ele ) => ele?.compliance );
|
|
3578
|
-
const
|
|
3582
|
+
const productCompliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
|
|
3579
3583
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf.toObject(), type: 'vm' } );
|
|
3580
3584
|
|
|
3581
3585
|
return {
|
|
3582
3586
|
...shelf.toObject(),
|
|
3583
3587
|
productCount: productDetails.length,
|
|
3584
3588
|
vmCount: vmCount,
|
|
3585
|
-
compliance,
|
|
3589
|
+
compliance: productCompliance,
|
|
3586
3590
|
};
|
|
3587
3591
|
} ),
|
|
3588
3592
|
);
|
|
@@ -3624,6 +3628,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3624
3628
|
shelfConfig: shelfDetails,
|
|
3625
3629
|
vmConfig: vmDetails,
|
|
3626
3630
|
...( req.body.type == 'fixtureMeasurement' && { fixtureMeasurement: compliance.answers?.[0]?.fixtureWidth } ),
|
|
3631
|
+
...( ( compliance?.answers?.[0]?.status && req.body.type == 'fixture' && req.body.redo ) && { ansStatus: true } ),
|
|
3627
3632
|
};
|
|
3628
3633
|
} ),
|
|
3629
3634
|
);
|
|
@@ -3684,12 +3689,12 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3684
3689
|
let productIdList = productDetails.map( ( ele ) => ele._id );
|
|
3685
3690
|
let status = await planoComplianceService.find( { fixtureId: fixture._id, shelfId: shelf.toObject(), planoMappingId: { $in: productIdList } }, { compliance: 1 } );
|
|
3686
3691
|
status = status.map( ( ele ) => ele?.compliance );
|
|
3687
|
-
|
|
3692
|
+
let productCompliance = status.length ? ( status.includes( 'missing' ) || status.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
|
|
3688
3693
|
return {
|
|
3689
3694
|
...shelf.toObject(),
|
|
3690
3695
|
productCount: productDetails.length,
|
|
3691
3696
|
vmCount: vmCount,
|
|
3692
|
-
compliance,
|
|
3697
|
+
compliance: productCompliance,
|
|
3693
3698
|
};
|
|
3694
3699
|
} ),
|
|
3695
3700
|
);
|
|
@@ -3731,6 +3736,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3731
3736
|
shelfConfig: shelfDetails,
|
|
3732
3737
|
vmConfig: vmDetails,
|
|
3733
3738
|
...( req.body.type == 'fixtureMeasurement' && { fixtureMeasurement: compliance.answers?.[0]?.fixtureWidth } ),
|
|
3739
|
+
...( ( compliance?.answers?.[0]?.status && req.body.type == 'fixture' && req.body.redo ) && { ansStatus: true } ),
|
|
3734
3740
|
};
|
|
3735
3741
|
} ),
|
|
3736
3742
|
);
|
|
@@ -5253,7 +5259,15 @@ export async function planoList( req, res ) {
|
|
|
5253
5259
|
|
|
5254
5260
|
if ( inputData.filter.status.length ) {
|
|
5255
5261
|
if ( inputData.filter.status.includes( 'taskAssigned' ) ) {
|
|
5256
|
-
orQuery.push( { 'planoTask.taskStatus.status': { $in: [ 'open', 'inprogress' ] } } );
|
|
5262
|
+
// orQuery.push( { 'planoTask.taskStatus.status': { $in: [ 'open', 'inprogress' ] } } );
|
|
5263
|
+
orQuery.push( {
|
|
5264
|
+
'planoTask.taskStatus': {
|
|
5265
|
+
$elemMatch: {
|
|
5266
|
+
status: { $ne: 'submit' },
|
|
5267
|
+
breach: false,
|
|
5268
|
+
},
|
|
5269
|
+
},
|
|
5270
|
+
} );
|
|
5257
5271
|
}
|
|
5258
5272
|
if ( inputData.filter.status.includes( 'reviewPending' ) ) {
|
|
5259
5273
|
orQuery.push( {
|
|
@@ -7012,12 +7026,13 @@ export async function searchProduct( req, res ) {
|
|
|
7012
7026
|
|
|
7013
7027
|
export async function updateProductMapping( req, res ) {
|
|
7014
7028
|
try {
|
|
7015
|
-
let storeDetails = await storeService.find( { clientId: req.body.clientId, ...( req.body.stores && { storeName: { $in: req.body.stores } } ), status: 'active' }, { storeId: 1 } );
|
|
7029
|
+
let storeDetails = await storeService.find( { clientId: req.body.clientId, ...( req.body.stores && { storeName: { $in: req.body.stores } } ), status: 'active' }, { storeId: 1, storeName: 1 } );
|
|
7016
7030
|
if ( !storeDetails.length ) {
|
|
7017
7031
|
return res.sendError( 'No data found', 204 );
|
|
7018
7032
|
}
|
|
7019
7033
|
await Promise.all( storeDetails.map( async ( store ) => {
|
|
7020
|
-
let
|
|
7034
|
+
let number = Number( store.storeName.replace( /\D/g, '' ) );
|
|
7035
|
+
let getLatestData = await fetch( `${JSON.parse( process.env.LAMBDAURL )?.getRFIDDetails}/${number}`, { method: 'GET' } );
|
|
7021
7036
|
if ( getLatestData.status == 200 ) {
|
|
7022
7037
|
let response = await getLatestData.json();
|
|
7023
7038
|
let data = response.mac_details.flatMap( ( ele ) => ele.body );
|
|
@@ -45,10 +45,10 @@ storeBuilderRouter
|
|
|
45
45
|
.post( '/storeLayoutElements', isAllowedSessionHandler, storeBuilderController.storeLayoutElements )
|
|
46
46
|
.post( '/qrScan', isAllowedSessionHandler, storeBuilderController.qrScan )
|
|
47
47
|
.post( '/storeFixturesV2', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
|
|
48
|
-
.post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
|
|
49
|
-
.post( '/storeFixturesTaskv2', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv2 )
|
|
48
|
+
// .post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
|
|
49
|
+
// .post( '/storeFixturesTaskv2', isAllowedSessionHandler, storeBuilderController.storeFixturesTaskv2 )
|
|
50
50
|
.post( '/qrScan1', isAllowedSessionHandler, storeBuilderController.qrScan1 )
|
|
51
|
-
.post( '/storeFixturesV2', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
|
|
51
|
+
// .post( '/storeFixturesV2', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv2 )
|
|
52
52
|
.post( '/storeFixturesV3', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv3 )
|
|
53
53
|
.post( '/fixtureShelfDetailsv2', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv2 )
|
|
54
54
|
.post( '/fixtureShelfDetailsv3', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv3 )
|
|
@@ -27,3 +27,7 @@ export async function updateOne( query, record ) {
|
|
|
27
27
|
export async function count( data ) {
|
|
28
28
|
return model.planoComplianceModel.countDocuments( data );
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
export async function findLean( query={}, field={} ) {
|
|
32
|
+
return model.planoComplianceModel.findOne( query, field ).lean();
|
|
33
|
+
}
|