Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RuoYi-Vue-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AI算法平台
RuoYi-Vue-master
Commits
b616ce08
Commit
b616ce08
authored
Mar 01, 2024
by
baoxiaode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
算法场景增加频次字段
parent
bb9e5a83
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
14 deletions
+64
-14
ruoyi-admin/src/main/java/com/ruoyi/algorithm/domain/AlgorithmSceneBase.java
...n/java/com/ruoyi/algorithm/domain/AlgorithmSceneBase.java
+11
-0
ruoyi-admin/src/main/java/com/ruoyi/algorithm/domain/dto/AlgorithmSceneDetailsDto.java
.../ruoyi/algorithm/domain/dto/AlgorithmSceneDetailsDto.java
+2
-0
ruoyi-admin/src/main/java/com/ruoyi/algorithm/domain/dto/AlgorithmSceneListDto.java
...com/ruoyi/algorithm/domain/dto/AlgorithmSceneListDto.java
+2
-0
ruoyi-admin/src/main/java/com/ruoyi/algorithm/domain/dto/AlgorithmSceneSaveDto.java
...com/ruoyi/algorithm/domain/dto/AlgorithmSceneSaveDto.java
+2
-0
ruoyi-admin/src/main/java/com/ruoyi/algorithm/service/impl/AlgorithmSceneBaseServiceImpl.java
...algorithm/service/impl/AlgorithmSceneBaseServiceImpl.java
+37
-12
ruoyi-admin/src/main/resources/mapper/system/AlgorithmCameraBaseMapper.xml
...ain/resources/mapper/system/AlgorithmCameraBaseMapper.xml
+1
-1
ruoyi-admin/src/main/resources/mapper/system/AlgorithmSceneBaseMapper.xml
...main/resources/mapper/system/AlgorithmSceneBaseMapper.xml
+9
-1
No files found.
ruoyi-admin/src/main/java/com/ruoyi/algorithm/domain/AlgorithmSceneBase.java
View file @
b616ce08
...
...
@@ -54,6 +54,8 @@ public class AlgorithmSceneBase extends BaseEntity
/** Flink jobId */
private
String
jobId
;
private
String
frequency
;
public
Long
getId
()
{
return
id
;
}
...
...
@@ -133,4 +135,13 @@ public class AlgorithmSceneBase extends BaseEntity
public
void
setJobId
(
String
jobId
)
{
this
.
jobId
=
jobId
;
}
public
String
getFrequency
()
{
return
frequency
;
}
public
void
setFrequency
(
String
frequency
)
{
this
.
frequency
=
frequency
;
}
}
ruoyi-admin/src/main/java/com/ruoyi/algorithm/domain/dto/AlgorithmSceneDetailsDto.java
View file @
b616ce08
...
...
@@ -49,4 +49,6 @@ public class AlgorithmSceneDetailsDto {
* 更新者
*/
private
String
updateBy
;
private
String
frequency
;
}
ruoyi-admin/src/main/java/com/ruoyi/algorithm/domain/dto/AlgorithmSceneListDto.java
View file @
b616ce08
...
...
@@ -45,4 +45,6 @@ public class AlgorithmSceneListDto {
/** 摄像头id列表字符串 */
private
String
cameraIdList
;
private
String
frequency
;
}
ruoyi-admin/src/main/java/com/ruoyi/algorithm/domain/dto/AlgorithmSceneSaveDto.java
View file @
b616ce08
...
...
@@ -49,4 +49,6 @@ public class AlgorithmSceneSaveDto {
* 更新者
*/
private
String
updateBy
;
private
String
frequency
;
}
ruoyi-admin/src/main/java/com/ruoyi/algorithm/service/impl/AlgorithmSceneBaseServiceImpl.java
View file @
b616ce08
...
...
@@ -20,11 +20,13 @@ import com.ruoyi.common.config.AiRestApiConfig;
import
com.ruoyi.common.config.FlinkConfig
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.utils.bean.BeanUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.algorithm.mapper.AlgorithmSceneBaseMapper
;
import
com.ruoyi.algorithm.domain.AlgorithmSceneBase
;
import
com.ruoyi.algorithm.service.IAlgorithmSceneBaseService
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
...
...
@@ -34,6 +36,7 @@ import javax.annotation.Resource;
* @author ruoyi
* @date 2023-04-26
*/
@Slf4j
@Service
public
class
AlgorithmSceneBaseServiceImpl
implements
IAlgorithmSceneBaseService
{
@Autowired
...
...
@@ -134,14 +137,24 @@ public class AlgorithmSceneBaseServiceImpl implements IAlgorithmSceneBaseService
newSceneBase
.
setJobId
(
""
);
if
(
"0"
.
equals
(
algorithmSceneBase
.
getStatus
()))
{
// flink 启动job
try
{
String
result
=
FlinkRestApiUtil
.
runJar
(
FlinkConfig
.
getJarId
(),
FlinkConfig
.
getEntryClass
()
,
StrUtil
.
format
(
FlinkConfig
.
getProgramArgs
(),
algorithmSceneBase
.
getId
()));
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
result
);
String
jobId
=
jsonObject
.
getStr
(
"job"
);
newSceneBase
.
setJobId
(
jobId
);
}
catch
(
Exception
e
){
log
.
error
(
"flink 启动job异常"
);
e
.
printStackTrace
();
}
}
else
{
// flink 取消job
String
s
=
FlinkRestApiUtil
.
cancelJob
(
sceneBase
.
getJobId
());
try
{
FlinkRestApiUtil
.
cancelJob
(
sceneBase
.
getJobId
());
}
catch
(
Exception
e
){
log
.
error
(
"flink 取消job异常"
);
e
.
printStackTrace
();
}
}
//修改场景状态
updateAlgorithmSceneBase
(
newSceneBase
);
...
...
@@ -162,8 +175,12 @@ public class AlgorithmSceneBaseServiceImpl implements IAlgorithmSceneBaseService
//新建场景
AlgorithmSceneBase
algorithmSceneBase
=
new
AlgorithmSceneBase
();
BeanUtils
.
copyBeanProp
(
algorithmSceneBase
,
algorithmSceneSaveDto
);
if
(!
CollectionUtils
.
isEmpty
(
algorithmSceneSaveDto
.
getAlarmTypes
())){
algorithmSceneBase
.
setAlarmTypes
(
algorithmSceneSaveDto
.
getAlarmTypes
().
stream
().
collect
(
Collectors
.
joining
(
","
)));
}
if
(!
CollectionUtils
.
isEmpty
(
algorithmSceneSaveDto
.
getCameraIdList
())){
algorithmSceneBase
.
setCameraIdList
(
algorithmSceneSaveDto
.
getCameraIdList
().
stream
().
collect
(
Collectors
.
joining
(
","
)));
}
int
i
=
insertAlgorithmSceneBase
(
algorithmSceneBase
);
//删除场景下算法块及参数数据
...
...
@@ -197,8 +214,12 @@ public class AlgorithmSceneBaseServiceImpl implements IAlgorithmSceneBaseService
//更新场景
AlgorithmSceneBase
algorithmSceneBase
=
new
AlgorithmSceneBase
();
BeanUtils
.
copyBeanProp
(
algorithmSceneBase
,
algorithmSceneSaveDto
);
if
(!
CollectionUtils
.
isEmpty
(
algorithmSceneSaveDto
.
getAlarmTypes
())){
algorithmSceneBase
.
setAlarmTypes
(
algorithmSceneSaveDto
.
getAlarmTypes
().
stream
().
collect
(
Collectors
.
joining
(
","
)));
}
if
(!
CollectionUtils
.
isEmpty
(
algorithmSceneSaveDto
.
getCameraIdList
())){
algorithmSceneBase
.
setCameraIdList
(
algorithmSceneSaveDto
.
getCameraIdList
().
stream
().
collect
(
Collectors
.
joining
(
","
)));
}
int
i
=
updateAlgorithmSceneBase
(
algorithmSceneBase
);
//删除场景下算法块及参数数据
...
...
@@ -282,8 +303,12 @@ public class AlgorithmSceneBaseServiceImpl implements IAlgorithmSceneBaseService
//通知ai算法
String
url
=
"http://{}:{}/{}?sceneId={}"
;
try
{
url
=
StrUtil
.
format
(
url
,
AiRestApiConfig
.
getHost
(),
AiRestApiConfig
.
getPort
(),
statusKey
,
sceneId
);
HttpUtil
.
post
(
url
,
new
HashMap
<>());
}
catch
(
Exception
e
){
log
.
error
(
"通知ai失败"
);
}
return
;
}
}
ruoyi-admin/src/main/resources/mapper/system/AlgorithmCameraBaseMapper.xml
View file @
b616ce08
...
...
@@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
su.nick_name,
acb.create_time,
acb.sort,
acb.belong
acb.belong
,
acb.`status`
FROM
algorithm_camera_base acb
...
...
ruoyi-admin/src/main/resources/mapper/system/AlgorithmSceneBaseMapper.xml
View file @
b616ce08
...
...
@@ -20,6 +20,7 @@
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"frequency"
column=
"frequency"
/>
</resultMap>
<resultMap
type=
"com.ruoyi.algorithm.domain.dto.AlgorithmSceneListDto"
id=
"AlgorithmSceneListDtoResult"
>
...
...
@@ -34,6 +35,7 @@
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"cameraIdList"
column=
"camera_id_list"
/>
<result
property=
"alarmTypesString"
column=
"alarm_types"
/>
<result
property=
"frequency"
column=
"frequency"
/>
<collection
property=
"alarmTypes"
javaType=
"ArrayList"
column=
"alarm_types"
ofType=
"com.ruoyi.algorithm.domain.AlgorithmBaseType"
select=
"selectAlgorithmBaseType"
/>
<collection
property=
"cameras"
javaType=
"ArrayList"
column=
"camera_id_list"
...
...
@@ -41,7 +43,8 @@
</resultMap>
<sql
id=
"selectAlgorithmSceneBaseVo"
>
select id, scene_name, algorithm_id, alarm_types, frame_second, camera_id_list, live, status, job_id, del_flag, create_by, create_time, update_by, update_time, remark from algorithm_scene_base
select id, scene_name, algorithm_id, alarm_types, frame_second, camera_id_list, live, frequency,
status, job_id, del_flag, create_by, create_time, update_by, update_time, remark from algorithm_scene_base
</sql>
<select
id=
"selectAlgorithmSceneBaseList"
parameterType=
"AlgorithmSceneBase"
resultMap=
"AlgorithmSceneBaseResult"
>
...
...
@@ -52,6 +55,7 @@
<if
test=
"alarmTypes != null and alarmTypes != ''"
>
and alarm_types = #{alarmTypes}
</if>
<if
test=
"frameSecond != null "
>
and frame_second = #{frameSecond}
</if>
<if
test=
"cameraIdList != null and cameraIdList != ''"
>
and camera_id_list = #{cameraIdList}
</if>
<if
test=
"frequency != null and frequency != ''"
>
and frequency = #{frequency}
</if>
</where>
</select>
...
...
@@ -69,6 +73,7 @@
asb.create_time,
asb.`status`,
asb.camera_id_list,
asb.frequency,
asb.alarm_types
FROM
algorithm_scene_base asb
...
...
@@ -131,6 +136,7 @@
<if
test=
"updateBy != null"
>
update_by,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"remark != null"
>
remark,
</if>
<if
test=
"frequency != null"
>
frequency,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"sceneName != null"
>
#{sceneName},
</if>
...
...
@@ -147,6 +153,7 @@
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"remark != null"
>
#{remark},
</if>
<if
test=
"frequency != null"
>
#{frequency},
</if>
</trim>
</insert>
...
...
@@ -167,6 +174,7 @@
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"remark != null"
>
remark = #{remark},
</if>
<if
test=
"frequency != null and frequency != ''"
>
and frequency = #{frequency}
</if>
</trim>
where id = #{id}
</update>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment