<?xml version="1.0" encoding="UTF-8" ?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<mapper namespace="com.mes.hollow.mapper.HollowBigStorageCageDetailsMapper">
|
|
<resultMap id="baseMap" type="com.mes.hollow.entity.dto.FlowCardGlassInfoDTO">
|
<result column="engineer_id" property="engineerId"/>
|
<result column="flow_card_id" property="flowCardId"/>
|
<result column="layer" property="layer"/>
|
<result column="films_id" property="filmsId"/>
|
<result column="thickness" property="thickness"/>
|
<result column="sum_count" property="sumCount"/>
|
<result column="pair_count" property="pairCount"/>
|
<result column="real_count" property="realCount"/>
|
<result column="damage_count" property="damageCount"/>
|
<result column="lack_count" property="lackCount"/>
|
</resultMap>
|
<resultMap id="virtualSlotSequenceDTO" type="com.mes.hollow.entity.dto.FlowCardVirtualSlotDTO">
|
<result column="flow_card_id" property="flowCardId"/>
|
<result column="layer" property="layer"/>
|
<result column="virtual_slot" property="virtualSlot"/>
|
</resultMap>
|
<resultMap id="baseSlotSequenceDTO" type="com.mes.hollow.entity.dto.BigStorageSequenceDTO">
|
<result column="slot" property="slot"/>
|
<result column="max_sequence" property="maxSequence"/>
|
<result column="min_sequence" property="minSequence"/>
|
</resultMap>
|
|
<update id="updateBySlot">
|
update hollow_big_storage_cage_details
|
<set>
|
state = #{state}
|
</set>
|
<where>
|
(glass_id,slot) in (
|
<foreach collection="list" item="item" separator=",">
|
(#{item.glassId}, #{item.targetSlot})
|
</foreach>
|
)
|
and state !=101
|
</where>
|
</update>
|
<update id="updateDeviceIdBySlot">
|
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 (
|
<foreach collection="list" item="item" separator=",">
|
#{item}
|
</foreach>
|
)
|
</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 (
|
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
|
),
|
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 (
|
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
|
<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
|
</if>
|
GROUP BY
|
t.flow_card_id
|
),
|
result_flow_layer_count AS (
|
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}
|
<if test="flag == true">
|
and sum_count = pair_count
|
</if>
|
</select>
|
|
<select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO">
|
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>
|
|
<select id="queryNeedDispatchSlot" resultMap="baseSlotSequenceDTO">
|
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
|
</select>
|
<select id="queryOutGlassList" resultType="com.mes.hollow.entity.HollowBigStorageCageDetails">
|
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
|
<if test="cell != 931">
|
desc
|
</if>
|
</select>
|
<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)
|
group by hbsc.device_id, hbsc.slot
|
order by hbsc.device_id, hbsc.slot
|
</select>
|
<select id="querySlotMaxSequence" resultType="com.mes.hollow.entity.HollowBigStorageCageDetails">
|
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
|
</select>
|
<select id="queryPairGlassList" resultType="com.mes.hollow.entity.HollowBigStorageCageDetails">
|
with hollow_sequence_temp as (
|
SELECT hollow_sequence, count(distinct layer) as count
|
FROM hollow_big_storage_cage_details
|
WHERE flow_card_id = #{flowCardId}
|
<if test="isOut == 0">
|
AND STATE = 100
|
</if>
|
|
GROUP BY hollow_sequence
|
having count = #{totalLayer}
|
limit #{totalPairQuantity}
|
),
|
hollow_details as (select *
|
from hollow_big_storage_cage_details
|
WHERE flow_card_id = #{flowCardId}
|
<if test="isOut == 0">
|
AND STATE = 100
|
</if>
|
)
|
select *
|
from hollow_details t
|
inner join hollow_sequence_temp t1 on t.hollow_sequence = t1.hollow_sequence
|
ORDER BY t.hollow_sequence
|
</select>
|
</mapper>
|