fix: 补全OA离职员工审批人姓名 #779
@ -823,11 +823,27 @@ class DingProcessDetailMirrorSynchronizer
|
||||
/** @return array<string,string> */
|
||||
private function employees(UpstreamReadOnlyQuery $query): array
|
||||
{
|
||||
$rows = $query->select('SELECT userid, name FROM rpt.hr_employee');
|
||||
try {
|
||||
$rows = [
|
||||
...$rows,
|
||||
...$query->select('SELECT userid, name, realName FROM rpt.hr_employee_dimission'),
|
||||
];
|
||||
} catch (Throwable) {
|
||||
// 离职目录短暂不可用时不阻断审批同步,已解析的在职姓名继续使用。
|
||||
}
|
||||
|
||||
$employees = [];
|
||||
foreach ($query->select('SELECT userid, name FROM rpt.hr_employee') as $row) {
|
||||
foreach ($rows as $row) {
|
||||
$id = trim((string) ($row['userid'] ?? ''));
|
||||
if ($id === '' || isset($employees[$id])) {
|
||||
continue;
|
||||
}
|
||||
$name = trim((string) ($row['name'] ?? ''));
|
||||
if ($id !== '' && $name !== '') {
|
||||
if ($name === '') {
|
||||
$name = trim((string) ($row['realName'] ?? ''));
|
||||
}
|
||||
if ($name !== '') {
|
||||
$employees[$id] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,13 @@
|
||||
return $approver;
|
||||
}
|
||||
|
||||
return ($row->status ?? '') === '审批中' ? '审批人待同步' : '-';
|
||||
if (($row->status ?? '') === '审批中') {
|
||||
return trim((string) ($row->current_task_name ?? '')) === ''
|
||||
? '无在途任务'
|
||||
: '审批人待补全';
|
||||
}
|
||||
|
||||
return '-';
|
||||
};
|
||||
$pageUrl ??= route('business.pages.show', [
|
||||
'section' => 'process-data',
|
||||
|
||||
@ -367,7 +367,7 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
|
||||
'taskGroupName' => '行政核价',
|
||||
'status' => 'RUNNING',
|
||||
'result' => 'NONE',
|
||||
'userId' => 'user-2',
|
||||
'userId' => 'user-3',
|
||||
'createTime' => '2026-10-29T19:20Z',
|
||||
'finishTime' => '',
|
||||
]];
|
||||
@ -379,7 +379,7 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase
|
||||
->where('business_id', '202610291915000052466')
|
||||
->first();
|
||||
$this->assertSame('行政核价', $row->current_task_name);
|
||||
$this->assertSame('王五', $row->current_approver_name);
|
||||
$this->assertSame('赵六', $row->current_approver_name);
|
||||
$this->assertSame('2026-10-29 19:20:00', (string) $row->current_task_started_at);
|
||||
$this->assertSame('not_applicable', $row->payment_source_state);
|
||||
}
|
||||
@ -1059,6 +1059,11 @@ class FakeDingProcessDetailQuery extends UpstreamReadOnlyQuery
|
||||
{
|
||||
$this->calls[] = compact('sql', 'bindings');
|
||||
|
||||
if (str_contains($sql, 'FROM rpt.hr_employee_dimission')) {
|
||||
return [
|
||||
['userid' => 'user-3', 'name' => '赵六', 'realName' => '赵六'],
|
||||
];
|
||||
}
|
||||
if (str_contains($sql, 'FROM rpt.hr_employee')) {
|
||||
return [
|
||||
['userid' => 'user-1', 'name' => '陈芝豹'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user