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.
 
 
 
 
 
 

122 lines
4.4 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.QuoteDetailToolMapper">
<select id="queryQuoteDetailTool" resultType="com.spring.modules.quote.entity.QuoteDetailTool">
select qdt.id,
qdt.quote_detail_id,
qdt.quote_id,
qdt.quote_no,
qdt.site,
qdt.bu_no,
qdt.version_no,
qdt.quote_detail_item_no,
qdt.tool_no,
qdt.item_no,
qdt.tool_desc,
qdt.tool_qty,
qdt.tool_spec,
qdt.unit_cost,
qdt.expected_service_life,
qdt.quote_unit_cost,
qdt.remark
from plm_quote_detail_tool qdt
<where>
<if test="quoteDetailId != null">
and qdt.quote_detail_id = #{quoteDetailId}
</if>
<if test="quoteNo != null and quoteNo != ''">
and quote_no = #{quoteNo}
</if>
<if test="site != null and site != ''">
and site = #{site}
</if>
<if test="buNo != null and buNo != ''">
and bu_no = #{buNo}
</if>
<if test="quoteId != null ">
and qdt.quote_id = #{quoteId}
</if>
<if test="versionNo != null and versionNo != ''">
and version_no = #{versionNo}
</if>
<if test="quoteDetailItemNo">
and quote_detail_item_no = #{quoteDetailItemNo}
</if>
</where>
order by qdt.item_no desc
</select>
<select id="queryItemNo" resultType="int">
select isnull(max(item_no),0)+1 from plm_quote_detail_tool where quote_detail_id = #{quoteDetailId}
</select>
<select id="queryToolList" resultType="com.spring.modules.quote.entity.QuoteDetailTool">
select
t.tool_id as toolNo,
t.tool_description as toolDesc,
t.Spec as toolSpec,
t.standard_cost as unitCost
from tool_header t
<where>
site = #{site}
<if test="toolNo != null and toolNo != ''">
and t.tool_id like #{toolNo}
</if>
<if test="toolDesc != null and toolDesc != ''">
and t.tool_description like #{toolDesc}
</if>
</where>
</select>
<insert id="saveToolByRouting">
insert into plm_quote_detail_tool
(quote_detail_id, quote_id, quote_no, site, bu_no, version_no, quote_detail_item_no, tool_no, item_no, tool_desc, tool_qty, tool_spec, unit_cost, expected_service_life, quote_unit_cost, remark, create_by, create_date, update_by, update_date)
select
#{quoteDetailId},
#{quoteId},
#{quoteNo},
#{site},
#{buNo},
#{versionNo},
#{quoteDetailItemNo},
'',
row_number() over (ORDER BY rt.id),
th.tool_description,
rt.tool_qty,
'',
isnull(th.standard_cost,0),
0,
case when rt.tool_qty = 0 then 0 else th.standard_cost / rt.tool_qty end,
null,
#{createBy},
#{createDate},
null,
null
from routing_tool rt
left join tool_header th on rt.tool_id = th.tool_id and rt.site = th.site
where rt.site = #{site}
and rt.part_no = #{partNo}
and rt.routing_revision = #{routingRevision}
and rt.routing_type = #{routingType}
and rt.alternative_no = #{alternativeNo}
</insert>
<select id="queryToolListByPage" resultType="com.spring.modules.quote.entity.QuoteDetailTool">
select
t.tool_id as toolNo,
t.tool_description as toolDesc,
t.Spec as toolSpec,
t.standard_cost as unitCost
from tool_header t
<where>
site = #{params.site}
<if test="params.toolNo != null and params.toolNo != ''">
and t.tool_id like #{params.toolNo}
</if>
<if test="params.toolDesc != null and params.toolDesc != ''">
and t.tool_description like #{params.toolDesc}
</if>
</where>
</select>
</mapper>