tango-app-api-store-builder 1.0.30 → 1.0.31

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,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-store-builder",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -9573,8 +9573,8 @@ export async function productMappings( req, res ) {
9573
9573
 
9574
9574
  const { fixtureId, Top, Mid, Bottom } = payload;
9575
9575
 
9576
- const storeName = 'LKST2681';
9577
- const storeId = '11-2362';
9576
+ const storeName = 'LKST11';
9577
+ const storeId = '11-259';
9578
9578
  const clientId = '11';
9579
9579
 
9580
9580
  if ( !fixtureId ) {
@@ -5154,8 +5154,8 @@ export async function planoList( req, res ) {
5154
5154
  clientId: inputData.clientId,
5155
5155
  status: 'active',
5156
5156
  ...( inputData?.stores?.length && { storeId: { $in: inputData.stores } } ),
5157
- ...( req.body.filter?.country?.length && { 'storeProfile.country': { $in: req.body.filter.country } } ),
5158
- ...( req.body.filter?.city?.length && { 'storeProfile.city': { $in: req.body.filter.city } } ),
5157
+ ...( req.body.filter.country.length && { 'storeProfile.country': { $in: req.body.filter.country } } ),
5158
+ ...( req.body.filter.city.length && { 'storeProfile.city': { $in: req.body.filter.city } } ),
5159
5159
  ...( req.body?.assignedStores?.length && { storeId: { $in: req.body?.assignedStores } } ) }, { storeId: 1, storeProfile: 1 } );
5160
5160
 
5161
5161
  let storeDetails = storeList.map( ( ele ) => ele.storeId );
