tango-app-api-store-builder 1.0.0-beta-134 → 1.0.0-beta-136
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 +1 -1
- package/src/controllers/fixtureTemplate.controller.js +52 -14
- package/src/controllers/managePlano.controller.js +205 -268
- package/src/controllers/planoLibrary.controller.js +142 -99
- package/src/controllers/script.controller.js +149 -46
- package/src/controllers/storeBuilder.controller.js +410 -28
- package/src/controllers/task.controller.js +5 -2
- package/src/routes/script.routes.js +1 -0
- package/src/routes/storeBuilder.routes.js +5 -4
- package/src/service/fixtureShelf.service.js +4 -0
- package/src/service/planoTask.service.js +3 -0
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@ export async function createTemplate( req, res ) {
|
|
|
26
26
|
( acc, ele ) => ele.trayRows ? acc + ( ele.trayRows * ele.productPerShelf ) : ( acc + ele.productPerShelf ),
|
|
27
27
|
0,
|
|
28
28
|
);
|
|
29
|
-
let templateId = await getTemplateId();
|
|
29
|
+
let templateId = await getTemplateId( getLibDetails.fixtureCategory, getLibDetails.fixtureWidth );
|
|
30
30
|
let templateData = {
|
|
31
31
|
clientId: inputData.clientId,
|
|
32
32
|
fixtureLibraryId: inputData.fixtureLibraryId,
|
|
@@ -49,6 +49,7 @@ export async function createTemplate( req, res ) {
|
|
|
49
49
|
value: 1220,
|
|
50
50
|
unit: 'mm',
|
|
51
51
|
},
|
|
52
|
+
templateIndex: parseInt( templateId.split( '-' )[1] ),
|
|
52
53
|
};
|
|
53
54
|
let fixtureData = await fixtureConfigService.create( templateData );
|
|
54
55
|
return res.sendSuccess( { message: 'Fixture template created successfully', fixtureData } );
|
|
@@ -58,15 +59,11 @@ export async function createTemplate( req, res ) {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
async function getTemplateId() {
|
|
62
|
-
let templateId = '
|
|
63
|
-
let fixtureTemplateData = await fixtureConfigService.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
while ( fixtureData.includes( templateId ) ) {
|
|
67
|
-
count = count + 1;
|
|
68
|
-
let countId = String( count ).padStart( 2, '0' );
|
|
69
|
-
templateId =`Template${countId}`;
|
|
62
|
+
async function getTemplateId( name, width ) {
|
|
63
|
+
let templateId = 'Template-1';
|
|
64
|
+
let fixtureTemplateData = await fixtureConfigService.sortAndFindOne( { 'fixtureCategory': name, 'fixtureWidth.unit': width.unit, 'fixtureWidth.value': width.value }, { templateIndex: 1 }, { _id: -1 } );
|
|
65
|
+
if ( fixtureTemplateData.length ) {
|
|
66
|
+
templateId= `Template-${fixtureTemplateData[0].templateIndex + 1}`;
|
|
70
67
|
}
|
|
71
68
|
return templateId;
|
|
72
69
|
}
|
|
@@ -164,7 +161,7 @@ export async function deleteTemplate( req, res ) {
|
|
|
164
161
|
|
|
165
162
|
export async function duplicateTemplate( req, res ) {
|
|
166
163
|
try {
|
|
167
|
-
let templateDetails = await fixtureConfigService.findOne( { _id: req.body.templateId } );
|
|
164
|
+
let templateDetails = await fixtureConfigService.findOne( { _id: req.body.templateId }, { createdAt: 0, updatedAt: 0 } );
|
|
168
165
|
if ( !templateDetails ) {
|
|
169
166
|
return res.sendError( 'No data found', 204 );
|
|
170
167
|
}
|
|
@@ -282,12 +279,14 @@ export async function getTemplateList( req, res ) {
|
|
|
282
279
|
$group: {
|
|
283
280
|
_id: null,
|
|
284
281
|
planoId: { $addToSet: '$planoId' },
|
|
282
|
+
storeList: { $addToSet: '$storeName' },
|
|
285
283
|
},
|
|
286
284
|
},
|
|
287
285
|
{
|
|
288
286
|
$project: {
|
|
289
287
|
_id: 0,
|
|
290
288
|
planoId: 1,
|
|
289
|
+
storeList: 1,
|
|
291
290
|
},
|
|
292
291
|
},
|
|
293
292
|
],
|
|
@@ -301,6 +300,42 @@ export async function getTemplateList( req, res ) {
|
|
|
301
300
|
fixtureWidth: 1,
|
|
302
301
|
productBrandName: 1,
|
|
303
302
|
productCategory: 1,
|
|
303
|
+
shelfProduct: {
|
|
304
|
+
$reduce: {
|
|
305
|
+
input: '$shelfConfig',
|
|
306
|
+
initialValue: [],
|
|
307
|
+
in: {
|
|
308
|
+
$concatArrays: [
|
|
309
|
+
'$$value',
|
|
310
|
+
{ $ifNull: [ '$$this.productBrandName', [] ] },
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
shelfProductCategory: {
|
|
316
|
+
$reduce: {
|
|
317
|
+
input: '$shelfConfig',
|
|
318
|
+
initialValue: [],
|
|
319
|
+
in: {
|
|
320
|
+
$concatArrays: [
|
|
321
|
+
'$$value',
|
|
322
|
+
{ $ifNull: [ '$$this.productCategory', [] ] },
|
|
323
|
+
],
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
shelfProductSubCategory: {
|
|
328
|
+
$reduce: {
|
|
329
|
+
input: '$shelfConfig',
|
|
330
|
+
initialValue: [],
|
|
331
|
+
in: {
|
|
332
|
+
$concatArrays: [
|
|
333
|
+
'$$value',
|
|
334
|
+
{ $ifNull: [ '$$this.productSubCategory', [] ] },
|
|
335
|
+
],
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
},
|
|
304
339
|
clientId: 1,
|
|
305
340
|
productSubCategory: 1,
|
|
306
341
|
status: 1,
|
|
@@ -316,6 +351,7 @@ export async function getTemplateList( req, res ) {
|
|
|
316
351
|
},
|
|
317
352
|
},
|
|
318
353
|
planoId: { $ifNull: [ { $arrayElemAt: [ '$storeFixtureDetails.planoId', 0 ] }, [] ] },
|
|
354
|
+
storeList: { $ifNull: [ { $arrayElemAt: [ '$storeFixtureDetails.storeList', 0 ] }, [] ] },
|
|
319
355
|
},
|
|
320
356
|
},
|
|
321
357
|
{
|
|
@@ -345,16 +381,18 @@ export async function getTemplateList( req, res ) {
|
|
|
345
381
|
fixtureCategory: 1,
|
|
346
382
|
fixtureName: 1,
|
|
347
383
|
fixtureWidth: 1,
|
|
348
|
-
productBrandName:
|
|
349
|
-
productCategory:
|
|
384
|
+
productBrandName: { $concatArrays: [ '$productBrandName', '$shelfProduct' ] },
|
|
385
|
+
productCategory: { $concatArrays: [ '$productCategory', '$shelfProductCategory' ] },
|
|
350
386
|
clientId: 1,
|
|
351
387
|
fixtureType: 1,
|
|
352
|
-
productSubCategory:
|
|
388
|
+
productSubCategory: { $concatArrays: [ '$productSubCategory', '$shelfProductSubCategory' ] },
|
|
353
389
|
status: 1,
|
|
354
390
|
templateId: 1,
|
|
355
391
|
planoId: 1,
|
|
356
392
|
vmCapacity: 1,
|
|
357
393
|
productCapacity: 1,
|
|
394
|
+
storeList: 1,
|
|
395
|
+
storeCount: { $size: '$storeList' },
|
|
358
396
|
planoStatus: { $ifNull: [ { $arrayElemAt: [ '$planoStatus.statusList', 0 ] }, [] ] },
|
|
359
397
|
status: {
|
|
360
398
|
$cond: {
|
|
@@ -18,180 +18,103 @@ import mongoose from 'mongoose';
|
|
|
18
18
|
import * as planoRevisionService from '../service/planoRevision.service.js';
|
|
19
19
|
export async function getplanoFeedback( req, res ) {
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
$project: {
|
|
46
|
-
'userName': 1,
|
|
47
|
-
'createdAt': 1,
|
|
48
|
-
'createdByName': 1,
|
|
49
|
-
'submitTime_string': 1,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
as: 'taskData',
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
}, { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: true } },
|
|
57
|
-
{ $sort: { _id: -1 } },
|
|
21
|
+
const taskTypes = req.body.filterByTask && req.body.filterByTask.length > 0 ? req.body.filterByTask : [ 'layout', 'fixture', 'vm' ];
|
|
22
|
+
const filterByStatus = req.body.filterByStatus || [];
|
|
23
|
+
const filterByApprovalStatus = req.body.filterByApprovalStatus || [];
|
|
24
|
+
const resultMap = {};
|
|
25
|
+
const commentMap = {};
|
|
26
|
+
console.log( taskTypes );
|
|
27
|
+
await Promise.all(
|
|
28
|
+
taskTypes.map( async ( type, index ) => {
|
|
29
|
+
const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus );
|
|
30
|
+
|
|
31
|
+
const data = await planoTaskService.aggregate( pipeline );
|
|
32
|
+
console.log( '-------', data );
|
|
33
|
+
resultMap[type] = data;
|
|
34
|
+
|
|
35
|
+
const comments = await planoGlobalCommentService.find( {
|
|
36
|
+
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
37
|
+
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
38
|
+
taskType: type,
|
|
39
|
+
} );
|
|
40
|
+
commentMap[type] = comments;
|
|
41
|
+
} ),
|
|
58
42
|
);
|
|
59
43
|
|
|
44
|
+
const response = {
|
|
45
|
+
layoutData: resultMap['layout'] || [],
|
|
46
|
+
fixtureData: resultMap['fixture'] || [],
|
|
47
|
+
VmData: resultMap['vm'] || [],
|
|
48
|
+
layoutComment: commentMap['layout'] || [],
|
|
49
|
+
fixtureComment: commentMap['fixture'] || [],
|
|
50
|
+
vmComment: commentMap['vm'] || [],
|
|
51
|
+
};
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
res.sendSuccess( response );
|
|
54
|
+
} catch ( e ) {
|
|
55
|
+
logger.error( { functionName: 'getplanoFeedback', error: e, message: req.body } );
|
|
56
|
+
return res.sendError( e, 500 );
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByApprovalStatus ) {
|
|
60
|
+
console.log( type, planoId, floorId, filterByStatus );
|
|
61
|
+
const matchStage = {
|
|
62
|
+
$match: {
|
|
63
|
+
planoId: new mongoose.Types.ObjectId( planoId ),
|
|
64
|
+
floorId: new mongoose.Types.ObjectId( floorId ),
|
|
65
|
+
type: type,
|
|
66
|
+
...( filterByStatus?.length ? { status: { $in: filterByStatus } } : {} ),
|
|
71
67
|
},
|
|
72
|
-
|
|
73
|
-
$lookup: {
|
|
74
|
-
from: 'processedtasks',
|
|
75
|
-
let: { 'taskId': '$taskId' },
|
|
76
|
-
pipeline: [
|
|
77
|
-
{
|
|
78
|
-
$match: {
|
|
79
|
-
$expr: {
|
|
80
|
-
$and: [
|
|
81
|
-
{ $eq: [ '$_id', '$$taskId' ] },
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
$project: {
|
|
88
|
-
'userName': 1,
|
|
89
|
-
'createdAt': 1,
|
|
90
|
-
'createdByName': 1,
|
|
91
|
-
'submitTime_string': 1,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
as: 'taskData',
|
|
96
|
-
},
|
|
68
|
+
};
|
|
97
69
|
|
|
98
|
-
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
$
|
|
106
|
-
$
|
|
107
|
-
$
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
70
|
+
const taskLookup = {
|
|
71
|
+
$lookup: {
|
|
72
|
+
from: 'processedtasks',
|
|
73
|
+
let: { taskId: '$taskId' },
|
|
74
|
+
pipeline: [
|
|
75
|
+
{
|
|
76
|
+
$match: {
|
|
77
|
+
$expr: {
|
|
78
|
+
$and: [
|
|
79
|
+
{ $eq: [ '$_id', '$$taskId' ] },
|
|
80
|
+
{
|
|
81
|
+
$or: [
|
|
82
|
+
{ $eq: [ '$redoStatus', true ] },
|
|
83
|
+
{
|
|
84
|
+
$and: [
|
|
85
|
+
{ $eq: [ '$redoStatus', false ] },
|
|
86
|
+
{ $eq: [ '$checklistStatus', 'submit' ] },
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
111
92
|
},
|
|
112
93
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
$lookup: {
|
|
122
|
-
from: 'fixtureconfigs',
|
|
123
|
-
let: { 'fixtureConfigId': '$storeFixtureData.fixtureConfigId' },
|
|
124
|
-
pipeline: [
|
|
125
|
-
{
|
|
126
|
-
$match: {
|
|
127
|
-
$expr: {
|
|
128
|
-
$and: [
|
|
129
|
-
{ $eq: [ '$_id', '$$fixtureConfigId' ] },
|
|
130
|
-
],
|
|
131
|
-
},
|
|
132
|
-
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
$project: {
|
|
97
|
+
userName: 1,
|
|
98
|
+
createdAt: 1,
|
|
99
|
+
createdByName: 1,
|
|
100
|
+
submitTime_string: 1,
|
|
133
101
|
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
$unwind: { path: '$FixtureData', preserveNullAndEmptyArrays: true },
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
as: 'taskData',
|
|
140
105
|
},
|
|
141
|
-
|
|
106
|
+
};
|
|
142
107
|
|
|
108
|
+
const unwindTask = { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: false } };
|
|
143
109
|
|
|
144
|
-
|
|
145
|
-
let queryVm = [];
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
queryVm.push( {
|
|
149
|
-
$match: {
|
|
150
|
-
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
151
|
-
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
152
|
-
type: 'vm',
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
$lookup: {
|
|
157
|
-
from: 'processedtasks',
|
|
158
|
-
let: { 'taskId': '$taskId' },
|
|
159
|
-
pipeline: [
|
|
160
|
-
{
|
|
161
|
-
$match: {
|
|
162
|
-
$expr: {
|
|
163
|
-
$and: [
|
|
164
|
-
{ $eq: [ '$_id', '$$taskId' ] },
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
$project: {
|
|
171
|
-
'userName': 1,
|
|
172
|
-
'createdAt': 1,
|
|
173
|
-
'createdByName': 1,
|
|
174
|
-
'submitTime_string': 1,
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
as: 'taskData',
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
}, { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: true } },
|
|
110
|
+
const commonLookups = type === 'layout' ? [] : [
|
|
182
111
|
{
|
|
183
112
|
$lookup: {
|
|
184
113
|
from: 'storefixtures',
|
|
185
|
-
let: {
|
|
114
|
+
let: { fixtureId: '$fixtureId' },
|
|
186
115
|
pipeline: [
|
|
187
116
|
{
|
|
188
|
-
$match: {
|
|
189
|
-
$expr: {
|
|
190
|
-
$and: [
|
|
191
|
-
{ $eq: [ '$_id', '$$fixtureId' ] },
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
},
|
|
117
|
+
$match: { $expr: { $eq: [ '$_id', '$$fixtureId' ] } },
|
|
195
118
|
},
|
|
196
119
|
],
|
|
197
120
|
as: 'storeFixtureData',
|
|
@@ -203,16 +126,10 @@ export async function getplanoFeedback( req, res ) {
|
|
|
203
126
|
{
|
|
204
127
|
$lookup: {
|
|
205
128
|
from: 'fixtureconfigs',
|
|
206
|
-
let: {
|
|
129
|
+
let: { fixtureConfigId: '$storeFixtureData.fixtureConfigId' },
|
|
207
130
|
pipeline: [
|
|
208
131
|
{
|
|
209
|
-
$match: {
|
|
210
|
-
$expr: {
|
|
211
|
-
$and: [
|
|
212
|
-
{ $eq: [ '$_id', '$$fixtureConfigId' ] },
|
|
213
|
-
],
|
|
214
|
-
},
|
|
215
|
-
},
|
|
132
|
+
$match: { $expr: { $eq: [ '$_id', '$$fixtureConfigId' ] } },
|
|
216
133
|
},
|
|
217
134
|
],
|
|
218
135
|
as: 'FixtureData',
|
|
@@ -221,27 +138,22 @@ export async function getplanoFeedback( req, res ) {
|
|
|
221
138
|
{
|
|
222
139
|
$unwind: { path: '$FixtureData', preserveNullAndEmptyArrays: true },
|
|
223
140
|
},
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
const vmStages = type === 'vm' ? [
|
|
224
144
|
{
|
|
225
145
|
$unwind: { path: '$FixtureData.vmConfig', preserveNullAndEmptyArrays: true },
|
|
226
146
|
},
|
|
227
147
|
{
|
|
228
148
|
$lookup: {
|
|
229
149
|
from: 'planovmdetails',
|
|
230
|
-
let: {
|
|
150
|
+
let: { vmId: '$FixtureData.vmConfig.vmId' },
|
|
231
151
|
pipeline: [
|
|
232
152
|
{
|
|
233
|
-
$match: {
|
|
234
|
-
$expr: {
|
|
235
|
-
$and: [
|
|
236
|
-
{ $eq: [ '$_id', '$$vmId' ] },
|
|
237
|
-
],
|
|
238
|
-
},
|
|
239
|
-
},
|
|
153
|
+
$match: { $expr: { $eq: [ '$_id', '$$vmId' ] } },
|
|
240
154
|
},
|
|
241
155
|
{
|
|
242
|
-
$project: {
|
|
243
|
-
vmName: 1,
|
|
244
|
-
},
|
|
156
|
+
$project: { vmName: 1 },
|
|
245
157
|
},
|
|
246
158
|
],
|
|
247
159
|
as: 'vmDetails',
|
|
@@ -251,59 +163,10 @@ export async function getplanoFeedback( req, res ) {
|
|
|
251
163
|
$unwind: { path: '$vmDetails', preserveNullAndEmptyArrays: true },
|
|
252
164
|
},
|
|
253
165
|
{
|
|
254
|
-
$
|
|
255
|
-
'
|
|
256
|
-
'type': 1,
|
|
257
|
-
'type': 1,
|
|
258
|
-
'taskId': 1,
|
|
259
|
-
'taskData': 1,
|
|
260
|
-
'answers': 1,
|
|
261
|
-
'createdAt': 1,
|
|
262
|
-
'date_iso': 1,
|
|
263
|
-
'date_string': 1,
|
|
264
|
-
'fixtureId': 1,
|
|
265
|
-
'floorId': 1,
|
|
266
|
-
'planoId': 1,
|
|
267
|
-
'status': 1,
|
|
268
|
-
'taskType': 1,
|
|
269
|
-
'FixtureData': 1,
|
|
270
|
-
'FixtureData': {
|
|
271
|
-
_id: '$FixtureData._id',
|
|
272
|
-
clientId: '$FixtureData.clientId',
|
|
273
|
-
clientId: '$FixtureData.clientId',
|
|
274
|
-
fixtureCapacity: '$FixtureData.fixtureCapacity',
|
|
275
|
-
fixtureCategory: '$FixtureData.fixtureCategory',
|
|
276
|
-
fixtureLength: '$FixtureData.fixtureLength',
|
|
277
|
-
fixtureLibraryId: '$FixtureData.fixtureLibraryId',
|
|
278
|
-
fixtureName: '$FixtureData.fixtureName',
|
|
279
|
-
fixtureStaticLength: '$FixtureData.fixtureStaticLength',
|
|
280
|
-
fixtureStaticWidth: '$FixtureData.fixtureStaticWidth',
|
|
281
|
-
fixtureType: '$FixtureData.fixtureType',
|
|
282
|
-
fixtureWidth: '$FixtureData.fixtureWidth',
|
|
283
|
-
footer: '$FixtureData.footer',
|
|
284
|
-
header: '$FixtureData.header',
|
|
285
|
-
isBodyEnabled: '$FixtureData.isBodyEnabled',
|
|
286
|
-
productBrandName: '$FixtureData.productBrandName',
|
|
287
|
-
productCategory: '$FixtureData.productCategory',
|
|
288
|
-
productResolutionLevel: '$FixtureData.productResolutionLevel',
|
|
289
|
-
productSubCategory: '$FixtureData.productSubCategory',
|
|
290
|
-
shelfConfig: '$FixtureData.shelfConfig',
|
|
291
|
-
status: '$FixtureData.status',
|
|
292
|
-
templateIndex: '$FixtureData.templateIndex',
|
|
293
|
-
shelfConfig: '$FixtureData.shelfConfig',
|
|
294
|
-
vmConfig: {
|
|
295
|
-
vmName: '$vmDetails.vmName',
|
|
296
|
-
endYPosition: '$FixtureData.vmConfig.endYPosition',
|
|
297
|
-
startYPosition: '$FixtureData.vmConfig.startYPosition',
|
|
298
|
-
vmId: '$FixtureData.vmConfig.vmId',
|
|
299
|
-
xZone: '$FixtureData.vmConfig.xZone',
|
|
300
|
-
yZone: '$FixtureData.vmConfig.yZone',
|
|
301
|
-
position: '$FixtureData.vmConfig.position',
|
|
302
|
-
},
|
|
303
|
-
},
|
|
166
|
+
$set: {
|
|
167
|
+
'FixtureData.vmConfig.vmName': '$vmDetails.vmName',
|
|
304
168
|
},
|
|
305
169
|
},
|
|
306
|
-
|
|
307
170
|
{
|
|
308
171
|
$group: {
|
|
309
172
|
_id: '$_id',
|
|
@@ -332,20 +195,7 @@ export async function getplanoFeedback( req, res ) {
|
|
|
332
195
|
},
|
|
333
196
|
},
|
|
334
197
|
{
|
|
335
|
-
$
|
|
336
|
-
_id: 1,
|
|
337
|
-
answers: 1,
|
|
338
|
-
createdAt: 1,
|
|
339
|
-
date_iso: 1,
|
|
340
|
-
date_string: 1,
|
|
341
|
-
fixtureId: 1,
|
|
342
|
-
floorId: 1,
|
|
343
|
-
planoId: 1,
|
|
344
|
-
status: 1,
|
|
345
|
-
taskType: 1,
|
|
346
|
-
type: 1,
|
|
347
|
-
taskId: 1,
|
|
348
|
-
taskData: 1,
|
|
198
|
+
$set: {
|
|
349
199
|
FixtureData: {
|
|
350
200
|
$mergeObjects: [
|
|
351
201
|
'$baseFixtureData',
|
|
@@ -368,39 +218,114 @@ export async function getplanoFeedback( req, res ) {
|
|
|
368
218
|
},
|
|
369
219
|
},
|
|
370
220
|
},
|
|
371
|
-
|
|
372
|
-
$sort: { _id: -1 },
|
|
373
|
-
},
|
|
374
|
-
|
|
221
|
+
] : [];
|
|
375
222
|
|
|
376
|
-
);
|
|
377
223
|
|
|
224
|
+
let pipeline = [
|
|
225
|
+
matchStage,
|
|
226
|
+
taskLookup,
|
|
227
|
+
unwindTask,
|
|
228
|
+
...commonLookups,
|
|
229
|
+
...vmStages,
|
|
230
|
+
{ $sort: { _id: -1 } },
|
|
231
|
+
];
|
|
232
|
+
if ( filterByApprovalStatus && filterByApprovalStatus != '' ) {
|
|
233
|
+
let filterByApprovalCond = { $eq: filterByApprovalStatus };
|
|
234
|
+
if ( filterByApprovalStatus != 'pending' ) {
|
|
235
|
+
filterByApprovalCond = { $ne: 'pending' };
|
|
236
|
+
}
|
|
237
|
+
console.log( '*********************' );
|
|
238
|
+
pipeline = [];
|
|
239
|
+
pipeline.push( matchStage );
|
|
240
|
+
pipeline.push(
|
|
241
|
+
{ $unwind: '$answers' },
|
|
242
|
+
{ $unwind: '$answers.issues' },
|
|
243
|
+
{ $unwind: '$answers.issues.Details' },
|
|
244
|
+
{
|
|
245
|
+
$match: {
|
|
246
|
+
'answers.issues.Details.status': filterByApprovalCond,
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
$group: {
|
|
251
|
+
_id: '$_id',
|
|
252
|
+
doc: { $first: '$$ROOT' },
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
$replaceRoot: {
|
|
257
|
+
newRoot: {
|
|
258
|
+
$mergeObjects: [ '$doc', { answers: '$doc.originalAnswers' } ],
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
$project: {
|
|
264
|
+
originalAnswers: 0, // remove the temp field
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
$addFields: {
|
|
269
|
+
answers: {
|
|
270
|
+
$map: {
|
|
271
|
+
input: {
|
|
272
|
+
$cond: [
|
|
273
|
+
{ $isArray: '$answers' },
|
|
274
|
+
'$answers',
|
|
275
|
+
{ $cond: [ { $gt: [ { $type: '$answers' }, 'missing' ] }, [ '$answers' ], [] ] },
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
as: 'ans',
|
|
279
|
+
in: {
|
|
280
|
+
$mergeObjects: [
|
|
281
|
+
'$$ans',
|
|
282
|
+
{
|
|
283
|
+
issues: {
|
|
284
|
+
$map: {
|
|
285
|
+
input: {
|
|
286
|
+
$cond: [
|
|
287
|
+
{ $isArray: '$$ans.issues' },
|
|
288
|
+
'$$ans.issues',
|
|
289
|
+
{ $cond: [ { $gt: [ { $type: '$$ans.issues' }, 'missing' ] }, [ '$$ans.issues' ], [] ] },
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
as: 'issue',
|
|
293
|
+
in: {
|
|
294
|
+
$mergeObjects: [
|
|
295
|
+
'$$issue',
|
|
296
|
+
{
|
|
297
|
+
Details: {
|
|
298
|
+
$cond: [
|
|
299
|
+
{ $isArray: '$$issue.Details' },
|
|
300
|
+
'$$issue.Details',
|
|
301
|
+
{ $cond: [ { $gt: [ { $type: '$$issue.Details' }, 'missing' ] }, [ '$$issue.Details' ], [] ] },
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
},
|
|
378
316
|
|
|
379
|
-
let findvmCompliance = await planoTaskService.aggregate( queryVm );
|
|
380
317
|
|
|
318
|
+
);
|
|
319
|
+
pipeline.push( taskLookup );
|
|
320
|
+
pipeline.push( unwindTask );
|
|
321
|
+
pipeline.push( ...commonLookups );
|
|
322
|
+
pipeline.push( ...vmStages );
|
|
323
|
+
}
|
|
381
324
|
|
|
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
325
|
|
|
398
|
-
|
|
399
|
-
} catch ( e ) {
|
|
400
|
-
logger.error( { functionName: 'getplanoFeedback', error: e, message: req.body } );
|
|
401
|
-
return res.sendError( e, 500 );
|
|
402
|
-
}
|
|
326
|
+
return pipeline;
|
|
403
327
|
}
|
|
328
|
+
|
|
404
329
|
export async function getStoreFixturesfeedback( req, res ) {
|
|
405
330
|
try {
|
|
406
331
|
let query = [];
|
|
@@ -671,6 +596,18 @@ export async function updateFixtureStatus( req, res ) {
|
|
|
671
596
|
'status': 'complete',
|
|
672
597
|
},
|
|
673
598
|
);
|
|
599
|
+
if ( req.body.taskType === 'layout' ) {
|
|
600
|
+
await planoTaskService.updateMany(
|
|
601
|
+
{
|
|
602
|
+
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
603
|
+
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
604
|
+
type: 'layout',
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
'status': 'complete',
|
|
608
|
+
},
|
|
609
|
+
);
|
|
610
|
+
}
|
|
674
611
|
}
|
|
675
612
|
}
|
|
676
613
|
|