tango-app-api-task 3.3.1-hotfix-3 → 3.4.0-alpha-1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-task",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-alpha-1",
|
|
4
4
|
"description": "Task",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"mongodb": "^6.10.0",
|
|
25
25
|
"nodemon": "^3.1.7",
|
|
26
26
|
"npm": "^10.9.2",
|
|
27
|
-
"tango-api-schema": "^2.2.
|
|
27
|
+
"tango-api-schema": "^2.2.73",
|
|
28
28
|
"tango-app-api-middleware": "^3.1.58",
|
|
29
29
|
"winston": "^3.17.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger, fileUpload, signedUrl, getObject } from 'tango-app-api-middleware';
|
|
1
|
+
import { logger, fileUpload, signedUrl, getObject, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
2
2
|
import * as taskService from '../service/task.service.js';
|
|
3
3
|
import * as checklistLogs from '../service/checklistLog.service.js';
|
|
4
4
|
import * as taskQuestionService from '../service/taskQuestion.service.js';
|
|
@@ -1688,6 +1688,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1688
1688
|
section_id: inputBody.sectionId,
|
|
1689
1689
|
qno: inputBody.qno,
|
|
1690
1690
|
parentQuestion: inputBody.parentQuestion,
|
|
1691
|
+
uniqueNo: inputBody.uniqueNo,
|
|
1691
1692
|
},
|
|
1692
1693
|
'upsert': {
|
|
1693
1694
|
taskId: String( response?._id ),
|
|
@@ -1696,7 +1697,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1696
1697
|
taskDate: dayjs( response.scheduleDate ).format( 'YYYY-MM-DD' ),
|
|
1697
1698
|
},
|
|
1698
1699
|
};
|
|
1699
|
-
|
|
1700
|
+
console.log( params );
|
|
1700
1701
|
const requestOptions = {
|
|
1701
1702
|
method: 'POST',
|
|
1702
1703
|
headers: {
|
|
@@ -1712,6 +1713,26 @@ export async function createChecklistTask( req, res ) {
|
|
|
1712
1713
|
if ( !searchResponse.ok ) {
|
|
1713
1714
|
return res.sendError( 'Something went wrong', 500 );
|
|
1714
1715
|
}
|
|
1716
|
+
let logData= {
|
|
1717
|
+
'client_id': inputBody.clientId,
|
|
1718
|
+
'createAt': new Date(),
|
|
1719
|
+
'sourceCheckList_id': taskDetails.sourceCheckList_id,
|
|
1720
|
+
'checkListName': inputBody.checkListName,
|
|
1721
|
+
'fromCheckListName': taskDetails.checkListName,
|
|
1722
|
+
'type': 'task',
|
|
1723
|
+
'action': 'created',
|
|
1724
|
+
'store_id': storeDetails?.storeId?storeDetails.storeId:'',
|
|
1725
|
+
'storeName': inputBody?.storeName?inputBody?.storeName:'',
|
|
1726
|
+
'createdByEmail': req.user.email,
|
|
1727
|
+
'createdBy': req.user._id,
|
|
1728
|
+
'userName': inputBody.userName,
|
|
1729
|
+
'userEmail': inputBody.userEmail,
|
|
1730
|
+
'coverage': 'store',
|
|
1731
|
+
'logDetails': {},
|
|
1732
|
+
};
|
|
1733
|
+
let urlopensearch = JSON.parse( process.env.OPENSEARCH );
|
|
1734
|
+
console.log( 'logData', logData );
|
|
1735
|
+
await insertOpenSearchData( urlopensearch.traxActivityLog, logData );
|
|
1715
1736
|
}
|
|
1716
1737
|
await insertSingleProcessData( response?._id );
|
|
1717
1738
|
return res.sendSuccess( 'Task created successfully' );
|
|
@@ -1722,6 +1743,225 @@ export async function createChecklistTask( req, res ) {
|
|
|
1722
1743
|
}
|
|
1723
1744
|
}
|
|
1724
1745
|
|
|
1746
|
+
export async function createChecklistMultiTask( req, res ) {
|
|
1747
|
+
try {
|
|
1748
|
+
let inputBody = req.body;
|
|
1749
|
+
console.log( inputBody );
|
|
1750
|
+
let inputData= inputBody.coverage==='user'?inputBody.userEmail:inputBody.storeName;
|
|
1751
|
+
let userDetailList;
|
|
1752
|
+
for ( let user of inputData ) {
|
|
1753
|
+
userDetailList = await userService.findOne( { email: user.userEmail } );
|
|
1754
|
+
if ( !userDetailList ) {
|
|
1755
|
+
let userData = {
|
|
1756
|
+
userName: user.userName,
|
|
1757
|
+
email: user.userEmail,
|
|
1758
|
+
mobileNumber: '',
|
|
1759
|
+
clientId: inputBody.clientId,
|
|
1760
|
+
};
|
|
1761
|
+
userDetailList = await createUser( userData );
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
// let title = `New Task Alert ${inputBody.checkListName}`;
|
|
1766
|
+
// let description = '';
|
|
1767
|
+
|
|
1768
|
+
// if ( inputBody.checkListType === 'checklistTask' ) {
|
|
1769
|
+
// description = `A new task has been generated from the response for ${inputBody.storeName}.`;
|
|
1770
|
+
// } else if ( inputBody.checkListType === 'CCTV' ) {
|
|
1771
|
+
// description = `A new task has been generated from the Live view for ${inputBody.storeName}.`;
|
|
1772
|
+
// }
|
|
1773
|
+
|
|
1774
|
+
// if ( userDetails.fcmToken ) {
|
|
1775
|
+
// const fcmToken = userDetails.fcmToken;
|
|
1776
|
+
// await sendPushNotification( title, description, fcmToken );
|
|
1777
|
+
// }
|
|
1778
|
+
|
|
1779
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
1780
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
1781
|
+
for ( let originaldata of inputData ) {
|
|
1782
|
+
let checklistDetails = await checklistService.findOne( { _id: originaldata?.checkListId }, { coverage: 1 } );
|
|
1783
|
+
let data = {
|
|
1784
|
+
checkListName: inputBody.checkListName,
|
|
1785
|
+
checkListDescription: inputBody.checkListDescription,
|
|
1786
|
+
createdBy: req.user._id,
|
|
1787
|
+
createdByName: req.user.userName,
|
|
1788
|
+
publish: true,
|
|
1789
|
+
questionCount: 1,
|
|
1790
|
+
storeCount: 1,
|
|
1791
|
+
scheduleDate: date,
|
|
1792
|
+
scheduleEndTime: time,
|
|
1793
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
1794
|
+
priorityType: 'high',
|
|
1795
|
+
client_id: inputBody.clientId,
|
|
1796
|
+
checkListType: inputBody.checkListType,
|
|
1797
|
+
publishDate: new Date(),
|
|
1798
|
+
locationCount: 1,
|
|
1799
|
+
...( originaldata?.checkListId ) ? { referenceCheckListId: originaldata?.checkListId } : {},
|
|
1800
|
+
coverage: checklistDetails?.coverage || 'store',
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
if ( req.user.userType == 'tango' || ( req.user.userType == 'client' && [ 'user' ].includes( req.user.role ) ) ) {
|
|
1804
|
+
let userList = await userService.findOne( { clientId: inputBody.clientId, role: 'superadmin' }, { userName: 1, email: 1 } );
|
|
1805
|
+
if ( userList ) {
|
|
1806
|
+
data['approver'] = { name: userList.userName, value: userList.email };
|
|
1807
|
+
}
|
|
1808
|
+
} else {
|
|
1809
|
+
data['approver'] = { name: req.user.userName, value: req.user.email };
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
let response = await taskService.create( data );
|
|
1813
|
+
if ( response?.approver.length ) {
|
|
1814
|
+
let data = [];
|
|
1815
|
+
response?.approver.forEach( ( ele ) => {
|
|
1816
|
+
data.push( {
|
|
1817
|
+
userEmail: ele.value,
|
|
1818
|
+
checkListId: response._id,
|
|
1819
|
+
type: 'task',
|
|
1820
|
+
client_id: inputBody.clientId,
|
|
1821
|
+
checkListName: inputBody?.checkListName || '',
|
|
1822
|
+
} );
|
|
1823
|
+
} );
|
|
1824
|
+
await traxApprover.insertMany( data );
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
if ( response?._id ) {
|
|
1828
|
+
if ( inputBody.question[0].questionReferenceImage.length ) {
|
|
1829
|
+
let images = [];
|
|
1830
|
+
inputBody.question[0].questionReferenceImage.forEach( ( ele ) => {
|
|
1831
|
+
let imgUrl = decodeURIComponent( ele.split( '?' )[0] );
|
|
1832
|
+
let url = imgUrl.split( '/' );
|
|
1833
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
1834
|
+
url.splice( 0, 3 );
|
|
1835
|
+
}
|
|
1836
|
+
images.push( url.join( '/' ) );
|
|
1837
|
+
} );
|
|
1838
|
+
inputBody.question[0].questionReferenceImage = images;
|
|
1839
|
+
}
|
|
1840
|
+
if ( inputBody.question[0].answers[0].referenceImage.length ) {
|
|
1841
|
+
let images = [];
|
|
1842
|
+
inputBody.question[0].answers[0].referenceImage.forEach( ( ele ) => {
|
|
1843
|
+
let imgUrl = decodeURIComponent( ele.split( '?' )[0] );
|
|
1844
|
+
let url = imgUrl.split( '/' );
|
|
1845
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
1846
|
+
url.splice( 0, 3 );
|
|
1847
|
+
}
|
|
1848
|
+
images.push( url.join( '/' ) );
|
|
1849
|
+
} );
|
|
1850
|
+
inputBody.question[0].answers[0].referenceImage = images;
|
|
1851
|
+
}
|
|
1852
|
+
let question = {
|
|
1853
|
+
checkListId: response?._id,
|
|
1854
|
+
question: inputBody.question,
|
|
1855
|
+
section: 'Section 1',
|
|
1856
|
+
checkList: data.checkListName,
|
|
1857
|
+
client_id: inputBody.clientId,
|
|
1858
|
+
};
|
|
1859
|
+
await taskQuestionService.create( question );
|
|
1860
|
+
let storeDetails;
|
|
1861
|
+
if ( originaldata?.storeName ) {
|
|
1862
|
+
storeDetails = await storeService.findOne( { storeName: originaldata.storeName, status: 'active' }, { storeId: 1, storeProfile: 1 } );
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
let userDetails = {
|
|
1866
|
+
userName: originaldata.userName?originaldata.userName:'',
|
|
1867
|
+
userEmail: originaldata.userEmail?originaldata.userEmail:'',
|
|
1868
|
+
store_id: storeDetails?.storeId?storeDetails.storeId:'',
|
|
1869
|
+
storeName: originaldata?.storeName?originaldata?.storeName:'',
|
|
1870
|
+
city: storeDetails?.storeProfile?.city?storeDetails?.storeProfile?.city:'',
|
|
1871
|
+
checkFlag: true,
|
|
1872
|
+
checkListId: response?._id,
|
|
1873
|
+
checkListName: data.checkListName,
|
|
1874
|
+
client_id: inputBody.clientId,
|
|
1875
|
+
userId: userDetailList&&userDetailList._id?userDetailList._id:'',
|
|
1876
|
+
assignId: response?.coverage == 'store' ? storeDetails?._id : userDetailList._id,
|
|
1877
|
+
coverage: response?.coverage || 'store',
|
|
1878
|
+
};
|
|
1879
|
+
await taskAssignService.create( userDetails );
|
|
1880
|
+
console.log( originaldata?.checklistId );
|
|
1881
|
+
if ( inputBody.checkListType == 'checklistTask' ) {
|
|
1882
|
+
let taskDetails = await processedChecklist.findOne( { _id: originaldata?.checklistId }, { questionAnswers: 1, taskStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1 } );
|
|
1883
|
+
console.log( taskDetails );
|
|
1884
|
+
if ( !taskDetails ) {
|
|
1885
|
+
return res.sendError( 'No data found', 204 );
|
|
1886
|
+
}
|
|
1887
|
+
let question = taskDetails.questionAnswers;
|
|
1888
|
+
let sectionIndex = question.findIndex( ( sec ) => sec?.sectionName == req.body?.sectionName );
|
|
1889
|
+
if ( sectionIndex == -1 ) {
|
|
1890
|
+
return res.sendError( 'section is not found', 400 );
|
|
1891
|
+
}
|
|
1892
|
+
let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.qno );
|
|
1893
|
+
|
|
1894
|
+
let data = { ...question[sectionIndex].questions[findQuestion], taskId: response?._id, task: true };
|
|
1895
|
+
question[sectionIndex].questions[req.body.qno - 1] = data;
|
|
1896
|
+
taskDetails.questionAnswers = question;
|
|
1897
|
+
let updateData = {
|
|
1898
|
+
taskStatus: true,
|
|
1899
|
+
questionAnswers: question,
|
|
1900
|
+
};
|
|
1901
|
+
await processedChecklist.updateOne( { _id: originaldata.checklistId }, updateData );
|
|
1902
|
+
let params = {
|
|
1903
|
+
'payload': {
|
|
1904
|
+
_id: originaldata.checklistId,
|
|
1905
|
+
section_id: originaldata.section_id,
|
|
1906
|
+
uniqueNo: originaldata.uniqueNo,
|
|
1907
|
+
qno: inputBody.qno,
|
|
1908
|
+
parentQuestion: inputBody.parentQuestion,
|
|
1909
|
+
},
|
|
1910
|
+
'upsert': {
|
|
1911
|
+
taskId: String( response?._id ),
|
|
1912
|
+
taskStatus: true,
|
|
1913
|
+
task: true,
|
|
1914
|
+
taskDate: dayjs( response.scheduleDate ).format( 'YYYY-MM-DD' ),
|
|
1915
|
+
},
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
const requestOptions = {
|
|
1919
|
+
method: 'POST',
|
|
1920
|
+
headers: {
|
|
1921
|
+
'Content-Type': 'application/json',
|
|
1922
|
+
},
|
|
1923
|
+
body: JSON.stringify( params ),
|
|
1924
|
+
};
|
|
1925
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1926
|
+
|
|
1927
|
+
let searchResponse = await fetch( url.redoChecklist, requestOptions );
|
|
1928
|
+
console.log( searchResponse.ok );
|
|
1929
|
+
|
|
1930
|
+
|
|
1931
|
+
if ( !searchResponse.ok ) {
|
|
1932
|
+
return res.sendError( 'Something went wrong', 500 );
|
|
1933
|
+
}
|
|
1934
|
+
let logData= {
|
|
1935
|
+
'client_id': inputBody.clientId,
|
|
1936
|
+
'createAt': new Date(),
|
|
1937
|
+
'sourceCheckList_id': taskDetails.sourceCheckList_id,
|
|
1938
|
+
'checkListName': inputBody.checkListName,
|
|
1939
|
+
'fromCheckListName': taskDetails.checkListName,
|
|
1940
|
+
'type': 'task',
|
|
1941
|
+
'action': 'created',
|
|
1942
|
+
'store_id': storeDetails?.storeId?storeDetails.storeId:'',
|
|
1943
|
+
'storeName': originaldata?.storeName?originaldata?.storeName:'',
|
|
1944
|
+
'createdByEmail': req.user.email,
|
|
1945
|
+
'createdBy': req.user._id,
|
|
1946
|
+
// 'userName': inputBody.userName,
|
|
1947
|
+
// 'userEmail': inputBody.userEmail,
|
|
1948
|
+
'coverage': 'store',
|
|
1949
|
+
'logDetails': {},
|
|
1950
|
+
};
|
|
1951
|
+
let urlopensearch = JSON.parse( process.env.OPENSEARCH );
|
|
1952
|
+
console.log( 'logData', logData );
|
|
1953
|
+
await insertOpenSearchData( urlopensearch.traxActivityLog, logData );
|
|
1954
|
+
}
|
|
1955
|
+
await insertSingleProcessData( response?._id );
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
1959
|
+
} catch ( e ) {
|
|
1960
|
+
logger.error( { functionName: 'createChecklistMultiTask', error: e, message: req.body } );
|
|
1961
|
+
return res.sendError( e, 500 );
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1725
1965
|
export async function approveTask( req, res ) {
|
|
1726
1966
|
try {
|
|
1727
1967
|
let toDate = new Date( req.body.toDate );
|
|
@@ -1801,7 +2041,7 @@ export async function redoTask( req, res ) {
|
|
|
1801
2041
|
return res.sendError( 'Question number is Required', 400 );
|
|
1802
2042
|
}
|
|
1803
2043
|
|
|
1804
|
-
let taskDetails = await taskProcessedService.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1 } );
|
|
2044
|
+
let taskDetails = await taskProcessedService.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1, userEmail: 1, coverage: 1 } );
|
|
1805
2045
|
if ( !taskDetails ) {
|
|
1806
2046
|
return res.sendError( 'No data found', 204 );
|
|
1807
2047
|
}
|
|
@@ -1866,6 +2106,26 @@ export async function redoTask( req, res ) {
|
|
|
1866
2106
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1867
2107
|
let searchResponse = await fetch( url.redoTask, requestOptions );
|
|
1868
2108
|
// console.log( searchResponse.ok );
|
|
2109
|
+
let logData= {
|
|
2110
|
+
'client_id': taskDetails.client_id,
|
|
2111
|
+
'createAt': new Date(),
|
|
2112
|
+
'sourceCheckList_id': taskDetails.sourceCheckList_id,
|
|
2113
|
+
'checkListName': taskDetails.checkListName,
|
|
2114
|
+
'fromCheckListName': taskDetails.checkListName,
|
|
2115
|
+
'type': 'checklist',
|
|
2116
|
+
'action': 'redo',
|
|
2117
|
+
'storeName': taskDetails?.storeName?taskDetails?.storeName:'',
|
|
2118
|
+
'store_id': taskDetails?.store_id?taskDetails?.store_id:'',
|
|
2119
|
+
'userName': taskDetails.userName,
|
|
2120
|
+
'userEmail': taskDetails.userEmail,
|
|
2121
|
+
'createdByEmail': req.user.email,
|
|
2122
|
+
'createdBy': req.user.userName,
|
|
2123
|
+
'coverage': taskDetails.coverage,
|
|
2124
|
+
'logDetails': {},
|
|
2125
|
+
};
|
|
2126
|
+
let urlopensearch = JSON.parse( process.env.OPENSEARCH );
|
|
2127
|
+
console.log( 'logData', logData );
|
|
2128
|
+
await insertOpenSearchData( urlopensearch.traxActivityLog, logData );
|
|
1869
2129
|
if ( searchResponse.ok ) {
|
|
1870
2130
|
return res.sendSuccess( 'Question redo successfully' );
|
|
1871
2131
|
} else {
|
|
@@ -1879,6 +2139,117 @@ export async function redoTask( req, res ) {
|
|
|
1879
2139
|
return res.sendError( e, 500 );
|
|
1880
2140
|
}
|
|
1881
2141
|
}
|
|
2142
|
+
export async function redomultiTask( req, res ) {
|
|
2143
|
+
try {
|
|
2144
|
+
let inputData = req.body.payload.coverage==='user'?req.body.payload.userEmail:req.body.payload.storeName;
|
|
2145
|
+
|
|
2146
|
+
|
|
2147
|
+
for ( let originalData of inputData ) {
|
|
2148
|
+
if ( !originalData.checklistId ) {
|
|
2149
|
+
return res.sendError( 'Id is Required', 400 );
|
|
2150
|
+
}
|
|
2151
|
+
if ( !originalData.section_id ) {
|
|
2152
|
+
return res.sendError( 'Section id is Required', 400 );
|
|
2153
|
+
}
|
|
2154
|
+
if ( !req.body.payload.qno ) {
|
|
2155
|
+
return res.sendError( 'Question number is Required', 400 );
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
let taskDetails = await taskProcessedService.findOne( { _id: originalData.checklistId }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1, userEmail: 1, coverage: 1 } );
|
|
2159
|
+
if ( !taskDetails ) {
|
|
2160
|
+
return res.sendError( 'No data found', 204 );
|
|
2161
|
+
}
|
|
2162
|
+
let question = taskDetails.questionAnswers;
|
|
2163
|
+
let sectionIndex = question.findIndex( ( sec ) => sec.section_id == req.body.payload.section_id );
|
|
2164
|
+
if ( sectionIndex == -1 ) {
|
|
2165
|
+
return res.sendError( 'section is not found', 400 );
|
|
2166
|
+
}
|
|
2167
|
+
let data = { ...question[sectionIndex].questions[req.body.payload.qno - 1], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
|
|
2168
|
+
let userAnswer = data.userAnswer;
|
|
2169
|
+
|
|
2170
|
+
question[sectionIndex].questions[req.body.payload.qno - 1] = data;
|
|
2171
|
+
question[sectionIndex].questions[req.body.payload.qno - 1].remarks = '';
|
|
2172
|
+
question[sectionIndex].questions[req.body.payload.qno - 1].userAnswer = [];
|
|
2173
|
+
taskDetails.questionAnswers = question;
|
|
2174
|
+
let updateData = {
|
|
2175
|
+
checklistStatus: 'open',
|
|
2176
|
+
redoStatus: true,
|
|
2177
|
+
questionAnswers: question,
|
|
2178
|
+
...( dayjs.utc( taskDetails.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ) == dayjs().format( 'YYYY-MM-DD' ) ) ? { scheduleEndTime_iso: dayjs.utc().endOf( 'day' ) } : {},
|
|
2179
|
+
};
|
|
2180
|
+
|
|
2181
|
+
let response = await taskProcessedService.updateOne( { _id: originalData.checklistId }, updateData );
|
|
2182
|
+
// console.log( response );
|
|
2183
|
+
if ( response.modifiedCount || response.matchedCount ) {
|
|
2184
|
+
let storeTimeZone = await storeService.findOne( { storeName: taskDetails.storeName }, { 'storeProfile.timeZone': 1 } );
|
|
2185
|
+
let currentDateTime;
|
|
2186
|
+
if ( storeTimeZone?.storeProfile?.timeZone ) {
|
|
2187
|
+
currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
|
|
2188
|
+
} else {
|
|
2189
|
+
currentDateTime = dayjs();
|
|
2190
|
+
}
|
|
2191
|
+
data = {
|
|
2192
|
+
checklistId: taskDetails.sourceCheckList_id,
|
|
2193
|
+
checkListName: taskDetails.checkListName,
|
|
2194
|
+
checklistDescription: req.body.payload.checklistDescription,
|
|
2195
|
+
sectionId: originalData.section_id,
|
|
2196
|
+
sectionName: question[sectionIndex].sectionName,
|
|
2197
|
+
questionName: question[sectionIndex].questions[req.body.payload.qno - 1].qname,
|
|
2198
|
+
action: 'redo',
|
|
2199
|
+
store_id: taskDetails?.store_id?taskDetails?.store_id:'',
|
|
2200
|
+
storeName: taskDetails.storeName?taskDetails.storeName:'',
|
|
2201
|
+
client_id: taskDetails.client_id,
|
|
2202
|
+
processedChecklistId: taskDetails._id,
|
|
2203
|
+
type: taskDetails.checkListType,
|
|
2204
|
+
userAnswer: userAnswer,
|
|
2205
|
+
initiatedBy: req.user.userName,
|
|
2206
|
+
initiatedTime: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
|
|
2207
|
+
answerType: question[sectionIndex].questions[req.body.payload.qno - 1].answerType,
|
|
2208
|
+
submitedBy: taskDetails.userName,
|
|
2209
|
+
submitTime: taskDetails.submitTime,
|
|
2210
|
+
};
|
|
2211
|
+
req.body.payload._id=originalData.checklistId;
|
|
2212
|
+
req.body.payload.section_id=originalData.section_id;
|
|
2213
|
+
req.body.payload.uniqueNo=originalData.uniqueNo;
|
|
2214
|
+
await checklistLogs.create( data );
|
|
2215
|
+
const requestOptions = {
|
|
2216
|
+
method: 'POST',
|
|
2217
|
+
headers: {
|
|
2218
|
+
'Content-Type': 'application/json',
|
|
2219
|
+
},
|
|
2220
|
+
body: JSON.stringify( req.body ),
|
|
2221
|
+
};
|
|
2222
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
2223
|
+
let searchResponse = await fetch( url.redoTask, requestOptions );
|
|
2224
|
+
console.log( searchResponse.ok );
|
|
2225
|
+
let logData= {
|
|
2226
|
+
'client_id': taskDetails.client_id,
|
|
2227
|
+
'createAt': new Date(),
|
|
2228
|
+
'sourceCheckList_id': taskDetails.sourceCheckList_id,
|
|
2229
|
+
'checkListName': taskDetails.checkListName,
|
|
2230
|
+
'fromCheckListName': taskDetails.checkListName,
|
|
2231
|
+
'type': 'checklist',
|
|
2232
|
+
'action': 'redo',
|
|
2233
|
+
'storeName': taskDetails?.storeName?taskDetails?.storeName:'',
|
|
2234
|
+
'store_id': taskDetails?.store_id?taskDetails?.store_id:'',
|
|
2235
|
+
'userName': taskDetails.userName,
|
|
2236
|
+
'userEmail': taskDetails.userEmail,
|
|
2237
|
+
'createdByEmail': req.user.email,
|
|
2238
|
+
'createdBy': req.user.userName,
|
|
2239
|
+
'coverage': taskDetails.coverage,
|
|
2240
|
+
'logDetails': {},
|
|
2241
|
+
};
|
|
2242
|
+
let urlopensearch = JSON.parse( process.env.OPENSEARCH );
|
|
2243
|
+
console.log( 'logData', logData );
|
|
2244
|
+
await insertOpenSearchData( urlopensearch.traxActivityLog, logData );
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
return res.sendSuccess( 'Question redo successfully' );
|
|
2248
|
+
} catch ( e ) {
|
|
2249
|
+
logger.error( { function: 'redomultiTask', error: e, message: req.body } );
|
|
2250
|
+
return res.sendError( e, 500 );
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
1882
2253
|
|
|
1883
2254
|
|
|
1884
2255
|
export async function getQuestions( req, res ) {
|
|
@@ -4149,6 +4520,7 @@ export async function taskcreation( req, res ) {
|
|
|
4149
4520
|
checkListName: data.checkListName,
|
|
4150
4521
|
client_id: inputBody.clientId,
|
|
4151
4522
|
userId: userId,
|
|
4523
|
+
assignId: storeDetails._id,
|
|
4152
4524
|
};
|
|
4153
4525
|
await taskAssignService.create( userDetails );
|
|
4154
4526
|
await insertSingleProcessData( response?._id );
|
|
@@ -15,8 +15,10 @@ taskRouter
|
|
|
15
15
|
.post( '/config', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.taskConfig )
|
|
16
16
|
.post( '/reinitiate', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.reinitiateTask )
|
|
17
17
|
.post( '/checklistTask', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.createChecklistTask )
|
|
18
|
+
.post( '/checklistMultiTask', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.createChecklistMultiTask )
|
|
18
19
|
.post( '/updateApprove', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.approveTask )
|
|
19
20
|
.post( '/redo', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.redoTask )
|
|
21
|
+
.post( '/multiredo', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.redomultiTask )
|
|
20
22
|
.post( '/taskDropdown', isAllowedSessionHandler, taskController.taskDropdown )
|
|
21
23
|
.post( '/getQuestions', isAllowedSessionHandler, taskController.getQuestions )
|
|
22
24
|
.post( '/getAnswers', isAllowedSessionHandler, taskController.getAnswers )
|