O
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.
 
 
 
 
 
 

454 lines
18 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.part.mapper.QuicklyCreateBomMapper">
<!-- 获取所有节点 -->
<select id="getNodeTree" resultType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity" parameterType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity">
SELECT
a.site,
b.sourceBu as buNo,
a.template_no,
a.node_id,
a.node_name,
a.main_part,
a.part_no,
b.part_desc,
a.id,
a.p_id,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
b.umid2 as printUnit,
dbo.qc_get_um_name(a.site, b.umid2) as printUnitName,
a.eng_chg_level,
a.routing_revision
FROM plm_quickly_bom_Info as a
left join part as b on a.site = b.site and a.part_no = b.part_no
<where>
a.site = #{site} AND a.main_part = #{mainPart}
<if test="nodeId != null and nodeId != ''">
AND a.node_id = #{nodeId}
</if>
</where>
</select>
<!-- 获得id -->
<select id="getSonId" parameterType="BomNodeEntity" resultType="java.lang.String">
SELECT MAX(
CAST(
RIGHT(id, LEN(id) - CHARINDEX('-', id, LEN(#{pId}) + 1)) AS INT
)
) AS maxSubId
FROM plm_quickly_bom_Info
WHERE site = #{site}
AND id LIKE #{pId} + '-%'
AND CHARINDEX('-', id, LEN(#{pId}) + 2) = 0
</select>
<!-- 新增节点 -->
<insert id="saveNewNode" parameterType="BomNodeEntity">
INSERT INTO plm_bom_node (site, node_id, node_name, part_no, id, p_id, create_date, create_by)
VALUES (#{site}, #{nodeId}, #{nodeName}, #{partNo}, #{id}, #{pId}, getDate(), #{createBy})
</insert>
<update id="nodeEdit" parameterType="BomNodeEntity">
UPDATE plm_quickly_bom_Info
SET node_name = #{nodeName},
update_date = getDate(),
update_by = #{updateBy}
WHERE site = #{site} and main_part = #{mainPart} and node_id = #{nodeId}
</update>
<!-- 删除该节点以及其子节点-->
<delete id="nodeDelete" parameterType="BomNodeEntity">
DELETE FROM plm_quickly_bom_Info
WHERE site = #{site} and main_part = #{mainPart}
<if test="id != null and id != ''">
and (id like #{id} + '-%' or id = #{id})
</if>
</delete>
<select id="getBomInformationByPartNo" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo" parameterType="com.xujie.sys.modules.part.vo.BomHeaderVo">
SELECT top 1
a.site,
a.bu_no,
dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
a.part_no,
b.part_desc,
a.eng_chg_level,
a.bom_type,
a.note_text,
a.eff_phase_in_date,
a.eff_phase_out_date,
a.eng_revision,
a.type_flag,
a.net_weight,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
b.umid2 as printUnit,
dbo.qc_get_um_name(a.site, b.umid2) as printUnitName,
isnull(dbo.get_yield_rate(a.site, a.bu_no, b.product_group_id2, '2'), 100) as yieldRate,
a.process_unit,
c.UMName as processUnitName
FROM plm_bom_header as a
left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
left join plm_bom_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.eng_chg_level = d.eng_chg_level and a.bom_type = d.bom_type
left join UM as c on a.site = c.site and a.process_unit = c.UMID
<where>
a.site = #{site}
<if test="buNo != null and buNo != ''">
and a.bu_no = #{buNo}
</if>
<if test="partNo != null and partNo != ''">
and a.part_no = #{partNo}
</if>
<if test="bomType != null and bomType != ''">
and a.bom_type = #{bomType}
</if>
</where>
order by a.eng_chg_level desc
</select>
<update id="updateBomNodePart">
UPDATE plm_quickly_bom_Info
SET part_no = #{partNo}
WHERE site = #{site} and main_part = #{mainPart} and node_id = #{nodeId}
</update>
<select id="getRoutingInformationByPartNo" resultType="com.xujie.sys.modules.part.vo.RoutingHeaderVo" parameterType="com.xujie.sys.modules.part.vo.RoutingHeaderVo">
SELECT top 1
a.site,
a.bu_no,
dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
a.part_no,
b.part_desc,
a.routing_revision,
a.routing_type,
a.note_text,
a.phase_in_date,
a.phase_out_date,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
b.umid2 as printUnit,
dbo.qc_get_um_name(a.site, b.umid2) as printUnitName,
b.code_no
FROM plm_routing_header as a
left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
left join plm_routing_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.routing_revision = d.routing_revision and a.routing_type = d.routing_type
<where>
a.site = #{site}
<if test="buNo != null and buNo != ''">
and a.bu_no = #{buNo}
</if>
<if test="partNo != null and partNo != ''">
and a.part_no = #{partNo}
</if>
<if test="routingType != null and routingType != ''">
and a.routing_type = #{routingType}
</if>
</where>
order by a.routing_revision desc
</select>
<update id="resetNodePartInfo" >
UPDATE plm_bom_node
SET part_no = ''
WHERE Site = #{site}
</update>
<select id="getBomTemplateDetail" resultType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity">
SELECT
pbtd.site,
pbtd.template_no,
pbtd.node_id,
pbn.node_name,
pbtd.id,
pbtd.p_id,
#{partNo} as mainPart,
#{createBy} as createBy
FROM plm_bom_template_detail as pbtd left join plm_bom_node as pbn on pbtd.site = pbn.site and pbtd.node_id = pbn.node_id
where pbtd.site = #{site} and pbtd.template_no = #{templateNo}
</select>
<insert id="saveQuicklyBomInfo">
insert into plm_quickly_bom_Info
(site, template_no, node_id, main_part, part_no, id, p_id, create_date, create_by, node_name, eng_chg_level, routing_revision)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.templateNo}, #{item.nodeId}, #{item.mainPart},
<choose>
<when test='item.pId.toString() == "0"'>
#{item.mainPart}
</when>
<otherwise>
#{item.partNo}
</otherwise>
</choose>
, #{item.id}, #{item.pId}, getDate(), #{item.createBy}, #{item.nodeName}, 1, 1)
</foreach>
</insert>
<insert id="saveTemplateHeader" parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
insert into plm_template_header
(site, bu_no, template_no, template_name) VALUES (#{site}, #{buNo}, #{templateNo}, #{templateName})
</insert>
<insert id="saveTemplateDetail" parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
insert into plm_template_detail
(site, bu_no, template_no, um_id, family_id, product_group_id1, product_group_id2, product_group_id3, code_no, bom_template_no)
VALUES (#{site}, #{buNo}, #{templateNo}, #{umId}, #{familyId}, #{productGroupId1}, #{productGroupId2}, #{productGroupId3}, #{codeNo}, #{bomTemplateNo})
</insert>
<update id="updateTemplateHeader" parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
UPDATE plm_template_header
SET template_name = #{templateName}
WHERE site = #{site} AND bu_no = #{buNo} AND template_no = #{templateNo}
</update>
<delete id="deleteTemplateDetail" parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
DELETE FROM plm_template_detail
WHERE site = #{site} AND bu_no = #{buNo} AND template_no = #{templateNo}
</delete>
<delete id="deleteQuicklyBomInfo">
DELETE FROM plm_quickly_bom_Info
WHERE site = #{site} and main_part = #{partNo}
</delete>
<delete id="deletePartSubPropertiesValue"
parameterType="com.xujie.sys.modules.part.entity.PartSubPropertiesValueData">
delete from part_sub_properties_value
WHERE site = #{site} and part_no = #{partNo} and bu_no = #{buNo} and record_type = #{recordType}
</delete>
<select id="getPartInfoByNo" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
SELECT
a.id,
a.site,
a.sourceBu as buNo,
a.part_no,
a.part_desc,
a.umid2 as umId2,
um.UMName as umName,
a.spec,
a.active,
a.remark,
a.part_type2,
a.product_group_id1,
dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id1, '1') as productGroupName1,
a.product_group_id2,
dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id2, '2') as productGroupName2,
a.product_group_id3,
dbo.get_product_group_name(a.site, a.sourceBu, a.product_group_id3, '3') as productGroupName3,
a.FamilyID as familyID,
pf.family_name as familyName,
a.part_desce_en,
a.code_no,
dbo.get_code_desc(a.site, a.sourceBu, a.code_no, 'IP') as codeDesc,
a.template_no,
pbt.template_name
FROM part as a
LEFT JOIN UM as um on a.site = um.site and a.umid2 = um.UMID
LEFT JOIN part_family as pf on a.site = pf.site and a.sourceBu = pf.bu_no and a.FamilyID = pf.family_id
LEFT JOIN plm_bom_template as pbt on a.site = pbt.site and a.template_no = pbt.template_no
where a.site = #{site} and a.part_no = #{partNo}
</select>
<select id="findNode" resultType="com.xujie.sys.modules.part.entity.BomNodeEntity"
parameterType="com.xujie.sys.modules.part.entity.BomNodeEntity">
select site,
node_id,
node_name,
part_no,
id,
p_id
from plm_bom_node
where site = #{site} and node_id = #{nodeId} and id = #{id}
</select>
<select id="deletePartSubPropertiesValueHeader">
delete from part_sub_properties_value_header
where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and code_no = #{codeNo} and record_type = #{recordType} and sub_code_seq_no = 1
</select>
<select id="getTemplateList" resultType="com.xujie.sys.modules.part.vo.TemplateVo"
parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
select template_no,
template_name
from plm_template_header
where site = #{site} and bu_no = #{buNo}
</select>
<select id="chooseTemplate" resultType="com.xujie.sys.modules.part.vo.TemplateVo"
parameterType="com.xujie.sys.modules.part.vo.TemplateVo">
select ptd.*,
um.UmName as umName,
pf.family_name as familyName,
dbo.get_product_group_name(ptd.site, ptd.bu_no, ptd.product_group_id1, '1') as productGroupName1,
dbo.get_product_group_name(ptd.site, ptd.bu_no, ptd.product_group_id2, '2') as productGroupName2,
dbo.get_product_group_name(ptd.site, ptd.bu_no, ptd.product_group_id3, '3') as productGroupName3,
dbo.get_code_desc(ptd.site, ptd.bu_no, ptd.code_no, 'IP') as codeDesc,
pbt.template_name as bomTemplateName
from plm_template_detail as ptd
left join UM as um on ptd.site = um.site and ptd.um_id = um.UMID
left join part_family as pf on ptd.site = pf.site and ptd.bu_no = pf.bu_no and ptd.family_id = pf.family_id
left join plm_bom_template as pbt on ptd.site = pbt.site and ptd.bom_template_no = pbt.template_no
where ptd.site = #{site} and ptd.bu_no = #{buNo} and ptd.template_no = #{tempNo}
</select>
<select id="getBomInformationListByPartNo" resultType="com.xujie.sys.modules.part.vo.BomHeaderVo"
parameterType="com.xujie.sys.modules.part.vo.BomHeaderVo">
SELECT
a.site,
a.bu_no,
dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
a.part_no,
b.part_desc,
a.eng_chg_level,
a.bom_type,
a.note_text,
a.eff_phase_in_date,
a.eff_phase_out_date,
a.eng_revision,
a.type_flag,
a.net_weight,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
b.umid2 as printUnit,
dbo.qc_get_um_name(a.site, b.umid2) as printUnitName,
isnull(dbo.get_yield_rate(a.site, a.bu_no, b.product_group_id2, '2'), 100) as yieldRate,
a.process_unit,
c.UMName as processUnitName
FROM plm_bom_header as a
left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
left join plm_bom_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.eng_chg_level = d.eng_chg_level and a.bom_type = d.bom_type
left join UM as c on a.site = c.site and a.process_unit = c.UMID
<where>
a.site = #{site}
<if test="buNo != null and buNo != ''">
and a.bu_no = #{buNo}
</if>
<if test="partNo != null and partNo != ''">
and a.part_no = #{partNo}
</if>
<if test="bomType != null and bomType != ''">
and a.bom_type = #{bomType}
</if>
</where>
order by a.eng_chg_level
</select>
<select id="getRoutingInformationListByPartNo" resultType="com.xujie.sys.modules.part.vo.RoutingHeaderVo"
parameterType="com.xujie.sys.modules.part.vo.RoutingHeaderVo">
SELECT
a.site,
a.bu_no,
dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
a.part_no,
b.part_desc,
a.routing_revision,
a.routing_type,
a.note_text,
a.phase_in_date,
a.phase_out_date,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
b.umid2 as printUnit,
dbo.qc_get_um_name(a.site, b.umid2) as printUnitName
FROM plm_routing_header as a
left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
left join plm_routing_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.routing_revision = d.routing_revision and a.routing_type = d.routing_type
<where>
a.site = #{site}
<if test="buNo != null and buNo != ''">
and a.bu_no = #{buNo}
</if>
<if test="partNo != null and partNo != ''">
and a.part_no = #{partNo}
</if>
<if test="routingType != null and routingType != ''">
and a.routing_type = #{routingType}
</if>
</where>
order by a.routing_revision
</select>
<select id="getEngChgLevelList" resultType="java.lang.Integer">
SELECT
a.eng_chg_level
FROM plm_bom_header as a
left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
left join plm_bom_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.eng_chg_level = d.eng_chg_level and a.bom_type = d.bom_type
left join UM as c on a.site = c.site and a.process_unit = c.UMID
<where>
a.site = #{site}
<if test="buNo != null and buNo != ''">
and a.bu_no = #{buNo}
</if>
<if test="partNo != null and partNo != ''">
and a.part_no = #{partNo}
</if>
<if test="bomType != null and bomType != ''">
and a.bom_type = #{bomType}
</if>
</where>
order by a.eng_chg_level
</select>
<select id="getRoutingRevisionList" resultType="java.lang.Integer">
SELECT
a.routing_revision
FROM plm_routing_header as a
left join part as b on a.site = b.site and a.bu_no = b.sourceBu and a.part_no = b.part_no
left join plm_routing_detail as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.part_no and a.routing_revision = d.routing_revision and a.routing_type = d.routing_type
<where>
a.site = #{site}
<if test="buNo != null and buNo != ''">
and a.bu_no = #{buNo}
</if>
<if test="partNo != null and partNo != ''">
and a.part_no = #{partNo}
</if>
<if test="routingType != null and routingType != ''">
and a.routing_type = #{routingType}
</if>
</where>
order by a.routing_revision desc
</select>
<update id="updateBomInfoId" parameterType="com.xujie.sys.modules.part.entity.PlmQuicklyBomInfoEntity">
UPDATE plm_quickly_bom_info
SET
id = REPLACE(id, #{data.pId}, #{data.id}),
p_id = REPLACE(p_id, #{data.pId}, #{data.id})
WHERE site = #{data.site}
AND main_part = #{data.mainPart}
AND id LIKE #{data.id} + '%'
AND (
LEN(id) = LEN(#{data.id})
OR
(LEN(id) > LEN(#{data.id}) AND SUBSTRING(id, LEN(#{data.id}) + 1, 1) = '-')
)
</update>
<update id="updatePartNoOfNode" parameterType="com.xujie.sys.modules.part.entity.PartNodeVo">
update plm_quickly_bom_info
set part_no = #{partNo}
where site = #{site}
and node_id = #{nodeId}
and main_part = #{mainPart}
</update>
<update id="setRevision" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo">
update plm_quickly_bom_info
set eng_chg_level = #{engChgLevel},
routing_revision = #{routingRevision}
where site = #{site}
and part_no = #{partNo}
and main_part = #{mainPart}
</update>
</mapper>