LiftMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. ui.name AS workerName
  83. FROM platform_company_lift_relevance pclr
  84. LEFT JOIN lift l ON pclr.lift_id = l.id
  85. LEFT JOIN project_lift_relevance plr ON pclr.mt_company_id = plr.mt_company_id AND pclr.lift_id = plr.lift_id
  86. LEFT JOIN project p ON pclr.mt_company_id = p.mt_company_id AND plr.project_id = p.id
  87. LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
  88. LEFT JOIN user_account ac ON ac.user_id = plr.worker_id
  89. LEFT JOIN user_info ui ON ui.user_id = plr.worker_id
  90. <where>
  91. <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
  92. AND pclr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
  93. </if>
  94. <if test="request.liftStatus == 1">
  95. AND pclr.lift_company_status > 1 AND pclr.delete_flag = 0
  96. </if>
  97. <if test="request.liftStatus == 0">
  98. AND pclr.lift_company_status = 1 AND pclr.delete_flag = 0
  99. </if>
  100. <if test="request.liftType!=null and request.liftType!=''">
  101. AND l.lift_type = #{request.liftType,jdbcType=VARCHAR}
  102. </if>
  103. <if test="request.liftBrand!=null and request.liftBrand!=''">
  104. AND lb.code = #{request.liftBrand,jdbcType=VARCHAR}
  105. </if>
  106. <if test="request.registrationCode!=null and request.registrationCode!=''">
  107. AND l.registration_code LIKE #{request.registrationCode,jdbcType=VARCHAR}
  108. </if>
  109. <if test="request.regionId!=null and request.regionId!=''">
  110. AND p.region_id = #{request.regionId,jdbcType=BIGINT}
  111. </if>
  112. <if test="request.projectId!=null and request.projectId!=''">
  113. AND p.id = #{request.projectId,jdbcType=BIGINT}
  114. </if>
  115. </where>
  116. </select>
  117. <!-- 查询项目下电梯列表 -->
  118. <select id="findLiftListByProjectId"
  119. resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftResponse"
  120. parameterType="cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest">
  121. SELECT
  122. l.id AS id,
  123. l.lift_code AS liftCode,
  124. l.registration_code AS registrationCode,
  125. l.lift_type AS liftType,
  126. l.device_position AS devicePosition,
  127. lb.name AS liftBrand,
  128. l.annual_inspection_date AS annualInspectionDate,
  129. pclr.id AS companyRelevanceId,
  130. pclr.lift_company_status AS liftStatus,
  131. plr.id AS projectRelevanceId,
  132. plr.project_id AS projectId,
  133. plr.worker_id AS workerId,
  134. plr.lift_locked AS liftLocked,
  135. ui.name AS workerName
  136. FROM project_lift_relevance plr
  137. LEFT JOIN lift l ON plr.lift_id = l.id
  138. LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
  139. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  140. LEFT JOIN platform_company_lift_relevance pclr ON plr.lift_id = pclr.lift_id AND pclr.id = plr.relevance_id
  141. WHERE 1=1
  142. <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
  143. AND plr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
  144. </if>
  145. <if test="request.projectId!=null and request.projectId!=''">
  146. AND plr.project_id = #{request.projectId,jdbcType=BIGINT}
  147. </if>
  148. </select>
  149. <!-- 选择电梯 -->
  150. <select id="chooseLiftList" resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftResponse"
  151. parameterType="cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest">
  152. SELECT l.id AS id,
  153. l.lift_code AS liftCode,
  154. l.registration_code AS registrationCode,
  155. l.lift_type AS liftType,
  156. l.device_position AS devicePosition,
  157. lb.name AS liftBrand,
  158. l.annual_inspection_date AS annualInspectionDate,
  159. pclr.lift_company_status AS liftStatus,
  160. pclr.id AS companyRelevanceId,
  161. ui.name AS workerName,
  162. plr.worker_id AS workerId
  163. FROM platform_company_lift_relevance pclr
  164. LEFT JOIN lift l ON pclr.lift_id = l.id
  165. LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
  166. LEFT JOIN project_lift_relevance plr ON pclr.lift_id = plr.lift_id
  167. AND pclr.id = plr.relevance_id
  168. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  169. WHERE pclr.lift_company_status != '1'
  170. AND l.lift_status = '2'
  171. <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
  172. AND pclr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
  173. </if>
  174. AND plr.project_id IS NULL
  175. </select>
  176. <!--根据公司和项目查询电梯 -->
  177. <select id="listByCompanyAndProject" resultType="cn.com.ty.lift.business.library.dao.entity.model.LiftProjectModel">
  178. SELECT plr.id,
  179. plr.project_id,
  180. plr.lift_id,
  181. li.registration_code,
  182. plr.relevance_id,
  183. plr.worker_id,
  184. ui.`name` AS worker_name,
  185. plr.mt_company_id
  186. FROM lift li
  187. LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id
  188. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  189. WHERE plr.mt_company_id = #{mtCompanyId}
  190. AND plr.project_id = #{projectId}
  191. </select>
  192. <select id="queryById" resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftExtendResponse"
  193. parameterType="java.lang.Long">
  194. SELECT l.*,
  195. plr.id AS relevanceId,
  196. plr.worker_id AS workerId,
  197. ui.name AS workerName
  198. FROM lift l
  199. LEFT JOIN project_lift_relevance plr ON l.id = plr.lift_id
  200. LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
  201. WHERE l.id = #{id,jdbcType=BIGINT}
  202. AND plr.project_id = #{projectId}
  203. </select>
  204. <select id="queryLiftListByIdList" parameterType="java.util.List"
  205. resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.response.LiftPrintResponse">
  206. SELECT l.id AS liftId,
  207. plr.project_id AS projectId,
  208. plr.mt_company_id AS mtCompanyId,
  209. l.registration_code AS registrationCode,
  210. l.device_position AS devicePosition
  211. FROM lift l
  212. LEFT JOIN project_lift_relevance plr ON l.id = plr.lift_id
  213. WHERE l.id IN
  214. <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
  215. #{id}
  216. </foreach>
  217. </select>
  218. <!--lift中的年检时间都是月初, 所以相隔时间(45)-->
  219. <select id="toConfirmAnnualInspection" parameterType="java.lang.Long" resultType="cn.com.ty.lift.business.library.dao.entity.model.response.LiftAnnualInspectionResponse">
  220. SELECT
  221. li.id AS lift_id,
  222. li.registration_code,
  223. pr.id AS project_id,
  224. pr.project_name,
  225. re.area_name,
  226. li.use_company_code,
  227. li.device_position,
  228. ui.name AS director_name,
  229. li.is_check_governer,
  230. li.load_inspection_setting,
  231. li.annual_inspection_date AS plan_date
  232. FROM lift li
  233. LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id
  234. LEFT JOIN project_user pu ON pu.project_id = plr.project_id AND pu.mt_company_id = ai.mt_company_id
  235. LEFT JOIN project pr ON plr.project_id = pr.id
  236. LEFT JOIN region re ON re.id = pr.region_id
  237. LEFT JOIN user_info ui ON re.user_id = ui.user_id
  238. 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
  239. WHERE
  240. li.annual_inspection_date &lt;= date_add(curdate(), INTERVAL #{days} DAY)
  241. AND li.annual_inspection_date &gt;= curdate() AND isnull(ai.id)
  242. <if test="mtCompanyId != null and mtCompanyId > 0">
  243. AND plr.mt_company_id = #{mtCompanyId}
  244. </if>
  245. <if test="userId != null and userId > 0">
  246. AND pu.userId = #{userId}
  247. </if>
  248. </select>
  249. <select id="groupByRegistrationCode" resultType="cn.com.ty.lift.business.library.dao.entity.Lift">
  250. SELECT
  251. *
  252. FROM
  253. lift
  254. WHERE
  255. registration_code IN (
  256. SELECT
  257. registration_code
  258. FROM
  259. lift
  260. GROUP BY
  261. registration_code
  262. HAVING
  263. count( * ) > 1
  264. )
  265. ORDER BY
  266. registration_code
  267. </select>
  268. <select id="exportList" resultType="java.util.Map" parameterType="java.util.List">
  269. SELECT l.lift_code AS liftCode,
  270. l.registration_code AS registrationCode,
  271. lb.name AS liftBrand,
  272. if(l.lift_type = 1, '直梯', '扶梯') AS liftType,
  273. l.device_position AS devicePosition
  274. FROM lift l
  275. LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
  276. <where>
  277. <if test="exportList != null and exportList.size > 0">
  278. l.id IN
  279. <foreach collection="exportList" item="id" open="(" separator="," close=")">
  280. #{id}
  281. </foreach>
  282. </if>
  283. </where>
  284. </select>
  285. </mapper>