|
@@ -1283,58 +1283,40 @@
|
|
|
|
|
|
<!-- 分页查询部门参与项目情况-->
|
|
|
<select id="selectDeptPartInProjects" resultType="java.util.Map">
|
|
|
- SELECT department.department_id AS departmentId,
|
|
|
- department.department_name AS deptName,
|
|
|
- u.projectCount,
|
|
|
- u.peopleCount,
|
|
|
- t.trip AS tripCount
|
|
|
- from department
|
|
|
- left JOIN (
|
|
|
- SELECT `user`.department_id AS departmentId,
|
|
|
- COUNT(DISTINCT(project.id)) AS projectCount,
|
|
|
- COUNT(`user`.id) AS peopleCount
|
|
|
- from `user`
|
|
|
- LEFT JOIN participation ON `user`.id = participation.user_id
|
|
|
- LEFT JOIN project ON project.id = participation.project_id
|
|
|
- WHERE user.company_id = #{companyId}
|
|
|
- and project.id is not null
|
|
|
- <if test="branchDepartment!=null and branchDepartment.size()>0">
|
|
|
- and user.department_id in
|
|
|
- <foreach collection="branchDepartment" open="(" close=")" separator="," item="item">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="deptIds!=null and deptIds.size()>0">
|
|
|
- and user.department_id in
|
|
|
- <foreach collection="deptIds" open="(" item="item" close=")" separator=",">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="startDate!= null and startDate!= ''" >
|
|
|
- and project.create_date >= #{startDate}
|
|
|
- </if>
|
|
|
- <if test="endDate!= null and endDate!= ''">
|
|
|
- and project.create_date <= #{endDate}
|
|
|
- </if>
|
|
|
- GROUP BY `user`.department_id
|
|
|
- ) u ON department.department_id = u.departmentId
|
|
|
- left join (
|
|
|
- SELECT u.deptId AS deptId,SUM(tripCount) AS trip
|
|
|
- FROM (
|
|
|
- SELECT `user`.department_id AS deptId,SUM(day_count) AS tripCount from business_trip
|
|
|
- LEFT JOIN `user` ON business_trip.owner_id = `user`.id
|
|
|
- where STATUS = 0
|
|
|
- AND user.company_id = #{companyId}
|
|
|
- <if test="endDate!= null and endDate!= ''" >
|
|
|
- and business_trip.start_date <=#{endDate}
|
|
|
+ SELECT department.department_id deptId,
|
|
|
+ department_name deptName,
|
|
|
+ COUNT(`user`.id) deptHeadCount,
|
|
|
+ pro.projectCount projectCount,
|
|
|
+ pro.centerCount centerCount,
|
|
|
+ pcon.peopleCount peopleCount
|
|
|
+ FROM department
|
|
|
+ LEFT JOIN `user`
|
|
|
+ ON `user`.department_id = department.department_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT report.dept_id,COUNT(DISTINCT(report.project_id)) projectCount,
|
|
|
+ COUNT(DISTINCT(r.degree_id)) centerCount
|
|
|
+ FROM report
|
|
|
+ LEFT JOIN report r
|
|
|
+ ON report.id = r.id AND r.degree_id != -1
|
|
|
+ WHERE report.state = 1
|
|
|
+ <if test="startDate!= null and startDate!= '' and endDate!= null and endDate!= ''" >
|
|
|
+ And report.create_date BETWEEN #{startDate} AND #{endDate}
|
|
|
</if>
|
|
|
- <if test="startDate!= null and startDate!= ''">
|
|
|
- and business_trip.end_date >= #{startDate}
|
|
|
+ GROUP BY report.dept_id
|
|
|
+ ) pro
|
|
|
+ ON pro.dept_id = department.department_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT dept_id,sum(p.con) peopleCount
|
|
|
+ FROM (
|
|
|
+ SELECT dept_id,count(DISTINCT project_id)con FROM report
|
|
|
+ WHERE report.state = 1
|
|
|
+ <if test="startDate!= null and startDate!= '' and endDate!= null and endDate!= ''" >
|
|
|
+ And report.create_date BETWEEN #{startDate} AND #{endDate}
|
|
|
</if>
|
|
|
- GROUP BY `user`.id
|
|
|
- ) u
|
|
|
- GROUP BY u.deptId
|
|
|
- ) t on t.deptId = department.department_id
|
|
|
+ GROUP BY report.creator_id,report.dept_id
|
|
|
+ ) p GROUP BY p.dept_id
|
|
|
+ ) pcon
|
|
|
+ ON pcon.dept_id = department.department_id
|
|
|
WHERE department.company_id = #{companyId}
|
|
|
<if test="branchDepartment!=null and branchDepartment.size()>0">
|
|
|
and department.department_id in
|
|
@@ -1348,7 +1330,8 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- ORDER BY u.projectCount,u.peopleCount
|
|
|
+ GROUP BY department.department_id,projectCount,centerCount,peopleCount
|
|
|
+ ORDER BY projectCount
|
|
|
<if test="size!=null and start!=null">
|
|
|
limit #{start},#{size}
|
|
|
</if>
|