<?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.huimv.getdata.mapper.ErpKuCunMapper">


    <select id="getYuanCaiLiaoCunLiang" resultType="com.huimv.getdata.entity.kucun.YuanCaiLiaoKuCun"
            parameterType="java.util.Date">
        SELECT DISTINCT  A.FSTOCKORGID ,A.FUPDATETIME , A.FBASEQTY , B.FNAME  ,C.FMATERIALID ,C.FNAME wuLiaoName ,D.FNUMBER  FROM T_STK_INVENTORY A
        INNER JOIN t_BD_Stock_L	B  ON B.FSTOCKID = A.FSTOCKID
        INNER JOIN T_BD_MATERIAL D ON D.FMATERIALID= A.FMATERIALID
        INNER JOIN T_BD_MATERIAL_L C ON C.FMATERIALID = A.FMATERIALID
        <if test="date !=null">
            where  A.FUPDATETIME >= #{date}
        </if>
ORDER BY FBASEQTY DESC

    </select>
    <select id="getYangMaoZhiKuCun" resultType="com.huimv.getdata.entity.kucun.YangMaoZhiChuKu"
            parameterType="java.util.Date">
        SELECT DISTINCT   A.FBASEQTY , A.FSTOCKORGID ,A.FUPDATETIME ,  B.FNAME wuLiaoName ,C.FMATERIALID ,C.FNAME ,D.FNUMBER  FROM T_STK_INVENTORY A
INNER JOIN t_BD_Stock_L	B  ON B.FSTOCKID = A.FSTOCKID
INNER JOIN T_BD_MATERIAL_L C ON C.FMATERIALID = A.FMATERIALID
INNER JOIN T_BD_MATERIAL  D ON D.FMATERIALID = A.FMATERIALID
WHERE FNUMBER = '10020002'
        <if test="date !=null">
            and  A.FUPDATETIME >= #{date}
        </if>

    </select>
    <select id="getYuanCaiLiaoDangRi" resultType="com.huimv.getdata.entity.kucun.YuanCaiLiaoDangRiRuKu"
            parameterType="java.util.Date">
(SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME  wuLiaoName,C.FNUMBER ,E.FNAME
FROM T_STK_INSTOCK A
INNER JOIN T_STK_INSTOCKENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME ='原料库' 	AND C.FNUMBER != '10020002'
        <if test="date !=null">
            and  A.FUPDATETIME >= #{date}
        </if>)
 UNION ALL(
 SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME ,C.FNUMBER  ,E.FNAME
FROM T_PRD_INSTOCK A
INNER JOIN T_PRD_INSTOCKENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE  C.FNUMBER != '10020002' AND E.FNAME ='原料库'
        <if test="date !=null">
            and  A.FUPDATETIME >= #{date}
        </if>)
 UNION ALL (
SELECT DISTINCT B.FQTY  FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME ,C.FNUMBER  ,E.FNAME
FROM T_STK_MISCELLANEOUS A
INNER JOIN T_STK_MISCELLANEOUSENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE  C.FNUMBER != '10020002' AND E.FNAME ='原料库'  <if test="date !=null">
        and  A.FUPDATETIME >= #{date}
    </if>)

    </select>



    <select id="getChengPinDangRi" resultType="com.huimv.getdata.entity.kucun.ChengPinRuKu"
            parameterType="java.util.Date">

SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_STK_INSTOCK A
INNER JOIN T_STK_INSTOCKENTRY B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME IN ('成品库','成品库CW')
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
 SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_PRD_INSTOCK A
INNER JOIN T_PRD_INSTOCKENTRY  B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME IN ('成品库','成品库CW')
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
  SELECT DISTINCT B.FQTY FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_STK_MISCELLANEOUS  A
INNER JOIN T_STK_MISCELLANEOUSENTRY  B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME IN ('成品库','成品库CW')
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
    </select>
    <select id="getYangMaoZhiDangRi" resultType="com.huimv.getdata.entity.kucun.ChengPinRuKu"
            parameterType="java.util.Date">
