kindring 2 жил өмнө
parent
commit
0d0a01ba87

+ 2 - 0
src/main/java/com/genersoft/iot/vmp/conf/exception/ControllerException.java

@@ -34,4 +34,6 @@ public class ControllerException extends RuntimeException{
     public void setMsg(String msg) {
         this.msg = msg;
     }
+
+
 }

+ 3 - 0
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java

@@ -70,6 +70,8 @@ public interface IVideoManagerStorage {
 	 */
 	public List<AiLib> queryLibraryList();
 
+	public int addAiLib(Integer arithmetic,String libraryName);
+
 	/**
 	 * 添加数据库子项
 	 * @param libraryId
@@ -143,6 +145,7 @@ public interface IVideoManagerStorage {
 	 */
 	public PageInfo<Device> queryVideoDeviceList(int page, int count);
 
+
 	public PageInfo<AiLib> searchAiLib(int page,int count,String key,Integer arithmetic);
 	/**
 	 * 获取多个设备

+ 17 - 7
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java

@@ -3,6 +3,7 @@ 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.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
@@ -16,6 +17,7 @@ import com.genersoft.iot.vmp.storager.dao.*;
 import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
 import com.genersoft.iot.vmp.utils.DateUtil;
 import com.genersoft.iot.vmp.vmanager.bean.AiLib;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
 import com.genersoft.iot.vmp.vmanager.bean.UploadService;
 import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
 import com.github.pagehelper.PageHelper;
@@ -275,7 +277,16 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
 	public List<AiLib> queryLibraryList(){
 		return HfyDevAiMapper.getAiLibraryList();
 	}
-
+	public int addAiLib(Integer arithmetic,String libraryName){
+		// 判断算法是否为
+		//if(arithmetic==null){ throw new ControllerException(ErrorCode.ERROR400.getCode(),"请输入算法类型"); }
+		if(arithmetic.intValue()==2){	throw new ControllerException(ErrorCode.ERROR400.getCode(),"该算法不支持创建数据库");}
+		AiLib aiLib = new AiLib();
+		aiLib.setVersion("1");
+		aiLib.setArithmetic(arithmetic.intValue());
+		aiLib.setLibraryName(libraryName);
+		return HfyDevAiMapper.createAiLibrary(aiLib);
+	}
 	/**
 	 * 添加数据库子项
 	 * @param libraryId
@@ -287,7 +298,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
 	public String addLibItem(int libraryId, String itemName, String itemNo, String card, MultipartFile file){
 		// 获取library数据
 		List<AiLib> aiLibArr = HfyDevAiMapper.getAiLibraryByLibId(libraryId);
-		if(aiLibArr.isEmpty()){	logger.warn("无法找到lib库"); return "-1";}
+		if(aiLibArr.isEmpty()){throw new ControllerException(ErrorCode.ERROR400.getCode(),"无法找到lib库");}
 		AiLib libData = aiLibArr.stream().findFirst().get();
 		// 判断ai类型来检测是否合法
 		int arithmetic = libData.getArithmetic();
@@ -345,17 +356,16 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
 				" pushUrl:"+pushUrl);
 		// 火情类型,但是触发类型不是无限制
 		if(arithmetic == 2 && triggerType != 1){
-			logger.warn("火情类型,但是采用了黑白名单触发");
-			return -1;
+			throw new ControllerException(ErrorCode.ERROR400.getCode(),"火情类型,但是采用了黑白名单触发");
 		}
 		// 黑白名单类型,但是没有选择libarayId
 		if(triggerType != 1 && libraryId <1){
-			logger.warn("在非限制类型下使用了ai库");
-			return -1;
+			throw new ControllerException(ErrorCode.ERROR400.getCode(),"在非限制类型下使用了ai库");
 		}
 		if(libraryId > 0 ){
 			List<AiLib> aiLibList = HfyDevAiMapper.findLibByAiTypeAndLibraryId(libraryId,arithmetic);
-			if(aiLibList.isEmpty()){logger.warn("无法找到lib库"); return -1;}
+			if(aiLibList.isEmpty()){throw new ControllerException(ErrorCode.ERROR400.getCode(),"无法找到lib库");}
+
 		}
 		// 查找是否能够找到lib库id
 

+ 7 - 0
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java

@@ -138,6 +138,13 @@ public class DeviceConfig {
 //		return 1;
 	}
 
+	@Operation(summary = "新增ai库")
+	@Parameter(name = "arithmetic" ,description = "算法",required = true)
+	@Parameter(name = "libraryName" ,description = "lib库名称",required = true)
+	@PostMapping("/addLib")
+	public int addLib(@RequestBody Integer arithmetic,@RequestBody String libraryName){
+		return storager.addAiLib(arithmetic,libraryName);
+	}
 
 	/**
 	 * 设备配置查询请求API接口

+ 1 - 0
web_src/src/layout/UiHeader.vue

@@ -13,6 +13,7 @@
       <el-menu-item index="/cloudRecord">云端录像</el-menu-item>
       <el-menu-item index="/mediaServerManger">节点管理</el-menu-item>
       <el-menu-item index="/parentPlatformList/15/1">国标级联</el-menu-item>
+      <el-menu-item index="/aiLib">算法管理</el-menu-item>
       <el-menu-item v-if="editUser" index="/userManager">用户管理</el-menu-item>
 
       <!--            <el-submenu index="/setting">-->