| | |
| | | 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 |
| | |
| | | </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> |
| | | |
| | | <delete id="deleteByWorkOrderIds" parameterType="java.util.List"> |
| | | DELETE FROM production_product_main |
| | |
| | | #{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 >= #{ew.startTime} |
| | | and create_time < #{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 >= #{ew.startTime} |
| | | and create_time < #{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> |