update index.js and process.js

main
MohammadHoseinPaymard 2 months ago
parent c14342a2d1
commit b013919fd2
  1. 39
      index.js
  2. 6
      process.js

@ -18,17 +18,19 @@ require(path.join(process.cwd(),"..","server","dist","database.js"));
}); });
if (workflows.length == 0) throw "There is not any workflow"; if (workflows.length == 0) throw "There is not any workflow";
const allWorkflowInfo = {}; const allWorkFlowInfo = {};
workflowsFor: workflowsFor:
for await (const workflow of workflows) { for await (const workflow of workflows) {
if (+workflow.id < 0) continue; if (+workflow.id < 0) continue;
const processes = await getAllProcesses(workflow); const processes = await getAllProcesses(workflow, {
subFlowId: null,
});
if (processes.length == 0) { if (processes.length == 0) {
allWorkflowInfo[workflow.id] = { allWorkFlowInfo[workflow.id] = {
isValid: false, isValid: false,
root: { root: {
valid: 0, valid: 0,
@ -42,6 +44,7 @@ require(path.join(process.cwd(),"..","server","dist","database.js"));
const { allPaths: tree, subFlowParentIds, invalidPathsWithoutEnding } = await getProcessPaths(processes, workflow); const { allPaths: tree, subFlowParentIds, invalidPathsWithoutEnding } = await getProcessPaths(processes, workflow);
allWorkFlowInfo[workflow.id] = { allWorkFlowInfo[workflow.id] = {
isValid: invalidPathsWithoutEnding.length == 0 ? true : false,
root: { root: {
validPaths: tree, validPaths: tree,
invalidPaths: invalidPathsWithoutEnding, invalidPaths: invalidPathsWithoutEnding,
@ -52,6 +55,36 @@ require(path.join(process.cwd(),"..","server","dist","database.js"));
subFlow: {} subFlow: {}
} }
const subFlowInfo = {}
subFlowFor:
for await (const subFlowId of subFlowParentIds) {
const processesSubFlow = await getAllProcesses(workflow, {
[Op.or]: [
{
subFlowId: subFlowId,
},
{
subFlowPid: subFlowId
}
]
})
if (processesSubFlow.length == 0) {
allWorkFlowInfo[workflow.id].isValid = false;
subFlowInfo[subFlowId] = {
valid: subTreePath.length,
invalid: invalidSubPathsWithoutEnding.length,
validSubTreePath:subTreePath,
invalidSubTreePath: invalidSubPathsWithoutEnding
}
continue subFlowFor;
}
}
allWorkFlowInfo[workflow.id]["subFlow"] = subFlowInfo;
console.log("allWorkFlowInfo",JSON.stringify(allWorkFlowInfo,null,2));
} }
console.timeEnd("WorkflowTester") console.timeEnd("WorkflowTester")

@ -2,7 +2,6 @@ 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,
subFlowId: null,
...query ...query
// type:{ // type:{
// [Op.in]:[0,1] // [Op.in]:[0,1]
@ -181,7 +180,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 }); invalidSubPathsWithoutEnding.push({ path: null, data: null, workflow: workflow.id, subworkflow: subFlowIdTemp,error:"هیچ پروسس استارتی برای این ورک فلو وجود ندارد" });
return { return {
subTreePath: [], subTreePath: [],
invalidSubPathsWithoutEnding invalidSubPathsWithoutEnding
@ -257,7 +256,8 @@ 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 });
invalidSubPathsWithoutEnding.push({ path: newPath.map(n => n.id), data: newMergedData ,error:"هیچ پروسس پایانی برای این ورک فلو وجود ندارد"});
} }
return; return;
} }

Loading…
Cancel
Save