UserMapper.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. </resultMap>
  42. <resultMap id="BaseResultMap2" type="com.management.platform.entity.User">
  43. <id column="id" property="id" />
  44. <result column="name" property="name" />
  45. <result column="department_id" property="departmentId" />
  46. <result column="department_name" property="departmentName" />
  47. </resultMap>
  48. <!-- 通用查询结果列 -->
  49. <sql id="Base_Column_List">
  50. 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
  51. </sql>
  52. <!--单独分页获取人员-->
  53. <select id="getUserByDepartment" resultType="java.util.Map">
  54. 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,
  55. a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
  56. 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,
  57. a.job_number as jobNumber
  58. FROM user AS a
  59. LEFT JOIN department AS b ON a.department_id = b.department_id
  60. WHERE a.company_id = #{companyId}
  61. <if test="departmentId != null and companyId != ''">
  62. AND a.department_id = #{departmentId}
  63. </if>
  64. <if test="keyword != null and keyword != ''">
  65. AND a.name like '%${keyword}%'
  66. </if>
  67. <if test="status != null">
  68. AND a.is_active = #{status}
  69. </if>
  70. <if test="roleId != null">
  71. AND a.role_id = #{roleId}
  72. </if>
  73. </select>
  74. <!--范围分页获取人员-->
  75. <select id="getUserByDepartmentList" resultType="java.util.Map">
  76. 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,
  77. a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
  78. 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,
  79. a.job_number as jobNumber
  80. FROM user AS a
  81. LEFT JOIN department AS b ON a.department_id = b.department_id
  82. WHERE a.company_id = #{companyId} AND a.department_id IN
  83. <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
  84. #{departmentId}
  85. </foreach>
  86. <if test="keyword != null and keyword != ''">
  87. AND a.name like '%${keyword}%'
  88. </if>
  89. <if test="status != null">
  90. AND a.is_active = #{status}
  91. </if>
  92. <if test="roleId != null">
  93. AND a.role_id = #{roleId}
  94. </if>
  95. </select>
  96. <select id="getPushUserList" resultType="java.util.Map">
  97. SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid, a.name, a.phone, b.department_name AS departmentName
  98. FROM user AS a LEFT JOIN department b ON a.department_id = b.department_id
  99. WHERE a.company_id = #{companyId}
  100. AND (a.wx_openid IS NOT NULL or corpwx_userid is not null)
  101. AND a.is_active = 1
  102. AND a.report_status =0
  103. <choose>
  104. <when test="alertType!=null and alertType==1">
  105. 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'))
  106. </when>
  107. <otherwise>
  108. AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND report.`create_date` = DATE_FORMAT(NOW(), '%Y-%m-%d'))
  109. </otherwise>
  110. </choose>
  111. <if test="date != null">
  112. 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)
  113. </if>
  114. </select>
  115. <select id="getPushDingdingUserList" resultType="java.util.Map">
  116. SELECT a.company_id as companyId, a.dingding_userid as dingdingUserid
  117. FROM user AS a left join time_type on time_type.company_id = a.company_id
  118. WHERE a.dingding_userid is not null and time_type.alert_time = #{alertTime}
  119. AND a.is_active = 1
  120. AND a.report_status=0
  121. 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)))
  122. <if test="date != null">
  123. 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)
  124. </if>
  125. order by a.company_id
  126. </select>
  127. <!--获取项目的参与人的推送id -->
  128. <select id="getProjectPushUserList" resultType="java.util.Map">
  129. SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid
  130. FROM user AS a
  131. WHERE a.wx_openid IS NOT NULL
  132. AND a.is_active = 1
  133. AND a.id in (select user_id from participation where project_id = #{projectId})
  134. </select>
  135. <select id="getSimpleNameList" resultType="java.util.HashMap">
  136. select id, name, job_number as jobNumber from user
  137. ${ew.customSqlSegment}
  138. </select>
  139. <select id="getUserWithDept" resultMap="BaseResultMap2">
  140. select user.id, name, department.department_name from user left join department on department.department_id = user.department_id
  141. ${ew.customSqlSegment}
  142. </select>
  143. </mapper>