tango-app-api-audit 3.4.3-alpha.0 → 3.4.3-alpha.2
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/audit.controllers.js +29 -0
- package/src/controllers/traxAudit.controllers.js +37 -32
- package/src/docs/traxAudit.docs.js +88 -2
- package/src/dtos/audit.dtos.js +0 -2
- package/src/dtos/traxAudit.dtos.js +21 -7
- package/src/routes/audit.routes.js +4 -1
- package/src/routes/traxAudit.routes.js +7 -13
- package/src/service/userEmpDetection.service.js +2 -0
package/package.json
CHANGED
|
@@ -4302,3 +4302,32 @@ export async function getUserAuditCountMTD( req, res ) {
|
|
|
4302
4302
|
}
|
|
4303
4303
|
}
|
|
4304
4304
|
|
|
4305
|
+
export async function auditViewLogs( req, res ) {
|
|
4306
|
+
try {
|
|
4307
|
+
const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
|
|
4308
|
+
let downTimeQuery = {
|
|
4309
|
+
'size': 100,
|
|
4310
|
+
'query': {
|
|
4311
|
+
'bool': {
|
|
4312
|
+
'must': [
|
|
4313
|
+
{
|
|
4314
|
+
'term': {
|
|
4315
|
+
'doc.date.keyword': dayjs( inputQuery.filedate ).format( 'DD-MM-YYYY' ),
|
|
4316
|
+
},
|
|
4317
|
+
},
|
|
4318
|
+
{
|
|
4319
|
+
'term': {
|
|
4320
|
+
'doc.store_id.keyword': inputQuery.storeId,
|
|
4321
|
+
},
|
|
4322
|
+
},
|
|
4323
|
+
],
|
|
4324
|
+
|
|
4325
|
+
},
|
|
4326
|
+
},
|
|
4327
|
+
};
|
|
4328
|
+
const downtime = await getOpenSearchData( parsedOpenSearch.activityLog, downTimeQuery );
|
|
4329
|
+
return res.sendSuccess( downtime );
|
|
4330
|
+
} catch ( err ) {
|
|
4331
|
+
|
|
4332
|
+
}
|
|
4333
|
+
}
|
|
@@ -7,12 +7,15 @@ import { aggregateTraxAuditData, findOneTraxAuditData } from '../service/traxAud
|
|
|
7
7
|
import { aggregateClient } from '../service/client.service.js';
|
|
8
8
|
import dayjs from 'dayjs';
|
|
9
9
|
import { aggregateAssignAudit } from '../service/assignAudit.service.js';
|
|
10
|
-
import { aggregateStoreEmpDetection, updateManyStoreEmpDetection } from '../service/storeEmpDetection.service.js';
|
|
10
|
+
import { aggregateStoreEmpDetection, updateManyStoreEmpDetection, updateOneStoreEmpDetection } from '../service/storeEmpDetection.service.js';
|
|
11
11
|
import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
12
12
|
import _ from 'lodash';
|
|
13
13
|
import mongoose from 'mongoose';
|
|
14
|
-
import { findOneAuditLog
|
|
15
|
-
|
|
14
|
+
import { findOneAuditLog, createAuditLog,
|
|
15
|
+
} from '../service/auditLog.service.js';
|
|
16
|
+
import {
|
|
17
|
+
findOneUserEmpDetection,
|
|
18
|
+
} from '../service/userEmpDetection.service.js';
|
|
16
19
|
|
|
17
20
|
// export async function getDetectionAuditFile( req, res ) {
|
|
18
21
|
// try {
|
|
@@ -334,13 +337,13 @@ import { findOneAuditLog } from '../service/auditLog.service.js';
|
|
|
334
337
|
// const data = await signedUrl( fetchData );
|
|
335
338
|
// const mapimg = {
|
|
336
339
|
// img_path: data,
|
|
337
|
-
// img_name:
|
|
338
|
-
// img_id:
|
|
340
|
+
// img_name: image[0],
|
|
341
|
+
// img_id: indexes[1],
|
|
339
342
|
// };
|
|
340
343
|
// files.push( {
|
|
341
344
|
// img_path: data,
|
|
342
|
-
//
|
|
343
|
-
// img_id:
|
|
345
|
+
// img_name: image[0],
|
|
346
|
+
// img_id: indexes[1],
|
|
344
347
|
// selected: false,
|
|
345
348
|
// dropped: false,
|
|
346
349
|
// count: 1,
|
|
@@ -709,7 +712,7 @@ export async function workSpace( req, res ) {
|
|
|
709
712
|
{ clientId: { $in: clientList } },
|
|
710
713
|
{ userId: { $eq: req.user._id } },
|
|
711
714
|
{ moduleType: { $eq: inputData.moduleType } },
|
|
712
|
-
{ createdAt: { $gte:
|
|
715
|
+
{ createdAt: { $gte: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ) } },
|
|
713
716
|
{ createdAt: { $lte: dateRange.end } },
|
|
714
717
|
],
|
|
715
718
|
},
|
|
@@ -742,6 +745,8 @@ export async function workSpace( req, res ) {
|
|
|
742
745
|
},
|
|
743
746
|
];
|
|
744
747
|
|
|
748
|
+
logger.info( { moduleType: inputData.moduleType, key: [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType ), dateStart: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ), end: dateRange.end, user: req.user._id, client: clientList } );
|
|
749
|
+
|
|
745
750
|
const userAsignAudit = [
|
|
746
751
|
{
|
|
747
752
|
$match: {
|
|
@@ -794,10 +799,11 @@ export async function workSpace( req, res ) {
|
|
|
794
799
|
},
|
|
795
800
|
];
|
|
796
801
|
|
|
797
|
-
const auditUserCount =
|
|
798
|
-
const userIncompleteFilesCount =
|
|
802
|
+
const auditUserCount = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( auditFiles ) : await aggregateBinaryAudit( auditFiles );
|
|
803
|
+
const userIncompleteFilesCount = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( userIncompleteFiles ) : await aggregateBinaryAudit( userIncompleteFiles );
|
|
804
|
+
logger.info( { moduleType: inputData.moduleType, userIncompleteFiles: userIncompleteFilesCount } );
|
|
799
805
|
const userAsignAuditCount = await aggregateAssignAudit( userAsignAudit );
|
|
800
|
-
const completedStoresCount =
|
|
806
|
+
const completedStoresCount = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( completedStores ) : await aggregateBinaryAudit( binarCompletedStores );
|
|
801
807
|
const clientAssignedCount = await aggregateAssignAudit( clientAssign );
|
|
802
808
|
const auditStoreData = await aggregateTraxAuditData(
|
|
803
809
|
auditStoreDataQuery,
|
|
@@ -1694,7 +1700,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1694
1700
|
},
|
|
1695
1701
|
);
|
|
1696
1702
|
}
|
|
1697
|
-
const count =
|
|
1703
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1698
1704
|
if ( count.length == 0 ) {
|
|
1699
1705
|
return res.sendError( 'No Data Found', 204 );
|
|
1700
1706
|
}
|
|
@@ -1764,7 +1770,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1764
1770
|
{
|
|
1765
1771
|
$limit: limit,
|
|
1766
1772
|
} );
|
|
1767
|
-
const result =
|
|
1773
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1768
1774
|
|
|
1769
1775
|
return res.sendSuccess( { result: result, count: count.length } );
|
|
1770
1776
|
} catch ( error ) {
|
|
@@ -2423,7 +2429,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2423
2429
|
},
|
|
2424
2430
|
);
|
|
2425
2431
|
}
|
|
2426
|
-
const count =
|
|
2432
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
2427
2433
|
|
|
2428
2434
|
if ( count.length == 0 ) {
|
|
2429
2435
|
return res.sendError( 'No data Found', 204 );
|
|
@@ -2438,7 +2444,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2438
2444
|
} else {
|
|
2439
2445
|
query.push( { $limit: 10000 } );
|
|
2440
2446
|
}
|
|
2441
|
-
const result =
|
|
2447
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2442
2448
|
if ( inputData.isExport ) {
|
|
2443
2449
|
const exportdata = [];
|
|
2444
2450
|
result.forEach( ( element ) => {
|
|
@@ -2741,7 +2747,7 @@ export async function userMetrics( req, res ) {
|
|
|
2741
2747
|
);
|
|
2742
2748
|
}
|
|
2743
2749
|
|
|
2744
|
-
const count =
|
|
2750
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2745
2751
|
if ( count.length == 0 ) {
|
|
2746
2752
|
return res.sendError( 'No Data Found', 204 );
|
|
2747
2753
|
}
|
|
@@ -2775,7 +2781,7 @@ export async function userMetrics( req, res ) {
|
|
|
2775
2781
|
'Product Type': '$value',
|
|
2776
2782
|
// 'Mapping Percentage': '$mappingPerc',
|
|
2777
2783
|
};
|
|
2778
|
-
|
|
2784
|
+
[ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?
|
|
2779
2785
|
query.push(
|
|
2780
2786
|
{
|
|
2781
2787
|
$project: detection,
|
|
@@ -2789,7 +2795,7 @@ export async function userMetrics( req, res ) {
|
|
|
2789
2795
|
}
|
|
2790
2796
|
|
|
2791
2797
|
|
|
2792
|
-
const result =
|
|
2798
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2793
2799
|
if ( inputData.isExport ) {
|
|
2794
2800
|
await download( result, res );
|
|
2795
2801
|
return;
|
|
@@ -2933,7 +2939,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2933
2939
|
},
|
|
2934
2940
|
);
|
|
2935
2941
|
}
|
|
2936
|
-
const count =
|
|
2942
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2937
2943
|
if ( count.length == 0 ) {
|
|
2938
2944
|
return res.sendError( 'No Data Found', 204 );
|
|
2939
2945
|
}
|
|
@@ -2949,7 +2955,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2949
2955
|
} );
|
|
2950
2956
|
}
|
|
2951
2957
|
|
|
2952
|
-
const result =
|
|
2958
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2953
2959
|
if ( inputData.isExport ) {
|
|
2954
2960
|
const exportdata = [];
|
|
2955
2961
|
result.forEach( ( element ) => {
|
|
@@ -3143,7 +3149,7 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
3143
3149
|
},
|
|
3144
3150
|
];
|
|
3145
3151
|
|
|
3146
|
-
const storeAudit =
|
|
3152
|
+
const storeAudit = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( storeAuditQuery ) : await aggregateBinaryAudit( binaryAuditQuery );
|
|
3147
3153
|
if ( storeAudit.length > 0 ) {
|
|
3148
3154
|
temp.inprogressStores= storeAudit[0].inprogressStores;
|
|
3149
3155
|
temp.completedStores = storeAudit[0].completedStores;
|
|
@@ -3274,7 +3280,7 @@ export async function summarySplit( req, res ) {
|
|
|
3274
3280
|
},
|
|
3275
3281
|
},
|
|
3276
3282
|
];
|
|
3277
|
-
const result =
|
|
3283
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3278
3284
|
const totalCount = await aggregateTraxAuditData( totalQuery );
|
|
3279
3285
|
result[0].totalCount = totalCount[0]?.total;
|
|
3280
3286
|
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
@@ -3421,7 +3427,7 @@ export async function overviewTable( req, res ) {
|
|
|
3421
3427
|
},
|
|
3422
3428
|
);
|
|
3423
3429
|
}
|
|
3424
|
-
const count =
|
|
3430
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3425
3431
|
if ( count.length == 0 ) {
|
|
3426
3432
|
return res.sendError( 'No Data Found', 204 );
|
|
3427
3433
|
}
|
|
@@ -3436,7 +3442,7 @@ export async function overviewTable( req, res ) {
|
|
|
3436
3442
|
$limit: limit,
|
|
3437
3443
|
} );
|
|
3438
3444
|
}
|
|
3439
|
-
const result =
|
|
3445
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3440
3446
|
if ( inputData.isExport ) {
|
|
3441
3447
|
const exportdata = [];
|
|
3442
3448
|
result.forEach( ( element ) => {
|
|
@@ -3809,13 +3815,13 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
3809
3815
|
const data = await signedUrl( fetchData );
|
|
3810
3816
|
const mapimg = {
|
|
3811
3817
|
img_path: data,
|
|
3812
|
-
img_name:
|
|
3813
|
-
img_id:
|
|
3818
|
+
img_name: image[0],
|
|
3819
|
+
img_id: indexes[1],
|
|
3814
3820
|
};
|
|
3815
3821
|
files.push( {
|
|
3816
3822
|
img_path: data,
|
|
3817
|
-
img_name:
|
|
3818
|
-
img_id:
|
|
3823
|
+
img_name: image[0],
|
|
3824
|
+
img_id: indexes[1],
|
|
3819
3825
|
selected: false,
|
|
3820
3826
|
dropped: false,
|
|
3821
3827
|
count: 1,
|
|
@@ -3942,7 +3948,7 @@ export async function saveDraft( req, res ) {
|
|
|
3942
3948
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
3943
3949
|
const inputData = req.body;
|
|
3944
3950
|
inputData.userId = req.user._id;
|
|
3945
|
-
const getUserAuditData = await
|
|
3951
|
+
const getUserAuditData = await findOneUserEmpDetection( { _id: inputData.auditId } );
|
|
3946
3952
|
if ( !getUserAuditData ) {
|
|
3947
3953
|
return res.sendError( 'No Data Found', 204 );
|
|
3948
3954
|
}
|
|
@@ -3960,7 +3966,6 @@ export async function saveDraft( req, res ) {
|
|
|
3960
3966
|
const storeQuery = {
|
|
3961
3967
|
storeId: inputData.storeId,
|
|
3962
3968
|
fileDate: inputData.fileDate,
|
|
3963
|
-
zoneName: inputData.zoneName,
|
|
3964
3969
|
};
|
|
3965
3970
|
|
|
3966
3971
|
let storeRecord = {
|
|
@@ -4000,8 +4005,8 @@ export async function saveDraft( req, res ) {
|
|
|
4000
4005
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
4001
4006
|
}
|
|
4002
4007
|
await createAuditLog( inputData );
|
|
4003
|
-
await
|
|
4004
|
-
await
|
|
4008
|
+
await updateOneUserEmpDetection( userQuery, userRecord );
|
|
4009
|
+
await updateOneStoreEmpDetection( storeQuery, storeRecord );
|
|
4005
4010
|
return res.sendSuccess( {
|
|
4006
4011
|
result: 'The file has been drafted successfully',
|
|
4007
4012
|
} );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { getFileSchema, userAuditHistorySchema, workSpaceSchema, saveSchema, clientMetricsSchema, storeMetricsSchema, userMetricsSchema, pendingSummaryTableSchema, overAllAuditSummarySchema, overviewTableSchema, summarySplitSchema, getUpdatedFileSchema, getDetectionFileValid } from '../dtos/traxAudit.dtos.js';
|
|
2
|
+
import { getFileSchema, userAuditHistorySchema, workSpaceSchema, saveSchema, clientMetricsSchema, storeMetricsSchema, userMetricsSchema, pendingSummaryTableSchema, overAllAuditSummarySchema, overviewTableSchema, summarySplitSchema, getUpdatedFileSchema, getDetectionFileValid, saveBinarySchema, saveDraftSchema, getDraftedDataSchema } from '../dtos/traxAudit.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const traxAuditDocs = {
|
|
5
5
|
|
|
@@ -124,7 +124,7 @@ export const traxAuditDocs = {
|
|
|
124
124
|
requestBody: {
|
|
125
125
|
content: {
|
|
126
126
|
'application/json': {
|
|
127
|
-
schema: j2s(
|
|
127
|
+
schema: j2s( saveBinarySchema ).swagger,
|
|
128
128
|
},
|
|
129
129
|
},
|
|
130
130
|
},
|
|
@@ -317,4 +317,90 @@ export const traxAuditDocs = {
|
|
|
317
317
|
},
|
|
318
318
|
},
|
|
319
319
|
},
|
|
320
|
+
'/v3/trax-audit/save': {
|
|
321
|
+
post: {
|
|
322
|
+
tags: [ 'Trax Audit' ],
|
|
323
|
+
description: `submit the audit file. which is store in the bucket in the json format`,
|
|
324
|
+
operationId: 'save',
|
|
325
|
+
parameters: {},
|
|
326
|
+
requestBody: {
|
|
327
|
+
content: {
|
|
328
|
+
'application/json': {
|
|
329
|
+
schema: j2s( saveSchema ).swagger,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
responses: {
|
|
334
|
+
200: { description: 'The Audited file has been submited successfully ' },
|
|
335
|
+
401: { description: 'Unauthorized User' },
|
|
336
|
+
422: { description: 'Field Error' },
|
|
337
|
+
500: { description: 'Server Error' },
|
|
338
|
+
204: { description: 'Not Found' },
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
|
|
343
|
+
'/v3/trax-audit/save-draft': {
|
|
344
|
+
post: {
|
|
345
|
+
tags: [ 'Trax Audit' ],
|
|
346
|
+
description: `save audited file. which is save in the mongo db`,
|
|
347
|
+
operationId: 'save-draft',
|
|
348
|
+
parameters: {},
|
|
349
|
+
requestBody: {
|
|
350
|
+
content: {
|
|
351
|
+
'application/json': {
|
|
352
|
+
schema: j2s( saveDraftSchema ).swagger,
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
responses: {
|
|
357
|
+
200: { description: 'Successful' },
|
|
358
|
+
401: { description: 'Unauthorized User' },
|
|
359
|
+
422: { description: 'Field Error' },
|
|
360
|
+
500: { description: 'Server Error' },
|
|
361
|
+
204: { description: 'Not Found' },
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
|
|
366
|
+
'/v3/trax-audit/get-drafted-data': {
|
|
367
|
+
get: {
|
|
368
|
+
tags: [ 'Trax Audit' ],
|
|
369
|
+
description: 'Get a saved file via DB',
|
|
370
|
+
operationId: 'get-drafted-data',
|
|
371
|
+
parameters: [
|
|
372
|
+
{
|
|
373
|
+
in: 'query',
|
|
374
|
+
name: 'fileDate',
|
|
375
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
376
|
+
require: true,
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
in: 'query',
|
|
380
|
+
name: 'storeId',
|
|
381
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
382
|
+
require: true,
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
in: 'query',
|
|
386
|
+
name: 'moduleType',
|
|
387
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
388
|
+
require: true,
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
in: 'query',
|
|
392
|
+
name: 'userId',
|
|
393
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
394
|
+
require: false,
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
responses: {
|
|
398
|
+
200: { description: 'Successful' },
|
|
399
|
+
401: { description: 'Unauthorized User' },
|
|
400
|
+
422: { description: 'Field Error' },
|
|
401
|
+
500: { description: 'Server Error' },
|
|
402
|
+
204: { description: 'Not Found' },
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
},
|
|
320
406
|
};
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -96,8 +96,6 @@ export const saveSchema = joi.object( {
|
|
|
96
96
|
employee: joi.array().required(),
|
|
97
97
|
customerCount: joi.number().required(),
|
|
98
98
|
customer: joi.array().required(),
|
|
99
|
-
moduleType: joi.string().required(),
|
|
100
|
-
zoneName: joi.string().required(),
|
|
101
99
|
} );
|
|
102
100
|
|
|
103
101
|
export const saveValid = {
|
|
@@ -45,7 +45,7 @@ export const saveDraftSchema = joi.object(
|
|
|
45
45
|
storeId: joi.string().required(),
|
|
46
46
|
auditId: joi.string().required(),
|
|
47
47
|
moduleType: joi.string().required(),
|
|
48
|
-
zoneName: joi.string().required(),
|
|
48
|
+
// zoneName: joi.string().required(),
|
|
49
49
|
auditType: joi.string().required(),
|
|
50
50
|
fileDate: joi.string().required(),
|
|
51
51
|
queueName: joi.string().required(),
|
|
@@ -54,8 +54,6 @@ export const saveDraftSchema = joi.object(
|
|
|
54
54
|
junk: joi.array().optional(),
|
|
55
55
|
employeeCount: joi.number().optional(),
|
|
56
56
|
employee: joi.array().optional(),
|
|
57
|
-
customerCount: joi.number().optional(),
|
|
58
|
-
customer: joi.array().optional(),
|
|
59
57
|
retagCount: joi.number().optional(),
|
|
60
58
|
retagImage: joi.array().optional(),
|
|
61
59
|
},
|
|
@@ -71,7 +69,6 @@ export const getDraftedDataSchema = joi.object(
|
|
|
71
69
|
fileDate: joi.string().required(),
|
|
72
70
|
userId: joi.string().optional(),
|
|
73
71
|
moduleType: joi.string().required(),
|
|
74
|
-
zoneName: joi.string().required(),
|
|
75
72
|
},
|
|
76
73
|
);
|
|
77
74
|
|
|
@@ -79,7 +76,7 @@ export const getDraftedDataValid = {
|
|
|
79
76
|
query: getDraftedDataSchema,
|
|
80
77
|
};
|
|
81
78
|
|
|
82
|
-
export const
|
|
79
|
+
export const saveBinarySchema = joi.object(
|
|
83
80
|
{
|
|
84
81
|
auditId: joi.string().required(),
|
|
85
82
|
storeId: joi.string().required(),
|
|
@@ -93,8 +90,8 @@ export const saveSchema = joi.object(
|
|
|
93
90
|
},
|
|
94
91
|
);
|
|
95
92
|
|
|
96
|
-
export const
|
|
97
|
-
body:
|
|
93
|
+
export const saveBinaryValid = {
|
|
94
|
+
body: saveBinarySchema,
|
|
98
95
|
};
|
|
99
96
|
|
|
100
97
|
export const workSpaceSchema = joi.object(
|
|
@@ -268,3 +265,20 @@ export const overviewTableSchema = joi.object(
|
|
|
268
265
|
export const overviewTableValid= {
|
|
269
266
|
body: overviewTableSchema,
|
|
270
267
|
};
|
|
268
|
+
|
|
269
|
+
export const saveSchema = joi.object( {
|
|
270
|
+
auditId: joi.string().required(),
|
|
271
|
+
storeId: joi.string().required(),
|
|
272
|
+
fileDate: joi.string().required(),
|
|
273
|
+
auditType: joi.string().required(),
|
|
274
|
+
moduleType: joi.string().required(),
|
|
275
|
+
beforeCount: joi.number().required(),
|
|
276
|
+
junkCount: joi.number().required(),
|
|
277
|
+
junk: joi.array().required(),
|
|
278
|
+
employeeCount: joi.number().required(),
|
|
279
|
+
employee: joi.array().required(),
|
|
280
|
+
} );
|
|
281
|
+
|
|
282
|
+
export const saveValid = {
|
|
283
|
+
body: saveSchema,
|
|
284
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isAuditDocumentExist, isAuditInputFolderExist, isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overviewTable, pendingSummaryTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, totalNotAssignedCount, userAuditHistory, userMetrics, workSpace, getUserAuditCount, getUserAuditCountMTD } from '../controllers/audit.controllers.js';
|
|
4
|
+
import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overviewTable, pendingSummaryTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, totalNotAssignedCount, userAuditHistory, userMetrics, workSpace, getUserAuditCount, getUserAuditCountMTD, auditViewLogs } from '../controllers/audit.controllers.js';
|
|
5
5
|
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, pendingSummaryTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid, overviewTableValid } from '../dtos/audit.dtos.js';
|
|
6
6
|
|
|
7
7
|
export const auditRouter = express.Router();
|
|
@@ -39,4 +39,7 @@ auditRouter.get( '/total-not-assigned-count', isAllowedSessionHandler, totalNotA
|
|
|
39
39
|
// audit user wallet
|
|
40
40
|
auditRouter.get( '/get-user-audit-count', isAllowedSessionHandler, getUserAuditCount );
|
|
41
41
|
auditRouter.get( '/get-user-audit-count-mtd', isAllowedSessionHandler, getUserAuditCountMTD );
|
|
42
|
+
|
|
43
|
+
// audit log
|
|
44
|
+
auditRouter.get( '/audit-viewLogs', auditViewLogs );
|
|
42
45
|
export default auditRouter;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
3
|
-
import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid, getUpdatedFileValid } from '../dtos/traxAudit.dtos.js';
|
|
3
|
+
import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid, getUpdatedFileValid, saveBinaryValid, getDraftedDataValid, saveDraftValid } from '../dtos/traxAudit.dtos.js';
|
|
4
4
|
import { isExistsQueue } from '../validation/audit.validation.js';
|
|
5
5
|
import { clientMetrics, getAuditFile, getDetectionAuditFile, getUpdatedFile, overAllAuditSummary, overviewTable, pendingSummaryTable, saveBinary, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace, saveDraft, getDraftedData, save } from '../controllers/traxAudit.controllers.js';
|
|
6
6
|
import { isTraxAuditDocumentExist, validateBinaryAudit } from '../validation/traxAuditValidation.js';
|
|
@@ -9,19 +9,19 @@ export const traxAuditRouter = Router();
|
|
|
9
9
|
|
|
10
10
|
// Audit Mapping
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
traxAuditRouter.post( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
|
|
12
|
+
traxAuditRouter.get( '/get-file-detection', isAllowedSessionHandler, validate( getDetectionFileValid ), isExistsQueue, getDetectionAuditFile );
|
|
13
|
+
traxAuditRouter.post( '/save', validate( saveValid ), isAllowedSessionHandler, save );
|
|
14
|
+
traxAuditRouter.post( '/save-draft', validate( saveDraftValid ), isAllowedSessionHandler, saveDraft );
|
|
15
|
+
traxAuditRouter.get( '/get-drafted-data', validate( getDraftedDataValid ), isAllowedSessionHandler, getDraftedData );
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
// Y/n
|
|
20
19
|
traxAuditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ), isExistsQueue, getAuditFile );
|
|
21
20
|
traxAuditRouter.post( '/get-updated-file', isAllowedSessionHandler, validate( getUpdatedFileValid ), isTraxAuditDocumentExist, getUpdatedFile );
|
|
22
|
-
traxAuditRouter.post( '/save-binary-audit', isAllowedSessionHandler, validate(
|
|
21
|
+
traxAuditRouter.post( '/save-binary-audit', isAllowedSessionHandler, validate( saveBinaryValid ), validateBinaryAudit, saveBinary );
|
|
23
22
|
|
|
24
23
|
// metrcis
|
|
24
|
+
traxAuditRouter.post( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
|
|
25
25
|
traxAuditRouter.post( '/metrics/user-audit-history', isAllowedSessionHandler, validate( userAuditHistoryValid ), userAuditHistory );
|
|
26
26
|
traxAuditRouter.post( '/metrics/client-metrics', isAllowedSessionHandler, validate( clientMetricsValid ), clientMetrics );
|
|
27
27
|
traxAuditRouter.post( '/metrics/store-metrics', isAllowedSessionHandler, validate( storeMetricsValid ), storeMetrics );
|
|
@@ -34,10 +34,4 @@ traxAuditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler,
|
|
|
34
34
|
traxAuditRouter.post( '/metrics/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
|
|
35
35
|
traxAuditRouter.post( '/metrics/overview-table', isAllowedSessionHandler, validate( overviewTableValid ), overviewTable );
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
traxAuditRouter.get( '/get-file-detection', isAllowedSessionHandler, validate( getDetectionFileValid ), isExistsQueue, getDetectionAuditFile );
|
|
39
|
-
traxAuditRouter.post( '/save', isAllowedSessionHandler, save );
|
|
40
|
-
traxAuditRouter.post( '/save-draft', isAllowedSessionHandler, saveDraft );
|
|
41
|
-
traxAuditRouter.get( '/get-drafted-data', isAllowedSessionHandler, getDraftedData );
|
|
42
|
-
|
|
43
37
|
export default traxAuditRouter;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import userEmpDetectionModel from 'tango-api-schema/schema/userEmpDetection.model.js';
|
|
2
|
+
import { logger } from 'tango-app-api-middleware';
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
export function aggregateUserEmpDetection( query ) {
|
|
6
|
+
logger.info( { seelevt: 'yryruteretwyyyyyyyyyyyyyyyyyyyyyyyyyyyyewe' } );
|
|
5
7
|
return userEmpDetectionModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
6
8
|
}
|
|
7
9
|
|