AI预警修改保存目录

This commit is contained in:
GUO 2024-06-01 20:02:23 +08:00
parent 0bc230dd45
commit 2f97b5e3db
2 changed files with 8 additions and 3 deletions

View File

@ -600,8 +600,9 @@ public class AiAnalyseHardWareAlarmRecordServiceImpl extends ServiceImpl<AiAnaly
record.setIsPushed(true); record.setIsPushed(true);
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(record.getProjectSn()); ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(record.getProjectSn());
String relativePath = projectInfoBySn.getProjectName() + "/AI预警列表/" + DateUtil.today(); String relativePath = projectInfoBySn.getProjectName() + "/AI预警列表/" + DateUtil.today();
FileUtil.copy(PathUtil.getBasePath() + "/" + record.getImageUrl(), PathUtil.getBasePath() + "/" + relativePath, false); String dir = PathUtil.getBasePath() + "/" + relativePath;
FileUtil.copy(PathUtil.getBasePath() + "/" + record.getAlarmVideo(), PathUtil.getBasePath() + "/" + relativePath, false); FileUtil.copy(PathUtil.getBasePath() + "/" + record.getImageUrl(), dir + "/" + FileUtil.getName(record.getImageUrl()), true);
FileUtil.copy(PathUtil.getBasePath() + "/" + record.getAlarmVideo(), dir + "/" + FileUtil.getName(record.getAlarmVideo()), true);
baseMapper.updateById(record); baseMapper.updateById(record);
UserInfo user = SecurityUtils.getUser(); UserInfo user = SecurityUtils.getUser();
@ -620,6 +621,8 @@ public class AiAnalyseHardWareAlarmRecordServiceImpl extends ServiceImpl<AiAnaly
throw new OpenAlertException("未找到该记录"); throw new OpenAlertException("未找到该记录");
} }
baseMapper.deleteById(id); baseMapper.deleteById(id);
FileUtil.del(PathUtil.getBasePath() + "/" + record.getImageUrl());
FileUtil.del(PathUtil.getBasePath() + "/" + record.getAlarmVideo());
} }
@Override @Override

View File

@ -2,7 +2,9 @@ package com.zhgd.xmgl.util;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class PathUtil { public class PathUtil {
private static String basePath; private static String basePath;
@ -31,6 +33,6 @@ public class PathUtil {
@Value("${basePath}") @Value("${basePath}")
public void setBasePath(String basePath) { public void setBasePath(String basePath) {
basePath = basePath; PathUtil.basePath = basePath;
} }
} }