diff --git a/process.js b/process.js index 0805406..df3497c 100644 --- a/process.js +++ b/process.js @@ -1,22 +1,22 @@ const { convertStringToJson } = require("./util"); -const getAllProcesses = async (workflow,query = {}) => { +const getAllProcesses = async (workflow, query = {}) => { const processes = await bpmsDB.bpms_process.findAll({ - where: { - workflowId: workflow.id, - ...query - // type:{ - // [Op.in]:[0,1] - // } - }, - order: [ - ['id', 'ASC'] - ], - attributes: [ - "id", "pid", "link", "type", "name", "conditions", "subFlowPid", "subFlowId" - ], - raw: true - }); + where: { + workflowId: workflow.id, + ...query + // type:{ + // [Op.in]:[0,1] + // } + }, + order: [ + ['id', 'ASC'] + ], + attributes: [ + "id", "pid", "link", "type", "name", "conditions", "subFlowPid", "subFlowId" + ], + raw: true + }); return processes; } @@ -43,7 +43,7 @@ function getProcessPaths(data, workflow) { // console.log("startNodes", startNodes) if (startNodes?.length === 0 || !startNodes) { - invalidPathsWithoutEnding.push({ path: null, data: null, workflow: workflow.id,error:"هیچ پروسسی برای استارت این ورک فلو وجود ندارد" }); + invalidPathsWithoutEnding.push({ path: null, data: null, workflow: workflow.id, error: "هیچ پروسسی برای استارت این ورک فلو وجود ندارد" }); return { allPaths: [], subFlowParentIds: [], @@ -86,7 +86,7 @@ function getProcessPaths(data, workflow) { const newMergedData = [...mergedData] newMergedData.push({ processId: currentNode.id.toString(), - condition: convertStringToJson(currentNode.conditions) + // condition: convertStringToJson(currentNode.conditions) }); @@ -119,7 +119,7 @@ function getProcessPaths(data, workflow) { if (nextNodes?.length === 0) { if (isUniquePath(newPath)) { // allPaths.push({path:newPath.map(n => n.id),data:newMergedData}); - invalidPathsWithoutEnding.push({ path: newPath.map(n => n.id), data: newMergedData,error:"ورک فلو در این مسیر به پایان نرسید"}); + invalidPathsWithoutEnding.push({ path: newPath.map(n => n.id), data: newMergedData, error: "ورک فلو در این مسیر به پایان نرسید" }); } return; } @@ -182,7 +182,7 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) { if (startNodes?.length === 0 || !startNodes) { // return []; - invalidSubPathsWithoutEnding.push({ path: null, data: null, workflow: workflow.id, subworkflow: subFlowIdTemp,error:"هیچ پروسس استارتی برای این ورک فلو وجود ندارد" }); + invalidSubPathsWithoutEnding.push({ path: null, data: null, workflow: workflow.id, subworkflow: subFlowIdTemp, error: "هیچ پروسس استارتی برای این ورک فلو وجود ندارد" }); return { subTreePath: [], invalidSubPathsWithoutEnding @@ -223,7 +223,7 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) { const newMergedData = [...mergedData] newMergedData.push({ processId: currentNode.id.toString(), - condition: convertStringToJson(currentNode.conditions) + // condition: convertStringToJson(currentNode.conditions) }); @@ -232,7 +232,12 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) { ) { // allPaths.push(newPath.map(n => n.id)); if (isUniquePath(newPath)) { - subTreePath.push({ path: newPath.map(n => n.id).join(","), data: newMergedData }); + subTreePath.push( + { + path: newPath.map(n => n.id).join(","), + // data: newMergedData + } + ); } // console.timeEnd(date); return; @@ -258,8 +263,14 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) { if (nextNodes?.length === 0) { if (isUniquePath(newPath)) { // allPaths.push({path:newPath.map(n => n.id),data:newMergedData}); - - invalidSubPathsWithoutEnding.push({ path: newPath.map(n => n.id), data: newMergedData ,error:"هیچ پروسس پایانی برای این ورک فلو وجود ندارد"}); + + invalidSubPathsWithoutEnding.push( + { + path: newPath.map(n => n.id), + // data: newMergedData, + error: "هیچ پروسس پایانی برای این ورک فلو وجود ندارد" + } + ); } return; }