tango-app-api-trax 3.3.1-hotfix-21 → 3.3.1-hotfix-23
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/download.controller.js +130 -2
- package/src/controllers/internalTrax.controller.js +31 -0
- package/src/dtos/downloadValidation.dtos.js +1 -1
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/download.router.js +4 -0
- package/src/routes/internalTraxApi.router.js +1 -0
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import * as processedchecklistService from '../services/processedchecklist.servi
|
|
|
5
5
|
import * as processedTaskService from '../services/processedTaskList.service.js';
|
|
6
6
|
import * as taskConfigService from '../services/taskConfig.service.js';
|
|
7
7
|
import * as checklistService from '../services/checklist.service.js';
|
|
8
|
-
|
|
8
|
+
import * as processedcheklistconfigService from '../services/processedchecklistconfig.services.js';
|
|
9
9
|
import * as clientService from '../services/clients.services.js';
|
|
10
10
|
import * as storeService from '../services/store.service.js';
|
|
11
11
|
|
|
@@ -143,8 +143,9 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
143
143
|
'viewRedo': requestData.viewRedo || false,
|
|
144
144
|
'userEmailList': requestData.userEmailList || [],
|
|
145
145
|
'filtertype': requestData.filtertype || 'Clusters',
|
|
146
|
-
|
|
146
|
+
'checkListType': requestData.checkListType,
|
|
147
147
|
};
|
|
148
|
+
console.log( insertData );
|
|
148
149
|
let resultData = await downloadService.insert( insertData );
|
|
149
150
|
if ( resultData ) {
|
|
150
151
|
let sqsMessageRequestData = {
|
|
@@ -171,6 +172,103 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
171
172
|
return res.sendError( e, 500 );
|
|
172
173
|
}
|
|
173
174
|
};
|
|
175
|
+
export const downloadInsertAI = async ( req, res ) => {
|
|
176
|
+
try {
|
|
177
|
+
let requestData = req.body;
|
|
178
|
+
let name;
|
|
179
|
+
let fileType = requestData?.fileType || 'pdfzip';
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
if ( requestData.fileType == 'pdf' ) {
|
|
183
|
+
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id != '' ) {
|
|
184
|
+
fileType = 'pdfzip';
|
|
185
|
+
}
|
|
186
|
+
if ( requestData?.checklistId && requestData?.checklistId.length > 1 ) {
|
|
187
|
+
fileType = 'pdfzip';
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if ( requestData.checklistName != '' ) {
|
|
192
|
+
name = requestData.checklistName + '_' + dayjs( requestData.fromDate ).format( 'DD/MM/YYYY' );
|
|
193
|
+
if ( requestData?.toDate ) {
|
|
194
|
+
name = name + '-' + dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
195
|
+
}
|
|
196
|
+
let regexName = new RegExp( `^${name.split( '(' )[0]} \\(.*\\)$`, 'i' );
|
|
197
|
+
let type = requestData.fileType || 'pdfzip';
|
|
198
|
+
let downloadDetails = await downloadService.getCount( { $and: [ { $or: [ { name: { $regex: regexName } }, { name: name } ] }, { fileType: type } ] } );
|
|
199
|
+
if ( downloadDetails ) {
|
|
200
|
+
name = name + ' (' + downloadDetails + ')';
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
name = requestData?.checklistName;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
let findchecklist = await processedcheklistconfigService.findOne( { 'checkListType': requestData.checkListType, 'client_id': requestData.clientId } ).sort( { _id: -1 } );
|
|
208
|
+
|
|
209
|
+
console.log( findchecklist );
|
|
210
|
+
name = name + '-' + requestData.fileType;
|
|
211
|
+
let insertData = {
|
|
212
|
+
'date_string': requestData.fromDate || '',
|
|
213
|
+
'sourceCheckList_id': requestData?.sourceCheckList_id || '',
|
|
214
|
+
'checklistIdList': requestData?.checklistId || [],
|
|
215
|
+
'status': 'inprogress',
|
|
216
|
+
'client_id': requestData.clientId || '',
|
|
217
|
+
'date_iso': new Date( requestData.fromDate ) || '',
|
|
218
|
+
'createdBy': req.user._id || '',
|
|
219
|
+
'name': name,
|
|
220
|
+
'fileType': fileType,
|
|
221
|
+
'storeIds': requestData.storeIds || [],
|
|
222
|
+
'questions': requestData.questions || [],
|
|
223
|
+
'fromDate': requestData.fromDate || '',
|
|
224
|
+
'toDate': requestData.toDate || '',
|
|
225
|
+
'previewType': requestData.previewType || '',
|
|
226
|
+
'viewFlag': requestData.viewFlag || false,
|
|
227
|
+
'userEmail': req.user.email || '',
|
|
228
|
+
'createdBy': req.user._id || '',
|
|
229
|
+
'downloadInsertFrom': requestData.downloadInsertFrom || '',
|
|
230
|
+
'answerType': requestData.answerType || '',
|
|
231
|
+
'searchValue': requestData.searchValue || '',
|
|
232
|
+
'insertType': requestData.insertType || '',
|
|
233
|
+
'viewRedo': requestData.viewRedo || false,
|
|
234
|
+
'userEmailList': requestData.userEmailList || [],
|
|
235
|
+
'filtertype': requestData.filtertype || 'Clusters',
|
|
236
|
+
'checkListType': requestData.checkListType,
|
|
237
|
+
'checkListName': findchecklist.checkListName,
|
|
238
|
+
'checkListDescription': findchecklist.checkListDescription,
|
|
239
|
+
|
|
240
|
+
};
|
|
241
|
+
console.log( requestData );
|
|
242
|
+
console.log( insertData );
|
|
243
|
+
|
|
244
|
+
let resultData = await downloadService.insert( insertData );
|
|
245
|
+
console.log( resultData );
|
|
246
|
+
if ( resultData ) {
|
|
247
|
+
let sqsMessageRequestData = {
|
|
248
|
+
'zipId': resultData._id,
|
|
249
|
+
'fileType': fileType || 'zip',
|
|
250
|
+
'storeId': requestData.storeIds || [],
|
|
251
|
+
};
|
|
252
|
+
console.log( sqsMessageRequestData );
|
|
253
|
+
if ( fileType === 'csv' || fileType === 'pdf' || fileType === 'csvzip' || fileType === 'pdfzip' || fileType === 'zipfiles' ) {
|
|
254
|
+
const msg = await sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).AIchecklistExport}`, JSON.stringify( sqsMessageRequestData ) );
|
|
255
|
+
console.log( 'Send SQS Message CSV/PDF=>', msg );
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if ( fileType === 'ppt' || fileType === 'pptzip' ) {
|
|
259
|
+
const msg = await sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).AIchecklistExport}`, JSON.stringify( sqsMessageRequestData ) );
|
|
260
|
+
console.log( 'Send SQS Message PPT=>', msg );
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
res.sendSuccess( 'Success' );
|
|
264
|
+
} else {
|
|
265
|
+
return res.sendError( 'something went wrong, please try again', 500 );
|
|
266
|
+
}
|
|
267
|
+
} catch ( e ) {
|
|
268
|
+
console.log( 'insertdownloadRequest =>', e );
|
|
269
|
+
return res.sendError( e, 500 );
|
|
270
|
+
}
|
|
271
|
+
};
|
|
174
272
|
|
|
175
273
|
export const downloadInsertOld = async ( req, res ) => {
|
|
176
274
|
try {
|
|
@@ -482,6 +580,36 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
482
580
|
return res.sendError( error, 500 );
|
|
483
581
|
}
|
|
484
582
|
};
|
|
583
|
+
export const getAiChecklistDataFromZipId = async ( req, res ) => {
|
|
584
|
+
try {
|
|
585
|
+
let reqquery = req.query;
|
|
586
|
+
let getzipdata = await downloadService.findOne( { _id: new mongoose.Types.ObjectId( reqquery.zipId ) } );
|
|
587
|
+
let brandInfo = {
|
|
588
|
+
clientName: '',
|
|
589
|
+
brandLogo: '',
|
|
590
|
+
checkListDescription: '',
|
|
591
|
+
};
|
|
592
|
+
if ( getzipdata ) {
|
|
593
|
+
let getClientData = await clientService.findOne( { clientId: getzipdata.client_id } );
|
|
594
|
+
if ( getClientData ) {
|
|
595
|
+
brandInfo.clientName = getClientData.clientName;
|
|
596
|
+
brandInfo.brandLogo = getzipdata.client_id + '/logo/' + getClientData.profileDetails.logo;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
getzipdata.brandInfo = brandInfo;
|
|
600
|
+
console.log( getzipdata );
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
return res.sendSuccess( getzipdata );
|
|
604
|
+
} else {
|
|
605
|
+
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
606
|
+
}
|
|
607
|
+
} catch ( error ) {
|
|
608
|
+
console.log( 'error =>', error );
|
|
609
|
+
logger.error( { error: error, function: 'getChecklistFromZipId' } );
|
|
610
|
+
return res.sendError( error, 500 );
|
|
611
|
+
}
|
|
612
|
+
};
|
|
485
613
|
|
|
486
614
|
export const getPDFCSVChecklistDetails = async ( req, res ) => {
|
|
487
615
|
try {
|
|
@@ -1454,6 +1454,37 @@ export async function getPDFCSVChecklistDetails( req, res ) {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
|
|
1456
1456
|
|
|
1457
|
+
export async function AiPushNotificationAlert( req, res ) {
|
|
1458
|
+
try {
|
|
1459
|
+
console.log( req.body );
|
|
1460
|
+
let findAichecklist = await PCLconfig.findOne( { checkListType: req.body.checkListType, client_id: req.body.clientId, date_string: req.body.Date }, { aiConfig: 1 } );
|
|
1461
|
+
if ( findAichecklist.aiConfig&&findAichecklist.aiConfig.alerts&&findAichecklist.aiConfig.alerts.users&&findAichecklist.aiConfig.alerts.users.length>0 ) {
|
|
1462
|
+
console.log( findAichecklist.aiConfig.alerts.users );
|
|
1463
|
+
for ( let user of findAichecklist.aiConfig.alerts.users ) {
|
|
1464
|
+
let findOneUser = await userService.findOne( { email: user }, { fcmToken: 1 } );
|
|
1465
|
+
console.log( findOneUser );
|
|
1466
|
+
if ( findOneUser&&findOneUser.fcmToken&&findOneUser.fcmToken!='' ) {
|
|
1467
|
+
console.log( findOneUser.fcmToken );
|
|
1468
|
+
try {
|
|
1469
|
+
await sendPushNotification( req.body.title, req.body.description, findOneUser.fcmToken );
|
|
1470
|
+
} catch ( e ) {
|
|
1471
|
+
logger.error( {
|
|
1472
|
+
message: 'push notification',
|
|
1473
|
+
error: e,
|
|
1474
|
+
details: data,
|
|
1475
|
+
} );
|
|
1476
|
+
}
|
|
1477
|
+
} ;
|
|
1478
|
+
}
|
|
1479
|
+
return res.sendSuccess( 'Push notification send successfully' );
|
|
1480
|
+
}
|
|
1481
|
+
} catch ( e ) {
|
|
1482
|
+
logger.error( { function: 'AiPushNotificationAlert', error: e } );
|
|
1483
|
+
return res.sendError( e, 500 );
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
|
|
1457
1488
|
export async function taskPushNotification( req, res ) {
|
|
1458
1489
|
try {
|
|
1459
1490
|
let query = [ {
|
|
@@ -25,7 +25,7 @@ export const validateDownloadInsertSchema = joi.object( {
|
|
|
25
25
|
insertType: joi.string().optional().allow( '' ),
|
|
26
26
|
filter: joi.string().optional().allow( '' ),
|
|
27
27
|
filtertype: joi.string().optional().allow( '' ),
|
|
28
|
-
|
|
28
|
+
checkListType: joi.string().required(),
|
|
29
29
|
} );
|
|
30
30
|
|
|
31
31
|
export const validateDownloadInsertParams = {
|