LiftMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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.library.dao.mapper.LiftMapper">
  4. <resultMap id="BaseResultMap" type="cn.com.ty.lift.business.library.dao.entity.Lift">
  5. <id column="id" property="id" jdbcType="BIGINT"/>
  6. <result column="registration_code" property="registrationCode" jdbcType="VARCHAR"/>
  7. <result column="category" property="category" jdbcType="INTEGER"/>
  8. <result column="lift_type" property="liftType" jdbcType="INTEGER"/>
  9. <result column="lift_code" property="liftCode" jdbcType="CHAR"/>
  10. <result column="manufacture_date" property="manufactureDate" jdbcType="DATE"/>
  11. <result column="factory_code" property="factoryCode" jdbcType="VARCHAR"/>
  12. <result column="device_usage" property="deviceUsage" jdbcType="INTEGER"/>
  13. <result column="lift_brand" property="liftBrand" jdbcType="VARCHAR"/>
  14. <result column="install_company" property="installCompany" jdbcType="VARCHAR"/>
  15. <result column="lift_model" property="liftModel" jdbcType="VARCHAR"/>
  16. <result column="pulley_diameter" property="pulleyDiameter" jdbcType="DECIMAL"/>
  17. <result column="rope_num" property="ropeNum" jdbcType="INTEGER"/>
  18. <result column="lock_model" property="lockModel" jdbcType="VARCHAR"/>
  19. <result column="rated_load" property="ratedLoad" jdbcType="INTEGER"/>
  20. <result column="promote_height" property="promoteHeight" jdbcType="DECIMAL"/>
  21. <result column="step_width" property="stepWidth" jdbcType="DECIMAL"/>
  22. <result column="sidewalk_length" property="sidewalkLength" jdbcType="DECIMAL"/>
  23. <result column="tilt_angle" property="tiltAngle" jdbcType="DECIMAL"/>
  24. <result column="motor_power" property="motorPower" jdbcType="DECIMAL"/>
  25. <result column="rated_speed" property="ratedSpeed" jdbcType="DECIMAL"/>
  26. <result column="layer_station_door" property="layerStationDoor" jdbcType="VARCHAR"/>
  27. <result column="clamp_type" property="clampType" jdbcType="INTEGER"/>
  28. <result column="reform_company" property="reformCompany" jdbcType="VARCHAR"/>
  29. <result column="device_position" property="devicePosition" jdbcType="VARCHAR"/>
  30. <result column="coordinate" property="coordinate" jdbcType="VARCHAR"/>
  31. <result column="remarks" property="remarks" jdbcType="VARCHAR"/>
  32. <result column="creator_id" property="creatorId" jdbcType="BIGINT"/>
  33. <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
  34. <result column="steel_belt" property="steelBelt" jdbcType="INTEGER"/>
  35. <result column="cylinder_type" property="cylinderType" jdbcType="VARCHAR"/>
  36. <result column="cylinder_num" property="cylinderNum" jdbcType="INTEGER"/>
  37. <result column="top_type" property="topType" jdbcType="INTEGER"/>
  38. <result column="control_type" property="controlType" jdbcType="VARCHAR"/>
  39. <result column="mpa" property="mpa" jdbcType="INTEGER"/>
  40. <result column="factory" property="factory" jdbcType="VARCHAR"/>
  41. <result column="custom_number" property="customNumber" jdbcType="VARCHAR"/>
  42. <result column="use_company_code" property="useCompanyCode" jdbcType="VARCHAR"/>
  43. <result column="device_position_code" property="devicePositionCode" jdbcType="CHAR"/>
  44. <result column="agency" property="agency" jdbcType="VARCHAR"/>
  45. <result column="reform_date" property="reformDate" jdbcType="TIMESTAMP"/>
  46. <result column="install_date" property="installDate" jdbcType="TIMESTAMP"/>
  47. <result column="inner_floor" property="innerFloor" jdbcType="INTEGER"/>
  48. <result column="annual_inspection_date" property="annualInspectionDate" jdbcType="DATE"/>
  49. <result column="is_check_governer" property="isCheckGoverner" jdbcType="TINYINT" />
  50. <result column="load_inspection_setting" property="loadInspectionSetting" jdbcType="TINYINT" />
  51. <result column="area_code" property="areaCode" jdbcType="CHAR"/>
  52. <result column="device_id" property="deviceId" jdbcType="VARCHAR"/>
  53. <result column="device_type" property="deviceType" jdbcType="TINYINT"/>
  54. </resultMap>
  55. <sql id="Base_Column_List">
  56. id, registration_code, category, lift_type, lift_code, manufacture_date, factory_code,
  57. device_usage, lift_brand, install_company, lift_model, pulley_diameter, rope_num,
  58. lock_model, rated_load, promote_height, step_width, sidewalk_length, tilt_angle,
  59. motor_power, rated_speed, layer_station_door, clamp_type, reform_company, device_position,
  60. coordinate, remarks, creator_id, create_date, steel_belt, cylinder_type, cylinder_num,
  61. top_type, control_type, mpa, factory, custom_number, use_company_code, device_position_code,
  62. agency, reform_date, install_date, inner_floor, annual_inspection_date, area_code, device_id, device_type
  63. </sql>
  64. <!-- 根据区域,项目,电梯号,电梯品牌,电梯类型,维保工查询电梯列表信息-->
  65. <select id="findByCondition" resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftResponse"
  66. parameterType="cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest">
  67. SELECT l.id AS id,
  68. pclr.id AS companyRelevanceId,
  69. plr.id AS projectRelevanceId,
  70. l.lift_code AS liftCode,
  71. l.registration_code AS registrationCode,
  72. l.lift_type AS liftType,
  73. l.device_position AS devicePosition,
  74. lb.name AS liftBrand,
  75. pclr.lift_company_status AS liftStatus,
  76. plr.first_time AS firstMaintenanceTime,
  77. p.project_name AS projectName,
  78. p.id AS projectId,
  79. plr.lift_locked AS liftLocked,
  80. plr.worker_id AS workerId,
  81. ac.mobile AS mobile
  82. FROM platform_company_lift_relevance pclr
  83. LEFT JOIN lift l ON pclr.lift_id = l.id
  84. LEFT JOIN project_lift_relevance plr ON pclr.mt_company_id = plr.mt_company_id AND pclr.lift_id = plr.lift_id
  85. LEFT JOIN project p ON pclr.mt_company_id = p.mt_company_id AND plr.project_id = p.id
  86. LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
  87. LEFT JOIN user_account ac ON ac.user_id = plr.worker_id
  88. <where>
  89. <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
  90. AND pclr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
  91. </if>
  92. <if test="request.liftStatus == 1">
  93. AND pclr.lift_company_status > 1 AND pclr.delete_flag = 0
  94. </if>
  95. <if test="request.liftStatus == 0">
  96. AND pclr.lift_company_status = 1 AND pclr.delete_flag = 0
  97. </if>
  98. <if test="request.liftType!=null and request.liftType!=''">
  99. AND l.lift_type = #{request.liftType,jdbcType=VARCHAR}
  100. </if>
  101. <if test="request.liftBrand!=null and request.liftBrand!=''">
  102. AND lb.code = #{request.liftBrand,jdbcType=VARCHAR}
  103. </if>
  104. <if test="request.registrationCode!=null and request.registrationCode!=''">
  105. AND l.registration_code LIKE #{request.registrationCode,jdbcType=VARCHAR}
  106. </if>
  107. <if test="request.regionId!=null and request.regionId!=''">
  108. AND p.region_id = #{request.regionId,jdbcType=BIGINT}
  109. </if>
  110. <if test="request.projectId!=null and request.projectId!=''">
  111. AND p.id = #{request.projectId,jdbcType=BIGINT}
  112. </if>
  113. </where>
  114. </select>
  115. <!-- 查询项目下电梯列表 -->
  116. <select id="findLiftListByProjectId"
  117. resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftResponse"
  118. parameterType="cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest">
  119. SELECT
  120. l.id AS id,
  121. l.lift_code AS liftCode,
  122. l.registration_code AS registrationCode,
  123. l.lift_type AS liftType,
  124. l.device_position AS devicePosition,
  125. lb.name AS liftBrand,
  126. l.annual_inspection_date AS annualInspectionDate,
  127. pclr.id AS companyRelevanceId,
  128. pclr.lift_company_status AS liftStatus,
  129. plr.id AS projectRelevanceId,
  130. plr.project_id AS projectId,
  131. plr.worker_id AS workerId,
  132. plr.lift_locked AS liftLocked,
  133. ui.name AS workerName
  134. FROM project_lift_relevance plr
  135. LEFT JOIN lift l ON plr.lift_id = l.id
  136. LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
  137. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  138. LEFT JOIN platform_company_lift_relevance pclr ON plr.lift_id = pclr.lift_id AND pclr.id = plr.relevance_id
  139. WHERE 1=1
  140. <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
  141. AND plr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
  142. </if>
  143. <if test="request.projectId!=null and request.projectId!=''">
  144. AND plr.project_id = #{request.projectId,jdbcType=BIGINT}
  145. </if>
  146. </select>
  147. <!-- 选择电梯 -->
  148. <select id="chooseLiftList" resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftResponse"
  149. parameterType="cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest">
  150. SELECT l.id AS id,
  151. l.lift_code AS liftCode,
  152. l.registration_code AS registrationCode,
  153. l.lift_type AS liftType,
  154. l.device_position AS devicePosition,
  155. lb.name AS liftBrand,
  156. l.annual_inspection_date AS annualInspectionDate,
  157. pclr.lift_company_status AS liftStatus,
  158. pclr.id AS companyRelevanceId,
  159. ui.name AS workerName,
  160. plr.worker_id AS workerId
  161. FROM platform_company_lift_relevance pclr
  162. LEFT JOIN lift l ON pclr.lift_id = l.id
  163. LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
  164. LEFT JOIN project_lift_relevance plr ON pclr.lift_id = plr.lift_id
  165. AND pclr.id = plr.relevance_id
  166. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  167. WHERE pclr.lift_company_status != '1'
  168. AND l.lift_status = '2'
  169. <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
  170. AND pclr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
  171. </if>
  172. AND plr.project_id IS NULL
  173. </select>
  174. <!--根据公司和项目查询电梯 -->
  175. <select id="listByCompanyAndProject" resultType="cn.com.ty.lift.business.library.dao.entity.model.LiftProjectModel">
  176. SELECT plr.id,
  177. plr.project_id,
  178. plr.lift_id,
  179. li.registration_code,
  180. plr.relevance_id,
  181. plr.worker_id,
  182. ui.`name` AS worker_name,
  183. plr.mt_company_id
  184. FROM lift li
  185. LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id
  186. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  187. WHERE plr.mt_company_id = #{mtCompanyId}
  188. AND plr.project_id = #{projectId}
  189. </select>
  190. <select id="queryById" resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftExtendResponse"
  191. parameterType="java.lang.Long">
  192. SELECT l.*,
  193. plr.id AS relevanceId,
  194. plr.worker_id AS workerId,
  195. ui.name AS workerName
  196. FROM lift l
  197. LEFT JOIN project_lift_relevance plr ON l.id = plr.lift_id
  198. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  199. WHERE l.id = #{id,jdbcType=BIGINT}
  200. AND plr.project_id = #{projectId}
  201. </select>
  202. <select id="queryLiftListByIdList" parameterType="java.util.List"
  203. resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.response.LiftPrintResponse">
  204. SELECT l.id AS liftId,
  205. plr.project_id AS projectId,
  206. plr.mt_company_id AS mtCompanyId,
  207. l.registration_code AS registrationCode,
  208. l.device_position AS devicePosition
  209. FROM lift l
  210. LEFT JOIN project_lift_relevance plr ON l.id = plr.lift_id
  211. WHERE l.id IN
  212. <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
  213. #{id}
  214. </foreach>
  215. </select>
  216. <!--lift中的年检时间都是月初, 所以相隔时间(45)-->
  217. <select id="toConfirmAnnualInspection" parameterType="java.lang.Long" resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftAnnualInspectionResponse">
  218. SELECT
  219. li.id AS lift_id,
  220. li.registration_code,
  221. pr.id AS project_id,
  222. pr.project_name,
  223. re.area_name,
  224. li.use_company_code,
  225. li.device_position,
  226. ui.name AS director_name,
  227. li.is_check_governer,
  228. li.load_inspection_setting,
  229. li.annual_inspection_date AS plan_date
  230. FROM lift li
  231. LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id
  232. LEFT JOIN project pr ON plr.project_id = pr.id
  233. LEFT JOIN region re ON re.id = pr.region_id
  234. LEFT JOIN user_info ui ON re.user_id = ui.user_id
  235. LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND ai.mt_company_id = plr.mt_company_id AND ai.plan_date = li.annual_inspection_date
  236. WHERE
  237. li.annual_inspection_date &lt;= date_add(curdate(), INTERVAL #{days} DAY)
  238. AND li.annual_inspection_date &gt;= curdate() AND isnull(ai.id)
  239. <if test="mtCompanyId != null and mtCompanyId > 0">
  240. AND plr.mt_company_id = #{mtCompanyId}
  241. </if>
  242. </select>
  243. <select id="groupByRegistrationCode" resultType="cn.com.ty.lift.business.library.dao.entity.Lift">
  244. SELECT
  245. *
  246. FROM
  247. lift
  248. WHERE
  249. registration_code IN (
  250. SELECT
  251. registration_code
  252. FROM
  253. lift
  254. GROUP BY
  255. registration_code
  256. HAVING
  257. count( * ) > 1
  258. )
  259. ORDER BY
  260. registration_code
  261. </select>
  262. <select id="exportList" resultType="java.util.Map" parameterType="java.util.List">
  263. SELECT l.lift_code AS liftCode,
  264. l.registration_code AS registrationCode,
  265. lb.name AS liftBrand,
  266. if(l.lift_type = 1, '直梯', '扶梯') AS liftType,
  267. l.device_position AS devicePosition
  268. FROM lift l
  269. LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
  270. <where>
  271. <if test="exportList != null and exportList.size > 0">
  272. l.id IN
  273. <foreach collection="exportList" item="id" open="(" separator="," close=")">
  274. #{id}
  275. </foreach>
  276. </if>
  277. </where>
  278. </select>
  279. </mapper>