修复工作
This commit is contained in:
@@ -65,11 +65,10 @@ public class InspectionTaskEventListener {
|
|||||||
Long taskId = event.getTaskId();
|
Long taskId = event.getTaskId();
|
||||||
log.info("接收到任务完成事件: 任务ID={}", taskId);
|
log.info("接收到任务完成事件: 任务ID={}", taskId);
|
||||||
|
|
||||||
try {
|
// 注意:视频分析已经在 InspectionTaskServiceImpl.performVideoAnalysisWithRecord 中同步执行
|
||||||
// 开始异步视频分析
|
// 因此这里不需要再次调用分析
|
||||||
videoAnalysisService.analyzeVideo(taskId);
|
log.info("任务完成处理完毕: 任务ID={}", taskId);
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理任务完成事件失败: {}", e.getMessage());
|
// 如果未来需要在任务完成后执行其他操作,可以在这里添加
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,7 @@ import javax.imageio.ImageIO;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -118,7 +119,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 启用任务,使用新版实体类的方法
|
// 启用任务,使用新版实体类的方法
|
||||||
task.setStatus(0); // 0表示启用
|
task.setStatus("0"); // 0表示启用
|
||||||
task.setUpdateTime(DateUtils.getNowDate());
|
task.setUpdateTime(DateUtils.getNowDate());
|
||||||
inspectionTaskMapper.updateInspectionTask(task);
|
inspectionTaskMapper.updateInspectionTask(task);
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 停用任务,使用新版实体类的方法
|
// 停用任务,使用新版实体类的方法
|
||||||
task.setStatus(1); // 1表示停用
|
task.setStatus("1"); // 1表示停用
|
||||||
task.setUpdateTime(DateUtils.getNowDate());
|
task.setUpdateTime(DateUtils.getNowDate());
|
||||||
inspectionTaskMapper.updateInspectionTask(task);
|
inspectionTaskMapper.updateInspectionTask(task);
|
||||||
|
|
||||||
@@ -151,7 +152,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
@Async
|
@Async
|
||||||
public void executeInspectionTask(Long taskId) {
|
public void executeInspectionTask(Long taskId) {
|
||||||
InspectionTask task = inspectionTaskMapper.selectInspectionTaskById(taskId);
|
InspectionTask task = inspectionTaskMapper.selectInspectionTaskById(taskId);
|
||||||
if (task == null || task.getStatus() != 0) { // 0表示启用状态
|
if (task == null || !"0".equals(task.getStatus())) { // 0表示启用状态
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +170,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 更新任务状态为执行中
|
// 更新任务状态为执行中
|
||||||
task.setStatus(1);
|
task.setStatus("1");
|
||||||
inspectionTaskMapper.updateInspectionTask(task);
|
inspectionTaskMapper.updateInspectionTask(task);
|
||||||
|
|
||||||
// 获取设备信息
|
// 获取设备信息
|
||||||
@@ -190,7 +191,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
inspectionTaskRecordMapper.updateInspectionTaskRecord(record);
|
inspectionTaskRecordMapper.updateInspectionTaskRecord(record);
|
||||||
|
|
||||||
// 更新任务状态为已完成
|
// 更新任务状态为已完成
|
||||||
task.setStatus(2);
|
task.setStatus("2");
|
||||||
inspectionTaskMapper.updateInspectionTask(task);
|
inspectionTaskMapper.updateInspectionTask(task);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -198,7 +199,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
updateRecordFailed(record, e.getMessage());
|
updateRecordFailed(record, e.getMessage());
|
||||||
|
|
||||||
// 更新任务状态为已完成(虽然失败)
|
// 更新任务状态为已完成(虽然失败)
|
||||||
task.setStatus(2);
|
task.setStatus("2");
|
||||||
inspectionTaskMapper.updateInspectionTask(task);
|
inspectionTaskMapper.updateInspectionTask(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,12 +282,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
minioObject.setCreateTime(new Date());
|
minioObject.setCreateTime(new Date());
|
||||||
Long objectId = vMinioObjectService.insertVMinioObject(minioObject);
|
Long objectId = vMinioObjectService.insertVMinioObject(minioObject);
|
||||||
|
|
||||||
// 7. 更新任务的视频ID和状态
|
// 7. 更新记录的附件信息(视频URL)
|
||||||
task.setVideoOssId(objectId);
|
|
||||||
task.setVideoStatus(1); // 已录制未分析
|
|
||||||
inspectionTaskMapper.updateInspectionTask(task);
|
|
||||||
|
|
||||||
// 8. 更新记录的附件信息(视频URL)
|
|
||||||
record.setAccessory(objectUrl);
|
record.setAccessory(objectUrl);
|
||||||
inspectionTaskRecordMapper.updateInspectionTaskRecord(record);
|
inspectionTaskRecordMapper.updateInspectionTaskRecord(record);
|
||||||
|
|
||||||
@@ -454,18 +450,17 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
|
|
||||||
AlarmRecord alarm = new AlarmRecord();
|
AlarmRecord alarm = new AlarmRecord();
|
||||||
alarm.setTaskId(task.getTaskId());
|
alarm.setTaskId(task.getTaskId());
|
||||||
// 这些字段在新版实体类中可能不存在,需要调整
|
alarm.setTaskName(task.getTaskName());
|
||||||
// alarm.setTaskName(task.getTaskName());
|
|
||||||
alarm.setDeviceId(task.getDeviceId());
|
alarm.setDeviceId(task.getDeviceId());
|
||||||
// alarm.setDeviceName(task.getDeviceName());
|
alarm.setDeviceName(task.getDeviceName());
|
||||||
alarm.setAlarmType(best.getLabel());
|
alarm.setAlarmType(best.getLabel());
|
||||||
// 这里需要转换double为float
|
// 这里需要转换double为float
|
||||||
alarm.setAlarmLevel(getAlarmLevel((float)best.getConfidence()));
|
alarm.setAlarmLevel(getAlarmLevel((float)best.getConfidence()));
|
||||||
alarm.setAlarmContent(String.format("检测到%s,置信度: %.2f", best.getLabel(), best.getConfidence()));
|
alarm.setAlarmDesc(String.format("检测到%s,置信度: %.2f", best.getLabel(), best.getConfidence()));
|
||||||
alarm.setConfidence(best.getConfidence());
|
alarm.setConfidence(BigDecimal.valueOf(best.getConfidence()));
|
||||||
alarm.setImageOssId(rec.getObjectId());
|
alarm.setImagePath(up.getUrl());
|
||||||
alarm.setCreateTime(new Date(now));
|
alarm.setAlarmTime(new Date(now));
|
||||||
alarm.setStatus(0); // 0: 未处理
|
alarm.setHandleStatus("0"); // 0: 未处理
|
||||||
saveAlarmRecord(alarm);
|
saveAlarmRecord(alarm);
|
||||||
currentAlarmId = alarm.getAlarmId();
|
currentAlarmId = alarm.getAlarmId();
|
||||||
|
|
||||||
@@ -546,8 +541,7 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
|
|
||||||
AlarmRecord patch = new AlarmRecord();
|
AlarmRecord patch = new AlarmRecord();
|
||||||
patch.setAlarmId(currentAlarmId);
|
patch.setAlarmId(currentAlarmId);
|
||||||
// videoPath字段在新版实体类中可能不存在,需要调整
|
patch.setVideoPath(upv.getUrl());
|
||||||
// patch.setVideoPath(upv.getUrl());
|
|
||||||
alarmRecordMapper.updateAlarmRecord(patch);
|
alarmRecordMapper.updateAlarmRecord(patch);
|
||||||
} catch (Exception ue) {
|
} catch (Exception ue) {
|
||||||
log.warn("巡检会话-上传/回填视频失败: {}", ue.getMessage());
|
log.warn("巡检会话-上传/回填视频失败: {}", ue.getMessage());
|
||||||
@@ -673,19 +667,18 @@ public class InspectionTaskServiceImpl implements InspectionTaskService {
|
|||||||
// 创建告警记录
|
// 创建告警记录
|
||||||
AlarmRecord alarmRecord = new AlarmRecord();
|
AlarmRecord alarmRecord = new AlarmRecord();
|
||||||
alarmRecord.setTaskId(taskId);
|
alarmRecord.setTaskId(taskId);
|
||||||
// 这些字段在新版实体类中可能不存在,需要调整
|
alarmRecord.setTaskName(task.getTaskName());
|
||||||
// alarmRecord.setTaskName(task.getTaskName());
|
|
||||||
alarmRecord.setDeviceId(task.getDeviceId());
|
alarmRecord.setDeviceId(task.getDeviceId());
|
||||||
// alarmRecord.setDeviceName(task.getDeviceName());
|
alarmRecord.setDeviceName(task.getDeviceName());
|
||||||
alarmRecord.setAlarmType(detection.getLabel());
|
alarmRecord.setAlarmType(detection.getLabel());
|
||||||
alarmRecord.setAlarmLevel(getAlarmLevel((float)detection.getConfidence()));
|
alarmRecord.setAlarmLevel(getAlarmLevel((float)detection.getConfidence()));
|
||||||
alarmRecord.setAlarmContent(String.format("检测到%s,置信度: %.2f",
|
alarmRecord.setAlarmDesc(String.format("检测到%s,置信度: %.2f",
|
||||||
detection.getLabel(), detection.getConfidence()));
|
detection.getLabel(), detection.getConfidence()));
|
||||||
alarmRecord.setConfidence(detection.getConfidence());
|
alarmRecord.setConfidence(BigDecimal.valueOf(detection.getConfidence()));
|
||||||
// 设置图片路径 - 需要调整为适合新实体类的方式
|
// 设置图片路径 - 使用正确的方法名
|
||||||
// alarmRecord.setImagePath(imagePath);
|
alarmRecord.setImagePath(imagePath);
|
||||||
alarmRecord.setCreateTime(new Date());
|
alarmRecord.setAlarmTime(new Date());
|
||||||
alarmRecord.setStatus(0); // 0: 未处理
|
alarmRecord.setHandleStatus("0"); // 0: 未处理
|
||||||
|
|
||||||
saveAlarmRecord(alarmRecord);
|
saveAlarmRecord(alarmRecord);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user