Commit 1d32b8f2 authored by nie'hong's avatar nie'hong

完善项目统计报表

parent e289fd64
...@@ -93,6 +93,6 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -93,6 +93,6 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/** /**
* 获取人员项目工时 * 获取人员项目工时
*/ */
List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("status") Integer status, @Param("projectIds") List<Integer> projectIds); List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("isConclusion") Integer isConclusion, @Param("projectIds") List<Integer> projectIds, @Param("userIds") List<Integer>userIds);
} }
...@@ -23,4 +23,5 @@ public interface WorkUserProjectMapper extends BaseMapper<WorkUserProject> { ...@@ -23,4 +23,5 @@ public interface WorkUserProjectMapper extends BaseMapper<WorkUserProject> {
int insertBatch(@Param("userIds") List<Integer> userIds,@Param("projectId") Integer projectId); int insertBatch(@Param("userIds") List<Integer> userIds,@Param("projectId") Integer projectId);
List<Integer> selectUserIdByProjectIds(@Param("projectIds") List<Integer> projectIds);
} }
...@@ -81,8 +81,11 @@ ...@@ -81,8 +81,11 @@
select <include refid="Base_Column_List"/> select <include refid="Base_Column_List"/>
from <include refid="table"/> from <include refid="table"/>
<where> <where>
<if test="isConclusion != null">
is_conclusion = #{isConclusion}
</if>
<if test="managerId != null"> <if test="managerId != null">
manager_id = #{managerId} AND manager_id = #{managerId}
</if> </if>
<if test="deptId != null"> <if test="deptId != null">
OR dept_id = #{deptId} OR dept_id = #{deptId}
...@@ -113,15 +116,14 @@ ...@@ -113,15 +116,14 @@
</where> </where>
</select> </select>
<select id="getManagerProjectsDto" resultType="cn.wisenergy.model.dto.ManagerProjectsDto"> <select id="getManagerProjectsDto" resultType="cn.wisenergy.model.dto.ManagerProjectsDto">
select p.id,p.oa_project_id,p.project_name,p.type,p.create_time,p.is_conclusion, select p.id,p.oa_project_id,p.project_name,p.type,p.create_time,p.is_conclusion,
GROUP_CONCAT(DISTINCT(u.name)) as 'Participants',p.cost_budget,p.work_time,p.start_time,p.end_time, GROUP_CONCAT(DISTINCT(u.name)) as 'Participants',p.cost_budget,p.work_time,p.start_time,p.end_time,
ROUND(SUM(o.work_time)/8,2) as 'currentLaborCost',ROUND(SUM(o.work_time),2) as 'totalCurrentWorkingHours', ROUND(SUM(o.work_time)/8,2) as 'currentLaborCost',ROUND(SUM(o.work_time),2) as 'totalCurrentWorkingHours',
if(now() BETWEEN p.start_time and p.end_time,'否','是') as 'isItOverdue', if(now() BETWEEN p.start_time and p.end_time,'否','是') as 'isItOverdue',
if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange' if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange'
from work_project p LEFT JOIN work_time_order o on p.id = o.project_id from work_project p LEFT JOIN work_time_order o on p.id = o.project_id
LEFT JOIN work_user u on p.manager_id = u.id LEFT JOIN work_user u on p.manager_id = u.id
<where> <where>
<if test="null != userId"> <if test="null != userId">
AND p.manager_id = #{userId} AND p.manager_id = #{userId}
</if> </if>
...@@ -131,21 +133,14 @@ if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange' ...@@ -131,21 +133,14 @@ if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange'
<if test="null !=isConclusion"> <if test="null !=isConclusion">
AND p.is_conclusion = #{isConclusion} AND p.is_conclusion = #{isConclusion}
</if> </if>
<if test="deptIds != null"> <if test="deptIds != null">
OR p.dept_id IN OR p.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>
</where> GROUP BY p.id
GROUP BY p.id
</select> </select>
......
...@@ -112,10 +112,7 @@ ...@@ -112,10 +112,7 @@
<select id="selectListByMonth" resultMap="projectStatisticsByMonth"> <select id="selectListByMonth" resultMap="projectStatisticsByMonth">
select ptc.project_id AS project_id, project_name, 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),'月') AS date,
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 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 from work_project_time_cost ptc join work_project p on ptc.project_id = p.id
<where> <where>
......
...@@ -298,13 +298,16 @@ ...@@ -298,13 +298,16 @@
SELECT u.id AS user_id ,u.`name` AS user_name, t.project_id AS project_id SELECT u.id AS user_id ,u.`name` AS user_name, t.project_id AS project_id
,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 left join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id
where where
t.work_day &lt; #{endDate} t.status in (2,5) AND
t.work_day &lt;= #{endDate}
<if test="isConclusion != null">
AND p.is_conclusion = #{isConclusion}
</if>
<if test="startDate != null"> <if test="startDate != null">
AND t.work_day > #{startDate} AND t.work_day > #{startDate}
</if> </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=",">
...@@ -312,5 +315,18 @@ ...@@ -312,5 +315,18 @@
</foreach> </foreach>
</if> </if>
GROUP BY u.id,u.`name`,t.project_id,t.type,p.project_name, t.is_overtime GROUP BY u.id,u.`name`,t.project_id,t.type,p.project_name, t.is_overtime
<if test="userIds != null">
UNION
SELECT u.id AS user_id ,u.`name` AS user_name, t.project_id AS project_id
,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
from work_time_order t left join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id
where
t.status in (2,5) AND t.type in(5,6,7) AND t.user_id in
<foreach collection="userIds" item="userId" separator="," open="(" close=")" >
#{userId}
</foreach>
GROUP BY u.id,u.`name`,t.project_id,t.type,p.project_name, t.is_overtime
</if>
</select> </select>
</mapper> </mapper>
...@@ -38,4 +38,13 @@ ...@@ -38,4 +38,13 @@
WHERE project_id = #{projectId} WHERE project_id = #{projectId}
</select> </select>
<select id="selectUserIdByProjectIds" resultType="java.lang.Integer">
select user_id
from work_user_project
where project_id in
<foreach collection="projectIds" item="projectId" open="(" close=")" separator=",">
#{projectId}
</foreach>
</select>
</mapper> </mapper>
...@@ -5,8 +5,8 @@ public enum ProjectTypeEnum { ...@@ -5,8 +5,8 @@ public enum ProjectTypeEnum {
BUSINESS_OPPORTUNITY(2, "商机", 1), BUSINESS_OPPORTUNITY(2, "商机", 1),
LEAVE(3, "请假", 2), LEAVE(3, "请假", 2),
COMPENSATORY_LEAVE(4, "调休", 2), COMPENSATORY_LEAVE(4, "调休", 2),
EXTERNAL_BUSINESS(5, "外部商务技术交流", 3), EXTERNAL_BUSINESS(5, "外部商务/技术交流", 3),
INTERNAL_TRAINING(6, "内部培训、技术准备、管理", 3), INTERNAL_TRAINING(6, "内部培训/技术准备/管理", 3),
OTHER_NON_PROJECTS(7, "其他非项目/商机工作", 3), OTHER_NON_PROJECTS(7, "其他非项目/商机工作", 3),
; ;
......
...@@ -61,7 +61,10 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -61,7 +61,10 @@ public class StatisticsServiceImpl implements StatisticsService {
private UserRoleLevelUtils userRoleLevelUtils; private UserRoleLevelUtils userRoleLevelUtils;
@Autowired @Autowired
WorkProjectTimeCostMapper workProjectTimeCostMapper; private WorkProjectTimeCostMapper workProjectTimeCostMapper;
@Autowired
private WorkUserProjectMapper workUserProjectMapper;
private final static Integer EXCEL_WIDTH = 1000 * 6; private final static Integer EXCEL_WIDTH = 1000 * 6;
...@@ -451,13 +454,17 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -451,13 +454,17 @@ public class StatisticsServiceImpl implements StatisticsService {
@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[]");
List<Integer> role = userRoleLevelUtils.getRole(userId);
if (role.contains(ManagerEnum.NOT_MANAGER.getCode())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
// 默认统计截至时间为前一天 // 默认统计截至时间为前一天
if (StringUtil.isEmpty(endDate)) { if (StringUtil.isEmpty(endDate)) {
endDate = DateUtil.convertDateToYMDStr(new Date()); endDate = DateUtil.convertDateToYMDStr(new Date());
} }
// 获取用户负责项目主键集合 // 获取用户负责项目主键集合
List<WorkProject> userManageProjects = workProjectService.getUserManageProjects(userId); List<WorkProject> userManageProjects = workProjectService.getUserManageProjects(userId);
// 为空则提前结束 // 管理项目为空则提前结束
if (CollectionUtil.isEmpty(userManageProjects)) { if (CollectionUtil.isEmpty(userManageProjects)) {
return null; return null;
} }
...@@ -469,29 +476,42 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -469,29 +476,42 @@ public class StatisticsServiceImpl implements StatisticsService {
UserWorkTimeStatisticsByProject userWorkTimeStatisticsByProject = new UserWorkTimeStatisticsByProject(); UserWorkTimeStatisticsByProject userWorkTimeStatisticsByProject = new UserWorkTimeStatisticsByProject();
List<ProjectWorkTimeAndType> projectWorkTimeAndTypes = new ArrayList<>(); List<ProjectWorkTimeAndType> projectWorkTimeAndTypes = new ArrayList<>();
for (WorkProject userManageProject : userManageProjects) { for (WorkProject userManageProject : userManageProjects) {
ProjectWorkTimeAndType projectWorkTimeAndType = new ProjectWorkTimeAndType(); // 项目加班工时对象
projectWorkTimeAndType.setProjectId(userManageProject.getId()); ProjectWorkTimeAndType projectWorkTimeAndType = createProjectWorkTimeAndType(userManageProject);
projectWorkTimeAndType.setProjectName(userManageProject.getProjectName());
projectWorkTimeAndType.setWorkTime(0);
projectWorkTimeAndType.setIsOvertime("正常"); projectWorkTimeAndType.setIsOvertime("正常");
projectWorkTimeAndTypes.add(projectWorkTimeAndType); projectWorkTimeAndTypes.add(projectWorkTimeAndType);
// 项目正常工时对象
projectWorkTimeAndType = createProjectWorkTimeAndType(userManageProject);
projectWorkTimeAndType.setIsOvertime("加班"); projectWorkTimeAndType.setIsOvertime("加班");
projectWorkTimeAndTypes.add(projectWorkTimeAndType); projectWorkTimeAndTypes.add(projectWorkTimeAndType);
} }
// 添加表头:外部商务/技术交流、内部培训/技术准备/管理、其他非项目/商机工作
List<ProjectWorkTimeAndType> projectWorkTimeAndTypeListByType = createProjectWorkTimeAndTypeListByType();
projectWorkTimeAndTypes.addAll(projectWorkTimeAndTypeListByType);
// 管理项目组成人员主键,如果用户仅为项目级别管理人员,则为空
List<Integer> userIds = null;
if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) || role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
userIds = workUserProjectMapper.selectUserIdByProjectIds(projectIds);
}
// 查询人员项目工时统计 // 查询人员项目工时统计
List<UserWorkTimeStatisticsByProject> userProjectWorkTimeStatistics = workTimeOrderMapper.getUserProjectWorkTimeStatistics(startDate, endDate, status, projectIds); List<UserWorkTimeStatisticsByProject> userProjectWorkTimeStatistics = workTimeOrderMapper.getUserProjectWorkTimeStatistics(startDate, endDate, status, projectIds, userIds);
// 取出单人的项目工时统计 // 取出单人的项目工时统计
for (UserWorkTimeStatisticsByProject userProjectWorkTimeStatistic : userWorkTimeStatisticsByProjects) { for (UserWorkTimeStatisticsByProject userProjectWorkTimeStatistic : userProjectWorkTimeStatistics) {
int totalTime = 0; int totalTime = 0;
List<ProjectWorkTimeAndType> projectWorkTimeAndType1 = userProjectWorkTimeStatistic.getProjectWorkTimeAndType();
// 遍历一个人所有项目统计,计算所有项目所有工时总和 // 遍历一个人所有项目统计,计算所有项目所有工时总和
for (ProjectWorkTimeAndType projectWorkTimeAndType : userProjectWorkTimeStatistic.getProjectWorkTimeAndType()) { for (ProjectWorkTimeAndType projectWorkTimeAndType : projectWorkTimeAndType1) {
totalTime += projectWorkTimeAndType.getWorkTime(); totalTime += projectWorkTimeAndType.getWorkTime();
// 计算项目的所有人员工时总和 // 计算项目的所有人员工时总和
for (ProjectWorkTimeAndType workTimeAndType : projectWorkTimeAndTypes) { for (ProjectWorkTimeAndType workTimeAndType : projectWorkTimeAndTypes) {
if (workTimeAndType.getProjectName().equals(projectWorkTimeAndType.getProjectName()) && workTimeAndType.getIsOvertime().equals(projectWorkTimeAndType.getIsOvertime())) { // 项目统计数据
workTimeAndType.setWorkTime(workTimeAndType.getWorkTime()+projectWorkTimeAndType.getWorkTime()); if (workTimeAndType.getProjectName() != null && workTimeAndType.getProjectName().equals(projectWorkTimeAndType.getProjectName()) && workTimeAndType.getIsOvertime().equals(projectWorkTimeAndType.getIsOvertime())) {
workTimeAndType.setWorkTime(workTimeAndType.getWorkTime() + projectWorkTimeAndType.getWorkTime());
}else if (workTimeAndType.getProjectType() != null && workTimeAndType.getProjectType().equals(projectWorkTimeAndType.getProjectType()) && workTimeAndType.getIsOvertime().equals(projectWorkTimeAndType.getIsOvertime())) {
workTimeAndType.setWorkTime(workTimeAndType.getWorkTime() + projectWorkTimeAndType.getWorkTime());
} }
} }
} }
...@@ -522,23 +542,23 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -522,23 +542,23 @@ 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);
} }
// 部门主键参数不为空,查询部门下所有项目统计信息。为空时,查询项目编号参数为主键的项目统计信息 // 部门主键参数不为空,查询部门下所有项目统计信息。部门主键为空时,查询项目编号参数为主键的项目统计信息
List<ProjectStatisticsByMonth> projectStatisticsByMonths = workProjectTimeCostMapper.selectListByMonth(year, deptId, projectId); List<ProjectStatisticsByMonth> projectStatisticsByMonths = workProjectTimeCostMapper.selectListByMonth(year, deptId, projectId);
// 计算工时和成本合计 if (CollectionUtil.isEmpty(projectStatisticsByMonths)) {
if (CollectionUtil.isNotEmpty(projectStatisticsByMonths)) { return null;
// 存放所有项目所有月份合计 }
// 部门主键不为空时,日期格式只有某月。为空时,日期格式为某年统计的第一个月为某年某月,其余为某月
this.conversionDateFormat(projectStatisticsByMonths, deptId);
// 计算合计,存放所有项目所有月份合计
ProjectStatisticsByMonth projectStatisticsByMonthTotal = new ProjectStatisticsByMonth(); ProjectStatisticsByMonth projectStatisticsByMonthTotal = new ProjectStatisticsByMonth();
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimeList = new ArrayList<>(13); List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimeList = new ArrayList<>(13);
// 设置合计时间1到12月和项目合计 // 设置合计时间1到12月和项目合计
for (int i = 0; i < 12; i++) { for (int i = 1; i <= 12; i++) {
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime(); ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime = this.createStatisticsDateAndWorkTime(i + "月");
statisticsDateAndWorkTime.setDate(i + 1 + "月");
statisticsDateAndWorkTime.setTotalTime(new BigDecimal("0.00"));
statisticsDateAndWorkTime.setCost(new BigDecimal("0.00"));
statisticsDateAndWorkTimeList.add(statisticsDateAndWorkTime); statisticsDateAndWorkTimeList.add(statisticsDateAndWorkTime);
} }
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime1 = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime(); ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime1 = this.createStatisticsDateAndWorkTime("项目合计");
statisticsDateAndWorkTime1.setDate("项目合计");
statisticsDateAndWorkTimeList.add(statisticsDateAndWorkTime1); statisticsDateAndWorkTimeList.add(statisticsDateAndWorkTime1);
// 遍历所有项目的统计 // 遍历所有项目的统计
...@@ -547,16 +567,25 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -547,16 +567,25 @@ public class StatisticsServiceImpl implements StatisticsService {
BigDecimal totalTime = new BigDecimal("0.00"); BigDecimal totalTime = new BigDecimal("0.00");
BigDecimal cost = new BigDecimal("0.00"); BigDecimal cost = new BigDecimal("0.00");
for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTimes : projectStatisticsByMonth.getStatisticsDateAndWorkTimes()) { for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTimes : projectStatisticsByMonth.getStatisticsDateAndWorkTimes()) {
// 某月的所有项目的工时统计,查询某个项目全声明周期数据时不统计
if (deptId != null) {
for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime : statisticsDateAndWorkTimeList) { for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime : statisticsDateAndWorkTimeList) {
// 某个项目的全周期生命统计不需要所有项目合计 if (statisticsDateAndWorkTime.getDate().equals(statisticsDateAndWorkTimes.getDate())) {
if (statisticsDateAndWorkTime.getDate().equals(statisticsDateAndWorkTimes.getDate()) && deptId != null) {
statisticsDateAndWorkTime.setCost(statisticsDateAndWorkTime.getCost().add(statisticsDateAndWorkTimes.getCost())); statisticsDateAndWorkTime.setCost(statisticsDateAndWorkTime.getCost().add(statisticsDateAndWorkTimes.getCost()));
statisticsDateAndWorkTime.setTotalTime(statisticsDateAndWorkTime.getTotalTime().add(statisticsDateAndWorkTimes.getTotalTime())); statisticsDateAndWorkTime.setTotalTime(statisticsDateAndWorkTime.getTotalTime().add(statisticsDateAndWorkTimes.getTotalTime()));
} }
} }
}
cost = cost.add(statisticsDateAndWorkTimes.getCost()); cost = cost.add(statisticsDateAndWorkTimes.getCost());
totalTime = totalTime.add(statisticsDateAndWorkTimes.getTotalTime()); totalTime = totalTime.add(statisticsDateAndWorkTimes.getTotalTime());
} }
// 所有项目的所有月的合计,
for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime : statisticsDateAndWorkTimeList) {
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime2 = statisticsDateAndWorkTimeList.get(statisticsDateAndWorkTimeList.size() - 1);
statisticsDateAndWorkTime2.setTotalTime(statisticsDateAndWorkTime2.getTotalTime().add(statisticsDateAndWorkTime.getTotalTime()));
statisticsDateAndWorkTime2.setCost(statisticsDateAndWorkTime2.getCost().add(statisticsDateAndWorkTime.getCost()));
}
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime(); ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime();
statisticsDateAndWorkTime.setDate("项目合计"); statisticsDateAndWorkTime.setDate("项目合计");
statisticsDateAndWorkTime.setCost(cost); statisticsDateAndWorkTime.setCost(cost);
...@@ -569,7 +598,6 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -569,7 +598,6 @@ public class StatisticsServiceImpl implements StatisticsService {
projectStatisticsByMonthTotal.setProjectName("合计"); projectStatisticsByMonthTotal.setProjectName("合计");
projectStatisticsByMonths.add(projectStatisticsByMonthTotal); projectStatisticsByMonths.add(projectStatisticsByMonthTotal);
} }
}
return projectStatisticsByMonths; return projectStatisticsByMonths;
} }
...@@ -653,4 +681,81 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -653,4 +681,81 @@ public class StatisticsServiceImpl implements StatisticsService {
return cellStyle; return cellStyle;
} }
// 返回一个项目工时类型信息对象
public ProjectWorkTimeAndType createProjectWorkTimeAndType(WorkProject project) {
ProjectWorkTimeAndType projectWorkTimeAndType = new ProjectWorkTimeAndType();
projectWorkTimeAndType.setProjectId(project.getId());
projectWorkTimeAndType.setProjectName(project.getProjectName());
projectWorkTimeAndType.setWorkTime(0);
return projectWorkTimeAndType;
}
// 生成三种类型的表头
public List<ProjectWorkTimeAndType> createProjectWorkTimeAndTypeListByType() {
List<ProjectWorkTimeAndType> list = new ArrayList<>(6);
ProjectWorkTimeAndType timeAndType ;
// 外部商务、技术交流
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.EXTERNAL_BUSINESS.getTypeName(), "正常");
list.add(timeAndType);
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.EXTERNAL_BUSINESS.getTypeName(), "加班");
list.add(timeAndType);
// 内部培训、技术准备、管理
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.INTERNAL_TRAINING.getTypeName(), "正常");
list.add(timeAndType);
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.INTERNAL_TRAINING.getTypeName(), "加班");
list.add(timeAndType);
// 其他非项目/商机工作
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.OTHER_NON_PROJECTS.getTypeName(), "正常");
list.add(timeAndType);
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.OTHER_NON_PROJECTS.getTypeName(), "加班");
list.add(timeAndType);
return list;
}
// 根据类型生成ProjectWorkTimeAndType对象
public ProjectWorkTimeAndType createProjectWorkTimeAndTypeByType(String type, String isOvertime) {
ProjectWorkTimeAndType projectWorkTimeAndType = new ProjectWorkTimeAndType();
projectWorkTimeAndType.setProjectType(type);
projectWorkTimeAndType.setIsOvertime(isOvertime);
projectWorkTimeAndType.setWorkTime(0);
return projectWorkTimeAndType;
}
// 根据日期生成ProjectStatisticsByMonth对象
public ProjectStatisticsByMonth.StatisticsDateAndWorkTime createStatisticsDateAndWorkTime(String date) {
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime();
statisticsDateAndWorkTime.setDate(date);
statisticsDateAndWorkTime.setTotalTime(new BigDecimal("0.00"));
statisticsDateAndWorkTime.setCost(new BigDecimal("0.00"));
return statisticsDateAndWorkTime;
}
// 部门主键不为空时,日期格式只有某月。为空时,日期格式为某年统计的第一个月为某年某月,其余为某月
public void conversionDateFormat(List<ProjectStatisticsByMonth> projectStatisticsByMonths, Integer deptId){
for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) {
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth.getStatisticsDateAndWorkTimes();
// 部门主键不为空时,日期格式只有某月
if (deptId != null) {
for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime : statisticsDateAndWorkTimes) {
String date = statisticsDateAndWorkTime.getDate();
StringBuilder stringBuilder = new StringBuilder(date);
// 删除年份
stringBuilder.delete(0, 5);
statisticsDateAndWorkTime.setDate(stringBuilder.toString());
}
}else {
for (int i = statisticsDateAndWorkTimes.size()-1; i > 0; i--) {
String date1 = statisticsDateAndWorkTimes.get(i).getDate();
String date2 = statisticsDateAndWorkTimes.get(i - 1).getDate();
// 如果不为当年统计数据的第一个月,则删除年份
if (date1.charAt(2) == date2.charAt(2) && date1.charAt(3) == date2.charAt(3)) {
StringBuilder dateBuilder1 = new StringBuilder(date1);
// 删除年份
dateBuilder1.delete(0, 5);
statisticsDateAndWorkTimes.get(i).setDate(dateBuilder1.toString());
}
}
}
}
}
} }
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