tango-app-api-store-builder 1.0.0-beta-135 → 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
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
|
}
|
|
@@ -18,182 +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
|
-
{ $eq: [ '$checklistStatus', 'submit' ] },
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
$project: {
|
|
89
|
-
'userName': 1,
|
|
90
|
-
'createdAt': 1,
|
|
91
|
-
'createdByName': 1,
|
|
92
|
-
'submitTime_string': 1,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
as: 'taskData',
|
|
97
|
-
},
|
|
68
|
+
};
|
|
98
69
|
|
|
99
|
-
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
$
|
|
107
|
-
$
|
|
108
|
-
$
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
],
|
|
112
92
|
},
|
|
113
93
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
{
|
|
122
|
-
$lookup: {
|
|
123
|
-
from: 'fixtureconfigs',
|
|
124
|
-
let: { 'fixtureConfigId': '$storeFixtureData.fixtureConfigId' },
|
|
125
|
-
pipeline: [
|
|
126
|
-
{
|
|
127
|
-
$match: {
|
|
128
|
-
$expr: {
|
|
129
|
-
$and: [
|
|
130
|
-
{ $eq: [ '$_id', '$$fixtureConfigId' ] },
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
$project: {
|
|
97
|
+
userName: 1,
|
|
98
|
+
createdAt: 1,
|
|
99
|
+
createdByName: 1,
|
|
100
|
+
submitTime_string: 1,
|
|
134
101
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
$unwind: { path: '$FixtureData', preserveNullAndEmptyArrays: true },
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
as: 'taskData',
|
|
141
105
|
},
|
|
142
|
-
|
|
143
|
-
|
|
106
|
+
};
|
|
144
107
|
|
|
145
|
-
|
|
146
|
-
let queryVm = [];
|
|
108
|
+
const unwindTask = { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: false } };
|
|
147
109
|
|
|
148
|
-
|
|
149
|
-
queryVm.push( {
|
|
150
|
-
$match: {
|
|
151
|
-
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
152
|
-
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
153
|
-
type: 'vm',
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
$lookup: {
|
|
158
|
-
from: 'processedtasks',
|
|
159
|
-
let: { 'taskId': '$taskId' },
|
|
160
|
-
pipeline: [
|
|
161
|
-
{
|
|
162
|
-
$match: {
|
|
163
|
-
$expr: {
|
|
164
|
-
$and: [
|
|
165
|
-
{ $eq: [ '$_id', '$$taskId' ] },
|
|
166
|
-
{ $eq: [ '$checklistStatus', 'submit' ] },
|
|
167
|
-
],
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
$project: {
|
|
173
|
-
'userName': 1,
|
|
174
|
-
'createdAt': 1,
|
|
175
|
-
'createdByName': 1,
|
|
176
|
-
'submitTime_string': 1,
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
as: 'taskData',
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
}, { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: false } },
|
|
110
|
+
const commonLookups = type === 'layout' ? [] : [
|
|
184
111
|
{
|
|
185
112
|
$lookup: {
|
|
186
113
|
from: 'storefixtures',
|
|
187
|
-
let: {
|
|
114
|
+
let: { fixtureId: '$fixtureId' },
|
|
188
115
|
pipeline: [
|
|
189
116
|
{
|
|
190
|
-
$match: {
|
|
191
|
-
$expr: {
|
|
192
|
-
$and: [
|
|
193
|
-
{ $eq: [ '$_id', '$$fixtureId' ] },
|
|
194
|
-
],
|
|
195
|
-
},
|
|
196
|
-
},
|
|
117
|
+
$match: { $expr: { $eq: [ '$_id', '$$fixtureId' ] } },
|
|
197
118
|
},
|
|
198
119
|
],
|
|
199
120
|
as: 'storeFixtureData',
|
|
@@ -205,16 +126,10 @@ export async function getplanoFeedback( req, res ) {
|
|
|
205
126
|
{
|
|
206
127
|
$lookup: {
|
|
207
128
|
from: 'fixtureconfigs',
|
|
208
|
-
let: {
|
|
129
|
+
let: { fixtureConfigId: '$storeFixtureData.fixtureConfigId' },
|
|
209
130
|
pipeline: [
|
|
210
131
|
{
|
|
211
|
-
$match: {
|
|
212
|
-
$expr: {
|
|
213
|
-
$and: [
|
|
214
|
-
{ $eq: [ '$_id', '$$fixtureConfigId' ] },
|
|
215
|
-
],
|
|
216
|
-
},
|
|
217
|
-
},
|
|
132
|
+
$match: { $expr: { $eq: [ '$_id', '$$fixtureConfigId' ] } },
|
|
218
133
|
},
|
|
219
134
|
],
|
|
220
135
|
as: 'FixtureData',
|
|
@@ -223,27 +138,22 @@ export async function getplanoFeedback( req, res ) {
|
|
|
223
138
|
{
|
|
224
139
|
$unwind: { path: '$FixtureData', preserveNullAndEmptyArrays: true },
|
|
225
140
|
},
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
const vmStages = type === 'vm' ? [
|
|
226
144
|
{
|
|
227
145
|
$unwind: { path: '$FixtureData.vmConfig', preserveNullAndEmptyArrays: true },
|
|
228
146
|
},
|
|
229
147
|
{
|
|
230
148
|
$lookup: {
|
|
231
149
|
from: 'planovmdetails',
|
|
232
|
-
let: {
|
|
150
|
+
let: { vmId: '$FixtureData.vmConfig.vmId' },
|
|
233
151
|
pipeline: [
|
|
234
152
|
{
|
|
235
|
-
$match: {
|
|
236
|
-
$expr: {
|
|
237
|
-
$and: [
|
|
238
|
-
{ $eq: [ '$_id', '$$vmId' ] },
|
|
239
|
-
],
|
|
240
|
-
},
|
|
241
|
-
},
|
|
153
|
+
$match: { $expr: { $eq: [ '$_id', '$$vmId' ] } },
|
|
242
154
|
},
|
|
243
155
|
{
|
|
244
|
-
$project: {
|
|
245
|
-
vmName: 1,
|
|
246
|
-
},
|
|
156
|
+
$project: { vmName: 1 },
|
|
247
157
|
},
|
|
248
158
|
],
|
|
249
159
|
as: 'vmDetails',
|
|
@@ -253,59 +163,10 @@ export async function getplanoFeedback( req, res ) {
|
|
|
253
163
|
$unwind: { path: '$vmDetails', preserveNullAndEmptyArrays: true },
|
|
254
164
|
},
|
|
255
165
|
{
|
|
256
|
-
$
|
|
257
|
-
'
|
|
258
|
-
'type': 1,
|
|
259
|
-
'type': 1,
|
|
260
|
-
'taskId': 1,
|
|
261
|
-
'taskData': 1,
|
|
262
|
-
'answers': 1,
|
|
263
|
-
'createdAt': 1,
|
|
264
|
-
'date_iso': 1,
|
|
265
|
-
'date_string': 1,
|
|
266
|
-
'fixtureId': 1,
|
|
267
|
-
'floorId': 1,
|
|
268
|
-
'planoId': 1,
|
|
269
|
-
'status': 1,
|
|
270
|
-
'taskType': 1,
|
|
271
|
-
'FixtureData': 1,
|
|
272
|
-
'FixtureData': {
|
|
273
|
-
_id: '$FixtureData._id',
|
|
274
|
-
clientId: '$FixtureData.clientId',
|
|
275
|
-
clientId: '$FixtureData.clientId',
|
|
276
|
-
fixtureCapacity: '$FixtureData.fixtureCapacity',
|
|
277
|
-
fixtureCategory: '$FixtureData.fixtureCategory',
|
|
278
|
-
fixtureLength: '$FixtureData.fixtureLength',
|
|
279
|
-
fixtureLibraryId: '$FixtureData.fixtureLibraryId',
|
|
280
|
-
fixtureName: '$FixtureData.fixtureName',
|
|
281
|
-
fixtureStaticLength: '$FixtureData.fixtureStaticLength',
|
|
282
|
-
fixtureStaticWidth: '$FixtureData.fixtureStaticWidth',
|
|
283
|
-
fixtureType: '$FixtureData.fixtureType',
|
|
284
|
-
fixtureWidth: '$FixtureData.fixtureWidth',
|
|
285
|
-
footer: '$FixtureData.footer',
|
|
286
|
-
header: '$FixtureData.header',
|
|
287
|
-
isBodyEnabled: '$FixtureData.isBodyEnabled',
|
|
288
|
-
productBrandName: '$FixtureData.productBrandName',
|
|
289
|
-
productCategory: '$FixtureData.productCategory',
|
|
290
|
-
productResolutionLevel: '$FixtureData.productResolutionLevel',
|
|
291
|
-
productSubCategory: '$FixtureData.productSubCategory',
|
|
292
|
-
shelfConfig: '$FixtureData.shelfConfig',
|
|
293
|
-
status: '$FixtureData.status',
|
|
294
|
-
templateIndex: '$FixtureData.templateIndex',
|
|
295
|
-
shelfConfig: '$FixtureData.shelfConfig',
|
|
296
|
-
vmConfig: {
|
|
297
|
-
vmName: '$vmDetails.vmName',
|
|
298
|
-
endYPosition: '$FixtureData.vmConfig.endYPosition',
|
|
299
|
-
startYPosition: '$FixtureData.vmConfig.startYPosition',
|
|
300
|
-
vmId: '$FixtureData.vmConfig.vmId',
|
|
301
|
-
xZone: '$FixtureData.vmConfig.xZone',
|
|
302
|
-
yZone: '$FixtureData.vmConfig.yZone',
|
|
303
|
-
position: '$FixtureData.vmConfig.position',
|
|
304
|
-
},
|
|
305
|
-
},
|
|
166
|
+
$set: {
|
|
167
|
+
'FixtureData.vmConfig.vmName': '$vmDetails.vmName',
|
|
306
168
|
},
|
|
307
169
|
},
|
|
308
|
-
|
|
309
170
|
{
|
|
310
171
|
$group: {
|
|
311
172
|
_id: '$_id',
|
|
@@ -334,20 +195,7 @@ export async function getplanoFeedback( req, res ) {
|
|
|
334
195
|
},
|
|
335
196
|
},
|
|
336
197
|
{
|
|
337
|
-
$
|
|
338
|
-
_id: 1,
|
|
339
|
-
answers: 1,
|
|
340
|
-
createdAt: 1,
|
|
341
|
-
date_iso: 1,
|
|
342
|
-
date_string: 1,
|
|
343
|
-
fixtureId: 1,
|
|
344
|
-
floorId: 1,
|
|
345
|
-
planoId: 1,
|
|
346
|
-
status: 1,
|
|
347
|
-
taskType: 1,
|
|
348
|
-
type: 1,
|
|
349
|
-
taskId: 1,
|
|
350
|
-
taskData: 1,
|
|
198
|
+
$set: {
|
|
351
199
|
FixtureData: {
|
|
352
200
|
$mergeObjects: [
|
|
353
201
|
'$baseFixtureData',
|
|
@@ -370,39 +218,114 @@ export async function getplanoFeedback( req, res ) {
|
|
|
370
218
|
},
|
|
371
219
|
},
|
|
372
220
|
},
|
|
373
|
-
|
|
374
|
-
$sort: { _id: -1 },
|
|
375
|
-
},
|
|
221
|
+
] : [];
|
|
376
222
|
|
|
377
223
|
|
|
378
|
-
|
|
379
|
-
|
|
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
|
+
},
|
|
380
316
|
|
|
381
|
-
let findvmCompliance = await planoTaskService.aggregate( queryVm );
|
|
382
317
|
|
|
318
|
+
);
|
|
319
|
+
pipeline.push( taskLookup );
|
|
320
|
+
pipeline.push( unwindTask );
|
|
321
|
+
pipeline.push( ...commonLookups );
|
|
322
|
+
pipeline.push( ...vmStages );
|
|
323
|
+
}
|
|
383
324
|
|
|
384
|
-
let layoutComment = await planoGlobalCommentService.find( {
|
|
385
|
-
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
386
|
-
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
387
|
-
taskType: 'layout',
|
|
388
|
-
} );
|
|
389
|
-
let fixtureComment = await planoGlobalCommentService.find( {
|
|
390
|
-
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
391
|
-
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
392
|
-
taskType: 'fixture',
|
|
393
|
-
} );
|
|
394
|
-
let vmComment = await planoGlobalCommentService.find( {
|
|
395
|
-
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
396
|
-
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
397
|
-
taskType: 'vm',
|
|
398
|
-
} );
|
|
399
325
|
|
|
400
|
-
|
|
401
|
-
} catch ( e ) {
|
|
402
|
-
logger.error( { functionName: 'getplanoFeedback', error: e, message: req.body } );
|
|
403
|
-
return res.sendError( e, 500 );
|
|
404
|
-
}
|
|
326
|
+
return pipeline;
|
|
405
327
|
}
|
|
328
|
+
|
|
406
329
|
export async function getStoreFixturesfeedback( req, res ) {
|
|
407
330
|
try {
|
|
408
331
|
let query = [];
|
|
@@ -673,7 +596,7 @@ export async function updateFixtureStatus( req, res ) {
|
|
|
673
596
|
'status': 'complete',
|
|
674
597
|
},
|
|
675
598
|
);
|
|
676
|
-
if ( req.body.taskType==='layout' ) {
|
|
599
|
+
if ( req.body.taskType === 'layout' ) {
|
|
677
600
|
await planoTaskService.updateMany(
|
|
678
601
|
{
|
|
679
602
|
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
@@ -3311,6 +3311,15 @@ export async function planoList( req, res ) {
|
|
|
3311
3311
|
date: '$dateString',
|
|
3312
3312
|
floorId: '$_id.floorId',
|
|
3313
3313
|
endTime: '$scheduleEndTime_iso',
|
|
3314
|
+
breach: {
|
|
3315
|
+
$cond: {
|
|
3316
|
+
if: {
|
|
3317
|
+
$gte: [ '$scheduleEndTime_iso', new Date() ],
|
|
3318
|
+
},
|
|
3319
|
+
then: false,
|
|
3320
|
+
else: true,
|
|
3321
|
+
},
|
|
3322
|
+
},
|
|
3314
3323
|
},
|
|
3315
3324
|
},
|
|
3316
3325
|
taskIds: { $push: '$taskId' },
|
|
@@ -3568,46 +3577,29 @@ export async function planoList( req, res ) {
|
|
|
3568
3577
|
} );
|
|
3569
3578
|
}
|
|
3570
3579
|
if ( inputData?.filter?.taskPending?.length && inputData?.filter?.taskPending !== 'all' ) {
|
|
3571
|
-
let andQuery = [
|
|
3580
|
+
let andQuery = [ {
|
|
3581
|
+
'planoTask.taskStatus': {
|
|
3582
|
+
$elemMatch: {
|
|
3583
|
+
type: inputData.filter.taskPending,
|
|
3584
|
+
status: 'submit',
|
|
3585
|
+
},
|
|
3586
|
+
},
|
|
3587
|
+
} ];
|
|
3572
3588
|
|
|
3573
3589
|
if ( inputData.filter.taskPending === 'layout' ) {
|
|
3574
3590
|
andQuery.push(
|
|
3575
|
-
{
|
|
3576
|
-
'planoTask.taskStatus': {
|
|
3577
|
-
$elemMatch: {
|
|
3578
|
-
type: 'layout',
|
|
3579
|
-
status: 'submit',
|
|
3580
|
-
},
|
|
3581
|
-
},
|
|
3582
|
-
},
|
|
3583
3591
|
{ 'taskDetails.layoutStatus': 'pending' },
|
|
3584
3592
|
);
|
|
3585
3593
|
}
|
|
3586
3594
|
|
|
3587
3595
|
if ( inputData.filter.taskPending === 'fixture' ) {
|
|
3588
3596
|
andQuery.push(
|
|
3589
|
-
{
|
|
3590
|
-
'planoTask.taskStatus': {
|
|
3591
|
-
$elemMatch: {
|
|
3592
|
-
type: 'fixture',
|
|
3593
|
-
status: 'submit',
|
|
3594
|
-
},
|
|
3595
|
-
},
|
|
3596
|
-
},
|
|
3597
3597
|
{ 'taskDetails.fixtureStatus': 'pending' },
|
|
3598
3598
|
);
|
|
3599
3599
|
}
|
|
3600
3600
|
|
|
3601
3601
|
if ( inputData.filter.taskPending === 'vm' ) {
|
|
3602
3602
|
andQuery.push(
|
|
3603
|
-
{
|
|
3604
|
-
'planoTask.taskStatus': {
|
|
3605
|
-
$elemMatch: {
|
|
3606
|
-
type: 'vm',
|
|
3607
|
-
status: 'submit',
|
|
3608
|
-
},
|
|
3609
|
-
},
|
|
3610
|
-
},
|
|
3611
3603
|
{ 'taskDetails.vmStatus': 'pending' },
|
|
3612
3604
|
);
|
|
3613
3605
|
}
|
|
@@ -3619,6 +3611,27 @@ export async function planoList( req, res ) {
|
|
|
3619
3611
|
} );
|
|
3620
3612
|
}
|
|
3621
3613
|
|
|
3614
|
+
if ( inputData?.filter?.flag?.length ) {
|
|
3615
|
+
let andQuery = [];
|
|
3616
|
+
andQuery.push(
|
|
3617
|
+
{
|
|
3618
|
+
'planoTask.taskStatus': {
|
|
3619
|
+
$elemMatch: {
|
|
3620
|
+
type: { $in: inputData.filter.flag },
|
|
3621
|
+
status: { $ne: 'submit' },
|
|
3622
|
+
breach: true,
|
|
3623
|
+
},
|
|
3624
|
+
},
|
|
3625
|
+
},
|
|
3626
|
+
{ 'taskDetails.layoutStatus': 'pending' },
|
|
3627
|
+
);
|
|
3628
|
+
query.push( {
|
|
3629
|
+
$match: {
|
|
3630
|
+
$and: andQuery,
|
|
3631
|
+
},
|
|
3632
|
+
} );
|
|
3633
|
+
}
|
|
3634
|
+
|
|
3622
3635
|
let orQuery = [];
|
|
3623
3636
|
|
|
3624
3637
|
if ( inputData.filter.status.length ) {
|
|
@@ -3873,6 +3886,15 @@ export async function getTaskDetails( req, res ) {
|
|
|
3873
3886
|
floorId: '$_id.floorId',
|
|
3874
3887
|
redoStatus: '$redoStatus',
|
|
3875
3888
|
endTime: '$scheduleEndTime_iso',
|
|
3889
|
+
breach: {
|
|
3890
|
+
$cond: {
|
|
3891
|
+
if: {
|
|
3892
|
+
$gte: [ '$scheduleEndTime_iso', new Date() ],
|
|
3893
|
+
},
|
|
3894
|
+
then: false,
|
|
3895
|
+
else: true,
|
|
3896
|
+
},
|
|
3897
|
+
},
|
|
3876
3898
|
},
|
|
3877
3899
|
},
|
|
3878
3900
|
taskIds: { $push: '$taskId' },
|
|
@@ -4124,6 +4146,7 @@ export async function getTaskDetails( req, res ) {
|
|
|
4124
4146
|
floorId: '$$task.floorId',
|
|
4125
4147
|
redoStatus: '$$task.redoStatus',
|
|
4126
4148
|
endTime: '$$task.endTime',
|
|
4149
|
+
breach: '$$task.breach',
|
|
4127
4150
|
feedbackStatus: {
|
|
4128
4151
|
$switch: {
|
|
4129
4152
|
branches: [
|
|
@@ -4152,7 +4175,8 @@ export async function getTaskDetails( req, res ) {
|
|
|
4152
4175
|
];
|
|
4153
4176
|
|
|
4154
4177
|
let taskInfo = await planotaskService.aggregate( query );
|
|
4155
|
-
let disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ele.feedbackStatus != 'complete' ) || ele.status != 'submit' ) &&
|
|
4178
|
+
let disabledInfo = taskInfo?.[0]?.taskStatus?.filter( ( ele ) => ( ( ele.feedbackStatus && ele.feedbackStatus != 'complete' ) || ele.status != 'submit' ) && !ele?.breach );
|
|
4179
|
+
console.log( disabledInfo );
|
|
4156
4180
|
return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus, disabled: disabledInfo?.length ? true : false } );
|
|
4157
4181
|
} catch ( e ) {
|
|
4158
4182
|
logger.error( { functionName: 'getTaskDetails', error: e } );
|