Browse Source

2026-04-08

BOM的Multi Level Structure页签调整
master
fengyuan_yang 1 week ago
parent
commit
3036896124
  1. 4
      src/main/java/com/spring/modules/part/entity/BomMultiLevelStructureData.java
  2. 145
      src/main/resources/mapper/part/BomManagementMapper.xml

4
src/main/java/com/spring/modules/part/entity/BomMultiLevelStructureData.java

@ -8,6 +8,10 @@ import java.math.BigDecimal;
@Data @Data
public class BomMultiLevelStructureData { public class BomMultiLevelStructureData {
/**
* 结构层级根下第一层为 1对应 IFS MANUF_STRUCTURE.LEVEL
**/
private Integer structureLevel;
/** /**
* 工厂 * 工厂
**/ **/

145
src/main/resources/mapper/part/BomManagementMapper.xml

@ -877,34 +877,127 @@
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and by_prod_line_item_no = #{byProdLineItemNo} and component_line_item_no = #{componentLineItemNo} where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and by_prod_line_item_no = #{byProdLineItemNo} and component_line_item_no = #{componentLineItemNo}
</update> </update>
<!-- 查bom子明细 -->
<!-- 多层级 BOM 展开:IFS CONNECT BY 语义;子装配解析在 DefaultChildBom(非递归)中完成。递归成员仅 INNER JOIN,避免 SQL Server 对递归 CTE 的限制(禁止派生表/子查询/外连接/OPTION)。 -->
<select id="queryBomMultiLevelStructureList" parameterType="BomDetailEntity" resultType="BomMultiLevelStructureData"> <select id="queryBomMultiLevelStructureList" parameterType="BomDetailEntity" resultType="BomMultiLevelStructureData">
WITH DefaultChildBom AS (
SELECT pick.site, pick.part_no, pick.bom_type, pick.eng_chg_level, pick.alternative_no
FROM (
SELECT bd.site,
bd.part_no,
bd.bom_type,
bd.eng_chg_level,
bd.alternative_no,
ROW_NUMBER() OVER (
PARTITION BY bd.site, bd.part_no, bd.bom_type
ORDER BY bh.eff_phase_in_date DESC, bh.create_date DESC
) AS rn
FROM plm_bom_detail bd
INNER JOIN plm_bom_header bh ON bd.site = bh.site AND bd.part_no = bh.part_no
AND bd.bom_type = bh.bom_type AND bd.eng_chg_level = bh.eng_chg_level
INNER JOIN part_revision pr ON pr.site = bh.site AND pr.part_no = bh.part_no AND pr.eng_chg_level = bh.eng_chg_level
WHERE bd.alternative_no = '*'
AND pr.eff_phase_out_date IS NULL
AND ISNULL(bd.status, '') <![CDATA[<>]]> 'Obsolete'
) pick
WHERE pick.rn = 1
),
ExplodedBom AS (
SELECT
1 AS structure_level,
CAST(RIGHT(REPLICATE('0', 8) + CAST(a.line_sequence AS VARCHAR(8)), 8) AS VARCHAR(8000)) AS sort_key,
a.site,
a.part_no,
dbo.get_part_name(a.site, a.part_no) AS partDesc,
a.bom_type,
a.eng_chg_level,
a.alternative_no,
b.alternative_description,
a.component_part,
dbo.get_part_name(a.site, a.component_part) AS componentPartDesc,
a.qty_per_assembly,
a.print_unit,
dbo.get_um_name(a.print_unit) AS printUnitName,
c.product_group_id4,
dbo.get_product_group_name(c.site, c.product_group_id4, '4') AS productGroupName4,
c.min_order_qty,
c.mul_order_qty,
c.planning_method,
c.cum_lead_time,
c.unprotected_lead_time,
dbo.get_cum_lead_time(a.site, a.component_part) AS componentCumLeadTime,
dbo.get_unprotected_lead_time(a.site, a.component_part) AS componentUnprotectedLeadTime
FROM plm_bom_component AS a
LEFT JOIN plm_bom_detail AS b ON a.site = b.site AND a.part_no = b.part_no AND a.bom_type = b.bom_type
AND a.eng_chg_level = b.eng_chg_level AND a.alternative_no = b.alternative_no
LEFT JOIN part AS c ON a.site = c.site AND a.part_no = c.part_no
WHERE a.site = #{site}
AND a.part_no = #{partNo}
AND a.bom_type = #{bomType}
AND a.eng_chg_level = #{engChgLevel}
AND a.alternative_no = #{alternativeNo}
AND a.qty_per_assembly &gt;= 0
UNION ALL
SELECT
p.structure_level + 1,
CAST(p.sort_key + '.' + RIGHT(REPLICATE('0', 8) + CAST(a.line_sequence AS VARCHAR(8)), 8) AS VARCHAR(8000)),
a.site,
a.part_no,
dbo.get_part_name(a.site, a.part_no) AS partDesc,
a.bom_type,
a.eng_chg_level,
a.alternative_no,
b.alternative_description,
a.component_part,
dbo.get_part_name(a.site, a.component_part) AS componentPartDesc,
a.qty_per_assembly,
a.print_unit,
dbo.get_um_name(a.print_unit) AS printUnitName,
c.product_group_id4,
dbo.get_product_group_name(c.site, c.product_group_id4, '4') AS productGroupName4,
c.min_order_qty,
c.mul_order_qty,
c.planning_method,
c.cum_lead_time,
c.unprotected_lead_time,
dbo.get_cum_lead_time(a.site, a.component_part) AS componentCumLeadTime,
dbo.get_unprotected_lead_time(a.site, a.component_part) AS componentUnprotectedLeadTime
FROM ExplodedBom AS p
INNER JOIN DefaultChildBom AS cb ON cb.site = p.site AND cb.part_no = p.component_part AND cb.bom_type = p.bom_type
INNER JOIN plm_bom_component AS a ON a.site = cb.site AND a.part_no = cb.part_no
AND a.bom_type = cb.bom_type AND a.eng_chg_level = cb.eng_chg_level AND a.alternative_no = cb.alternative_no
INNER JOIN plm_bom_detail AS b ON a.site = b.site AND a.part_no = b.part_no AND a.bom_type = b.bom_type
AND a.eng_chg_level = b.eng_chg_level AND a.alternative_no = b.alternative_no
INNER JOIN part AS c ON a.site = c.site AND a.part_no = c.part_no
WHERE p.structure_level &lt; 100
AND a.qty_per_assembly &gt;= 0
)
SELECT SELECT
a.site,
a.part_no,
dbo.get_part_name(a.site, a.part_no) as partDesc,
a.bom_type,
a.eng_chg_level,
a.alternative_no,
b.alternative_description,
a.component_part,
dbo.get_part_name(a.site, a.component_part) as componentPartDesc,
a.qty_per_assembly,
a.print_unit,
dbo.get_um_name(a.print_unit) as printUnitName,
c.product_group_id4,
dbo.get_product_group_name(c.site, c.product_group_id4, '4') as productGroupName4,
c.min_order_qty,
c.mul_order_qty,
c.planning_method,
c.cum_lead_time,
c.unprotected_lead_time,
dbo.get_cum_lead_time(a.site, a.component_part) as componentCumLeadTime,
dbo.get_unprotected_lead_time(a.site, a.component_part) as componentUnprotectedLeadTime
FROM plm_bom_component as a
LEFT JOIN plm_bom_detail as b on a.site = b.site and a.part_no = b.part_no and a.bom_type = b.bom_type and a.eng_chg_level = b.eng_chg_level and a.alternative_no = b.alternative_no
LEFT JOIN part as c on a.site = c.site and a.part_no = c.part_no
where a.site = #{site} and a.part_no = #{partNo} and a.bom_type = #{bomType} and a.eng_chg_level = #{engChgLevel} and a.alternative_no = #{alternativeNo}
structure_level,
site,
part_no,
partDesc,
bom_type,
eng_chg_level,
alternative_no,
alternative_description,
component_part,
componentPartDesc,
qty_per_assembly,
print_unit,
printUnitName,
product_group_id4,
productGroupName4,
min_order_qty,
mul_order_qty,
planning_method,
cum_lead_time,
unprotected_lead_time,
componentCumLeadTime,
componentUnprotectedLeadTime
FROM ExplodedBom
ORDER BY sort_key
</select> </select>
<!-- 新增BOM子明细表内容 --> <!-- 新增BOM子明细表内容 -->

Loading…
Cancel
Save