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.
 
 
 
 
 
 

276 lines
14 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.quotation.mapper.QuotationDetailMapper">
<resultMap id="quotationDetailVo" type="com.spring.modules.quotation.vo.QuotationDetailVo">
<id column="quotation_detail_id" jdbcType="INTEGER" property="quotationDetailId" />
<result column="quotation_header_id" jdbcType="INTEGER" property="quotationHeaderId" />
<result column="quotation_no" jdbcType="VARCHAR" property="quotationNo" />
<result column="site" jdbcType="VARCHAR" property="site" />
<result column="product_no" jdbcType="VARCHAR" property="productNo" />
<result column="product_desc" jdbcType="VARCHAR" property="productDesc" />
<result column="internal_inquiry_no" jdbcType="VARCHAR" property="internalInquiryNo" />
<result column="quotation_detail_quantity" jdbcType="DECIMAL" property="quotationDetailQuantity" />
<result column="quotation_detail_count" jdbcType="INTEGER" property="quotationDetailCount" />
<result column="quotation_detail_status" jdbcType="VARCHAR" property="quotationDetailStatus" />
<result column="compute_part_cost" jdbcType="DECIMAL" property="computePartCost" />
<result column="compute_labour_cost" jdbcType="DECIMAL" property="computeLabourCost" />
<result column="compute_fabricate_cost" jdbcType="DECIMAL" property="computeFabricateCost" />
<result column="compute_tool_cost" jdbcType="DECIMAL" property="computeToolCost" />
<result column="adjust_part_cost" jdbcType="DECIMAL" property="adjustPartCost" />
<result column="adjust_labour_cost" jdbcType="DECIMAL" property="adjustLabourCost" />
<result column="adjust_fabricate_cost" jdbcType="DECIMAL" property="adjustFabricateCost" />
<result column="adjust_tool_cost" jdbcType="DECIMAL" property="adjustToolCost" />
<result column="detail_other_cost" jdbcType="DECIMAL" property="detailOtherCost" />
<result column="detail_manage_cost" jdbcType="DECIMAL" property="detailManageCost" />
<result column="detail_total_cost" jdbcType="DECIMAL" property="detailTotalCost" />
<result column="detail_profit_rate" jdbcType="DECIMAL" property="detailProfitRate" />
<result column="detail_profit_amount" jdbcType="DECIMAL" property="detailProfitAmount" />
<result column="system_compute_amount" jdbcType="DECIMAL" property="systemComputeAmount" />
<result column="system_compute_price" jdbcType="DECIMAL" property="systemComputePrice" />
<result column="final_untaxed_price" jdbcType="DECIMAL" property="finalUntaxedPrice" />
<result column="final_taxed_price" jdbcType="DECIMAL" property="finalTaxedPrice" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="compute_machine_cost" jdbcType="DECIMAL" property="computeMachineCost" />
<result column="adjust_machine_cost" jdbcType="DECIMAL" property="adjustMachineCost" />
<result column="tax_rate" jdbcType="DECIMAL" property="taxRate" />
<collection property="quotationPartList" column="quotation_detail_id"
select="com.spring.modules.quotation.mapper.QuotationPartMapper.getQuotationPart"
ofType="com.spring.modules.quotation.entity.QuotationPart" >
</collection>
<collection property="quotationRoutingVoList" column="quotation_detail_id"
select="com.spring.modules.quotation.mapper.QuotationRoutingMapper.searchQuotationRoutingByDetailId"
ofType="com.spring.modules.quotation.vo.QuotationRoutingVo">
</collection>
<collection property="quotationToolList" column="quotation_detail_id"
select="com.spring.modules.quotation.mapper.QuotationToolMapper.getQuotationTool"
ofType="com.spring.modules.quotation.entity.QuotationTool">
</collection>
</resultMap>
<resultMap id="quotationDetail" type="com.spring.modules.quotation.vo.QuotationDetailVo">
<id column="quotation_detail_id" jdbcType="INTEGER" property="quotationDetailId" />
<result column="quotation_header_id" jdbcType="INTEGER" property="quotationHeaderId" />
<result column="site" jdbcType="VARCHAR" property="site" />
<result column="product_no" jdbcType="VARCHAR" property="productNo" />
<result column="product_desc" jdbcType="VARCHAR" property="productDesc" />
<result column="internal_inquiry_no" jdbcType="VARCHAR" property="internalInquiryNo" />
<result column="quotation_detail_quantity" jdbcType="DECIMAL" property="quotationDetailQuantity" />
<result column="quotation_detail_count" jdbcType="INTEGER" property="quotationDetailCount" />
<result column="quotation_detail_status" jdbcType="VARCHAR" property="quotationDetailStatus" />
<result column="compute_part_cost" jdbcType="DECIMAL" property="computePartCost" />
<result column="compute_labour_cost" jdbcType="DECIMAL" property="computeLabourCost" />
<result column="compute_fabricate_cost" jdbcType="DECIMAL" property="computeFabricateCost" />
<result column="compute_tool_cost" jdbcType="DECIMAL" property="computeToolCost" />
<result column="adjust_part_cost" jdbcType="DECIMAL" property="adjustPartCost" />
<result column="adjust_labour_cost" jdbcType="DECIMAL" property="adjustLabourCost" />
<result column="adjust_fabricate_cost" jdbcType="DECIMAL" property="adjustFabricateCost" />
<result column="adjust_tool_cost" jdbcType="DECIMAL" property="adjustToolCost" />
<result column="detail_other_cost" jdbcType="DECIMAL" property="detailOtherCost" />
<result column="detail_manage_cost" jdbcType="DECIMAL" property="detailManageCost" />
<result column="detail_total_cost" jdbcType="DECIMAL" property="detailTotalCost" />
<result column="detail_profit_rate" jdbcType="DECIMAL" property="detailProfitRate" />
<result column="detail_profit_amount" jdbcType="DECIMAL" property="detailProfitAmount" />
<result column="system_compute_amount" jdbcType="DECIMAL" property="systemComputeAmount" />
<result column="system_compute_price" jdbcType="DECIMAL" property="systemComputePrice" />
<result column="final_untaxed_price" jdbcType="DECIMAL" property="finalUntaxedPrice" />
<result column="final_taxed_price" jdbcType="DECIMAL" property="finalTaxedPrice" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="compute_machine_cost" jdbcType="DECIMAL" property="computeMachineCost" />
<result column="adjust_machine_cost" jdbcType="DECIMAL" property="adjustMachineCost" />
<result column="tax_rate" jdbcType="DECIMAL" property="taxRate" />
<result column="active" property="active" />
</resultMap>
<select id="getQuotationDetailVoList" resultMap="quotationDetailVo">
select
qd.quotation_detail_id,
qd.quotation_header_id,
qh.quotation_no,
qd.site,
qd.product_no,
qd.product_desc,
qd.internal_inquiry_no,
qd.quotation_detail_quantity,
qd.quotation_detail_count,
qd.quotation_detail_status,
qd.compute_part_cost,
qd.compute_labour_cost,
qd.compute_fabricate_cost,
qd.compute_tool_cost,
qd.adjust_part_cost,
qd.adjust_labour_cost,
qd.adjust_fabricate_cost,
qd.adjust_tool_cost,
qd.detail_other_cost,
qd.detail_manage_cost,
qd.detail_total_cost,
qd.detail_profit_rate,
qd.detail_profit_amount,
qd.system_compute_amount,
qd.system_compute_price,
qd.final_untaxed_price,
qd.final_taxed_price,
qd.remark,
qd.compute_machine_cost,
qd.adjust_machine_cost,
qd.tax_rate
from dbo.quotation_detail qd
left join dbo.quotation_header qh on qd.quotation_header_id = qh.quotation_header_id
left join dbo.view_Project_Part ppp on qd.product_no = ppp.test_part_no and qd.site = ppp.site
<where>
qd.site = #{site} and qd.active = 'Y' and qh.active = 'Y'
<if test="quotationDetailId != null">
and qd.quotation_detail_id &lt;&gt; #{quotationDetailId}
</if>
<if test="quotationHeaderId != null">
and qd.quotation_header_id &lt;&gt; #{quotationHeaderId}
</if>
<if test="quotationNo != null and quotationNo != ''">
and qh.quotation_no like #{quotationNo}
</if>
<if test="productNo != null and productNo != ''">
and qd.product_no like #{productNo}
</if>
<if test="internalInquiryNo != null and internalInquiryNo != ''">
and qd.internal_inquiry_no like #{internalInquiryNo}
</if>
<if test="productDesc != null and productDesc != ''">
and qd.product_desc like #{productDesc}
</if>
order by qh.quotation_no desc
</where>
</select>
<select id="getQuotationDetailVoListByInternalInquiryNo" resultMap="quotationDetailVo">
select
qd.quotation_detail_id,
qd.quotation_header_id,
qh.quotation_no,
qd.site,
qd.product_no,
qd.product_desc,
qd.internal_inquiry_no,
qd.quotation_detail_quantity,
qd.quotation_detail_count,
qd.quotation_detail_status,
qd.compute_part_cost,
qd.compute_labour_cost,
qd.compute_fabricate_cost,
qd.compute_tool_cost,
qd.adjust_part_cost,
qd.adjust_labour_cost,
qd.adjust_fabricate_cost,
qd.adjust_tool_cost,
qd.detail_other_cost,
qd.detail_manage_cost,
qd.detail_total_cost,
qd.detail_profit_rate,
qd.detail_profit_amount,
qd.system_compute_amount,
qd.system_compute_price,
qd.final_untaxed_price,
qd.final_taxed_price,
qd.remark,
qd.compute_machine_cost,
qd.adjust_machine_cost,
qd.tax_rate
from dbo.quotation_detail qd
left join dbo.quotation_header qh on qd.quotation_header_id = qh.quotation_header_id
left join dbo.view_Project_Part ppp on qd.product_no = ppp.test_part_no and qd.site = ppp.site
where qd.internal_inquiry_no &lt;&gt; '' and qd.site = #{site} and qd.active = 'Y' and qh.active = 'Y'
<if test="quotationNo != null and quotationNo != ''">
and qh.quotation_no like #{quotationNo}
</if>
<if test="productNo != null and productNo != ''">
and qd.product_no like #{productNo}
</if>
<if test="internalInquiryNo != null and internalInquiryNo != ''">
and qd.internal_inquiry_no like #{internalInquiryNo}
</if>
<if test="productDesc != null and productDesc != ''">
and qd.product_desc like #{productDesc}
</if>
order by qh.quotation_no desc
</select>
<select id="getQuotationDetailVoListByPage" resultMap="quotationDetail">
select quotation_detail_id,
quotation_header_id,
site,
product_no,
dbo.get_part_name(site, product_no) as product_desc,
internal_inquiry_no,
quotation_detail_quantity,
quotation_detail_count,
quotation_detail_status,
compute_part_cost,
compute_labour_cost,
compute_fabricate_cost,
compute_tool_cost,
adjust_part_cost,
adjust_labour_cost,
adjust_fabricate_cost,
adjust_tool_cost,
detail_other_cost,
detail_manage_cost,
detail_total_cost,
detail_profit_rate,
detail_profit_amount,
system_compute_amount,
system_compute_price,
final_untaxed_price,
final_taxed_price,
remark,
compute_machine_cost,
adjust_machine_cost,
tax_rate,
active
from quotation_detail qd
<where>
and active = 'Y'
<if test="quotationHeaderId != null">
and quotation_header_id = #{quotationHeaderId}
</if>
</where>
order by quotation_detail_id
</select>
<insert id="handleSavePropertiesHeader">
INSERT INTO PartSubPropertiesValueHeader
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
SELECT
concat('BJ',#{quotationDetailId}),
site,
code_no,
1,
code_desc,
function_type
FROM plm_properties_model_header
WHERE function_type = 'BJ'
AND code_no = 'BJ001'
AND site = #{site}
</insert>
<insert id="handleSavePropertiesDetail">
INSERT INTO PartSubPropertiesValue
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
select concat('BJ',#{quotationDetailId}),ppmd.site,ppmd.code_no,1,ppmh.code_desc,seq_no,properties_item_no,'','',ppmd.function_type
from plm_properties_model_detail ppmd
left join plm_properties_model_header ppmh on ppmh.function_type = ppmd.function_type and ppmh.code_no = ppmd.code_no and ppmh.site = ppmd.site
WHERE ppmd.function_type = 'BJ'
AND ppmd.code_no = 'BJ001'
AND ppmd.site = #{site}
</insert>
<delete id="removePropertiesHeader">
delete from PartSubPropertiesValueHeader where PartNo = concat('BJ',#{quotationDetailId})
</delete>
<delete id="removePropertiesDetail">
delete from PartSubPropertiesValue where PartNo = concat('BJ',#{quotationDetailId})
</delete>
</mapper>