DeviceMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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.zcxk.smartcity.data.access.dao.DeviceMapper">
  4. <!--auto generated Code-->
  5. <resultMap id="BaseResultMap" type="com.zcxk.smartcity.data.access.entity.Device">
  6. <result column="id" property="id" jdbcType="BIGINT"/>
  7. <result column="device_no" property="deviceNo" jdbcType="VARCHAR"/>
  8. <result column="device_type" property="deviceType" jdbcType="BIGINT"/>
  9. <result column="device_category" property="deviceCategory" jdbcType="INTEGER"/>
  10. <result column="is_water" property="isWater" jdbcType="INTEGER"/>
  11. <result column="sys_id" property="sysId" jdbcType="BIGINT"/>
  12. <result column="site_id" property="siteId" jdbcType="BIGINT"/>
  13. <result column="building_id" property="buildingId" jdbcType="BIGINT"/>
  14. <result column="community" property="communityId" jdbcType="INTEGER"/>
  15. <result column="floor" property="floorId" jdbcType="INTEGER"/>
  16. <result column="loc_desc" property="locDesc" jdbcType="VARCHAR"/>
  17. <result column="related_device_no" property="relatedDeviceNo" jdbcType="BIGINT"/>
  18. <result column="manufacturer_id" property="manufacturerId" jdbcType="BIGINT"/>
  19. <result column="device_status" property="deviceStatus" jdbcType="INTEGER"/>
  20. <result column="status" property="status" jdbcType="INTEGER"/>
  21. <result column="is_tag" property="isTag" jdbcType="INTEGER"/>
  22. <result column="is_card" property="isCard" jdbcType="INTEGER"/>
  23. <result column="is_lora_meter" property="isLoraMeter" jdbcType="INTEGER"/>
  24. <result column="x_coordinates" property="xCoordinates" jdbcType="DECIMAL"/>
  25. <result column="y_coordinates" property="yCoordinates" jdbcType="DECIMAL"/>
  26. <result column="customer_id" property="customerId" jdbcType="INTEGER"/>
  27. <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
  28. <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
  29. <result column="date_create" property="dateCreate" jdbcType="TIMESTAMP"/>
  30. <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP"/>
  31. </resultMap>
  32. <!--auto generated Code-->
  33. <sql id="Base_Column_List">
  34. id,
  35. device_no,
  36. device_type,
  37. sys_id,
  38. site_id,
  39. building_id,
  40. floor,
  41. loc_desc,
  42. related_device_no,
  43. manufacturer_id,
  44. device_status,
  45. status,
  46. is_tag,
  47. x_coordinates,
  48. y_coordinates,
  49. create_by,
  50. update_by,
  51. date_create,
  52. date_update
  53. </sql>
  54. <!--auto generated Code-->
  55. <insert id="insert" useGeneratedKeys="true" keyProperty="device.id">
  56. INSERT INTO sc_device (
  57. id,
  58. device_no,
  59. device_type,
  60. sys_id,
  61. site_id,
  62. building_id,
  63. floor,
  64. loc_desc,
  65. related_device_no,
  66. manufacturer_id,
  67. device_status,
  68. status,
  69. is_tag,
  70. x_coordinates,
  71. y_coordinates,
  72. create_by,
  73. update_by,
  74. date_create,
  75. date_update
  76. ) VALUES (
  77. #{device.id,jdbcType=BIGINT},
  78. #{device.deviceNo,jdbcType=VARCHAR},
  79. #{device.deviceType,jdbcType=BIGINT},
  80. #{device.sysId,jdbcType=BIGINT},
  81. #{device.siteId,jdbcType=BIGINT},
  82. #{device.buildingId,jdbcType=BIGINT},
  83. #{device.floorId,jdbcType=INTEGER},
  84. #{device.locDesc,jdbcType=VARCHAR},
  85. #{device.relatedDeviceNo,jdbcType=BIGINT},
  86. #{device.manufacturerId,jdbcType=BIGINT},
  87. #{device.deviceStatus,jdbcType=INTEGER},
  88. #{device.status,jdbcType=INTEGER},
  89. #{device.isTag,jdbcType=INTEGER},
  90. #{device.xCoordinates,jdbcType=DECIMAL},
  91. #{device.yCoordinates,jdbcType=DECIMAL},
  92. #{device.createBy,jdbcType=VARCHAR},
  93. #{device.updateBy,jdbcType=VARCHAR},
  94. #{device.dateCreate,jdbcType=TIMESTAMP},
  95. #{device.dateUpdate,jdbcType=TIMESTAMP}
  96. )
  97. </insert>
  98. <!--auto generated Code-->
  99. <insert id="insertSelective" useGeneratedKeys="true" keyProperty="device.id">
  100. INSERT INTO sc_device
  101. <trim prefix="(" suffix=")" suffixOverrides=",">
  102. <if test="device.id!=null"> id,</if>
  103. <if test="device.deviceNo!=null"> device_no,</if>
  104. <if test="device.deviceType!=null"> device_type,</if>
  105. <if test="device.sysId!=null"> sys_id,</if>
  106. <if test="device.siteId!=null"> site_id,</if>
  107. <if test="device.buildingId!=null"> building_id,</if>
  108. <if test="device.floorId!=null"> floor,</if>
  109. <if test="device.locDesc!=null"> loc_desc,</if>
  110. <if test="device.relatedDeviceNo!=null"> related_device_no,</if>
  111. <if test="device.manufacturerId!=null"> manufacturer_id,</if>
  112. <if test="device.deviceStatus!=null"> device_status,</if>
  113. <if test="device.status!=null"> status,</if>
  114. <if test="device.isTag!=null"> is_tag,</if>
  115. <if test="device.xCoordinates!=null"> x_coordinates,</if>
  116. <if test="device.yCoordinates!=null"> y_coordinates,</if>
  117. <if test="device.createBy!=null"> create_by,</if>
  118. <if test="device.updateBy!=null"> update_by,</if>
  119. <if test="device.dateCreate!=null"> date_create,</if>
  120. <if test="device.dateUpdate!=null"> date_update,</if>
  121. </trim>
  122. VALUES
  123. <trim prefix="(" suffix=")" suffixOverrides=",">
  124. <if test="device.id!=null">#{device.id,jdbcType=BIGINT},
  125. </if>
  126. <if test="device.deviceNo!=null">#{device.deviceNo,jdbcType=VARCHAR},
  127. </if>
  128. <if test="device.deviceType!=null">#{device.deviceType,jdbcType=BIGINT},
  129. </if>
  130. <if test="device.sysId!=null">#{device.sysId,jdbcType=BIGINT},
  131. </if>
  132. <if test="device.siteId!=null">#{device.siteId,jdbcType=BIGINT},
  133. </if>
  134. <if test="device.buildingId!=null">#{device.buildingId,jdbcType=BIGINT},
  135. </if>
  136. <if test="device.floorId!=null">#{device.floorId,jdbcType=INTEGER},
  137. </if>
  138. <if test="device.locDesc!=null">#{device.locDesc,jdbcType=VARCHAR},
  139. </if>
  140. <if test="device.relatedDeviceNo!=null">#{device.relatedDeviceNo,jdbcType=BIGINT},
  141. </if>
  142. <if test="device.manufacturerId!=null">#{device.manufacturerId,jdbcType=BIGINT},
  143. </if>
  144. <if test="device.deviceStatus!=null">#{device.deviceStatus,jdbcType=INTEGER},
  145. </if>
  146. <if test="device.status!=null">#{device.status,jdbcType=INTEGER},
  147. </if>
  148. <if test="device.isTag!=null">#{device.isTag,jdbcType=INTEGER},
  149. </if>
  150. <if test="device.xCoordinates!=null">#{device.xCoordinates,jdbcType=DECIMAL},
  151. </if>
  152. <if test="device.yCoordinates!=null">#{device.yCoordinates,jdbcType=DECIMAL},
  153. </if>
  154. <if test="device.createBy!=null">#{device.createBy,jdbcType=VARCHAR},
  155. </if>
  156. <if test="device.updateBy!=null">#{device.updateBy,jdbcType=VARCHAR},
  157. </if>
  158. <if test="device.dateCreate!=null">#{device.dateCreate,jdbcType=TIMESTAMP},
  159. </if>
  160. <if test="device.dateUpdate!=null">#{device.dateUpdate,jdbcType=TIMESTAMP},
  161. </if>
  162. </trim>
  163. </insert>
  164. <!--auto generated Code-->
  165. <insert id="insertList">
  166. INSERT INTO sc_device (
  167. id,
  168. device_no,
  169. device_type,
  170. sys_id,
  171. site_id,
  172. building_id,
  173. floor,
  174. loc_desc,
  175. related_device_no,
  176. manufacturer_id,
  177. device_status,
  178. status,
  179. is_tag,
  180. x_coordinates,
  181. y_coordinates,
  182. create_by,
  183. update_by,
  184. date_create,
  185. date_update
  186. )VALUES
  187. <foreach collection="devices" item="device" index="index" separator=",">
  188. (
  189. #{device.id,jdbcType=BIGINT},
  190. #{device.deviceNo,jdbcType=VARCHAR},
  191. #{device.deviceType,jdbcType=BIGINT},
  192. #{device.sysId,jdbcType=BIGINT},
  193. #{device.siteId,jdbcType=BIGINT},
  194. #{device.buildingId,jdbcType=BIGINT},
  195. #{device.floorId,jdbcType=INTEGER},
  196. #{device.locDesc,jdbcType=VARCHAR},
  197. #{device.relatedDeviceNo,jdbcType=BIGINT},
  198. #{device.manufacturerId,jdbcType=BIGINT},
  199. #{device.deviceStatus,jdbcType=INTEGER},
  200. #{device.status,jdbcType=INTEGER},
  201. #{device.isTag,jdbcType=INTEGER},
  202. #{device.xCoordinates,jdbcType=DECIMAL},
  203. #{device.yCoordinates,jdbcType=DECIMAL},
  204. #{device.createBy,jdbcType=VARCHAR},
  205. #{device.updateBy,jdbcType=VARCHAR},
  206. #{device.dateCreate,jdbcType=TIMESTAMP},
  207. #{device.dateUpdate,jdbcType=TIMESTAMP}
  208. )
  209. </foreach>
  210. </insert>
  211. <!--auto generated Code-->
  212. <update id="updateByPrimaryKeySelective">
  213. UPDATE sc_device
  214. <set>
  215. <if test="device.deviceNo != null"> device_no= #{device.deviceNo,jdbcType=VARCHAR},</if>
  216. <if test="device.deviceType != null"> device_type= #{device.deviceType,jdbcType=BIGINT},</if>
  217. <if test="device.sysId != null"> sys_id= #{device.sysId,jdbcType=BIGINT},</if>
  218. <if test="device.siteId != null"> site_id= #{device.siteId,jdbcType=BIGINT},</if>
  219. <if test="device.buildingId != null"> building_id= #{device.buildingId,jdbcType=BIGINT},</if>
  220. <if test="device.floorId != null"> floor= #{device.floorId,jdbcType=INTEGER},</if>
  221. <if test="device.locDesc != null"> loc_desc= #{device.locDesc,jdbcType=VARCHAR},</if>
  222. <if test="device.relatedDeviceNo != null"> related_device_no= #{device.relatedDeviceNo,jdbcType=BIGINT},</if>
  223. <if test="device.manufacturerId != null"> manufacturer_id= #{device.manufacturerId,jdbcType=BIGINT},</if>
  224. <if test="device.deviceStatus != null"> device_status= #{device.deviceStatus,jdbcType=INTEGER},</if>
  225. <if test="device.status != null"> status= #{device.status,jdbcType=INTEGER},</if>
  226. <if test="device.isTag != null"> is_tag= #{device.isTag,jdbcType=INTEGER},</if>
  227. <if test="device.xCoordinates != null"> x_coordinates= #{device.xCoordinates,jdbcType=DECIMAL},</if>
  228. <if test="device.yCoordinates != null"> y_coordinates= #{device.yCoordinates,jdbcType=DECIMAL},</if>
  229. <if test="device.lastReceiveTime != null"> last_receive_time= #{device.lastReceiveTime,jdbcType=TIMESTAMP}</if>
  230. </set>
  231. WHERE id = #{device.id,jdbcType=BIGINT}
  232. </update>
  233. <select id="findByDeviceNo" resultMap="BaseResultMap">
  234. SELECT
  235. CASE WHEN
  236. ext.id IS NOT NULL THEN
  237. 1 ELSE 0
  238. END AS is_card,
  239. CASE WHEN
  240. c.id IS NOT NULL THEN
  241. 1 ELSE 0
  242. END AS is_lora_meter,
  243. d.id,
  244. d.device_no,
  245. d.device_no,
  246. d.water_meter_no,
  247. d.device_type,
  248. d.sys_id,
  249. d.site_id,
  250. d.building_id,
  251. d.floor,
  252. d.loc_desc,
  253. d.related_device_no,
  254. d.manufacturer_id,
  255. d.device_status,
  256. d.STATUS,
  257. d.is_tag,
  258. d.x_coordinates,
  259. d.y_coordinates,
  260. d.customer_id,
  261. b.community,
  262. IF
  263. ( mt.id IS NOT NULL, 1, 0 ) AS is_water,
  264. dt.device_type AS device_category,
  265. dt.equipment_type AS equipment_type
  266. FROM
  267. sc_device d
  268. LEFT JOIN sc_device_extend_info ext ON ( d.id = ext.device_id AND ext.extend_type_name = 'category' AND ext.extend_value = 'jobCard' AND ext.`status` = '1' )
  269. LEFT JOIN sc_device_type dt ON ( d.device_type = dt.id )
  270. LEFT JOIN sc_building b ON ( d.building_id = b.id )
  271. LEFT JOIN sc_w_meter_type mt ON ( d.device_type = mt.device_type_id)
  272. LEFT JOIN sc_channel_device_type_use tu on ( d.device_type = tu.device_type_id and tu.`status` = 1 )
  273. left join sc_channel c on (tu.channel_id = c.id and c.channel_code = 'lora_meter' and c.`status` = 1)
  274. WHERE
  275. d.STATUS = 1
  276. AND d.device_no = #{deviceNo} limit 1
  277. </select>
  278. <select id="findByMeterNo" resultMap="BaseResultMap">
  279. SELECT
  280. CASE WHEN
  281. ext.id IS NOT NULL THEN
  282. 1 ELSE 0
  283. END AS is_card,
  284. CASE WHEN
  285. c.id IS NOT NULL THEN
  286. 1 ELSE 0
  287. END AS is_lora_meter,
  288. d.id,
  289. d.device_no,
  290. d.device_no,
  291. d.water_meter_no,
  292. d.device_type,
  293. d.sys_id,
  294. d.site_id,
  295. d.building_id,
  296. d.floor,
  297. d.loc_desc,
  298. d.related_device_no,
  299. d.manufacturer_id,
  300. d.device_status,
  301. d.STATUS,
  302. d.is_tag,
  303. d.x_coordinates,
  304. d.y_coordinates,
  305. d.customer_id,
  306. b.community,
  307. IF
  308. ( mt.id IS NOT NULL, 1, 0 ) AS is_water,
  309. dt.device_type AS device_category,
  310. dt.equipment_type AS equipment_type
  311. FROM
  312. sc_device d
  313. LEFT JOIN sc_device_extend_info ext ON ( d.id = ext.device_id AND ext.extend_type_name = 'category' AND ext.extend_value = 'jobCard' AND ext.`status` = '1' )
  314. LEFT JOIN sc_device_type dt ON ( d.device_type = dt.id )
  315. LEFT JOIN sc_building b ON ( d.building_id = b.id )
  316. LEFT JOIN sc_w_meter_type mt ON ( d.device_type = mt.device_type_id)
  317. LEFT JOIN sc_channel_device_type_use tu on ( d.device_type = tu.device_type_id and tu.`status` = 1 )
  318. left join sc_channel c on (tu.channel_id = c.id and c.channel_code = 'lora_meter' and c.`status` = 1)
  319. WHERE
  320. d.STATUS = 1
  321. AND d.water_meter_no = #{meterNo,jdbcType=VARCHAR} limit 1
  322. </select>
  323. <update id="updateDeviceErrorDays">
  324. update sc_water_meter_error_days set days = #{days} , last_error_type = null where device_id = #{deviceId}
  325. </update>
  326. </mapper>