AI预警修改保存目录
This commit is contained in:
parent
c734368723
commit
0bc230dd45
@ -6,6 +6,7 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.xuyanwu.spring.file.storage.FileStorageService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -21,6 +22,7 @@ import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.base.*;
|
||||
import com.zhgd.xmgl.call.entity.ChargeDeletionParam;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.UploadFileService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarCamera;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||
@ -37,7 +39,9 @@ import com.zhgd.xmgl.modules.frontierprotectionnonet.mapper.FrontierProtectionNo
|
||||
import com.zhgd.xmgl.modules.frontierprotectionnonet.service.IFrontierProtectionNoNetDevService;
|
||||
import com.zhgd.xmgl.modules.frontierprotectionnonet.service.impl.FrontierProtectionNoNetDataServiceImpl;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.project.service.impl.ProjectServiceImpl;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareRecord;
|
||||
import com.zhgd.xmgl.modules.video.mapper.AiAnalyseHardWareAlarmRecordMapper;
|
||||
@ -52,10 +56,10 @@ import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
||||
import com.zhgd.xmgl.modules.worker.service.IWorkerAttendancePresenceService;
|
||||
import com.zhgd.xmgl.modules.worker.service.IWorkerAttendanceService;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.WorkerAttendanceServiceImpl;
|
||||
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionCompareDataMapper;
|
||||
import com.zhgd.xmgl.modules.xz.service.IXzHikvisionCompareDataService;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzHikvisionSync;
|
||||
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionCompareDataMapper;
|
||||
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
|
||||
import com.zhgd.xmgl.modules.xz.service.IXzHikvisionCompareDataService;
|
||||
import com.zhgd.xmgl.modules.xz.service.impl.XzHikvisionSyncServiceImpl;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.*;
|
||||
@ -90,6 +94,15 @@ public class HikvisionCall {
|
||||
XzHikvisionSyncServiceImpl xzHikvisionSyncService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
UploadFileService uploadFileService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
ProjectServiceImpl projectService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
FileStorageService fileStorageService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
CarPassRecordServiceImpl carPassRecordService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
@ -385,6 +398,7 @@ public class HikvisionCall {
|
||||
log.info("重复的ai预警数据不保存,deviceID:{},createTime:{}", deviceID, createTime);
|
||||
return;
|
||||
}
|
||||
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(dev.getProjectSn());
|
||||
AiAnalyseHardWareAlarmRecord aiAnalyseHardWareAlarmRecord = new AiAnalyseHardWareAlarmRecord();
|
||||
aiAnalyseHardWareAlarmRecord.setCreateTime(createTime);
|
||||
aiAnalyseHardWareAlarmRecord.setAlarmType(Integer.valueOf(eventType));
|
||||
@ -393,7 +407,8 @@ public class HikvisionCall {
|
||||
aiAnalyseHardWareAlarmRecord.setLocation(srcName);
|
||||
aiAnalyseHardWareAlarmRecord.setProjectSn(dev.getProjectSn());
|
||||
aiAnalyseHardWareAlarmRecord.setStatus(1);
|
||||
aiAnalyseHardWareAlarmRecord.setImageUrl(saveToLocal(imageUrl));
|
||||
String relativePath = projectInfoBySn.getProjectName() + "/" + DateUtil.today();
|
||||
aiAnalyseHardWareAlarmRecord.setImageUrl(uploadFileService.uploadUrlReturnFileName(imageUrl, relativePath));
|
||||
aiAnalyseHardWareAlarmRecordMapper.insert(aiAnalyseHardWareAlarmRecord);
|
||||
//将数据通过MQTT转发到前台
|
||||
asyncAiAnalyse.sendAiAnalyse(aiAnalyseHardWareAlarmRecord, Cts.PROJECT_LEVEL_AND_CHILDREN);
|
||||
@ -1294,9 +1309,9 @@ public class HikvisionCall {
|
||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||
return;
|
||||
}
|
||||
deleteWorkerFace(uniqueId,workerInfo, project);
|
||||
deleteWorkerFace(uniqueId, workerInfo, project);
|
||||
|
||||
deleteWorkerFromHttp(uniqueId,workerInfo, project);
|
||||
deleteWorkerFromHttp(uniqueId, workerInfo, project);
|
||||
}
|
||||
|
||||
public void deleteWorkerFromHttp(String uniqueId, WorkerInfo workerInfo, Project project) throws Exception {
|
||||
@ -2261,17 +2276,7 @@ public class HikvisionCall {
|
||||
|
||||
|
||||
public String saveToLocal(String url) {
|
||||
if (StringUtils.isBlank(url)) {
|
||||
return null;
|
||||
}
|
||||
String fileName = IdUtil.simpleUUID() + ".png";
|
||||
try {
|
||||
X509TrustManagerUtil.downLoadFromUrl(url, fileName, basePath);
|
||||
} catch (Exception e) {
|
||||
log.error("下载海康图片出现异常:" + e);
|
||||
return null;
|
||||
}
|
||||
return fileName;
|
||||
return UrlUtil.saveToLocal(url, basePath, IdUtil.simpleUUID() + ".png");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -34,17 +34,28 @@ public interface UploadFileService {
|
||||
|
||||
FileInfo uploadFileBase64Image(String base64Image);
|
||||
|
||||
/**
|
||||
* 上传url返回文件名称
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
String uploadUrlReturnFileName(String url);
|
||||
|
||||
/**
|
||||
* 上传url返回文件名称
|
||||
*
|
||||
* @param url
|
||||
* @param relativePath 相对路径
|
||||
* @return
|
||||
*/
|
||||
String uploadUrlReturnFileName(String url, String relativePath);
|
||||
|
||||
|
||||
FileInfo uploadFileBufferedImage(BufferedImage bufferedImage);
|
||||
|
||||
Map<String, Object> uploadUrlResource(String url);
|
||||
|
||||
String uploadUrlResourceRtName(String url);
|
||||
|
||||
/**
|
||||
* 异步文件上传
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
void uploadAsync(MultipartFile file);
|
||||
|
||||
Result<UploadImageVo> uploadSjImage(MultipartFile file);
|
||||
|
||||
@ -5,7 +5,6 @@ import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import cn.xuyanwu.spring.file.storage.FileStorageService;
|
||||
import com.zhgd.file.FileUtil;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.vo.UploadImageVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.UploadFileService;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
@ -38,8 +37,7 @@ public class UploadFileServiceImpl implements UploadFileService {
|
||||
private FileStorageService fileStorageService;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* 2017年7月20日 下午5:17:36 @throws
|
||||
* @throws Exception 2017年7月20日 下午5:17:36 @throws
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> uploadImage(MultipartFile[] files) throws Exception {
|
||||
@ -146,7 +144,7 @@ public class UploadFileServiceImpl implements UploadFileService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadUrlResourceRtName(String url) {
|
||||
public String uploadUrlReturnFileName(String url) {
|
||||
try {
|
||||
return ((List<Map<String, Object>>) uploadUrlResource(url).get("data")).get(0).get("imageUrl").toString();
|
||||
} catch (Exception e) {
|
||||
@ -155,6 +153,12 @@ public class UploadFileServiceImpl implements UploadFileService {
|
||||
throw new RuntimeException("转码错误!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadUrlReturnFileName(String url, String relativePath) {
|
||||
FileInfo fileInfo = fileStorageService.of(UrlUtil.uploadImgUrlToMultipartFile(url)).setPath(relativePath).upload();
|
||||
return relativePath + "/" + fileInfo.getFilename();
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步文件上传
|
||||
*/
|
||||
|
||||
@ -3,6 +3,7 @@ package com.zhgd.xmgl.modules.video.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import cn.xuyanwu.spring.file.storage.FileStorageService;
|
||||
@ -32,6 +33,7 @@ import com.zhgd.xmgl.modules.basicdata.service.UploadFileService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectJqmDev;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.project.service.ProjectJqmDevService;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
|
||||
@ -202,16 +204,18 @@ public class AiAnalyseHardWareAlarmRecordServiceImpl extends ServiceImpl<AiAnaly
|
||||
aiAnalyseHardWareAlarmRecord.setHardwareId(aiAnalyseHardWareRecord.getHardwareId());
|
||||
aiAnalyseHardWareAlarmRecord.setHardwareName(aiAnalyseHardWareRecord.getHardwareName());
|
||||
String alarmVideo = body.getString("alarmVideo");
|
||||
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(aiAnalyseHardWareRecord.getProjectSn());
|
||||
String relativePath = projectInfoBySn.getProjectName() + "/AI推送列表/" + DateUtil.today();
|
||||
if (StringUtils.isNotEmpty(alarmVideo)) {
|
||||
FileInfo alarmVideoInfo = fileStorageService.of(UrlUtil.uploadImgUrlToMultipartFile(alarmVideo)).setPath(DateUtil.today()).upload();
|
||||
aiAnalyseHardWareAlarmRecord.setAlarmVideo(DateUtil.today() + "/" + alarmVideoInfo.getFilename());
|
||||
FileInfo alarmVideoInfo = fileStorageService.of(UrlUtil.uploadImgUrlToMultipartFile(alarmVideo)).setPath(relativePath).upload();
|
||||
aiAnalyseHardWareAlarmRecord.setAlarmVideo(relativePath + "/" + alarmVideoInfo.getFilename());
|
||||
}
|
||||
aiAnalyseHardWareAlarmRecord.setProjectSn(aiAnalyseHardWareRecord.getProjectSn());
|
||||
aiAnalyseHardWareAlarmRecord.setStatus(1);
|
||||
String alarmImage = body.getString("alarmImage");
|
||||
if (StringUtils.isNotEmpty(alarmImage)) {
|
||||
FileInfo alarmImageInfo = fileStorageService.of(UrlUtil.uploadImgUrlToMultipartFile(alarmImage)).setPath(DateUtil.today()).upload();
|
||||
aiAnalyseHardWareAlarmRecord.setImageUrl(DateUtil.today() + "/" + alarmImageInfo.getFilename());
|
||||
FileInfo alarmImageInfo = fileStorageService.of(UrlUtil.uploadImgUrlToMultipartFile(alarmImage)).setPath(relativePath).upload();
|
||||
aiAnalyseHardWareAlarmRecord.setImageUrl(relativePath + "/" + alarmImageInfo.getFilename());
|
||||
}
|
||||
|
||||
aiAnalyseHardWareAlarmRecord.setAlarmDesc(body.getString("alarmDesc"));
|
||||
@ -594,6 +598,10 @@ public class AiAnalyseHardWareAlarmRecordServiceImpl extends ServiceImpl<AiAnaly
|
||||
throw new OpenAlertException("未找到该记录");
|
||||
}
|
||||
record.setIsPushed(true);
|
||||
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(record.getProjectSn());
|
||||
String relativePath = projectInfoBySn.getProjectName() + "/AI预警列表/" + DateUtil.today();
|
||||
FileUtil.copy(PathUtil.getBasePath() + "/" + record.getImageUrl(), PathUtil.getBasePath() + "/" + relativePath, false);
|
||||
FileUtil.copy(PathUtil.getBasePath() + "/" + record.getAlarmVideo(), PathUtil.getBasePath() + "/" + relativePath, false);
|
||||
baseMapper.updateById(record);
|
||||
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
|
||||
@ -36,7 +36,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -194,7 +193,7 @@ public class JzgTask {
|
||||
workerAttendance.setProjectSn(projectSn);
|
||||
workerAttendance.setPassType(Integer.valueOf(jzg.getDirection()));
|
||||
workerAttendance.setCardType(getCardType(jzg.getAttendType()));
|
||||
workerAttendance.setImageUrl(uploadFileService.uploadUrlResourceRtName(jzg.getImageUrl()));
|
||||
workerAttendance.setImageUrl(uploadFileService.uploadUrlReturnFileName(jzg.getImageUrl()));
|
||||
for (UfaceDev ufaceDev : ufaceDevs) {
|
||||
Integer passType = workerAttendance.getPassType();
|
||||
if (Objects.equals(passType, 1) && Objects.equals(ufaceDev.getIsEnter(), 1)) {
|
||||
@ -302,25 +301,25 @@ public class JzgTask {
|
||||
if (owi != null) {
|
||||
deleteFile(owi.getFieldAcquisitionUrl());
|
||||
}
|
||||
wi.setFieldAcquisitionUrl(uploadFileService.uploadUrlResourceRtName(jzg.getIssueCardPicUrl()));
|
||||
wi.setFieldAcquisitionUrl(uploadFileService.uploadUrlReturnFileName(jzg.getIssueCardPicUrl()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(jzg.getHeadImageUrl())) {
|
||||
if (owi != null) {
|
||||
deleteFile(owi.getIdCardBigPhotoUrl());
|
||||
}
|
||||
wi.setIdCardBigPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getHeadImageUrl()));
|
||||
wi.setIdCardBigPhotoUrl(uploadFileService.uploadUrlReturnFileName(jzg.getHeadImageUrl()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(jzg.getPositiveIdCardImageUrl())) {
|
||||
if (owi != null) {
|
||||
deleteFile(owi.getIdCardUpPhotoUrl());
|
||||
}
|
||||
wi.setIdCardUpPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getPositiveIdCardImageUrl()));
|
||||
wi.setIdCardUpPhotoUrl(uploadFileService.uploadUrlReturnFileName(jzg.getPositiveIdCardImageUrl()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(jzg.getNegativeIdCardImageUrl())) {
|
||||
if (owi != null) {
|
||||
deleteFile(owi.getIdCardDownPhotoUrl());
|
||||
}
|
||||
wi.setIdCardDownPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getNegativeIdCardImageUrl()));
|
||||
wi.setIdCardDownPhotoUrl(uploadFileService.uploadUrlReturnFileName(jzg.getNegativeIdCardImageUrl()));
|
||||
}
|
||||
wi.setPhoneNumber(jzg.getCellPhone());
|
||||
wi.setIssuingAuthorityForIdcard(jzg.getGrantOrg());
|
||||
|
||||
@ -1,16 +1,12 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
public class PathUtil {
|
||||
|
||||
private static String basePath;
|
||||
|
||||
@Value("${basePath}")
|
||||
public void setBasePath(String basePath) {
|
||||
basePath = basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除多余的斜杠
|
||||
*
|
||||
@ -30,6 +26,11 @@ public class PathUtil {
|
||||
}
|
||||
|
||||
public static String getBasePath() {
|
||||
return basePath;
|
||||
return StrUtil.removeSuffix(basePath, "/");
|
||||
}
|
||||
|
||||
@Value("${basePath}")
|
||||
public void setBasePath(String basePath) {
|
||||
basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,11 +188,31 @@ public class UrlUtil {
|
||||
return mapRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存图片到本地
|
||||
*
|
||||
* @param url
|
||||
* @param savePath
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
public static String saveToLocal(String url, String savePath, String fileName) {
|
||||
if (StringUtils.isBlank(url)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
X509TrustManagerUtil.downLoadFromUrl(url, fileName, savePath);
|
||||
} catch (Exception e) {
|
||||
log.error("下载图片出现异常:" + e);
|
||||
return null;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("k1", "v1");
|
||||
map.put("k", "v");
|
||||
System.out.println(urlJoin("http://baidu.com", map));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user