|
@@ -1486,33 +1486,34 @@
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
- <!--获取按维度分组的工时成本-->
|
|
|
+ <!--获取按项目分组的工时成本-->
|
|
|
<select id="getExportDegreeCost" resultType="java.util.Map">
|
|
|
- SELECT r.name as name,report.degree_id as id,SUM(report.working_time) AS cost, SUM(report.cost) AS costMoney
|
|
|
- FROM report
|
|
|
- LEFT JOIN report_extra_degree AS r ON report.degree_id = r.id
|
|
|
- WHERE report.company_id = #{companyId}
|
|
|
+ SELECT a.id, a.project_code as projectCode, a.project_name AS projectName, SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney,a.category_name as categoryName
|
|
|
+ FROM project AS a
|
|
|
+ LEFT JOIN report AS b ON b.project_id = a.id
|
|
|
+ JOIN user AS c ON b.creator_id = c.id
|
|
|
+ WHERE a.company_id = #{companyId}
|
|
|
<if test="projectId != null">
|
|
|
- AND report.project_id = #{projectId}
|
|
|
+ AND a.id = #{projectId}
|
|
|
</if>
|
|
|
<if test="startDate != null and endDate != null">
|
|
|
- AND report.create_date between #{startDate} and #{endDate}
|
|
|
+ AND b.create_date between #{startDate} and #{endDate}
|
|
|
</if>
|
|
|
<choose>
|
|
|
<when test="filterDeptIds!=null and filterDeptIds.size()>0">
|
|
|
- and report.dept_id in
|
|
|
+ and b.dept_id in
|
|
|
<foreach collection="filterDeptIds" open="(" item="item" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
<if test="deptIds!=null and deptIds.size()>0">
|
|
|
- and (report.dept_id in
|
|
|
+ and (b.dept_id in
|
|
|
<foreach collection="deptIds" open="(" item="item" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
<if test="deptRelatedProjectIds.size() > 0">
|
|
|
- or report.project_id in
|
|
|
+ or a.id in
|
|
|
<foreach collection="deptRelatedProjectIds" open="(" item="pid" separator="," close=")">
|
|
|
#{pid}
|
|
|
</foreach>
|
|
@@ -1521,29 +1522,24 @@
|
|
|
</if>
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
- AND report.state = 1
|
|
|
- GROUP BY report.degree_id,r.name
|
|
|
- ORDER BY report.degree_id
|
|
|
+ AND b.state = 1
|
|
|
+ GROUP BY a.id
|
|
|
+ ORDER BY a.id ASC
|
|
|
</select>
|
|
|
|
|
|
- <!--获取某个维度每个人分别需要的工时-->
|
|
|
+ <!--获取某个项目每个维度分别需要的工时-->
|
|
|
<select id="getDegreeDetailCost" resultType="java.util.Map">
|
|
|
- SELECT b.id as creatorId,a.project_id as projectId, b.name,b.corpwx_userid as corpwxUserId,a.dept_id as deptId,department.corpwx_deptid as corpwxDeptId, IFNULL(department.department_name, '未分配') as departmentName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney,
|
|
|
- p.project_name as projectName,p.project_code as projectCode,p.category_name as categoryName
|
|
|
+ SELECT b.id as creatorId,a.project_id as projectId, b.name,b.corpwx_userid as corpwxUserId,a.dept_id as deptId,department.corpwx_deptid as corpwxDeptId, IFNULL(department.department_name, '未分配') as departmentName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney,r.name as degreeName
|
|
|
FROM report AS a
|
|
|
JOIN user AS b ON a.creator_id = b.id
|
|
|
- left JOIN project AS P on a.project_id = p.id
|
|
|
left join department on department.department_id = a.dept_id
|
|
|
+ left join report_extra_degree as r on a.degree_id = r.id
|
|
|
WHERE a.company_id=#{companyId}
|
|
|
- and a.state = 1
|
|
|
- <if test="projectId != null">
|
|
|
- AND a.project_id = #{projectId}
|
|
|
+ <if test="curProjectId != null">
|
|
|
+ and a.project_id = #{curProjectId}
|
|
|
</if>
|
|
|
- <if test="degreeId != null">
|
|
|
- and a.degree_id = #{degreeId}
|
|
|
- </if>
|
|
|
- <if test="degreeId == null">
|
|
|
- and a.degree_id is null
|
|
|
+ <if test="projectId != null">
|
|
|
+ and a.project_id = #{projectId}
|
|
|
</if>
|
|
|
<if test="startDate != null and endDate != null">
|
|
|
AND a.create_date between #{startDate} and #{endDate}
|
|
@@ -1557,21 +1553,14 @@
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
<if test="deptIds!=null and deptIds.size()>0">
|
|
|
- and (report.dept_id in
|
|
|
+ and a.dept_id in
|
|
|
<foreach collection="deptIds" open="(" item="item" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- <if test="deptRelatedProjectIds.size() > 0">
|
|
|
- or report.project_id in
|
|
|
- <foreach collection="deptRelatedProjectIds" open="(" item="pid" separator="," close=")">
|
|
|
- #{pid}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- )
|
|
|
</if>
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
- GROUP BY a.project_id,a.creator_id,a.degree_id
|
|
|
- ORDER BY b.id ASC, a.dept_id ASC
|
|
|
+ GROUP BY a.project_id,b.id,a.degree_id
|
|
|
+ ORDER BY b.id,a.degree_id ASC
|
|
|
</select>
|
|
|
</mapper>
|