| | |
| | | detail_temp AS ( |
| | | SELECT t.* |
| | | FROM glass_temp t |
| | | WHERE NOT EXISTS ( |
| | | WHERE NOT EXISTS( |
| | | SELECT 1 |
| | | FROM hollow_big_storage_cage_details t1 |
| | | WHERE t1.glass_id = t.glass_id |
| | | AND t1.state NOT IN (8,9) |
| | | AND t1.state NOT IN (8, 9) |
| | | ) |
| | | ), |
| | | damage_latest AS ( |
| | | SELECT |
| | | dr.glass_id, |
| | | dr.type, |
| | | dr.status |
| | | SELECT dr.glass_id, |
| | | dr.type, |
| | | dr.status |
| | | FROM ( |
| | | SELECT |
| | | t1.glass_id, |
| | | t1.type, |
| | | t1.status, |
| | | ROW_NUMBER() OVER(PARTITION BY t1.glass_id ORDER BY t1.id DESC) as rn |
| | | SELECT t1.glass_id, |
| | | t1.type, |
| | | t1.status, |
| | | ROW_NUMBER() OVER(PARTITION BY t1.glass_id ORDER BY t1.id DESC) as rn |
| | | FROM detail_temp t |
| | | INNER JOIN damage t1 ON t.flow_card_id = t1.process_id |
| | | ) dr |
| | | WHERE dr.rn = 1 |
| | | ), |
| | | result_temp AS ( |
| | | SELECT |
| | | t.flow_card_id, |
| | | t.layer, |
| | | t.glass_type, |
| | | t.thickness, |
| | | t.filmsId, |
| | | t.width, |
| | | t.height, |
| | | COUNT(DISTINCT t.glass_id) as lack_count, |
| | | COUNT(DISTINCT CASE WHEN t1.type IN (8,9) AND t1.status = 1 THEN t.glass_id END) as damage_count |
| | | SELECT t.flow_card_id, |
| | | t.layer, |
| | | t.glass_type, |
| | | t.thickness, |
| | | t.filmsId, |
| | | t.width, |
| | | t.height, |
| | | COUNT(DISTINCT t.glass_id) as lack_count, |
| | | COUNT(DISTINCT |
| | | CASE WHEN t1.type IN (8, 9) AND t1.status = 1 THEN t.glass_id END) as damage_count |
| | | FROM detail_temp t |
| | | LEFT JOIN damage_latest t1 ON t.glass_id = t1.glass_id |
| | | GROUP BY |
| | | t.flow_card_id, |
| | | t.layer, |
| | | t.glass_type, |
| | | t.thickness, |
| | | t.filmsId, |
| | | t.width, |
| | | t.height |
| | | GROUP BY t.flow_card_id, |
| | | t.layer, |
| | | t.glass_type, |
| | | t.thickness, |
| | | t.filmsId, |
| | | t.width, |
| | | t.height |
| | | ) |
| | | SELECT * |
| | | FROM result_temp |
| | |
| | | , detail_temp as ( |
| | | select t.* |
| | | from glass_temp t |
| | | left join hollow_big_storage_cage_details t1 on t.glass_id = t1.glass_id and t1.state not in (8,9) |
| | | left join hollow_big_storage_cage_details t1 on t.glass_id = t1.glass_id and t1.state not in (8, 9) |
| | | where t1.glass_id is null |
| | | ) |
| | | , damage_ranked AS ( |
| | |
| | | select * |
| | | from damage_latest |
| | | </select> |
| | | <select id="queryLackByFlowCardByERP" resultType="com.mes.hollow.entity.dto.LackDetailsDTO"> |
| | | WITH RECURSIVE nums(n) AS ( |
| | | SELECT 1 |
| | | UNION ALL |
| | | SELECT n + 1 FROM nums WHERE n < (SELECT MAX(quantity) FROM ( |
| | | <foreach collection="flowCardIdList" item="item" separator="UNION ALL"> |
| | | SELECT #{item.lackQuantity} AS quantity |
| | | </foreach> |
| | | ) t) |
| | | ) |
| | | <foreach collection="flowCardIdList" item="item" separator="UNION ALL"> |
| | | SELECT t1.* |
| | | FROM ( |
| | | SELECT |
| | | g.flow_card_id AS flowCardId, |
| | | g.layer AS layer, |
| | | g.glass_type AS glassType, |
| | | g.filmsid AS filmsId, |
| | | g.width AS width, |
| | | g.height AS height, |
| | | g.thickness AS thickness |
| | | FROM glass_info g |
| | | WHERE g.flow_card_id = #{item.processId} |
| | | AND g.layer = #{item.technologyNumber} |
| | | AND g.glass_type = #{item.orderNumber} |
| | | LIMIT 1 |
| | | ) t1 |
| | | CROSS JOIN nums |
| | | WHERE nums.n <= #{item.lackQuantity} |
| | | </foreach> |
| | | </select> |
| | | |
| | | |
| | | <update id="clearDirtyFlowCardData"> |