SELECT DISTINCT  B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME ,C.FNUMBER fnumber
FROM T_STK_INSTOCK A
INNER JOIN T_STK_INSTOCKENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 WHERE C.FNUMBER = '10020002'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
UNION ALL
SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME ,C.FNUMBER fnumber
FROM T_PRD_INSTOCK A
INNER JOIN T_PRD_INSTOCKENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 WHERE  C.FNUMBER = '10020002'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
SELECT DISTINCT B.FQTY  FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME ,C.FNUMBER fnumber
FROM T_STK_MISCELLANEOUS A
INNER JOIN T_STK_MISCELLANEOUSENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 WHERE  C.FNUMBER = '10020002'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>

    </select>
    <select id="getYuanCaiLiaoChuKu" resultType="com.huimv.getdata.entity.kucun.YuanCaiLiaoChuKu"
            parameterType="java.util.Date">
         SELECT DISTINCT B.FSALUNITQTY, A.FDATE , A.FSTOCKORGID , F.FMATERIALID , D.FNAME wuLiaoName,C.FNUMBER ,E.FNAME
FROM T_SAL_OUTSTOCK A
INNER JOIN T_SAL_OUTSTOCKENTRY F ON F.FID = A.FID
INNER JOIN T_SAL_OUTSTOCKENTRY_F B ON F.FENTRYID = B.FENTRYID
 INNER JOIN  T_BD_MATERIAL C  ON F.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = F.FSTOCKID
 WHERE E.FNAME ='原料库' 	AND C.FNUMBER != '10020002'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
  SELECT DISTINCT B.FQTY   FSALUNITQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME wuLiaoName ,C.FNUMBER  ,E.FNAME
FROM T_PRD_INSTOCK A
INNER JOIN T_STK_MISDELIVERYENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE  C.FNUMBER != '10020002' AND E.FNAME ='原料库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
    </select>
    <select id="getChengPinChuKu" resultType="com.huimv.getdata.entity.kucun.ChenPinChuKu"
            parameterType="java.util.Date">
        SELECT DISTINCT B.FSALUNITQTY, A.FDATE , A.FSTOCKORGID , F.FMATERIALID ,E.FNAME
FROM T_SAL_OUTSTOCK A
INNER JOIN T_SAL_OUTSTOCKENTRY F ON F.FID = A.FID
INNER JOIN T_SAL_OUTSTOCKENTRY_F B ON F.FENTRYID = B.FENTRYID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = F.FSTOCKID
 WHERE E.FNAME IN('成品库','成品库CW')
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
UNION ALL
  SELECT DISTINCT B.FQTY FSALUNITQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID ,E.FNAME
FROM T_PRD_INSTOCK A
INNER JOIN T_STK_MISDELIVERYENTRY B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE  E.FNAME IN ('成品库','成品库CW')
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>

    </select>
    <select id="getYangMaoZhiChuKu" resultType="com.huimv.getdata.entity.kucun.YangMaoZhiChuKu"
            parameterType="java.util.Date">
         SELECT DISTINCT B.FSALUNITQTY, A.FDATE , A.FSTOCKORGID , F.FMATERIALID , D.FNAME ,C.FNUMBER
FROM T_SAL_OUTSTOCK A
INNER JOIN T_SAL_OUTSTOCKENTRY F ON F.FID = A.FID
INNER JOIN T_SAL_OUTSTOCKENTRY_F B ON F.FENTRYID = B.FENTRYID
 INNER JOIN  T_BD_MATERIAL C  ON F.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 WHERE C.FNUMBER = '10020002'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
 SELECT DISTINCT B.FQTY FSALUNITQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME ,C.FNUMBER
FROM T_PRD_INSTOCK A
INNER JOIN T_STK_MISDELIVERYENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 WHERE  C.FNUMBER = '10020002'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
    </select>
    <select id="getKunCunQuShi" resultType="com.huimv.getdata.entity.kucun.KunCunQuShi"
            parameterType="java.util.Date">
        SELECT DISTINCT A.FBALDATE , A.FBASEENDQTY ,B.FNAME , A.FSTOCKORGID FROM T_STK_INVBAL A
INNER JOIN T_BD_MATERIAL_L B ON A.FMATERIALID = B.FMATERIALID
        <if test="date !=null">
            and  A.FBALDATE >= #{date}
        </if>
    </select>
    <select id="getChuKuShuLiang" resultType="com.huimv.getdata.entity.kucun.YangMaoZhiChuKu"
            parameterType="java.util.Date">
        SELECT DISTINCT B.FSALUNITQTY, A.FDATE , A.FSTOCKORGID , F.FMATERIALID , D.FNAME wuLiaoName ,C.FNUMBER ,E.FNAME
FROM T_SAL_OUTSTOCK A
INNER JOIN T_SAL_OUTSTOCKENTRY F ON F.FID = A.FID
INNER JOIN T_SAL_OUTSTOCKENTRY_F B ON F.FENTRYID = B.FENTRYID
 INNER JOIN  T_BD_MATERIAL C  ON F.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = F.FSTOCKID
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
UNION ALL
  SELECT DISTINCT B.FQTY FSALUNITQTY , A.FDATE , A.FSTOCKORGID , B.FMATERIALID , D.FNAME ,C.FNUMBER  ,E.FNAME
