<?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.fjhx.mes.mapper.work.WorkOrderMapper">
    <select id="getPage" resultType="com.fjhx.mes.entity.work.vo.WorkOrderVo">
        select
            wo.id,
            wo.code,
            wo.source,
            wo.product_id,
            wo.quantity,
            wo.remarks,
            wo.status,
            wo.create_user,
            wo.create_time,
            wo.update_user,
            wo.update_time,
            wo.is_customized
        from work_order wo
            ${ew.customSqlSegment}
    </select>

    <select id="getSumCountInResourceId" resultType="com.fjhx.mes.entity.work.vo.WorkOrderVo">
        SELECT
            IFNULL(SUM(quantity),0) AS sumQuantity,
            source_id
        FROM
            work_order
        <where>
            source = 0
            <if test="dataResourceIds neq null and dataResourceIds.size() > 0">
                <foreach collection="dataResourceIds" item="dataResourceId" open="AND source_id IN (" separator="," close=")">
                    #{dataResourceId}
                </foreach>
            </if>
        </where>
        GROUP BY source_id
    </select>
</mapper>
