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
58d94ca6
Commit
58d94ca6
authored
4 years ago
by
nie'hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善工时统计
parent
7b0cd554
chenqi5.0
chenqi
chenqi2.0
chenqi3.0
chenqi4.0
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
27 deletions
+52
-27
WorkTimeOrderMapper.xml
...-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
+27
-4
WorkType.java
...-model/src/main/java/cn/wisenergy/model/app/WorkType.java
+0
-2
StatisticsServiceImpl.java
...java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
+25
-21
No files found.
wisenergy-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
View file @
58d94ca6
...
@@ -262,9 +262,9 @@
...
@@ -262,9 +262,9 @@
SELECT t.type AS type, d.id AS dept_id,dept_name,
SELECT t.type AS type, d.id AS dept_id,dept_name,
IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day),
IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day),
'年')) AS statistics_time ,SUM(t.work_time)/8 AS
'年')) AS statistics_time ,SUM(t.work_time)/8 AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost
total_time, SUM(t.work_time * s.day_salary)/8 AS cost
,ty.sort AS ty_sort, d.sort AS d_sort
FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id join work_type ty on t.type = ty.id
FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id join work_type ty on t.type = ty.id
WHERE t.status IN (2,5) AND s.create_time
<
t.work_day AND s.end_time > t.work_day
WHERE t.status IN (2,5) AND s.create_time
<
t.work_day AND s.end_time > t.work_day
AND year(t.work_day)
<
year(NOW())
<if
test=
"firstDayOfMonth != null"
>
<if
test=
"firstDayOfMonth != null"
>
AND work_day >= #{firstDayOfMonth}
AND work_day >= #{firstDayOfMonth}
</if>
</if>
...
@@ -278,8 +278,31 @@
...
@@ -278,8 +278,31 @@
<if
test=
"centreId != null"
>
<if
test=
"centreId != null"
>
AND centre_id = #{centreId}
AND centre_id = #{centreId}
</if>
</if>
group by t.type,d.id, dept_name, if(YEAR (work_day) = YEAR(NOW()),',month(work_day)','')
group by t.type,d.id, dept_name,year(work_day)
order by d.id,work_day,ty.sort
union
SELECT t.type AS type, d.id AS dept_id,dept_name,
IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day),
'年')) AS statistics_time ,SUM(t.work_time)/8 AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost,ty.sort AS ty_sort, d.sort AS d_sort
FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id join work_type ty on t.type = ty.id
WHERE t.status IN (2,5) AND s.create_time
<
t.work_day AND s.end_time > t.work_day AND year(t.work_day) = year(NOW())
<if
test=
"firstDayOfMonth != null"
>
AND work_day >= #{firstDayOfMonth}
</if>
<if
test=
"deptId != null"
>
AND t.dept_id = #{deptId}
</if>
AND t.type in
<foreach
collection=
"types"
item=
"type"
open=
"("
close=
")"
separator=
","
>
#{type}
</foreach>
<if
test=
"centreId != null"
>
AND centre_id = #{centreId}
</if>
group by t.type,d.id, dept_name,month(work_day)
ORDER BY ty_sort, d_sort, statistics_time
</select>
</select>
<select
id=
"getDaysByDateAndStatus"
resultType=
"date"
>
<select
id=
"getDaysByDateAndStatus"
resultType=
"date"
>
...
...
This diff is collapsed.
Click to expand it.
wisenergy-model/src/main/java/cn/wisenergy/model/app/WorkType.java
View file @
58d94ca6
...
@@ -38,8 +38,6 @@ public class WorkType implements Serializable, Comparable<WorkType>{
...
@@ -38,8 +38,6 @@ public class WorkType implements Serializable, Comparable<WorkType>{
private
Integer
sort
;
private
Integer
sort
;
@Override
@Override
public
int
compareTo
(
WorkType
o
)
{
public
int
compareTo
(
WorkType
o
)
{
...
...
This diff is collapsed.
Click to expand it.
wisenergy-service/src/main/java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
View file @
58d94ca6
...
@@ -11,6 +11,7 @@ import cn.wisenergy.model.app.*;
...
@@ -11,6 +11,7 @@ import cn.wisenergy.model.app.*;
import
cn.wisenergy.model.dto.*
;
import
cn.wisenergy.model.dto.*
;
import
cn.wisenergy.model.enums.*
;
import
cn.wisenergy.model.enums.*
;
import
cn.wisenergy.service.StatisticsService
;
import
cn.wisenergy.service.StatisticsService
;
import
cn.wisenergy.service.WorkTypeService
;
import
cn.wisenergy.service.WorkUserService
;
import
cn.wisenergy.service.WorkUserService
;
import
cn.wisenergy.service.utils.UserRoleLevelUtils
;
import
cn.wisenergy.service.utils.UserRoleLevelUtils
;
import
com.alibaba.excel.util.StringUtils
;
import
com.alibaba.excel.util.StringUtils
;
...
@@ -71,6 +72,9 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -71,6 +72,9 @@ public class StatisticsServiceImpl implements StatisticsService {
@Autowired
@Autowired
private
WorkDeptMapper
workDeptMapper
;
private
WorkDeptMapper
workDeptMapper
;
@Autowired
private
WorkTypeService
workTypeService
;
private
final
static
Integer
EXCEL_WIDTH
=
1000
*
6
;
private
final
static
Integer
EXCEL_WIDTH
=
1000
*
6
;
...
@@ -233,18 +237,20 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -233,18 +237,20 @@ public class StatisticsServiceImpl implements StatisticsService {
List
<
Integer
>
types
=
monthlyWorkingHoursStatistics
.
stream
().
map
(
MonthlyWorkingHoursStatistics:
:
getProjectType
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
types
=
monthlyWorkingHoursStatistics
.
stream
().
map
(
MonthlyWorkingHoursStatistics:
:
getProjectType
).
collect
(
Collectors
.
toList
());
// 如果没填写填报类型其中某项,造对象传前端
// 如果没填写填报类型其中某项,造对象传前端
List
<
WorkType
>
workTypes
=
workType
Mapper
.
getAll
(
);
List
<
WorkType
>
workTypes
=
workType
Service
.
getAll
(
1
);
if
(
monthlyWorkingHoursStatistics
.
size
()
<
workTypes
.
size
())
{
if
(
monthlyWorkingHoursStatistics
.
size
()
<
workTypes
.
size
())
{
for
(
WorkType
workType
:
workTypes
)
{
for
(
int
i
=
0
;
i
<
workTypes
.
size
();
i
++)
{
WorkType
workType
=
workTypes
.
get
(
i
);
if
(!
types
.
contains
(
workType
.
getId
()))
{
if
(!
types
.
contains
(
workType
.
getId
()))
{
MonthlyWorkingHoursStatistics
workingHoursStatistics
=
new
MonthlyWorkingHoursStatistics
();
MonthlyWorkingHoursStatistics
workingHoursStatistics
=
new
MonthlyWorkingHoursStatistics
();
workingHoursStatistics
.
setTypeName
(
workType
.
getName
());
workingHoursStatistics
.
setTypeName
(
workType
.
getName
());
workingHoursStatistics
.
setProjectType
(
workType
.
getId
());
workingHoursStatistics
.
setProjectType
(
workType
.
getId
());
workingHoursStatistics
.
setCount
(
0
);
workingHoursStatistics
.
setCount
(
0
);
workingHoursStatistics
.
setWorkTime
(
0
);
workingHoursStatistics
.
setWorkTime
(
0
);
monthlyWorkingHoursStatistics
.
add
(
workingHoursStatistics
);
monthlyWorkingHoursStatistics
.
add
(
i
,
workingHoursStatistics
);
}
}
}
}
}
}
// 赋值未填报天数、被驳回未重报天
// 赋值未填报天数、被驳回未重报天
...
@@ -286,7 +292,7 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -286,7 +292,7 @@ public class StatisticsServiceImpl implements StatisticsService {
List
<
Integer
>
rank
=
this
.
getUserRank
(
roleUserLevel
,
LevelEnum
.
PROJECT_STATISTICS
.
getLevelName
());
List
<
Integer
>
rank
=
this
.
getUserRank
(
roleUserLevel
,
LevelEnum
.
PROJECT_STATISTICS
.
getLevelName
());
// 获取所有的类型
// 获取所有的类型
List
<
WorkType
>
workTypes
=
workType
Mapper
.
getAll
(
);
List
<
WorkType
>
workTypes
=
workType
Service
.
getAll
(
1
);
// 存储查询的类型
// 存储查询的类型
List
<
Integer
>
types
=
new
ArrayList
<>();
List
<
Integer
>
types
=
new
ArrayList
<>();
// 只存储项目和商机之外的类型
// 只存储项目和商机之外的类型
...
@@ -331,18 +337,17 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -331,18 +337,17 @@ public class StatisticsServiceImpl implements StatisticsService {
}
}
// 获取查询结果中的类型
// 获取查询结果中的类型
List
<
Integer
>
typeList
=
workTimeAndCostCollects
.
stream
().
map
(
WorkTimeAndCostCollect:
:
getType
).
collect
(
Collectors
.
toList
());
if
(!
rank
.
contains
(
LevelRankEnum
.
PROJECT_LEVEL
.
getRank
()))
{
// 如果查询结果不包含查询条件中的类型,造对象传前端
List
<
Integer
>
typeList
=
workTimeAndCostCollects
.
stream
().
map
(
WorkTimeAndCostCollect:
:
getType
).
collect
(
Collectors
.
toList
());
for
(
WorkType
workType
:
workTypes
)
{
// 如果查询结果不包含查询条件中的类型,造对象传前端
if
(!
typeList
.
contains
(
workType
.
getId
()))
{
for
(
int
i
=
0
;
i
<
workTypes
.
size
();
i
++)
{
// 权限级别为项目级别的用户只返回项目和商机类型的汇总
WorkType
workType
=
workTypes
.
get
(
i
);
if
(
rank
.
contains
(
LevelRankEnum
.
PROJECT_LEVEL
.
getRank
())
&&
rank
.
size
()
==
1
&&
types
.
contains
(
workType
.
getId
()))
{
if
(!
typeList
.
contains
(
workType
.
getId
()))
{
continue
;
WorkTimeAndCostCollect
workTimeAndCostCollect1
=
new
WorkTimeAndCostCollect
();
workTimeAndCostCollect1
.
setType
(
workType
.
getId
());
workTimeAndCostCollect1
.
setTypeName
(
workType
.
getName
());
workTimeAndCostCollects
.
add
(
i
,
workTimeAndCostCollect1
);
}
}
WorkTimeAndCostCollect
workTimeAndCostCollect1
=
new
WorkTimeAndCostCollect
();
workTimeAndCostCollect1
.
setType
(
workType
.
getId
());
workTimeAndCostCollect1
.
setTypeName
(
workType
.
getName
());
workTimeAndCostCollects
.
add
(
workTimeAndCostCollect1
);
}
}
}
}
...
@@ -798,14 +803,12 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -798,14 +803,12 @@ public class StatisticsServiceImpl implements StatisticsService {
HSSFCell
cell2
=
totalRow1
.
createCell
((
i
+
1
)
*
2
+
1
);
HSSFCell
cell2
=
totalRow1
.
createCell
((
i
+
1
)
*
2
+
1
);
cell2
.
setCellValue
(
projectWorkTimeAndType
.
get
(
i
).
getOverTime
());
cell2
.
setCellValue
(
projectWorkTimeAndType
.
get
(
i
).
getOverTime
());
}
else
{
}
else
{
//
加班工时和正常工时行最后的
//
合计行最后的列
short
lastCellNum
=
row_2
.
getLastCellNum
();
short
lastCellNum
=
totalRow1
.
getLastCellNum
();
// 调休和请假的类型名单元格
// 调休和请假的类型名单元格
row_1Cell
=
row_1
.
createCell
(
lastCellNum
);
row_1Cell
=
row_1
.
createCell
(
lastCellNum
);
// 请假或调休的总计单元格
// 请假或调休的总计单元格
totalRow2Cell
=
totalRow2
.
createCell
(
lastCellNum
);
totalRow2Cell
=
totalRow2
.
createCell
(
lastCellNum
);
// 类型名称
row_1Cell
.
setCellValue
(
projectWorkTimeAndType
.
get
(
i
).
getProjectName
());
// 请假或调休合计
// 请假或调休合计
HSSFCell
cell1
=
totalRow1
.
createCell
(
lastCellNum
);
HSSFCell
cell1
=
totalRow1
.
createCell
(
lastCellNum
);
cell1
.
setCellValue
(
projectWorkTimeAndType
.
get
(
i
).
getNormalTime
());
cell1
.
setCellValue
(
projectWorkTimeAndType
.
get
(
i
).
getNormalTime
());
...
@@ -880,8 +883,9 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -880,8 +883,9 @@ public class StatisticsServiceImpl implements StatisticsService {
CellRangeAddress
cellRangeAddress3
=
new
CellRangeAddress
(
userWorkTimeStatisticsReport
.
size
()
+
1
,
userWorkTimeStatisticsReport
.
size
()
+
1
,
0
,
1
);
CellRangeAddress
cellRangeAddress3
=
new
CellRangeAddress
(
userWorkTimeStatisticsReport
.
size
()
+
1
,
userWorkTimeStatisticsReport
.
size
()
+
1
,
0
,
1
);
sheet1
.
addMergedRegion
(
cellRangeAddress3
);
sheet1
.
addMergedRegion
(
cellRangeAddress3
);
setBorderStyle
(
BorderStyle
.
THIN
,
cellRangeAddress3
,
sheet1
);
setBorderStyle
(
BorderStyle
.
THIN
,
cellRangeAddress3
,
sheet1
);
// 项目行和总计行
// 项目行和总计行,正常工时和加班工时表头列数
for
(
int
i
=
0
;
i
<
row1_lastCellNum
/
2
-
1
;
i
++)
{
short
lastCellNum
=
row_2
.
getLastCellNum
();
for
(
int
i
=
0
;
i
<
lastCellNum
/
2
;
i
++)
{
// 总计行
// 总计行
CellRangeAddress
cellRangeAddress4
=
new
CellRangeAddress
(
userWorkTimeStatisticsReport
.
size
()
+
2
,
userWorkTimeStatisticsReport
.
size
()
+
2
,
i
*
2
,
i
*
2
+
1
);
CellRangeAddress
cellRangeAddress4
=
new
CellRangeAddress
(
userWorkTimeStatisticsReport
.
size
()
+
2
,
userWorkTimeStatisticsReport
.
size
()
+
2
,
i
*
2
,
i
*
2
+
1
);
sheet1
.
addMergedRegion
(
cellRangeAddress4
);
sheet1
.
addMergedRegion
(
cellRangeAddress4
);
...
...
This diff is collapsed.
Click to expand it.
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