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:
60
src/medications/dto/recognition-status.dto.ts
Normal file
60
src/medications/dto/recognition-status.dto.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { RecognitionStatusEnum } from '../enums/recognition-status.enum';
|
||||
import { RecognitionResultDto } from './recognition-result.dto';
|
||||
|
||||
/**
|
||||
* 药物识别状态响应 DTO
|
||||
*/
|
||||
export class RecognitionStatusDto {
|
||||
@ApiProperty({
|
||||
description: '任务ID',
|
||||
example: 'task_user123_1234567890',
|
||||
})
|
||||
taskId: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '识别状态',
|
||||
enum: RecognitionStatusEnum,
|
||||
example: RecognitionStatusEnum.ANALYZING_PRODUCT,
|
||||
})
|
||||
status: RecognitionStatusEnum;
|
||||
|
||||
@ApiProperty({
|
||||
description: '当前步骤描述',
|
||||
example: '正在识别药品基本信息...',
|
||||
})
|
||||
currentStep: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '进度百分比(0-100)',
|
||||
example: 40,
|
||||
})
|
||||
progress: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: '识别结果(仅在状态为completed时返回)',
|
||||
type: RecognitionResultDto,
|
||||
required: false,
|
||||
})
|
||||
result?: RecognitionResultDto;
|
||||
|
||||
@ApiProperty({
|
||||
description: '错误信息(仅在状态为failed时返回)',
|
||||
example: '图片无法识别,请提供更清晰的照片',
|
||||
required: false,
|
||||
})
|
||||
errorMessage?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '创建时间',
|
||||
example: '2025-01-20T12:00:00.000Z',
|
||||
})
|
||||
createdAt: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: '完成时间(仅在completed或failed时返回)',
|
||||
example: '2025-01-20T12:01:30.000Z',
|
||||
required: false,
|
||||
})
|
||||
completedAt?: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user