RepairUserMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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="workType" column="work_type"/>
  16. <result property="workTypeName" column="work_type_name"/>
  17. <result property="acceptanceTime" column="acceptance_assess_time"/>
  18. <result property="maintenanceTime" column="maintenance_assess_time"/>
  19. </resultMap>
  20. <select id="queryUserPageList" resultType="com.repair.model.vo.RepairUserVo" resultMap="repairUserPageMap">
  21. select ru.card_number,ru.acceptance_assess_time,ru.maintenance_assess_time,ru.id,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,
  22. ru.user_zzid,ru.work_type,rwt.name as work_type_name from repair_user ru
  23. left join repair_area ra on ra.id = ru.school_id and ra.deleted = 0
  24. left join repair_work_type rwt on rwt.id = ru.work_type and ra.deleted = 0
  25. <where>
  26. and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2 or ru.user_zzid = 3 or ru.user_zzid = 4)
  27. <if test="schoolId != null and schoolId != ''">
  28. and ru.school_id = ${schoolId}
  29. </if>
  30. <if test="teamId != null and teamId != ''">
  31. and ru.team_id = ${teamId}
  32. </if>
  33. <if test="keyWord != null and keyWord != ''">
  34. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%')
  35. </if>
  36. </where>
  37. </select>
  38. <resultMap type="com.repair.model.vo.ArticleBuildVo" id="repairArticleBuildMap">
  39. <result property="id" column="id"/>
  40. <result property="articleId" column="article_id"/>
  41. <result property="buildId" column="build_id"/>
  42. <result property="articleName" column="article_name"/>
  43. <result property="buildName" column="build_name"/>
  44. <result property="userId" column="user_id"/>
  45. </resultMap>
  46. <!--获取报修关联楼栋种的数据-->
  47. <select id="queryArticleBuilds" resultType="com.repair.model.vo.ArticleBuildVo" resultMap="repairArticleBuildMap">
  48. SELECT rab.id,rat.name as article_name,rab.article_id,rab.build_id,(select GROUP_CONCAT(name) from repair_area where find_in_set(id,rab.build_id)) as build_name,rab.user_id
  49. FROM repair_article_build rab
  50. left join repair_article_type rat on rat.deleted = 0 and rat.id = rab.article_id
  51. where rab.deleted = 0 and rab.user_id in (${userIds})
  52. </select>
  53. <resultMap type="com.repair.model.vo.RepairLogisticsVo" id="repairLogisticsMap">
  54. <result property="id" column="id"/>
  55. </resultMap>
  56. <select id="queryLogisticsList" resultType="com.repair.model.vo.RepairLogisticsVo" resultMap="repairLogisticsMap">
  57. select id from repair_user ru
  58. where EXISTS (select id from repair_record where deleted = 0 and id = #{recordId} and school_id = ru.school_id)
  59. and ru.user_zzid = 3 and ru.deleted = 0
  60. </select>
  61. <resultMap type="com.repair.model.vo.UserDataVo" id="userDataMap">
  62. <result property="id" column="id"/>
  63. <result property="state" column="state"/>
  64. <result property="shiftId" column="shift_id"/>
  65. <result property="userName" column="user_name"/>
  66. <result property="userPhone" column="user_phone"/>
  67. <result property="startDate" column="start_date"/>
  68. <result property="articleId" column="article_id"/>
  69. <result property="acceptanceAssessTime" column="acceptance_assess_time"/>
  70. <result property="maintenanceAssessTime" column="maintenance_assess_time"/>
  71. </resultMap>
  72. <select id="queryUserData" resultType="com.repair.model.vo.UserDataVo" resultMap="userDataMap">
  73. 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,
  74. (select GROUP_CONCAT(a.articleId) from (select (select GROUP_CONCAT(id) from repair_article_type where (id =repair_article_build.article_id or parent_id = repair_article_build.article_id) and deleted = 0) as articleId
  75. from repair_article_build where deleted = 0 and user_id = ru.id) a) as article_id
  76. from repair_user ru
  77. left join repair_classes_settings rcs on rcs.deleted = 0 and rcs.user_id = #{userId} and start_date = #{dateNow}
  78. where ru.id = #{userId} and ru.deleted = 0
  79. </select>
  80. <resultMap type="com.repair.model.vo.CollaboratorVo" id="collaboratorMap">
  81. <result property="id" column="id"/>
  82. <result property="userName" column="user_name"/>
  83. <result property="userPhone" column="user_phone"/>
  84. <result property="workTypeName" column="work_type_name"/>
  85. <result property="state" column="state"/>
  86. </resultMap>
  87. <select id="queryCollaborator" resultType="com.repair.model.vo.CollaboratorVo" resultMap="collaboratorMap">
  88. select ru.id,ru.user_name,ru.user_phone,rwt.name as work_type_name,ru.state
  89. from repair_user ru
  90. left join repair_work_type rwt on rwt.deleted = 0 and rwt.id = ru.work_type
  91. <where>
  92. and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2)
  93. <if test="userId != null and userId != ''">
  94. and ru.id != #{userId}
  95. </if>
  96. <if test="schoolId != null and schoolId != ''">
  97. and ru.school_id = #{schoolId}
  98. </if>
  99. <if test="keyWord != null and keyWord != ''">
  100. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%' or rwt.name like '%' #{keyWord} '%')
  101. </if>
  102. </where>
  103. </select>
  104. <resultMap type="com.repair.model.vo.AddressBookVo" id="addressBookMap">
  105. <result property="id" column="id"/>
  106. <result property="teamId" column="team_id"/>
  107. <result property="userName" column="user_name"/>
  108. <result property="userPhone" column="user_phone"/>
  109. <result property="workType" column="work_type"/>
  110. <result property="workTypeName" column="work_type_name"/>
  111. <result property="state" column="state"/>
  112. <result property="acceptanceTime" column="acceptance_assess_time"/>
  113. <result property="maintenanceTime" column="maintenance_assess_time"/>
  114. </resultMap>
  115. <select id="queryAddressBook" resultType="com.repair.model.vo.AddressBookVo" resultMap="addressBookMap">
  116. 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
  117. from repair_user ru
  118. left join repair_work_type rwt on rwt.deleted = 0 and rwt.id = ru.work_type
  119. <where>
  120. and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2)
  121. <if test="schoolId != null and schoolId != ''">
  122. and ru.school_id = #{schoolId}
  123. </if>
  124. <if test="keyWord != null and keyWord != ''">
  125. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%' or rwt.name like '%' #{keyWord} '%')
  126. </if>
  127. </where>
  128. </select>
  129. <select id="queryUserPageBySchoolId" resultType="com.repair.model.vo.AddressBookVo" resultMap="addressBookMap">
  130. 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
  131. from repair_user ru
  132. left join repair_work_type rwt on rwt.deleted = 0 and rwt.id = ru.work_type
  133. <where>
  134. and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2)
  135. <if test="schoolId != null and schoolId != ''">
  136. and ru.school_id = #{schoolId}
  137. </if>
  138. <if test="userId != null and userId != ''">
  139. and ru.id = #{userId}
  140. </if>
  141. </where>
  142. </select>
  143. <resultMap type="com.repair.model.vo.AutoDispatchUserVo" id="AutoDispatchUserMap">
  144. <result property="id" column="id"/>
  145. <result property="state" column="state"/>
  146. <result property="workType" column="work_type"/>
  147. <result property="rdrCount" column="rdr_count"/>
  148. <result property="userName" column="user_name"/>
  149. <result property="userPhone" column="user_phone"/>
  150. <result property="acceptanceTime" column="acceptance_assess_time"/>
  151. <result property="maintenanceTime" column="maintenance_assess_time"/>
  152. <result property="startDate" column="start_date"/>
  153. <result property="shiftId" column="shift_id"/>
  154. </resultMap>
  155. <select id="autoDispatchUser" resultType="com.repair.model.vo.AutoDispatchUserVo" resultMap="AutoDispatchUserMap">
  156. select * from (
  157. select ru.user_zzid,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.user_phone,ru.acceptance_assess_time,ru.maintenance_assess_time,ru.id,ru.user_name,rcs.start_date,rcs.shift_id
  158. from repair_user ru
  159. inner join repair_classes_settings rcs on rcs.deleted = 0 and rcs.user_id = ru.id and start_date = #{dateNow}
  160. left join repair_work_type wt on wt.deleted = 0 and wt.id = ru.work_type
  161. where ru.school_id = #{schoolId} and ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2) and ru.state = 1
  162. and ru.id in (select user_id from
  163. (select user_id,(select GROUP_CONCAT(id) from repair_article_type where (id = repair_article_build.article_id or parent_id = repair_article_build.article_id) and deleted = 0) as article_id,build_id
  164. from repair_article_build
  165. where deleted = 0) d
  166. where FIND_IN_SET(${articleId},d.article_id) and FIND_IN_SET(${buildId},d.build_id))
  167. <if test="keyWord != null and keyWord != ''">
  168. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%')
  169. </if>
  170. group by ru.id) t
  171. order by t.rdr_count
  172. </select>
  173. <resultMap type="com.repair.model.vo.AutoOfflineUserVo" id="AutoOfflineUserMap">
  174. <result property="id" column="id"/>
  175. <result property="userName" column="user_name"/>
  176. <result property="teamName" column="team_name"/>
  177. <result property="userZzName" column="userZz_name"/>
  178. <result property="workType" column="work_type"/>
  179. </resultMap>
  180. <select id="autoOfflineRepairUser" resultType="com.repair.model.vo.AutoOfflineUserVo" resultMap="AutoOfflineUserMap">
  181. select ru.id,ru.user_name,case team_id when 0 then '校方人员' else '第三方人员' end as team_name,'线下' as userZz_name,wt.name as work_type
  182. from repair_user ru
  183. left join repair_work_type wt on wt.deleted = 0 and wt.id = ru.work_type
  184. where ru.school_id = #{schoolId} and ru.deleted = 0 and ru.user_zzid = 4 and ru.state = 1
  185. <if test="keyWord != null and keyWord != ''">
  186. and ru.user_name like '%' #{keyWord} '%'
  187. </if>
  188. </select>
  189. <!--获取协作下拉人员信息-->
  190. <resultMap type="com.repair.model.vo.RepairWorkTypeVo" id="collaboratorUserMap">
  191. <result property="id" column="id"/>
  192. <result property="name" column="user_name"/>
  193. <result property="workType" column="work_type"/>
  194. <result property="state" column="state"/>
  195. <result property="userPhone" column="user_phone"/>
  196. </resultMap>
  197. <select id="queryCollaboratorUser" resultType="com.repair.model.vo.RepairWorkTypeVo" resultMap="collaboratorUserMap">
  198. select ru.id,ru.user_phone,'正常接单' as state,wt.name as work_type,ru.user_name from repair_user ru
  199. 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}
  200. left join repair_work_type wt on wt.deleted = 0 and wt.id = ru.work_type
  201. 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}
  202. <if test="keyWord != null and keyWord != ''">
  203. and (ru.user_name like '%' #{keyWord} '%' or ru.user_phone like '%' #{keyWord} '%')
  204. </if>
  205. </select>
  206. <resultMap type="com.repair.model.vo.PositiveReviewVo" id="positiveReviewMap">
  207. <result property="id" column="id"/>
  208. <result property="userName" column="user_name"/>
  209. <result property="finishCount" column="finish_count"/>
  210. <result property="evaluateCount" column="evaluate_count"/>
  211. </resultMap>
  212. <select id="queryPositiveReviewPage" resultType="com.repair.model.vo.PositiveReviewVo" resultMap="positiveReviewMap">
  213. 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,
  214. (select Count(*) from repair_record rr
  215. inner join repair_evaluate re on re.deleted = 0 and re.star > 3 and re.record_id = rr.id
  216. where rr.deleted = 0 and rr.maintenance_state = 7 and rr.school_id = #{schoolId} and find_in_set(ru.id,rr.maintenancer_id)) as evaluate_count
  217. from repair_user ru
  218. where ru.deleted = 0 and (ru.user_zzid = 1 or ru.user_zzid = 2) and ru.school_id = #{schoolId}
  219. </select>
  220. <select id="dropDown" resultType="com.repair.model.vo.AutoDispatchUserVo">
  221. select * from (
  222. 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
  223. from repair_user ru
  224. inner join repair_classes_settings rcs on rcs.deleted = 0 and rcs.user_id = ru.id and rcs.start_date = CURRENT_DATE()
  225. left join repair_work_type wt on wt.deleted = 0 and wt.id = ru.work_type
  226. where
  227. ru.id in (select user_id from
  228. (select user_id,(select GROUP_CONCAT(id) from repair_article_type where (id = repair_article_build.article_id or parent_id = repair_article_build.article_id) and deleted = 0) as article_id,build_id
  229. from repair_article_build
  230. where deleted = 0) d
  231. where FIND_IN_SET(${articleId},d.article_id) and FIND_IN_SET(${buildId},d.build_id)) and
  232. 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}) t
  233. order by t.rdr_count
  234. </select>
  235. </mapper>