FROM T_PRD_INSTOCK A
INNER JOIN T_STK_MISDELIVERYENTRY B ON A.FID = B.FID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
        <if test="date !=null">
            where  A.FDATE >= #{date}
        </if>

    </select>
    <select id="getWuLiaoMingXi" resultType="com.huimv.getdata.entity.kucun.WuLiaoKuMingXi"
            parameterType="java.util.Date">
        SELECT DISTINCT A.FDATE , A.FSTOCKORGID ,B.FACTRECEIVEQTY , F.FINSTOCKQTY ,(B.FACTRECEIVEQTY  -F.FINSTOCKQTY ) daiJian,D.FNAME wuLiaoName,C.FNUMBER,E.FNAME ,B.FMATERIALID
FROM T_PUR_RECEIVE A
INNER JOIN T_PUR_RECEIVEENTRY B ON A.FID = B.FID
INNER JOIN T_PUR_RECEIVEENTRY_S F ON F.FENTRYID = B.FENTRYID
 INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
 INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
        <if test="date !=null">
            where  A.FDATE >= #{date}
        </if>
    </select>
    <select id="getYangMaoZhiGongYingShang" resultType="com.huimv.getdata.entity.kucun.YangMaoZhiGongYingShang"
            parameterType="java.util.Date">
        SELECT DISTINCT A.FSTOCKORGID ,A.FDATE ,B.FREALQTY ,C.FNAME ,C.FSUPPLIERID  ,D.FNAME wuliaoName FROM T_STK_INSTOCK A
INNER JOIN T_STK_INSTOCKENTRY B ON A.FID = B.FID
INNER JOIN t_BD_Supplier_L C ON C.FSUPPLIERID = A.FSUPPLIERID
INNER JOIN T_BD_MATERIAL_L D ON D.FMATERIALID = B.FMATERIALID
WHERE D.FNAME  in(' 二氢羊毛甾醇标准品','羊毛甾醇标准品','羊毛粗脂')
        <if test="date !=null">
            where  A.FDATE >= #{date}
        </if>
    </select>
    <select id="getYangMaoZhiGongYingShangLeiJi" resultType="com.huimv.getdata.entity.kucun.YangMaoZhiGongYingShang"
            parameterType="java.util.Date">

        SELECT DISTINCT A.FSTOCKORGID ,A.FDATE ,B.FREALQTY ,C.FNAME ,C.FSUPPLIERID  ,D.FNAME wuliaoName FROM T_STK_INSTOCK A
INNER JOIN T_STK_INSTOCKENTRY B ON A.FID = B.FID
INNER JOIN t_BD_Supplier_L C ON C.FSUPPLIERID = A.FSUPPLIERID
INNER JOIN T_BD_MATERIAL_L D ON D.FMATERIALID = B.FMATERIALID
WHERE D.FNAME  in(' 二氢羊毛甾醇标准品','羊毛甾醇标准品','羊毛粗脂')

    </select>
    <select id="getWuJinDangRi" resultType="com.huimv.getdata.entity.kucun.ChengPinRuKu"
            parameterType="java.util.Date">

SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_STK_INSTOCK A
INNER JOIN T_STK_INSTOCKENTRY B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME ='五金库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
 SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_PRD_INSTOCK A
INNER JOIN T_PRD_INSTOCKENTRY  B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME  ='五金库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
  SELECT DISTINCT B.FQTY FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_STK_MISCELLANEOUS  A
INNER JOIN T_STK_MISCELLANEOUSENTRY  B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME  ='五金库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
    </select>
    <select id="getBaoCaiDangRi" resultType="com.huimv.getdata.entity.kucun.ChengPinRuKu"
            parameterType="java.util.Date">SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_STK_INSTOCK A
INNER JOIN T_STK_INSTOCKENTRY B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME ='包材库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
 SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_PRD_INSTOCK A
INNER JOIN T_PRD_INSTOCKENTRY  B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME  ='包材库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
 UNION ALL
  SELECT DISTINCT B.FQTY FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME
