liding
3 天以前 1a3f5db043fd381b60a0a5f40687136274a2cbd1
src/main/resources/mapper/production/ProductionProductMainMapper.xml
@@ -18,6 +18,7 @@
        pwo.status as workOrderStatus,
        u.nick_name as nickName,
        p.product_name as productName,
        pp.name as process,
        pm.model as productModelName,
        ppo.quantity,
        ppo.scrap_qty,
@@ -26,6 +27,8 @@
        from
        production_product_main ppm
        left join product_work_order pwo on pwo.id = ppm.work_order_id
        left join product_process_route_item ppri on ppri.id = pwo.product_process_route_item_id
        left join product_process pp on pp.id = ppri.process_id
        left join product_order po on po.id = pwo.product_order_id
        left join production_product_output ppo on ppm.id = ppo.product_main_id
        left join product_model pm on pm.id = ppo.product_model_id
@@ -115,4 +118,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>