tango-app-api-store-builder 1.0.0-beta-195 → 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
|
@@ -874,7 +874,33 @@ export async function replaceFixtureDetails( req, res ) {
|
|
|
874
874
|
}
|
|
875
875
|
if ( inputData.storeList.length == 0 && inputData.publishAll ) {
|
|
876
876
|
await fixtureConfigService.updateOne( { _id: inputData.replaceFixture }, { isEdited: false } );
|
|
877
|
-
|
|
877
|
+
let query = [
|
|
878
|
+
{
|
|
879
|
+
$match: {
|
|
880
|
+
fixtureConfigId: new ObjectId( inputData.findFixture ),
|
|
881
|
+
},
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
$group: {
|
|
885
|
+
_id: '$storeId',
|
|
886
|
+
floorDetails: {
|
|
887
|
+
$first: {
|
|
888
|
+
_id: '$floorId',
|
|
889
|
+
},
|
|
890
|
+
},
|
|
891
|
+
},
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
$project: {
|
|
895
|
+
storeId: '$_id',
|
|
896
|
+
floorDetails: 1,
|
|
897
|
+
_id: 0,
|
|
898
|
+
},
|
|
899
|
+
},
|
|
900
|
+
];
|
|
901
|
+
|
|
902
|
+
// inputData.storeList = await storeFixtureService.find( { fixtureConfigId: inputData.findFixture }, { storeId: 1 } );
|
|
903
|
+
inputData.storeList = await storeFixtureService.aggregate( query );
|
|
878
904
|
let data = {
|
|
879
905
|
templateId: inputData.replaceFixture,
|
|
880
906
|
data: replaceFixtureData,
|
|
@@ -973,11 +999,35 @@ export async function getMasterList( req, res ) {
|
|
|
973
999
|
let page = req.body?.offset || 1;
|
|
974
1000
|
let skip = limit * ( page - 1 );
|
|
975
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
|
+
|
|
976
1026
|
const matchStage = {
|
|
977
1027
|
clientId: req.body.clientId,
|
|
978
1028
|
templateType: 'master',
|
|
979
1029
|
...( req.body?.searchValue ?
|
|
980
|
-
{ fixtureName: { $regex: req.body.searchValue, $options: 'i' } } :
|
|
1030
|
+
{ $or: [ { fixtureName: { $regex: req.body.searchValue, $options: 'i' } }, { _id: { $in: searchMasterList } } ] } :
|
|
981
1031
|
{} ),
|
|
982
1032
|
...( req.body?.filter?.brand?.length ?
|
|
983
1033
|
{
|
|
@@ -1155,6 +1205,9 @@ export async function getChildList( req, res ) {
|
|
|
1155
1205
|
clientId: req.body.clientId,
|
|
1156
1206
|
templateType: 'sub',
|
|
1157
1207
|
masterTemplateId: new ObjectId( req.body.masterTemplateId ),
|
|
1208
|
+
...( req.body?.searchValue ?
|
|
1209
|
+
{ fixtureName: { $regex: req.body.searchValue, $options: 'i' } } :
|
|
1210
|
+
{} ),
|
|
1158
1211
|
};
|
|
1159
1212
|
|
|
1160
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
|
;
|