feat(video): 添加模型名称字段以支持动态模型选择
- 在 InspectionTask 实体类中新增 modelName 字段及其 getter/setter 方法 - 更新 MyBatis 映射文件,增加对 model_name 字段的映射和支持 - 修改 SQL 查询语句,在查询条件和插入、更新操作中加入 modelName 字段处理 - 调整 VideoAnalysisService 中的模型选择逻辑,优先使用任务配置的模型名称 - 记录日志输出所使用的模型名称及对应的任务ID,便于追踪分析过程
This commit is contained in:
@@ -52,6 +52,16 @@ public class InspectionTask extends BaseEntity {
|
|||||||
/** 报警次数 */
|
/** 报警次数 */
|
||||||
private Long alarmCount;
|
private Long alarmCount;
|
||||||
|
|
||||||
|
private String modelName;
|
||||||
|
|
||||||
|
public void setModelName(String modelName) {
|
||||||
|
this.modelName = modelName;
|
||||||
|
}
|
||||||
|
public String getModelName() {
|
||||||
|
return modelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setTaskId(Long taskId) {
|
public void setTaskId(Long taskId) {
|
||||||
this.taskId = taskId;
|
this.taskId = taskId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ public class VideoAnalysisService {
|
|||||||
/**
|
/**
|
||||||
* 分析视频并更新记录(同步调用)
|
* 分析视频并更新记录(同步调用)
|
||||||
* @param task 巡检任务
|
* @param task 巡检任务
|
||||||
* @param record 巡检记录
|
|
||||||
* @param videoFile 视频文件
|
* @param videoFile 视频文件
|
||||||
*/
|
*/
|
||||||
public void analyzeVideoWithRecord(InspectionTask task, com.ruoyi.video.domain.InspectionTaskRecord record, File videoFile) {
|
public void analyzeVideoWithRecord(InspectionTask task, com.ruoyi.video.domain.InspectionTaskRecord record, File videoFile) {
|
||||||
@@ -83,7 +82,11 @@ public class VideoAnalysisService {
|
|||||||
File outputVideoFile = File.createTempFile("analysis_output_", ".mp4");
|
File outputVideoFile = File.createTempFile("analysis_output_", ".mp4");
|
||||||
|
|
||||||
// 创建检测器
|
// 创建检测器
|
||||||
HttpYoloDetector detector = new HttpYoloDetector("yolov8", PYTHON_API_URL, MODEL_NAME, 0x00FF00);
|
String chosenModel = (task.getModelName() != null && !task.getModelName().trim().isEmpty())
|
||||||
|
? task.getModelName().trim()
|
||||||
|
: MODEL_NAME;
|
||||||
|
log.info("使用模型进行分析: {} (taskId={})", chosenModel, task.getTaskId());
|
||||||
|
HttpYoloDetector detector = new HttpYoloDetector("yolov8", PYTHON_API_URL, chosenModel, 0x00FF00);
|
||||||
|
|
||||||
// 处理视频并记录检测结果
|
// 处理视频并记录检测结果
|
||||||
String detectionResult = processVideoWithRecord(videoFile, outputVideoFile, detector, task, record);
|
String detectionResult = processVideoWithRecord(videoFile, outputVideoFile, detector, task, record);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="executeCount" column="execute_count" />
|
<result property="executeCount" column="execute_count" />
|
||||||
<result property="alarmCount" column="alarm_count" />
|
<result property="alarmCount" column="alarm_count" />
|
||||||
<result property="lastExecuteTime" column="last_execute_time" />
|
<result property="lastExecuteTime" column="last_execute_time" />
|
||||||
|
<result property="modelName" column="model_name" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
@@ -27,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<sql id="selectInspectionTaskVo">
|
<sql id="selectInspectionTaskVo">
|
||||||
select task_id, task_name, device_id, device_name, cron_expression, duration,
|
select task_id, task_name, device_id, device_name, cron_expression, duration,
|
||||||
threshold, enable_detection, status, execute_count, alarm_count,
|
threshold, enable_detection, status, execute_count, alarm_count,
|
||||||
last_execute_time, remark, create_by, create_time, update_by, update_time
|
last_execute_time, model_name, remark, create_by, create_time, update_by, update_time
|
||||||
from v_inspection_task
|
from v_inspection_task
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
|
||||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
<if test="enableDetection != null and enableDetection != ''"> and enable_detection = #{enableDetection}</if>
|
<if test="enableDetection != null and enableDetection != ''"> and enable_detection = #{enableDetection}</if>
|
||||||
|
<if test="modelName != null and modelName != ''"> and model_name = #{modelName}</if>
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
@@ -68,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="executeCount != null">execute_count,</if>
|
<if test="executeCount != null">execute_count,</if>
|
||||||
<if test="alarmCount != null">alarm_count,</if>
|
<if test="alarmCount != null">alarm_count,</if>
|
||||||
<if test="lastExecuteTime != null">last_execute_time,</if>
|
<if test="lastExecuteTime != null">last_execute_time,</if>
|
||||||
|
<if test="modelName != null and modelName != ''">model_name,</if>
|
||||||
<if test="remark != null">remark,</if>
|
<if test="remark != null">remark,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
create_time
|
create_time
|
||||||
@@ -84,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="executeCount != null">#{executeCount},</if>
|
<if test="executeCount != null">#{executeCount},</if>
|
||||||
<if test="alarmCount != null">#{alarmCount},</if>
|
<if test="alarmCount != null">#{alarmCount},</if>
|
||||||
<if test="lastExecuteTime != null">#{lastExecuteTime},</if>
|
<if test="lastExecuteTime != null">#{lastExecuteTime},</if>
|
||||||
|
<if test="modelName != null and modelName != ''">#{modelName},</if>
|
||||||
<if test="remark != null">#{remark},</if>
|
<if test="remark != null">#{remark},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
@@ -104,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="executeCount != null">execute_count = #{executeCount},</if>
|
<if test="executeCount != null">execute_count = #{executeCount},</if>
|
||||||
<if test="alarmCount != null">alarm_count = #{alarmCount},</if>
|
<if test="alarmCount != null">alarm_count = #{alarmCount},</if>
|
||||||
<if test="lastExecuteTime != null">last_execute_time = #{lastExecuteTime},</if>
|
<if test="lastExecuteTime != null">last_execute_time = #{lastExecuteTime},</if>
|
||||||
|
<if test="modelName != null and modelName != ''">model_name = #{modelName},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
|
|||||||
Reference in New Issue
Block a user