tango-app-api-store-builder 1.0.0-beta-167 → 1.0.0-beta-169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-store-builder",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-169",
|
|
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.204",
|
|
36
36
|
"tango-app-api-middleware": "3.1.48",
|
|
37
37
|
"url": "^0.11.4",
|
|
38
38
|
"winston": "^3.17.0",
|
|
@@ -22,10 +22,6 @@ export async function createTemplate( req, res ) {
|
|
|
22
22
|
if ( !getLibDetails ) {
|
|
23
23
|
return res.sendError( 'Fixture library id is wrong', 400 );
|
|
24
24
|
}
|
|
25
|
-
let fixtureCapacity = getLibDetails.shelfConfig.reduce(
|
|
26
|
-
( acc, ele ) => ele.trayRows ? acc + ( ele.trayRows * ele.productPerShelf ) : ( acc + ele.productPerShelf ),
|
|
27
|
-
0,
|
|
28
|
-
);
|
|
29
25
|
let templateId = await getTemplateId( getLibDetails.fixtureCategory, getLibDetails.fixtureWidth );
|
|
30
26
|
let templateData = {
|
|
31
27
|
clientId: inputData.clientId,
|
|
@@ -40,7 +36,7 @@ export async function createTemplate( req, res ) {
|
|
|
40
36
|
header: getLibDetails.header,
|
|
41
37
|
footer: getLibDetails.footer,
|
|
42
38
|
isBodyEnabled: getLibDetails.isBodyEnabled,
|
|
43
|
-
fixtureCapacity: fixtureCapacity,
|
|
39
|
+
fixtureCapacity: getLibDetails.fixtureCapacity,
|
|
44
40
|
fixtureStaticLength: {
|
|
45
41
|
value: 1524,
|
|
46
42
|
unit: 'mm',
|
|
@@ -84,21 +80,12 @@ export async function updateTemplate( req, res ) {
|
|
|
84
80
|
let templateData = { ...templateDetails, ...inputData };
|
|
85
81
|
newFixture = await fixtureConfigService.create( templateData );
|
|
86
82
|
}
|
|
87
|
-
let fixtureCapacity = inputData.shelfConfig.reduce( ( acc, ele ) => {
|
|
88
|
-
if ( ele.shelfType == 'tray' ) {
|
|
89
|
-
ele.productPerShelf = ele.trayRows * ele.productPerShelf;
|
|
90
|
-
}
|
|
91
|
-
acc = acc + ele.productPerShelf;
|
|
92
|
-
return acc;
|
|
93
|
-
},
|
|
94
|
-
0 );
|
|
95
83
|
|
|
96
84
|
let storeFixtureDetails = await storeFixtureService.find( { fixtureConfigId: req.params.templateId } );
|
|
97
85
|
if ( storeFixtureDetails.length ) {
|
|
98
86
|
let fixtureList = storeFixtureDetails.map( ( ele ) => ele._id );
|
|
99
87
|
let fixtureData = {
|
|
100
88
|
...inputData,
|
|
101
|
-
fixtureCapacity: fixtureCapacity,
|
|
102
89
|
fixtureConfigId: newFixture ? newFixture._id : req.params.templateId,
|
|
103
90
|
};
|
|
104
91
|
delete fixtureData._id;
|
|
@@ -109,8 +96,8 @@ export async function updateTemplate( req, res ) {
|
|
|
109
96
|
let shelfData = [];
|
|
110
97
|
inputData.shelfConfig.forEach( ( ele, index ) => {
|
|
111
98
|
shelfData.push( {
|
|
112
|
-
productCategory:
|
|
113
|
-
productSubCategory:
|
|
99
|
+
productCategory: ele.productCategory,
|
|
100
|
+
productSubCategory: ele.productSubCategory,
|
|
114
101
|
shelfType: ele.shelfType,
|
|
115
102
|
trayRows: ele.trayRows,
|
|
116
103
|
shelfNumber: index + 1,
|
|
@@ -533,7 +520,42 @@ export async function getAllTemplates( req, res ) {
|
|
|
533
520
|
return res.sendError( 'Client Id is required', 400 );
|
|
534
521
|
}
|
|
535
522
|
|
|
536
|
-
const
|
|
523
|
+
const query = [
|
|
524
|
+
{
|
|
525
|
+
$match: {
|
|
526
|
+
clientId: req.body.clientId,
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
$project: {
|
|
531
|
+
'fixtureName': 1,
|
|
532
|
+
'fixtureWidth': 1,
|
|
533
|
+
'productBrandName': {
|
|
534
|
+
$cond: {
|
|
535
|
+
if: { $eq: [ '$productResolutionLevel', 'L1' ] },
|
|
536
|
+
then: '$productBrandName',
|
|
537
|
+
else: {
|
|
538
|
+
$reduce: {
|
|
539
|
+
input: {
|
|
540
|
+
$map: {
|
|
541
|
+
input: '$shelfConfig',
|
|
542
|
+
as: 'shelf',
|
|
543
|
+
in: '$$shelf.productBrandName',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
initialValue: [],
|
|
547
|
+
in: {
|
|
548
|
+
$setUnion: [ '$$value', '$$this' ],
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
];
|
|
557
|
+
|
|
558
|
+
const fixtureTemplates = await fixtureConfigService.aggregate( query );
|
|
537
559
|
|
|
538
560
|
res.sendSuccess( fixtureTemplates );
|
|
539
561
|
} catch ( e ) {
|
|
@@ -145,26 +145,29 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
145
145
|
$match: { $expr: { $eq: [ '$_id', '$$fixtureId' ] } },
|
|
146
146
|
},
|
|
147
147
|
],
|
|
148
|
-
as: '
|
|
148
|
+
as: 'FixtureData',
|
|
149
149
|
},
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
|
-
$unwind: { path: '$
|
|
152
|
+
$unwind: { path: '$FixtureData', preserveNullAndEmptyArrays: true },
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
155
|
$lookup: {
|
|
156
|
-
from: '
|
|
157
|
-
let: {
|
|
156
|
+
from: 'fixtureshelves',
|
|
157
|
+
let: { fixtureId: '$FixtureData._id' },
|
|
158
158
|
pipeline: [
|
|
159
159
|
{
|
|
160
|
-
$match: { $expr: { $eq: [ '$
|
|
160
|
+
$match: { $expr: { $eq: [ '$fixtureId', '$$fixtureId' ] } },
|
|
161
161
|
},
|
|
162
162
|
],
|
|
163
|
-
as: '
|
|
163
|
+
as: 'Fixtureshelves',
|
|
164
164
|
},
|
|
165
165
|
},
|
|
166
|
+
|
|
166
167
|
{
|
|
167
|
-
$
|
|
168
|
+
$set: {
|
|
169
|
+
'FixtureData.shelfConfig': '$Fixtureshelves',
|
|
170
|
+
},
|
|
168
171
|
},
|
|
169
172
|
];
|
|
170
173
|
|
|
@@ -2658,7 +2658,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2658
2658
|
planograms.map( async ( planogram ) => {
|
|
2659
2659
|
const floors = await storeBuilderService.find(
|
|
2660
2660
|
{ planoId: planogram._id },
|
|
2661
|
-
{ floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1 },
|
|
2661
|
+
{ floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress:1, },
|
|
2662
2662
|
);
|
|
2663
2663
|
|
|
2664
2664
|
const floorsWithFixtures = await Promise.all(
|
|
@@ -3308,6 +3308,7 @@ export async function planoList( req, res ) {
|
|
|
3308
3308
|
{
|
|
3309
3309
|
$lte: [ '$date_iso', new Date( dayjs().format( 'YYYY-MM-DD' ) ) ],
|
|
3310
3310
|
},
|
|
3311
|
+
{ $in: [ '$planoType', [ 'layout', 'fixture', 'vm' ] ] },
|
|
3311
3312
|
],
|
|
3312
3313
|
},
|
|
3313
3314
|
},
|
|
@@ -3362,6 +3363,7 @@ export async function planoList( req, res ) {
|
|
|
3362
3363
|
$and: [
|
|
3363
3364
|
{ $eq: [ '$floorId', '$$floor' ] },
|
|
3364
3365
|
{ $eq: [ '$status', 'incomplete' ] },
|
|
3366
|
+
{ $in: [ '$type', [ 'layout', 'fixture', 'vm' ] ] },
|
|
3365
3367
|
],
|
|
3366
3368
|
},
|
|
3367
3369
|
},
|
|
@@ -3810,7 +3812,22 @@ export async function planoList( req, res ) {
|
|
|
3810
3812
|
} );
|
|
3811
3813
|
}
|
|
3812
3814
|
if ( inputData.filter.status.includes( 'completed' ) ) {
|
|
3813
|
-
|
|
3815
|
+
let taskType= [ 'layout', 'fixture', 'vm' ];
|
|
3816
|
+
let andCondition = [];
|
|
3817
|
+
taskType.forEach( ( type ) => {
|
|
3818
|
+
andCondition.push(
|
|
3819
|
+
{ 'planoTask.taskStatus': {
|
|
3820
|
+
$elemMatch: {
|
|
3821
|
+
type,
|
|
3822
|
+
status: 'submit',
|
|
3823
|
+
},
|
|
3824
|
+
} },
|
|
3825
|
+
{
|
|
3826
|
+
[`taskDetails.${type}Status`]: '',
|
|
3827
|
+
},
|
|
3828
|
+
);
|
|
3829
|
+
} );
|
|
3830
|
+
orQuery.push( { $and: andCondition } );
|
|
3814
3831
|
}
|
|
3815
3832
|
if ( inputData.filter.status.includes( 'yetToAssign' ) ) {
|
|
3816
3833
|
orQuery.push( { $expr: { $eq: [ { $size: '$planoTask' }, 0 ] } } );
|
|
@@ -3871,6 +3888,7 @@ export async function planoList( req, res ) {
|
|
|
3871
3888
|
planoId: { $in: planoIdList.map( ( ele ) => ele._id ) },
|
|
3872
3889
|
isPlano: true,
|
|
3873
3890
|
date_iso: { $lte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
3891
|
+
planoType: { $in: [ 'layout', 'fixture', 'vm' ] },
|
|
3874
3892
|
},
|
|
3875
3893
|
},
|
|
3876
3894
|
{
|
|
@@ -4523,7 +4541,6 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4523
4541
|
{
|
|
4524
4542
|
$match: {
|
|
4525
4543
|
clientId: req.body.clientId,
|
|
4526
|
-
planoProgress: 100,
|
|
4527
4544
|
storeId: { $in: storeDetails },
|
|
4528
4545
|
},
|
|
4529
4546
|
},
|
|
@@ -4808,7 +4825,11 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4808
4825
|
},
|
|
4809
4826
|
];
|
|
4810
4827
|
|
|
4811
|
-
let extraCondition = [
|
|
4828
|
+
let extraCondition = [ {
|
|
4829
|
+
$match: {
|
|
4830
|
+
planoProgress: 100,
|
|
4831
|
+
},
|
|
4832
|
+
} ];
|
|
4812
4833
|
|
|
4813
4834
|
if ( req.body?.filter?.type == 'rollout' ) {
|
|
4814
4835
|
extraCondition.push( {
|
|
@@ -5079,6 +5100,10 @@ export async function getRolloutTaskDetails( req, res ) {
|
|
|
5079
5100
|
$group: {
|
|
5080
5101
|
_id: { type: '$planoType', floorId: '$floorId' },
|
|
5081
5102
|
dateString: { $last: '$date_string' },
|
|
5103
|
+
createdByName: { $last: '$createdByName' },
|
|
5104
|
+
userName: { $last: '$userName' },
|
|
5105
|
+
createdAt: { $last: '$createdAt' },
|
|
5106
|
+
submitTime_string: { $last: '$submitTime_string' },
|
|
5082
5107
|
checklistStatus: { $last: '$checklistStatus' },
|
|
5083
5108
|
taskId: { $last: '$_id' },
|
|
5084
5109
|
redoStatus: { $last: '$redoStatus' },
|
|
@@ -5097,6 +5122,10 @@ export async function getRolloutTaskDetails( req, res ) {
|
|
|
5097
5122
|
floorId: '$_id.floorId',
|
|
5098
5123
|
redoStatus: '$redoStatus',
|
|
5099
5124
|
endTime: '$scheduleEndTime_iso',
|
|
5125
|
+
createdByName: '$createdByName',
|
|
5126
|
+
userName: '$userName',
|
|
5127
|
+
createdAt: '$createdAt',
|
|
5128
|
+
submitTime_string: '$submitTime_string',
|
|
5100
5129
|
id: '$taskId',
|
|
5101
5130
|
breach: {
|
|
5102
5131
|
$cond: {
|
|
@@ -5369,6 +5398,10 @@ export async function getRolloutTaskDetails( req, res ) {
|
|
|
5369
5398
|
endTime: '$$task.endTime',
|
|
5370
5399
|
breach: '$$task.breach',
|
|
5371
5400
|
taskId: '$$task.id',
|
|
5401
|
+
createdByName: '$$task.createdByName',
|
|
5402
|
+
createdAt: '$$task.createdAt',
|
|
5403
|
+
userName: '$$task.userName',
|
|
5404
|
+
submitTime_string: '$$task.submitTime_string',
|
|
5372
5405
|
feedbackStatus: {
|
|
5373
5406
|
$switch: {
|
|
5374
5407
|
branches: [
|
|
@@ -666,9 +666,9 @@ export async function updateAnswersv2( req, res ) {
|
|
|
666
666
|
console.log( '111111', data.answers[0] );
|
|
667
667
|
console.log( '111111', data.answers[0].issues[0] );
|
|
668
668
|
if ( req.body.type==='layout' ) {
|
|
669
|
-
await planoTaskService.updateOne( { planoId: req.body.planoId, taskType: req.body.taskType, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type,
|
|
669
|
+
await planoTaskService.updateOne( { planoId: req.body.planoId, taskType: req.body.taskType, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, ...( taskDetails?._id ) ? { taskId: taskDetails?._id } :{} }, data );
|
|
670
670
|
} else {
|
|
671
|
-
await planoTaskService.updateOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type,
|
|
671
|
+
await planoTaskService.updateOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, ...( taskDetails?._id ) ? { taskId: taskDetails?._id } :{} }, data );
|
|
672
672
|
}
|
|
673
673
|
|
|
674
674
|
await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).planotaskcompliances, data );
|
|
@@ -1047,10 +1047,13 @@ export async function redoTask( req, res ) {
|
|
|
1047
1047
|
|
|
1048
1048
|
export async function revokeTask( req, res ) {
|
|
1049
1049
|
try {
|
|
1050
|
-
if ( !req.body.
|
|
1051
|
-
return res.sendError( '
|
|
1050
|
+
if ( !req.body.planoId ) {
|
|
1051
|
+
return res.sendError( 'plano id is required', 400 );
|
|
1052
|
+
}
|
|
1053
|
+
if ( !req.body.floorId ) {
|
|
1054
|
+
return res.sendError( 'floor id is required', 400 );
|
|
1052
1055
|
}
|
|
1053
|
-
await processedService.deleteMany( {
|
|
1056
|
+
await processedService.deleteMany( { planoId: req.body.planoId, floorId: req.body.floorId, checklistStatus: { $ne: 'submit' }, date_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } } );
|
|
1054
1057
|
return res.sendSuccess( 'Task revoked successfully' );
|
|
1055
1058
|
} catch ( e ) {
|
|
1056
1059
|
logger.error( { functionName: 'revokeTask', error: e } );
|