<?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.ErpVoucherMapper">


    <select id="getShouRuJinE" resultType="com.huimv.getdata.entity.voucher.ErpVoucher"
            parameterType="java.util.Date">

        select DISTINCT  D.FCREDIT ,M.FDATE ,M.FACCTORGID  from T_GL_VOUCHER M
        inner join T_GL_VOUCHERENTRY D on D.FVOUCHERID=M.FVOUCHERID
        inner join T_BD_ACCOUNT KM ON KM.FACCTID=D.FACCOUNTID
         where
	KM.FNumber in ('6001.01', '6001.02','6001.03')
	<if test="date !=null">
	and  m.FDATE >= #{date}
	</if>
	ORDER BY M.FDATE  DESC

    </select>
    <select id="getDangQianYueYingYeE" resultType="com.huimv.getdata.entity.voucher.ErpVoucher"
            parameterType="java.util.Date">

        select  DISTINCT D.FCREDIT ,M.FDATE ,M.FACCTORGID  from T_GL_VOUCHER M
inner join T_GL_VOUCHERENTRY D on D.FVOUCHERID=M.FVOUCHERID
inner join T_BD_ACCOUNT KM ON KM.FACCTID=D.FACCOUNTID
 where
	KM.FNumber in ('6401.01.01', '6401.01.02','6401.02.01','6401.02.02','6401.02.03')
	<if test="date !=null">
        and  m.FDATE >= #{date}
    </if>
    ORDER BY M.FDATE DESC
    </select>
    <select id="getDangQianYueJingLiRun" resultType="com.huimv.getdata.entity.voucher.ErpVoucher"
            parameterType="java.util.Date">
        select DISTINCT  D.FCREDIT ,M.FDATE ,M.FACCTORGID  from T_GL_VOUCHER M
        inner join T_GL_VOUCHERENTRY D on D.FVOUCHERID=M.FVOUCHERID
        inner join T_BD_ACCOUNT KM ON KM.FACCTID=D.FACCOUNTID
         where
	        substring(KM.FNumber,0,5) in ('6301','6703','6704','6112','6113','6101','6111')
        <if test="date !=null">
            and  m.FDATE >= #{date}
        </if>
	 ORDER BY M.FDATE DESC
    </select>
    <select id="getDangQianZiJinYvE" resultType="com.huimv.getdata.entity.voucher.ErpVoucher"
            parameterType="java.util.Date">
select DISTINCT  D.FCREDIT ,M.FDATE ,M.FACCTORGID ,KM.FNAME    from T_GL_VOUCHER M
inner join T_GL_VOUCHERENTRY D on D.FVOUCHERID=M.FVOUCHERID
        inner join T_BD_ACCOUNT_L KM ON KM.FACCTID=D.FACCOUNTID

        <if test="date !=null">
           where  m.FDATE >= #{date}
        </if>
ORDER BY M.FDATE DESC

    </select>
    <select id="getDangYueJieKuanYvE" resultType="com.huimv.getdata.entity.voucher.ErpVoucher"
            parameterType="java.util.Date">
        select  D.FCREDIT ,M.FDATE ,M.FACCTORGID   from T_GL_VOUCHER M
        inner join T_GL_VOUCHERENTRY D on D.FVOUCHERID=M.FVOUCHERID
        inner join T_BD_ACCOUNT KM ON KM.FACCTID=D.FACCOUNTID
        WHERE KM.FNumber IN ('2001','2004','2501')
        <if test="date !=null">
            where  m.FDATE >= #{date}
        </if>

    </select>
    <select id="getGuoNeiWaiSouRu" resultType="com.huimv.getdata.entity.voucher.ErpVoucher"
            parameterType="java.util.Date">
SELECT    M.FNAME ,D.FCREDIT , B.FDATE ,B.FACCTORGID from  T_BD_ACCOUNT_L  M
INNER JOIN T_GL_VOUCHERENTRY D ON  M.FACCTID= D.FACCOUNTID
INNER JOIN   T_GL_VOUCHER B ON B.FVOUCHERID  = D.FVOUCHERID

 WHERE M.FNAME in ('国内销售收入','国内销售收入2','国外销售收入')
        <if test="date !=null">
            and  B.FDATE >= #{date}
        </if>

    </select>
    <select id="getChanPinShouRu" resultType="com.huimv.getdata.entity.voucher.ChanPinShouRu"
            parameterType="java.util.Date">
SELECT   DISTINCT  A.FSTOCKORGID ,  A.FDATE , C.FALLAMOUNT ,D.FNAME  FROM  T_SAL_OUTSTOCK  A
INNER JOIN  T_SAL_OUTSTOCKENTRY B  ON A.FID= B.FID
INNER JOIN T_SAL_OUTSTOCKENTRY_F C ON C.FENTRYID  = B.FENTRYID
INNER JOIN T_BD_MATERIAL_L D  ON D.FMATERIALID = B.FMATERIALID
	WHERE FNAME in ('50万IU/G饲料添加剂VD3微粒','NF级胆固醇','饲料级胆固醇91%','25-羟基VD3原','4000万IU/G胆钙化醇','维生素D3原','蜡丸','100万IU/G复配营养强化剂MO','饲料级胆固醇80%','化妆品级羊毛醇')
        <if test="date !=null">
            and  A.FDATE >= #{date}
        </if>
    </select>
    <select id="getJingLiRunQuShi" resultType="com.huimv.getdata.entity.voucher.JingLiRunQuShi"
            parameterType="java.util.Date">

        select  D.FCREDIT ,M.FDATE ,M.FACCTORGID ,KM.Fnumber from T_GL_VOUCHER M
        inner join T_GL_VOUCHERENTRY D on D.FVOUCHERID=M.FVOUCHERID
        inner join T_BD_ACCOUNT KM ON KM.FACCTID=D.FACCOUNTID
         where
        substring (KM.Fnumber,0,5) = 6301
        <if test="date !=null">
            and  M.FDATE >= #{date}
        </if>
        order  BY M.FDATE


    </select>
    <select id="getLinJinHuanKuan" resultType="com.huimv.getdata.entity.voucher.LinJinHuanKuanQi"
            parameterType="java.util.Date">

        SELECT  A.FCREDIT ,B.FNAME ,C.FDATE ,D.FNAME orgName ,D.FORGID FROM  T_GL_VOUCHERENTRY A
	INNER JOIN  T_BD_CURRENCY_L  B ON A.FCURRENCYID  = B.FCURRENCYID
INNER JOIN  T_GL_VOUCHER C ON C. FVOUCHERID = A.FVOUCHERID
INNER JOIN t_org_organizations_l D ON D.FORGID = C.FACCTORGID

        <if test="date !=null">
            where  C.FDATE >= #{date}
        </if>

    </select>
</mapper>
