SELECT
ppo.out_batch_no,
ppo.product_main_id,
pot.mo_routing_operation_id,
pots.mo_id
FROM
production_product_output ppo
LEFT JOIN production_product_main ppm ON ppo.product_main_id = ppm."id"
LEFT JOIN production_operation_task pot ON ppm.operation_task_id = pot."id"
LEFT JOIN production_operation_task_supply pots ON pot."id" = pots.operation_task_id
WHERE
ppo.system_no = #{systemNo}
LIMIT 1
SELECT
*
FROM
plan_mo_sampling_rule
WHERE
mo_id = #{moId}
AND mo_routing_operation_id = #{moRoutingOperationId}
AND apply_type = #{applyType}
SELECT
ppi.part_batch_no
FROM
production_product_input ppi
LEFT JOIN production_product_output ppo ON ppi.system_no = ppo.system_no
LEFT JOIN production_product_main ppm ON ppo.product_main_id = ppm."id"
LEFT JOIN production_operation_task pot ON ppm.operation_task_id = pot."id"
LEFT JOIN plan_manufacturing_order_routing_operation pmoro ON pmoro."id" = pot.mo_routing_operation_id
LEFT JOIN technology_operation too ON too."id" = pmoro.operation_id
WHERE
ppi.product_main_id = #{productMainId}
AND too."id" = #{retrospectOperationId}
ORDER BY input_quantity DESC
LIMIT 1
UPDATE
quality_report_sampling_record
SET
version = version + 1,
checked_num = checked_num + #{checkedNum}
,sampling_num = sampling_num + #{samplingNum}
,report_id = #{reportId}
WHERE
id = #{id}
and version = #{version}