Surya: test

This commit is contained in:
surya 2021-09-24 11:31:53 +05:30
parent 17a2157483
commit 8381e7830e
2 changed files with 121 additions and 94 deletions

View File

@ -1,4 +1,5 @@
const { response } = require('express');
const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods , Entityfinyears } = require('../models') const { sequelize, Entities , Financials , Statementsmaster , Sectionsmaster , Subsectionsmaster , Brokenperiods , Entityfinyears } = require('../models')
const { logMsg } = require('../services/logger.js'); const { logMsg } = require('../services/logger.js');
@ -250,15 +251,19 @@ exports.test = (req, res) => {
exports.test2 = (req, res) => { exports.test2 = async (req, res) => {
const losid = req.query.losid const losid = req.query.losid
const promise = Promise.resolve(res.send({'losid':losid,'status':200,'message':"success"}));
const p1 = losid => new Promise((resolve,reject) =>{
//console.log(losid)
resolve(losid)
})
p1(1).then((losid) => {
// const promise = Promise.resolve(res.send({'losid':losid,'status':200,'message':"success"}));
var promise = (losid) => new Promise((resolve,reject) =>{
resolve(losid)
})
// p1(losid).then((losid) => {
promise(losid).then((losid) => {
console.log(losid)
//pro 42 api call using losid //pro 42 api call using losid
const Pro42Data = [ const Pro42Data = [
{"losid":losid,"pan":"AA1234AAAA","cin":"test1_cin","bizname":"test1_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4}, {"losid":losid,"pan":"AA1234AAAA","cin":"test1_cin","bizname":"test1_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4},
@ -323,16 +328,23 @@ exports.test = (req, res) => {
} //end of else condition } //end of else condition
}); // end of (losid,pan,cin) combination checking entity data exist or not }) // end of (losid,pan,cin) combination checking entity data exist or not
}); // end of pro42 data foreach }) // end of pro42 data foreach
return ({'losid':losid,'status':200,'message':"success",'data':"No data"}); // success message return ({'losid':losid,'status':200,'message':"success",'data':"No data"}); // success message
//end of try catch //end of try catch
})
.then((value) => {
})
// await sleep(2000)
//promise.then(function(value){
//.then((value) => {
.then(function(value){
// writeToBody(topic);
console.log(value)
setTimeout(function(){
console.log(value)
try { try {
if(value.status == 200) if(value.status == 200)
@ -354,20 +366,23 @@ exports.test = (req, res) => {
}], }],
required :false required :false
}) })
.then(MasterData => { .then(MasterData =>
{
//setTimeout(
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] }) Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
// ,2000)
.then(EntitiesData => { .then(EntitiesData => {
console.log(EntitiesData)
let data = []; let data = [];
EntitiesData.forEach((value, key)=>{ EntitiesData.forEach((value, key)=>{
obj_data = { ...value.dataValues , statementsmasterrData:MasterData } obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
data.push(obj_data); data.push(obj_data);
}) // end of EntitiesData foreach }); // end of EntitiesData foreach
console.log(data) console.log(data)
console.log('4') logMsg.info("MenuList api working")
logMsg.info("MenuList api working"); Promise.resolve(res.send({'losid':losid,'status':200,'message':"success",'data':data}))
return (data);
return ({'status':200,'message':"success",'data':data});
}); // end of findall EntitiesData }); // end of findall EntitiesData
}); // end of findall masters datas }); // end of findall masters datas
} // end of starter function if condition } // end of starter function if condition
@ -375,13 +390,24 @@ exports.test = (req, res) => {
} }
catch (err) { catch (err) {
console.log(err) console.log
return res.status(500).json({'status':404,'message':"failed",'data':"No data"})
} }
},1000);
})
// .then((value) =>{
// console.log(value)
// console.log('last')
}).catch(console.log) // resolve(res.send({'losid':losid,'status':200,'message':"success",'data':value}))
// })
// Promise.all([promise]).then(value => {
// console.log(value)
// console.log('last')
// resolve(res.send({'losid':losid,'status':200,'message':"success",'data':value}))
// })
.catch(console.log)
} }

View File

@ -233,6 +233,10 @@ module.exports = app => {
* type: integer * type: integer
* description: Third Year statement type * description: Third Year statement type
* example: 1 * example: 1
* Y4_st_type:
* type: integer
* description: fourth Year statement type
* example: 1 or null
* updatedby: * updatedby:
* type: integer * type: integer
* description: The person who modified * description: The person who modified
@ -815,9 +819,6 @@ module.exports = app => {
*/ */
router.get("/Historyapi", master.Historyapi); router.get("/Historyapi", master.Historyapi);
// router.get("/printAll", test.printAll);
router.get("/test", test.test);
router.get("/test1", test.test1);
router.get("/test2", test.test2); router.get("/test2", test.test2);