Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
8d81b301
提交
8d81b301
authored
5月 15, 2022
作者:
Administrator
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:人员统计查询导出功能
上级
c5315cc2
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
413 行增加
和
0 行删除
+413
-0
PersonnelStatistics.java
.../yiring/app/domain/perstatistics/PersonnelStatistics.java
+61
-0
PersonnelStatisticsRepository.java
...p/domain/perstatistics/PersonnelStatisticsRepository.java
+17
-0
PersonnelStatisticsExportExcel.java
...p/excel/perstatistics/PersonnelStatisticsExportExcel.java
+34
-0
PersonnelStatisticsQueryParam.java
...pp/param/perstatistics/PersonnelStatisticsQueryParam.java
+30
-0
PersonnelStatisticsService.java
...app/service/perstatistics/PersonnelStatisticsService.java
+39
-0
PersonnelStatisticsServiceImpl.java
...ce/perstatistics/impl/PersonnelStatisticsServiceImpl.java
+137
-0
PersonnelStatisticsVo.java
...om/yiring/app/vo/perstatistics/PersonnelStatisticsVo.java
+39
-0
PersonnelStatisticsController.java
.../app/web/perstatistics/PersonnelStatisticsController.java
+56
-0
没有找到文件。
app/src/main/java/com/yiring/app/domain/perstatistics/PersonnelStatistics.java
0 → 100644
浏览文件 @
8d81b301
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
perstatistics
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
javax.persistence.*
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
import
lombok.experimental.FieldNameConstants
;
import
org.hibernate.annotations.Comment
;
import
org.hibernate.annotations.CreationTimestamp
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.hibernate.annotations.UpdateTimestamp
;
import
org.hibernate.snowflake.SnowflakeId
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/15 9:15
*/
@Getter
@Setter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
@Entity
@Table
(
name
=
"BS_PERSONNEL_STATISTICS"
)
@Comment
(
"区域人员统计"
)
public
class
PersonnelStatistics
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
1276138943241366605L
;
@Id
@Comment
(
"主键id"
)
@GeneratedValue
(
generator
=
SnowflakeId
.
GENERATOR
)
@GenericGenerator
(
name
=
SnowflakeId
.
GENERATOR
,
strategy
=
SnowflakeId
.
Strategy
.
LONG
)
Long
id
;
@Comment
(
"区域"
)
String
region
;
@Comment
(
"入场人数"
)
String
admissionNumber
;
@Comment
(
"出场人数"
)
String
attendance
;
@Comment
(
"创建时间"
)
@CreationTimestamp
LocalDateTime
createTime
;
@Comment
(
"修改时间"
)
@UpdateTimestamp
LocalDateTime
updateTime
;
}
app/src/main/java/com/yiring/app/domain/perstatistics/PersonnelStatisticsRepository.java
0 → 100644
浏览文件 @
8d81b301
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
domain
.
perstatistics
;
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
* @version 1.0
* @description:
* @date 2022/5/15 9:20
*/
@Repository
public
interface
PersonnelStatisticsRepository
extends
JpaRepository
<
PersonnelStatistics
,
Serializable
>,
JpaSpecificationExecutor
<
PersonnelStatistics
>
{}
app/src/main/java/com/yiring/app/excel/perstatistics/PersonnelStatisticsExportExcel.java
0 → 100644
浏览文件 @
8d81b301
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
excel
.
perstatistics
;
import
com.github.liaochong.myexcel.core.annotation.ExcelColumn
;
import
java.io.Serial
;
import
java.io.Serializable
;
import
lombok.*
;
import
lombok.experimental.FieldDefaults
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/15 9:55
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
PersonnelStatisticsExportExcel
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
6466089255235570264L
;
@ExcelColumn
(
title
=
"区域"
,
width
=
10
)
String
region
;
@ExcelColumn
(
title
=
"入场人数"
,
width
=
5
)
String
admissionNumber
;
@ExcelColumn
(
title
=
"出场人数"
,
width
=
5
)
String
attendance
;
}
app/src/main/java/com/yiring/app/param/perstatistics/PersonnelStatisticsQueryParam.java
0 → 100644
浏览文件 @
8d81b301
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
param
.
perstatistics
;
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/15 9:15
*/
@ApiModel
(
"PersonnelStatisticsQueryParam"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
PersonnelStatisticsQueryParam
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
638192778218413746L
;
@ApiModelProperty
(
value
=
"区域"
,
example
=
"化工区"
)
String
region
;
}
app/src/main/java/com/yiring/app/service/perstatistics/PersonnelStatisticsService.java
0 → 100644
浏览文件 @
8d81b301
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
service
.
perstatistics
;
import
com.yiring.app.param.perstatistics.PersonnelStatisticsQueryParam
;
import
com.yiring.app.vo.perstatistics.PersonnelStatisticsVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.vo.PageVo
;
import
javax.servlet.http.HttpServletResponse
;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/15 9:27
*/
public
interface
PersonnelStatisticsService
{
/**
* 分页查询
* @author tzl
* @date 2022/5/15 9:41
* @param personnelStatisticsQueryParam PersonnelStatisticsQueryParam
* @param pageParam PageParam
* @return com.yiring.common.core.Result<com.yiring.common.vo.PageVo<com.yiring.app.vo.perstatistics.PersonnelStatisticsVo>>
*/
Result
<
PageVo
<
PersonnelStatisticsVo
>>
pagePerSta
(
PersonnelStatisticsQueryParam
personnelStatisticsQueryParam
,
PageParam
pageParam
);
/**
* 导出人员统计
* @author tzl
* @date 2022/5/15 9:56
* @param personnelStatisticsQueryParam PersonnelStatisticsQueryParam
* @param response HttpServletResponse
*/
void
export
(
PersonnelStatisticsQueryParam
personnelStatisticsQueryParam
,
HttpServletResponse
response
);
}
app/src/main/java/com/yiring/app/service/perstatistics/impl/PersonnelStatisticsServiceImpl.java
0 → 100644
浏览文件 @
8d81b301
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
service
.
perstatistics
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder
;
import
com.yiring.app.domain.perstatistics.PersonnelStatistics
;
import
com.yiring.app.domain.perstatistics.PersonnelStatisticsRepository
;
import
com.yiring.app.excel.perstatistics.PersonnelStatisticsExportExcel
;
import
com.yiring.app.param.perstatistics.PersonnelStatisticsQueryParam
;
import
com.yiring.app.service.perstatistics.PersonnelStatisticsService
;
import
com.yiring.app.vo.perstatistics.PersonnelStatisticsVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.vo.PageVo
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.persistence.criteria.Order
;
import
javax.persistence.criteria.Predicate
;
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.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
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/15 9:28
*/
@Slf4j
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
@Service
public
class
PersonnelStatisticsServiceImpl
implements
PersonnelStatisticsService
{
@Resource
PersonnelStatisticsRepository
personnelStatisticsRepository
;
@Override
public
Result
<
PageVo
<
PersonnelStatisticsVo
>>
pagePerSta
(
PersonnelStatisticsQueryParam
personnelStatisticsQueryParam
,
PageParam
pageParam
)
{
//分页
Pageable
pageable
=
PageRequest
.
of
(
pageParam
.
getPageNo
()
-
1
,
pageParam
.
getPageSize
());
Page
<
PersonnelStatistics
>
all
=
personnelStatisticsRepository
.
findAll
(
condition
(
personnelStatisticsQueryParam
),
pageable
);
List
<
PersonnelStatisticsVo
>
data
=
all
.
get
()
.
map
(
personnelStatistics
->
{
PersonnelStatisticsVo
vo
=
new
PersonnelStatisticsVo
();
BeanUtils
.
copyProperties
(
personnelStatistics
,
vo
);
return
vo
;
})
.
collect
(
Collectors
.
toList
());
PageVo
<
PersonnelStatisticsVo
>
resultVo
=
PageVo
.
build
(
data
,
all
.
getTotalElements
());
return
Result
.
ok
(
resultVo
);
}
@Override
public
void
export
(
PersonnelStatisticsQueryParam
personnelStatisticsQueryParam
,
HttpServletResponse
response
)
{
List
<
PersonnelStatistics
>
all
=
personnelStatisticsRepository
.
findAll
(
condition
(
personnelStatisticsQueryParam
));
List
<
PersonnelStatisticsExportExcel
>
visitorExportExcels
=
all
.
stream
()
.
map
(
personnelStatistics
->
{
PersonnelStatisticsExportExcel
personnelStatisticsExportExcel
=
new
PersonnelStatisticsExportExcel
();
BeanUtils
.
copyProperties
(
personnelStatistics
,
personnelStatisticsExportExcel
);
return
personnelStatisticsExportExcel
;
})
.
toList
();
try
(
DefaultStreamExcelBuilder
<
PersonnelStatisticsExportExcel
>
defaultStreamExcelBuilder
=
DefaultStreamExcelBuilder
.
of
(
PersonnelStatisticsExportExcel
.
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
(
visitorExportExcels
);
String
fileName
=
URLEncoder
.
encode
(
"人员统计.xlsx"
,
StandardCharsets
.
UTF_8
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
fileName
);
OutputStream
out
=
response
.
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
<
PersonnelStatistics
>
condition
(
PersonnelStatisticsQueryParam
personnelStatisticsQueryParam
)
{
return
(
root
,
query
,
criteriaBuilder
)
->
{
List
<
Predicate
>
list
=
new
ArrayList
<>();
//查询条件
if
(
StrUtil
.
isNotBlank
(
personnelStatisticsQueryParam
.
getRegion
()))
{
//区域查询
list
.
add
(
criteriaBuilder
.
like
(
root
.
get
(
PersonnelStatistics
.
Fields
.
region
),
"%"
+
personnelStatisticsQueryParam
.
getRegion
()
+
"%"
)
);
}
Order
order
=
criteriaBuilder
.
desc
(
root
.
get
(
PersonnelStatistics
.
Fields
.
updateTime
));
Predicate
[]
predicates
=
new
Predicate
[
list
.
size
()];
query
.
orderBy
(
order
);
query
.
where
(
list
.
toArray
(
predicates
));
return
criteriaBuilder
.
and
(
list
.
toArray
(
predicates
));
};
}
}
app/src/main/java/com/yiring/app/vo/perstatistics/PersonnelStatisticsVo.java
0 → 100644
浏览文件 @
8d81b301
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
vo
.
perstatistics
;
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/15 9:15
*/
@ApiModel
(
"PersonnelStatisticsVo"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
)
public
class
PersonnelStatisticsVo
implements
Serializable
{
@Serial
private
static
final
long
serialVersionUID
=
-
5973651085056867803L
;
@ApiModelProperty
(
value
=
"主键id"
,
example
=
"1"
)
Long
id
;
@ApiModelProperty
(
value
=
"区域"
,
example
=
"化工区"
)
String
region
;
@ApiModelProperty
(
value
=
"入场人数"
,
example
=
"10"
)
String
admissionNumber
;
@ApiModelProperty
(
value
=
"出场人数"
,
example
=
"5"
)
String
attendance
;
}
app/src/main/java/com/yiring/app/web/perstatistics/PersonnelStatisticsController.java
0 → 100644
浏览文件 @
8d81b301
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
app
.
web
.
perstatistics
;
import
com.yiring.app.param.perstatistics.PersonnelStatisticsQueryParam
;
import
com.yiring.app.service.perstatistics.PersonnelStatisticsService
;
import
com.yiring.app.vo.perstatistics.PersonnelStatisticsVo
;
import
com.yiring.common.core.Result
;
import
com.yiring.common.param.PageParam
;
import
com.yiring.common.vo.PageVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
javax.annotation.Resource
;
import
javax.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/15 9:49
*/
@Slf4j
@Validated
@Api
(
tags
=
"personnelStatistics(人员统计)"
)
@RestController
@RequestMapping
(
"/personnelStatistics/"
)
public
class
PersonnelStatisticsController
{
@Resource
PersonnelStatisticsService
personnelStatisticsService
;
@ApiOperation
(
value
=
"分页查询人员统计"
)
@GetMapping
(
"pagePerSta"
)
public
Result
<
PageVo
<
PersonnelStatisticsVo
>>
pagePerSta
(
@Valid
PersonnelStatisticsQueryParam
personnelStatisticsQueryParam
,
@Valid
PageParam
pageParam
)
{
return
personnelStatisticsService
.
pagePerSta
(
personnelStatisticsQueryParam
,
pageParam
);
}
@ApiOperation
(
value
=
"导出"
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
@PostMapping
(
"export"
)
public
void
exportVideo
(
HttpServletResponse
response
,
@Valid
PersonnelStatisticsQueryParam
personnelStatisticsQueryParam
)
{
personnelStatisticsService
.
export
(
personnelStatisticsQueryParam
,
response
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论