Commit 145e31b8 authored by nie'hong's avatar nie'hong

完善小程序工时统计

parent f8dd35c0
...@@ -20,4 +20,6 @@ public interface WorkDeptMapper extends BaseMapper<WorkDept> { ...@@ -20,4 +20,6 @@ public interface WorkDeptMapper extends BaseMapper<WorkDept> {
List<WorkDept> getDeptByCondition(Map<String, Object> map); List<WorkDept> getDeptByCondition(Map<String, Object> map);
List<OrganizationStructureDto> getAllDeptByAllCentre(); List<OrganizationStructureDto> getAllDeptByAllCentre();
WorkDept getById(Integer deptId);
} }
...@@ -80,10 +80,11 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -80,10 +80,11 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/** /**
* 获取上班日期集合 * 获取上班日期集合
* *
* @param firstDayOfMonth * @param date
* @param userId
* @return * @return
*/ */
List<Date> getDaysByDateAndStatus(@Param("firstDayOfMonth") Date firstDayOfMonth, @Param("userId") Integer userId); List<Date> getDaysByDateAndStatus(@Param("userId") Integer userId, @Param("date") Date date);
List<WorkTimeOrder> getAutoOrder(Integer autoExamine); List<WorkTimeOrder> getAutoOrder(Integer autoExamine);
...@@ -93,7 +94,7 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -93,7 +94,7 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/** /**
* 获取人员项目工时 * 获取人员项目工时
*/ */
List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("isConclusion") Integer isConclusion, @Param("projectIds") List<Integer> projectIds, @Param("isAll") Boolean isAll); List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectIds") List<Integer> projectIds, @Param("isAll") Boolean isAll);
/** /**
* 根据工单状态获取填报条数 * 根据工单状态获取填报条数
...@@ -106,5 +107,5 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -106,5 +107,5 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
List<MonthlyWorkingHoursStatistics> selectCountByTypeAndStatus(@Param("userId") Integer userId, @Param("firstDayOfMonth") Date firstDayOfMonth, @Param("status") Integer[] status); List<MonthlyWorkingHoursStatistics> selectCountByTypeAndStatus(@Param("userId") Integer userId, @Param("firstDayOfMonth") Date firstDayOfMonth, @Param("status") Integer[] status);
List<UserWorkTimeStatisticsByProject> selectListByType(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("isConclusion") Integer isConclusion, @Param("queryType") List<Integer> queryType, @Param("userIds") List<Integer> userIds, @Param("isAll") Boolean isAll); List<UserWorkTimeStatisticsByProject> selectListByType(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("queryType") List<Integer> queryType, @Param("userIds") List<Integer> userIds, @Param("isAll") Boolean isAll);
} }
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</sql> </sql>
<sql id="cols_exclude_id"> <sql id="cols_exclude_id">
dept_name, create_time, modify_time dept_name,oa_dept_id,dept_manager_id,centre_id, create_time, modify_time
</sql> </sql>
<sql id="criteria"> <sql id="criteria">
...@@ -64,5 +64,11 @@ from work_centre c LEFT JOIN work_dept d ON c.id = d.centre_id ...@@ -64,5 +64,11 @@ from work_centre c LEFT JOIN work_dept d ON c.id = d.centre_id
ORDER BY c.id,d.id ORDER BY c.id,d.id
</select> </select>
<select id="getById" resultMap="BaseResultMap">
select <include refid="cols_all"/>
from <include refid="table"/>
where id =#{deptId}
</select>
</mapper> </mapper>
...@@ -164,7 +164,8 @@ ORDER BY p.is_conclusion DESC ...@@ -164,7 +164,8 @@ ORDER BY p.is_conclusion DESC
<select id="getListByDeptAndIsConclusion" resultType="cn.wisenergy.model.app.WorkProject"> <select id="getListByDeptAndIsConclusion" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/> select <include refid="Base_Column_List"/>
from <include refid="table"/> from <include refid="table"/>
where dept=#{deptId} AND isConclusion=#{isConclusion} where dept_id = #{deptId}
<if test="isConclusion !=null ">AND is_conclusion=#{isConclusion}</if>
</select> </select>
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
<select id="selectList" resultMap="workTimeAndCostCollect"> <select id="selectList" resultMap="workTimeAndCostCollect">
SELECT type ,dept_name,ptc.dept_id,ptc.project_id AS SELECT type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,ptc.dept_id,</if>ptc.project_id AS
project_id,project_name,min(statistics_start) AS statistics_start,max(statistics_end) AS project_id,project_name,min(statistics_start) AS statistics_start,max(statistics_end) AS
statistics_end,sum(total_time) AS total_time,sum(cost) AS cost statistics_end,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 p.dept_id=d.id from work_project_time_cost ptc join work_project p on ptc.project_id=p.id join work_dept d on p.dept_id=d.id
...@@ -95,14 +95,19 @@ ...@@ -95,14 +95,19 @@
<if test="deptId != null"> <if test="deptId != null">
AND dept_id = #{deptId} AND dept_id = #{deptId}
</if> </if>
AND type in <if test="types != null">
<foreach collection="types" open="(" close=")" separator="," item="type"> AND type in
#{type} <foreach collection="types" open="(" close=")" separator="," item="type">
</foreach> #{type}
</foreach>
</if>
<if test="centreId != null">
AND centre_id = #{centreId}
</if>
<if test="firstDayOfMonth != null"> <if test="firstDayOfMonth != null">
AND statistics_start >= #{firstDayOfMonth} AND statistics_start >= #{firstDayOfMonth}
</if> </if>
GROUP BY type,dept_name,dept_id,ptc.project_id,project_name GROUP BY type, <if test="centreId == null"> dept_name,</if> <if test="centreId != null"> dept_name,ptc.dept_id,</if>ptc.project_id,project_name
</select> </select>
......
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
<select id="statisticsByProjectType" resultMap="monthlyWorkHourStatistics"> <select id="statisticsByProjectType" resultMap="monthlyWorkHourStatistics">
select t2.id AS id , t2.name AS name ,count(1),sum(work_time) select t2.id AS id , t2.name AS name ,count(1),sum(work_time)
from work_time_order t join work_type t2 on t.type = t2.id from work_time_order t join work_type t2 on t.type = t2.id
where user_id = #{userId} AND work_day >= #{currentMonthFirstDay} where user_id = #{userId} AND work_day >= #{currentMonthFirstDay} AND t.status != 3
group by type group by type
</select> </select>
...@@ -232,9 +232,9 @@ ...@@ -232,9 +232,9 @@
</select> </select>
<select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect" > <select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect" >
SELECT t.type AS type,t.dept_id AS dept_id, SELECT t.type AS type, t.dept_id AS dept_id,dept_name,
t.project_id AS project_id ,MIN(t.work_day) AS first_time,MAX(t.work_day) AS last_time,ROUND(SUM(t.work_time)/8,2) AS t.project_id AS project_id ,MIN(t.work_day) AS first_time,MAX(t.work_day) AS last_time,ROUND(SUM(t.work_time)/8,2) AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost,dept_name AS dept_name,project_name total_time, SUM(t.work_time * s.day_salary)/8 AS cost ,project_name
FROM work_time_order t LEFT JOIN work_project p ON t.project_id=p.id LEFT JOIN work_dept d ON t.dept_id=d.id LEFT JOIN work_user_salary s ON s.user_id = t.user_id FROM work_time_order t LEFT JOIN work_project p ON t.project_id=p.id LEFT JOIN work_dept d ON t.dept_id=d.id LEFT JOIN work_user_salary s ON s.user_id = t.user_id
WHERE status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day WHERE status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day
<if test="projectIds != null"> <if test="projectIds != null">
...@@ -254,16 +254,17 @@ ...@@ -254,16 +254,17 @@
<foreach collection="types" item="type" open="(" close=")" separator=","> <foreach collection="types" item="type" open="(" close=")" separator=",">
#{type} #{type}
</foreach> </foreach>
group by t.type,t.dept_id, t.project_id,dept_name,p.project_name group by t.type,t.dept_id, dept_name, t.project_id,p.project_name
order by t.dept_id order by t.dept_id
</select> </select>
<select id="getDaysByDateAndStatus" resultType="date"> <select id="getDaysByDateAndStatus" resultType="date">
select distinct(work_day) select distinct(work_day)
from from
<include refid="table"/> <include refid="table"/>
where work_day >= #{firstDayOfMonth} AND user_id = #{userId} where year(#{date}) = year(work_day) AND month(#{date}) = month(work_day) AND user_id = #{userId} AND status != 3
</select> </select>
<select id="geByMonth" resultType="cn.wisenergy.model.app.WorkTimeOrder"> <select id="geByMonth" resultType="cn.wisenergy.model.app.WorkTimeOrder">
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
...@@ -303,9 +304,6 @@ ...@@ -303,9 +304,6 @@
where where
t.status in (2,5) AND t.status in (2,5) AND
t.work_day &lt;= #{endDate} 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>
...@@ -331,9 +329,6 @@ ...@@ -331,9 +329,6 @@
from work_type ty left join work_time_order t on t.type = ty.id left join work_user u on t.user_id = u.id from work_type ty left join work_time_order t on t.type = ty.id left join work_user u on t.user_id = u.id
where where
(t.work_day &lt;= #{endDate} or t.work_day is null) AND (t.status IN (2, 5) or t.status is null) (t.work_day &lt;= #{endDate} or t.work_day is null) AND (t.status IN (2, 5) or t.status is null)
<if test="isConclusion != null">
AND (p.is_conclusion = #{isConclusion} or p.is_conclusion is null)
</if>
<if test="startDate != null"> <if test="startDate != null">
AND (t.work_day > #{startDate} or t.work_day is null) AND (t.work_day > #{startDate} or t.work_day is null)
</if> </if>
......
...@@ -6,10 +6,7 @@ import cn.wisenergy.common.utils.ExcelUtils; ...@@ -6,10 +6,7 @@ import cn.wisenergy.common.utils.ExcelUtils;
import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM; import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException; import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.*; import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.WorkHoliday; import cn.wisenergy.model.app.*;
import cn.wisenergy.model.app.WorkProject;
import cn.wisenergy.model.app.WorkType;
import cn.wisenergy.model.app.WorkUser;
import cn.wisenergy.model.dto.*; import cn.wisenergy.model.dto.*;
import cn.wisenergy.model.enums.*; import cn.wisenergy.model.enums.*;
import cn.wisenergy.service.StatisticsService; import cn.wisenergy.service.StatisticsService;
...@@ -70,6 +67,10 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -70,6 +67,10 @@ public class StatisticsServiceImpl implements StatisticsService {
@Autowired @Autowired
private WorkProjectMapper workProjectMapper; private WorkProjectMapper workProjectMapper;
@Autowired
private WorkDeptMapper workDeptMapper;
@Autowired @Autowired
private WorkUserProjectMapper workUserProjectMapper; private WorkUserProjectMapper workUserProjectMapper;
...@@ -145,7 +146,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -145,7 +146,7 @@ public class StatisticsServiceImpl implements StatisticsService {
List<Integer> role = userRoleLevelUtils.getRole(user.getId()); List<Integer> role = userRoleLevelUtils.getRole(user.getId());
//本月第一天 //本月第一天
Date firstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth(); Date firstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth();
//返回数据对象 // 返回数据对象
Map<String, Object> objects = new HashMap<>(); Map<String, Object> objects = new HashMap<>();
//存放查询条件 //存放查询条件
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -196,7 +197,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -196,7 +197,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 本月应填报日期 // 本月应填报日期
List<Date> currentMonthWorkDays = this.currentMonthWorkDays(firstDayOfMonth); List<Date> currentMonthWorkDays = this.currentMonthWorkDays(firstDayOfMonth);
// 本月已填报日期 // 本月已填报日期
List<Date> currentMonthFilledDays = currentMonthFilledDays(userId); List<Date> currentMonthFilledDays = this.currentMonthFilledDays(userId, firstDayOfMonth);
// 本月未填报日期 // 本月未填报日期
currentMonthWorkDays.removeAll(currentMonthFilledDays); currentMonthWorkDays.removeAll(currentMonthFilledDays);
int notFilledCount = currentMonthWorkDays.size(); int notFilledCount = currentMonthWorkDays.size();
...@@ -285,29 +286,46 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -285,29 +286,46 @@ public class StatisticsServiceImpl implements StatisticsService {
if (StringUtil.isNotEmpty(startTime)) { if (StringUtil.isNotEmpty(startTime)) {
map.put("firstDayOfMonth", startTime); map.put("firstDayOfMonth", startTime);
} }
// 查询所有类型
// 工时类型包含:项目,商机
List<Integer> types = new ArrayList<>();
List<WorkType> workTypes = workTypeMapper.getAll(); List<WorkType> workTypes = workTypeMapper.getAll();
types.add(workTypes.get(1).getId());
types.add(workTypes.get(2).getId()); if (role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
map.put("types", types); WorkDept workDept = workDeptMapper.getById(user.getDeptId());
map.put("centreId",workDept.getCentreId() );
}
// 查询项目和商机的工时统计 // 查询项目和商机的工时统计
List<WorkTimeAndCostCollect> collect = workProjectTimeCostMapper.selectList(map); List<WorkTimeAndCostCollect> collect = workProjectTimeCostMapper.selectList(map);
// 获取查询出的类型
List<Integer> queryType = collect.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList());
// 商机和项目
List<Integer> types = new ArrayList<>();
types.add(workTypes.get(0).getId());
types.add(workTypes.get(1).getId());
// 如果查询出的结果中不包含项目和商机中的类型,造对象传前端
types.removeAll(queryType);
if (CollectionUtil.isNotEmpty(types)) {
for (Integer type : types) {
WorkTimeAndCostCollect workTimeAndCostCollect = new WorkTimeAndCostCollect();
workTimeAndCostCollect.setType(type);
workTimeAndCostCollect.setWorkTime(new BigDecimal("0.0000"));
collect.add(workTimeAndCostCollect);
}
}
// 部门和中心级别 // 部门和中心级别
if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) || role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) { if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) || role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
// 请假、调休、外部商务、技术交流,内部培训、技术准备、管理,其他非项目/商机工作 // 清除查询条件
types.clear();
map.clear(); map.clear();
// 请假、调休、外部商务、技术交流,内部培训、技术准备、管理,其他非项目/商机工作
for (WorkType workType : workTypes) { for (WorkType workType : workTypes) {
// 查询条件排除项目和商机 // 查询条件排除项目和商机
if (!workType.getName().equals(workTypes.get(1).getName()) && !workType.getName().equals(workTypes.get(2).getName())) { if (!workType.getName().equals(workTypes.get(0).getName()) && !workType.getName().equals(workTypes.get(1).getName())) {
types.add(workType.getId()); types.add(workType.getId());
} }
} }
// 用户仅为部门管理 // 用户仅为部门管理
if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) && role.size() == 1) { if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) && role.size() == 1) {
map.put("deptId", user.getDeptId()); map.put("deptId", user.getDeptId());
...@@ -317,10 +335,6 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -317,10 +335,6 @@ public class StatisticsServiceImpl implements StatisticsService {
// 将查询结果封装在一起 // 将查询结果封装在一起
collect.addAll(workTimeAndCostCollect); collect.addAll(workTimeAndCostCollect);
for (WorkTimeAndCostCollect timeAndCostCollect : collect) {
WorkType workType = workTypes.get(timeAndCostCollect.getType() - 1);
timeAndCostCollect.setTypeName(workType.getName());
}
// 获取查询结果中的类型 // 获取查询结果中的类型
List<Integer> typeList = collect.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList()); List<Integer> typeList = collect.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList());
// 如果查询结果不包含查询条件中的类型,造对象传前端 // 如果查询结果不包含查询条件中的类型,造对象传前端
...@@ -333,9 +347,15 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -333,9 +347,15 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
} }
} }
// 给类型赋值类型名称
for (WorkTimeAndCostCollect timeAndCostCollect : collect) {
WorkType workType = workTypes.get(timeAndCostCollect.getType() - 1);
timeAndCostCollect.setTypeName(workType.getName());
}
for (WorkTimeAndCostCollect workTimeAndCostCollect : collect) { for (WorkTimeAndCostCollect workTimeAndCostCollect : collect) {
// 类型的总工时 // 类型的总工时
BigDecimal typeTotalTime = new BigDecimal("0.00"); BigDecimal typeTotalTime = new BigDecimal("0.0000");
List<DeptProjectWorkTimeAndCost> deptProjectWorkTimeAndCosts = workTimeAndCostCollect.getDeptProjectWorkTimeAndCosts(); List<DeptProjectWorkTimeAndCost> deptProjectWorkTimeAndCosts = workTimeAndCostCollect.getDeptProjectWorkTimeAndCosts();
if (CollectionUtil.isNotEmpty(deptProjectWorkTimeAndCosts)) { if (CollectionUtil.isNotEmpty(deptProjectWorkTimeAndCosts)) {
for (DeptProjectWorkTimeAndCost deptProjectWorkTimeAndCost : deptProjectWorkTimeAndCosts) { for (DeptProjectWorkTimeAndCost deptProjectWorkTimeAndCost : deptProjectWorkTimeAndCosts) {
...@@ -478,7 +498,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -478,7 +498,7 @@ public class StatisticsServiceImpl implements StatisticsService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN); throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
} }
// 不是中心级不能选择部门 // 不是中心级不能选择部门
if (!role.contains(ManagerEnum.IS_CENTRE_DIRECTOR) && deptId != null) { if (!role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode()) && deptId != null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY); throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY);
} }
...@@ -489,9 +509,11 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -489,9 +509,11 @@ public class StatisticsServiceImpl implements StatisticsService {
endDate = DateUtil.convertDateToYMDStr(yesterday); endDate = DateUtil.convertDateToYMDStr(yesterday);
} }
// 获取用户负责项目主键集合 // 获取用户负责项目主键集合
List<WorkProject> userManageProjects = workProjectService.getUserManageProjects(userId); List<WorkProject> userManageProjects;
if (deptId != null) { if (deptId != null) {
userManageProjects = workProjectMapper.getListByDeptAndIsConclusion(deptId, isConclusion); userManageProjects = workProjectMapper.getListByDeptAndIsConclusion(deptId, isConclusion);
}else {
userManageProjects = workProjectService.getUserManageProjects(userId);
} }
// 管理项目为空则提前结束 // 管理项目为空则提前结束
if (CollectionUtil.isEmpty(userManageProjects)) { if (CollectionUtil.isEmpty(userManageProjects)) {
...@@ -501,7 +523,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -501,7 +523,7 @@ 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> userProjectWorkTimeStatistics = workTimeOrderMapper.getUserProjectWorkTimeStatistics(startDate, endDate, isConclusion, projectIds, false); List<UserWorkTimeStatisticsByProject> userProjectWorkTimeStatistics = workTimeOrderMapper.getUserProjectWorkTimeStatistics(startDate, endDate, projectIds, false);
// 查询除开项目于、商机、请假、调休这几种类型的工单 // 查询除开项目于、商机、请假、调休这几种类型的工单
List<WorkType> types = workTypeMapper.getAll(); List<WorkType> types = workTypeMapper.getAll();
...@@ -514,15 +536,15 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -514,15 +536,15 @@ public class StatisticsServiceImpl implements StatisticsService {
// 部门级别以上的用户可以查询所管理项目的成员所填的其他类型的工单 // 部门级别以上的用户可以查询所管理项目的成员所填的其他类型的工单
List<Integer> userIds = workUserProjectMapper.selectUserIdByProjectIds(projectIds); List<Integer> userIds = workUserProjectMapper.selectUserIdByProjectIds(projectIds);
if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) || role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) { if (role.contains(ManagerEnum.IS_DEPARTMENT_DIRECTOR.getCode()) || role.contains(ManagerEnum.IS_CENTRE_DIRECTOR.getCode())) {
List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsByProjectList = workTimeOrderMapper.selectListByType(startDate, endDate, isConclusion, queryType, userIds,false); List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsByProjectList = workTimeOrderMapper.selectListByType(startDate, endDate, queryType, userIds,false);
if (CollectionUtil.isNotEmpty(userWorkTimeStatisticsByProjectList)) { if (CollectionUtil.isNotEmpty(userWorkTimeStatisticsByProjectList)) {
userProjectWorkTimeStatistics.get(0).getProjectWorkTimeAndType().addAll(userWorkTimeStatisticsByProjectList.get(0).getProjectWorkTimeAndType()); userProjectWorkTimeStatistics.get(0).getProjectWorkTimeAndType().addAll(userWorkTimeStatisticsByProjectList.get(0).getProjectWorkTimeAndType());
} }
} }
// 查询各个项目下所有人的加班工时和平常工时 // 查询各个项目下所有人的加班工时和平常工时
List<UserWorkTimeStatisticsByProject> userProjectWorkTimeStatistics1 = workTimeOrderMapper.getUserProjectWorkTimeStatistics(startDate, endDate, isConclusion, projectIds, true); List<UserWorkTimeStatisticsByProject> userProjectWorkTimeStatistics1 = workTimeOrderMapper.getUserProjectWorkTimeStatistics(startDate, endDate, projectIds, true);
// 查询各个项目下所有人的其他除了项目、商机、请假、调休类型的加班工时和平常工时 // 查询各个项目下所有人的其他除了项目、商机、请假、调休类型的加班工时和平常工时
List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsByProjects = workTimeOrderMapper.selectListByType(startDate, endDate, isConclusion, queryType, userIds, true); List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsByProjects = workTimeOrderMapper.selectListByType(startDate, endDate, queryType, userIds, true);
for (UserWorkTimeStatisticsByProject userWorkTimeStatisticsByProject : userWorkTimeStatisticsByProjects) { for (UserWorkTimeStatisticsByProject userWorkTimeStatisticsByProject : userWorkTimeStatisticsByProjects) {
for (UserWorkTimeStatisticsByProject workTimeStatisticsByProject : userProjectWorkTimeStatistics1) { for (UserWorkTimeStatisticsByProject workTimeStatisticsByProject : userProjectWorkTimeStatistics1) {
if (userWorkTimeStatisticsByProject.getUserId() != null && userWorkTimeStatisticsByProject.getUserId().equals(workTimeStatisticsByProject.getUserId())) { if (userWorkTimeStatisticsByProject.getUserId() != null && userWorkTimeStatisticsByProject.getUserId().equals(workTimeStatisticsByProject.getUserId())) {
...@@ -531,12 +553,6 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -531,12 +553,6 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
} }
userProjectWorkTimeStatistics.addAll(userProjectWorkTimeStatistics1); userProjectWorkTimeStatistics.addAll(userProjectWorkTimeStatistics1);
/*
*
*
*
* */
// 取出单人的项目工时统计 // 取出单人的项目工时统计
for (UserWorkTimeStatisticsByProject userProjectWorkTimeStatistic : userProjectWorkTimeStatistics) { for (UserWorkTimeStatisticsByProject userProjectWorkTimeStatistic : userProjectWorkTimeStatistics) {
...@@ -578,18 +594,25 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -578,18 +594,25 @@ public class StatisticsServiceImpl implements StatisticsService {
// 部门主键不为空时,日期格式只有某月。为空时,日期格式为某年统计的第一个月为某年某月,其余为某月 // 部门主键不为空时,日期格式只有某月。为空时,日期格式为某年统计的第一个月为某年某月,其余为某月
this.conversionDateFormat(projectStatisticsByMonths, deptId); this.conversionDateFormat(projectStatisticsByMonths, deptId);
List<ProjectStatisticsByMonth> projectStatisticsByMonths1 = workProjectTimeCostMapper.selectListStatistics(year, deptId, projectId); List<ProjectStatisticsByMonth> projectStatisticsByMonths1 = workProjectTimeCostMapper.selectListStatistics(year, deptId, projectId);
// 将查询结果封装在一起 // 将查询结果封装在一起,部门主键为空,项目总计在前,否则在后
projectStatisticsByMonths.addAll(projectStatisticsByMonths1); List<ProjectStatisticsByMonth> projectStatistics = new ArrayList<>();
if (deptId == null) {
projectStatistics.addAll(projectStatisticsByMonths);
projectStatistics.addAll(projectStatisticsByMonths1);
}else {
projectStatistics.addAll(projectStatisticsByMonths1);
projectStatistics.addAll(projectStatisticsByMonths);
}
// 计算项目工时和成本合计 // 计算项目工时和成本合计
for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) { for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths1) {
// 一条统计的 // 一条统计的
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth.getStatisticsDateAndWorkTimes(); List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth.getStatisticsDateAndWorkTimes();
// 项目合计对象 // 项目合计对象
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime1 = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime(); ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime1 = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime();
statisticsDateAndWorkTime1.setDate("项目合计"); statisticsDateAndWorkTime1.setDate("项目合计");
BigDecimal totalTime = new BigDecimal("0.00"); BigDecimal totalTime = new BigDecimal("0.0000");
BigDecimal cost = new BigDecimal("0.00"); BigDecimal cost = new BigDecimal("0.0000");
// 统计项目工时和成本 // 统计项目工时和成本
for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime : statisticsDateAndWorkTimes) { for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime : statisticsDateAndWorkTimes) {
totalTime = totalTime.add(statisticsDateAndWorkTime.getTotalTime()); totalTime = totalTime.add(statisticsDateAndWorkTime.getTotalTime());
...@@ -600,8 +623,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -600,8 +623,7 @@ public class StatisticsServiceImpl implements StatisticsService {
statisticsDateAndWorkTime1.setCost(cost); statisticsDateAndWorkTime1.setCost(cost);
statisticsDateAndWorkTimes.add(statisticsDateAndWorkTime1); statisticsDateAndWorkTimes.add(statisticsDateAndWorkTime1);
} }
return projectStatisticsByMonths1;
return projectStatisticsByMonths;
} }
//获取一个月应上班日期,如果是当月,时间截至到当天 //获取一个月应上班日期,如果是当月,时间截至到当天
...@@ -613,7 +635,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -613,7 +635,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 当前时间 // 当前时间
Date now = new Date(); Date now = new Date();
if (DateUtil.getYear(date) == DateUtil.getYear(now) && DateUtil.getMonth(date) == DateUtil.getMonth(now)) { if (DateUtil.getYear(date) == DateUtil.getYear(now) && DateUtil.getMonth(date) == DateUtil.getMonth(now)) {
endDate = now; endDate = DateUtil.getStartOfDay(now);
} else { } else {
endDate = DateUtil.getLastDayOfMonth(date); endDate = DateUtil.getLastDayOfMonth(date);
} }
...@@ -649,11 +671,10 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -649,11 +671,10 @@ public class StatisticsServiceImpl implements StatisticsService {
return workDays; return workDays;
} }
//获取用户本月已填报的日期 //获取用户某月已填报的日期,如果一天中只有被驳回则不为已填报
public List<Date> currentMonthFilledDays(Integer userId) { public List<Date> currentMonthFilledDays(Integer userId, Date date) {
log.info("StatisticsServiceImpl[]currentMonthFilledDays[]input.method"); log.info("StatisticsServiceImpl[]currentMonthFilledDays[]input.method");
Date firstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth(); List<Date> currentMonthFilledDays = workTimeOrderMapper.getDaysByDateAndStatus( userId, date);
List<Date> currentMonthFilledDays = workTimeOrderMapper.getDaysByDateAndStatus(firstDayOfMonth, userId);
return currentMonthFilledDays; 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