LiftMapper.xml 17 KB

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