tango-app-api-store-builder 1.0.0-beta-132 → 1.0.0-beta-133
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 +2 -2
- package/src/controllers/fixtureTemplate.controller.js +57 -35
- package/src/controllers/managePlano.controller.js +123 -3
- package/src/controllers/planoLibrary.controller.js +2 -2
- package/src/controllers/script.controller.js +251 -26
- package/src/controllers/storeBuilder.controller.js +1 -0
- package/src/routes/fixtureTemplate.routes.js +2 -1
- package/src/routes/managePlano.routes.js +6 -1
- package/src/service/planoGlobalComment.service.js +25 -0
- package/src/service/planoLibrary.service.js +8 -0
- package/src/service/planoRevision.service.js +15 -0
- package/src/service/storeFixture.service.js +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-store-builder",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-133",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"path": "^0.12.7",
|
|
33
33
|
"selenium-webdriver": "^4.31.0",
|
|
34
34
|
"sharp": "^0.34.1",
|
|
35
|
-
"tango-api-schema": "^2.2.
|
|
35
|
+
"tango-api-schema": "^2.2.169",
|
|
36
36
|
"tango-app-api-middleware": "3.1.48",
|
|
37
37
|
"url": "^0.11.4",
|
|
38
38
|
"winston": "^3.17.0",
|
|
@@ -78,9 +78,8 @@ export async function updateTemplate( req, res ) {
|
|
|
78
78
|
if ( !templateDetails ) {
|
|
79
79
|
return res.sendError( 'No data found', 204 );
|
|
80
80
|
}
|
|
81
|
-
if ( inputData.status == '
|
|
81
|
+
if ( inputData.status == 'complete' ) {
|
|
82
82
|
let newFixture;
|
|
83
|
-
let storeList = inputData.store;
|
|
84
83
|
delete inputData.store;
|
|
85
84
|
if ( req.body?.new ) {
|
|
86
85
|
templateDetails = templateDetails.toObject();
|
|
@@ -88,44 +87,53 @@ export async function updateTemplate( req, res ) {
|
|
|
88
87
|
let templateData = { ...templateDetails, ...inputData };
|
|
89
88
|
newFixture = await fixtureConfigService.create( templateData );
|
|
90
89
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
let fixtureCapacity = inputData.shelfConfig.reduce( ( acc, ele ) => {
|
|
91
|
+
if ( ele.shelfType == 'tray' ) {
|
|
92
|
+
ele.productPerShelf = ele.trayRows * ele.productPerShelf;
|
|
93
|
+
}
|
|
94
|
+
acc = acc + ele.productPerShelf;
|
|
95
|
+
return acc;
|
|
96
|
+
},
|
|
97
|
+
0 );
|
|
98
|
+
|
|
99
|
+
let storeFixtureDetails = await storeFixtureService.find( { fixtureConfigId: req.params.templateId } );
|
|
100
|
+
if ( storeFixtureDetails.length ) {
|
|
101
|
+
let fixtureList = storeFixtureDetails.map( ( ele ) => ele._id );
|
|
97
102
|
let fixtureData = {
|
|
98
103
|
...inputData,
|
|
99
|
-
storeName: ele.storeName,
|
|
100
|
-
storeId: ele.storeId,
|
|
101
104
|
fixtureCapacity: fixtureCapacity,
|
|
102
|
-
fixtureConfigId: newFixture ? newFixture._id :
|
|
105
|
+
fixtureConfigId: newFixture ? newFixture._id : req.params.templateId,
|
|
103
106
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
delete fixtureData._id;
|
|
108
|
+
delete fixtureData.status;
|
|
109
|
+
await storeFixtureService.updateMany( { _id: { $in: fixtureList } }, fixtureData );
|
|
110
|
+
await Promise.all( storeFixtureDetails.map( async ( fixture ) => {
|
|
111
|
+
await fixtureShelfService.deleteMany( { fixtureId: fixture } );
|
|
112
|
+
let shelfData = [];
|
|
113
|
+
inputData.shelfConfig.forEach( ( ele, index ) => {
|
|
114
|
+
shelfData.push( {
|
|
115
|
+
productCategory: inputData.productCategory,
|
|
116
|
+
productSubCategory: inputData.productCategory,
|
|
117
|
+
shelfType: ele.shelfType,
|
|
118
|
+
trayRows: ele.trayRows,
|
|
119
|
+
shelfNumber: index + 1,
|
|
120
|
+
fixtureId: fixture,
|
|
121
|
+
clientId: req.body.clientId,
|
|
122
|
+
planoId: fixture.planoId,
|
|
123
|
+
floorId: fixture.floorId,
|
|
124
|
+
productBrandName: ele.productBrandName,
|
|
125
|
+
shelfOrder: 'LTR',
|
|
126
|
+
shelfSplitup: 0,
|
|
127
|
+
storeId: fixture.storeId,
|
|
128
|
+
storeName: fixture.storeName,
|
|
129
|
+
productPerShelf: ele.productPerShelf,
|
|
130
|
+
sectionZone: ele.zone,
|
|
131
|
+
zone: ele.zone,
|
|
132
|
+
} );
|
|
125
133
|
} );
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
134
|
+
await fixtureShelfService.insertMany( shelfData );
|
|
135
|
+
} ) );
|
|
136
|
+
}
|
|
129
137
|
}
|
|
130
138
|
await fixtureConfigService.updateOne( { _id: req.params.templateId }, inputData );
|
|
131
139
|
return res.sendSuccess( 'Fixture template details updated successfully' );
|
|
@@ -473,3 +481,17 @@ export async function updateFixtureTask( req, res ) {
|
|
|
473
481
|
logger.error( { functionName: 'updateFixtureTask', error: e } );
|
|
474
482
|
}
|
|
475
483
|
}
|
|
484
|
+
|
|
485
|
+
export async function getAllTemplates( req, res ) {
|
|
486
|
+
try {
|
|
487
|
+
if ( !req.body.clientId ) {
|
|
488
|
+
return res.sendError( 'Client Id is required', 400 );
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const fixtureTemplates = await fixtureConfigService.find( { clientId: req.body.clientId }, { fixtureName: 1, fixtureWidth: 1, productBrandName: 1 } );
|
|
492
|
+
|
|
493
|
+
res.sendSuccess( fixtureTemplates );
|
|
494
|
+
} catch ( e ) {
|
|
495
|
+
logger.error( { functionName: 'getAllTemplates', error: e } );
|
|
496
|
+
}
|
|
497
|
+
}
|
|
@@ -13,12 +13,13 @@ import * as planoproductCategoryService from '../service/planoproductCategory.se
|
|
|
13
13
|
import * as fixtureConfigService from '../service/fixtureConfig.service.js';
|
|
14
14
|
import * as fixtureLibraryService from '../service/planoLibrary.service.js';
|
|
15
15
|
import * as planoTaskService from '../service/planoTask.service.js';
|
|
16
|
+
import * as planoGlobalCommentService from '../service/planoGlobalComment.service.js';
|
|
16
17
|
import mongoose from 'mongoose';
|
|
18
|
+
import * as planoRevisionService from '../service/planoRevision.service.js';
|
|
17
19
|
export async function getplanoFeedback( req, res ) {
|
|
18
20
|
try {
|
|
19
21
|
let query = [];
|
|
20
22
|
|
|
21
|
-
|
|
22
23
|
query.push( {
|
|
23
24
|
$match: {
|
|
24
25
|
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
@@ -376,8 +377,25 @@ export async function getplanoFeedback( req, res ) {
|
|
|
376
377
|
|
|
377
378
|
|
|
378
379
|
let findvmCompliance = await planoTaskService.aggregate( queryVm );
|
|
379
|
-
|
|
380
|
-
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
let layoutComment = await planoGlobalCommentService.find( {
|
|
383
|
+
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
384
|
+
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
385
|
+
taskType: 'layout',
|
|
386
|
+
} );
|
|
387
|
+
let fixtureComment = await planoGlobalCommentService.find( {
|
|
388
|
+
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
389
|
+
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
390
|
+
taskType: 'fixture',
|
|
391
|
+
} );
|
|
392
|
+
let vmComment = await planoGlobalCommentService.find( {
|
|
393
|
+
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
394
|
+
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
395
|
+
taskType: 'vm',
|
|
396
|
+
} );
|
|
397
|
+
|
|
398
|
+
res.sendSuccess( { layoutData: findPlanoCompliance, layoutComment: layoutComment, fixtureComment: fixtureComment, vmComment: vmComment, fixtureData: findfixtureCompliance, VmData: findvmCompliance } );
|
|
381
399
|
} catch ( e ) {
|
|
382
400
|
logger.error( { functionName: 'getplanoFeedback', error: e, message: req.body } );
|
|
383
401
|
return res.sendError( e, 500 );
|
|
@@ -804,3 +822,105 @@ export async function updateredostatus( req, res ) {
|
|
|
804
822
|
return res.sendError( e, 500 );
|
|
805
823
|
}
|
|
806
824
|
}
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
export async function updateGlobalComment( req, res ) {
|
|
828
|
+
try {
|
|
829
|
+
await planoGlobalCommentService.create( {
|
|
830
|
+
userId: req.user._id,
|
|
831
|
+
userName: req.user.userName,
|
|
832
|
+
comment: req.body.comment,
|
|
833
|
+
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
834
|
+
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
835
|
+
taskType: req.body.taskType,
|
|
836
|
+
clientId: req.body.clientId,
|
|
837
|
+
} );
|
|
838
|
+
|
|
839
|
+
res.sendSuccess( 'updated successfully' );
|
|
840
|
+
} catch ( e ) {
|
|
841
|
+
logger.error( { functionName: 'updateGlobalComment', error: e } );
|
|
842
|
+
return res.sendError( e, 500 );
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
export async function getGlobalComment( req, res ) {
|
|
846
|
+
try {
|
|
847
|
+
let layoutComment = await planoGlobalCommentService.find( {
|
|
848
|
+
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
849
|
+
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
850
|
+
taskType: req.body.taskType,
|
|
851
|
+
} );
|
|
852
|
+
res.sendSuccess( layoutComment );
|
|
853
|
+
} catch ( e ) {
|
|
854
|
+
logger.error( { functionName: 'getGlobalComment', error: e } );
|
|
855
|
+
return res.sendError( e, 500 );
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
export async function getAllPlanoRevisions( req, res ) {
|
|
860
|
+
try {
|
|
861
|
+
const { clientId } = req.body;
|
|
862
|
+
|
|
863
|
+
if ( !clientId ) {
|
|
864
|
+
return res.sendError( 'Client Id is required', 400 );
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
const revisions = await planoRevisionService.find(
|
|
868
|
+
{ clientId },
|
|
869
|
+
{ storeName: 1, storeId: 1, planoId: 1, floorId: 1, createdAt: 1 },
|
|
870
|
+
);
|
|
871
|
+
|
|
872
|
+
res.sendSuccess( revisions );
|
|
873
|
+
} catch ( e ) {
|
|
874
|
+
logger.error( { functionName: 'getAllPlanoRevisions', error: e } );
|
|
875
|
+
res.sendError( 'Failed to fetch plano revisions', 500 );
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
export async function createPlanoRevision( req, res ) {
|
|
880
|
+
try {
|
|
881
|
+
const { storeName, storeId, clientId, planoId, floorId, floorData } = req.body;
|
|
882
|
+
|
|
883
|
+
if ( !storeName || !storeId || !clientId || !planoId || !floorId || !floorData ) {
|
|
884
|
+
return res.sendError( 'Missing required fields', 400 );
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
const newRevision = await planoRevisionService.create( {
|
|
888
|
+
storeName,
|
|
889
|
+
storeId,
|
|
890
|
+
clientId,
|
|
891
|
+
planoId,
|
|
892
|
+
floorId,
|
|
893
|
+
floorData,
|
|
894
|
+
} );
|
|
895
|
+
|
|
896
|
+
res.sendSuccess( newRevision );
|
|
897
|
+
} catch ( e ) {
|
|
898
|
+
logger.error( { functionName: 'createPlanoRevision', error: e } );
|
|
899
|
+
res.sendError( 'Failed to create plano revision', 500 );
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
export async function getPlanoRevisionById( req, res ) {
|
|
904
|
+
try {
|
|
905
|
+
const { id } = req.params;
|
|
906
|
+
|
|
907
|
+
if ( !id ) {
|
|
908
|
+
return res.sendError( 'Revision ID is required', 400 );
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
const revision = await planoRevisionService.findOne(
|
|
912
|
+
{ _id: id },
|
|
913
|
+
);
|
|
914
|
+
|
|
915
|
+
if ( !revision ) {
|
|
916
|
+
return res.sendError( 'Plano revision not found', 404 );
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
res.sendSuccess( revision );
|
|
920
|
+
} catch ( e ) {
|
|
921
|
+
logger.error( { functionName: 'getPlanoRevisionById', error: e } );
|
|
922
|
+
res.sendError( 'Failed to fetch plano revision', 500 );
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
|
|
@@ -92,7 +92,7 @@ export async function fixtureBulkUpload( req, res ) {
|
|
|
92
92
|
|
|
93
93
|
async function getMaxFixtureLibCode() {
|
|
94
94
|
try {
|
|
95
|
-
let getFixtureLibDetails = await planoLibraryService.find( {}, { fixtureLibCode: 1 } );
|
|
95
|
+
let getFixtureLibDetails = await planoLibraryService.find( { fixtureLibCode: { $exists: true } }, { fixtureLibCode: 1 } );
|
|
96
96
|
if ( !getFixtureLibDetails.length ) {
|
|
97
97
|
return 'FX01';
|
|
98
98
|
} else {
|
|
@@ -1397,7 +1397,7 @@ export async function vmBulkUpload( req, res ) {
|
|
|
1397
1397
|
|
|
1398
1398
|
async function getMaxVMLibCode() {
|
|
1399
1399
|
try {
|
|
1400
|
-
let getVMLibDetails = await vmService.find( {}, { vmLibCode: 1 } );
|
|
1400
|
+
let getVMLibDetails = await vmService.find( { vmLibCode: { $exists: true } }, { vmLibCode: 1 } );
|
|
1401
1401
|
if ( !getVMLibDetails.length ) {
|
|
1402
1402
|
return 'VM01';
|
|
1403
1403
|
} else {
|
|
@@ -2323,9 +2323,9 @@ export async function updateVmData( req, res ) {
|
|
|
2323
2323
|
|
|
2324
2324
|
// import https from 'https';
|
|
2325
2325
|
// async function scrapeCrest() {
|
|
2326
|
-
// const storeIds = [ '
|
|
2326
|
+
// const storeIds = [ 'LKST506' ];
|
|
2327
2327
|
// const apiUrl = 'https://api.getcrest.ai/api/ms_shelfsensei/layout/';
|
|
2328
|
-
// const bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
|
|
2328
|
+
// const bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzUwNjA1NDA1LCJpYXQiOjE3NTA2MDE4MDUsImp0aSI6IjAxZWJmNzRkYzNkODQ2MjliNTA4YzI0MjM3MDRiYjdlIiwidXNlcl9pZCI6MTA4NSwiaWQiOjEwODUsImlzX21lZXNlZWtfYWNjb3VudCI6ZmFsc2UsImN1c3RvbWVyX2dyb3VwIjozOTgsImxpY2VuY2Vfc2NvcGVzIjpbeyJyZXNvdXJjZV9zZXQiOiJwcF9zZXQiLCJzY29wZV9yb2xlIjoiY29udHJpYnV0b3IifSx7InJlc291cmNlX3NldCI6ImRwX3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9LHsicmVzb3VyY2Vfc2V0IjoiZGZfc2V0Iiwic2NvcGVfcm9sZSI6ImNvbnRyaWJ1dG9yIn0seyJyZXNvdXJjZV9zZXQiOiJkZWZhdWx0X3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9XX0.OnXe5ws08FwY1h0u3bLl8-dxQyrCL2mxr6c_b1lyf-Q';
|
|
2329
2329
|
// const filePath = 'response.json';
|
|
2330
2330
|
// let allResults = [];
|
|
2331
2331
|
|
|
@@ -7223,6 +7223,174 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7223
7223
|
}
|
|
7224
7224
|
};
|
|
7225
7225
|
|
|
7226
|
+
const getLibraryType = ( fixtureName ) => {
|
|
7227
|
+
const parts = fixtureName
|
|
7228
|
+
.split( ' - ' )
|
|
7229
|
+
.map( ( str ) => str.trim() )
|
|
7230
|
+
.filter( Boolean );
|
|
7231
|
+
|
|
7232
|
+
let category = 'Unknown';
|
|
7233
|
+
let value = 3;
|
|
7234
|
+
|
|
7235
|
+
const last = parts[parts.length - 1];
|
|
7236
|
+
const secondLast = parts[parts.length - 2];
|
|
7237
|
+
|
|
7238
|
+
const match = last?.match( /^([\d.]+)ft$/ );
|
|
7239
|
+
|
|
7240
|
+
if ( match && secondLast ) {
|
|
7241
|
+
value = parseFloat( match[1] );
|
|
7242
|
+
value = Math.round( value * 10 ) / 10;
|
|
7243
|
+
if ( value % 1 === 0 ) value = Math.round( value );
|
|
7244
|
+
|
|
7245
|
+
category = secondLast;
|
|
7246
|
+
} else {
|
|
7247
|
+
if ( last?.toLowerCase() === 'ft' || last?.toLowerCase().endsWith( 'ft' ) ) {
|
|
7248
|
+
category = secondLast || last;
|
|
7249
|
+
} else {
|
|
7250
|
+
category = last;
|
|
7251
|
+
}
|
|
7252
|
+
|
|
7253
|
+
value = 3;
|
|
7254
|
+
}
|
|
7255
|
+
|
|
7256
|
+
return {
|
|
7257
|
+
fixtureCategory: category,
|
|
7258
|
+
fixtureWidth: { value, unit: 'ft' },
|
|
7259
|
+
};
|
|
7260
|
+
};
|
|
7261
|
+
|
|
7262
|
+
|
|
7263
|
+
const sampleLibrary = {
|
|
7264
|
+
'clientId': '11',
|
|
7265
|
+
'fixtureType': 'wall',
|
|
7266
|
+
'fixtureHeight': {
|
|
7267
|
+
'value': 0,
|
|
7268
|
+
'unit': 'ft',
|
|
7269
|
+
},
|
|
7270
|
+
'fixtureLength': {
|
|
7271
|
+
'value': 4,
|
|
7272
|
+
'unit': 'ft',
|
|
7273
|
+
},
|
|
7274
|
+
'header': {
|
|
7275
|
+
'height': {
|
|
7276
|
+
'value': 0,
|
|
7277
|
+
'unit': '',
|
|
7278
|
+
},
|
|
7279
|
+
},
|
|
7280
|
+
'footer': {
|
|
7281
|
+
'height': {
|
|
7282
|
+
'value': 0,
|
|
7283
|
+
'unit': '',
|
|
7284
|
+
},
|
|
7285
|
+
},
|
|
7286
|
+
'fixtureCapacity': 90,
|
|
7287
|
+
'status': 'complete',
|
|
7288
|
+
'shelfConfig': [
|
|
7289
|
+
{
|
|
7290
|
+
'shelfNumber': 1,
|
|
7291
|
+
'shelfType': 'shelf',
|
|
7292
|
+
'shelfZone': 'Top',
|
|
7293
|
+
'productPerShelf': 6,
|
|
7294
|
+
'trayRows': 0,
|
|
7295
|
+
'label': '',
|
|
7296
|
+
},
|
|
7297
|
+
{
|
|
7298
|
+
'shelfNumber': 2,
|
|
7299
|
+
'shelfType': 'shelf',
|
|
7300
|
+
'shelfZone': 'Top',
|
|
7301
|
+
'productPerShelf': 6,
|
|
7302
|
+
'trayRows': 0,
|
|
7303
|
+
'label': '',
|
|
7304
|
+
},
|
|
7305
|
+
{
|
|
7306
|
+
'shelfNumber': 3,
|
|
7307
|
+
'shelfType': 'shelf',
|
|
7308
|
+
'shelfZone': 'Top',
|
|
7309
|
+
'productPerShelf': 6,
|
|
7310
|
+
'trayRows': 0,
|
|
7311
|
+
'label': '',
|
|
7312
|
+
},
|
|
7313
|
+
{
|
|
7314
|
+
'shelfNumber': 4,
|
|
7315
|
+
'shelfType': 'tray',
|
|
7316
|
+
'shelfZone': 'Mid',
|
|
7317
|
+
'productPerShelf': 6,
|
|
7318
|
+
'trayRows': 3,
|
|
7319
|
+
'label': '',
|
|
7320
|
+
},
|
|
7321
|
+
{
|
|
7322
|
+
'shelfNumber': 5,
|
|
7323
|
+
'shelfType': 'tray',
|
|
7324
|
+
'shelfZone': 'Mid',
|
|
7325
|
+
'productPerShelf': 6,
|
|
7326
|
+
'trayRows': 3,
|
|
7327
|
+
'label': '',
|
|
7328
|
+
},
|
|
7329
|
+
{
|
|
7330
|
+
'shelfNumber': 6,
|
|
7331
|
+
'shelfType': 'tray',
|
|
7332
|
+
'shelfZone': 'Bottom',
|
|
7333
|
+
'productPerShelf': 6,
|
|
7334
|
+
'trayRows': 3,
|
|
7335
|
+
'label': '',
|
|
7336
|
+
},
|
|
7337
|
+
{
|
|
7338
|
+
'shelfNumber': 7,
|
|
7339
|
+
'shelfType': 'tray',
|
|
7340
|
+
'shelfZone': 'Bottom',
|
|
7341
|
+
'productPerShelf': 6,
|
|
7342
|
+
'trayRows': 3,
|
|
7343
|
+
'label': '',
|
|
7344
|
+
},
|
|
7345
|
+
],
|
|
7346
|
+
'vmConfig': [
|
|
7347
|
+
{
|
|
7348
|
+
'vmNumber': 1,
|
|
7349
|
+
'vmHeightmm': 100,
|
|
7350
|
+
'vmWidthmm': 905,
|
|
7351
|
+
'startShelf': 1,
|
|
7352
|
+
'endShelf': 2,
|
|
7353
|
+
'zone': 'left',
|
|
7354
|
+
'position': 'Top',
|
|
7355
|
+
},
|
|
7356
|
+
{
|
|
7357
|
+
'vmNumber': 2,
|
|
7358
|
+
'vmHeightmm': 100,
|
|
7359
|
+
'vmWidthmm': 230,
|
|
7360
|
+
'startShelf': 5,
|
|
7361
|
+
'endShelf': 5,
|
|
7362
|
+
'zone': 'left',
|
|
7363
|
+
'position': 'Mid',
|
|
7364
|
+
},
|
|
7365
|
+
{
|
|
7366
|
+
'vmNumber': 3,
|
|
7367
|
+
'vmHeightmm': 100,
|
|
7368
|
+
'vmWidthmm': 905,
|
|
7369
|
+
'startShelf': 5,
|
|
7370
|
+
'endShelf': 5,
|
|
7371
|
+
'zone': 'left',
|
|
7372
|
+
'position': 'Mid',
|
|
7373
|
+
},
|
|
7374
|
+
{
|
|
7375
|
+
'vmNumber': 4,
|
|
7376
|
+
'vmHeightmm': 100,
|
|
7377
|
+
'vmWidthmm': 230,
|
|
7378
|
+
'startShelf': 6,
|
|
7379
|
+
'endShelf': 6,
|
|
7380
|
+
'zone': 'right',
|
|
7381
|
+
'position': 'Bottom',
|
|
7382
|
+
},
|
|
7383
|
+
],
|
|
7384
|
+
'fixtureStaticLength': {
|
|
7385
|
+
'value': 1524,
|
|
7386
|
+
'unit': 'mm',
|
|
7387
|
+
},
|
|
7388
|
+
'fixtureStaticWidth': {
|
|
7389
|
+
'value': 1220,
|
|
7390
|
+
'unit': 'mm',
|
|
7391
|
+
},
|
|
7392
|
+
};
|
|
7393
|
+
|
|
7226
7394
|
|
|
7227
7395
|
if ( !req?.body?.storeName ) {
|
|
7228
7396
|
return res.sendError( 'No store supplied', 200 );
|
|
@@ -7232,19 +7400,7 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7232
7400
|
clientId: '11',
|
|
7233
7401
|
$and: [
|
|
7234
7402
|
{ storeName: req.body.storeName },
|
|
7235
|
-
// { storeName: { $in: [
|
|
7236
|
-
// 'LKST81',
|
|
7237
|
-
// 'LKST682',
|
|
7238
|
-
// 'LKST351',
|
|
7239
|
-
// 'LKST1193',
|
|
7240
|
-
// 'LKST98',
|
|
7241
|
-
// 'LKST01',
|
|
7242
|
-
// 'LKST266',
|
|
7243
|
-
// 'LKST495',
|
|
7244
|
-
// 'LKST2280',
|
|
7245
|
-
// 'LKST599',
|
|
7246
|
-
// 'LKST267',
|
|
7247
|
-
// ] } },
|
|
7403
|
+
// { storeName: { $in: ['LKST98', 'LKST682', 'ST185', 'ST36', 'LKST1193'] } },
|
|
7248
7404
|
// { storeName: { $nin: [ 'LKST98', 'LKST1193' ] } },
|
|
7249
7405
|
],
|
|
7250
7406
|
};
|
|
@@ -7478,8 +7634,31 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7478
7634
|
for ( let index = 0; index < leftFixtures.length; index++ ) {
|
|
7479
7635
|
const fixture = leftFixtures[index];
|
|
7480
7636
|
|
|
7481
|
-
|
|
7482
|
-
|
|
7637
|
+
if ( !fixture.fixtureName ) {
|
|
7638
|
+
return;
|
|
7639
|
+
}
|
|
7640
|
+
|
|
7641
|
+
const libraryType = getLibraryType( fixture.fixtureName );
|
|
7642
|
+
|
|
7643
|
+
if ( libraryType.fixtureCategory === 'Space' ) {
|
|
7644
|
+
continue;
|
|
7645
|
+
}
|
|
7646
|
+
|
|
7647
|
+
let fixtureConfig = await fixtureLibraryService.findOne( libraryType );
|
|
7648
|
+
|
|
7649
|
+
if ( !fixtureConfig ) {
|
|
7650
|
+
const existingLibrary = await fixtureLibraryService.findOne( { fixtureCategory: libraryType.fixtureCategory } );
|
|
7651
|
+
|
|
7652
|
+
const insertData = {
|
|
7653
|
+
...sampleLibrary,
|
|
7654
|
+
...( existingLibrary ? existingLibrary.toObject() : {} ),
|
|
7655
|
+
...libraryType,
|
|
7656
|
+
};
|
|
7657
|
+
|
|
7658
|
+
delete insertData._id;
|
|
7659
|
+
|
|
7660
|
+
fixtureConfig = await fixtureLibraryService.upsertOne( libraryType, insertData );
|
|
7661
|
+
}
|
|
7483
7662
|
const fixtureConfigDoc = fixtureConfig.toObject();
|
|
7484
7663
|
|
|
7485
7664
|
let mapKey = `${fixtureConfigDoc.fixtureCategory}${fixtureConfigDoc.fixtureWidth.value}${fixtureConfigDoc.fixtureWidth.unit},${fixture.header}`;
|
|
@@ -7495,7 +7674,7 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7495
7674
|
|
|
7496
7675
|
mapKey += ','+shelfIdentifier;
|
|
7497
7676
|
|
|
7498
|
-
const productSubBrandName = shelfSection?.productName?.replace( /\s*PIDs
|
|
7677
|
+
const productSubBrandName = shelfSection?.productName?.replace( /\s*PIDs?\b/g, '' )?.split( /\s*\+\s*/ ) || [];
|
|
7499
7678
|
|
|
7500
7679
|
productSubBrandName.forEach( ( item ) => fixtureProductSubBrandName.add( item ) );
|
|
7501
7680
|
|
|
@@ -7749,8 +7928,31 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7749
7928
|
for ( let index = 0; index < backFixtures.length; index++ ) {
|
|
7750
7929
|
const fixture = backFixtures[index];
|
|
7751
7930
|
|
|
7752
|
-
|
|
7753
|
-
|
|
7931
|
+
if ( !fixture.fixtureName ) {
|
|
7932
|
+
return;
|
|
7933
|
+
}
|
|
7934
|
+
|
|
7935
|
+
const libraryType = getLibraryType( fixture.fixtureName );
|
|
7936
|
+
|
|
7937
|
+
if ( libraryType.fixtureCategory === 'Space' ) {
|
|
7938
|
+
continue;
|
|
7939
|
+
}
|
|
7940
|
+
|
|
7941
|
+
let fixtureConfig = await fixtureLibraryService.findOne( libraryType );
|
|
7942
|
+
|
|
7943
|
+
if ( !fixtureConfig ) {
|
|
7944
|
+
const existingLibrary = await fixtureLibraryService.findOne( { fixtureCategory: libraryType.fixtureCategory } );
|
|
7945
|
+
|
|
7946
|
+
const insertData = {
|
|
7947
|
+
...sampleLibrary,
|
|
7948
|
+
...( existingLibrary ? existingLibrary.toObject() : {} ),
|
|
7949
|
+
...libraryType,
|
|
7950
|
+
};
|
|
7951
|
+
|
|
7952
|
+
delete insertData._id;
|
|
7953
|
+
|
|
7954
|
+
fixtureConfig = await fixtureLibraryService.upsertOne( libraryType, insertData );
|
|
7955
|
+
}
|
|
7754
7956
|
const fixtureConfigDoc = fixtureConfig.toObject();
|
|
7755
7957
|
|
|
7756
7958
|
let mapKey = `${fixtureConfigDoc.fixtureCategory}${fixtureConfigDoc.fixtureWidth.value}${fixtureConfigDoc.fixtureWidth.unit},${fixture.header}`;
|
|
@@ -7766,7 +7968,7 @@ export async function migrateCrestv1( req, res ) {
|
|
|
7766
7968
|
|
|
7767
7969
|
mapKey += ','+shelfIdentifier;
|
|
7768
7970
|
|
|
7769
|
-
const productSubBrandName = shelfSection?.productName?.replace( /\s*PIDs
|
|
7971
|
+
const productSubBrandName = shelfSection?.productName?.replace( /\s*PIDs?\b/g, '' )?.split( /\s*\+\s*/ ) || [];
|
|
7770
7972
|
|
|
7771
7973
|
productSubBrandName.forEach( ( item ) => fixtureProductSubBrandName.add( item ) );
|
|
7772
7974
|
|
|
@@ -8019,8 +8221,31 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8019
8221
|
for ( let index = 0; index < rightFixtures.length; index++ ) {
|
|
8020
8222
|
const fixture = rightFixtures[index];
|
|
8021
8223
|
|
|
8022
|
-
|
|
8023
|
-
|
|
8224
|
+
if ( !fixture.fixtureName ) {
|
|
8225
|
+
return;
|
|
8226
|
+
}
|
|
8227
|
+
|
|
8228
|
+
const libraryType = getLibraryType( fixture.fixtureName );
|
|
8229
|
+
|
|
8230
|
+
if ( libraryType.fixtureCategory === 'Space' ) {
|
|
8231
|
+
continue;
|
|
8232
|
+
}
|
|
8233
|
+
|
|
8234
|
+
let fixtureConfig = await fixtureLibraryService.findOne( libraryType );
|
|
8235
|
+
|
|
8236
|
+
if ( !fixtureConfig ) {
|
|
8237
|
+
const existingLibrary = await fixtureLibraryService.findOne( { fixtureCategory: libraryType.fixtureCategory } );
|
|
8238
|
+
|
|
8239
|
+
const insertData = {
|
|
8240
|
+
...sampleLibrary,
|
|
8241
|
+
...( existingLibrary ? existingLibrary.toObject() : {} ),
|
|
8242
|
+
...libraryType,
|
|
8243
|
+
};
|
|
8244
|
+
|
|
8245
|
+
delete insertData._id;
|
|
8246
|
+
|
|
8247
|
+
fixtureConfig = await fixtureLibraryService.upsertOne( libraryType, insertData );
|
|
8248
|
+
}
|
|
8024
8249
|
const fixtureConfigDoc = fixtureConfig.toObject();
|
|
8025
8250
|
|
|
8026
8251
|
let mapKey = `${fixtureConfigDoc.fixtureCategory}${fixtureConfigDoc.fixtureWidth.value}${fixtureConfigDoc.fixtureWidth.unit},${fixture.header}`;
|
|
@@ -8036,7 +8261,7 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8036
8261
|
|
|
8037
8262
|
mapKey += ','+shelfIdentifier;
|
|
8038
8263
|
|
|
8039
|
-
const productSubBrandName = shelfSection?.productName?.replace( /\s*PIDs
|
|
8264
|
+
const productSubBrandName = shelfSection?.productName?.replace( /\s*PIDs?\b/g, '' )?.split( /\s*\+\s*/ ) || [];
|
|
8040
8265
|
|
|
8041
8266
|
productSubBrandName.forEach( ( item ) => fixtureProductSubBrandName.add( item ) );
|
|
8042
8267
|
|
|
@@ -8323,10 +8548,10 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8323
8548
|
mapKey += ','+shelfIdentifier;
|
|
8324
8549
|
|
|
8325
8550
|
|
|
8326
|
-
let productSubBrandName = fixture.centerSubMain.replace( /\s*PIDs
|
|
8551
|
+
let productSubBrandName = fixture.centerSubMain.replace( /\s*PIDs?\b/g, '' )?.split( /\s*\+\s*/ ) || [];
|
|
8327
8552
|
|
|
8328
8553
|
if ( shelfSection ) {
|
|
8329
|
-
productSubBrandName = shelfSection.name.replace( /\s*PIDs
|
|
8554
|
+
productSubBrandName = shelfSection.name.replace( /\s*PIDs?\b/g, '' )?.split( /\s*\+\s*/ ) || [];
|
|
8330
8555
|
}
|
|
8331
8556
|
|
|
8332
8557
|
productSubBrandName.forEach( ( item ) => fixtureProductSubBrandName.add( item ) );
|
|
@@ -13,5 +13,6 @@ fixtureTemplateRouter
|
|
|
13
13
|
.post( '/duplicateTemplate', validate( validateDtos.templateId ), fixtureTemplateController.duplicateTemplate )
|
|
14
14
|
.post( '/getTemplateList', validate( validateDtos.fixtureVMListSchema ), fixtureTemplateController.getTemplateList )
|
|
15
15
|
.get( '/getTemplateDetails', validate( validateDtos.queryTemplateId ), fixtureTemplateController.getTemplateDetails )
|
|
16
|
-
.post( '/updateFixtureTask', validate( validateDtos.updateFixtureTask ), fixtureTemplateController.updateFixtureTask )
|
|
16
|
+
.post( '/updateFixtureTask', validate( validateDtos.updateFixtureTask ), fixtureTemplateController.updateFixtureTask )
|
|
17
|
+
.post( '/getAllTemplates', fixtureTemplateController.getAllTemplates );
|
|
17
18
|
|
|
@@ -15,4 +15,9 @@ managePlanoRouter
|
|
|
15
15
|
.get( '/fixtureVMList', managePlanoController.fixtureVMList )
|
|
16
16
|
.post( '/updateFixtureStatus', isAllowedSessionHandler, managePlanoController.updateFixtureStatus )
|
|
17
17
|
.post( '/updateStoreFixture', managePlanoController.updateStoreFixture )
|
|
18
|
-
.post( '/updateredostatus', managePlanoController.updateredostatus )
|
|
18
|
+
.post( '/updateredostatus', managePlanoController.updateredostatus )
|
|
19
|
+
.post( '/updateGlobalComment', isAllowedSessionHandler, managePlanoController.updateGlobalComment )
|
|
20
|
+
.post( '/getGlobalComment', isAllowedSessionHandler, managePlanoController.getGlobalComment )
|
|
21
|
+
.post( '/createRevision', managePlanoController.createPlanoRevision )
|
|
22
|
+
.post( '/getRevisions', managePlanoController.getAllPlanoRevisions )
|
|
23
|
+
.post( '/getRevisionData', managePlanoController.getPlanoRevisionById );
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import model from 'tango-api-schema';
|
|
2
|
+
|
|
3
|
+
export async function create( data ) {
|
|
4
|
+
return model.planoGlobalComment.create( data );
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function findOne( query = {}, field = {} ) {
|
|
8
|
+
return model.planoGlobalComment.findOne( query, field );
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function updateOne( query = {}, record = {} ) {
|
|
12
|
+
return model.planoGlobalComment.updateOne( query, { $set: record }, { upsert: true } );
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function deleteMany( query = {} ) {
|
|
16
|
+
return model.planoGlobalComment.deleteMany( query );
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function aggregate( query = {} ) {
|
|
20
|
+
return model.planoGlobalComment.aggregate( query );
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function find( query = {}, field = {} ) {
|
|
24
|
+
return model.planoGlobalComment.find( query, field );
|
|
25
|
+
}
|
|
@@ -35,3 +35,11 @@ export const create = async ( data = {} ) => {
|
|
|
35
35
|
export const aggregate = async ( query=[] ) => {
|
|
36
36
|
return await model.fixtureLibraryModel.aggregate( query );
|
|
37
37
|
};
|
|
38
|
+
|
|
39
|
+
export async function upsertOne( query, record ) {
|
|
40
|
+
return model.fixtureLibraryModel.findOneAndUpdate(
|
|
41
|
+
query,
|
|
42
|
+
record,
|
|
43
|
+
{ upsert: true, new: true },
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import model from 'tango-api-schema';
|
|
2
|
+
|
|
3
|
+
const planoRevisionModel = model.planoRevisionModel;
|
|
4
|
+
|
|
5
|
+
export const findOne = async ( query = {}, field = {} ) => {
|
|
6
|
+
return await planoRevisionModel.findOne( query, field );
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const find = async ( query = {}, field = {} ) => {
|
|
10
|
+
return await planoRevisionModel.find( query, field );
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const create = async ( data = {} ) => {
|
|
14
|
+
return await planoRevisionModel.create( data );
|
|
15
|
+
};
|
|
@@ -20,6 +20,11 @@ export async function updateOne( query, record ) {
|
|
|
20
20
|
return model.storeFixtureModel.updateOne( query, { $set: record } );
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export async function updateMany( query, record ) {
|
|
24
|
+
console.log( record, 'record' );
|
|
25
|
+
return model.storeFixtureModel.updateMany( query, { $set: record } );
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
export async function findOneAndUpdate( query={}, field={} ) {
|
|
24
29
|
return model.storeFixtureModel.findOneAndUpdate( query, field );
|
|
25
30
|
}
|