Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
6b2dcfaf
提交
6b2dcfaf
authored
5月 27, 2022
作者:
Administrator
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:预警信息
上级
e4c9a1e7
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
876 行增加
和
0 行删除
+876
-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
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
+21
-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
没有找到文件。
app/src/main/java/com/yiring/app/domain/warningMsg/WarningMessage.java
0 → 100644
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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/param/warningMsg/WarningMessageAddParam.java
0 → 100644
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
...
...
@@ -10,7 +10,10 @@ 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.warningMsg.WarningMessage
;
import
com.yiring.app.domain.warningMsg.WarningMessageRepository
;
import
com.yiring.app.param.key.KeyAlarmAddParam
;
import
com.yiring.app.param.warningMsg.WarningMessageAddParam
;
import
com.yiring.app.service.message.PositionMessageService
;
import
com.yiring.app.util.GeoUtils
;
import
com.yiring.app.vo.equipment.EquipmentVo
;
...
...
@@ -81,6 +84,9 @@ public class PositionMessageServiceImpl implements PositionMessageService {
@Resource
UserRepository
userRepository
;
@Resource
WarningMessageRepository
warningMessageRepository
;
@Times
(
"Message Consume"
)
@Override
public
void
consume
(
String
message
)
{
...
...
@@ -106,6 +112,8 @@ public class PositionMessageServiceImpl implements PositionMessageService {
case
"deviceStatus"
->
processDeviceStatusMessage
(
data
);
// 按键报警
case
"keyWarning"
->
processKeyWarningMessage
(
data
);
// 预警
case
"warning"
->
processWarningMessage
(
data
);
// 围栏报警
case
"enclosure"
->
log
.
warn
(
"Ignore Message Type [enclosure]: {}"
,
info
);
default
->
log
.
warn
(
"Unknown Message Type: {}"
,
info
);
...
...
@@ -505,4 +513,17 @@ public class PositionMessageServiceImpl implements PositionMessageService {
keyAlarmLogRepository
.
saveAll
(
keyAlarmLogs
);
}
/**
* 处理按键报警消息
* @param data 消息内容
*/
public
void
processWarningMessage
(
JSONObject
data
)
{
WarningMessageAddParam
warningMessageAddParam
=
data
.
toJavaObject
(
WarningMessageAddParam
.
class
);
WarningMessage
warningMessage
=
WarningMessage
.
builder
()
.
createTime
(
warningMessageAddParam
.
getCreateTime
())
.
tagNum
(
warningMessageAddParam
.
getTagNum
())
.
build
();
}
}
app/src/main/java/com/yiring/app/service/warningMsg/WarningMessageService.java
0 → 100644
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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
浏览文件 @
6b2dcfaf
/* (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
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论