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.
838 lines
33 KiB
838 lines
33 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.xujie.sys.modules.part.mapper.BomSearch3Mapper">
|
|
|
|
<!-- Bom列表 -->
|
|
<select id="bomSearchHeader" parameterType="com.xujie.sys.modules.part.vo.BomHeaderVo" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo">
|
|
SELECT
|
|
a.id as bomId,
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
b.part_desc,
|
|
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,
|
|
dbo.getOperatorDesc(a.site, a.create_by) as createByDesc,
|
|
a.update_date,
|
|
a.update_by,
|
|
dbo.getOperatorDesc(a.site, a.update_by) as updateByDesc,
|
|
b.umid2 as printUnit,
|
|
c.UMName as printUnitName,
|
|
b.part_type2,
|
|
case
|
|
when part_type2 = 'Manufactured' then '成品'
|
|
when part_type2 = 'Manufactured Recipe' then '半成品'
|
|
when part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
|
|
isnull(dbo.get_yield_rate(b.site, b.sourceBu, b.product_group_id2, '2'), 100) as yieldRate
|
|
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
|
|
left join UM as c on a.site = c.site and b.umid2 = c.UMID
|
|
<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.buDesc != null and query.buDesc != ''">
|
|
AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
|
|
</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 b.part_desc like '%' + #{query.partDesc} + '%'
|
|
</if>
|
|
<if test = "query.partType2 != null and query.partType2 != ''">
|
|
AND b.part_type2 = #{query.partType2}
|
|
</if>
|
|
<if test = "query.engChgLevel != null and query.engChgLevel != ''">
|
|
AND a.eng_chg_level = #{query.engChgLevel}
|
|
</if>
|
|
</where>
|
|
order by a.create_date desc
|
|
</select>
|
|
|
|
<!-- 查bom明细 -->
|
|
<select id="getAlternativeTree" parameterType="com.xujie.sys.modules.part.vo.BomHeaderVo" resultType="com.xujie.sys.modules.part.entity.BomComponentEntity">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
a.bom_type,
|
|
a.eng_chg_level,
|
|
a.alternative_no,
|
|
a.component_part,
|
|
(a.site + '-' + a.component_part + '-' + a.bom_type + '-' + convert(varchar, a.eng_chg_level)) as id,
|
|
(a.site + '-' + a.part_no + '-' + a.bom_type + '-' + convert(varchar, c.eng_chg_level)) as parentId
|
|
FROM plm_bom_component as a
|
|
left join plm_bom_header as c on a.site = c.site and a.bu_no = c.bu_no and a.component_part = c.part_no and a.bom_type = c.bom_type
|
|
where a.site = #{site}
|
|
</select>
|
|
|
|
<!-- 查bom子明细 -->
|
|
<select id="getComponentPartList" parameterType="com.xujie.sys.modules.part.vo.BomComponentVo" resultType="com.xujie.sys.modules.part.vo.BomComponentVo">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
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.qc_get_um_name(a.site, a.print_unit) as printUnitName,
|
|
a.qty_per_assembly,
|
|
a.component_scrap,
|
|
a.issue_type,
|
|
a.shrinkage_factor,
|
|
a.line_item_no,
|
|
a.operation_id,
|
|
c.operation_no,
|
|
c.operation_name,
|
|
a.issue_to_loc,
|
|
dbo.get_location_name(a.site, a.bu_no, a.issue_to_loc) as issueToLocName,
|
|
a.note_text,
|
|
a.line_sequence,
|
|
a.consumption_item
|
|
FROM plm_bom_component as a
|
|
left join part as b on a.site = b.site and a.component_part = b.part_no
|
|
left join plm_routing_component as c on a.operation_id = c.operation_id
|
|
where a.site = #{site} and a.part_no = #{componentPart} and a.bom_type = #{bomType} and a.eng_chg_level = #{engChgLevel} and a.alternative_no = '*'
|
|
order by a.line_sequence
|
|
</select>
|
|
|
|
<select id="queryPartBom" resultType="com.xujie.sys.modules.part.entity.CopyTempBomTree">
|
|
select top 1
|
|
bd.site,
|
|
bd.bu_no,
|
|
bd.part_no,
|
|
bd.alternative_no,
|
|
bd.bom_type,
|
|
bd.eng_chg_level
|
|
from plm_bom_detail bd
|
|
left join plm_bom_header bh on bd.site = bh.site and bd.part_no = bh.part_no and bd.bu_no = bh.bu_no and bd.bom_type = bh.bom_type and bd.eng_chg_level = bh.eng_chg_level
|
|
where bd.site = #{site} and bd.bu_no = #{buNo} and bd.part_no = #{partNo} and bd.status != 'Tentative'
|
|
<if test="engChgLevel == null">
|
|
and bh.eff_phase_out_date is null
|
|
</if>
|
|
<if test="engChgLevel != null">
|
|
and bh.eng_chg_level = #{engChgLevel}
|
|
</if>
|
|
<if test="alternativeNo != null and alternativeNo != ''">
|
|
and bd.alternative_no = #{alternativeNo}
|
|
</if>
|
|
<if test="alternativeNo == null or alternativeNo == ''">
|
|
and bd.alternative_no = '*'
|
|
</if>
|
|
order by bh.eff_phase_in_date desc,bh.create_date desc
|
|
</select>
|
|
|
|
<select id="queryPartBomRouting" resultType="com.xujie.sys.modules.part.entity.CopyTempRouting">
|
|
select top 1
|
|
rd.site,
|
|
rd.bu_no,
|
|
rd.routing_revision,
|
|
rd.routing_type,
|
|
rd.part_no,
|
|
rd.alternative_no,
|
|
#{bomId} as bomId
|
|
from plm_routing_detail rd
|
|
left join plm_routing_header rh on rd.site = rh.site and rd.bu_no = rh.bu_no and rd.part_no = rh.part_no and rd.routing_type = rh.routing_type and rd.routing_revision = rh.routing_revision
|
|
where rd.site = #{site} and rd.bu_no = #{buNo} and rd.part_no = #{partNo}
|
|
<if test="engChgLevel == null">
|
|
and rh.phase_out_date is null
|
|
</if>
|
|
<if test="engChgLevel != null">
|
|
and rh.routing_revision = #{engChgLevel}
|
|
</if>
|
|
<if test="alternativeNo != null and alternativeNo != ''">
|
|
and rd.alternative_no = #{alternativeNo}
|
|
</if>
|
|
<if test="alternativeNo == null or alternativeNo == ''">
|
|
and rd.alternative_no = '*'
|
|
</if>
|
|
order by rh.phase_in_date desc, rh.create_date desc
|
|
</select>
|
|
|
|
<insert id="saveCopyTempRouting">
|
|
insert into plm_copy_temp_routing
|
|
(site, bu_no, part_no, routing_revision, routing_type, alternative_no, operation_no, efficiency_factor,
|
|
mach_run_factor, mach_setup_time, run_time_code, labor_run_factor, labor_setup_time, crew_size, setup_crew_size,
|
|
outside_op_item, machine_no, work_center_no, labor_class_no, setup_labor_class_no, overlap, note_text, operation_id,
|
|
operation_name, create_by, create_date, tree_id, mach_cycle_time, labor_cycle_time, bom_id)
|
|
select
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
1,
|
|
routing_type,
|
|
alternative_no,
|
|
operation_no,
|
|
efficiency_factor,
|
|
mach_run_factor,
|
|
mach_setup_time,
|
|
run_time_code,
|
|
labor_run_factor,
|
|
labor_setup_time,
|
|
crew_size,
|
|
setup_crew_size,
|
|
outside_op_item,
|
|
machine_no,
|
|
work_center_no,
|
|
labor_class_no,
|
|
setup_labor_class_no,
|
|
overlap,
|
|
note_text,
|
|
operation_id,
|
|
operation_name,
|
|
#{createBy},
|
|
#{createDate},
|
|
#{treeId},
|
|
mach_cycle_time,
|
|
labor_cycle_time,
|
|
#{bomId}
|
|
from plm_routing_component
|
|
where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_revision = #{routingRevision} and routing_type = #{routingType} and alternative_no = #{alternativeNo}
|
|
</insert>
|
|
|
|
<select id="queryBomComponentPart" resultType="com.xujie.sys.modules.part.entity.CopyTempBom">
|
|
select
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
1 as engChgLevel,
|
|
bom_type,
|
|
alternative_no,
|
|
component_part,
|
|
print_unit,
|
|
qty_per_assembly,
|
|
component_scrap,
|
|
issue_type,
|
|
shrinkage_factor,
|
|
line_item_no,
|
|
operation_id,
|
|
issue_to_loc,
|
|
note_text,
|
|
create_date,
|
|
create_by,
|
|
line_sequence,
|
|
consumption_item,
|
|
#{bomId} as bomId,
|
|
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
|
|
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}
|
|
</select>
|
|
|
|
<select id="queryCopyTempBomTree" resultType="com.xujie.sys.modules.part.entity.CopyTempBomTree">
|
|
select
|
|
qdbt.id,
|
|
qdbt.site,
|
|
qdbt.bu_no,
|
|
qdbt.part_no,
|
|
qdbt.bom_type,
|
|
qdbt.eng_chg_level,
|
|
qdbt.alternative_no,
|
|
qdbt.parent_id,
|
|
qdbt.level,
|
|
qdbt.bom_id,
|
|
qdbt.change_flag
|
|
from plm_copy_temp_bom_tree qdbt
|
|
where bom_id = #{bomId} and username = #{createBy}
|
|
</select>
|
|
|
|
<select id="queryCopyTempBom" resultType="com.xujie.sys.modules.part.entity.CopyTempBom">
|
|
select
|
|
qdb.id,
|
|
qdb.bom_id,
|
|
qdb.site,
|
|
qdb.bu_no,
|
|
qdb.part_no,
|
|
qdb.eng_chg_level,
|
|
qdb.bom_type,
|
|
qdb.alternative_no,
|
|
qdb.component_part,
|
|
qdb.print_unit,
|
|
dbo.qc_get_um_name(qdb.site, qdb.print_unit) as printUnitName,
|
|
qdb.qty_per_assembly,
|
|
qdb.component_scrap,
|
|
qdb.issue_type,
|
|
qdb.shrinkage_factor,
|
|
(100 - qdb.shrinkage_factor) as yield_rate,
|
|
qdb.line_item_no,
|
|
qdb.operation_id,
|
|
qdb.issue_to_loc,
|
|
qdb.note_text,
|
|
qdb.line_sequence,
|
|
qdb.consumption_item,
|
|
qdb.create_by,
|
|
qdb.create_date,
|
|
qdb.tree_id,
|
|
p.part_desc,
|
|
p.FamilyID as familyID,
|
|
qdb.consumption_loss,
|
|
qdb.production_data,
|
|
qdb.material_data,
|
|
qdb.finished_product_data,
|
|
qdb.coating_length,
|
|
qdb.glue_weight,
|
|
qdb.material_width,
|
|
qdb.width_conversion,
|
|
qdb.material_length,
|
|
qdb.material_thickness,
|
|
qdb.area_conversion,
|
|
qdb.density_conversion,
|
|
qdb.material_weight,
|
|
qdb.material_length2,
|
|
qdb.unit_conversion
|
|
from plm_copy_temp_bom as qdb
|
|
left join part as p on qdb.site = p.site and qdb.component_part = p.part_no
|
|
where bom_id = #{bomId} and tree_id = #{treeId}
|
|
order by tree_id
|
|
</select>
|
|
|
|
<select id="queryCopyTempRouting" resultType="com.xujie.sys.modules.part.entity.CopyTempRouting">
|
|
select
|
|
qdr.id,
|
|
qdr.bom_id,
|
|
qdr.site,
|
|
qdr.bu_no,
|
|
qdr.part_no,
|
|
qdr.routing_revision,
|
|
qdr.routing_type,
|
|
qdr.alternative_no,
|
|
qdr.operation_no,
|
|
qdr.efficiency_factor,
|
|
qdr.mach_run_factor,
|
|
qdr.mach_setup_time,
|
|
qdr.run_time_code,
|
|
(case
|
|
when qdr.run_time_code = 'Units/Hour' then '单位/小时'
|
|
when qdr.run_time_code = 'Hour/Units' then '小时/单位'
|
|
when qdr.run_time_code = 'Hour' then '小时'
|
|
else '' end) as runTimeDesc,
|
|
qdr.labor_run_factor,
|
|
qdr.labor_setup_time,
|
|
qdr.crew_size,
|
|
qdr.setup_crew_size,
|
|
qdr.outside_op_item,
|
|
qdr.machine_no,
|
|
qdr.work_center_no,
|
|
qdr.labor_class_no,
|
|
qdr.setup_labor_class_no,
|
|
qdr.overlap,
|
|
qdr.note_text,
|
|
qdr.operation_id,
|
|
qdr.operation_name,
|
|
qdr.create_by,
|
|
qdr.create_date,
|
|
qdr.tree_id,
|
|
p.part_desc,
|
|
wc.work_center_desc,
|
|
qdr.mach_cycle_time,
|
|
qdr.labor_cycle_time
|
|
from plm_copy_temp_routing qdr
|
|
left join part p on qdr.part_no = p.part_no and qdr.site = p.site
|
|
left join work_center wc on qdr.work_center_no = wc.work_center_no and qdr.site = wc.site
|
|
where qdr.bom_id = #{bomId} and qdr.tree_id = #{treeId}
|
|
order by qdr.tree_id, qdr.operation_no
|
|
</select>
|
|
|
|
<select id="queryCopyTempRoutingVersion" resultType="com.xujie.sys.modules.part.entity.CopyTempRouting">
|
|
select
|
|
prh.site,
|
|
prh.bu_no,
|
|
prh.part_no,
|
|
prh.routing_revision,
|
|
prh.routing_type,
|
|
p.part_desc,
|
|
prh.note_text
|
|
from plm_routing_header prh
|
|
left join part p on prh.part_no = p.part_no and prh.site = p.site
|
|
where prh.site = #{site} and prh.bu_no = #{buNo} and prh.part_no = #{partNo}
|
|
<if test="routingType != null and routingType != ''">
|
|
and prh.routing_type = #{routingType}
|
|
</if>
|
|
order by prh.routing_type, prh.routing_revision
|
|
</select>
|
|
|
|
<select id="queryCopyTempRoutingAlternative" resultType="com.xujie.sys.modules.part.entity.CopyTempRouting">
|
|
select
|
|
prd.site,
|
|
prd.bu_no,
|
|
prd.part_no,
|
|
prd.routing_revision,
|
|
prd.routing_type,
|
|
prd.alternative_no,
|
|
p.part_desc
|
|
from plm_routing_detail prd
|
|
left join part p on prd.part_no = p.part_no and prd.site = p.site
|
|
where prd.site = #{site} and prd.bu_no = #{buNo} and prd.part_no = #{partNo} and prd.routing_type = #{routingType} and prd.routing_revision = #{routingRevision}
|
|
order by prd.alternative_no desc
|
|
</select>
|
|
|
|
<select id="queryCopyTempBomTreeLevel" resultType="com.xujie.sys.modules.part.entity.CopyTempBomTree">
|
|
select
|
|
bom.site,
|
|
bom.bu_no,
|
|
bom.part_no,
|
|
bom.eng_chg_level,
|
|
bom.bom_type,
|
|
p.part_desc,
|
|
bom.note_text
|
|
from plm_bom_header bom
|
|
left join part p on bom.part_no = p.part_no and bom.site = p.site
|
|
where bom.site = #{site} and bom.part_no = #{partNo}
|
|
<if test="bomType != null and bomType != ''">
|
|
and bom.bom_type = #{bomType}
|
|
</if>
|
|
order by bom_type, eng_chg_level
|
|
</select>
|
|
|
|
<select id="handleQueryCopyTempBomAlternative" resultType="com.xujie.sys.modules.part.entity.CopyTempBomTree">
|
|
select
|
|
bom.site,
|
|
bom.bu_no,
|
|
bom.part_no,
|
|
bom.eng_chg_level,
|
|
bom.bom_type,
|
|
bom.alternative_no,
|
|
p.part_desc
|
|
from plm_bom_detail bom
|
|
left join part p on bom.part_no = p.part_no and bom.site = p.site
|
|
where bom.site = #{site} and bom.part_no = #{partNo} and bom.status != 'Tentative'
|
|
<if test="bomType != null and bomType != ''">
|
|
and bom.bom_type = #{bomType}
|
|
</if>
|
|
and bom.eng_chg_level = #{engChgLevel}
|
|
order by bom.alternative_no
|
|
</select>
|
|
|
|
<select id="getBomHeaderById" resultType="com.xujie.sys.modules.part.entity.CopyTempBom">
|
|
select
|
|
id as bomId,
|
|
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,
|
|
process_unit
|
|
from plm_bom_header
|
|
where id = #{bomId}
|
|
</select>
|
|
|
|
<update id="updateBomTreePartNoById">
|
|
update plm_copy_temp_bom_tree
|
|
set part_no = #{partNo},
|
|
change_flag = #{changeFlag}
|
|
where id = #{treeId}
|
|
</update>
|
|
|
|
<update id="updateBomPartNoByTreeId">
|
|
update plm_copy_temp_bom
|
|
set part_no = #{partNo}
|
|
where tree_id = #{treeId}
|
|
</update>
|
|
|
|
<update id="updateRoutingPartNoByTreeId">
|
|
update plm_copy_temp_routing
|
|
set part_no = #{partNo}
|
|
where tree_id = #{treeId}
|
|
</update>
|
|
|
|
<update id="updateItemPartNoByTreeId">
|
|
update plm_copy_temp_item_value
|
|
set part_no = #{partNo}
|
|
where tree_id = #{treeId}
|
|
</update>
|
|
|
|
<select id="getTempComponentLineSequence" 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_copy_temp_bom
|
|
WHERE tree_id = #{treeId} order by line_sequence desc
|
|
</select>
|
|
|
|
<select id="getComponentByLineSequenceNo" resultType="com.xujie.sys.modules.part.entity.BomComponentEntity">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
eng_chg_level,
|
|
bom_type,
|
|
alternative_no,
|
|
component_part,
|
|
line_sequence
|
|
FROM plm_copy_temp_bom
|
|
WHERE tree_id = #{treeId} and line_sequence = #{lineSequence}
|
|
</select>
|
|
|
|
<select id="selectMaxLineItemNo" resultType="com.xujie.sys.modules.part.entity.BomComponentEntity">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
eng_chg_level,
|
|
bom_type,
|
|
alternative_no,
|
|
component_part,
|
|
line_item_no
|
|
FROM plm_copy_temp_bom
|
|
WHERE tree_id = #{treeId} and line_item_no = (
|
|
SELECT MAX(line_item_no)
|
|
FROM plm_copy_temp_bom
|
|
WHERE tree_id = #{treeId})
|
|
</select>
|
|
|
|
<!-- 查询最大工序号 -->
|
|
<select id="queryTempMaxOperationNo" resultType="com.xujie.sys.modules.part.entity.CopyTempRouting">
|
|
SELECT top 1
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
routing_revision,
|
|
routing_type,
|
|
alternative_no,
|
|
operation_no
|
|
FROM plm_copy_temp_routing
|
|
where tree_id = #{treeId}
|
|
order by operation_no desc
|
|
</select>
|
|
|
|
<insert id="saveBomComponentFromTemp">
|
|
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,
|
|
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)
|
|
select
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
a.eng_chg_level,
|
|
a.bom_type,
|
|
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.issue_to_loc,
|
|
a.note_text,
|
|
getDate(),
|
|
a.create_by,
|
|
a.line_sequence,
|
|
a.consumption_item,
|
|
a.consumption_loss,
|
|
a.production_data,
|
|
a.material_data,
|
|
a.finished_product_data,
|
|
a.coating_length,
|
|
a.glue_weight,
|
|
a.material_width,
|
|
a.width_conversion,
|
|
a.material_length,
|
|
a.material_thickness,
|
|
a.area_conversion,
|
|
a.density_conversion,
|
|
a.material_weight,
|
|
a.material_length2,
|
|
a.unit_conversion
|
|
from plm_copy_temp_bom as a
|
|
left join plm_copy_temp_bom_tree as b on b.id = a.tree_id
|
|
where a.bom_id = #{bomId} and a.create_by = #{createBy} and b.change_flag = 'Y'
|
|
</insert>
|
|
|
|
<insert id="saveRoutingComponentFromTemp">
|
|
insert into plm_routing_component
|
|
(site, bu_no, part_no, routing_revision, routing_type, alternative_no, operation_no, efficiency_factor,
|
|
mach_run_factor, mach_setup_time, run_time_code, labor_run_factor, labor_setup_time, crew_size, setup_crew_size,
|
|
outside_op_item, machine_no, work_center_no, labor_class_no, setup_labor_class_no, overlap, note_text,
|
|
operation_name, create_by, create_date, mach_cycle_time, labor_cycle_time)
|
|
select
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
a.routing_revision,
|
|
a.routing_type,
|
|
a.alternative_no,
|
|
a.operation_no,
|
|
a.efficiency_factor,
|
|
a.mach_run_factor,
|
|
a.mach_setup_time,
|
|
a.run_time_code,
|
|
a.labor_run_factor,
|
|
a.labor_setup_time,
|
|
a.crew_size,
|
|
a.setup_crew_size,
|
|
a.outside_op_item,
|
|
a.machine_no,
|
|
a.work_center_no,
|
|
a.labor_class_no,
|
|
a.setup_labor_class_no,
|
|
a.overlap,
|
|
a.note_text,
|
|
a.operation_name,
|
|
a.create_by,
|
|
getDate(),
|
|
a.mach_cycle_time,
|
|
a.labor_cycle_time
|
|
from plm_copy_temp_routing as a
|
|
left join plm_copy_temp_bom_tree as b on b.id = a.tree_id
|
|
where a.bom_id = #{bomId} and a.create_by = #{createBy} and b.change_flag = 'Y'
|
|
</insert>
|
|
|
|
<insert id="savePartSubPropertiesValueFromTemp">
|
|
insert into part_sub_properties_value
|
|
(site, bu_no, part_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type)
|
|
select
|
|
site,
|
|
bu_no,
|
|
#{partNo},
|
|
code_no,
|
|
sub_code_seq_no,
|
|
sub_code_desc,
|
|
item_no,
|
|
properties_item_no,
|
|
text_value,
|
|
num_value,
|
|
record_type
|
|
from plm_copy_temp_item_value
|
|
where tree_id = #{treeId}
|
|
</insert>
|
|
|
|
<!-- 删除已存在的BOM header(用于复制前清理)-->
|
|
<delete id="deleteBomHeaderForCopy">
|
|
delete from plm_bom_header
|
|
where site = (select top 1 site from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and bu_no = (select top 1 bu_no from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and part_no = (select top 1 part_no from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and eng_chg_level = (select top 1 eng_chg_level from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and bom_type = (select top 1 bom_type from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
</delete>
|
|
|
|
<!-- 从临时表保存BOM header -->
|
|
<insert id="saveBomHeaderFromTemp">
|
|
insert into plm_bom_header
|
|
(site, bu_no, part_no, eng_chg_level, bom_type, note_text, eff_phase_in_date, eng_revision, type_flag, net_weight, create_date, create_by, process_unit)
|
|
select distinct
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
eng_chg_level,
|
|
bom_type,
|
|
null as note_text,
|
|
getDate() as eff_phase_in_date,
|
|
1 as eng_revision,
|
|
null as type_flag,
|
|
0 as net_weight,
|
|
getDate() as create_date,
|
|
#{createBy} as create_by,
|
|
null as process_unit
|
|
from plm_copy_temp_bom_tree
|
|
where bom_id = #{bomId} and username = #{createBy} and change_flag = 'Y' and level = 0
|
|
</insert>
|
|
|
|
<!-- 删除已存在的BOM detail(用于复制前清理)-->
|
|
<delete id="deleteBomDetailForCopy">
|
|
delete from plm_bom_detail
|
|
where site = (select top 1 site from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and bu_no = (select top 1 bu_no from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and part_no = (select top 1 part_no from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and eng_chg_level = (select top 1 eng_chg_level from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and bom_type = (select top 1 bom_type from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
</delete>
|
|
|
|
<!-- 从临时表保存BOM detail -->
|
|
<insert id="saveBomDetailFromTemp">
|
|
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)
|
|
select distinct
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
eng_chg_level,
|
|
bom_type,
|
|
alternative_no,
|
|
'*' as alternative_description,
|
|
'Released' as status,
|
|
1 as min_lot_qty,
|
|
'Y' as default_flag,
|
|
null as note_text,
|
|
getDate() as create_date,
|
|
#{createBy} as create_by
|
|
from plm_copy_temp_bom_tree
|
|
where bom_id = #{bomId} and username = #{createBy} and change_flag = 'Y' and level = 0
|
|
</insert>
|
|
|
|
<!-- 删除已存在的Routing header(用于复制前清理)-->
|
|
<delete id="deleteRoutingHeaderForCopy">
|
|
delete from plm_routing_header
|
|
where site = (select top 1 site from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and bu_no = (select top 1 bu_no from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and part_no = (select top 1 part_no from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and routing_revision = (select top 1 eng_chg_level from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and routing_type = (select top 1 bom_type from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
</delete>
|
|
|
|
<!-- 从临时表保存Routing header -->
|
|
<insert id="saveRoutingHeaderFromTemp">
|
|
insert into plm_routing_header
|
|
(site, bu_no, part_no, routing_revision, routing_type, note_text, phase_in_date, create_date, create_by)
|
|
select distinct
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
eng_chg_level as routing_revision,
|
|
bom_type as routing_type,
|
|
null as note_text,
|
|
getDate() as phase_in_date,
|
|
getDate() as create_date,
|
|
#{createBy} as create_by
|
|
from plm_copy_temp_bom_tree
|
|
where bom_id = #{bomId} and username = #{createBy} and change_flag = 'Y' and level = 0
|
|
</insert>
|
|
|
|
<!-- 删除已存在的Routing detail(用于复制前清理)-->
|
|
<delete id="deleteRoutingDetailForCopy">
|
|
delete from plm_routing_detail
|
|
where site = (select top 1 site from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and bu_no = (select top 1 bu_no from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and part_no = (select top 1 part_no from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and routing_revision = (select top 1 eng_chg_level from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
and routing_type = (select top 1 bom_type from plm_copy_temp_bom_tree where bom_id = #{bomId} and username = #{createBy} and level = 0)
|
|
</delete>
|
|
|
|
<!-- 从临时表保存Routing detail -->
|
|
<insert id="saveRoutingDetailFromTemp">
|
|
insert into plm_routing_detail
|
|
(site, bu_no, part_no, routing_revision, routing_type, alternative_no, status, create_date, create_by)
|
|
select distinct
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
eng_chg_level as routing_revision,
|
|
bom_type as routing_type,
|
|
alternative_no,
|
|
'Released' as status,
|
|
getDate() as create_date,
|
|
#{createBy} as create_by
|
|
from plm_copy_temp_bom_tree
|
|
where bom_id = #{bomId} and username = #{createBy} and change_flag = 'Y' and level = 0
|
|
</insert>
|
|
|
|
<!-- 查询原BOM的节点树结构(用于复制)-->
|
|
<select id="queryOriginalBomNodeTree" resultType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity">
|
|
SELECT
|
|
site,
|
|
template_no,
|
|
node_id,
|
|
node_name,
|
|
part_no,
|
|
id,
|
|
p_id,
|
|
eng_chg_level,
|
|
routing_revision
|
|
FROM plm_quickly_bom_Info
|
|
WHERE site = #{site}
|
|
AND main_part = #{originalPartNo}
|
|
ORDER BY id
|
|
</select>
|
|
|
|
<!-- 批量插入快速BOM节点 -->
|
|
<insert id="batchInsertQuicklyBomInfo">
|
|
INSERT INTO plm_quickly_bom_Info
|
|
(site, template_no, node_id, main_part, part_no, id, p_id, create_date, create_by, node_name, eng_chg_level, routing_revision)
|
|
VALUES
|
|
<foreach collection="list" item="item" separator=",">
|
|
(#{item.site}, #{item.templateNo}, #{item.nodeId}, #{item.mainPart}, #{item.partNo},
|
|
#{item.id}, #{item.pId}, getDate(), #{item.createBy}, #{item.nodeName},
|
|
#{item.engChgLevel}, #{item.routingRevision})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<update id="updateComponentPartNo">
|
|
update plm_copy_temp_bom
|
|
set component_part = #{newPartNo}
|
|
where tree_id = #{treeId} and component_part = #{oldPartNo}
|
|
</update>
|
|
|
|
<insert id="saveStandardOperation">
|
|
insert into plm_copy_temp_routing
|
|
(bom_id, tree_id, site, bu_no, part_no, routing_revision, routing_type, alternative_no, operation_name, operation_no, efficiency_factor,
|
|
mach_run_factor, mach_setup_time, run_time_code, labor_run_factor, labor_setup_time, crew_size, setup_crew_size, outside_op_item,
|
|
machine_no, work_center_no, labor_class_no, setup_labor_class_no, overlap, note_text, create_date, create_by, mach_cycle_time, labor_cycle_time)
|
|
VALUES
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
(#{item.bomId}, #{item.treeId}, #{item.site}, #{item.buNo}, #{item.partNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.operationName}, #{item.operationNo}, #{item.efficiencyFactor},
|
|
#{item.machRunFactor}, #{item.machSetupTime}, #{item.runTimeCode}, #{item.laborRunFactor}, #{item.laborSetupTime}, #{item.crewSize,jdbcType=FLOAT}, #{item.setupCrewSize,jdbcType=FLOAT}, #{item.outsideOpItem},
|
|
#{item.machineNo}, #{item.workCenterNo}, #{item.laborClassNo}, #{item.setupLaborClassNo}, #{item.overlap}, #{item.noteText}, getDate(), #{item.createBy}, #{item.machCycleTime}, #{item.laborCycleTime})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<update id="updateCopyTempBom" parameterType="com.xujie.sys.modules.part.entity.CopyTempBom">
|
|
update plm_copy_temp_bom
|
|
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},
|
|
consumption_loss = #{consumptionLoss},
|
|
production_data = #{productionData},
|
|
material_data = #{materialData},
|
|
finished_product_data = #{finishedProductData},
|
|
coating_length = #{coatingLength},
|
|
glue_weight = #{glueWeight},
|
|
material_width = #{materialWidth},
|
|
width_conversion = #{widthConversion},
|
|
material_length = #{materialLength},
|
|
material_thickness = #{materialThickness},
|
|
area_conversion = #{areaConversion},
|
|
density_conversion = #{densityConversion},
|
|
material_weight = #{materialWeight},
|
|
material_length2 = #{materialLength2},
|
|
unit_conversion = #{unitConversion}
|
|
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>
|
|
</mapper>
|