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
2943e540
Commit
2943e540
authored
Jan 24, 2021
by
nie'hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
我的-工时统计(小成)
parent
8a89a45c
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
147 additions
and
29 deletions
+147
-29
WorkHolidayMapper.java
.../src/main/java/cn/wisenergy/mapper/WorkHolidayMapper.java
+5
-0
WorkTimeOrderMapper.java
...rc/main/java/cn/wisenergy/mapper/WorkTimeOrderMapper.java
+7
-0
WorkHolidayMapper.xml
...gy-mapper/src/main/resources/mapper/WorkHolidayMapper.xml
+11
-0
WorkProjectMapper.xml
...gy-mapper/src/main/resources/mapper/WorkProjectMapper.xml
+6
-6
WorkTimeOrderMapper.xml
...-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
+5
-1
MonthlyWorkingHoursStatistics.java
...cn/wisenergy/model/dto/MonthlyWorkingHoursStatistics.java
+10
-0
HolidayTypeEnum.java
...c/main/java/cn/wisenergy/model/enums/HolidayTypeEnum.java
+22
-0
WorkDeptService.java
...e/src/main/java/cn/wisenergy/service/WorkDeptService.java
+1
-1
StatisticsServiceImpl.java
...java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
+71
-14
WorkProjectServiceImpl.java
...ava/cn/wisenergy/service/impl/WorkProjectServiceImpl.java
+9
-7
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/WorkHolidayMapper.java
View file @
2943e540
...
...
@@ -2,6 +2,10 @@ package cn.wisenergy.mapper;
import
cn.wisenergy.model.app.WorkHoliday
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
import
java.util.List
;
/**
* <p>
...
...
@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public
interface
WorkHolidayMapper
extends
BaseMapper
<
WorkHoliday
>
{
List
<
WorkHoliday
>
getByDate
(
@Param
(
"startDay"
)
Date
startDay
,
@Param
(
"endDay"
)
Date
endDay
);
}
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/WorkTimeOrderMapper.java
View file @
2943e540
...
...
@@ -58,4 +58,11 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
Integer
getCountByCondition
(
Map
<
String
,
Object
>
map
);
List
<
WorkTimeAndCostCollect
>
getWorkTimeAndCostCollect
(
@Param
(
"projectIds"
)
List
<
Integer
>
projectIds
,
@Param
(
"firstDayOfMonth"
)
Date
firstDayOfMonth
);
/**
* 获取上班日期集合
* @param firstDayOfMonth
* @return
*/
List
<
Date
>
getDaysByDateAndStatus
(
@Param
(
"firstDayOfMonth"
)
Date
firstDayOfMonth
,
@Param
(
"userId"
)
Integer
userId
);
}
wisenergy-mapper/src/main/resources/mapper/WorkHolidayMapper.xml
View file @
2943e540
...
...
@@ -16,4 +16,15 @@
id, day_start, day_end, day_type, des
</sql>
<sql
id=
"table"
>
work_holiday
</sql>
<select
id=
"getByDate"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"table"
/>
where (year(day_start) = year(#{startDay}) AND month(day_start) = month(#{startDay})) OR
(year(day_end) = year(#{endDay}) AND month(day_end) = month(#{endDay}))
</select>
</mapper>
wisenergy-mapper/src/main/resources/mapper/WorkProjectMapper.xml
View file @
2943e540
...
...
@@ -51,13 +51,13 @@
from
<include
refid=
"table"
/>
<where>
<include
refid=
"criteria"
/>
<if
test=
"deptIds != null"
>
AND dept_id IN
<foreach
collection=
"deptIds"
item=
"deptId"
separator=
","
open=
"("
close=
")"
>
#{deptId}
</foreach>
</if>
</where>
<if
test=
"deptIds != null"
>
AND dept_id IN
<foreach
collection=
"deptIds"
item=
"deptId"
separator=
","
open=
"("
close=
")"
>
#{deptId}
</foreach>
</if>
</select>
</mapper>
wisenergy-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
View file @
2943e540
...
...
@@ -138,7 +138,6 @@
select count(1),sum(work_time)
from
<include
refid=
"table"
/>
where user_id = #{userId} AND type = #{projectType} AND work_day >=#{currentMonthFirstDay}
</select>
<select
id=
"listByDateAndUserId"
resultMap=
"dayWorkTimeAndType"
>
...
...
@@ -189,4 +188,9 @@
group by `type`,dept_id, project_name
</select>
<select
id=
"getDaysByDateAndStatus"
resultType=
"date"
>
select distinct(work_day)
from
<include
refid=
"table"
/>
where work_day >= #{firstDayOfMonth} AND user_id = #{userId}
</select>
</mapper>
wisenergy-model/src/main/java/cn/wisenergy/model/dto/MonthlyWorkingHoursStatistics.java
View file @
2943e540
...
...
@@ -28,5 +28,15 @@ public class MonthlyWorkingHoursStatistics implements Serializable {
*/
private
Integer
workTime
;
/**
* 未填报天数
*/
private
Integer
notFilledCount
;
/**
* 被驳回次数
*/
private
Integer
rejectCount
;
}
wisenergy-model/src/main/java/cn/wisenergy/model/enums/HolidayTypeEnum.java
0 → 100644
View file @
2943e540
package
cn
.
wisenergy
.
model
.
enums
;
public
enum
HolidayTypeEnum
{
WORKING_DAY
(
0
,
"工作日"
),
HOLIDAY
(
1
,
"假日"
);
private
Integer
code
;
private
String
msg
;
HolidayTypeEnum
(
Integer
code
,
String
msg
){
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
Integer
getCode
(){
return
code
;
}
public
String
getMsg
(){
return
msg
;
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/WorkDeptService.java
View file @
2943e540
...
...
@@ -17,7 +17,7 @@ public interface WorkDeptService {
WorkDept
getById
(
Integer
id
);
/**
* 获取全部部门信息或单条信息
* 获取全部部门信息或单条信息
,部门主键为空查询全部部门信息
* @param deptId
* @return
*/
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
View file @
2943e540
...
...
@@ -4,19 +4,15 @@ import cn.hutool.core.collection.CollectionUtil;
import
cn.wisenergy.common.utils.DateUtil
;
import
cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM
;
import
cn.wisenergy.common.utils.exception.BaseCustomException
;
import
cn.wisenergy.mapper.WorkHolidayMapper
;
import
cn.wisenergy.mapper.WorkTimeOrderMapper
;
import
cn.wisenergy.mapper.WorkUserDeptMapper
;
import
cn.wisenergy.model.app.WorkHoliday
;
import
cn.wisenergy.model.app.WorkProject
;
import
cn.wisenergy.model.app.WorkUser
;
import
cn.wisenergy.model.dto.*
;
import
cn.wisenergy.model.enums.ManagerEnum
;
import
cn.wisenergy.model.enums.ProjectTypeEnum
;
import
cn.wisenergy.model.enums.WorkOrderStatus
;
import
cn.wisenergy.model.enums.WorkOrderType
;
import
cn.wisenergy.service.StatisticsService
;
import
cn.wisenergy.service.WorkDeptService
;
import
cn.wisenergy.service.WorkProjectService
;
import
cn.wisenergy.service.WorkUserService
;
import
cn.wisenergy.model.enums.*
;
import
cn.wisenergy.service.*
;
import
com.alibaba.excel.util.StringUtils
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
...
...
@@ -51,6 +47,11 @@ public class StatisticsServiceImpl implements StatisticsService {
@Autowired
private
WorkProjectService
workProjectService
;
@Autowired
private
WorkHolidayService
workHolidayService
;
@Autowired
private
WorkHolidayMapper
workHolidayMapper
;
private
final
static
Integer
DEFAULT_DEPT_ID
=
1
;
...
...
@@ -71,7 +72,7 @@ public class StatisticsServiceImpl implements StatisticsService {
if
(
StringUtils
.
isEmpty
(
param
.
getYear
())
||
StringUtils
.
isEmpty
(
param
.
getMonth
()))
{
Date
now
=
new
Date
();
year
=
DateUtil
.
getYear
(
now
);
month
=
DateUtil
.
getMonth
(
now
)
+
1
;
month
=
DateUtil
.
getMonth
(
now
)
+
1
;
}
//默认部门主键为1
Integer
deptId
=
param
.
getDeptId
();
...
...
@@ -119,10 +120,11 @@ public class StatisticsServiceImpl implements StatisticsService {
Date
firstDayOfMonth
=
DateUtil
.
getCurrentFirstDayOfMonth
();
//返回数据对象
List
<
Object
>
objects
=
new
ArrayList
<>();
//存放查询条件
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
//用户是项目或部门级别
if
(
user
.
getLevel
().
equals
(
ManagerEnum
.
IS_PROJECT_DIRECTOR
.
getCode
())
||
user
.
getLevel
().
equals
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()))
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
//以审批人、审核状态、开始时间查询本月审批数量
map
.
put
(
"reviewerId"
,
userId
);
map
.
put
(
"status"
,
WorkOrderStatus
.
ALREADY_AUDIT
.
getCode
());
...
...
@@ -169,14 +171,27 @@ public class StatisticsServiceImpl implements StatisticsService {
ArrayList
<
MonthlyWorkingHoursStatistics
>
statisticsArrayList
=
new
ArrayList
<>();
if
(
user
.
getLevel
().
equals
(
ManagerEnum
.
NOT_MANAGER
.
getCode
())
||
user
.
getLevel
().
equals
(
ManagerEnum
.
IS_PROJECT_DIRECTOR
.
getCode
()))
{
String
currentDayOfMonth
=
DateUtil
.
convertDateToYMDStr
(
DateUtil
.
getCurrentFirstDayOfMonth
());
//本月应填报天数
List
<
Date
>
currentMonthWorkDays
=
this
.
currentMonthWorkDays
();
List
<
Date
>
currentMonthFilledDays
=
currentMonthFilledDays
(
userId
);
currentMonthWorkDays
.
removeAll
(
currentMonthFilledDays
);
int
notFilledCount
=
currentMonthWorkDays
.
size
();
//本月被现存驳回数
map
.
put
(
"status"
,
3
);
map
.
put
(
"startDay"
,
firstDayOfMonth
);
Integer
countByCondition
=
workTimeOrderMapper
.
getCountByCondition
(
map
);
String
currentDayOfMonth
=
DateUtil
.
convertDateToYMDStr
(
firstDayOfMonth
);
//统计项目类型工单填报次数、总工时
MonthlyWorkingHoursStatistics
statistics1
=
workTimeOrderMapper
.
statisticsByProjectType
(
userId
,
ProjectTypeEnum
.
PROJECT
.
getCode
(),
currentDayOfMonth
);
statistics1
.
setProjectType
(
ProjectTypeEnum
.
PROJECT
.
getMsg
());
statistics1
.
setProjectType
(
ProjectTypeEnum
.
PROJECT
.
getMsg
());
statistics1
.
setNotFilledCount
(
notFilledCount
);
statistics1
.
setRejectCount
(
countByCondition
);
statisticsArrayList
.
add
(
statistics1
);
//统计商机类型工单填报次数、总工时
MonthlyWorkingHoursStatistics
statistics2
=
workTimeOrderMapper
.
statisticsByProjectType
(
userId
,
ProjectTypeEnum
.
BUSINESS_OPPORTUNITY
.
getCode
(),
currentDayOfMonth
);
statistics2
.
setProjectType
(
ProjectTypeEnum
.
BUSINESS_OPPORTUNITY
.
getMsg
());
statistics2
.
setNotFilledCount
(
notFilledCount
);
statistics2
.
setRejectCount
(
countByCondition
);
statisticsArrayList
.
add
(
statistics2
);
objects
.
add
(
statisticsArrayList
);
}
...
...
@@ -184,7 +199,7 @@ public class StatisticsServiceImpl implements StatisticsService {
}
@Override
public
List
<
WorkTimeAndCostCollect
>
getCurrentMonthWorkTimeCollect
(
Integer
userId
,
Date
startTime
)
{
public
List
<
WorkTimeAndCostCollect
>
getCurrentMonthWorkTimeCollect
(
Integer
userId
,
Date
startTime
)
{
log
.
info
(
"StatisticsServiceImpl[]getCurrentMonthWorkTimeCollect[]input.param"
+
userId
+
startTime
);
if
(
userId
==
null
)
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
...
...
@@ -197,7 +212,9 @@ public class StatisticsServiceImpl implements StatisticsService {
List
<
WorkProject
>
userManageProjects
=
workProjectService
.
getUserManageProjects
(
userId
);
//获取项目集合中所有项目的项目主键
List
<
Integer
>
projectIds
=
userManageProjects
.
stream
().
map
(
WorkProject:
:
getId
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isEmpty
(
projectIds
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
MANAGER_NOT_PROJECT
);
}
List
<
WorkTimeAndCostCollect
>
collect
=
workTimeOrderMapper
.
getWorkTimeAndCostCollect
(
projectIds
,
startTime
);
for
(
WorkTimeAndCostCollect
timeAndCostCollect
:
collect
)
{
//复制部门名称
...
...
@@ -206,4 +223,44 @@ public class StatisticsServiceImpl implements StatisticsService {
return
collect
;
}
//获取本月应上班日期集合
public
List
<
Date
>
currentMonthWorkDays
()
{
log
.
info
(
"StatisticsServiceImpl[]currentMonthWorkDays[]input.method"
);
//当前时间
Date
now
=
new
Date
();
//本月第一天
Date
firstDayOfMonth
=
DateUtil
.
getFirstDayOfMonth
(
now
);
//本月第一天到当日的日期集合
List
<
Date
>
workDays
=
DateUtil
.
getDatesBetweenTwoDate
(
firstDayOfMonth
,
now
);
//除去周末和节假日
Iterator
<
Date
>
iterator
=
workDays
.
iterator
();
while
(
iterator
.
hasNext
())
{
Date
next
=
iterator
.
next
();
if
(
workHolidayService
.
isHoliday
(
next
))
{
iterator
.
remove
();
}
}
//获取当月的节日和周末上班日期
List
<
WorkHoliday
>
specialDates
=
workHolidayMapper
.
getByDate
(
firstDayOfMonth
,
now
);
if
(
CollectionUtil
.
isNotEmpty
(
specialDates
))
{
for
(
WorkHoliday
specialDate
:
specialDates
)
{
//获取的是工作日
if
(
specialDate
.
getDayType
().
equals
(
HolidayTypeEnum
.
WORKING_DAY
.
getCode
()))
{
//在本月应上班集合中加上这天,一般都是放假前后的周末调整上班
List
<
Date
>
isWorkDays
=
DateUtil
.
getDatesBetweenTwoDate
(
specialDate
.
getDayStart
(),
specialDate
.
getDayEnd
());
workDays
.
addAll
(
isWorkDays
);
}
}
}
return
workDays
;
}
//用户本月填报日期集合
public
List
<
Date
>
currentMonthFilledDays
(
Integer
userId
)
{
log
.
info
(
"StatisticsServiceImpl[]currentMonthFilledDays[]input.method"
);
Date
firstDayOfMonth
=
DateUtil
.
getCurrentFirstDayOfMonth
();
List
<
Date
>
currentMonthFilledDays
=
workTimeOrderMapper
.
getDaysByDateAndStatus
(
firstDayOfMonth
,
userId
);
return
currentMonthFilledDays
;
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkProjectServiceImpl.java
View file @
2943e540
package
cn
.
wisenergy
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM
;
import
cn.wisenergy.common.utils.exception.BaseCustomException
;
import
cn.wisenergy.mapper.WorkCentreMapper
;
...
...
@@ -125,17 +124,21 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
WorkUser
user
=
workUserService
.
getById
(
userId
);
//普通用户
if
(
user
.
getLevel
().
equals
(
ManagerEnum
.
NOT_MANAGER
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN
);
}
//存放项目列表
List
<
WorkProject
>
workProjects
=
new
ArrayList
<>();
//存放查询条件
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
//项目级别查询项目管理员为用户的项目
if
(
user
.
getLevel
()
==
ManagerEnum
.
IS_PROJECT_DIRECTOR
.
getCode
(
))
{
if
(
user
.
getLevel
()
.
equals
(
ManagerEnum
.
IS_PROJECT_DIRECTOR
.
getCode
()
))
{
map
.
put
(
"managerId"
,
userId
);
workProjects
=
workProjectMapper
.
getProjectsByCriteria
(
map
);
}
//用户是部门级别,查询该部门下的所有项目
if
(
user
.
getLevel
()
==
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
(
))
{
if
(
user
.
getLevel
()
.
equals
(
ManagerEnum
.
IS_DEPARTMENT_DIRECTOR
.
getCode
()
))
{
map
.
put
(
"deptId"
,
user
.
getDeptId
());
workProjects
=
workProjectMapper
.
getProjectsByCriteria
(
map
);
}
...
...
@@ -153,14 +156,13 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
DEPT_NOT_FOUND
);
}
//获取这些部门的主键
List
<
Integer
>
deptIds
=
workDepts
.
stream
().
map
(
workDept
->
workDept
.
getId
()
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
deptIds
=
workDepts
.
stream
().
map
(
WorkDept:
:
getId
).
collect
(
Collectors
.
toList
());
map
.
clear
();
map
.
put
(
"deptIds"
,
deptIds
);
workProjects
=
workProjectMapper
.
getProjectsByCriteria
(
map
);
}
if
(
CollectionUtil
.
isEmpty
(
workProjects
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
MANAGER_NOT_PROJECT
);
}
return
workProjects
;
}
}
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