chenhj
8 天以前 7e84848f0ea65411bdc9f27e5fa9d714157d032a
src/main/resources/mapper/production/ProductionProductMainMapper.xml
@@ -63,7 +63,7 @@
        sl.sales_contract_no,
        sl.customer_name,
        p.product_name,
        pm.model,
        pm.model as product_model_name,
        pm.unit,
        slpa.process,
        ppo.quantity,
@@ -71,7 +71,7 @@
        slpa.work_hours * slpa.finished_num AS wages
        FROM
        production_product_main ppm
        LEFT JOIN sales_ledger_production_accounting slpa ON slpa.sales_ledger_work_id = ppm.id
        LEFT JOIN sales_ledger_production_accounting slpa ON slpa.product_main_id = ppm.id
        LEFT JOIN production_product_output ppo ON ppm.id = ppo.product_main_id
        LEFT JOIN product_work_order pwo ON pwo.id = ppm.work_order_id
        LEFT JOIN product_order po ON po.id = pwo.product_order_id
@@ -83,6 +83,28 @@
            <if test="ew.schedulingUserName != null and ew.schedulingUserName !=''">
                and slpa.scheduling_user_name = #{ew.schedulingUserName}
            </if>
            <if test="ew.entryDate != null " >
                and slpa.scheduling_date >= #{ew.entryDate}
                and slpa.scheduling_date &lt; DATE_ADD(#{ew.entryDate}, INTERVAL 1 DAY)
            </if>
            <if test="ew.entryDateStart != null and ew.entryDateEnd != null" >
                and slpa.scheduling_date >= #{ew.entryDateStart}
                and slpa.scheduling_date &lt; date_add(#{ew.entryDateEnd}, INTERVAL 1 DAY)
            </if>
        </where>
    </select>
    <select id="listMain" resultType="java.lang.Long">
        SELECT ppm.id FROM production_product_main ppm
            left join product_work_order pwo on pwo.id = ppm.work_order_id
                  left join product_order po on po.id = pwo.product_order_id
                  left join sales_ledger sl on sl.id = po.sales_ledger_id
        <where>
            <if test="idList != null and idList.size() > 0">
                and sl.id in
                <foreach item="id" collection="idList" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>
@@ -93,4 +115,30 @@
            #{id}
        </foreach>
    </delete>
    <select id="queryProductInputAndOutput" resultType="Hashmap">
        select *
        from (select p.product_name      as productName,
                     pm.model            as model,
                     pm.unit             as unit,
                     temp.inputQuantity  as inputQuantity,
                     temp.outputQuantity as outputQuantity
              from (select product_model_id,
                           coalesce(sum(inputQuantity), 0)  as inputQuantity,
                           coalesce(sum(outputQuantity), 0) as outputQuantity
                    from ((select product_model_id, coalesce(sum(quantity), 0) as inputQuantity, 0 as outputQuantity
                           from production_product_input
                           where create_time &gt;= #{ew.startTime}
                             and create_time &lt; #{ew.endTime}
                           group by product_model_id)
                          union all
                          (select product_model_id, 0 as inputQuantity, coalesce(sum(quantity), 0) as outputQuantity
                           from production_product_output
                           where create_time &gt;= #{ew.startTime}
                             and create_time &lt; #{ew.endTime}
                           group by product_model_id)) t
                    group by product_model_id) temp
                       left join product_model pm on temp.product_model_id = pm.id
                       left join product p on pm.product_id = p.id) tmp
    </select>
</mapper>