瀏覽代碼

暂存,图片上传接口制作

kindring 2 年之前
父節點
當前提交
362c70f117

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

@@ -143,6 +143,7 @@ public interface IVideoManagerStorage {
 	 */
 	public PageInfo<Device> queryVideoDeviceList(int page, int count);
 
+	public PageInfo<AiLib> searchAiLib(int page,int count,String key,Integer arithmetic);
 	/**
 	 * 获取多个设备
 	 *

+ 9 - 0
src/main/java/com/genersoft/iot/vmp/storager/dao/HfyDevAiMapper.java

@@ -67,6 +67,15 @@ public interface HfyDevAiMapper {
     @Select("select * from ai_library ")
     List<AiLib> getAiLibraryList();
 
+    @Select(value = {" <script>" +
+            "select * from ai_library where" +
+            " libraryId != 0" +
+            " <if test=\"key != null and key != ''\">and libraryName like '%${key}%'</if>" +
+            " <if test=\"arithmetic != null and arithmetic != 0\">and arithmetic = '${arithmetic}'</if>" +
+            " " +
+            " </script>"})
+    List<AiLib> searchAiLib(String key,Integer arithmetic);
+
     @Select("select * from ai_library where libraryId = #{libraryId}")
     List<AiLib> getAiLibraryByLibId(int libraryId);
 

+ 6 - 0
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java

@@ -440,6 +440,12 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
 		return new PageInfo<>(all);
 	}
 
+	public PageInfo<AiLib> searchAiLib(int page,int count,String key,Integer arithmetic){
+		PageHelper.startPage(page, count);
+		List<AiLib> all = HfyDevAiMapper.searchAiLib(key,arithmetic);
+		return new PageInfo<>(all);
+	}
+
 	/**
 	 * 获取多个设备
 	 *

+ 14 - 0
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java

@@ -152,6 +152,20 @@ public class DeviceQuery {
 		}
 		return storager.queryLibraryList();
 	}
+	@Operation(summary = "ai数据库搜索")
+	@Parameter(name = "page", description = "当前页", required = true)
+	@Parameter(name = "count", description = "每页查询数量", required = true)
+	@Parameter(name = "key", description = "搜索关键字", required = false)
+	@Parameter(name = "arithmetic", description = "搜索关键字", required = false)
+	@GetMapping("/libs")
+	public PageInfo<AiLib> searchAiLibrary(int page,int count,String key,Integer arithmetic){
+		if (logger.isDebugEnabled()) {
+			logger.debug("设备ai数据查询");
+		}
+
+		return storager.searchAiLib(page,count,key,arithmetic);
+	}
+
 	@Operation(summary = "ai库子项数据查询")
 	@Parameter(name = "libraryId", description = "设备国标编号", required = true)
 	@GetMapping("/aiLibItem/{libraryId}")

+ 89 - 16
web_src/src/components/AiLib.vue

@@ -1,22 +1,43 @@
 <template>
   <div id="aiLib w-full" style="width:100%">
     <div class="page-header">
-      <div class="page-title">
+      <div class="page-title flex align-center">
         <el-button icon="el-icon-back" size="mini" style="font-size: 20px; color: #000;" type="text" @click="toBack" ></el-button>
         <el-divider direction="vertical"></el-divider>
         ai数据库
-        <el-select v-model="aiTypeVal" @change="getNowAiLib" placeholder="请选择ai类型">
-          <el-option
-            v-for="item in aiTypeArr"
-            :key="item.val"
-            :label="item.text"
-            :value="item.val"
-            :disabled="item.disabled">
-          </el-option>
-        </el-select>
-        <el-button icon="el-icon-search" type="primary" :loading="isLoading">搜索</el-button>
+
+        <div class="">
+          <el-input class="ml-5 input-with-select" placeholder="输入算法名片段" v-model="key" >
+          <el-select v-model="aiTypeVal"
+                     style="width: 120px;"
+                     slot="prepend"
+                     @change="getNowAiLib" placeholder="请选择ai类型">
+            <el-option
+              :key="0"
+              label="全部算法"
+              :value="0">
+            </el-option>
+            <el-option
+              v-for="item in aiTypeArr"
+              :key="item.val"
+              :label="item.text"
+              :value="item.val"
+              :disabled="item.disabled">
+            </el-option>
+          </el-select>
+          <el-button slot="append"
+                     style="width: 80px;"
+                     icon="el-icon-search"
+                     type="primary"
+                     :loading="isLoading"
+                     @click="searchLibList">搜索</el-button>
+        </el-input>
+        </div>
       </div>
       <div class="page-header-btn">
+        <el-tooltip class="item" effect="dark" content="创建新算法库" placement="left-start">
+          <el-button icon="el-icon-plus" circle size="mini" @click="showCreateLib" ></el-button>
+        </el-tooltip>
       </div>
     </div>
     <el-table :data="libList" style="width: 100%;font-size: 12px;" :height="winHeight" header-row-class-name="table-header">
@@ -47,6 +68,7 @@
 <script>
 import {toNumber} from "@/until/typeTool";
 import aiMap from "@/map/ai";
+import handle from "@/until/handle";
 
 export default {
   name: "AiLib",
@@ -62,8 +84,14 @@ export default {
     currentPage: 1,
     count: 15,
     total: 1,
-
+    key: '',
+    searchKey: '',
+    searchArithmetic: '',
+    lastPage: 1,
   }},
+  mounted(){
+    this.searchLibList();
+  },
   methods:{
     toBack(){
       this.$router.back();
@@ -76,8 +104,48 @@ export default {
       this.libraryId = 0;
       this.triggerType = this.triggerTypes.unlimited;
     },
+    async searchData(searchParam){
+      this.isLoading = true;
+      this.searchKey = searchParam.key;
+      this.searchArithmetic = searchParam.arithmetic;
+      let [err,res] = await handle(this.$axios({
+        method: 'get',
+        url: `/api/device/query/libs`,
+        params: searchParam
+      }))
+      this.isLoading = false;
+      if(err){
+        console.error(err);
+        this.$message.error(err.message);
+        return;
+      }
+      console.log('------------');
+      console.log(res)
+      let result = res.data;
+      if(res.data.code === 0){
+        this.total = result.data.total;
+        this.libList = result.data.list;
+      }
+    },
     searchLibList(){
-
+      // 按搜索按钮进行搜索.
+      let searchParam = {
+        page: 1,
+        count: this.count,
+        key: this.key
+      }
+      if(this.aiTypeVal){searchParam.arithmetic = this.aiTypeVal}
+      this.searchData(searchParam);
+    },
+    changePage(){
+      // 使用当前配置进行搜索
+      let searchParam = {
+        page: this.currentPage,
+        count: this.count,
+        key: this.searchKey,
+        arithmetic: this.searchArithmetic
+      }
+      this.searchData(searchParam);
     },
     /**
      * 编辑lib数据
@@ -86,18 +154,23 @@ export default {
     editLibHandle(row){
       this.$router.push(`/libEdit/${row.libraryId}`);
     },
+    showCreateLib(){
+      this.$router.push(`/createLib`);
+    },
     currentChange: function (val) {
       this.currentPage = val;
-      this.searchLibList();
+      this.changePage();
     },
     handleSizeChange: function (val) {
       this.count = val;
-      this.searchLibList();
+      this.changePage();
     },
   }
 }
 </script>
 
 <style scoped>
-
+.ml-5{
+  margin-left: 5px;
+}
 </style>

+ 137 - 0
web_src/src/components/CreateLib.vue

@@ -0,0 +1,137 @@
+<template>
+  <div id="aiConfig w-full" style="width:100%">
+    <div class="page-header">
+      <div class="page-title">
+        <el-button icon="el-icon-top" size="mini" style="font-size: 20px; color: #000;" type="text" @click="toBack" ></el-button>
+        <el-divider direction="vertical"></el-divider>
+        创建ai库
+      </div>
+      <div class="page-header-btn">
+      </div>
+    </div>
+    <el-container v-loading="isLoading" style="min-height: 82vh;flex-direction: column;" >
+      <el-card  class="box-card mt-5">
+        <div slot="header" class="card-header flex space-between align-center" >
+          <span>输入ai库配置</span>
+        </div>
+        <div class="box-center">
+          <div class="line">
+            <div class="label">算法类型</div>
+            <div class="input">
+              <el-select v-model="aiTypeVal"  placeholder="请选择">
+                <el-option
+                  v-for="item in aiTypeArr"
+                  :key="item.val"
+                  :label="item.text"
+                  :value="item.val"
+                  :disabled="item.val === aiTypes.fire">
+                </el-option>
+              </el-select>
+            </div>
+          </div>
+
+          <div class="line">
+            <div class="label">ai库名称</div>
+            <div class="input">
+              <el-input placeholder="ai库的名称" v-model="libraryName"/>
+            </div>
+          </div>
+
+        </div>
+
+        <el-divider></el-divider>
+        <el-button-group>
+          <el-button @click="init">重置</el-button>
+          <el-button @click="submitData()" type="primary">确认添加</el-button>
+        </el-button-group>
+      </el-card>
+    </el-container>
+  </div>
+</template>
+
+<script>
+import aiMap from "@/map/ai";
+import handle from "@/until/handle";
+
+export default {
+  name: "CreateLib",
+  data(){
+    return {
+      aiTypes: aiMap.aiTypes,
+      aiTypeArr: aiMap.getAITypeArr(),
+      aiTypeVal: 0,
+      libraryName: '',
+      isLoading: false,
+    }
+  },
+  mounted(){
+    this.init();
+  },
+  methods:{
+    init(){
+      this.aiTypeVal = this.aiTypes.face;
+    },
+    toBack(){
+      this.$router.back();
+      this.beforeUrl = "/aiLib"
+    },
+    async submitData(){
+      let data = {};
+      data.arithmetic = this.aiTypeVal;
+      data.libraryName = this.libraryName;
+      this.isLoading = true;
+      let [err,res] = await handle(this.$axios.post(
+        '/api/device/config/addLib',data));
+      this.isLoading = false;
+      if(err){
+        console.error(err)
+        this.$message({
+          showClose: true,
+          message: err,
+          type: 'error'
+        });
+        return;
+      }
+      console.log(res);
+      this.$message.success("创建成功!!!");
+      this.init();
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+.box-center{
+  width:100%;
+  height: auto;
+}
+.box-center{
+  width: 100%;
+  height: auto;
+  padding: 10px 5px;
+  box-sizing: border-box;
+}
+.box-center .line{
+  width: 100%;
+  height: 35px;
+  display: flex;
+  margin-bottom: 10px;
+}
+.box-center .line .label{
+  width: 20%;
+  height: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+.box-center .line .input{
+  width: 80%;
+  height: 100%;
+  display: flex;
+  align-items: center;
+  box-sizing: border-box;
+  padding-left: 8px;
+  border-left: 1px solid grey;
+}
+</style>

+ 6 - 3
web_src/src/components/aiConfig.vue

@@ -7,9 +7,9 @@
       ai订阅配置
     </div>
     <div class="page-header-btn">
-<!--      <el-tooltip class="item" effect="dark" content="添加算法" placement="left-start">-->
-<!--        <el-button icon="el-icon-plus" circle size="mini" @click="showArithmeticDialog" ></el-button>-->
-<!--      </el-tooltip>-->
+      <el-tooltip class="item" effect="dark" content="算法" placement="left-start">
+        <el-button icon="el-icon-more" circle size="mini" @click="showAiLib" ></el-button>
+      </el-tooltip>
     </div>
   </div>
   <add-arithmetic ref="addArithmeticDialog" @select="selectConfigHandle" ></add-arithmetic>
@@ -309,6 +309,9 @@ export default {
     },
     showArithmeticDialog(arithemtic){
       this.$refs.addArithmeticDialog.showDialog(arithemtic,this.deviceId,this.aiList,this.arithmetic[arithemtic]);
+    },
+    showAiLib(){
+      this.$router.push(`/aiLib`);
     }
 
   }

+ 1 - 1
web_src/src/components/createConfig.vue

@@ -211,7 +211,7 @@ export default {
       console.log(this.nowAiLib);
     },
     toAddLibrary(){
-
+      this.$router.push('/createLib');
     },
     // 构建数据结构体
     async submitData(){

+ 12 - 0
web_src/src/router/index.js

@@ -23,6 +23,8 @@ import devAiEdit from "../components/devAiEdit";
 import createConfig from "@/components/createConfig";
 import wasmPlayer from '../components/common/jessibuca.vue'
 import rtcPlayer from '../components/dialog/rtcPlayer.vue'
+import aiLib from "@/components/AiLib";
+import createLib from "@/components/CreateLib";
 
 const originalPush = VueRouter.prototype.push
 VueRouter.prototype.push = function push(location) {
@@ -71,6 +73,16 @@ export default new VueRouter({
           name: 'aiConfig',
           component: aiConfig,
         },
+        {
+          path: '/aiLib',
+          name: 'aiLib',
+          component: aiLib,
+        },
+        {
+          path: '/createLib',
+          name: 'createLib',
+          component: createLib,
+        },
         {
           path: '/createConfig/:arithmetic?',
           name: 'createConfig',