You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

594 lines
23 KiB

<?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,
dbo.get_part_name(a.site, 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.um_id as printUnit,
dbo.get_um_name(b.um_id) as printUnitName
FROM plm_bom_header as a
left join part as b on a.site = b.site and a.part_no = b.part_no
<where>
a.site = #{query.site}
<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.get_part_name(a.site, a.part_no) like #{query.partDesc}
</if>
</where>
</select>
<!-- 查询物料清单 -->
<select id="queryPartList" parameterType="ComponentPartData" resultType="BomAllFieldEntity">
SELECT
site,
part_no,
part_desc,
spec,
um_id as printUnit,
dbo.get_um_name(um_id) as printUnitName,
part_type
FROM part
<where>
site = #{site} and active = 'Y'
<if test = "partNo != null and partNo != ''">
AND part_no = #{partNo}
</if>
<if test = "partDesc != null and partDesc != ''">
AND part_desc like #{partDesc}
</if>
<if test = "status != null and status != ''">
AND status = #{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_id, note_text, create_date, create_by, line_sequence)
VALUES
(#{site}, #{partNo}, #{engChgLevel}, #{bomType}, #{alternativeNo}, #{componentPart}, #{lineItemNo}, #{printUnit}, #{qtyPerAssembly}, #{componentScrap}, #{shrinkageFactor}, #{issueType}, #{issueToLoc}, #{operationId}, #{noteText}, getDate(), #{createBy}, #{lineSequence})
</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
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_id,
issue_to_loc,
dbo.get_location_name(site, issue_to_loc) as issueToLocName,
note_text,
line_sequence
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_id = #{operationId},
issue_to_loc = #{issueToLoc},
note_text = #{noteText},
line_sequence = #{lineSequence},
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="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,
'add' as histType
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}
</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>
</mapper>