with temp_flow as (SELECT t.process_id,
t.order_id,
t.order_number,
t.technology_number,
t.quantity,
t1.child_width,
t1.child_height
from pp.flow_card t
LEFT JOIN sd.order_glass_detail t1
on t.order_id = t1.order_id
and t.order_number = t1.order_number
and t.technology_number = t1.technology_number
where t.process_id = #{flowCardId}),
glass_info_temp as (
select process_id,
order_id,
GREATEST(child_width, child_height) as first_length,
least(child_width, child_height) as second_length,
child_width,
child_height,
order_number,
technology_number,
quantity
from temp_flow
where technology_number = #{totalLayer}
)
select row_number() over (order by second_length desc,first_length desc) as rn, t.*
from glass_info_temp t
with temp_flow as (SELECT t.process_id,
t.order_id,
t.order_number,
t.technology_number,
t.quantity,
t1.child_width,
t1.child_height
from pp.flow_card t
LEFT JOIN sd.order_glass_detail t1
on t.order_id = t1.order_id
and t.order_number = t1.order_number
and t.technology_number = t1.technology_number
where t.process_id = #{flowCardId}),
glass_info_max_layer_temp as (
select process_id,
order_id,
GREATEST(child_width, child_height) as first_length,
least(child_width, child_height) as second_length,
child_width,
child_height,
order_number,
technology_number,
quantity
from temp_flow
where technology_number = #{totalLayer}
),
glass_info_layer_temp as (
select process_id,
order_id,
GREATEST(child_width, child_height) as first_length,
least(child_width, child_height) as second_length,
child_width,
child_height,
order_number,
technology_number,
quantity
from temp_flow
where technology_number = #{layer}
),
max_layer_sequence as (
select row_number() over (order by second_length desc,first_length desc) as rn, t.order_number
from glass_info_max_layer_temp t
),
result as (select t.*
from glass_info_layer_temp t
INNER join max_layer_sequence t1 on t.order_number = t1.order_number
order by t1.rn)
select *
from result
with relation_length as (
select flow_card_id,
layer,
tempering_layout_id,
tempering_feed_sequence,
GREATEST(width, height) as first_length,
LEAST(width, height) as second_Length,
width,
height,
thickness,
films_id
from hollow_glass_relation_info
where flow_card_id = #{flowCardId}
and tempering_layout_id is null
and tempering_feed_sequence is null
)
select flow_card_id, layer, first_length, films_id, second_Length, thickness, count(*) as lack_cout
from relation_length
group by flow_card_id, layer, films_id, first_length, second_Length, thickness
select count(distinct layer)
from hollow_glass_relation_info
where flow_card_id = #{flowCardId}
select t.product_name, t1.customer_name
from sd.order_detail t
inner join sd.order t1 on t.order_id = t1.order_id
where (t.order_id, t.order_number) = (
select min(order_id) as order_id, min(order_number) as order_number
from pp.flow_card
where process_id = #{flowCardId}
and t.product_name like concat('%', #{productName}, '%')
and t1.customer_name like concat('%', #{customerName}, '%')
)
limit 1
update hollow_glass_relation_info
set glass_id = null,
tempering_layout_id = null,
tempering_feed_sequence = null,
engineer_id = null,
state = 0
where flow_card_id = #{flowCardId}
and layer = #{layer}
and glass_id not in (
select glass_id
from hollow_big_storage_cage_details
where flow_card_id = #{flowCardId}
and layer = #{layer}
and state in (100, 102, 103, 104)
)