zhoushihao
2024-08-13 07fa8e744d9ed8dce280a4ca6851fe50d27ff4bd
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/mapper/DownGlassInfoMapper.xml
@@ -10,7 +10,7 @@
    <resultMap id="downGlassInfo" type="com.mes.downworkstation.entity.dto.DownGlassInfoDTO">
        <result column="flow_card_id" property="flowCardId"/>
        <result column="layer" property="layer"/>
        <result column="count" property="count"/>
        <result column="racks_number" property="racksNumber"/>
        <collection property="glassInfoList" ofType="com.mes.glassinfo.entity.GlassInfo">
            <id column="id" property="id"/>
            <result column="flow_card_id" property="flowCardId"/>
@@ -38,41 +38,56 @@
        order by count desc limit 1
    </select>
    <select id="queryMaxSequence" resultType="java.lang.Integer">
        SELECT max(sequence) + 1 as sequence
        SELECT COALESCE(max(sequence) + 1, 1) as sequence
        FROM down_glass_info
        WHERE flow_card_id = #{flowCardId}
          AND layer = #{layer}
    </select>
    <select id="queryWorkStationIsIn" resultMap="downGlassInfo">
        SELECT T.*
        <if test="isDownload == null and isDownload == true ">
        SELECT
        T.FLOW_CARD_ID,
        T.LAYER,
        T.RACKS_NUMBER
        <if test="!isDownload">
            ,T1.*
        </if>
        FROM (
        SELECT T.FLOW_CARD_ID,
        T.LAYER,
        COUNT(T.LAYER) AS COUNT
        FROM
        DOWN_GLASS_INFO T
        INNER JOIN DOWN_WORKSTATION T1
        ON T.FLOW_CARD_ID = T1.FLOW_CARD_ID
        AND T.LAYER = T1.LAYER
        GROUP BY
        T.FLOW_CARD_ID,
        T.LAYER
        ) T
        DOWN_WORKSTATION T
        INNER JOIN GLASS_INFO T1 ON T.FLOW_CARD_ID = T1.FLOW_CARD_ID
        AND T.LAYER = T1.LAYER
        LEFT JOIN DOWN_GLASS_INFO T2 ON T1.GLASS_ID = T2.GLASS_ID
        <where>
            <if test="isDownload == null or isDownload == false">
            t.workstation_id in
            <foreach collection="workList" item="item" open='(' close=')' separator=','>
                #{item}
            </foreach>
            <if test="!isDownload">
                AND T2.GLASS_ID IS NULL
            </if>
            <if test="isDownload == true">
            <if test="isDownload">
                AND T2.GLASS_ID IS not NULL
            </if>
        </where>
        order by t.count desc
        ORDER BY
        T.RACKS_NUMBER DESC,
        T1.TEMPERING_LAYOUT_ID,
        T1.TEMPERING_FEED_SEQUENCE DESC
    </select>
    <select id="queryWorkStationFlowCard" resultMap="downGlassInfo">
        SELECT
        T.FLOW_CARD_ID,
        T.LAYER,
        T.RACKS_NUMBER
        FROM
        DOWN_WORKSTATION T
        where
        (t.flow_card_id is not null and t.flow_card_id != '')
        and t.workstation_id in
        <foreach collection="workList" item="item" open='(' close=')' separator=','>
            #{item}
        </foreach>
        ORDER BY T.RACKS_NUMBER DESC
    </select>
</mapper>