Finish mzl_dev
This commit is contained in:
@@ -122,14 +122,6 @@ class WsEvents
|
|||||||
'system.auth',
|
'system.auth',
|
||||||
['uid' => $user->uid]
|
['uid' => $user->uid]
|
||||||
));
|
));
|
||||||
|
|
||||||
// 初始化推送
|
|
||||||
$wdata = [
|
|
||||||
'is_first' => true,
|
|
||||||
'event' => 'approval.todo.counts',
|
|
||||||
'user_id' => $user->uid
|
|
||||||
];
|
|
||||||
\Webman\RedisQueue\Redis::send('ws-msg', $wdata);
|
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
flg('[x] [TOKEN认证] TOKEN认证失败:'.$th->getMessage(), false);
|
flg('[x] [TOKEN认证] TOKEN认证失败:'.$th->getMessage(), false);
|
||||||
Gateway::sendToClient($client_id, WsResponse::error(
|
Gateway::sendToClient($client_id, WsResponse::error(
|
||||||
@@ -164,6 +156,18 @@ class WsEvents
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function systemConnect(?string $traceId)
|
||||||
|
{
|
||||||
|
$num = (new \app\common\utils\approval\service\ApprovalFlowService())->getInitTodoCount($_SESSION['uid']);
|
||||||
|
$this->todoCounts($_SESSION['uid'], $num);
|
||||||
|
|
||||||
|
Gateway::sendToClient($this->clientId, WsResponse::success(
|
||||||
|
'system.connect.receive',
|
||||||
|
['time' => time()],
|
||||||
|
$traceId
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// ================= 消息通知事件 =================
|
// ================= 消息通知事件 =================
|
||||||
/**
|
/**
|
||||||
* 管理端主动推送通知
|
* 管理端主动推送通知
|
||||||
@@ -255,6 +259,7 @@ class WsEvents
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
init.pull
|
||||||
approval.todo.counts 审批待办数量
|
approval.todo.counts 审批待办数量
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@@ -269,4 +274,38 @@ class WsEvents
|
|||||||
default => throw new \InvalidArgumentException('UID must be integer or string'),
|
default => throw new \InvalidArgumentException('UID must be integer or string'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ================= 临时业务处理 =================
|
||||||
|
|
||||||
|
public function todoCounts(int $userId, int $num = 0)
|
||||||
|
{
|
||||||
|
$ly = [
|
||||||
|
1 => 186,
|
||||||
|
3 => 226,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($num === 0) {
|
||||||
|
$num = (new \app\common\utils\approval\service\ApprovalFlowService())->getInitTodoCount($userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$systemIds = \app\common\model\UserSystems::where('user_id', $userId)->pluck('system_id')->toArray();
|
||||||
|
if (count($systemIds) > 0) {
|
||||||
|
foreach ($systemIds as $systemId) {
|
||||||
|
if (isset($ly[$systemId])) {
|
||||||
|
$chain = \app\common\service\MenuBadgeService::buildBadgeChain(menuId: $ly[$systemId], leafCount: $num);
|
||||||
|
$this->pushWebsocket('approval.todo.counts', $userId, $chain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1938,15 +1938,10 @@ class ApprovalFlowService
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
foreach ($payload as $uid => $cnt) {
|
foreach ($payload as $uid => $cnt) {
|
||||||
\Webman\RedisQueue\Redis::send('ws-msg', [
|
(new \app\common\utils\WsEvents())->todoCounts($uid, $cnt);
|
||||||
'event' => 'approval.todo.counts',
|
|
||||||
'user_id' => $uid,
|
|
||||||
'num' => $cnt,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('ws todo push error: '.$e->getMessage());
|
Log::error('ws todo push error: '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ class WsMsg implements Consumer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
dpr($th);
|
||||||
throw $th;
|
throw $th;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user