DeviceMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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.bz.smart_city.dao.DeviceMapper">
  4. <update id="deleteBySiteId">
  5. update sc_device set status = 0,date_update = NOW(),update_by=#{updateBy}
  6. where status = 1 and site_id = #{siteId}
  7. </update>
  8. <update id="deleteBySysId">
  9. update sc_device set status = 0,date_update = NOW(),update_by=#{updateBy}
  10. where status = 1 and sys_id = #{sysId}
  11. </update>
  12. <insert id="insertList">
  13. INSERT INTO sc_device(
  14. id,
  15. device_no,
  16. device_type,
  17. sys_id,
  18. site_id,
  19. building_id,
  20. `floor`,
  21. loc_desc,
  22. related_device_no,
  23. manufacturer_id,
  24. device_status,
  25. `status`,
  26. is_tag,
  27. x_coordinates,
  28. y_coordinates,
  29. create_by,
  30. update_by,
  31. date_create,
  32. date_update,
  33. plan_id,
  34. water_meter_no,
  35. water_meter_file_no,
  36. customer_id,
  37. udip_id,
  38. metercode,
  39. account_id,
  40. curr_status,
  41. new_meter_start,
  42. device_model
  43. )VALUES
  44. <foreach collection="devices" item="device" index="index" separator=",">
  45. (
  46. #{device.id,jdbcType=BIGINT},
  47. #{device.deviceNo,jdbcType=VARCHAR},
  48. #{device.deviceType,jdbcType=BIGINT},
  49. #{device.sysId,jdbcType=BIGINT},
  50. #{device.siteId,jdbcType=BIGINT},
  51. #{device.buildingId,jdbcType=BIGINT},
  52. #{device.floor,jdbcType=INTEGER},
  53. #{device.locDesc,jdbcType=VARCHAR},
  54. #{device.relatedDeviceNo,jdbcType=BIGINT},
  55. #{device.manufacturerId,jdbcType=BIGINT},
  56. #{device.deviceStatus,jdbcType=INTEGER},
  57. #{device.status,jdbcType=INTEGER},
  58. #{device.isTag,jdbcType=INTEGER},
  59. #{device.xCoordinates,jdbcType=DECIMAL},
  60. #{device.yCoordinates,jdbcType=DECIMAL},
  61. #{device.createBy,jdbcType=VARCHAR},
  62. #{device.updateBy,jdbcType=VARCHAR},
  63. #{device.dateCreate,jdbcType=TIMESTAMP},
  64. #{device.dateUpdate,jdbcType=TIMESTAMP},
  65. #{device.planId,jdbcType=INTEGER},
  66. #{device.waterMeterNo,jdbcType=VARCHAR},
  67. #{device.waterMeterFileNo,jdbcType=VARCHAR},
  68. #{device.customerId,jdbcType=INTEGER},
  69. #{device.udipId,jdbcType=VARCHAR},
  70. #{device.metercode,jdbcType=VARCHAR},
  71. #{device.accountId,jdbcType=BIGINT},
  72. #{device.currStatus,jdbcType=INTEGER},
  73. #{device.newMeterStart,jdbcType=VARCHAR},
  74. #{device.deviceModel,jdbcType=VARCHAR}
  75. )
  76. </foreach>
  77. </insert>
  78. <update id="updateSync">
  79. update sc_device
  80. <set>
  81. <if test="devices.deviceNo != null "> device_no = #{devices.deviceNo,jdbcType=VARCHAR},</if>
  82. <if test="devices.deviceType != null"> device_model = #{devices.deviceType,jdbcType=INTEGER},</if>
  83. <if test="devices.locDesc != null">loc_desc = #{devices.locDesc,jdbcType=VARCHAR},</if>
  84. <if test="devices.waterMeterNo != null">water_meter_no = #{devices.waterMeterNo,jdbcType=VARCHAR},</if>
  85. <if test="devices.dateCreate != null and devices.dateCreate != ''">date_create = #{devices.dateCreate,jdbcType=VARCHAR},</if>
  86. <if test="devices.dateUpdate != null and devices.dateUpdate != ''">date_update = #{devices.dateUpdate,jdbcType=VARCHAR},</if>
  87. <if test="devices.status != null">status = #{devices.status,jdbcType=INTEGER},</if>
  88. <if test="devices.currStatus != null">curr_status = #{devices.currStatus,jdbcType=INTEGER},</if>
  89. <if test="devices.initialData != null">new_meter_start = #{devices.initialData,jdbcType=DECIMAL}</if>
  90. </set>
  91. where metercode = #{devices.fileNo,jdbcType=VARCHAR}
  92. </update>
  93. <update id="updateMeterCode">
  94. update sc_device
  95. set metercode=#{newMeterCode}
  96. where metercode = #{newMeterCode}
  97. <if test="customerId != null and customerId != ''"> and customer_id=#{customerId}</if>
  98. </update>
  99. <select id="getNoSyncList" resultType="com.bz.smart_city.entity.Device">
  100. select
  101. id,
  102. device_no,
  103. device_type,
  104. sys_id,
  105. site_id,
  106. building_id,
  107. `floor`,
  108. loc_desc,
  109. related_device_no,
  110. manufacturer_id,
  111. device_status,
  112. `status`,
  113. is_tag,
  114. x_coordinates,
  115. y_coordinates,
  116. create_by,
  117. update_by,
  118. date_create,
  119. date_update,
  120. plan_id,
  121. water_meter_no,
  122. water_meter_file_no,
  123. customer_id,
  124. udip_id,
  125. curr_status,
  126. new_meter_start,
  127. device_model,
  128. metercode
  129. from sc_device where curr_status = 0 and metercode is not null
  130. <if test="siteId != null"> and site_id = #{siteId,jdbcType=INTEGER}</if>
  131. <if test="customerId != null"> and customer_id = #{customerId,jdbcType=INTEGER}</if>
  132. </select>
  133. </mapper>