zhou zhou
1 天以前 aaf8a50511d77dbc209ca93bbba308c21179a8bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
const STATUS_META = {
  1: { text: '正常', type: 'success' },
  0: { text: '冻结', type: 'info' }
}
 
export const TASK_INSTANCE_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 createTaskInstanceSearchState() {
  return {
    condition: '',
    timeStart: '',
    timeEnd: '',
    taskNo: '',
    bizNo: '',
    bizType: '',
    templateId: '',
    templateCode: '',
    templateVersion: '',
    sourceInfo: '',
    targetInfo: '',
    sourceCode: '',
    targetCode: '',
    plannedPath: '',
    actualPath: '',
    priority: '',
    timeoutAt: '',
    currentNodeCode: '',
    currentNodeName: '',
    totalNodes: '',
    completedNodes: '',
    progressRate: '',
    estimatedDurationMinutes: '',
    actualDurationMinutes: '',
    startTime: '',
    endTime: '',
    resultCode: '',
    resultMessage: '',
    resultData: '',
    retryTimes: '',
    lastRetryTime: '',
    extParams: '',
    remark: '',
    memo: '',
    status: ''
  }
}
 
export function getTaskInstancePaginationKey() {
  return {
    current: 'current',
    size: 'pageSize'
  }
}
 
export function buildTaskInstanceSearchParams(params = {}) {
  const result = {}
 
  ;[
    'condition',
    'taskNo',
    'bizNo',
    'bizType',
    'templateCode',
    'sourceInfo',
    'targetInfo',
    'sourceCode',
    'targetCode',
    'plannedPath',
    'actualPath',
    'timeoutAt',
    'currentNodeCode',
    'currentNodeName',
    'startTime',
    'endTime',
    'resultCode',
    'resultMessage',
    'resultData',
    'lastRetryTime',
    'extParams',
    'remark',
    'memo'
  ].forEach((key) => {
    const value = normalizeText(params[key])
    if (value) {
      result[key] = value
    }
  })
 
  ;['timeStart', 'timeEnd'].forEach((key) => {
    if (params[key]) {
      result[key] = params[key]
    }
  })
 
  ;[
    'templateId',
    'templateVersion',
    'priority',
    'totalNodes',
    'completedNodes',
    'progressRate',
    'estimatedDurationMinutes',
    'actualDurationMinutes',
    'retryTimes',
    'status'
  ].forEach((key) => {
    const value = normalizeNumber(params[key])
    if (value !== null) {
      result[key] = value
    }
  })
 
  return {
    condition: '',
    ...result
  }
}
 
export function buildTaskInstancePageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildTaskInstanceSearchParams(params)
  }
}
 
export function normalizeTaskInstanceRow(record = {}) {
  const statusMeta = STATUS_META[Number(record.status)] || STATUS_META[0]
 
  return {
    ...record,
    id: record.id ?? '--',
    taskNo: normalizeText(record.taskNo) || '--',
    bizNo: normalizeText(record.bizNo) || '--',
    bizType: normalizeText(record.bizType) || '--',
    templateCode: normalizeText(record.templateCode) || '--',
    sourceCode: normalizeText(record.sourceCode) || '--',
    targetCode: normalizeText(record.targetCode) || '--',
    currentNodeName: normalizeText(record.currentNodeName) || '--',
    progressRate: record.progressRate ?? '--',
    resultMessage: normalizeText(record.resultMessage) || '--',
    startTimeText: normalizeDateTime(record['startTime$'] || record.startTimeText || record.startTime),
    endTimeText: normalizeDateTime(record['endTime$'] || record.endTimeText || record.endTime),
    statusText: record['status$'] || statusMeta.text,
    statusType: statusMeta.type,
    memo: normalizeText(record.memo) || '--',
    remark: normalizeText(record.remark) || '--'
  }
}
 
export function getTaskInstanceReportColumns() {
  return [
    { prop: 'taskNo', label: '任务号' },
    { prop: 'bizNo', label: '业务单号' },
    { prop: 'bizType', label: '业务类型' },
    { prop: 'templateCode', label: '模板编码' },
    { prop: 'sourceCode', label: '来源编码' },
    { prop: 'targetCode', label: '目标编码' },
    { prop: 'currentNodeName', label: '当前节点' },
    { prop: 'progressRate', label: '节点进度' },
    { prop: 'resultMessage', label: '结果信息' },
    { prop: 'startTimeText', label: '开始时间' },
    { prop: 'endTimeText', label: '结束时间' },
    { prop: 'statusText', label: '状态' },
    { prop: 'memo', label: '备注' }
  ]
}
 
export function buildTaskInstancePrintRows(records = []) {
  return (Array.isArray(records) ? records : []).map((record) => {
    const row = normalizeTaskInstanceRow(record)
    return {
      taskNo: row.taskNo,
      bizNo: row.bizNo,
      bizType: row.bizType,
      templateCode: row.templateCode,
      sourceCode: row.sourceCode,
      targetCode: row.targetCode,
      currentNodeName: row.currentNodeName,
      progressRate: row.progressRate,
      resultMessage: row.resultMessage,
      startTimeText: row.startTimeText,
      endTimeText: row.endTimeText,
      statusText: row.statusText,
      memo: row.memo
    }
  })
}