Commit 5c2d62da authored by nie'hong's avatar nie'hong

完善工时统计

parent e8b63dc5
......@@ -110,7 +110,7 @@
<select id="selectListByMonth" resultMap="projectStatisticsByMonth">
select <if test="deptId != null">'合计' AS project_name,</if> <if test="projectId != null"> project_name,</if> group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date,sum(total_time) AS total_time, sum(cost) AS cost
select <if test="deptId != null">'合计' AS project_name,</if> <if test="projectId != null"> project_name,</if> group_CONCAT(DISTINCT YEAR (statistics_start),'年',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 join work_dept d on ptc.dept_id = d.id
<where>
<if test="projectId != null ">
......
......@@ -69,8 +69,6 @@ public class StatisticsServiceImpl implements StatisticsService {
private WorkDeptMapper workDeptMapper;
@Autowired
private WorkUserProjectMapper workUserProjectMapper;
......@@ -543,7 +541,7 @@ public class StatisticsServiceImpl implements StatisticsService {
}
Map<String, Object> map = new HashMap<>();
map.put("isConclusion", isConclusion);
List<WorkProject> userManageProjects = null;
List<WorkProject> userManageProjects;
// 当前权限最高为中心级别权限
if (rank.contains(LevelRankEnum.CENTRAL_LEVEL.getRank())) {
// 查询部门下所有项目,部门主键为空时是默认部门
......@@ -560,13 +558,14 @@ public class StatisticsServiceImpl implements StatisticsService {
// 管理项目为空则提前结束
if (CollectionUtil.isEmpty(userManageProjects)) {
return new ArrayList<>();
return null;
}
// 提取项目主键
List<Integer> projectIds = userManageProjects.stream().map(WorkProject::getId).collect(Collectors.toList());
// 查询各个项目正常工时和加班工时统计总计
List<UserWorkTimeStatisticsByProject> userProjectWorkTimeStatistics = workTimeOrderMapper.getUserProjectWorkTimeStatistics(startDate, endDate, projectIds, false);
// 查询结果为空,新建一个“合计”对象添加到集合
if (CollectionUtils.isEmpty(userProjectWorkTimeStatistics)) {
UserWorkTimeStatisticsByProject userWorkTimeStatisticsByProject = new UserWorkTimeStatisticsByProject();
userWorkTimeStatisticsByProject.setUserName("合计");
......@@ -668,6 +667,31 @@ public class StatisticsServiceImpl implements StatisticsService {
return null;
}
List<ProjectStatisticsByMonth> projectStatisticsByMonths1 = workProjectTimeCostMapper.selectListStatistics(year, deptId, projectId);
if (projectId != null) {
// 项目的全周期统计
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonths.get(0).getStatisticsDateAndWorkTimes();
// 遍历各个部门对改项目的贡献集合
for (ProjectStatisticsByMonth statisticsByMonth : projectStatisticsByMonths1) {
// 部门的各个月对项目的贡献工时
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes1 = statisticsByMonth.getStatisticsDateAndWorkTimes();
// 如果该部门对该项目的贡献的时间不是和该项目周期一样
if (statisticsDateAndWorkTimes1.size() != statisticsDateAndWorkTimes.size()) {
for (int i = 0; i < statisticsDateAndWorkTimes.size(); i++) {
if (statisticsDateAndWorkTimes1.size() < statisticsDateAndWorkTimes.size() || !statisticsDateAndWorkTimes1.get(i).getDate().equals(statisticsDateAndWorkTimes.get(i).getDate())) {
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime();
statisticsDateAndWorkTime.setTotalTime(new BigDecimal("0"));
statisticsDateAndWorkTime.setCost(new BigDecimal("0"));
statisticsDateAndWorkTime.setDate(statisticsDateAndWorkTimes.get(i).getDate());
statisticsDateAndWorkTimes1.add(i, statisticsDateAndWorkTime);
} else {
continue;
}
}
}
}
}
// 将查询结果封装在一起,部门主键为空,项目总计在前,否则在后
List<ProjectStatisticsByMonth> projectStatistics = new ArrayList<>();
if (deptId == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment