123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.management.platform.mapper.DepartmentMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.management.platform.entity.Department">
- <id column="department_id" property="departmentId" />
- <result column="department_name" property="departmentName" />
- <result column="seq" property="seq" />
- <result column="superior_id" property="superiorId" />
- <result column="company_id" property="companyId" />
- <result column="manager_id" property="managerId" />
- <result column="report_audit_userid" property="reportAuditUserid" />
- <result column="corpwx_deptid" property="corpwxDeptid" />
- <result column="corpwx_deptpid" property="corpwxDeptpid" />
- <result column="dd_deptid" property="ddDeptid" />
- <result column="feishu_deptid" property="feishuDeptid" />
- <result column="push_to_sap" property="pushToSap" />
- <result column="dept_code" property="deptCode" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- department_id, department_name, seq, superior_id, company_id, manager_id, report_audit_userid, corpwx_deptid, corpwx_deptpid, dd_deptid, feishu_deptid, push_to_sap, dept_code
- </sql>
- <!--根据部门获取成本-->
- <select id="getCostByDepartment" resultType="java.util.Map">
- SELECT SUM(b.working_time) AS time, SUM(b.cost) AS money
- FROM report AS b
- WHERE b.state = 1
- <if test="departmentIds != null and departmentIds.size()>0">
- AND b.dept_id IN
- <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
- #{departmentId}
- </foreach>
- </if>
- <if test="startDate != null and endDate != null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- </select>
- <!--根据人员获取成本-->
- <select id="getCostByUser" resultType="java.util.Map">
- SELECT a.id as id, a.name AS user,a.corpwx_userid as corpwxUserId, a.job_number as jobNumber, c.project_name AS project,c.project_code as projectCode, c.project_main_id as projectMainId, project_main.code as mainProjectCode, project_main.name as mainProjectName, ifnull(SUM(b.working_time),0) AS time, ifnull(SUM(b.cost),0) AS
- money
- FROM user AS a
- LEFT JOIN report AS b ON a.id = b.creator_id
- LEFT JOIN project AS c ON b.project_id = c.id
- left join project_main on project_main.id = c.project_main_id
- WHERE b.state = 1
- <if test="departmentIds != null and departmentIds.size()>0">
- AND b.dept_id IN
- <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
- #{departmentId}
- </foreach>
- </if>
- <if test="userIds != null">
- AND a.id IN
- <foreach collection="userIds" item="userId" index="index" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </if>
- <if test="companyId != null">
- AND a.company_id = #{companyId}
- </if>
- <if test="startDate != null and endDate != null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- GROUP BY b.project_id, a.id order by a.department_id
- </select>
- <!--根据人员获取成本-->
- <select id="getCostByUserSum" resultType="java.util.Map">
- SELECT a.id as id, a.name AS user,a.corpwx_userid as corpwxUserId, a.job_number as jobNumber, ifnull(SUM(b.working_time),0) AS time, ifnull(SUM(b.cost),0) AS
- money
- FROM user AS a
- LEFT JOIN report AS b ON a.id = b.creator_id
- WHERE b.state = 1
- <if test="departmentIds != null and departmentIds.size()>0">
- AND b.dept_id IN
- <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
- #{departmentId}
- </foreach>
- </if>
- <if test="companyId != null">
- AND a.company_id = #{companyId}
- </if>
- <if test="startDate != null and endDate != null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- GROUP BY a.id order by a.department_id
- </select>
- <!-- 根据人员获取自定义的日报数值 -->
- <select id="getCustomDataByUser" resultType="java.util.Map">
- SELECT a.id as id, a.name AS user,a.corpwx_userid as corpwxUserid, a.job_number as jobNumber,c.project_name AS project, IFNULL(SUM(b.custom_data),0) AS cost
- FROM user AS a
- LEFT JOIN report AS b ON a.id = b.creator_id
- LEFT JOIN project AS c ON b.project_id = c.id
- WHERE b.state = 1
- <if test="departmentIds != null">
- AND a.department_id IN
- <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
- #{departmentId}
- </foreach>
- </if>
- <if test="userIds != null">
- AND a.id IN
- <foreach collection="userIds" item="userId" index="index" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </if>
- <if test="companyId != null">
- AND a.company_id = #{companyId}
- </if>
- <if test="startDate != null and endDate != null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- GROUP BY b.project_id, a.id
- having IFNULL(SUM(b.custom_data),0) > 0
- </select>
- <!-- 根据部门获取自定义的日报数值 -->
- <select id="getDeptCustomDataStatistic" resultType="java.util.Map">
- SELECT a.department_id as id, a.department_name AS department, c.project_name AS project, IFNULL(SUM(b.custom_data),0) AS cost
- FROM department AS a
- LEFT JOIN report AS b ON a.department_id = b.dept_id
- LEFT JOIN project AS c ON b.project_id = c.id
- WHERE b.state = 1
- <if test="companyId!=null">
- AND a.company_id =#{companyId}
- </if>
- <if test="departmentIds != null">
- AND a.department_id IN
- <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
- #{departmentId}
- </foreach>
- </if>
- <if test="startDate!=null and endDate!=null">
- AND b.create_date between #{startDate} and #{endDate}
- </if>
- GROUP BY b.project_id, a.department_id
- having IFNULL(SUM(b.custom_data),0) > 0
- </select>
- <select id="getNameWithProjectRelate" resultType="com.management.platform.entity.vo.ProjectDeptInfo">
- select department.department_id,department.department_name
- from department
- left join project_dept_relate pdr on department.department_id = pdr.department_id
- where pdr.project_id = #{id}
- </select>
- <select id="getNameWithProjectRelates" resultType="com.management.platform.entity.vo.ProjectDeptInfo">
- select department.department_id,department.department_name,pdr.project_id
- from department
- left join project_dept_relate pdr on department.department_id = pdr.department_id
- where pdr.project_id in
- <foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
- #{projectId}
- </foreach>
- </select>
- </mapper>
|