优化摄像机任务逻辑

This commit is contained in:
weitang 2025-05-20 16:57:02 +08:00
parent 778e365e18
commit bd0cbc1711
2 changed files with 16 additions and 52 deletions

View File

@ -66,8 +66,13 @@ public class VoiceServerServiceImpl implements VoiceServerService {
e.printStackTrace();
}
if ("OFF".equals(actionPower)) {
if ("3".equals(httpServerConfig.getFilefromtype())) {
FileUtil.copy("D:\\riis\\video\\sound.wav", httpServerConfig.getSnapFilePath() + fileName, true);
// this.createAudioFile(fileName);
}
if ("1".equals(httpServerConfig.getFilefromtype())) {
this.createAudioFile(fileName);
}
}
return true;
}

View File

@ -100,7 +100,6 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
SpringContextHolder.getBean(ISysDictionaryItemsService.class);
TaskResultMapper taskResultMapper = SpringContextHolder.getBean(TaskResultMapper.class);
VoiceServerService voiceServerService = SpringContextHolder.getBean(VoiceServerService.class);
// QuartzMultiTaskManage quartzMultiTaskManage = SpringContextHolder.getBean(QuartzMultiTaskManage.class);
if ("false".equals(config.getDoTask())) {
return;
@ -141,8 +140,7 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
quartzJob.getTaskTodoId(), quartzJob.getPlanStartTime()));
// 任务增加开始时间
LambdaUpdateWrapper<TaskTodo> updateWrapper = new LambdaUpdateWrapper<>();
String startTime1 = quartzJob.getStartTime();
if (StrUtil.isBlank(startTime1)) {
if (StrUtil.isBlank(quartzJob.getStartTime())) {
updateWrapper.eq(TaskTodo::getTaskTodoId, quartzJob.getTaskTodoId()).ne(TaskTodo::getTaskState, "1").set(TaskTodo::getTaskState, "2").set(TaskTodo::getStartTime, DateUtil.now());
todoTaskService.update(updateWrapper);
if (StrUtil.isBlank(quartzJob.getControlNum())) {
@ -276,13 +274,6 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
}
}
//缺陷识别结果类型
// if (ObjUtil.isNotEmpty(map.get("defectresulttypes"))) {
// JSONArray jsonArray = JSONUtil.parseArray(map.get
// ("defectresulttypes").toString());
// customParams.put("defectresulttypes", jsonArray);
// }
if (typelist.size() == 0) {
throw new Exception("未设置识别方式,不能进行图形识别!");
}
@ -315,31 +306,13 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
quartzJob.getTaskCode(),
filetype
);
//文件命名格式为日期_时间_间隔名_设备名_点位名_类型.jpg
// String filename = String.format("%s_%s_%s_%s_%s_%s.jpg",
// DateUtil.format(DateUtil.date(), "yyyyMMdd"),
// DateUtil.format(DateUtil.date(), "HHmmss"),
// map.get("bayName").toString(),
// map.get("mainDeviceName").toString(),
// map.get("deviceName").toString(),
// "原图"
// );
// device_id patroldevice_code
String filename = String.format("%s_%s_%s.jpg",
map.get("deviceId").toString(),
map.get("patroldeviceCode").toString(),
DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss")
);
if ("1".equals(finalLinkageType)) {
//文件命名格式为日期_时间_间隔名_设备名_点位名_类型.jpg
// filename = String.format("%s_%s_%s_%s_%s_%s.mp4",
// DateUtil.format(DateUtil.date(), "yyyyMMdd"),
// DateUtil.format(DateUtil.date(), "HHmmss"),
// map.get("bayName").toString(),
// map.get("mainDeviceName").toString(),
// map.get("deviceName").toString(),
// "视频"
// );
filename = String.format("%s_%s_%s.mp4",
map.get("deviceId").toString(),
map.get("patroldeviceCode").toString(),
@ -372,8 +345,7 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
}
}
}
List<TaskResult> mapList = new ArrayList<>();
JSONObject callresult = null;
JSONObject callresult;
if ("sound".equals(typelist.get(0).toString())) {
//声音检测
filename = String.format("%s_%s_%s_%s_%s.wav",
@ -403,7 +375,6 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
try {
String patroldeviceCode = map.get("patroldeviceCode").toString();
voiceServerService.sendVoiceServerControl(patroldeviceCode, "ON", fullfilename);
// FileUtil.copy("D:\\riis\\video\\sound.wav", config.getSnapFilePath() + fullfilename, true);
Thread.sleep(duration * 1000);
voiceServerService.sendVoiceServerControl(patroldeviceCode, "OFF", fullfilename);
} catch (Exception e) {
@ -451,7 +422,6 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
Thread.sleep(waitTime);
log.info("开始调用视频并截图");
log.info("rtspurl" + rtspurl);
String type = null;
httpUtil.getMonitorVideoSnap(config.getffmpegPath(), rtspurl, fullfilename);
log.info("完成视频截图并保存到对应位置下!,文件名称:" + fullfilename);
String identifyMaterialId = ObjectUtil.isNotEmpty(map.get(
@ -482,16 +452,12 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
//更新当前记录状态修改为 1已巡视(图像已采集)
//转码存储
String encodefilename = fullfilename;
if (fullfilename != null) {
fullfilename = URLEncoder.encode(fullfilename, "utf-8");
}
// if (!"3".equals(config.getFilefromtype())) {
todoTaskService.updateTaskResultStatus(quartzJob.getTaskTodoId(), map.get("resultId").toString(), fullfilename, "1");
// }
// 3 调用图片识别算法进行图形识别
//表计类型
// if (ObjectUtil.isNotEmpty(map.get("meterType"))) {
// customParams.put("meterType", map.get
// ("meterType").toString());
// }
todoTaskService.updateTaskResultStatus(quartzJob.getTaskTodoId(),
map.get("resultId").toString(), fullfilename, "1");
if (ObjectUtil.isNotEmpty(map.get("outsideAngle"))) {
if (JSONUtil.isTypeJSONArray(map.get("outsideAngle").toString())) {
JSONArray jsonArray = JSONUtil.parseArray(map.get("outsideAngle").toString());
@ -531,13 +497,6 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
}
}
//有效识别区域
// if (ObjUtil.isNotEmpty(map.get
// ("patroldeviceEffectiveregion"))) {
// customParams.put("effectiveregion", map.get
// ("patroldeviceEffectiveregion").toString());
// }
log.info("==============================typelist=======================" + typelist.toString());
if ("infrared".equals(typelist.get(0).toString()) && !"3".equals(config.getFilefromtype())) {
//红外测温