tango-app-api-store-builder 1.0.0-beta-196 → 1.0.0-beta-197
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
|
@@ -999,11 +999,35 @@ export async function getMasterList( req, res ) {
|
|
|
999
999
|
let page = req.body?.offset || 1;
|
|
1000
1000
|
let skip = limit * ( page - 1 );
|
|
1001
1001
|
|
|
1002
|
+
let searchMasterList = [];
|
|
1003
|
+
|
|
1004
|
+
if ( req.body?.searchValue ) {
|
|
1005
|
+
let searchQuery = [
|
|
1006
|
+
{
|
|
1007
|
+
$match: {
|
|
1008
|
+
clientId: req.body.clientId,
|
|
1009
|
+
templateType: 'sub',
|
|
1010
|
+
fixtureName: { $regex: req.body.searchValue, $options: 'i' },
|
|
1011
|
+
},
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
$group: {
|
|
1015
|
+
_id: '$masterTemplateId',
|
|
1016
|
+
},
|
|
1017
|
+
},
|
|
1018
|
+
];
|
|
1019
|
+
|
|
1020
|
+
let subTemplateDetails = await fixtureConfigService.aggregate( searchQuery );
|
|
1021
|
+
if ( subTemplateDetails.length ) {
|
|
1022
|
+
searchMasterList = subTemplateDetails.map( ( ele ) => ele._id );
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1002
1026
|
const matchStage = {
|
|
1003
1027
|
clientId: req.body.clientId,
|
|
1004
1028
|
templateType: 'master',
|
|
1005
1029
|
...( req.body?.searchValue ?
|
|
1006
|
-
{ fixtureName: { $regex: req.body.searchValue, $options: 'i' } } :
|
|
1030
|
+
{ $or: [ { fixtureName: { $regex: req.body.searchValue, $options: 'i' } }, { _id: { $in: searchMasterList } } ] } :
|
|
1007
1031
|
{} ),
|
|
1008
1032
|
...( req.body?.filter?.brand?.length ?
|
|
1009
1033
|
{
|
|
@@ -1181,6 +1205,9 @@ export async function getChildList( req, res ) {
|
|
|
1181
1205
|
clientId: req.body.clientId,
|
|
1182
1206
|
templateType: 'sub',
|
|
1183
1207
|
masterTemplateId: new ObjectId( req.body.masterTemplateId ),
|
|
1208
|
+
...( req.body?.searchValue ?
|
|
1209
|
+
{ fixtureName: { $regex: req.body.searchValue, $options: 'i' } } :
|
|
1210
|
+
{} ),
|
|
1184
1211
|
};
|
|
1185
1212
|
|
|
1186
1213
|
const query = [
|
|
@@ -9548,3 +9548,58 @@ async function updateHeaders() {
|
|
|
9548
9548
|
console.log( key );
|
|
9549
9549
|
} );
|
|
9550
9550
|
}
|
|
9551
|
+
|
|
9552
|
+
|
|
9553
|
+
export async function readExcel( req, res ) {
|
|
9554
|
+
try {
|
|
9555
|
+
const workbook = xlsx.read( req.files.file.data, { type: 'buffer' } );
|
|
9556
|
+
const sheetName = 'Updated - 275';
|
|
9557
|
+
const raw = xlsx.utils.sheet_to_json( workbook.Sheets[sheetName] );
|
|
9558
|
+
// const sheetName1 = 'Zone Level Allocation with No o';
|
|
9559
|
+
const sheetName1 = 'Zone Level Allocation with > 1 ';
|
|
9560
|
+
const rawZone = xlsx.utils.sheet_to_json( workbook.Sheets[sheetName1] );
|
|
9561
|
+
console.log( rawZone );
|
|
9562
|
+
let data = [];
|
|
9563
|
+
function cleanFixtures( obj ) {
|
|
9564
|
+
const cleaned = {};
|
|
9565
|
+
for ( const key in obj ) {
|
|
9566
|
+
// Skip keys that match pattern "Fixture number_number"
|
|
9567
|
+
if ( /^Fixture \d+_\d+$/.test( key ) ) continue;
|
|
9568
|
+
cleaned[key] = obj[key];
|
|
9569
|
+
}
|
|
9570
|
+
return cleaned;
|
|
9571
|
+
}
|
|
9572
|
+
raw.forEach( ( ele ) => {
|
|
9573
|
+
ele = cleanFixtures( ele );
|
|
9574
|
+
let keys = Object.keys( ele );
|
|
9575
|
+
let category = ele['Category'];
|
|
9576
|
+
let fixture = [];
|
|
9577
|
+
keys.splice( 0, 1 );
|
|
9578
|
+
keys.forEach( ( key ) => {
|
|
9579
|
+
let topValue = rawZone.find( ( zone ) => zone.Category == category && zone.r == keys.length && zone.Category_1 == 'Top' );
|
|
9580
|
+
let midValue = rawZone.find( ( zone ) => zone.Category == category && zone.r == keys.length && zone.Category_1 == 'Mid' );
|
|
9581
|
+
let midValue1 = rawZone.find( ( zone ) => zone.Category == category && zone.r == keys.length && zone.Category_1 == 'Mid 2' || zone.Category_1 == 'Mid _2' );
|
|
9582
|
+
let bottomValue = rawZone.find( ( zone ) => zone.Category == category && zone.r == keys.length && zone.Category_1 == 'Bottom' );
|
|
9583
|
+
if ( midValue1 && midValue1[key] != '-' ) {
|
|
9584
|
+
midValue[key] = midValue[key] + ' + ' + midValue1[key];
|
|
9585
|
+
}
|
|
9586
|
+
fixture.push( {
|
|
9587
|
+
header: ele[key],
|
|
9588
|
+
top: topValue[key],
|
|
9589
|
+
mid: midValue[key],
|
|
9590
|
+
bottom: bottomValue[key],
|
|
9591
|
+
} );
|
|
9592
|
+
} );
|
|
9593
|
+
data.push( {
|
|
9594
|
+
category: category,
|
|
9595
|
+
fixtureCount: fixture.length,
|
|
9596
|
+
fixtures: fixture,
|
|
9597
|
+
} );
|
|
9598
|
+
} );
|
|
9599
|
+
return res.sendSuccess( data );
|
|
9600
|
+
} catch ( e ) {
|
|
9601
|
+
console.log( e );
|
|
9602
|
+
logger.error( { functionName: 'readExcel', error: e } );
|
|
9603
|
+
return res.sendError( e, 500 );
|
|
9604
|
+
}
|
|
9605
|
+
}
|
|
@@ -32,4 +32,5 @@ scriptRouter
|
|
|
32
32
|
.post( '/recorrectTaskData', scriptController.recorrectTaskData )
|
|
33
33
|
.post( '/migrateCrest', scriptController.migrateCrestv1 )
|
|
34
34
|
.post( '/updatePlanoMappings', scriptController.updatePlanoMappings )
|
|
35
|
+
.post( '/readExcel', scriptController.readExcel )
|
|
35
36
|
;
|