<?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.ruoyi.nanjing.mapper.TBdProducttypeMapper">

    <resultMap type="TBdProducttype" id="TBdProducttypeResult">
        <result property="ID"    column="ID"    />
        <result property="ProductTypeID"    column="ProductTypeID"    />
        <result property="ProductTypeName"    column="ProductTypeName"    />
    </resultMap>

    <resultMap id="ProRpList" type="com.ruoyi.nanjing.domain.ProRpList">
        <result property="barcode" column="Barcode"/>
        <result property="productName" column="ProductName"/>
        <result property="semiBarcode" column="SemiBarcode_A"/>
        <result property="state" column="State"/>
        <result property="currentStation" column="CurrentStation"/>
        <result property="NGStation" column="NGStation"/>
        <result property="finishFlag" column="FinishFlag"/>
        <result property="namePlateInfo" column="NamePlateInfo"/>
        <result property="isDis" column="IsDis"/>
        <result property="beginTime" column="BeginTime"/>
        <result property="endTime" column="EndTime"/>
    </resultMap>

    <resultMap id="qtProduct" type="com.ruoyi.nanjing.domain.QtProduct">
        <result property="shiftNo" column="班次"/>
        <result property="groupNo" column="班组"/>
        <result property="inputNum" column="投入量"/>
        <result property="finNum" column="成品数量"/>
        <result property="okNum" column="合格品"/>
        <result property="noNum" column="不合格品"/>
        <result property="ero" column="异常"/>
    </resultMap>

    <resultMap id="qsProduct" type="com.ruoyi.nanjing.domain.QsProduct">
        <result property="productTp" column="机种类型"/>
        <result property="inputNum" column="投入量"/>
        <result property="okNum" column="合格品"/>
        <result property="noNum" column="不合格品"/>
        <result property="ero" column="异常"/>
        <result property="allRate" column="综合合格率"/>
    </resultMap>

    <resultMap id="qsStation" type="com.ruoyi.nanjing.domain.QsStation">
        <result property="stationCode" column="工位代码"/>
        <result property="stationName" column="工位名称"/>
        <result property="inputNum" column="总数量"/>
        <result property="okNum" column="合格数量"/>
        <result property="ero" column="异常数量"/>
        <result property="allRate" column="合格率"/>
    </resultMap>

    <resultMap id="repo" type="com.ruoyi.nanjing.domain.ReportData">
        <result property="id" column="id"/>
        <result property="barcode" column="Barcode"/>
        <result property="parameaning" column="parameaning"/>
        <result property="value" column="value"/>
        <result property="beginTime" column="begintime"/>
        <result property="stationName" column="stationname"/>
    </resultMap>
    <sql id="selectTBdProducttypeVo">
        select ID, ProductTypeID, ProductTypeName from T_BD_ProductType
    </sql>

    <select id="selectTBdProducttype" resultMap="TBdProducttypeResult">
        select top 1 ID, ProductTypeID, ProductTypeName from T_BD_ProductType
        order by ProductTypeID desc
    </select>
    <select id="selectTBdProducttypeList" parameterType="TBdProducttype" resultMap="TBdProducttypeResult">
        <include refid="selectTBdProducttypeVo"/>
        <where>
            <if test="ProductTypeName != null "> and ProductTypeName like ('%' + #{ProductTypeName} + '%')</if>
        </where>
    </select>

    <select id="selectProLists" parameterType="map" statementType="CALLABLE" resultMap="ProRpList">
            {
                call pro_ProRpList
                (
                    #{beginTime,mode=IN,jdbcType=DATE},
                    #{endTime,mode=IN,jdbcType=DATE},
                    #{semiBarcode,mode=IN,jdbcType=VARCHAR},
                    #{state,mode=IN,jdbcType=VARCHAR},
                    #{productId,mode=IN,jdbcType=VARCHAR},
                    #{productType,mode=IN,jdbcType=VARCHAR}
                )
            }
    </select>

    <select id="selectQtProductList" parameterType="map" resultMap="qtProduct" statementType="CALLABLE">
        {
            call pro_StatisticOfProductQty
            (
                #{beginTime,mode=IN,jdbcType=DATE},
                #{endTime,mode=IN,jdbcType=DATE},
                #{productId,mode=IN,jdbcType=VARCHAR},
                #{productType,mode=IN,jdbcType=VARCHAR},
                #{shiftId,mode=IN,jdbcType=VARCHAR},
                #{groupId,mode=IN,jdbcType=VARCHAR}
            )
        }
    </select>
    <select id="selectQsProductList" parameterType="map" resultMap="qsProduct" statementType="CALLABLE">
        {
            call   pro_StatisticOfProductQRate
            (
                #{beginTime,mode=IN,jdbcType=DATE},
                #{endTime,mode=IN,jdbcType=DATE},
                #{productId,mode=IN,jdbcType=VARCHAR},
                #{productType,mode=IN,jdbcType=VARCHAR}
            )
        }

    </select>
    <select id="selectQ1ProductList" parameterType="map" resultMap="qsProduct" statementType="CALLABLE">
        {
            call   pro_StatisticOfProductQ1Rate
            (
                #{beginTime,mode=IN,jdbcType=DATE},
                #{endTime,mode=IN,jdbcType=DATE},
                #{productId,mode=IN,jdbcType=VARCHAR},
                #{productType,mode=IN,jdbcType=VARCHAR}
            )
        }
    </select>

    <select id="selectStationQs" parameterType="map" statementType="CALLABLE" resultMap="qsStation">
        {
            call   pro_StationQStatistic
            (
                #{beginTime,mode=IN,jdbcType=DATE},
                #{endTime,mode=IN,jdbcType=DATE},
                #{stationType,mode=IN,jdbcType=VARCHAR},
                #{stationId,mode=IN,jdbcType=VARCHAR},
                #{productId,mode=IN,jdbcType=VARCHAR}
            )
        }

    </select>
    <select id="selectAllQs" parameterType="map" statementType="CALLABLE" resultMap="qsProduct">
        {
            call pro_StatisticOfProductQRate
            (
                #{begin,mode=IN,jdbcType=DATE},
                #{end,mode=IN,jdbcType=DATE},
                #{productId,mode=IN,jdbcType=VARCHAR},
                #{productType,mode=IN,jdbcType=VARCHAR}
            )
        }
    </select>

    <select id="selectReport" parameterType="map" statementType="CALLABLE"  resultType="java.util.LinkedHashMap">
        {
            call testrow
            (
                #{begin,mode=IN,jdbcType=DATE},
                #{end,mode=IN,jdbcType=DATE},
                #{barcode,mode=IN,jdbcType=VARCHAR}
            )
        }
    </select>


    <!--    <insert id="insertTBdProducttype" parameterType="TBdProducttype">-->
<!--        insert into T_BD_ProductType-->
<!--        <trim prefix="(" suffix=")" suffixOverrides=",">-->
<!--            <if test="ID != null">ID,</if>-->
<!--            <if test="ProductTypeID != null">ProductTypeID,</if>-->
<!--            <if test="ProductTypeName != null">ProductTypeName,</if>-->
<!--         </trim>-->
<!--        <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<!--            <if test="ID != null">#{ID},</if>-->
<!--            <if test="ProductTypeID != null">#{ProductTypeID},</if>-->
<!--            <if test="ProductTypeName != null">#{ProductTypeName},</if>-->
<!--         </trim>-->
<!--    </insert>-->

<!--    <update id="updateTBdProducttype" parameterType="TBdProducttype">-->
<!--        update T_BD_ProductType-->
<!--        <trim prefix="SET" suffixOverrides=",">-->
<!--            <if test="ProductTypeID != null">ProductTypeID = #{ProductTypeID},</if>-->
<!--            <if test="ProductTypeName != null">ProductTypeName = #{ProductTypeName},</if>-->
<!--        </trim>-->
<!--        where ID = #{ID}-->
<!--    </update>-->

<!--    <delete id="deleteTBdProducttypeById" parameterType="Long">-->
<!--        delete from T_BD_ProductType where ID = #{ID}-->
<!--    </delete>-->

<!--    <delete id="deleteTBdProducttypeByIds" parameterType="String">-->
<!--        delete from T_BD_ProductType where ID in-->
<!--        <foreach item="ID" collection="array" open="(" separator="," close=")">-->
<!--            #{ID}-->
<!--        </foreach>-->
<!--    </delete>-->

</mapper>
