巴林闲侠
2 years ago
7 changed files with 301 additions and 32 deletions
@ -0,0 +1,63 @@ |
|||||
|
const moment = require('moment') |
||||
|
|
||||
|
let isDev = false |
||||
|
// let isDev = true
|
||||
|
|
||||
|
module.exports = function (app, opts) { |
||||
|
const workorderStatistics = app.fs.scheduleInit( |
||||
|
{ |
||||
|
interval: '24 */1 * * * *', |
||||
|
immediate: isDev, |
||||
|
proRun: !isDev, |
||||
|
disabled: true |
||||
|
}, |
||||
|
async () => { |
||||
|
try { |
||||
|
const { models, ORM: sequelize } = app.fs.dc |
||||
|
const { apMergeDeVeAnxinProjectId = '' } = opts |
||||
|
const { clickHouse } = app.fs |
||||
|
const { database: camWorkflow } = clickHouse.camWorkflow.opts.config |
||||
|
const { parseProcessData } = app.fs.utils |
||||
|
|
||||
|
const attendanceRes = await clickHouse.pepEmis.query( |
||||
|
` |
||||
|
SELECT |
||||
|
story.id AS historyId, |
||||
|
story.apply_user AS pepUserId, |
||||
|
story.form_data AS formData, |
||||
|
story.submit_form_data AS submitFormData, |
||||
|
fform.form_schema AS formSchema, |
||||
|
fprocess.name AS processName, |
||||
|
procin.state_ AS state, |
||||
|
fform.id AS formId, |
||||
|
fversion.id AS versionId, |
||||
|
fgroup.name AS groupName |
||||
|
FROM |
||||
|
workflow_process_history AS story |
||||
|
INNER JOIN workflow_process_version AS fversion |
||||
|
ON fversion.id = story.version_id |
||||
|
INNER JOIN workflow_process_form AS fform |
||||
|
ON fform.id = fversion.form_id |
||||
|
INNER JOIN workflow_process AS fprocess |
||||
|
ON fprocess.id = fform.process_id |
||||
|
INNER JOIN workflow_group AS fgroup |
||||
|
ON fgroup.id = fprocess.group_id |
||||
|
AND fgroup.name = '运维中台表单' |
||||
|
INNER JOIN ${camWorkflow}.act_hi_procinst AS procin |
||||
|
ON procin.id_ = story.procinst_id |
||||
|
${existOvertimeCount || existVacateCount ? |
||||
|
`WHERE story.create_at > '2023-03-16 00:00:00'` |
||||
|
: ''} |
||||
|
` |
||||
|
).toPromise() |
||||
|
|
||||
|
} catch (error) { |
||||
|
console.error(error); |
||||
|
} |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
return { |
||||
|
workorderStatistics, |
||||
|
} |
||||
|
} |
@ -0,0 +1,106 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const schemaRecursionObj = (obj, target, schemaPath) => { |
||||
|
let schemaPath_ = JSON.parse(JSON.stringify(schemaPath)) |
||||
|
if (obj.properties) { |
||||
|
for (let prKey in obj.properties) { |
||||
|
if (obj.properties[prKey].title == target) { |
||||
|
schemaPath_.push({ |
||||
|
prKey, |
||||
|
...obj.properties[prKey] |
||||
|
}) |
||||
|
return schemaPath_ |
||||
|
} |
||||
|
const hasProperties = obj.properties[prKey].properties |
||||
|
const isGroup = obj.properties[prKey].type == 'array' && obj.properties[prKey].title == '分组' |
||||
|
if (hasProperties || isGroup) { |
||||
|
schemaPath_.push({ |
||||
|
prKey, |
||||
|
...obj.properties[prKey], |
||||
|
isGroup: isGroup, |
||||
|
}) |
||||
|
schemaPath_ = schemaRecursionObj( |
||||
|
isGroup ? |
||||
|
obj.properties[prKey].items |
||||
|
: obj.properties[prKey], |
||||
|
target, |
||||
|
schemaPath_ |
||||
|
) |
||||
|
if (!schemaPath_) { |
||||
|
return [] |
||||
|
} |
||||
|
if (schemaPath_.length > schemaPath.length) { |
||||
|
return schemaPath_ |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
return schemaPath_ |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const dataRecursionObj = (dataObj, index, needData, lastKeyObj, nd) => { |
||||
|
const keyObj = needData[nd].schemaPath[index] |
||||
|
if (dataObj.hasOwnProperty(keyObj.prKey)) { |
||||
|
if (lastKeyObj.prKey == keyObj.prKey) { |
||||
|
let gotValue = dataObj[keyObj.prKey] |
||||
|
if (keyObj.enum && !needData[nd].fromDataSource) { |
||||
|
let vIndex = keyObj.enum.findIndex(ke => ke == gotValue) |
||||
|
gotValue = keyObj.enumNames[vIndex] |
||||
|
} |
||||
|
return gotValue |
||||
|
} else { |
||||
|
if (keyObj.isGroup) { |
||||
|
for (let item of dataObj[keyObj.prKey]) { |
||||
|
const gotValue = dataRecursionObj(item, index + 1, needData, lastKeyObj, nd) |
||||
|
if (gotValue) { |
||||
|
return gotValue |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
return dataRecursionObj(dataObj[keyObj.prKey], index + 1, needData, lastKeyObj, nd) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const getData = (applyDetail, needData) => { |
||||
|
for (let nd in needData) { |
||||
|
if (needData[nd].noProcess) { |
||||
|
continue |
||||
|
} |
||||
|
needData[nd].schemaPath = schemaRecursionObj(applyDetail.formSchema.jsonSchema, needData[nd]['keyWord'], []) |
||||
|
if (needData[nd].schemaPath && needData[nd].schemaPath.length) { |
||||
|
const lastKeyObj = needData[nd].schemaPath[ |
||||
|
needData[nd].schemaPath.length - 1 |
||||
|
] |
||||
|
needData[nd].value = dataRecursionObj(applyDetail.formData, 0, needData, lastKeyObj, nd) |
||||
|
} else { |
||||
|
// 记录错误 关键数据没找到
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = function (app, opts) { |
||||
|
|
||||
|
const parseProcessData = (applyDetail, pomsNeedData = { |
||||
|
title: { |
||||
|
keyWord: '标题', |
||||
|
}, |
||||
|
pomsProjectId: { |
||||
|
keyWord: '关联项目', |
||||
|
fromDataSource: true |
||||
|
}, |
||||
|
expectTime: { |
||||
|
keyWord: '期望完成时间' |
||||
|
} |
||||
|
}) => { |
||||
|
let needData = JSON.parse(JSON.stringify(pomsNeedData)) |
||||
|
getData(applyDetail, needData) |
||||
|
return needData |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
parseProcessData |
||||
|
} |
||||
|
} |
@ -1,42 +1,45 @@ |
|||||
import { ProblemData, OperationData, WorkorderData } from './containers'; |
import { ProblemData, OperationData, WorkorderData } from './containers'; |
||||
|
|
||||
export default [{ |
export default [{ |
||||
type: 'inner', |
type: 'inner', |
||||
route: { |
route: { |
||||
path: '/analysis', |
path: '/analysis', |
||||
key: 'analysis', |
key: 'analysis', |
||||
breadcrumb: '分析', |
breadcrumb: '分析', |
||||
// 不设置 component 则面包屑禁止跳转
|
// 不设置 component 则面包屑禁止跳转
|
||||
childRoutes: [{ |
childRoutes: [ |
||||
|
{ |
||||
path: '/problemAnalysis', |
path: '/problemAnalysis', |
||||
key: 'problemAnalysis', |
key: 'problemAnalysis', |
||||
breadcrumb: '问题分析', |
breadcrumb: '问题分析', |
||||
childRoutes: [{ |
childRoutes: [{ |
||||
path: '/problemData', |
path: '/problemData', |
||||
key: 'problemData', |
key: 'problemData', |
||||
component: ProblemData, |
component: ProblemData, |
||||
breadcrumb: '分析数据', |
breadcrumb: '分析数据', |
||||
}] |
}] |
||||
}, { |
}, { |
||||
path: '/operationAnalysis', |
path: '/operationAnalysis', |
||||
key: 'operationAnalysis', |
key: 'operationAnalysis', |
||||
breadcrumb: '运维分析', |
breadcrumb: '运维分析', |
||||
childRoutes: [{ |
childRoutes: [{ |
||||
path: '/operationData', |
path: '/operationData', |
||||
key: 'operationData', |
key: 'operationData', |
||||
component: OperationData, |
component: OperationData, |
||||
breadcrumb: '运维数据', |
breadcrumb: '运维数据', |
||||
}] |
}] |
||||
}, { |
}, |
||||
|
{ |
||||
path: '/workorderAnalysis', |
path: '/workorderAnalysis', |
||||
key: 'workorderAnalysis', |
key: 'workorderAnalysis', |
||||
breadcrumb: '工单分析', |
breadcrumb: '工单分析', |
||||
childRoutes: [{ |
childRoutes: [{ |
||||
path: '/workorderData', |
path: '/workorderData', |
||||
key: 'workorderData', |
key: 'workorderData', |
||||
component: WorkorderData, |
component: WorkorderData, |
||||
breadcrumb: '工单数据', |
breadcrumb: '工单数据', |
||||
}] |
}] |
||||
}] |
} |
||||
} |
] |
||||
|
} |
||||
}]; |
}]; |
Loading…
Reference in new issue