| | |
| | | <!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="baseMap" type="com.mes.hollow.entity.dto.HollowGlassDetailsDTO"> |
| | | <result column="process_id" property="flowCardId"/> |
| | | <result column="child_width" property="width"/> |
| | | <result column="child_height" property="height"/> |
| | | <result column="order_number" property="orderSort"/> |
| | | <result column="technology_number" property="layer"/> |
| | | <result column="quantity" property="quantity"/> |
| | | </resultMap> |
| | | <resultMap id="lackBaseMap" type="com.mes.hollow.entity.dto.LackDetailsDTO"> |
| | | <result column="flow_card_id" property="flowCardId"/> |
| | | <result column="layer" property="layer"/> |
| | |
| | | <result column="lack_count" property="lackCount"/> |
| | | <result column="damage_count" property="damageCount"/> |
| | | </resultMap> |
| | | |
| | | <select id="queryFlowCardIdMaxLayerGlassInfo" resultMap="baseMap"> |
| | | with temp_flow as (SELECT t.process_id, |
| | | t.order_id, |
| | | t.order_number, |
| | | t.technology_number, |
| | | t.quantity, |
| | | t1.child_width, |
| | | t1.child_height |
| | | |
| | | from pp.flow_card t |
| | | LEFT JOIN sd.order_glass_detail t1 |
| | | on t.order_id = t1.order_id |
| | | and t.order_number = t1.order_number |
| | | and t.technology_number = t1.technology_number |
| | | where t.process_id = #{flowCardId}), |
| | | glass_info_temp as ( |
| | | select process_id, |
| | | order_id, |
| | | GREATEST(child_width, child_height) as first_length, |
| | | least(child_width, child_height) as second_length, |
| | | child_width, |
| | | child_height, |
| | | order_number, |
| | | technology_number, |
| | | quantity |
| | | from temp_flow |
| | | where technology_number = #{totalLayer} |
| | | ) |
| | | select row_number() over (order by second_length desc,first_length desc) as rn, t.* |
| | | from glass_info_temp t |
| | | </select> |
| | | |
| | | <select id="queryFlowCardIdLayerGlassInfo" resultMap="baseMap"> |
| | | with temp_flow as (SELECT t.process_id, |
| | | t.order_id, |
| | | t.order_number, |
| | | t.technology_number, |
| | | t.quantity, |
| | | t1.child_width, |
| | | t1.child_height |
| | | from pp.flow_card t |
| | | LEFT JOIN sd.order_glass_detail t1 |
| | | on t.order_id = t1.order_id |
| | | and t.order_number = t1.order_number |
| | | and t.technology_number = t1.technology_number |
| | | where t.process_id = #{flowCardId}), |
| | | glass_info_max_layer_temp as ( |
| | | select process_id, |
| | | order_id, |
| | | GREATEST(child_width, child_height) as first_length, |
| | | least(child_width, child_height) as second_length, |
| | | child_width, |
| | | child_height, |
| | | order_number, |
| | | technology_number, |
| | | quantity |
| | | from temp_flow |
| | | where technology_number = #{totalLayer} |
| | | ), |
| | | glass_info_layer_temp as ( |
| | | select process_id, |
| | | order_id, |
| | | GREATEST(child_width, child_height) as first_length, |
| | | least(child_width, child_height) as second_length, |
| | | child_width, |
| | | child_height, |
| | | order_number, |
| | | technology_number, |
| | | quantity |
| | | from temp_flow |
| | | where technology_number = #{layer} |
| | | ), |
| | | max_layer_sequence as ( |
| | | select row_number() over (order by second_length desc,first_length desc) as rn, t.order_number |
| | | from glass_info_max_layer_temp t |
| | | ), |
| | | result as (select t.* |
| | | from glass_info_layer_temp t |
| | | INNER join max_layer_sequence t1 on t.order_number = t1.order_number |
| | | order by t1.rn) |
| | | <select id="queryLackByFlowCard" resultType="com.mes.hollow.entity.dto.LackDetailsDTO"> |
| | | 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 = #{flowCardId} |
| | | </if> |
| | | ) |
| | | , glass_temp as ( |
| | | select t1.* |
| | | from hollow_flow_temp t |
| | | INNER JOIN glass_info t1 on t.flow_card_id = t1.flow_card_id |
| | | ) |
| | | , detail_temp as ( |
| | | select t.* |
| | | from glass_temp t |
| | | left join hollow_big_storage_cage_details t1 on t.glass_id = t1.glass_id |
| | | where t1.glass_id is null |
| | | ) |
| | | , damage_ranked AS ( |
| | | SELECT t.flow_card_id, |
| | | t.layer, |
| | | t.glass_id, |
| | | t.glass_type, |
| | | t.width, |
| | | t.height, |
| | | t.filmsId, |
| | | t.thickness, |
| | | case |
| | | when type in (7, 8) and status = 1 then '' |
| | | else t1.working_procedure end as working_procedure, |
| | | 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.glass_id = t1.glass_id |
| | | ) |
| | | , damage_latest AS ( |
| | | SELECT * |
| | | FROM damage_ranked |
| | | WHERE rn = 1 |
| | | ) |
| | | select * |
| | | from result |
| | | from damage_latest |
| | | |
| | | </select> |
| | | <select id="queryAllLackByFlowCard" resultMap="lackBaseMap"> |
| | | with flow_card_id_info as ( |
| | |
| | | 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(1) as damage_count |
| | | 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) |
| | | and type in (8, 9) |
| | | and status < 3 |
| | | group by process_id, technology_number, order_number |
| | | ), |
| | | result_count as ( |
| | | select t.*, IFNULL(t1.damage_count, 0) damage_count |
| | | 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 |
| | |
| | | from hollow_glass_relation_info |
| | | where flow_card_id = #{flowCardId} |
| | | </select> |
| | | <select id="queryLackByFlowCard" resultType="com.mes.hollow.entity.dto.LackDetailsDTO"> |
| | | 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 = #{flowCardId} |
| | | </if> |
| | | ) |
| | | , glass_temp as ( |
| | | select t1.* |
| | | from hollow_flow_temp t |
| | | INNER JOIN glass_info t1 on t.flow_card_id = t1.flow_card_id |
| | | <select id="queryLackGlassByFlowCard" resultType="com.mes.hollow.entity.dto.LackDetailsDTO"> |
| | | with glass_temp as ( |
| | | select * |
| | | from glass_info |
| | | where flow_card_id = #{flowCardId} |
| | | and glass_type = #{orderSort} |
| | | and layer = #{layer} |
| | | ) |
| | | , detail_temp as ( |
| | | select t.* |
| | | from glass_temp t |
| | | left join hollow_big_storage_cage_details t1 on t.glass_id = t1.glass_id |
| | | where t1.glass_id is null |
| | | 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 t.flow_card_id, |
| | |
| | | t.thickness, |
| | | case |
| | | when type in (7, 8) and status = 1 then '' |
| | | else t1.working_procedure end as working_procedure, |
| | | ROW_NUMBER() OVER (PARTITION BY t1.glass_id ORDER BY t1.id DESC) as rn |
| | | else t1.working_procedure end as working_procedure, |
| | | 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.glass_id = t1.glass_id |
| | | ) |
| | |
| | | ) |
| | | select * |
| | | from damage_latest |
| | | |
| | | </select> |
| | | |
| | | |
| | | <update id="clearDirtyFlowCardData"> |
| | | update tempering_glass_relation_info |
| | | set shelf_order = null |