RepairUserMapper.xml 17 KB

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