case when part_type2 = 'Manufactured' then '成品' when part_type2 = 'Manufactured Recipe' then '半成品' when part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
FamilyID,
dbo.get_family_name(site, sourceBu, FamilyID) as familyName
FROM part
a.site,
a.sourceBu as buNo,
a.part_no,
a.part_desc,
a.spec,
a.umid2 as printUnit,
dbo.qc_get_um_name(a.site, a.umid2) as printUnitName,
a.part_type2,
case when a.part_type2 = 'Manufactured' then '成品' when a.part_type2 = 'Manufactured Recipe' then '半成品' when a.part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
a.FamilyID,
dbo.get_family_name(a.site, a.sourceBu, a.FamilyID) as familyName,
isnull(b.yield_rate, 100) as yieldRate
FROM part as a
left join part_product_group as b on a.site = b.site and a.sourceBu = b.bu_no and a.product_group_id2 = b.product_group_id
<where>
site = #{query.site}
and sourceBu = #{query.buNo}
and (part_type2 <![CDATA[<>]]> 'Purchased (raw)' or part_type2 is null)
and active = 'Y'
a.site = #{query.site} and a.sourceBu = #{query.buNo} and a.active = 'Y' and b.type = '2'
and (a.part_type2 <![CDATA[<>]]> 'Purchased (raw)' or a.part_type2 is null)
<iftest ="query.partNo != null and query.partNo != ''">
AND part_no like '%' + #{query.partNo} + '%'
AND a.part_no like '%' + #{query.partNo} + '%'
</if>
<iftest ="query.partDesc != null and query.partDesc != ''">
AND part_desc like '%' + #{query.partDesc} + '%'
AND a.part_desc like '%' + #{query.partDesc} + '%'
case when part_type2 = 'Manufactured' then '成品' when part_type2 = 'Manufactured Recipe' then '半成品' when part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
FamilyID,
dbo.get_family_name(site, sourceBu, FamilyID) as familyName
FROM part
a.site,
a.sourceBu as buNo,
a.part_no,
a.part_desc,
a.spec,
a.umid2 as printUnit,
dbo.qc_get_um_name(a.site, a.umid2) as printUnitName,
a.part_type2,
case when a.part_type2 = 'Manufactured' then '成品' when a.part_type2 = 'Manufactured Recipe' then '半成品' when a.part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
a.FamilyID,
dbo.get_family_name(a.site, a.sourceBu, a.FamilyID) as familyName,
isnull(b.yield_rate, 100) as yieldRate
FROM part as a
left join part_product_group as b on a.site = b.site and a.sourceBu = b.bu_no and a.product_group_id2 = b.product_group_id
<where>
site = #{query.site}
and sourceBu = #{query.buNo}
and active = 'Y'
and (part_type2 <![CDATA[<>]]> 'Purchased (raw)' or part_type2 is null)
a.site = #{query.site} and a.sourceBu = #{query.buNo} and a.active = 'Y' and b.type = '2'
and (a.part_type2 <![CDATA[<>]]> 'Purchased (raw)' or a.part_type2 is null)
<iftest ="query.partNo != null and query.partNo != ''">
AND part_no like '%' + #{query.partNo} + '%'
AND a.part_no like '%' + #{query.partNo} + '%'
</if>
<iftest ="query.partDesc != null and query.partDesc != ''">
AND part_desc like '%' + #{query.partDesc} + '%'
AND a.part_desc like '%' + #{query.partDesc} + '%'