tango-app-api-store-builder 1.0.0-beta-225 → 1.0.0-beta-227

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-store-builder",
3
- "version": "1.0.0-beta-225",
3
+ "version": "1.0.0-beta-227",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -88,10 +88,10 @@ export async function getplanoFeedback( req, res ) {
88
88
  };
89
89
 
90
90
  response.fixtureData = await Promise.all( response.fixtureData.map( async ( ele ) => {
91
- if ( ele?.FixtureData ) {
92
- if ( !ele?.FixtureData._id ) {
93
- return res.sendError( 'Fixture Id is required', 400 );
94
- }
91
+ if ( ele?.FixtureData && ele?.FixtureData?._id ) {
92
+ // if ( !ele?.FixtureData._id ) {
93
+ // return res.sendError( 'Fixture Id is required', 400 );
94
+ // }
95
95
  let query = {
96
96
  query: {
97
97
  bool: {
@@ -18,6 +18,8 @@ import * as planoComplianceService from '../service/planoCompliance.service.js';
18
18
  import * as planoProductCategoryService from '../service/planoproductCategory.service.js';
19
19
  import * as fixtureConfigService from '../service/fixtureConfig.service.js';
20
20
  import * as fixtureLibraryService from '../service/planoLibrary.service.js';
21
+ import * as userService from '../service/user.service.js';
22
+ import * as staticService from '../service/planoStaticData.service.js';
21
23
  import mongoose from 'mongoose';
22
24
  import JSZip from 'jszip';
23
25
  import { signedUrl } from 'tango-app-api-middleware';
@@ -14544,3 +14546,132 @@ async function updateStoreFixtureShelves() {
14544
14546
 
14545
14547
  // updateStoreFixtureShelves();
14546
14548
 
14549
+ export async function planoAccess( req, res ) {
14550
+ try {
14551
+ if ( !req.body?.email ) {
14552
+ return res.sendError( 'Email is required', 400 );
14553
+ }
14554
+ if ( !req.body.clientId ) {
14555
+ return res.sendError( 'clientId is required', 400 );
14556
+ }
14557
+ let userQuery = [
14558
+ {
14559
+ $addFields: {
14560
+ uEmail: { $toLower: '$email' },
14561
+ },
14562
+ },
14563
+ {
14564
+ $match: {
14565
+ uEmail: req.body?.email.toLowerCase(),
14566
+ },
14567
+ },
14568
+ ];
14569
+ let getusers = await userService.aggregate( userQuery );
14570
+ if ( !getusers ) {
14571
+ let userData = {
14572
+ clientId: req.body.clientId,
14573
+ mobileNumber: '',
14574
+ email: req.body?.email,
14575
+ userName: req.body?.email.split( '@' )[0],
14576
+ };
14577
+ await createUser( userData );
14578
+ }
14579
+
14580
+ await staticService.updateOne( { type: 'user' }, { $push: { data: req.body?.email } } );
14581
+ return res.sendSuccess( 'updated successfully' );
14582
+ } catch ( e ) {
14583
+ logger.error( { functionName: 'planoAccess', error: e } );
14584
+ return res.sendError( e, 500 );
14585
+ }
14586
+ }
14587
+
14588
+ async function createUser( data ) {
14589
+ try {
14590
+ let params = {
14591
+ userName: data.userName,
14592
+ email: data.email,
14593
+ mobileNumber: data?.mobileNumber || '',
14594
+ clientId: data.clientId,
14595
+ role: 'user',
14596
+ password: '5dqFKAJj29PsV6P+kL+3Dw==',
14597
+ isActive: true,
14598
+ userType: 'client',
14599
+ rolespermission: [
14600
+ {
14601
+ featureName: 'Global',
14602
+ modules: [
14603
+ {
14604
+ name: 'Store',
14605
+ isAdd: false,
14606
+ isEdit: false,
14607
+
14608
+ },
14609
+ {
14610
+ name: 'User',
14611
+ isAdd: false,
14612
+ isEdit: false,
14613
+
14614
+ },
14615
+ {
14616
+ name: 'Camera',
14617
+ isAdd: false,
14618
+ isEdit: false,
14619
+
14620
+ },
14621
+ {
14622
+ name: 'Configuration',
14623
+ isAdd: false,
14624
+ isEdit: false,
14625
+
14626
+ },
14627
+ {
14628
+ name: 'Subscription',
14629
+ isAdd: false,
14630
+ isEdit: false,
14631
+
14632
+ },
14633
+ {
14634
+ name: 'Billing',
14635
+ isAdd: false,
14636
+ isEdit: false,
14637
+
14638
+ },
14639
+ ],
14640
+ },
14641
+ {
14642
+ featurName: 'TangoEye',
14643
+ modules: [
14644
+ {
14645
+ name: 'ZoneTag',
14646
+ isAdd: false,
14647
+ isEdit: false,
14648
+
14649
+ },
14650
+ ],
14651
+ },
14652
+ {
14653
+ featurName: 'TangoTrax',
14654
+ modules: [
14655
+ {
14656
+ name: 'checklist',
14657
+ isAdd: false,
14658
+ isEdit: false,
14659
+
14660
+ },
14661
+ {
14662
+ name: 'Task',
14663
+ isAdd: false,
14664
+ isEdit: false,
14665
+
14666
+ },
14667
+ ],
14668
+ },
14669
+ ],
14670
+ };
14671
+ let response = await userService.create( params );
14672
+ return response;
14673
+ } catch ( e ) {
14674
+ logger.error( 'createUser =>', e );
14675
+ return false;
14676
+ }
14677
+ }
@@ -3335,6 +3335,11 @@ 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
+ let getImages = await planoTaskComplianceService.findOne( { fixtureId: fixtureId, type: 'fixture' } );
3339
+
3340
+ let fixtureImage = getImages?.answers?.[0]?.image ?? '';
3341
+
3342
+
3338
3343
  if ( req.body?.compliance ) {
3339
3344
  let getAllFixtures = await fixtureShelfService.find( { planoId: fixture.planoId, floorId: fixture.floorId, fixtureId: { $ne: fixtureId } } );
3340
3345
 
@@ -3425,7 +3430,7 @@ export async function fixtureShelfProductv2( req, res ) {
3425
3430
  );
3426
3431
 
3427
3432
  let storageProducts = await planoMappingService.find( { fixtureId: new mongoose.Types.ObjectId( fixtureId ), type: 'storageBox' } );
3428
- return res.sendSuccess( { ...fixture.toObject(), shelves: shelfProducts, vmConfig: vmDetails, productCount: productCount, storageProducts: storageProducts } );
3433
+ return res.sendSuccess( { ...fixture.toObject(), shelves: shelfProducts, vmConfig: vmDetails, productCount: productCount, storageProducts: storageProducts, fixtureImage: fixtureImage } );
3429
3434
  }
3430
3435
 
3431
3436
  return res.sendError( 'Incorrect resolution level', 400 );
@@ -7094,7 +7099,7 @@ export async function updateProductMapping( req, res ) {
7094
7099
  await planoMappingService.deleteMany( { storeId: store.storeId } );
7095
7100
  let mappingInsertData = await planoMappingService.insertMany( mappingData );
7096
7101
  mappingInsertData = new Map( mappingInsertData.map( ( ele, index ) => [ index, ele ] ) );
7097
- let date = new Date();
7102
+ let date = dayjs().format();
7098
7103
  complianceData.forEach( ( compliance, index ) => {
7099
7104
  compliance.planoMappingId = mappingInsertData.get( index );
7100
7105
  compliance.createdAt = date;
@@ -7120,11 +7125,9 @@ export async function calculateCompliance( req, res ) {
7120
7125
  floorId: new mongoose.Types.ObjectId( req.body.floorId ),
7121
7126
  storeName: req.body.storeName,
7122
7127
  compliance: 'proper',
7128
+ date: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
7123
7129
  },
7124
7130
  },
7125
- {
7126
- $sort: { createdAt: -1 },
7127
- },
7128
7131
  {
7129
7132
  $group: {
7130
7133
  _id: '$createdAt',
@@ -7138,6 +7141,9 @@ export async function calculateCompliance( req, res ) {
7138
7141
  count: 1,
7139
7142
  },
7140
7143
  },
7144
+ {
7145
+ $sort: { date: -1 },
7146
+ },
7141
7147
  {
7142
7148
  $limit: 2,
7143
7149
  },
@@ -7182,7 +7188,7 @@ export async function calculateCompliance( req, res ) {
7182
7188
  let diff = previousMerchCompliance - result.merchCompliance;
7183
7189
  result.previousMerchCompliance = diff;
7184
7190
  }
7185
- result.lastCheck = dayjs.utc( getCompliance?.[0]?.date ).format( 'hh:mm A' );
7191
+ result.lastCheck = dayjs( getCompliance?.[0]?.date ).format( 'hh:mm A' );
7186
7192
  }
7187
7193
  }
7188
7194
  return res.sendSuccess( result );
@@ -7207,7 +7213,83 @@ export async function getPlanogramList( req, res ) {
7207
7213
 
7208
7214
  const pipeline = [
7209
7215
  { $match: { clientId } },
7210
-
7216
+ {
7217
+ $lookup: {
7218
+ from: 'storefixtures',
7219
+ let: { plano: '$planoId', floor: '$_id' },
7220
+ pipeline: [
7221
+ {
7222
+ $match: {
7223
+ $expr: {
7224
+ $and: [
7225
+ { $eq: [
7226
+ '$planoId', '$$plano',
7227
+ ],
7228
+ },
7229
+ {
7230
+ $eq: [
7231
+ '$floorId', '$$floor',
7232
+ ],
7233
+ },
7234
+ ],
7235
+ },
7236
+ },
7237
+ },
7238
+ {
7239
+ $group: {
7240
+ _id: '$floorId',
7241
+ productCount: { $sum: '$fixtureCapacity' },
7242
+ },
7243
+ },
7244
+ ],
7245
+ as: 'fixtureDetails',
7246
+ },
7247
+ },
7248
+ {
7249
+ $lookup: {
7250
+ from: 'planocompliances',
7251
+ let: { plano: '$planoId', floor: '$_id' },
7252
+ pipeline: [
7253
+ {
7254
+ $match: {
7255
+ $expr: {
7256
+ $and: [
7257
+ {
7258
+ $eq: [ '$planoId', '$$plano' ],
7259
+ },
7260
+ {
7261
+ $eq: [ '$floorId', '$$floor' ],
7262
+ },
7263
+ {
7264
+ $eq: [ '$date', new Date( dayjs().format( 'YYYY-MM-DD' ) ) ],
7265
+ },
7266
+ ],
7267
+ },
7268
+ },
7269
+ },
7270
+ {
7271
+ $group: {
7272
+ _id: '$createdAt',
7273
+ count: { $sum: 1 },
7274
+ },
7275
+ },
7276
+ {
7277
+ $project: {
7278
+ _id: 0,
7279
+ date: '$_id',
7280
+ count: 1,
7281
+ },
7282
+ },
7283
+ {
7284
+ $sort: { date: -1 },
7285
+ },
7286
+ {
7287
+ $limit: 1,
7288
+ },
7289
+ ],
7290
+ as: 'complianceCount',
7291
+ },
7292
+ },
7211
7293
  {
7212
7294
  $project: {
7213
7295
  _id: 1,
@@ -7221,6 +7303,21 @@ export async function getPlanogramList( req, res ) {
7221
7303
  status: 1,
7222
7304
  storeId: 1,
7223
7305
  storeName: 1,
7306
+ fixtureDetails: 1,
7307
+ complianceCount: 1,
7308
+ merchCompliance: {
7309
+ $floor: {
7310
+ $multiply: [
7311
+ {
7312
+ $divide: [
7313
+ { $arrayElemAt: [ '$complianceCount.count', 0 ] },
7314
+ { $arrayElemAt: [ '$fixtureDetails.productCount', 0 ] },
7315
+ ],
7316
+ },
7317
+ 100,
7318
+ ],
7319
+ },
7320
+ },
7224
7321
  },
7225
7322
  },
7226
7323
  ];
@@ -14,6 +14,7 @@ const ObjectId = mongoose.Types.ObjectId;
14
14
  import * as floorService from '../service/storeBuilder.service.js';
15
15
  import * as planoStaticService from '../service/planoStaticData.service.js';
16
16
  import * as assignService from '../service/assignService.service.js';
17
+ import * as taskAssignService from '../service/assignService.service.js';
17
18
  import * as storeBuilderService from '../service/storeBuilder.service.js';
18
19
  import * as storeFixtureService from '../service/storeFixture.service.js';
19
20
  import * as fixtureShelfService from '../service/fixtureShelf.service.js';
@@ -190,10 +191,43 @@ export async function createTask( req, res ) {
190
191
  store: req.body.store.toLowerCase(),
191
192
  },
192
193
  },
194
+ {
195
+ $sort: {
196
+ _id: -1,
197
+ },
198
+ },
199
+ {
200
+ $limit: 1,
201
+ },
193
202
  ];
194
203
  let getUserDetails = await assignService.aggregate( assignQuery );
195
204
  if ( !getUserDetails.length ) {
196
- return res.sendError( 'Email is required' );
205
+ getUserDetails = await taskAssignService.taskAggregate( assignQuery );
206
+ if ( !getUserDetails.length ) {
207
+ let storeQuery = [
208
+ {
209
+ $addFields: {
210
+ store: { $toLower: '$storeName' },
211
+ },
212
+ },
213
+ {
214
+ $match: {
215
+ clientId: req.body.clientId,
216
+ store: req.body.store.toLowerCase(),
217
+ },
218
+ },
219
+ {
220
+ $project: {
221
+ spocDetails: 1,
222
+ },
223
+ },
224
+ ];
225
+ let getEmail = await storeService.aggregate( storeQuery );
226
+ console.log( getEmail );
227
+ if ( getEmail.length ) {
228
+ getUserDetails = [ { storeName: req.body.store, userEmail: getEmail?.[0]?.spocDetails?.[0]?.email } ];
229
+ }
230
+ }
197
231
  }
198
232
  req.body.stores = [
199
233
  {
@@ -6,39 +6,39 @@ import { isAllowedSessionHandler } from 'tango-app-api-middleware';
6
6
  export const scriptRouter = express.Router();
7
7
 
8
8
  scriptRouter
9
- .post('/getUniqueStoresFromExcel', scriptController.getStoreNames)
10
- .post('/bilkInsertFixtureConfig', scriptController.createFixtureConfig)
11
- .post('/bulkInsertPlanoData', scriptController.createPlano)
12
- .post('/bulkIinsertFloorData', scriptController.createFloors)
13
- .post('/bulkIinsertVmTemplateData', scriptController.createVmData)
14
- .post('/bulkIinsertFixturesShelvesVmsData', scriptController.createFixturesShelves)
15
- .post('/updateFixturesShelvesVms', scriptController.updateFixturesShelves)
16
- .post('/lk98lK1993Update', scriptController.lk98lK1993Update)
17
- .post('/updateinventory', scriptController.updateInventory)
18
- .post('/updateRfidProduct', scriptController.updateRfidProduct)
19
- .post('/updateRfidProduct2', scriptController.updateRfidProduct2)
20
- .post('/getProdTaskData', scriptController.getProdTaskData)
21
- .post('/updateLayoutFeedback', scriptController.updatelayoutFeedback)
22
- .post('/updateFixtureFeedback', scriptController.updateFixtureFeedback)
23
- .post('/getFileNames', scriptController.extractZipFileNames)
24
- .post('/getVmTaskData', scriptController.getVmTaskData)
25
- .post('/updateVmData', scriptController.updateVmData)
26
- .post('/createCrestPlanogram', scriptController.createCrestPlanogram)
27
- .post('/updateCrestPlanogram', scriptController.updateCrestPlanogram)
28
- .post('/updatelayout', scriptController.updatelayout)
29
- .post('/updateCrestVms', scriptController.updateCrestVms)
30
- .post('/downloadPlanoImages', scriptController.downloadPlanoImage)
31
- .post('/getVideoUrls', scriptController.getVideoLinks)
32
- .post('/updateExcelPlanogram', scriptController.updateExcelPlanogram)
33
- .post('/recorrectTaskData', scriptController.recorrectTaskData)
34
- .post('/migrateCrest', scriptController.migrateCrestv1)
35
- .post('/updatePlanoMappings', scriptController.updatePlanoMappings)
36
- .post('/readExcel', scriptController.readExcel)
37
- .post('/migrateOvmToIvm', scriptController.migrateOvmToIvm)
9
+ .post( '/getUniqueStoresFromExcel', scriptController.getStoreNames )
10
+ .post( '/bilkInsertFixtureConfig', scriptController.createFixtureConfig )
11
+ .post( '/bulkInsertPlanoData', scriptController.createPlano )
12
+ .post( '/bulkIinsertFloorData', scriptController.createFloors )
13
+ .post( '/bulkIinsertVmTemplateData', scriptController.createVmData )
14
+ .post( '/bulkIinsertFixturesShelvesVmsData', scriptController.createFixturesShelves )
15
+ .post( '/updateFixturesShelvesVms', scriptController.updateFixturesShelves )
16
+ .post( '/lk98lK1993Update', scriptController.lk98lK1993Update )
17
+ .post( '/updateinventory', scriptController.updateInventory )
18
+ .post( '/updateRfidProduct', scriptController.updateRfidProduct )
19
+ .post( '/updateRfidProduct2', scriptController.updateRfidProduct2 )
20
+ .post( '/getProdTaskData', scriptController.getProdTaskData )
21
+ .post( '/updateLayoutFeedback', scriptController.updatelayoutFeedback )
22
+ .post( '/updateFixtureFeedback', scriptController.updateFixtureFeedback )
23
+ .post( '/getFileNames', scriptController.extractZipFileNames )
24
+ .post( '/getVmTaskData', scriptController.getVmTaskData )
25
+ .post( '/updateVmData', scriptController.updateVmData )
26
+ .post( '/createCrestPlanogram', scriptController.createCrestPlanogram )
27
+ .post( '/updateCrestPlanogram', scriptController.updateCrestPlanogram )
28
+ .post( '/updatelayout', scriptController.updatelayout )
29
+ .post( '/updateCrestVms', scriptController.updateCrestVms )
30
+ .post( '/downloadPlanoImages', scriptController.downloadPlanoImage )
31
+ .post( '/getVideoUrls', scriptController.getVideoLinks )
32
+ .post( '/updateExcelPlanogram', scriptController.updateExcelPlanogram )
33
+ .post( '/recorrectTaskData', scriptController.recorrectTaskData )
34
+ .post( '/migrateCrest', scriptController.migrateCrestv1 )
35
+ .post( '/updatePlanoMappings', scriptController.updatePlanoMappings )
36
+ .post( '/readExcel', scriptController.readExcel )
37
+ .post( '/migrateOvmToIvm', scriptController.migrateOvmToIvm )
38
38
  // .post( '/migrateOvmToOvm', scriptController.migrateOvmToOvm )
39
- .post('/groupFixture', scriptController.groupFixture)
40
- .post('/productMappings', scriptController.productMappings)
41
- .post('/productMappings', scriptController.productMappings)
42
- .post('/complianceFromMappings', scriptController.createComplianceFromMappins)
43
- .get('/getAllPlanoIdsM', scriptController.getAllPlanoIds)
44
- ;
39
+ .post( '/groupFixture', scriptController.groupFixture )
40
+ .post( '/productMappings', scriptController.productMappings )
41
+ .post( '/productMappings', scriptController.productMappings )
42
+ .post( '/complianceFromMappings', scriptController.createComplianceFromMappins )
43
+ .get( '/getAllPlanoIdsM', scriptController.getAllPlanoIds )
44
+ .post( '/planoAccess', scriptController.planoAccess );
@@ -4,4 +4,8 @@ export async function aggregate( query = [] ) {
4
4
  return await model.checklistassignconfigModel.aggregate( query );
5
5
  }
6
6
 
7
+ export async function taskAggregate( query = [] ) {
8
+ return await model.taskAssignModel.aggregate( query );
9
+ }
10
+
7
11