Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
@@ -0,0 +1,26 @@
|
||||
# AI 分析列显隐只读复核
|
||||
|
||||
日期:2026-10-17。已读根目录 `AGENTS.md`;项目没有 `.trellis/`,因此没有可读的 workflow/spec。本次只读代码与既有测试;仅新增本报告,未改业务代码或测试,未连接生产。
|
||||
|
||||
## 结论与最小修复
|
||||
|
||||
- `prescriptions.py:1276` 初始化隐藏第 11 列;`1697` 是唯一运行时直接修改第 11 列显隐的位置。目前 `_set_ai_columns()` 仅按服务开关 `enabled` 显示“AI 分析”,因此一致度未授权时仍显示该列。
|
||||
- 建议第 11、12 列统一使用 `self._ai_enabled and self._agreement_visible` 决定显示。在 `_set_ai_columns()` 中按新条件处理两列;在 `_set_agreement_visible()` 中同时更新两列,覆盖能力查询开始、失败、撤权、授权恢复及 statuses 顶层 flag 变化。只改前者会遗漏撤权立即隐藏与后续授权恢复。
|
||||
- 保留 `_ai_enabled = enabled` 的服务状态含义,不能改成 `enabled and agreement_visible`。行内“AI 报告”在 `1589` 依赖 `_ai_enabled`;复用该变量表示授权会误删用户要求保留的按钮。
|
||||
- 第 11 列除此之外没有 `hideColumn/showColumn/setColumnHidden` 路径。`_render_ai_statuses()` 只更新内容;表头移动/列宽设置不会改变显隐,无需修改。
|
||||
|
||||
## AI 报告入口条件
|
||||
|
||||
- 行内按钮:`1589`,服务启用、同时具备 reports/detail 权限、非空白处方;不依赖一致度授权,应保持。
|
||||
- 工具栏按钮:`1884–1890`,非空白处方、reports/detail 权限、仓库支持 `list_prescription_ai_reports`;不依赖服务开关或一致度授权,应保持。
|
||||
- 右键菜单:`1828–1838`,reports/detail 权限、仓库支持 reports、非空白处方;受限时仍显示“AI 报告”。
|
||||
- `can_open_issued_ai()` 在 `issued_prescription_ai.py:402` 只检查 reports/detail 权限。现有统计与报告详情的一致度门禁不需要因本次列显隐要求改动。
|
||||
|
||||
## 必要回归
|
||||
|
||||
1. 服务启用但 capability 为 false、缺失或非布尔 true,以及 capability 查询失败:第 11、12 列均隐藏,工具栏与行内“AI 报告”仍存在;root/`*` 不豁免。
|
||||
2. capability 已允许但 statuses 顶层 `agreement_visible` 未明确 true:两列隐藏;statuses 的 `enabled` 仍为 true,报告入口可用。
|
||||
3. 已授权显示两列 → 重新查询能力时立即隐藏 → 撤权或失败保持隐藏,旧回调不能恢复;重新明确授权且 statuses 允许后恢复两列。
|
||||
4. 保留服务关闭、无 statuses 权限、空白处方原行为;服务关闭仍可查看历史报告。
|
||||
|
||||
现有 `app/tests/test_issued_prescription_ai.py:813` 明确断言受限时第 11 列仍显示,需随新要求反转;该测试已覆盖能力失败、撤权、旧回调、工具栏报告保留,可扩展行内按钮断言。`test_list_rechecks_completed_scores_after_hide_and_show` 可补两列恢复断言。建议离线更新/目视检查 `artifacts/prescription-ai-visibility/list-restricted.png`;原截图脚本已有受限列表 fixture。
|
||||
@@ -0,0 +1,16 @@
|
||||
# 未授权账号隐藏 AI 分析列
|
||||
|
||||
2026-10-17。用户补充范围:未被指定授权的账号隐藏已开处方列表“AI 分析”列,保留“AI 报告”按钮。
|
||||
|
||||
修改 `app/src/doctor_workstation/ui/pages/prescriptions.py` 的两个列显隐入口,统一按分析服务启用且当前账号获授权显示第 11/12 列。能力查询开始、失败、撤销、后续状态响应均会更新两列;服务状态仍独立保留,工具栏及行内报告入口继续可用。
|
||||
|
||||
验证结果:
|
||||
|
||||
- 修复前定向 5 个场景失败,复现未授权及能力查询失败后 AI 分析列仍显示。
|
||||
- `test_issued_prescription_ai.py`:142 passed。
|
||||
- `test_prescription_ui.py`:23 passed。
|
||||
- 最终补充行内报告入口断言后,定向 5 个场景通过,含 toolbar 报告点击、root 不豁免、缺失/非布尔能力及旧回调。
|
||||
- Ruff、限定变更文件 `git diff --check` 通过。
|
||||
- 使用真实主题与内存数据离屏核对 [预览](ai-analysis-column-hidden.png):两列已隐藏,AI 报告入口保留。
|
||||
|
||||
本次仅修改桌面端源码和测试,未打包部署、不涉及新增 SQL;前次授权配置迁移若已执行,本次无需再执行数据库变更。更新桌面端后生效。
|
||||
@@ -0,0 +1,87 @@
|
||||
面诊文字对话:后端与桌面端只读调查
|
||||
调查日期:2026-10-20
|
||||
范围:仅代码、SQL 定义与无数据库契约;未读取 .env/凭据,未连接数据库,未查询患者数据,未修改业务代码。
|
||||
|
||||
结论
|
||||
1. Web 新增“面诊文字对话”页签可以直接复用现有 getCallRecords,不需要新增 ASR、转写写入或全文详情接口。
|
||||
2. 一次面诊在当前数据契约里对应一条 tcm_call_record,以 id / call_record_id 标识。全文 transcript_text 已逐通话存储。
|
||||
3. 当前 HTTP getCallRecords 有登录验证,但控制器和查询逻辑未做诊单行级可见性验证。应补 canViewReadonlyDiagnosis,不能仅靠前端页签权限。
|
||||
4. 没有独立转写分段 read 接口。现有 HTTP 列表不返回 transcript_segments;仅需已保存的完整文字时不存在接口缺口,需要逐句时间戳/说话人结构时才需要额外 read 能力。
|
||||
|
||||
一、现有读取接口与字段
|
||||
- API:GET /adminapi/tcm.diagnosis/getCallRecords?diagnosis_id=<positive diagnosis id>。
|
||||
前端请求封装使用 /tcm.diagnosis/getCallRecords,admin/src/api/tcm.ts:226。
|
||||
- 控制器:server/app/adminapi/controller/tcm/DiagnosisController.php:430,读取 GET 参数,仅验证 diagnosis_id 非空,随后调用 DiagnosisLogic::getCallRecords。
|
||||
- 逻辑:server/app/adminapi/logic/tcm/DiagnosisLogic.php:1816。
|
||||
CallRecord::where('diagnosis_id', $params['diagnosis_id'])->order('id', 'desc')->select()->toArray()。
|
||||
无 page_no/page_size/limit/paginate/count;返回该诊单全部通话记录,顺序为 id 降序,不应假设是按 appointment 分页。
|
||||
- JSON 外层沿用 JsonService::data:{code: 1, show: 0, msg: '', data: [<record>, ...]}。
|
||||
Web request 封装和桌面 client 均使用解包后的数组。
|
||||
- 返回完整 CallRecord 行,另添加:start_time_text、end_time_text、duration_text、recording_urls_list、recording_status_text、local_audio_urls_list、local_audio_status_text、transcription_status_text。
|
||||
- 通话核心字段:id、diagnosis_id、caller_id、caller_type、callee_id、callee_type、call_type(1语音/2视频)、status(1进行中/2已结束/3未接听/4已取消)、start_time/end_time(Unix秒)、duration(秒)、room_id。
|
||||
- 转写字段(2026_08_12_add_call_transcription_fields.sql):
|
||||
transcription_session_id: string <=128
|
||||
transcription_language: string <=32
|
||||
transcription_status: '' | running | completed | partial | failed
|
||||
transcription_segment_count: unsigned int
|
||||
transcript_text: nullable longtext,全通话转写,包含“医生:/患者:/未知说话人:”前缀与换行
|
||||
transcription_started_at / transcription_finished_at: Unix 秒,未发生时为0
|
||||
- 状态展示:running=录音转写中;completed=文字已生成;partial=文字部分保存;failed=文字生成失败;其他/空值=未生成文字。
|
||||
- start_time_text/end_time_text 由服务端 date('Y-m-d H:i:s') 生成;不要在前端将此字符串当 UTC 再转换。
|
||||
- 查询异常当前被 logic 捕获后返回 [],控制器仍返回成功包装。前端能显示空记录,但无法靠此接口区分“真空列表”与后端查询异常;本次最小接入不应暗示不存在的数据一定已生成。
|
||||
|
||||
二、分段格式与持久化
|
||||
- 服务端表:zyt_tcm_call_transcript_segment(实际表前缀由部署决定)。
|
||||
字段:id bigint、call_record_id int、transcription_session_id string、segment_id string、speaker_user_id string、speaker_role string、timestamp_ms bigint、text string、create_time/update_time Unix秒。
|
||||
- 唯一键:(call_record_id, transcription_session_id, segment_id),防止同一完成分段重试时重复存储。
|
||||
- 写入接口 upsertCallTranscriptSegments 的 segments 数组项:
|
||||
{segment_id: string<=160, speaker_user_id: string<=160, speaker_role: 'doctor'|'patient'|'unknown', timestamp: nonnegative integer, text: nonempty string<=4000 chars}
|
||||
每批1到50条;未知 role 被规范为 unknown;timestamp 写入为 timestamp_ms,不应混用随访录音的 start_ms/end_ms/channel 分段格式。
|
||||
- snapshot 读取按 call_record_id AND transcription_session_id 过滤,按 timestamp_ms ASC, id ASC 排序,将每项拼成角色标签 + ':' + 文本,用换行连接到 transcript_text,并同步 transcription_segment_count。
|
||||
代码:DiagnosisLogic.php:2130 buildCallTranscriptSnapshot。
|
||||
- 启动/上载/结束是 POST startCallTranscription、upsertCallTranscriptSegments、finishCallTranscription。它们不是读取接口。
|
||||
start:要求该 call 仍为 status=1;同一 record 已绑定其他 session 拒绝。
|
||||
upsert:session 必须匹配且 transcription_status=running,保存后即可在列表中看到已固化的部分全文。
|
||||
finish:期望完成条数大于实际条数时将 completed 降为 partial;结束后保留已存文本。
|
||||
- 不应仅按 status=completed 才允许查看文字:running/partial/failed 也可能已有有效的 transcript_text。
|
||||
|
||||
三、数据隔离与权限核对
|
||||
- call_record_id / diagnosis_id:写入路径 resolveCallRecordForTranscription 用 id=call_record_id AND diagnosis_id AND caller_id=当前管理员 AND caller_type='doctor',防止串记录与越权写;快照再以 session 筛选。
|
||||
- HTTP read:getCallRecords 目前只有 diagnosis_id WHERE,未使用 admin_id/adminInfo,也未调用 canViewReadonlyDiagnosis。CallRecord 和 BaseModel 没有隐藏的 DataScope 全局过滤。
|
||||
因此诊单 A 的请求不会混入诊单 B 的行,但调用者能否读诊单 A 没有在该业务入口校验。前端对诊单详情已授权不能替代每个 read 入口的独立校验。
|
||||
- 现成行域入口:DiagnosisLogic::canViewReadonlyDiagnosis (DiagnosisLogic.php:4339)。验证正数诊单/管理员、排除被删除诊单;医助 role2 限本人 assistant_id;启用 DataScope 时按 visibleAdminIds 收窄;不存在与越权共用错误文案。
|
||||
- 全局 LoginMiddleware 要求 token(此控制器没有免登录声明);AuthMiddleware 验证登录 IP 和菜单权限,但未登记的 action 会走 legacy bypass。没有任何通用行级诊单过滤。
|
||||
- 转写 POST 的权限迁移 2026_08_12_call_transcription_permissions.sql,将三个写操作作为 tcm.diagnosis/video-call 子权限分配;不能将这一“发起通话”权限直接作为历史文字查看的唯一权限。
|
||||
- 现有 Web CallRecordPanel 和桌面诊单视频Tab均以 tcm.diagnosis/huifang 控制可见。兼容的最小 read 约束是:在 AuthMiddleware 未注册路由放行逻辑之前,针对规范化后的 tcm.diagnosis/getcallrecords 精确判断管理员具有 tcm.diagnosis/huifang 或 tcm.diagnosis/getcallrecords;保留既有 root 豁免,然后由控制器执行 canViewReadonlyDiagnosis。
|
||||
不要给历史 read 添加 edit 强制条件,也不要限定 caller_id=当前用户,否则可见诊单内其他医生的历史通话会被误挡。新的文字Tab应复用 huifang,或与直接getCallRecords权限做同样OR;权限撤回时退回基本资料并清空文字。
|
||||
- MCP catalog/review/tcm.php:86 对 getCallRecords 有显式 canViewReadonlyDiagnosis guard。但该 guard 只用于 MCP 包装入口,不能证明 HTTP 控制器已经受到保护。
|
||||
- appointment_id:仅 getCallSignature/startCall 用 AppointmentCallPolicy 检查允许通话方式;startCall 创建记录没有写 appointment_id。当前 CallRecord SQL与模型也没有该字段。
|
||||
因此按 diagnosis_id 返回的是该诊单历次通话,不能声称按 appointment_id 精确隔离。当前需求按每条通话分组可实现;如果产品必须对应某一挂号/预约,则需要持久化 appointment_id 与历史迁移策略,超出此次最小只读接入范围。
|
||||
- 2026-10-24医生网页面诊停用策略只拦签名/发起动作,不拦 getCallRecords;历史文字仍可查看,符合本次读取功能。
|
||||
|
||||
四、native 桌面端现状
|
||||
- app/src/doctor_workstation/services/repository.py:2448 list_call_records:只校验诊单ID>0,然后 GET tcm.diagnosis/getCallRecords,参数只有 diagnosis_id;没有逐条 transcript 详情请求。
|
||||
- ui/dialogs/diagnosis.py:2788,在视频Tab懒加载 list_call_records / get_call_records;返回时以 diagnosis_id 和 generation 双重校验,防止旧请求覆盖新诊单。
|
||||
- ui/dialogs/diagnosis.py:3886 _call_transcript_text:先读 transcript_text,兼容 call_transcript/conversation_text/transcript;只有没有全文时才尝试 transcript_segments/segments,将 speaker_role 映射为中文角色并拼接文本。
|
||||
这个 fallback 是兼容能力,不能当作服务器列表实际返回 segments 的证据。
|
||||
- ui/dialogs/diagnosis.py:4074:某行有文字且 call_record_id>0 时显示“查看文字”,将该行全文与id直接传入只读 QPlainTextEdit 对话框。无网络详情调用,也不会合并其他通话。
|
||||
- mock_repository.py 中示例 record 的 transcript_segments 项格式与存储表不同:写入上来的 segment 字典被保留,通常具有 segment_id/speaker_user_id/speaker_role/timestamp/text;不能据 mock 声称真实 HTTP 有此字段。
|
||||
- 已有桌面测试 app/tests/test_diagnosis_order_video_visual.py:479 覆盖云端回放、本机音频、转写文字分别显示,并将“查看文字”按钮绑定该行id。
|
||||
|
||||
五、建议的最小 Web 接入
|
||||
- 新增“面诊文字对话”Tab,按当前 diagnosis_id 懒加载现有 getCallRecords。
|
||||
- 以 record.id 选中单次通话,显示开始时间、时长、通话/转写状态与 transcription_segment_count;全文取该行 transcript_text,以纯文本保留换行显示(不要 v-html)。
|
||||
- 数据仍按服务端 id 降序,默认选最新有文字记录或最新记录;列表保留没有文字的通话,说明未生成/进行中/部分保存/失败,避免误解为缺少该次面诊。
|
||||
- 诊单切换时先清空 records/selection;用请求序号或 diagnosis_id 检查忽略旧响应;同诊单手动刷新尽量保留选中的 record.id。
|
||||
- 如果全部记录都没有全文,应显示“暂无已保存的面诊文字”,不能提示点击生成/补采集,因为本次不接 ASR 与写接口。
|
||||
- 不要求新后端 detail 接口、不增数据表、不调用转写 POST。同步补齐既有 read 的行域和功能权限即能满足本次范围。
|
||||
- 若将来需要细粒度分段,则新增只读详情必须接受诊单id+通话id,并服务端验证 call_record_id属于该诊单、诊单可见;查询以记录当前 transcription_session_id精确过滤,分页稳定按timestamp_ms,id,切勿仅凭传入session读任意分段。
|
||||
|
||||
六、无数据库验证
|
||||
1. 已运行:php server/tests/CallRecordLifecycleIdentityContractTest.php
|
||||
结果:Call-record lifecycle identity contract: OK(反射/源码契约,无数据库)。
|
||||
2. 已运行仅 pathlib 读取源码的 Python 合同检查,13项全部 PASS:
|
||||
diagnosis WHERE、id降序、无分页、read不加载分段、状态标签、snapshot call+session双过滤、稳定排序、换行拼接、longtext迁移、唯一键、桌面diagnosis-only GET、桌面先取全文、桌面旧响应保护。
|
||||
3. 未跑网络/数据库接口;不能确认各部署实际迁移执行情况、菜单登记数据、既存患者是否有转写。上线前由已有后端流程保证转写字段迁移已部署。
|
||||
|
||||
本报告完成时未修改业务文件;仅新增本调查交付文件。以上行号为调查时定位,主线程随后补授权时可能改变。
|
||||
@@ -0,0 +1,57 @@
|
||||
面诊文字对话:后端授权回归验证
|
||||
日期:2026-10-20
|
||||
|
||||
结果:本轮要求的测试与语法检查全部通过。
|
||||
|
||||
新增测试文件
|
||||
server/tests/ConsultationTranscriptAuthorizationTest.php
|
||||
|
||||
测试方法
|
||||
- 通过 Composer autoload 加载并执行实际 DiagnosisController::getCallRecords 与 AuthMiddleware::handle。
|
||||
- 控制器派生类只提供合成 request、管理员身份及 JSON 包装;不替换待测动作。
|
||||
- DiagnosisLogic 的授权/读取依赖、AdminAuthCache、LoginLogic 与 JsonService 使用进程内替身;所有记录和身份均为合成数据。
|
||||
- middleware 的 request() 使用固定测试IP;env() 替身一旦调用即抛错。因此本测试不初始化框架、不读取 .env、不访问数据库或网络。
|
||||
- 无菜单注册的替身 getAllUri 返回 [],并记录调用次数;专门断言该敏感路由完全不落入 legacy 未登记绕过路径。
|
||||
- 本测试验证控制器会调用既有行级策略并在拒绝时停止读取;行级策略本身的语义继续由 DiagnosisWorkspaceRowAuthorizationTest 覆盖。本轮没有访问真实患者或数据库。
|
||||
|
||||
新增测试覆盖(57个断言)
|
||||
1. 菜单中未注册 getCallRecords 时,无功能权限仍拒绝。
|
||||
2. 仅有 edit/detail/video-call 或相似前缀权限不能读取面诊记录。
|
||||
3. huifang 或 getCallRecords 任一精确权限单独即可读取,无需 edit;两者同时存在可用。
|
||||
4. 路由与直接权限的大小写规范化不形成绕过。
|
||||
5. root 保留原中间件权限豁免,且控制器仍调用诊单行级校验。
|
||||
6. 诊单无权读取/不存在时,在 getCallRecords 读取依赖执行前拒绝,错误为空时使用统一兜底文案。
|
||||
7. 缺失、null、0、负数、空串、非数字字符串 ID 被拒绝,不执行行级策略或读取。
|
||||
8. 合法数字字符串 ID 规范成整数;实际行级授权收到可信 adminId/adminInfo。
|
||||
9. 外部 call_record_id/appointment_id/caller_id 参数不会透传为额外的读取控制项。
|
||||
10. 正常返回保留两个不同通话 ID、不同 caller_id(均非当前用户)、session、状态、全文及顺序,不强加 caller 限制。
|
||||
11. 全文里的换行、中文与 <test>/& 保持原样;partial 记录的已保存文字不会被清除。
|
||||
12. 已授权空记录仍返回原契约 data: []。
|
||||
|
||||
已执行命令及结果
|
||||
php server/tests/ConsultationTranscriptAuthorizationTest.php
|
||||
PASS: Consultation transcript authorization: 57 assertions passed (no DB or network)
|
||||
php server/tests/DiagnosisWorkspaceRowAuthorizationTest.php
|
||||
PASS: Diagnosis workspace row authorization: OK
|
||||
php server/tests/CallRecordLifecycleIdentityContractTest.php
|
||||
PASS: Call-record lifecycle identity contract: OK
|
||||
php -l server/app/adminapi/controller/tcm/DiagnosisController.php
|
||||
PASS: No syntax errors detected
|
||||
php -l server/app/adminapi/http/middleware/AuthMiddleware.php
|
||||
PASS: No syntax errors detected
|
||||
php -l server/tests/ConsultationTranscriptAuthorizationTest.php
|
||||
PASS: No syntax errors detected
|
||||
以上进程退出码均为0。
|
||||
|
||||
已向主线程说明的校验边界
|
||||
本轮控制器版本先将 diagnosis_id 强转为 (int),再检查 >0。因此它拒绝上面第7项的输入,但尚不是严格正整数字符串/整数形状校验。
|
||||
例如 '701suffix'、'701.5' 或 true 可被 PHP 强转为正整数。这些最终仍须通过诊单行级可见性验证,不构成跳过授权;但不应将当前输入形状表述为“已严格拒绝所有非法ID”。
|
||||
主线程已知悉,并计划在本轮终态之后收紧形状验证,随后复跑本测试。严格形状校验当前不计入57项通过断言,尚未声称已完成。
|
||||
|
||||
变更范围
|
||||
本轮仅新增上述后端测试与本验证报告;未修改业务代码、已有测试、部署文件或用户脏文件。
|
||||
|
||||
主线程最终补充验收
|
||||
- 已将 diagnosis_id 收紧为整数或字符串输入,再经 FILTER_VALIDATE_INT/min_range=1 验证;小数、尾缀字符串、布尔、数组和对象均被拒绝。
|
||||
- 已将这些输入形状加入同一无数据库控制器/中间件测试。最终重新执行输出:Consultation transcript authorization: 73 assertions passed (no DB or network),退出码0。
|
||||
- 因此上文“整数强转”边界描述仅对应首次验证快照,最终交付代码已处理该问题。
|
||||
@@ -0,0 +1,109 @@
|
||||
# 医生网页面诊迁移:后端只读调查
|
||||
|
||||
调查日期:2026-10-20。确认截止时刻:**北京时间 2026-10-24 00:00:00(10 月 23 日结束后)**,即 UTC 2026-10-23 16:00:00,Unix 秒 `1792771200`。应按 `now >= cutoff` 判定到期,不能在 10 月 23 日零点提前禁用。
|
||||
|
||||
本文只调查现有实现并给出建议;未改业务代码,未读取 `.env`、数据库内容、令牌或密钥。已有脏文件保留。
|
||||
|
||||
## 结论
|
||||
|
||||
本次最小准确业务范围是:**到期后,仅禁止医生从网页获取新的通话签名及发起新的通话**。建议统一策略作用于 `tcm.diagnosis/getCallSignature` 和 `tcm.diagnosis/startCall`;医助、管理员、医生桌面工作站保持原权限。列表、历史病历、处方和通话收尾接口不需要随迁移公告一起禁用。
|
||||
|
||||
最关键的兼容问题:**医生 Python 桌面应用和网页当前均用 `terminal=1` 登录**,不能直接以 `terminal == PC` 区分它们。若本次以明确的工作站 User-Agent 识别新桌面,并兼容旧 `python-httpx/...`,这是常规客户端迁移识别方案,不是不可伪造的客户端认证;浏览器 `Origin`、`Sec-Fetch-*` 等信号应优先判为网页。长期更稳妥的办法是独立医生工作站终端与会话,但会涉及已安装客户端和旧令牌的迁移,本次不必扩大。
|
||||
|
||||
## 现有公告机制
|
||||
|
||||
- `server/app/adminapi/controller/notice/NoticeController.php`:`settingLists()`、`detail()`、`set()` 是“通知设置”的管理接口。
|
||||
- `server/app/adminapi/logic/notice/NoticeLogic.php:36`:`detail()` 从 `NoticeSetting` 取 `system_notice/sms_notice/oa_notice/mnp_notice`;`system_notice` 是场景通知模板(标题、内容、启用状态)。`set()` 更新现有模板配置,未提供接诊台或问诊列表的全局公告发布/读取接口。
|
||||
- `server/app/common/enum/notice/NoticeEnum.php`:目前主要为登录/绑定/换绑/找回密码验证码场景,不是医生客户端迁移公告。
|
||||
- `server/app/adminapi/logic/ConfigLogic.php:51` / `controller/ConfigController.php:40`:`getConfig()` 是免登录基础配置,目前只有网站名称、logo、版权、版本等,无系统公告字段。
|
||||
|
||||
因此,两页面共用一个迁移公告组件/配置即可,不建议把一次客户端迁移伪装成现有验证码通知场景。若需要服务端统一时间和文案,可新增小的只读政策响应或向基础配置附加公开政策;服务端执行拦截时仍必须独立使用服务器时间。
|
||||
|
||||
## 医生身份与角色
|
||||
|
||||
| 证据 | 当前语义 |
|
||||
| --- | --- |
|
||||
| `server/app/adminapi/logic/firstvisit/MyPatientLogic.php:22` | `DOCTOR_ROLE_ID = 1`,`ASSISTANT_ROLE_ID = 2`,团队角色 `[3,7,8]`,root 优先放行 |
|
||||
| `server/app/adminapi/logic/tcm/DiagnosisLogic.php:3118` `getDoctors()` | 联表 `admin_role`,`role_id=1` 获取医生 |
|
||||
| 同文件 `getAssistants()` | `role_id=2` 获取医助 |
|
||||
| `server/app/common/cache/AdminTokenCache.php:89` | 缓存含 `admin_id/root/role_id/terminal`,`role_id` 是数组 |
|
||||
| `server/app/adminapi/logic/auth/AdminLogic.php:319` | `myself` 返回 `user.role_ids` 整数数组,适合前端公告受众与禁用状态使用 |
|
||||
|
||||
后端判定应该使用可信的登录身份,角色值先转整数,不能用前端提交的角色、姓名或“有接诊菜单”代替医生身份。需先排除 `root=1`。单纯拥有医助/团队角色且没有角色 1 的账号应放行;多角色 `[1,2]` 或 `[1,3]` 需要明确定义医生身份优先级,至少加入回归用例,避免依赖角色数组第一项。按“含角色 1 的非 root 为医生”最接近现有医生列表语义;如业务要对同时拥有管理角色的医生豁免,需显式列出豁免角色,不能猜测。
|
||||
|
||||
## 终端认证与桌面兼容
|
||||
|
||||
| 文件/方法 | 证据 |
|
||||
| --- | --- |
|
||||
| `admin/src/config/index.ts:2` | 网页 `terminal: 1` |
|
||||
| `admin/src/api/user.ts:5` `login()` | `/login/account` 带 `terminal: config.terminal`;企微网页登录亦如此 |
|
||||
| `app/src/doctor_workstation/services/repository.py:842` `login()` | 医生 Python 桌面明确发送 `{"account": ..., "password": ..., "terminal": 1}` |
|
||||
| `app/src/doctor_workstation/services/api_client.py:477` `_headers()` | 自定义头目前仅 `Accept`、`version`、`Content-Type`、`token`;没有专用医生工作站身份头或 User-Agent |
|
||||
| `server/app/common/enum/AdminTerminalEnum.php:26` | `PC=1`、`MOBILE=2`、`WECOM_RPA=7`、`WECOM_RPA_MOBILE=9`;8 被 AI 浏览器占用 |
|
||||
| `server/app/adminapi/validate/LoginValidate.php:34` | 账号登录只接受 1/2/7/9 |
|
||||
| `server/app/adminapi/service/AdminTokenService.php:41` `setToken()` | 按 `(admin_id, terminal)` 找/复用会话,故终端 1 不只是枚举冲突,也会共用会话维度 |
|
||||
| `server/app/common/cache/AdminTokenCache.php:98` | `terminal` 从持久化 `AdminSession` 进入请求身份 |
|
||||
|
||||
**7/9 不是医生工作站终端。** `server/app/adminapi/controller/DesktopController.php` 的 `session()` 是企微客服软件换取客服身份的接口,只允许 `wecomRpaTerminals()`;不能为医生工作站借用 7 或9,否则会扩大客服后台身份的可换取范围。
|
||||
|
||||
推荐的即时方案:给医生桌面设置 `ZytDoctorWorkstation/<version>` User-Agent;服务器在浏览器信号不存在时识别这个明确前缀,并按部署范围兼容旧 `python-httpx/<version>`。旧桌面兼容策略应写测试并在研究/变更说明中如实表述其可信边界。不要仅接受任意请求提交的 `desktop=1` 即放行。
|
||||
|
||||
若以后分离医生工作站终端,应增加新的未占用枚举、登录验证、Python 登录参数,保留既有账号和权限逻辑;旧终端 1 的持久化 token 不会自动变成新终端,升级后应清理/重新登录或安全换取新会话。`LoginController::workWechatLogin()` 当前直接收 `terminal`,未使用 `LoginValidate`,有新终端方案时也应统一处理其允许值。
|
||||
|
||||
## 面诊/问诊调用入口
|
||||
|
||||
| 接口/方法 | 当前行为与建议 |
|
||||
| --- | --- |
|
||||
| `DiagnosisController::getCallSignature()`(334)→ `DiagnosisLogic::getCallSignature()`(908) | 校验诊单/患者身份、行级范围,生成 `doctor_<adminId>` 的 TRTC/IM 签名,签名有效 **86400 秒**。**应作为主要迁移拦截入口**,在签名生成/IM账号导入前拒绝到期的医生网页请求。 |
|
||||
| `DiagnosisController::startCall()`(350)→ `DiagnosisLogic::startCall()`(1520) | 校验患者、数据范围、挂号音视频策略后创建进行中通话记录。**应加相同拦截**,覆盖已缓存签名后重新开始的请求。不能把它等同于腾讯SDK本身的鉴权。 |
|
||||
| `doctor.appointment/reception` / `AppointmentLogic::reception()`(645) | 接诊台聚合详情,已有挂号/数据范围检查;属于查看数据,建议保留。 |
|
||||
| `tcm.diagnosis/lists/detail/readonlyDetail/trackingWindow` | 列表/历史病例查看,医助与管理员也使用,建议保留。 |
|
||||
| `doctor.appointment/complete` / `AppointmentLogic::complete()`(583) | 标记完成、通知医助、可能系统代开空处方;不是开始通话,建议不在本次一起禁用。 |
|
||||
| `tcm.prescription/add/edit/audit/void/delete` | 处方动作有独立鉴权/别名策略,本次“网页到期无法面诊”不应自动扩大到开方、审核或药师工作。 |
|
||||
| `tcm.diagnosis/edit`、`doctor.appointment/addDoctorNote` | 病例、诊疗笔记写入,和通话迁移不是同一权限,建议保持现状。 |
|
||||
| `bindCallRoom/endCall/startCloudRecording/uploadCallRecording/attachLocalCallRecording/startCallTranscription/upsertCallTranscriptSegments/finishCallTranscription` | 当前通话房间绑定、结束、录音/文字落盘流程。建议保留原权限,避免跨截止时刻进行中的通话丢失记录;尤其不能一刀切封 `tcm.diagnosis/*`。 |
|
||||
| `tcm.diagnosis/watchCall` | 医助只拉流旁观,`getAssistantWatchRoomParams()` 另校验指派医助,保留。 |
|
||||
| `tcm.diagnosis/getDoctorSignature`(631) / `getPatientSignature`(649) | 历史测试签名入口;`admin/src/views/test/patient-call.vue:308` 用前者。不是当前常规医生面诊链路。需要记录为边界:如果本次要求阻止所有可用签名获取途径,应对医生网页同样限制这两个入口;医助仍需兼容,不能全局删除。 |
|
||||
|
||||
网页主链路证据:`admin/src/views/patient/reception/index.vue:439` 的 `handleCall()` 先调 `getCallSignature()`,再打开 `chat-dialog`;挂号页 `admin/src/views/tcm/appointment/list.vue`、`list_h5.vue` 也发同一签名请求。问诊聊天组件 `admin/src/components/chat-dialog/index.vue` 会再次取签名并创建通话记录。
|
||||
|
||||
### 必须处理的旧页面边界
|
||||
|
||||
- 由于签名有效24小时,截止前已拿到签名并已登录腾讯IM/TRTC的网页,不会因服务器后续拒绝签名自动退出。
|
||||
- `admin/src/components/chat-dialog/index.vue:769` 的 `ensureCallRecordStarted()` 捕获 `startCall()` 失败后只 `console.warn`,因此“拒绝落库”本身未必阻止腾讯SDK呼叫。
|
||||
- 为覆盖真实使用场景,前端需要在通话按钮/呼叫前钩子再次判定到期,并在页面保持打开期间跨越截止时刻时更新状态;后端两入口作为常规请求的最终防线。只隐藏接诊台按钮不足以覆盖挂号页、H5或已经打开的聊天弹窗。
|
||||
- 若要求对持有旧签名的非标准客户端也强制断开,需要腾讯侧会话/签名吊销或更强设备认证策略,不属于仅新增公告的最小变更范围。
|
||||
|
||||
## 放置策略与响应
|
||||
|
||||
现有链路为 `server/app/adminapi/config/route.php`:Init → Login → Auth → CheckDemo。`LoginMiddleware` 验证 token 并设置 `request.adminInfo/adminId`,AuthMiddleware 存在 root 放行与未注册路由绕过。
|
||||
|
||||
统一迁移策略适合在登录身份已加载后按两个精确控制器/动作调用,或放在两个控制器方法开始处调用同一个 helper;不要依赖新权限菜单存在才触发,也不要在登录时整账号封禁。政策判断应顺序处理:精确面诊入口 → 截止时刻 → root/医生角色 → 桌面识别 → 返回迁移提示。
|
||||
|
||||
失败响应可沿用 `JsonService::fail()` 的 `code=0` 业务失败,附稳定的迁移标识/截止数据方便页面呈现;不要用 `code=-1`,否则前端会当登录过期退出并丢失工作上下文。不要复用企微绑定 `code=10`。
|
||||
|
||||
日期建议使用带时区的不可变时间对象(`Asia/Shanghai` 或明确 `+08:00`),或固定 epoch;`server/config/app.php` 当前默认时区虽为 `Asia/Shanghai`,但不应依赖宿主机器时区解析这个业务截止。
|
||||
|
||||
## 验证方式
|
||||
|
||||
本次已执行既有只读契约测试(均只 require autoload、反射源码或调用纯策略,未启动业务服务):
|
||||
|
||||
```powershell
|
||||
cd D:\web\zyt\server
|
||||
php tests/CallSignatureIdentityContractTest.php
|
||||
php tests/DiagnosisWorkspaceRowAuthorizationTest.php
|
||||
php tests/AdminDesktopAuthContractTest.php
|
||||
```
|
||||
|
||||
结果全部通过:`Call signature identity contract: OK`、`Diagnosis workspace row authorization: OK`、`OK`。
|
||||
|
||||
实施后应加一组无数据库政策测试,注入当前时间并覆盖:
|
||||
|
||||
1. 截止前1秒、截止当秒、截止后1秒,且进程默认时区换为UTC仍一致。
|
||||
2. 网页医生 `root=0, role_id=[1], terminal=1` 在两入口被拒绝;医助 `[2]`、管理员 root、无医生角色的团队账号保留。
|
||||
3. 新工作站UA和旧Python桌面UA按兼容策略放行;带Origin/Sec-Fetch的浏览器即使声称桌面UA也不意外放行;正常浏览器、空UA/未知UA在到期后作为网页处理。
|
||||
4. 多角色数组、字符串数字角色、空身份的明确语义。
|
||||
5. 只读列表/病例/处方、结束通话、录音上传、医助旁观等非拦截路由仍通过策略。
|
||||
6. 前端在截止前打开并持有签名,跨到截止后不能从聊天栏或音视频工具栏发起新呼叫;进行中通话的结束和录音上传仍完成。
|
||||
|
||||
测试环境可用时间注入,不要修改生产系统时间或依赖测试机当前日期。未进行真实患者呼叫、真实开方或任何生产写操作。
|
||||
@@ -0,0 +1,63 @@
|
||||
# 医生网页面诊迁移:后端与桌面客户端独立验证
|
||||
|
||||
验证日期:2026-10-20。只读审查与本地契约测试;未修改业务代码,未读取 `.env`,未调用真实业务接口,未处理其他现有脏改动。
|
||||
|
||||
## 结果
|
||||
|
||||
**指定检查全部通过,未发现本次后端与桌面请求变更的阻塞性问题。** 截止时刻、医生受众、精确通话入口和新旧桌面请求兼容性均与迁移要求一致。
|
||||
|
||||
| 检查 | 结果 |
|
||||
| --- | --- |
|
||||
| `php tests/DoctorWebConsultationPolicyTest.php` | 通过,62 条断言 |
|
||||
| `DoctorWebConsultationPolicy.php` 语法 | 通过 |
|
||||
| `DoctorWebConsultationMiddleware.php` 语法 | 通过 |
|
||||
| `config/route.php` 语法 | 通过 |
|
||||
| `logic/auth/AdminLogic.php` 语法 | 通过 |
|
||||
| `tests/DoctorWebConsultationPolicyTest.php` 语法 | 通过 |
|
||||
| `php tests/CallSignatureIdentityContractTest.php` | 通过 |
|
||||
| `php tests/CallRecordLifecycleIdentityContractTest.php` | 通过 |
|
||||
| `php tests/AppointmentCallPolicyTest.php` | 通过,34 条内存模型断言,不访问数据库 |
|
||||
| `php tests/AdminDesktopAuthContractTest.php` | 通过 |
|
||||
| `app/.venv-runtime/Scripts/python.exe -m pytest tests/test_api_client.py -q` | 通过,16 项测试 |
|
||||
| HTTPX 原生默认头 / 新 ApiClient MockTransport 请求 | 通过,实际观测旧 UA `python-httpx/0.28.1` 和新 UA `ZytDoctorWorkstation/1.4.8`,两者均不附浏览器 Origin/Referer/Sec-Fetch 头 |
|
||||
|
||||
首次使用全局 `python` 运行时因该解释器未安装 pytest 失败;随后使用项目现有 `.venv-runtime` 成功完成指定测试,没有安装或更新依赖。PHP 使用本机 `D:/phpstudy_pro/Extensions/php/php8.2.9nts/php.exe`。
|
||||
|
||||
## 实现审查
|
||||
|
||||
### 日期
|
||||
|
||||
`server/app/adminapi/service/DoctorWebConsultationPolicy.php` 的 `CUTOFF_AT` 明确为 `2026-10-24T00:00:00+08:00`,即北京时间 10 月 23 日结束后。`DateTimeImmutable` 带明确偏移量,不依赖宿主机时区。`now < cutoff` 放行,截止当秒起执行限制。政策测试在 UTC 默认时区覆盖截止前一秒、截止当秒和后一秒。
|
||||
|
||||
`publicPolicy()` 返回相同 `cutoff_at` 和秒级 `server_time`,`AdminLogic` 将其附在 `myself` 的 `user.web_consultation_policy`;未给前端另造不同截止时刻。
|
||||
|
||||
### 受众与路由范围
|
||||
|
||||
策略只对可信登录身份中 **非 root 且角色数组包含医生角色 1** 的请求生效,角色先转换为整数。医助 `[2]`、无医生角色的管理团队 `[3,7,8]` 和 root 保持原有权限。多角色 `[2,1]` 仍按医生处理,与已写明的政策一致。
|
||||
|
||||
限定控制器 `tcm.diagnosis` 和四个动作:
|
||||
|
||||
- `getCallSignature`
|
||||
- `startCall`
|
||||
- `getDoctorSignature`
|
||||
- `getPatientSignature`
|
||||
|
||||
后两个是此前调查发现的历史测试签名入口,限制它们避免常规签名入口停用后仍可从旧测试页取新签名。没有扩大到处方、病历编辑、预约完成、历史查看、医助旁观或通话收尾。
|
||||
|
||||
`DoctorWebConsultationMiddleware` 注册在 Login/Auth 之后,拿已验证身份执行检查;后续业务方法在策略拒绝时不会运行。失败沿用 `code=0`,带 `reason=doctor_web_consultation_expired` 和截止信息,不会触发登录过期流程。root 豁免在独立策略里再次明确,因此原 AuthMiddleware 的 root 提前放行不会破坏本次语义。
|
||||
|
||||
### 桌面兼容
|
||||
|
||||
没有错误地把 `terminal=1` 统一视为网页。`ApiClient._headers()` 增加 `ZytDoctorWorkstation/<__version__>`,当前源码版本 `1.4.8` 能匹配后端完整 UA 格式。API 客户端测试确认真正发出的请求带该 UA。
|
||||
|
||||
政策同时识别旧 HTTPX 默认 UA。额外用 `httpx.MockTransport` 捕获本地请求确认:未改旧模式的 HTTPX 客户端实际发 `python-httpx/0.28.1`,新 ApiClient 发 `ZytDoctorWorkstation/1.4.8`;均无浏览器信号。没有更改医生桌面登录终端、token头、API版本头或现有重试语义。
|
||||
|
||||
`Origin/Referer/Sec-Fetch-*` 优先于 UA;即使浏览器误带原生 UA 也会受限。空 UA、未知 UA、带额外前后缀的 UA 不会意外得到桌面豁免。策略测试覆盖这些情况。
|
||||
|
||||
## 已知边界
|
||||
|
||||
1. UA 是产品客户端兼容识别,**不是不可伪造的客户端认证**。能自行构造请求并持有有效医生 token 的调用方仍可仿造原生 UA。这是已选即时迁移方案的边界,不应宣传为设备级安全认证。
|
||||
2. 后端拦截不会撤销截止前已签发且尚未过期的腾讯签名。已打开页面跨过截止时间后的呼叫应由本次前端呼叫前守卫处理;本次独立验证按分工不覆盖浏览器界面。真实腾讯呼叫、线上部署与已安装旧版程序没有进行端到端验证。
|
||||
3. 受控测试证明拒绝路径不进入业务回调、旧原生请求允许继续,并保留 `endCall/bind/录音上传/文字落盘` 等收尾路由;这不替代部署环境中反向代理对请求头的实际行为验证。
|
||||
|
||||
以上边界没有扩大本次变更范围,也没有导致所运行测试失败。
|
||||
@@ -0,0 +1,40 @@
|
||||
医生网页面诊配置化:后端验证
|
||||
日期:2026-10-22
|
||||
|
||||
配置入口:server/config/doctor_web_consultation.php
|
||||
- cutoff_at 默认 2026-10-24 00:00:00,严格按 Asia/Shanghai 解析到秒。
|
||||
- approaching_hours 默认 48,urgent_hours 默认 24;必须为非负整数且前者 >= 后者。
|
||||
- 提醒日期由截止时间自动计算。修改此文件即可在后续接口请求读取,无须前端重新构建。
|
||||
- 使用固定路径 require,绕过 ThinkPHP 已加载/缓存的配置;不做日期静态缓存。
|
||||
- PHP 提供 opcache_invalidate 时,读取前主动失效该文件的字节码缓存。
|
||||
|
||||
接口与行为:
|
||||
- 免登录只读 /config/doctorWebConsultation:cutoff_at、approaching_at、urgent_at、server_time。
|
||||
- 登录用户资料继续通过同一 publicPolicy() 返回策略。
|
||||
- 中间件截止判定、截止时间字段和停用文案均来自配置。
|
||||
- 保留医生角色、root、精确动作范围、浏览器头优先和新版/旧版桌面 UA 兼容行为。
|
||||
- 非法日期(含不存在的日历日期/当地时间)、时区后缀、非整数/负数/逆序/溢出小时数抛出明确字段错误。
|
||||
- 不相关动作、非医生、root 和无浏览器信号的已知桌面请求先行放行,不因无效迁移配置扩大影响。
|
||||
|
||||
运行环境:PHP 8.2.9 CLI,Windows。
|
||||
通过:
|
||||
1. php tests/DoctorWebConsultationPolicyTest.php
|
||||
Doctor web consultation policy: 133 assertions passed
|
||||
覆盖默认前一秒/截止秒/后一秒、自定义 2032 年中午截止与跨年提醒、小时数修改、秒级消息、
|
||||
多进程时区、无效配置、真实中间件、原生客户端兼容、真实配置控制器动作及免登录名单。
|
||||
临时目录中仅修改专用配置,验证同一 PHP 进程立即读取新日期;同时保留旧 ThinkPHP 缓存值验证绕过缓存。
|
||||
2. php tests/CallSignatureIdentityContractTest.php
|
||||
Call signature identity contract: OK
|
||||
3. php tests/AppointmentCallPolicyTest.php
|
||||
Appointment call policy: 34 assertions passed (in-memory model, no database)
|
||||
4. php tests/AdminMultiRoleRegressionTest.php
|
||||
AdminMultiRoleRegressionTest passed
|
||||
5. php tests/DesktopWorkstationUpdateContractTest.php
|
||||
Desktop workstation update contract: OK
|
||||
6. php -l 检查全部 5 个新增/修改的后端 PHP 文件通过。
|
||||
|
||||
限制:
|
||||
- 未连接业务数据库或线上服务,未进行线上 HTTP 冒烟测试;控制器和中间件使用内存请求/响应测试替身。
|
||||
- 本地 PHP CLI 未加载 OPcache,主动失效 OPcache 分支未做真实扩展环境验证。
|
||||
- 使用真实 Asia/Shanghai 时区规则;历史夏令时或早期时区偏移会依照时区数据库输出,现代/未来日期输出 +08:00。
|
||||
- 本次仅修改后端,不修改前端代码、不清理现有未提交变更。
|
||||
@@ -0,0 +1,68 @@
|
||||
Configurable doctor web consultation schedule - frontend verification
|
||||
Verified on 2026-10-22 (Asia/Shanghai) in D:\web\zyt.
|
||||
|
||||
Scope
|
||||
- Read the policy helper, shared useDoctorWebConsultation hook, runtime API,
|
||||
shared notice, user clock integration, call guards, and targeted test coverage.
|
||||
- No authored frontend source changes were made by this verifier.
|
||||
|
||||
Targeted regression tests: PASS
|
||||
Working directory: D:\web\zyt\admin
|
||||
Command: node --test tests/doctor-web-consultation.test.cjs tests/appointment-call-mode.test.cjs tests/consultation-transcripts.test.cjs
|
||||
Actual process exit code: 0
|
||||
Result: 27 tests, 27 passed, 0 failed, 0 cancelled, 0 skipped, 0 todo.
|
||||
Log: D:\web\zyt\.codex-tasks\doctor-web-config-tests.log
|
||||
|
||||
Coverage observed includes configurable arbitrary cutoff dates and seconds,
|
||||
Beijing timezone display, exact reminder/enforcement boundaries, server clock
|
||||
offset, same-page clock transitions, click-time recheck, shared request
|
||||
deduplication, minute polling, focus/visibility refresh, failed/invalid response
|
||||
recovery retaining the last valid policy, public fresh policy requests, installer
|
||||
availability throughout reminder phases, and notice compilation on reception,
|
||||
diagnosis, and both appointment list entries. Related call-mode and transcript
|
||||
regressions also passed.
|
||||
|
||||
Full Vue typecheck: EXISTING FAILURES ONLY; NO NEW DIAGNOSTICS
|
||||
Command: node node_modules/vue-tsc/bin/vue-tsc.js --noEmit --composite false --incremental false --pretty false
|
||||
Actual process exit code: 2
|
||||
Baseline: D:\web\zyt\.codex-tasks\consultation-transcripts-typecheck.log
|
||||
Stable result log: D:\web\zyt\.codex-tasks\doctor-web-config-typecheck.log
|
||||
Baseline diagnostics: 61
|
||||
Stable current diagnostics: 61
|
||||
New normalized diagnostic signatures: 0
|
||||
Removed normalized diagnostic signatures: 0
|
||||
Full-log normalized line differences: 0
|
||||
Comparison removed (line,column) locations before comparing primary error
|
||||
signatures and all log lines. The full project is not typecheck-clean; its
|
||||
reported diagnostics match the supplied baseline.
|
||||
|
||||
The first typecheck ran concurrently with Vite's generation of ignored
|
||||
admin/components.d.ts and temporarily reported 57 diagnostics with a changed
|
||||
Element Plus template diagnostic set. It was not used for the final comparison.
|
||||
After the build exited, typecheck was rerun to actual completion against stable
|
||||
generated declarations; it produced the baseline-matching 61 diagnostics above.
|
||||
Preserved concurrent-run log:
|
||||
D:\web\zyt\.codex-tasks\doctor-web-config-typecheck-concurrent.log
|
||||
|
||||
Vite production build: PASS
|
||||
Working directory: D:\web\zyt\admin
|
||||
Command: node node_modules/vite/bin/vite.js build --outDir D:\web\zyt\.codex-tasks\doctor-web-config-build --emptyOutDir --logLevel error
|
||||
Actual process exit code: 0
|
||||
Log: D:\web\zyt\.codex-tasks\doctor-web-config-build.log
|
||||
Output: D:\web\zyt\.codex-tasks\doctor-web-config-build
|
||||
Before --emptyOutDir, the absolute normalized output path was verified to be
|
||||
inside D:\web\zyt and to equal the exact requested output directory.
|
||||
Produced 501 files totaling 41,475,816 bytes; index.html exists (31,872 bytes).
|
||||
Built JavaScript includes the runtime consultation policy endpoint/helper.
|
||||
Build log contains only a warning that caniuse-lite browser data is six months
|
||||
old; no build error was reported.
|
||||
|
||||
Relevant implementation observations
|
||||
- Schedule dates originate in the server response; the browser helper has no
|
||||
independent cutoff constant.
|
||||
- All reminder phases and call blocking consume the same normalized policy.
|
||||
- The hook shares in-flight policy requests, refreshes every minute and on
|
||||
focus/visibility, and retains the last valid policy when refresh fails.
|
||||
- Expired blocking applies to doctor role 1 while excluding root accounts;
|
||||
notices keep desktop installer links and refresh actions available.
|
||||
- Verification did not exercise a live browser/backend or perform deployment.
|
||||
@@ -0,0 +1,75 @@
|
||||
医生网页迁移:安装包只读调查
|
||||
核查日期:2026-10-20(Asia/Shanghai)
|
||||
范围:只读源码、文档、本地产物;匿名 GET 公开更新接口;HEAD 已公布安装器 URL。未读取 .env/密钥,未访问管理配置/上传凭据接口,未下载远程大包,未安装/执行/发布安装器,未修改业务代码。
|
||||
Trellis:D:/web/zyt/.trellis/workflow.md 不存在。
|
||||
|
||||
结论
|
||||
1. 有真实可复用的 Windows x64 1.4.8 安装器,且当前线上已发布、匿名 HEAD 可读取,下载入口可直接复用现有公开更新契约。不需要为了本次网页迁移再造一套包上传功能。
|
||||
2. “已实现下载入口”和“包已发布”是两件事。本次包发布事实由 2026-10-20 的生产 GET/HEAD 实测支持;本地 app/dist 产物单独只能证明本地存在。未做远程整包重新哈希或真实安装验收,不把 HEAD 当成完整安装验收。
|
||||
3. 现有安装器不是本轮源码的重新构建产物。其最后修改时间为 2026-10-17;可以作为已有正式桌面端的迁移入口,不应声称包含本轮尚未重新打包的源码修改。
|
||||
|
||||
真实已发布 Windows 安装器
|
||||
公开读取地址:
|
||||
GET https://admin.zhenyangtang.com.cn/adminapi/setting.desktop_workstation/check?current_version=0.0.0&platform=windows&arch=x64
|
||||
HTTP 200,JSON code=1。
|
||||
data.enabled=true
|
||||
data.latest_version=1.4.8
|
||||
data.min_version=1.4.8
|
||||
data.has_update=true
|
||||
data.force=true
|
||||
data.can_install=true
|
||||
data.title=更新说明
|
||||
data.notes(现有发布说明)=1.修复无法编辑诊单\n2.诊疗台增加医助标识\n3.修复AI回复慢
|
||||
data.package.type=inno_setup
|
||||
data.package.filename=DoctorWorkstation-Setup-Windows-x64-1.4.8.exe
|
||||
data.package.size=171474334 字节(约 163.53 MiB)
|
||||
data.package.sha256=792f2273bba9f1d92d3b9e8eacabedcc53755ac003c284d648a9dca105bfb321
|
||||
data.package.url=https://gz-1349751149.cos.ap-guangzhou.myqcloud.com/uploads/desktop_package/1/20261017/1792229692103-0288326cfce9f6dc.exe
|
||||
|
||||
该 package.url 的匿名 HEAD 验证:
|
||||
HTTP 200
|
||||
Content-Type: application/x-msdownload
|
||||
Content-Length: 171474334
|
||||
Last-Modified: Sat, 17 Oct 2026 09:34:52 GMT
|
||||
ETag: "bc4b1f4762535d4e420928518c2e1a4a-33"
|
||||
Accept-Ranges: bytes
|
||||
Content-Disposition: 未提供
|
||||
注意:COS 多段上传 ETag 不能当作 SHA-256。跨域 <a download> 也不保证浏览器强制使用 metadata.filename;下载按钮文案应明确为 Windows 安装包及版本。
|
||||
|
||||
本地产物独立核验
|
||||
路径:D:/web/zyt/app/dist/DoctorWorkstation-Setup-Windows-x64-1.4.8.exe
|
||||
大小:171474334
|
||||
最后修改:2026-10-17T17:33:43.1648862+08:00
|
||||
Windows ProductVersion:1.4.8(资源字段带尾部空格)
|
||||
Get-FileHash SHA256:792F2273BBA9F1D92D3B9E8EACABEDCC53755AC003C284D648A9DCA105BFB321
|
||||
与本地 SHA256SUMS.txt 及生产接口 package.sha256 完全一致。
|
||||
Get-AuthenticodeSignature:NotSigned(本地当前安装器未签名);不要向用户标成“已完成代码签名”。
|
||||
主程序 D:/web/zyt/app/dist/DoctorWorkstation/DoctorWorkstation.exe 的 FileVersion/ProductVersion 均为 1.4.8。
|
||||
便携 ZIP D:/web/zyt/app/dist/DoctorWorkstation-Windows-x64-1.4.8.zip 存在,242411630 字节;SHA256SUMS.txt 记录 DF0F80AFA29825C42323C666F0C033EC0335C83A3DA6C7723ED2FA74C819CA85。本轮没有远程 ZIP 发布证据,不应在迁移页面承诺 ZIP 已上线。
|
||||
|
||||
安全复用读取方式
|
||||
- server/app/adminapi/controller/setting/DesktopWorkstationController.php:28 显式 notNeedLogin=['check'];check 仅调用 DesktopWorkstationLogic::check($request->get())。
|
||||
- 同控制器 getConfig 不是免登录接口,并配有管理菜单权限;医生页面不要调用管理设置 getConfig,也不要读取数据库或对象存储凭据。
|
||||
- 推荐网页 GET 同源 /adminapi/setting.desktop_workstation/check,固定 current_version=0.0.0、platform=windows、arch=x64,从 data.package 提取 url/filename/size/type,显示 data.latest_version。
|
||||
- server/app/adminapi/logic/setting/DesktopWorkstationLogic.php:85-102 表明 package 在完整 URL/SHA 存在时返回;can_install 额外取决于 enabled 与版本比较。若希望迁移入口只分发当前已发布包,可按经过校验的 package 判断是否存在,避免把“自动更新开关关闭”误当成“没有任何包”;如果产品明确要求关闭自动更新也撤下下载,则同时要求 enabled/can_install。
|
||||
- 实现时只接受 https: 的有效安装包 URL,并限制 type/文件格式为适配 Windows 的 inno_setup EXE(或明确另行支持的 archive ZIP);拒绝 javascript:/data:/空链接。链接使用 noopener/noreferrer;显示版本、适用系统、大小及必要的校验值。
|
||||
- 当前已公开 package URL 无查询签名/令牌;可用配置动态取得,避免硬编码日期目录。读 GET 无需用户登录 token;也无需调用 COS STS。
|
||||
- 请求失败、package 缺失或 URL 无效时,下载区显示“安装包暂未就绪,请联系管理员”,保留重试和明确的支持渠道。不要用 # 占位、猜测 URL,或把“按钮已写好”报告成“已提供安装包”。
|
||||
|
||||
现有打包/发布链路
|
||||
- app/src/doctor_workstation/__init__.py:6、10、11:源码版本 1.4.8;DEBUG_MODE=False;公开生产根地址为 https://admin.zhenyangtang.com.cn。
|
||||
- app/Build_DoctorWorkstation.bat 调用 app/scripts/package_windows.ps1;后者使用该单一版本源,构建 PyInstaller onedir,执行冻结应用/媒体门禁,生成 Inno Setup EXE、便携 ZIP、SHA256SUMS.txt。
|
||||
- app/packaging/windows/doctor_workstation.iss:44、46:x64compatible,最低 Windows 10 1809(10.0.17763)。因此页面适用文案应为 Windows 10 1809+ / Windows 11 64 位;不能写 Windows 7 或笼统“所有 Windows”。
|
||||
- app/README.md:12-23 及 app/packaging/README.md:34-40 已有正式打包和自动更新发布说明。
|
||||
- admin/src/views/setting/desktop_workstation/index.vue 已有三个包槽 windows_x64/macos_arm64/macos_x64;Windows 默认 inno_setup。上传组件 type=desktop_package、direct,浏览器计算 SHA-256 并记录 filename/size;上传成功只填地址,点保存才 POST setConfig 发布策略。
|
||||
- admin/src/components/upload/index.vue 使用 uploadDirectToCos;desktop_package 若未配置 COS 则直接报错,不回退业务服务普通上传;管理页面说明支持 EXE/ZIP、最大 2GB。
|
||||
- server/app/adminapi/logic/setting/DesktopWorkstationLogic.php:48-54 将 enabled/latest_version/min_version/force_update/title/notes/packages 存于 ConfigService 的 desktop_workstation 分类。不存在需要迁移页自行创建的安装包清单文件。
|
||||
- macOS 有源码打包机制及槽位,但本轮未验证 macOS 在线包;只承诺已核查的 Windows 包。
|
||||
|
||||
若后续线上包缺失
|
||||
1. 已有健康包:使用管理设置上传/填入经过核验的 HTTPS 产物,填同版 filename/size/SHA 后保存,然后匿名 GET + HEAD 检验发布契约。
|
||||
2. 需要新源码才可用:在明确版本/tag 的原生 Windows 构建环境重新打包,完成现有安装/启动/卸载 smoke,再由授权发布流程上传及保存。不可把 latest_version 改新而继续绑定旧包(app/research/server_release_diagnosis.md 和 update_install_handoff_diagnosis.md 已记录过该类问题)。
|
||||
3. 生产包尚不可用时:可以完成页面下载状态和失败提示,但上线通告中的“可下载安装”必须以真实发布验证为前提。本次已找到并核实 1.4.8,因此当前无需用缺包状态作为默认交付。
|
||||
|
||||
关于“分阶段提醒”的界限
|
||||
现有升级配置 title/notes 是桌面自动升级内容,未发现网页停用的阶段调度字段。网页迁移的公告/截止前提醒/截止后阻断应使用本轮迁移策略;下载包元数据可在各阶段复用公开 check 接口。本轮调查没有创建自动化、发送通知或修改线上升级策略。
|
||||
@@ -0,0 +1,67 @@
|
||||
医生网页迁移补充:后端下载清单及安装包验证
|
||||
日期:2026-10-20(Asia/Shanghai)
|
||||
验证范围:后端新增 downloads()/downloadCatalog()、控制器免登录白名单、原更新契约和网页面诊政策回归、真实已发布 Windows 1.4.8 元数据。
|
||||
操作限制:仅运行本地纯 PHP 测试、源码检查、生产公开更新 GET 和安装包 HEAD。未读取 .env/密钥,未执行真实上传/发布/业务写入,未下载安装包或执行安装。未修改业务代码或测试。
|
||||
|
||||
结果:本次指定验证全部通过。
|
||||
|
||||
PHP 运行环境
|
||||
D:/phpstudy_pro/Extensions/php/php8.2.9nts/php.exe
|
||||
|
||||
指定测试(全部退出码 0)
|
||||
1. php server/tests/DesktopWorkstationDownloadsTest.php
|
||||
输出:Desktop workstation downloads: 21 assertions passed
|
||||
覆盖:仅 version/packages 顶层字段、可用平台、SHA 小写规范化、Windows inno_setup、平台标签、管理策略字段不泄露、enabled=0 仍能手动下载、无效/凭据嵌入 URL 和无效 SHA 被剔除、空清单、免登录白名单和控制器委托现有配置读取。
|
||||
2. php server/tests/DesktopWorkstationUpdateContractTest.php
|
||||
输出:Desktop workstation update contract: OK
|
||||
覆盖:原版本比较、平台映射、可选/强制/最低版本更新、关闭自动检测、缺少平台包、更新 check 的公开契约,以及原安装包直传权限和菜单契约。
|
||||
3. php server/tests/DoctorWebConsultationPolicyTest.php
|
||||
输出:Doctor web consultation policy: 62 assertions passed
|
||||
原网页面诊截止策略回归通过。
|
||||
|
||||
PHP 语法检查(每项退出码 0)
|
||||
php -l server/app/adminapi/logic/setting/DesktopWorkstationLogic.php
|
||||
php -l server/app/adminapi/controller/setting/DesktopWorkstationController.php
|
||||
php -l server/tests/DesktopWorkstationDownloadsTest.php
|
||||
php -l server/tests/DesktopWorkstationUpdateContractTest.php
|
||||
四项均输出 No syntax errors detected。
|
||||
|
||||
源码核对
|
||||
- DesktopWorkstationLogic::downloads() 仅返回 self::downloadCatalog(self::getConfig()),沿用已发布配置和现有 URL 补全逻辑,没有新增配置存储或上传行为。
|
||||
- downloadCatalog() 固定遍历 windows_x64、macos_arm64、macos_x64。每个包先经 plainPackage(),最终仅有 platform/label/url/sha256/size/filename/type;顶层只有 version/packages,不包含 notes/title/min_version/force_update/enabled。
|
||||
- 下载清单不依赖 enabled,关闭自动检测仍可供首次安装。原 evaluate() 未改变,关闭后仍不提示自动升级。
|
||||
- DesktopWorkstationController 的 notNeedLogin 精确为 ['check', 'downloads']。getConfig/setConfig 未列入;downloads() 使用 data(DesktopWorkstationLogic::downloads())。
|
||||
- BaseLikeAdminController::isNotNeedLogin() 按动作名检查该白名单;LoginMiddleware 对非免登录动作要求有效 token,AuthMiddleware 对免登录动作跳过管理菜单权限校验。管理设置读写没有被本次白名单扩大。
|
||||
- downloadCatalog() 拒绝无 host、嵌入用户名/密码以及非 HTTP(S) scheme;实际生产安装器为 HTTPS。当前函数仍兼容 HTTP,未把“强制 HTTPS”作为实现事实。
|
||||
|
||||
真实已发布 1.4.8 元数据验证
|
||||
读取:
|
||||
GET https://admin.zhenyangtang.com.cn/adminapi/setting.desktop_workstation/check?current_version=0.0.0&platform=windows&arch=x64
|
||||
匿名 GET 返回 HTTP 200、JSON code=1、latest_version=1.4.8。
|
||||
|
||||
将该 GET 的真实 data.package 传给本地新 downloadCatalog(),构造 enabled=0,同时加入未知平台 linux_x64 和额外 package 字段 extra,以及管理 title/notes。独立 PHP 断言全部通过:
|
||||
- 顶层键精确为 version/packages;
|
||||
- 只输出一个 windows_x64 包,未知平台被忽略;
|
||||
- 包键精确为 platform/label/url/sha256/size/filename/type,额外字段被剔除;
|
||||
- url/sha256/size/filename/type 与真实发布元数据逐字段一致;
|
||||
- version=1.4.8,enabled=0 不阻断清单。
|
||||
输出:Live public 1.4.8 metadata accepted with automatic checks disabled; top-level, package and platform whitelists passed.
|
||||
|
||||
实际接受的包:
|
||||
platform=windows_x64
|
||||
label=Windows 64位
|
||||
filename=DoctorWorkstation-Setup-Windows-x64-1.4.8.exe
|
||||
type=inno_setup
|
||||
size=171474334
|
||||
sha256=792f2273bba9f1d92d3b9e8eacabedcc53755ac003c284d648a9dca105bfb321
|
||||
url=https://gz-1349751149.cos.ap-guangzhou.myqcloud.com/uploads/desktop_package/1/20261017/1792229692103-0288326cfce9f6dc.exe
|
||||
|
||||
对上述真实 URL 仅发 HEAD:
|
||||
HTTP 200
|
||||
Content-Type=application/x-msdownload
|
||||
Content-Length=171474334(与清单一致)
|
||||
Last-Modified=Sat, 17 Oct 2026 09:34:52 GMT
|
||||
证明现有线上地址可读取且大小吻合;未重新下载远程整包或进行安装验收。
|
||||
|
||||
验证边界
|
||||
新 /adminapi/setting.desktop_workstation/downloads 是当前工作树实现;未声称该新接口已部署到生产。公开访问范围依据源码及指定纯测试核对,未启动完整框架/数据库进行本地 HTTP 集成请求。真实线上元数据来自已有 check 接口,不依赖新端点部署。本文件不包含前端分阶段提醒视觉或交互验收结果。
|
||||
@@ -0,0 +1,65 @@
|
||||
医生网页面诊迁移:前端类型检查基线验证
|
||||
验证日期:2026-10-20
|
||||
|
||||
结论:最终当前代码和本任务相关的 HEAD 内存覆盖基线均返回 exit 2,各有 61 个 TypeScript 错误。按 git diff 的行号偏移映射后,所有诊断的文件、行号、列号、错误码、消息及续行说明完全一致:新增诊断 0,消失诊断 0。本任务未增加类型检查错误;全项目类型检查仍因既有问题失败,不能称为全量类型检查通过。
|
||||
|
||||
这是真实执行的 vue-tsc 基线对比,不仅是源码核对。原 .codex-tasks/doctor-web-migration-typecheck.log 为较早的 57 条诊断,未把该旧日志作为最终当前状态或最终基线。
|
||||
|
||||
运行方式
|
||||
|
||||
Node 包装 admin/node_modules/vue-tsc,通过安装版本的 _tsc.js 启动前钩子,在内存中覆盖 TypeScript 的 sys.readFile / sys.readDirectory / sys.fileExists。两个模式使用完全相同的选项:
|
||||
|
||||
--noEmit --composite false --incremental false --pretty false
|
||||
|
||||
HEAD 引用:d61bb3e117d538219aca01debd1fa2ce2e10a104
|
||||
vue-tsc:2.2.2
|
||||
TypeScript:5.7.3
|
||||
|
||||
current 模式读取当前工作区。
|
||||
head 模式只把本任务改动的以下 6 个源文件读取替换为 git show HEAD:<path> 内容;工作区其他文件和依赖保持当前状态,因此这是本任务相关基线,不是完整 HEAD checkout:
|
||||
|
||||
admin/src/components/chat-dialog/index.vue
|
||||
admin/src/stores/modules/user.ts
|
||||
admin/src/views/patient/reception/index.vue
|
||||
admin/src/views/tcm/diagnosis/index.vue
|
||||
admin/src/views/tcm/appointment/list.vue
|
||||
admin/src/views/tcm/appointment/list_h5.vue
|
||||
|
||||
head 模式同时从编译器目录枚举和文件存在判断中排除新增的 3 个源文件:
|
||||
|
||||
admin/src/components/doctor-web-consultation-notice/index.vue
|
||||
admin/src/hooks/useDoctorWebConsultation.ts
|
||||
admin/src/utils/doctor-web-consultation.ts
|
||||
|
||||
忽略的生成文件 admin/components.d.ts 在 Vite 构建时已加入新公告组件的全局声明。head 模式仅在内存中移除 DoctorWebConsultationNotice 这一条新增注册,防止该生成声明重新导入已排除的新组件;磁盘文件完全不改。
|
||||
|
||||
覆盖可靠性证据
|
||||
|
||||
最终 head 元数据确认 6 个 HEAD 源文件全部被编译器实际读取,每个至少 1 次;3 个新增文件全部从 readDirectory 中排除;生成声明的内存替换亦被读取。current 和 head 两轮 sourcePatched/sysPatched 都为 true。
|
||||
|
||||
最终两轮对 6 个改动源文件、3 个新增源文件、components.d.ts 的运行前后 SHA-256 均相同:unchanged=true,changedDuringRun=[]。sys.writeFile 被设置为失败保护,编译器若尝试写入会直接报错。没有实际回退工作区,没有创建 worktree,没有修改业务源文件,也没有读取 .env。
|
||||
|
||||
开始阶段前两轮在主线程继续补页面、Vite 重生成忽略的组件声明时检测到内容哈希变化,因此以 exit 97 拒收,没有冒称稳定基线成功。最终使用文件稳定后的第三轮结果;未继续重复运行或修复任何无关类型错误。忽略的生成声明确曾重生成,不能只根据 git status/diff 判断此类忽略文件未变。
|
||||
|
||||
诊断比较
|
||||
|
||||
最终全部 error TS 行数:current=61,head=61;比较脚本解析数量也分别为 61,未漏掉非 src 前缀诊断。
|
||||
|
||||
修改文件中的唯一当前诊断:
|
||||
src/views/tcm/appointment/list.vue(91,26): error TS2322: Type 'unknown[]' is not assignable to type 'TreeNodeData[]'.
|
||||
Type 'unknown' is not assignable to type 'TreeNodeData'.
|
||||
|
||||
它映射到 HEAD 的同文件第 90 行,不在本次添加的公告组件或 import 行内。其余 60 条位于未改动的文件。新增 notice/hook/helper 均没有直接类型诊断。较早 57 条日志中的 diagnosis/index.vue 的 cmd 隐式 any 诊断不在最终 61 条输出中,因此不把旧日志行号直接套用到最终结果。
|
||||
|
||||
可复查文件
|
||||
|
||||
.codex-tasks/doctor-web-migration-typecheck-overlay.cjs
|
||||
.codex-tasks/doctor-web-migration-compare-typecheck.cjs
|
||||
.codex-tasks/doctor-web-migration-typecheck-current-verified.log
|
||||
.codex-tasks/doctor-web-migration-typecheck-head-overlay.log
|
||||
.codex-tasks/doctor-web-migration-typecheck-current-meta.json
|
||||
.codex-tasks/doctor-web-migration-typecheck-head-meta.json
|
||||
.codex-tasks/doctor-web-migration-typecheck-comparison.json
|
||||
|
||||
比较命令:node .codex-tasks/doctor-web-migration-compare-typecheck.cjs
|
||||
最终比较退出 0,equivalent=true,sourceHashesUnchanged=true。
|
||||
@@ -0,0 +1,117 @@
|
||||
# 聊天记录同步缓存权限审计
|
||||
|
||||
日期:2026-10-20。范围:本地源码、项目部署说明和调度配置;未连接线上服务器,未执行修复或业务同步。排除了 `public`、`vendor`、`node_modules`、`runtime`;本报告不包含环境变量值或凭据。`.trellis/` 当前不存在;已读取根 `AGENTS.md`。
|
||||
|
||||
## 结论
|
||||
|
||||
`server/runtime/cache/la` 下 `file_put_contents(...): Permission denied` 与本项目默认文件缓存配置一致。聊天同步在 HTTP 和 CLI 中都会写同一套 Cache 检查点;调度器直接在当前进程调用业务命令,不切换身份。**若线上系统 cron / 宝塔任务以 root 执行 `php think crontab`,而 PHP-FPM worker 为 www,root 创建的缓存目录或文件会令后续 www 写入失败。** 这是源码能够支持的主要假设;必须结合线上文件属主、权限、ACL、实际调度用户完成确认,不能仅凭报错断言 root 是唯一原因。
|
||||
|
||||
持久修复应把同一应用的 PHP-FPM、系统 cron、常驻 worker、部署中的 PHP 命令统一为已确认的应用用户,再修复已有缓存归属。只执行一次 `chown` 而继续让 root 定时写缓存会复发。该故障通常无需修改聊天同步业务代码。
|
||||
|
||||
主线程现场反馈(本子任务未独立连接服务器复核):PHP-FPM 用户确认为 www;`runtime/cache/la/06`、`runtime/cache/la/09` 均为 root:root、0755;root 的宝塔 cron 同时存在 `php think crontab`、`sync_im_chat_archive`。这组证据已确认 root 调度与 www Web 进程共写文件缓存导致的权限冲突。主线程负责备份调度脚本、统一 PHP 执行用户和修复缓存归属。
|
||||
|
||||
## 证据与文件位置
|
||||
|
||||
| 文件和行号 | 观察 | 含义 |
|
||||
|---|---|---|
|
||||
| `server/config/cache.php:9` | `default` 为 `env('cache.driver', 'file')` | 未覆盖配置时采用文件缓存;实际驱动仍需线上确认。 |
|
||||
| `server/config/cache.php:17`、`:19` | 文件缓存 `path` 为空、`prefix` 为 `la` | 符合报错中的 `runtime/cache/la` 路径。未读取 vendor,因此不将具体散列目录规则当作已验证事实。 |
|
||||
| `server/app/adminapi/controller/tcm/DiagnosisController.php:491`、`:498`、`:499` | 调用分页同步,捕获 Throwable 后返回“聊天记录同步失败:”加原异常 | PHP 缓存权限异常会原样成为用户看到的同步失败消息。 |
|
||||
| `server/app/adminapi/logic/tcm/DiagnosisLogic.php:1094`、`:1100` | 读写 `im_chat_sync:<token>`,TTL 3600 秒 | HTTP 每一步同步都依赖缓存写入。 |
|
||||
| `server/app/adminapi/logic/tcm/DiagnosisLogic.php:1133`、`:1159` | 读写 `im_chat_complete_v1:<patient>:<account>`,TTL 86400 秒 | HTTP 和 CLI 共用会话完成检查点;不是单纯网页独有的缓存。 |
|
||||
| `server/app/adminapi/logic/tcm/DiagnosisLogic.php:1175` | CLI 也调用 `advanceImChatSync()` | CLI 能以不同 OS 用户创建上述缓存目录和文件。 |
|
||||
| `server/app/adminapi/logic/tcm/DiagnosisLogic.php:1192`、`:1200`、`:1209` | 批量补拉读写 `im_chat_archive_batch_cursor:<sinceDays>`,永久缓存 | 定时批处理还有额外文件缓存写入口。 |
|
||||
| `server/app/common/command/SyncImChatArchive.php:21`、`:42` | 注册 `sync_im_chat_archive`,调用批量同步 | 这是具体定时补拉入口。 |
|
||||
| `server/app/common/command/SyncImChatArchive.php:45`–`:50` | 记录错误并抛 RuntimeException | 归档失败会暴露为任务错误,不是成功返回。 |
|
||||
| `server/app/common/command/Crontab.php:75`、`:77` | 通过 `Console::call()` 在当前进程执行命令 | 任务继承调度器的 OS 用户;数据库任务定义不负责切换 www。 |
|
||||
| `server/app/common/command/Crontab.php:81`–`:86` | IM 归档失败后继续保持 START | 权限未修复时会反复失败;其他任务可能进入 ERROR。 |
|
||||
| `server/config/console.php:23` | 命令类注册 | CLI 名称与业务入口相符。 |
|
||||
| `server/sql/1.9.20260507/add_sync_im_chat_archive_crontab.sql:14`、`:17` | 注册 `sync_im_chat_archive`,周期 `*/30 * * * *` | 数据库内置调度与系统每分钟调度器是两层。 |
|
||||
| `server/sql/1.9.20260909/fix_im_chat_archive_crontab.sql:3`–`:8` | 已有任务改为 `--since-days=0 --limit=200` | 调整覆盖范围不会解决文件权限;不要为本故障重复插入任务。 |
|
||||
| `docs/plans/prescription-ai-deployment.md:19`、`:20`、`:28` | 既有部署记录为 `/www/wwwroot/zyt/server`、`/www/server/php/82/bin/php`、运行用户 www,曾验证 www 的 runtime 写权限 | 可作为现场核对起点;历史记录不能代替当前进程/权限检查。 |
|
||||
| `docs/plans/assistant-revisit-reach-deployment.md:53`、`:60`–`:67` | 文档要求执行 `php think clear`、初始化命令和每分钟 `php think crontab`,没有在每条命令明确运行用户 | 运维按 root 终端照抄存在身份混用风险;后续说明宜明确 www。 |
|
||||
| `server/docs/qywx-im-deploy.md:53`–`:64` | 另一组系统 cron 示例直接执行 php think,未写用户 | 同项目其他 cron 也需要核查身份,否则依然可能污染共享缓存。 |
|
||||
| `docs/wecom-promotion-automation-deployment.md:30`–`:34` | Supervisor 示例使用 `user=www-data` | 是通用示例,线上为 www 时应使用现场身份;避免用户命名混用。 |
|
||||
| `docker/docker-compose.yml:38`、`:41`–`:52` | PHP 服务 `user` 被注释;欢迎语 CLI worker 没有显式 `user` | 属本地开发栈隐患;未检查镜像默认用户,不能据此推断线上 root。 |
|
||||
|
||||
## 线上只读核对命令
|
||||
|
||||
以下 Linux 命令仅作为执行建议,本次未执行。路径来自现有部署记录,现场先核对:
|
||||
|
||||
```sh
|
||||
APP=/www/wwwroot/zyt/server
|
||||
readlink -f "$APP"
|
||||
ps -eo user,group,pid,ppid,comm | awk 'NR == 1 || $5 ~ /php/'
|
||||
stat -c '%U:%G %a %n' "$APP/runtime" "$APP/runtime/cache" "$APP/runtime/cache/la"
|
||||
namei -l "$APP/runtime/cache/la"
|
||||
find "$APP/runtime/cache" -xdev -type d ! -user www -printf '%u:%g %m %p\n' | head -n 40
|
||||
find "$APP/runtime/cache" -xdev -type f ! -user www -printf '%u:%g %m %p\n' | head -n 40
|
||||
runuser -u www -- test -w "$APP/runtime/cache/la"
|
||||
printf 'cache-prefix-write-check=%s\n' "$?"
|
||||
getfacl -p "$APP/runtime/cache" "$APP/runtime/cache/la"
|
||||
lsattr -d "$APP/runtime/cache" "$APP/runtime/cache/la"
|
||||
findmnt -T "$APP/runtime/cache/la"
|
||||
df -h "$APP/runtime/cache/la"
|
||||
df -i "$APP/runtime/cache/la"
|
||||
```
|
||||
|
||||
还应对报错中**完整文件及其散列子目录**执行 `stat` / `namei -l` / `getfacl`。仅检查 `la` 顶层可写并不足够:root 所有的子目录不可写会阻止新缓存创建,root 所有的 0644 文件会阻止既有缓存覆盖;祖先目录缺少遍历权限、ACL 或 SELinux 也能产生相同报错。
|
||||
|
||||
调度位置定位时仅打印文件名,避免把脚本中可能含有的凭据写入审计输出:
|
||||
|
||||
```sh
|
||||
grep -RIlE 'think[[:space:]]+(crontab|sync_im_chat_archive)' /var/spool/cron /etc/cron.d /www/server/cron 2>/dev/null
|
||||
```
|
||||
|
||||
随后本地核实匹配 cron 的任务归属、宝塔配置中的执行用户,以及包装脚本是否降权。对于启动后常驻的 PHP worker,核查 Supervisor `user` / systemd `User` / 容器 UID。PHP-FPM 的 master 为 root 可以正常存在;应以处理请求的 pool worker 身份为准。
|
||||
|
||||
若属主与 POSIX 权限均正常,再核查 ACL mask、只读挂载、immutable 标记、SELinux 拒绝日志。磁盘满或 inode 满一般会产生不同错误,但可同时排除。
|
||||
|
||||
## 持久修复建议
|
||||
|
||||
1. 先把会写这个应用缓存的系统调度和常驻进程统一为确认后的应用用户。若 PHP-FPM worker 确认为 www,可让 root/宝塔调度脚本显式 `runuser -u www`;不要只是给命令外层做目录授权。保留既有执行周期、命令参数、日志和互斥机制,修改现有条目,避免重复注册调度。
|
||||
2. 用户切换后,修复已产生的缓存所有权。限制操作到核实后的应用缓存目录,保留缓存内容;不要为此清空聊天归档表或整个 runtime。
|
||||
3. 后续部署执行 `php think clear`、迁移、初始化、预热等 PHP 命令也使用 www;Supervisor、systemd、容器中涉及该应用的 worker 同样明确身份。
|
||||
4. 如确实需要多个 OS 用户共享文件缓存,才采用专用组、setgid 目录、默认 ACL 与一致 umask;单一应用用户方案更直接。仅设 setgid 而文件仍为 0644 不能让同组用户覆盖文件。
|
||||
|
||||
root / 宝塔包装脚本示例(PHP 路径、项目目录、应用用户确认后使用):
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd /www/wwwroot/zyt/server
|
||||
exec /usr/sbin/runuser -u www -- /www/server/php/82/bin/php think crontab
|
||||
```
|
||||
|
||||
`/etc/cron.d` 示例具有独立的用户字段;不要把该行直接放进用户 crontab,二者格式不同:
|
||||
|
||||
```cron
|
||||
* * * * * www cd /www/wwwroot/zyt/server && /www/server/php/82/bin/php think crontab
|
||||
```
|
||||
|
||||
只修复已确认缓存树的命令示例(有变更,需在调度身份修正后执行):
|
||||
|
||||
```sh
|
||||
APP=/www/wwwroot/zyt/server
|
||||
CACHE=$(readlink -f -- "$APP/runtime/cache")
|
||||
test "$CACHE" = /www/wwwroot/zyt/server/runtime/cache || exit 1
|
||||
find "$CACHE" -xdev -type d -exec chown www:www {} +
|
||||
find "$CACHE" -xdev -type f -exec chown www:www {} +
|
||||
find "$CACHE" -xdev -type d -exec chmod u+rwx {} +
|
||||
find "$CACHE" -xdev -type f -exec chmod u+rw {} +
|
||||
```
|
||||
|
||||
该示例不跟随内部符号链接;如发现缓存树中存在符号链接,应先解释其用途和实际目标。仅恢复属主读写,不对整个站点执行 `chmod 777`。`runtime` 下可能保存 IAM 事务、私有音频、加密密钥等有意设为 0600 的文件;不要笼统递归 chmod 全部 runtime。
|
||||
|
||||
若 `runtime/cache` 本身不存在,则在确认路径无重定向后以 www 身份创建所需目录;同时保证祖先目录可遍历。若错误路径实际为 `runtime/adminapi/cache` 等应用子路径,应按现场路径做等价的有限修复。
|
||||
|
||||
不建议为了本次事件直接全站改用 Redis:当前配置提供 Redis 选项,但切换会影响所有默认缓存、已有登录状态及正在续拉的 token,另需验证连接、数据语义和所有进程配置一致性。即使改 Redis,其他 runtime 文件仍要求正确的进程身份。
|
||||
|
||||
## 验收标准
|
||||
|
||||
- HTTP 同步至少推进一次 token 续拉,返回同步进度而无 Permission denied;检查点完成后可再次同步。
|
||||
- 用 www 执行一个获授权诊单的补拉命令:`/www/server/php/82/bin/php think sync_im_chat_archive --diagnosis-id=<已确认ID> --limit=1`。该命令会请求腾讯并写业务归档,不是只读探针,避免作为权限调查的第一步。
|
||||
- 等待现有系统调度至少完成一轮后,重新检查缓存所有权,确认没有新增 root 属主目录/文件;后台 IM 定时任务错误清除、last_time 正常推进。只在当前数据证明必要时恢复异常停掉的其他任务。
|
||||
- 重复检查 Supervisor / systemd / cron / 手工部署 PHP 命令身份;仅手工 `chown` 后立即点击成功,尚不足以证明不会复发。
|
||||
|
||||
本子任务未修改调度、改动业务代码或执行线上验证命令;线上属主证据仅按主线程现场反馈记录。修复和验收结果由主线程补充。
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"repair": {
|
||||
"started_at": "2026-10-20T10:50:01+0800",
|
||||
"jobs": 256,
|
||||
"completed_jobs": 256,
|
||||
"scanned": 2590008,
|
||||
"changed": 933369,
|
||||
"expired_during_scan": 2,
|
||||
"errors": [],
|
||||
"complete": true,
|
||||
"finished_at": "2026-10-20T10:58:26+0800"
|
||||
},
|
||||
"metadata": {
|
||||
"tasks_verified": 14,
|
||||
"php_commands_verified": 17,
|
||||
"cache_directory_owners": {
|
||||
"www": 256
|
||||
},
|
||||
"sampled_cache_file_owners": {
|
||||
"www": 256
|
||||
},
|
||||
"scheduler_users": [
|
||||
"www"
|
||||
]
|
||||
},
|
||||
"functional": {
|
||||
"uid": 1000,
|
||||
"default_cache_driver": "think\\cache\\driver\\File",
|
||||
"cache_buckets_passed": 256,
|
||||
"sync_completed": true,
|
||||
"sync_steps": 3,
|
||||
"sync_errors": [],
|
||||
"diagnosis_id": 13780,
|
||||
"doctor_id": 213,
|
||||
"archived_rows": 27,
|
||||
"sync_error": ""
|
||||
},
|
||||
"verified_at": "2026-10-20T10:59:33.829357+08:00"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
/mysql-runtime/
|
||||
@@ -0,0 +1,68 @@
|
||||
Payment -> prescription business order links: backend verification
|
||||
Date: 2026-10-22
|
||||
|
||||
Implementation
|
||||
- Both admin payment list rows and detail return prescription_orders: [{id: int, order_no: string}], or [].
|
||||
- Shared lookup: server/app/adminapi/service/order/PaymentPrescriptionOrderService.php.
|
||||
- Lookup runs after the existing permission/search/data scope/pagination query; count() is unchanged.
|
||||
- Exactly one additional joined SELECT for a nonempty payment page; no lookup for an empty page.
|
||||
- Query is bounded to IDs of payments on that page; prescription orders are joined by the actual junction.
|
||||
- Result is deduplicated by prescription business order ID, ordered by business order ID, and projects only id/order_no.
|
||||
- Soft-deleted prescription business orders and dangling junction targets are excluded.
|
||||
- Cancelled/refunded business orders and payments retain display links while the junction still exists.
|
||||
- Existing Order model soft-delete scopes keep deleted payments absent from both list and detail.
|
||||
- No payment mutation, permission change, count/pagination change, migration, or business-data connection was introduced.
|
||||
|
||||
Legacy association decision
|
||||
- tcm_prescription_order_pay_order is the canonical relationship used by existing business order readers/mutations.
|
||||
- Existing migration 2026_04_09_prescription_order_pay_links.sql already imports valid linked_pay_order_id rows idempotently.
|
||||
- No runtime fallback to linked_pay_order_id: it can be stale, including after the existing payment split path.
|
||||
- Current unlink/clear mutations clear the primary legacy field, but an old/stale value must not resurrect a removed junction.
|
||||
- Regression covers positive migrated legacy history, a legacy-only stale field, explicit unlink then stale primary, and a real split transfer.
|
||||
- A deployment must already have the existing April association-table migration applied, as other existing order features require.
|
||||
|
||||
Isolation and cleanup
|
||||
- PHP 8.2.9 with project's installed ThinkPHP/ThinkORM vendor runtime.
|
||||
- MySQL 5.7.26 started with --no-defaults on 127.0.0.1:13429 using a freshly initialized disposable data directory.
|
||||
- Application initialize(), .env, production database configuration, and server/config/project.php were not loaded/read.
|
||||
- Tests create random named databases and DROP only those databases in finally blocks.
|
||||
- Database process 19164 was shut down with mysqladmin; subsequent checks found no process or listening port 13429.
|
||||
- Automatic approval review rejected recursive deletion of the verified exact directory
|
||||
D:\web\zyt\artifacts\payment-prescription-links\mysql-runtime
|
||||
with stated reason "blocked by policy". No additional reason was supplied. Temporary runtime files remain there.
|
||||
- Artifact-local .gitignore excludes mysql-runtime/ to prevent accidental staging. No approval bypass was attempted.
|
||||
- Temporary instrumented regression test copies were removed.
|
||||
|
||||
Passed checks
|
||||
1. ZYT_PAYMENT_LINK_TEST_MYSQL_PORT=13429 php tests/PaymentPrescriptionOrderLinksTest.php
|
||||
PASS (52 checks), executing real OrderLists::lists/count, OrderLogic::detail,
|
||||
PrescriptionOrderLogic::unlinkPayOrder and OrderLogic::split with the actual ORM.
|
||||
Coverage: multiple payment rows, one/multiple/no associations, duplicate rows,
|
||||
same patient without a relation, deleted/dangling business orders, deleted payments,
|
||||
status/search/creator permission, page order/offset/count, one query restricted to page IDs,
|
||||
typed/minimal payload, list/detail consistency, empty page no-query, migrated legacy history,
|
||||
stale primary/unlink behavior, cancelled/refunded history, and split transfer to every child.
|
||||
2. ZYT_UNLINK_TEST_MYSQL_PORT=13429 php tests/PrescriptionOrderUnlinkPayOrderTest.php
|
||||
PASS (131 assertions), original unmodified test.
|
||||
3. php tests/OrderEditTimeContractTest.php
|
||||
PASS (Order edit time contract: OK), original unmodified test.
|
||||
4. PHP lint: OrderLists.php, OrderLogic.php, PaymentPrescriptionOrderService.php,
|
||||
PaymentPrescriptionOrderLinksTest.php: all PASS.
|
||||
5. Scoped git diff --check: PASS after parent mechanically normalized only added/changed
|
||||
OrderLogic.php lines to LF, preserving the existing unchanged CRLF lines.
|
||||
PHP lint for OrderLogic.php also passed after that line-ending correction.
|
||||
|
||||
Existing test bootstrap limitation and supplementary validation
|
||||
- Original PrescriptionOrderReleaseAndTimeTest.php and PrescriptionOrderTrackingAuditTest.php
|
||||
initially failed in RevisitDueHook's warning path: Unable to resolve NULL driver for [think\Log].
|
||||
Their isolated empty config has no logger; the revisit hook hits fixture schema it does not define.
|
||||
- Re-ran temporary copies in the same tests directory with exactly one additional bootstrap statement,
|
||||
immediately after the existing empty config binding:
|
||||
Container::getInstance()->instance('log', new \Psr\Log\NullLogger());
|
||||
- No production method/schema/assertion was modified, and original tests remain unchanged.
|
||||
- ReleaseAndTime: PASS (112 assertions); TrackingAudit: PASS (196 assertions).
|
||||
- These two supplementary passes validate their original order behavior but do not validate revisit hooks.
|
||||
|
||||
Verification limit
|
||||
- Testing used synthetic disposable fixtures, not production data or a deployed authenticated HTTP session.
|
||||
- Existing frontend verification is recorded separately in frontend-verification.txt.
|
||||
@@ -0,0 +1,18 @@
|
||||
支付单关联处方业务订单号:前端验证
|
||||
日期:2026-10-22
|
||||
|
||||
修改:admin/src/views/order/index.vue
|
||||
- 支付单列表在支付单订单号旁增加“处方业务订单号”列。
|
||||
- 支付单详情增加同名字段。
|
||||
- 读取 prescription_orders 数组;多笔逐条展示,无关联展示“未关联”。
|
||||
- 编号自动换行,Vue 插值转义;展示不发起逐行网络请求。
|
||||
|
||||
通过的检查:
|
||||
- 使用 @vue/compiler-sfc 编译完整页面的 script setup 和 template,无编译错误。
|
||||
- 从真实页面 AST 提取新增列表列及详情字段,以 @vue/server-renderer 渲染 8 个场景:
|
||||
字段缺失、空关联、单笔关联、多笔关联分别在列表/详情展示。
|
||||
- 验证无关联占位、实际业务订单号、支付单号不混淆及带 HTML 字符的编号转义。
|
||||
- git diff --check -- admin/src/views/order/index.vue 通过。
|
||||
|
||||
本次为展示字段变更,未新增前端业务逻辑;未重复运行全量生产构建。
|
||||
未部署、未修改真实支付/处方数据。
|
||||
Reference in New Issue
Block a user