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

完善项目统计报表

parent e289fd64
......@@ -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> {
int insertBatch(@Param("userIds") List<Integer> userIds,@Param("projectId") Integer projectId);
List<Integer> selectUserIdByProjectIds(@Param("projectIds") List<Integer> projectIds);
}
......@@ -81,8 +81,11 @@
select <include refid="Base_Column_List"/>
from <include refid="table"/>
<where>
<if test="isConclusion != null">
is_conclusion = #{isConclusion}
</if>
<if test="managerId != null">
manager_id = #{managerId}
AND manager_id = #{managerId}
</if>
<if test="deptId != null">
OR dept_id = #{deptId}
......@@ -113,15 +116,14 @@
</where>
</select>
<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,
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',
if(now() BETWEEN p.start_time and p.end_time,'否','是') as 'isItOverdue',
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
LEFT JOIN work_user u on p.manager_id = u.id
<where>
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,
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(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange'
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
<where>
<if test="null != userId">
AND p.manager_id = #{userId}
</if>
......@@ -131,21 +133,14 @@ if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange'
<if test="null !=isConclusion">
AND p.is_conclusion = #{isConclusion}
</if>
<if test="deptIds != null">
OR p.dept_id IN
<foreach collection="deptIds" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
</where>
GROUP BY p.id
</where>
GROUP BY p.id
</select>
......
......@@ -112,10 +112,7 @@
<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,
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
<where>
......
......@@ -298,13 +298,16 @@
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 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
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">
AND t.work_day > #{startDate}
</if>
AND p.is_conclusion=#{status} AND t.type not in(3,4)
<if test="projectIds != null">
AND project_id in
<foreach collection="projectIds" item="projectId" open="(" close=")" separator=",">
......@@ -312,5 +315,18 @@
</foreach>
</if>
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>
</mapper>
......@@ -38,4 +38,13 @@
WHERE project_id = #{projectId}
</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>
......@@ -5,8 +5,8 @@ public enum ProjectTypeEnum {
BUSINESS_OPPORTUNITY(2, "商机", 1),
LEAVE(3, "请假", 2),
COMPENSATORY_LEAVE(4, "调休", 2),
EXTERNAL_BUSINESS(5, "外部商务技术交流", 3),
INTERNAL_TRAINING(6, "内部培训、技术准备、管理", 3),
EXTERNAL_BUSINESS(5, "外部商务/技术交流", 3),
INTERNAL_TRAINING(6, "内部培训/技术准备/管理", 3),
OTHER_NON_PROJECTS(7, "其他非项目/商机工作", 3),
;
......
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