RepairUserMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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.repair.mapper.RepairUserMapper">
  4. <resultMap type="com.repair.model.vo.RepairUserVo" id="repairUserPageMap">
  5. <result property="id" column="id"/>
  6. <result property="cardNumber" column="card_number"/>
  7. <result property="userName" column="user_name"/>
  8. <result property="userPhone" column="user_phone"/>
  9. <result property="teamId" column="team_id"/>
  10. <result property="teamName" column="team_name"/>
  11. <result property="schoolId" column="school_id"/>
  12. <result property="schoolName" column="school_name"/>
  13. <result property="userZzid" column="user_zzid"/>
  14. <result property="userZzname" column="user_zzname"/>
  15. <result property="buildId" column="build_id"/>
  16. <result property="buildName" column="build_name"/>
  17. <result property="articleId" column="article_id"/>
  18. <result property="articleName" column="article_name"/>
  19. <result property="workType" column="work_type"/>
  20. <result property="workTypeName" column="work_type_name"/>
  21. <result property="acceptanceTime" column="acceptance_assess_time"/>
  22. <result property="maintenanceTime" column="maintenance_assess_time"/>
  23. </resultMap>
  24. <select id="queryUserPageList" resultType="com.repair.model.vo.RepairUserVo" resultMap="repairUserPageMap">
  25. select ru.card_number,ru.acceptance_assess_time,ru.maintenance_assess_time,ru.id,ru.article_id,(select GROUP_CONCAT(name) from repair_article_type where find_in_set(id,ru.article_id)) as article_name,ru.user_name, ru.user_phone, ru.team_id, case ru.team_id when 0 then '校方人员' else '第三方人员' end as team_name, ru.school_id,ra.name as school_name,
  26. ru.user_zzid,case ru.user_zzid when 3 then '后勤人员' else '维修师傅' end as user_zzname,ru.build_id,(select GROUP_CONCAT(name) from repair_area where find_in_set(id,ru.build_id)) as build_name,ru.work_type,rwt.name as work_type_name from repair_user ru
  27. left join repair_area ra on ra.id = ru.school_id and ra.deleted = 0
  28. left join repair_work_type rwt on rwt.id = ru.work_type and ra.deleted = 0
  29. <where>
  30. and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2 or ru.user_zzid = 3)
  31. <if test="schoolId != null and schoolId != ''">
  32. and ru.school_id = ${schoolId}
  33. </if>
  34. <if test="teamId != null and teamId != ''">
  35. and ru.team_id = ${teamId}
  36. </if>
  37. <if test="keyWord != null and keyWord != ''">
  38. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%')
  39. </if>
  40. </where>
  41. </select>
  42. <resultMap type="com.repair.model.vo.RepairLogisticsVo" id="repairLogisticsMap">
  43. <result property="id" column="id"/>
  44. </resultMap>
  45. <select id="queryLogisticsList" resultType="com.repair.model.vo.RepairLogisticsVo" resultMap="repairLogisticsMap">
  46. select id from repair_user ru
  47. where EXISTS (select id from repair_record where deleted = 0 and id = #{recordId} and school_id = ru.school_id)
  48. and ru.user_zzid = 3 and ru.deleted = 0
  49. </select>
  50. <resultMap type="com.repair.model.vo.UserDataVo" id="userDataMap">
  51. <result property="id" column="id"/>
  52. <result property="state" column="state"/>
  53. <result property="shiftId" column="shift_id"/>
  54. <result property="userName" column="user_name"/>
  55. <result property="userPhone" column="user_phone"/>
  56. <result property="startDate" column="start_date"/>
  57. <result property="articleId" column="article_id"/>
  58. <result property="acceptanceAssessTime" column="acceptance_assess_time"/>
  59. <result property="maintenanceAssessTime" column="maintenance_assess_time"/>
  60. </resultMap>
  61. <select id="queryUserData" resultType="com.repair.model.vo.UserDataVo" resultMap="userDataMap">
  62. select ru.user_phone,ru.acceptance_assess_time,ru.maintenance_assess_time,ru.state,ru.id,ru.user_name,rcs.start_date,rcs.shift_id,GROUP_CONCAT(rat.id) as article_id from repair_user ru
  63. left join repair_classes_settings rcs on rcs.deleted = 0 and rcs.user_id = #{userId} and start_date = #{dateNow}
  64. left join repair_article_type rat on rat.deleted = 0 and (FIND_IN_SET(rat.id,ru.article_id) or FIND_IN_SET(rat.parent_id,ru.article_id))
  65. where ru.id = #{userId} and ru.deleted = 0
  66. </select>
  67. <resultMap type="com.repair.model.vo.CollaboratorVo" id="collaboratorMap">
  68. <result property="id" column="id"/>
  69. <result property="userName" column="user_name"/>
  70. <result property="userPhone" column="user_phone"/>
  71. <result property="workTypeName" column="work_type_name"/>
  72. <result property="state" column="state"/>
  73. </resultMap>
  74. <select id="queryCollaborator" resultType="com.repair.model.vo.CollaboratorVo" resultMap="collaboratorMap">
  75. select ru.id,ru.user_name,ru.user_phone,rwt.name as work_type_name,ru.state
  76. from repair_user ru
  77. left join repair_work_type rwt on rwt.deleted = 0 and rwt.id = ru.work_type
  78. <where>
  79. and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2)
  80. <if test="userId != null and userId != ''">
  81. and ru.id != #{userId}
  82. </if>
  83. <if test="schoolId != null and schoolId != ''">
  84. and ru.school_id = #{schoolId}
  85. </if>
  86. <if test="keyWord != null and keyWord != ''">
  87. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%' or rwt.name like '%' #{keyWord} '%')
  88. </if>
  89. </where>
  90. </select>
  91. <resultMap type="com.repair.model.vo.AddressBookVo" id="addressBookMap">
  92. <result property="id" column="id"/>
  93. <result property="teamId" column="team_id"/>
  94. <result property="userName" column="user_name"/>
  95. <result property="userPhone" column="user_phone"/>
  96. <result property="workType" column="work_type"/>
  97. <result property="workTypeName" column="work_type_name"/>
  98. <result property="state" column="state"/>
  99. <result property="acceptanceTime" column="acceptance_assess_time"/>
  100. <result property="maintenanceTime" column="maintenance_assess_time"/>
  101. </resultMap>
  102. <select id="queryAddressBook" resultType="com.repair.model.vo.AddressBookVo" resultMap="addressBookMap">
  103. select ru.team_id,ru.id,ru.user_name,ru.user_phone,ru.work_type,rwt.name as work_type_name,ru.state,ru.state,ru.acceptance_assess_time,ru.maintenance_assess_time
  104. from repair_user ru
  105. left join repair_work_type rwt on rwt.deleted = 0 and rwt.id = ru.work_type
  106. <where>
  107. and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2)
  108. <if test="schoolId != null and schoolId != ''">
  109. and ru.school_id = #{schoolId}
  110. </if>
  111. <if test="keyWord != null and keyWord != ''">
  112. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%' or rwt.name like '%' #{keyWord} '%')
  113. </if>
  114. </where>
  115. </select>
  116. <select id="queryUserPageBySchoolId" resultType="com.repair.model.vo.AddressBookVo" resultMap="addressBookMap">
  117. select ru.team_id,ru.id,ru.user_name,ru.user_phone,ru.work_type,rwt.name as work_type_name,ru.state,ru.state,ru.acceptance_assess_time,ru.maintenance_assess_time
  118. from repair_user ru
  119. left join repair_work_type rwt on rwt.deleted = 0 and rwt.id = ru.work_type
  120. <where>
  121. and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2)
  122. <if test="schoolId != null and schoolId != ''">
  123. and ru.school_id = #{schoolId}
  124. </if>
  125. </where>
  126. </select>
  127. <resultMap type="com.repair.model.vo.AutoDispatchUserVo" id="AutoDispatchUserMap">
  128. <result property="id" column="id"/>
  129. <result property="state" column="state"/>
  130. <result property="workType" column="work_type"/>
  131. <result property="rdrCount" column="rdr_count"/>
  132. <result property="buildId" column="build_id"/>
  133. <result property="userName" column="user_name"/>
  134. <result property="userPhone" column="user_phone"/>
  135. <result property="acceptanceTime" column="acceptance_assess_time"/>
  136. <result property="maintenanceTime" column="maintenance_assess_time"/>
  137. <result property="startDate" column="start_date"/>
  138. <result property="shiftId" column="shift_id"/>
  139. <result property="articleId" column="article_id"/>
  140. </resultMap>
  141. <select id="autoDispatchUser" resultType="com.repair.model.vo.AutoDispatchUserVo" resultMap="AutoDispatchUserMap">
  142. select * from (
  143. select wt.name as work_type,'大量接单' as state,(select count(*) from repair_dispatch_record where deleted = 0 and is_lose_efficacy = 0 and assigned_time like '%' #{dateNow} '%' and users_id = ru.id) as rdr_count,ru.build_id,ru.user_phone,ru.acceptance_assess_time,ru.maintenance_assess_time,ru.id,ru.user_name,rcs.start_date,rcs.shift_id,GROUP_CONCAT(rat.id) as article_id from repair_user ru
  144. inner join repair_classes_settings rcs on rcs.deleted = 0 and rcs.user_id = ru.id and start_date = #{dateNow}
  145. left join repair_article_type rat on rat.deleted = 0 and (FIND_IN_SET(rat.id,ru.article_id) or FIND_IN_SET(rat.parent_id,ru.article_id))
  146. left join repair_work_type wt on wt.deleted = 0 and wt.id = ru.work_type
  147. where ru.school_id = #{schoolId} and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2) and ru.state = 1
  148. <if test="keyWord != null and keyWord != ''">
  149. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%')
  150. </if>
  151. group by ru.id) t where FIND_IN_SET(${articleId},t.article_id) and FIND_IN_SET(${buildId},t.build_id)
  152. order by t.rdr_count
  153. </select>
  154. <!--获取协作下拉人员信息-->
  155. <resultMap type="com.repair.model.vo.RepairWorkTypeVo" id="collaboratorUserMap">
  156. <result property="id" column="id"/>
  157. <result property="name" column="user_name"/>
  158. <result property="workType" column="work_type"/>
  159. <result property="state" column="state"/>
  160. <result property="userPhone" column="user_phone"/>
  161. </resultMap>
  162. <select id="queryCollaboratorUser" resultType="com.repair.model.vo.RepairWorkTypeVo" resultMap="collaboratorUserMap">
  163. select ru.id,ru.user_phone,'大量接单' as state,wt.name as work_type,ru.user_name from repair_user ru
  164. inner join repair_classes_settings rcs on rcs.deleted = 0 and rcs.user_id = ru.id and rcs.shift_id != '' and rcs.start_date = #{dateNow}
  165. left join repair_work_type wt on wt.deleted = 0 and wt.id = ru.work_type
  166. where ru.school_id = #{schoolId} and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2) and ru.state = 1 and ru.id != #{userId}
  167. <if test="keyWord != null and keyWord != ''">
  168. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%')
  169. </if>
  170. </select>
  171. <resultMap type="com.repair.model.vo.PositiveReviewVo" id="positiveReviewMap">
  172. <result property="id" column="id"/>
  173. <result property="userName" column="user_name"/>
  174. <result property="finishCount" column="finish_count"/>
  175. <result property="evaluateCount" column="evaluate_count"/>
  176. </resultMap>
  177. <select id="queryPositiveReviewPage" resultType="com.repair.model.vo.PositiveReviewVo" resultMap="positiveReviewMap">
  178. select ru.id,ru.user_name, (select Count(*) from repair_record where deleted = 0 and maintenance_state = 7 and find_in_set(ru.id,maintenancer_id)) as finish_count,
  179. (select Count(*) from repair_record rr
  180. inner join repair_evaluate re on re.deleted = 0 and re.star > 3 and re.record_id = rr.id
  181. where rr.deleted = 0 and rr.maintenance_state = 7 and find_in_set(ru.id,rr.maintenancer_id)) as evaluate_count
  182. from repair_user ru
  183. where ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2) and ru.school_id = #{schoolId}
  184. </select>
  185. <select id="dropDown" resultType="com.repair.model.vo.AutoDispatchUserVo">
  186. select * from (
  187. select wt.name as work_type,'大量接单' as state,(select count(*) from repair_dispatch_record where deleted = 0 and is_lose_efficacy = 0 and users_id = ru.id) as rdr_count,ru.build_id,ru.user_phone,ru.acceptance_assess_time,ru.maintenance_assess_time,ru.id,ru.user_name,rcs.start_date,rcs.shift_id,GROUP_CONCAT(rat.id) as article_id from repair_user ru
  188. inner join repair_classes_settings rcs on rcs.deleted = 0 and rcs.user_id = ru.id
  189. left join repair_article_type rat on rat.deleted = 0 and (FIND_IN_SET(rat.id,ru.article_id) or FIND_IN_SET(rat.parent_id,ru.article_id))
  190. left join repair_work_type wt on wt.deleted = 0 and wt.id = ru.work_type
  191. where ru.school_id = #{schoolId} and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2) and ru.state = 1
  192. group by ru.id) t where FIND_IN_SET(${articleId},t.article_id) and FIND_IN_SET(${buildId},t.build_id)
  193. order by t.rdr_count
  194. </select>
  195. </mapper>