PlanFactoryMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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="com.tofly.gpsboot.mapper.plan.PlanFactoryMapper">
  4. <resultMap id="planFactoryMap" type="com.tofly.pojo.plan.PlanFactory">
  5. <id property="id" column="ID"/>
  6. <result property="planId" column="PLAN_ID"/>
  7. <result property="belongStationId" column="BELONG_STATION_ID"/>
  8. <result property="belongPumpId" column="BELONG_PUMP_ID"/>
  9. <result property="category" column="CATEGORY"/>
  10. <result property="inspectTypeId" column="INSPECT_TYPE_ID"/>
  11. <result property="deviceId" column="DEVICE_Id"/>
  12. <result property="deviceType" column="DEVICE_TYPE"/>
  13. <result property="isOver" column="IS_OVER"/>
  14. <result property="isDeviceError" column="IS_DEVICE_ERROR"/>
  15. <result property="overDate" column="OVER_DATE"/>
  16. <result property="overUser" column="OVER_USER"/>
  17. <result property="longitude" column="LONGITUDE"/>
  18. <result property="latitude" column="LATITUDE"/>
  19. <result property="address" column="ADDRESS"/>
  20. <result property="fileIds" column="FILE_IDS"/>
  21. <result property="note" column="NOTE"/>
  22. <result property="overAddress" column="OVER_ADDRESS"/>
  23. <result property="createUser" column="CREATE_USER"/>
  24. <result property="createTime" column="CREATE_TIME"/>
  25. <association property="isOverName" column="IS_OVER" select="getIsOverName"/>
  26. <association property="isDeviceErrorName" column="IS_DEVICE_ERROR" select="getIsDeviceErrorName"/>
  27. <association property="overUserName" column="OVER_USER"
  28. select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
  29. <association property="createUserName" column="CREATE_USER"
  30. select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
  31. <association property="filePathList" column="FILE_IDS"
  32. select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getFilePathList"/>
  33. <association property="belongStationName" column="BELONG_STATION_ID" select="getBelongStationName"/>
  34. <association property="belongPumpName" column="BELONG_PUMP_ID" select="getBelongPumpName"/>
  35. <association property="categoryName" column="CATEGORY" select="getCategoryName"/>
  36. <association property="deviceTypeName" column="DEVICE_TYPE" select="getDeviceTypeName"/>
  37. <association property="inspectTypeName" column="INSPECT_TYPE_ID"
  38. select="com.tofly.gpsboot.mapper.plan.InspecttypeMapper.getInspectTypeName"/>
  39. <association property="device" column="DEVICE_Id" select="getDeviceInfo"/>
  40. <association property="stationSiteInfo" column="FACTORY_ID" select="getStationSiteInfo"/>
  41. </resultMap>
  42. <select id="getBelongPumpName" resultType="string">
  43. select name
  44. from tf_monitor_pump_station_w
  45. where id = #{belongPumpId}
  46. </select>
  47. <select id="getBelongStationName" resultType="string">
  48. select name
  49. from tf_ywpn_monitor_stationsiteinfo_w
  50. where id = #{belongStationId}
  51. </select>
  52. <select id="getIsOverName" resultType="string">
  53. SELECT case #{isOver} when '0' then '否' when '1' then '是' end
  54. </select>
  55. <select id="getIsDeviceErrorName" resultType="string">
  56. SELECT case#{isDeviceError} when '0' then '正常' when '1' then '异常' end
  57. </select>
  58. <select id="getCategoryName" resultType="string">
  59. select PCNAME categoryName
  60. from TF_YWPN_SYSCHILDCODE_D
  61. where PCID = 50700
  62. and ID = #{category}
  63. </select>
  64. <select id="getDeviceTypeName" resultType="string">
  65. select name deviceTypeName
  66. FROM tf_ywpn_monitor_devicetype_w
  67. where id = #{deviceType}
  68. </select>
  69. <select id="getDeviceInfo" resultType="com.tofly.pojo.Device">
  70. select *
  71. from TF_YWPN_MONITOR_DEVICE_W
  72. where id = #{deviceId}
  73. </select>
  74. <select id="getStationSiteInfo" resultType="com.tofly.pojo.Stationsiteinfo">
  75. select *
  76. from TF_YWPN_MONITOR_STATIONSITEINFO_W
  77. where id = #{factoryId}
  78. </select>
  79. <select id="getPlanDeviceList" resultMap="planFactoryMap">
  80. SELECT
  81. t1.belong_station_id,
  82. t1.belong_Pump_Id,
  83. t1.category,
  84. t1.id as device_Id,
  85. t1.type as device_Type,
  86. t1.latitude,
  87. t1.longitude,
  88. t1.location address,
  89. t2.name belongStationName,
  90. t3.name belongPumpName,
  91. t1.id as id,
  92. t4.is_Over,
  93. t4.OVER_DATE,
  94. t4.OVER_USER,
  95. t4.id as plan_Id
  96. FROM tf_ywpn_monitor_device_w t1
  97. LEFT JOIN tf_ywpn_monitor_stationsiteinfo_w t2
  98. on t1.belong_station_id = t2.id
  99. LEFT JOIN tf_monitor_pump_station_w t3
  100. on t1.belong_Pump_Id = t3.id
  101. RIGHT JOIN tf_ywpn_plan_factory t4
  102. on t1.id = t4.device_Id
  103. where 1=1
  104. <if test="dto.category != null ">
  105. and t1.category =#{dto.category}
  106. </if>
  107. <if test="dto.belongStationId != null ">
  108. and t1.belong_station_id =#{dto.belongStationId}
  109. </if>
  110. <if test="dto.belongPumpId != null ">
  111. and t1.belong_Pump_Id =#{dto.belongPumpId}
  112. </if>
  113. <if test="dto.isOver != null ">
  114. and t4.is_Over =#{dto.isOver}
  115. </if>
  116. <if test="dto.planId != null ">
  117. and t4.PLAN_ID =#{dto.planId}
  118. </if>
  119. <if test="dto.belongStationName != null and dto.belongStationName != '' ">
  120. and t2.name like CONCAT ('%',#{dto.belongStationName,jdbcType=VARCHAR},'%')
  121. </if>
  122. <if test="dto.belongPumpName != null and dto.belongPumpName != '' ">
  123. and t3.name like CONCAT ('%',#{dto.belongPumpName,jdbcType=VARCHAR},'%')
  124. </if>
  125. </select>
  126. <select id="getDeviceList" resultMap="planFactoryMap">
  127. SELECT
  128. t1.belong_station_id,
  129. t1.belong_Pump_Id,
  130. t1.category,
  131. t1.id as device_Id,
  132. t1.type as device_Type,
  133. t1.latitude,
  134. t1.longitude,
  135. t1.location address,
  136. t2.name belongStationName,
  137. t3.name belongPumpName,
  138. t1.id as id
  139. FROM tf_ywpn_monitor_device_w t1
  140. LEFT JOIN tf_ywpn_monitor_stationsiteinfo_w t2
  141. on t1.belong_station_id = t2.id
  142. LEFT JOIN tf_monitor_pump_station_w t3
  143. on t1.belong_Pump_Id = t3.id
  144. where 1=1
  145. <if test="dto.category != null ">
  146. and t1.category =#{dto.category}
  147. </if>
  148. <if test="dto.belongStationId != null ">
  149. and t1.belong_station_id =#{dto.belongStationId}
  150. </if>
  151. <if test="dto.belongPumpId != null ">
  152. and t1.belong_Pump_Id =#{dto.belongPumpId}
  153. </if>
  154. <if test="dto.belongStationName != null and dto.belongStationName != '' ">
  155. and t2.name like CONCAT ('%',#{dto.belongStationName,jdbcType=VARCHAR},'%')
  156. </if>
  157. <if test="dto.belongPumpName != null and dto.belongPumpName != '' ">
  158. and t3.name like CONCAT ('%',#{dto.belongPumpName,jdbcType=VARCHAR},'%')
  159. </if>
  160. </select>
  161. <select id="getMaintenanceStatisticsPlan" resultType="com.tofly.pojo.statement.vo.MaintenancePlanVo">
  162. select t1.CATEGORY category,
  163. (select PCNAME from tf_ywpn_syschildcode_d where ID = t1.CATEGORY) categoryName,
  164. t1.BELONG_STATION_ID belongStationId,
  165. t4.name belongStationName,
  166. t1.BELONG_PUMP_ID belongPumpId,
  167. t5.name belongPumpName,
  168. t1.DEVICE_ID ID,
  169. t1.DEVICE_ID deviceId,
  170. t2.name deviceName,
  171. t2.no deviceCode,
  172. t1.DEVICE_TYPE deviceTypeId,
  173. t6.name deviceTypeName,
  174. t2.status status,
  175. (case t2.status when '0' then '离线' when '1' then '正常' when '2' then '报警'end) statusName,
  176. sum(CASE t3.PLAN_TYPE WHEN '0' THEN 1 else 0 END) inspectionNum,
  177. sum(CASE t3.PLAN_TYPE WHEN '1' THEN 1 else 0 END) maintainNum,
  178. sum(CASE t3.PLAN_TYPE WHEN '0' THEN
  179. (CASE t1.IS_DEVICE_ERROR WHEN '0' THEN 1 else 0 END) else 0 END) normalInspectionNum,
  180. sum(CASE t3.PLAN_TYPE WHEN '0' THEN
  181. (CASE t1.IS_DEVICE_ERROR WHEN '1' THEN 1 else 0 END) else 0 END) errorInspectionNum,
  182. sum(CASE t3.PLAN_TYPE WHEN '1' THEN
  183. (CASE t1.IS_DEVICE_ERROR WHEN '0' THEN 1 else 0 END) else 0 END) normalMaintainNum,
  184. sum(CASE t3.PLAN_TYPE WHEN '1' THEN
  185. (CASE t1.IS_DEVICE_ERROR WHEN '1' THEN 1 else 0 END) else 0 END) errorMaintainNum
  186. from tf_ywpn_plan_factory t1 left join tf_ywpn_monitor_device_w t2
  187. on t1.DEVICE_ID = t2.id right join tf_ywpn_plan_w t3
  188. on t1.PLAN_ID = t3.ID left join tf_ywpn_monitor_stationsiteinfo_w t4
  189. on t1.BELONG_STATION_ID = t4.ID left join tf_monitor_pump_station_w t5
  190. on t1.BELONG_PUMP_ID = t5.ID left join tf_ywpn_monitor_devicetype_w t6
  191. on t1.DEVICE_TYPE = t6.id
  192. where 1=1
  193. <if test="dto.category != null ">
  194. and t1.category =#{dto.category}
  195. </if>
  196. <if test="dto.belongPumpId != null ">
  197. and t1.BELONG_PUMP_ID =#{dto.belongPumpId}
  198. </if>
  199. <if test="dto.belongStationId != null ">
  200. and t1.BELONG_STATION_ID =#{dto.belongStationId}
  201. </if>
  202. <if test="dto.status != null and dto.status != '' ">
  203. and t2.status = #{dto.status}
  204. </if>
  205. <if test="dto.likStr != null and dto.likStr != '' ">
  206. and t2.name like CONCAT ('%',#{dto.likStr},'%')
  207. or deviceTypeName like CONCAT ('%',#{dto.likStr},'%')
  208. </if>
  209. GROUP BY
  210. t1.CATEGORY,t1.BELONG_STATION_ID,t1.BELONG_PUMP_ID,t1.DEVICE_ID,t2.name,t2.no,t1.DEVICE_TYPE,t1.IS_DEVICE_ERROR,t2.status,t3.PLAN_TYPE,t4.name,t5.name,t6.name
  211. </select>
  212. </mapper>