java110
2023-07-11 212aa4ae1f54fe4d3e51b9695224f9f86cd1bd22
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
@@ -2761,117 +2761,70 @@
    <select id="queryHuaningOweFeeCount" parameterType="Map" resultType="Map">
        select count(1) count
        from (
        select a.floorNum,a.oweAmount,b.curOweAmount
        from
        (select t.floor_num floorNum,SUM(rfms.owe_amount) oweAmount
        from f_floor t
        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        LEFT JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.obj_type = '3333' and
        rfms.status_cd = '0'
        where t.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="objName !=null and objName != ''">
            and rfms.obj_name= #{objName}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and rfms.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and rfms.fee_month= #{feeMonth}
        </if>
        GROUP BY t.floor_num
        ) a,
        (select t.floor_num floorNum,SUM(curT.owe_amount) curOweAmount
        from f_floor t
        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner join report_fee_month_statistics curT on curT.obj_id = br.room_id and curT.obj_type = '3333' and
        curT.status_cd = '0' and curT.community_id = t.community_id
        where t.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and curT.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and curT.fee_month= #{feeMonth}
        </if>
        GROUP BY t.floor_num
        ) b
        where a.floorNum = b.floorNum
        <if test="floorId !=null and floorId != ''">
            and a.floor_id = #{floorId}
        </if>
        ) t
        from f_floor f
        where 1=1
        and f.community_id = #{communityId}
        and f.status_cd = '0'
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryHuaningOweFee" parameterType="Map" resultType="Map">
        select a.floorNum,a.oweAmount,b.curOweAmount
        from
        (select t.floor_num floorNum,SUM(rfms.owe_amount) oweAmount
        from f_floor t
        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        LEFT JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.obj_type = '3333' and
        rfms.status_cd = '0'
        where t.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        select
        f.floor_num floorNum,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{endTime}
        ) oweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="objName !=null and objName != ''">
            and rfms.obj_name= #{objName}
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{endTime}
        and t.cur_month_time &gt;= #{startTime}
        ) curOweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and rfms.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and rfms.fee_month= #{feeMonth}
        </if>
        GROUP BY t.floor_num
        ) a,
        (select t.floor_num floorNum,SUM(curT.owe_amount) curOweAmount
        from f_floor t
        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner join report_fee_month_statistics curT on curT.obj_id = br.room_id and curT.obj_type = '3333' and
        curT.status_cd = '0' and curT.community_id = t.community_id
        where t.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and curT.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and curT.fee_month= #{feeMonth}
        </if>
        GROUP BY t.floor_num
        ) b
        where a.floorNum = b.floorNum
        <if test="floorId !=null and floorId != ''">
            and a.floor_id = #{floorId}
        </if>
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
        and t.detail_id = '-1'
        and t.cur_month_time &lt; #{startTime}
        ) preOweAmount
        from f_floor f
        where 1=1
        and f.community_id = #{communityId}
        and f.status_cd = '0'
    </select>
