132 lines
3.2 KiB
JavaScript
132 lines
3.2 KiB
JavaScript
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
|
|
{
|
|
console.log("1");
|
|
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
|
|
};
|
|
return new Promise((resolve, reject) => {
|
|
request({
|
|
url: start_url,
|
|
method: "POST",
|
|
json: true,
|
|
body: myJSONObject
|
|
}, function (error, response, body){
|
|
console.log(body);
|
|
let data = body;
|
|
instancesid = data.id;
|
|
resolve(instancesid);
|
|
});
|
|
|
|
});
|
|
}
|
|
catch (error)
|
|
{
|
|
console.log(error);
|
|
}
|
|
}
|
|
|
|
function financialsListOfProcessInstances(instancesid,req,res)
|
|
{
|
|
try
|
|
{
|
|
console.log("1");
|
|
const task_id_url = URL+"task";
|
|
const myJSONObject = { "processInstanceIdIn":[instancesid] };
|
|
return new Promise((resolve, reject) => {
|
|
request({
|
|
url: task_id_url,
|
|
method: "POST",
|
|
json: true,
|
|
body: myJSONObject
|
|
}, function (error, response, body){
|
|
let data = body;
|
|
|
|
if(data.length)
|
|
{
|
|
task_id = data[0].id;
|
|
resolve(task_id);
|
|
}
|
|
else
|
|
{
|
|
resolve(false);
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
}
|
|
catch (error)
|
|
{
|
|
console.log(error);
|
|
}
|
|
}
|
|
|
|
|
|
function financialsTaskComplete(taskid,value)
|
|
{
|
|
try
|
|
{
|
|
console.log("1");
|
|
const task_complete_url = URL+"task/"+taskid+"/complete";
|
|
const myJSONObject = {"variables":{"review_status":{"value":value}}};
|
|
|
|
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
|
|
{
|
|
console.log("1");
|
|
const form_variable_url = URL+"task/"+taskid+"/form-variables";
|
|
return new Promise((resolve, reject) => {
|
|
request({
|
|
url: form_variable_url,
|
|
method: "GET"
|
|
}, function (error, response, body){
|
|
|
|
resolve(body);
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
catch (error)
|
|
{
|
|
console.log(error);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
startFinancialsProcessInstance : startFinancialsProcessInstance,
|
|
financialsListOfProcessInstances : financialsListOfProcessInstances,
|
|
financialsTaskComplete : financialsTaskComplete,
|
|
financialsFormVariables : financialsFormVariables
|
|
|
|
} |