Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
work_service
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
work_service
Commits
ec039315
Commit
ec039315
authored
Jan 29, 2021
by
nie'hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加导出
parent
1346ecd3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
180 additions
and
34 deletions
+180
-34
WorkTimeOrderMapper.java
...rc/main/java/cn/wisenergy/mapper/WorkTimeOrderMapper.java
+2
-2
WorkUserMapper.java
...per/src/main/java/cn/wisenergy/mapper/WorkUserMapper.java
+3
-0
WorkTimeOrderMapper.xml
...-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
+7
-3
WorkUserMapper.xml
...nergy-mapper/src/main/resources/mapper/WorkUserMapper.xml
+8
-0
DayWorkTimeAndType.java
.../main/java/cn/wisenergy/model/dto/DayWorkTimeAndType.java
+9
-3
StatisticsService.java
...src/main/java/cn/wisenergy/service/StatisticsService.java
+9
-0
StatisticsServiceImpl.java
...java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
+109
-26
StatisticsController.java
...energy/web/admin/controller/app/StatisticsController.java
+33
-0
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/WorkTimeOrderMapper.java
View file @
ec039315
...
...
@@ -51,10 +51,10 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/**
* @param year
* @param month
* @param userId
* @param userId
s
* @return
*/
List
<
DayWorkTimeAndType
>
listByDateAndUserId
(
@Param
(
"year"
)
Integer
year
,
@Param
(
"month"
)
Integer
month
,
@Param
(
"userId
"
)
Integer
userId
);
List
<
DayWorkTimeAndType
>
listByDateAndUserId
(
@Param
(
"year"
)
Integer
year
,
@Param
(
"month"
)
Integer
month
,
@Param
(
"userId
s"
)
List
<
Integer
>
userIds
);
/**
...
...
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/WorkUserMapper.java
View file @
ec039315
package
cn
.
wisenergy
.
mapper
;
import
cn.wisenergy.model.app.WorkUser
;
import
cn.wisenergy.model.dto.StatisticsTableDto
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -26,5 +28,6 @@ public interface WorkUserMapper extends BaseMapper<WorkUser> {
Integer
updateUserInfo
(
WorkUser
user
);
List
<
StatisticsTableDto
>
getStatisticsTableDtos
(
List
<
Integer
>
userIds
);
}
wisenergy-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
View file @
ec039315
...
...
@@ -47,6 +47,7 @@
</sql>
<resultMap
id=
"dayWorkTimeAndType"
type=
"cn.wisenergy.model.dto.DayWorkTimeAndType"
>
<result
property=
"userId"
column=
"user_id"
/>
<result
property=
"day"
column=
"day(work_day)"
/>
<result
property=
"type"
column=
"type"
/>
<result
property=
"workTime"
column=
"sum(work_time)"
/>
...
...
@@ -143,10 +144,13 @@
</select>
<select
id=
"listByDateAndUserId"
resultMap=
"dayWorkTimeAndType"
>
select user_id,day(work_day),CASE when `type` = 3 then
1 when `type` = 4 then 2 else 0
end AS `type`, sum(work_time)
select user_id,day(work_day),CASE when `type` = 3 then
"请假" when `type` = 4 then "调休" else "正常"
end AS `type`, sum(work_time)
from
<include
refid=
"table"
/>
where year(work_day) = #{year} AND month(work_day) = #{month} AND user_id = #{userId} AND status in (2,5)
group by user_id,day(work_day), CASE when `type` = 3 then 1 when `type` = 4 then 2 else 0 end
where year(work_day) = #{year} AND month(work_day) = #{month} AND (status = 2 OR status=5)AND user_id IN
<foreach
collection=
"userIds"
separator=
","
close=
")"
item=
"userId"
open=
"("
>
#{userId}
</foreach>
group by user_id,day(work_day), CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else "正常" end
order by day(work_day)
</select>
...
...
wisenergy-mapper/src/main/resources/mapper/WorkUserMapper.xml
View file @
ec039315
...
...
@@ -85,6 +85,14 @@
from
<include
refid=
"table"
/>
where id = #{userId}
</select>
<select
id=
"getStatisticsTableDtos"
resultType=
"cn.wisenergy.model.dto.StatisticsTableDto"
>
select u.id AS user_id, u.name AS dept_name, d.dept_name
from work_user u join work_dept d on u.dept_id=d.id
where u.id in
<foreach
collection=
"list"
open=
"("
close=
")"
separator=
","
item=
"id"
>
#{id}
</foreach>
</select>
<update
id=
"updateUserInfo"
parameterType=
"cn.wisenergy.model.app.WorkUser"
>
update
<include
refid=
"table"
/>
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/dto/DayWorkTimeAndType.java
View file @
ec039315
...
...
@@ -17,6 +17,12 @@ public class DayWorkTimeAndType implements Serializable {
private
static
final
long
serialVersionUID
=
1198786417184957375L
;
/**
* 用户主键
*/
@ApiModelProperty
(
name
=
"userId"
,
value
=
"用户主键"
)
private
Integer
userId
;
/**
* 日期中的日
*/
...
...
@@ -24,10 +30,10 @@ public class DayWorkTimeAndType implements Serializable {
private
Integer
day
;
/**
* 工时类型,
0:正常,1:请假,2:
调休
* 工时类型,
正常,请假,
调休
*/
@ApiModelProperty
(
name
=
"type"
,
value
=
"工时类型,
0:正常,1:请假,2:
调休"
)
private
Integer
type
;
@ApiModelProperty
(
name
=
"type"
,
value
=
"工时类型,
正常,请假,
调休"
)
private
String
type
;
/**
* 工时
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/StatisticsService.java
View file @
ec039315
...
...
@@ -3,6 +3,7 @@ package cn.wisenergy.service;
import
cn.wisenergy.model.dto.GetMonthlyCollectParam
;
import
cn.wisenergy.model.dto.WorkTimeAndCostCollect
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
java.util.List
;
...
...
@@ -27,4 +28,12 @@ public interface StatisticsService {
* @param userId
*/
List
<
WorkTimeAndCostCollect
>
getCurrentMonthWorkTimeCollect
(
Integer
userId
,
String
startTime
);
/**
* 导出一个部门下员工一个月中每天的工时
* @param param
* @return
*/
HSSFWorkbook
exportWorkTimeExcel
(
GetMonthlyCollectParam
param
);
}
wisenergy-service/src/main/java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
View file @
ec039315
This diff is collapsed.
Click to expand it.
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/StatisticsController.java
View file @
ec039315
...
...
@@ -14,11 +14,15 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.net.URLEncoder
;
import
java.util.List
;
/**
...
...
@@ -77,4 +81,33 @@ public class StatisticsController extends BaseController {
return
getResult
(
monthlyStatistics
);
}
@ApiOperation
(
value
=
"导出部门员工一个月每天的工时"
,
notes
=
"导出部门员工一个月每天的工时"
)
@GetMapping
(
"/exportWorkTime"
)
public
void
export
(
GetMonthlyCollectParam
param
,
HttpServletResponse
response
)
{
log
.
info
(
"StatisticsController[]getDeptInfo[]input.param"
+
param
);
// 获取excel
HSSFWorkbook
sheets
=
statisticsService
.
exportWorkTimeExcel
(
param
);
// 获取excel中的第2行第2列中的部门名称
String
deptName
=
sheets
.
getSheet
(
"Sheet1"
).
getRow
(
1
).
getCell
(
1
).
getStringCellValue
();
// 文件名
String
fileName
=
deptName
+
"-"
+
param
.
getYear
()
+
"-"
+
param
.
getMonth
();
//响应类型为application/octet- stream情况下使用了这个头信息的话,那就意味着不想直接显示内容
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
//attachment为以附件方式下载
try
{
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
fileName
+
".xls"
,
"utf-8"
));
response
.
setHeader
(
"Cache-Control"
,
"No-cache"
);
response
.
flushBuffer
();
sheets
.
write
(
response
.
getOutputStream
());
sheets
.
close
();
}
catch
(
Exception
e
)
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
SERVER_ERROR
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment