<?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.HollowGlassRelationInfoMapper">
|
|
<resultMap id="lackBaseMap" type="com.mes.hollow.entity.dto.LackDetailsDTO">
|
<result column="flow_card_id" property="flowCardId"/>
|
<result column="layer" property="layer"/>
|
<result column="order_sort" property="glassType"/>
|
<result column="films_id" property="filmsId"/>
|
<result column="first_length" property="width"/>
|
<result column="second_Length" property="height"/>
|
<result column="thickness" property="thickness"/>
|
<result column="lack_count" property="lackCount"/>
|
<result column="damage_count" property="damageCount"/>
|
</resultMap>
|
|
<select id="queryLackByFlowCard" resultMap="lackBaseMap">
|
with flow_card_id_info as (
|
select distinct flow_card_id from hollow_big_storage_cage_details where state = 100
|
),
|
relation_length as (
|
select flow_card_id,
|
layer,
|
order_sort,
|
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 in (select flow_card_id from flow_card_id_info)
|
and tempering_layout_id is null
|
and tempering_feed_sequence is null
|
),
|
lack_count_temp as (
|
select flow_card_id,
|
layer,
|
order_sort,
|
first_length,
|
films_id,
|
second_Length,
|
thickness,
|
count(*) as lack_count
|
from relation_length
|
group by flow_card_id, layer, order_sort, films_id, first_length, second_Length, thickness
|
),
|
damage_count_temp as (
|
select process_id as flow_card_id,
|
technology_number as layer,
|
order_number as order_sort,
|
count(distinct
|
case when type = 8 and status < 3 then glass_id else null end) as damage_count,
|
count(distinct case when type = 8 and status >= 3 then glass_id else null end) as patch_count
|
from damage
|
where process_id in (select flow_card_id from flow_card_id_info)
|
group by process_id, technology_number, order_number
|
),
|
result_count as (
|
select t.*, IFNULL(t1.damage_count, 0) damage_count, IFNULL(t1.patch_count, 0) patch_count
|
from lack_count_temp t
|
left join damage_count_temp t1 on t.flow_card_id = t1.flow_card_id and t.layer = t1.layer and
|
t.order_sort = t1.order_sort
|
order by t.flow_card_id, t.layer
|
)
|
select *
|
from result_count
|
</select>
|
<select id="queryLayerByFlowCardId" resultType="java.lang.Integer">
|
select count(distinct layer)
|
from hollow_glass_relation_info
|
where flow_card_id = #{flowCardId}
|
</select>
|
<select id="queryLackGlassByFlowCard" resultType="com.mes.glassinfo.entity.GlassInfo">
|
with glass_id_info as (
|
select glass_id,order_sort from hollow_glass_relation_info where flow_card_id=#{flowCardId} and
|
order_sort=#{orderSort} and layer=#{layer} and glass_id is not null
|
),
|
damage_glass_id as (
|
select glass_id from damage where process_id=#{flowCardId} and order_number=#{orderSort} and
|
technology_number=#{layer} and type=8 and status < 3 and glass_id is not null
|
)
|
select t.* from glass_info t left join glass_id_info t1 on t.glass_id=t1.glass_id
|
left join damage_glass_id t2 on t.glass_id=t2.glass_id
|
where t.flow_card_id=#{flowCardId} and t.glass_type=#{orderSort} and t.layer=#{layer} and t1.glass_id is null
|
and t2.glass_id is null
|
</select>
|
|
<update id="clearDirtyFlowCardData">
|
update tempering_glass_relation_info
|
set shelf_order = null
|
, state = 0
|
where flow_card_id = #{flowCardId}
|
and layer = #{layer}
|
and shelf_order not in (
|
select shelf_order
|
from vertical_sheet_cage_details
|
where flow_card_id = #{flowCardId}
|
and layer = #{layer}
|
and state in (100, 102, 103, 104)
|
)
|
</update>
|
</mapper>
|