zhoushihao
2025-10-11 4b1d2b9c80eb4a914121aa1566e22249a6a24a0c
hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowGlassRelationInfoMapper.xml
@@ -139,18 +139,18 @@
                 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
@@ -164,6 +164,37 @@
        from hollow_glass_relation_info
        where flow_card_id = #{flowCardId}
    </select>
    <select id="queryProductNameByFlowCardId" resultType="com.mes.hollow.entity.dto.OrderDetailsDTO">
        select t.product_name, t1.customer_name
        from sd.order_detail t
        inner join sd.order t1 on t.order_id = t1.order_id
        where (t.order_id, t.order_number) = (
        select min(order_id) as order_id, min(order_number) as order_number
        from pp.flow_card
        where process_id = #{flowCardId}
        <if test="productName != null and productName != ''">
            and t.product_name like concat('%', #{productName}, '%')
        </if>
        <if test="customerName != null and customerName != ''">
            and t1.customer_name like concat('%', #{customerName}, '%')
        </if>
        )
        limit 1
    </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 &lt; 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