tango-app-api-store-builder 1.0.0-beta-108 → 1.0.0-beta-110
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 +47 -48
- package/src/controllers/fixtureTemplate.controller.js +15 -3
- package/src/controllers/managePlano.controller.js +9 -97
- package/src/controllers/planoLibrary.controller.js +101 -15
- package/src/controllers/script.controller.js +115 -175
- package/src/controllers/storeBuilder.controller.js +2 -2
- package/src/controllers/task.controller.js +64 -29
- package/src/dtos/validation.dtos.js +12 -4
- package/src/routes/planoLibrary.routes.js +1 -1
- package/src/service/fixtureConfig.service.js +1 -7
|
@@ -11,7 +11,7 @@ import * as checklistService from '../service/checklist.service.js';
|
|
|
11
11
|
import timeZone from 'dayjs/plugin/timezone.js';
|
|
12
12
|
import * as planoProductService from '../service/planoProduct.service.js';
|
|
13
13
|
import mongoose from 'mongoose';
|
|
14
|
-
const ObjectId = mongoose.Types.ObjectId;
|
|
14
|
+
// const ObjectId = mongoose.Types.ObjectId;
|
|
15
15
|
import * as floorService from '../service/storeBuilder.service.js';
|
|
16
16
|
import * as planoStaticService from '../service/planoStaticData.service.js';
|
|
17
17
|
|
|
@@ -110,6 +110,7 @@ async function createUser( data ) {
|
|
|
110
110
|
|
|
111
111
|
export async function createTask( req, res ) {
|
|
112
112
|
try {
|
|
113
|
+
console.log( 1 );
|
|
113
114
|
let taskDetails = await taskService.find( { isPlano: true, client_id: req.body.clientId, ...( req.body.checkListName )? { checkListName: req.body.checkListName } : {} } );
|
|
114
115
|
let storeList = req.body.stores.map( ( ele ) => ele.store.toLowerCase() );
|
|
115
116
|
let userDetails;
|
|
@@ -218,6 +219,7 @@ export async function createTask( req, res ) {
|
|
|
218
219
|
let storeDetails = await storeService.aggregate( query );
|
|
219
220
|
await Promise.all( storeDetails.map( async ( store ) => {
|
|
220
221
|
let getUserEmail = req.body.stores.find( ( ele ) => ele.store.toLowerCase() == store.storeName.toLowerCase() );
|
|
222
|
+
console.log( getUserEmail, 'email' );
|
|
221
223
|
let planoDetails = await planoService.findOne( { storeName: store.storeName } );
|
|
222
224
|
if ( planoDetails ) {
|
|
223
225
|
let floorDetails = await floorService.find( { planoId: planoDetails._id }, { _id: 1, floorName: 1 } );
|
|
@@ -244,13 +246,13 @@ export async function createTask( req, res ) {
|
|
|
244
246
|
taskData.checkListName = taskData.checkListName +' - '+ floorDetails[i].floorName;
|
|
245
247
|
taskData.floorId = floorDetails[i]._id;
|
|
246
248
|
}
|
|
249
|
+
console.log( userDetails );
|
|
247
250
|
taskData.store_id = store.storeId;
|
|
248
251
|
taskData.storeName = store.storeName;
|
|
249
252
|
taskData.userId = userDetails._id;
|
|
250
253
|
taskData.userName = userDetails.userName;
|
|
251
254
|
taskData.userEmail = userDetails.email;
|
|
252
255
|
taskData.planoId = planoDetails?._id;
|
|
253
|
-
console.log( taskData );
|
|
254
256
|
for ( let i=0; i<req.body.days; i++ ) {
|
|
255
257
|
let currDate = dayjs().add( i, 'day' );
|
|
256
258
|
let insertData = { ...taskData, date_string: currDate.format( 'YYYY-MM-DD' ), date_iso: new Date( currDate.format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( `${currDate.format( 'YYYY-MM-DD' )} 12:00 AM`, 'YYYY-MM-DD hh:mm A' ).format() };
|
|
@@ -525,9 +527,6 @@ export async function updateAnswers( req, res ) {
|
|
|
525
527
|
};
|
|
526
528
|
|
|
527
529
|
await planoTaskService.updateOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, date_string: dayjs().format( 'YYYY-MM-DD' ), ...( taskDetails?._id ) ? { taskId: taskDetails?._id } :{} }, data );
|
|
528
|
-
// req.body.taskId = taskDetails?._id;
|
|
529
|
-
// req.body.status = 'submit';
|
|
530
|
-
// await updateStatus( req, res );
|
|
531
530
|
return res.sendSuccess( 'Fixture details updated successfully' );
|
|
532
531
|
} catch ( e ) {
|
|
533
532
|
logger.error( { functionName: 'updateAnswers', error: e } );
|
|
@@ -673,26 +672,44 @@ export async function generatetaskDetails( req, res ) {
|
|
|
673
672
|
userEmail: { $nin: [ 'sandeep.pal@yopmail.com', 'balaji@tangotech.co.in', 'gowri@tangotech.co.in', 'gowri@yopmail.com' ] },
|
|
674
673
|
},
|
|
675
674
|
},
|
|
676
|
-
{
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
675
|
+
// {
|
|
676
|
+
// $lookup: {
|
|
677
|
+
// from: '$planogram',
|
|
678
|
+
// let: { plano: '$planoId' },
|
|
679
|
+
// pipeline: [
|
|
680
|
+
// {
|
|
681
|
+
// $match: {
|
|
682
|
+
// $expr: {
|
|
683
|
+
// $and: {
|
|
684
|
+
// $eq: [ '$_id', '$$plano' ],
|
|
685
|
+
// },
|
|
686
|
+
// },
|
|
687
|
+
// },
|
|
688
|
+
// },
|
|
689
|
+
// ],
|
|
690
|
+
// as: 'planogram',
|
|
691
|
+
// },
|
|
692
|
+
// },
|
|
693
|
+
// {
|
|
694
|
+
// $lookup: {
|
|
695
|
+
// from: 'checklistassignconfigs',
|
|
696
|
+
// let: { storeId: '$store_id', email: '$userEmail' },
|
|
697
|
+
// pipeline: [
|
|
698
|
+
// {
|
|
699
|
+
// $match: {
|
|
700
|
+
// $expr: {
|
|
701
|
+
// $and: [
|
|
702
|
+
// // { $eq: [ '$checkListId', new ObjectId( '6789e3c7a5683c58215ec089' ) ] },
|
|
703
|
+
// { $eq: [ '$store_id', '$$storeId' ] },
|
|
704
|
+
// { $eq: [ '$userEmail', '$$email' ] },
|
|
705
|
+
// ],
|
|
706
|
+
// },
|
|
707
|
+
// },
|
|
708
|
+
// },
|
|
709
|
+
// ],
|
|
710
|
+
// as: 'assignUser',
|
|
711
|
+
// },
|
|
712
|
+
// },
|
|
696
713
|
{
|
|
697
714
|
$project: {
|
|
698
715
|
_id: 1,
|
|
@@ -717,7 +734,7 @@ export async function generatetaskDetails( req, res ) {
|
|
|
717
734
|
_id: '$planoId',
|
|
718
735
|
count: { $sum: 1 },
|
|
719
736
|
storeName: { $first: '$storeName' },
|
|
720
|
-
taskId: { $
|
|
737
|
+
taskId: { $push: '$_id' },
|
|
721
738
|
checklistStatus: { $push: '$checklistStatus' },
|
|
722
739
|
date_string: { $push: '$date_string' },
|
|
723
740
|
},
|
|
@@ -735,10 +752,26 @@ export async function generatetaskDetails( req, res ) {
|
|
|
735
752
|
},
|
|
736
753
|
];
|
|
737
754
|
let taskDetails = await processedService.aggregate( query );
|
|
738
|
-
console.log( taskDetails.
|
|
739
|
-
|
|
755
|
+
console.log( taskDetails.flatMap( ( ele ) => ele.taskId ) );
|
|
756
|
+
// ...( req.body.store.length ) ? { storeName: { $in: req.body.store } } : {}, taskId: { $in: taskDetails.flatMap( ( ele ) => ele.taskId ) } },
|
|
757
|
+
let processedTaskDetails = await planoTaskService.find( { date_string: { $gte: req.body.fromDate, $lte: req.body.toDate }, type: 'layout' }, { status: 1, planoId: 1, date_string: 1, _id: 0, taskId: 1 } );
|
|
758
|
+
console.log( processedTaskDetails.length );
|
|
759
|
+
|
|
760
|
+
processedTaskDetails = await Promise.all( processedTaskDetails.map( async ( ele ) => {
|
|
761
|
+
ele = { ...ele.toObject(), storeName: '' };
|
|
762
|
+
if ( ele.planoId ) {
|
|
763
|
+
let planoDetails = await planoService.findOne( { _id: ele.planoId }, { storeName: 1 } );
|
|
764
|
+
console.log( planoDetails );
|
|
765
|
+
if ( planoDetails ) {
|
|
766
|
+
ele.storeName = planoDetails.storeName;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return ele;
|
|
770
|
+
} ) );
|
|
771
|
+
|
|
740
772
|
processedTaskDetails.forEach( ( item ) => {
|
|
741
773
|
let taskIndex = taskDetails.findIndex( ( taskItem ) => taskItem.checklistStatus.includes( 'submit' ) && taskItem.date_string.includes( item.date_string ) && item.planoId.toString() == taskItem.planoId.toString() );
|
|
774
|
+
console.log( taskIndex, 'index' );
|
|
742
775
|
if ( taskIndex != -1 ) {
|
|
743
776
|
taskDetails[taskIndex].storeStatus = item.status == 'complete' ? 'yes' : 'No';
|
|
744
777
|
}
|
|
@@ -787,8 +820,10 @@ export async function generatetaskDetails( req, res ) {
|
|
|
787
820
|
}
|
|
788
821
|
|
|
789
822
|
let data = [ ...completeStore, ...incompleteStore ];
|
|
823
|
+
let yesCount = completeStore.filter( ( ele ) => ele.storeStatus == 'yes' );
|
|
824
|
+
let noCount = completeStore.filter( ( ele ) => ele.storeStatus == 'No' );
|
|
790
825
|
|
|
791
|
-
return res.sendSuccess( { count: data.length, completeStore: completeStore.length, incompleteStore: incompleteStore.length, data } );
|
|
826
|
+
return res.sendSuccess( { count: data.length, completeStore: completeStore.length, incompleteStore: incompleteStore.length, yesCount: yesCount.length, noCount: noCount.length, data } );
|
|
792
827
|
} catch ( e ) {
|
|
793
828
|
console.log( e );
|
|
794
829
|
logger.error( { functioName: 'generatetaskDetails', error: e } );
|
|
@@ -168,6 +168,16 @@ export const getClient = {
|
|
|
168
168
|
query: getClientSchema,
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
+
export const brandSchema = joi.object( {
|
|
172
|
+
clientId: joi.string().required(),
|
|
173
|
+
export: joi.boolean().optional(),
|
|
174
|
+
emptyDownload: joi.boolean().optional(),
|
|
175
|
+
} );
|
|
176
|
+
|
|
177
|
+
export const brandDetails ={
|
|
178
|
+
body: brandSchema,
|
|
179
|
+
};
|
|
180
|
+
|
|
171
181
|
export const deleteVMTypeImageSchema = joi.object( {
|
|
172
182
|
vmId: joi.string().required(),
|
|
173
183
|
index: joi.number().required(),
|
|
@@ -211,10 +221,8 @@ export const fixtureBulkUpload = {
|
|
|
211
221
|
|
|
212
222
|
export const addUpdateBrandSchema = joi.object( {
|
|
213
223
|
clientId: joi.string().required(),
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
subCategory: joi.array().items( joi.any() ).min( 0 ).required(),
|
|
217
|
-
category: joi.array().items( joi.any() ).min( 1 ).required(),
|
|
224
|
+
brandUsedList: joi.array().items( joi.any() ).min( 0 ).required(),
|
|
225
|
+
brandData: joi.array().items( joi.any() ).min( 1 ).required(),
|
|
218
226
|
} );
|
|
219
227
|
|
|
220
228
|
export const addUpdateBrand = {
|
|
@@ -24,7 +24,7 @@ planoLibraryRouter
|
|
|
24
24
|
.post( '/deleteVmTypeImage', isAllowedSessionHandler, validate( validateDtos.deleteVMTypeImage ), planoLibraryController.deletevmTypeImage );
|
|
25
25
|
|
|
26
26
|
planoLibraryRouter
|
|
27
|
-
.
|
|
27
|
+
.post( '/getBrandList', isAllowedSessionHandler, validate( validateDtos.brandDetails ), planoLibraryController.getBrandList )
|
|
28
28
|
.post( '/addUpdateBrand', isAllowedSessionHandler, validate( validateDtos.addUpdateBrand ), planoLibraryController.addUpdateBrandList )
|
|
29
29
|
.post( '/uploadBrandList', isAllowedSessionHandler, validate( validateDtos.uploadBrandList ), planoLibraryController.uploadBrandList )
|
|
30
30
|
.post( '/updateTaskconfig', isAllowedSessionHandler, validate( validateDtos.updateTaskConfig ), planoLibraryController.updateTaskConfig )
|
|
@@ -5,7 +5,7 @@ export async function find( query={}, field={} ) {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export async function findOne( query={}, field={} ) {
|
|
8
|
-
return model.
|
|
8
|
+
return model.fixtureConfigModel.findOne( query, field );
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export async function insertMany( data = [] ) {
|
|
@@ -42,9 +42,3 @@ export async function deleteOne( query = {} ) {
|
|
|
42
42
|
export const findAndSort = async ( query={}, field={}, sort={} ) => {
|
|
43
43
|
return await model.fixtureConfigModel.find( query, field ).sort( sort ).collation( { locale: 'en_US', numericOrdering: true } );
|
|
44
44
|
};
|
|
45
|
-
|
|
46
|
-
export async function sortAndFindOne( query = {}, field = {}, sort = {} ) {
|
|
47
|
-
return model.fixtureConfigModel.find( query, field )
|
|
48
|
-
.sort( sort )
|
|
49
|
-
.limit( 1 );
|
|
50
|
-
}
|