tango-app-api-store-builder 1.0.44 → 1.0.45
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/items.xlsx
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -940,74 +940,74 @@ export async function getVmLibList( req, res ) {
|
|
|
940
940
|
|
|
941
941
|
const query = [
|
|
942
942
|
{ $match: matchStage },
|
|
943
|
-
{
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
},
|
|
965
|
-
{
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
},
|
|
970
|
-
{
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
},
|
|
978
|
-
{
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
},
|
|
989
|
-
{
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
},
|
|
943
|
+
// {
|
|
944
|
+
// $lookup: {
|
|
945
|
+
// from: 'fixtureconfigs',
|
|
946
|
+
// let: { libraryId: '$_id' },
|
|
947
|
+
// pipeline: [
|
|
948
|
+
// {
|
|
949
|
+
// $match: {
|
|
950
|
+
// $expr: {
|
|
951
|
+
// $in: [ '$$libraryId', { $ifNull: [ '$vmConfig.vmId', [] ] } ],
|
|
952
|
+
// },
|
|
953
|
+
// },
|
|
954
|
+
// },
|
|
955
|
+
// {
|
|
956
|
+
// $group: {
|
|
957
|
+
// _id: null,
|
|
958
|
+
// templateIds: { $addToSet: '$_id' },
|
|
959
|
+
// },
|
|
960
|
+
// },
|
|
961
|
+
// ],
|
|
962
|
+
// as: 'fixtureTemplate',
|
|
963
|
+
// },
|
|
964
|
+
// },
|
|
965
|
+
// {
|
|
966
|
+
// $set: {
|
|
967
|
+
// templateId: { $ifNull: [ { $arrayElemAt: [ '$fixtureTemplate.templateIds', 0 ] }, [] ] },
|
|
968
|
+
// },
|
|
969
|
+
// },
|
|
970
|
+
// {
|
|
971
|
+
// $lookup: {
|
|
972
|
+
// from: 'storefixtures',
|
|
973
|
+
// localField: 'templateId',
|
|
974
|
+
// foreignField: 'fixtureConfigId',
|
|
975
|
+
// as: 'storeFixtureDetails',
|
|
976
|
+
// },
|
|
977
|
+
// },
|
|
978
|
+
// {
|
|
979
|
+
// $set: {
|
|
980
|
+
// planoId: {
|
|
981
|
+
// $setUnion: [
|
|
982
|
+
// { $map: { input: '$storeFixtureDetails', as: 'sf', in: '$$sf.planoId' } },
|
|
983
|
+
// [],
|
|
984
|
+
// ],
|
|
985
|
+
// },
|
|
986
|
+
// templateCount: { $size: '$templateId' },
|
|
987
|
+
// },
|
|
988
|
+
// },
|
|
989
|
+
// {
|
|
990
|
+
// $lookup: {
|
|
991
|
+
// from: 'planograms',
|
|
992
|
+
// let: { planoIds: '$planoId' },
|
|
993
|
+
// pipeline: [
|
|
994
|
+
// {
|
|
995
|
+
// $match: {
|
|
996
|
+
// $expr: {
|
|
997
|
+
// $in: [ '$_id', { $ifNull: [ '$$planoIds', [] ] } ],
|
|
998
|
+
// },
|
|
999
|
+
// },
|
|
1000
|
+
// },
|
|
1001
|
+
// {
|
|
1002
|
+
// $group: {
|
|
1003
|
+
// _id: null,
|
|
1004
|
+
// statusList: { $push: '$status' },
|
|
1005
|
+
// },
|
|
1006
|
+
// },
|
|
1007
|
+
// ],
|
|
1008
|
+
// as: 'planoStatus',
|
|
1009
|
+
// },
|
|
1010
|
+
// },
|
|
1011
1011
|
{
|
|
1012
1012
|
$project: {
|
|
1013
1013
|
vmName: 1,
|
|
@@ -1020,29 +1020,31 @@ export async function getVmLibList( req, res ) {
|
|
|
1020
1020
|
vmWidth: 1,
|
|
1021
1021
|
vmImageUrl: 1,
|
|
1022
1022
|
isDoubleSided: 1,
|
|
1023
|
-
templateId: 1,
|
|
1024
|
-
planoId: 1,
|
|
1025
1023
|
vmLibCode: 1,
|
|
1026
1024
|
vmSubCategory: 1,
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1025
|
+
// templateId: 1,
|
|
1026
|
+
// planoId: 1,
|
|
1027
|
+
// vmLibCode: 1,
|
|
1028
|
+
// vmSubCategory: 1,
|
|
1029
|
+
// planoStatus: { $ifNull: [ { $arrayElemAt: [ '$planoStatus.statusList', 0 ] }, [] ] },
|
|
1030
|
+
// templateCount: 1,
|
|
1031
|
+
// status: {
|
|
1032
|
+
// $cond: {
|
|
1033
|
+
// if: { $and: [ { $in: [ 'completed', { $ifNull: [ { $arrayElemAt: [ '$planoStatus.statusList', 0 ] }, [] ] } ] }, { $gt: [ { $size: '$templateId' }, 0 ] } ] },
|
|
1034
|
+
// then: 'active',
|
|
1035
|
+
// else: {
|
|
1036
|
+
// $cond: {
|
|
1037
|
+
// if: {
|
|
1038
|
+
// $eq: [
|
|
1039
|
+
// '$status', 'draft',
|
|
1040
|
+
// ],
|
|
1041
|
+
// },
|
|
1042
|
+
// then: 'draft',
|
|
1043
|
+
// else: 'inactive',
|
|
1044
|
+
// },
|
|
1045
|
+
// },
|
|
1046
|
+
// },
|
|
1047
|
+
// },
|
|
1046
1048
|
},
|
|
1047
1049
|
},
|
|
1048
1050
|
];
|
|
@@ -1081,6 +1083,21 @@ export async function getVmLibList( req, res ) {
|
|
|
1081
1083
|
if ( !req.body.export && !fixtureDetails[0]?.fixtureData.length ) {
|
|
1082
1084
|
return res.sendError( 'No data found', 204 );
|
|
1083
1085
|
}
|
|
1086
|
+
fixtureDetails[0].fixtureData = await Promise.all( fixtureDetails[0].fixtureData.map( async ( vm ) => {
|
|
1087
|
+
let getMappedTemplates = await fixtureTemplateService.find( { 'vmConfig.vmId': vm._id } );
|
|
1088
|
+
let getMapppedFixtureDetails = await storeFixtureService.find( { fixtureConfigId: { $in: getMappedTemplates.map( ( temp ) => temp._id ) } } );
|
|
1089
|
+
|
|
1090
|
+
let data = {
|
|
1091
|
+
|
|
1092
|
+
templateId: getMappedTemplates.map( ( temp ) => ele?._id ),
|
|
1093
|
+
planoId: getMapppedFixtureDetails.map( ( plano ) => plano.planoId ),
|
|
1094
|
+
planoStatus: 'incomplete',
|
|
1095
|
+
status: 'inactive',
|
|
1096
|
+
|
|
1097
|
+
};
|
|
1098
|
+
|
|
1099
|
+
return { ...vm, ...data };
|
|
1100
|
+
} ) );
|
|
1084
1101
|
let result = {
|
|
1085
1102
|
count: fixtureDetails[0].count[0].total,
|
|
1086
1103
|
data: fixtureDetails[0].fixtureData,
|
|
@@ -15508,7 +15508,7 @@ export async function insertAntennaMappingData( req, res ) {
|
|
|
15508
15508
|
"shelfConfig": [
|
|
15509
15509
|
{ "shelfNumber": 1, "antennaNo": [ 10 ] },
|
|
15510
15510
|
{ "shelfNumber": 2, "antennaNo": [ 11 ] },
|
|
15511
|
-
{ "shelfNumber": 3, "antennaNo": [
|
|
15511
|
+
{ "shelfNumber": 3, "antennaNo": [ 22, 23 ] },
|
|
15512
15512
|
{ "shelfNumber": 4, "antennaNo": [ 20, 21 ] },
|
|
15513
15513
|
{ "shelfNumber": 5, "antennaNo": [ 18, 19 ] },
|
|
15514
15514
|
{ "shelfNumber": 6, "antennaNo": [ 25, 30 ] },
|
|
@@ -15521,7 +15521,7 @@ export async function insertAntennaMappingData( req, res ) {
|
|
|
15521
15521
|
"shelfConfig": [
|
|
15522
15522
|
{ "shelfNumber": 1, "antennaNo": [ 24 ] },
|
|
15523
15523
|
{ "shelfNumber": 2, "antennaNo": [ 17 ] },
|
|
15524
|
-
{ "shelfNumber": 3, "antennaNo": [
|
|
15524
|
+
{ "shelfNumber": 3, "antennaNo": [ 9, 16 ] },
|
|
15525
15525
|
{ "shelfNumber": 4, "antennaNo": [ 12, 13 ] },
|
|
15526
15526
|
{ "shelfNumber": 5, "antennaNo": [ 14, 15 ] },
|
|
15527
15527
|
{ "shelfNumber": 6, "antennaNo": [ 1, 4 ] },
|
|
@@ -15612,8 +15612,8 @@ export async function insertAntennaMappingData( req, res ) {
|
|
|
15612
15612
|
{ "shelfNumber": 3, "antennaNo": [ 10 ] },
|
|
15613
15613
|
{ "shelfNumber": 4, "antennaNo": [ 8 ] },
|
|
15614
15614
|
{ "shelfNumber": 5, "antennaNo": [ 12 ] },
|
|
15615
|
-
{ "shelfNumber": 6, "antennaNo": [
|
|
15616
|
-
{ "shelfNumber": 7, "antennaNo": [
|
|
15615
|
+
{ "shelfNumber": 6, "antennaNo": [ 4 ] },
|
|
15616
|
+
{ "shelfNumber": 7, "antennaNo": [ 9 ] },
|
|
15617
15617
|
{ "shelfNumber": 8, "antennaNo": [ 3 ] },
|
|
15618
15618
|
],
|
|
15619
15619
|
},
|
|
@@ -15779,11 +15779,14 @@ export async function insertAntennaMappingData( req, res ) {
|
|
|
15779
15779
|
shelfNumber: shelfNumber,
|
|
15780
15780
|
} );
|
|
15781
15781
|
|
|
15782
|
+
console.log( shelf );
|
|
15783
|
+
|
|
15782
15784
|
if ( shelf ) {
|
|
15783
|
-
await fixtureShelfService.updateOne(
|
|
15785
|
+
let data = await fixtureShelfService.updateOne(
|
|
15784
15786
|
{ _id: shelf._id },
|
|
15785
15787
|
{ antennaNo: antennaNo },
|
|
15786
15788
|
);
|
|
15789
|
+
console.log( data );
|
|
15787
15790
|
console.log( `Updated fixture ${fixtureNumber}, shelf ${shelfNumber} with antennaNo:`, antennaNo );
|
|
15788
15791
|
} else {
|
|
15789
15792
|
const errorMsg = `Shelf not found for fixture ${fixtureNumber}, shelfNumber: ${shelfNumber}`;
|
|
@@ -15865,3 +15868,69 @@ export async function get4487FixtureDetails( req, res ) {
|
|
|
15865
15868
|
return res.sendError( e, 500 );
|
|
15866
15869
|
}
|
|
15867
15870
|
}
|
|
15871
|
+
|
|
15872
|
+
export async function getstoreMBQFixtureExcel( req, res ) {
|
|
15873
|
+
try {
|
|
15874
|
+
if ( !req.body?.storeName ) {
|
|
15875
|
+
return res.sendError( 'storeName is required', 400 );
|
|
15876
|
+
}
|
|
15877
|
+
let getStoreDetails = await storeService.find( { storeName: { $in: req.body.storeName }, status: 'active', clientId: '11' }, { storeProfile: 1, storeName: 1 } );
|
|
15878
|
+
if ( !getStoreDetails.length ) {
|
|
15879
|
+
return res.sendError( 'No data found', 204 );
|
|
15880
|
+
}
|
|
15881
|
+
let data = [];
|
|
15882
|
+
let sortOrder = [ 5, 1, 2, 3, 4 ];
|
|
15883
|
+
await Promise.all( getStoreDetails.map( async ( store ) => {
|
|
15884
|
+
let storeFixturesList = await storeFixtureService.findAndSort( { storeName: store.storeName }, {}, { fixtureNumber: 1, associatedElementNumber: 1, associatedElementFixtureNumber: 1 } );
|
|
15885
|
+
storeFixturesList.sort( ( a, b ) => {
|
|
15886
|
+
const floorDiff = b.floorId.toString().localeCompare( a.floorId.toString() );
|
|
15887
|
+
if ( floorDiff !== 0 ) return floorDiff;
|
|
15888
|
+
|
|
15889
|
+
if ( a.fixtureType !== b.fixtureType ) {
|
|
15890
|
+
return a.fixtureType === "wall" ? -1 : 1;
|
|
15891
|
+
}
|
|
15892
|
+
|
|
15893
|
+
if ( a.fixtureType === "wall" ) {
|
|
15894
|
+
const orderDiff =
|
|
15895
|
+
sortOrder.indexOf( a.associatedElementNumber ) -
|
|
15896
|
+
sortOrder.indexOf( b.associatedElementNumber );
|
|
15897
|
+
|
|
15898
|
+
if ( orderDiff !== 0 ) return orderDiff;
|
|
15899
|
+
|
|
15900
|
+
return (
|
|
15901
|
+
( a.associatedElementFixtureNumber || 0 ) -
|
|
15902
|
+
( b.associatedElementFixtureNumber || 0 )
|
|
15903
|
+
);
|
|
15904
|
+
}
|
|
15905
|
+
|
|
15906
|
+
return 0;
|
|
15907
|
+
} );
|
|
15908
|
+
|
|
15909
|
+
|
|
15910
|
+
let storeFixtureDetails = [];
|
|
15911
|
+
for ( let ele of storeFixturesList ) {
|
|
15912
|
+
let shelfDetails = await fixtureShelfService.findAndSort( { fixtureId: ele._id }, {}, { shelfNumber: 1 } );
|
|
15913
|
+
|
|
15914
|
+
storeFixtureDetails.push( {
|
|
15915
|
+
"Store Code": ele.storeName,
|
|
15916
|
+
"Wall": ele?.associatedElementNumber ?? 'floor',
|
|
15917
|
+
"Unique Fixture Number": 'FX - ' + ele.fixtureNumber,
|
|
15918
|
+
"Brand-Category": ele.header?.label,
|
|
15919
|
+
"Fixture Type": ele.fixtureCategory,
|
|
15920
|
+
"Fixture Size": ele.fixtureWidth.value +' '+ ele.fixtureWidth.unit,
|
|
15921
|
+
"Shelves/ Rods/ Space per Fixture": shelfDetails.length,
|
|
15922
|
+
'Display per Shelf/ Rod/ Space': shelfDetails?.[0]?.productPerShelf,
|
|
15923
|
+
'Fixture Capacity': ele?.fixtureCapacity,
|
|
15924
|
+
},
|
|
15925
|
+
);
|
|
15926
|
+
}
|
|
15927
|
+
data.push( ...storeFixtureDetails );
|
|
15928
|
+
} ) );
|
|
15929
|
+
// for ( let store of getStoreDetails ) {
|
|
15930
|
+
// }
|
|
15931
|
+
await download( data, res );
|
|
15932
|
+
} catch ( e ) {
|
|
15933
|
+
console.log( e );
|
|
15934
|
+
return res.sendError( e, 500 );
|
|
15935
|
+
}
|
|
15936
|
+
}
|
|
@@ -27,8 +27,8 @@ import * as fixtureConfigDuplicateService from '../service/fixtureConfigDuplicat
|
|
|
27
27
|
import * as planoVmDuplicateService from '../service/planoVmDuplicate.service.js';
|
|
28
28
|
import advancedFormat from 'dayjs/plugin/advancedFormat.js';
|
|
29
29
|
import * as planoRevisionService from '../service/planoRevision.service.js';
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
import xlsx from 'xlsx';
|
|
31
|
+
import fs from 'fs';
|
|
32
32
|
|
|
33
33
|
dayjs.extend( advancedFormat );
|
|
34
34
|
dayjs.extend( utc );
|
|
@@ -8042,10 +8042,6 @@ export async function updateProductMapping( req, res ) {
|
|
|
8042
8042
|
let excelData = [];
|
|
8043
8043
|
for ( let macDetails of response?.mac_details ) {
|
|
8044
8044
|
let fixtureDetails = await storeFixtureService.find( { readerId: macDetails?.MAC } );
|
|
8045
|
-
console.log( macDetails?.MAC );
|
|
8046
|
-
if ( macDetails?.MAC == 'A4-E8-A3-91-7E-FD' ) {
|
|
8047
|
-
console.log( fixtureDetails );
|
|
8048
|
-
}
|
|
8049
8045
|
if ( fixtureDetails.length ) {
|
|
8050
8046
|
let data = macDetails?.body ?? [];
|
|
8051
8047
|
await Promise.all( data.map( async ( ele ) => {
|
|
@@ -8061,6 +8057,9 @@ export async function updateProductMapping( req, res ) {
|
|
|
8061
8057
|
} else {
|
|
8062
8058
|
fixtureShelfDetails = fixtureDetails.find( ( fixt ) => fixt._id.toString() == getShelfDetails.fixtureId.toString() );
|
|
8063
8059
|
}
|
|
8060
|
+
if ( macDetails?.MAC == 'A4-E8-A3-91-7F-05' ) {
|
|
8061
|
+
console.log( ele?.data?.antenna, fixtureShelfDetails?._id );
|
|
8062
|
+
}
|
|
8064
8063
|
logger.error( { data: fixtureShelfDetails, antennaNo: ele.data.antenna, macId: ele?.data?.MAC } );
|
|
8065
8064
|
if ( getShelfDetails && fixtureShelfDetails ) {
|
|
8066
8065
|
let productDetails = await planoProductService.findOne( { productId: ele.data.idText } );
|
|
@@ -8146,6 +8145,7 @@ export async function updateProductMapping( req, res ) {
|
|
|
8146
8145
|
|
|
8147
8146
|
export async function calculateCompliance( req, res ) {
|
|
8148
8147
|
try {
|
|
8148
|
+
let clFixtures = await storeFixtureService.findOne( { 'header.label': 'CL' }, { _id: 1 } );
|
|
8149
8149
|
let query = [
|
|
8150
8150
|
{
|
|
8151
8151
|
$match: {
|
|
@@ -8154,6 +8154,7 @@ export async function calculateCompliance( req, res ) {
|
|
|
8154
8154
|
storeName: req.body.storeName,
|
|
8155
8155
|
compliance: 'proper',
|
|
8156
8156
|
date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
8157
|
+
fixtureId: { $ne: clFixtures._id },
|
|
8157
8158
|
},
|
|
8158
8159
|
},
|
|
8159
8160
|
{
|
|
@@ -51,4 +51,5 @@ scriptRouter
|
|
|
51
51
|
.post( '/getFixtureDetails', isAllowedInternalAPIHandler, scriptController.getFixtureDetails )
|
|
52
52
|
.post( '/update4487Inventory', scriptController.update4487Inventory )
|
|
53
53
|
.get( '/4487FixtureDetails', scriptController.get4487FixtureDetails )
|
|
54
|
+
.post( '/getstoreMBQFixtureExcel', scriptController.getstoreMBQFixtureExcel )
|
|
54
55
|
;
|