UserMapper.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.management.platform.mapper.UserMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.User">
  6. <id column="id" property="id" />
  7. <result column="name" property="name" />
  8. <result column="phone" property="phone" />
  9. <result column="password" property="password" />
  10. <result column="portrait_url" property="portraitUrl" />
  11. <result column="create_time" property="createTime" />
  12. <result column="role" property="role" />
  13. <result column="company_id" property="companyId" />
  14. <result column="department_id" property="departmentId" />
  15. <result column="department_cascade" property="departmentCascade" />
  16. <result column="cost" property="cost" />
  17. <result column="month_cost" property="monthCost" />
  18. <result column="salary_type" property="salaryType" />
  19. <result column="manage_dept_id" property="manageDeptId" />
  20. <result column="color" property="color" />
  21. <result column="is_active" property="isActive" />
  22. <result column="wx_openid" property="wxOpenid" />
  23. <result column="role_id" property="roleId" />
  24. <result column="role_name" property="roleName" />
  25. <result column="cost_apply_date" property="costApplyDate" />
  26. <result column="dingding_userid" property="dingdingUserid" />
  27. <result column="dingding_unionid" property="dingdingUnionid" />
  28. <result column="corpwx_userid" property="corpwxUserid" />
  29. <result column="induction_date" property="inductionDate" />
  30. <result column="inactive_date" property="inactiveDate" />
  31. <result column="position" property="position" />
  32. <result column="report_status" property="reportStatus" />
  33. <result column="superior_id" property="superiorId" />
  34. <result column="plate1" property="plate1" />
  35. <result column="plate2" property="plate2" />
  36. <result column="plate3" property="plate3" />
  37. <result column="plate4" property="plate4" />
  38. <result column="plate5" property="plate5" />
  39. <result column="is_ops" property="isOps" />
  40. <result column="job_number" property="jobNumber" />
  41. <result column="corpwx_deptid" property="corpwxDeptid" />
  42. </resultMap>
  43. <resultMap id="BaseResultMap2" type="com.management.platform.entity.User">
  44. <id column="id" property="id" />
  45. <result column="name" property="name" />
  46. <result column="department_id" property="departmentId" />
  47. <result column="department_name" property="departmentName" />
  48. </resultMap>
  49. <!-- 通用查询结果列 -->
  50. <sql id="Base_Column_List">
  51. id, name, phone, password, portrait_url, create_time, role, company_id, department_id, department_cascade, cost, month_cost, salary_type, manage_dept_id, color, is_active, wx_openid, role_id, role_name, cost_apply_date, dingding_userid, dingding_unionid, corpwx_userid, induction_date, inactive_date, position, report_status, superior_id, plate1, plate2, plate3, plate4, plate5, is_ops, job_number, corpwx_deptid
  52. </sql>
  53. <!--单独分页获取人员-->
  54. <select id="getUserByDepartment" resultType="java.util.Map">
  55. SELECT a.id, a.role_id as roleId, a.role_name as roleName, a.name, a.phone, a.portrait_url AS portraitUrl, a.role, a.company_id AS companyId, a.cost,
  56. a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
  57. a.month_cost as monthCost, a.salary_type as salaryType, a.is_active as isActive,date_format(a.`inactive_date`, '%Y-%m-%d') AS inactiveDate, a.cost_apply_date as costApplyDate,a.plate1,a.plate2,a.plate3,a.plate4,a.plate5,
  58. a.job_number as jobNumber, DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%m') as createTime
  59. FROM user AS a
  60. LEFT JOIN department AS b ON a.department_id = b.department_id
  61. WHERE a.company_id = #{companyId}
  62. <if test="departmentId != null and companyId != ''">
  63. AND a.department_id = #{departmentId}
  64. </if>
  65. <if test="keyword != null and keyword != ''">
  66. AND a.name like '%${keyword}%'
  67. </if>
  68. <if test="status != null">
  69. AND a.is_active = #{status}
  70. </if>
  71. <if test="roleId != null">
  72. AND a.role_id = #{roleId}
  73. </if>
  74. </select>
  75. <!--范围分页获取人员-->
  76. <select id="getUserByDepartmentList" resultType="java.util.Map">
  77. SELECT a.id, a.role_id as roleId, a.role_name as roleName, a.name, a.phone, a.portrait_url AS portraitUrl, a.role, a.company_id AS companyId, a.cost,
  78. a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
  79. a.month_cost as monthCost, a.salary_type as salaryType, a.is_active as isActive,date_format(a.`inactive_date`, '%Y-%m-%d') AS inactiveDate, a.cost_apply_date as costApplyDate,a.plate1,a.plate2,a.plate3,a.plate4,a.plate5,
  80. a.job_number as jobNumber, DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%m') as createTime
  81. FROM user AS a
  82. LEFT JOIN department AS b ON a.department_id = b.department_id
  83. WHERE a.company_id = #{companyId} AND a.department_id IN
  84. <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
  85. #{departmentId}
  86. </foreach>
  87. <if test="keyword != null and keyword != ''">
  88. AND a.name like '%${keyword}%'
  89. </if>
  90. <if test="status != null">
  91. AND a.is_active = #{status}
  92. </if>
  93. <if test="roleId != null">
  94. AND a.role_id = #{roleId}
  95. </if>
  96. </select>
  97. <select id="getPushUserList" resultType="java.util.Map">
  98. SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid, a.name, a.phone, b.department_name AS departmentName
  99. FROM user AS a LEFT JOIN department b ON a.department_id = b.department_id
  100. WHERE a.company_id = #{companyId}
  101. AND (a.wx_openid IS NOT NULL or corpwx_userid is not null)
  102. AND a.is_active = 1
  103. AND a.report_status =0
  104. <choose>
  105. <when test="alertType!=null and alertType==1">
  106. AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND report.`create_date` = DATE_FORMAT(date_sub(NOW(),interval 1 day), '%Y-%m-%d'))
  107. </when>
  108. <otherwise>
  109. AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND report.`create_date` = DATE_FORMAT(NOW(), '%Y-%m-%d'))
  110. </otherwise>
  111. </choose>
  112. <if test="date != null">
  113. and not exists (select 1 from leave_sheet where owner_id = a.id and start_date &lt;= #{date} and end_date &gt;= #{date} and leave_sheet.status = 0)
  114. </if>
  115. </select>
  116. <select id="getPushDingdingUserList" resultType="java.util.Map">
  117. SELECT a.company_id as companyId, a.dingding_userid as dingdingUserid
  118. FROM user AS a left join time_type on time_type.company_id = a.company_id
  119. WHERE a.dingding_userid is not null and time_type.alert_time = #{alertTime}
  120. AND a.is_active = 1
  121. AND a.report_status=0
  122. AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND ((report.`create_date` = DATE_FORMAT(date_sub(NOW(),interval 1 day), '%Y-%m-%d') and time_type.alert_type=1)or(report.`create_date` = DATE_FORMAT(NOW(), '%Y-%m-%d') and time_type.alert_type=0)))
  123. <if test="date != null">
  124. and not exists (select 1 from leave_sheet where owner_id = a.id and start_date &lt;= #{date} and end_date &gt;= #{date} and leave_sheet.status = 0)
  125. </if>
  126. order by a.company_id
  127. </select>
  128. <!--获取项目的参与人的推送id -->
  129. <select id="getProjectPushUserList" resultType="java.util.Map">
  130. SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid
  131. FROM user AS a
  132. WHERE a.wx_openid IS NOT NULL
  133. AND a.is_active = 1
  134. AND a.id in (select user_id from participation where project_id = #{projectId})
  135. </select>
  136. <select id="getSimpleNameList" resultType="java.util.HashMap">
  137. select id, name, job_number as jobNumber from user
  138. ${ew.customSqlSegment}
  139. </select>
  140. <select id="getUserWithDept" resultMap="BaseResultMap2">
  141. select user.id, name, department.department_name from user left join department on department.department_id = user.department_id
  142. ${ew.customSqlSegment}
  143. </select>
  144. </mapper>