新增本地目录文件点位逻辑

This commit is contained in:
weitang 2025-05-14 16:20:02 +08:00
parent 88ee5540d9
commit 2f51438a5b
4 changed files with 17 additions and 109 deletions

View File

@ -85,7 +85,8 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
String uuid = IdUtil.fastSimpleUUID();
algorithmClass.setId(uuid);
}
String currentUsername = SecurityUtils.getCurrentUsername();
// String currentUsername = SecurityUtils.getCurrentUsername();
String currentUsername = "admin";
this.saveOrUpdate(algorithmClass);
List<AlgorithmParams> algorithmParamsList = algorithmParamsRequest.getAlgorithmParamsList();
algorithmParamsList.forEach(r -> {

View File

@ -463,70 +463,19 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
config.getSnapFilePath() + fullfilename);
}
} else if ("3".equals(config.getFilefromtype())) {
typelist.clear();
String typeStr = "bj_bpmh,bj_bpps,bj_wkps,bjdsyc_zz,bjdsyc_ywj,bmwh," +
"hxq_gjbs,hxq_gjtps,hxq_yfps,jyz_pl,pzqcd,sly_dmyw,ws_ywyc," +
"xmbhyc,yljdq_flow,yljdq_stop,yw_gkxfw,ywzt_yfyc";
// String typeStr = "sly_dmyw";
typelist.addAll(StrUtil.split(typeStr, ","));
//检测系统指定文件目录
String sourceFilePath = config.getTestfilepath();
File directory = new File(sourceFilePath);
if (directory.exists() && directory.isDirectory()) {
File[] files = directory.listFiles();
if (files != null && files.length > 0) {
String taskTodoId = taskTodo.getTaskTodoId();
LambdaUpdateWrapper<TaskTodo> updateWrapper1 =
new LambdaUpdateWrapper<>();
updateWrapper1.eq(TaskTodo::getTaskTodoId, taskTodoId).set(TaskTodo::getDeviceSumnum, files.length);
todoTaskService.update(updateWrapper1);
TaskResult taskResult = taskResultMapper.selectById(map.get("resultId").toString());
taskResultMapper.deleteById(taskResult.getResultId());
for (int i = 0; i < files.length; i++) {
TaskResult taskResult1 = BeanUtil.copyProperties(taskResult,
TaskResult.class);
String id = IdUtil.simpleUUID();
taskResult1.setResultId(id);
String firstFileName = files[i].getName();
String sourceFile = sourceFilePath + firstFileName;
String filepath1 = String.format("%s/%s/%s/%s/%s/%s/",
quartzJob.getStationCode(),
DateUtil.format(DateUtil.date(), "yyyy"),
DateUtil.format(DateUtil.date(), "MM"),
DateUtil.format(DateUtil.date(), "dd"),
quartzJob.getTaskCode(),
filetype
);
//文件命名格式为日期_时间_间隔名_设备名_点位名_类型.jpg
// String filename1 = String.format("%s_%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(),
// i,
// "原图"
// );
String filename1 = firstFileName.replace(".", "_原图.");
String fullfilename1 = filepath1 + filename1;
FileUtil.touch(config.getSnapFilePath() + fullfilename1);
FileUtil.copy(sourceFile,
config.getSnapFilePath() + fullfilename1, true);
// FileUtil
// .del
// (sourceFile);
taskResult1.setFilePath(fullfilename1);
taskResultMapper.insert(taskResult1);
mapList.add(taskResult1);
}
} else {
log.error("目录为空或没有文件");
String deviceName = ObjectUtil.isNotEmpty(map.get("deviceName")) ?
map.get("deviceName").toString() : "";
if (StrUtil.isNotBlank(deviceName)) {
String formatfilePath = String.format("%s%s.jpg", sourceFilePath,
deviceName);
if (FileUtil.exist(formatfilePath)) {
FileUtil.copy(formatfilePath,
config.getSnapFilePath() + fullfilename, true);
log.info("直接获取文件夹中文件" + fullfilename);
}
} else {
log.error("指定的路径不是一个有效的目录");
}
}
}
}
@ -534,9 +483,9 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
//转码存储
String encodefilename = fullfilename;
fullfilename = URLEncoder.encode(fullfilename, "utf-8");
if (!"3".equals(config.getFilefromtype())) {
// if (!"3".equals(config.getFilefromtype())) {
todoTaskService.updateTaskResultStatus(quartzJob.getTaskTodoId(), map.get("resultId").toString(), fullfilename, "1");
}
// }
// 3 调用图片识别算法进行图形识别
//表计类型
// if (ObjectUtil.isNotEmpty(map.get("meterType"))) {
@ -600,51 +549,9 @@ public class TodoTaskJob extends QuartzJobBean implements InterruptableJob {
rtspurl, fullfilename, outsideAngle,
csvFilePath);
} else {
if ("3".equals(config.getFilefromtype())) {
// for (TaskResult taskResult : mapList) {
// Thread.sleep(3000);
// httpUtil.callPicAnalyse(map.get("taskTodoId").toString(), taskResult.getResultId(), JSONUtil.toJsonStr(typelist), JSONUtil.toJsonStr(customParams), taskResult.getFilePath());
// }
// 线程池大小
int numberOfThreads = 1;
// 计算每个线程需要处理的数据量
int chunkSize = mapList.size() / numberOfThreads;
// 线程池
ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
// 提交任务给线程池
for (int i = 0; i < numberOfThreads; i++) {
int start = i * chunkSize;
int end = (i == numberOfThreads - 1) ? mapList.size() : start + chunkSize;
List<TaskResult> subList = mapList.subList(start, end);
// 提交一个Callable或Runnable任务给线程池
// 这里我们使用Runnable和一个匿名内部类来简化示例
executor.submit(() -> {
for (TaskResult taskResult : subList) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
log.error(e.getMessage());;
}
log.info("customParams" + JSONUtil.toJsonStr(customParams));
try {
httpUtil.callPicAnalyse(map.get("taskTodoId").toString(), taskResult.getResultId(), JSONUtil.toJsonStr(typelist),
JSONUtil.toJsonStr(customParams), taskResult.getFilePath());
} catch (Exception e) {
log.error(e.getMessage());;
}
}
});
}
} else {
callresult = httpUtil.callPicAnalyse(map.get("taskTodoId").toString(),
map.get("resultId").toString(), JSONUtil.toJsonStr(typelist),
JSONUtil.toJsonStr(customParams), encodefilename);
}
}
// 解除摄像头的工作状态

View File

@ -154,8 +154,8 @@ httpserver: #配置http请求访问的地址
documentpath: d:\riis\document\
callmethod: 0 #热成像调用方式 0: 调用sdk, 1: 调用智能分析主机
filefromtype: 1 # 1: 摄像机视频流截图, 2:机器人采集上传文件 3测试检测目录文件
testfilepath: d:\Test\ #检测识别文件存放目录
filefromtype: 3 # 1: 摄像机视频流截图, 2:机器人采集上传文件 3测试检测目录文件
testfilepath: d:\test\ #检测识别文件存放目录
algorithm:
manufacturer:

View File

@ -18,7 +18,7 @@
ad.source_type,
ad.device_id,
ad.device_name,
ad.id
ap.id
FROM
iis_algorithm_params ap
LEFT JOIN iis_algorithm_device ad ON ap.id = ad.param_id