PayControlRuleMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.pay.PayControlRuleMapper">
  4. <insert id="add" useGeneratedKeys="true" keyColumn="id">
  5. insert into
  6. pay_control_rule(
  7. name,
  8. `condition`,
  9. condition_id,
  10. operator,
  11. value,
  12. action,
  13. unit,
  14. disable,
  15. create_by,
  16. create_date,
  17. update_by,
  18. update_date,
  19. remarks,
  20. del_flag,
  21. site_id,
  22. customer_id
  23. )
  24. values (
  25. #{payControlRule.name,jdbcType=VARCHAR},
  26. #{payControlRule.condition,jdbcType=VARCHAR},
  27. #{payControlRule.conditionId,jdbcType=INTEGER},
  28. #{payControlRule.operator,jdbcType=VARCHAR},
  29. #{payControlRule.value,jdbcType=VARCHAR},
  30. #{payControlRule.action,jdbcType=VARCHAR},
  31. #{payControlRule.unit,jdbcType=VARCHAR},
  32. #{payControlRule.disable,jdbcType=VARCHAR},
  33. #{payControlRule.createBy,jdbcType=BIGINT},
  34. #{payControlRule.createDate,jdbcType=TIMESTAMP},
  35. #{payControlRule.updateBy,jdbcType=BIGINT},
  36. #{payControlRule.updateDate,jdbcType=TIMESTAMP},
  37. #{payControlRule.remarks,jdbcType=VARCHAR},
  38. #{payControlRule.delFlag,jdbcType=VARCHAR},
  39. #{payControlRule.siteId,jdbcType=BIGINT},
  40. #{payControlRule.customerId,jdbcType=BIGINT}
  41. )
  42. </insert>
  43. <select id="findList" resultType="com.bz.smart_city.entity.pay.PayControlRule">
  44. select
  45. id,
  46. name,
  47. `condition`,
  48. condition_id,
  49. operator,
  50. value,
  51. action,
  52. unit,
  53. disable,
  54. create_by,
  55. create_date,
  56. update_by,
  57. update_date,
  58. remarks,
  59. del_flag,
  60. site_id,
  61. customer_id
  62. from pay_control_rule
  63. <where>
  64. del_flag = 0
  65. <if test="customerId != null"> and customer_id = #{customerId} </if>
  66. <if test="id != null"> and id = #{id}</if>
  67. <if test="name != null and name != ''"> and name LIKE concat('%',#{name},'%')</if>
  68. </where>
  69. order by update_date desc
  70. </select>
  71. <select id="ExitsData" resultType="com.bz.smart_city.entity.pay.PayControlRule">
  72. select
  73. id,
  74. name,
  75. `condition`,
  76. operator,
  77. value,
  78. action,
  79. unit,
  80. disable,
  81. create_by,
  82. create_date,
  83. update_by,
  84. update_date,
  85. remarks,
  86. del_flag,
  87. site_id,
  88. customer_id
  89. from pay_control_rule
  90. <where>
  91. del_flag = 0 and customer_id = #{customerId}
  92. and name = #{name}
  93. <if test="id != null"> and id <![CDATA[ <> ]]> #{id,jdbcType=BIGINT}</if>
  94. </where>
  95. </select>
  96. <select id="isUsed" resultType="string">
  97. select valve_rule_id
  98. from pay_base_customerandmeterrela
  99. WHERE valve_rule_id like concat('%',#{id},'%')
  100. <if test="customerId != null and customerId != ''"> and customer_id = #{customerId}</if>
  101. limit 1
  102. </select>
  103. <delete id="delete">
  104. update pay_control_rule set del_flag = 1 where id = #{id,jdbcType=INTEGER}
  105. </delete>
  106. <update id="edit">
  107. update pay_control_rule pcr
  108. <set>
  109. <if test="payControlRule.name != null and payControlRule.name != ''"> pcr.name = #{payControlRule.name},</if>
  110. <if test="payControlRule.condition != null and payControlRule.condition != ''"> pcr.condition = #{payControlRule.condition},</if>
  111. <if test="payControlRule.conditionId "> pcr.condition_id = #{payControlRule.conditionId},</if>
  112. <if test="payControlRule.value != null and payControlRule.value != ''"> pcr.value = #{payControlRule.value},</if>
  113. <if test="payControlRule.operator != null "> pcr.operator = #{payControlRule.operator},</if>
  114. <if test="payControlRule.action != null "> pcr.action = #{payControlRule.action},</if>
  115. <if test="payControlRule.unit != null"> pcr.unit = #{payControlRule.unit},</if>
  116. <if test="payControlRule.disable != null"> pcr.disable = #{payControlRule.disable},</if>
  117. <if test="payControlRule.updateBy != null"> pcr.update_by = #{payControlRule.updateBy},</if>
  118. <if test="payControlRule.updateDate != null"> pcr.update_date = #{payControlRule.updateDate},</if>
  119. <if test="payControlRule.remarks != null and payControlRule.remarks != ''"> pcr.remarks = #{payControlRule.remarks},</if>
  120. <if test="payControlRule.delFlag != null"> pcr.del_flag = #{payControlRule.delFlag}</if>
  121. </set>
  122. where id = #{payControlRule.id}
  123. </update>
  124. <select id="findDebtMoney" resultType="Decimal">
  125. select
  126. sum( CASE WHEN rece.debt IS NULL THEN 0 ELSE rece.debt END ) sumDebt
  127. from pay_pay_receivable rece
  128. where rece.debt > 0 and rece.account_id = #{accountId}
  129. </select>
  130. <select id="findDebtDay" resultType="integer">
  131. select
  132. to_days(now()) - to_days(create_date) days
  133. from pay_pay_receivable rece
  134. where rece.debt > 0 and rece.account_id = #{accountId}
  135. </select>
  136. <select id="findUseMoeny" resultType="decimal">
  137. select
  138. (
  139. SELECT remaining remaining from pay_pay_rechargeaccount
  140. where account_id=#{accountId})
  141. -
  142. (select IFNULL(SUM(debt),0) debt from pay_pay_receivable where
  143. account_id=#{accountId} and debt > 0 )
  144. as remaining
  145. </select>
  146. <select id="findOpenUse" resultType="integer">
  147. select
  148. scd.curr_status state
  149. from sc_device scd
  150. where scd.account_id = #{accountId}
  151. </select>
  152. <select id="findDevice" resultType="com.bz.smart_city.entity.Device">
  153. select control_status
  154. from sc_device
  155. where id = #{watermeterId}
  156. </select>
  157. </mapper>