Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
dfb5fc22
提交
dfb5fc22
authored
4月 28, 2022
作者:
涂茂林
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:电子围栏的增删查改
上级
f6454aa4
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
591 行增加
和
114 行删除
+591
-114
FenceTypeEnum.java
...ain/java/com/yiring/app/constant/alarm/FenceTypeEnum.java
+4
-4
RelevanceParamEnum.java
...ava/com/yiring/app/constant/alarm/RelevanceParamEnum.java
+4
-4
AlarmType.java
app/src/main/java/com/yiring/app/domain/alarm/AlarmType.java
+0
-1
AlarmTypeRepository.java
...java/com/yiring/app/domain/alarm/AlarmTypeRepository.java
+2
-1
District.java
...rc/main/java/com/yiring/app/domain/district/District.java
+0
-1
Fence.java
app/src/main/java/com/yiring/app/domain/fence/Fence.java
+0
-69
LocationFence.java
...in/java/com/yiring/app/domain/location/LocationFence.java
+35
-20
LocationFenceRepository.java
...m/yiring/app/domain/location/LocationFenceRepository.java
+31
-0
LocationFenceRule.java
...ava/com/yiring/app/domain/location/LocationFenceRule.java
+19
-3
AlarmTypeExcel.java
.../main/java/com/yiring/app/excel/alarm/AlarmTypeExcel.java
+2
-2
LocationFenceAddParam.java
...iring/app/param/location/fence/LocationFenceAddParam.java
+81
-0
LocationFenceConditionParam.java
...app/param/location/fence/LocationFenceConditionParam.java
+33
-0
LocationFenceModifyParam.java
...ng/app/param/location/fence/LocationFenceModifyParam.java
+76
-0
AlarmServiceImpl.java
...a/com/yiring/app/service/alarm/impl/AlarmServiceImpl.java
+12
-7
DistrictServiceImpl.java
...yiring/app/service/district/impl/DistrictServiceImpl.java
+3
-0
LocationFenceService.java
...ring/app/service/location/fence/LocationFenceService.java
+47
-0
LocationFenceServiceImpl.java
...service/location/fence/impl/LocationFenceServiceImpl.java
+109
-0
AlarmTypeVo.java
app/src/main/java/com/yiring/app/vo/alarm/AlarmTypeVo.java
+2
-2
LocationFenceVo.java
...ava/com/yiring/app/vo/location/fence/LocationFenceVo.java
+69
-0
LocationFenceController.java
...iring/app/web/location/fence/LocationFenceController.java
+62
-0
没有找到文件。
app/src/main/java/com/yiring/app/constant/alarm/FenceTypeEnum.java
浏览文件 @
dfb5fc22
...
...
@@ -56,13 +56,13 @@ public enum FenceTypeEnum {
/**
* 根据key获取value
* @param
key
围栏类别key
* @param
code
围栏类别key
* @return 围栏类别
*/
public
static
String
getBy
Key
(
Integer
key
)
{
if
(
key
!=
null
)
{
public
static
String
getBy
Code
(
Integer
code
)
{
if
(
code
!=
null
)
{
for
(
FenceTypeEnum
item
:
values
())
{
if
(
item
.
code
.
equals
(
key
))
{
if
(
item
.
code
.
equals
(
code
))
{
return
item
.
name
;
}
}
...
...
app/src/main/java/com/yiring/app/constant/alarm/RelevanceParamEnum.java
浏览文件 @
dfb5fc22
...
...
@@ -76,13 +76,13 @@ public enum RelevanceParamEnum {
/**
* 根据key获取value
* @param
key
关联参数key
* @param
code
关联参数key
* @return 关联参数
*/
public
static
String
getBy
Key
(
Integer
key
)
{
if
(
key
!=
null
)
{
public
static
String
getBy
Code
(
Integer
code
)
{
if
(
code
!=
null
)
{
for
(
RelevanceParamEnum
item
:
values
())
{
if
(
item
.
code
.
equals
(
key
))
{
if
(
item
.
code
.
equals
(
code
))
{
return
item
.
name
;
}
}
...
...
app/src/main/java/com/yiring/app/domain/alarm/AlarmType.java
浏览文件 @
dfb5fc22
...
...
@@ -44,7 +44,6 @@ public class AlarmType implements Serializable {
private
Long
id
;
@Comment
(
"报警类型名称"
)
@Column
(
unique
=
true
)
private
String
name
;
@Comment
(
"围栏类型"
)
...
...
app/src/main/java/com/yiring/app/domain/alarm/AlarmTypeRepository.java
浏览文件 @
dfb5fc22
...
...
@@ -2,6 +2,7 @@
package
com
.
yiring
.
app
.
domain
.
alarm
;
import
java.io.Serializable
;
import
java.util.List
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
...
...
@@ -26,5 +27,5 @@ public interface AlarmTypeRepository
* @param name 名称
* @return 是否存在
*/
AlarmType
find
ByName
(
String
name
);
List
<
AlarmType
>
findAll
ByName
(
String
name
);
}
app/src/main/java/com/yiring/app/domain/district/District.java
浏览文件 @
dfb5fc22
...
...
@@ -46,7 +46,6 @@ public class District implements Serializable {
private
Long
id
;
@Comment
(
"区域信息名称"
)
@Column
(
unique
=
true
)
private
String
name
;
@Comment
(
"风险等级"
)
...
...
app/src/main/java/com/yiring/app/domain/fence/Fence.java
deleted
100644 → 0
浏览文件 @
f6454aa4
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
fence
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
javax.persistence.*
;
import
lombok.*
;
import
lombok.experimental.FieldNameConstants
;
import
org.hibernate.annotations.Comment
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.hibernate.annotations.Where
;
import
org.hibernate.snowflake.SnowflakeId
;
import
org.springframework.data.annotation.CreatedDate
;
import
org.springframework.data.annotation.LastModifiedDate
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
/**
* @author tml
* @version 1.0
* @date 2022/4/28 9:27
*/
@Getter
@Setter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@Entity
@Where
(
clause
=
"deleted = false"
)
@Table
(
name
=
"BS_Fence"
)
@Comment
(
"电子围栏信息"
)
@EntityListeners
(
AuditingEntityListener
.
class
)
public
class
Fence
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
3665747044184158014L
;
@Id
@Comment
(
"主键id"
)
@GeneratedValue
(
generator
=
SnowflakeId
.
GENERATOR
)
@GenericGenerator
(
name
=
SnowflakeId
.
GENERATOR
,
strategy
=
SnowflakeId
.
Strategy
.
LONG
)
private
Long
id
;
private
String
name
;
private
Integer
fenceType
;
@Comment
(
"消抖阈值(秒)"
)
private
Integer
debouncingDuration
;
@Comment
(
"滞留时间(秒)"
)
private
Integer
residenceTime
;
@Comment
(
"创建时间"
)
@CreatedDate
@Column
(
nullable
=
false
)
private
LocalDateTime
createTime
;
@Comment
(
"最后修改时间"
)
@LastModifiedDate
@Column
(
nullable
=
false
)
private
LocalDateTime
lastUpdateTime
;
@Comment
(
value
=
"是否删除"
)
@Column
(
nullable
=
false
)
Boolean
deleted
;
}
app/src/main/java/com/yiring/app/domain/location/LocationFence.java
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
location
;
import
com.yiring.
common.annotation.FieldMapping
;
import
com.yiring.
app.domain.video.Video
;
import
com.yiring.common.domain.BasicEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
...
...
@@ -9,11 +9,11 @@ import java.util.HashSet;
import
java.util.Set
;
import
javax.persistence.*
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
import
lombok.experimental.FieldNameConstants
;
import
lombok.experimental.SuperBuilder
;
import
org.hibernate.annotations.Comment
;
import
org.hibernate.annotations.Type
;
import
org.hibernate.annotations.Where
;
import
org.locationtech.jts.geom.Geometry
;
/**
...
...
@@ -32,47 +32,62 @@ import org.locationtech.jts.geom.Geometry;
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@
FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@
Where
(
clause
=
"deleted = false"
)
@Entity
@Table
(
name
=
"BS_LOCATION_FENCE"
,
indexes
=
{
@Index
(
columnList
=
"mode"
)
}
)
@Table
(
name
=
"BS_LOCATION_FENCE"
)
@Comment
(
"围栏"
)
public
class
LocationFence
extends
BasicEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
4155868702188991300L
;
@Comment
(
"
地图 ID
"
)
Long
areaId
;
@Comment
(
"
围栏名称
"
)
private
String
name
;
@FieldMapping
(
"entityTypes"
)
@Comment
(
"围栏模型"
)
@Enumerated
(
EnumType
.
STRING
)
Mode
mode
;
@Comment
(
"地图ID"
)
private
Long
mapId
;
@Comment
(
"地图名称"
)
private
String
mapName
;
@Comment
(
"摄像头"
)
@ManyToOne
@JoinColumn
(
name
=
"video_id"
)
private
Video
video
;
@Comment
(
"围栏类别"
)
private
Integer
fenceType
;
@Comment
(
"空间信息"
)
@Type
(
type
=
"jts_geometry"
)
@Column
(
columnDefinition
=
"geometry"
)
Geometry
geometry
;
private
Geometry
geometry
;
@Comment
(
"
超时时间(秒)
"
)
Integer
overt
ime
;
@Comment
(
"
滞留时间(秒)
"
)
private
Integer
residenceT
ime
;
@Comment
(
"消抖时间(秒)"
)
Integer
threshold
;
@Comment
(
"消抖时间(秒)"
)
private
Integer
threshold
;
@Comment
(
"是否启用"
)
private
Boolean
enable
;
@Comment
(
value
=
"是否删除"
)
@Column
(
nullable
=
false
)
Boolean
deleted
;
@Comment
(
"信标集合"
)
@Builder
.
Default
@ManyToMany
@ToString
.
Exclude
Set
<
LocationBeacon
>
beacons
=
new
HashSet
<>(
0
);
private
Set
<
LocationBeacon
>
beacons
=
new
HashSet
<>(
0
);
@Comment
(
"围栏规则集合"
)
@Builder
.
Default
@OneToMany
(
mappedBy
=
"fence"
)
@ToString
.
Exclude
Set
<
LocationFenceRule
>
rules
=
new
HashSet
<>(
0
);
@SuppressWarnings
({
"unused"
})
private
Set
<
LocationFenceRule
>
rules
=
new
HashSet
<>(
0
);
/*@SuppressWarnings({ "unused" })
public enum Mode {
NORMAL("常规区域"),
DANGER("危险源区域");
...
...
@@ -83,5 +98,5 @@ public class LocationFence extends BasicEntity implements Serializable {
Mode(String text) {
this.text = text;
}
}
}
*/
}
app/src/main/java/com/yiring/app/domain/location/LocationFenceRepository.java
0 → 100644
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
location
;
import
java.io.Serializable
;
import
java.util.List
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
/**
* @author tml
* @version 1.0
* @date 2022/4/28 13:48
*/
@Repository
public
interface
LocationFenceRepository
extends
JpaRepository
<
LocationFence
,
Serializable
>,
JpaSpecificationExecutor
<
LocationFence
>
{
/**
* 查询名称是否存在
* @param name 围栏名称
* @return true:存在 false:不存在
*/
Boolean
existsByName
(
String
name
);
/**
* 根据名称查询围栏信息
* @param name 围栏名称
* @return 围栏信息
*/
List
<
LocationFence
>
findAllByName
(
String
name
);
}
app/src/main/java/com/yiring/app/domain/location/LocationFenceRule.java
浏览文件 @
dfb5fc22
...
...
@@ -4,13 +4,14 @@ package com.yiring.app.domain.location;
import
com.yiring.common.domain.BasicEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.Objects
;
import
javax.persistence.Entity
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
import
lombok.experimental.FieldNameConstants
;
import
org.hibernate.Hibernate
;
import
org.hibernate.annotations.Comment
;
/**
...
...
@@ -29,7 +30,6 @@ import org.hibernate.annotations.Comment;
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@Entity
@Table
(
name
=
"BS_LOCATION_FENCE_RULE"
)
@Comment
(
"围栏规则"
)
...
...
@@ -41,10 +41,26 @@ public class LocationFenceRule extends BasicEntity implements Serializable {
@Comment
(
"围栏"
)
@ManyToOne
@JoinColumn
(
name
=
"fence_id"
)
LocationFence
fence
;
private
LocationFence
fence
;
@Comment
(
"静止时长(分钟)"
)
private
Integer
staticDuration
;
// TODO
// 字段补充
// 关联表补充(报警规则)
// 关联表配置值补充
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
Hibernate
.
getClass
(
this
)
!=
Hibernate
.
getClass
(
o
))
return
false
;
LocationFenceRule
that
=
(
LocationFenceRule
)
o
;
return
getId
()
!=
null
&&
Objects
.
equals
(
getId
(),
that
.
getId
());
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
super
.
hashCode
(),
fence
,
staticDuration
);
}
}
app/src/main/java/com/yiring/app/excel/alarm/AlarmTypeExcel.java
浏览文件 @
dfb5fc22
...
...
@@ -50,8 +50,8 @@ public class AlarmTypeExcel implements Serializable {
return
AlarmTypeExcel
.
builder
()
.
name
(
alarmType
.
getName
())
.
fenceType
(
FenceTypeEnum
.
getBy
Key
(
alarmType
.
getFenceType
()))
.
relevanceParam
(
RelevanceParamEnum
.
getBy
Key
(
alarmType
.
getRelevanceParam
()))
.
fenceType
(
FenceTypeEnum
.
getBy
Code
(
alarmType
.
getFenceType
()))
.
relevanceParam
(
RelevanceParamEnum
.
getBy
Code
(
alarmType
.
getRelevanceParam
()))
.
comment
(
alarmType
.
getComment
())
.
build
();
}
...
...
app/src/main/java/com/yiring/app/param/location/fence/LocationFenceAddParam.java
0 → 100644
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
param
.
location
.
fence
;
import
com.yiring.app.constant.alarm.FenceTypeEnum
;
import
com.yiring.app.domain.location.LocationFence
;
import
com.yiring.app.domain.video.Video
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.validator.constraints.Length
;
import
org.hibernate.validator.constraints.Range
;
import
org.locationtech.jts.geom.Geometry
;
/**
* @author tml
* @version 1.0
* @date 2022/4/28 10:52
*/
@ApiModel
(
"LocationFenceAddParam(添加围栏信息的param)"
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
LocationFenceAddParam
{
@ApiModelProperty
(
value
=
"围栏名称"
,
example
=
"1"
)
@NotEmpty
(
message
=
"围栏名称不能为空"
)
@Length
(
max
=
10
,
message
=
"围栏名称不能超过10个字符"
)
private
String
name
;
@ApiModelProperty
(
value
=
"地图ID"
,
example
=
"1"
)
@NotNull
(
message
=
"地图不能为空"
)
private
Long
mapId
;
@ApiModelProperty
(
value
=
"地图名称"
,
example
=
"1"
)
@NotNull
(
message
=
"地图名称不能为空"
)
private
String
mapName
;
@ApiModelProperty
(
value
=
"摄像头ID"
,
example
=
"1"
)
@NotNull
(
message
=
"关联摄像头不能为空"
)
private
Long
videoId
;
@ApiModelProperty
(
value
=
"围栏类别"
,
example
=
"1"
)
@NotNull
(
message
=
"围栏类别不能为空"
)
@Range
(
min
=
FenceTypeEnum
.
MIN
,
max
=
FenceTypeEnum
.
MAX
,
message
=
"请选择正确的围栏类别"
)
private
Integer
fenceType
;
@ApiModelProperty
(
value
=
"空间信息"
,
example
=
"1"
)
@NotNull
(
message
=
"区域信息不能为空"
)
private
Geometry
geometry
;
@ApiModelProperty
(
value
=
"滞留时间(秒)"
,
example
=
"1"
)
@NotNull
(
message
=
"滞留时间不能为空"
)
private
Integer
residenceTime
;
@ApiModelProperty
(
value
=
"消抖时间(秒)"
,
example
=
"1"
)
@NotNull
(
message
=
"消抖时间不能为空"
)
private
Integer
threshold
;
public
LocationFence
transform
()
{
Video
video
=
Video
.
builder
().
id
(
videoId
).
build
();
return
LocationFence
.
builder
()
.
name
(
name
)
.
mapId
(
mapId
)
.
mapName
(
mapName
)
.
video
(
video
)
.
fenceType
(
fenceType
)
.
geometry
(
geometry
)
.
residenceTime
(
residenceTime
)
.
threshold
(
threshold
)
.
enable
(
false
)
.
deleted
(
false
)
.
build
();
}
}
app/src/main/java/com/yiring/app/param/location/fence/LocationFenceConditionParam.java
0 → 100644
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
param
.
location
.
fence
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author tml
* @version 1.0
* @date 2022/4/28 13:35
*/
@ApiModel
(
"LocationFenceConditionParam(查询围栏信息的条件param)"
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
LocationFenceConditionParam
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
6711068412873775138L
;
@ApiModelProperty
(
value
=
"地图id"
,
example
=
"1"
)
private
Long
mapId
;
@ApiModelProperty
(
value
=
"围栏类型"
,
example
=
"1"
)
private
Long
fenceType
;
}
app/src/main/java/com/yiring/app/param/location/fence/LocationFenceModifyParam.java
0 → 100644
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
param
.
location
.
fence
;
import
com.yiring.app.constant.alarm.FenceTypeEnum
;
import
com.yiring.app.domain.location.LocationFence
;
import
com.yiring.app.domain.video.Video
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotNull
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.validator.constraints.Length
;
import
org.hibernate.validator.constraints.Range
;
import
org.locationtech.jts.geom.Geometry
;
/**
* @author tml
* @version 1.0
* @date 2022/4/28 10:52
*/
@ApiModel
(
"LocationFenceModifyParam(修改围栏信息的param)"
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
LocationFenceModifyParam
{
@ApiModelProperty
(
value
=
"围栏ID"
,
example
=
"1"
)
@NotNull
(
message
=
"围栏id不能为空"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"围栏名称"
,
example
=
"1"
)
@Length
(
max
=
10
,
message
=
"围栏名称不能超过10个字符"
)
private
String
name
;
@ApiModelProperty
(
value
=
"地图ID"
,
example
=
"1"
)
private
Long
mapId
;
@ApiModelProperty
(
value
=
"地图名称"
,
example
=
"1"
)
private
String
mapName
;
@ApiModelProperty
(
value
=
"摄像头ID"
,
example
=
"1"
)
private
Long
videoId
;
@ApiModelProperty
(
value
=
"围栏类别"
,
example
=
"1"
)
@Range
(
min
=
FenceTypeEnum
.
MIN
,
max
=
FenceTypeEnum
.
MAX
,
message
=
"请选择正确的围栏类别"
)
private
Integer
fenceType
;
@ApiModelProperty
(
value
=
"空间信息"
,
example
=
"1"
)
private
Geometry
geometry
;
@ApiModelProperty
(
value
=
"滞留时间(秒)"
,
example
=
"1"
)
private
Integer
residenceTime
;
@ApiModelProperty
(
value
=
"消抖时间(秒)"
,
example
=
"1"
)
private
Integer
threshold
;
public
LocationFence
transform
()
{
Video
video
=
Video
.
builder
().
id
(
videoId
).
build
();
return
LocationFence
.
builder
()
.
id
(
id
)
.
name
(
name
)
.
mapId
(
mapId
)
.
mapName
(
mapName
)
.
video
(
video
)
.
fenceType
(
fenceType
)
.
geometry
(
geometry
)
.
residenceTime
(
residenceTime
)
.
threshold
(
threshold
)
.
enable
(
false
)
.
build
();
}
}
app/src/main/java/com/yiring/app/service/alarm/impl/AlarmServiceImpl.java
浏览文件 @
dfb5fc22
...
...
@@ -60,14 +60,19 @@ public class AlarmServiceImpl implements AlarmService {
@Override
public
Result
<
String
>
modifyAlarmType
(
AlarmTypeModifyParam
param
)
{
AlarmType
alarmType
;
AlarmType
byName
=
alarmTypeRepository
.
findByName
(
param
.
getName
());
if
(
byName
!=
null
)
{
if
(!
byName
.
getId
().
equals
(
param
.
getId
()))
{
AlarmType
alarmType
=
null
;
List
<
AlarmType
>
allByName
=
alarmTypeRepository
.
findAllByName
(
param
.
getName
());
if
(
allByName
.
size
()
>
1
)
{
log
.
warn
(
"AlarmServiceImpl.modifyAlarmType时查询出两条报警类型名称相同的数据,param:[{}]"
,
param
);
}
for
(
AlarmType
item
:
allByName
)
{
if
(
item
.
getId
().
equals
(
param
.
getId
()))
{
alarmType
=
item
;
}
else
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"名称已被占用"
);
}
alarmType
=
byName
;
}
else
{
}
if
(
alarmType
==
null
)
{
Optional
<
AlarmType
>
optional
=
alarmTypeRepository
.
findById
(
param
.
getId
());
if
(
optional
.
isEmpty
())
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"修改的报警类型不存在"
);
...
...
@@ -153,7 +158,7 @@ public class AlarmServiceImpl implements AlarmService {
if
(
conditionParam
.
getRelevanceParam
()
!=
null
)
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"relevanceParam"
),
conditionParam
.
getRelevanceParam
()));
}
Predicate
[]
array
=
list
.
toArray
(
new
Predicate
[
list
.
size
()
]);
Predicate
[]
array
=
list
.
toArray
(
new
Predicate
[
0
]);
return
criteriaBuilder
.
and
(
array
);
};
}
...
...
app/src/main/java/com/yiring/app/service/district/impl/DistrictServiceImpl.java
浏览文件 @
dfb5fc22
...
...
@@ -48,6 +48,9 @@ public class DistrictServiceImpl implements DistrictService {
public
Result
<
String
>
modifyDistrict
(
DistrictModifyParam
param
)
{
List
<
District
>
list
=
districtRepository
.
findAllByName
(
param
.
getName
());
District
district
=
null
;
if
(
list
.
size
()
>
1
)
{
log
.
warn
(
"DistrictServiceImpl.modifyDistrict时查询出两条区域信息名称相同的数据,param:[{}]"
,
param
);
}
//校验名称是否重复
for
(
District
item
:
list
)
{
if
(
item
.
getId
().
equals
(
param
.
getId
()))
{
...
...
app/src/main/java/com/yiring/app/service/location/fence/LocationFenceService.java
0 → 100644
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
service
.
location
.
fence
;
import
com.yiring.app.param.location.fence.LocationFenceAddParam
;
import
com.yiring.app.param.location.fence.LocationFenceConditionParam
;
import
com.yiring.app.param.location.fence.LocationFenceModifyParam
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.vo.PageVo
;
/**
* @author tml
* @version 1.0
* @date 2022/4/28 13:44
*/
public
interface
LocationFenceService
{
/**
* 添加围栏信息
* @param param 围栏信息
* @return 是否成功
*/
Result
<
String
>
addLocationFence
(
LocationFenceAddParam
param
);
/**
* 修改围栏信息
* @param param 围栏信息
* @return 是否成功
*/
Result
<
String
>
modifyLocationFence
(
LocationFenceModifyParam
param
);
/**
* 删除围栏信息
* @param param 围栏id
* @return 是否成功
*/
Result
<
String
>
removeLocationFence
(
IdParam
param
);
/**
* 根据条件分页查询围栏信息
* @param conditionParam 条件
* @param pageParam 分页参数
* @return 是否成功
*/
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
LocationFenceConditionParam
conditionParam
,
PageParam
pageParam
);
}
app/src/main/java/com/yiring/app/service/location/fence/impl/LocationFenceServiceImpl.java
0 → 100644
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
service
.
location
.
fence
.
impl
;
import
com.yiring.app.domain.location.LocationFence
;
import
com.yiring.app.domain.location.LocationFenceRepository
;
import
com.yiring.app.param.location.fence.LocationFenceAddParam
;
import
com.yiring.app.param.location.fence.LocationFenceConditionParam
;
import
com.yiring.app.param.location.fence.LocationFenceModifyParam
;
import
com.yiring.app.service.location.fence.LocationFenceService
;
import
com.yiring.app.util.JpaUtil
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.core.Status
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.vo.PageVo
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.persistence.criteria.Predicate
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* 围栏信息service
* @author tml
* @version 1.0
* @date 2022/4/28 13:47
*/
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Slf4j
public
class
LocationFenceServiceImpl
implements
LocationFenceService
{
@Resource
private
LocationFenceRepository
locationFenceRepository
;
@Override
public
Result
<
String
>
addLocationFence
(
LocationFenceAddParam
param
)
{
Boolean
exists
=
locationFenceRepository
.
existsByName
(
param
.
getName
());
if
(
exists
)
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"围栏名称已被占用"
);
}
LocationFence
locationFence
=
param
.
transform
();
locationFenceRepository
.
saveAndFlush
(
locationFence
);
return
Result
.
ok
();
}
@Override
public
Result
<
String
>
modifyLocationFence
(
LocationFenceModifyParam
param
)
{
List
<
LocationFence
>
allByName
=
locationFenceRepository
.
findAllByName
(
param
.
getName
());
if
(
allByName
.
size
()
>
1
)
{
log
.
warn
(
"LocationFenceServiceImpl.modifyLocationFence时查询出两条围栏名称相同的数据,param:[{}]"
,
param
);
}
LocationFence
locationFence
=
null
;
for
(
LocationFence
item
:
allByName
)
{
if
(
item
.
getId
().
equals
(
param
.
getId
()))
{
locationFence
=
item
;
}
else
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"围栏名称已被占用"
);
}
}
if
(
locationFence
==
null
)
{
Optional
<
LocationFence
>
optional
=
locationFenceRepository
.
findById
(
param
.
getId
());
if
(
optional
.
isEmpty
())
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"要修改的围栏信息不存在"
);
}
locationFence
=
optional
.
get
();
}
JpaUtil
.
copyNotNullProperties
(
param
,
locationFence
);
return
Result
.
ok
();
}
@Override
public
Result
<
String
>
removeLocationFence
(
IdParam
param
)
{
Optional
<
LocationFence
>
optional
=
locationFenceRepository
.
findById
(
param
.
getId
());
if
(
optional
.
isEmpty
())
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"要删除的围栏信息不存在"
);
}
optional
.
get
().
setDeleted
(
true
);
return
Result
.
ok
();
}
@Override
public
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
LocationFenceConditionParam
conditionParam
,
PageParam
pageParam
)
{
Specification
<
LocationFence
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
ArrayList
<
Predicate
>
list
=
new
ArrayList
<>();
if
(
conditionParam
.
getMapId
()
!=
null
)
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"mapId"
),
conditionParam
.
getMapId
()));
}
if
(
conditionParam
.
getFenceType
()
!=
null
)
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"fenceType"
),
conditionParam
.
getFenceType
()));
}
Predicate
[]
array
=
list
.
toArray
(
new
Predicate
[
0
]);
return
criteriaBuilder
.
and
(
array
);
};
Pageable
pageable
=
PageParam
.
toPageable
(
pageParam
);
Page
<
LocationFence
>
fencePage
=
locationFenceRepository
.
findAll
(
specification
,
pageable
);
List
<
LocationFenceVo
>
voList
=
fencePage
.
get
().
map
(
LocationFenceVo:
:
transform
).
collect
(
Collectors
.
toList
());
PageVo
<
LocationFenceVo
>
pageVo
=
PageVo
.
build
(
voList
,
fencePage
.
getTotalElements
());
return
Result
.
ok
(
pageVo
);
}
}
app/src/main/java/com/yiring/app/vo/alarm/AlarmTypeVo.java
浏览文件 @
dfb5fc22
...
...
@@ -48,8 +48,8 @@ public class AlarmTypeVo implements Serializable {
.
builder
()
.
id
(
alarmType
.
getId
())
.
name
(
alarmType
.
getName
())
.
fenceType
(
FenceTypeEnum
.
getBy
Key
(
alarmType
.
getFenceType
()))
.
relevanceParam
(
RelevanceParamEnum
.
getBy
Key
(
alarmType
.
getRelevanceParam
()))
.
fenceType
(
FenceTypeEnum
.
getBy
Code
(
alarmType
.
getFenceType
()))
.
relevanceParam
(
RelevanceParamEnum
.
getBy
Code
(
alarmType
.
getRelevanceParam
()))
.
comment
(
alarmType
.
getComment
())
.
build
();
}
...
...
app/src/main/java/com/yiring/app/vo/location/fence/LocationFenceVo.java
0 → 100644
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
vo
.
location
.
fence
;
import
com.yiring.app.constant.alarm.FenceTypeEnum
;
import
com.yiring.app.domain.location.LocationFence
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author tml
* @version 1.0
* @date 2022/4/28 11:07
*/
@ApiModel
(
"围栏信息VO"
)
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
LocationFenceVo
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
3616144084051520412L
;
@ApiModelProperty
(
value
=
"围栏名称"
)
private
String
name
;
@ApiModelProperty
(
value
=
"地图名称"
)
private
String
mapName
;
@ApiModelProperty
(
value
=
"摄像头名称"
)
private
String
videoName
;
@ApiModelProperty
(
value
=
"围栏类别"
)
private
String
fenceType
;
@ApiModelProperty
(
value
=
"滞留时间(秒)"
)
private
Integer
residenceTime
;
@ApiModelProperty
(
value
=
"消抖时间(秒)"
)
private
Integer
threshold
;
@ApiModelProperty
(
value
=
"是否启用"
)
private
Boolean
enable
;
public
static
LocationFenceVo
transform
(
LocationFence
locationFence
)
{
return
LocationFenceVo
.
builder
()
.
name
(
locationFence
.
getName
())
.
mapName
(
locationFence
.
getMapName
())
.
videoName
(
locationFence
.
getVideo
().
getVideoName
())
.
fenceType
(
FenceTypeEnum
.
getByCode
(
locationFence
.
getFenceType
()))
.
residenceTime
(
locationFence
.
getResidenceTime
())
.
threshold
(
locationFence
.
getThreshold
())
.
enable
(
locationFence
.
getEnable
())
.
build
();
}
public
static
List
<
LocationFenceVo
>
transforms
(
List
<
LocationFence
>
locationFences
)
{
return
locationFences
.
stream
().
map
(
LocationFenceVo:
:
transform
).
collect
(
Collectors
.
toList
());
}
}
app/src/main/java/com/yiring/app/web/location/fence/LocationFenceController.java
0 → 100644
浏览文件 @
dfb5fc22
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
web
.
location
.
fence
;
import
com.yiring.app.param.location.fence.LocationFenceAddParam
;
import
com.yiring.app.param.location.fence.LocationFenceConditionParam
;
import
com.yiring.app.param.location.fence.LocationFenceModifyParam
;
import
com.yiring.app.service.location.fence.LocationFenceService
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.vo.PageVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
/**
* @author tml
* @version 1.0
* @date 2022/4/28 11:50
*/
@RestController
@Api
(
tags
=
"LocationFenceController(围栏信息)"
)
@Validated
@Slf4j
@RequestMapping
(
"location/fence"
)
public
class
LocationFenceController
{
@Resource
private
LocationFenceService
locationFenceService
;
@ApiOperation
(
"添加围栏信息"
)
@PostMapping
(
"/addLocationFence"
)
public
Result
<
String
>
addLocationFence
(
@Valid
@RequestBody
LocationFenceAddParam
param
)
{
return
locationFenceService
.
addLocationFence
(
param
);
}
@ApiOperation
(
"修改围栏信息"
)
@PostMapping
(
"/modifyLocationFence"
)
public
Result
<
String
>
modifyLocationFence
(
@Valid
@RequestBody
LocationFenceModifyParam
param
)
{
return
locationFenceService
.
modifyLocationFence
(
param
);
}
@ApiOperation
(
"删除围栏信息"
)
@PostMapping
(
"/removeLocationFence"
)
public
Result
<
String
>
removeLocationFence
(
@Valid
IdParam
param
)
{
return
locationFenceService
.
removeLocationFence
(
param
);
}
@ApiOperation
(
"根据条件分页查询围栏信息"
)
@PostMapping
(
"/LocationFenceVo"
)
public
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
@Valid
LocationFenceConditionParam
conditionParam
,
@Valid
PageParam
pageParam
)
{
return
locationFenceService
.
findList
(
conditionParam
,
pageParam
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论