Commit 3f97e249 authored by nie'hong's avatar nie'hong

完善工时统计

parent 7c183d72
......@@ -51,4 +51,6 @@ public interface WorkProjectMapper extends BaseMapper<WorkProject> {
int updateProject(ModifyProjectVo modifyProjectVo);
List<WorkProject> getListByDeptAndIsConclusion(@Param("deptId") Integer deptId,@Param("isConclusion") Integer isConclusion);
List<Integer> getProjectIdByManager(Integer userId);
}
......@@ -168,5 +168,11 @@ ORDER BY p.is_conclusion DESC
<if test="isConclusion !=null ">AND is_conclusion=#{isConclusion}</if>
</select>
<select id="getProjectIdByManager" resultType="java.lang.Integer">
select id
from <include refid="table"/>
where manager_id = #{userId}
</select>
</mapper>
......@@ -210,15 +210,16 @@
<if test="startDay != null">
AND work_day>=#{startDay}
</if>
<if test="projectIds != null">
<if test="projectIdList != null">
AND project_id IN
<foreach collection="projectIds" item="projectId" open="(" close=")" separator=",">
<foreach collection="projectIdList" item="projectId" open="(" close=")" separator=",">
#{projectId}
</foreach>
</if>
<if test="statusArray != null">
AND `status` IN
<foreach collection="statusArray" item="workStatus" open="(" close=")" separator=",">#{workStatus}
<foreach collection="statusArray" item="workStatus" open="(" close=")" separator=",">
#{workStatus}
</foreach>
</if>
<if test="typeList != null">
......
......@@ -6,7 +6,8 @@ package cn.wisenergy.model.enums;
*/
public enum LevelEnum {
EXAMINE("工时审批"),
STATISTICS("统计"),
USER_STATISTICS("人员统计报表"),
PROJECT_STATITSTICS("项目统计报表"),
PROJECT_MANAGER( "项目/商机管理"),
TIMEEXPORT("工时导出"),
SYSTEMSETTINGS("系统设置"),
......
......@@ -148,13 +148,13 @@ public class StatisticsServiceImpl implements StatisticsService {
log.info("WorkTimeOrderServiceImpl[]getMonthlyStatistics[]input.param" + userId);
WorkUser user = workUserService.getById(userId);
List<String> userAuthority = this.getUserAuthority(userId);
//本月第一天
// 本月第一天
Date firstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth();
// 返回数据对象
Map<String, Object> objects = new HashMap<>();
//存放查询条件
// 存放查询条件
Map<String, Object> map = new HashMap<>();
//用户是项目或部门级别,查询审批统计
// 用户有审批权限
if (userAuthority.contains(LevelEnum.EXAMINE.getLevelName())) {
//以审批人、审核状态、开始时间查询本月审批数量
map.put("reviewerId", userId);
......@@ -165,39 +165,45 @@ public class StatisticsServiceImpl implements StatisticsService {
map.put("status", WorkOrderStatus.TURN_DOWN.getCode());
Integer rejectAndNotResubmit = workTimeOrderMapper.getCountByCondition(map);
// 查询用户负责项目
List<WorkProject> projects = workProjectService.getUserManageProjects(userId);
if (CollectionUtil.isNotEmpty(projects)) {
List<Integer> projectIds = projects.stream().map(WorkProject::getId).collect(Collectors.toList());
map.put("projectIds", projectIds);
// 移除查询审批人和状态条件
map.remove("reviewerId");
map.remove("status");
//待审核包括:新提交和重新提交的
List<Integer> statusArray = new ArrayList<>();
statusArray.add(WorkOrderStatus.WAIT_AUDIT.getCode());
statusArray.add(WorkOrderStatus.RE_SUBMIT.getCode());
//本月未审批数量查询
map.put("statusArray", statusArray);
// 查询用户负责的项目和商机id
List<Integer> projectIdList = workProjectMapper.getProjectIdByManager(userId);
if (CollectionUtil.isNotEmpty(projectIdList)) {
map.put("projectIdList", projectIdList);
}
// 项目和商机的未审批的条数
Integer notCompletedCount1 = workTimeOrderMapper.getCountByCondition(map);
// 查询用户负责审批的除项目合商机的其余类型
List<WorkTypeManager> workTypeManagers = workTypeManagerMapper.getListByManagerId(userId);
if (CollectionUtil.isNotEmpty(workTypeManagers)) {
map.remove("projectIdList");
List<Integer> type = workTypeManagers.stream().map(WorkTypeManager::getType).collect(Collectors.toList());
map.put("typeList", type);
map.put("deptId", user.getDeptId());
}
// 其余类型为审批的条数
Integer notCompletedCount2 = workTimeOrderMapper.getCountByCondition(map);
//待审核包括:新提交和重新提交的
List<Integer> statusArray = new ArrayList<>();
statusArray.add(WorkOrderStatus.WAIT_AUDIT.getCode());
statusArray.add(WorkOrderStatus.RE_SUBMIT.getCode());
map.remove("reviewerId");
map.remove("status");
//本月未审批数量查询
map.put("statusArray", statusArray);
Integer notCompletedCount = workTimeOrderMapper.getCountByCondition(map);
//所有查询结果封装进对象
ApprovalStatistics approvalStatistics = new ApprovalStatistics();
approvalStatistics.setApprovalCount(completedCount);
approvalStatistics.setRejectNotSubmit(rejectAndNotResubmit);
approvalStatistics.setNotApprovalCount(notCompletedCount);
approvalStatistics.setNotApprovalCount(notCompletedCount1 + notCompletedCount2);
objects.put("manager", approvalStatistics);
}
// 填报情况
// 本月应填报日期
List<Date> currentMonthWorkDays = this.currentMonthWorkDays(firstDayOfMonth,true);
List<Date> currentMonthWorkDays = this.currentMonthWorkDays(firstDayOfMonth, true);
// 本月已填报日期
List<Date> currentMonthFilledDays = this.currentMonthFilledDays(userId, firstDayOfMonth);
// 本月未填报日期
......@@ -258,14 +264,6 @@ public class StatisticsServiceImpl implements StatisticsService {
if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
WorkUser user = workUserService.getById(userId);
// 时间不为空,赋值当月第一天
if (StringUtil.isNotEmpty(startTime)) {
Date currentFirstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth();
startTime = DateUtil.convertDateToYMDStr(currentFirstDayOfMonth);
}
// 用户角色
List<Integer> role = UserRoleLevelUtils.getRole(userId);
// 用户权限
......@@ -274,6 +272,13 @@ public class StatisticsServiceImpl implements StatisticsService {
if (!userAuthority.contains(LevelEnum.EXAMINE.getLevelName())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
WorkUser user = workUserService.getById(userId);
// 时间不为空,赋值当月第一天
if (StringUtil.isNotEmpty(startTime)) {
Date currentFirstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth();
startTime = DateUtil.convertDateToYMDStr(currentFirstDayOfMonth);
}
// 查询用户管理的项目
List<WorkProject> userManageProjects = workProjectService.getUserManageProjects(userId);
......@@ -295,7 +300,7 @@ public class StatisticsServiceImpl implements StatisticsService {
if (role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
WorkDept workDept = workDeptMapper.getById(user.getDeptId());
map.put("centreId",workDept.getCentreId() );
map.put("centreId", workDept.getCentreId());
}
// 查询项目和商机的工时统计
List<WorkTimeAndCostCollect> collect = workProjectTimeCostMapper.selectList(map);
......@@ -411,7 +416,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 第一列列宽
sheet.setColumnWidth(1, EXCEL_WIDTH);
// 获取本月应上班日期集合
List<Date> dates = this.currentMonthWorkDays(date,false);
List<Date> dates = this.currentMonthWorkDays(date, false);
List<Integer> days = new ArrayList<>();
for (Date date1 : dates) {
days.add(DateUtil.getDay(date1));
......@@ -529,7 +534,7 @@ public class StatisticsServiceImpl implements StatisticsService {
List<WorkProject> userManageProjects;
if (deptId != null) {
userManageProjects = workProjectMapper.getListByDeptAndIsConclusion(deptId, isConclusion);
}else {
} else {
userManageProjects = workProjectService.getUserManageProjects(userId);
}
// 管理项目为空则提前结束
......@@ -553,7 +558,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 部门级别以上的用户可以查询所管理项目的成员所填的其他类型的工单
List<Integer> userIds = workUserProjectMapper.selectUserIdByProjectIds(projectIds);
if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) || role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsByProjectList = workTimeOrderMapper.selectListByType(startDate, endDate, queryType, userIds,false);
List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsByProjectList = workTimeOrderMapper.selectListByType(startDate, endDate, queryType, userIds, false);
if (CollectionUtil.isNotEmpty(userWorkTimeStatisticsByProjectList)) {
userProjectWorkTimeStatistics.get(0).getProjectWorkTimeAndType().addAll(userWorkTimeStatisticsByProjectList.get(0).getProjectWorkTimeAndType());
}
......@@ -577,7 +582,7 @@ public class StatisticsServiceImpl implements StatisticsService {
List<ProjectWorkTimeAndType> projectWorkTimeAndType1 = userProjectWorkTimeStatistic.getProjectWorkTimeAndType();
// 遍历一个人所有项目统计,计算所有项目所有工时总和
for (ProjectWorkTimeAndType projectWorkTimeAndType : projectWorkTimeAndType1) {
projectWorkTimeAndType.setProjectTypeName(types.get(projectWorkTimeAndType.getProjectType()-1).getName());
projectWorkTimeAndType.setProjectTypeName(types.get(projectWorkTimeAndType.getProjectType() - 1).getName());
totalTime += projectWorkTimeAndType.getWorkTime();
}
userProjectWorkTimeStatistic.setTotalTime(totalTime);
......@@ -589,11 +594,9 @@ public class StatisticsServiceImpl implements StatisticsService {
@Override
public List<ProjectStatisticsByMonth> getProjectStatistics(Integer userId, Integer deptId, Integer year, Integer projectId) {
log.info("StatisticsServiceImpl[]getProjectStatistics[]input.param" + userId + deptId + year + projectId);
// 获取角色
List<Integer> role = userRoleLevelUtils.getRole(userId);
// 获取权限
List<String> userAuthority = this.getUserAuthority(userId);
if (!role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
if (!userAuthority.contains(LevelEnum.PROJECT_STATITSTICS.getLevelName())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY);
}
// 默认查询时间为当前
......@@ -618,7 +621,7 @@ public class StatisticsServiceImpl implements StatisticsService {
if (deptId == null) {
projectStatistics.addAll(projectStatisticsByMonths);
projectStatistics.addAll(projectStatisticsByMonths1);
}else {
} else {
projectStatistics.addAll(projectStatisticsByMonths1);
projectStatistics.addAll(projectStatisticsByMonths);
}
......@@ -694,7 +697,7 @@ public class StatisticsServiceImpl implements StatisticsService {
//获取用户某月已填报的日期,如果一天中只有被驳回则不为已填报
public List<Date> currentMonthFilledDays(Integer userId, Date date) {
log.info("StatisticsServiceImpl[]currentMonthFilledDays[]input.method");
List<Date> currentMonthFilledDays = workTimeOrderMapper.getDaysByDateAndStatus( userId, date);
List<Date> currentMonthFilledDays = workTimeOrderMapper.getDaysByDateAndStatus(userId, date);
return currentMonthFilledDays;
}
......
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