更新
This commit is contained in:
@@ -7,6 +7,7 @@ namespace app\command;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
use app\common\model\tcm\DiagnosisTodo;
|
||||
use app\common\service\assistantservice\AssistantServiceReminderRecipient;
|
||||
use app\common\service\wechat\WechatWorkAppMessageService;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
@@ -26,7 +27,7 @@ use think\facade\Log;
|
||||
* 行为:
|
||||
* 1. 取出 status=0 且 remind_time<=now 的待办,按 remind_time asc,限 200 条
|
||||
* 2. 每条用乐观锁 (update set status=1 where id=? and status=0) 抢占,避免并发重复推送
|
||||
* 3. 找创建人 admin.work_wechat_userid,未绑定 → status=3 + error
|
||||
* 3. 普通提醒找创建人,医助服务跟进找当前有权访问患者的执行人;未绑定 → status=3 + error
|
||||
* 4. 调 WechatWorkAppMessageService::sendTextToUser,失败 → status=3 + error(终态,不重试)
|
||||
* 5. 整批不中断;输出 处理 N / 成功 X / 失败 Y / 跳过未绑定 Z
|
||||
*/
|
||||
@@ -38,7 +39,7 @@ class DiagnosisTodoNotify extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('tcm:diagnosis-todo-notify')
|
||||
->setDescription('诊单待办事项:扫描到点的待执行项并向创建人发送企业微信消息');
|
||||
->setDescription('诊单待办事项:普通提醒发给创建人,医助服务跟进发给执行人');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output): int
|
||||
@@ -52,7 +53,7 @@ class DiagnosisTodoNotify extends Command
|
||||
$totalSent = 0;
|
||||
$totalFailed = 0;
|
||||
$totalSkipped = 0; // 被并发抢占
|
||||
$totalUnbound = 0; // 创建人未绑定企微(计入 failed)
|
||||
$totalUnbound = 0; // 收件人未绑定企微(计入 failed)
|
||||
|
||||
try {
|
||||
$todoTable = (new DiagnosisTodo())->getTable();
|
||||
@@ -91,15 +92,15 @@ class DiagnosisTodoNotify extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
// 取创建人 work_wechat_userid
|
||||
$creatorId = (int) ($row['creator_id'] ?? 0);
|
||||
// 模块任务按执行人发送,并重检当前患者访问权限;保留真实创建人审计。
|
||||
$recipientId = AssistantServiceReminderRecipient::resolve($row);
|
||||
$wxId = '';
|
||||
if ($creatorId > 0) {
|
||||
$wxId = (string) Admin::where('id', $creatorId)->value('work_wechat_userid');
|
||||
if ($recipientId > 0) {
|
||||
$wxId = (string) Admin::where('id', $recipientId)->value('work_wechat_userid');
|
||||
}
|
||||
|
||||
if ($wxId === '') {
|
||||
$this->markFailed($todoTable, $todoId, '创建人未绑定企业微信 userid');
|
||||
$this->markFailed($todoTable, $todoId, '提醒收件人未绑定企业微信 userid');
|
||||
$totalUnbound++;
|
||||
$totalFailed++;
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user