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.
1023 lines
42 KiB
1023 lines
42 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.PartInformationMapper">
|
|
|
|
<!-- 材料信息列表 -->
|
|
<select id="partInformationSearch" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
|
|
SELECT
|
|
a.id,
|
|
a.site,
|
|
a.part_no,
|
|
a.part_desc,
|
|
a.umid2 as umId2,
|
|
um.UMName as umName,
|
|
a.spec,
|
|
a.created_by as createBy,
|
|
a.creation_date as createDate,
|
|
a.active,
|
|
case when a.active = 'Y' then '是' when a.active = 'N' then '否' else '' end as activeDesc,
|
|
a.remark,
|
|
a.part_type2,
|
|
case when a.part_type2 = 'Manufactured' then '成品' when a.part_type2 = 'Manufactured Recipe' then '半成品' when a.part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
|
|
a.sourceBu as buNo,
|
|
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,
|
|
dbo.get_bu_desc(a.site, a.sourceBu) as buDesc,
|
|
a.update_by,
|
|
a.update_date,
|
|
a.standard_cost,
|
|
a.standard_cost_currency,
|
|
a.actual_cost,
|
|
a.actual_cost_currency,
|
|
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 in (select site from eam_access_site where username = #{query.userName})
|
|
and (a.site + '-' + a.sourceBu) in (select * from dbo.query_bu(#{query.userName}))
|
|
<if test="query.queryType != null and query.queryType != ''">
|
|
AND a.part_no like #{query.queryType} + '%'
|
|
</if>
|
|
<if test="query.buNo != null and query.buNo != ''">
|
|
AND a.sourceBu = #{query.buNo}
|
|
</if>
|
|
<if test = "query.partNo != null and query.partNo != ''">
|
|
AND a.part_no like '%' + #{query.partNo} + '%'
|
|
</if>
|
|
<if test = "query.partDesc != null and query.partDesc != ''">
|
|
AND a.part_desc like '%' + #{query.partDesc} + '%'
|
|
</if>
|
|
<if test="query.startDate != null">
|
|
AND a.creation_date >= #{query.startDate}
|
|
</if>
|
|
<if test="query.endDate != null">
|
|
AND #{query.endDate} >= a.creation_date
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="partInformationHsCode" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
|
|
SELECT
|
|
id,
|
|
site,
|
|
part_no,
|
|
part_desc,
|
|
umid2 as umId2,
|
|
dbo.qc_get_um_name(site, umid2) as umName,
|
|
spec,
|
|
created_by as createBy,
|
|
creation_date as createDate,
|
|
active,
|
|
case when active = 'Y' then '是' when active = 'N' then '否' else '' end as activeDesc,
|
|
remark,
|
|
part_type2,
|
|
case when part_type2 = 'Manufactured' then '成品' when part_type2 = 'Manufactured Recipe' then '半成品' when part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc,
|
|
sourceBu as buNo,
|
|
product_group_id1,
|
|
dbo.get_product_group_name(site, sourceBu, product_group_id1, '1') as productGroupName1,
|
|
product_group_id2,
|
|
dbo.get_product_group_name(site, sourceBu, product_group_id2, '2') as productGroupName2,
|
|
product_group_id3,
|
|
dbo.get_product_group_name(site, sourceBu, product_group_id3, '3') as productGroupName3,
|
|
FamilyID as familyID,
|
|
dbo.get_family_name(site, sourceBu, FamilyID) as familyName,
|
|
part_desce_en,
|
|
code_no,
|
|
dbo.get_code_desc(site, sourceBu, code_no, 'IP') as codeDesc,
|
|
dbo.get_bu_desc(site, sourceBu) as buDesc,
|
|
update_by,
|
|
update_date,
|
|
standard_cost,
|
|
standard_cost_currency,
|
|
actual_cost,
|
|
actual_cost_currency,
|
|
hsCode, hsCodeDesc
|
|
FROM part
|
|
<where>
|
|
site in (select site from eam_access_site where username = #{query.userName})
|
|
and (site + '-' + sourceBu) in (select * from dbo.query_bu(#{query.userName}))
|
|
<if test="query.queryType != null and query.queryType != ''">
|
|
AND part_no like #{query.queryType} + '%'
|
|
</if>
|
|
<if test="query.buNo != null and query.buNo != ''">
|
|
AND sourceBu = #{query.buNo}
|
|
</if>
|
|
<if test = "query.partNo != null and query.partNo != ''">
|
|
AND part_no like '%' + #{query.partNo} + '%'
|
|
</if>
|
|
<if test = "query.partDesc != null and query.partDesc != ''">
|
|
AND part_desc like '%' + #{query.partDesc} + '%'
|
|
</if>
|
|
<if test="query.startDate != null">
|
|
AND creation_date >= #{query.startDate}
|
|
</if>
|
|
<if test="query.endDate != null">
|
|
AND #{query.endDate} >= creation_date
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 检查材料属性 -->
|
|
<select id="checkValueHeaderData" resultType="PartSubPropertiesValueHeaderData">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
code_no,
|
|
sub_code_seq_no,
|
|
sub_code_desc,
|
|
record_type
|
|
from part_sub_properties_value_header
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and code_no = #{codeNo} and record_type = #{recordType}
|
|
</select>
|
|
|
|
<!-- 删除材料属性 -->
|
|
<delete id="deletePartSubPropertiesValueHeader">
|
|
delete from part_sub_properties_value_header
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType}
|
|
</delete>
|
|
|
|
<!-- 删除材料属性值 -->
|
|
<delete id="deletePartSubPropertiesValue">
|
|
delete from part_sub_properties_value
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType}
|
|
</delete>
|
|
|
|
<!-- 新增材料属性 -->
|
|
<insert id="savePartSubPropertiesValueHeader">
|
|
insert into part_sub_properties_value_header
|
|
(part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, record_type)
|
|
select
|
|
#{partNo},
|
|
#{site},
|
|
#{buNo},
|
|
#{codeNo},
|
|
1,
|
|
code_desc,
|
|
#{recordType}
|
|
from plm_properties_model_header
|
|
where code_no = #{codeNo} and site = #{site} and bu_no = #{buNo} and function_type = #{recordType}
|
|
</insert>
|
|
|
|
<!-- 新增材料属性值 -->
|
|
<insert id="savePartSubPropertiesValue">
|
|
insert into part_sub_properties_value
|
|
(part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type)
|
|
select
|
|
#{partNo},
|
|
#{site},
|
|
#{buNo},
|
|
#{codeNo},
|
|
1,
|
|
a.code_desc,
|
|
b.seq_No,
|
|
b.properties_item_no,
|
|
case when c.value_type_db = 'T' then c.default_value else null end,
|
|
case when c.value_type_db = 'N' and c.default_value != '' then c.default_value else null end,
|
|
#{recordType}
|
|
from plm_properties_model_header a
|
|
left join plm_properties_model_detail b on a.code_no = b.code_no and a.site = b.site and a.bu_no = b.bu_no and a.function_type = b.function_type
|
|
left join plm_properties_item c on b.properties_item_no = c.item_no and b.site = c.site and b.bu_no = c.bu_no and a.function_type = c.item_type
|
|
where a.code_no = #{codeNo} and a.site = #{site} and a.bu_no = #{buNo} AND B.site IS NOT NULL AND A.function_type = #{recordType}
|
|
</insert>
|
|
|
|
<select id="getItemModal" resultType="PartSubPropertiesValueData">
|
|
SELECT
|
|
a.part_no,
|
|
a.site,
|
|
a.bu_no,
|
|
a.code_no,
|
|
a.sub_code_seq_no,
|
|
a.sub_code_desc,
|
|
a.item_no,
|
|
a.properties_item_no,
|
|
a.text_value,
|
|
a.num_value,
|
|
a.record_type,
|
|
b.item_desc as itemDesc,
|
|
b.value_type,
|
|
b.value_type_db,
|
|
b.value_choose_flag
|
|
FROM part_sub_properties_value as a
|
|
left join plm_properties_item as b on a.properties_item_no = b.item_no and a.site = b.site and a.bu_no = b.bu_no and a.record_type = b.item_type
|
|
where a.site = #{site} and a.bu_no = #{buNo} and record_type = #{recordType} and a.part_no = #{partNo}
|
|
</select>
|
|
|
|
|
|
<!-- 获取属性可选值 -->
|
|
<select id="getAvailableValueList" resultType="PlmPropertiesItemAvailableData">
|
|
select
|
|
itemNo,
|
|
valueNo,
|
|
availableValue
|
|
from plm_properties_item_available
|
|
where itemNo = #{propertiesItemNo} and site = #{site} and bu_no = #{buNo} and itemType = #{recordType}
|
|
</select>
|
|
|
|
<!-- 编辑属性值 -->
|
|
<update id="savePartItemValue" >
|
|
update part_sub_properties_value
|
|
set text_value = #{textValue},
|
|
num_value = #{numValue, jdbcType=DOUBLE}
|
|
where properties_item_no = #{propertiesItemNo} and site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and record_type = #{recordType}
|
|
</update>
|
|
|
|
<!-- 查询代理商列表 -->
|
|
<select id="getAgentList" resultType="AgentInformationEntity" parameterType="AgentInformationEntity">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
agent_id,
|
|
agent_name
|
|
FROM agent
|
|
<where>
|
|
site = #{site} and bu_no = #{buNo}
|
|
<if test = "agentId != null and agentId != ''">
|
|
AND agent_id LIKE '%' + #{agentId} + '%'
|
|
</if>
|
|
<if test = "agentName != null and agentName != ''">
|
|
AND agent_name LIKE '%' + #{deptName} + '%'
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 查询代理商列表 -->
|
|
<select id="getPartAgent" resultType="com.xujie.sys.modules.part.vo.AgentInformationVo" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
a.agent_id,
|
|
b.agent_name,
|
|
b.active,
|
|
b.create_date,
|
|
b.create_by,
|
|
b.update_date,
|
|
b.update_by
|
|
FROM part_agent as a
|
|
left join agent as b on a.site = b.site and a.bu_no = b.bu_no and a.agent_id = b.agent_id
|
|
where a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
|
|
</select>
|
|
|
|
<!-- 获取当前物料不包含的代理商 -->
|
|
<select id="getAgentList1" resultType="AgentInformationEntity" parameterType="PartInformationEntity">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.agent_id,
|
|
a.agent_name,
|
|
a.active,
|
|
a.create_date,
|
|
a.create_by,
|
|
a.update_date,
|
|
a.update_by
|
|
FROM agent as a
|
|
left join part_agent as b on a.site = b.site and a.bu_no = b.bu_no and a.agent_id = b.agent_id and b.part_no = #{partNo}
|
|
where a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
|
|
</select>
|
|
|
|
<!-- 获取当前物料所包含的代理商 -->
|
|
<select id="getAgentList2" resultType="AgentInformationEntity" parameterType="PartInformationEntity">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.agent_id,
|
|
b.agent_name,
|
|
b.active,
|
|
b.create_date,
|
|
b.create_by,
|
|
b.update_date,
|
|
b.update_by
|
|
FROM part_agent a
|
|
LEFT JOIN agent b ON a.agent_id = b.agent_id and a.site = b.site and a.bu_no = b.bu_no
|
|
WHERE a.part_no = #{partNo} and a.site = #{site} and a.bu_no = #{buNo}
|
|
</select>
|
|
|
|
<!-- 获取当前物料所包含的代理商 -->
|
|
<select id="selectAgentByPartNo" resultType="com.xujie.sys.modules.part.vo.AgentInformationVo" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
|
|
SELECT
|
|
site,
|
|
agent_id
|
|
FROM part_agent
|
|
WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and agent_id = #{agentId}
|
|
</select>
|
|
|
|
<!-- 新增物料代理商 -->
|
|
<insert id="addPartAgent" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
|
|
insert into part_agent (site, part_no, agent_id, bu_no)
|
|
values (#{site}, #{partNo}, #{agentId}, #{buNo})
|
|
</insert>
|
|
|
|
<!-- 删除物料代理商 -->
|
|
<delete id="deletePartAgent" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
|
|
delete from part_agent
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and agent_id = #{agentId}
|
|
</delete>
|
|
|
|
<!-- 获取当前物料不包含的代理商 -->
|
|
<select id="getAgentListBy" resultType="AgentInformationEntity" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.agent_id,
|
|
a.agent_name,
|
|
a.active,
|
|
a.create_date,
|
|
a.create_by,
|
|
a.update_date,
|
|
a.update_by
|
|
FROM agent as a
|
|
left join part_agent as b on a.site = b.site and a.bu_no = b.bu_no and a.agent_id = b.agent_id and b.part_no = #{partNo}
|
|
<where>
|
|
a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
|
|
<if test = "agentId != null and agentId != ''">
|
|
AND a.agent_id LIKE '%' + #{agentId} + '%'
|
|
</if>
|
|
<if test = "agentName != null and agentName != ''">
|
|
AND a.agent_name LIKE '%' + #{agentName} + '%'
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 删除物料代理商 -->
|
|
<delete id="deleteAgent" parameterType="com.xujie.sys.modules.part.vo.AgentInformationVo">
|
|
delete from part_agent
|
|
where part_no = #{partNo} and site = #{site} and agent_id = #{agentId} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 查询制造商列表 -->
|
|
<select id="getPartManufacturer" resultType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
a.manufacturer_id,
|
|
b.manufacturer_name,
|
|
b.active,
|
|
b.create_date,
|
|
b.create_by,
|
|
b.update_date,
|
|
b.update_by
|
|
FROM part_manufacturer as a
|
|
left join manufacturer as b on a.site = b.site and a.bu_no = b.bu_no and a.manufacturer_id = b.manufacturer_id
|
|
where a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
|
|
</select>
|
|
|
|
<!-- 获取当前物料不包含的制造商 -->
|
|
<select id="getManufacturerList1" resultType="ManufacturerInformationEntity" parameterType="PartInformationEntity">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.manufacturer_id,
|
|
a.manufacturer_name,
|
|
a.active,
|
|
a.create_date,
|
|
a.create_by,
|
|
a.update_date,
|
|
a.update_by
|
|
FROM manufacturer as a
|
|
left join part_manufacturer as b on a.site = b.site and a.bu_no = b.bu_no and a.manufacturer_id = b.manufacturer_id and b.part_no = #{partNo}
|
|
where a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
|
|
</select>
|
|
|
|
<!-- 获取当前物料所包含的制造商 -->
|
|
<select id="getManufacturerList2" resultType="ManufacturerInformationEntity" parameterType="PartInformationEntity">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.manufacturer_id,
|
|
b.manufacturer_name,
|
|
b.active,
|
|
b.create_date,
|
|
b.create_by,
|
|
b.update_date,
|
|
b.update_by
|
|
FROM part_manufacturer a
|
|
LEFT JOIN manufacturer b ON a.manufacturer_id = b.manufacturer_id and a.site = b.site and a.bu_no = b.bu_no
|
|
WHERE a.part_no = #{partNo} and a.site = #{site} and a.bu_no = #{buNo}
|
|
</select>
|
|
|
|
<!-- 获取当前物料所包含的制造商 -->
|
|
<select id="selectManufacturerByPartNo" resultType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
manufacturer_id
|
|
FROM part_manufacturer
|
|
WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and manufacturer_id = #{manufacturerId}
|
|
</select>
|
|
|
|
<!-- 新增物料制造商 -->
|
|
<insert id="addPartManufacturer" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
|
|
insert into part_manufacturer (site, part_no, manufacturer_id, bu_no)
|
|
values (#{site}, #{partNo}, #{manufacturerId}, #{buNo})
|
|
</insert>
|
|
|
|
<!-- 删除物料制造商 -->
|
|
<delete id="deletePartManufacturer" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
|
|
delete from part_manufacturer
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and manufacturer_id = #{manufacturerId}
|
|
</delete>
|
|
|
|
<!-- 删除物料制造商 -->
|
|
<delete id="deleteManufacturer">
|
|
delete from part_manufacturer
|
|
where part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 获取当前物料不包含的制造商 -->
|
|
<select id="getManufacturerListBy" resultType="ManufacturerInformationEntity" parameterType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo">
|
|
SELECT
|
|
a.site,
|
|
a.manufacturer_id,
|
|
a.manufacturer_name,
|
|
a.active,
|
|
a.create_date,
|
|
a.create_by,
|
|
a.update_date,
|
|
a.update_by
|
|
FROM manufacturer as a
|
|
left join part_manufacturer as b on a.site = b.site and a.bu_no = b.bu_no and a.manufacturer_id = b.manufacturer_id and b.part_no = #{partNo}
|
|
<where>
|
|
a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
|
|
<if test = "manufacturerId != null and manufacturerId != ''">
|
|
AND a.manufacturer_id LIKE '%' + #{manufacturerId} + '%'
|
|
</if>
|
|
<if test = "manufacturerName != null and manufacturerName != ''">
|
|
AND a.manufacturer_name LIKE '%' + #{manufacturerName} + '%'
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- -->
|
|
<update id="commitItemValue" parameterType="PartSubPropertiesValueData">
|
|
UPDATE part_sub_properties_value
|
|
SET text_value = #{textValue},
|
|
num_value = #{numValue, jdbcType=DECIMAL}
|
|
WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and code_no = #{codeNo} and sub_code_seq_no = #{subCodeSeqNo} and item_no = #{itemNo} and record_type = #{recordType}
|
|
</update>
|
|
|
|
<!-- 删除属性值 -->
|
|
<delete id="deleteItem" parameterType="PartSubPropertiesValueData">
|
|
delete from part_sub_properties_value
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType} and code_no = #{codeNo} and sub_code_seq_no = #{subCodeSeqNo} and item_no = #{itemNo}
|
|
</delete>
|
|
|
|
<select id="getItemLists" resultType="PropertiesItemData" parameterType="PartSubPropertiesValueData">
|
|
SELECT
|
|
a.item_no as itNo,
|
|
a.item_desc
|
|
FROM plm_properties_item a
|
|
LEFT JOIN part_sub_properties_value b on b.record_type = #{recordType} and b.code_no = #{codeNo} and b.part_no = #{partNo} and b.properties_item_no = a.item_No and a.site = b.site and a.bu_no = b.bu_no
|
|
<where>
|
|
a.item_type = #{recordType}
|
|
and a.site = #{site} and a.bu_no = #{buNo}
|
|
AND b.code_no is null
|
|
<if test = "propertiesItemNo != null and propertiesItemNo != ''">
|
|
AND a.item_no LIKE #{propertiesItemNo}
|
|
</if>
|
|
<if test = "itemDesc != null and itemDesc != ''">
|
|
AND a.item_desc LIKE #{itemDesc}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="getModelItemLists" resultType="PropertiesItemData" parameterType="PartSubPropertiesValueData">
|
|
select
|
|
a.properties_item_no as itNo,
|
|
b.item_desc,
|
|
a.item_no,
|
|
a.part_no,
|
|
a.site,
|
|
a.bu_no,
|
|
a.code_no,
|
|
a.sub_code_seq_no,
|
|
a.record_type
|
|
from part_sub_properties_value a
|
|
left join plm_properties_item b on a.properties_item_no = b.item_no and a.record_type = b.item_type and a.site = b.site and a.bu_no = b.bu_no
|
|
where a.code_no = #{codeNo} and a.record_type = #{recordType} and a.site = #{site} and a.part_no = #{partNo} and a.bu_no = #{buNo}
|
|
</select>
|
|
|
|
<select id="checkPartItem" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
|
|
select
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
code_no,
|
|
sub_code_seq_no,
|
|
item_no,
|
|
properties_item_no,
|
|
record_type
|
|
from part_sub_properties_value
|
|
where code_no = #{codeNo} and record_type = #{recordType} and site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and properties_item_no = #{itNo}
|
|
</select>
|
|
|
|
<select id="checkItem" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
|
|
SELECT
|
|
item_desc
|
|
FROM plm_properties_item
|
|
where item_type = #{recordType} and item_no = #{itNo} and site = #{site}
|
|
</select>
|
|
|
|
<select id="getModalDetailSeqNo" resultType="double" parameterType="PartSubPropertiesValueData">
|
|
SELECT
|
|
isnull(max(item_no),0) + 1
|
|
from part_sub_properties_value
|
|
where record_type = #{recordType} and code_no = #{codeNo} and site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and sub_code_seq_no = #{subCodeSeqNo}
|
|
</select>
|
|
|
|
<insert id="addPartItem" parameterType="PartSubPropertiesValueData">
|
|
insert into part_sub_properties_value
|
|
(part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type)
|
|
values (#{partNo}, #{site}, #{buNo}, #{codeNo}, #{subCodeSeqNo,jdbcType=FLOAT}, #{codeDesc}, #{itemNo, jdbcType=FLOAT}, #{itNo}, #{textValue}, #{numValue, jdbcType=FLOAT}, #{recordType})
|
|
</insert>
|
|
|
|
<delete id="deletePartItem" parameterType="PartSubPropertiesValueData">
|
|
delete from part_sub_properties_value
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and record_type = #{recordType} and code_no = #{codeNo} and sub_code_seq_no = #{subCodeSeqNo} and item_no = #{itemNo}
|
|
</delete>
|
|
|
|
<select id="queryCodeNo" parameterType="com.xujie.sys.modules.part.entity.PartInformationEntity" resultType="PartSubPropertiesValueData">
|
|
SELECT
|
|
part_no,
|
|
site,
|
|
bu_no,
|
|
code_no,
|
|
sub_code_seq_no,
|
|
sub_code_desc,
|
|
record_type
|
|
FROM part_sub_properties_value_header
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and sub_code_seq_no = 1 and record_type = 'IP'
|
|
</select>
|
|
|
|
<!-- 获取当前物料不包含的库位 -->
|
|
<select id="getLocationList1" resultType="LocationInformationEntity" parameterType="PartInformationEntity">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.location_id,
|
|
a.location_name,
|
|
a.warehouse_id,
|
|
a.active,
|
|
a.created_date as createDate,
|
|
a.created_by as createBy,
|
|
a.update_date,
|
|
a.update_by,
|
|
a.location_type
|
|
FROM location as a
|
|
left join part_location as b on a.site = b.site and a.bu_no = b.bu_no and a.location_id = b.location_id and b.part_no = #{partNo}
|
|
where a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
|
|
</select>
|
|
|
|
<!-- 获取当前物料所包含的库位 -->
|
|
<select id="getLocationList2" resultType="LocationInformationEntity" parameterType="PartInformationEntity">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.location_id,
|
|
b.location_name,
|
|
b.warehouse_id,
|
|
b.active,
|
|
b.created_date as createDate,
|
|
b.created_by as createBy,
|
|
b.update_date,
|
|
b.update_by,
|
|
b.location_type
|
|
FROM part_location a
|
|
LEFT JOIN location b ON a.location_id = b.location_id and a.site = b.site and a.bu_no = b.bu_no
|
|
WHERE a.part_no = #{partNo} and a.site = #{site} and a.bu_no = #{buNo}
|
|
</select>
|
|
|
|
<!-- 获取当前物料不包含的库位 -->
|
|
<select id="getLocationListBy" resultType="LocationInformationEntity" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
|
|
SELECT
|
|
a.id,
|
|
a.site,
|
|
a.bu_no,
|
|
a.location_id,
|
|
a.location_name,
|
|
a.warehouse_id,
|
|
a.active,
|
|
a.created_date as createDate,
|
|
a.created_by as createBy,
|
|
a.update_date,
|
|
a.update_by,
|
|
a.version
|
|
FROM location as a
|
|
left join part_location as b on a.site = b.site and a.bu_no = b.bu_no and a.location_id = b.location_id and b.part_no = #{partNo}
|
|
<where>
|
|
a.site = #{site} and a.bu_no = #{buNo} and b.part_no is null
|
|
<if test = "locationId != null and locationId != ''">
|
|
AND a.location_id LIKE '%' + #{locationId} + '%'
|
|
</if>
|
|
<if test = "locationName != null and locationName != ''">
|
|
AND a.location_name LIKE '%' + #{locationName} + '%'
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!-- 查询库位列表 -->
|
|
<select id="getDefaultLocation" resultType="com.xujie.sys.modules.part.vo.LocationInformationVo" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
|
|
SELECT
|
|
a.site,
|
|
a.bu_no,
|
|
a.part_no,
|
|
a.location_id,
|
|
b.location_name,
|
|
b.warehouse_id,
|
|
b.active,
|
|
b.created_date as createDate,
|
|
b.created_by as createBy,
|
|
b.update_date,
|
|
b.update_by,
|
|
b.delflag,
|
|
b.version,
|
|
b.keeper
|
|
FROM part_location as a
|
|
left join location as b on a.site = b.site and a.bu_no = b.bu_no and a.location_id = b.location_id
|
|
where a.site = #{site} and a.bu_no = #{buNo} and a.part_no = #{partNo}
|
|
</select>
|
|
|
|
<!-- 获取当前物料所包含的库位 -->
|
|
<select id="selectLocationByPartNo" resultType="com.xujie.sys.modules.part.vo.LocationInformationVo" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
location_id
|
|
FROM part_location
|
|
WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo} and location_id = #{locationId}
|
|
</select>
|
|
|
|
<!-- 新增物料库位 -->
|
|
<insert id="addDefaultLocation" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
|
|
insert into part_location (site, part_no, location_id, bu_no)
|
|
values (#{site}, #{partNo}, #{locationId}, #{buNo})
|
|
</insert>
|
|
|
|
<!-- 删除物料库位 -->
|
|
<delete id="deleteDefaultLocation" parameterType="com.xujie.sys.modules.part.vo.LocationInformationVo">
|
|
delete from part_location
|
|
where part_no = #{partNo} and site = #{site} and location_id = #{locationId} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 删除代理商 -->
|
|
<delete id="deleteAgentByPartNo" parameterType="PartInformationEntity">
|
|
delete from part_agent
|
|
where part_no = #{partNo} and site = #{site}
|
|
</delete>
|
|
|
|
<!-- 删除制造商商 -->
|
|
<delete id="deleteManufacturerByPartNo" parameterType="PartInformationEntity">
|
|
delete from part_manufacturer
|
|
where part_no = #{partNo} and site = #{site}
|
|
</delete>
|
|
|
|
<!-- 删除代理商 -->
|
|
<delete id="deleteLocationByPartNo" parameterType="PartInformationEntity">
|
|
delete from part_location
|
|
where part_no = #{partNo} and site = #{site} and bu_no = #{buNo}
|
|
</delete>
|
|
|
|
<!-- 获取当前物料所包含的库位 -->
|
|
<select id="getFromPartLocation" resultType="com.xujie.sys.modules.part.vo.LocationInformationVo" parameterType="PartInformationEntity">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
location_id
|
|
FROM part_location
|
|
WHERE part_no = #{partNo} and site = #{site} and bu_no = #{buNo}
|
|
</select>
|
|
|
|
<!-- 新增项目物料 -->
|
|
<insert id="saveProjectPart" parameterType="PartInformationEntity">
|
|
insert into plm_project_part
|
|
(site, project_id, test_part_no, base_no, rev_no, part_no_source)
|
|
values
|
|
(#{site}, #{projectId}, #{partNo}, #{baseNo}, #{revNo}, #{partNoSource})
|
|
</insert>
|
|
|
|
<!-- 修改项目物料finalPart -->
|
|
<update id="updateProjectFinalPart" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo">
|
|
UPDATE plm_project_part
|
|
SET final_part_no = #{ifsPartNo},
|
|
update_date = getDate(),
|
|
update_by = #{updateBy}
|
|
WHERE site = #{site} and test_part_no = #{partNo}
|
|
</update>
|
|
|
|
<!-- 新增项目物料 -->
|
|
<insert id="saveCustomerPartInfo" parameterType="PartInformationEntity">
|
|
insert into plm_customer_part_info
|
|
(site, customer_no, part_no, customer_part_no, create_date, create_by)
|
|
values
|
|
(#{site}, #{customerNo}, #{partNo}, #{customerPartNo}, getDate(), #{createBy})
|
|
</insert>
|
|
|
|
<!-- 新增项目物料 -->
|
|
<insert id="addProjectPart">
|
|
insert into plm_project_part
|
|
(site, project_id, test_part_no, create_date, create_by, part_no_source) VALUES
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
(#{item.site}, #{item.projectId}, #{item.partNo}, getDate(), #{item.createBy}, #{item.partNoSource})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 新增项目物料 -->
|
|
<insert id="addCustomerPartInfo">
|
|
insert into plm_customer_part_info
|
|
(site, customer_no, part_no, customer_part_no, create_date, create_by) VALUES
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
(#{item.site}, #{item.customerNo}, #{item.partNo}, #{item.customerPartNo}, getDate(), #{item.createBy})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 查询Routing替代 -->
|
|
<select id="queryRoutingAlternativeList" resultType="RoutingDetailEntity" parameterType="PartInformationEntity">
|
|
SELECT
|
|
a.site,
|
|
a.part_no,
|
|
a.routing_type,
|
|
a.routing_revision,
|
|
a.alternative_no,
|
|
a.alternative_description,
|
|
a.rout_template_id,
|
|
a.plan_date,
|
|
a.fixed_lead_time_day,
|
|
a.fixed_lead_time_hour,
|
|
a.variable_lead_time_day,
|
|
a.variable_lead_time_hour,
|
|
a.for_std_lot_by_day,
|
|
a.for_lot_by_day,
|
|
a.min_lot_qty,
|
|
a.note_text,
|
|
a.status,
|
|
a.official_flag
|
|
FROM plm_routing_detail as a
|
|
LEFT JOIN plm_routing_header as b on a.site = b.site and a.part_no = b.part_no and a.routing_revision = b.routing_revision and a.routing_type = b.routing_type
|
|
where a.site = #{site} and a.part_no = #{partNo} and a.routing_type = 'Manufacturing' and b.phase_out_date is null
|
|
</select>
|
|
|
|
<!-- 根据物料编码删除 BOM Header -->
|
|
<delete id="deleteBomHeaderByPartNo" parameterType="PartInformationEntity">
|
|
delete from plm_bom_header
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 根据物料编码删除 BOM Detail -->
|
|
<delete id="deleteBomDetailByPartNo" parameterType="PartInformationEntity">
|
|
delete from plm_bom_detail
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 根据物料编码删除 BOM Component -->
|
|
<delete id="deleteBomComponentByPartNo" parameterType="PartInformationEntity">
|
|
delete from plm_bom_component
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 根据物料编码删除 BOM 副产品成本分配 -->
|
|
<delete id="deleteBomManufStructCostDistribByPartNo" parameterType="PartInformationEntity">
|
|
delete from plm_bom_manuf_struct_cost_distrib
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 根据物料编码删除 Routing Header -->
|
|
<delete id="deleteRoutingHeaderByPartNo" parameterType="PartInformationEntity">
|
|
delete from plm_routing_header
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 根据物料编码删除 Routing Detail -->
|
|
<delete id="deleteRoutingDetailByPartNo" parameterType="PartInformationEntity">
|
|
delete from plm_routing_detail
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 根据物料编码删除 Routing Component -->
|
|
<delete id="deleteRoutingComponentByPartNo" parameterType="PartInformationEntity">
|
|
delete from plm_routing_component
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 根据物料编码删除 Routing Tool -->
|
|
<delete id="deleteRoutingToolByPartNo" parameterType="PartInformationEntity">
|
|
delete from routing_tool
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 根据物料编码删除 Routing GuideLine -->
|
|
<delete id="deleteRoutingGuideLineByPartNo" parameterType="PartInformationEntity">
|
|
delete from plm_routing_work_guide
|
|
where site = #{site} and part_no = #{partNo}
|
|
</delete>
|
|
|
|
<!-- 新增物料制造商 -->
|
|
<insert id="savePartDefaultLocation">
|
|
insert into part_location
|
|
(site, part_no, location_id, bu_no) VALUES
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
(#{item.site}, #{item.partNo}, #{item.locationId}, #{item.buNo})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 下一个物料编码 -->
|
|
<select id="getNextPartNo2" resultType="string" parameterType="com.xujie.sys.modules.part.vo.PartInformationVo">
|
|
select dbo.get_next_part_code(#{site}, #{buNo}, #{queryType})
|
|
</select>
|
|
|
|
<select id="handleQueryPart" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
|
|
select p.id,
|
|
p.site,
|
|
part_no,
|
|
part_desc,
|
|
umid2 as umId2,
|
|
dbo.qc_get_um_name(p.site, umid2) as umName,
|
|
sourceBu as buNo,
|
|
dbo.get_bu_desc(p.site, sourceBu) as buDesc,
|
|
part_type2,
|
|
case
|
|
when part_type2 = 'Manufactured' then '成品'
|
|
when part_type2 = 'Manufactured Recipe' then '半成品'
|
|
when part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc
|
|
from part p
|
|
left join BU b on p.sourceBu = b.bu_no and p.site = b.site
|
|
where
|
|
p.site in (select site from eam_access_site where username = #{userName})
|
|
and (p.site + '-' + sourceBu) in (select * from dbo.query_bu(#{userName}))
|
|
and p.active = 'Y'
|
|
<if test="buId != null">
|
|
and b.id = #{buId}
|
|
</if>
|
|
<if test = "partNo != null and partNo != ''">
|
|
AND part_no like #{partNo}
|
|
</if>
|
|
<if test = "partDesc != null and partDesc != ''">
|
|
AND part_desc like #{partDesc}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="handleQueryPartByPage" resultType="com.xujie.sys.modules.part.vo.PartInformationVo">
|
|
select p.id,
|
|
p.site,
|
|
part_no,
|
|
part_desc,
|
|
umid2 as umId2,
|
|
dbo.qc_get_um_name(p.site, umid2) as umName,
|
|
sourceBu as buNo,
|
|
dbo.get_bu_desc(p.site, sourceBu) as buDesc,
|
|
part_type2,
|
|
case
|
|
when part_type2 = 'Manufactured' then '成品'
|
|
when part_type2 = 'Manufactured Recipe' then '半成品'
|
|
when part_type2 = 'Purchased (raw)' then '原材料' end as partType2Desc
|
|
from part p
|
|
left join BU b on p.sourceBu = b.bu_no and p.site = b.site
|
|
where
|
|
p.site in (select site from eam_access_site where username = #{params.userName})
|
|
and (p.site + '-' + sourceBu) in (select * from dbo.query_bu(#{params.userName}))
|
|
and p.active = 'Y'
|
|
<if test="params.buId != null">
|
|
and b.id = #{params.buId}
|
|
</if>
|
|
<if test = "params.partNo != null and params.partNo != ''">
|
|
AND part_no like #{params.partNo}
|
|
</if>
|
|
<if test = "params.partDesc != null and params.partDesc != ''">
|
|
AND part_desc like #{params.partDesc}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 查routing子明细 -->
|
|
<select id="getRoutingOperationId" resultType="RoutingComponentEntity">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
routing_type,
|
|
routing_revision,
|
|
alternative_no,
|
|
operation_id,
|
|
operation_no,
|
|
operation_name
|
|
FROM plm_routing_component
|
|
where site = #{site} and bu_no = #{buNo} and part_no = #{partNo} and routing_type = #{routingType} and routing_revision = #{routingRevision} and alternative_no = #{alternativeNo} and operation_no = #{operationNo}
|
|
</select>
|
|
|
|
<select id="getTblBaseData" parameterType="TblBaseData" resultType="TblBaseData">
|
|
SELECT
|
|
id,
|
|
site,
|
|
type,
|
|
base_data,
|
|
base_desc,
|
|
status,
|
|
remark,
|
|
third_type,
|
|
second_type,
|
|
page_control
|
|
FROM tbl_base_data
|
|
where site = #{site} and type = #{type} and third_type = #{thirdType} and second_type = #{secondType}
|
|
</select>
|
|
|
|
<insert id="saveTblBaseData" parameterType="TblBaseData">
|
|
insert into tbl_base_data
|
|
(site, type, base_data, base_desc, status, remark, third_type, second_type, page_control)
|
|
values
|
|
(#{site}, #{type}, #{baseData}, #{baseDesc}, #{status}, #{remark}, #{thirdType}, #{secondType}, #{pageControl})
|
|
</insert>
|
|
|
|
<update id="updateTblBaseData" parameterType="TblBaseData">
|
|
UPDATE tbl_base_data
|
|
SET base_data = #{baseData}
|
|
WHERE site = #{site} and type = #{type} and third_type = #{thirdType} and second_type = #{secondType}
|
|
</update>
|
|
|
|
<insert id="savePartSubPropertiesValueByPartNo">
|
|
insert into part_sub_properties_value
|
|
(part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type)
|
|
select
|
|
#{partNo},
|
|
site,
|
|
bu_no,
|
|
code_no,
|
|
1,
|
|
sub_code_desc,
|
|
item_no,
|
|
properties_item_no,
|
|
text_value,
|
|
num_value,
|
|
record_type
|
|
from part_sub_properties_value
|
|
where site = #{site} and bu_no = #{buNo} and part_no = #{basePartNo}
|
|
</insert>
|
|
|
|
<select id="getPreviousPartNo" parameterType="TblBaseData" resultType="string">
|
|
SELECT
|
|
base_data
|
|
FROM tbl_base_data
|
|
where site = #{site} and type = #{type} and third_type = #{thirdType} and second_type = #{secondType}
|
|
</select>
|
|
|
|
<!-- 新增材料属性值 -->
|
|
<insert id="savePartModelDetails">
|
|
insert into part_sub_properties_value
|
|
(part_no, site, bu_no, code_no, sub_code_seq_no, sub_code_desc, item_no, properties_item_no, text_value, num_value, record_type) VALUES
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
(#{item.partNo}, #{item.site}, #{item.buNo}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.itemNo,jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue,jdbcType=FLOAT}, #{item.recordType})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="getPartAgents" resultType="com.xujie.sys.modules.part.vo.AgentInformationVo" parameterType="PartInformationEntity">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
agent_id
|
|
FROM part_agent
|
|
where site = #{site} and bu_no = #{buNo} and part_no = #{partNo}
|
|
</select>
|
|
|
|
<insert id="savePartAgent">
|
|
insert into part_agent
|
|
(site, bu_no, part_no, agent_id) VALUES
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
(#{item.site}, #{item.buNo}, #{item.partNo}, #{item.agentId})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="getPartManufacturers" resultType="com.xujie.sys.modules.part.vo.ManufacturerInformationVo" parameterType="PartInformationEntity">
|
|
SELECT
|
|
site,
|
|
bu_no,
|
|
part_no,
|
|
manufacturer_id
|
|
FROM part_manufacturer
|
|
where site = #{site} and bu_no = #{buNo} and part_no = #{partNo}
|
|
</select>
|
|
|
|
<insert id="savePartManufacturer">
|
|
insert into part_manufacturer
|
|
(site, bu_no, part_no, manufacturer_id) VALUES
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
(#{item.site}, #{item.buNo}, #{item.partNo}, #{item.manufacturerId})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<update id="savePartHSCode">
|
|
update Part set hsCode=#{hsCode},hsCodeDesc=#{hsCodeDesc}
|
|
where site = #{site} and part_no = #{partNo}
|
|
</update>
|
|
</mapper>
|