Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
e289fd64
Commit
e289fd64
authored
Feb 10, 2021
by
nie'hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
人员工时统计报表,项目统计报表
parent
02912147
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
146 additions
and
62 deletions
+146
-62
BASE_RESP_CODE_ENUM.java
...wisenergy/common/utils/exception/BASE_RESP_CODE_ENUM.java
+1
-0
WorkProjectMapper.xml
...gy-mapper/src/main/resources/mapper/WorkProjectMapper.xml
+3
-2
WorkProjectTimeCost.xml
...-mapper/src/main/resources/mapper/WorkProjectTimeCost.xml
+6
-6
WorkUserRoleMapper.xml
...y-mapper/src/main/resources/mapper/WorkUserRoleMapper.xml
+1
-0
StatisticsService.java
...src/main/java/cn/wisenergy/service/StatisticsService.java
+4
-3
StatisticsServiceImpl.java
...java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
+123
-44
WorkProjectServiceImpl.java
...ava/cn/wisenergy/service/impl/WorkProjectServiceImpl.java
+8
-6
StatisticsController.java
...energy/web/admin/controller/app/StatisticsController.java
+0
-1
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/exception/BASE_RESP_CODE_ENUM.java
View file @
e289fd64
...
@@ -76,6 +76,7 @@ public enum BASE_RESP_CODE_ENUM {
...
@@ -76,6 +76,7 @@ public enum BASE_RESP_CODE_ENUM {
REPEAT_WITH_OLDTIME
(
"654"
,
"日期与旧时间冲突"
),
REPEAT_WITH_OLDTIME
(
"654"
,
"日期与旧时间冲突"
),
BUDGET_CANNOT_BELESSTHAN_ZERO
(
"655"
,
"预算不能小于0"
),
BUDGET_CANNOT_BELESSTHAN_ZERO
(
"655"
,
"预算不能小于0"
),
ITEMOADUPLICATE
(
"656"
,
"项目OA重复"
),
ITEMOADUPLICATE
(
"656"
,
"项目OA重复"
),
NO_AUTHORITY
(
"657"
,
"暂无该权限"
)
;
;
...
...
wisenergy-mapper/src/main/resources/mapper/WorkProjectMapper.xml
View file @
e289fd64
...
@@ -81,10 +81,10 @@
...
@@ -81,10 +81,10 @@
select
<include
refid=
"Base_Column_List"
/>
select
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"table"
/>
from
<include
refid=
"table"
/>
<where>
<where>
<if
test=
"manager
_i
d != null"
>
<if
test=
"manager
I
d != null"
>
manager_id = #{managerId}
manager_id = #{managerId}
</if>
</if>
<if
test=
"dept
_i
d != null"
>
<if
test=
"dept
I
d != null"
>
OR dept_id = #{deptId}
OR dept_id = #{deptId}
</if>
</if>
<if
test=
"deptIds != null"
>
<if
test=
"deptIds != null"
>
...
@@ -95,6 +95,7 @@
...
@@ -95,6 +95,7 @@
</if>
</if>
</where>
</where>
</select>
</select>
<select
id=
"getProjectsByIds"
resultType=
"cn.wisenergy.model.app.WorkProject"
>
<select
id=
"getProjectsByIds"
resultType=
"cn.wisenergy.model.app.WorkProject"
>
select
<include
refid=
"Base_Column_List"
/>
select
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"table"
/>
from
<include
refid=
"table"
/>
...
...
wisenergy-mapper/src/main/resources/mapper/WorkProjectTimeCost.xml
View file @
e289fd64
...
@@ -50,20 +50,20 @@
...
@@ -50,20 +50,20 @@
INSERT INTO work_project_time_cost (
INSERT INTO work_project_time_cost (
project_id,
project_id,
user_id,
user_id,
is_overtime,
statistics_start,
statistics_start,
statistics_end,
statistics_end,
total_time,
total_time,
cost
cost,
create_time
)
)
SELECT
SELECT
project_id,
project_id,
t.user_id,
t.user_id,
is_overtime,
min(work_day),
min(work_day),
max(work_day),
max(work_day),
sum(work_time / 8),
sum(work_time / 8),
sum(work_time / 8 * s.day_salary)
sum(work_time / 8 * s.day_salary),
now() AS create_time
FROM
FROM
work_time_order t
work_time_order t
JOIN work_user_salary s ON t.user_id = s.user_id
JOIN work_user_salary s ON t.user_id = s.user_id
...
@@ -76,8 +76,8 @@
...
@@ -76,8 +76,8 @@
is_overtime,
is_overtime,
YEAR (work_day),
YEAR (work_day),
MONTH (work_day)
MONTH (work_day)
ON DUPLICATE KEY UPDATE
is_over
time =
ON DUPLICATE KEY UPDATE
create_
time =
VALUES(
is_over
time),
VALUES(
create_
time),
statistics_end =
statistics_end =
VALUES(statistics_end),
VALUES(statistics_end),
total_time =
total_time =
...
...
wisenergy-mapper/src/main/resources/mapper/WorkUserRoleMapper.xml
View file @
e289fd64
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
FROM work_user_role
FROM work_user_role
WHERE user_id = #{userId}
WHERE user_id = #{userId}
</select>
</select>
<select
id=
"getRoleUserLevel"
resultType=
"cn.wisenergy.model.dto.UserRoleLevelDto"
>
<select
id=
"getRoleUserLevel"
resultType=
"cn.wisenergy.model.dto.UserRoleLevelDto"
>
select ur.user_id as 'user_id',r.id as 'role_id',l.name as 'level_name',l.rank as 'rank'
select ur.user_id as 'user_id',r.id as 'role_id',l.name as 'level_name',l.rank as 'rank'
from work_user_role ur join work_role r on ur.role_id = r.id
from work_user_role ur join work_role r on ur.role_id = r.id
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/StatisticsService.java
View file @
e289fd64
...
@@ -28,7 +28,7 @@ public interface StatisticsService {
...
@@ -28,7 +28,7 @@ public interface StatisticsService {
List
<
Object
>
getMonthlyStatistics
(
Integer
userId
);
List
<
Object
>
getMonthlyStatistics
(
Integer
userId
);
/**
/**
* 获取负责项目
在本月
的工时汇总:花费工时,工时成本
* 获取负责项目的工时汇总:花费工时,工时成本
*
*
* @param userId
* @param userId
*/
*/
...
@@ -44,7 +44,7 @@ public interface StatisticsService {
...
@@ -44,7 +44,7 @@ public interface StatisticsService {
HSSFWorkbook
exportWorkTimeExcel
(
GetMonthlyCollectParam
param
);
HSSFWorkbook
exportWorkTimeExcel
(
GetMonthlyCollectParam
param
);
/**
/**
* 获取用户
所在未结项目的
工时统计
* 获取用户
管理项目人员
工时统计
*
*
* @param startDate
* @param startDate
* @param endDate
* @param endDate
...
@@ -58,7 +58,8 @@ public interface StatisticsService {
...
@@ -58,7 +58,8 @@ public interface StatisticsService {
*
*
* @param userId
* @param userId
* @param deptId
* @param deptId
* @param date
* @param year
* @param projectId
* @return
* @return
*/
*/
List
<
ProjectStatisticsByMonth
>
getProjectStatistics
(
Integer
userId
,
Integer
deptId
,
Integer
year
,
Integer
projectId
);
List
<
ProjectStatisticsByMonth
>
getProjectStatistics
(
Integer
userId
,
Integer
deptId
,
Integer
year
,
Integer
projectId
);
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
View file @
e289fd64
...
@@ -14,6 +14,7 @@ import cn.wisenergy.model.enums.*;
...
@@ -14,6 +14,7 @@ import cn.wisenergy.model.enums.*;
import
cn.wisenergy.service.StatisticsService
;
import
cn.wisenergy.service.StatisticsService
;
import
cn.wisenergy.service.WorkProjectService
;
import
cn.wisenergy.service.WorkProjectService
;
import
cn.wisenergy.service.WorkUserService
;
import
cn.wisenergy.service.WorkUserService
;
import
cn.wisenergy.service.utils.UserRoleLevelUtils
;
import
com.alibaba.excel.util.StringUtils
;
import
com.alibaba.excel.util.StringUtils
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
...
@@ -21,10 +22,7 @@ import com.github.pagehelper.util.StringUtil;
...
@@ -21,10 +22,7 @@ import com.github.pagehelper.util.StringUtil;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.hssf.util.HSSFColor
;
import
org.apache.poi.hssf.util.HSSFColor
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.FillPatternType
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -60,7 +58,7 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -60,7 +58,7 @@ public class StatisticsServiceImpl implements StatisticsService {
private
WorkUserMapper
workUserMapper
;
private
WorkUserMapper
workUserMapper
;
@Autowired
@Autowired
private
WorkProjectMapper
workProjectMapper
;
private
UserRoleLevelUtils
userRoleLevelUtils
;
@Autowired
@Autowired
WorkProjectTimeCostMapper
workProjectTimeCostMapper
;
WorkProjectTimeCostMapper
workProjectTimeCostMapper
;
...
@@ -76,8 +74,8 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -76,8 +74,8 @@ public class StatisticsServiceImpl implements StatisticsService {
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
}
//管理员用户
//管理员用户
WorkUser
user
=
workUserService
.
getById
(
param
.
getUserId
());
List
<
Integer
>
role
=
userRoleLevelUtils
.
getRole
(
param
.
getUserId
());
if
(!
user
.
getLevel
().
equal
s
(
ManagerEnum
.
IS_SYSTEM_MANAGER
.
getCode
()))
{
if
(!
role
.
contain
s
(
ManagerEnum
.
IS_SYSTEM_MANAGER
.
getCode
()))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN
);
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN
);
}
}
//默认时间为当月
//默认时间为当月
...
@@ -134,6 +132,7 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -134,6 +132,7 @@ public class StatisticsServiceImpl implements StatisticsService {
public
List
<
Object
>
getMonthlyStatistics
(
Integer
userId
)
{
public
List
<
Object
>
getMonthlyStatistics
(
Integer
userId
)
{
log
.
info
(
"WorkTimeOrderServiceImpl[]getMonthlyStatistics[]input.param"
+
userId
);
log
.
info
(
"WorkTimeOrderServiceImpl[]getMonthlyStatistics[]input.param"
+
userId
);
WorkUser
user
=
workUserService
.
getById
(
userId
);
WorkUser
user
=
workUserService
.
getById
(
userId
);
List
<
Integer
>
role
=
userRoleLevelUtils
.
getRole
(
user
.
getId
());
//本月第一天
//本月第一天
Date
firstDayOfMonth
=
DateUtil
.
getCurrentFirstDayOfMonth
();
Date
firstDayOfMonth
=
DateUtil
.
getCurrentFirstDayOfMonth
();
//返回数据对象
//返回数据对象
...
@@ -141,7 +140,7 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -141,7 +140,7 @@ public class StatisticsServiceImpl implements StatisticsService {
//存放查询条件
//存放查询条件
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
//用户是项目或部门级别,查询审批统计
//用户是项目或部门级别,查询审批统计
if
(
user
.
getLevel
()
!=
ManagerEnum
.
NOT_MANAGER
.
getCode
(
))
{
if
(
role
.
contains
(
ManagerEnum
.
IS_PROJECT_DIRECTOR
.
getCode
())
||
role
.
contains
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()
))
{
//以审批人、审核状态、开始时间查询本月审批数量
//以审批人、审核状态、开始时间查询本月审批数量
map
.
put
(
"reviewerId"
,
userId
);
map
.
put
(
"reviewerId"
,
userId
);
map
.
put
(
"startDay"
,
firstDayOfMonth
);
map
.
put
(
"startDay"
,
firstDayOfMonth
);
...
@@ -152,7 +151,7 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -152,7 +151,7 @@ public class StatisticsServiceImpl implements StatisticsService {
Integer
rejectAndNotResubmit
=
workTimeOrderMapper
.
getCountByCondition
(
map
);
Integer
rejectAndNotResubmit
=
workTimeOrderMapper
.
getCountByCondition
(
map
);
// 项目级别,获取所管理项目,
// 项目级别,获取所管理项目,
if
(
user
.
getLevel
().
equal
s
(
ManagerEnum
.
IS_PROJECT_DIRECTOR
.
getCode
()))
{
if
(
role
.
contain
s
(
ManagerEnum
.
IS_PROJECT_DIRECTOR
.
getCode
()))
{
List
<
WorkProject
>
projects
=
workProjectService
.
getUserManageProjects
(
userId
);
List
<
WorkProject
>
projects
=
workProjectService
.
getUserManageProjects
(
userId
);
if
(
CollectionUtil
.
isNotEmpty
(
projects
))
{
if
(
CollectionUtil
.
isNotEmpty
(
projects
))
{
List
<
Integer
>
projectIds
=
projects
.
stream
().
map
(
WorkProject:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
projectIds
=
projects
.
stream
().
map
(
WorkProject:
:
getId
).
collect
(
Collectors
.
toList
());
...
@@ -160,7 +159,7 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -160,7 +159,7 @@ public class StatisticsServiceImpl implements StatisticsService {
}
}
}
}
// 部门级别
// 部门级别
if
(
user
.
getLevel
().
equal
s
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()))
{
if
(
role
.
contain
s
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()))
{
map
.
put
(
"deptId"
,
user
.
getDeptId
());
map
.
put
(
"deptId"
,
user
.
getDeptId
());
//填报项目类型编码
//填报项目类型编码
int
[]
workOrderTypeArray
=
{
WorkOrderType
.
EXTERNAL_WORK
.
getCode
(),
WorkOrderType
.
INTERNAL_WORK
.
getCode
(),
WorkOrderType
.
OTHER_NOT_PROJECT_BUSINESS
.
getCode
()};
int
[]
workOrderTypeArray
=
{
WorkOrderType
.
EXTERNAL_WORK
.
getCode
(),
WorkOrderType
.
INTERNAL_WORK
.
getCode
(),
WorkOrderType
.
OTHER_NOT_PROJECT_BUSINESS
.
getCode
()};
...
@@ -244,16 +243,21 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -244,16 +243,21 @@ public class StatisticsServiceImpl implements StatisticsService {
if
(
userId
==
null
)
{
if
(
userId
==
null
)
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
}
WorkUser
user
=
workUserService
.
getById
(
userId
);
// 时间不为空,赋值当月第一天
// 时间不为空,赋值当月第一天
if
(
StringUtil
.
isNotEmpty
(
startTime
))
{
if
(
StringUtil
.
isNotEmpty
(
startTime
))
{
Date
currentFirstDayOfMonth
=
DateUtil
.
getCurrentFirstDayOfMonth
();
Date
currentFirstDayOfMonth
=
DateUtil
.
getCurrentFirstDayOfMonth
();
startTime
=
DateUtil
.
convertDateToYMDStr
(
currentFirstDayOfMonth
);
startTime
=
DateUtil
.
convertDateToYMDStr
(
currentFirstDayOfMonth
);
}
}
WorkUser
user
=
workUserService
.
getById
(
userId
);
// 用户角色
List
<
Integer
>
role
=
userRoleLevelUtils
.
getRole
(
user
.
getId
());
// 普通用户
// 普通用户
if
(
user
.
getLevel
().
equal
s
(
ManagerEnum
.
NOT_MANAGER
.
getCode
()))
{
if
(
role
.
contain
s
(
ManagerEnum
.
NOT_MANAGER
.
getCode
()))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN
);
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN
);
}
}
// 查询用户管理的项目
// 查询用户管理的项目
List
<
WorkProject
>
userManageProjects
=
workProjectService
.
getUserManageProjects
(
userId
);
List
<
WorkProject
>
userManageProjects
=
workProjectService
.
getUserManageProjects
(
userId
);
if
(
CollectionUtil
.
isEmpty
(
userManageProjects
))
{
if
(
CollectionUtil
.
isEmpty
(
userManageProjects
))
{
...
@@ -280,7 +284,7 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -280,7 +284,7 @@ public class StatisticsServiceImpl implements StatisticsService {
List
<
WorkTimeAndCostCollect
>
collect
=
workProjectTimeCostMapper
.
selectList
(
map
);
List
<
WorkTimeAndCostCollect
>
collect
=
workProjectTimeCostMapper
.
selectList
(
map
);
// 部门和中心级别
// 部门和中心级别
if
(
!
user
.
getLevel
().
equals
(
ManagerEnum
.
IS_PROJECT
_DIRECTOR
.
getCode
()))
{
if
(
role
.
contains
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
())
||
role
.
contains
(
ManagerEnum
.
IS_CENTRE
_DIRECTOR
.
getCode
()))
{
// 请假、调休、外部商务、技术交流,内部培训、技术准备、管理,其他非项目/商机工作
// 请假、调休、外部商务、技术交流,内部培训、技术准备、管理,其他非项目/商机工作
types
.
clear
();
types
.
clear
();
map
.
clear
();
map
.
clear
();
...
@@ -290,22 +294,23 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -290,22 +294,23 @@ public class StatisticsServiceImpl implements StatisticsService {
types
.
add
(
value
.
getType
());
types
.
add
(
value
.
getType
());
}
}
}
}
if
(
role
.
contains
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()))
{
if
(
user
.
getLevel
().
equals
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()))
{
map
.
put
(
"deptId"
,
user
.
getDeptId
());
map
.
put
(
"deptId"
,
user
.
getDeptId
());
}
}
map
.
put
(
"types"
,
types
);
map
.
put
(
"types"
,
types
);
List
<
WorkTimeAndCostCollect
>
workTimeAndCostCollect
=
workTimeOrderMapper
.
getWorkTimeAndCostCollect
(
map
);
List
<
WorkTimeAndCostCollect
>
workTimeAndCostCollect
=
workTimeOrderMapper
.
getWorkTimeAndCostCollect
(
map
);
List
<
String
>
typeList
=
workTimeAndCostCollect
.
stream
().
map
(
WorkTimeAndCostCollect:
:
getType
).
collect
(
Collectors
.
toList
());
// 将查询结果封装在一起
// 如果查询结果不包含查询条件中的类型,并且不为项目或商机类型,造对象传前端
collect
.
addAll
(
workTimeAndCostCollect
);
// 获取查询结果中的类型
List
<
String
>
typeList
=
collect
.
stream
().
map
(
WorkTimeAndCostCollect:
:
getType
).
collect
(
Collectors
.
toList
());
// 如果查询结果不包含查询条件中的类型,造对象传前端
for
(
ProjectTypeEnum
value
:
ProjectTypeEnum
.
values
())
{
for
(
ProjectTypeEnum
value
:
ProjectTypeEnum
.
values
())
{
if
(!
typeList
.
contains
(
value
.
getTypeName
())
&&
!
value
.
getTypeName
().
equals
(
ProjectTypeEnum
.
PROJECT
.
getTypeName
())
&&
!
value
.
getTypeName
().
equals
(
ProjectTypeEnum
.
BUSINESS_OPPORTUNITY
.
getTypeName
())
)
{
if
(!
typeList
.
contains
(
value
.
getTypeName
()))
{
WorkTimeAndCostCollect
workTimeAndCostCollect1
=
new
WorkTimeAndCostCollect
();
WorkTimeAndCostCollect
workTimeAndCostCollect1
=
new
WorkTimeAndCostCollect
();
workTimeAndCostCollect1
.
setType
(
value
.
getTypeName
());
workTimeAndCostCollect1
.
setType
(
value
.
getTypeName
());
workTimeAndCostC
ollect
.
add
(
workTimeAndCostCollect1
);
c
ollect
.
add
(
workTimeAndCostCollect1
);
}
}
}
}
collect
.
addAll
(
workTimeAndCostCollect
);
}
}
for
(
WorkTimeAndCostCollect
workTimeAndCostCollect
:
collect
)
{
for
(
WorkTimeAndCostCollect
workTimeAndCostCollect
:
collect
)
{
// 类型的总工时
// 类型的总工时
...
@@ -337,22 +342,17 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -337,22 +342,17 @@ public class StatisticsServiceImpl implements StatisticsService {
HSSFWorkbook
sheets
=
new
HSSFWorkbook
();
HSSFWorkbook
sheets
=
new
HSSFWorkbook
();
// 创建表
// 创建表
HSSFSheet
sheet
=
sheets
.
createSheet
(
"Sheet1"
);
HSSFSheet
sheet
=
sheets
.
createSheet
(
"Sheet1"
);
// 节假日样式,底色为红色,其余样式与普通项目
HSSFCellStyle
cellStyle1
=
sheets
.
createCellStyle
();
// cellStyle1.setFillBackgroundColor(HSSFColor.HSSFColorPredefined.RED.getIndex());
cellStyle1
.
setFillForegroundColor
(
HSSFColor
.
HSSFColorPredefined
.
RED
.
getIndex
());
// 设置全填充
cellStyle1
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
// 普通样式对象
// 普通样式对象
HSSFCellStyle
cellStyle
=
sheets
.
createCellStyle
();
HSSFCellStyle
cellStyle
=
this
.
createOrdinaryCellStyle
(
sheets
);
// 垂直、水平中心对齐
cellStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
// 节假日样式,底色为绿色,其余样式与普通相同
cellStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
HSSFCellStyle
cellStyle1
=
this
.
createOrdinaryCellStyle
(
sheets
);
cellStyle1
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
cellStyle1
.
setFillForegroundColor
(
HSSFColor
.
HSSFColorPredefined
.
LIGHT_GREEN
.
getIndex
());
cellStyle1
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
// 自动换行
// 当日工时小于8,底色为红色,其余样式与普通相同
cellStyle
.
setWrapText
(
true
);
HSSFCellStyle
cellStyle2
=
this
.
createOrdinaryCellStyle
(
sheets
);
cellStyle1
.
setWrapText
(
true
);
cellStyle2
.
setFillForegroundColor
(
HSSFColor
.
HSSFColorPredefined
.
RED
.
getIndex
());
// 第一列列宽
// 第一列列宽
sheet
.
setColumnWidth
(
1
,
EXCEL_WIDTH
);
sheet
.
setColumnWidth
(
1
,
EXCEL_WIDTH
);
// 获取本月应上班日期集合
// 获取本月应上班日期集合
...
@@ -403,16 +403,51 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -403,16 +403,51 @@ public class StatisticsServiceImpl implements StatisticsService {
emptyCell
.
setCellValue
(
timeAndType
.
getType
()
+
timeAndType
.
getWorkTime
().
toString
());
emptyCell
.
setCellValue
(
timeAndType
.
getType
()
+
timeAndType
.
getWorkTime
().
toString
());
}
}
}
}
// 给该行每个单元格设置单元格样式
for
(
Cell
cell
:
row_i
)
{
cell
.
setCellStyle
(
cellStyle
);
}
// 换行
// 换行
i
++;
i
++;
}
}
// 给节假日单元格设置单元格格式
for
(
int
j
=
0
;
j
<
list
.
size
();
j
++)
{
HSSFRow
row
=
sheet
.
getRow
(
j
+
1
);
for
(
int
r
=
0
;
r
<
dayCount
;
r
++)
{
HSSFCell
cell
=
null
;
if
(
row
.
getCell
(
r
+
3
)
==
null
)
{
cell
=
row
.
createCell
(
r
+
3
);
}
else
{
cell
=
row
.
getCell
(
r
+
3
);
}
// 节假日单元格标绿色
if
(!
days
.
contains
(
r
+
1
))
{
cell
.
setCellStyle
(
cellStyle1
);
}
// 获取单元格中的工时,当日总工时小于8,则单元格底色为红色
String
cellValue
=
ExcelUtils
.
getCellValue
(
cell
,
true
);
if
(
StringUtil
.
isNotEmpty
(
cellValue
))
{
Integer
numberOfString
=
this
.
getNumberOfString
(
cellValue
);
if
(
numberOfString
!=
null
&&
numberOfString
<
8
)
{
cell
.
setCellStyle
(
cellStyle2
);
}
}
}
}
return
sheets
;
return
sheets
;
}
}
// 将字符串中的1到9的数字相加
private
Integer
getNumberOfString
(
String
value
)
{
value
=
value
.
trim
();
if
(
StringUtil
.
isEmpty
(
value
))
{
return
null
;
}
Integer
sum
=
0
;
for
(
int
i
=
0
;
i
<
value
.
length
();
i
++)
{
if
(
value
.
charAt
(
i
)
>=
48
&&
value
.
charAt
(
i
)
<=
57
)
{
sum
+=
value
.
charAt
(
i
)
-
48
;
}
}
return
sum
;
}
@Override
@Override
public
List
<
UserWorkTimeStatisticsByProject
>
getUserWorkTimeStatisticsReport
(
Integer
userId
,
String
startDate
,
String
endDate
,
Integer
status
)
{
public
List
<
UserWorkTimeStatisticsByProject
>
getUserWorkTimeStatisticsReport
(
Integer
userId
,
String
startDate
,
String
endDate
,
Integer
status
)
{
log
.
info
(
"StatisticsServiceImpl[]getUserWorkTimeStatisticsReport[]"
);
log
.
info
(
"StatisticsServiceImpl[]getUserWorkTimeStatisticsReport[]"
);
...
@@ -422,9 +457,11 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -422,9 +457,11 @@ public class StatisticsServiceImpl implements StatisticsService {
}
}
// 获取用户负责项目主键集合
// 获取用户负责项目主键集合
List
<
WorkProject
>
userManageProjects
=
workProjectService
.
getUserManageProjects
(
userId
);
List
<
WorkProject
>
userManageProjects
=
workProjectService
.
getUserManageProjects
(
userId
);
// 为空则提前结束
if
(
CollectionUtil
.
isEmpty
(
userManageProjects
))
{
if
(
CollectionUtil
.
isEmpty
(
userManageProjects
))
{
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.MANAGER_NOT_PROJECT)
;
return
null
;
}
}
// 提取项目主键
List
<
Integer
>
projectIds
=
userManageProjects
.
stream
().
map
(
WorkProject:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
projectIds
=
userManageProjects
.
stream
().
map
(
WorkProject:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
UserWorkTimeStatisticsByProject
>
userWorkTimeStatisticsByProjects
=
new
ArrayList
<>();
List
<
UserWorkTimeStatisticsByProject
>
userWorkTimeStatisticsByProjects
=
new
ArrayList
<>();
...
@@ -435,21 +472,34 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -435,21 +472,34 @@ public class StatisticsServiceImpl implements StatisticsService {
ProjectWorkTimeAndType
projectWorkTimeAndType
=
new
ProjectWorkTimeAndType
();
ProjectWorkTimeAndType
projectWorkTimeAndType
=
new
ProjectWorkTimeAndType
();
projectWorkTimeAndType
.
setProjectId
(
userManageProject
.
getId
());
projectWorkTimeAndType
.
setProjectId
(
userManageProject
.
getId
());
projectWorkTimeAndType
.
setProjectName
(
userManageProject
.
getProjectName
());
projectWorkTimeAndType
.
setProjectName
(
userManageProject
.
getProjectName
());
projectWorkTimeAndType
.
setWorkTime
(
0
);
projectWorkTimeAndType
.
setIsOvertime
(
"正常"
);
projectWorkTimeAndTypes
.
add
(
projectWorkTimeAndType
);
projectWorkTimeAndType
.
setIsOvertime
(
"加班"
);
projectWorkTimeAndTypes
.
add
(
projectWorkTimeAndType
);
projectWorkTimeAndTypes
.
add
(
projectWorkTimeAndType
);
}
}
userWorkTimeStatisticsByProject
.
setProjectWorkTimeAndType
(
projectWorkTimeAndTypes
);
userWorkTimeStatisticsByProjects
.
add
(
userWorkTimeStatisticsByProject
);
// 查询人员项目工时统计
// 查询人员项目工时统计
List
<
UserWorkTimeStatisticsByProject
>
userProjectWorkTimeStatistics
=
workTimeOrderMapper
.
getUserProjectWorkTimeStatistics
(
startDate
,
endDate
,
status
,
projectIds
);
List
<
UserWorkTimeStatisticsByProject
>
userProjectWorkTimeStatistics
=
workTimeOrderMapper
.
getUserProjectWorkTimeStatistics
(
startDate
,
endDate
,
status
,
projectIds
);
// 取出单人的项目工时统计
// 取出单人的项目工时统计
for
(
UserWorkTimeStatisticsByProject
userProjectWorkTimeStatistic
:
user
ProjectWorkTimeStatistic
s
)
{
for
(
UserWorkTimeStatisticsByProject
userProjectWorkTimeStatistic
:
user
WorkTimeStatisticsByProject
s
)
{
int
totalTime
=
0
;
int
totalTime
=
0
;
// 遍历一个人所有项目统计,计算所有项目所有工时总和
for
(
ProjectWorkTimeAndType
projectWorkTimeAndType
:
userProjectWorkTimeStatistic
.
getProjectWorkTimeAndType
())
{
for
(
ProjectWorkTimeAndType
projectWorkTimeAndType
:
userProjectWorkTimeStatistic
.
getProjectWorkTimeAndType
())
{
totalTime
+=
projectWorkTimeAndType
.
getWorkTime
();
totalTime
+=
projectWorkTimeAndType
.
getWorkTime
();
// 计算项目的所有人员工时总和
for
(
ProjectWorkTimeAndType
workTimeAndType
:
projectWorkTimeAndTypes
)
{
if
(
workTimeAndType
.
getProjectName
().
equals
(
projectWorkTimeAndType
.
getProjectName
())
&&
workTimeAndType
.
getIsOvertime
().
equals
(
projectWorkTimeAndType
.
getIsOvertime
()))
{
workTimeAndType
.
setWorkTime
(
workTimeAndType
.
getWorkTime
()+
projectWorkTimeAndType
.
getWorkTime
());
}
}
}
}
userProjectWorkTimeStatistic
.
setTotalTime
(
totalTime
);
userProjectWorkTimeStatistic
.
setTotalTime
(
totalTime
);
}
}
// 返回结果第一条数据是所有项目的名称和工时总计
userWorkTimeStatisticsByProject
.
setProjectWorkTimeAndType
(
projectWorkTimeAndTypes
);
userWorkTimeStatisticsByProjects
.
add
(
userWorkTimeStatisticsByProject
);
// 将项目名称集合与人员工时统计封装在一起
// 将项目名称集合与人员工时统计封装在一起
userWorkTimeStatisticsByProjects
.
addAll
(
userProjectWorkTimeStatistics
);
userWorkTimeStatisticsByProjects
.
addAll
(
userProjectWorkTimeStatistics
);
return
userWorkTimeStatisticsByProjects
;
return
userWorkTimeStatisticsByProjects
;
...
@@ -459,7 +509,10 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -459,7 +509,10 @@ public class StatisticsServiceImpl implements StatisticsService {
public
List
<
ProjectStatisticsByMonth
>
getProjectStatistics
(
Integer
userId
,
Integer
deptId
,
Integer
year
,
Integer
projectId
)
{
public
List
<
ProjectStatisticsByMonth
>
getProjectStatistics
(
Integer
userId
,
Integer
deptId
,
Integer
year
,
Integer
projectId
)
{
log
.
info
(
"StatisticsServiceImpl[]getProjectStatistics[]input.param"
+
userId
+
deptId
+
year
+
projectId
);
log
.
info
(
"StatisticsServiceImpl[]getProjectStatistics[]input.param"
+
userId
+
deptId
+
year
+
projectId
);
// 权限判断
// 权限判断
List
<
Integer
>
role
=
userRoleLevelUtils
.
getRole
(
userId
);
if
(!
role
.
contains
(
ManagerEnum
.
IS_CENTRE_DIRECTOR
.
getCode
()))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
NO_AUTHORITY
);
}
// 默认查询时间为当前
// 默认查询时间为当前
if
(
year
==
null
)
{
if
(
year
==
null
)
{
year
=
DateUtil
.
getYear
(
new
Date
());
year
=
DateUtil
.
getYear
(
new
Date
());
...
@@ -574,4 +627,30 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -574,4 +627,30 @@ public class StatisticsServiceImpl implements StatisticsService {
return
currentMonthFilledDays
;
return
currentMonthFilledDays
;
}
}
// 设置单元格基本样式
HSSFCellStyle
createOrdinaryCellStyle
(
HSSFWorkbook
sheets
)
{
HSSFCellStyle
cellStyle
=
sheets
.
createCellStyle
();
// 设置全填充
cellStyle
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
// 垂直、水平中心对齐
cellStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
cellStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
cellStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
cellStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
//设置下边框的边框线颜色(颜色和上述的颜色对照表是一样的)
cellStyle
.
setBottomBorderColor
(
IndexedColors
.
SKY_BLUE
.
getIndex
());
cellStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
//左边框
cellStyle
.
setLeftBorderColor
(
IndexedColors
.
SKY_BLUE
.
getIndex
());
cellStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
//上边框
cellStyle
.
setRightBorderColor
(
IndexedColors
.
SKY_BLUE
.
getIndex
());
cellStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
//右边框
cellStyle
.
setTopBorderColor
(
IndexedColors
.
SKY_BLUE
.
getIndex
());
// 自动换行
cellStyle
.
setWrapText
(
true
);
return
cellStyle
;
}
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkProjectServiceImpl.java
View file @
e289fd64
...
@@ -66,7 +66,7 @@ public class WorkProjectServiceImpl implements WorkProjectService {
...
@@ -66,7 +66,7 @@ public class WorkProjectServiceImpl implements WorkProjectService {
private
WorkProjectChangeService
workProjectChangeService
;
private
WorkProjectChangeService
workProjectChangeService
;
@Autowired
@Autowired
private
WorkUserDeptService
workUserDeptService
;
private
UserRoleLevelUtils
userRoleLevelUtils
;
/**
/**
* 功能:根据项目id获取项目
* 功能:根据项目id获取项目
...
@@ -145,8 +145,9 @@ public class WorkProjectServiceImpl implements WorkProjectService {
...
@@ -145,8 +145,9 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
}
WorkUser
user
=
workUserService
.
getById
(
userId
);
WorkUser
user
=
workUserService
.
getById
(
userId
);
List
<
Integer
>
role
=
userRoleLevelUtils
.
getRole
(
user
.
getId
());
//普通用户
//普通用户
if
(
user
.
getLevel
().
equals
(
ManagerEnum
.
NOT_MANAGER
))
{
if
(
role
.
contains
(
ManagerEnum
.
NOT_MANAGER
.
getCode
()
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN
);
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN
);
}
}
//存放项目列表
//存放项目列表
...
@@ -154,14 +155,15 @@ public class WorkProjectServiceImpl implements WorkProjectService {
...
@@ -154,14 +155,15 @@ public class WorkProjectServiceImpl implements WorkProjectService {
//存放查询条件
//存放查询条件
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
// 查询项目表中管理为用户的项目集合,
用户为项目经理,但level可能不为1
// 查询项目表中管理为用户的项目集合,
map
.
put
(
"managerId"
,
userId
);
map
.
put
(
"managerId"
,
userId
);
//用户是部门级别,查询该部门下的所有项目
//用户是部门级别,查询该部门下的所有项目
if
(
user
.
getLevel
().
equals
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()))
{
if
(
role
.
contains
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()))
{
map
.
remove
(
"managerId"
);
map
.
put
(
"deptId"
,
user
.
getDeptId
());
map
.
put
(
"deptId"
,
user
.
getDeptId
());
}
}
//中心级别的用户查看中心下所有部门的所有项目
//中心级别的用户查看中心下所有部门的所有项目
if
(
user
.
getLevel
().
equal
s
(
ManagerEnum
.
IS_CENTRE_DIRECTOR
.
getCode
()))
{
if
(
role
.
contain
s
(
ManagerEnum
.
IS_CENTRE_DIRECTOR
.
getCode
()))
{
//获取中心信息
//获取中心信息
WorkCentre
workCentre
=
workCentreMapper
.
getByManagerId
(
user
.
getId
());
WorkCentre
workCentre
=
workCentreMapper
.
getByManagerId
(
user
.
getId
());
if
(
workCentre
==
null
)
{
if
(
workCentre
==
null
)
{
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/StatisticsController.java
View file @
e289fd64
...
@@ -128,5 +128,4 @@ public class StatisticsController extends BaseController {
...
@@ -128,5 +128,4 @@ public class StatisticsController extends BaseController {
return
getResult
(
projectStatisticsByMonths
);
return
getResult
(
projectStatisticsByMonths
);
}
}
}
}
\ No newline at end of file
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