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.
298 lines
12 KiB
298 lines
12 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.quote.mapper.QuoteDetailMapper">
|
|
|
|
<select id="queryQuoteDetail" resultType="com.xujie.sys.modules.quote.entity.QuoteDetail">
|
|
select qd.id,
|
|
qd.quote_id,
|
|
qd.site,
|
|
qd.bu_no,
|
|
qd.quote_no,
|
|
qd.version_no,
|
|
qd.item_no,
|
|
qd.part_id,
|
|
pp.part_no,
|
|
pp.part_desc,
|
|
qd.internal_inquiry_no,
|
|
qd.qty,
|
|
qd.quote_count,
|
|
qd.status,
|
|
qd.part_cost,
|
|
qd.adjust_part_cost,
|
|
qd.labour_cost,
|
|
qd.adjust_labour_cost,
|
|
qd.fabricate_cost,
|
|
qd.adjust_fabricate_cost,
|
|
qd.tool_cost,
|
|
qd.adjust_tool_cost,
|
|
qd.machine_cost,
|
|
qd.adjust_machine_cost,
|
|
qd.other_cost,
|
|
qd.manage_cost,
|
|
qd.total_cost,
|
|
qd.profit_rate,
|
|
qd.profit_amount,
|
|
qd.total_price,
|
|
qd.unit_price,
|
|
qd.tax_rate,
|
|
qd.tax_total_price,
|
|
qd.tax_unit_price,
|
|
qd.remark,
|
|
qd.active,
|
|
qd.create_by,
|
|
qd.create_date,
|
|
qd.update_by,
|
|
qd.update_date,
|
|
qd.pack_cost,
|
|
qd.shipping_cost,
|
|
qd.process_time,
|
|
qd.yield,
|
|
qd.bom_un_yield,
|
|
qd.bom_yield,
|
|
qd.parent_attrition_rate,
|
|
qd.child_attrition_rate,
|
|
qd.adjust_bom_un_yield,
|
|
qd.quote_cost,
|
|
qd.adjust_quote_cost,
|
|
qd.quote_total_cost,
|
|
qd.quote_profit_rate,
|
|
qd.quote_profit_amount,
|
|
qd.quote_total_price,
|
|
qd.quote_unit_price,
|
|
qd.quote_tax_rate,
|
|
qd.quote_tax_total_price,
|
|
qd.quote_tax_unit_price
|
|
from plm_quote_detail qd
|
|
left join part pp on qd.part_id = pp.id
|
|
<where>
|
|
<if test="id != null">
|
|
and qd.id = #{id}
|
|
</if>
|
|
<if test="quoteId != null">
|
|
and qd.quote_id = #{quoteId}
|
|
</if>
|
|
<if test="quoteNo != null and quoteNo != ''">
|
|
and qd.quote_no = #{quoteNo}
|
|
</if>
|
|
<if test="site != null and site != ''">
|
|
and qd.site = #{site}
|
|
</if>
|
|
<if test="buNo != null and buNo != ''">
|
|
and qd.bu_no = #{buNo}
|
|
</if>
|
|
<if test="versionNo != null and versionNo != ''">
|
|
and qd.version_no = #{versionNo}
|
|
</if>
|
|
</where>
|
|
order by qd.id desc
|
|
</select>
|
|
|
|
<select id="queryQuoteDetailByPage" resultType="com.xujie.sys.modules.quote.entity.QuoteDetail">
|
|
select qd.id,
|
|
qd.quote_id,
|
|
qd.site,
|
|
qd.bu_no,
|
|
qd.quote_no,
|
|
qd.version_no,
|
|
qd.item_no,
|
|
qd.part_id,
|
|
pp.test_part_no as partNo,
|
|
pp.part_desc,
|
|
qd.internal_inquiry_no,
|
|
qd.qty,
|
|
qd.quote_count,
|
|
qd.status,
|
|
qd.part_cost,
|
|
qd.adjust_part_cost,
|
|
qd.labour_cost,
|
|
qd.adjust_labour_cost,
|
|
qd.fabricate_cost,
|
|
qd.adjust_fabricate_cost,
|
|
qd.tool_cost,
|
|
qd.adjust_tool_cost,
|
|
qd.machine_cost,
|
|
qd.adjust_machine_cost,
|
|
qd.other_cost,
|
|
qd.manage_cost,
|
|
qd.total_cost,
|
|
qd.profit_rate,
|
|
qd.profit_amount,
|
|
qd.total_price,
|
|
qd.unit_price,
|
|
qd.tax_rate,
|
|
qd.tax_total_price,
|
|
qd.tax_unit_price,
|
|
qd.remark,
|
|
qd.active,
|
|
qd.create_by,
|
|
qd.create_date,
|
|
qd.update_by,
|
|
qd.update_date,
|
|
qd.pack_cost,
|
|
qd.shipping_cost,
|
|
qd.process_time,
|
|
qd.yield,
|
|
qd.bom_un_yield,
|
|
qd.bom_yield,
|
|
qd.parent_attrition_rate,
|
|
qd.child_attrition_rate,
|
|
qd.adjust_bom_un_yield,
|
|
qd.quote_cost,
|
|
qd.adjust_quote_cost,
|
|
qd.quote_total_cost,
|
|
qd.quote_profit_rate,
|
|
qd.quote_profit_amount,
|
|
qd.quote_total_price,
|
|
qd.quote_unit_price,
|
|
qd.quote_tax_rate,
|
|
qd.quote_tax_total_price,
|
|
qd.quote_tax_unit_price
|
|
from plm_quote_detail qd
|
|
left join plm_project_part pp on qd.part_id = pp.id
|
|
<where>
|
|
<if test="params.quoteId != null">
|
|
and qd.quote_id = #{params.quoteId}
|
|
</if>
|
|
<if test="params.quoteNo != null and params.quoteNo != ''">
|
|
and qd.quote_no = #{params.quoteNo}
|
|
</if>
|
|
<if test="params.site != null and params.site != ''">
|
|
and qd.site = #{params.site}
|
|
</if>
|
|
<if test="params.buNo != null and params.buNo != ''">
|
|
and qd.bu_no = #{params.buNo}
|
|
</if>
|
|
<if test="params.versionNo != null and params.versionNo != ''">
|
|
and qd.version_no = #{params.versionNo}
|
|
</if>
|
|
</where>
|
|
order by qd.id desc
|
|
</select>
|
|
|
|
<select id="queryItemNo" resultType="java.lang.Integer">
|
|
select ISNULL(max(item_no),0)+1 from plm_quote_detail where quote_id = #{quoteId}
|
|
</select>
|
|
|
|
<select id="getPartYield" resultType="java.math.BigDecimal">
|
|
select dbo.get_part_yield(#{site},#{partNo})
|
|
</select>
|
|
|
|
<select id="queryQuoteDetailReport" resultType="com.xujie.sys.modules.quote.entity.QuoteDetail">
|
|
select qd.id,
|
|
qd.site,
|
|
qd.bu_no,
|
|
qd.quote_id,
|
|
b.bu_desc,
|
|
q.quote_version_no,
|
|
q.customer_no,
|
|
c.customer_desc,
|
|
q.quote_date,
|
|
q.customer_inquiry_no,
|
|
qd.part_id,
|
|
pp.part_no,
|
|
pp.part_desc,
|
|
qd.status,
|
|
qd.create_by,
|
|
qd.create_date,
|
|
qd.update_by,
|
|
qd.update_date,
|
|
qd.remark,
|
|
q.remark as quoteRemark,
|
|
qd.internal_inquiry_no,
|
|
rh.required_completion_date,
|
|
rh.request_date,
|
|
(case rh.status
|
|
when 'C' then '草稿'
|
|
when 'B' then '已下达'
|
|
when 'A' then '已报价'
|
|
else '其他' end) as rfqStatus,
|
|
(case rh.status
|
|
when 'A' then '普通'
|
|
when 'B' then '重要'
|
|
when 'C' then '紧急'
|
|
else '其他' end) as priority_level,
|
|
dbo.get_requester_name(qd.site, rh.requester) as requesterName,
|
|
rh.remark as rfqRemark,
|
|
rd.id as rfq_detail_id
|
|
from plm_quote_detail qd
|
|
left join plm_quote q on qd.quote_id = q.id
|
|
left join plm_customer_information c on q.customer_no = c.customer_no and q.site = c.site
|
|
left join BU b on qd.bu_no = b.bu_no and b.site = qd.site
|
|
left join part pp on qd.part_id = pp.id
|
|
left join plm_rfq_header rh
|
|
on rh.site = qd.site and rh.bu_no = qd.bu_no and qd.internal_inquiry_no = rh.rfq_no
|
|
left join plm_rfq_detail rd on rh.id = rd.rfq_id and rd.site = qd.site and rd.test_part_id = qd.part_id
|
|
<where>
|
|
<if test="params.buId != null">
|
|
and b.id = #{params.buId}
|
|
</if>
|
|
<if test="params.quoteVersionNo != null and params.quoteVersionNo != ''">
|
|
and q.quote_version_no like #{params.quoteVersionNo}
|
|
</if>
|
|
<if test="params.customerNo != null and params.customerNo != ''">
|
|
and q.customer_no like #{params.customerNo}
|
|
</if>
|
|
<if test="params.customerDesc != null and params.customerDesc != ''">
|
|
and c.customer_desc like #{params.customerDesc}
|
|
</if>
|
|
<if test="params.status != null and params.status != ''">
|
|
and qd.status = #{params.status}
|
|
</if>
|
|
<if test="params.partNo != null and params.partNo != ''">
|
|
and pp.part_no like #{params.partNo}
|
|
</if>
|
|
<if test="params.partDesc != null and params.partDesc != ''">
|
|
and pp.part_desc like #{params.partDesc}
|
|
</if>
|
|
|
|
<if test="params.list != null and params.list.size() > 0">
|
|
and pp.part_no in (SELECT distinct p.part_no
|
|
FROM part p
|
|
LEFT JOIN BU b ON p.sourceBu = b.bu_no AND p.site = b.site
|
|
INNER JOIN part_sub_properties_value_header ph
|
|
ON p.part_no = ph.part_no AND p.site = ph.site AND
|
|
p.sourceBu = ph.bu_no
|
|
AND p.code_no = ph.code_no AND ph.record_type = 'IP'
|
|
inner join plm_properties_model_header pmh
|
|
on ph.site = pmh.site and ph.bu_no = pmh.bu_no and
|
|
ph.code_no = pmh.code_no and function_type = 'IP'
|
|
WHERE b.id = 1018
|
|
AND pmh.id = #{params.codeId}
|
|
<foreach collection="params.list" item="item">
|
|
AND EXISTS (
|
|
SELECT 1
|
|
FROM part_sub_properties_value pd
|
|
WHERE pd.part_no = p.part_no
|
|
AND pd.site = p.site
|
|
AND pd.bu_no = p.sourceBu
|
|
AND pd.code_no = p.code_no
|
|
AND pd.record_type = 'IP'
|
|
<if test="item.propertiesItemNo != null and item.propertiesItemNo != ''">
|
|
and pd.properties_item_no = #{item.propertiesItemNo}
|
|
</if>
|
|
<if test="item.textValue != null and item.textValue != ''">
|
|
and pd.text_value = #{item.textValue}
|
|
</if>
|
|
<if test="item.numValue != null">
|
|
and pd.num_value = #{item.numValue}
|
|
</if>
|
|
)
|
|
</foreach>
|
|
)
|
|
</if>
|
|
</where>
|
|
order by qd.id desc
|
|
</select>
|
|
|
|
<select id="queryQuoteDetailReportOverall" resultType="com.xujie.sys.modules.quote.entity.QuoteDetailOverall">
|
|
exec dbo.plm_calculate_quote_cost_overall #{site},#{quoteId},#{id}
|
|
</select>
|
|
|
|
<select id="queryQuoteDetailReportRM" resultType="com.xujie.sys.modules.quote.entity.QuoteDetailOverall">
|
|
exec dbo.plm_calculate_quote_cost_RM #{site},#{quoteId},#{id}
|
|
</select>
|
|
|
|
<select id="queryQuoteDetailReportTP" resultType="java.util.LinkedHashMap">
|
|
exec dbo.plm_calculate_quote_detail_TP #{id}
|
|
</select>
|
|
</mapper>
|