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.
 
 
 
 
 
 

1753 lines
69 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.part.mapper.PartInformationMapper">
<!-- 材料信息列表 -->
<select id="partInformationSearch" parameterType="com.spring.modules.part.vo.PartInformationVo" resultType="com.spring.modules.part.vo.PartInformationVo">
SELECT
site,
part_no,
part_desc,
spec,
part_type_db,
part_type,
family_id,
dbo.get_family_name(site, family_id) as familyName,
group_id,
dbo.get_group_name(site, group_id) as groupName,
um_id,
dbo.get_um_name(um_id) as umName,
weight_net,
uom_for_weight_net,
volume_net,
uom_for_volume_net,
lot_tracking_code,
active,
product_group_id1,
dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
product_group_id2,
dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
product_group_id3,
dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
product_group_id4,
dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
erp_part_no,
code_no,
dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
manufacturer_id,
dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
agent_id,
dbo.split_agent_id(site, agent_id) as agentName,
type_designation,
hazard_code,
dbo.get_hazard_name(site, hazard_code) as hazardDesc,
asset_class,
dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
dim_quality,
abc_class,
dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
frequency_class,
lifecycle_stage,
country_of_origin,
dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
manufacturing_lead_time,
expected_lead_time,
region_of_origin,
dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
customs_stat_no,
dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
durability_day,
intrastat_conv_factor,
part_status,
dbo.get_part_status_name(site, part_status) as partStatusDesc,
configuration_id,
estimated_material_cost,
inventory_valuation_method,
part_cost_group_id,
dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
inventory_part_cost_level,
invoice_consideration,
zero_cost_flag,
planning_method,
dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
safety_stock,
min_order_qty,
max_order_qty,
mul_order_qty,
safety_lead_time,
shrinkage_fac,
std_order_qty,
cum_lead_time,
back_flush_part,
by_prod_as_supply_in_mrp_db,
unprotected_lead_time,
issue_type,
mrp_control_flag_db,
fixed_lead_time_day,
over_reporting,
use_theoretical_density_db,
variable_lead_time_day,
over_report_tolerance,
fixed_lead_time_hour,
density,
variable_lead_time_hour,
remark,
status,
create_date,
create_by,
update_date,
update_by,
plm_part_no,
ifs_part_no,
case when status = 'Y' then '正式物料' else '临时物料' end as statusDesc
FROM part
<where>
site = #{query.site}
<if test = "query.partNo != null and query.partNo != ''">
AND part_no like #{query.partNo}
</if>
<if test = "query.erpPartNo != null and query.erpPartNo != ''">
AND erp_part_no like #{query.erpPartNo}
</if>
<if test = "query.partDesc != null and query.partDesc != ''">
AND part_desc like #{query.partDesc}
</if>
<if test = "query.spec != null and query.spec != ''">
AND spec like #{query.spec}
</if>
<if test="query.startDate != null ">
AND required_completion_date >= #{query.startDate}
</if>
<if test="query.endDate != null ">
AND #{query.endDate} >= required_completion_date
</if>
</where>
</select>
<!-- 检查材料属性 -->
<select id="checkValueHeaderData" resultType="PartSubPropertiesValueHeaderData">
SELECT
PartNo,
Site,
CodeNo,
SubCodeSeqNo,
SubCodeDesc,
RecordType
from PartSubPropertiesValueHeader
where PartNo = #{partNo} and site = #{site} and CodeNo = #{codeNo} and RecordType = #{recordType}
</select>
<!-- 删除材料属性 -->
<delete id="deletePartSubPropertiesValueHeader">
delete from PartSubPropertiesValueHeader
where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType}
</delete>
<!-- 删除材料属性值 -->
<delete id="deletePartSubPropertiesValue">
delete from PartSubPropertiesValue
where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType}
</delete>
<!-- 新增材料属性 -->
<insert id="savePartSubPropertiesValueHeader">
insert into PartSubPropertiesValueHeader
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
select
#{partNo},
#{site},
#{codeNo},
1,
Code_Desc,
#{recordType}
from plm_properties_model_header
where Code_No = #{codeNo} and site = #{site} and function_type = #{recordType}
</insert>
<!-- 新增材料属性值 -->
<insert id="savePartSubPropertiesValue">
insert into PartSubPropertiesValue (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
select
#{partNo},
#{site},
#{codeNo},
1,
a.Code_Desc,
b.seq_No,
b.properties_item_no,
case when c.ValueType_DB = 'T' then c.DefaultValue else null end,
case when c.ValueType_DB = 'N' and c.DefaultValue != '' then c.DefaultValue 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.function_type = b.function_type
left join plm_properties_item c on b.properties_item_no = c.ItemNo and b.site = c.site and a.function_type = c.itemType
where a.Code_No = #{codeNo} and a.site = #{site} AND B.SITE IS NOT NULL AND A.function_type = #{recordType}
</insert>
<select id="getItemModal" resultType="PartSubPropertiesValueData">
SELECT
a.PartNo,
a.Site,
a.CodeNo,
a.SubCodeSeqNo,
a.SubCodeDesc,
a.ItemNo,
a.PropertiesItemNo,
a.TextValue,
a.NumValue,
a.RecordType,
b.ItemDesc as ItemDesc,
b.ValueType,
b.ValueType_DB,
b.ValueChooseFlag
FROM PartSubPropertiesValue as a
left join plm_properties_item as b on a.PropertiesItemNo = b.ItemNo and a.site = b.site and a.RecordType = b.ItemType
where a.site = #{site} and RecordType = #{recordType} and a.PartNo = #{partNo,jdbcType=VARCHAR}
</select>
<!-- 获取属性可选值 -->
<select id="getAvailableValueList" resultType="PlmPropertiesItemAvailableData">
select
ItemNo,
ValueNo,
AvailableValue
from plm_properties_item_available
where itemNo = #{propertiesItemNo} and site = #{site} and ItemType = #{recordType}
</select>
<!-- 编辑属性值 -->
<update id="savePartItemValue" >
update PartSubPropertiesValue
set TextValue = #{textValue},
NumValue = #{numValue, jdbcType=DOUBLE}
where PropertiesItemNo = #{propertiesItemNo} and site = #{site} and PartNo = #{partNo} and RecordType = #{recordType}
</update>
<!-- 查询代理商列表 -->
<select id="getAgentList" resultType="AgentInformationEntity" parameterType="AgentInformationEntity">
SELECT
site,
agent_id,
agent_name
FROM agent
<where>
site = #{site}
<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.spring.modules.part.vo.AgentInformationVo" parameterType="com.spring.modules.part.vo.AgentInformationVo">
SELECT
a.site,
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.agent_id = b.agent_id
where a.site = #{site} and a.part_no = #{partNo}
</select>
<!-- 获取当前物料不包含的代理商 -->
<select id="getAgentList1" resultType="AgentInformationEntity" parameterType="PartInformationEntity">
SELECT
a.site,
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.agent_id = b.agent_id and b.part_no = #{partNo}
where a.site = #{site} and b.part_no is null
</select>
<!-- 获取当前物料所包含的代理商 -->
<select id="getAgentList2" resultType="AgentInformationEntity" parameterType="PartInformationEntity">
SELECT
a.site,
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
WHERE a.part_no = #{partNo} and a.site = #{site}
</select>
<!-- 获取当前物料所包含的代理商 -->
<select id="selectAgentByPartNo" resultType="com.spring.modules.part.vo.AgentInformationVo" parameterType="com.spring.modules.part.vo.AgentInformationVo">
SELECT
site,
agent_id
FROM part_agent
WHERE part_no = #{partNo} and site = #{site} and agent_id = #{agentId}
</select>
<!-- 新增物料代理商 -->
<insert id="addPartAgent" parameterType="com.spring.modules.part.vo.AgentInformationVo">
insert into part_agent (site, part_no, agent_id)
values (#{site}, #{partNo}, #{agentId})
</insert>
<!-- 删除物料代理商 -->
<delete id="deletePartAgent" parameterType="com.spring.modules.part.vo.AgentInformationVo">
delete from part_agent
where part_no = #{partNo} and site = #{site} and agent_id = #{agentId}
</delete>
<!-- 获取当前物料不包含的代理商 -->
<select id="getAgentListBy" resultType="AgentInformationEntity" parameterType="com.spring.modules.part.vo.AgentInformationVo">
SELECT
a.site,
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.agent_id = b.agent_id and b.part_no = #{partNo}
<where>
a.site = #{site} 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.spring.modules.part.vo.AgentInformationVo">
delete from part_agent
where part_no = #{partNo} and site = #{site} and agent_id = #{agentId}
</delete>
<!-- 查询制造商列表 -->
<select id="getManufacturerList" resultType="ManufacturerInformationEntity" parameterType="ManufacturerInformationEntity">
SELECT
site,
manufacturer_id,
manufacturer_name
FROM manufacturer
<where>
site = #{site}
<if test = "manufacturerId != null and manufacturerId != ''">
AND manufacturer_id LIKE #{manufacturerId}
</if>
<if test = "manufacturerName != null and manufacturerName != ''">
AND manufacturer_name LIKE #{manufacturerName}
</if>
</where>
</select>
<!-- 查询制造商列表 -->
<select id="getPartManufacturer" resultType="com.spring.modules.part.vo.ManufacturerInformationVo" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
SELECT
a.site,
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.manufacturer_id = b.manufacturer_id
where a.site = #{site} and a.part_no = #{partNo}
</select>
<!-- 获取当前物料不包含的制造商 -->
<select id="getManufacturerList1" resultType="ManufacturerInformationEntity" parameterType="PartInformationEntity">
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.manufacturer_id = b.manufacturer_id and b.part_no = #{partNo}
where a.site = #{site} and b.part_no is null
</select>
<!-- 获取当前物料所包含的制造商 -->
<select id="getManufacturerList2" resultType="ManufacturerInformationEntity" parameterType="PartInformationEntity">
SELECT
a.site,
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
WHERE a.part_no = #{partNo} and a.site = #{site}
</select>
<!-- 获取当前物料所包含的制造商 -->
<select id="selectManufacturerByPartNo" resultType="com.spring.modules.part.vo.ManufacturerInformationVo" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
SELECT
site,
manufacturer_id
FROM part_manufacturer
WHERE part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId}
</select>
<!-- 新增物料制造商 -->
<insert id="addPartManufacturer" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
insert into part_manufacturer (site, part_no, manufacturer_id)
values (#{site}, #{partNo}, #{manufacturerId})
</insert>
<!-- 删除物料制造商 -->
<delete id="deletePartManufacturer" parameterType="com.spring.modules.part.vo.ManufacturerInformationVo">
delete from part_manufacturer
where part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId}
</delete>
<!-- 删除物料制造商 -->
<delete id="deleteManufacturer">
delete from part_manufacturer
where part_no = #{partNo} and site = #{site} and manufacturer_id = #{manufacturerId}
</delete>
<!-- 获取当前物料不包含的制造商 -->
<select id="getManufacturerListBy" resultType="ManufacturerInformationEntity" parameterType="com.spring.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.manufacturer_id = b.manufacturer_id and b.part_no = #{partNo}
<where>
a.site = #{site} 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>
<!-- 修改IQC明细记录信息 -->
<update id="commitItemValue" parameterType="PartSubPropertiesValueData">
UPDATE PartSubPropertiesValue
SET TextValue = #{textValue},
NumValue = #{numValue,jdbcType=DECIMAL}
WHERE PartNo = #{partNo} and Site = #{site} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo} and RecordType = #{recordType}
</update>
<!-- 删除属性值 -->
<delete id="deleteItem" parameterType="PartSubPropertiesValueData">
delete from PartSubPropertiesValue
where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo}
</delete>
<select id="getItemLists" resultType="PlmPropertiesItemData" parameterType="PartSubPropertiesValueData">
SELECT
a.itemNo as itNo,
a.ItemDesc
FROM plm_properties_item a
LEFT JOIN PartSubPropertiesValue b on b.recordType = #{recordType} and b.codeNo = #{codeNo} and b.PartNo = #{partNo} and b.PropertiesItemNo = a.ItemNo and a.site = b.site
<where>
a.ItemType = #{recordType}
and a.site = #{site}
AND b.codeNo is null
<if test = "propertiesItemNo != null and propertiesItemNo != ''">
AND a.ItemNo LIKE #{propertiesItemNo}
</if>
<if test = "itemDesc != null and itemDesc != ''">
AND a.ItemDesc LIKE #{itemDesc}
</if>
</where>
</select>
<select id="getModelItemLists" resultType="PlmPropertiesItemData" parameterType="PartSubPropertiesValueData">
select
a.PropertiesItemNo as itNo,
b.ItemDesc,
a.ItemNo,
a.PartNo,
a.Site,
a.CodeNo,
a.SubCodeSeqNo,
a.recordType
from PartSubPropertiesValue a
left join plm_properties_item b on a.PropertiesItemNo = b.ItemNo and a.recordType = b.ItemType and a.site = b.site
where a.codeNo = #{codeNo} and a.recordType = #{recordType} and a.site = #{site} and a.PartNo = #{partNo}
</select>
<select id="checkPartItem" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
select
site,
PartNo,
CodeNo,
SubCodeSeqNo,
itemNo,
PropertiesItemNo,
RecordType
from PartSubPropertiesValue
where codeNo = #{codeNo} and recordType = #{recordType} and site = #{site} and PartNo = #{partNo} and PropertiesItemNo = #{itNo}
</select>
<select id="checkItem" resultType="PartSubPropertiesValueData" parameterType="PartSubPropertiesValueData">
SELECT
ItemDesc
FROM plm_properties_item
where itemType = #{recordType} and itemNo = #{itNo} and site = #{site}
</select>
<select id="getModalDetailSeqNo" resultType="double" parameterType="PartSubPropertiesValueData">
SELECT
isnull(max(itemNo),0) + 1
from PartSubPropertiesValue
where RecordType = #{recordType} and CodeNo = #{codeNo} and site = #{site} and PartNo = #{partNo} and SubCodeSeqNo = #{subCodeSeqNo}
</select>
<insert id="addPartItem" parameterType="PartSubPropertiesValueData">
insert into PartSubPropertiesValue
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
values (#{partNo}, #{site}, #{codeNo}, #{subCodeSeqNo,jdbcType=FLOAT}, #{codeDesc}, #{itemNo, jdbcType=FLOAT}, #{itNo}, #{textValue}, #{numValue, jdbcType=FLOAT}, #{recordType})
</insert>
<delete id="deletePartItem" parameterType="PartSubPropertiesValueData">
delete from PartSubPropertiesValue
where PartNo = #{partNo} and site = #{site} and RecordType = #{recordType} and CodeNo = #{codeNo} and SubCodeSeqNo = #{subCodeSeqNo} and ItemNo = #{itemNo}
</delete>
<select id="queryCodeNo" parameterType="com.spring.modules.part.vo.MasterPartInformationVo" resultType="PartSubPropertiesValueData">
SELECT
PartNo,
Site,
CodeNo,
SubCodeSeqNo,
SubCodeDesc,
RecordType
FROM PartSubPropertiesValueHeader
where PartNo = #{partNo} and Site = #{site} and SubCodeSeqNo = 1 and RecordType = 'IP'
</select>
<!-- 获取当前物料不包含的库位 -->
<select id="getLocationList1" resultType="LocationInformationEntity" parameterType="PartInformationEntity">
SELECT
a.site,
a.location_id,
a.location_name,
a.warehouse_id,
a.active,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
a.location_type
FROM location as a
left join plm_part_location as b on a.site = b.site and a.location_id = b.location_id and b.part_no = #{partNo}
where a.site = #{site} and b.part_no is null
</select>
<!-- 获取当前物料所包含的库位 -->
<select id="getLocationList2" resultType="LocationInformationEntity" parameterType="PartInformationEntity">
SELECT
a.site,
a.location_id,
b.location_name,
b.warehouse_id,
b.active,
b.create_date,
b.create_by,
b.update_date,
b.update_by,
b.location_type
FROM plm_part_location a
LEFT JOIN location b ON a.location_id = b.location_id and a.site = b.site
WHERE a.part_no = #{partNo} and a.site = #{site}
</select>
<!-- 获取当前物料不包含的库位 -->
<select id="getLocationListBy" resultType="LocationInformationEntity" parameterType="com.spring.modules.part.vo.LocationInformationVo">
SELECT
a.site,
a.location_id,
a.location_name,
a.warehouse_id,
a.active,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
a.location_type
FROM location as a
left join plm_part_location as b on a.site = b.site and a.location_id = b.location_id and b.part_no = #{partNo}
<where>
a.site = #{site} 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.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
SELECT
a.site,
a.part_no,
a.location_id,
b.location_name,
b.warehouse_id,
b.active,
b.create_date,
b.create_by,
b.update_date,
b.update_by,
b.location_type
FROM plm_part_location as a
left join location as b on a.site = b.site and a.location_id = b.location_id
where a.site = #{site} and a.part_no = #{partNo}
</select>
<!-- 获取当前物料所包含的库位 -->
<select id="selectLocationByPartNo" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
SELECT
site,
location_id
FROM plm_part_location
WHERE part_no = #{partNo} and site = #{site} and location_id = #{locationId}
</select>
<!-- 新增物料库位 -->
<insert id="addDefaultLocation" parameterType="com.spring.modules.part.vo.LocationInformationVo">
insert into plm_part_location (site, part_no, location_id)
values (#{site}, #{partNo}, #{locationId})
</insert>
<!-- 删除物料库位 -->
<delete id="deleteDefaultLocation" parameterType="com.spring.modules.part.vo.LocationInformationVo">
delete from plm_part_location
where part_no = #{partNo} and site = #{site} and location_id = #{locationId}
</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 plm_part_location
where part_no = #{partNo} and site = #{site}
</delete>
<select id="partAllInfoSearch" parameterType="com.spring.modules.part.vo.PartInformationVo" resultType="com.spring.modules.part.vo.PartInformationVo">
SELECT
site,
part_no,
part_desc,
spec,
part_type_db,
part_type,
family_id,
dbo.get_family_name(site, family_id) as familyName,
group_id,
dbo.get_group_name(site, group_id) as groupName,
um_id,
dbo.get_um_name(um_id) as umName,
weight_net,
uom_for_weight_net,
volume_net,
uom_for_volume_net,
lot_tracking_code,
active,
product_group_id1,
dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
product_group_id2,
dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
product_group_id3,
dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
product_group_id4,
dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
erp_part_no,
code_no,
dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
manufacturer_id,
dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
agent_id,
dbo.split_agent_id(site, agent_id) as agentName,
type_designation,
hazard_code,
dbo.get_hazard_name(site, hazard_code) as hazardDesc,
asset_class,
dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
dim_quality,
abc_class,
dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
frequency_class,
lifecycle_stage,
country_of_origin,
dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
manufacturing_lead_time,
expected_lead_time,
region_of_origin,
dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
customs_stat_no,
dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
durability_day,
intrastat_conv_factor,
part_status,
dbo.get_part_status_name(site, part_status) as partStatusDesc,
configuration_id,
estimated_material_cost,
inventory_valuation_method,
part_cost_group_id,
dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
inventory_part_cost_level,
invoice_consideration,
zero_cost_flag,
planning_method,
dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
safety_stock,
min_order_qty,
max_order_qty,
mul_order_qty,
safety_lead_time,
shrinkage_fac,
std_order_qty,
cum_lead_time,
back_flush_part,
by_prod_as_supply_in_mrp_db,
unprotected_lead_time,
issue_type,
mrp_control_flag_db,
fixed_lead_time_day,
over_reporting,
use_theoretical_density_db,
variable_lead_time_day,
over_report_tolerance,
fixed_lead_time_hour,
density,
variable_lead_time_hour,
create_date,
create_by,
update_date,
update_by
FROM part
<where>
site = #{query.site}
<if test = "query.partNo != null and query.partNo != ''">
AND part_no like #{query.partNo}
</if>
<if test = "query.erpPartNo != null and query.erpPartNo != ''">
AND erp_part_no like #{query.erpPartNo}
</if>
<if test = "query.partDesc != null and query.partDesc != ''">
AND part_desc like #{query.partDesc}
</if>
<if test = "query.spec != null and query.spec != ''">
AND spec like #{query.spec}
</if>
<if test="query.startDate != null ">
AND required_completion_date >= #{query.startDate}
</if>
<if test="query.endDate != null ">
AND #{query.endDate} >= required_completion_date
</if>
</where>
</select>
<!-- 根据物料编码查 masterPart 属性 -->
<select id="queryMasterField" resultType="com.spring.modules.part.vo.MasterPartInformationVo" parameterType="PartInformationEntity">
SELECT
part_no,
part_desc,
weight_net,
uom_for_weight_net,
volume_net,
uom_for_volume_net,
um_id,
dbo.get_um_name(um_id) as umName
FROM part_catalog
WHERE part_no = #{partNo}
</select>
<!-- 物料状态改为Y -->
<update id="updatePartStatus" parameterType="PartInformationEntity">
UPDATE part
SET status = #{status},
update_date = #{updateDate},
update_by = #{updateBy}
WHERE part_no = #{partNo} and Site = #{site}
</update>
<!-- 查询物料的revision列表 -->
<select id="queryPartRevisionList" resultType="PartRevisionEntity" parameterType="PartRevisionEntity">
SELECT
site,
part_no,
eng_chg_level,
eff_phase_in_date,
eff_phase_out_date,
revision_text,
product_status,
repair_status,
eng_revision,
create_date,
create_by,
update_date,
update_by
FROM part_revision
WHERE site = #{site} and part_no = #{partNo}
</select>
<!-- 查询物料的revision列表 -->
<select id="getPartRevisionList" resultType="PartIfsInventoryRevision" parameterType="PartInformationEntity">
SELECT
site as contract,
part_no,
eng_chg_level,
eff_phase_in_date,
eff_phase_out_date,
revision_text,
product_status,
repair_status,
eng_revision
FROM part_revision
WHERE site = #{site} and part_no = #{partNo}
</select>
<!-- 修改物料版本 -->
<update id="updateRevision" parameterType="PartRevisionEntity">
UPDATE part_revision
SET eff_phase_in_date = #{effPhaseInDate},
eff_phase_out_date = #{effPhaseOutDate},
revision_text = #{revisionText},
eng_revision = #{engRevision},
update_date = getDate(),
update_by = #{updateBy}
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
</update>
<!-- 获取当前物料所包含的库位 -->
<select id="getPartLocationList" resultType="PartIfsInventoryLocation" parameterType="PartInformationEntity">
SELECT
a.site as contract,
a.part_no,
a.location_id as locationNo,
b.location_type as locationType
FROM plm_part_location as a
left join location as b on a.site = b.site and a.location_id = b.location_id
WHERE a.part_no = #{partNo} and a.site = #{site}
</select>
<!-- 获取当前物料所包含的库位 -->
<select id="getFromPartLocation" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="PartInformationEntity">
SELECT
site,
part_no,
location_id
FROM plm_part_location
WHERE part_no = #{partNo} and site = #{site}
</select>
<!-- 获取物料的所有bomHeader -->
<select id="getBomHeader" resultType="BomIfsHeader" parameterType="PartInformationEntity">
SELECT
site as contract,
part_no,
eng_chg_level,
bom_type,
eff_phase_in_date,
eff_phase_out_date,
note_text,
create_date
FROM plm_bom_header
WHERE site = #{site} and part_no = #{partNo}
</select>
<!-- 获取header的所有detail -->
<select id="getBomDetail" resultType="BomIfsAlternative" parameterType="BomIfsHeader">
SELECT
site as contract,
part_no,
eng_chg_level,
bom_type,
alternative_no,
alternative_description as alternativeDesc,
note_text
FROM plm_bom_detail
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType}
</select>
<!-- 获取 detail 的所有 component -->
<select id="getBomComponent" resultType="BomIfsItem" parameterType="BomIfsAlternative">
SELECT
site as contract,
part_no,
eng_chg_level,
bom_type,
alternative_no,
line_item_no,
line_sequence,
component_part,
qty_per_assembly,
issue_type,
component_scrap,
shrinkage_factor
FROM plm_bom_component
WHERE site = #{contract} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and alternative_no = #{alternativeNo}
</select>
<!-- 物料的bom状态改为Y -->
<update id="updateBomOfficialFlag" parameterType="PartInformationEntity">
UPDATE plm_bom_header
SET official_flag = #{status}
WHERE part_no = #{partNo} and Site = #{site}
</update>
<!-- 查询版本 -->
<select id="queryRevision" resultType="PartRevisionEntity" parameterType="PartRevisionEntity">
SELECT
site,
part_no,
eng_chg_level,
eff_phase_in_date,
eff_phase_out_date,
revision_text,
product_status,
repair_status,
eng_revision,
create_date,
create_by,
update_date,
update_by
FROM part_revision
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
</select>
<!-- 新增物料版本 -->
<insert id="saveRevision" parameterType="PartRevisionEntity">
insert into part_revision (site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by)
values (#{site}, #{partNo}, #{engChgLevel}, #{effPhaseInDate}, #{effPhaseOutDate}, #{revisionText}, #{productStatus}, #{repairStatus}, #{engRevision}, getDate(), #{createBy})
</insert>
<!-- 修改当前物料版本的bom -->
<update id="updateBomHeaderByRevision" parameterType="PartRevisionEntity">
UPDATE plm_bom_header
SET note_text = #{revisionText},
eff_phase_in_date = #{effPhaseInDate},
eff_phase_out_date = #{effPhaseOutDate},
eng_revision = #{engRevision}
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
</update>
<!-- 查询版本 -->
<select id="queryBomAlternative" resultType="BomDetailEntity" parameterType="PartRevisionEntity">
SELECT
site,
part_no,
alternative_no,
alternative_description,
bom_type,
eng_chg_level,
min_lot_qty,
default_flag,
note_text,
create_date,
create_by,
update_date,
update_by,
status,
official_flag
FROM plm_bom_detail
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
</select>
<!-- 删除revision -->
<delete id="deleteRevision" parameterType="PartRevisionEntity">
delete from part_revision
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
</delete>
<!-- 删除该版本下的bomDetail -->
<delete id="deleteBomDetail" parameterType="PartRevisionEntity">
delete from plm_bom_detail
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
</delete>
<!-- 删除该版本下的bomComponent -->
<delete id="deleteBomComponent" parameterType="PartRevisionEntity">
delete from plm_bom_component
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
</delete>
<!-- 删除该版本下的副产品成本分配数据 -->
<delete id="deleteManufStruct" parameterType="PartRevisionEntity">
delete from plm_bom_manuf_struct_cost_distrib
where site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel}
</delete>
<!-- 获取当前物料所包含的版本 -->
<select id="getFromPartRevision" resultType="PartRevisionEntity" parameterType="PartInformationEntity">
SELECT
site,
part_no,
eng_chg_level,
eff_phase_in_date,
eff_phase_out_date,
revision_text,
product_status,
repair_status,
eng_revision
FROM part_revision
WHERE part_no = #{partNo} and site = #{site}
</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.spring.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>
<!-- 查询编码对象 -->
<select id="getTranNoData" resultType="TransNoControlData" parameterType="string">
SELECT
Site,
TransType,
NextNumber,
AutoAuthorize,
AutoTransfer,
TypeDesc,
Length,
TransNo
FROM TransNoControl
WHERE site = #{site} and TransType = #{projectPartNo}
</select>
<!-- 材料信息列表 -->
<select id="getProjectPartRow" parameterType="PlmProjectPartData" resultType="com.spring.modules.part.vo.PartInformationVo">
SELECT
site,
part_no,
part_desc,
spec,
part_type_db,
part_type,
family_id,
dbo.get_family_name(site, family_id) as familyName,
group_id,
dbo.get_group_name(site, group_id) as groupName,
um_id,
dbo.get_um_name(um_id) as umName,
weight_net,
uom_for_weight_net,
volume_net,
uom_for_volume_net,
lot_tracking_code,
active,
product_group_id1,
dbo.get_product_group_name(site, product_group_id1, '1') as productGroupName1,
product_group_id2,
dbo.get_product_group_name(site, product_group_id2, '2') as productGroupName2,
product_group_id3,
dbo.get_product_group_name(site, product_group_id3, '3') as productGroupName3,
product_group_id4,
dbo.get_product_group_name(site, product_group_id4, '4') as productGroupName4,
erp_part_no,
code_no,
dbo.get_code_desc(site, code_no, 'IP') as codeDesc,
manufacturer_id,
dbo.get_manufacturer_name(site, manufacturer_id) as manufacturerName,
agent_id,
dbo.split_agent_id(site, agent_id) as agentName,
type_designation,
hazard_code,
dbo.get_hazard_name(site, hazard_code) as hazardDesc,
asset_class,
dbo.get_assetClass_name(site, asset_class) as assetClassDesc,
dim_quality,
abc_class,
dbo.get_abcClass_name(site, abc_class) as abcClassDesc,
frequency_class,
lifecycle_stage,
country_of_origin,
dbo.get_country_of_origin_name(site, country_of_origin) as countryOfOriginDesc,
manufacturing_lead_time,
expected_lead_time,
region_of_origin,
dbo.get_region_of_origin_name(site, region_of_origin) as regionOfOriginDesc,
customs_stat_no,
dbo.get_customs_stat_name(site, customs_stat_no) as customsStatDesc,
durability_day,
intrastat_conv_factor,
part_status,
dbo.get_part_status_name(site, part_status) as partStatusDesc,
configuration_id,
estimated_material_cost,
inventory_valuation_method,
part_cost_group_id,
dbo.get_part_cost_group_name(site, part_cost_group_id) as partCostGroupDesc,
inventory_part_cost_level,
invoice_consideration,
zero_cost_flag,
planning_method,
dbo.get_planning_method_name(site, planning_method) as planningMethodDesc,
safety_stock,
min_order_qty,
max_order_qty,
mul_order_qty,
safety_lead_time,
shrinkage_fac,
std_order_qty,
cum_lead_time,
back_flush_part,
by_prod_as_supply_in_mrp_db,
unprotected_lead_time,
issue_type,
mrp_control_flag_db,
fixed_lead_time_day,
over_reporting,
use_theoretical_density_db,
variable_lead_time_day,
over_report_tolerance,
fixed_lead_time_hour,
density,
variable_lead_time_hour,
remark,
status,
create_date,
create_by,
update_date,
update_by
FROM part
where site = #{site} and part_no = #{testPartNo}
</select>
<!-- 材料信息列表 -->
<select id="getProjectPartRow2" parameterType="PlmProjectPartData" resultType="com.spring.modules.part.vo.PartInformationVo">
SELECT
a.site,
a.part_no,
a.part_desc,
a.spec,
a.part_type_db,
a.part_type,
a.family_id,
dbo.get_family_name(a.site, a.family_id) as familyName,
a.group_id,
dbo.get_group_name(a.site, a.group_id) as groupName,
a.um_id,
dbo.get_um_name(a.um_id) as umName,
a.weight_net,
a.uom_for_weight_net,
a.volume_net,
a.uom_for_volume_net,
a.lot_tracking_code,
a.active,
a.product_group_id1,
dbo.get_product_group_name(a.site, a.product_group_id1, '1') as productGroupName1,
a.product_group_id2,
dbo.get_product_group_name(a.site, a.product_group_id2, '2') as productGroupName2,
a.product_group_id3,
dbo.get_product_group_name(a.site, a.product_group_id3, '3') as productGroupName3,
a.product_group_id4,
dbo.get_product_group_name(a.site, a.product_group_id4, '4') as productGroupName4,
a.erp_part_no,
a.code_no,
dbo.get_code_desc(a.site, a.code_no, 'IP') as codeDesc,
a.manufacturer_id,
dbo.get_manufacturer_name(a.site, a.manufacturer_id) as manufacturerName,
a.agent_id,
dbo.split_agent_id(a.site, a.agent_id) as agentName,
a.type_designation,
a.hazard_code,
dbo.get_hazard_name(a.site, a.hazard_code) as hazardDesc,
a.asset_class,
dbo.get_assetClass_name(a.site, a.asset_class) as assetClassDesc,
a.dim_quality,
a.abc_class,
dbo.get_abcClass_name(a.site, a.abc_class) as abcClassDesc,
a.frequency_class,
a.lifecycle_stage,
a.country_of_origin,
dbo.get_country_of_origin_name(a.site, a.country_of_origin) as countryOfOriginDesc,
a.manufacturing_lead_time,
a.expected_lead_time,
a.region_of_origin,
dbo.get_region_of_origin_name(a.site, a.region_of_origin) as regionOfOriginDesc,
a.customs_stat_no,
dbo.get_customs_stat_name(a.site, a.customs_stat_no) as customsStatDesc,
a.durability_day,
a.intrastat_conv_factor,
a.part_status,
dbo.get_part_status_name(a.site, a.part_status) as partStatusDesc,
a.configuration_id,
a.estimated_material_cost,
a.inventory_valuation_method,
a.part_cost_group_id,
dbo.get_part_cost_group_name(a.site, a.part_cost_group_id) as partCostGroupDesc,
a.inventory_part_cost_level,
a.invoice_consideration,
a.zero_cost_flag,
a.planning_method,
dbo.get_planning_method_name(a.site, a.planning_method) as planningMethodDesc,
a.safety_stock,
a.min_order_qty,
a.max_order_qty,
a.mul_order_qty,
a.safety_lead_time,
a.shrinkage_fac,
a.std_order_qty,
a.cum_lead_time,
a.back_flush_part,
a.by_prod_as_supply_in_mrp_db,
a.unprotected_lead_time,
a.issue_type,
a.mrp_control_flag_db,
a.fixed_lead_time_day,
a.over_reporting,
a.use_theoretical_density_db,
a.variable_lead_time_day,
a.over_report_tolerance,
a.fixed_lead_time_hour,
a.density,
a.variable_lead_time_hour,
a.remark,
a.status,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
d.customer_part_no
FROM part as a
LEFT JOIN plm_project_part as b on a.site = b.site and a.part_no = b.test_part_no
LEFT JOIN plm_project_info as c on b.site = c.site and b.project_id = c.project_id
LEFT JOIN plm_customer_part_info as d on c.site = d.site and c.customer_id = d.customer_no and b.test_part_no = d.part_no
where a.site = #{site} and a.part_no = #{testPartNo} and c.customer_id = #{customerId}
</select>
<!-- 新增项目物料 -->
<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>
<!-- 获取当前项目不包含的物料 -->
<select id="getProjectPartList1" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">
SELECT
c.site,
c.part_no,
c.part_desc
FROM (select
prp1.site,
prp1.test_part_no
from plm_project_part as prp1
left join plm_project_info as ppi1 on ppi1.site = prp1.site and ppi1.project_id = prp1.project_id
where prp1.site = #{site} and ppi1.customer_id <![CDATA[<>]]> #{customerId}
) as a
left join (select
prp2.site,
prp2.test_part_no
from plm_project_part as prp2
left join plm_project_info as ppi2 on ppi2.site = prp2.site and ppi2.project_id = prp2.project_id
where prp2.site = #{site} and ppi2.customer_id = #{customerId}) as b
on a.site = b.site and a.test_part_no = b.test_part_no
left join part as c on a.site = c.site and a.test_part_no = c.part_no
where b.test_part_no is null
</select>
<!-- 获取当前项目所包含的物料 -->
<select id="getProjectPartList2" resultType="com.spring.modules.part.vo.PartInformationVo" parameterType="PlmProjectPartData">
SELECT
a.site,
b.part_no,
b.part_desc,
d.customer_part_no
FROM plm_project_part a
LEFT JOIN part b ON a.site = b.site and a.test_part_no = b.part_no
LEFT JOIN plm_project_info as c on a.site = c.site and a.project_id = c.project_id
LEFT JOIN plm_customer_part_info as d on c.site = d.site and c.customer_id = d.customer_no and a.test_part_no = d.part_no
WHERE a.site = #{site} and a.project_id = #{projectId}
</select>
<!-- 新增项目物料 -->
<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>
<!-- 获取当前项目所包含的物料 -->
<select id="getChangeRecordByPartNo" resultType="com.spring.modules.change.vo.ChangeRequestVo" parameterType="PlmProjectPartData">
SELECT
a.site,
a.change_no,
a.applicant_id,
dbo.get_userDisPlay(a.applicant_id) as applicantName,
d.department_no as applicationDepartmentId,
dbo.get_department_name(a.site, d.department_no) as applicationDepartmentName,
a.apply_date,
a.ecn_type,
a.change_impact,
a.change_impact_desc,
a.ecn_stage,
a.change_type,
a.tp_engineer_id,
dbo.get_userDisPlay(a.tp_engineer_id) as tpEngineerName,
a.change_phase_in_date,
a.df_is_product,
a.printing,
a.manufacturing_cost_is_change,
a.change_request_desc,
a.is_re_quote,
a.ul_certification_requirements,
a.ul_continue_to_meet_demand,
a.gp_certification_requirements,
a.gp_continue_to_meet_demand,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
a.industrial_engineer_id,
dbo.get_userDisPlay(a.industrial_engineer_id) as industrialEngineerName,
a.change_status,
a.cqc_operator_id,
dbo.get_userDisPlay(a.cqc_operator_id) as cqcOperatorName,
a.fai_operator_id,
dbo.get_userDisPlay(a.fai_operator_id) as faiOperatorName
FROM plm_change_request as a
LEFT JOIN sys_user as d on a.site = d.site and a.applicant_id = d.username
LEFT JOIN plm_change_request_detail as b on a.site = b.site and a.change_no = b.change_no
LEFT JOIN plm_project_part as c on b.site = c.site and b.part_no = c.final_part_no
WHERE a.site = #{site} and c.project_id = #{projectId}
</select>
<!-- 查询Bom替代 -->
<select id="queryBomAlternativeList" resultType="com.spring.modules.part.vo.BomDetailVo" parameterType="PartInformationEntity">
SELECT
a.site,
a.part_no,
a.alternative_no,
a.alternative_description,
a.bom_type,
a.eng_chg_level,
a.min_lot_qty,
a.default_flag,
a.note_text,
a.create_date,
a.create_by,
a.update_date,
a.update_by,
a.status,
a.official_flag,
b.eff_phase_in_date,
b.note_text as bomHeaderNoteText,
b.eng_revision
FROM plm_bom_detail as a
LEFT JOIN plm_bom_header as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level and a.bom_type = b.bom_type
WHERE a.site = #{site} and a.part_no = #{partNo} and a.bom_type = 'Manufacturing' and (b.eff_phase_out_date is null or b.eff_phase_out_date = '')
</select>
<!-- 查询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>
<!-- &lt;!&ndash; 获取 component 对象&ndash;&gt;-->
<!-- <select id="getComponentPart" parameterType="com.spring.modules.part.vo.BomDetailVo" resultType="com.spring.modules.part.vo.PartInformationVo">-->
<!-- SELECT-->
<!-- a.site,-->
<!-- a.component_part as partNo,-->
<!-- a.eng_chg_level,-->
<!-- a.bom_type,-->
<!-- a.alternative_no,-->
<!-- b.alternative_description,-->
<!-- d.status-->
<!-- FROM plm_bom_component as a-->
<!-- LEFT JOIN plm_bom_detail as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level and a.bom_type = b.bom_type and a.alternative_no = b.alternative_no-->
<!-- LEFT JOIN plm_bom_header as c on c.site = b.site and c.part_no = b.part_no and c.eng_chg_level = b.eng_chg_level and c.bom_type = b.bom_type-->
<!-- LEFT JOIN part as d on a.site = d.site and a.component_part = d.part_no-->
<!-- WHERE c.site = #{site} and c.part_no = #{partNo} and c.bom_type = 'Manufacturing' and c.eff_phase_out_date is null-->
<!-- </select>-->
<!-- 获取 component 对象-->
<select id="getComponentPart" parameterType="com.spring.modules.part.vo.BomDetailVo" resultType="com.spring.modules.part.vo.PartInformationVo">
SELECT
a.site,
a.component_part as partNo,
a.eng_chg_level,
a.bom_type,
a.alternative_no,
b.alternative_description,
d.status
FROM plm_bom_component as a
LEFT JOIN plm_bom_detail as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level and a.bom_type = b.bom_type and a.alternative_no = b.alternative_no
LEFT JOIN part as d on a.site = d.site and a.component_part = d.part_no
WHERE a.site = #{site} and a.part_no = #{partNo} and a.bom_type = #{bomType} and a.eng_chg_level = #{engChgLevel} and a.alternative_no = #{alternativeNo}
</select>
<select id="getPartRevision" parameterType="PartInformationEntity" resultType="PartRevisionEntity">
SELECT
site,
part_no,
eng_chg_level,
eff_phase_in_date,
eff_phase_out_date,
revision_text,
product_status,
repair_status,
eng_revision,
create_date,
create_by,
update_date,
update_by
FROM part_revision
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = 1
</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="saveRevisions">
insert into part_revision
(site, part_no, eng_chg_level, eff_phase_in_date, eff_phase_out_date, revision_text, product_status, repair_status, eng_revision, create_date, create_by) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.partNo}, #{item.engChgLevel},CONVERT(datetime2, #{item.effPhaseInDate, jdbcType=TIMESTAMP}),
CONVERT(datetime2, #{item.effPhaseOutDate, jdbcType=TIMESTAMP}), #{item.revisionText}, #{item.productStatus}, #{item.repairStatus}, #{item.engRevision}, getDate(), #{item.createBy})
</foreach>
</insert>
<!-- 创建 IFS 物料的 BOM 替代 -->
<insert id="saveIfsBomAlternatives">
insert into plm_bom_detail
(site, part_no, eng_chg_level, bom_type, alternative_no, alternative_description, status, min_lot_qty, default_flag, note_text, create_date, create_by, official_flag) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.ifsPartNo}, #{item.engChgLevel}, #{item.bomType}, #{item.alternativeNo}, #{item.alternativeDescription}, #{item.status}, #{item.minLotQty}, #{item.defaultFlag}, #{item.detailNoteText}, getDate(), #{item.createBy}, #{item.officialFlag})
</foreach>
</insert>
<!-- 创建 IFS 物料的 Routing 替代 -->
<insert id="saveIfsRoutingAlternatives">
insert into plm_routing_detail
(site, part_no, routing_revision, routing_type, alternative_no, alternative_description, fixed_lead_time_day, fixed_lead_time_hour, variable_lead_time_day, variable_lead_time_hour, for_std_lot_by_day, for_lot_by_day, min_lot_qty, note_text, create_date, create_by, status, official_flag) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.ifsPartNo}, #{item.routingRevision}, #{item.routingType}, #{item.alternativeNo}, #{item.alternativeDescription}, #{item.fixedLeadTimeDay}, #{item.fixedLeadTimeHour}, #{item.variableLeadTimeDay}, #{item.variableLeadTimeHour}, #{item.forStdLotByDay}, #{item.forLotByDay}, #{item.minLotQty}, #{item.detailNoteText}, getDate(), #{item.createBy}, #{item.status}, #{item.officialFlag})
</foreach>
</insert>
<!-- 查询代理商列表 -->
<select id="getPartAgents" resultType="com.spring.modules.part.vo.AgentInformationVo" parameterType="PartInformationEntity">
SELECT
site,
part_no,
agent_id
FROM part_agent
where site = #{site} and part_no = #{partNo}
</select>
<!-- 查询制造商列表 -->
<select id="getPartManufacturers" resultType="com.spring.modules.part.vo.ManufacturerInformationVo" parameterType="PartInformationEntity">
SELECT
site,
part_no,
manufacturer_id
FROM part_manufacturer
where site = #{site} and part_no = #{partNo}
</select>
<!-- 查询默认库位列表 -->
<select id="getPartDefaultLocations" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="PartInformationEntity">
SELECT
site,
part_no,
location_id
FROM plm_part_location
where site = #{site} and part_no = #{partNo}
</select>
<!-- 查询文件列表 -->
<select id="getPartFiles" resultType="SysOssEntity" parameterType="PartInformationEntity">
SELECT
id,
url,
create_date,
file_name,
new_file_name,
create_by,
order_ref1,
order_ref2,
order_ref3,
file_type,
file_suffix,
file_type_code,
file_remark
FROM sys_oss
where order_ref1 = #{site} and order_ref2 = #{partNo}
</select>
<!-- 新增物料代理商 -->
<insert id="savePartAgent">
insert into part_agent
(site, part_no, agent_id) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.partNo}, #{item.agentId})
</foreach>
</insert>
<!-- 新增物料制造商 -->
<insert id="savePartManufacturer">
insert into part_manufacturer
(site, part_no, manufacturer_id) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.partNo}, #{item.manufacturerId})
</foreach>
</insert>
<!-- 新增物料制造商 -->
<insert id="savePartDefaultLocation">
insert into plm_part_location
(site, part_no, location_id) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.site}, #{item.partNo}, #{item.locationId})
</foreach>
</insert>
<!-- 新增物料文件 -->
<insert id="savePartFile">
insert into sys_oss
(url, create_date, file_name, new_file_name, create_by, order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code, file_remark) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.url}, #{item.createDate}, #{item.fileName}, #{item.newFileName}, #{item.createBy}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.fileType}, #{item.fileSuffix}, #{item.fileTypeCode}, #{item.fileRemark})
</foreach>
</insert>
<!-- 下一个物料编码 -->
<select id="getNextPartNo" resultType="integer" parameterType="com.spring.modules.part.vo.PartInformationVo">
select
max(convert(int,right(part_no,5)))
from part_catalog
where part_no like #{ifsPartNo} + '%' and len(part_no) = 8
</select>
<select id="checkPartLocationType" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
SELECT
a.site,
a.part_no,
a.location_id,
b.location_type
FROM plm_part_location as a
left join location as b on a.site = b.site and a.location_id = b.location_id
WHERE a.part_no = #{partNo} and a.site = #{site} and b.location_type = #{locationType}
</select>
<select id="checkPartLocationType2" resultType="com.spring.modules.part.vo.LocationInformationVo" parameterType="com.spring.modules.part.vo.LocationInformationVo">
SELECT
a.site,
a.part_no,
a.location_id,
b.location_type
FROM plm_part_location as a
left join location as b on a.site = b.site and a.location_id = b.location_id
WHERE a.part_no = #{partNo} and a.site = #{site} and b.location_type in ('Picking', 'Floor stock', 'Production line')
</select>
<!-- 修改物料版本 -->
<update id="updateRevisionOutDate">
UPDATE part_revision
SET eff_phase_out_date = #{effPhaseOutDate}
WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{effPhaseOutDate}
</update>
<select id="getModelHeader" resultType="PartSubPropertiesValueHeaderData">
SELECT
#{ifsPartNo} as partNo,
Site,
CodeNo,
SubCodeSeqNo,
SubCodeDesc,
RecordType
FROM PartSubPropertiesValueHeader
where site = #{site} and RecordType = #{recordType} and PartNo = #{partNo} and CodeNo = #{codeNo}
</select>
<select id="getModelDetail" resultType="PartSubPropertiesValueData">
SELECT
#{ifsPartNo} as partNo,
Site,
CodeNo,
SubCodeSeqNo,
SubCodeDesc,
ItemNo,
PropertiesItemNo,
TextValue,
NumValue,
RecordType,
order_id
FROM PartSubPropertiesValue
where site = #{site} and RecordType = #{recordType} and PartNo = #{partNo} and CodeNo = #{codeNo}
</select>
<insert id="savePartModelHeaders">
insert into PartSubPropertiesValueHeader
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.partNo}, #{item.site}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.recordType})
</foreach>
</insert>
<insert id="savePartModelDetails">
insert into PartSubPropertiesValue
(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.partNo}, #{item.site}, #{item.codeNo}, #{item.subCodeSeqNo,jdbcType=FLOAT}, #{item.subCodeDesc}, #{item.itemNo,jdbcType=FLOAT}, #{item.propertiesItemNo}, #{item.textValue}, #{item.numValue,jdbcType=FLOAT}, #{item.recordType}, #{item.orderId})
</foreach>
</insert>
<select id="queryPart" resultType="com.spring.modules.part.entity.PartInformationEntity">
select site,
part_no,
part_desc,
spec,
part_type_db,
dbo.get_part_unitCost(site, part_no) as standardCost,
status,
um_id
from part
where site = #{site} and part_no = #{partNo} and status = 'Y'
</select>
</mapper>