@ -55,7 +55,46 @@
</select>
<select id= "queryPartBom" resultType= "com.xujie.sys.modules.quote.entity.QuoteDetailBomTree" >
select top 1 bd.site,
select top 1 * from (
select top 1
bd.site,
#{buNo} as bu_no,
bd.part_no,
bd.alternative_no,
bd.bom_type,
bd.eng_chg_level,
#{quoteId} as quote_id,
#{quoteNo} as quote_no,
#{id} as quote_detail_id,
#{itemNo} as quote_detail_item_no,
#{versionNo} as version_no,
1 as priority
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
inner join plm_quickly_bom_Info pqbi on bd.site = pqbi.site and bd.part_no = pqbi.part_no and bd.eng_chg_level = pqbi.eng_chg_level
where bd.site = #{site}
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
union all
select top 1
bd.site,
#{buNo} as bu_no,
bd.part_no,
bd.alternative_no,
@ -65,11 +104,13 @@
#{quoteNo} as quote_no,
#{id} as quote_detail_id,
#{itemNo} as quote_detail_item_no,
#{versionNo} as version_no
#{versionNo} as version_no,
2 as priority
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
left join plm_quickly_bom_Info pqbi on bd.site = pqbi.site and bd.part_no = pqbi.part_no and bd.eng_chg_level = pqbi.eng_chg_level
where bd.site = #{site}
and bd.part_no = #{partNo}
and bd.status != 'Tentative'
@ -82,10 +123,12 @@
<if test= "alternativeNo != null and alternativeNo != ''" >
and bd.alternative_no = #{alternativeNo}
</if>
<if test= "alternativeNo == null or alternativeNo == ''" >
<if test= "alternativeNo == null or alternativeNo == ''" >
and bd.alternative_no = '*'
</if>
order by bh.eff_phase_in_date desc,bh.create_date desc
) combined_result
order by priority
</select>
<select id= "queryBomComponentPart" resultType= "com.xujie.sys.modules.quote.entity.QuoteDetailBom" >
@ -119,7 +162,6 @@
#{versionNo} as version_no,
1 as attrition_rate
from plm_bom_component pbc
inner join plm_quickly_bom_Info pqbi on pbc.site = pqbi.site and pbc.part_no = pqbi.part_no and pqbi.eng_chg_level = pbc.eng_chg_level
where pbc.site = #{site}
and pbc.part_no = #{partNo}
and pbc.bom_type = #{bomType}
@ -164,6 +206,43 @@
</select>
<select id= "queryPartBomRouting" resultType= "com.xujie.sys.modules.quote.entity.QuoteDetailRouting" >
select top 1 * from (
select top 1
rd.site,
#{buNo} as bu_no,
rd.routing_revision,
rd.routing_type,
rd.part_no,
rd.alternative_no,
#{quoteId} as quote_id,
#{quoteNo} as quote_no,
#{id} as quote_detail_id,
#{itemNo} as quote_detail_item_no,
#{versionNo} as version_no,
1 as priority
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
inner join plm_quickly_bom_Info qbi on rd.site = qbi.site and rd.part_no = qbi.part_no and rd.routing_revision = qbi.routing_revision
where rd.site = #{site}
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
union all
select top 1
rd.site,
#{buNo} as bu_no,
@ -175,12 +254,12 @@
#{quoteNo} as quote_no,
#{id} as quote_detail_id,
#{itemNo} as quote_detail_item_no,
#{versionNo} as version_no
#{versionNo} as version_no,
2 as priority
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
rd.routing_type = rh.routing_type and rd.routing_revision = rh.routing_revision
left join plm_quickly_bom_Info qbi on rd.site = qbi.site and rd.part_no = qbi.part_no and rd.routing_revision = qbi.routing_revision
where rd.site = #{site}
and rd.part_no = #{partNo}
@ -193,10 +272,12 @@
<if test= "alternativeNo != null and alternativeNo != ''" >
and rd.alternative_no = #{alternativeNo}
</if>
<if test= "alternativeNo == null or alternativeNo == ''" >
<if test= "alternativeNo == null or alternativeNo == ''" >
and rd.alternative_no = '*'
</if>
order by rh.phase_in_date desc,rh.create_date desc
) combined_result
order by priority
</select>
<select id= "queryYieldRate" resultType= "java.math.BigDecimal" >