Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
72d1f1ff
提交
72d1f1ff
authored
5月 26, 2022
作者:
涂茂林
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:风险预警管理导入
上级
427753dc
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
540 行增加
和
30 行删除
+540
-30
TemplateList.java
.../main/java/com/yiring/app/constant/risk/TemplateList.java
+4
-1
AllowEntranceStrategy.java
...iring/app/design/strategy/rule/AllowEntranceStrategy.java
+36
-3
NotAllowLeaveStrategy.java
...iring/app/design/strategy/rule/NotAllowLeaveStrategy.java
+35
-4
RiskWarn.java
app/src/main/java/com/yiring/app/domain/risk/RiskWarn.java
+3
-2
Threshold.java
app/src/main/java/com/yiring/app/domain/risk/Threshold.java
+2
-2
RiskWarnExcel.java
...rc/main/java/com/yiring/app/excel/risk/RiskWarnExcel.java
+25
-6
LocationFenceService.java
...ring/app/service/location/fence/LocationFenceService.java
+8
-0
LocationFenceServiceImpl.java
...service/location/fence/impl/LocationFenceServiceImpl.java
+24
-6
LocationFenceRuleServiceImpl.java
...vice/location/rule/impl/LocationFenceRuleServiceImpl.java
+6
-0
RiskWarnServiceImpl.java
...com/yiring/app/service/risk/impl/RiskWarnServiceImpl.java
+313
-5
DistrictVo.java
app/src/main/java/com/yiring/app/vo/district/DistrictVo.java
+5
-0
LocationFenceGeoVo.java
.../com/yiring/app/vo/location/fence/LocationFenceGeoVo.java
+66
-0
RiskWarnDetailVo.java
...rc/main/java/com/yiring/app/vo/risk/RiskWarnDetailVo.java
+5
-0
LocationFenceController.java
...iring/app/web/location/fence/LocationFenceController.java
+8
-1
没有找到文件。
app/src/main/java/com/yiring/app/constant/risk/TemplateList.java
浏览文件 @
72d1f1ff
...
@@ -19,6 +19,7 @@ public class TemplateList {
...
@@ -19,6 +19,7 @@ public class TemplateList {
RiskWarnExcel
RiskWarnExcel
.
builder
()
.
builder
()
.
workAreaName
(
"BTC产品库房"
)
.
workAreaName
(
"BTC产品库房"
)
.
point
(
"112.863173604639,30.4786075211555,0"
)
.
install
(
"产品库房北侧中间立柱东1"
)
.
install
(
"产品库房北侧中间立柱东1"
)
.
monitoring
(
"有毒气体报警器"
)
.
monitoring
(
"有毒气体报警器"
)
.
locationNum
(
"AT-4736"
)
.
locationNum
(
"AT-4736"
)
...
@@ -36,6 +37,7 @@ public class TemplateList {
...
@@ -36,6 +37,7 @@ public class TemplateList {
RiskWarnExcel
RiskWarnExcel
.
builder
()
.
builder
()
.
workAreaName
(
"计量槽"
)
.
workAreaName
(
"计量槽"
)
.
point
(
"112.863173604639,30.4786075211555,0"
)
.
install
(
"1号槽液位"
)
.
install
(
"1号槽液位"
)
.
monitoring
(
"液位"
)
.
monitoring
(
"液位"
)
.
locationNum
(
"PI-2107A"
)
.
locationNum
(
"PI-2107A"
)
...
@@ -53,6 +55,7 @@ public class TemplateList {
...
@@ -53,6 +55,7 @@ public class TemplateList {
RiskWarnExcel
RiskWarnExcel
.
builder
()
.
builder
()
.
workAreaName
(
"合成盐酸"
)
.
workAreaName
(
"合成盐酸"
)
.
point
(
"112.863173604639,30.4786075211555,0"
)
.
install
(
"1号炉一楼"
)
.
install
(
"1号炉一楼"
)
.
monitoring
(
"火焰检测"
)
.
monitoring
(
"火焰检测"
)
.
locationNum
(
"BSA-1401A"
)
.
locationNum
(
"BSA-1401A"
)
...
@@ -63,7 +66,7 @@ public class TemplateList {
...
@@ -63,7 +66,7 @@ public class TemplateList {
.
high
(
""
)
.
high
(
""
)
.
highHigh
(
""
)
.
highHigh
(
""
)
.
flame
(
"1"
)
.
flame
(
"1"
)
.
remark
(
"注意:火焰检测在报警值(熄灭)这里添加预警值"
)
.
remark
(
"注意:火焰检测在报警值(熄灭)这里添加预警值
,等于这个数值时显示熄灭
"
)
.
build
()
.
build
()
);
);
}
}
...
...
app/src/main/java/com/yiring/app/design/strategy/rule/AllowEntranceStrategy.java
浏览文件 @
72d1f1ff
...
@@ -12,13 +12,16 @@ import com.yiring.app.param.location.fence.LocationFenceJobParam;
...
@@ -12,13 +12,16 @@ import com.yiring.app.param.location.fence.LocationFenceJobParam;
import
com.yiring.app.param.location.rule.*
;
import
com.yiring.app.param.location.rule.*
;
import
com.yiring.app.util.TimeUtil
;
import
com.yiring.app.util.TimeUtil
;
import
com.yiring.app.vo.location.fence.LocationFenceJobVo
;
import
com.yiring.app.vo.location.fence.LocationFenceJobVo
;
import
com.yiring.auth.domain.user.User
;
import
com.yiring.auth.domain.user.UserRepository
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.core.Status
;
import
com.yiring.common.core.Status
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -31,6 +34,9 @@ import org.springframework.util.CollectionUtils;
...
@@ -31,6 +34,9 @@ import org.springframework.util.CollectionUtils;
@Component
@Component
public
class
AllowEntranceStrategy
implements
IParamInitStrategy
<
LocationFenceRuleAddParam
>,
IScanAlarmStrategy
{
public
class
AllowEntranceStrategy
implements
IParamInitStrategy
<
LocationFenceRuleAddParam
>,
IScanAlarmStrategy
{
@Resource
private
UserRepository
userRepository
;
public
AllowEntranceStrategy
()
{
public
AllowEntranceStrategy
()
{
Integer
relevanceParam
=
RelevanceParamEnum
.
ALLOW_ENTRANCE
.
getCode
();
Integer
relevanceParam
=
RelevanceParamEnum
.
ALLOW_ENTRANCE
.
getCode
();
LocationFenceRuleContext
.
register
(
relevanceParam
,
this
);
LocationFenceRuleContext
.
register
(
relevanceParam
,
this
);
...
@@ -62,6 +68,33 @@ public class AllowEntranceStrategy implements IParamInitStrategy<LocationFenceRu
...
@@ -62,6 +68,33 @@ public class AllowEntranceStrategy implements IParamInitStrategy<LocationFenceRu
}
}
}
}
}
}
//检查配置的员工是否存在
Specification
<
User
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
CriteriaBuilder
.
In
<
Object
>
in
=
criteriaBuilder
.
in
(
root
.
get
(
User
.
Fields
.
uuid
));
HashSet
<
String
>
ids
=
new
HashSet
<>();
for
(
TimeAndUserParam
item
:
timeAndUser
)
{
for
(
RelevanceUserParam
userParam
:
item
.
getUser
())
{
ids
.
add
(
userParam
.
getUuid
());
}
}
for
(
String
uuid
:
ids
)
{
in
.
value
(
uuid
);
}
return
criteriaBuilder
.
and
(
in
);
};
Map
<
String
,
List
<
User
>>
map
=
userRepository
.
findAll
(
specification
)
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
User:
:
getUuid
));
for
(
TimeAndUserParam
item
:
timeAndUser
)
{
for
(
RelevanceUserParam
userParam
:
item
.
getUser
())
{
List
<
User
>
list
=
map
.
get
(
userParam
.
getUuid
());
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"工号为:"
+
userParam
.
getUuid
()
+
"员工不存在"
);
}
userParam
.
setRealName
(
list
.
get
(
0
).
getRealName
());
}
}
ruleParam
.
setDuration
(
null
);
ruleParam
.
setDuration
(
null
);
ruleParam
.
setDistance
(
null
);
ruleParam
.
setDistance
(
null
);
ruleParam
.
setTimeAndNumber
(
new
ArrayList
<>());
ruleParam
.
setTimeAndNumber
(
new
ArrayList
<>());
...
...
app/src/main/java/com/yiring/app/design/strategy/rule/NotAllowLeaveStrategy.java
浏览文件 @
72d1f1ff
...
@@ -10,15 +10,16 @@ import com.yiring.app.param.location.fence.LocationFenceJobParam;
...
@@ -10,15 +10,16 @@ import com.yiring.app.param.location.fence.LocationFenceJobParam;
import
com.yiring.app.param.location.rule.*
;
import
com.yiring.app.param.location.rule.*
;
import
com.yiring.app.util.TimeUtil
;
import
com.yiring.app.util.TimeUtil
;
import
com.yiring.app.vo.location.fence.LocationFenceJobVo
;
import
com.yiring.app.vo.location.fence.LocationFenceJobVo
;
import
com.yiring.auth.domain.user.User
;
import
com.yiring.auth.domain.user.UserRepository
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.core.Status
;
import
com.yiring.common.core.Status
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -34,6 +35,9 @@ public class NotAllowLeaveStrategy implements IParamInitStrategy<LocationFenceRu
...
@@ -34,6 +35,9 @@ public class NotAllowLeaveStrategy implements IParamInitStrategy<LocationFenceRu
@Resource
@Resource
private
LocationTurnoverRepository
locationTurnoverRepository
;
private
LocationTurnoverRepository
locationTurnoverRepository
;
@Resource
private
UserRepository
userRepository
;
public
NotAllowLeaveStrategy
()
{
public
NotAllowLeaveStrategy
()
{
Integer
relevanceParam
=
RelevanceParamEnum
.
NOT_ALLOW_LEAVE
.
getCode
();
Integer
relevanceParam
=
RelevanceParamEnum
.
NOT_ALLOW_LEAVE
.
getCode
();
LocationFenceRuleContext
.
register
(
relevanceParam
,
this
);
LocationFenceRuleContext
.
register
(
relevanceParam
,
this
);
...
@@ -65,6 +69,33 @@ public class NotAllowLeaveStrategy implements IParamInitStrategy<LocationFenceRu
...
@@ -65,6 +69,33 @@ public class NotAllowLeaveStrategy implements IParamInitStrategy<LocationFenceRu
}
}
}
}
}
}
//检查配置的员工是否存在
Specification
<
User
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
CriteriaBuilder
.
In
<
Object
>
in
=
criteriaBuilder
.
in
(
root
.
get
(
User
.
Fields
.
uuid
));
HashSet
<
String
>
ids
=
new
HashSet
<>();
for
(
TimeAndUserParam
item
:
timeAndUser
)
{
for
(
RelevanceUserParam
userParam
:
item
.
getUser
())
{
ids
.
add
(
userParam
.
getUuid
());
}
}
for
(
String
uuid
:
ids
)
{
in
.
value
(
uuid
);
}
return
criteriaBuilder
.
and
(
in
);
};
Map
<
String
,
List
<
User
>>
map
=
userRepository
.
findAll
(
specification
)
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
User:
:
getUuid
));
for
(
TimeAndUserParam
item
:
timeAndUser
)
{
for
(
RelevanceUserParam
userParam
:
item
.
getUser
())
{
List
<
User
>
list
=
map
.
get
(
userParam
.
getUuid
());
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"工号为:"
+
userParam
.
getUuid
()
+
"员工不存在"
);
}
userParam
.
setRealName
(
list
.
get
(
0
).
getRealName
());
}
}
ruleParam
.
setDuration
(
null
);
ruleParam
.
setDuration
(
null
);
ruleParam
.
setDistance
(
null
);
ruleParam
.
setDistance
(
null
);
ruleParam
.
setTimeAndNumber
(
new
ArrayList
<>());
ruleParam
.
setTimeAndNumber
(
new
ArrayList
<>());
...
...
app/src/main/java/com/yiring/app/domain/risk/RiskWarn.java
浏览文件 @
72d1f1ff
...
@@ -44,7 +44,7 @@ public class RiskWarn extends BasicEntity implements Serializable {
...
@@ -44,7 +44,7 @@ public class RiskWarn extends BasicEntity implements Serializable {
private
String
install
;
private
String
install
;
@Comment
(
"经纬度"
)
@Comment
(
"经纬度"
)
@Column
(
columnDefinition
=
"geometry(Point,4326)"
)
@Column
(
columnDefinition
=
"geometry(Point
Z
,4326)"
)
private
Point
point
;
private
Point
point
;
@Comment
(
"监控参数"
)
@Comment
(
"监控参数"
)
...
@@ -68,6 +68,7 @@ public class RiskWarn extends BasicEntity implements Serializable {
...
@@ -68,6 +68,7 @@ public class RiskWarn extends BasicEntity implements Serializable {
@ToString
.
Exclude
@ToString
.
Exclude
@Comment
(
"阈值区间信息"
)
@Comment
(
"阈值区间信息"
)
@Builder
.
Default
@Builder
.
Default
@OneToMany
(
mappedBy
=
"riskWarn"
)
@OneToMany
(
cascade
=
{
CascadeType
.
PERSIST
,
CascadeType
.
REFRESH
})
@JoinColumn
(
name
=
"risk_warn_id"
)
private
List
<
Threshold
>
thresholds
=
new
ArrayList
<>();
private
List
<
Threshold
>
thresholds
=
new
ArrayList
<>();
}
}
app/src/main/java/com/yiring/app/domain/risk/Threshold.java
浏览文件 @
72d1f1ff
...
@@ -30,10 +30,10 @@ public class Threshold extends BasicEntity implements Serializable {
...
@@ -30,10 +30,10 @@ public class Threshold extends BasicEntity implements Serializable {
@Serial
@Serial
private
static
final
long
serialVersionUID
=
3115736944401082777L
;
private
static
final
long
serialVersionUID
=
3115736944401082777L
;
@ManyToOne
/*
@ManyToOne
@JoinColumn(name = "risk_warn_id")
@JoinColumn(name = "risk_warn_id")
@Comment("对应的风险预警信息")
@Comment("对应的风险预警信息")
private
RiskWarn
riskWarn
;
private RiskWarn riskWarn;
*/
@Comment
(
"阈值区间起始值"
)
@Comment
(
"阈值区间起始值"
)
private
String
min
;
private
String
min
;
...
...
app/src/main/java/com/yiring/app/excel/risk/RiskWarnExcel.java
浏览文件 @
72d1f1ff
...
@@ -15,6 +15,7 @@ import lombok.AllArgsConstructor;
...
@@ -15,6 +15,7 @@ import lombok.AllArgsConstructor;
import
lombok.Builder
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
org.springframework.util.CollectionUtils
;
/**
/**
* @author tml
* @author tml
...
@@ -37,6 +38,9 @@ public class RiskWarnExcel implements Serializable {
...
@@ -37,6 +38,9 @@ public class RiskWarnExcel implements Serializable {
@ExcelColumn
(
title
=
"安装位置"
,
width
=
15
)
@ExcelColumn
(
title
=
"安装位置"
,
width
=
15
)
private
String
install
;
private
String
install
;
@ExcelColumn
(
title
=
"经纬度"
,
width
=
30
)
private
String
point
;
@ExcelColumn
(
title
=
"监控参数"
,
width
=
15
)
@ExcelColumn
(
title
=
"监控参数"
,
width
=
15
)
private
String
monitoring
;
private
String
monitoring
;
...
@@ -68,19 +72,34 @@ public class RiskWarnExcel implements Serializable {
...
@@ -68,19 +72,34 @@ public class RiskWarnExcel implements Serializable {
private
String
remark
;
private
String
remark
;
public
static
RiskWarnExcel
transform
(
RiskWarn
riskWarn
)
{
public
static
RiskWarnExcel
transform
(
RiskWarn
riskWarn
)
{
String
range
=
riskWarn
.
getMin
()
+
" - "
+
riskWarn
.
getMax
();
String
range
=
""
;
if
(
riskWarn
.
getMin
()
!=
null
&&
riskWarn
.
getMax
()
!=
null
)
{
range
=
riskWarn
.
getMin
()
+
"-"
+
riskWarn
.
getMax
();
}
String
point
=
riskWarn
.
getPoint
().
getCoordinate
().
getX
()
+
","
+
riskWarn
.
getPoint
().
getCoordinate
().
getY
()
+
","
+
riskWarn
.
getPoint
().
getCoordinate
().
getZ
();
Map
<
Integer
,
List
<
Threshold
>>
map
=
riskWarn
Map
<
Integer
,
List
<
Threshold
>>
map
=
riskWarn
.
getThresholds
()
.
getThresholds
()
.
stream
()
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
Threshold:
:
getStatus
));
.
collect
(
Collectors
.
groupingBy
(
Threshold:
:
getStatus
));
String
lowLow
=
map
.
get
(
ThresholdStatusEnum
.
LOW_LOW
.
getCode
()).
get
(
0
).
getMin
();
List
<
Threshold
>
lowLowList
=
map
.
get
(
ThresholdStatusEnum
.
LOW_LOW
.
getCode
());
String
low
=
map
.
get
(
ThresholdStatusEnum
.
LOW
.
getCode
()).
get
(
0
).
getMin
();
List
<
Threshold
>
lowList
=
map
.
get
(
ThresholdStatusEnum
.
LOW
.
getCode
());
String
high
=
map
.
get
(
ThresholdStatusEnum
.
HIGH
.
getCode
()).
get
(
0
).
getMin
();
List
<
Threshold
>
highList
=
map
.
get
(
ThresholdStatusEnum
.
HIGH
.
getCode
());
String
highHigh
=
map
.
get
(
ThresholdStatusEnum
.
HIGH_HIGH
.
getCode
()).
get
(
0
).
getMin
();
List
<
Threshold
>
highHighList
=
map
.
get
(
ThresholdStatusEnum
.
HIGH_HIGH
.
getCode
());
String
flame
=
map
.
get
(
ThresholdStatusEnum
.
FLAME_EXTINGUISH
.
getCode
()).
get
(
0
).
getMin
();
List
<
Threshold
>
flameList
=
map
.
get
(
ThresholdStatusEnum
.
FLAME_EXTINGUISH
.
getCode
());
String
lowLow
=
CollectionUtils
.
isEmpty
(
lowLowList
)
?
""
:
lowLowList
.
get
(
0
).
getMin
();
String
low
=
CollectionUtils
.
isEmpty
(
lowList
)
?
""
:
lowList
.
get
(
0
).
getMin
();
String
high
=
CollectionUtils
.
isEmpty
(
highList
)
?
""
:
highList
.
get
(
0
).
getMin
();
String
highHigh
=
CollectionUtils
.
isEmpty
(
highHighList
)
?
""
:
highHighList
.
get
(
0
).
getMin
();
String
flame
=
CollectionUtils
.
isEmpty
(
flameList
)
?
""
:
flameList
.
get
(
0
).
getMin
();
return
RiskWarnExcel
return
RiskWarnExcel
.
builder
()
.
builder
()
.
workAreaName
(
riskWarn
.
getWorkArea
().
getWorkAreaName
())
.
workAreaName
(
riskWarn
.
getWorkArea
().
getWorkAreaName
())
.
point
(
point
)
.
install
(
riskWarn
.
getInstall
())
.
install
(
riskWarn
.
getInstall
())
.
monitoring
(
riskWarn
.
getMonitoring
())
.
monitoring
(
riskWarn
.
getMonitoring
())
.
locationNum
(
riskWarn
.
getLocationNum
())
.
locationNum
(
riskWarn
.
getLocationNum
())
...
...
app/src/main/java/com/yiring/app/service/location/fence/LocationFenceService.java
浏览文件 @
72d1f1ff
...
@@ -7,6 +7,7 @@ import com.yiring.app.param.location.fence.LocationFenceConditionParam;
...
@@ -7,6 +7,7 @@ import com.yiring.app.param.location.fence.LocationFenceConditionParam;
import
com.yiring.app.param.location.fence.LocationFenceModifyParam
;
import
com.yiring.app.param.location.fence.LocationFenceModifyParam
;
import
com.yiring.app.vo.CodeNameVo
;
import
com.yiring.app.vo.CodeNameVo
;
import
com.yiring.app.vo.location.fence.FenceRealtimeVo
;
import
com.yiring.app.vo.location.fence.FenceRealtimeVo
;
import
com.yiring.app.vo.location.fence.LocationFenceGeoVo
;
import
com.yiring.app.vo.location.fence.LocationFenceSearchVo
;
import
com.yiring.app.vo.location.fence.LocationFenceSearchVo
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.auth.param.IdsParam
;
import
com.yiring.auth.param.IdsParam
;
...
@@ -52,6 +53,13 @@ public interface LocationFenceService {
...
@@ -52,6 +53,13 @@ public interface LocationFenceService {
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
LocationFenceConditionParam
conditionParam
,
PageParam
pageParam
);
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
LocationFenceConditionParam
conditionParam
,
PageParam
pageParam
);
/**
/**
* 查询围栏的位置信息列表
* @param conditionParam 条件
* @return 是否成功
*/
Result
<
PageVo
<
LocationFenceGeoVo
>>
findGeoList
(
LocationFenceConditionParam
conditionParam
);
/**
* 根据id查询围栏信息
* 根据id查询围栏信息
* @param param id
* @param param id
* @return 详细信息
* @return 详细信息
...
...
app/src/main/java/com/yiring/app/service/location/fence/impl/LocationFenceServiceImpl.java
浏览文件 @
72d1f1ff
...
@@ -13,6 +13,7 @@ import com.yiring.app.service.location.fence.LocationFenceService;
...
@@ -13,6 +13,7 @@ import com.yiring.app.service.location.fence.LocationFenceService;
import
com.yiring.app.util.JpaUtil
;
import
com.yiring.app.util.JpaUtil
;
import
com.yiring.app.vo.CodeNameVo
;
import
com.yiring.app.vo.CodeNameVo
;
import
com.yiring.app.vo.location.fence.FenceRealtimeVo
;
import
com.yiring.app.vo.location.fence.FenceRealtimeVo
;
import
com.yiring.app.vo.location.fence.LocationFenceGeoVo
;
import
com.yiring.app.vo.location.fence.LocationFenceSearchVo
;
import
com.yiring.app.vo.location.fence.LocationFenceSearchVo
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.app.vo.map.MapVo
;
import
com.yiring.app.vo.map.MapVo
;
...
@@ -36,6 +37,7 @@ import org.springframework.data.domain.Pageable;
...
@@ -36,6 +37,7 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
/**
/**
* 围栏信息service
* 围栏信息service
...
@@ -96,13 +98,34 @@ public class LocationFenceServiceImpl implements LocationFenceService {
...
@@ -96,13 +98,34 @@ public class LocationFenceServiceImpl implements LocationFenceService {
if
(
optional
.
isEmpty
())
{
if
(
optional
.
isEmpty
())
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"要删除的围栏信息不存在"
);
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"要删除的围栏信息不存在"
);
}
}
if
(!
CollectionUtils
.
isEmpty
(
optional
.
get
().
getRules
()))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"要删除的围栏已经配置了规则,不能删除"
);
}
optional
.
get
().
setDeleted
(
true
);
optional
.
get
().
setDeleted
(
true
);
return
Result
.
ok
();
return
Result
.
ok
();
}
}
@Override
@Override
public
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
LocationFenceConditionParam
conditionParam
,
PageParam
pageParam
)
{
public
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
LocationFenceConditionParam
conditionParam
,
PageParam
pageParam
)
{
Specification
<
LocationFence
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
Specification
<
LocationFence
>
specification
=
getSpecification
(
conditionParam
);
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
);
}
@Override
public
Result
<
PageVo
<
LocationFenceGeoVo
>>
findGeoList
(
LocationFenceConditionParam
conditionParam
)
{
Specification
<
LocationFence
>
specification
=
getSpecification
(
conditionParam
);
List
<
LocationFence
>
list
=
locationFenceRepository
.
findAll
(
specification
);
List
<
LocationFenceGeoVo
>
voList
=
list
.
stream
().
map
(
LocationFenceGeoVo:
:
transform
).
collect
(
Collectors
.
toList
());
PageVo
<
LocationFenceGeoVo
>
pageVo
=
PageVo
.
build
(
voList
,
voList
.
size
());
return
Result
.
ok
(
pageVo
);
}
private
Specification
<
LocationFence
>
getSpecification
(
LocationFenceConditionParam
conditionParam
)
{
return
(
root
,
query
,
criteriaBuilder
)
->
{
ArrayList
<
Predicate
>
list
=
new
ArrayList
<>();
ArrayList
<
Predicate
>
list
=
new
ArrayList
<>();
if
(
conditionParam
.
getMapId
()
!=
null
)
{
if
(
conditionParam
.
getMapId
()
!=
null
)
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"mapId"
),
conditionParam
.
getMapId
()));
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"mapId"
),
conditionParam
.
getMapId
()));
...
@@ -113,11 +136,6 @@ public class LocationFenceServiceImpl implements LocationFenceService {
...
@@ -113,11 +136,6 @@ public class LocationFenceServiceImpl implements LocationFenceService {
Predicate
[]
array
=
list
.
toArray
(
new
Predicate
[
0
]);
Predicate
[]
array
=
list
.
toArray
(
new
Predicate
[
0
]);
return
criteriaBuilder
.
and
(
array
);
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
);
}
}
@Override
@Override
...
...
app/src/main/java/com/yiring/app/service/location/rule/impl/LocationFenceRuleServiceImpl.java
浏览文件 @
72d1f1ff
...
@@ -13,6 +13,7 @@ import com.yiring.common.core.Result;
...
@@ -13,6 +13,7 @@ import com.yiring.common.core.Result;
import
com.yiring.common.core.Status
;
import
com.yiring.common.core.Status
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.vo.PageVo
;
import
com.yiring.common.vo.PageVo
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -79,6 +80,11 @@ public class LocationFenceRuleServiceImpl implements LocationFenceRuleService {
...
@@ -79,6 +80,11 @@ public class LocationFenceRuleServiceImpl implements LocationFenceRuleService {
List
<
LocationFenceRuleVo
>
voList
=
ruleList
List
<
LocationFenceRuleVo
>
voList
=
ruleList
.
stream
()
.
stream
()
.
map
(
LocationFenceRuleVo:
:
transform
)
.
map
(
LocationFenceRuleVo:
:
transform
)
.
sorted
(
Comparator
.
comparing
(
LocationFenceRuleVo:
:
getRelevanceParamType
)
.
thenComparing
(
LocationFenceRuleVo:
:
getId
)
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
PageVo
<
LocationFenceRuleVo
>
pageVo
=
PageVo
.
build
(
voList
,
voList
.
size
());
PageVo
<
LocationFenceRuleVo
>
pageVo
=
PageVo
.
build
(
voList
,
voList
.
size
());
return
Result
.
ok
(
pageVo
);
return
Result
.
ok
(
pageVo
);
...
...
app/src/main/java/com/yiring/app/service/risk/impl/RiskWarnServiceImpl.java
浏览文件 @
72d1f1ff
...
@@ -3,15 +3,22 @@ package com.yiring.app.service.risk.impl;
...
@@ -3,15 +3,22 @@ package com.yiring.app.service.risk.impl;
import
com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder
;
import
com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder
;
import
com.github.liaochong.myexcel.core.SaxExcelReader
;
import
com.github.liaochong.myexcel.core.SaxExcelReader
;
import
com.github.liaochong.myexcel.utils.StringUtil
;
import
com.yiring.app.constant.rehearsal.RiskLevelEnum
;
import
com.yiring.app.constant.risk.TemplateList
;
import
com.yiring.app.constant.risk.TemplateList
;
import
com.yiring.app.constant.risk.ThresholdStatusEnum
;
import
com.yiring.app.domain.risk.RiskWarn
;
import
com.yiring.app.domain.risk.RiskWarn
;
import
com.yiring.app.domain.risk.RiskWarnRepository
;
import
com.yiring.app.domain.risk.RiskWarnRepository
;
import
com.yiring.app.domain.risk.Threshold
;
import
com.yiring.app.domain.workArea.WorkArea
;
import
com.yiring.app.domain.workArea.WorkAreaRepository
;
import
com.yiring.app.excel.risk.RiskWarnExcel
;
import
com.yiring.app.excel.risk.RiskWarnExcel
;
import
com.yiring.app.param.risk.RiskWarnAddParam
;
import
com.yiring.app.param.risk.RiskWarnAddParam
;
import
com.yiring.app.param.risk.RiskWarnConditionParam
;
import
com.yiring.app.param.risk.RiskWarnConditionParam
;
import
com.yiring.app.param.risk.RiskWarnModifyParam
;
import
com.yiring.app.param.risk.RiskWarnModifyParam
;
import
com.yiring.app.param.risk.ThresholdParam
;
import
com.yiring.app.param.risk.ThresholdParam
;
import
com.yiring.app.service.risk.RiskWarnService
;
import
com.yiring.app.service.risk.RiskWarnService
;
import
com.yiring.app.util.GeoUtils
;
import
com.yiring.app.util.JpaUtil
;
import
com.yiring.app.util.JpaUtil
;
import
com.yiring.app.vo.risk.RiskWarnDetailVo
;
import
com.yiring.app.vo.risk.RiskWarnDetailVo
;
import
com.yiring.app.vo.risk.RiskWarnVo
;
import
com.yiring.app.vo.risk.RiskWarnVo
;
...
@@ -24,20 +31,20 @@ import com.yiring.common.vo.PageVo;
...
@@ -24,20 +31,20 @@ import com.yiring.common.vo.PageVo;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.math.BigDecimal
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Predicate
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.locationtech.jts.geom.Point
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.domain.Specification
;
...
@@ -58,6 +65,9 @@ public class RiskWarnServiceImpl implements RiskWarnService {
...
@@ -58,6 +65,9 @@ public class RiskWarnServiceImpl implements RiskWarnService {
@Resource
@Resource
private
RiskWarnRepository
riskWarnRepository
;
private
RiskWarnRepository
riskWarnRepository
;
@Resource
private
WorkAreaRepository
workAreaRepository
;
@Override
@Override
public
Result
<
String
>
addOne
(
RiskWarnAddParam
param
)
{
public
Result
<
String
>
addOne
(
RiskWarnAddParam
param
)
{
Result
<
String
>
result
=
checkThreshold
(
param
.
getThresholds
());
Result
<
String
>
result
=
checkThreshold
(
param
.
getThresholds
());
...
@@ -177,7 +187,305 @@ public class RiskWarnServiceImpl implements RiskWarnService {
...
@@ -177,7 +187,305 @@ public class RiskWarnServiceImpl implements RiskWarnService {
log
.
info
(
e
.
getMessage
());
log
.
info
(
e
.
getMessage
());
throw
new
RuntimeException
(
"文件导入异常"
);
throw
new
RuntimeException
(
"文件导入异常"
);
}
}
return
null
;
//校验并转换数据
Result
<
ArrayList
<
RiskWarn
>>
result
=
initImport
(
riskWarnExcels
);
if
(
Status
.
OK
.
value
()
!=
result
.
getStatus
())
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
result
.
getDetails
());
}
List
<
RiskWarn
>
riskWarns
=
riskWarnRepository
.
saveAllAndFlush
(
result
.
getBody
());
return
Result
.
ok
(
"已成功添加"
+
riskWarns
.
size
()
+
"添加"
);
}
/**
* 校验并转换导入的预警信息
* @param excels 导入的预警信息
* @return 是否成功转换
*/
private
Result
<
ArrayList
<
RiskWarn
>>
initImport
(
List
<
RiskWarnExcel
>
excels
)
{
//检查工区是否存在
Set
<
String
>
set
=
excels
.
stream
().
map
(
RiskWarnExcel:
:
getWorkAreaName
).
collect
(
Collectors
.
toSet
());
Specification
<
WorkArea
>
specification
=
(
root
,
query
,
criteriaBuilder
)
->
{
CriteriaBuilder
.
In
<
Object
>
in
=
criteriaBuilder
.
in
(
root
.
get
(
WorkArea
.
Fields
.
workAreaName
));
for
(
String
item
:
set
)
{
in
.
value
(
item
);
}
return
criteriaBuilder
.
and
(
in
);
};
List
<
WorkArea
>
workAreaList
=
workAreaRepository
.
findAll
(
specification
);
Map
<
String
,
List
<
WorkArea
>>
map
=
workAreaList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
WorkArea:
:
getWorkAreaName
));
Set
<
String
>
stringSet
=
map
.
keySet
();
Set
<
String
>
fail
=
set
.
stream
().
filter
(
e
->
!
stringSet
.
contains
(
e
)).
collect
(
Collectors
.
toSet
());
if
(
fail
.
size
()
!=
0
)
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"这些工区不存在:"
+
fail
);
}
//检查位号是否重复
Set
<
String
>
excelSet
=
excels
.
stream
().
map
(
RiskWarnExcel:
:
getLocationNum
).
collect
(
Collectors
.
toSet
());
if
(
excelSet
.
size
()
!=
excels
.
size
())
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"位号不能为空,并且不能重复"
);
}
Specification
<
RiskWarn
>
specifica
=
(
root
,
query
,
criteriaBuilder
)
->
{
CriteriaBuilder
.
In
<
Object
>
in
=
criteriaBuilder
.
in
(
root
.
get
(
RiskWarn
.
Fields
.
locationNum
));
for
(
String
item
:
excelSet
)
{
in
.
value
(
item
);
}
return
criteriaBuilder
.
and
(
in
);
};
List
<
RiskWarn
>
riskWarnList
=
riskWarnRepository
.
findAll
(
specifica
);
if
(
riskWarnList
.
size
()
!=
0
)
{
Set
<
String
>
collect
=
riskWarnList
.
stream
().
map
(
RiskWarn:
:
getLocationNum
).
collect
(
Collectors
.
toSet
());
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"这些位号已经存在了:"
+
collect
);
}
ArrayList
<
RiskWarn
>
list
=
new
ArrayList
<>();
//每条数据以此检查
for
(
RiskWarnExcel
excel
:
excels
)
{
if
(
StringUtil
.
isBlank
(
excel
.
getWorkAreaName
()))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"工区不能为空"
);
}
if
(
StringUtil
.
isBlank
(
excel
.
getInstall
()))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"安装位置不能为空"
);
}
if
(
StringUtil
.
isBlank
(
excel
.
getMonitoring
()))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"监控参数不能为空"
);
}
WorkArea
workArea
=
map
.
get
(
excel
.
getWorkAreaName
()).
get
(
0
);
//检查并转换量程和区间信息
String
[]
array
=
{
""
,
""
};
boolean
enable
=
true
;
ArrayList
<
Threshold
>
thresholds
=
new
ArrayList
<>();
if
(!
StringUtil
.
isBlank
(
excel
.
getRange
()))
{
array
=
excel
.
getRange
().
split
(
"-"
);
if
(
array
.
length
!=
2
||
!
array
[
0
].
matches
(
RegEx
.
DIGIT_DECIMALS
)
||
!
array
[
1
].
matches
(
RegEx
.
DIGIT_DECIMALS
)
)
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"里程格式"
+
excel
.
getRange
()
+
"错误,正确格式是: 1-20"
);
}
Result
<
ArrayList
<
Threshold
>>
result
=
initThresholdS
(
excel
,
array
);
if
(
Status
.
OK
.
value
()
!=
result
.
getStatus
())
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
result
.
getDetails
());
}
thresholds
=
initThresholdS
(
excel
,
array
).
getBody
();
}
else
{
enable
=
false
;
}
String
flame
=
excel
.
getFlame
();
if
(!
StringUtil
.
isBlank
(
flame
))
{
if
(!
checkThreshold
(
flame
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值(熄灭)"
+
flame
+
"格式错误,正确格式: 1 或者 100%"
);
}
thresholds
.
add
(
Threshold
.
builder
()
.
min
(
flame
)
.
max
(
flame
)
.
status
(
ThresholdStatusEnum
.
FLAME_EXTINGUISH
.
getCode
())
.
build
()
);
}
//检查并转换坐标信息
if
(
StringUtil
.
isBlank
(
excel
.
getPoint
()))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"经纬度不能为空"
);
}
String
[]
split
=
excel
.
getPoint
().
split
(
","
);
if
(
split
.
length
!=
3
)
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"坐标格式"
+
excel
.
getPoint
()
+
"错误,正确格式是: 112.863173604639,30.4786075211555,0"
);
}
Point
point
=
GeoUtils
.
createPoint
(
Double
.
parseDouble
(
split
[
0
]),
Double
.
parseDouble
(
split
[
1
]),
Double
.
parseDouble
(
split
[
2
])
);
RiskWarn
riskWarn
=
RiskWarn
.
builder
()
.
workArea
(
workArea
)
.
point
(
point
)
.
install
(
excel
.
getInstall
())
.
monitoring
(
excel
.
getMonitoring
())
.
locationNum
(
excel
.
getLocationNum
())
.
min
((
""
).
equals
(
array
[
0
])
?
null
:
new
BigDecimal
(
array
[
0
]))
.
max
((
""
).
equals
(
array
[
1
])
?
null
:
new
BigDecimal
(
array
[
0
]))
.
unit
(
excel
.
getUnit
())
.
enable
(
enable
)
.
thresholds
(
thresholds
)
.
build
();
list
.
add
(
riskWarn
);
}
return
Result
.
ok
(
list
);
}
/**
* 将阈值区间转换
* @param excel 阈值区间信息
* @param array 量程
* @return 转换后的阈值区间西悉尼
*/
private
Result
<
ArrayList
<
Threshold
>>
initThresholdS
(
RiskWarnExcel
excel
,
String
[]
array
)
{
ArrayList
<
Threshold
>
threshold
=
new
ArrayList
<>();
Boolean
flag
=
null
;
BigDecimal
lowLowInt
=
null
;
BigDecimal
lowInt
=
null
;
BigDecimal
highInt
=
null
;
BigDecimal
highHighInt
=
null
;
ArrayList
<
BigDecimal
>
list
=
new
ArrayList
<>();
list
.
add
(
new
BigDecimal
(
array
[
1
]));
String
highHigh
=
excel
.
getHighHigh
();
if
(!
StringUtil
.
isBlank
(
highHigh
))
{
if
(!
checkThreshold
(
highHigh
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值(高高)"
+
highHigh
+
"格式错误,正确格式: 40 或者 90%"
);
}
flag
=
highHigh
.
endsWith
(
"%"
);
if
(
flag
)
{
highHighInt
=
new
BigDecimal
(
highHigh
.
substring
(
0
,
highHigh
.
length
()
-
1
))
.
divide
(
new
BigDecimal
(
100
),
4
,
BigDecimal
.
ROUND_HALF_UP
);
}
else
{
highHighInt
=
new
BigDecimal
(
highHigh
);
}
list
.
add
(
highHighInt
);
BigDecimal
max
=
list
.
get
(
list
.
size
()
-
2
);
String
maxString
=
flag
?
max
.
toString
()
+
"%"
:
max
.
toString
();
threshold
.
add
(
Threshold
.
builder
()
.
min
(
highHigh
)
.
max
(
maxString
)
.
status
(
ThresholdStatusEnum
.
HIGH_HIGH
.
getCode
())
.
riskLevel
(
RiskLevelEnum
.
RED
.
getCode
())
.
build
()
);
}
String
high
=
excel
.
getHigh
();
if
(!
StringUtil
.
isBlank
(
high
))
{
if
(!
checkThreshold
(
high
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值(高)"
+
high
+
"格式错误,正确格式: 30 或者 70%"
);
}
if
(
flag
==
null
)
{
flag
=
high
.
endsWith
(
"%"
);
}
else
if
(
flag
!=
high
.
endsWith
(
"%"
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值要么都为百分比,要么都不为百分比"
);
}
if
(
flag
)
{
highInt
=
new
BigDecimal
(
high
.
substring
(
0
,
high
.
length
()
-
1
))
.
divide
(
new
BigDecimal
(
100
),
4
,
BigDecimal
.
ROUND_HALF_UP
);
}
else
{
highInt
=
new
BigDecimal
(
high
);
}
list
.
add
(
highInt
);
BigDecimal
max
=
list
.
get
(
list
.
size
()
-
2
);
String
maxString
=
flag
?
max
.
toString
()
+
"%"
:
max
.
toString
();
threshold
.
add
(
Threshold
.
builder
()
.
min
(
high
)
.
max
(
maxString
)
.
status
(
ThresholdStatusEnum
.
HIGH
.
getCode
())
.
riskLevel
(
RiskLevelEnum
.
ORANGE
.
getCode
())
.
build
()
);
}
String
low
=
excel
.
getLow
();
if
(!
StringUtil
.
isBlank
(
low
))
{
if
(!
checkThreshold
(
low
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值(低)"
+
low
+
"格式错误,正确格式: 13 或者 30%"
);
}
if
(
flag
==
null
)
{
flag
=
low
.
endsWith
(
"%"
);
}
else
if
(
flag
!=
low
.
endsWith
(
"%"
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值要么都为百分比,要么都不为百分比"
);
}
if
(
flag
)
{
lowInt
=
new
BigDecimal
(
low
.
substring
(
0
,
low
.
length
()
-
1
))
.
divide
(
new
BigDecimal
(
100
),
4
,
BigDecimal
.
ROUND_HALF_UP
);
}
else
{
lowInt
=
new
BigDecimal
(
low
);
}
list
.
add
(
lowInt
);
BigDecimal
max
=
list
.
get
(
list
.
size
()
-
2
);
String
maxString
=
flag
?
max
.
toString
()
+
"%"
:
max
.
toString
();
threshold
.
add
(
Threshold
.
builder
()
.
min
(
low
)
.
max
(
maxString
)
.
status
(
ThresholdStatusEnum
.
LOW
.
getCode
())
.
riskLevel
(
RiskLevelEnum
.
YELLOW
.
getCode
())
.
build
()
);
}
String
lowLow
=
excel
.
getLowLow
();
if
(!
StringUtil
.
isBlank
(
lowLow
))
{
if
(!
checkThreshold
(
lowLow
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值(低低)"
+
lowLow
+
"格式错误,正确格式: 1 或者 15%"
);
}
if
(
flag
==
null
)
{
flag
=
lowLow
.
endsWith
(
"%"
);
}
else
if
(
flag
!=
lowLow
.
endsWith
(
"%"
))
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值要么都为百分比,要么都不为百分比"
);
}
if
(
flag
)
{
lowLowInt
=
new
BigDecimal
(
lowLow
.
substring
(
0
,
lowLow
.
length
()
-
1
))
.
divide
(
new
BigDecimal
(
100
),
4
,
BigDecimal
.
ROUND_HALF_UP
);
}
else
{
lowLowInt
=
new
BigDecimal
(
lowLow
);
}
list
.
add
(
lowLowInt
);
BigDecimal
max
=
list
.
get
(
list
.
size
()
-
2
);
String
maxString
=
flag
?
max
.
toString
()
+
"%"
:
max
.
toString
();
threshold
.
add
(
Threshold
.
builder
()
.
min
(
lowLow
)
.
max
(
maxString
)
.
status
(
ThresholdStatusEnum
.
LOW_LOW
.
getCode
())
.
riskLevel
(
RiskLevelEnum
.
BLUE
.
getCode
())
.
build
()
);
}
list
.
add
(
new
BigDecimal
(
array
[
0
]));
if
(
flag
!=
null
&&
flag
)
{
list
.
set
(
0
,
new
BigDecimal
(
1
));
list
.
set
(
list
.
size
()
-
1
,
new
BigDecimal
(
0
));
}
for
(
int
i
=
1
;
i
<
list
.
size
()
-
1
;
i
++)
{
if
(
list
.
get
(
i
).
compareTo
(
list
.
get
(
i
+
1
))
<
0
)
{
return
Result
.
no
(
Status
.
EXPECTATION_FAILED
,
"报警值区间值设置错误,风险高的值大于风险低的值了"
);
}
}
return
Result
.
ok
(
threshold
);
}
/**
* 判断字符串是否以%结尾或是数字或是小数
* @param threshold 阈值
* @return true:满足 false不满足
*/
private
boolean
checkThreshold
(
String
threshold
)
{
return
threshold
.
endsWith
(
"%"
)
||
threshold
.
matches
(
RegEx
.
DIGIT_DECIMALS
);
}
}
@Override
@Override
...
...
app/src/main/java/com/yiring/app/vo/district/DistrictVo.java
浏览文件 @
72d1f1ff
...
@@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
...
@@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
import
lombok.Builder
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
org.locationtech.jts.geom.Geometry
;
/**
/**
* 区域信息VO
* 区域信息VO
...
@@ -39,12 +40,16 @@ public class DistrictVo implements Serializable {
...
@@ -39,12 +40,16 @@ public class DistrictVo implements Serializable {
@ApiModelProperty
(
value
=
"风险等级(区域颜色)"
,
example
=
"f##0000"
)
@ApiModelProperty
(
value
=
"风险等级(区域颜色)"
,
example
=
"f##0000"
)
private
String
riskGrade
;
private
String
riskGrade
;
@ApiModelProperty
(
value
=
"区域位置信息"
,
dataType
=
"java.lang.String"
)
private
Geometry
geometry
;
public
static
DistrictVo
transform
(
District
district
)
{
public
static
DistrictVo
transform
(
District
district
)
{
return
DistrictVo
return
DistrictVo
.
builder
()
.
builder
()
.
id
(
district
.
getId
())
.
id
(
district
.
getId
())
.
name
(
district
.
getName
())
.
name
(
district
.
getName
())
.
riskGrade
(
district
.
getRiskGrade
())
.
riskGrade
(
district
.
getRiskGrade
())
.
geometry
(
district
.
getGeometry
())
.
build
();
.
build
();
}
}
}
}
app/src/main/java/com/yiring/app/vo/location/fence/LocationFenceGeoVo.java
0 → 100644
浏览文件 @
72d1f1ff
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
vo
.
location
.
fence
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.fasterxml.jackson.databind.ser.std.ToStringSerializer
;
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
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.locationtech.jts.geom.Geometry
;
/**
* @author tml
* @version 1.0
* @date 2022/5/26 9:08
*/
@ApiModel
(
"电子围栏地图信息"
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
LocationFenceGeoVo
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
7736396772271720214L
;
@JsonSerialize
(
using
=
ToStringSerializer
.
class
)
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"type"
)
private
String
type
;
@ApiModelProperty
(
"properties"
)
private
Properties
properties
;
@ApiModelProperty
(
value
=
"位置信息"
)
private
Geometry
geometry
;
public
static
LocationFenceGeoVo
transform
(
LocationFence
locationFence
)
{
return
LocationFenceGeoVo
.
builder
()
.
id
(
locationFence
.
getId
())
.
type
(
"Feature"
)
.
properties
(
new
Properties
(
locationFence
.
getName
(),
locationFence
.
getGeometry
().
getGeometryType
()))
.
geometry
(
locationFence
.
getGeometry
())
.
build
();
}
@Data
@AllArgsConstructor
@NoArgsConstructor
static
class
Properties
{
@ApiModelProperty
(
value
=
"围栏名称"
)
private
String
name
;
@ApiModelProperty
(
value
=
"位置类型"
)
private
String
type
;
}
}
app/src/main/java/com/yiring/app/vo/risk/RiskWarnDetailVo.java
浏览文件 @
72d1f1ff
...
@@ -14,6 +14,7 @@ import lombok.AllArgsConstructor;
...
@@ -14,6 +14,7 @@ import lombok.AllArgsConstructor;
import
lombok.Builder
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
org.locationtech.jts.geom.Point
;
/**
/**
* @author tml
* @author tml
...
@@ -37,6 +38,9 @@ public class RiskWarnDetailVo implements Serializable {
...
@@ -37,6 +38,9 @@ public class RiskWarnDetailVo implements Serializable {
@ApiModelProperty
(
value
=
"工区名称"
,
example
=
"组装工区"
)
@ApiModelProperty
(
value
=
"工区名称"
,
example
=
"组装工区"
)
private
String
workAreaName
;
private
String
workAreaName
;
@ApiModelProperty
(
value
=
"经纬度"
,
dataType
=
"java.lang.String"
)
private
Point
point
;
@ApiModelProperty
(
value
=
"安装位置"
,
example
=
"组装厂区二楼"
)
@ApiModelProperty
(
value
=
"安装位置"
,
example
=
"组装厂区二楼"
)
private
String
install
;
private
String
install
;
...
@@ -68,6 +72,7 @@ public class RiskWarnDetailVo implements Serializable {
...
@@ -68,6 +72,7 @@ public class RiskWarnDetailVo implements Serializable {
.
builder
()
.
builder
()
.
id
(
riskWarn
.
getId
())
.
id
(
riskWarn
.
getId
())
.
workAreaName
(
riskWarn
.
getWorkArea
().
getWorkAreaName
())
.
workAreaName
(
riskWarn
.
getWorkArea
().
getWorkAreaName
())
.
point
(
riskWarn
.
getPoint
())
.
install
(
riskWarn
.
getInstall
())
.
install
(
riskWarn
.
getInstall
())
.
monitoring
(
riskWarn
.
getMonitoring
())
.
monitoring
(
riskWarn
.
getMonitoring
())
.
locationNum
(
riskWarn
.
getLocationNum
())
.
locationNum
(
riskWarn
.
getLocationNum
())
...
...
app/src/main/java/com/yiring/app/web/location/fence/LocationFenceController.java
浏览文件 @
72d1f1ff
...
@@ -10,6 +10,7 @@ import com.yiring.app.param.location.fence.LocationFenceModifyParam;
...
@@ -10,6 +10,7 @@ import com.yiring.app.param.location.fence.LocationFenceModifyParam;
import
com.yiring.app.service.location.fence.LocationFenceService
;
import
com.yiring.app.service.location.fence.LocationFenceService
;
import
com.yiring.app.vo.CodeNameVo
;
import
com.yiring.app.vo.CodeNameVo
;
import
com.yiring.app.vo.location.fence.FenceRealtimeVo
;
import
com.yiring.app.vo.location.fence.FenceRealtimeVo
;
import
com.yiring.app.vo.location.fence.LocationFenceGeoVo
;
import
com.yiring.app.vo.location.fence.LocationFenceSearchVo
;
import
com.yiring.app.vo.location.fence.LocationFenceSearchVo
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.app.vo.location.fence.LocationFenceVo
;
import
com.yiring.auth.param.IdsParam
;
import
com.yiring.auth.param.IdsParam
;
...
@@ -63,7 +64,7 @@ public class LocationFenceController {
...
@@ -63,7 +64,7 @@ public class LocationFenceController {
}
}
@ApiOperation
(
"根据条件分页查询围栏信息"
)
@ApiOperation
(
"根据条件分页查询围栏信息"
)
@PostMapping
(
"/
LocationFenceVo
"
)
@PostMapping
(
"/
findList
"
)
public
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
public
Result
<
PageVo
<
LocationFenceVo
>>
findList
(
@Valid
LocationFenceConditionParam
conditionParam
,
@Valid
LocationFenceConditionParam
conditionParam
,
@Valid
PageParam
pageParam
@Valid
PageParam
pageParam
...
@@ -75,6 +76,12 @@ public class LocationFenceController {
...
@@ -75,6 +76,12 @@ public class LocationFenceController {
return
locationFenceService
.
findList
(
conditionParam
,
pageParam
);
return
locationFenceService
.
findList
(
conditionParam
,
pageParam
);
}
}
@ApiOperation
(
"根据条件查询围栏地图位置信息"
)
@GetMapping
(
"/findGeoList"
)
public
Result
<
PageVo
<
LocationFenceGeoVo
>>
findGeoList
(
@Valid
LocationFenceConditionParam
conditionParam
)
{
return
locationFenceService
.
findGeoList
(
conditionParam
);
}
@ApiOperation
(
"根据id查询围栏信息"
)
@ApiOperation
(
"根据id查询围栏信息"
)
@PostMapping
(
"/findById"
)
@PostMapping
(
"/findById"
)
public
Result
<
LocationFenceVo
>
findById
(
@Valid
IdParam
param
)
{
public
Result
<
LocationFenceVo
>
findById
(
@Valid
IdParam
param
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论