update index.js and process.js

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

@ -3,48 +3,51 @@ const { sleep } = require('./util');
const { getAllWorkflows } = require('./workflow'); const { getAllWorkflows } = require('./workflow');
const { getAllProcesses, getProcessPaths } = require('./process'); const { getAllProcesses, getProcessPaths } = require('./process');
require(path.join(process.cwd(),"..","server","dist","database.js")); require(path.join(process.cwd(), "..", "server", "dist", "database.js"));
(async function(){ (async function () {
await sleep(5e3); await sleep(5e3);
console.time("WorkflowTester") console.time("WorkflowTester")
console.log("initilizing begin.."); console.log("initilizing begin..");
const workflows = await getAllWorkflows({ const workflows = await getAllWorkflows({
id:{ id: {
[Op.gt] : 0 [Op.gt]: 0
} }
}); });
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){ });
allWorkflowInfo[workflow.id] = {
isValid:false, if (processes.length == 0) {
root:{ allWorkFlowInfo[workflow.id] = {
isValid: false,
root: {
valid: 0, valid: 0,
invalid: 0, invalid: 0,
subFlowList: [] subFlowList: []
}, },
subFlow:{} subFlow: {}
} }
continue workflowsFor; continue workflowsFor;
} }
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,
valid: tree.length, valid: tree.length,
invalid: invalidPathsWithoutEnding.length, invalid: invalidPathsWithoutEnding.length,
subFlowList: subFlowParentIds subFlowList: subFlowParentIds
@ -52,8 +55,38 @@ 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")
console.log("DONE"); console.log("DONE");
})() })()

@ -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