update hollow_big_storage_cage_details
state = #{state}
(glass_id,slot) in (
(#{item.glassId}, #{item.targetSlot})
)
and state not in (8, 9, 101)
update big_storage_cage_details t inner join big_storage_cage t1 on t.slot = t1.slot
set t.device_id = t1.device_id
where t.slot in (
#{item}
)
WITH flow_layer_stats AS (
SELECT
h.flow_card_id,
h.layer,
MIN(r.films_id) AS films_id,
MIN(r.thickness) AS thickness,
COUNT(*) AS sum_count,
COUNT(DISTINCT h.slot) AS slot_count,
SUM(CASE WHEN h.state = 100 THEN 1 ELSE 0 END) AS real_count
FROM hollow_glass_relation_info r
LEFT JOIN hollow_big_storage_cage_details h
ON r.flow_card_id = h.flow_card_id AND r.layer = h.layer
WHERE r.flow_card_id = #{flowCardId}
GROUP BY h.flow_card_id, h.layer
),
damage_stats AS (
SELECT
process_id AS flow_card_id,
technology_number AS layer,
COUNT(*) AS damage_count
FROM damage
WHERE type IN (8,9) AND process_id = #{flowCardId}
GROUP BY process_id, technology_number
),
pair_stats AS (
SELECT
t1.flow_card_id,
COUNT(*) AS pair_count
FROM hollow_big_storage_cage_details t1
INNER JOIN hollow_big_storage_cage_details t2
ON t1.flow_card_id = t2.flow_card_id
AND t1.virtual_slot = t2.virtual_slot
AND t1.sequence = t2.sequence
AND t1.layer = 1 AND t2.layer = 2
AND t1.state = 100 AND t2.state = 100
INNER JOIN hollow_big_storage_cage_details t3
ON t1.flow_card_id = t3.flow_card_id
AND t1.virtual_slot = t3.virtual_slot
AND t1.sequence = t3.sequence
AND t3.layer = 3 AND t3.state = 100
WHERE t1.flow_card_id = #{flowCardId}
GROUP BY t1.flow_card_id
)
SELECT
f.flow_card_id,
f.layer,
f.films_id,
f.thickness,
f.sum_count,
COALESCE(p.pair_count, 0) AS pair_count,
COALESCE(f.real_count, 0) AS real_count,
COALESCE(d.damage_count, 0) AS damage_count,
(f.sum_count - COALESCE(f.real_count, 0) - COALESCE(d.damage_count, 0)) AS lack_count,
f.slot_count
FROM flow_layer_stats f
LEFT JOIN damage_stats d
ON f.flow_card_id = d.flow_card_id AND f.layer = d.layer
LEFT JOIN pair_stats p
ON f.flow_card_id = p.flow_card_id
WHERE 1=1
AND f.sum_count = COALESCE(p.pair_count, 0)
ORDER BY f.layer;
with relation_temp as (
select flow_card_id, layer, virtual_slot, count(1) as slot_count
from hollow_glass_relation_info
group by flow_card_id, layer, virtual_slot
),
details_temp as (
select flow_card_id, layer, virtual_slot, count(1) as slot_count
from hollow_big_storage_cage_details
where state = 100
group by flow_card_id, layer, virtual_slot
),
result_one as (
select t.*, t1.slot_count as tslot_count
from relation_temp t
INNER JOIN details_temp t1 on t.flow_card_id = t1.flow_card_id and
t.layer = t1.layer and
t.virtual_slot = t1.virtual_slot
where t.slot_count = t1.slot_count
)
select flow_card_id, layer, virtual_slot
from result_one
order by flow_card_id, layer, virtual_slot
select slot, max(sequence) as max_sequence, min(sequence) as min_sequence
from hollow_big_storage_cage_details
where (flow_card_id, layer, virtual_slot) = (#{flowCardId}, #{layer}, #{virtualSlot})
group by slot
order by max_sequence
with flow_card_id_layer as (
select flow_card_id, max(total_layer) as total_layer
FROM hollow_big_storage_cage_details
group by flow_card_id
),
details_sequence_count_temp as (
SELECT flow_card_id, hollow_sequence, count(1) as max_count
FROM hollow_big_storage_cage_details
where state = 100
group by flow_card_id, hollow_sequence
),
glass_out_temp as (
select t1.*, case when t.total_layer = t1.max_count then 1 else 0 end is_pair
from flow_card_id_layer t
inner join details_sequence_count_temp t1 on t.flow_card_id = t1.flow_card_id
),
result_detail as (
select t.id,
t.device_id,
t.virtual_slot,
t.slot,
t.glass_id,
t.sequence,
t.flow_card_id,
t.glass_type,
t.width,
t.height,
t.thickness,
t.tempering_layout_id,
t.tempering_feed_sequence,
t.state,
t.gap,
t.engineer_id,
t.total_layer,
t.layer,
t.create_time,
t.update_time,
t.hollow_sequence,
t.films_id,
t1.is_pair
from hollow_big_storage_cage_details t
INNER JOIN glass_out_temp t1
on t.flow_card_id = t1.flow_card_id and t.hollow_sequence = t1.hollow_sequence
where t.state = 100
and t.flow_card_id = #{flowCardId}
)
select *
from result_detail
order by flow_card_id, hollow_sequence,layer
desc
select hbsc.device_id, hbsc.slot, count(hbscd.glass_id) as count
from hollow_big_storage_cage hbsc
left join hollow_big_storage_cage_details hbscd
on hbsc.slot = hbscd.slot and hbscd.state in (100, 102, 103, 104)
group by hbsc.device_id, hbsc.slot
order by hbsc.device_id, hbsc.slot
select max(sequence) as sequence, device_id, slot
from hollow_big_storage_cage_details
where (flow_card_id, total_layer, layer, virtual_slot) =
(#{flowCardId}, #{totalLayer}, #{layer}, #{virtualSlot})
and state in (0, 100, 102, 103, 104)
group by device_id, slot
order by sequence
with hollow_sequence_temp as (
SELECT hollow_sequence, count(distinct layer) as count
FROM hollow_big_storage_cage_details
WHERE flow_card_id = #{flowCardId}
AND STATE = 100
GROUP BY hollow_sequence
having count = #{totalLayer}
limit #{totalPairQuantity}
),
hollow_details as (select *
from hollow_big_storage_cage_details
WHERE flow_card_id = #{flowCardId}
AND STATE = 100
)
select *
from hollow_details t
inner join hollow_sequence_temp t1 on t.hollow_sequence = t1.hollow_sequence
ORDER BY t.hollow_sequence
select flow_card_id, layer
from hollow_big_storage_cage_details
where state in (100, 102, 103, 104)
group by flow_card_id, layer