From f48f417cce736a6e9cdfb80c66cf2410509beaaa Mon Sep 17 00:00:00 2001 From: MohammadHoseinPaymard Date: Tue, 27 May 2025 09:24:22 +0330 Subject: [PATCH] update index.js and initFunctionData.js --- index.js | 34 +++++++++++++++++++++++++--------- initFunctionData.js | 35 ++++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index d37d24f..0e63318 100644 --- a/index.js +++ b/index.js @@ -104,7 +104,7 @@ require(path.join(process.cwd(), "..", "server", "dist", "database.js")); } - + //---------------------------------------------------------------------------------------- // console.log("allWorkFlowInfo", JSON.stringify(allWorkFlowInfo, null, 2)); @@ -115,8 +115,8 @@ require(path.join(process.cwd(), "..", "server", "dist", "database.js")); //invalid haro ham dar yek araye zakhire kon //---------------------------------------------------------------------------------------- - - for await(let key of Object.keys(allWorkFlowInfo)){ + + for await (let key of Object.keys(allWorkFlowInfo)) { if (!allWorkFlowInfo[key].isValid) { console.log(`workflow with id:'${key}' in invalid`); delete allWorkFlowInfo[key]; @@ -127,18 +127,34 @@ require(path.join(process.cwd(), "..", "server", "dist", "database.js")); fs.writeFileSync("./result-afterProcess.json", JSON.stringify(allWorkFlowInfo)); - for await(const workflow of Object.keys(allWorkFlowInfo)){ - if(workflow==57){ + for await (const workflow of Object.keys(allWorkFlowInfo)) { + if (workflow == 57) { const data = allWorkFlowInfo[workflow]; const pathsCollection = data?.root?.validPaths || []; - if(pathsCollection?.length==0) allWorkFlowInfo[key].isValid = false; - for await(let pathString of pathsCollection){ - const path = pathString.split(","); - console.log("path",path); + if (pathsCollection?.length == 0) allWorkFlowInfo[key].isValid = false; + for await (let pathString of pathsCollection) { + const pathCollection = pathString.split(","); + + let data = {} + + //inja masir start mishe + + for await (let path of pathCollection) { + console.log(path); + } + return; } return; } } + + + for await (let key of Object.keys(allWorkFlowInfo)) { + if (!allWorkFlowInfo[key].isValid) { + console.log(`workflow with id:'${key}' in invalid`); + delete allWorkFlowInfo[key]; + } + } console.timeEnd("WorkflowTester"); console.log("DONE"); process.exit(0); diff --git a/initFunctionData.js b/initFunctionData.js index f5e8f99..12170a8 100644 --- a/initFunctionData.js +++ b/initFunctionData.js @@ -20,24 +20,24 @@ initFunctionData = async (data) => { raw: true, })); // if (process.networkId) { - const processNetwork = await db.network.findByPk(process.networkId, { - raw: true, - attributes: ["level"], - }); - // const payloadNetwork = await db.network.findOne({ - // where: { - // [`level${processNetwork.level}Id`]: process.networkId, - // id: payload.networkId, - // }, - // raw: true, - // }); + const processNetwork = await db.network.findByPk(process.networkId, { + raw: true, + attributes: ["level"], + }); + // const payloadNetwork = await db.network.findOne({ + // where: { + // [`level${processNetwork.level}Id`]: process.networkId, + // id: payload.networkId, + // }, + // raw: true, + // }); // } let processChecklist = await bpmsDB.bpms_processChecklist.findAll({ where: { processId: process.id }, attributes: ["checklistId"], order: [["ord", "asc"]], }); - + const checklistIds = data?.checklists?.length ? data.checklists.map((item) => +item.id).filter(Boolean).join(",") @@ -46,7 +46,7 @@ initFunctionData = async (data) => { .filter((id) => !isNaN(id) && id !== 0) .join(","); - const previousTask = data.previousTask; + const previousTask = data.previousTask; const network = await db.network.findByPk(processNetwork.id, { raw: true, }); @@ -82,6 +82,11 @@ initFunctionData = async (data) => { (await db.unit.findOne({ where: { id: unitId, status: 1 }, })); + } + return { data: newData, transaction: data.transaction } } - return { data: newData, transaction: data.transaction } -}} \ No newline at end of file +} + +module.exports = { + initFunctionData +} \ No newline at end of file