FROM T_STK_MISCELLANEOUS  A
INNER JOIN T_STK_MISCELLANEOUSENTRY  B ON A.FID = B.FID
 INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
 WHERE E.FNAME  ='包材库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
    </select>

    <select id="getWuJinChuKu" resultType="com.huimv.getdata.entity.kucun.ChenPinChuKu"
            parameterType="java.util.Date">
        SELECT DISTINCT B.FSALUNITQTY, A.FDATE , A.FSTOCKORGID , F.FMATERIALID ,E.FNAME
        FROM T_SAL_OUTSTOCK A
        INNER JOIN T_SAL_OUTSTOCKENTRY F ON F.FID = A.FID
        INNER JOIN T_SAL_OUTSTOCKENTRY_F B ON F.FENTRYID = B.FENTRYID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = F.FSTOCKID
        WHERE E.FNAME ='五金库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
        UNION ALL
        SELECT DISTINCT B.FQTY FSALUNITQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID ,E.FNAME
        FROM T_PRD_INSTOCK A
        INNER JOIN T_STK_MISDELIVERYENTRY B ON A.FID = B.FID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
        WHERE  E.FNAME ='五金库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>

    </select>
    <select id="getBaoCaiChuKu" resultType="com.huimv.getdata.entity.kucun.ChenPinChuKu"
            parameterType="java.util.Date">
        SELECT DISTINCT B.FSALUNITQTY, A.FDATE , A.FSTOCKORGID , F.FMATERIALID ,E.FNAME
        FROM T_SAL_OUTSTOCK A
        INNER JOIN T_SAL_OUTSTOCKENTRY F ON F.FID = A.FID
        INNER JOIN T_SAL_OUTSTOCKENTRY_F B ON F.FENTRYID = B.FENTRYID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = F.FSTOCKID
        WHERE E.FNAME ='包材库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
        UNION ALL
        SELECT DISTINCT B.FQTY FSALUNITQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID ,E.FNAME
        FROM T_PRD_INSTOCK A
        INNER JOIN T_STK_MISDELIVERYENTRY B ON A.FID = B.FID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
        WHERE  E.FNAME ='包材库'
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
    </select>
    <select id="getChengPinDangRiAll" resultType="com.huimv.getdata.entity.kucun.ChengPinRuKu"
            parameterType="java.lang.String">

        SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME ,C.FNUMBER ,D.FNAME wuLiaoName
        FROM T_STK_INSTOCK A
        INNER JOIN T_STK_INSTOCKENTRY B ON A.FID = B.FID
        INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
        INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
        UNION ALL
        SELECT DISTINCT B.FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME ,C.FNUMBER ,D.FNAME wuLiaoName
        FROM T_PRD_INSTOCK A
        INNER JOIN T_PRD_INSTOCKENTRY  B ON A.FID = B.FID
        INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
        INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
        UNION ALL
        SELECT DISTINCT B.FQTY FREALQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID  ,E.FNAME,C.FNUMBER ,D.FNAME wuLiaoName
        FROM T_STK_MISCELLANEOUS  A
        INNER JOIN T_STK_MISCELLANEOUSENTRY  B ON A.FID = B.FID
        INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
        INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>


    </select>
    <select id="getChengPinChuKuAll" resultType="com.huimv.getdata.entity.kucun.ChenPinChuKu"
            parameterType="java.lang.String">

        SELECT DISTINCT B.FSALUNITQTY, A.FDATE , A.FSTOCKORGID ,F.FMATERIALID ,E.FNAME ,C.FNUMBER ,D.FNAME wuLiaoName
        FROM T_SAL_OUTSTOCK A
        INNER JOIN T_SAL_OUTSTOCKENTRY F ON F.FID = A.FID
        INNER JOIN T_SAL_OUTSTOCKENTRY_F B ON F.FENTRYID = B.FENTRYID
        INNER JOIN  T_BD_MATERIAL C  ON F.FMATERIALID  = C.FMATERIALID
        INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = F.FSTOCKID
        <if test="date !=null">
            WHERE  A.FDATE >= #{date}
        </if>

        UNION ALL
        SELECT DISTINCT B.FQTY FSALUNITQTY, A.FDATE , A.FSTOCKORGID , B.FMATERIALID ,E.FNAME ,C.FNUMBER ,D.FNAME  wuLiaoName
        FROM T_PRD_INSTOCK A
        INNER JOIN T_STK_MISDELIVERYENTRY B ON A.FID = B.FID
        INNER JOIN  T_BD_MATERIAL C  ON B.FMATERIALID  = C.FMATERIALID
        INNER JOIN  T_BD_MATERIAL_L D  ON D.FMATERIALID  = C.FMATERIALID
        INNER JOIN t_BD_Stock_L  E ON E.FSTOCKID = B.FSTOCKID
        <if test="date !=null">
            WHERE  A.FDATE >= #{date}
        </if>

    </select>

</mapper>
