EmergencyRepairMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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="cn.com.ty.lift.business.emergency.mapper.EmergencyRepairMapper" >
  4. <resultMap id="BaseResultMap" type="cn.com.ty.lift.business.emergency.dto.RepairResponse" >
  5. <id column="id" property="id" jdbcType="BIGINT" />
  6. <result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
  7. <result column="lift_id" property="liftId" jdbcType="BIGINT" />
  8. <result column="is_trapped" property="isTrapped" jdbcType="TINYINT" />
  9. <result column="is_critical" property="isCritical" jdbcType="TINYINT" />
  10. <result column="source" property="source" jdbcType="TINYINT" />
  11. <result column="caller_id" property="callerId" jdbcType="BIGINT" />
  12. <result column="caller_name" property="callerName" jdbcType="VARCHAR" />
  13. <result column="caller_tel" property="callerTel" jdbcType="CHAR" />
  14. <result column="caller_date" property="callerDate" jdbcType="TIMESTAMP" />
  15. <result column="stop_date" property="stopDate" jdbcType="TIMESTAMP" />
  16. <result column="recovery_date" property="recoveryDate" jdbcType="TIMESTAMP" />
  17. <result column="assign_time" property="assignTime" jdbcType="TIMESTAMP" />
  18. <result column="taking_time" property="takingTime" jdbcType="TIMESTAMP" />
  19. <result column="arrive_time" property="arriveTime" jdbcType="TIMESTAMP" />
  20. <result column="charge" property="charge" jdbcType="VARCHAR" />
  21. <result column="worker_id" property="workerId" jdbcType="BIGINT" />
  22. <result column="worker_tel" property="workerTel" jdbcType="CHAR" />
  23. <result column="position" property="position" jdbcType="VARCHAR" />
  24. <result column="status" property="status" jdbcType="TINYINT" />
  25. <result column="creator_id" property="creatorId" jdbcType="BIGINT" />
  26. <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
  27. <result column="update_id" property="updateId" jdbcType="BIGINT" />
  28. <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
  29. <result column="repair_reason" property="repairReason" jdbcType="TINYINT" />
  30. <result column="parts_cost" property="partsCost" jdbcType="DECIMAL" />
  31. <result column="safety_confirm" property="safetyConfirm" jdbcType="VARCHAR" />
  32. <result column="read_time" property="readTime" jdbcType="TIMESTAMP" />
  33. <result column="worker_id1" property="workerId1" jdbcType="BIGINT" />
  34. <result column="wl_floor" property="wlFloor" jdbcType="INTEGER" />
  35. <result column="wl_liftdoor" property="wlLiftdoor" jdbcType="TINYINT" />
  36. <result column="wl_fault" property="wlFault" jdbcType="VARCHAR" />
  37. <result column="wl_fault_reason" property="wlFaultReason" jdbcType="VARCHAR" />
  38. <result column="wl_fault_handle" property="wlFaultHandle" jdbcType="VARCHAR" />
  39. <result column="wl_run_direction" property="wlRunDirection" jdbcType="TINYINT" />
  40. <result column="cost_total" property="costTotal" jdbcType="DECIMAL" />
  41. <result column="pay_total" property="payTotal" jdbcType="DECIMAL" />
  42. <result column="invoice_total" property="invoiceTotal" jdbcType="DECIMAL" />
  43. <result column="project_id" property="projectId" jdbcType="BIGINT" />
  44. <result column="caller_fault_description" property="callerFaultDescription" jdbcType="LONGVARCHAR" />
  45. <result column="sparepart" property="sparepart" jdbcType="LONGVARCHAR" />
  46. <result column="worker_fault_description" property="workerFaultDescription" jdbcType="LONGVARCHAR" />
  47. <result column="field_description" property="fieldDescription" jdbcType="LONGVARCHAR" />
  48. <result column="repair_procedure" property="repairProcedure" jdbcType="LONGVARCHAR" />
  49. <result column="close_reason" property="closeReason" jdbcType="VARCHAR" />
  50. <result column="main_sign" property="mainSign" jdbcType="VARCHAR" />
  51. <result column="second_sign" property="secondSign" jdbcType="VARCHAR" />
  52. <result column="has_evaluate" property="hasEvaluate" jdbcType="INTEGER" />
  53. <result column="project_name" property="projectName" jdbcType="VARCHAR" />
  54. <result column="project_code" property="projectCode" jdbcType="VARCHAR" />
  55. <result column="project_address" property="projectAddress" jdbcType="VARCHAR" />
  56. <result column="area_name" property="areaName" jdbcType="VARCHAR" />
  57. <result column="registration_code" property="registrationCode" jdbcType="VARCHAR" />
  58. <result column="use_company_code" property="useCompanyCode" jdbcType="VARCHAR" />
  59. <result column="lift_category" property="liftCategory" jdbcType="INTEGER" />
  60. <result column="lift_type" property="liftType" jdbcType="INTEGER" />
  61. <result column="device_position" property="devicePosition" jdbcType="VARCHAR" />
  62. <result column="create_name" property="createName" jdbcType="VARCHAR" />
  63. <result column="worker_name" property="workerName" jdbcType="VARCHAR" />
  64. <result column="worker_mobile" property="workerMobile" jdbcType="VARCHAR" />
  65. <result column="lift_company_status" property="liftCompanyStatus" jdbcType="VARCHAR" />
  66. <result column="repair_diff" property="repairDiff" jdbcType="BIGINT" />
  67. <result column="advice" property="advice" jdbcType="VARCHAR" />
  68. <result column="img_url" property="imgUrl" jdbcType="VARCHAR" />
  69. <result column="service_level" property="serviceLevel" jdbcType="INTEGER" />
  70. <result column="star_level" property="starLevel" jdbcType="INTEGER" />
  71. </resultMap>
  72. <!--分页查询急修中-->
  73. <select id="pageByRepairing" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest">
  74. SELECT
  75. t.*,
  76. ui.name AS worker_name
  77. FROM
  78. (SELECT
  79. er.*,
  80. ui.`name` AS create_name,
  81. li.registration_code,
  82. li.category AS lift_category,
  83. li.lift_type,
  84. li.use_company_code,
  85. li.device_position,
  86. pr.project_name,
  87. pr.project_code,
  88. pr.address AS project_address,
  89. pclr.lift_company_status
  90. FROM
  91. emergency_repair er
  92. LEFT JOIN user_info ui ON ui.user_id = er.creator_id
  93. LEFT JOIN lift li ON li.id = er.lift_id
  94. LEFT JOIN project pr ON pr.id = er.project_id
  95. LEFT JOIN platform_company_lift_relevance pclr ON pclr.lift_id = er.lift_id AND pclr.mt_company_id = er.mt_company_id
  96. WHERE
  97. er.`status` IN (0,1)
  98. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  99. AND er.mt_company_id = #{cond.mtCompanyId}
  100. </if>
  101. ) t
  102. LEFT JOIN user_info ui ON ui.user_id = t.worker_id1
  103. </select>
  104. <!--根据条件查询急修记录总条数-->
  105. <select id="countByCondition" resultType="java.lang.Long" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest" >
  106. SELECT
  107. count(*)
  108. FROM
  109. emergency_repair er
  110. <where>
  111. <if test="cond.status != null">
  112. AND er.status = #{cond.status}
  113. </if>
  114. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  115. AND er.mt_company_id = #{cond.mtCompanyId}
  116. </if>
  117. </where>
  118. </select>
  119. <!--根据条件分页查询急修记录-->
  120. <select id="pageByCondition" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest" >
  121. SELECT
  122. er.*,
  123. li.registration_code,
  124. li.device_position,
  125. li.category AS lift_category,
  126. li.lift_type,
  127. li.use_company_code,
  128. pr.project_name,
  129. pr.project_code,
  130. pr.address AS project_address,
  131. re.area_name,
  132. ui.name AS worker_name,
  133. ui.mobile AS worker_mobile,
  134. TimeStampDiff(SECOND ,er.stop_date,er.recovery_date) * 1000 AS repair_diff
  135. FROM
  136. emergency_repair er
  137. LEFT JOIN project pr ON er.project_id = pr.id AND pr.mt_company_id = er.mt_company_id
  138. LEFT JOIN region re ON pr.region_id = re.id
  139. LEFT JOIN lift li ON er.lift_id = li.id
  140. LEFT JOIN user_info ui ON ui.user_id = er.worker_id1
  141. <where>
  142. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  143. AND er.mt_company_id = #{cond.mtCompanyId}
  144. </if>
  145. <if test="cond.projectId != null and cond.projectId > 0">
  146. AND pr.id = #{cond.projectId}
  147. </if>
  148. <if test="cond.regionId != null and cond.regionId > 0">
  149. AND pr.region_id = #{cond.regionId}
  150. </if>
  151. <if test="cond.workerId != null and cond.workerId > 0">
  152. AND er.worker_id1 = #{cond.workerId}
  153. </if>
  154. <if test="cond.repairBegin != null">
  155. AND date(er.caller_date) &gt;= #{cond.repairBegin}
  156. </if>
  157. <if test="cond.repairEnd != null">
  158. AND date(er.caller_date) &lt;= #{cond.repairEnd}
  159. </if>
  160. <if test="cond.status != null">
  161. AND er.status = #{cond.status}
  162. </if>
  163. <if test="cond.source != null">
  164. AND er.source = #{cond.source}
  165. </if>
  166. <if test="cond.info != null and cond.info != ''">
  167. AND li.registration_code LIKE concat('%',#{cond.info},'%')
  168. </if>
  169. </where>
  170. </select>
  171. <select id="listByIdList" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest" >
  172. SELECT
  173. er.*,
  174. li.registration_code,
  175. li.device_position,
  176. li.category AS lift_category,
  177. li.lift_type,
  178. li.use_company_code,
  179. pr.project_code,
  180. pr.address AS project_address,
  181. pr.project_name,
  182. re.area_name,
  183. ev.advice,
  184. ev.service_level,
  185. ev.star_level,
  186. ev.img_url,
  187. ui.name AS worker_name,
  188. TimeStampDiff(SECOND ,er.stop_date,er.recovery_date) * 1000 AS repair_diff
  189. FROM
  190. emergency_repair er
  191. LEFT JOIN project pr ON er.project_id = pr.id AND pr.mt_company_id = er.mt_company_id
  192. LEFT JOIN region re ON pr.region_id = re.id AND re.mt_company_id = er.mt_company_id
  193. LEFT JOIN lift li ON er.lift_id = li.id
  194. LEFT JOIN user_info ui ON ui.user_id = er.worker_id1
  195. LEFT JOIN evaluation ev ON ev.record_id = er.id AND ev.source = 2
  196. <where>
  197. <if test="cond.ids != null">
  198. AND er.id IN
  199. <foreach collection="cond.ids" item="id" open="(" separator="," close=")">
  200. #{id}
  201. </foreach>
  202. </if>
  203. </where>
  204. </select>
  205. <!--根据id查找带扩展信息-->
  206. <select id="infoById" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  207. SELECT
  208. er.*,
  209. li.registration_code,
  210. li.device_position,
  211. li.category AS lift_category,
  212. li.lift_type,
  213. li.use_company_code,
  214. pr.project_name,
  215. pr.project_code,
  216. pr.address AS project_address,
  217. re.area_name,
  218. ui.name AS worker_name
  219. FROM
  220. emergency_repair er
  221. LEFT JOIN project pr ON er.project_id = pr.id
  222. LEFT JOIN region re ON pr.region_id = re.id
  223. LEFT JOIN lift li ON er.lift_id = li.id
  224. LEFT JOIN user_info ui ON ui.user_id = er.worker_id1
  225. WHERE er.id = #{id}
  226. </select>
  227. <!--根据用户查询急修信息-->
  228. <select id="pageByUser" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest" >
  229. SELECT
  230. er.*,
  231. pr.project_name,
  232. pr.project_code,
  233. pr.address AS project_address,
  234. li.registration_code,
  235. li.category AS lift_category,
  236. li.lift_type,
  237. li.use_company_code,
  238. re.area_name
  239. FROM
  240. project_user pu
  241. LEFT JOIN project pr ON pu.project_id = pr.id
  242. LEFT JOIN emergency_repair er ON er.project_id = pr.id AND er.mt_company_id = pu.mt_company_id
  243. LEFT JOIN lift li ON er.lift_id = li.id
  244. LEFT JOIN region re ON re.id = pr.region_id
  245. <where>
  246. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  247. AND er.mt_company_id = #{cond.mtCompanyId}
  248. </if>
  249. <if test="cond.userId != null and cond.userId > 0">
  250. AND pu.user_id = #{cond.userId}
  251. </if>
  252. <if test="cond.status != null">
  253. AND er.status = #{cond.status}
  254. </if>
  255. </where>
  256. </select>
  257. <!--根据条件分页查询急修记录-->
  258. <select id="pageByLift" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest" >
  259. SELECT
  260. er.*,
  261. li.registration_code,
  262. li.use_company_code,
  263. ui.name AS worker_name
  264. FROM
  265. emergency_repair er
  266. LEFT JOIN lift li ON er.lift_id = li.id
  267. LEFT JOIN user_info ui ON ui.user_id = er.worker_id1
  268. <where>
  269. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  270. AND er.mt_company_id = #{cond.mtCompanyId}
  271. </if>
  272. <if test="cond.projectId != null and cond.projectId > 0">
  273. AND er.project_id = #{cond.projectId}
  274. </if>
  275. <if test="cond.liftId != null and cond.liftId > 0">
  276. AND er.lift_id = #{cond.liftId}
  277. </if>
  278. </where>
  279. </select>
  280. <select id="countDoingByWorker" resultType="java.lang.Long" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest">
  281. SELECT
  282. count(*)
  283. FROM
  284. emergency_repair er
  285. WHERE er.status IN (0, 1)
  286. <if test="cond.userId != null and cond.userId > 0">
  287. AND er.worker_id1 = #{cond.userId}
  288. </if>
  289. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  290. AND er.mt_company_id = #{cond.mtCompanyId}
  291. </if>
  292. </select>
  293. <select id="countDoingByUser" resultType="java.lang.Long" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest">
  294. SELECT
  295. count(*)
  296. FROM
  297. emergency_repair er
  298. LEFT JOIN project_user pu ON er.project_id = pu.project_id AND er.mt_company_id = pu.mt_company_id
  299. WHERE er.status IN (0, 1)
  300. <if test="cond.userId != null and cond.userId > 0">
  301. AND pu.user_id = #{cond.userId}
  302. </if>
  303. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  304. AND er.mt_company_id = #{cond.mtCompanyId}
  305. </if>
  306. </select>
  307. <select id="findUserRole" resultType="java.lang.String" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest">
  308. SELECT
  309. user_role
  310. FROM
  311. project_user
  312. <where>
  313. <if test="cond.userId != null and cond.userId > 0">
  314. AND user_id = #{cond.userId}
  315. </if>
  316. <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
  317. AND mt_company_id = #{cond.mtCompanyId}
  318. </if>
  319. </where>
  320. </select>
  321. </mapper>