tango-app-api-audit 3.3.0-alpha.3 → 3.3.0-alpha.4
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 +68 -0
- package/src/routes/audit.routes.js +1 -2
- package/src/validation/audit.validation.js +1 -1
- package/src/controllers/auditMetrics.controllers.js +0 -71
- package/src/controllers/zoneAudit.controller.js +0 -1827
- package/src/docs/auditMetrics.docs.js +0 -70
- package/src/docs/zoneAudit.docs.js +0 -268
- package/src/dtos/auditMetrics.dtos.js +0 -39
- package/src/dtos/zoneAudit.dtos.js +0 -171
- package/src/routes/auditMetrics.routes.js +0 -14
- package/src/routes/zone.routes.js +0 -24
- package/src/validation/zoneAudit.validation.js +0 -167
package/package.json
CHANGED
|
@@ -42,12 +42,15 @@ import {
|
|
|
42
42
|
} from '../service/auditLog.service.js';
|
|
43
43
|
import { aggregateStore, countDocumentsStore, findOneStore } from '../service/store.service.js';
|
|
44
44
|
import {
|
|
45
|
+
getAuditFilterData,
|
|
46
|
+
getAuditImageData,
|
|
45
47
|
mapCustomer,
|
|
46
48
|
mapEmployee,
|
|
47
49
|
mapJunk,
|
|
48
50
|
splitB20000,
|
|
49
51
|
splitE0,
|
|
50
52
|
splitG20000,
|
|
53
|
+
zipDownloadImage,
|
|
51
54
|
} from '../validation/audit.validation.js';
|
|
52
55
|
import mongoose from 'mongoose';
|
|
53
56
|
import {
|
|
@@ -3047,3 +3050,68 @@ export async function summarySplit( req, res ) {
|
|
|
3047
3050
|
return res.sendError( err, 500 );
|
|
3048
3051
|
}
|
|
3049
3052
|
}
|
|
3053
|
+
|
|
3054
|
+
|
|
3055
|
+
export async function auditImages( req, res ) {
|
|
3056
|
+
try {
|
|
3057
|
+
const inputData = req.query;
|
|
3058
|
+
let auditImageDownload = '';
|
|
3059
|
+
switch ( inputData.imageType ) {
|
|
3060
|
+
case 'BC':
|
|
3061
|
+
const auditImageBC = await getAuditImageData( inputData );
|
|
3062
|
+
if ( auditImageBC?.errorCode ) {
|
|
3063
|
+
const error = auditImageBC?.errorMsg;
|
|
3064
|
+
const code = auditImageBC?.errorCode;
|
|
3065
|
+
return res.sendError( { error: error }, code );
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
if ( inputData.export==true ) {
|
|
3069
|
+
auditImageDownload= await zipDownloadImage( auditImageBC );
|
|
3070
|
+
// Set response headers for the zip file
|
|
3071
|
+
res.set( 'Content-Type', 'application/zip' );
|
|
3072
|
+
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
3073
|
+
|
|
3074
|
+
// Send the zip file as the API response
|
|
3075
|
+
return res.send( auditImageDownload );
|
|
3076
|
+
}
|
|
3077
|
+
res.sendSuccess( { result: auditImageBC } );
|
|
3078
|
+
|
|
3079
|
+
break;
|
|
3080
|
+
|
|
3081
|
+
case 'AC':
|
|
3082
|
+
|
|
3083
|
+
const [ filterData, auditImageAC ] = await Promise.all( [ getAuditFilterData( inputData ), getAuditImageData( inputData ) ] );
|
|
3084
|
+
|
|
3085
|
+
if ( filterData?.errorCode || auditImageAC?.errorCode ) {
|
|
3086
|
+
const error = filterData?.errorMsg || auditImageAC.errorMsg;
|
|
3087
|
+
const code = filterData?.errorCode || auditImageAC.errorCode;
|
|
3088
|
+
return res.sendError( { error: error }, code );
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
const reauditImg = await getReauditImg( filterData, auditImageAC );
|
|
3092
|
+
|
|
3093
|
+
logger.info( { auditImageAC: auditImageAC, filterData: filterData, reauditImg: reauditImg } );
|
|
3094
|
+
if ( inputData.export==true ) {
|
|
3095
|
+
auditImageDownload= await zipDownloadImage( reauditImg );
|
|
3096
|
+
// Set response headers for the zip file
|
|
3097
|
+
res.set( 'Content-Type', 'application/zip' );
|
|
3098
|
+
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
3099
|
+
|
|
3100
|
+
// Send the zip file as the API response
|
|
3101
|
+
return res.send( auditImageDownload );
|
|
3102
|
+
}
|
|
3103
|
+
res.sendSuccess( { result: reauditImg } );
|
|
3104
|
+
break;
|
|
3105
|
+
default:
|
|
3106
|
+
res.sendError( 'No Data Found', 204 );
|
|
3107
|
+
break;
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
|
|
3111
|
+
// return res.sendSuccess( { result: inputData } );
|
|
3112
|
+
} catch ( error ) {
|
|
3113
|
+
const err = error.message || 'Internal Server Error';
|
|
3114
|
+
logger.info( { error: error, message: req.body, function: 'beforeCountImages' } );
|
|
3115
|
+
return res.sendError( err, 500 );
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
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 { auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overViewTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/audit.controllers.js';
|
|
4
|
+
import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overViewTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/audit.controllers.js';
|
|
5
5
|
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, overViewTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid } from '../dtos/audit.dtos.js';
|
|
6
|
-
import { auditImages } from '../controllers/auditMetrics.controllers.js';
|
|
7
6
|
|
|
8
7
|
export const auditRouter = express.Router();
|
|
9
8
|
|
|
@@ -212,7 +212,7 @@ export async function getAuditImageData( data ) {
|
|
|
212
212
|
const fileDate = data.fileDate;
|
|
213
213
|
const files = [];
|
|
214
214
|
const fetchData = {
|
|
215
|
-
Bucket: `${bucket.
|
|
215
|
+
Bucket: `${bucket.auditOutput}`,
|
|
216
216
|
filePath: `${fileDate}/${storeId}/${data.zoneName}/`,
|
|
217
217
|
};
|
|
218
218
|
const folderPath = await listFileWithoutLimit( fetchData );
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { logger } from 'tango-app-api-middleware';
|
|
2
|
-
import { getAuditFilterData, getAuditImageData, zipDownloadImage } from '../validation/audit.validation.js';
|
|
3
|
-
import { getReauditImg } from './audit.controllers.js';
|
|
4
|
-
// import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export async function auditImages( req, res ) {
|
|
8
|
-
try {
|
|
9
|
-
const inputData = req.query;
|
|
10
|
-
let auditImageDownload = '';
|
|
11
|
-
switch ( inputData.imageType ) {
|
|
12
|
-
case 'BC':
|
|
13
|
-
const auditImageBC = await getAuditImageData( inputData );
|
|
14
|
-
if ( auditImageBC?.errorCode ) {
|
|
15
|
-
const error = auditImageBC?.errorMsg;
|
|
16
|
-
const code = auditImageBC?.errorCode;
|
|
17
|
-
return res.sendError( { error: error }, code );
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if ( inputData.export==true ) {
|
|
21
|
-
auditImageDownload= await zipDownloadImage( auditImageBC );
|
|
22
|
-
// Set response headers for the zip file
|
|
23
|
-
res.set( 'Content-Type', 'application/zip' );
|
|
24
|
-
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
25
|
-
|
|
26
|
-
// Send the zip file as the API response
|
|
27
|
-
return res.send( auditImageDownload );
|
|
28
|
-
}
|
|
29
|
-
res.sendSuccess( { result: auditImageBC } );
|
|
30
|
-
|
|
31
|
-
break;
|
|
32
|
-
|
|
33
|
-
case 'AC':
|
|
34
|
-
|
|
35
|
-
const [ filterData, auditImageAC ] = await Promise.all( [ getAuditFilterData( inputData ), getAuditImageData( inputData ) ] );
|
|
36
|
-
|
|
37
|
-
if ( filterData?.errorCode || auditImageAC?.errorCode ) {
|
|
38
|
-
const error = filterData?.errorMsg || auditImageAC.errorMsg;
|
|
39
|
-
const code = filterData?.errorCode || auditImageAC.errorCode;
|
|
40
|
-
return res.sendError( { error: error }, code );
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const reauditImg = await getReauditImg( filterData, auditImageAC );
|
|
44
|
-
|
|
45
|
-
logger.info( { filterData: filterData } );
|
|
46
|
-
logger.info( { auditImageAC: auditImageAC } );
|
|
47
|
-
logger.info( { reauditImg: reauditImg } );
|
|
48
|
-
if ( inputData.export==true ) {
|
|
49
|
-
auditImageDownload= await zipDownloadImage( reauditImg );
|
|
50
|
-
// Set response headers for the zip file
|
|
51
|
-
res.set( 'Content-Type', 'application/zip' );
|
|
52
|
-
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
53
|
-
|
|
54
|
-
// Send the zip file as the API response
|
|
55
|
-
return res.send( auditImageDownload );
|
|
56
|
-
}
|
|
57
|
-
res.sendSuccess( { result: reauditImg } );
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
res.sendError( 'No Data Found', 204 );
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// return res.sendSuccess( { result: inputData } );
|
|
66
|
-
} catch ( error ) {
|
|
67
|
-
const err = error.message || 'Internal Server Error';
|
|
68
|
-
logger.info( { error: error, message: req.body, function: 'beforeCountImages' } );
|
|
69
|
-
return res.sendError( err, 500 );
|
|
70
|
-
}
|
|
71
|
-
}
|