diff --git a/src/main/java/com/xujie/sys/modules/part/service/impl/BomSearch3ServiceImpl.java b/src/main/java/com/xujie/sys/modules/part/service/impl/BomSearch3ServiceImpl.java index 541ce75f..6775fc6a 100644 --- a/src/main/java/com/xujie/sys/modules/part/service/impl/BomSearch3ServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/part/service/impl/BomSearch3ServiceImpl.java @@ -612,22 +612,22 @@ public class BomSearch3ServiceImpl implements BomSearch3Service { log.info("步骤2: 保存BOM detail"); bomSearch3Mapper.saveBomDetailFromTemp(data.getBomId(), data.getCreateBy()); - // 3. 新增BOM component(子物料) - log.info("步骤3: 保存BOM component"); - bomSearch3Mapper.saveBomComponentFromTemp(data.getBomId(), data.getCreateBy()); - - // 4. 新增Routing header(主表) - log.info("步骤4: 保存Routing header"); + // 3. 新增Routing header(主表)⚠️ 调整顺序:必须先保存Routing + log.info("步骤3: 保存Routing header"); bomSearch3Mapper.saveRoutingHeaderFromTemp(data.getBomId(), data.getCreateBy()); - // 5. 新增Routing detail(明细表) - log.info("步骤5: 保存Routing detail"); + // 4. 新增Routing detail(明细表) + log.info("步骤4: 保存Routing detail"); bomSearch3Mapper.saveRoutingDetailFromTemp(data.getBomId(), data.getCreateBy()); - // 6. 新增Routing component(工艺路线) - log.info("步骤6: 保存Routing component"); + // 5. 新增Routing component(工艺路线)⚠️ 关键步骤:生成新的operation_id + log.info("步骤5: 保存Routing component"); bomSearch3Mapper.saveRoutingComponentFromTemp(data.getBomId(), data.getCreateBy()); + // 6. 新增BOM component(子物料)⚠️ 调整顺序:在Routing之后,确保可以映射operation_id + log.info("步骤6: 保存BOM component"); + bomSearch3Mapper.saveBomComponentFromTemp(data.getBomId(), data.getCreateBy()); + // 7. 新增BOM节点树到快速创建BOM表 log.info("步骤7: 保存BOM节点树"); // data.getPartNo() = 原BOM的物料编码, bomTreeHeader.getPartNo() = 新BOM的物料编码 diff --git a/src/main/resources/mapper/part/BomSearch3Mapper.xml b/src/main/resources/mapper/part/BomSearch3Mapper.xml index 2346a848..cec589d5 100644 --- a/src/main/resources/mapper/part/BomSearch3Mapper.xml +++ b/src/main/resources/mapper/part/BomSearch3Mapper.xml @@ -533,10 +533,32 @@ order by operation_no desc + insert into plm_bom_component (site, bu_no, part_no, eng_chg_level, bom_type, alternative_no, component_part, print_unit, qty_per_assembly, - component_scrap, issue_type, shrinkage_factor, line_item_no, issue_to_loc, note_text, create_date, create_by, + component_scrap, issue_type, shrinkage_factor, line_item_no, operation_id, issue_to_loc, note_text, create_date, create_by, line_sequence, consumption_item, consumption_loss, production_data, material_data, finished_product_data, coating_length, glue_weight, material_width, width_conversion, material_length, material_thickness, area_conversion, density_conversion, material_weight, material_length2, unit_conversion) @@ -554,6 +576,21 @@ a.issue_type, a.shrinkage_factor, a.line_item_no, + (select top 1 new_rc.operation_id + from plm_copy_temp_routing as temp_r + inner join plm_routing_component as new_rc + on temp_r.site = new_rc.site + and temp_r.bu_no = new_rc.bu_no + and temp_r.part_no = new_rc.part_no + and temp_r.routing_type = new_rc.routing_type + and temp_r.routing_revision = new_rc.routing_revision + and temp_r.alternative_no = new_rc.alternative_no + and temp_r.operation_no = new_rc.operation_no + where temp_r.tree_id = a.tree_id + and temp_r.operation_id = a.operation_id + and temp_r.bom_id = a.bom_id + and temp_r.create_by = a.create_by + ) as operation_id, a.issue_to_loc, a.note_text, getDate(),