|
@@ -631,9 +631,9 @@
|
|
|
select
|
|
|
c.account_id as "accountId"
|
|
|
,c.valve_rule_id as "valveRuleIds"
|
|
|
- ,r.debt
|
|
|
- ,rh.remaining
|
|
|
- ,rh.balance
|
|
|
+ ,ifnull(r.debt,0) as "debt"
|
|
|
+ ,ifnull(rh.remaining,0) as "remaining"
|
|
|
+ ,ifnull(rh.balance,0) as "balance"
|
|
|
,TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) as "days"
|
|
|
,d.id as "meterId"
|
|
|
,d.control_status as "valveState"
|
|
@@ -654,20 +654,26 @@
|
|
|
where c.businessstate =1 and d.control_status = 1 and c.site_id= #{siteId} and c.customer_id = #{customerId}
|
|
|
<if test="payControlRules != null and payControlRules.size() != 0">
|
|
|
<foreach collection="payControlRules" item="rule" open=" and ( " separator=" or " close=" ) ">
|
|
|
- ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
|
|
|
<if test="rule.conditionId != null and rule.conditionId == 1">
|
|
|
- and TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) ${rule.operatorString} #{rule.value}
|
|
|
+ ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
|
|
|
+ and TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) ${rule.operatorString} #{rule.value})
|
|
|
</if>
|
|
|
<if test="rule.conditionId != null and rule.conditionId == 2">
|
|
|
- and r.debt ${rule.operatorString} #{rule.value}
|
|
|
+ ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
|
|
|
+ and r.debt ${rule.operatorString} #{rule.value})
|
|
|
</if>
|
|
|
<if test="rule.conditionId != null and rule.conditionId == 3">
|
|
|
- and rh.remaining ${rule.operatorString} #{rule.value}
|
|
|
+ ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
|
|
|
+ and rh.remaining ${rule.operatorString} #{rule.value})
|
|
|
</if>
|
|
|
<if test="rule.conditionId != null and rule.conditionId == 4">
|
|
|
- and rh.balance ${rule.operatorString} #{rule.value}
|
|
|
+ ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
|
|
|
+ and rh.balance ${rule.operatorString} #{rule.value})
|
|
|
+ </if>
|
|
|
+ <if test="rule.conditionId != null and rule.conditionId == 7">
|
|
|
+ ( concat(',',c.valve_rule_id,',') like concat('%,',${rule.id},',%')
|
|
|
+ and ifnull(rh.remaining,0) -ifnull(r.debt,0) ${rule.operatorString} #{rule.value})
|
|
|
</if>
|
|
|
- )
|
|
|
</foreach>
|
|
|
</if>
|
|
|
|