select <iftest="deptId != null">'合计' AS project_name,</if><iftest="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 <iftest="projectId == null">'合计' AS project_name,</if><iftest="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>
<iftest="projectId != null ">
ptc.project_id = #{projectId}
</if>
<iftest="deptId != null">
<iftest="deptId != null and managerId == null">
AND p.dept_id = #{deptId} AND year(statistics_start) = #{year}
</if>
<iftest="deptId != null and managerId == null">
AND (p.dept_id = #{deptId} OR p.manager_id= #{managerId}) AND year(statistics_start) = #{year}
</if>
<iftest="deptId == null and managerId != null">
AND p.manager_id = #{managerId} AND year(statistics_start) = #{year}
</if>
</where>
group by <iftest="projectId != null"> project_name,</if> year(statistics_start),MONTH(statistics_start)
</select>
...
...
@@ -129,12 +134,18 @@
sum(total_time) AS total_time, sum(cost) AS cost <iftest="projectId != null "> ,d.dept_name AS dept_name</if>
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>
<iftest="projectId != null ">
ptc.project_id = #{projectId}
</if>
<iftest="deptId != null">
AND p.dept_id = #{deptId} AND year(statistics_start) = #{year}
</if>
<iftest="projectId != null ">
ptc.project_id = #{projectId}
</if>
<iftest="deptId != null and managerId == null">
AND p.dept_id = #{deptId} AND year(statistics_start) = #{year}
</if>
<iftest="deptId != null and managerId == null">
AND (p.dept_id = #{deptId} OR p.manager_id= #{managerId}) AND year(statistics_start) = #{year}
</if>
<iftest="deptId == null and managerId != null">
AND p.manager_id = #{managerId} AND year(statistics_start) = #{year}
</if>
</where>
group by ptc.project_id,project_name,year(statistics_start),MONTH(statistics_start) <iftest="projectId != null "> ,d.dept_name</if>
SELECT <iftest="isAll"> u.id AS user_id, u.`name` AS user_name,</if><iftest="!isAll">'合计' AS user_name ,</if> t.project_id AS project_id, t.type AS project_type, p.project_name AS project_name,IF(t.is_overtime = 0, 0, sum(t.work_time)) AS over_time, if(t.is_overtime=1, 0, sum(t.work_time)) AS normal_time
SELECT <iftest="isAll"> u.id AS user_id, u.`name` AS user_name,</if><iftest="!isAll">'合计' AS user_name ,</if> t.project_id AS project_id, t.type AS project_type, p.project_name AS project_name,
IF(t.is_overtime = 0, <iftest="!isAll">0</if><iftest="isAll">null</if>, sum(t.work_time)) AS over_time, if(t.is_overtime=1, <iftest="!isAll">0</if><iftest="isAll">null</if>, sum(t.work_time)) AS normal_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
...
...
@@ -323,11 +324,13 @@
<iftest="isConclusion != null">
AND p.is_conclusion = #{isConclusion}
</if>
<iftest="deptId != null">
<iftest="deptId != null and managerId == null">
AND p.dept_id = #{deptId}
</if>
<iftest="managerId != null">
<iftest="deptId != null and managerId != null">
AND (p.dept_id = #{deptId} OR p.manager_id = #{managerId})