<?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="org.jeecg.modules.fbsInventory.mapper.FbsInventoryMapper">
    <select id="getInventoryGetByOrderId" resultType="org.jeecg.modules.fbsInventory.entity.FbsInventory" >
        SELECT
        i.cInvCode as cinvcode,i.cInvName as cinvname,m.CostItemName
        FROM
        mom_orderdetail m
        LEFT JOIN Inventory i ON m.InvCode = i.cInvCode
        WHERE
        m.MoId = #{moId}
    </select>

    <select id="getStockList" resultType="java.util.HashMap">

        select top 20 a.iQuantity realStockSum,b.iSafeNum safeStockSum ,b.cInvCode materialCode,b.cInvName materialName,cInvStd specs from

        (select cInvCode,sum(iQuantity) as iQuantity  from CurrentStock group by cInvCode) a

        left join Inventory b on a.cInvCode = b.cInvCode
        where b.iSafeNum is not null

    </select>

    <select id="getAllStockList" resultType="java.util.HashMap">

        select top 5 a.iQuantity realStockSum,b.cInvName materialName from
        (select cInvCode,sum(iQuantity) as iQuantity  from CurrentStock group by cInvCode) a
        left join Inventory b on a.cInvCode = b.cInvCode

    </select>
</mapper>