<?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.applet.mapper.InkStatisticsMapper">

    <select id="selectInkStatistics" resultType="java.util.Map">
        SELECT sh.`Name`                  houseName,
               Count(1)                   count,
               sum(sd.Quantity)           quantity,
               sum(sd.Quantity * m.Price) amount
        FROM stock_detail sd
                 LEFT JOIN material m ON sd.MaterialCode = m.`Code`
                 LEFT JOIN stock_house sh ON sd.StockHouseId = sh.ID
        WHERE m.TechnologyType = '3'
        GROUP BY sh.`Name`
    </select>

    <select id="selectInkW" resultType="java.util.Map">
        SELECT sh.`Name`                              houseName,
               count(1)                               count,
               sum(swd.ChangeNum)                     changeNum,
               round(sum(swd.ChangeNum * m.Price), 2) amount
        FROM stock_waterdetial swd
                 LEFT JOIN stock_water sw ON swd.WaterId = sw.ID
                 LEFT JOIN stock_house sh ON sw.StockHouseId = sh.ID
                 LEFT JOIN material m ON swd.MaterialCode = m.`Code`
            ${ew.customSqlSegment}
    </select>

    <select id="selectInkEWDetails" resultType="java.util.Map">
        SELECT u.RealName                             nickName,
               Count(1)                               count,
               sum(swd.ChangeNum)                     changeNum,
               round(sum(swd.ChangeNum * m.Price), 2) amount
        FROM stock_waterdetial swd
                 LEFT JOIN material m ON swd.MaterialCode = m.`Code`
                 LEFT JOIN u_user u ON swd.OperUserId = u.ID
            ${ew.customSqlSegment}
    </select>

</mapper>