@@ -2888,95 +2841,118 @@
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryHuaningPayFee" parameterType="Map" resultType="Map">
        select
        a.floorNum,f.receivableAmount,a.receivedAmount,b.receivedAmount1,c.receivedAmount2,d.receivedAmount3,e.receivedAmount4
        from
        (select t.floor_num floorNum,sum(pfd.received_amount) receivedAmount
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) a,
        (select t.floor_num floorNum,sum(pfdm1.received_amount ) receivedAmount1
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        LEFT JOIN pay_fee_detail_month pfdm1 on pf.fee_id = pfdm1.fee_id and pfd.detail_id = pfdm1.detail_id and
        pfdm1.status_cd = '0' and pfdm1.detail_year = #{year} and pfdm1.detail_month &lt; #{month}
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) b,
        (select t.floor_num floorNum,sum(pfdm2.received_amount ) receivedAmount2
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        LEFT JOIN pay_fee_detail_month pfdm2 on pf.fee_id = pfdm2.fee_id and pfd.detail_id = pfdm2.detail_id and
        pfdm2.status_cd = '0' and pfdm2.detail_year = #{year} and pfdm2.detail_month = #{month}
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) c,
        (select t.floor_num floorNum,sum(pfdm3.received_amount ) receivedAmount3
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        LEFT JOIN pay_fee_detail_month pfdm3 on pf.fee_id = pfdm3.fee_id and pfd.detail_id = pfdm3.detail_id and
        pfdm3.status_cd = '0' and pfdm3.detail_year = #{nextYear} and pfdm3.detail_month = #{nextMonth}
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) d,
        (select t.floor_num floorNum,sum(pfdm4.received_amount ) receivedAmount4
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        LEFT JOIN pay_fee_detail_month pfdm4 on pf.fee_id = pfdm4.fee_id and pfd.detail_id = pfdm4.detail_id and
        pfdm4.status_cd = '0' and pfdm4.detail_year &lt; #{year}
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) e,
        (select t.floor_num floorNum,SUM(rfms.receivable_amount) receivableAmount
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.status_cd = '0'
        where t.community_id = #{communityId}
        and rfms.fee_year = #{year}
        and rfms.fee_month = #{month}
        group by t.floor_num
        ) f
        where a.floorNum = b.floorNum
        and b.floorNum = c.floorNum
        and c.floorNum = d.floorNum
        and d.floorNum = e.floorNum
        and e.floorNum = f.floorNum
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        f.floor_num floorNum,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.cur_month_time = #{endTime}
        ) receivableAmount,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.detail_id != '-1'
        ) receivedAmount,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &lt; #{endTime}
        and t.cur_month_time &gt;= #{startTime}
        and t.detail_id != '-1'
        ) receivedAmount1,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time = #{endTime}
        and t.detail_id != '-1'
        ) receivedAmount2,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &gt;= #{nextMonthTime}
        and t.detail_id != '-1'
        ) receivedAmount3,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where
        1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &lt; #{startTime}
        and t.detail_id != '-1'
        ) receivedAmount4
        from f_floor f
        where 1=1
        and f.community_id = #{communityId}
        and f.status_cd = '0'
    </select>
    <select id="queryHuaningPayFeeTwoCount" parameterType="Map" resultType="Map">
        select count(1) count
@@ -3101,32 +3077,79 @@
        </if>
    </select>
    <select id="queryHuaningOweFeeDetailCount" parameterType="Map" resultType="Map">
        select count(1) count
        from (
        select t.payer_obj_name payerObjName,br.built_up_area builtUpArea,pfc.square_price squarePrice, t.fee_id
        feeId,t.end_time startTime,t.deadline_time endTime,t.amount_owed oweAmount
        from report_owe_fee t
        left join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
        left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        where t.amount_owed > 0
        and pfc.fee_type_cd = '888800010001'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        select
        count(1) count
        from building_room br
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
        inner join pay_fee pf on rof.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and br.community_id = #{communityId}
        and br.status_cd = '0'
        and rof.amount_owed > 0
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        ) tt
        <if test="floorId != null and floorId != ''">
            and f.floor_id = #{floorId}
        </if>
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryHuaningOweFeeDetail" parameterType="Map" resultType="Map">
        select t.payer_obj_name payerObjName,br.built_up_area builtUpArea,pfc.square_price squarePrice, t.fee_id
        feeId,t.end_time startTime,t.deadline_time endTime,t.amount_owed oweAmount
        from report_owe_fee t
        left join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
        left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        where t.amount_owed > 0
        and pfc.fee_type_cd = '888800010001'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        select
        concat(f.floor_num,'-',bu.unit_num,'-',br.room_num) roomName,
        br.built_up_area builtUpArea,
        rof.fee_name feeName,
        rof.end_time endTime,
        rof.deadline_time deadlineTime,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        where
        1=1
        and t.fee_id = rof.fee_id
        and t.community_id = f.community_id
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{startTime}
        ) oweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        where
        1=1
        and t.fee_id = rof.fee_id
        and t.community_id = f.community_id
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{startTime}
        and t.cur_month_time &gt;= #{endTime}
        ) curOweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        where
        1=1
        and t.fee_id = rof.fee_id
        and t.community_id = f.community_id
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{startTime}
        ) preOweAmount
        from building_room br
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
        inner join pay_fee pf on rof.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and br.community_id = #{communityId}
        and br.status_cd = '0'
        and rof.amount_owed > 0
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="floorId != null and floorId != ''">
            and f.floor_id = #{floorId}
        </if>
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}