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
a3805c47
Commit
a3805c47
authored
Feb 09, 2021
by
nie'hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
人员工时统计报表,项目统计报表
parent
87a0a3c1
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
275 additions
and
36 deletions
+275
-36
WorkProjectTimeCostMapper.java
...n/java/cn/wisenergy/mapper/WorkProjectTimeCostMapper.java
+13
-1
WorkProjectMapper.xml
...gy-mapper/src/main/resources/mapper/WorkProjectMapper.xml
+14
-7
WorkProjectTimeCost.xml
...-mapper/src/main/resources/mapper/WorkProjectTimeCost.xml
+64
-16
WorkTimeOrderMapper.xml
...-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
+6
-1
ProjectStatisticsByMonth.java
...java/cn/wisenergy/model/dto/ProjectStatisticsByMonth.java
+48
-0
ProjectWorkTimeAndType.java
...n/java/cn/wisenergy/model/dto/ProjectWorkTimeAndType.java
+1
-1
UserWorkTimeStatisticsByProject.java
.../wisenergy/model/dto/UserWorkTimeStatisticsByProject.java
+5
-1
StatisticsService.java
...src/main/java/cn/wisenergy/service/StatisticsService.java
+16
-0
StatisticsServiceImpl.java
...java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
+96
-5
StatisticsController.java
...energy/web/admin/controller/app/StatisticsController.java
+10
-2
AutoStatistics.java
...ain/java/cn/wisenergy/web/config/auto/AutoStatistics.java
+2
-2
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/WorkProjectTimeCostMapper.java
View file @
a3805c47
package
cn
.
wisenergy
.
mapper
;
package
cn
.
wisenergy
.
mapper
;
import
cn.wisenergy.model.dto.ProjectStatisticsByMonth
;
import
cn.wisenergy.model.dto.WorkTimeAndCostCollect
;
import
cn.wisenergy.model.dto.WorkTimeAndCostCollect
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -15,7 +17,7 @@ public interface WorkProjectTimeCostMapper {
...
@@ -15,7 +17,7 @@ public interface WorkProjectTimeCostMapper {
/**
/**
* 根据添加查询项目统计信息
* 根据添加查询项目统计信息
*/
*/
void
statisticsTimeOrderByMonth
(
);
int
statisticsTimeOrderByMonth
(
String
date
);
/**
/**
* 统计项目总工时和成本,按月统计
* 统计项目总工时和成本,按月统计
...
@@ -23,9 +25,19 @@ public interface WorkProjectTimeCostMapper {
...
@@ -23,9 +25,19 @@ public interface WorkProjectTimeCostMapper {
*/
*/
List
<
WorkTimeAndCostCollect
>
selectList
(
Map
<
String
,
Object
>
map
);
List
<
WorkTimeAndCostCollect
>
selectList
(
Map
<
String
,
Object
>
map
);
/**
* 部门编号不为空,查询部门下所有项目统计。部门主键为空时,查询项目主键参数为主键的项目信息
* @param year
* @param deptId
* @param projectId
* @return
*/
List
<
ProjectStatisticsByMonth
>
selectListByMonth
(
@Param
(
"year"
)
Integer
year
,
@Param
(
"deptId"
)
Integer
deptId
,
@Param
(
"projectId"
)
Integer
projectId
);
/**
/**
* 删除月份大于参数的统计数据
* 删除月份大于参数的统计数据
* @return
* @return
*/
*/
int
deleteStatisticsByQuarter
(
String
date
);
int
deleteStatisticsByQuarter
(
String
date
);
}
}
wisenergy-mapper/src/main/resources/mapper/WorkProjectMapper.xml
View file @
a3805c47
...
@@ -80,13 +80,20 @@
...
@@ -80,13 +80,20 @@
<select
id=
"getProjectsByCriteria"
resultMap=
"BaseResultMap"
parameterType=
"map"
>
<select
id=
"getProjectsByCriteria"
resultMap=
"BaseResultMap"
parameterType=
"map"
>
select
<include
refid=
"Base_Column_List"
/>
select
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"table"
/>
from
<include
refid=
"table"
/>
where manager_id = #{managerId} OR dept_id = #{deptId}
<where>
<if
test=
"manager_id != null"
>
manager_id = #{managerId}
</if>
<if
test=
"dept_id != null"
>
OR dept_id = #{deptId}
</if>
<if
test=
"deptIds != null"
>
<if
test=
"deptIds != null"
>
OR dept_id IN
OR dept_id IN
<foreach
collection=
"deptIds"
item=
"deptId"
separator=
","
open=
"("
close=
")"
>
<foreach
collection=
"deptIds"
item=
"deptId"
separator=
","
open=
"("
close=
")"
>
#{deptId}
#{deptId}
</foreach>
</foreach>
</if>
</if>
</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"
/>
...
...
wisenergy-mapper/src/main/resources/mapper/WorkProjectTimeCost.xml
View file @
a3805c47
...
@@ -29,6 +29,16 @@
...
@@ -29,6 +29,16 @@
</collection>
</collection>
</resultMap>
</resultMap>
<resultMap
id=
"projectStatisticsByMonth"
type=
"cn.wisenergy.model.dto.ProjectStatisticsByMonth"
>
<result
property=
"projectId"
column=
"project_id"
/>
<result
property=
"projectName"
column=
"project_name"
/>
<collection
property=
"statisticsDateAndWorkTimes"
ofType=
"cn.wisenergy.model.dto.ProjectStatisticsByMonth$StatisticsDateAndWorkTime"
>
<result
property=
"date"
column=
"date"
/>
<result
property=
"totalTime"
column=
"total_time"
/>
<result
property=
"cost"
column=
"cost"
/>
</collection>
</resultMap>
<delete
id=
"deleteStatisticsByQuarter"
>
<delete
id=
"deleteStatisticsByQuarter"
>
delete
delete
from work_project_time_cost
from work_project_time_cost
...
@@ -36,26 +46,44 @@
...
@@ -36,26 +46,44 @@
</delete>
</delete>
<insert
id=
"statisticsTimeOrderByMonth"
>
<insert
id=
"statisticsTimeOrderByMonth"
useGeneratedKeys=
"true"
>
INSERT into work_project_time_cost(project_id,user_id,is_overtime,statistics_start,statistics_end,total_time,cost)
INSERT INTO work_project_time_cost (
SELECT
project_id,
project_id,
user_id,
user_id,
is_overtime,
is_overtime,
statistics_start,
statistics_end,
total_time,
cost
)
SELECT
project_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)
FROM
FROM
work_time_order t join work_user_salary s on t.user_id = s.user_id
work_time_order t
WHERE status in (2,5) AND s.create_time
<
work_day AND s.end_time>work_day AND
JOIN work_user_salary s ON t.user_id = s.user_id
WHERE
t.work_day >= #{date} AND s.create_time
<
work_day AND s.end_time > work_day
AND t.`status` IN (2, 5)
GROUP BY
GROUP BY
project_id,
project_id,
user_id,
t.
user_id,
is_overtime,
is_overtime,
YEAR (work_day),
YEAR (work_day),
MONTH (work_day)
MONTH (work_day)
ON DUPLICATE key UPDATE is_overtime = VALUES(is_overtime), statistics_end = VALUES(statistics_end),total_time = VALUES(total_time),cost= VALUES(cost)
ON DUPLICATE KEY UPDATE is_overtime =
VALUES(is_overtime),
statistics_end =
VALUES(statistics_end),
total_time =
VALUES(total_time),
cost =
VALUES(cost)
</insert>
</insert>
...
@@ -80,4 +108,24 @@
...
@@ -80,4 +108,24 @@
</if>
</if>
GROUP BY type,dept_name,dept_id,ptc.project_id,project_name
GROUP BY type,dept_name,dept_id,ptc.project_id,project_name
</select>
</select>
<select
id=
"selectListByMonth"
resultMap=
"projectStatisticsByMonth"
>
select ptc.project_id AS project_id, project_name,
IF ( GROUP_CONCAT(DISTINCT MONTH (statistics_start)) = 1,
group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月'),
group_CONCAT(DISTINCT MONTH (statistics_start),'月')
) AS date,
sum(total_time) AS total_time, sum(cost) AS cost
from work_project_time_cost ptc join work_project p on ptc.project_id = p.id
<where>
<if
test=
"projectId != null "
>
ptc.project_id = #{projectId}
</if>
<if
test=
"deptId != null"
>
AND dept_id = #{deptId} AND year(statistics_start) = #{year}
</if>
</where>
group by ptc.project_id,project_name,year(statistics_start),MONTH(statistics_start)
</select>
</mapper>
</mapper>
\ No newline at end of file
wisenergy-mapper/src/main/resources/mapper/WorkTimeOrderMapper.xml
View file @
a3805c47
...
@@ -299,7 +299,12 @@
...
@@ -299,7 +299,12 @@
,case t.type when 1 then '项目' when 2 then '商机' when 5 then '外部商务/技术交流' when 6 then '内部培训/技术准备/管理' when 7 then '其他非项目/商机工作' end AS project_type
,case t.type when 1 then '项目' when 2 then '商机' when 5 then '外部商务/技术交流' when 6 then '内部培训/技术准备/管理' when 7 then '其他非项目/商机工作' end AS project_type
,p.project_name AS project_name, case t.is_overtime when 1 then '加班' ELSE '正常' end AS is_overtime,SUM(t.work_time) AS work_time
,p.project_name AS project_name, case t.is_overtime when 1 then '加班' ELSE '正常' end AS is_overtime,SUM(t.work_time) AS work_time
from work_time_order t join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id
from work_time_order t join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id
where DATE(t.work_day) > #{startDate} AND DATE(t.work_day)
<
#{endDate} AND p.is_conclusion=#{status} AND t.type not in(3,4)
where
t.work_day
<
#{endDate}
<if
test=
"startDate != null"
>
AND t.work_day > #{startDate}
</if>
AND p.is_conclusion=#{status} AND t.type not in(3,4)
<if
test=
"projectIds != null"
>
<if
test=
"projectIds != null"
>
AND project_id in
AND project_id in
<foreach
collection=
"projectIds"
item=
"projectId"
open=
"("
close=
")"
separator=
","
>
<foreach
collection=
"projectIds"
item=
"projectId"
open=
"("
close=
")"
separator=
","
>
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/dto/ProjectStatisticsByMonth.java
0 → 100644
View file @
a3805c47
package
cn
.
wisenergy
.
model
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
* @description:
* @author: nh
* @create: 2021-02-09 09:40
**/
@Data
@ApiModel
(
value
=
"ProjectStatisticsByMonth"
,
description
=
"项目统计报表返回对象"
)
public
class
ProjectStatisticsByMonth
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
2958828761910039617L
;
@ApiModelProperty
(
name
=
"projectId"
,
value
=
"项目主键"
)
private
Integer
projectId
;
@ApiModelProperty
(
name
=
"projectName"
,
value
=
"项目名称"
)
private
String
projectName
;
@ApiModelProperty
(
name
=
"statisticsDateAndWorkTime"
,
value
=
"项目统计的时间段、工时和成本"
)
List
<
StatisticsDateAndWorkTime
>
statisticsDateAndWorkTimes
;
@Data
public
static
class
StatisticsDateAndWorkTime
{
/**
* 项目统计的时间
*/
String
date
;
/**
* 总工时
*/
BigDecimal
totalTime
;
/**
* 成本
*/
BigDecimal
cost
;
}
}
wisenergy-model/src/main/java/cn/wisenergy/model/dto/ProjectWorkTimeAndType.java
View file @
a3805c47
...
@@ -35,6 +35,6 @@ public class ProjectWorkTimeAndType{
...
@@ -35,6 +35,6 @@ public class ProjectWorkTimeAndType{
* 总工时
* 总工时
*/
*/
@ApiModelProperty
(
name
=
"workTime"
,
value
=
"总工时"
)
@ApiModelProperty
(
name
=
"workTime"
,
value
=
"总工时"
)
private
String
workTime
;
private
Integer
workTime
;
}
}
\ No newline at end of file
wisenergy-model/src/main/java/cn/wisenergy/model/dto/UserWorkTimeStatisticsByProject.java
View file @
a3805c47
...
@@ -36,7 +36,11 @@ public class UserWorkTimeStatisticsByProject implements Serializable {
...
@@ -36,7 +36,11 @@ public class UserWorkTimeStatisticsByProject implements Serializable {
@ApiModelProperty
(
name
=
"projectWorkTimeAndType"
,
value
=
"项目工时列表"
)
@ApiModelProperty
(
name
=
"projectWorkTimeAndType"
,
value
=
"项目工时列表"
)
private
List
<
ProjectWorkTimeAndType
>
projectWorkTimeAndType
;
private
List
<
ProjectWorkTimeAndType
>
projectWorkTimeAndType
;
/**
* 总工时
*/
@ApiModelProperty
(
name
=
"totalTime"
,
value
=
"总工时"
)
private
Integer
totalTime
;
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/StatisticsService.java
View file @
a3805c47
package
cn
.
wisenergy
.
service
;
package
cn
.
wisenergy
.
service
;
import
cn.wisenergy.model.dto.GetMonthlyCollectParam
;
import
cn.wisenergy.model.dto.GetMonthlyCollectParam
;
import
cn.wisenergy.model.dto.ProjectStatisticsByMonth
;
import
cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject
;
import
cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject
;
import
cn.wisenergy.model.dto.WorkTimeAndCostCollect
;
import
cn.wisenergy.model.dto.WorkTimeAndCostCollect
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
...
@@ -12,6 +13,7 @@ public interface StatisticsService {
...
@@ -12,6 +13,7 @@ public interface StatisticsService {
/**
/**
* 获取部门所有员工每天工时
* 获取部门所有员工每天工时
*
* @param param 参数对象
* @param param 参数对象
* @return
* @return
*/
*/
...
@@ -19,6 +21,7 @@ public interface StatisticsService {
...
@@ -19,6 +21,7 @@ public interface StatisticsService {
/**
/**
* 获取用户本月填报和审批情况,权限为填报时只有填报情况
* 获取用户本月填报和审批情况,权限为填报时只有填报情况
*
* @param userId
* @param userId
* @return
* @return
*/
*/
...
@@ -26,6 +29,7 @@ public interface StatisticsService {
...
@@ -26,6 +29,7 @@ public interface StatisticsService {
/**
/**
* 获取负责项目在本月的工时汇总:花费工时,工时成本
* 获取负责项目在本月的工时汇总:花费工时,工时成本
*
* @param userId
* @param userId
*/
*/
List
<
WorkTimeAndCostCollect
>
getCurrentMonthWorkTimeCollect
(
Integer
userId
,
String
startTime
);
List
<
WorkTimeAndCostCollect
>
getCurrentMonthWorkTimeCollect
(
Integer
userId
,
String
startTime
);
...
@@ -33,6 +37,7 @@ public interface StatisticsService {
...
@@ -33,6 +37,7 @@ public interface StatisticsService {
/**
/**
* 导出一个部门下员工一个月中每天的工时
* 导出一个部门下员工一个月中每天的工时
*
* @param param
* @param param
* @return
* @return
*/
*/
...
@@ -40,10 +45,21 @@ public interface StatisticsService {
...
@@ -40,10 +45,21 @@ public interface StatisticsService {
/**
/**
* 获取用户所在未结项目的工时统计
* 获取用户所在未结项目的工时统计
*
* @param startDate
* @param startDate
* @param endDate
* @param endDate
* @param status
* @param status
* @return
* @return
*/
*/
List
<
UserWorkTimeStatisticsByProject
>
getUserWorkTimeStatisticsReport
(
Integer
userId
,
String
startDate
,
String
endDate
,
Integer
status
);
List
<
UserWorkTimeStatisticsByProject
>
getUserWorkTimeStatisticsReport
(
Integer
userId
,
String
startDate
,
String
endDate
,
Integer
status
);
/**
* 获取项目统计
*
* @param userId
* @param deptId
* @param date
* @return
*/
List
<
ProjectStatisticsByMonth
>
getProjectStatistics
(
Integer
userId
,
Integer
deptId
,
Integer
year
,
Integer
projectId
);
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/impl/StatisticsServiceImpl.java
View file @
a3805c47
...
@@ -59,6 +59,9 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -59,6 +59,9 @@ public class StatisticsServiceImpl implements StatisticsService {
@Autowired
@Autowired
private
WorkUserMapper
workUserMapper
;
private
WorkUserMapper
workUserMapper
;
@Autowired
private
WorkProjectMapper
workProjectMapper
;
@Autowired
@Autowired
WorkProjectTimeCostMapper
workProjectTimeCostMapper
;
WorkProjectTimeCostMapper
workProjectTimeCostMapper
;
...
@@ -296,7 +299,7 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -296,7 +299,7 @@ public class StatisticsServiceImpl implements StatisticsService {
List
<
String
>
typeList
=
workTimeAndCostCollect
.
stream
().
map
(
WorkTimeAndCostCollect:
:
getType
).
collect
(
Collectors
.
toList
());
List
<
String
>
typeList
=
workTimeAndCostCollect
.
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
())
&&
!
value
.
getTypeName
().
equals
(
ProjectTypeEnum
.
PROJECT
.
getTypeName
())
&&
!
value
.
getTypeName
().
equals
(
ProjectTypeEnum
.
BUSINESS_OPPORTUNITY
.
getTypeName
()))
{
WorkTimeAndCostCollect
workTimeAndCostCollect1
=
new
WorkTimeAndCostCollect
();
WorkTimeAndCostCollect
workTimeAndCostCollect1
=
new
WorkTimeAndCostCollect
();
workTimeAndCostCollect1
.
setType
(
value
.
getTypeName
());
workTimeAndCostCollect1
.
setType
(
value
.
getTypeName
());
workTimeAndCostCollect
.
add
(
workTimeAndCostCollect1
);
workTimeAndCostCollect
.
add
(
workTimeAndCostCollect1
);
...
@@ -424,10 +427,98 @@ public class StatisticsServiceImpl implements StatisticsService {
...
@@ -424,10 +427,98 @@ public class StatisticsServiceImpl implements StatisticsService {
}
}
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
<>();
// 返回结果集合第一个元素是用户管理项目的集合
UserWorkTimeStatisticsByProject
userWorkTimeStatisticsByProject
=
new
UserWorkTimeStatisticsByProject
();
List
<
ProjectWorkTimeAndType
>
projectWorkTimeAndTypes
=
new
ArrayList
<>();
for
(
WorkProject
userManageProject
:
userManageProjects
)
{
ProjectWorkTimeAndType
projectWorkTimeAndType
=
new
ProjectWorkTimeAndType
();
projectWorkTimeAndType
.
setProjectId
(
userManageProject
.
getId
());
projectWorkTimeAndType
.
setProjectName
(
userManageProject
.
getProjectName
());
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
:
userProjectWorkTimeStatistics
)
{
int
totalTime
=
0
;
for
(
ProjectWorkTimeAndType
projectWorkTimeAndType
:
userProjectWorkTimeStatistic
.
getProjectWorkTimeAndType
())
{
totalTime
+=
projectWorkTimeAndType
.
getWorkTime
();
}
userProjectWorkTimeStatistic
.
setTotalTime
(
totalTime
);
}
// 将项目名称集合与人员工时统计封装在一起
userWorkTimeStatisticsByProjects
.
addAll
(
userProjectWorkTimeStatistics
);
return
userWorkTimeStatisticsByProjects
;
}
@Override
public
List
<
ProjectStatisticsByMonth
>
getProjectStatistics
(
Integer
userId
,
Integer
deptId
,
Integer
year
,
Integer
projectId
)
{
log
.
info
(
"StatisticsServiceImpl[]getProjectStatistics[]input.param"
+
userId
+
deptId
+
year
+
projectId
);
// 权限判断
// 默认查询时间为当前
if
(
year
==
null
)
{
year
=
DateUtil
.
getYear
(
new
Date
());
}
// 部门主键和项目主键不能同时为空
if
(
deptId
==
null
&&
projectId
==
null
)
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
return
userProjectWorkTimeStatistics
;
// 部门主键参数不为空,查询部门下所有项目统计信息。为空时,查询项目编号参数为主键的项目统计信息
List
<
ProjectStatisticsByMonth
>
projectStatisticsByMonths
=
workProjectTimeCostMapper
.
selectListByMonth
(
year
,
deptId
,
projectId
);
// 计算工时和成本合计
if
(
CollectionUtil
.
isNotEmpty
(
projectStatisticsByMonths
))
{
// 存放所有项目所有月份合计
ProjectStatisticsByMonth
projectStatisticsByMonthTotal
=
new
ProjectStatisticsByMonth
();
List
<
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
>
statisticsDateAndWorkTimeList
=
new
ArrayList
<>(
13
);
// 设置合计时间1到12月和项目合计
for
(
int
i
=
0
;
i
<
12
;
i
++)
{
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
statisticsDateAndWorkTime
=
new
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
();
statisticsDateAndWorkTime
.
setDate
(
i
+
1
+
"月"
);
statisticsDateAndWorkTime
.
setTotalTime
(
new
BigDecimal
(
"0.00"
));
statisticsDateAndWorkTime
.
setCost
(
new
BigDecimal
(
"0.00"
));
statisticsDateAndWorkTimeList
.
add
(
statisticsDateAndWorkTime
);
}
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
statisticsDateAndWorkTime1
=
new
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
();
statisticsDateAndWorkTime1
.
setDate
(
"项目合计"
);
statisticsDateAndWorkTimeList
.
add
(
statisticsDateAndWorkTime1
);
// 遍历所有项目的统计
for
(
ProjectStatisticsByMonth
projectStatisticsByMonth
:
projectStatisticsByMonths
)
{
// 一个项目统计中的所有月份工时和成本信息
BigDecimal
totalTime
=
new
BigDecimal
(
"0.00"
);
BigDecimal
cost
=
new
BigDecimal
(
"0.00"
);
for
(
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
statisticsDateAndWorkTimes
:
projectStatisticsByMonth
.
getStatisticsDateAndWorkTimes
())
{
for
(
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
statisticsDateAndWorkTime
:
statisticsDateAndWorkTimeList
)
{
// 某个项目的全周期生命统计不需要所有项目合计
if
(
statisticsDateAndWorkTime
.
getDate
().
equals
(
statisticsDateAndWorkTimes
.
getDate
())
&&
deptId
!=
null
)
{
statisticsDateAndWorkTime
.
setCost
(
statisticsDateAndWorkTime
.
getCost
().
add
(
statisticsDateAndWorkTimes
.
getCost
()));
statisticsDateAndWorkTime
.
setTotalTime
(
statisticsDateAndWorkTime
.
getTotalTime
().
add
(
statisticsDateAndWorkTimes
.
getTotalTime
()));
}
}
cost
=
cost
.
add
(
statisticsDateAndWorkTimes
.
getCost
());
totalTime
=
totalTime
.
add
(
statisticsDateAndWorkTimes
.
getTotalTime
());
}
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
statisticsDateAndWorkTime
=
new
ProjectStatisticsByMonth
.
StatisticsDateAndWorkTime
();
statisticsDateAndWorkTime
.
setDate
(
"项目合计"
);
statisticsDateAndWorkTime
.
setCost
(
cost
);
statisticsDateAndWorkTime
.
setTotalTime
(
totalTime
);
// 将统计的结果放在一个项目统计集合的末尾
projectStatisticsByMonth
.
getStatisticsDateAndWorkTimes
().
add
(
statisticsDateAndWorkTime
);
}
if
(
deptId
!=
null
)
{
projectStatisticsByMonthTotal
.
setStatisticsDateAndWorkTimes
(
statisticsDateAndWorkTimeList
);
projectStatisticsByMonthTotal
.
setProjectName
(
"合计"
);
projectStatisticsByMonths
.
add
(
projectStatisticsByMonthTotal
);
}
}
return
projectStatisticsByMonths
;
}
}
//获取一个月应上班日期,如果是当月,时间截至到当天
//获取一个月应上班日期,如果是当月,时间截至到当天
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/StatisticsController.java
View file @
a3805c47
...
@@ -5,6 +5,7 @@ import cn.wisenergy.common.utils.exception.BaseCustomException;
...
@@ -5,6 +5,7 @@ import cn.wisenergy.common.utils.exception.BaseCustomException;
import
cn.wisenergy.common.utils.exception.Result
;
import
cn.wisenergy.common.utils.exception.Result
;
import
cn.wisenergy.model.app.WorkDept
;
import
cn.wisenergy.model.app.WorkDept
;
import
cn.wisenergy.model.dto.GetMonthlyCollectParam
;
import
cn.wisenergy.model.dto.GetMonthlyCollectParam
;
import
cn.wisenergy.model.dto.ProjectStatisticsByMonth
;
import
cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject
;
import
cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject
;
import
cn.wisenergy.model.dto.WorkTimeAndCostCollect
;
import
cn.wisenergy.model.dto.WorkTimeAndCostCollect
;
import
cn.wisenergy.service.StatisticsService
;
import
cn.wisenergy.service.StatisticsService
;
...
@@ -42,8 +43,6 @@ public class StatisticsController extends BaseController {
...
@@ -42,8 +43,6 @@ public class StatisticsController extends BaseController {
@Autowired
@Autowired
WorkDeptService
workDeptService
;
WorkDeptService
workDeptService
;
@ApiOperation
(
value
=
"获取部门员工一个月每天的工时"
,
notes
=
"获取部门员工一个月每天的工时"
)
@ApiOperation
(
value
=
"获取部门员工一个月每天的工时"
,
notes
=
"获取部门员工一个月每天的工时"
)
@GetMapping
(
"/getMonthlyCollect"
)
@GetMapping
(
"/getMonthlyCollect"
)
public
PageInfo
getMonthlyCollect
(
GetMonthlyCollectParam
param
)
{
public
PageInfo
getMonthlyCollect
(
GetMonthlyCollectParam
param
)
{
...
@@ -121,4 +120,13 @@ public class StatisticsController extends BaseController {
...
@@ -121,4 +120,13 @@ public class StatisticsController extends BaseController {
return
getResult
(
userWorkTimeStatisticsByProjects
);
return
getResult
(
userWorkTimeStatisticsByProjects
);
}
}
@ApiOperation
(
value
=
"获取项目统计报表"
,
notes
=
"获取项目统计报表"
)
@GetMapping
(
"/getProjectStatistics"
)
public
Result
<
List
<
ProjectStatisticsByMonth
>>
getProjectStatistics
(
Integer
userId
,
Integer
deptId
,
Integer
year
,
Integer
projectId
)
{
log
.
info
(
"StatisticsController[]getProjectStatistics[]input.param"
+
userId
+
deptId
+
year
,
projectId
);
List
<
ProjectStatisticsByMonth
>
projectStatisticsByMonths
=
statisticsService
.
getProjectStatistics
(
userId
,
deptId
,
year
,
projectId
);
return
getResult
(
projectStatisticsByMonths
);
}
}
}
\ No newline at end of file
wisenergy-web-admin/src/main/java/cn/wisenergy/web/config/auto/AutoStatistics.java
View file @
a3805c47
...
@@ -26,12 +26,12 @@ public class AutoStatistics {
...
@@ -26,12 +26,12 @@ public class AutoStatistics {
private
WorkProjectTimeCostMapper
workProjectTimeCostMapper
;
private
WorkProjectTimeCostMapper
workProjectTimeCostMapper
;
@Transactional
@Transactional
@Scheduled
(
cron
=
"0
43 11
* * ?"
)
@Scheduled
(
cron
=
"0
0 0
* * ?"
)
public
void
autoStatistics
(){
public
void
autoStatistics
(){
log
.
info
(
"AutoStatistics[]autoStatistics[]自动统计任务"
);
log
.
info
(
"AutoStatistics[]autoStatistics[]自动统计任务"
);
Date
date
=
DateUtil
.
add
(
new
Date
(),
Calendar
.
DAY_OF_MONTH
,
-
3
);
Date
date
=
DateUtil
.
add
(
new
Date
(),
Calendar
.
DAY_OF_MONTH
,
-
3
);
String
firstDayOfMonth
=
DateUtil
.
convertDateToYMDStr
(
DateUtil
.
getFirstDayOfMonth
(
date
));
String
firstDayOfMonth
=
DateUtil
.
convertDateToYMDStr
(
DateUtil
.
getFirstDayOfMonth
(
date
));
workProjectTimeCostMapper
.
deleteStatisticsByQuarter
(
firstDayOfMonth
);
workProjectTimeCostMapper
.
deleteStatisticsByQuarter
(
firstDayOfMonth
);
workProjectTimeCostMapper
.
statisticsTimeOrderByMonth
();
workProjectTimeCostMapper
.
statisticsTimeOrderByMonth
(
firstDayOfMonth
);
}
}
}
}
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