Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
c8c03cd2
提交
c8c03cd2
authored
5月 27, 2022
作者:
17607474349
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:
1、监测推送:数据存储到预警表,发送处置消息并且记录
上级
2f25667e
隐藏空白字符变更
内嵌
并排
正在显示
23 个修改的文件
包含
1228 行增加
和
9 行删除
+1228
-9
RiskHandlePush.java
.../main/java/com/yiring/app/domain/risk/RiskHandlePush.java
+6
-0
RiskHandlePushLog.java
...in/java/com/yiring/app/domain/risk/RiskHandlePushLog.java
+57
-0
RiskHandlePushLogRepository.java
...m/yiring/app/domain/risk/RiskHandlePushLogRepository.java
+15
-0
RiskMeterDetect.java
...main/java/com/yiring/app/domain/risk/RiskMeterDetect.java
+51
-0
RiskMeterDetectRepository.java
...com/yiring/app/domain/risk/RiskMeterDetectRepository.java
+15
-0
WarningMessage.java
...java/com/yiring/app/domain/warningMsg/WarningMessage.java
+66
-0
WarningMessageRepository.java
...iring/app/domain/warningMsg/WarningMessageRepository.java
+15
-0
WarningMessageExportExcel.java
...iring/app/excel/warningMsg/WarningMessageExportExcel.java
+49
-0
MockPositionMessageJob.java
.../main/java/com/yiring/app/job/MockPositionMessageJob.java
+2
-2
RiskHandlePushSaveParam.java
...va/com/yiring/app/param/risk/RiskHandlePushSaveParam.java
+8
-0
WarningMessageAddParam.java
...m/yiring/app/param/warningMsg/WarningMessageAddParam.java
+34
-0
WarningMessageParam.java
.../com/yiring/app/param/warningMsg/WarningMessageParam.java
+38
-0
WarningMessageQueryParam.java
...yiring/app/param/warningMsg/WarningMessageQueryParam.java
+55
-0
PositionMessageServiceImpl.java
.../app/service/message/impl/PositionMessageServiceImpl.java
+211
-2
RiskHandlePushServiceImpl.java
...ring/app/service/risk/impl/RiskHandlePushServiceImpl.java
+3
-0
WarningMessageService.java
.../yiring/app/service/warningMsg/WarningMessageService.java
+74
-0
WarningMessageServiceImpl.java
...pp/service/warningMsg/impl/WarningMessageServiceImpl.java
+315
-0
WarningMessageCountVo.java
...a/com/yiring/app/vo/warningMsg/WarningMessageCountVo.java
+33
-0
WarningMessageRecVo.java
...ava/com/yiring/app/vo/warningMsg/WarningMessageRecVo.java
+33
-0
WarningMessageVo.java
...n/java/com/yiring/app/vo/warningMsg/WarningMessageVo.java
+64
-0
WarningMessageController.java
...m/yiring/app/web/warningMsg/WarningMessageController.java
+79
-0
UserPhoneParam.java
.../main/java/com/yiring/auth/param/user/UserPhoneParam.java
+3
-3
UserPwdParam.java
...rc/main/java/com/yiring/auth/param/user/UserPwdParam.java
+2
-2
没有找到文件。
app/src/main/java/com/yiring/app/domain/risk/RiskHandlePush.java
浏览文件 @
c8c03cd2
...
...
@@ -40,6 +40,12 @@ public class RiskHandlePush extends BasicEntity implements Serializable {
@Serial
private
static
final
long
serialVersionUID
=
7118854661682647225L
;
@Comment
(
"起始预警时间"
)
Integer
timeStart
;
@Comment
(
"结束"
)
Integer
timeEnd
;
@Comment
(
"风险推送"
)
@ManyToOne
RiskPush
riskPush
;
...
...
app/src/main/java/com/yiring/app/domain/risk/RiskHandlePushLog.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
risk
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.yiring.auth.domain.user.User
;
import
com.yiring.common.domain.BasicEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
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
lombok.experimental.SuperBuilder
;
import
org.hibernate.annotations.Comment
;
/**
* 处置推送日志
*
* @author LJ-2204
* @date 2022/5/27
*/
@Getter
@Setter
@ToString
@SuperBuilder
(
toBuilder
=
true
)
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@Entity
@Table
(
name
=
"BS_RISK_HANDLE_PUSH_LOG"
)
@Comment
(
"处置推送日志"
)
public
class
RiskHandlePushLog
extends
BasicEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
4525914994066766232L
;
@ManyToOne
@Comment
(
"风险推送"
)
RiskPush
riskPush
;
@Comment
(
"通知方式"
)
String
types
;
@Comment
(
"接收状态"
)
Boolean
status
;
@ManyToOne
@JoinColumn
(
name
=
"leader_id"
)
@JsonIgnore
@Comment
(
"负责人"
)
User
user
;
}
app/src/main/java/com/yiring/app/domain/risk/RiskHandlePushLogRepository.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
risk
;
import
java.io.Serializable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
/**
* 部门信息控制器
*
* @author LJ-2204
* @date 2022/5/27
*/
public
interface
RiskHandlePushLogRepository
extends
JpaRepository
<
RiskHandlePushLog
,
Serializable
>,
JpaSpecificationExecutor
<
RiskHandlePushLog
>
{}
app/src/main/java/com/yiring/app/domain/risk/RiskMeterDetect.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
risk
;
import
com.yiring.app.domain.warningMsg.WarningMessage
;
import
com.yiring.common.domain.BasicEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
javax.persistence.Entity
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
import
lombok.experimental.FieldNameConstants
;
import
lombok.experimental.SuperBuilder
;
import
org.hibernate.annotations.Comment
;
/**
* 监测记录
*
* @author LJ-2204
* @date 2022/5/27
*/
@Getter
@Setter
@ToString
@SuperBuilder
(
toBuilder
=
true
)
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@Entity
@Table
(
name
=
"BS_RISK_METER_DETECT"
)
@Comment
(
"监测记录表"
)
public
class
RiskMeterDetect
extends
BasicEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
1124679497996569631L
;
@Comment
(
"点位"
)
@ManyToOne
RiskWarn
riskWarn
;
@Comment
(
"预警"
)
@ManyToOne
WarningMessage
warningMessage
;
@Comment
(
"最新监测值"
)
BigDecimal
newestMonitor
;
}
app/src/main/java/com/yiring/app/domain/risk/RiskMeterDetectRepository.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
risk
;
import
java.io.Serializable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
/**
* 监测记录
*
* @author LJ-2204
* @date 2022/5/27
*/
public
interface
RiskMeterDetectRepository
extends
JpaRepository
<
RiskMeterDetect
,
Serializable
>,
JpaSpecificationExecutor
<
RiskMeterDetect
>
{}
app/src/main/java/com/yiring/app/domain/warningMsg/WarningMessage.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
warningMsg
;
import
com.yiring.app.domain.workArea.WorkArea
;
import
com.yiring.common.domain.BasicEntity
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
javax.persistence.Entity
;
import
javax.persistence.OneToOne
;
import
javax.persistence.Table
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
import
lombok.experimental.FieldNameConstants
;
import
lombok.experimental.SuperBuilder
;
import
org.hibernate.annotations.Comment
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/21 16:14
*/
@Getter
@Setter
@ToString
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@Entity
@Table
(
name
=
"BS_WARNING_MESSAGE"
)
@Comment
(
"预警信息"
)
public
class
WarningMessage
extends
BasicEntity
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
5118710539465436913L
;
@OneToOne
@Comment
(
"工区"
)
WorkArea
workArea
;
@Comment
(
"位号"
)
String
tagNum
;
@Comment
(
"阈值状态"
)
String
thrState
;
@Comment
(
"风险等级"
)
String
riskLevel
;
@Comment
(
"预警状态"
)
String
status
;
@Comment
(
"监测值"
)
String
monitorValue
;
@Comment
(
"通知方式"
)
String
notificationMethod
;
@Comment
(
"处置接收人"
)
String
noticeRecipient
;
@Comment
(
"通知方式"
)
String
notificationInfo
;
}
app/src/main/java/com/yiring/app/domain/warningMsg/WarningMessageRepository.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
warningMsg
;
import
java.io.Serializable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
/**
* @author tzl
* 2022/5/21 9:55
*/
@Repository
public
interface
WarningMessageRepository
extends
JpaRepository
<
WarningMessage
,
Serializable
>,
JpaSpecificationExecutor
<
WarningMessage
>
{}
app/src/main/java/com/yiring/app/excel/warningMsg/WarningMessageExportExcel.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
excel
.
warningMsg
;
import
com.github.liaochong.myexcel.core.annotation.ExcelColumn
;
import
com.github.liaochong.myexcel.core.annotation.ExcelModel
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/23 14:51
*/
@ExcelModel
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
WarningMessageExportExcel
{
@ExcelColumn
(
title
=
"工区名称"
)
String
workAreaName
;
@ExcelColumn
(
title
=
"负责人"
)
String
personInCharge
;
@ExcelColumn
(
title
=
"摄像头"
)
String
videoName
;
@ExcelColumn
(
title
=
"位号"
)
String
tagNum
;
@ExcelColumn
(
title
=
"阈值状态"
)
String
thrState
;
@ExcelColumn
(
title
=
"风险等级"
)
String
riskLevel
;
@ExcelColumn
(
title
=
"预警状态"
)
String
status
;
@ExcelColumn
(
title
=
"预警时间"
)
String
createTime
;
@ExcelColumn
(
title
=
"预警更新时间"
)
String
updateTime
;
}
app/src/main/java/com/yiring/app/job/MockPositionMessageJob.java
浏览文件 @
c8c03cd2
...
...
@@ -192,8 +192,8 @@ public class MockPositionMessageJob {
private
JSONObject
mockMeterDetectMessage
(
JSONObject
extra
)
{
JSONObject
params
=
new
JSONObject
();
params
.
put
(
"locationNum"
,
"
437
6"
);
params
.
put
(
"newestMonitor"
,
1
L
);
params
.
put
(
"locationNum"
,
"
AT-473
6"
);
params
.
put
(
"newestMonitor"
,
1
.5
);
params
.
put
(
"time"
,
LocalDateTime
.
now
());
params
.
putAll
(
extra
);
...
...
app/src/main/java/com/yiring/app/param/risk/RiskHandlePushSaveParam.java
浏览文件 @
c8c03cd2
...
...
@@ -29,6 +29,14 @@ public class RiskHandlePushSaveParam implements Serializable {
@Serial
private
static
final
long
serialVersionUID
=
830597649929357057L
;
@ApiModelProperty
(
value
=
"起始预警时间"
,
example
=
"0"
,
required
=
true
)
@NotNull
(
message
=
"起始预警时间不能为空"
)
Integer
timeStart
;
@ApiModelProperty
(
value
=
"结束预警时间"
,
example
=
"2"
,
required
=
true
)
@NotNull
(
message
=
"结束预警时间不能为空"
)
Integer
timeEnd
;
@ApiModelProperty
(
value
=
"风险推送id"
,
example
=
"1"
,
required
=
true
)
@NotNull
(
message
=
"风险推送id不能为空"
)
Long
riskPushId
;
...
...
app/src/main/java/com/yiring/app/param/warningMsg/WarningMessageAddParam.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
param
.
warningMsg
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/23 17:11
*/
@ApiModel
(
"WarningMessageParam"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
WarningMessageAddParam
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
7513618738675035368L
;
@ApiModelProperty
(
value
=
"位号"
,
example
=
"1"
)
String
tagNum
;
@ApiModelProperty
(
value
=
"预警时间"
,
example
=
"2022-05-23 22:22:22"
)
LocalDateTime
createTime
;
}
app/src/main/java/com/yiring/app/param/warningMsg/WarningMessageParam.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
param
.
warningMsg
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
javax.validation.constraints.NotEmpty
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/23 13:44
*/
@ApiModel
(
"WarningMessageParam"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
WarningMessageParam
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
1213328208483066739L
;
@ApiModelProperty
(
value
=
"通知方式"
,
example
=
"1,2"
)
String
notificationMethod
;
@ApiModelProperty
(
value
=
"处置接收人"
,
example
=
"1,2"
)
String
noticeRecipient
;
@ApiModelProperty
(
value
=
"通知内容"
,
example
=
"去处理"
,
required
=
true
)
@NotEmpty
(
message
=
"通知内容不能为空"
)
String
notificationInfo
;
}
app/src/main/java/com/yiring/app/param/warningMsg/WarningMessageQueryParam.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
param
.
warningMsg
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/23 13:44
*/
@ApiModel
(
"WarningMessageQueryParam"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
WarningMessageQueryParam
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
7062498310056412092L
;
@ApiModelProperty
(
value
=
"工区id"
,
example
=
"1"
)
Long
workAreaId
;
@ApiModelProperty
(
value
=
"位号"
,
example
=
"1"
)
String
tagNum
;
@ApiModelProperty
(
value
=
"阈值状态"
,
example
=
"1"
)
String
thrState
;
@ApiModelProperty
(
value
=
"风险登记"
,
example
=
"1"
)
String
riskLevel
;
@ApiModelProperty
(
value
=
"预警状态"
,
example
=
"1"
)
String
status
;
@ApiModelProperty
(
value
=
"开始时间"
,
example
=
"2022-05-23 22:22:22"
)
LocalDateTime
startTime
;
@ApiModelProperty
(
value
=
"结束时间"
,
example
=
"2022-05-23 22:22:22"
)
LocalDateTime
endTime
;
@ApiModelProperty
(
value
=
"每页记录数"
,
example
=
"10"
)
Integer
pageSize
;
@ApiModelProperty
(
value
=
"页码"
,
example
=
"1"
)
Integer
pageNo
;
}
app/src/main/java/com/yiring/app/service/message/impl/PositionMessageServiceImpl.java
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
service
.
message
.
impl
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -10,7 +14,11 @@ import com.yiring.app.domain.key.*;
import
com.yiring.app.domain.location.*
;
import
com.yiring.app.domain.log.ZyRealtimeLog
;
import
com.yiring.app.domain.log.ZyRealtimeLogRepository
;
import
com.yiring.app.domain.risk.*
;
import
com.yiring.app.domain.warningMsg.WarningMessage
;
import
com.yiring.app.domain.warningMsg.WarningMessageRepository
;
import
com.yiring.app.param.key.KeyAlarmAddParam
;
import
com.yiring.app.push.domain.PushMessage
;
import
com.yiring.app.service.message.PositionMessageService
;
import
com.yiring.app.stomp.message.PositionMessage
;
import
com.yiring.app.util.GeoUtils
;
...
...
@@ -18,9 +26,11 @@ import com.yiring.app.vo.equipment.EquipmentVo;
import
com.yiring.auth.domain.dept.Department
;
import
com.yiring.auth.domain.user.User
;
import
com.yiring.auth.domain.user.UserRepository
;
import
java.math.BigDecimal
;
import
java.time.Instant
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.temporal.ChronoUnit
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
...
...
@@ -81,6 +91,24 @@ public class PositionMessageServiceImpl implements PositionMessageService {
@Resource
UserRepository
userRepository
;
@Resource
RiskWarnRepository
riskWarnRepository
;
@Resource
RiskMeterDetectRepository
riskMeterDetectRepository
;
@Resource
WarningMessageRepository
warningMessageRepository
;
@Resource
RiskHandlePushRepository
riskHandlePushRepository
;
@Resource
RiskHandlePushLogRepository
riskHandlePushLogRepository
;
@Resource
RiskPushRepository
riskPushRepository
;
@Override
public
void
consume
(
String
message
)
{
// 将消息转换成 JSON 格式
...
...
@@ -105,6 +133,8 @@ public class PositionMessageServiceImpl implements PositionMessageService {
case
"position"
->
processPositionMessage
(
data
);
// 设备低电量
case
"lowPower"
->
processLowPowerMessage
(
data
);
// 风险监测
case
"meterDetect"
->
meterDetectMessage
(
data
);
// 设备状态变更
case
"deviceStatus"
->
processDeviceStatusMessage
(
data
);
// 按键报警
...
...
@@ -521,7 +551,7 @@ public class PositionMessageServiceImpl implements PositionMessageService {
if
(
userRepositoryOne
.
isEmpty
())
{
// throw new RuntimeException("没找到该用户");
log
.
warn
(
"
Tag
Not Found: {}"
,
"没找到该用户"
);
log
.
warn
(
"
User
Not Found: {}"
,
"没找到该用户"
);
return
;
}
...
...
@@ -555,7 +585,7 @@ public class PositionMessageServiceImpl implements PositionMessageService {
if
(
keyAlarmRuleOptional
.
isEmpty
())
{
// throw new RuntimeException("该部门未设置报警规则");
log
.
warn
(
"
Tag
Not Found: {}"
,
"该部门未设置报警规则"
);
log
.
warn
(
"
Dept
Not Found: {}"
,
"该部门未设置报警规则"
);
return
;
}
...
...
@@ -598,4 +628,183 @@ public class PositionMessageServiceImpl implements PositionMessageService {
message
.
put
(
"type"
,
finalKeyAlarm
.
getLeader
().
getType
());
simpMessagingTemplate
.
convertAndSend
(
"/topic/tag/keyWarning"
,
message
.
toJSONString
());
}
public
void
meterDetectMessage
(
JSONObject
data
)
{
// 1、通过位号拿到点位表相关信息
// 2、拿到点位表阈值区间
// 3、通过检测值判断阈值风险等级
// 4、记录推送数据
// 5、存在风险则将数据同步到预警表中
// 6、推送撤离数据
// 7、推送处置数据
// 位号
String
locationNum
=
data
.
getString
(
"locationNum"
);
// 检测值
BigDecimal
newestMonitor
=
data
.
getBigDecimal
(
"newestMonitor"
);
//更新时间
// LocalDateTime time = LocalDateTimeUtil;
LocalDateTime
time
=
data
.
getObject
(
"time"
,
LocalDateTime
.
class
);
// 通过位号拿到点位表
Optional
<
RiskWarn
>
riskWarnOptional
=
riskWarnRepository
.
findOne
(
Example
.
of
(
RiskWarn
.
builder
().
locationNum
(
locationNum
).
build
())
);
if
(
riskWarnOptional
.
isEmpty
())
{
log
.
warn
(
"RiskWarn Not Found: {}"
,
locationNum
);
return
;
}
// 实时修改点位表相关数据
RiskWarn
riskWarn
=
riskWarnOptional
.
get
();
riskWarn
.
setNewestMonitor
(
newestMonitor
);
// 拿到阈值区间
List
<
Threshold
>
thresholds
=
riskWarn
.
getThresholds
();
Optional
<
Threshold
>
thresholdOptional
=
thresholds
.
stream
()
.
filter
(
threshold
->
newestMonitor
.
compareTo
(
Convert
.
toBigDecimal
(
threshold
.
getMin
()))
>
-
1
&&
newestMonitor
.
compareTo
(
Convert
.
toBigDecimal
(
threshold
.
getMax
()))
<
0
)
.
findFirst
();
if
(
thresholdOptional
.
isEmpty
())
{
// 正常阈值
riskWarn
.
setWarnStatus
(
1
);
riskWarn
.
setRiskLevel
(
null
);
riskWarn
.
setThresholdStatus
(
5
);
riskWarn
.
setUpdateTime
(
time
);
riskWarn
=
riskWarnRepository
.
save
(
riskWarn
);
WarningMessage
warningMessage
=
null
;
// 关闭处于预警中的预警信息
Optional
<
WarningMessage
>
warningMessageOptional
=
warningMessageRepository
.
findOne
(
Example
.
of
(
WarningMessage
.
builder
().
tagNum
(
riskWarn
.
getLocationNum
()).
status
(
"2"
).
build
())
);
if
(
warningMessageOptional
.
isPresent
())
{
warningMessage
=
warningMessageOptional
.
get
();
warningMessage
.
setStatus
(
"1"
);
warningMessageRepository
.
save
(
warningMessage
);
}
RiskMeterDetect
riskMeterDetect
=
RiskMeterDetect
.
builder
()
.
riskWarn
(
riskWarn
)
.
warningMessage
(
warningMessage
)
.
newestMonitor
(
newestMonitor
)
.
build
();
riskMeterDetectRepository
.
save
(
riskMeterDetect
);
return
;
}
Threshold
threshold
=
thresholdOptional
.
get
();
// 触发预警
riskWarn
.
setWarnStatus
(
2
);
riskWarn
.
setRiskLevel
(
threshold
.
getRiskLevel
());
riskWarn
.
setThresholdStatus
(
threshold
.
getStatus
());
riskWarn
.
setUpdateTime
(
time
);
riskWarnRepository
.
save
(
riskWarn
);
Optional
<
WarningMessage
>
warningMessageOptional
=
warningMessageRepository
.
findOne
(
Example
.
of
(
WarningMessage
.
builder
().
tagNum
(
riskWarn
.
getLocationNum
()).
status
(
"2"
).
build
())
);
if
(
warningMessageOptional
.
isPresent
())
{
WarningMessage
warningMessage
=
warningMessageOptional
.
get
();
if
(
ObjectUtil
.
equal
(
riskWarn
.
getRiskLevel
(),
Convert
.
toInt
(
warningMessage
.
getRiskLevel
())))
{
// 存在预警数据并且风险等级相同时则更新时间
warningMessage
.
setMonitorValue
(
newestMonitor
.
toString
());
warningMessage
.
setUpdateTime
(
time
);
warningMessageRepository
.
save
(
warningMessage
);
// 记录监测日志
RiskMeterDetect
riskMeterDetect
=
RiskMeterDetect
.
builder
()
.
riskWarn
(
riskWarn
)
.
warningMessage
(
warningMessage
)
.
newestMonitor
(
newestMonitor
)
.
build
();
riskMeterDetectRepository
.
save
(
riskMeterDetect
);
return
;
}
else
{
warningMessage
.
setStatus
(
"1"
);
warningMessageRepository
.
save
(
warningMessage
);
}
}
WarningMessage
warningMessage
=
WarningMessage
.
builder
()
.
workArea
(
riskWarn
.
getWorkArea
())
.
tagNum
(
riskWarn
.
getLocationNum
())
.
thrState
(
riskWarn
.
getThresholdStatus
().
toString
())
.
riskLevel
(
riskWarn
.
getRiskLevel
().
toString
())
.
status
(
"2"
)
.
monitorValue
(
riskWarn
.
getNewestMonitor
().
toString
())
.
build
();
warningMessageRepository
.
save
(
warningMessage
);
RiskMeterDetect
riskMeterDetect
=
RiskMeterDetect
.
builder
()
.
riskWarn
(
riskWarn
)
.
warningMessage
(
warningMessage
)
.
newestMonitor
(
newestMonitor
)
.
build
();
riskMeterDetectRepository
.
save
(
riskMeterDetect
);
// 撤离推送
// 处置推送
Optional
<
RiskPush
>
riskPushOptional
=
riskPushRepository
.
findOne
(
Example
.
of
(
RiskPush
.
builder
().
workArea
(
riskWarn
.
getWorkArea
()).
level
(
riskWarn
.
getRiskLevel
()).
build
())
);
if
(
riskPushOptional
.
isEmpty
())
{
log
.
warn
(
"RiskPush Not Found"
);
return
;
}
RiskPush
riskPush
=
riskPushOptional
.
get
();
long
between
=
LocalDateTimeUtil
.
between
(
warningMessage
.
getCreateTime
(),
warningMessage
.
getUpdateTime
(),
ChronoUnit
.
MINUTES
);
Optional
<
RiskHandlePush
>
riskHandlePushOptional
=
riskHandlePushRepository
.
findOne
(
(
(
root
,
cq
,
cb
)
->
{
List
<
Predicate
>
predicates
=
ListUtil
.
toList
();
predicates
.
add
(
cb
.
equal
(
root
.
get
(
RiskHandlePush
.
Fields
.
riskPush
),
riskPush
));
predicates
.
add
(
cb
.
lessThanOrEqualTo
(
root
.
get
(
RiskHandlePush
.
Fields
.
timeStart
),
between
));
predicates
.
add
(
cb
.
greaterThan
(
root
.
get
(
RiskHandlePush
.
Fields
.
timeStart
),
between
));
return
cq
.
where
(
predicates
.
toArray
(
new
Predicate
[
0
])).
getRestriction
();
}
)
);
if
(
riskHandlePushOptional
.
isEmpty
())
{
log
.
warn
(
"RiskHandlePush Not Found: {}"
,
between
);
return
;
}
RiskHandlePush
riskHandlePush
=
riskHandlePushOptional
.
get
();
String
[]
split
=
riskHandlePush
.
getTypes
().
split
(
","
);
for
(
String
s
:
split
)
{
for
(
User
user
:
riskHandlePush
.
getUsers
())
{
Boolean
status
=
false
;
switch
(
PushMessage
.
Type
.
valueOf
(
s
))
{
case
APP
->
log
.
info
(
"APP 信息发送中---"
);
case
SMS
->
log
.
info
(
"SMS 信息发送中---"
);
case
EMAIL
->
log
.
info
(
"EMAIL 信息发送中---"
);
}
// 记录发送数据
RiskHandlePushLog
riskHandlePushLog
=
RiskHandlePushLog
.
builder
()
.
riskPush
(
riskPush
)
.
types
(
s
)
.
user
(
user
)
.
status
(
status
)
.
build
();
riskHandlePushLogRepository
.
save
(
riskHandlePushLog
);
}
}
}
}
app/src/main/java/com/yiring/app/service/risk/impl/RiskHandlePushServiceImpl.java
浏览文件 @
c8c03cd2
...
...
@@ -50,6 +50,7 @@ public class RiskHandlePushServiceImpl implements RiskHandlePushService {
@Resource
UserRepository
userRepository
;
// todo 预警区间限制
@Override
public
Result
<
String
>
add
(
RiskHandlePushSaveParam
param
)
{
Optional
<
RiskPush
>
riskPushOptional
=
riskPushRepository
.
findById
(
param
.
getRiskPushId
());
...
...
@@ -110,6 +111,8 @@ public class RiskHandlePushServiceImpl implements RiskHandlePushService {
RiskHandlePush
riskHandlePush
=
riskHandlePushOptional
.
get
();
riskHandlePush
.
setTypes
(
param
.
getTypes
());
riskHandlePush
.
setTimeStart
(
param
.
getTimeStart
());
riskHandlePush
.
setTimeEnd
(
param
.
getTimeEnd
());
Optional
<
RiskPush
>
riskPushOptional
=
riskPushRepository
.
findById
(
param
.
getRiskPushId
());
if
(
riskPushOptional
.
isEmpty
())
{
...
...
app/src/main/java/com/yiring/app/service/warningMsg/WarningMessageService.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
service
.
warningMsg
;
import
com.yiring.app.param.warningMsg.WarningMessageParam
;
import
com.yiring.app.param.warningMsg.WarningMessageQueryParam
;
import
com.yiring.app.vo.warningMsg.WarningMessageCountVo
;
import
com.yiring.app.vo.warningMsg.WarningMessageRecVo
;
import
com.yiring.app.vo.warningMsg.WarningMessageVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.IndexParam
;
import
com.yiring.common.vo.PageVo
;
import
javax.servlet.http.HttpServletResponse
;
public
interface
WarningMessageService
{
/**
* 通知处置预警信息
* @author tzl
* @date 2022/5/23 14:06
* @param warningMessageParam WarningMessageParam
* @param idParam IdParam
* @return com.yiring.common.core.Result<java.lang.String>
*/
Result
<
String
>
update
(
WarningMessageParam
warningMessageParam
,
IdParam
idParam
);
/**
* 删除已处置过的预警信息
* @author tzl
* @date 2022/5/23 14:06
* @param idParam IdParam
* @return com.yiring.common.core.Result<java.lang.String>
*/
Result
<
String
>
delete
(
IdParam
idParam
);
/**
* 分页查询预警信息
* @author tzl
* @date 2022/5/23 14:07
* @param warningMessageQueryParam WarningMessageQueryParam
* @return com.yiring.common.core.Result<com.yiring.common.vo.PageVo<com.yiring.app.vo.warningMsg.WarningMessageVo>>
*/
Result
<
PageVo
<
WarningMessageVo
>>
page
(
WarningMessageQueryParam
warningMessageQueryParam
);
/**
* 导出预警信息
* @author tzl
* @date 2022/5/23 14:49
* @param warningMessageQueryParam WarningMessageQueryParam
* @param httpServletResponse HttpServletResponse
*/
void
export
(
WarningMessageQueryParam
warningMessageQueryParam
,
HttpServletResponse
httpServletResponse
);
/**
* 根据时间查询统计各个风险预警的数量
* @author tzl
* @date 2022/5/23 16:59
* @param warningMessageQueryParam WarningMessageQueryParam
* @return com.yiring.common.core.Result<com.yiring.common.vo.PageVo<com.yiring.app.vo.warningMsg.WarningMessageCountVo>>
*/
Result
<
PageVo
<
WarningMessageCountVo
>>
list
(
WarningMessageQueryParam
warningMessageQueryParam
);
/**
* 根据位号查询预警日志记录
* @author tzl
* @date 2022/5/24 10:52
* @param indexParam IndexParam
* @return com.yiring.common.core.Result<com.yiring.common.vo.PageVo<com.yiring.app.vo.warningMsg.WarningMessageVo>>
*/
Result
<
PageVo
<
WarningMessageRecVo
>>
listRec
(
IndexParam
indexParam
);
// /**
// * 导出预警日志记录
// * @author tzl
// * @date 2022/5/25 15:17
// * @param warningMessageQueryParam WarningMessageQueryParam
// * @param httpServletResponse HttpServletResponse
// */
// void exportRec(WarningMessageQueryParam warningMessageQueryParam, HttpServletResponse httpServletResponse);
}
app/src/main/java/com/yiring/app/service/warningMsg/impl/WarningMessageServiceImpl.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
service
.
warningMsg
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder
;
import
com.yiring.app.domain.warningMsg.WarningMessage
;
import
com.yiring.app.domain.warningMsg.WarningMessageRepository
;
import
com.yiring.app.domain.workArea.WorkArea
;
import
com.yiring.app.excel.warningMsg.WarningMessageExportExcel
;
import
com.yiring.app.param.warningMsg.WarningMessageParam
;
import
com.yiring.app.param.warningMsg.WarningMessageQueryParam
;
import
com.yiring.app.service.warningMsg.WarningMessageService
;
import
com.yiring.app.vo.warningMsg.WarningMessageCountVo
;
import
com.yiring.app.vo.warningMsg.WarningMessageRecVo
;
import
com.yiring.app.vo.warningMsg.WarningMessageVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.core.Status
;
import
com.yiring.common.domain.BasicEntity
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.IndexParam
;
import
com.yiring.common.vo.PageVo
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.*
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.*
;
import
javax.servlet.http.HttpServletResponse
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/23 14:08
*/
@Slf4j
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
@Service
public
class
WarningMessageServiceImpl
implements
WarningMessageService
{
@Resource
WarningMessageRepository
warningMessageRepository
;
@Resource
EntityManager
em
;
@Override
public
Result
<
String
>
update
(
WarningMessageParam
warningMessageParam
,
IdParam
idParam
)
{
Optional
<
WarningMessage
>
byId
=
warningMessageRepository
.
findById
(
idParam
.
getId
());
if
(
byId
.
isEmpty
())
{
return
Result
.
no
(
Status
.
NOT_FOUND
);
}
WarningMessage
warningMessage
=
byId
.
get
();
BeanUtils
.
copyProperties
(
warningMessageParam
,
warningMessage
);
//校验通知内容是否符合阿里云短信模板内容
warningMessageRepository
.
saveAndFlush
(
warningMessage
);
return
Result
.
ok
();
}
@Override
public
Result
<
String
>
delete
(
IdParam
idParam
)
{
Optional
<
WarningMessage
>
byId
=
warningMessageRepository
.
findById
(
idParam
.
getId
());
if
(
byId
.
isEmpty
())
{
return
Result
.
no
(
Status
.
NOT_FOUND
);
}
WarningMessage
warningMessage
=
byId
.
get
();
warningMessageRepository
.
delete
(
warningMessage
);
return
Result
.
ok
();
}
@Override
public
Result
<
PageVo
<
WarningMessageVo
>>
page
(
WarningMessageQueryParam
warningMessageQueryParam
)
{
PageVo
<
WarningMessageVo
>
resultVo
;
//排序
Sort
sort
=
Sort
.
by
(
Sort
.
Order
.
desc
(
BasicEntity
.
Fields
.
updateTime
));
if
(
Objects
.
nonNull
(
warningMessageQueryParam
.
getPageNo
())
&&
Objects
.
nonNull
(
warningMessageQueryParam
.
getPageSize
())
)
{
//分页
Pageable
pageable
=
PageRequest
.
of
(
warningMessageQueryParam
.
getPageNo
()
-
1
,
warningMessageQueryParam
.
getPageSize
()
);
Page
<
WarningMessage
>
all
=
warningMessageRepository
.
findAll
(
condition
(
warningMessageQueryParam
),
pageable
);
List
<
WarningMessageVo
>
data
=
all
.
get
()
.
map
(
warningMessage
->
{
WarningMessageVo
vo
=
new
WarningMessageVo
();
BeanUtils
.
copyProperties
(
warningMessage
,
vo
);
return
vo
;
})
.
collect
(
Collectors
.
toList
());
resultVo
=
PageVo
.
build
(
data
,
all
.
getTotalElements
());
}
else
{
List
<
WarningMessage
>
all
=
warningMessageRepository
.
findAll
(
condition
(
warningMessageQueryParam
),
sort
);
List
<
WarningMessageVo
>
data
=
all
.
stream
()
.
map
(
warningMessage
->
{
WarningMessageVo
vo
=
new
WarningMessageVo
();
BeanUtils
.
copyProperties
(
warningMessage
,
vo
);
return
vo
;
})
.
collect
(
Collectors
.
toList
());
resultVo
=
PageVo
.
build
(
data
,
data
.
size
());
}
return
Result
.
ok
(
resultVo
);
}
@Override
public
void
export
(
WarningMessageQueryParam
warningMessageQueryParam
,
HttpServletResponse
httpServletResponse
)
{
List
<
WarningMessage
>
workAreas
=
warningMessageRepository
.
findAll
(
condition
(
warningMessageQueryParam
));
List
<
WarningMessageExportExcel
>
warningMessageExportExcels
=
workAreas
.
stream
()
.
map
(
warningMessage
->
{
WarningMessageExportExcel
warningMessageExportExcel
=
new
WarningMessageExportExcel
();
BeanUtils
.
copyProperties
(
warningMessage
,
warningMessageExportExcel
);
warningMessageExportExcel
.
setWorkAreaName
(
warningMessage
.
getWorkArea
().
getWorkAreaName
());
warningMessageExportExcel
.
setPersonInCharge
(
warningMessage
.
getWorkArea
().
getPersonInCharge
());
warningMessageExportExcel
.
setVideoName
(
warningMessage
.
getWorkArea
().
getVideo
().
getVideoName
());
return
warningMessageExportExcel
;
})
.
toList
();
try
(
DefaultStreamExcelBuilder
<
WarningMessageExportExcel
>
defaultStreamExcelBuilder
=
DefaultStreamExcelBuilder
.
of
(
WarningMessageExportExcel
.
class
)
.
threadPool
(
Executors
.
newFixedThreadPool
(
2
))
.
rowHeight
(
14
)
.
titleRowHeight
(
14
)
.
widths
(
8
)
.
style
(
"cell->vertical-align:center;text-align:center"
,
"title->vertical-align:center;text-align:center;font-weight:bold;font-family:等线"
)
.
start
()
)
{
defaultStreamExcelBuilder
.
append
(
warningMessageExportExcels
);
String
fileName
=
URLEncoder
.
encode
(
"预警信息.xlsx"
,
StandardCharsets
.
UTF_8
);
httpServletResponse
.
setContentType
(
"application/octet-stream"
);
httpServletResponse
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
httpServletResponse
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
fileName
);
OutputStream
out
=
httpServletResponse
.
getOutputStream
();
Workbook
workbook
=
defaultStreamExcelBuilder
.
fixedTitles
().
build
();
workbook
.
write
(
out
);
workbook
.
close
();
out
.
flush
();
out
.
close
();
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
RuntimeException
(
"导出预警信息失败: "
+
e
.
getMessage
());
}
}
public
Specification
<
WarningMessage
>
condition
(
WarningMessageQueryParam
warningMessageQueryParam
)
{
return
(
root
,
query
,
criteriaBuilder
)
->
{
List
<
Predicate
>
list
=
new
ArrayList
<>();
Join
<
WarningMessage
,
WorkArea
>
join
=
root
.
join
(
WarningMessage
.
Fields
.
workArea
,
JoinType
.
LEFT
);
if
(
ObjectUtil
.
isNotNull
(
warningMessageQueryParam
.
getWorkAreaId
()))
{
list
.
add
(
criteriaBuilder
.
equal
(
join
.
get
(
BasicEntity
.
Fields
.
id
),
warningMessageQueryParam
.
getWorkAreaId
())
);
}
if
(
StrUtil
.
isNotBlank
(
warningMessageQueryParam
.
getTagNum
()))
{
list
.
add
(
criteriaBuilder
.
like
(
root
.
get
(
WarningMessage
.
Fields
.
tagNum
),
warningMessageQueryParam
.
getTagNum
())
);
}
if
(
StrUtil
.
isNotBlank
(
warningMessageQueryParam
.
getRiskLevel
()))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
WarningMessage
.
Fields
.
riskLevel
),
warningMessageQueryParam
.
getRiskLevel
()
)
);
}
if
(
StrUtil
.
isNotBlank
(
warningMessageQueryParam
.
getThrState
()))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
WarningMessage
.
Fields
.
thrState
),
warningMessageQueryParam
.
getThrState
()
)
);
}
if
(
StrUtil
.
isNotBlank
(
warningMessageQueryParam
.
getStatus
()))
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
WarningMessage
.
Fields
.
status
),
warningMessageQueryParam
.
getStatus
())
);
}
if
(
ObjectUtil
.
isNotNull
(
warningMessageQueryParam
.
getEndTime
())
&&
ObjectUtil
.
isNotNull
(
warningMessageQueryParam
.
getStartTime
())
)
{
list
.
add
(
criteriaBuilder
.
between
(
root
.
get
(
BasicEntity
.
Fields
.
createTime
),
warningMessageQueryParam
.
getStartTime
(),
warningMessageQueryParam
.
getEndTime
()
)
);
}
Order
order
=
criteriaBuilder
.
desc
(
root
.
get
(
BasicEntity
.
Fields
.
updateTime
));
Predicate
[]
predicates
=
new
Predicate
[
list
.
size
()];
query
.
where
(
list
.
toArray
(
predicates
));
query
.
orderBy
(
order
);
return
criteriaBuilder
.
and
(
list
.
toArray
(
predicates
));
};
}
@Override
public
Result
<
PageVo
<
WarningMessageCountVo
>>
list
(
WarningMessageQueryParam
warningMessageQueryParam
)
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
WarningMessageCountVo
>
cq
=
cb
.
createQuery
(
WarningMessageCountVo
.
class
);
Root
<
WarningMessage
>
root
=
cq
.
from
(
WarningMessage
.
class
);
Path
<
Object
>
objectPath
=
root
.
get
(
WarningMessage
.
Fields
.
riskLevel
);
Expression
<
Long
>
num
=
cb
.
count
(
root
.
get
(
BasicEntity
.
Fields
.
id
));
cq
.
multiselect
(
num
,
objectPath
).
groupBy
(
objectPath
);
List
<
Predicate
>
list
=
new
ArrayList
<>();
if
(
ObjectUtil
.
isNotNull
(
warningMessageQueryParam
.
getStartTime
())
&&
ObjectUtil
.
isNotNull
(
warningMessageQueryParam
.
getEndTime
())
)
{
list
.
add
(
cb
.
between
(
root
.
get
(
BasicEntity
.
Fields
.
createTime
),
warningMessageQueryParam
.
getStartTime
(),
warningMessageQueryParam
.
getEndTime
()
)
);
}
cq
.
where
(
list
.
toArray
(
new
Predicate
[
0
]));
List
<
WarningMessageCountVo
>
resultList
=
em
.
createQuery
(
cq
).
getResultList
();
PageVo
<
WarningMessageCountVo
>
build
=
PageVo
.
build
(
resultList
,
resultList
.
size
());
return
Result
.
ok
(
build
);
}
@Override
public
Result
<
PageVo
<
WarningMessageRecVo
>>
listRec
(
IndexParam
indexParam
)
{
List
<
WarningMessage
>
all
=
warningMessageRepository
.
findAll
(
Example
.
of
(
WarningMessage
.
builder
().
tagNum
(
indexParam
.
getStr
()).
build
())
);
List
<
WarningMessageRecVo
>
list
=
all
.
stream
()
.
map
(
warningMessage
->
{
WarningMessageRecVo
warningMessageRecVo
=
new
WarningMessageRecVo
();
BeanUtils
.
copyProperties
(
warningMessage
,
warningMessageRecVo
);
return
warningMessageRecVo
;
})
.
collect
(
Collectors
.
toList
());
PageVo
<
WarningMessageRecVo
>
build
=
PageVo
.
build
(
list
,
list
.
size
());
return
Result
.
ok
(
build
);
}
// @Override
// public void exportRec(WarningMessageQueryParam warningMessageQueryParam, HttpServletResponse httpServletResponse) {
// List<WarningMessage> workAreas = warningMessageRepository.findAll(condition(warningMessageQueryParam));
// List<WarningMessageExportExcel> warningMessageExportExcels = workAreas
// .stream()
// .map(warningMessage -> {
// WarningMessageExportExcel warningMessageExportExcel = new WarningMessageExportExcel();
// BeanUtils.copyProperties(warningMessage, warningMessageExportExcel);
// warningMessageExportExcel.setWorkAreaName(warningMessage.getWorkArea().getWorkAreaName());
// warningMessageExportExcel.setPersonInCharge(warningMessage.getWorkArea().getPersonInCharge());
// warningMessageExportExcel.setVideoName(warningMessage.getWorkArea().getVideo().getVideoName());
// return warningMessageExportExcel;
// })
// .toList();
//
// try (
// DefaultStreamExcelBuilder<WarningMessageExportExcel> defaultStreamExcelBuilder = DefaultStreamExcelBuilder
// .of(WarningMessageExportExcel.class)
// .threadPool(Executors.newFixedThreadPool(2))
// .rowHeight(14)
// .titleRowHeight(14)
// .widths(8)
// .style(
// "cell->vertical-align:center;text-align:center",
// "title->vertical-align:center;text-align:center;font-weight:bold;font-family:等线"
// )
// .start()
// ) {
// defaultStreamExcelBuilder.append(warningMessageExportExcels);
//
// String fileName = URLEncoder.encode("预警信息.xlsx", StandardCharsets.UTF_8);
// httpServletResponse.setContentType("application/octet-stream");
// httpServletResponse.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
// httpServletResponse.setHeader("Content-Disposition", "attachment;filename=" + fileName);
// OutputStream out = httpServletResponse.getOutputStream();
//
// Workbook workbook = defaultStreamExcelBuilder.fixedTitles().build();
// workbook.write(out);
// workbook.close();
// out.flush();
// out.close();
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// throw new RuntimeException("导出预警信息失败: " + e.getMessage());
// }
// }
}
app/src/main/java/com/yiring/app/vo/warningMsg/WarningMessageCountVo.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
vo
.
warningMsg
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/23 16:54
*/
@ApiModel
(
"WarningMessageCountVo"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
WarningMessageCountVo
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
2381198342541182882L
;
@ApiModelProperty
(
value
=
"风险等级"
,
example
=
"1"
)
String
riskLevel
;
@ApiModelProperty
(
value
=
"数量"
,
example
=
"1"
)
String
num
;
}
app/src/main/java/com/yiring/app/vo/warningMsg/WarningMessageRecVo.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
vo
.
warningMsg
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/24 10:50
*/
@ApiModel
(
"WarningMessageRecVo"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
WarningMessageRecVo
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
7404330262476396295L
;
@ApiModelProperty
(
value
=
"监测值"
,
example
=
"1"
)
String
monitorValue
;
@ApiModelProperty
(
value
=
"预警时间"
,
example
=
"1"
)
String
createTime
;
}
app/src/main/java/com/yiring/app/vo/warningMsg/WarningMessageVo.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
vo
.
warningMsg
;
import
com.yiring.app.domain.workArea.WorkArea
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/23 13:50
*/
@ApiModel
(
"WarningMessageVo"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
WarningMessageVo
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
526816538193243051L
;
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"1"
)
Long
id
;
@ApiModelProperty
(
value
=
"工区信息"
,
example
=
"WorkArea"
)
WorkArea
workArea
;
@ApiModelProperty
(
value
=
"位号"
,
example
=
"1"
)
String
tagNum
;
@ApiModelProperty
(
value
=
"阈值状态"
,
example
=
"1"
)
String
thrState
;
@ApiModelProperty
(
value
=
"风险登记"
,
example
=
"1"
)
String
riskLevel
;
@ApiModelProperty
(
value
=
"预警状态"
,
example
=
"1"
)
String
status
;
@ApiModelProperty
(
value
=
"监测值"
,
example
=
"1"
)
String
monitorValue
;
@ApiModelProperty
(
value
=
"预警时间"
,
example
=
"2022-02-23 00:00:00"
)
String
createTime
;
@ApiModelProperty
(
value
=
"修改时间"
,
example
=
"2022-02-23 00:00:00"
)
String
updateTime
;
@ApiModelProperty
(
value
=
"通知方式"
,
example
=
"1,2"
)
String
notificationMethod
;
@ApiModelProperty
(
value
=
"处置接收人"
,
example
=
"1,2"
)
String
noticeRecipient
;
@ApiModelProperty
(
value
=
"通知内容"
,
example
=
"去处理"
)
String
notificationInfo
;
}
app/src/main/java/com/yiring/app/web/warningMsg/WarningMessageController.java
0 → 100644
浏览文件 @
c8c03cd2
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
web
.
warningMsg
;
import
com.yiring.app.param.warningMsg.WarningMessageParam
;
import
com.yiring.app.param.warningMsg.WarningMessageQueryParam
;
import
com.yiring.app.service.warningMsg.WarningMessageService
;
import
com.yiring.app.vo.warningMsg.WarningMessageCountVo
;
import
com.yiring.app.vo.warningMsg.WarningMessageRecVo
;
import
com.yiring.app.vo.warningMsg.WarningMessageVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.IdParam
;
import
com.yiring.common.param.IndexParam
;
import
com.yiring.common.vo.PageVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.MediaType
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/23 15:02
*/
@Slf4j
@Validated
@SuppressWarnings
({
"deprecation"
})
@Api
(
tags
=
"预警"
,
description
=
"WarningMessage"
)
@RestController
@RequestMapping
(
"/warningMessage/"
)
public
class
WarningMessageController
{
@Resource
WarningMessageService
warningMessageService
;
@ApiOperation
(
value
=
"通知处置预警信息"
)
@PostMapping
(
"update"
)
public
Result
<
String
>
update
(
@Valid
WarningMessageParam
warningMessageParam
,
@Valid
IdParam
idParam
)
{
return
warningMessageService
.
update
(
warningMessageParam
,
idParam
);
}
@ApiOperation
(
value
=
"删除预警信息"
)
@PostMapping
(
"delete"
)
public
Result
<
String
>
delete
(
@Valid
IdParam
idParam
)
{
return
warningMessageService
.
delete
(
idParam
);
}
@ApiOperation
(
value
=
"查看预警信息"
)
@GetMapping
(
"page"
)
public
Result
<
PageVo
<
WarningMessageVo
>>
page
(
@Valid
WarningMessageQueryParam
warningMessageQueryParam
)
{
return
warningMessageService
.
page
(
warningMessageQueryParam
);
}
@ApiOperation
(
value
=
"统计预警信息"
)
@GetMapping
(
"list"
)
public
Result
<
PageVo
<
WarningMessageCountVo
>>
list
(
@Valid
WarningMessageQueryParam
warningMessageQueryParam
)
{
return
warningMessageService
.
list
(
warningMessageQueryParam
);
}
@ApiOperation
(
value
=
"统计预警信息"
)
@GetMapping
(
"listRec"
)
public
Result
<
PageVo
<
WarningMessageRecVo
>>
listRec
(
@Valid
IndexParam
indexParam
)
{
return
warningMessageService
.
listRec
(
indexParam
);
}
@ApiOperation
(
value
=
"导出预警信息"
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
@PostMapping
(
"export"
)
public
void
export
(
HttpServletResponse
response
,
@Valid
WarningMessageQueryParam
warningMessageQueryParam
)
{
warningMessageService
.
export
(
warningMessageQueryParam
,
response
);
}
}
basic-auth/src/main/java/com/yiring/auth/param/user/UserPhoneParam.java
浏览文件 @
c8c03cd2
...
...
@@ -27,15 +27,15 @@ public class UserPhoneParam implements Serializable {
@Serial
private
static
final
long
serialVersionUID
=
-
3240552295880947685L
;
@ApiModelProperty
(
value
=
"手机号码"
,
example
=
"1888888888"
)
@ApiModelProperty
(
value
=
"手机号码"
,
example
=
"1888888888"
,
required
=
true
)
@NotEmpty
(
message
=
"手机号码不能为空"
)
String
mobile
;
@ApiModelProperty
(
value
=
"验证码"
,
example
=
"7758"
)
@ApiModelProperty
(
value
=
"验证码"
,
example
=
"7758"
,
required
=
true
)
@NotEmpty
(
message
=
"验证码不能为空"
)
String
code
;
@ApiModelProperty
(
value
=
"类型"
,
example
=
"phone/pwd"
)
@ApiModelProperty
(
value
=
"类型"
,
example
=
"phone/pwd"
,
required
=
true
)
@NotEmpty
(
message
=
"类型不能为空"
)
String
type
;
}
basic-auth/src/main/java/com/yiring/auth/param/user/UserPwdParam.java
浏览文件 @
c8c03cd2
...
...
@@ -30,11 +30,11 @@ public class UserPwdParam implements Serializable {
@ApiModelProperty
(
value
=
"旧密码"
,
example
=
"10086"
)
String
oldPassword
;
@ApiModelProperty
(
value
=
"新密码"
,
example
=
"10086"
)
@ApiModelProperty
(
value
=
"新密码"
,
example
=
"10086"
,
required
=
true
)
@NotEmpty
(
message
=
"新密码不能为空"
)
String
newPassword
;
@ApiModelProperty
(
value
=
"确认密码"
,
example
=
"10086"
)
@ApiModelProperty
(
value
=
"确认密码"
,
example
=
"10086"
,
required
=
true
)
@NotEmpty
(
message
=
"确认密码不能为空"
)
String
confirmPwd
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论