feat(medications): 增加基于视觉AI的药品智能录入系统

构建了从照片到药品档案的自动化处理流程,通过GLM多模态大模型实现药品信息的智能采集:

核心能力:
- 创建任务追踪表 t_medication_recognition_tasks 存储识别任务状态
- 四阶段渐进式分析:基础识别→人群适配→成分解析→风险评估
- 提供三个REST端点支持任务创建、进度查询和结果确认
- 前端可通过轮询方式获取0-100%的实时进度反馈
- VIP用户免费使用,普通用户按次扣费

技术实现:
- 利用GLM-4V-Plus模型处理多角度药品图像(正面+侧面+说明书)
- 采用GLM-4-Flash模型进行文本深度分析
- 异步任务执行机制避免接口阻塞
- 完整的异常处理和任务失败恢复策略
- 新增AI_RECOGNITION.md文档详细说明集成方式

同步修复:
- 修正会员用户AI配额扣减逻辑,避免不必要的次数消耗
- 优化APNs推送中无效设备令牌的检测和清理流程
- 将服药提醒的提前通知时间从15分钟缩短为5分钟
This commit is contained in:
richarjiang
2025-11-21 10:27:59 +08:00
parent 75fbea2c90
commit a17fe0b965
14 changed files with 1706 additions and 74 deletions

View File

@@ -0,0 +1,32 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsOptional } from 'class-validator';
/**
* 创建药物识别任务 DTO
*/
export class CreateRecognitionTaskDto {
@ApiProperty({
description: '正面图片URL必需',
example: 'https://cdn.example.com/medications/front_001.jpg',
})
@IsString()
@IsNotEmpty()
frontImageUrl: string;
@ApiProperty({
description: '侧面图片URL必需',
example: 'https://cdn.example.com/medications/side_001.jpg',
})
@IsString()
@IsNotEmpty()
sideImageUrl: string;
@ApiProperty({
description: '辅助面图片URL可选如说明书',
example: 'https://cdn.example.com/medications/auxiliary_001.jpg',
required: false,
})
@IsString()
@IsOptional()
auxiliaryImageUrl?: string;
}