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
d4e3ec46
Commit
d4e3ec46
authored
Mar 01, 2021
by
nie'hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善工时统计
parent
96357dfe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
32 deletions
+47
-32
WorkTimeOrderMapper.xml
...-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
+5
-2
StatisticsServiceImpl.java
...java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
+42
-30
No files found.
wisenergy-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
View file @
d4e3ec46
...
...
@@ -111,7 +111,7 @@
<update
id=
"updateByIds"
>
UPDATE
<include
refid=
"table"
/>
SET status = 2,reviewer_id = #{reviewerId}
SET status = 2,reviewer_id = #{reviewerId}
,modify_time = now()
WHERE work_id IN
<foreach
collection=
"ids"
item=
"id"
open=
"("
close=
")"
separator=
","
>
#{id}
...
...
@@ -211,7 +211,10 @@
<where>
<include
refid=
"criteria"
/>
<if
test=
"startDay != null"
>
AND work_day>=#{startDay}
AND modify_time>=#{startModifyTime}
</if>
<if
test=
""
>
AND work_day>={startWorkTime}
</if>
<if
test=
"projectIdList != null"
>
AND project_id IN
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
View file @
d4e3ec46
...
...
@@ -55,9 +55,6 @@ public class StatisticsServiceImpl implements StatisticsService {
@Autowired
private
WorkUserMapper
workUserMapper
;
@Autowired
private
UserRoleLevelUtils
userRoleLevelUtils
;
@Autowired
private
WorkTypeMapper
workTypeMapper
;
...
...
@@ -146,7 +143,13 @@ public class StatisticsServiceImpl implements StatisticsService {
public
Map
<
String
,
Object
>
getMonthlyStatistics
(
Integer
userId
)
{
log
.
info
(
"WorkTimeOrderServiceImpl[]getMonthlyStatistics[]input.param"
+
userId
);
WorkUser
user
=
workUserService
.
getById
(
userId
);
// 用户权限
List
<
String
>
userAuthority
=
this
.
getUserAuthority
(
userId
);
// 用户权限与权限对应级别
List
<
Integer
>
role
=
UserRoleLevelUtils
.
getRole
(
userId
);
List
<
Integer
>
list
=
UserRoleLevelUtils
.
getlevelIds
(
role
);
List
<
WorkLevel
>
workLevels
=
UserRoleLevelUtils
.
getlevelByIds
(
list
);
List
<
Integer
>
rank
=
this
.
getUserRank
(
workLevels
,
LevelEnum
.
EXAMINE
.
getLevelName
());
// 本月第一天
Date
firstDayOfMonth
=
DateUtil
.
getCurrentFirstDayOfMonth
();
// 返回数据对象
...
...
@@ -157,7 +160,7 @@ public class StatisticsServiceImpl implements StatisticsService {
if
(
CollectionUtil
.
isNotEmpty
(
userAuthority
)
&&
userAuthority
.
contains
(
LevelEnum
.
EXAMINE
.
getLevelName
()))
{
//以审批人、审核状态、开始时间查询本月审批数量
map
.
put
(
"reviewerId"
,
userId
);
map
.
put
(
"start
Day
"
,
firstDayOfMonth
);
map
.
put
(
"start
ModifyTime
"
,
firstDayOfMonth
);
Integer
completedCount
=
workTimeOrderMapper
.
getCountByCondition
(
map
);
//本月驳回未重报数量
...
...
@@ -184,17 +187,18 @@ public class StatisticsServiceImpl implements StatisticsService {
// 查询用户负责审批的除项目合商机的其余类型
Integer
notCompletedCount2
=
0
;
List
<
WorkTypeManager
>
workTypeManagers
=
workTypeManagerMapper
.
getListByManagerId
(
userId
);
if
(
CollectionUtil
.
isNotEmpty
(
workTypeManagers
))
{
if
(
rank
.
contains
(
LevelRankEnum
.
DEPARTMENT_LEVEL
.
getRank
()))
{
map
.
remove
(
"projectIdList"
);
List
<
Integer
>
type
=
workTypeManagers
.
stream
().
map
(
WorkTypeManager:
:
getType
).
collect
(
Collectors
.
toList
());
List
<
WorkType
>
allType
=
workTypeMapper
.
getAll
();
List
<
Integer
>
type
=
new
ArrayList
<>();
for
(
int
i
=
4
;
i
<
allType
.
size
();
i
++)
{
type
.
add
(
allType
.
get
(
i
).
getId
());
}
map
.
put
(
"typeList"
,
type
);
map
.
put
(
"deptId"
,
user
.
getDeptId
());
// 其余类型为审批的条数
notCompletedCount2
=
workTimeOrderMapper
.
getCountByCondition
(
map
);
}
//所有查询结果封装进对象
ApprovalStatistics
approvalStatistics
=
new
ApprovalStatistics
();
approvalStatistics
.
setApprovalCount
(
completedCount
);
...
...
@@ -215,7 +219,7 @@ public class StatisticsServiceImpl implements StatisticsService {
map
.
clear
();
map
.
put
(
"status"
,
StatusEnum
.
REJECTED
.
getCode
());
map
.
put
(
"userId"
,
userId
);
map
.
put
(
"start
Day
"
,
firstDayOfMonth
);
map
.
put
(
"start
WorkTime
"
,
firstDayOfMonth
);
Integer
countByCondition
=
workTimeOrderMapper
.
getCountByCondition
(
map
);
List
<
MonthlyWorkingHoursStatistics
>
monthlyWorkingHoursStatistics
=
workTimeOrderMapper
.
statisticsByProjectType
(
userId
,
firstDayOfMonth
);
...
...
@@ -286,7 +290,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 获取角色对应的权限
List
<
WorkLevel
>
workLevels
=
UserRoleLevelUtils
.
getlevelByIds
(
list
);
// 用户该权限的级别
List
<
Integer
>
rank
=
this
.
getUserRank
(
workLevels
,
LevelEnum
.
EXAMINE
.
getLevelName
());
List
<
Integer
>
rank
=
this
.
getUserRank
(
workLevels
,
LevelEnum
.
EXAMINE
.
getLevelName
());
// 获取所有的类型
List
<
WorkType
>
workTypes
=
workTypeMapper
.
getAll
();
...
...
@@ -311,13 +315,12 @@ public class StatisticsServiceImpl implements StatisticsService {
workTimeAndCostCollects
=
workProjectTimeCostMapper
.
selectList
(
map
);
// 除项目和项目的类型
map
.
put
(
"types"
,
types
);
map
.
put
(
"types"
,
types
);
// 获取这些类型的所有工单
List
<
WorkTimeAndCostCollect
>
workTimeAndCostCollect
=
workTimeOrderMapper
.
getWorkTimeAndCostCollect
(
map
);
workTimeAndCostCollects
.
addAll
(
workTimeAndCostCollect
);
}
else
if
(
rank
.
contains
(
LevelRankEnum
.
DEPARTMENT_LEVEL
.
getRank
())
)
{
// 如果用户的审批权限的级别最高为部门级别
}
else
if
(
rank
.
contains
(
LevelRankEnum
.
DEPARTMENT_LEVEL
.
getRank
()))
{
// 如果用户的审批权限的级别最高为部门级别
// 获取部门下的所有项目和商机的工时统计
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"deptId"
,
user
.
getDeptId
());
...
...
@@ -325,12 +328,11 @@ public class StatisticsServiceImpl implements StatisticsService {
workTimeAndCostCollects
=
workProjectTimeCostMapper
.
selectList
(
map
);
// 除项目和项目的类型
map
.
put
(
"types"
,
types
);
map
.
put
(
"types"
,
types
);
// 获取这些类型的所有工单
List
<
WorkTimeAndCostCollect
>
workTimeAndCostCollect
=
workTimeOrderMapper
.
getWorkTimeAndCostCollect
(
map
);
workTimeAndCostCollects
.
addAll
(
workTimeAndCostCollect
);
}
else
if
(
rank
.
contains
(
LevelRankEnum
.
PROJECT_LEVEL
.
getRank
()))
{
// 如果用户的审批权限的级别最高为项目/商机级别,与其他两种级别不同的是只汇总项目和商机类型的工单
}
else
if
(
rank
.
contains
(
LevelRankEnum
.
PROJECT_LEVEL
.
getRank
()))
{
// 如果用户的审批权限的级别最高为项目/商机级别,与其他两种级别不同的是只汇总项目和商机类型的工单
// 获取部门下的所有项目和商机的工时统计
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
// 获取用户负责项目和商机id
...
...
@@ -476,15 +478,17 @@ public class StatisticsServiceImpl implements StatisticsService {
// 节假日单元格标绿色
if
(!
days
.
contains
(
r
+
1
))
{
cell
.
setCellStyle
(
cellStyle1
);
}
else
{
cell
.
setCellStyle
(
cellStyle
);
}
// 获取单元格中的工时,当日总工时小于8,则单元格底色为红色
String
cellValue
=
ExcelUtils
.
getCellValue
(
cell
,
true
);
if
(
StringUtil
.
isNotEmpty
(
cellValue
))
{
Integer
numberOfString
=
this
.
getNumberOfString
(
cellValue
);
if
(
numberOfString
!=
null
&&
numberOfString
<
8
)
{
cell
.
setCellStyle
(
cellStyle2
);
}
}
//
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
;
...
...
@@ -518,7 +522,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 获取用户权限的级别
List
<
Integer
>
list
=
UserRoleLevelUtils
.
getlevelIds
(
role
);
List
<
WorkLevel
>
workLevels
=
UserRoleLevelUtils
.
getlevelByIds
(
list
);
List
<
Integer
>
rank
=
this
.
getUserRank
(
workLevels
,
LevelEnum
.
USER_STATISTICS
.
getLevelName
());
List
<
Integer
>
rank
=
this
.
getUserRank
(
workLevels
,
LevelEnum
.
USER_STATISTICS
.
getLevelName
());
// 不是中心级不能选择部门
if
(!
rank
.
contains
(
LevelRankEnum
.
CENTRAL_LEVEL
.
getRank
())
&&
deptId
!=
null
)
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
NO_AUTHORITY
);
...
...
@@ -541,11 +545,11 @@ public class StatisticsServiceImpl implements StatisticsService {
// 查询部门下所有项目,部门主键为空时是默认部门
map
.
put
(
"deptId"
,
deptId
);
userManageProjects
=
workProjectMapper
.
getListByCriteria
(
map
);
}
else
if
(
rank
.
contains
(
LevelRankEnum
.
DEPARTMENT_LEVEL
.
getRank
()))
{
}
else
if
(
rank
.
contains
(
LevelRankEnum
.
DEPARTMENT_LEVEL
.
getRank
()))
{
// 查询部门下所有项目,部门主键是用户的部门主键,当前权限最高级别为部门级别
map
.
put
(
"deptId"
,
user
.
getDeptId
());
userManageProjects
=
workProjectMapper
.
getListByCriteria
(
map
);
}
else
{
}
else
{
map
.
put
(
"managerId"
,
user
.
getId
());
userManageProjects
=
workProjectMapper
.
getListByCriteria
(
map
);
}
...
...
@@ -700,10 +704,18 @@ public class StatisticsServiceImpl implements StatisticsService {
//获取的是工作日
if
(
specialDate
.
getDayType
().
equals
(
HolidayTypeEnum
.
WORKING_DAY
.
getCode
()))
{
//在本月应上班集合中加上这天,一般都是放假前后的周末调整上班
workDays
.
addAll
(
isWorkDays
);
for
(
Date
isWorkDay
:
isWorkDays
)
{
if
(
isWorkDay
.
compareTo
(
endDate
)
!=
1
&&
isWorkDay
.
compareTo
(
startDate
)
!=
-
1
&&
!
workDays
.
contains
(
isWorkDay
))
{
workDays
.
add
(
isWorkDay
);
}
}
}
else
{
//否则就除去假日
workDays
.
removeAll
(
isWorkDays
);
for
(
Date
isWorkDay
:
isWorkDays
)
{
if
(
isWorkDay
.
compareTo
(
endDate
)
!=
1
&&
isWorkDay
.
compareTo
(
startDate
)
!=
-
1
&&
!
workDays
.
contains
(
isWorkDay
))
{
workDays
.
remove
(
isWorkDay
);
}
}
}
}
return
workDays
;
...
...
@@ -789,7 +801,7 @@ public class StatisticsServiceImpl implements StatisticsService {
}
// 获取用户当前权限对应的级别
public
List
<
Integer
>
getUserRank
(
List
<
WorkLevel
>
workLevels
,
String
levelName
){
public
List
<
Integer
>
getUserRank
(
List
<
WorkLevel
>
workLevels
,
String
levelName
)
{
List
<
Integer
>
rank
=
new
ArrayList
<>();
for
(
WorkLevel
workLevel
:
workLevels
)
{
if
(
workLevel
.
getName
().
equals
(
levelName
))
{
...
...
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