tango-app-api-trax 3.3.1-airtelai-4 → 3.3.1-airtelai-6
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 +2 -2
- package/src/controllers/internalTrax.controller.js +2 -2
- package/src/controllers/mobileTrax.controller.js +182 -0
- package/src/controllers/trax.controller.js +1 -1
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/mobileTrax.routes.js +1 -0
- package/src/services/camera.service.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.3.1-airtelai-
|
|
3
|
+
"version": "3.3.1-airtelai-6",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mongodb": "^6.8.0",
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
|
-
"tango-api-schema": "^2.2.
|
|
29
|
+
"tango-api-schema": "^2.2.97",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.72",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -304,7 +304,7 @@ async function insertData( requestData ) {
|
|
|
304
304
|
},
|
|
305
305
|
} );
|
|
306
306
|
let getSections = await CLquestions.aggregate( sectionQuery );
|
|
307
|
-
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall' ].includes( getCLconfig.checkListType ) ) {
|
|
307
|
+
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall','drinking','bagdetection' ].includes( getCLconfig.checkListType ) ) {
|
|
308
308
|
if ( getSections.length ) {
|
|
309
309
|
for ( let element3 of getSections ) {
|
|
310
310
|
let collectQuestions = {};
|
|
@@ -597,7 +597,7 @@ async function insertData( requestData ) {
|
|
|
597
597
|
// }
|
|
598
598
|
}
|
|
599
599
|
} else {
|
|
600
|
-
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall' ].includes( getCLconfig.checkListType ) ) {
|
|
600
|
+
if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall','drinking','bagdetection' ].includes( getCLconfig.checkListType ) ) {
|
|
601
601
|
let storeNameList = allQuestion.map( ( item ) => item.store_id );
|
|
602
602
|
let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'cleaning', 'scrum' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
|
|
603
603
|
let storeList = storeDetails.map( ( store ) => store.storeId );
|
|
@@ -25,6 +25,7 @@ import handlebars from 'handlebars';
|
|
|
25
25
|
dayjs.extend( customParseFormat );
|
|
26
26
|
dayjs.extend( timeZone );
|
|
27
27
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';
|
|
28
|
+
import * as cameraService from '../services/camera.service.js';
|
|
28
29
|
dayjs.extend( isSameOrBefore );
|
|
29
30
|
|
|
30
31
|
export async function storeList( req, res ) {
|
|
@@ -2017,6 +2018,184 @@ export async function submitTask( req, res ) {
|
|
|
2017
2018
|
return res.sendError( error.message || 'Internal Server Error', 500 );
|
|
2018
2019
|
}
|
|
2019
2020
|
}
|
|
2021
|
+
export async function submiteyeTestTask( req, res ) {
|
|
2022
|
+
try {
|
|
2023
|
+
const { body: requestData, user } = req;
|
|
2024
|
+
const { processedcheckListId, date, submittype, currentTime, questionAnswers,streamId,qrCode } = requestData;
|
|
2025
|
+
console.log(requestData)
|
|
2026
|
+
if(!streamId){
|
|
2027
|
+
return res.sendError("streamId is required",500)
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
let findQrExists = await cameraService.findOne({streamName:streamId,qrCode:qrCode})
|
|
2031
|
+
console.log(findQrExists)
|
|
2032
|
+
if(findQrExists){
|
|
2033
|
+
return res.sendError("Qr code already Exists",500)
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
await cameraService.updateOne({streamName:streamId},{qrCode:qrCode})
|
|
2037
|
+
|
|
2038
|
+
|
|
2039
|
+
|
|
2040
|
+
const findQuery = [
|
|
2041
|
+
{
|
|
2042
|
+
$match: {
|
|
2043
|
+
_id: new ObjectId( processedcheckListId ),
|
|
2044
|
+
userId: user._id,
|
|
2045
|
+
date_string: date,
|
|
2046
|
+
},
|
|
2047
|
+
},
|
|
2048
|
+
];
|
|
2049
|
+
|
|
2050
|
+
const [ checklist ] = await processedTask.aggregate( findQuery );
|
|
2051
|
+
|
|
2052
|
+
if ( !checklist ) {
|
|
2053
|
+
return res.sendError( 'Task edited. Please fill again', 422 );
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
// eslint-disable-next-line camelcase
|
|
2057
|
+
const { checklistStatus, storeName, userEmail, checkListName, store_id } = checklist;
|
|
2058
|
+
|
|
2059
|
+
if ( checklistStatus === 'open' ) {
|
|
2060
|
+
return res.sendError( 'Checklist is in open status. Please start.', 400 );
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
if ( checklistStatus === 'submit' ) {
|
|
2064
|
+
return res.sendError( 'Checklist already submitted', 400 );
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
const storeTimeZone = await storeService.findOne( { storeName }, { 'storeProfile.timeZone': 1 } );
|
|
2068
|
+
const currentDateTime = storeTimeZone?.storeProfile?.timeZone ?
|
|
2069
|
+
dayjs().tz( storeTimeZone.storeProfile.timeZone ) :
|
|
2070
|
+
dayjs();
|
|
2071
|
+
|
|
2072
|
+
const updateQuery = {
|
|
2073
|
+
_id: new ObjectId( processedcheckListId ),
|
|
2074
|
+
userId: user._id,
|
|
2075
|
+
date_string: date,
|
|
2076
|
+
};
|
|
2077
|
+
|
|
2078
|
+
// questionAnswers.forEach( ( section ) => {
|
|
2079
|
+
// section.questions.forEach( ( question ) => {
|
|
2080
|
+
// if ( question.redo === true ) {
|
|
2081
|
+
// question.redo = false;
|
|
2082
|
+
// }
|
|
2083
|
+
// } );
|
|
2084
|
+
// } );
|
|
2085
|
+
|
|
2086
|
+
const updateData = {
|
|
2087
|
+
questionAnswers,
|
|
2088
|
+
updatedAt: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
|
|
2089
|
+
questionFlag: QuestionFlag( req, res ),
|
|
2090
|
+
};
|
|
2091
|
+
|
|
2092
|
+
if ( submittype === 'draft' ) {
|
|
2093
|
+
logger.info(
|
|
2094
|
+
`v5 => Checklist Save => store Name: ${storeName}, User Email: ${userEmail}, Checklist Name: ${checkListName}`,
|
|
2095
|
+
);
|
|
2096
|
+
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2097
|
+
} else if ( submittype === 'submit' ) {
|
|
2098
|
+
logger.info(
|
|
2099
|
+
`v5 => Checklist Submit => store Name: ${storeName}, User Email: ${userEmail}, Checklist Name: ${checkListName}`,
|
|
2100
|
+
);
|
|
2101
|
+
Object.assign( updateData, {
|
|
2102
|
+
submitTime: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
|
|
2103
|
+
checklistStatus: 'submit',
|
|
2104
|
+
submitMobileTime: currentTime,
|
|
2105
|
+
submitTime_string: currentDateTime.format( 'hh:mm A, DD MMM YYYY' ),
|
|
2106
|
+
} );
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
const updateResult = await processedTask.updateOne( updateQuery, updateData );
|
|
2110
|
+
|
|
2111
|
+
if ( updateResult.modifiedCount > 0 ) {
|
|
2112
|
+
if ( submittype === 'submit' ) {
|
|
2113
|
+
const query1 = [
|
|
2114
|
+
{
|
|
2115
|
+
$match: {
|
|
2116
|
+
userId: user._id,
|
|
2117
|
+
sourceCheckList_id: checklist.sourceCheckList_id,
|
|
2118
|
+
checklistStatus: { $in: [ 'open', 'inprogress' ] },
|
|
2119
|
+
},
|
|
2120
|
+
},
|
|
2121
|
+
{
|
|
2122
|
+
$project: {
|
|
2123
|
+
_id: 1,
|
|
2124
|
+
date_iso: 1,
|
|
2125
|
+
date_string: 1,
|
|
2126
|
+
},
|
|
2127
|
+
},
|
|
2128
|
+
];
|
|
2129
|
+
|
|
2130
|
+
const processedTasksToDelete = await processedTask.aggregate( query1 );
|
|
2131
|
+
|
|
2132
|
+
if ( processedTasksToDelete?.length ) {
|
|
2133
|
+
const deleteIds = processedTasksToDelete?.filter( ( val ) => val?.date_string !== date )?.map( ( val ) => val?._id );
|
|
2134
|
+
|
|
2135
|
+
if ( deleteIds?.length ) {
|
|
2136
|
+
await processedTask.deleteMany( { _id: { $in: deleteIds } } );
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
} else if ( submittype === 'draft' ) {
|
|
2140
|
+
const query2 = [
|
|
2141
|
+
{
|
|
2142
|
+
$match: {
|
|
2143
|
+
_id: checklist.sourceCheckList_id,
|
|
2144
|
+
},
|
|
2145
|
+
},
|
|
2146
|
+
];
|
|
2147
|
+
const [ taskConfig ] = await taskConfigService.aggregate( query2 );
|
|
2148
|
+
|
|
2149
|
+
if ( taskConfig.scheduleEndTimeISO ) {
|
|
2150
|
+
const endDate = dayjs( taskConfig.scheduleEndTimeISO ).utc();
|
|
2151
|
+
const startDate = dayjs().add( 1, 'day' );
|
|
2152
|
+
|
|
2153
|
+
let currentDate = startDate;
|
|
2154
|
+
|
|
2155
|
+
while ( currentDate.isSameOrBefore( endDate ) ) {
|
|
2156
|
+
const updateDate = currentDate.format( 'YYYY-MM-DD' );
|
|
2157
|
+
|
|
2158
|
+
const updateQuery = {
|
|
2159
|
+
sourceCheckList_id: taskConfig._id,
|
|
2160
|
+
date_string: updateDate,
|
|
2161
|
+
userId: user._id,
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
if ( Object.values( updateQuery ).length === 3 ) {
|
|
2165
|
+
await processedTask.updateOne( updateQuery, { questionAnswers, checklistStatus: 'inprogress' } );
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
currentDate = currentDate.add( 1, 'day' );
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
const logInsertData = {
|
|
2173
|
+
// eslint-disable-next-line camelcase
|
|
2174
|
+
store_id,
|
|
2175
|
+
storeName,
|
|
2176
|
+
action: submittype === 'draft' ? 'saved' : 'submitted',
|
|
2177
|
+
checklistId: checklist.sourceCheckList_id,
|
|
2178
|
+
processedChecklistId: checklist._id,
|
|
2179
|
+
type: checklist.checkListType,
|
|
2180
|
+
checkListName,
|
|
2181
|
+
client_id: user.clientId,
|
|
2182
|
+
redoStatus: requestData?.redoStatus ? true : false,
|
|
2183
|
+
};
|
|
2184
|
+
await checklistLogs.create( logInsertData );
|
|
2185
|
+
|
|
2186
|
+
if ( submittype == 'submit' ) {
|
|
2187
|
+
updateOpenSearchTask( user, requestData );
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
return res.sendSuccess( 'Task Updated Successfully' );
|
|
2191
|
+
} else {
|
|
2192
|
+
return res.sendError( 'Something went wrong. Please try again', 500 );
|
|
2193
|
+
}
|
|
2194
|
+
} catch ( error ) {
|
|
2195
|
+
logger.error( { function: 'submiteyeTestTask', error, body: req.body } );
|
|
2196
|
+
return res.sendError( error.message || 'Internal Server Error', 500 );
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2020
2199
|
|
|
2021
2200
|
|
|
2022
2201
|
async function updateOpenSearch( user, data ) {
|
|
@@ -2463,6 +2642,7 @@ export async function checklistv1( req, res ) {
|
|
|
2463
2642
|
client_id: { $ifNull: [ '$client_id', '' ] },
|
|
2464
2643
|
coverage: { $ifNull: [ '$coverage', '' ] },
|
|
2465
2644
|
taskType: { $ifNull: [ '$planoType', '' ] },
|
|
2645
|
+
streamId: { $ifNull: [ '$streamId', '' ] },
|
|
2466
2646
|
},
|
|
2467
2647
|
},
|
|
2468
2648
|
];
|
|
@@ -2557,6 +2737,8 @@ export async function questionList( req, res ) {
|
|
|
2557
2737
|
storeName: { $ifNull: [ '$storeName', '' ] },
|
|
2558
2738
|
redoStatus: { $ifNull: [ '$redoStatus', false ] },
|
|
2559
2739
|
rawImageUpload: { $ifNull: [ '$rawImageUpload', false ] },
|
|
2740
|
+
taskType: { $ifNull: [ '$planoType', '' ] },
|
|
2741
|
+
streamId: { $ifNull: [ '$streamId', '' ] },
|
|
2560
2742
|
},
|
|
2561
2743
|
} );
|
|
2562
2744
|
|
|
@@ -3463,7 +3463,7 @@ async function updateOpenSearch( user, data ) {
|
|
|
3463
3463
|
export const aiChecklist = async ( req, res ) => {
|
|
3464
3464
|
try {
|
|
3465
3465
|
let storeDetails = await storeService.count( { clientId: req.query.clientId, status: 'active' } );
|
|
3466
|
-
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall' ];
|
|
3466
|
+
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall','drinking','bagdetection' ];
|
|
3467
3467
|
let checklistDetails = [];
|
|
3468
3468
|
let publishList = [];
|
|
3469
3469
|
let unpublishList = [];
|