const STATUS_META = {
|
1: { text: '正常', type: 'success' },
|
0: { text: '冻结', type: 'info' }
|
}
|
|
export const TASK_INSTANCE_NODE_REPORT_TITLE = '任务实例节点报表'
|
|
function normalizeText(value) {
|
return String(value ?? '').trim()
|
}
|
|
function normalizeNumber(value) {
|
if (value === '' || value === null || value === undefined) {
|
return null
|
}
|
const numericValue = Number(value)
|
return Number.isFinite(numericValue) ? numericValue : null
|
}
|
|
function normalizeDateTime(value) {
|
return normalizeText(value) || '--'
|
}
|
|
export function createTaskInstanceNodeSearchState() {
|
return {
|
condition: '',
|
timeStart: '',
|
timeEnd: '',
|
taskId: '',
|
taskNo: '',
|
nodeOrder: '',
|
nodeCode: '',
|
nodeName: '',
|
nodeType: '',
|
systemCode: '',
|
systemName: '',
|
executeParams: '',
|
executeResult: '',
|
errorCode: '',
|
errorMessage: '',
|
estimatedStartTime: '',
|
actualStartTime: '',
|
actualEndTime: '',
|
timeoutAt: '',
|
durationSeconds: '',
|
retryTimes: '',
|
maxRetryTimes: '',
|
dependsOnNodes: '',
|
memo: '',
|
status: ''
|
}
|
}
|
|
export function getTaskInstanceNodePaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function buildTaskInstanceNodeSearchParams(params = {}) {
|
const result = {}
|
|
;[
|
'condition',
|
'taskNo',
|
'nodeCode',
|
'nodeName',
|
'nodeType',
|
'systemCode',
|
'systemName',
|
'executeParams',
|
'executeResult',
|
'errorCode',
|
'errorMessage',
|
'estimatedStartTime',
|
'actualStartTime',
|
'actualEndTime',
|
'timeoutAt',
|
'dependsOnNodes',
|
'memo'
|
].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
;['timeStart', 'timeEnd'].forEach((key) => {
|
if (params[key]) {
|
result[key] = params[key]
|
}
|
})
|
|
;['taskId', 'nodeOrder', 'durationSeconds', 'retryTimes', 'maxRetryTimes', 'status'].forEach((key) => {
|
const value = normalizeNumber(params[key])
|
if (value !== null) {
|
result[key] = value
|
}
|
})
|
|
return {
|
condition: '',
|
...result
|
}
|
}
|
|
export function buildTaskInstanceNodePageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildTaskInstanceNodeSearchParams(params)
|
}
|
}
|
|
export function normalizeTaskInstanceNodeRow(record = {}) {
|
const statusMeta = STATUS_META[Number(record.status)] || STATUS_META[0]
|
|
return {
|
...record,
|
id: record.id ?? '--',
|
taskId: record.taskId ?? '--',
|
taskNo: normalizeText(record.taskNo) || '--',
|
nodeOrder: record.nodeOrder ?? '--',
|
nodeCode: normalizeText(record.nodeCode) || '--',
|
nodeName: normalizeText(record.nodeName) || '--',
|
systemName: normalizeText(record.systemName) || '--',
|
executeResult: normalizeText(record.executeResult) || '--',
|
errorMessage: normalizeText(record.errorMessage) || '--',
|
actualStartTimeText: normalizeDateTime(record['actualStartTime$'] || record.actualStartTimeText || record.actualStartTime),
|
actualEndTimeText: normalizeDateTime(record['actualEndTime$'] || record.actualEndTimeText || record.actualEndTime),
|
durationSeconds: record.durationSeconds ?? '--',
|
statusText: record['status$'] || statusMeta.text,
|
statusType: statusMeta.type,
|
memo: normalizeText(record.memo) || '--'
|
}
|
}
|
|
export function getTaskInstanceNodeReportColumns() {
|
return [
|
{ prop: 'taskId', label: '任务ID' },
|
{ prop: 'taskNo', label: '任务号' },
|
{ prop: 'nodeOrder', label: '节点顺序' },
|
{ prop: 'nodeCode', label: '节点编码' },
|
{ prop: 'nodeName', label: '节点名称' },
|
{ prop: 'systemName', label: '系统名称' },
|
{ prop: 'executeResult', label: '执行结果' },
|
{ prop: 'errorMessage', label: '错误信息' },
|
{ prop: 'actualStartTimeText', label: '实际开始时间' },
|
{ prop: 'actualEndTimeText', label: '实际结束时间' },
|
{ prop: 'durationSeconds', label: '耗时(秒)' },
|
{ prop: 'statusText', label: '状态' },
|
{ prop: 'memo', label: '备注' }
|
]
|
}
|
|
export function buildTaskInstanceNodePrintRows(records = []) {
|
return (Array.isArray(records) ? records : []).map((record) => {
|
const row = normalizeTaskInstanceNodeRow(record)
|
return {
|
taskId: row.taskId,
|
taskNo: row.taskNo,
|
nodeOrder: row.nodeOrder,
|
nodeCode: row.nodeCode,
|
nodeName: row.nodeName,
|
systemName: row.systemName,
|
executeResult: row.executeResult,
|
errorMessage: row.errorMessage,
|
actualStartTimeText: row.actualStartTimeText,
|
actualEndTimeText: row.actualEndTimeText,
|
durationSeconds: row.durationSeconds,
|
statusText: row.statusText,
|
memo: row.memo
|
}
|
})
|
}
|