From 486d206b618e9b4f38cce0551c4e568db7b17b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Fri, 22 Sep 2023 15:44:33 +0800 Subject: [PATCH] feat:fix bugs --- api/app/lib/schedule/workOrder.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/app/lib/schedule/workOrder.js b/api/app/lib/schedule/workOrder.js index 741db64..d71da5a 100644 --- a/api/app/lib/schedule/workOrder.js +++ b/api/app/lib/schedule/workOrder.js @@ -65,21 +65,22 @@ module.exports = function (app, opts,ctx) { ).toPromise() const procinstIds = [...new Set(formRes.map(e => e.procinstId))]; console.log('formRes1',procinstIds) - // 获取流程实例变量 + // 获取流程实例变量 if(formRes && formRes.length > 0){ let procinstsVariables = await request.post(encodeURI(opts.camundarest.host+'/'+opts.camundarest.root+`/engine-rest/history/variable-instance`)) .auth(username, password) .set('Content-Type', 'application/json') .send({processInstanceIdIn: procinstIds}) console.log('formRes2',procinstsVariables) - for (let f of formRes) { + if(procinstsVariables.body&&procinstsVariables.body.length){ + for (let f of formRes) { const parseData = parseProcessData({ formSchema: JSON.parse(f.formSchema), formData: JSON.parse(f.formData) }) const res=await models.Workorder.create({ projectId:parseData.pomsProjectId.value || null, - formname:procinstsVariables.body.find(item=>item.id===f.procinstId).name||null, + formname:procinstsVariables.body.find(t => t.name == 'fsEmisBusinessName') ? procinstsVariables.body.find(t => t.name == 'fsEmisBusinessName').value : '', state: f.state||null, endTime:f.endTime||null, startTime:f.createTime||null @@ -88,6 +89,10 @@ module.exports = function (app, opts,ctx) { console.log('工单数据抽取结束') } + }else{ + console.log('未查询到数据') + } + } }catch(error){