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.
496 lines
20 KiB
496 lines
20 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.quote.mapper.QuoteDetailMapper">
|
|
|
|
<select id="queryQuoteDetail" resultType="com.spring.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 as partNo,
|
|
pp.part_desc,
|
|
pp.plm_part_no,
|
|
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.show_flag,
|
|
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,
|
|
qd.currency1,
|
|
dbo.plm_get_dictDataLabel('plm_customer_information_customer_customer_currency', qd.currency1, qd.site) as currencyDesc1,
|
|
qd.final_transaction_price,
|
|
qd.exchange_rate1,
|
|
qd.currency2,
|
|
dbo.plm_get_dictDataLabel('plm_customer_information_customer_customer_currency', qd.currency2, qd.site) as currencyDesc2,
|
|
qd.exchange_rate2,
|
|
qd.moq,
|
|
qd.currency_total_cost1,
|
|
qd.currency_total_cost2,
|
|
qd.quote_currency_total_cost1,
|
|
qd.quote_currency_total_cost2,
|
|
qd.calculated_items,
|
|
qd.test_cost,
|
|
qd.adjust_test_cost,
|
|
qd.else_cost,
|
|
qd.adjust_else_cost,
|
|
pp.plm_part_no,
|
|
pp.ifs_part_no,
|
|
convert(decimal(20,6),(case when exchange_rate2 = 0 or exchange_rate2 is null then 0 else unit_price/exchange_rate2 end)) as unitPriceRate
|
|
from plm_quote_detail qd
|
|
left join plm_quote q on qd.quote_id = q.id
|
|
left join part pp on qd.part_no = pp.part_no and qd.site = pp.site
|
|
<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>
|
|
<if test="quoteGroupDetailId != null">
|
|
and qd.quote_group_detail_id = #{quoteGroupDetailId}
|
|
</if>
|
|
</where>
|
|
order by qd.id
|
|
</select>
|
|
|
|
<select id="queryQuoteDetailByPage" resultType="com.spring.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 as partNo,
|
|
pp.part_desc,
|
|
pp.plm_part_no,
|
|
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.show_flag,
|
|
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,
|
|
qd.currency1,
|
|
dbo.plm_get_dictDataLabel('plm_customer_information_customer_customer_currency', qd.currency1,
|
|
qd.site) as currencyDesc1,
|
|
qd.exchange_rate1,
|
|
qd.currency2,
|
|
dbo.plm_get_dictDataLabel('plm_customer_information_customer_customer_currency', qd.currency2,
|
|
qd.site) as currencyDesc2,
|
|
qd.exchange_rate2,
|
|
qd.moq,
|
|
qd.currency_total_cost1,
|
|
qd.currency_total_cost2,
|
|
qd.quote_currency_total_cost1,
|
|
qd.quote_currency_total_cost2,
|
|
qd.calculated_items,
|
|
qd.test_cost,
|
|
qd.adjust_test_cost,
|
|
qd.else_cost,
|
|
qd.adjust_else_cost
|
|
from plm_quote_detail qd
|
|
left join plm_quote q on qd.quote_id = q.id
|
|
left join part pp
|
|
on qd.part_no = pp.part_no and qd.site = pp.site
|
|
<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>
|
|
<if test="params.quoteGroupDetailId != null">
|
|
and qd.quote_group_detail_id = #{params.quoteGroupDetailId}
|
|
</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="queryQuoteDetailByInquiry" resultType="com.spring.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 as partNo,
|
|
pp.part_desc,
|
|
pp.plm_part_no,
|
|
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.show_flag,
|
|
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,
|
|
qd.currency1,
|
|
dbo.plm_get_dictDataLabel('plm_customer_information_customer_customer_currency', qd.currency1,
|
|
qd.site) as currencyDesc1,
|
|
qd.exchange_rate1,
|
|
qd.currency2,
|
|
dbo.plm_get_dictDataLabel('plm_customer_information_customer_customer_currency', qd.currency2,
|
|
qd.site) as currencyDesc2,
|
|
qd.exchange_rate2,
|
|
qd.moq,
|
|
qd.currency_total_cost1,
|
|
qd.currency_total_cost2,
|
|
qd.quote_currency_total_cost1,
|
|
qd.quote_currency_total_cost2,
|
|
q.quote_date,
|
|
q.quote_version_no,
|
|
q.inside_inquiry_no,
|
|
qd.calculated_items,
|
|
qd.test_cost,
|
|
qd.adjust_test_cost,
|
|
qd.else_cost,
|
|
qd.adjust_else_cost,
|
|
pp.ifs_part_no,
|
|
convert(decimal(20,6),(case when exchange_rate2 = 0 or exchange_rate2 is null then 0 else unit_price/exchange_rate2 end)) as unitPriceRate
|
|
|
|
from plm_quote q
|
|
left join plm_quote_detail qd on qd.quote_id = q.id
|
|
left join part pp
|
|
on qd.part_no = pp.part_no and qd.site = pp.site
|
|
<where>
|
|
and qd.status = '已完成'
|
|
<if test="site != null and site != ''">
|
|
and qd.site = #{site}
|
|
</if>
|
|
<if test="internalInquiryNo != null and internalInquiryNo != ''">
|
|
and q.inside_inquiry_no = #{internalInquiryNo}
|
|
</if>
|
|
<if test="projectNo != null and projectNo != ''">
|
|
and q.project_no = #{projectNo}
|
|
</if>
|
|
<if test="partNo != null and partNo != ''">
|
|
and pp.plm_part_no = #{partNo}
|
|
</if>
|
|
</where>
|
|
order by qd.part_no
|
|
</select>
|
|
|
|
<update id="updateShowFlag">
|
|
UPDATE plm_quote_detail
|
|
SET show_flag = #{showFlag}
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<!-- 报价明细查询报表 -->
|
|
<select id="queryQuoteDetailReport" resultType="com.spring.modules.quote.vo.QuoteDetailReportVo">
|
|
SELECT
|
|
q.site,
|
|
q.bu_no as buNo,
|
|
q.quote_version_no as quoteVersionNo,
|
|
q.customer_no as customerNo,
|
|
c.customer_desc as customerDesc,
|
|
q.project_no as projectNo,
|
|
p.project_name as projectDesc,
|
|
q.status,
|
|
pp.plm_part_no as plmPartNo,
|
|
pp.ifs_part_no as ifsPartNo,
|
|
pp.part_desc as partDesc,
|
|
qd.qty,
|
|
qd.adjust_part_cost as adjustPartCost,
|
|
qd.adjust_labour_cost as adjustLabourCost,
|
|
qd.adjust_machine_cost as adjustMachineCost,
|
|
qd.adjust_tool_cost as adjustToolCost,
|
|
qd.adjust_test_cost as adjustTestCost,
|
|
qd.pack_cost as packCost,
|
|
qd.shipping_cost as shippingCost,
|
|
qd.adjust_else_cost as adjustElseCost,
|
|
qd.total_cost as totalCost,
|
|
qd.final_transaction_price as finalTransactionPrice,
|
|
qd.quote_profit_rate as quoteProfitRate,
|
|
qd.quote_profit_amount as quoteProfitAmount,
|
|
qd.quote_tax_rate as quoteTaxRate,
|
|
qd.quote_tax_total_price as quoteTaxTotalPrice,
|
|
qd.unit_price as unitPrice,
|
|
qd.tax_rate as taxRate,
|
|
qd.tax_unit_price as taxUnitPrice
|
|
FROM plm_quote q
|
|
INNER JOIN plm_quote_detail qd ON q.id = qd.quote_id
|
|
LEFT JOIN plm_customer_information c ON q.customer_no = c.customer_no
|
|
LEFT JOIN plm_project_info p ON q.project_no = p.project_id AND q.site = p.site
|
|
LEFT JOIN part pp ON pp.part_no = qd.part_no AND pp.site = qd.site
|
|
<where>
|
|
<if test="query.site != null and query.site != ''">
|
|
AND q.site = #{query.site}
|
|
</if>
|
|
<if test="query.quoteVersionNo != null and query.quoteVersionNo != ''">
|
|
AND q.quote_version_no LIKE #{query.quoteVersionNo}
|
|
</if>
|
|
<if test="query.customerNo != null and query.customerNo != ''">
|
|
AND q.customer_no LIKE #{query.customerNo}
|
|
</if>
|
|
<if test="query.customerDesc != null and query.customerDesc != ''">
|
|
AND c.customer_desc LIKE #{query.customerDesc}
|
|
</if>
|
|
<if test="query.projectNo != null and query.projectNo != ''">
|
|
AND q.project_no LIKE #{query.projectNo}
|
|
</if>
|
|
<if test="query.projectDesc != null and query.projectDesc != ''">
|
|
AND p.project_name LIKE #{query.projectDesc}
|
|
</if>
|
|
<if test="query.quoter != null and query.quoter != ''">
|
|
AND dbo.plm_get_user_display(q.site, q.quoter) LIKE #{query.quoter}
|
|
</if>
|
|
<if test="query.status != null and query.status != ''">
|
|
AND q.status = #{query.status}
|
|
</if>
|
|
<if test="query.startDate != null and query.startDate != ''">
|
|
AND q.quote_date >= #{query.startDate}
|
|
</if>
|
|
<if test="query.endDate != null and query.endDate != ''">
|
|
AND q.quote_date <= #{query.endDate}
|
|
</if>
|
|
<if test="query.insideInquiryNo != null and query.insideInquiryNo != ''">
|
|
AND q.inside_inquiry_no LIKE #{query.insideInquiryNo}
|
|
</if>
|
|
<if test="query.partNo != null and query.partNo != ''">
|
|
AND (pp.part_no LIKE #{query.partNo} OR pp.plm_part_no LIKE #{query.partNo} OR pp.ifs_part_no LIKE #{query.partNo})
|
|
</if>
|
|
</where>
|
|
ORDER BY q.quote_version_no DESC, qd.item_no ASC
|
|
</select>
|
|
|
|
<!-- 报价明细查询报表导出 -->
|
|
<select id="queryQuoteDetailReportList" resultType="com.spring.modules.quote.vo.QuoteDetailReportVo">
|
|
SELECT
|
|
q.site,
|
|
q.bu_no as buNo,
|
|
q.quote_version_no as quoteVersionNo,
|
|
q.customer_no as customerNo,
|
|
c.customer_desc as customerDesc,
|
|
q.project_no as projectNo,
|
|
p.project_name as projectDesc,
|
|
q.status,
|
|
pp.plm_part_no as plmPartNo,
|
|
pp.ifs_part_no as ifsPartNo,
|
|
pp.part_desc as partDesc,
|
|
qd.qty,
|
|
qd.adjust_part_cost as adjustPartCost,
|
|
qd.adjust_labour_cost as adjustLabourCost,
|
|
qd.adjust_machine_cost as adjustMachineCost,
|
|
qd.adjust_tool_cost as adjustToolCost,
|
|
qd.adjust_test_cost as adjustTestCost,
|
|
qd.pack_cost as packCost,
|
|
qd.shipping_cost as shippingCost,
|
|
qd.adjust_else_cost as adjustElseCost,
|
|
qd.total_cost as totalCost,
|
|
qd.final_transaction_price as finalTransactionPrice,
|
|
qd.quote_profit_rate as quoteProfitRate,
|
|
qd.quote_profit_amount as quoteProfitAmount,
|
|
qd.quote_tax_rate as quoteTaxRate,
|
|
qd.quote_tax_total_price as quoteTaxTotalPrice,
|
|
qd.unit_price as unitPrice,
|
|
qd.tax_rate as taxRate,
|
|
qd.tax_unit_price as taxUnitPrice
|
|
FROM plm_quote q
|
|
INNER JOIN plm_quote_detail qd ON q.id = qd.quote_id
|
|
LEFT JOIN plm_customer_information c ON q.customer_no = c.customer_no
|
|
LEFT JOIN plm_project_info p ON q.project_no = p.project_id AND q.site = p.site
|
|
LEFT JOIN part pp ON pp.part_no = qd.part_no AND pp.site = qd.site
|
|
<where>
|
|
<if test="query.site != null and query.site != ''">
|
|
AND q.site = #{query.site}
|
|
</if>
|
|
<if test="query.quoteVersionNo != null and query.quoteVersionNo != ''">
|
|
AND q.quote_version_no LIKE #{query.quoteVersionNo}
|
|
</if>
|
|
<if test="query.customerNo != null and query.customerNo != ''">
|
|
AND q.customer_no LIKE #{query.customerNo}
|
|
</if>
|
|
<if test="query.customerDesc != null and query.customerDesc != ''">
|
|
AND c.customer_desc LIKE #{query.customerDesc}
|
|
</if>
|
|
<if test="query.projectNo != null and query.projectNo != ''">
|
|
AND q.project_no LIKE #{query.projectNo}
|
|
</if>
|
|
<if test="query.projectDesc != null and query.projectDesc != ''">
|
|
AND p.project_name LIKE #{query.projectDesc}
|
|
</if>
|
|
<if test="query.quoter != null and query.quoter != ''">
|
|
AND dbo.plm_get_user_display(q.site, q.quoter) LIKE #{query.quoter}
|
|
</if>
|
|
<if test="query.status != null and query.status != ''">
|
|
AND q.status = #{query.status}
|
|
</if>
|
|
<if test="query.startDate != null and query.startDate != ''">
|
|
AND q.quote_date >= #{query.startDate}
|
|
</if>
|
|
<if test="query.endDate != null and query.endDate != ''">
|
|
AND q.quote_date <= #{query.endDate}
|
|
</if>
|
|
<if test="query.insideInquiryNo != null and query.insideInquiryNo != ''">
|
|
AND q.inside_inquiry_no LIKE #{query.insideInquiryNo}
|
|
</if>
|
|
<if test="query.partNo != null and query.partNo != ''">
|
|
AND (pp.part_no LIKE #{query.partNo} OR pp.plm_part_no LIKE #{query.partNo} OR pp.ifs_part_no LIKE #{query.partNo})
|
|
</if>
|
|
</where>
|
|
ORDER BY q.quote_version_no DESC, qd.item_no ASC
|
|
</select>
|
|
</mapper>
|