@@ -6095,16 +6095,9 @@ export async function planoList( req, res ) {
6095
6095
  if ( req.body.export ) {
6096
6096
  let exportData = [];
6097
6097
  planoDetails[0].data.forEach( ( ele ) => {
6098
- let findStore = storeList.find( ( store ) => ele.storeId == store.storeId );
6099
- if ( findStore ) {
6100
- ele['country'] = findStore.storeProfile.country;
6101
- ele['city'] = findStore.storeProfile.city;
6102
- }
6103
6098
  exportData.push( {
6104
6099
  'Store Name': ele?.storeName ?? '--',
6105
6100
  'Layout Name': ele?.layoutName ?? '--',
6106
- 'Country': ele?.country ?? '--',
6107
- 'City': ele?.City ?? '--',
6108
6101
  'Plano Completion %': ele?.taskDetails.layoutStatus == 'complete' && ele?.taskDetails.fixtureStatus == 'complete' ? 100 : ele?.taskDetails.layoutStatus == 'complete' ? 50 : 25,
6109
6102
  'Layout': ele?.layoutCount ?? 0,
6110
6103
  'Layout Status': ele?.taskDetails.layoutStatus == 'complete' ? 'Completed' : 'Yet to assign',
@@ -6813,8 +6806,8 @@ export async function getRolloutDetails( req, res ) {
6813
6806
  clientId: req.body.clientId,
6814
6807
  status: 'active',
6815
6808
  ...( req.body?.stores?.length && { storeId: { $in: req.body.stores } } ),
6816
- ...( req.body.filter?.country?.length && { 'storeProfile.country': { $in: req.body.filter.country } } ),
6817
- ...( req.body.filter?.city?.length && { 'storeProfile.city': { $in: req.body.filter.city } } ),
6809
+ ...( req.body.filter.country.length && { 'storeProfile.country': { $in: req.body.filter.country } } ),
6810
+ ...( req.body.filter.city.length && { 'storeProfile.city': { $in: req.body.filter.city } } ),
6818
6811
  ...( req.body?.assignedStores?.length && { storeId: { $in: req.body?.assignedStores } } ) }, { storeId: 1, storeProfile: 1 } );
6819
6812
 
6820
6813
  let storeDetails = storeList.map( ( ele ) => ele.storeId );
@@ -7673,8 +7666,6 @@ export async function getRolloutDetails( req, res ) {
7673
7666
  exportData.push( {
7674
7667
  'Store Name': ele?.storeName ?? '--',
7675
7668
  'Plano Name': ele?.layoutName ?? '--',
7676
- 'Country': ele?.country ?? '--',
7677
- 'city': ele?.city ?? '--',
7678
7669
  'Merch Fixtures': ele?.fixtureCount ?? 0,
7679
7670
  'Merch Status': ele?.taskDetails.fixtureStatus == 'complete' ? 'Completed' : ele?.taskDetails.fixtureStatus == 'pending' ? 'Review Pending' : 'Yet to Assign',
7680
7671
  'Visual Merch': ele?.vmCount ?? 0,
@@ -8697,368 +8688,3 @@ export async function getPlanogramList( req, res ) {
8697
8688
  return res.sendError( err, 500 );
8698
8689
  }
8699
8690
  }
8700
-
8701
-
8702
- export async function revisionData( req, res ) {
8703
- try {
8704
- let storeList = req.body.store;
8705
- await Promise.all( storeList.map( async ( ele ) => {
8706
- console.log( ele );
8707
- req.body = { id: [ ele ] };
8708
- await convertFixtureStructure( req, res );
8709
- } ) );
8710
- return res.sendSuccess( 'Updated Successfully' );
8711
- } catch ( e ) {
8712
- logger.error( { functionName: 'revisionData', error: e } );
8713
- return res.sendError( e, 500 );
8714
- }
8715
- }
8716
-
8717
- async function convertFixtureStructure( req ) {
8718
- try {
8719
- const planoIds = req.body.id
8720
- .filter( ( id ) => mongoose.Types.ObjectId.isValid( id ) )
8721
- .map( ( id ) => new mongoose.Types.ObjectId( id ) );
8722
-
8723
- const planograms = await planoService.find(
8724
- {
8725
- $or: [
8726
- { _id: { $in: planoIds } },
8727
- { storeId: { $in: req.body.id } },
8728
- ],
8729
- },
8730
- { storeId: 1, storeName: 1, planoId: '$_id', productResolutionLevel: 1, scanType: 1, clientId: 1, validateShelfSections: 1, layoutName: 1 },
8731
- );
8732
-
8733
- if ( !planograms?.length ) return false;
8734
-
8735
- const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
8736
-
8737
- await Promise.all(
8738
- planograms.map( async ( planogram ) => {
8739
- const floors = await storeBuilderService.find(
8740
- { planoId: planogram._id, ...( req.body?.floorId && { _id: req.body.floorId } ) },
8741
- { floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress: 1, updatedAt: 1, verificationStatus: 1, merchRolloutStatus: 1, vmRolloutStatus: 1 },
8742
- );
8743
-
8744
- await Promise.all(
8745
- floors.map( async ( floor, index ) => {
8746
- let fixtureCount = 0;
8747
- let totalVmCount = 0;
8748
- let productCapacity = 0;
8749
- const masterTemplateIds = new Set();
8750
- const layoutPolygonWithFixtures = await Promise.all(
8751
- floor.layoutPolygon.map( async ( element ) => {
8752
- const fixtures = await storeFixtureService.findAndSort( {
8753
- floorId: floor._id,
8754
- associatedElementType: element.elementType,
8755
- associatedElementNumber: element.elementNumber,
8756
- fixtureType: { $ne: 'other' },
8757
- }, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
8758
-
8759
- const fixturesWithStatus = await Promise.all(
8760
- fixtures.map( async ( fixture ) => {
8761
- if ( fixture?.masterTemplateId && mongoose.Types.ObjectId.isValid( fixture?.masterTemplateId ) ) {
8762
- masterTemplateIds.add( fixture?.masterTemplateId );
8763
- }
8764
- if ( fixture?.imageUrl ) {
8765
- let params = {
8766
- Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
8767
- file_path: fixture.imageUrl,
8768
- };
8769
- fixture.imageUrl = await signedUrl( params );
8770
- } else {
8771
- fixture.imageUrl = '';
8772
- }
8773
- productCapacity += fixture.toObject().fixtureCapacity;
8774
- fixtureCount += 1;
8775
- const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
8776
-
8777
- const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
8778
-
8779
- const complianceCount = await planoComplianceService.count( {
8780
- fixtureId: fixture._id,
8781
- compliance: 'proper',
8782
- date: currentDate,
8783
- } );
8784
-
8785
- const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
8786
-
8787
- const shelfDetails = await Promise.all(
8788
- shelves.map( async ( shelf ) => {
8789
- const productDetails = await planoMappingService.find( { fixtureId: fixture._id, shelfId: shelf._id, type: 'product' }, { _id: 1 } );
8790
- let productIdList = productDetails.map( ( ele ) => ele._id );
8791
- let complianceQuery = [
8792
- {
8793
- $match: {
8794
- fixtureId: fixture._id,
8795
- shelfId: shelf._id,
8796
- date: currentDate,
8797
- planoMappingId: { $in: productIdList },
8798
- },
8799
- },
8800
- {
8801
- $group: {
8802
- _id: '$createdAt',
8803
- status: { $push: '$compliance' },
8804
- },
8805
- },
8806
- {
8807
- $sort: { _id: -1 },
8808
- },
8809
- {
8810
- $limit: 1,
8811
- },
8812
- ];
8813
- let complianceStatus = await planoComplianceService.aggregate( complianceQuery );
8814
- const compliance = complianceStatus?.[0]?.status?.length ? ( ( complianceStatus?.[0]?.status?.length != shelf.productPerShelf ) || complianceStatus?.[0]?.status.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
8815
-
8816
- const vmCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf._id, type: 'vm' } );
8817
-
8818
- return {
8819
- ...shelf.toObject(),
8820
- productCount: productDetails.length,
8821
- vmCount: vmCount,
8822
- compliance,
8823
- };
8824
- } ),
8825
- );
8826
-
8827
- let fixtureStatus;
8828
-
8829
- const cvProcessStatus = await planoQrConversionRequestService.count( { fixtureId: fixture._id, date: currentDate, status: 'initiated' } );
8830
-
8831
- if ( cvProcessStatus ) {
8832
- fixtureStatus = 'inprogress';
8833
- } else {
8834
- const missingCount = await planoComplianceService.count( {
8835
- fixtureId: fixture._id,
8836
- compliance: 'missing',
8837
- date: currentDate,
8838
- } );
8839
- fixtureStatus = complianceCount === 0 && !missingCount ? '' : complianceCount === productCount ? 'complete' : 'incomplete';
8840
- }
8841
-
8842
-
8843
- const vmDetails = await Promise.all( fixture.toObject()?.vmConfig?.map( async ( vm ) => {
8844
- totalVmCount += 1;
8845
- const vmInfo = await planoVmService.findOne( { _id: vm.vmId } );
8846
- return {
8847
- ...vm,
8848
- ...vmInfo?.toObject(),
8849
- };
8850
- } ) );
8851
-
8852
- return {
8853
- ...fixture.toObject(),
8854
- status: fixtureStatus,
8855
- shelfCount: shelves.length,
8856
- productCount: productCount,
8857
- vmCount: vmCount,
8858
- shelfConfig: shelfDetails,
8859
- vmConfig: vmDetails,
8860
- };
8861
- } ),
8862
- );
8863
-
8864
- const otherElements = await storeFixtureService.find( {
8865
- floorId: floor._id,
8866
- associatedElementType: element.elementType,
8867
- associatedElementNumber: element.elementNumber,
8868
- fixtureType: 'other',
8869
- } );
8870
-
8871
- return {
8872
- ...element,
8873
- fixtures: fixturesWithStatus,
8874
- otherElements: otherElements,
8875
- };
8876
- } ),
8877
- );
8878
-
8879
- const centerFixtures = await storeFixtureService.findAndSort( {
8880
- floorId: floor._id,
8881
- $and: [
8882
- { associatedElementType: { $exists: false } },
8883
- { associatedElementNumber: { $exists: false } },
8884
- { fixtureType: { $ne: 'other' } },
8885
- ],
8886
- }, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
8887
-
8888
-
8889
- const centerFixturesWithStatus = await Promise.all(
8890
- centerFixtures.map( async ( fixture ) => {
8891
- if ( fixture?.masterTemplateId && mongoose.Types.ObjectId.isValid( fixture?.masterTemplateId ) ) {
8892
- masterTemplateIds.add( fixture?.masterTemplateId );
8893
- }
8894
- if ( fixture?.imageUrl ) {
8895
- let params = {
8896
- Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
8897
- file_path: fixture.imageUrl,
8898
- };
8899
- fixture.imageUrl = await signedUrl( params );
8900
- } else {
8901
- fixture.imageUrl = '';
8902
- }
8903
- productCapacity += fixture.toObject().fixtureCapacity;
8904
- fixtureCount += 1;
8905
- const productCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'product' } );
8906
-
8907
- const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
8908
-
8909
- const complianceCount = await planoComplianceService.count( {
8910
- fixtureId: fixture._id,
8911
- compliance: 'proper',
8912
- date: currentDate,
8913
- } );
8914
-
8915
- const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
8916
-
8917
- const shelfDetails = await Promise.all(
8918
- shelves.map( async ( shelf ) => {
8919
- const productDetails = await planoMappingService.find( { fixtureId: fixture._id, shelfId: shelf._id, type: 'product' }, { _id: 1 } );
8920
- let productIdList = productDetails.map( ( ele ) => ele._id );
8921
- let complianceQuery = [
8922
- {
8923
- $match: {
8924
- fixtureId: fixture._id,
8925
- shelfId: shelf._id,
8926
- date: currentDate,
8927
- planoMappingId: { $in: productIdList },
8928
- },
8929
- },
8930
- {
8931
- $group: {
8932
- _id: '$createdAt',
8933
- status: { $push: '$compliance' },
8934
- },
8935
- },
8936
- {
8937
- $sort: { _id: -1 },
8938
- },
8939
- {
8940
- $limit: 1,
8941
- },
8942
- ];
8943
- let complianceStatus = await planoComplianceService.aggregate( complianceQuery );
8944
- const compliance = complianceStatus?.[0]?.status.length ? ( ( complianceStatus?.[0]?.status?.length != shelf.productPerShelf ) || complianceStatus?.[0]?.status?.includes( 'misplaced' ) ) ? 'improper' : 'proper' : 'improper';
8945
-
8946
-
8947
- const vmCount = await planoMappingService.count( { fixtureId: fixture._id, shelfId: shelf._id, type: 'vm' } );
8948
-
8949
- return {
8950
- ...shelf.toObject(),
8951
- productCount: productDetails.length,
8952
- vmCount: vmCount,
8953
- compliance,
8954
- };
8955
- } ),
8956
- );
8957
-
8958
- let fixtureStatus;
8959
-
8960
- const cvProcessStatus = await planoQrConversionRequestService.count( { fixtureId: fixture._id, date: currentDate, status: 'initiated' } );
8961
-
8962
- if ( cvProcessStatus ) {
8963
- fixtureStatus = 'inprogress';
8964
- } else {
8965
- const missingCount = await planoComplianceService.count( {
8966
- fixtureId: fixture._id,
8967
- compliance: 'missing',
8968
- date: currentDate,
8969
- } );
8970
- fixtureStatus = complianceCount === 0 && !missingCount ? '' : complianceCount === productCount ? 'complete' : 'incomplete';
8971
- }
8972
-
8973
-
8974
- const vmDetails = await Promise.all( fixture.toObject().vmConfig.map( async ( vm ) => {
8975
- totalVmCount += 1;
8976
- const vmInfo = await planoVmService.findOne( { _id: vm.vmId } );
8977
-
8978
- return {
8979
- ...vm,
8980
- ...vmInfo?.toObject(),
8981
- };
8982
- } ) );
8983
-
8984
- return {
8985
- ...fixture.toObject(),
8986
- status: fixtureStatus,
8987
- shelfCount: shelves.length,
8988
- productCount: productCount,
8989
- vmCount: vmCount,
8990
- shelfConfig: shelfDetails,
8991
- vmConfig: vmDetails,
8992
- };
8993
- } ),
8994
- );
8995
-
8996
-
8997
- const otherElements = await storeFixtureService.find( {
8998
- floorId: floor._id,
8999
- associatedElementType: { $exists: false },
9000
- associatedElementNumber: { $exists: false },
9001
- fixtureType: 'other',
9002
- } );
9003
-
9004
-
9005
- let masterTempArr = [ ...masterTemplateIds ];
9006
-
9007
-
9008
- if ( masterTempArr?.length && req.body?.treeView ) {
9009
- masterTempArr = await fixtureConfigService.find( { _id: { $in: [ ...masterTemplateIds ] } } );
9010
- }
9011
-
9012
- let floorData = {
9013
- ...floor.toObject(),
9014
- updatedAt: dayjs( floor?.updatedAt ).format( 'Do MMM YYYY' ),
9015
- fixtureCount: fixtureCount,
9016
- vmCount: totalVmCount,
9017
- layoutPolygon: layoutPolygonWithFixtures,
9018
- centerFixture: centerFixturesWithStatus,
9019
- otherElements: otherElements,
9020
- lastUpdate: dayjs( floor?.updatedAt ).format( 'Do MMMM YYYY hh:mm A' ),
9021
- ...( floors.length > 1 ) ? { floorNum: `Floor ${index + 1}/${floors.length}` } : { floorNum: 'Floor 1' },
9022
- };
9023
-
9024
- let planoProductCount = 0;
9025
- layoutPolygonWithFixtures.forEach( ( poly ) => {
9026
- poly.fixtures.forEach( ( fixt ) => {
9027
- planoProductCount += fixt.fixtureCapacity;
9028
- } );
9029
- } );
9030
-
9031
- centerFixturesWithStatus.forEach( ( fixt ) => {
9032
- planoProductCount += fixt.fixtureCapacity;
9033
- } );
9034
-
9035
- floorData = { ...floorData, planoProductCount };
9036
-
9037
- const data = {
9038
- storeName: planogram.storeName,
9039
- storeId: planogram.storeId,
9040
- clientId: planogram.clientId,
9041
- planoId: planogram._id,
9042
- productResolutionLevel: planogram.productResolutionLevel,
9043
- scanType: planogram.scanType,
9044
- createdByName: 'Bejan',
9045
- createdByEmail: 'Bejan@tangotech.co.in',
9046
- createdBy: new mongoose.Types.ObjectId( '66a78cd82734f4f857cd6db6' ),
9047
- layoutName: planogram.layoutName,
9048
- floorId: floorData._id,
9049
- floorData: floorData,
9050
- };
9051
-
9052
- console.log( data, 'data' );
9053
-
9054
- await planoRevisionService.create( data );
9055
- } ),
9056
- );
9057
- } ),
9058
- );
9059
- } catch ( e ) {
9060
- console.log( e );
9061
- logger.error( { functionName: 'storeFixturesv2', error: e, message: req.body } );
9062
- return e;
9063
- }
9064
- }
@@ -61,13 +61,12 @@ storeBuilderRouter
61
61
  .post( '/planoList', isAllowedSessionHandler, getAssinedStore, storeBuilderController.planoList )
62
62
  .get( '/taskDetails', isAllowedSessionHandler, storeBuilderController.getTaskDetails )
63
63
  .get( '/getPlanoUser', isAllowedSessionHandler, storeBuilderController.getPlanoUser )
64
- .post( '/planoRolloutList', isAllowedSessionHandler, storeBuilderController.getRolloutDetails )
64
+ .post( '/planoRolloutList', isAllowedSessionHandler, getAssinedStore, storeBuilderController.getRolloutDetails )
65
65
  .get( '/getRolloutTaskDetails', isAllowedSessionHandler, storeBuilderController.getRolloutTaskDetails )
66
66
  .get( '/getScandid', storeBuilderController.getScandid )
67
67
  .get( '/getPlanoStoreList', isAllowedSessionHandler, getAssinedStore, storeBuilderController.getPlanoStoreList )
68
68
  .get( '/getFixtureAIDetails', isAllowedSessionHandler, storeBuilderController.getFixtureAIDetails )
69
69
  .post( '/updateProductMapping', storeBuilderController.updateProductMapping )
70
70
  .post( '/calculateCompliance', isAllowedSessionHandler, storeBuilderController.calculateCompliance )
71
- .post( '/getPlanogramList', isAllowedSessionHandler, storeBuilderController.getPlanogramList )
72
- .post( '/revisionUpdate', storeBuilderController.revisionData )
71
+ .post( '/getPlanogramList', isAllowedSessionHandler, getAssinedStore, storeBuilderController.getPlanogramList )
73
72
  ;