| | |
| | | (#{item.glassId}, #{item.targetSlot}) |
| | | </foreach> |
| | | ) |
| | | and state !=101 |
| | | and state not in (8, 9, 101) |
| | | </where> |
| | | </update> |
| | | <update id="updateDeviceIdBySlot"> |
| | |
| | | </update> |
| | | |
| | | <select id="hollowIsAll" resultMap="baseMap"> |
| | | WITH sum_flow_layer_count AS ( SELECT flow_card_id, layer, min( films_id ) AS films_id, min(thickness) as |
| | | thickness,count(*) AS sum_count FROM hollow_glass_relation_info GROUP BY flow_card_id, layer ), |
| | | real_flow_layer_count AS ( SELECT flow_card_id, layer, count(*) AS real_count, count(distinct slot) as |
| | | slot_count FROM |
| | | hollow_big_storage_cage_details t WHERE state = 100 GROUP BY flow_card_id, layer ), |
| | | damage_flow_layer_count AS ( SELECT process_id AS flow_card_id, technology_number AS layer, count(*) as |
| | | damage_count FROM damage where type in(8,9) GROUP BY process_id, technology_number ), |
| | | lack_flow_layer_count AS ( |
| | | WITH flow_layer_stats AS ( |
| | | SELECT |
| | | t.flow_card_id, |
| | | t.layer, |
| | | ifnull((sum_count - real_count - ifnull(damage_count,0)),0) AS lack_count |
| | | FROM |
| | | sum_flow_layer_count t |
| | | left JOIN real_flow_layer_count t1 ON t.flow_card_id = t1.flow_card_id |
| | | AND t.layer = t1.layer |
| | | left JOIN damage_flow_layer_count t2 ON t1.flow_card_id = t2.flow_card_id |
| | | AND t1.layer = t2.layer |
| | | 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 |
| | | ), |
| | | layer_one AS ( SELECT * FROM hollow_big_storage_cage_details WHERE layer = 1 AND state = 100 ), |
| | | layer_two AS ( SELECT * FROM hollow_big_storage_cage_details WHERE layer = 2 AND state = 100), |
| | | layer_three AS ( SELECT * FROM hollow_big_storage_cage_details WHERE layer = 3 AND state = 100 ) |
| | | , |
| | | pair_flow_layer_count AS ( |
| | | damage_stats AS ( |
| | | SELECT |
| | | t.flow_card_id, |
| | | count(*) AS pair_count |
| | | FROM |
| | | layer_one t |
| | | INNER JOIN layer_two t1 ON t.flow_card_id = t1.flow_card_id |
| | | AND t.virtual_slot = t1.virtual_slot |
| | | AND t.sequence = t1.sequence |
| | | 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 |
| | | <if test="totalLayer == 3"> |
| | | inner join layer_three t2 |
| | | on t.flow_card_id = t2.flow_card_id and |
| | | t.virtual_slot = t2.virtual_slot and t.sequence = t2.sequence |
| | | 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 |
| | | </if> |
| | | GROUP BY |
| | | t.flow_card_id |
| | | ), |
| | | result_flow_layer_count AS ( |
| | | WHERE t1.flow_card_id = #{flowCardId} |
| | | GROUP BY t1.flow_card_id |
| | | ) |
| | | SELECT |
| | | t.flow_card_id, |
| | | t.layer, |
| | | t.films_id, |
| | | t.thickness, |
| | | sum_count, |
| | | IFNULL( t3.pair_count, 0 ) AS pair_count, |
| | | IFNULL( real_count, 0 ) AS real_count, |
| | | IFNULL( damage_count, 0 ) AS damage_count, |
| | | IFNULL( lack_count, 0 ) AS lack_count, |
| | | IFNULL(slot_count,0) AS slot_count |
| | | FROM |
| | | sum_flow_layer_count t |
| | | LEFT JOIN real_flow_layer_count t1 ON t.flow_card_id = t1.flow_card_id |
| | | AND t.layer = t1.layer |
| | | LEFT JOIN lack_flow_layer_count t2 ON t.flow_card_id = t2.flow_card_id |
| | | AND t.layer = t2.layer |
| | | LEFT JOIN pair_flow_layer_count t3 ON t.flow_card_id = t3.flow_card_id |
| | | LEFT JOIN damage_flow_layer_count t4 ON t.flow_card_id = t4.flow_card_id |
| | | AND t.layer = t4.layer |
| | | ) SELECT |
| | | * |
| | | FROM |
| | | result_flow_layer_count |
| | | WHERE |
| | | flow_card_id = #{flowCardId} |
| | | 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 |
| | | <if test="flag == true"> |
| | | and sum_count = pair_count |
| | | AND f.sum_count = COALESCE(p.pair_count, 0) |
| | | </if> |
| | | order by layer |
| | | ORDER BY f.layer; |
| | | </select> |
| | | |
| | | <select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO"> |
| | |
| | | <select id="queryHollowbigStorageCageDetail" resultType="com.mes.base.entity.vo.BigStorageVO"> |
| | | 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) |
| | | 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> |
| | |
| | | where state in (100, 102, 103, 104) |
| | | group by flow_card_id, layer |
| | | </select> |
| | | |
| | | <select id="queryHollowAllFlowCard" resultType="com.mes.hollow.entity.dto.FlowCardGlassInfoDTO"> |
| | | WITH hollow_flow_temp AS ( |
| | | SELECT DISTINCT |
| | | flow_card_id |
| | | FROM |
| | | hollow_big_storage_cage_details |
| | | WHERE |
| | | state = 100 |
| | | <if test="flowCardId != null and flowCardId != ''"> |
| | | AND flow_card_id LIKE CONCAT( |
| | | '%',#{flowCardId}, '%') |
| | | </if> |
| | | <if test="filmsId != null and filmsId != ''"> |
| | | AND films_id LIKE CONCAT( '%', #{filmsId}, '%') |
| | | </if> |
| | | <if test="thickness != 0"> |
| | | AND thickness = #{thickness} |
| | | </if> |
| | | ), |
| | | hollow_details_temp AS ( |
| | | SELECT |
| | | flow_card_id, |
| | | glass_id, |
| | | virtual_slot, |
| | | sequence, |
| | | layer, |
| | | total_layer, |
| | | hollow_sequence |
| | | FROM |
| | | hollow_big_storage_cage_details |
| | | WHERE |
| | | state = 100 |
| | | <if test="flowCardId != null and flowCardId != ''"> |
| | | AND flow_card_id LIKE CONCAT( |
| | | '%',#{flowCardId}, '%') |
| | | </if> |
| | | <if test="filmsId != null and filmsId != ''"> |
| | | AND films_id LIKE CONCAT( '%', #{filmsId}, '%') |
| | | </if> |
| | | <if test="thickness != 0"> |
| | | AND thickness = #{thickness} |
| | | </if> |
| | | ), |
| | | hollow_through_temp AS ( SELECT flow_card_id, MIN( hollow_sequence ) AS hollow_sequence, MAX( total_layer ) AS |
| | | total_layer FROM hollow_details_temp GROUP BY flow_card_id ), |
| | | hollow_pair_temp AS ( |
| | | SELECT |
| | | t1.flow_card_id, |
| | | COUNT(*) AS pair_count |
| | | FROM |
| | | hollow_details_temp t1 |
| | | INNER JOIN hollow_details_temp 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 |
| | | WHERE |
| | | NOT EXISTS ( SELECT 1 FROM hollow_through_temp ht WHERE ht.flow_card_id = t1.flow_card_id AND ht.total_layer = 3 |
| | | ) |
| | | OR EXISTS ( |
| | | SELECT |
| | | 1 |
| | | FROM |
| | | hollow_details_temp t3 |
| | | WHERE |
| | | t3.flow_card_id = t1.flow_card_id |
| | | AND t3.virtual_slot = t1.virtual_slot |
| | | AND t3.sequence = t1.sequence |
| | | AND t3.layer = 3 |
| | | ) |
| | | GROUP BY |
| | | t1.flow_card_id |
| | | ), |
| | | glass_info_temp AS ( |
| | | SELECT |
| | | gi.id, |
| | | gi.glass_id, |
| | | gi.flow_card_id, |
| | | gi.layer, |
| | | gi.thickness, |
| | | gi.filmsId |
| | | FROM |
| | | hollow_flow_temp hft |
| | | INNER JOIN glass_info gi ON hft.flow_card_id = gi.flow_card_id |
| | | ), |
| | | glass_engineer_temp AS ( |
| | | SELECT |
| | | distinct flow_card_id, |
| | | engineer_id |
| | | FROM |
| | | ( |
| | | SELECT |
| | | gi.flow_card_id, |
| | | gi.engineer_id, |
| | | ROW_NUMBER() OVER ( PARTITION BY gi.flow_card_id, gi.layer ORDER BY COUNT( gi.glass_id ) DESC ) AS rn |
| | | FROM |
| | | hollow_flow_temp hft |
| | | INNER JOIN glass_info gi ON hft.flow_card_id = gi.flow_card_id |
| | | GROUP BY |
| | | gi.flow_card_id, |
| | | gi.layer, |
| | | gi.engineer_id |
| | | ) t |
| | | WHERE |
| | | rn = 1 |
| | | ), |
| | | glass_result AS ( |
| | | SELECT |
| | | count( t1.id ) AS sum_count, |
| | | t1.flow_card_id, |
| | | t1.layer |
| | | FROM |
| | | glass_engineer_temp t |
| | | INNER JOIN glass_info t1 ON t.engineer_id = t1.engineer_id |
| | | AND t.flow_card_id = t1.flow_card_id |
| | | GROUP BY |
| | | t1.flow_card_id, |
| | | t1.layer |
| | | ), |
| | | damage_ranked AS ( |
| | | SELECT |
| | | d.glass_id, |
| | | d.type, |
| | | d.STATUS, |
| | | ROW_NUMBER() OVER ( PARTITION BY d.glass_id ORDER BY d.id DESC ) AS rn |
| | | FROM |
| | | hollow_flow_temp hft |
| | | INNER JOIN damage d ON hft.flow_card_id = d.process_id |
| | | ), |
| | | damage_latest AS ( SELECT glass_id, type, STATUS FROM damage_ranked WHERE rn = 1 ), |
| | | result_temp AS ( |
| | | SELECT |
| | | t.flow_card_id, |
| | | t.layer, |
| | | t.thickness, |
| | | t.filmsId, |
| | | COUNT( DISTINCT t1.glass_id ) AS real_count, |
| | | COUNT( DISTINCT CASE WHEN t2.type IN ( 7, 8 ) AND t2.STATUS = 1 THEN t.glass_id END ) AS damage_count |
| | | FROM |
| | | glass_info_temp t |
| | | LEFT JOIN hollow_details_temp t1 ON t.glass_id = t1.glass_id |
| | | LEFT JOIN damage_latest t2 ON t.glass_id = t2.glass_id |
| | | GROUP BY |
| | | t.flow_card_id, |
| | | t.layer, |
| | | t.thickness, |
| | | t.filmsId |
| | | ) SELECT |
| | | t.*, |
| | | t3.sum_count, |
| | | t3.sum_count - t.real_count AS lack_count, |
| | | COALESCE ( t1.pair_count, 0 ) AS pair_count, |
| | | t2.hollow_sequence, |
| | | t2.total_layer |
| | | FROM |
| | | result_temp t |
| | | LEFT JOIN hollow_pair_temp t1 ON t.flow_card_id = t1.flow_card_id |
| | | LEFT JOIN hollow_through_temp t2 ON t.flow_card_id = t2.flow_card_id |
| | | LEFT JOIN glass_result t3 ON t.flow_card_id = t3.flow_card_id |
| | | AND t.layer = t3.layer |
| | | ORDER BY |
| | | t.flow_card_id |
| | | </select> |
| | | <select id="queryVerticalSheetCageDetailsList" |
| | | resultType="com.mes.hollow.entity.vo.HollowBigCageDetailsVO"> |
| | | SELECT t.id,t.device_id,t.slot,t.remain_width ,t.enable_state,t1.virtual_slot,total_layer,t1.engineer_id, |
| | | t1.id as detail_id,t1.device_id as detail_device_id ,t1.slot as |
| | | detail_slot,t1.engineer_id,t1.glass_id,t1.tempering_layout_id,t1.tempering_feed_sequence, |
| | | t1.flow_card_id,t1.layer,t1.width,t1.height,t1.thickness,t1.films_id |
| | | FROM hollow_big_storage_cage t |
| | | left join hollow_big_storage_cage_details t1 on t.slot = t1.slot |
| | | and t1.state in (100, 102, 103, 104) |
| | | <if test="filmsId != null and filmsId != ''"> |
| | | and t1.films_id like CONCAT('%', #{filmsId}, '%') |
| | | </if> |
| | | <if test="flowCardId != null and flowCardId != ''"> |
| | | and t1.flow_card_id like CONCAT('%', #{flowCardId}, '%') |
| | | </if> |
| | | <if test="engineerId != null and engineerId != ''"> |
| | | and t1.engineer_id like CONCAT('%', #{engineerId}, '%') |
| | | </if> |
| | | <if test="glassId != null and glassId != ''"> |
| | | and t1.glass_id like CONCAT('%', #{glassId}, '%') |
| | | </if> |
| | | <if test="thickness != -1"> |
| | | and t1.thickness = #{thickness} |
| | | </if> |
| | | order by t.slot |
| | | </select> |
| | | |
| | | |
| | | </mapper> |