123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.huaxu.dao.RevenueMapper">
- <!--查询本月售水信息-->
- <select id="selectMonthSell" resultType="com.huaxu.dto.MonthSellwaterDto">
- select t2.property_name ,sum(t1.water_usage) water_usage
- from sms_month_sellwater t1
- inner join sms_water_property t2 on t1.property_id=t2.id
- where t1.collect_date>=date_format(curdate(), '%Y-%m' )
- <if test="tenantId != null and tenantId != ''">
- and t1.tenant_id=#{tenantId}
- </if>
- <if test="companyOrgId != null and companyOrgId !=''">
- and t1.company_org_id=#{companyOrgId}
- </if>
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2 or permissonType == 1">
- and t1.company_org_id in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- </if>
- group by t2.property_name
- order by water_usage desc
- </select>
- <!--查询近6个月的售水量-->
- <select id="selectMonthSellTotal" resultType="com.huaxu.dto.MonthSellwaterDto">
- select date_format(t1.collect_date, '%Y-%m' ) collect_date_string,sum(t1.water_usage) water_usage
- from sms_month_sellwater t1
- where t1.collect_date>=date_sub(date_format(curdate(), '%Y-%m-1' ), interval 5 month)
- <if test="tenantId != null and tenantId != ''">
- and t1.tenant_id=#{tenantId}
- </if>
- <if test="companyOrgId != null and companyOrgId !=''">
- and t1.company_org_id=#{companyOrgId}
- </if>
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2 or permissonType == 1">
- and t1.company_org_id in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- </if>
- group by collect_date_string
- order by collect_date_string
- </select>
- <!--查询月营收情况-->
- <select id="selectMonthRevenue" resultType="com.huaxu.dto.MonthRevenueDto">
- select date_format(t1.collect_date, '%Y-%m' ) collect_date_string,
- sum(receivable_total_amount) receivable_total_amount,sum(received_total_amount) received_total_amount,
- sum(general_user_usage) general_user_usage,sum(big_user_usage) big_user_usage,
- if(sum(receivable_total_amount)=0,null,sum(received_total_amount)/sum(receivable_total_amount)*100) water_fee_recovery_rate,
- if(sum(receivable_total_amount)=0,null,sum(general_user_usage)/sum(receivable_total_amount)*100) general_user_percent,
- if(sum(receivable_total_amount)=0,null,sum(big_user_usage)/sum(receivable_total_amount)*100) big_user_percent
- from sms_month_revenue t1
- where t1.collect_date>=date_sub(date_format(curdate(), '%y-%m-1' ), interval #{months}-1 month)
- <if test="tenantId != null and tenantId != ''">
- and t1.tenant_id=#{tenantId}
- </if>
- <if test="companyOrgId != null and companyOrgId !=''">
- and t1.company_org_id=#{companyOrgId}
- </if>
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2 or permissonType == 1">
- and t1.company_org_id in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- </if>
- group by collect_date_string
- order by collect_date_string
- </select>
- <!--查询本月各分公司的营收情况-->
- <select id="selectCompanyRevenue" resultType="com.huaxu.dto.MonthRevenueDto">
- select company_org_id,sum(receivable_total_amount) receivable_total_amount,sum(received_total_amount) received_total_amount,
- if(sum(receivable_total_amount)=0,null,sum(received_total_amount)/sum(receivable_total_amount)*100) water_fee_recovery_rate
- from sms_month_revenue t1
- where t1.collect_date>=date_format(curdate(), '%y-%m-1' )
- <if test="tenantId != null and tenantId != ''">
- and t1.tenant_id=#{tenantId}
- </if>
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2 or permissonType == 1">
- and t1.company_org_id in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- </if>
- group by company_org_id
- order by company_org_id
- </select>
- </mapper>
|