From 261698358e2b756a61e992bc1651e01b3f45290b Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 23 十月 2025 16:50:27 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml | 244 ++++++++++++++++++++++++------------------------
1 files changed, 124 insertions(+), 120 deletions(-)
diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml
index afee4ad..bdb9005 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml
@@ -5,138 +5,139 @@
<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="glass_type" property="glassType"/>
+ <result column="filmsid" property="filmsId"/>
+ <result column="width" property="width"/>
+ <result column="height" property="height"/>
<result column="thickness" property="thickness"/>
<result column="lack_count" property="lackCount"/>
<result column="damage_count" property="damageCount"/>
</resultMap>
+ <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 (8, 9) 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 damage_latest
- <select id="queryLackByFlowCard" resultMap="lackBaseMap">
- <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="queryAllLackByFlowCard" resultMap="lackBaseMap">
- with flow_card_id_info as (
- select distinct flow_card_id from hollow_big_storage_cage_details where state = 100
+ 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
+ glass_temp AS (
+ SELECT t.*
+ FROM glass_info t
+ INNER JOIN flow_card_id_info t1 ON t.flow_card_id = t1.flow_card_id
),
- 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
+ detail_temp AS (
+ SELECT t.*
+ FROM glass_temp t
+ 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)
+ )
),
- 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
+ damage_latest AS (
+ 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
+ FROM detail_temp t
+ INNER JOIN damage t1 ON t.flow_card_id = t1.process_id
+ ) dr
+ WHERE dr.rn = 1
),
- 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
+ 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
+ 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
)
- select *
- from result_count
+ SELECT *
+ FROM result_temp
+ ORDER BY flow_card_id, layer;
</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>
- <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
+ 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 (
@@ -149,9 +150,9 @@
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
+ when type in (8, 9) 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
)
@@ -162,18 +163,21 @@
)
select *
from damage_latest
-
</select>
+
<update id="clearDirtyFlowCardData">
- update tempering_glass_relation_info
- set shelf_order = null
- , state = 0
+ update hollow_glass_relation_info
+ set glass_id = null,
+ tempering_layout_id = null,
+ tempering_feed_sequence = null,
+ engineer_id = null,
+ state = 0
where flow_card_id = #{flowCardId}
and layer = #{layer}
- and shelf_order not in (
- select shelf_order
- from vertical_sheet_cage_details
+ and glass_id not in (
+ select glass_id
+ from hollow_big_storage_cage_details
where flow_card_id = #{flowCardId}
and layer = #{layer}
and state in (100, 102, 103, 104)
--
Gitblit v1.8.0