update 优化统计充电桩总数/直流数量/交流数量查询方法

This commit is contained in:
jsowell
2026-08-04 16:50:56 +08:00
parent 80d1d027a1
commit d46f11a352
10 changed files with 68 additions and 138 deletions

View File

@@ -534,28 +534,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by t1.trade_date
</select>
<select id="countTotalPilesByStationIds" resultType="java.lang.Long">
select count(distinct t1.sn)
from pile_basic_info t1
where t1.del_flag = '0'
<if test="stationIdList != null and stationIdList.size() > 0">
and t1.station_id in
<foreach collection="stationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<select id="countTotalPilesByMerchantIds" resultType="java.lang.Long">
select count(distinct t1.sn)
<!-- 充电桩数量统计:总数/直流/交流同源,保证 直流 + 交流 = 总数 -->
<select id="countPilesStat" resultType="com.jsowell.pile.vo.web.PileCountStatVO">
select
count(*) as totalPiles,
coalesce(sum(case when t2.speed_type = '1' then 1 else 0 end), 0) as dcPileCount,
coalesce(sum(case when t2.speed_type = '2' then 1 else 0 end), 0) as acPileCount
from pile_basic_info t1
join pile_model_info t2 on t2.id = t1.model_id and t2.del_flag = '0'
where t1.del_flag = '0'
and t2.speed_type in ('1', '2')
<if test="merchantIdList != null and merchantIdList.size() > 0">
and t1.merchant_id in
<foreach collection="merchantIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="stationIdList != null and stationIdList.size() > 0">
and t1.station_id in
<foreach collection="stationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<!-- 按merchantId分组汇总settle_order_report每个商户一行Java再汇总 -->

View File

@@ -394,45 +394,4 @@
</if>
</select>
<select id="countDcPiles" resultType="java.lang.Long">
select count(distinct t1.pile_sn)
from pile_connector_info t1
join pile_basic_info t2 on t2.sn = t1.pile_sn and t2.del_flag = '0'
join pile_model_info t3 on t3.id = t2.model_id and t3.del_flag = '0'
where t1.del_flag = '0'
and t3.speed_type = '1'
<if test="merchantIdList != null and merchantIdList.size() > 0">
and t2.merchant_id in
<foreach collection="merchantIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="stationIdList != null and stationIdList.size() > 0">
and t2.station_id in
<foreach collection="stationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<select id="countAcPiles" resultType="java.lang.Long">
select count(distinct t1.pile_sn)
from pile_connector_info t1
join pile_basic_info t2 on t2.sn = t1.pile_sn and t2.del_flag = '0'
join pile_model_info t3 on t3.id = t2.model_id and t3.del_flag = '0'
where t1.del_flag = '0'
and t3.speed_type = '2'
<if test="merchantIdList != null and merchantIdList.size() > 0">
and t2.merchant_id in
<foreach collection="merchantIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="stationIdList != null and stationIdList.size() > 0">
and t2.station_id in
<foreach collection="stationIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>