|
@@ -1,6 +1,5 @@
|
|
|
package com.genersoft.iot.vmp.storager.impl;
|
|
package com.genersoft.iot.vmp.storager.impl;
|
|
|
|
|
|
|
|
-import com.genersoft.iot.vmp.common.StreamInfo;
|
|
|
|
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
|
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
|
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
|
@@ -8,7 +7,6 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
|
|
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
|
|
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
|
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
|
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
|
|
-import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
|
|
|
|
import com.genersoft.iot.vmp.service.IGbStreamService;
|
|
import com.genersoft.iot.vmp.service.IGbStreamService;
|
|
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
|
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
|
@@ -16,6 +14,7 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
|
|
import com.genersoft.iot.vmp.storager.dao.*;
|
|
import com.genersoft.iot.vmp.storager.dao.*;
|
|
|
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
|
|
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
|
|
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
|
|
|
|
+import com.genersoft.iot.vmp.vmanager.bean.AiAlarm;
|
|
|
import com.genersoft.iot.vmp.vmanager.bean.AiLib;
|
|
import com.genersoft.iot.vmp.vmanager.bean.AiLib;
|
|
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
|
|
import com.genersoft.iot.vmp.vmanager.bean.UploadService;
|
|
import com.genersoft.iot.vmp.vmanager.bean.UploadService;
|
|
@@ -32,7 +31,6 @@ import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.ObjectUtils;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -305,18 +303,18 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
|
|
}
|
|
}
|
|
|
AiLib changeAiLibData = new AiLib();
|
|
AiLib changeAiLibData = new AiLib();
|
|
|
changeAiLibData.setLibraryId(libraryId);
|
|
changeAiLibData.setLibraryId(libraryId);
|
|
|
- logger.info("测试测试测试2");
|
|
|
|
|
|
|
+// logger.info("测试测试测试2");
|
|
|
if(aiLib.getVersion() == "" ){
|
|
if(aiLib.getVersion() == "" ){
|
|
|
- logger.info("设置ai");
|
|
|
|
|
|
|
+// logger.info("设置ai");
|
|
|
changeAiLibData.setVersion(aiLib.getVersion());
|
|
changeAiLibData.setVersion(aiLib.getVersion());
|
|
|
}else{
|
|
}else{
|
|
|
- logger.info("设置数据库");
|
|
|
|
|
|
|
+// logger.info("设置数据库");
|
|
|
changeAiLibData.setVersion(libData.getVersion());
|
|
changeAiLibData.setVersion(libData.getVersion());
|
|
|
}
|
|
}
|
|
|
- logger.info("测试测试测试3");
|
|
|
|
|
|
|
+// logger.info("测试测试测试3");
|
|
|
if(aiLib.getTotal() != 0){changeAiLibData.setTotal(aiLib.getTotal());}
|
|
if(aiLib.getTotal() != 0){changeAiLibData.setTotal(aiLib.getTotal());}
|
|
|
if(aiLib.getLibraryName() != ""){changeAiLibData.setLibraryName(aiLib.getLibraryName());}
|
|
if(aiLib.getLibraryName() != ""){changeAiLibData.setLibraryName(aiLib.getLibraryName());}
|
|
|
- logger.info("测试测试测试4");
|
|
|
|
|
|
|
+// logger.info("测试测试测试4");
|
|
|
return HfyDevAiMapper.updateAiLibrary(changeAiLibData);
|
|
return HfyDevAiMapper.updateAiLibrary(changeAiLibData);
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
@@ -339,12 +337,13 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
|
|
String carNo = "";
|
|
String carNo = "";
|
|
|
int itemType = 2;
|
|
int itemType = 2;
|
|
|
AiLib aiLib = new AiLib();
|
|
AiLib aiLib = new AiLib();
|
|
|
|
|
+ int newTotal = libData.getTotal();
|
|
|
if (arithmetic == 1 && !file.isEmpty()) {
|
|
if (arithmetic == 1 && !file.isEmpty()) {
|
|
|
// 人脸照片存储
|
|
// 人脸照片存储
|
|
|
UploadService uploadService = new UploadService();
|
|
UploadService uploadService = new UploadService();
|
|
|
fileName = uploadService.uploadLibImg(
|
|
fileName = uploadService.uploadLibImg(
|
|
|
String.valueOf(libData.getLibraryId()),
|
|
String.valueOf(libData.getLibraryId()),
|
|
|
- String.valueOf(libData.getTotal()),
|
|
|
|
|
|
|
+ String.valueOf(newTotal),
|
|
|
file);
|
|
file);
|
|
|
itemType = 1;
|
|
itemType = 1;
|
|
|
idCard = card;
|
|
idCard = card;
|
|
@@ -364,11 +363,62 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
|
|
// 添加完成,修改lib的子项
|
|
// 添加完成,修改lib的子项
|
|
|
AiLib newAiLib = new AiLib();
|
|
AiLib newAiLib = new AiLib();
|
|
|
newAiLib.setLibraryId(libraryId);
|
|
newAiLib.setLibraryId(libraryId);
|
|
|
- newAiLib.setTotal(libData.getTotal()+1);
|
|
|
|
|
- newAiLib.setVersion(""+(libData.getTotal()+1));
|
|
|
|
|
|
|
+ newAiLib.setTotal(newTotal+1);
|
|
|
|
|
+ newAiLib.setVersion("v_"+(newTotal+1));
|
|
|
HfyDevAiMapper.updateAiLibrary(newAiLib);
|
|
HfyDevAiMapper.updateAiLibrary(newAiLib);
|
|
|
|
|
+ // todo 发送ai库更新命令
|
|
|
|
|
+
|
|
|
return fileName;
|
|
return fileName;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public String editLibItem(int itemId, String itemName, String itemNo, String card , MultipartFile file){
|
|
|
|
|
+ // 获取item信息
|
|
|
|
|
+ List<AiLib> aiLibArr = HfyDevAiMapper.getAiLibraryFormItemId(itemId);
|
|
|
|
|
+ if(aiLibArr.isEmpty()){throw new ControllerException(ErrorCode.ERROR400.getCode(),"无法找到lib库");}
|
|
|
|
|
+ AiLib libData = aiLibArr.stream().findFirst().get();
|
|
|
|
|
+ // 获取设备原有值
|
|
|
|
|
+ int arithmetic = libData.getArithmetic();
|
|
|
|
|
+ String trait = libData.getTrait();
|
|
|
|
|
+ String imageUrl = libData.getImageUrl();
|
|
|
|
|
+
|
|
|
|
|
+ String _itemName = null;
|
|
|
|
|
+ String _itemNo = null;
|
|
|
|
|
+ String _idCard = null;
|
|
|
|
|
+ String _carNo = null;
|
|
|
|
|
+ String _trait = null;
|
|
|
|
|
+ String _imageUrl = null;
|
|
|
|
|
+
|
|
|
|
|
+ if (arithmetic == 1) {
|
|
|
|
|
+ // 人脸照片存储
|
|
|
|
|
+ if(file!=null && !file.isEmpty()){
|
|
|
|
|
+ logger.info("imageUrl:'"+imageUrl+"' len:"+imageUrl.length());
|
|
|
|
|
+ UploadService uploadService = new UploadService();
|
|
|
|
|
+ if(imageUrl != "" && imageUrl != "\'\'" && imageUrl != "\"\"" && imageUrl.length() != 0){
|
|
|
|
|
+ logger.info("change image Url");
|
|
|
|
|
+ _imageUrl = uploadService.changeImage(imageUrl,file);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ logger.info("new image Url");
|
|
|
|
|
+ _imageUrl = uploadService.uploadLibImg(
|
|
|
|
|
+ String.valueOf(libData.getLibraryId()),
|
|
|
|
|
+ String.valueOf(libData.getTotal()),
|
|
|
|
|
+ file);
|
|
|
|
|
+ logger.info("new imageName:"+_imageUrl);
|
|
|
|
|
+ }
|
|
|
|
|
+ _trait = "";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!card.isEmpty()){_idCard = card;}
|
|
|
|
|
+ }else if(arithmetic == 3 ){
|
|
|
|
|
+ if(!card.isEmpty()){_carNo = card;}
|
|
|
|
|
+ }
|
|
|
|
|
+ if(itemName!=""){
|
|
|
|
|
+ _itemName = itemName;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(itemNo != "" ){
|
|
|
|
|
+ _itemNo = itemNo;
|
|
|
|
|
+ }
|
|
|
|
|
+ HfyDevAiMapper.updateAiLibItem(itemId,_itemName,_itemNo,_idCard,_carNo,_imageUrl,_trait);
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
public int addAiConfig(String configName,
|
|
public int addAiConfig(String configName,
|
|
|
int arithmetic,
|
|
int arithmetic,
|
|
|
int triggerType,
|
|
int triggerType,
|
|
@@ -423,6 +473,13 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
|
|
return HfyDevAiMapper.getLibItemByLibraryId(libraryId);
|
|
return HfyDevAiMapper.getLibItemByLibraryId(libraryId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String queryAiLibVersion(String libId){
|
|
|
|
|
+ List<AiLib> aiLibArr = HfyDevAiMapper.getAiLibVersion(libId);
|
|
|
|
|
+ if(aiLibArr.isEmpty()){return "";}
|
|
|
|
|
+ AiLib libData = aiLibArr.stream().findFirst().get();
|
|
|
|
|
+ return libData.getVersion();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public AiLib queryItemInfoByItemId(int itemId){
|
|
public AiLib queryItemInfoByItemId(int itemId){
|
|
|
List<AiLib> aiLibItemArr = HfyDevAiMapper.queryItemInfoByItemId(itemId);
|
|
List<AiLib> aiLibItemArr = HfyDevAiMapper.queryItemInfoByItemId(itemId);
|
|
|
if(aiLibItemArr.isEmpty()){throw new ControllerException(ErrorCode.ERROR400.getCode(),"无法找到该数据,请检查id");}
|
|
if(aiLibItemArr.isEmpty()){throw new ControllerException(ErrorCode.ERROR400.getCode(),"无法找到该数据,请检查id");}
|
|
@@ -499,6 +556,46 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
|
|
return new PageInfo<>(all);
|
|
return new PageInfo<>(all);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 存储告警数据
|
|
|
|
|
+ * @param deviceId
|
|
|
|
|
+ * @param channelId
|
|
|
|
|
+ * @param arithmetic
|
|
|
|
|
+ * @param alarmItems
|
|
|
|
|
+ * @param uploads
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public int saveAlarm(String deviceId, String channelId, String arithmetic, List<AiAlarm> alarmItems, List<MultipartFile> uploads,
|
|
|
|
|
+ String firmware_version,String timestamp,String battery,String signal,String temp_env,String temp_cpu,String ccid){
|
|
|
|
|
+ // 1. 转储上传文件
|
|
|
|
|
+ UploadService uploadHandle = new UploadService();
|
|
|
|
|
+ String filePaths = uploadHandle.saveDevAlarm(sipConfig.getMediaPath(),deviceId,uploads);
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+ long unixTimestamp = date.getTime()/1000;
|
|
|
|
|
+ logger.info("[文件操作] 告警文件存储成功 文件:{}",filePaths);
|
|
|
|
|
+ logger.info("[数据库操作] alarmItems:{}",alarmItems);
|
|
|
|
|
+ HfyDevAiMapper.saveAiAlarm(deviceId,channelId,arithmetic,alarmItems.size(), String.valueOf(unixTimestamp),filePaths,
|
|
|
|
|
+ firmware_version, timestamp, battery,signal,temp_env,temp_cpu,ccid);
|
|
|
|
|
+ logger.info("[数据库操作] saveAiAlarm ok");
|
|
|
|
|
+ List<AiAlarm> agoAlarms = HfyDevAiMapper.findInsertAiAlarm(deviceId,channelId,arithmetic,alarmItems.size(), String.valueOf(unixTimestamp),filePaths);
|
|
|
|
|
+ if(agoAlarms.isEmpty()){logger.info("[数据库操作] 存储的数据文件无法找到{}",filePaths);return 1;}
|
|
|
|
|
+ AiAlarm agoAlarm = agoAlarms.stream().findFirst().get();
|
|
|
|
|
+ logger.info("[数据库操作] findInsertAiAlarm ok ,alarmId:{}",agoAlarm.getAlarmId());
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 存储info信息
|
|
|
|
|
+ // todo 修改循环单条加入到数据库中.
|
|
|
|
|
+ int AlarmId = agoAlarm.getAlarmId();
|
|
|
|
|
+ for (int i = 0; i < alarmItems.size(); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ AiAlarm alarm = alarmItems.get(i);
|
|
|
|
|
+ HfyDevAiMapper.inertAiarmItem(AlarmId, alarm.getSimilarity(),
|
|
|
|
|
+ alarm.getX1(),alarm.getX2(),alarm.getY1(),alarm.getY2(),
|
|
|
|
|
+ alarm.getInfo(),alarm.getTrackId(),alarm.getUid());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 返回正常值
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取多个设备
|
|
* 获取多个设备
|
|
|
*
|
|
*
|