EmergencyRepairMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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_tel" property="callerTel" jdbcType="CHAR" />
  13. <result column="caller_date" property="callerDate" jdbcType="TIMESTAMP" />
  14. <result column="stop_date" property="stopDate" jdbcType="TIMESTAMP" />
  15. <result column="recovery_date" property="recoveryDate" jdbcType="TIMESTAMP" />
  16. <result column="charge" property="charge" jdbcType="VARCHAR" />
  17. <result column="worker_id" property="workerId" jdbcType="BIGINT" />
  18. <result column="worker_tel" property="workerTel" jdbcType="CHAR" />
  19. <result column="position" property="position" jdbcType="VARCHAR" />
  20. <result column="status" property="status" jdbcType="TINYINT" />
  21. <result column="creator_id" property="creatorId" jdbcType="BIGINT" />
  22. <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
  23. <result column="repair_reason" property="repairReason" jdbcType="TINYINT" />
  24. <result column="parts_cost" property="partsCost" jdbcType="DECIMAL" />
  25. <result column="safety_confirm" property="safetyConfirm" jdbcType="VARCHAR" />
  26. <result column="read_time" property="readTime" jdbcType="TIMESTAMP" />
  27. <result column="worker_id1" property="workerId1" jdbcType="BIGINT" />
  28. <result column="wl_floor" property="wlFloor" jdbcType="INTEGER" />
  29. <result column="wl_liftdoor" property="wlLiftdoor" jdbcType="TINYINT" />
  30. <result column="wl_fault" property="wlFault" jdbcType="VARCHAR" />
  31. <result column="wl_fault_reason" property="wlFaultReason" jdbcType="VARCHAR" />
  32. <result column="wl_fault_handle" property="wlFaultHandle" jdbcType="VARCHAR" />
  33. <result column="wl_run_direction" property="wlRunDirection" jdbcType="TINYINT" />
  34. <result column="cost_total" property="costTotal" jdbcType="DECIMAL" />
  35. <result column="project_id" property="projectId" jdbcType="INTEGER" />
  36. <result column="caller_fault_description" property="callerFaultDescription" jdbcType="LONGVARCHAR" />
  37. <result column="sparepart" property="sparepart" jdbcType="LONGVARCHAR" />
  38. <result column="worker_fault_description" property="workerFaultDescription" jdbcType="LONGVARCHAR" />
  39. <result column="field_description" property="fieldDescription" jdbcType="LONGVARCHAR" />
  40. <result column="repair_procedure" property="repairProcedure" jdbcType="LONGVARCHAR" />
  41. <result column="project_name" property="projectName" jdbcType="VARCHAR" />
  42. <result column="area_name" property="areaName" jdbcType="VARCHAR" />
  43. <result column="registration_code" property="registrationCode" jdbcType="VARCHAR" />
  44. <result column="device_position" property="devicePosition" jdbcType="VARCHAR" />
  45. <result column="call_name" property="callName" jdbcType="VARCHAR" />
  46. <result column="create_name" property="createName" jdbcType="VARCHAR" />
  47. <result column="worker_name" property="workerName" jdbcType="VARCHAR" />
  48. <result column="lift_company_status" property="liftCompanyStatus" jdbcType="VARCHAR" />
  49. <result column="repair_diff" property="repairDiff" jdbcType="BIGINT" />
  50. </resultMap>
  51. <!--查询急修中-->
  52. <select id="listByRepairing" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest">
  53. SELECT
  54. t.*,
  55. ui.name AS worker_name
  56. FROM
  57. (SELECT
  58. er.*,
  59. ui.`name` AS create_name,
  60. li.registration_code,
  61. li.device_position,
  62. pr.project_name,
  63. pclr.lift_company_status
  64. FROM
  65. emergency_repair er
  66. LEFT JOIN user_info ui ON ui.user_id = er.caller_id
  67. LEFT JOIN lift li ON li.id = er.lift_id
  68. LEFT JOIN project pr ON pr.id = er.project_id
  69. LEFT JOIN platform_company_lift_relevance pclr ON pclr.lift_id = li.id
  70. WHERE
  71. er.`status` <![CDATA[ <> ]]> 4 ) t
  72. LEFT JOIN user_info ui ON ui.user_id = t.worker_id1
  73. </select>
  74. <!--根据条件查询急修记录总条数-->
  75. <select id="countByCondition" resultType="java.lang.Long" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest" >
  76. SELECT
  77. count(*)
  78. FROM
  79. emergency_repair er
  80. LEFT JOIN project pr ON er.project_id = pr.id
  81. LEFT JOIN region re ON pr.region_id = re.id
  82. LEFT JOIN lift li ON er.lift_id = li.id
  83. WHERE 1 = 1
  84. <if test="cond.status != null">
  85. AND er.status = #{cond.status}
  86. </if>
  87. </select>
  88. <!--根据条件查询急修记录-->
  89. <select id="listByCondition" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest" >
  90. SELECT
  91. er.*,
  92. li.registration_code AS registration_code,
  93. li.device_position AS device_position,
  94. pr.project_name,
  95. re.area_name,
  96. ui.name AS worker_name,
  97. TimeStampDiff(SECOND ,er.stop_date,er.recovery_date) AS repair_diff
  98. FROM
  99. emergency_repair er
  100. LEFT JOIN project pr ON er.project_id = pr.id
  101. LEFT JOIN region re ON pr.region_id = re.id
  102. LEFT JOIN lift li ON er.lift_id = li.id
  103. LEFT JOIN user_info ui ON ui.user_id = er.worker_id1
  104. WHERE 1 = 1
  105. <if test="cond.projectId != null and cond.projectId > 0">
  106. AND pr.id = #{cond.projectId}
  107. </if>
  108. <if test="cond.regionId != null and cond.regionId > 0">
  109. AND pr.region_id = #{cond.regionId}
  110. </if>
  111. <if test="cond.workerId != null and cond.workerId > 0">
  112. AND er.worker_id1 = #{cond.workerId}
  113. </if>
  114. <if test="cond.repairBegin != null">
  115. AND er.caller_date &gt; #{cond.repairBegin}
  116. </if>
  117. <if test="cond.repairEnd != null">
  118. AND er.caller_date &lt; #{cond.repairEnd}
  119. </if>
  120. <if test="cond.status != null">
  121. AND er.status = #{cond.status}
  122. </if>
  123. <if test="cond.source != null">
  124. AND er.source = #{cond.source}
  125. </if>
  126. <if test="cond.info != null and cond.info != ''">
  127. AND li.registration_code LIKE #{cond.info}
  128. </if>
  129. </select>
  130. <!--根据id查找带扩展信息-->
  131. <select id="selectByIdWithInfo" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest" >
  132. SELECT
  133. er.*,
  134. li.registration_code AS registration_code,
  135. pr.project_name,
  136. re.area_name
  137. FROM
  138. emergency_repair er
  139. LEFT JOIN project pr ON er.project_id = pr.id
  140. LEFT JOIN region re ON pr.region_id = re.id
  141. LEFT JOIN lift li ON er.lift_id = li.id
  142. WHERE er.id = #{cond.id}
  143. </select>
  144. </mapper>