123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?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="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" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- department_id, department_name, superior_id, company_id, manager_id, report_audit_userid, corpwx_deptid, corpwx_deptpid
- </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.job_number as jobNumber, c.project_name AS project, SUM(b.working_time) AS time, SUM(b.cost) 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
- 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="getCustomDataByUser" resultType="java.util.Map">
- SELECT a.id as id, a.name AS user, 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>
- </mapper>
|