update process.js

main
MohammadHoseinPaymard 2 weeks ago
parent 6e2621348e
commit 1d0f5a160a
  1. 59
      process.js

@ -1,22 +1,22 @@
const { convertStringToJson } = require("./util"); const { convertStringToJson } = require("./util");
const getAllProcesses = async (workflow,query = {}) => { const getAllProcesses = async (workflow, query = {}) => {
const processes = await bpmsDB.bpms_process.findAll({ const processes = await bpmsDB.bpms_process.findAll({
where: { where: {
workflowId: workflow.id, workflowId: workflow.id,
...query ...query
// type:{ // type:{
// [Op.in]:[0,1] // [Op.in]:[0,1]
// } // }
}, },
order: [ order: [
['id', 'ASC'] ['id', 'ASC']
], ],
attributes: [ attributes: [
"id", "pid", "link", "type", "name", "conditions", "subFlowPid", "subFlowId" "id", "pid", "link", "type", "name", "conditions", "subFlowPid", "subFlowId"
], ],
raw: true raw: true
}); });
return processes; return processes;
} }
@ -43,7 +43,7 @@ function getProcessPaths(data, workflow) {
// console.log("startNodes", startNodes) // console.log("startNodes", startNodes)
if (startNodes?.length === 0 || !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 { return {
allPaths: [], allPaths: [],
subFlowParentIds: [], subFlowParentIds: [],
@ -86,7 +86,7 @@ function getProcessPaths(data, workflow) {
const newMergedData = [...mergedData] const newMergedData = [...mergedData]
newMergedData.push({ newMergedData.push({
processId: currentNode.id.toString(), 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 (nextNodes?.length === 0) {
if (isUniquePath(newPath)) { if (isUniquePath(newPath)) {
// allPaths.push({path:newPath.map(n => n.id),data:newMergedData}); // 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; return;
} }
@ -182,7 +182,7 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) {
if (startNodes?.length === 0 || !startNodes) { if (startNodes?.length === 0 || !startNodes) {
// return []; // 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 { return {
subTreePath: [], subTreePath: [],
invalidSubPathsWithoutEnding invalidSubPathsWithoutEnding
@ -223,7 +223,7 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) {
const newMergedData = [...mergedData] const newMergedData = [...mergedData]
newMergedData.push({ newMergedData.push({
processId: currentNode.id.toString(), 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)); // allPaths.push(newPath.map(n => n.id));
if (isUniquePath(newPath)) { 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); // console.timeEnd(date);
return; return;
@ -258,8 +263,14 @@ function getProcessPathsSubFlow(data, subFlowIdTemp, workflow) {
if (nextNodes?.length === 0) { if (nextNodes?.length === 0) {
if (isUniquePath(newPath)) { if (isUniquePath(newPath)) {
// allPaths.push({path:newPath.map(n => n.id),data:newMergedData}); // 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; return;
} }

Loading…
Cancel
Save