tango-app-api-store-builder 1.0.0-beta-140 → 1.0.0-beta-142
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
|
@@ -418,7 +418,9 @@ export async function updateStorePlano( req, res ) {
|
|
|
418
418
|
} );
|
|
419
419
|
|
|
420
420
|
await floorService.updateOne( { _id: new mongoose.Types.ObjectId( floorId ) },
|
|
421
|
-
{ layoutPolygon: layoutPolygon
|
|
421
|
+
{ layoutPolygon: layoutPolygon,
|
|
422
|
+
...( req.body?.editMode === true && { isEdited: true } ),
|
|
423
|
+
} );
|
|
422
424
|
|
|
423
425
|
const currentWallFixtures = data.layoutPolygon.flatMap( ( element ) =>
|
|
424
426
|
( element.fixtures || [] ).map( ( fixture ) => fixture ),
|
|
@@ -8593,6 +8593,7 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8593
8593
|
vmName: vm.name + ' - 1',
|
|
8594
8594
|
vmHeight: configData1.vmHeightmm,
|
|
8595
8595
|
vmWidth: configData1.vmWidthmm,
|
|
8596
|
+
...( vm?.preview_image_url && { preview_image_url: vm?.preview_image_url } ),
|
|
8596
8597
|
},
|
|
8597
8598
|
{
|
|
8598
8599
|
startYPosition: configData2.startShelf,
|
|
@@ -8602,11 +8603,39 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8602
8603
|
vmName: vm.name + ' - 2',
|
|
8603
8604
|
vmHeight: configData2.vmHeightmm,
|
|
8604
8605
|
vmWidth: configData2.vmWidthmm,
|
|
8606
|
+
...( vm?.preview_image_url2 && { preview_image_url: vm?.preview_image_url2 } ),
|
|
8605
8607
|
},
|
|
8606
8608
|
];
|
|
8607
8609
|
} );
|
|
8608
8610
|
|
|
8609
8611
|
const vmTemplate = await Promise.all( vmConfig.map( async ( vmTemplate, k ) => {
|
|
8612
|
+
let attachmentId = '';
|
|
8613
|
+
let imgPath = '';
|
|
8614
|
+
let imageMeta = null;
|
|
8615
|
+
if ( vmTemplate?.preview_image_url ) {
|
|
8616
|
+
const parsedUrl = new URL( vmTemplate.preview_image_url );
|
|
8617
|
+
attachmentId = parsedUrl.searchParams.get( 'attachment_id' );
|
|
8618
|
+
|
|
8619
|
+
const isVmImageExist = await planoVmService.findOne( { crestImageId: attachmentId } );
|
|
8620
|
+
|
|
8621
|
+
if ( !isVmImageExist ) {
|
|
8622
|
+
const vmImageData = await fetchVmImage( attachmentId );
|
|
8623
|
+
|
|
8624
|
+
imageMeta = await getImageMetadata( vmImageData );
|
|
8625
|
+
|
|
8626
|
+
const params = {
|
|
8627
|
+
Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
|
|
8628
|
+
Key: `crestVms/`,
|
|
8629
|
+
fileName: `${attachmentId}.${imageMeta.fileExtension}`,
|
|
8630
|
+
ContentType: imageMeta.contentType,
|
|
8631
|
+
body: vmImageData,
|
|
8632
|
+
};
|
|
8633
|
+
|
|
8634
|
+
const imgUpload = await fileUpload( params );
|
|
8635
|
+
|
|
8636
|
+
imgPath = imgUpload.Key;
|
|
8637
|
+
}
|
|
8638
|
+
}
|
|
8610
8639
|
const vmInsertData = {
|
|
8611
8640
|
clientId: '11',
|
|
8612
8641
|
vmName: vmTemplate.vmName,
|
|
@@ -8623,6 +8652,11 @@ export async function migrateCrestv1( req, res ) {
|
|
|
8623
8652
|
vmType: 'LKVM',
|
|
8624
8653
|
};
|
|
8625
8654
|
|
|
8655
|
+
if ( attachmentId && imgPath ) {
|
|
8656
|
+
vmInsertData.crestImageId = attachmentId;
|
|
8657
|
+
vmInsertData.vmImageUrl = imgPath;
|
|
8658
|
+
}
|
|
8659
|
+
|
|
8626
8660
|
const vmIdentifier = `vm${k+1}=${vmTemplate.vmName}+${vmTemplate.vmHeight}+${vmTemplate.vmWidth}+${vmTemplate.startYPosition}+${vmTemplate.endYPosition}+${vmTemplate.xZone}`;
|
|
8627
8661
|
|
|
8628
8662
|
mapKey += ','+vmIdentifier;
|
|
@@ -2655,7 +2655,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2655
2655
|
planograms.map( async ( planogram ) => {
|
|
2656
2656
|
const floors = await storeBuilderService.find(
|
|
2657
2657
|
{ planoId: planogram._id },
|
|
2658
|
-
{ floorName: 1, layoutPolygon: 1, planoId: 1 },
|
|
2658
|
+
{ floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1 },
|
|
2659
2659
|
);
|
|
2660
2660
|
|
|
2661
2661
|
const floorsWithFixtures = await Promise.all(
|
|
@@ -2669,7 +2669,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2669
2669
|
floorId: floor._id,
|
|
2670
2670
|
associatedElementType: element.elementType,
|
|
2671
2671
|
associatedElementNumber: element.elementNumber,
|
|
2672
|
-
}, { shelfcount: 0 }, {
|
|
2672
|
+
}, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
|
|
2673
2673
|
|
|
2674
2674
|
const fixturesWithStatus = await Promise.all(
|
|
2675
2675
|
fixtures.map( async ( fixture ) => {
|
|
@@ -2762,13 +2762,14 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2762
2762
|
} ),
|
|
2763
2763
|
);
|
|
2764
2764
|
|
|
2765
|
-
const centerFixtures = await storeFixtureService.
|
|
2765
|
+
const centerFixtures = await storeFixtureService.findAndSort( {
|
|
2766
2766
|
floorId: floor._id,
|
|
2767
2767
|
$and: [
|
|
2768
2768
|
{ associatedElementType: { $exists: false } },
|
|
2769
2769
|
{ associatedElementNumber: { $exists: false } },
|
|
2770
2770
|
],
|
|
2771
|
-
} );
|
|
2771
|
+
}, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
|
|
2772
|
+
|
|
2772
2773
|
|
|
2773
2774
|
const centerFixturesWithStatus = await Promise.all(
|
|
2774
2775
|
centerFixtures.map( async ( fixture ) => {
|
|
@@ -2838,7 +2839,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2838
2839
|
return {
|
|
2839
2840
|
...fixture.toObject(),
|
|
2840
2841
|
status: fixtureStatus,
|
|
2841
|
-
shelfCount: shelves.
|
|
2842
|
+
shelfCount: shelves.length,
|
|
2842
2843
|
productCount: productCount,
|
|
2843
2844
|
vmCount: vmCount,
|
|
2844
2845
|
shelfConfig: shelfDetails,
|
|
@@ -2977,7 +2978,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
2977
2978
|
planograms.map( async ( planogram ) => {
|
|
2978
2979
|
const floors = await storeBuilderService.find(
|
|
2979
2980
|
{ planoId: planogram._id },
|
|
2980
|
-
{ floorName: 1, layoutPolygon: 1, planoId: 1 },
|
|
2981
|
+
{ floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1 },
|
|
2981
2982
|
);
|
|
2982
2983
|
|
|
2983
2984
|
const floorsWithFixtures = await Promise.all(
|
|
@@ -2992,7 +2993,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
2992
2993
|
floorId: floor._id,
|
|
2993
2994
|
associatedElementType: element.elementType,
|
|
2994
2995
|
associatedElementNumber: element.elementNumber,
|
|
2995
|
-
}, { shelfcount: 0 }, {
|
|
2996
|
+
}, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
|
|
2996
2997
|
|
|
2997
2998
|
const fixturesWithStatus = await Promise.all(
|
|
2998
2999
|
fixtures.map( async ( fixture ) => {
|
|
@@ -3086,13 +3087,13 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3086
3087
|
} ),
|
|
3087
3088
|
);
|
|
3088
3089
|
|
|
3089
|
-
const centerFixtures = await storeFixtureService.
|
|
3090
|
+
const centerFixtures = await storeFixtureService.findAndSort( {
|
|
3090
3091
|
floorId: floor._id,
|
|
3091
3092
|
$and: [
|
|
3092
3093
|
{ associatedElementType: { $exists: false } },
|
|
3093
3094
|
{ associatedElementNumber: { $exists: false } },
|
|
3094
3095
|
],
|
|
3095
|
-
} );
|
|
3096
|
+
}, { shelfcount: 0 }, { associatedElementFixtureNumber: 1 } );
|
|
3096
3097
|
|
|
3097
3098
|
const centerFixturesWithStatus = await Promise.all(
|
|
3098
3099
|
centerFixtures.map( async ( fixture ) => {
|
|
@@ -3161,7 +3162,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3161
3162
|
return {
|
|
3162
3163
|
...fixture.toObject(),
|
|
3163
3164
|
status: compliance?.status ? compliance.status : '',
|
|
3164
|
-
shelfCount: shelves.
|
|
3165
|
+
shelfCount: shelves.length,
|
|
3165
3166
|
productCount: productCount,
|
|
3166
3167
|
disabled: req?.body?.redo ? disabled : false,
|
|
3167
3168
|
vmCount: vmCount,
|
|
@@ -3343,7 +3344,7 @@ export async function planoList( req, res ) {
|
|
|
3343
3344
|
$and: [
|
|
3344
3345
|
{ $eq: [ '$planoId', '$$plano' ] },
|
|
3345
3346
|
// { $in: [ '$taskId', pendingDetails.map( ( ele ) => ele.taskId ) ] },
|
|
3346
|
-
{ $eq: [ '$taskType', 'initial' ] },
|
|
3347
|
+
// { $eq: [ '$taskType', 'initial' ] },
|
|
3347
3348
|
],
|
|
3348
3349
|
},
|
|
3349
3350
|
},
|
|
@@ -3361,13 +3362,28 @@ export async function planoList( req, res ) {
|
|
|
3361
3362
|
in: {
|
|
3362
3363
|
$concatArrays: [
|
|
3363
3364
|
'$$value',
|
|
3364
|
-
{
|
|
3365
|
+
{
|
|
3366
|
+
$reduce: {
|
|
3367
|
+
input: { $ifNull: [ '$$this.issues', [] ] },
|
|
3368
|
+
initialValue: [],
|
|
3369
|
+
in: {
|
|
3370
|
+
$concatArrays: [
|
|
3371
|
+
'$$value',
|
|
3372
|
+
{ $ifNull: [ '$$this.Details', [] ] },
|
|
3373
|
+
],
|
|
3374
|
+
},
|
|
3375
|
+
},
|
|
3376
|
+
},
|
|
3365
3377
|
],
|
|
3366
3378
|
},
|
|
3367
3379
|
},
|
|
3368
3380
|
},
|
|
3369
|
-
as: '
|
|
3370
|
-
in: {
|
|
3381
|
+
as: 'detail',
|
|
3382
|
+
in: {
|
|
3383
|
+
$or: [
|
|
3384
|
+
{ $eq: [ '$$detail.status', 'pending' ] },
|
|
3385
|
+
],
|
|
3386
|
+
},
|
|
3371
3387
|
},
|
|
3372
3388
|
},
|
|
3373
3389
|
},
|
|
@@ -3738,7 +3754,7 @@ export async function planoList( req, res ) {
|
|
|
3738
3754
|
{
|
|
3739
3755
|
$match: {
|
|
3740
3756
|
taskId: { $in: pendingDetails.map( ( ele ) => ele.taskId ) },
|
|
3741
|
-
taskType: 'initial',
|
|
3757
|
+
// taskType: 'initial',
|
|
3742
3758
|
},
|
|
3743
3759
|
},
|
|
3744
3760
|
{
|
|
@@ -3753,13 +3769,28 @@ export async function planoList( req, res ) {
|
|
|
3753
3769
|
in: {
|
|
3754
3770
|
$concatArrays: [
|
|
3755
3771
|
'$$value',
|
|
3756
|
-
{
|
|
3772
|
+
{
|
|
3773
|
+
$reduce: {
|
|
3774
|
+
input: { $ifNull: [ '$$this.issues', [] ] },
|
|
3775
|
+
initialValue: [],
|
|
3776
|
+
in: {
|
|
3777
|
+
$concatArrays: [
|
|
3778
|
+
'$$value',
|
|
3779
|
+
{ $ifNull: [ '$$this.Details', [] ] },
|
|
3780
|
+
],
|
|
3781
|
+
},
|
|
3782
|
+
},
|
|
3783
|
+
},
|
|
3757
3784
|
],
|
|
3758
3785
|
},
|
|
3759
3786
|
},
|
|
3760
3787
|
},
|
|
3761
|
-
as: '
|
|
3762
|
-
in: {
|
|
3788
|
+
as: 'detail',
|
|
3789
|
+
in: {
|
|
3790
|
+
$or: [
|
|
3791
|
+
{ $eq: [ '$$detail.status', 'pending' ] },
|
|
3792
|
+
],
|
|
3793
|
+
},
|
|
3763
3794
|
},
|
|
3764
3795
|
},
|
|
3765
3796
|
},
|
|
@@ -15,6 +15,7 @@ import mongoose from 'mongoose';
|
|
|
15
15
|
import * as floorService from '../service/storeBuilder.service.js';
|
|
16
16
|
import * as planoStaticService from '../service/planoStaticData.service.js';
|
|
17
17
|
import * as assignService from '../service/assignService.service.js';
|
|
18
|
+
import * as storeBuilderService from '../service/storeBuilder.service.js';
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
dayjs.extend( timeZone );
|
|
@@ -112,6 +113,9 @@ async function createUser( data ) {
|
|
|
112
113
|
|
|
113
114
|
export async function createTask( req, res ) {
|
|
114
115
|
try {
|
|
116
|
+
if ( req.body?.floorId ) {
|
|
117
|
+
await storeBuilderService.updateOne( { _id: new mongoose.Types.ObjectId( req.body?.floorId ) }, { isEdited: false } );
|
|
118
|
+
}
|
|
115
119
|
let scheduleEndTime = '11:59 PM';
|
|
116
120
|
if ( req.body?.redo ) {
|
|
117
121
|
if ( !req.body.taskId ) {
|
|
@@ -290,14 +294,14 @@ export async function createTask( req, res ) {
|
|
|
290
294
|
taskData.userName = userDetails.userName;
|
|
291
295
|
taskData.userEmail = userDetails.email;
|
|
292
296
|
taskData.planoId = planoDetails?._id;
|
|
297
|
+
let planoProgress = req.body.checkListName == 'Fixture Verification' ? 50 : req.body.checkListName == 'VM Verification' ? 75 : 25;
|
|
298
|
+
if ( req.body?.checkListName && req.body.checkListName == 'Layout Verification' ) {
|
|
299
|
+
await planoTaskService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId } );
|
|
300
|
+
planoProgress = 25;
|
|
301
|
+
await processedService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId, isPlano: true } );
|
|
302
|
+
}
|
|
303
|
+
await planoService.updateOne( { _id: planoDetails?._id }, { $set: { planoProgress } } );
|
|
293
304
|
for ( let j=0; j<req.body.days; j++ ) {
|
|
294
|
-
let planoProgress = req.body.checkListName == 'Fixture Verification' ? 50 : req.body.checkListName == 'VM Verification' ? 75 : 25;
|
|
295
|
-
if ( req.body?.checkListName && req.body.checkListName == 'Layout Verification' ) {
|
|
296
|
-
await planoTaskService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId } );
|
|
297
|
-
planoProgress = 25;
|
|
298
|
-
await processedService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId, isPlano: true } );
|
|
299
|
-
}
|
|
300
|
-
await planoService.updateOne( { _id: planoDetails?._id }, { $set: { planoProgress } } );
|
|
301
305
|
let currDate = dayjs().add( j, 'day' );
|
|
302
306
|
let time = '12:00 AM';
|
|
303
307
|
if ( currDate.format( 'YYYY-MM-DD' ) == dayjs().format( 'YYYY-MM-DD' ) ) {
|