|
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.spring.modules.part.mapper.BomManagementMapper">
<!-- 材料信息列表 --> <select id="bomManagementSearch" parameterType="com.spring.modules.part.vo.BomHeaderVo" resultType="com.spring.modules.part.vo.BomHeaderVo"> SELECT a.site, a.part_no, b.part_desc as partDesc, a.eng_chg_level, a.bom_type, a.note_text, a.eff_phase_in_date, a.eff_phase_out_date, a.eng_revision, a.type_flag, a.net_weight, a.create_date, a.create_by, a.update_date, a.update_by, b.um_id as printUnit, c.um_name as printUnitName, a.official_flag, b.ifs_part_no, b.plm_part_no FROM plm_bom_header as a left join part as b on a.site = b.site and a.part_no = b.part_no left join um as c on b.um_id = c.um_id <where> a.site = #{query.site} AND b.show_in_query_flag = 'Y' <if test = "query.plmPartNo != null and query.plmPartNo != ''"> AND b.plm_part_no like #{query.plmPartNo} </if> <if test = "query.ifsPartNo != null and query.ifsPartNo != ''"> AND b.ifs_part_no like #{query.ifsPartNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND b.part_desc like #{query.partDesc} </if> <if test = "query.bomType != null and query.bomType != ''"> AND a.bom_type = #{query.bomType} </if> <if test = "query.engChgLevel != null and query.engChgLevel != ''"> AND a.eng_chg_level = #{query.engChgLevel} </if> </where> </select>
<!-- 查询物料清单 --> <select id="queryPartList" parameterType="ComponentPartData" resultType="BomAllFieldEntity"> SELECT a.site, a.part_no, a.part_desc, a.spec, a.um_id as printUnit, b.um_name as printUnitName, a.part_type, a.family_id, c.family_name, a.part_status, d.part_status_desc, a.plm_part_no, a.ifs_part_no FROM part as a left join um as b on a.um_id = b.um_id left join part_family as c on a.site = c.site and a.family_id = c.family_id left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status <where> a.site = #{query.site} and a.part_type in ('Manufactured', 'Manufactured Recipe', 'Purchased') and a.active = 'Y' and a.show_in_query_flag = 'Y' <if test = "query.partNo != null and query.partNo != ''"> AND a.part_no like #{query.partNo} </if> <if test = "query.plmPartNo != null and query.plmPartNo != ''"> AND a.plm_part_no like #{query.plmPartNo} </if> <if test = "query.ifsPartNo != null and query.ifsPartNo != ''"> AND a.ifs_part_no like #{query.ifsPartNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND a.part_desc like #{query.partDesc} </if> <if test = "query.status != null and query.status != ''"> AND a.status = #{query.status} </if> </where> </select>
<!-- 查出可创建BOM的物料 --> <select id="queryPartListBom" parameterType="ComponentPartData" resultType="BomAllFieldEntity"> SELECT a.site, a.part_no, a.part_desc, a.spec, a.um_id as printUnit, b.um_name as printUnitName, a.part_type, a.family_id, c.family_name, a.part_status, d.part_status_desc, a.plm_part_no, a.ifs_part_no FROM part as a left join um as b on a.um_id = b.um_id left join part_family as c on a.site = c.site and a.family_id = c.family_id left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status <where> a.site = #{query.site} and a.active = 'Y' and a.show_in_query_flag = 'Y' and a.part_type <![CDATA[<>]]> 'Purchased (raw)' <if test = "query.partNo != null and query.partNo != ''"> AND a.part_no like #{query.partNo} </if> <if test = "query.plmPartNo != null and query.plmPartNo != ''"> AND a.plm_part_no like #{query.plmPartNo} </if> <if test = "query.ifsPartNo != null and query.ifsPartNo != ''"> AND a.ifs_part_no like #{query.ifsPartNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND a.part_desc like #{query.partDesc} </if> <if test = "query.status != null and query.status != ''"> AND a.status = #{query.status} </if> </where> </select>
<!-- 查出所有类型的物料 --> <select id="queryPartListAll" parameterType="ComponentPartData" resultType="BomAllFieldEntity"> SELECT a.site, a.part_no, a.part_desc, a.spec, a.um_id as printUnit, b.um_name as printUnitName, a.part_type, a.family_id, c.family_name, a.part_status, d.part_status_desc, a.plm_part_no, a.ifs_part_no, a.product_group_id4, dbo.get_product_group_name(a.site, a.product_group_id4, '4') as productGroupName4 FROM part as a left join um as b on a.um_id = b.um_id left join part_family as c on a.site = c.site and a.family_id = c.family_id left join plm_part_status as d on a.site = d.site and a.part_status = d.part_status <where> a.site = #{query.site} and a.active = 'Y' and a.show_in_query_flag = 'Y' <if test = "query.partNo != null and query.partNo != ''"> AND a.part_no like #{query.partNo} </if> <if test = "query.plmPartNo != null and query.plmPartNo != ''"> AND a.plm_part_no like #{query.plmPartNo} </if> <if test = "query.ifsPartNo != null and query.ifsPartNo != ''"> AND a.ifs_part_no like #{query.ifsPartNo} </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND a.part_desc like #{query.partDesc} </if> <if test = "query.status != null and query.status != ''"> AND a.status = #{query.status} </if> </where> </select>
<!-- 新增BOM主表内容 --> <insert id="saveBomHeader" parameterType="BomHeaderEntity"> INSERT INTO plm_bom_header (site, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, type_flag, net_weight, official_flag, create_date, create_by) VALUES (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{noteText}, #{effPhaseInDate}, #{effPhaseOutDate}, #{engRevision}, #{typeFlag}, #{netWeight}, #{officialFlag}, getDate(), #{createBy}) </insert>
<!-- bom明细新增 --> <insert id="bomDetailSave" parameterType="BomDetailEntity"> INSERT INTO plm_bom_detail (site, part_no, eng_chg_level, bom_type, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text, create_date, create_by, official_flag) VALUES (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{alternativeDescription}, #{status}, #{minLotQty}, #{defaultFlag}, #{detailNoteText}, getDate(), #{createBy}, #{officialFlag}) </insert>
<!-- 新增BOM子明细表内容 --> <insert id="saveBomComponent" parameterType="BomComponentEntity"> INSERT INTO plm_bom_component (site, part_no, eng_chg_level, bom_type, alternative_no, component_part, line_item_no, print_unit, qty_per_assembly, component_scrap, shrinkage_factor, issue_type, issue_to_loc, operation_no, note_text, create_date, create_by, line_sequence, consumption_item) VALUES (#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{componentPart}, #{lineItemNo}, #{printUnit}, #{qtyPerAssembly}, #{componentScrap}, #{shrinkageFactor}, #{issueType}, #{issueToLoc}, #{operationNo}, #{noteText}, getDate(), #{createBy}, #{lineSequence}, #{consumptionItem}) </insert>
<!-- 查bom明细 --> <select id="queryBomDetail" parameterType="BomHeaderEntity" resultType="BomDetailEntity"> SELECT site, part_no, bom_type, eng_chg_level, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text as detailNoteText, official_flag FROM plm_bom_detail where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} </select>
<!-- 查bom明细对象 --> <select id="queryDetailDataByNo" parameterType="BomDetailEntity" resultType="BomDetailEntity"> SELECT site, part_no, bom_type, eng_chg_level, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text as detailNoteText, official_flag FROM plm_bom_detail where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} </select>
<!-- 查bom子明细 --> <select id="queryBomComponent" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo"> SELECT a.site, a.part_no, a.bom_type, a.eng_chg_level, a.alternative_no, a.component_part, b.part_desc as componentPartDesc, a.print_unit, dbo.get_um_name(a.print_unit) as printUnitName, a.qty_per_assembly, a.component_scrap, a.issue_type, a.shrinkage_factor, a.line_item_no, a.operation_no, a.issue_to_loc, dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName, a.note_text, a.line_sequence, a.consumption_item, b.part_status, dbo.get_part_status_name(a.site, b.part_status) as partStatusDesc, dbo.get_ifHas_peifang( a.site,a.component_part) as ifHasPeifang FROM plm_bom_component as a left join part as b on a.site = b.site and a.component_part = b.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 <![CDATA[ >= ]]> 0 order by a.line_sequence </select>
<!-- 查bom子明细 --> <select id="queryBomByProducts" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo"> SELECT a.site, a.part_no, a.bom_type, a.eng_chg_level, a.alternative_no, a.component_part, b.part_desc as componentPartDesc, a.print_unit, dbo.get_um_name(a.print_unit) as printUnitName, abs(a.qty_per_assembly) as qtyPerAssembly, a.component_scrap, a.issue_type, a.shrinkage_factor, a.line_item_no, a.operation_no, a.issue_to_loc, dbo.get_location_name(a.site, a.issue_to_loc) as issueToLocName, a.note_text, a.line_sequence, a.consumption_item, b.part_status, dbo.get_part_status_name(a.site, b.part_status) as partStatusDesc FROM plm_bom_component as a left join part as b on a.site = b.site and a.component_part = b.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 <![CDATA[ < ]]> 0 order by a.line_sequence </select>
<!-- 查bom子明细 --> <select id="queryBomComponentAll" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo"> SELECT site, part_no, bom_type, eng_chg_level, alternative_no, component_part, dbo.get_part_name(site, component_part) as componentPartDesc, print_unit, dbo.get_um_name(print_unit) as printUnitName, qty_per_assembly, component_scrap, issue_type, shrinkage_factor, line_item_no, operation_no, issue_to_loc, dbo.get_location_name(site, issue_to_loc) as issueToLocName, note_text, line_sequence, consumption_item FROM plm_bom_component where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} order by line_sequence </select>
<!-- bom主表编辑 --> <update id="updateBomHeader" parameterType="BomAllFieldEntity"> update plm_bom_header set eff_phase_in_date = #{effPhaseInDate}, eff_phase_out_date = #{effPhaseOutDate}, eng_revision = #{engRevision}, type_flag = #{typeFlag}, net_weight = #{netWeight}, note_text = #{noteText}, update_date = getDate(), update_by = #{updateBy} where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </update>
<!-- bom明细表编辑 --> <update id="updateBomDetail" parameterType="BomDetailEntity"> update plm_bom_detail set alternative_description = #{alternativeDescription}, min_lot_qty = #{minLotQty}, note_text = #{detailNoteText}, status = #{status}, update_date = getDate(), update_by = #{updateBy} where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </update>
<!-- 删除bom子明细 --> <delete id="deleteBomComponent" parameterType="BomAllFieldEntity"> delete from plm_bom_component where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </delete>
<!-- 删除替代 --> <delete id="bomDetailDelete" parameterType="BomDetailEntity"> delete from plm_bom_detail where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </delete>
<!-- bom主表查重 --> <select id="checkBomOnlyOne" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomHeaderVo"> SELECT site, part_no, dbo.get_part_name(site, part_no) as partDesc, bom_type, eng_chg_level, eff_phase_in_date, eff_phase_out_date, eng_revision, type_flag, net_weight, note_text, official_flag FROM plm_bom_header where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} </select>
<!-- bom明细查重 --> <select id="checkBomDetailOnlyOne" parameterType="BomDetailEntity" resultType="BomDetailEntity"> SELECT site, part_no, bom_type, eng_chg_level, alternative_no, alternative_description, bom_type, eng_chg_level, min_lot_qty, default_flag, note_text as detailNoteText, status, official_flag FROM plm_bom_detail where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} </select>
<!-- 批量删除子明细物料 --> <delete id="deleteBomComponents" parameterType="BomComponentEntity"> delete from plm_bom_component where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = #{lineItemNo} </delete>
<!-- 删除bom子明细 --> <delete id="deleteBomComponentByPartNo" parameterType="BomHeaderEntity"> delete from plm_bom_component where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </delete>
<!-- 删除bom明细 --> <delete id="deleteBomDetailByPartNo" parameterType="BomHeaderEntity"> delete from plm_bom_detail where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </delete>
<!-- 删除bom主记录 --> <delete id="deleteBomHeaderByPartNo" parameterType="BomHeaderEntity"> delete from plm_bom_header where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </delete>
<!-- bom明细查重 --> <select id="checkBomComponentOnlyOne" parameterType="BomComponentEntity" resultType="BomComponentEntity"> SELECT site, part_no, bom_type, eng_chg_level, alternative_no, component_part, line_item_no FROM plm_bom_component where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} and line_item_no = #{lineItemNo} </select>
<!-- 修改bom子明细 --> <update id="updateBomComponent" parameterType="BomComponentEntity"> update plm_bom_component set qty_per_assembly = #{qtyPerAssembly}, component_scrap = #{componentScrap}, issue_type = #{issueType}, shrinkage_factor = #{shrinkageFactor}, operation_no = #{operationNo}, issue_to_loc = #{issueToLoc}, note_text = #{noteText}, line_sequence = #{lineSequence}, consumption_item = #{consumptionItem}, update_date = getDate(), update_by = #{updateBy} where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = #{lineItemNo} </update>
<!-- 修改替代状态 --> <update id="updateAlternativeStatus" parameterType="BomDetailEntity"> update plm_bom_detail set status = #{status}, update_date = getDate(), update_by = #{updateBy} where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </update>
<!-- 查bom明细对象 --> <select id="queryOperationList" parameterType="OperationEntity" resultType="OperationEntity"> select a.site, a.part_no, a.routing_revision, a.routing_type, a.alternative_no, b.alternative_description, b.status, a.operation_id, a.operation_no, a.operation_name from plm_routing_component as a left join plm_routing_detail as b on a.site = b.site and a.part_no = b.part_no and a.routing_revision = b.routing_revision and a.routing_type = b.routing_type and a.alternative_no = b.alternative_no <where> a.site = #{site} and a.part_no = #{partNo} <if test = "routingRevision != null and routingRevision != ''"> AND a.routing_revision = #{routingRevision} </if> <if test = "routingType != null and routingType != ''"> AND a.routing_type = #{routingType} </if> <if test = "alternativeNo != null and alternativeNo != ''"> AND a.alternative_no = #{alternativeNo} </if> <if test = "operationNo != null and operationNo != ''"> AND a.operation_no = #{operationNo} </if> <if test = "operationName != null and operationName != ''"> AND a.operation_name like #{operationName} </if> <if test = "operationId != null and operationId != ''"> AND a.operation_id = #{operationId} </if> </where> </select>
<!-- 查 max line_item_no --> <select id="selectMaxLineItemNo" parameterType="BomComponentEntity" resultType="BomComponentEntity"> SELECT site, part_no, eng_chg_level, bom_type, alternative_no, component_part, line_item_no FROM plm_bom_component WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = ( SELECT MAX(line_item_no) FROM plm_bom_component WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}) </select>
<!-- 判断是否已有该物料的 bom --> <select id="queryPartBom" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomHeaderVo"> SELECT top 1 site, part_no, bom_type, eng_chg_level, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, net_weight, official_flag FROM plm_bom_header WHERE site = #{site} and part_no = #{partNo} and bom_type = #{bomType} order by eng_chg_level desc </select>
<!-- 获取子料的序号 --> <select id="getComponentLineSequence" parameterType="BomAllFieldEntity" resultType="com.spring.modules.part.vo.BomComponentVo"> SELECT top 1 site, part_no, eng_chg_level, bom_type, alternative_no, line_sequence FROM plm_bom_component WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} order by line_sequence desc </select>
<!-- 判断该 bom 是否有 Buildable Obsolete 状态的替代 --> <select id="queryAlternativeStatus" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomDetailVo"> SELECT site, part_no, eng_chg_level, bom_type, alternative_no, status FROM plm_bom_detail WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and (status = 'Buildable' or status = 'Obsolete') </select>
<!-- 判断该 BOM 是否有正式的替代 --> <select id="queryOfficialBomDetail" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomDetailVo"> SELECT site, part_no, eng_chg_level, bom_type, alternative_no, status, official_flag FROM plm_bom_detail WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and official_flag = 'Y' </select>
<!-- 判断 BOM 是否存在子料 --> <select id="queryComponentPart" parameterType="BomHeaderEntity" resultType="com.spring.modules.part.vo.BomComponentVo"> SELECT site, part_no, eng_chg_level, bom_type, alternative_no, component_part FROM plm_bom_component WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </select>
<!-- 判断 BOM 是否存在子料 --> <select id="queryComponentPart2" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomComponentVo"> SELECT site, part_no, eng_chg_level, bom_type, alternative_no, component_part FROM plm_bom_component WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </select>
<!-- 获取ifs header 对象--> <select id="getBomHeader" parameterType="BomDetailEntity" resultType="BomIfsHeader"> SELECT site as contract, part_no, eng_chg_level, bom_type, eff_phase_in_date, eff_phase_out_date, note_text, create_date, 'add' as histType FROM plm_bom_header WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </select>
<!-- 获取ifs component 对象--> <select id="getBomComponent" parameterType="BomDetailEntity" resultType="BomIfsItem"> SELECT site as contract, part_no, eng_chg_level, bom_type, alternative_no, line_item_no, line_sequence, component_part, qty_per_assembly, issue_type, component_scrap, shrinkage_factor, note_text, consumption_item, operation_no, case when qty_per_assembly <![CDATA[<]]> 0 then 'byProduct' else '' end as productFlag FROM plm_bom_component WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </select>
<!-- 获取bom header 对象--> <select id="queryBomHeader" parameterType="BomHeaderEntity" resultType="BomHeaderEntity"> SELECT site, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, row_version, row_key, type_flag, net_weight FROM plm_bom_header WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </select>
<!-- bom主表编辑 --> <update id="updateInDate" parameterType="BomHeaderEntity"> update plm_bom_header set eff_phase_out_date = #{effPhaseOutDate}, update_date = getDate(), update_by = #{createBy} where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </update>
<!-- 校验物料版本是否存在--> <select id="queryPartRevision" parameterType="BomHeaderEntity" resultType="PartRevisionEntity"> SELECT site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by, update_date, update_by FROM part_revision WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} </select>
<!-- 新增物料版本 --> <insert id="savePartRevision" parameterType="BomHeaderEntity"> insert into part_revision (site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by) values (#{site}, #{partNo}, #{engChgLevel}, #{effPhaseInDate}, #{effPhaseOutDate}, #{noteText}, 'Not In Effect', 'Not In Effect', #{engRevision}, getDate(), #{createBy}) </insert>
<select id="queryBomDetailOfficialFlag" parameterType="BomComponentEntity" resultType="BomDetailEntity"> SELECT site, part_no, bom_type, eng_chg_level, alternative_no, alternative_description, min_lot_qty, default_flag, note_text as detailNoteText, status, official_flag FROM plm_bom_detail where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} </select>
<!-- 获取 component 对象--> <select id="queryComponentPartFlag" parameterType="BomDetailEntity" resultType="PartInformationEntity"> SELECT a.site, a.part_no, b.status FROM plm_bom_component as a LEFT JOIN part as b on a.site = b.site and a.component_part = b.part_no WHERE a.site = #{site} and a.part_no = #{partNo} and a.eng_chg_level = #{engChgLevel} and a.bom_type = #{bomType} and a.alternative_no = #{alternativeNo} </select>
<select id="queryBomDetailEntityList" resultType="com.spring.modules.part.entity.BomDetailEntity"> SELECT site, part_no, bom_type, eng_chg_level, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text as detailNoteText, official_flag FROM plm_bom_detail where site = #{site} and part_no = #{partNo} order by eng_chg_level desc </select>
<!-- 查询库位 --> <select id="selectLocation" parameterType="BomComponentEntity" resultType="LocationInformationEntity"> SELECT site, location_id, location_name FROM view_location <where> site = #{site} AND location_id = #{issueToLoc} </where> </select>
<!-- 查询part revision --> <select id="selectPartRevision" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.PartRevisionVo"> SELECT site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision FROM part_revision where site = #{site} AND part_no = #{partNo} and eng_chg_level = #{engChgLevel} </select>
<!-- 修改revision状态 --> <update id="updatePartRevisionProductStatus" parameterType="com.spring.modules.part.vo.PartRevisionVo"> update part_revision set product_status = #{productStatus}, <if test = "bomType == 'Repair'"> repair_status = 'In Effect', </if> update_date = getDate(), update_by = #{updateBy} where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} </update>
<!-- 新增副产品成本分配数据 --> <insert id="saveBomManufStructCostDistrib"> insert into plm_bom_manuf_struct_cost_distrib (site, part_no, eng_chg_level, bom_type, alternative_no, by_prod_line_item_no, component_line_item_no, item_cost_distribution, component_part_no, by_prod_part_no, create_date, create_by) VALUES <foreach collection="list" item="item" index="index" separator=","> (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.byProdLineItemNo}, #{item.componentLineItemNo}, #{item.itemCostDistribution,jdbcType=FLOAT}, #{item.componentPartNo}, #{item.byProdPartNo}, getDate(), #{item.createBy}) </foreach> </insert>
<!-- 查bom副产品成本分配 --> <select id="queryBomManufStructCostDistrib" parameterType="BomDetailEntity" resultType="com.spring.modules.part.vo.BomManufStructCostDistribVo"> SELECT site, part_no, bom_type, eng_chg_level, alternative_no, by_prod_line_item_no, component_line_item_no, item_cost_distribution, component_part_no, dbo.get_part_name(site, component_part_no) as componentPartDesc, by_prod_part_no, dbo.get_part_name(site, by_prod_part_no) as byProdPartDesc FROM plm_bom_manuf_struct_cost_distrib where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} </select>
<delete id="deletemanufStructCostDistribByProductPartNo" parameterType="BomComponentEntity"> delete from plm_bom_manuf_struct_cost_distrib 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 = #{lineItemNo} </delete>
<delete id="deletemanufStructCostDistribByComponentPartNo" parameterType="BomComponentEntity"> delete from plm_bom_manuf_struct_cost_distrib where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and component_line_item_no = #{lineItemNo} </delete>
<!-- 编辑副产品成本分配 --> <update id="updateManufStructCostDistrib" parameterType="com.spring.modules.part.vo.BomManufStructCostDistribVo"> update plm_bom_manuf_struct_cost_distrib set item_cost_distribution = #{itemCostDistribution,jdbcType=FLOAT}, update_date = getDate(), update_by = #{updateBy} 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>
<!-- 查bom子明细 --> <select id="queryBomMultiLevelStructureList" parameterType="BomDetailEntity" resultType="BomMultiLevelStructureData"> 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} </select>
<!-- 新增BOM子明细表内容 --> <insert id="saveBomComponents"> insert into plm_bom_component (site, part_no, eng_chg_level, bom_type, alternative_no, component_part, line_item_no, print_unit, qty_per_assembly, component_scrap, shrinkage_factor, issue_type, issue_to_loc, operation_no, note_text, create_date, create_by, line_sequence, consumption_item) VALUES <foreach collection="list" item="item" index="index" separator=","> (#{item.site}, #{item.partNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.componentPart}, #{item.lineItemNo}, #{item.printUnit}, #{item.qtyPerAssembly}, #{item.componentScrap}, #{item.shrinkageFactor}, #{item.issueType}, #{item.issueToLoc}, #{item.operationNo}, #{item.noteText}, getDate(), #{item.createBy}, #{item.lineSequence}, #{item.consumptionItem}) </foreach> </insert>
<update id="updateBomHeaderOfficialFlag" parameterType="com.spring.modules.part.vo.BomDetailVo"> update plm_bom_header set official_flag = 'Y' where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </update>
<update id="updateBomDetailOfficialFlag" parameterType="com.spring.modules.part.vo.BomDetailVo"> update plm_bom_detail set official_flag = 'Y' where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </update>
<!-- 查bom副产品成本分配 --> <select id="queryBomManufStructCostDistribToIfs" resultType="BomIfsManufStructCostDistrib"> SELECT site as contract, part_no, bom_type, eng_chg_level, alternative_no, by_prod_line_item_no, component_line_item_no, item_cost_distribution, component_part_no, by_prod_part_no as byProductPartNo, FROM plm_bom_manuf_struct_cost_distrib where site = #{site} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} </select>
<delete id="deleteManufStructCostDistribByAlternative" parameterType="BomDetailEntity"> delete from plm_bom_manuf_struct_cost_distrib where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </delete>
<select id="selectBomHeaderByPartNo" resultType="com.spring.modules.part.vo.BomHeaderVo"> SELECT a.site, a.part_no, a.bom_type, a.eng_chg_level, a.note_text, a.eff_phase_in_date, a.eff_phase_out_date, a.eng_revision, a.type_flag, a.net_weight, a.official_flag FROM plm_bom_header as a left join part_revision as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null </select>
<select id="selectBomDetailByPartNo" resultType="com.spring.modules.part.vo.BomDetailVo"> SELECT a.site, a.part_no, a.bom_type, a.eng_chg_level, a.alternative_no, a.alternative_description, a.status, a.min_lot_qty, a.default_flag, a.note_text as detailNoteText, a.official_flag FROM plm_bom_detail as a left join part_revision as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null </select>
<!-- bom明细查重 --> <select id="selectBomComponentByPartNo" resultType="com.spring.modules.part.vo.BomComponentVo"> SELECT a.site, a.part_no, a.bom_type, a.eng_chg_level, a.alternative_no, a.component_part, a.print_unit, a.qty_per_assembly, a.component_scrap, a.issue_type, a.shrinkage_factor, a.line_item_no, a.operation_no, a.issue_to_loc, a.note_text, a.line_sequence, a.consumption_item FROM plm_bom_component as a left join part_revision as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null </select>
<!-- 查bom副产品成本分配 --> <select id="selectBomManufStructCostDistribByPartNo" resultType="com.spring.modules.part.vo.BomManufStructCostDistribVo"> SELECT a.site, a.part_no, a.bom_type, a.eng_chg_level, a.alternative_no, a.by_prod_line_item_no, a.component_line_item_no, 0 as itemCostDistribution, a.component_part_no, a.by_prod_part_no FROM plm_bom_manuf_struct_cost_distrib as a left join part_revision as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level where a.site = #{site} and a.part_no = #{partNo} and b.eff_phase_out_date is null </select></mapper>
|