camunda_helper:GWM
This commit is contained in:
parent
9bde8a53ca
commit
a1b71ab08f
@ -1,6 +1,7 @@
|
|||||||
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');
|
||||||
const financialControllerHelper = require('../services/financial.controller.helper.js');
|
const financialControllerHelper = require('../services/financial.controller.helper.js');
|
||||||
|
const camundaHelper = require('../services/camunda.helper.js');
|
||||||
// all master data list for dropdown
|
// all master data list for dropdown
|
||||||
exports.MasterDatas = async (req, res) => {
|
exports.MasterDatas = async (req, res) => {
|
||||||
await Statementsmaster.findAll({
|
await Statementsmaster.findAll({
|
||||||
@ -38,11 +39,11 @@ exports.MenuList = (req, res) => {
|
|||||||
try {
|
try {
|
||||||
const losid = req.query.losid
|
const losid = req.query.losid
|
||||||
// call starter function here
|
// call starter function here
|
||||||
console.log(losid)
|
|
||||||
req_obj ={"losid":losid}
|
req_obj ={"losid":losid}
|
||||||
|
|
||||||
starter_response = starter(req_obj);
|
starter_response = starter(req_obj);
|
||||||
console.log(starter_response)
|
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
if(starter_response.status == 200)
|
if(starter_response.status == 200)
|
||||||
{
|
{
|
||||||
@ -64,10 +65,13 @@ exports.MenuList = (req, res) => {
|
|||||||
required :false
|
required :false
|
||||||
})
|
})
|
||||||
.then(MasterData => {
|
.then(MasterData => {
|
||||||
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' , 'process_instance_id' ] })
|
||||||
.then(EntitiesData => {
|
.then(EntitiesData => {
|
||||||
let data = [];
|
let data = [];
|
||||||
EntitiesData.forEach((value, key)=>{
|
EntitiesData.forEach((value, key)=>{
|
||||||
|
// instancesid = value.dataValues.process_instance_id;
|
||||||
|
// taskid = camundaHelper.financialsListOfProcessInstances(instancesid); console.log(taskid)
|
||||||
|
// camunda_status = camundaHelper.financialsFormVariables(taskid);
|
||||||
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
|
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
|
||||||
|
|
||||||
data.push(obj_data);
|
data.push(obj_data);
|
||||||
@ -447,59 +451,289 @@ exports.ConsolidatedSummary = async (req, res) => {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.testwo = async (req, res) => {
|
exports.test = async (req, res) => {
|
||||||
//sequelize.query("SELECT x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext,a.itemid,e.itemtext as items,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value FROM financials a JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '"+Year_1+"' and a.entity_id IN ("+IN+") and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id order by e.statement asc , e.section asc , e.id asc")
|
const losid = req.query.losid;
|
||||||
//sequelize.query("SELECT x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext,a.itemid,e.itemtext as items,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value,d.fy as Y4,SUM(d.value) as Y4_value FROM financials a JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_4+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) d ON a.entity_id = d.entity_id and a.itemid = d.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_3+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '"+Year_2+"' and entity_id IN ("+IN+") and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '"+Year_1+"' and a.entity_id IN ("+IN+") and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id,d.fy order by e.statement asc , e.section asc , e.id asc")
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
new Promise((resolve,reject) =>{
|
||||||
|
|
||||||
|
//pro 42 api call using losid
|
||||||
|
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":"BB1234BBBB","cin":"test2_cin","bizname":"test2_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4}
|
||||||
|
];
|
||||||
|
// insert pro42data into entities table using using foreach
|
||||||
|
Pro42Data.forEach((Pro42Datavalue, key)=>{
|
||||||
|
// check if the Pro42Data (entity) already inserted
|
||||||
|
Entities.findOne({ where: { losid : Pro42Datavalue.losid , pan : Pro42Datavalue.pan , cin : Pro42Datavalue.cin } }).then(Entity => {
|
||||||
|
if(Entity)
|
||||||
|
{
|
||||||
|
// skip inserting
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Entities.create({ "losid":Pro42Datavalue.losid,"pan":Pro42Datavalue.pan,"cin":Pro42Datavalue.cin,"bizname":Pro42Datavalue.bizname,"entity_type":Pro42Datavalue.entity_type,"activity_group":Pro42Datavalue.activity_group,"biz_act_desc":Pro42Datavalue.biz_act_desc,"createdby":Pro42Datavalue.createdby})
|
||||||
|
.then(Entitydata => {
|
||||||
|
|
||||||
|
//create Entityfinyears data
|
||||||
|
const Y1 = new Date().getFullYear();
|
||||||
|
const Y2 = Y1-1;
|
||||||
|
const Y3 = Y2-1;
|
||||||
|
Entityfinyears.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"Y1":Y1,"Y2":Y2,"Y3":Y3,"Y1_st_type":2,"Y2_st_type":2,"Y3_st_type":2})
|
||||||
|
.then(Entityfinyearsdata => {
|
||||||
|
|
||||||
|
//create financials data based on Entityfinyears
|
||||||
|
let fin_years_array = [];
|
||||||
|
fin_years_array = [
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y1,"st_type":Entityfinyearsdata.dataValues.Y1_st_type},
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y2,"st_type":Entityfinyearsdata.dataValues.Y2_st_type},
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y3,"st_type":Entityfinyearsdata.dataValues.Y3_st_type}
|
||||||
|
];
|
||||||
|
|
||||||
|
// create skeletion
|
||||||
|
fin_years_array.forEach((value, key)=>{
|
||||||
|
const entity_id = value.entity_id;
|
||||||
|
const fy = value.fy;
|
||||||
|
const st_type = value.st_type;
|
||||||
|
|
||||||
|
// generate financials data array
|
||||||
|
let fin_data_array = [];
|
||||||
|
for (let i = 1; i < 120; i++)
|
||||||
|
{
|
||||||
|
fin_data_obj = { "entity_id":entity_id,"st_type":st_type,"itemid":i,"fy":fy,"value":0,"is_active":1,"createdby":4}
|
||||||
|
fin_data_array.push(fin_data_obj);
|
||||||
|
} //console.log("------"+entity_id +"---"+ fy)
|
||||||
|
//bulk financials data create
|
||||||
|
Financials.bulkCreate(fin_data_array);
|
||||||
|
//console.log(fin_data_array)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}).catch(err => {
|
||||||
|
res.status(404).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
|
}); // end of entity fin year table data insert
|
||||||
|
|
||||||
|
}).catch(err => {
|
||||||
|
res.status(404).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
|
}); // end of entity insert
|
||||||
|
|
||||||
|
} //end of else condition
|
||||||
|
|
||||||
|
}); // end of (losid,pan,cin) combination checking entity data exist or not
|
||||||
|
|
||||||
|
}); // end of pro42 data foreach
|
||||||
|
|
||||||
|
//return {'status':200,'message':"success",'data':"No data"}; // success message
|
||||||
|
resolve(losid);
|
||||||
|
|
||||||
|
})
|
||||||
|
.then(function(value){
|
||||||
|
|
||||||
|
Statementsmaster.findAll({ where :{is_active : 1} , include: { all: true, nested: true , where :{is_active : 1} , required:false}})
|
||||||
|
.then(MasterData => {
|
||||||
|
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
|
||||||
|
.then(EntitiesData => {
|
||||||
|
let data = [];
|
||||||
|
EntitiesData.forEach((value, key)=>{
|
||||||
|
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
|
||||||
|
|
||||||
|
data.push(obj_data);
|
||||||
|
}); // end of EntitiesData foreach
|
||||||
|
|
||||||
|
// below code for overall sum object push process
|
||||||
|
sum_data = { ...{'losid':losid,'bizname':"Consolidated Financials Summary",'is_consolidated_api_call':1} , statementsmasterrData:MasterData };
|
||||||
|
data.push(sum_data);
|
||||||
|
|
||||||
|
// send respose to FE
|
||||||
|
Promise.resolve(res.send({'status':200,'message':"success",'data':data}))
|
||||||
|
|
||||||
|
}); // end of findall EntitiesData
|
||||||
|
}); // end of findall masters datas
|
||||||
|
|
||||||
|
})
|
||||||
|
} catch(err) {
|
||||||
|
res.status(500).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||||
|
}); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.testwo = async (req, res) => {
|
||||||
|
const losid = req.query.losid;
|
||||||
|
const api_call = 0;
|
||||||
|
var promise = (losid) => new Promise((resolve,reject) =>{
|
||||||
|
if(api_call == 1)
|
||||||
|
{
|
||||||
|
console.log(1);
|
||||||
|
console.log(losid);
|
||||||
|
}
|
||||||
|
resolve(losid)
|
||||||
|
})
|
||||||
|
promise(losid).then((losid) => {
|
||||||
|
console.log(2);
|
||||||
|
console.log(losid);
|
||||||
|
return ({'losid':losid,'status':200,'message':"success",'data':"No data"}); // success message
|
||||||
|
|
||||||
|
})
|
||||||
|
.then(function(value){
|
||||||
|
console.log(3);
|
||||||
|
console.log(losid);
|
||||||
|
//setTimeout(function(){
|
||||||
|
console.log(4);
|
||||||
|
console.log(losid);
|
||||||
|
data = "output";
|
||||||
|
Promise.resolve(res.send({'status':200,'message':"success",'data':data}))
|
||||||
|
//},1000);
|
||||||
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function testhree(req , res) {
|
exports.menu = async (req, res) => {
|
||||||
console.log( new Date().getFullYear())
|
const losid = req.query.losid;
|
||||||
console.log( req.losid)
|
try
|
||||||
return {'status':200,'message':"success"};
|
{
|
||||||
}
|
let promise = Promise.resolve();
|
||||||
|
//pro 42 api call using losid
|
||||||
|
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":"BB1234BBBB","cin":"test2_cin","bizname":"test2_bizname","entity_type":"type","activity_group":"grp","biz_act_desc":"des","createdby":4}
|
||||||
|
];
|
||||||
|
|
||||||
// const fin_summary = await Financials.findAll({
|
Pro42Data.forEach((Pro42Datavalue, key) => {
|
||||||
// attributes: [['fy','Y1'] ,'itemid',[sequelize.fn('sum', sequelize.col('value')), 'Y1_value'],],group: ['fy','itemid'],
|
promise = promise.then(() => {
|
||||||
// where: { fy : 2019 , entity_id : [6,7] , is_active : 1 }
|
// check if the Pro42Data (entity) already inserted
|
||||||
// },
|
Entities.findOne({ where: { losid : Pro42Datavalue.losid , pan : Pro42Datavalue.pan , cin : Pro42Datavalue.cin } }).then(Entity => {
|
||||||
// );
|
if(Entity)
|
||||||
|
{
|
||||||
|
// skip inserting
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Entities.create({ "losid":Pro42Datavalue.losid,"pan":Pro42Datavalue.pan,"cin":Pro42Datavalue.cin,"bizname":Pro42Datavalue.bizname,"entity_type":Pro42Datavalue.entity_type,"activity_group":Pro42Datavalue.activity_group,"biz_act_desc":Pro42Datavalue.biz_act_desc,"createdby":Pro42Datavalue.createdby})
|
||||||
|
.then(Entitydata => {
|
||||||
|
|
||||||
// sequelize.query("SELECT x.id as statement_id,x.statement as statement,y.id as section_id,y.section as section,e.subsection as subsection_id,z.subsection as subsection , z.itemtext as subsection_itemtext,a.itemid,e.itemtext as items,a.fy as Y1,SUM(a.value) as Y1_value ,b.fy as Y2,SUM(b.value) as Y2_value,c.fy as Y3,SUM(c.value) as Y3_value FROM financials a JOIN ( SELECT id,itemtext,statement,section,subsection,formula,is_calculated FROM itemsmaster ) e ON a.itemid = e.id JOIN ( SELECT id, statement FROM statementsmaster ) x ON e.statement = x.id JOIN ( SELECT id, section FROM sectionsmaster ) y ON e.section = y.id LEFT JOIN ( SELECT id, subsection , itemtext FROM subsectionsmaster ) z ON e.subsection = z.id LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '2019' and entity_id IN (6,7) and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) c ON a.entity_id = c.entity_id and a.itemid = c.itemid LEFT JOIN(SELECT entity_id,itemid,fy,value FROM financials WHERE fy = '2020' and entity_id IN (6,7) and is_active = 1 GROUP BY itemid,fy,is_active,value,entity_id) b ON a.entity_id = b.entity_id and a.itemid = b.itemid WHERE a.fy = '2021' and a.entity_id IN (6,7) and is_active = 1 GROUP BY a.itemid,a.fy,a.is_active,b.fy,c.fy,x.id,x.statement,y.id,y.section,e.subsection,z.subsection,z.itemtext,e.itemtext,e.statement,e.section,e.id order by e.statement asc , e.section asc , e.id asc")
|
//create Entityfinyears data
|
||||||
// .then(data =>{
|
const Y1 = new Date().getFullYear();
|
||||||
// res.send({'status':200,message: "success" ,'data': data });
|
const Y2 = Y1-1;
|
||||||
// })
|
const Y3 = Y2-1;
|
||||||
// .catch(err => {
|
Entityfinyears.create({ "losid":Entitydata.dataValues.losid,"entityid":Entitydata.dataValues.id,"Y1":Y1,"Y2":Y2,"Y3":Y3,"Y1_st_type":2,"Y2_st_type":2,"Y3_st_type":2})
|
||||||
// res.status(404).send({'status':404,
|
.then(Entityfinyearsdata => {
|
||||||
// message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
|
||||||
// });
|
//create financials data based on Entityfinyears
|
||||||
|
let fin_years_array = [];
|
||||||
|
fin_years_array = [
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y1,"st_type":Entityfinyearsdata.dataValues.Y1_st_type},
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y2,"st_type":Entityfinyearsdata.dataValues.Y2_st_type},
|
||||||
|
{"entity_id":Entityfinyearsdata.dataValues.entityid,"fy":Entityfinyearsdata.dataValues.Y3,"st_type":Entityfinyearsdata.dataValues.Y3_st_type}
|
||||||
|
];
|
||||||
|
|
||||||
|
// create skeletion
|
||||||
|
fin_years_array.forEach((value, key)=>{
|
||||||
|
const entity_id = value.entity_id;
|
||||||
|
const fy = value.fy;
|
||||||
|
const st_type = value.st_type;
|
||||||
|
|
||||||
|
// generate financials data array
|
||||||
|
let fin_data_array = [];
|
||||||
|
for (let i = 1; i < 120; i++)
|
||||||
|
{
|
||||||
|
fin_data_obj = { "entity_id":entity_id,"st_type":st_type,"itemid":i,"fy":fy,"value":0,"is_active":1,"createdby":4}
|
||||||
|
fin_data_array.push(fin_data_obj);
|
||||||
|
} //console.log("------"+entity_id +"---"+ fy)
|
||||||
|
//bulk financials data create
|
||||||
|
Financials.bulkCreate(fin_data_array);
|
||||||
|
//console.log(fin_data_array)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}).catch(err => {
|
||||||
|
res.status(404).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
|
}); // end of entity fin year table data insert
|
||||||
|
|
||||||
|
}).catch(err => {
|
||||||
|
res.status(404).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while insertinging statements." ,'data': "No data" });
|
||||||
|
}); // end of entity insert
|
||||||
|
|
||||||
|
} //end of else condition
|
||||||
|
|
||||||
|
}); // end of (losid,pan,cin) combination checking entity data exist or not
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
promise.then(() => {
|
||||||
|
setTimeout(function(){
|
||||||
|
Statementsmaster.findAll({ where :{is_active : 1} , include: { all: true, nested: true , where :{is_active : 1} , required:false}})
|
||||||
|
.then(MasterData => {
|
||||||
|
Entities.findAll({where : { losid } , attributes: ['id', 'losid' , 'pan' , 'cin' , 'bizname' , 'entity_type' , 'activity_group' , 'biz_act_desc' ] })
|
||||||
|
.then(EntitiesData => {
|
||||||
|
let data = [];
|
||||||
|
EntitiesData.forEach((value, key)=>{
|
||||||
|
obj_data = { ...value.dataValues , statementsmasterrData:MasterData }
|
||||||
|
data.push(obj_data);
|
||||||
|
}); // end of EntitiesData foreach
|
||||||
|
if(EntitiesData.length > 1)
|
||||||
|
{
|
||||||
|
// below code for overall sum object push process
|
||||||
|
sum_data = { ...{'losid':losid,'bizname':"Consolidated Financials Summary",'is_consolidated_api_call':1} , statementsmasterrData:MasterData };
|
||||||
|
data.push(sum_data);
|
||||||
|
}
|
||||||
|
// send respose to FE
|
||||||
|
Promise.resolve(res.send({'status':200,'message':"success",'data':data}))
|
||||||
|
|
||||||
|
}); // end of findall EntitiesData
|
||||||
|
}); // end of findall masters datas
|
||||||
|
},1000);
|
||||||
|
})
|
||||||
|
} catch(err) {
|
||||||
|
res.status(500).send({'status':404,
|
||||||
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||||
|
}); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.camunda = async (req, res) => {
|
||||||
function inner_test(req , res) {
|
const losid = req.query.losid;
|
||||||
const losid = req.losid
|
try
|
||||||
new Promise((resolve, reject) => {
|
{
|
||||||
console.log("from-inner-fn="+losid)
|
const losid = "fb37c1e4-271e-11ec-a4f4-42010a800002";
|
||||||
resolve(losid);
|
const cin = "test";
|
||||||
|
const user = "test";
|
||||||
|
|
||||||
}).then(value => { console.log("from-then="+value); return (value ); })
|
//let promise = Promise.resolve();
|
||||||
|
promiseA = new Promise((resolve, reject) => {
|
||||||
|
instancesid = "33f6a13d-272f-11ec-a4f4-42010a800002";
|
||||||
|
taskid = camundaHelper.financialsListOfProcessInstances(instancesid);
|
||||||
|
return taskid;
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(function(){
|
||||||
|
promiseB = promiseA.then(function(taskid){
|
||||||
|
console.log(taskid);
|
||||||
|
camunda_status = camundaHelper.financialsFormVariables(taskid);
|
||||||
|
return camunda_status;
|
||||||
|
})
|
||||||
|
},2000);
|
||||||
|
|
||||||
//return {'status':200,'message':"success"};
|
setTimeout(function(){
|
||||||
}
|
promiseB.then(function(camunda_status){
|
||||||
|
Promise.resolve(res.send({'status':200,'camunda': camunda_status }))
|
||||||
|
})
|
||||||
|
},2000);
|
||||||
// let promise = Promise.resolve();
|
|
||||||
// const posts = [{}, {}, {}];
|
|
||||||
|
} catch(err) {
|
||||||
// posts.forEach(post => {
|
res.status(500).send({'status':404,
|
||||||
// promise = promise.then(() => {
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
||||||
// return db.insert(post);
|
}); }
|
||||||
// });
|
};
|
||||||
// });
|
|
||||||
|
|
||||||
// promise.then(() => {
|
|
||||||
// // now all our docs have been saved
|
|
||||||
// })
|
|
||||||
|
|||||||
@ -9,9 +9,9 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
*/
|
*/
|
||||||
// define association here
|
// define association here
|
||||||
static associate({ Financials }) {
|
static associate({ Financials }) {
|
||||||
this.hasMany(Financials, { foreignKey: 'entity_id', as: 'financials' })
|
this.hasMany(Financials, { foreignKey: 'entity_id', as: 'financialsData' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Entities.init(
|
Entities.init(
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module.exports = app => {
|
|||||||
var router = require("express").Router();
|
var router = require("express").Router();
|
||||||
|
|
||||||
|
|
||||||
|
//router.get("/camunda", financials.camunda);
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/ConsolidatedSummary:
|
* /api/ConsolidatedSummary:
|
||||||
|
|||||||
110
app/services/camunda.helper.js
Normal file
110
app/services/camunda.helper.js
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
const request = require('request');
|
||||||
|
const DEFINITION_ID = process.env.CAMUNDA_PROCESS_DEFINITION_ID;
|
||||||
|
const URL = process.env.CAMUNDA_URL
|
||||||
|
|
||||||
|
function startFinancialsProcessInstance(losid,cin,user)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const start_url = URL+"process-definition/"+DEFINITION_ID+"/start";
|
||||||
|
const businessKey = losid+"-"+cin+"-"+user;
|
||||||
|
const myJSONObject = {
|
||||||
|
"variables":{
|
||||||
|
"los_id":{"value": losid },
|
||||||
|
"cin_no":{"value": cin },
|
||||||
|
"user":{"value": user }
|
||||||
|
},"businessKey": businessKey
|
||||||
|
};
|
||||||
|
request({
|
||||||
|
url: start_url,
|
||||||
|
method: "POST",
|
||||||
|
json: true,
|
||||||
|
body: myJSONObject
|
||||||
|
}, function (error, response, body){
|
||||||
|
let data = body;
|
||||||
|
instancesid = data.id;
|
||||||
|
return instancesid;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function financialsListOfProcessInstances(instancesid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const task_id_url = URL+"task";
|
||||||
|
const myJSONObject = { "processInstanceIdIn":[instancesid] };
|
||||||
|
request({
|
||||||
|
url: task_id_url,
|
||||||
|
method: "POST",
|
||||||
|
json: true,
|
||||||
|
body: myJSONObject
|
||||||
|
}, function (error, response, body){
|
||||||
|
let data = body;
|
||||||
|
task_id =data[0].id;
|
||||||
|
return task_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function financialsTaskComplete(taskid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const task_complete_url = URL+"/task/"+taskid+"/complete";
|
||||||
|
const myJSONObject = {"variables":{"review_status":{"value":true}}};
|
||||||
|
request({
|
||||||
|
url: task_complete_url,
|
||||||
|
method: "POST",
|
||||||
|
json: true,
|
||||||
|
body: myJSONObject
|
||||||
|
}, function (error, response, body){
|
||||||
|
|
||||||
|
return body;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function financialsFormVariables(taskid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const form_variable_url = URL+"task/"+taskid+"/form-variables";
|
||||||
|
request({
|
||||||
|
url: form_variable_url,
|
||||||
|
method: "GET"
|
||||||
|
}, function (error, response, body){
|
||||||
|
|
||||||
|
return body;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
startFinancialsProcessInstance : startFinancialsProcessInstance,
|
||||||
|
financialsListOfProcessInstances : financialsListOfProcessInstances,
|
||||||
|
financialsTaskComplete : financialsTaskComplete,
|
||||||
|
financialsFormVariables : financialsFormVariables
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user