|
|
<?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.xujie.sys.modules.part.mapper.BomManagementMapper">
<!-- 材料信息列表 --> <select id="bomManagementSearch" parameterType="com.xujie.sys.modules.part.vo.BomHeaderVo" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo"> SELECT a.site, a.bu_no, dbo.get_bu_desc(a.site, a.bu_no) as buDesc, a.part_no, dbo.qc_get_part_desc(a.site, a.bu_no, a.part_no) 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.umid as printUnit, dbo.qc_get_um_name(a.site, b.umid) as printUnitName FROM plm_bom_header as a left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no <where> a.site in (select site from eam_access_site where username = #{query.userName}) and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName})) <if test="query.buNo != null and query.buNo != ''"> AND a.bu_no = #{query.buNo} </if> <if test = "query.partNo != null and query.partNo != ''"> AND a.part_no like '%' + #{query.partNo} + '%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND dbo.qc_get_part_desc(a.site, a.bu_no, a.part_no) 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 like '%' + #{query.engChgLevel} + '%' </if> </where> </select>
<!-- 查询物料清单 --> <select id="queryPartList" parameterType="ComponentPartData" resultType="BomAllFieldEntity"> SELECT site, sourceBu as buNo, part_no, part_desc, spec, umid as printUnit, dbo.qc_get_um_name(site, umid) as printUnitName, part_type, FamilyID, dbo.get_family_name(site, sourceBu, FamilyID) as familyName FROM part <where> site = #{query.site} and sourceBu = #{query.buNo} and part_type <![CDATA[<>]]> 'Purchased (raw)' and active = 'Y' <if test = "query.partNo != null and query.partNo != ''"> AND part_no like '%' + #{query.partNo} + '%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND part_desc like '%' + #{query.partDesc} + '%' </if> </where> </select>
<!-- 查出可创建BOM的物料 --> <select id="queryPartListBom" parameterType="ComponentPartData" resultType="BomAllFieldEntity"> SELECT site, sourceBu as buNo, part_no, part_desc, spec, umid as printUnit, dbo.qc_get_um_name(site, umid) as printUnitName, part_type, FamilyID, dbo.get_family_name(site, sourceBu, FamilyID) as familyName FROM part <where> site = #{query.site} and sourceBu = #{query.buNo} and active = 'Y' and part_type <![CDATA[<>]]> 'Purchased (raw)' <if test = "query.partNo != null and query.partNo != ''"> AND part_no like '%' + #{query.partNo} + '%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND part_desc like '%' + #{query.partDesc} + '%' </if> </where> </select>
<!-- 新增BOM主表内容 --> <insert id="saveBomHeader" parameterType="BomHeaderEntity"> INSERT INTO plm_bom_header (site, bu_no, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, type_flag, net_weight, create_date, create_by) VALUES (#{site}, #{buNo}, #{partNo}, #{engChgLevel}, #{bomType}, #{noteText}, #{effPhaseInDate}, #{effPhaseOutDate}, #{engRevision}, #{typeFlag}, #{netWeight}, getDate(), #{createBy}) </insert>
<!-- bom明细新增 --> <insert id="bomDetailSave" parameterType="BomDetailEntity"> INSERT INTO plm_bom_detail (site, bu_no, part_no, eng_chg_level, bom_type, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text, create_date, create_by) VALUES (#{site}, #{buNo}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{alternativeDescription}, #{status}, #{minLotQty}, #{defaultFlag}, #{detailNoteText}, getDate(), #{createBy}) </insert>
<!-- 新增BOM子明细表内容 --> <insert id="saveBomComponent" parameterType="BomComponentEntity"> INSERT INTO plm_bom_component (site, bu_no, 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_id, note_text, create_date, create_by, line_sequence, consumption_item) VALUES (#{site}, #{buNo}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{componentPart}, #{lineItemNo}, #{printUnit}, #{qtyPerAssembly}, #{componentScrap}, #{shrinkageFactor}, #{issueType}, #{issueToLoc}, #{operationId}, #{noteText}, getDate(), #{createBy}, #{lineSequence}, #{consumptionItem}) </insert>
<!-- 查bom明细 --> <select id="queryBomDetail" parameterType="BomHeaderEntity" resultType="BomDetailEntity"> SELECT site, bu_no, part_no, bom_type, eng_chg_level, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text as detailNoteText FROM plm_bom_detail where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} </select>
<!-- 查bom明细对象 --> <select id="queryDetailDataByNo" parameterType="BomDetailEntity" resultType="BomDetailEntity"> SELECT site, bu_no, part_no, bom_type, eng_chg_level, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text as detailNoteText FROM plm_bom_detail where site = #{site} and bu_no = #{buNo} 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.xujie.sys.modules.part.vo.BomComponentVo"> SELECT site, bu_no, part_no, bom_type, eng_chg_level, alternative_no, component_part, dbo.qc_get_part_desc(site, bu_no, component_part) as componentPartDesc, print_unit, dbo.qc_get_um_name(site, print_unit) as printUnitName, qty_per_assembly, component_scrap, issue_type, shrinkage_factor, line_item_no, operation_id, dbo.plm_get_operation_no(operation_id) as operationNo, issue_to_loc, dbo.get_location_name(site, bu_no, issue_to_loc) as issueToLocName, note_text, line_sequence, consumption_item FROM plm_bom_component where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} and qty_per_assembly <![CDATA[ >= ]]> 0 order by line_sequence </select>
<!-- 查bom子明细 --> <select id="queryBomByProducts" parameterType="BomDetailEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo"> SELECT site, bu_no, part_no, bom_type, eng_chg_level, alternative_no, component_part, dbo.qc_get_part_desc(site, bu_no, component_part) as componentPartDesc, print_unit, dbo.qc_get_um_name(site, print_unit) as printUnitName, abs(qty_per_assembly) as qtyPerAssembly, component_scrap, issue_type, shrinkage_factor, line_item_no, operation_id, issue_to_loc, dbo.get_location_name(site, bu_no, issue_to_loc) as issueToLocName, note_text, line_sequence, consumption_item FROM plm_bom_component where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} and alternative_no = #{alternativeNo} and qty_per_assembly <![CDATA[ < ]]> 0 order by line_sequence </select>
<!-- 查bom子明细 --> <select id="queryBomComponentAll" parameterType="BomDetailEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo"> SELECT site, bu_no, part_no, bom_type, eng_chg_level, alternative_no, component_part, dbo.qc_get_part_desc(site, bu_no, component_part) as componentPartDesc, print_unit, dbo.qc_get_um_name(site, print_unit) as printUnitName, qty_per_assembly, component_scrap, issue_type, shrinkage_factor, line_item_no, operation_id, issue_to_loc, dbo.get_location_name(site, bu_no, issue_to_loc) as issueToLocName, note_text, line_sequence, consumption_item FROM plm_bom_component where site = #{site} and bu_no = #{buNo} 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 bu_no = #{buNo} 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 bu_no = #{buNo} 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 bu_no = #{buNo} 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 bu_no = #{buNo} 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.xujie.sys.modules.part.vo.BomHeaderVo"> SELECT site, bu_no, part_no, dbo.qc_get_part_desc(site, bu_no, 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 FROM plm_bom_header where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} and eng_chg_level = #{engChgLevel} </select>
<!-- bom明细查重 --> <select id="checkBomDetailOnlyOne" parameterType="BomDetailEntity" resultType="BomDetailEntity"> SELECT site, bu_no, 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 FROM plm_bom_detail where site = #{site} and bu_no = #{buNo} 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 bu_no = #{buNo} 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子明细 --> <update id="updateBomComponent" parameterType="BomComponentEntity"> update plm_bom_component set qty_per_assembly = #{qtyPerAssembly}, component_scrap = #{componentScrap}, issue_type = #{issueType}, shrinkage_factor = #{shrinkageFactor}, operation_id = #{operationId}, issue_to_loc = #{issueToLoc}, note_text = #{noteText}, line_sequence = #{lineSequence}, consumption_item = #{consumptionItem}, update_date = getDate(), update_by = #{updateBy} where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_item_no = #{lineItemNo} </update>
<!-- 查bom明细对象 --> <select id="queryOperationList" parameterType="OperationEntity" resultType="OperationEntity"> select a.site, a.bu_no, 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.bu_no = b.bu_no 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.bu_no = #{buNo} 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, bu_no, part_no, eng_chg_level, bom_type, alternative_no, component_part, line_item_no FROM plm_bom_component WHERE site = #{site} and bu_no = #{buNo} 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 bu_no = #{buNo} 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.xujie.sys.modules.part.vo.BomHeaderVo"> SELECT top 1 site, bu_no, part_no, bom_type, eng_chg_level, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, net_weight FROM plm_bom_header WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} order by eng_chg_level desc </select>
<!-- 获取子料的序号 --> <select id="getComponentLineSequence" parameterType="BomAllFieldEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo"> SELECT top 1 site, bu_no, part_no, eng_chg_level, bom_type, alternative_no, line_sequence FROM plm_bom_component WHERE site = #{site} and bu_no = #{buNo} 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.xujie.sys.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="queryComponentPart" parameterType="BomHeaderEntity" resultType="com.xujie.sys.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 header 对象--> <select id="queryBomHeader" parameterType="BomHeaderEntity" resultType="BomHeaderEntity"> SELECT site, bu_no, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date, eng_revision, type_flag, net_weight FROM plm_bom_header WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} </select>
<!-- 新增BOM子明细表内容 --> <insert id="saveBomComponents"> insert into plm_bom_component (site, bu_no, 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_id, note_text, create_date, create_by, line_sequence, consumption_item) VALUES <foreach collection="list" item="item" index="index" separator=","> (#{item.site}, #{item.buNo}, #{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.operationId}, #{item.noteText}, getDate(), #{item.createBy}, #{item.lineSequence}, #{item.consumptionItem}) </foreach> </insert>
<!-- 判断 BOM 是否存在子料 --> <select id="queryComponentPart2" parameterType="BomDetailEntity" resultType="com.xujie.sys.modules.part.vo.BomComponentVo"> SELECT site, bu_no, part_no, eng_chg_level, bom_type, alternative_no, component_part FROM plm_bom_component WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </select>
<!-- 修改替代状态 --> <update id="updateAlternativeStatus" parameterType="BomDetailEntity"> update plm_bom_detail set status = #{status}, update_date = getDate(), update_by = #{updateBy} where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} </update>
<select id="getComponentByLineSequenceNo" parameterType="BomComponentEntity" resultType="BomComponentEntity"> SELECT site, bu_no, part_no, eng_chg_level, bom_type, alternative_no, component_part, line_sequence FROM plm_bom_component WHERE site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo} and line_sequence = #{lineSequence} </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="queryPartListAll" parameterType="ComponentPartData" resultType="BomAllFieldEntity"> SELECT site, sourceBu as buNo, part_no, part_desc, spec, umid as printUnit, dbo.qc_get_um_name(site, umid) as printUnitName, part_type, FamilyID, dbo.get_family_name(site, sourceBu, FamilyID) as familyName FROM part <where> site = #{query.site} and sourceBu = #{query.buNo} and active = 'Y'<!-- and part_type <![CDATA[<>]]> 'Purchased (raw)' --> <if test = "query.partNo != null and query.partNo != ''"> AND part_no like '%' + #{query.partNo} + '%' </if> <if test = "query.partDesc != null and query.partDesc != ''"> AND part_desc like '%' + #{query.partDesc} + '%' </if> </where> </select>
<!-- 校验日期是否冲突--> <select id="queryHeaderPhaseDate" parameterType="BomHeaderEntity" resultType="BomHeaderEntity"> SELECT site, bu_no, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eff_phase_out_date FROM plm_bom_header <where> site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and bom_type = #{bomType} <if test = "effPhaseInDate == null"> and eff_phase_in_date = #{effPhaseInDate} </if> <if test = "effPhaseOutDate != null"> and #{effPhaseInDate} >= eff_phase_in_date and eff_phase_out_date >= #{effPhaseOutDate} </if> </where> </select></mapper>
|