<?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.fjhx.mapper.water.WaterBackMapper">

    <select id="getStatistics" resultType="java.util.LinkedHashMap">
        select count(0)                                                count,
               ifnull(sum(wbd.quantity), 0)                            quantity,
               ifnull(format(sum(wbd.quantity * m.width / 100), 2), 0) area,
               ifnull(format(sum(wbd.quantity * m.price), 2), 0)       price
        from water_back_details wbd
                 left join material m on wbd.material_id = m.id
            ${ew.customSqlSegment}
    </select>

    <select id="getPage" resultType="java.util.Map">
        select wbd.rfid,
               wbd.create_user,
               wbd.create_time,
               m.name                                             materialName,
               wbd.quantity,
               ifnull(format(wbd.quantity * m.width / 100, 2), 0) area
        from water_back_details wbd
                 left join material m on wbd.material_id = m.id
            ${ew.customSqlSegment}
    </select>

</mapper>
