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.
 
 
 
 
 
 

952 lines
35 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.base.dao.PropertiesMapper">
<!-- 查询点检项目 -->
<select id="plmPropertiesItemSearch" parameterType="PlmPropertiesItemData" resultType="PlmPropertiesItemData">
SELECT ppi.site,
ItemNo,
ItemDesc,
DefaultValue,
ValueType,
ValueType_DB as valueTypeDb,
ValueChooseFlag,
CreatedDate,
CreatedBy,
ppi.update_date,
ppi.update_by,
MaxValue,
MinValue,
ItemType,
pt.function_type_desc
FROM plm_properties_item ppi
left join properties_type pt on pt.function_type = ppi.itemType
<where>
ppi.site = #{query.site}
<if test="query.itemType != null and query.itemType != ''">
and ppi.ItemType = #{query.itemType}
</if>
<if test="query.itemNo != null and query.itemNo != ''">
AND ppi.ItemNo LIKE '%' + #{query.itemNo} + '%'
</if>
<if test="query.itemDesc != null and query.itemDesc != ''">
AND ppi.ItemDesc LIKE '%' + #{query.itemDesc} + '%'
</if>
<if test="query.valueType != null and query.valueType != ''">
AND ppi.valueType LIKE '%' + #{query.valueType} + '%'
</if>
</where>
order by ppi.ItemType, ppi.ItemNo
</select>
<select id="checkPlmPropertiesItem" resultType="PlmPropertiesItemData">
SELECT ItemNo, ItemDesc
FROM plm_properties_item
WHERE ItemNo = #{itemNo}
and ItemType = #{itemType}
and site = #{site}
</select>
<insert id="saveNewPlmPropertiesItem">
Insert into plm_properties_item ( site, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag
, CreatedDate
, CreatedBy, MaxValue, MinValue, ItemType)
values (#{site}, #{itemNo}, #{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, #{valueChooseFlag},
GetDate(),
#{createdBy}, #{maxValue,jdbcType=DOUBLE}, #{minValue,jdbcType=DOUBLE}, #{itemType})
</insert>
<update id="plmPropertiesItemEdit">
update plm_properties_item
set ItemDesc=#{itemDesc},
DefaultValue=#{defaultValue},
ValueType=#{valueType},
ValueType_DB=#{valueTypeDb},
ValueChooseFlag=#{valueChooseFlag},
update_date=GetDate()
,
update_by=#{updateBy},
MaxValue=#{maxValue,jdbcType=DOUBLE},
MinValue=#{minValue,jdbcType=DOUBLE},
ItemType=#{itemType}
WHERE ItemNo = #{itemNo}
and ItemType = #{itemType}
and site = #{site}
</update>
<delete id="propertiesItemDelete">
Delete
FROM plm_properties_item
WHERE ItemNo = #{itemNo}
and ItemType = #{itemType}
and site = #{site}
</delete>
<select id="searchItemAvailable" resultType="PlmPropertiesItemAvailableData">
SELECT site,
ItemNo,
ValueNo,
AvailableValue,
CreatedDate,
CreatedBy,
ItemType
from plm_properties_item_available
where itemNo = #{itemNo}
and ItemType = #{itemType}
and site = #{site}
</select>
<select id="getItemValueNo" resultType="Double">
SELECT isnull(max(valueNo), 0) + 1
from plm_properties_item_available
where itemNo = #{itemNo}
and ItemType = #{itemType}
and site = #{site}
</select>
<insert id="saveItemAvailable">
insert into plm_properties_item_available (ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType,
site)
values (#{itemNo}, #{valueNo}, #{availableValue}, GetDate(), #{createdBy}, #{itemType}, #{site})
</insert>
<update id="updateItemAvailable">
update plm_properties_item_available
set AvailableValue = #{availableValue}
where itemNo = #{itemNo}
and ItemType = #{itemType}
and ValueNo = #{valueNo}
and site = #{site}
</update>
<delete id="deleteItemAvailable">
delete
from plm_properties_item_available
where itemNo = #{itemNo}
and ItemType = #{itemType}
and ValueNo = #{valueNo}
and site = #{site}
</delete>
<select id="plmPropertiesModelSearch" parameterType="PlmPropertiesModelHeaderData"
resultType="PlmPropertiesModelHeaderData">
SELECT pmh.site,
pmh.function_type,
pmh.code_no,
pmh.code_desc,
pmh.active,
pmh.created_date,
pmh.created_by,
pmh.update_date,
pmh.update_by,
pmh.delflag,
pmh.version,
pmh.is_system,
pr.function_group_desc,
pg.menu_id as [group],
pmh.function_group,
pt.function_type_desc
FROM plm_properties_model_header pmh
left join properties_group pg
on pg.site = pmh.site and pg.function_type = pmh.function_type and pg.code_no = pmh.code_no
left join properties_bu bu
on bu.site = pmh.site and bu.function_type = pmh.function_type and bu.code_no = pmh.code_no
left join properties_type pt on pt.function_type = pmh.function_type
left join properties_relationship pr
on pr.function_group = pmh.function_group and pr.function_type = pmh.function_type
<where>
pmh.site = #{query.site}
<if test="query.codeNo != null and query.codeNo != ''">
AND pmh.code_no like '%' + #{query.codeNo} + '%'
</if>
<if test="query.codeDesc != null and query.codeDesc != ''">
AND pmh.code_desc like '%' + #{query.codeDesc} + '%'
</if>
<if test="query.active != null and query.active != ''">
AND pmh.active = #{query.active}
</if>
<if test="query.functionType != null and query.functionType != ''">
and pmh.function_type = #{query.functionType}
</if>
<if test="query.group != null and query.group != ''">
and pg.menu_id = #{query.group}
</if>
<if test="query.functionGroup != null and query.functionGroup != ''">
and pmh.function_group = #{query.functionGroup}
</if>
<if test="query.buNo != null and query.buNo != ''">
and bu.bu_no = #{query.buNo}
</if>
<if test="query.buNo == null or query.buNo == ''">
and bu.bu_no is null
</if>
</where>
</select>
<insert id="plmPropertiesModelSave">
insert into plm_properties_model_header
(function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by,
site, function_group)
values (#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(),
#{updateBy}, #{site}, #{functionGroup})
</insert>
<update id="plmPropertiesModelEdit">
update plm_properties_model_header
set version = version + 1,
code_desc = #{codeDesc},
function_group = #{functionGroup},
active = #{active},
update_by = #{updateBy},
update_date = GetDate()
where function_type = #{functionType}
and code_no = #{codeNo}
and site = #{site}
</update>
<select id="checkPropertiesModel" resultType="PlmPropertiesModelHeaderData">
SELECT function_type,
code_no,
code_desc,
active,
created_date,
created_by,
update_date,
update_by,
delflag,
version
FROM plm_properties_model_header
where function_type = #{functionType}
and code_no = #{codeNo}
and site = #{site}
</select>
<delete id="plmPropertiesModelDelete">
delete
from plm_properties_model_header
where function_type = #{functionType}
and code_no = #{codeNo}
and site = #{site}
</delete>
<select id="searchModalDetails" resultType="PlmPropertiesModelDetailData">
SELECT a.site,
a.function_type,
a.code_no,
a.properties_item_no itemNo,
a.seq_no,
b.ItemDesc,
b.DefaultValue,
b.ValueType,
b.ValueType_DB,
b.ValueChooseFlag,
b.MaxValue,
b.MinValue,
b.ItemType,
order_id
FROM plm_properties_model_detail a
left join plm_properties_item b
on a.function_type = b.itemType and a.properties_item_no = b.itemNo and a.site = b.site
where a.function_type = #{functionType}
and a.code_no = #{codeNo}
and a.site = #{site}
order by order_id
</select>
<select id="checkItem" resultType="PlmPropertiesModelDetailData">
SELECT ItemDesc
FROM plm_properties_item
where itemType = #{functionType}
and itemNo = #{itemNo}
and site = #{site}
</select>
<select id="checkModalDetails" resultType="PlmPropertiesModelDetailData">
SELECT function_type,
code_no,
properties_item_no itemNo,
seq_no
FROM plm_properties_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and properties_item_no = #{itemNo}
and site = #{site}
</select>
<select id="getModalDetailSeqNo" resultType="Integer">
SELECT isnull(max(seq_no), 0) + 1
from plm_properties_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and site = #{site}
</select>
<insert id="saveModalDetails">
insert into plm_properties_model_detail
(function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, order_id)
values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{orderId})
</insert>
<delete id="deleteModalDetails">
delete
from plm_properties_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and properties_item_no = #{itemNo}
and site = #{site}
</delete>
<select id="getItemLists" resultType="PlmPropertiesItemData">
SELECT a.itemNo,
a.ItemDesc
FROM plm_properties_item a
LEFT JOIN plm_properties_model_detail b
on b.function_type = #{functionType} and b.code_no = #{codeNo} and
b.properties_item_no = a.ItemNo and a.site = b.site
<where>
a.ItemType = #{functionType}
and a.site = #{site}
AND b.code_no is null
<if test="itemNo != null and itemNo != ''">
AND a.ItemNo LIKE '%' + #{itemNo} + '%'
</if>
<if test="itemDesc != null and itemDesc != ''">
AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
</if>
</where>
</select>
<select id="getModelItemLists" resultType="PlmPropertiesItemData">
select a.properties_item_no itemNo,
b.ItemDesc
from plm_properties_model_detail a
left join plm_properties_item b
on a.properties_item_no = b.ItemNo and a.function_type = b.ItemType and a.site = b.site
where a.code_no = #{codeNo}
and a.function_type = #{functionType}
and a.site = #{site}
</select>
<select id="getItemListsForPartAndCode" resultType="PlmPropertiesItemData">
select a.PropertiesItemNo itemNo,
b.ItemDesc
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.code_no = #{codeNo}
and a.RecordType = #{functionType}
and a.site = #{site}
and a.partNo = #{partNo}
</select>
<select id="searchPropertiesUnChoose" resultType="PlmPropertiesItemData">
SELECT b.site,
b.ItemType as functionType,
b.ItemNo,
b.ItemDesc,
b.DefaultValue,
b.ValueType,
b.ValueType_DB,
b.ValueChooseFlag,
b.MaxValue,
b.MinValue
FROM plm_properties_item b
where b.ItemType = #{codeType}
and b.site = #{site}
<if test="list != null and list.size() != 0">
and b.ItemNo not in (
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
)
</if>
</select>
<select id="checkValueHeaderData" resultType="PartSubPropertiesValueHeaderData">
SELECT PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType
from PartSubPropertiesValueHeader
where PartNo = #{testPartNo}
and site = #{site}
and CodeNo = #{codeNo}
and RecordType = 'IP'
</select>
<delete id="deletePartSubPropertiesValueHeader">
delete
from PartSubPropertiesValueHeader
where PartNo = #{testPartNo}
and site = #{site}
and RecordType = 'IP'
</delete>
<delete id="deletePartSubPropertiesValue">
delete
from PartSubPropertiesValue
where PartNo = #{testPartNo}
and site = #{site}
and RecordType = 'IP'
</delete>
<insert id="savePartSubPropertiesValueHeader">
insert into PartSubPropertiesValueHeader (PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc, RecordType)
select #{testPartNo}, #{site}, #{codeNo}, 1, Code_Desc, 'IP'
from plm_properties_model_header
where Code_No = #{codeNo}
and site = #{site}
and function_type = 'IP'
</insert>
<insert id="savePartSubPropertiesValue">
insert into PartSubPropertiesValue ( PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc
, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
select #{testPartNo},
#{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,
'IP'
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 = 'IP'
</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 ItemDesc
, b.ValueType
, b.ValueType_DB
, b.ValueChooseFlag
FROM PartSubPropertiesValue a
left join plm_properties_item b
on a.PropertiesItemNo = b.ItemNo and a.site = b.site and a.RecordType = b.ItemType
<where>
AND a.site = #{site}
and RecordType = 'IP'
AND a.PartNo = #{partNo,jdbcType=VARCHAR}
</where>
</select>
<select id="checkItemNo" resultType="PartSubPropertiesValueData">
select ValueType_DB
from plm_properties_item
where itemNo = #{propertiesItemNo}
and site = #{site}
and ItemType = 'IP'
</select>
<select id="getAvailableValueList" resultType="PlmPropertiesItemAvailableData">
select ItemNo, ValueNo, AvailableValue
from plm_properties_item_available
where itemNo = #{propertiesItemNo}
and site = #{site}
and ItemType = 'IP'
</select>
<update id="updateToolItem">
update PartSubPropertiesValue
set TextValue=#{textValue},
NumValue=#{numValue,jdbcType=DOUBLE}
where PropertiesItemNo = #{propertiesItemNo}
and site = #{site}
and PartNo = #{partNo}
and RecordType = 'IP'
</update>
<insert id="refreshItemModal">
insert into PartSubPropertiesValue(PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc,
ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType)
select #{partNo},
#{site},
a.CodeNo,
1,
a.SubCodeDesc,
b.seq_No,
b.properties_item_no,
case
when e.ValueType_DB = 'T' then e.DefaultValue
else null end,
case when e.ValueType_DB = 'N' and e.DefaultValue != '' then e.DefaultValue else null end,
'IP'
from PartSubPropertiesValueHeader a
left join plm_properties_model_detail b
on a.CodeNo = b.Code_No and a.site = b.site and a.RecordType = b.function_type
left join PartSubPropertiesValue c
on c.Site = #{site} and c.PartNo = #{partNo} and c.RecordType = 'IP' and
b.seq_no = c.ItemNo and a.RecordType = b.function_type
left join plm_properties_item e
on b.properties_item_no = e.ItemNo and a.site = e.site and a.RecordType = e.ItemType
where c.ItemNo is null
and a.RecordType = 'IP'
and a.PartNo = #{partNo}
and a.site = #{site}
</insert>
<select id="propertiesModelSearchForBM" parameterType="PlmBmModelHeaderData" resultType="PlmBmModelHeaderData">
SELECT site,
bu_no,
dbo.plm_get_bu_desc(site, bu_no) buDesc,
function_type,
code_no,
code_desc,
active,
created_date,
created_by,
update_date,
update_by,
delflag,
version,
edit_flag,
properties_code_no,
dbo.get_properties_codeDesc(site, function_type, properties_code_no) properties_code_desc
FROM plm_bm_model_header
<where>
site = #{query.site}
<if test="query.codeNo != null and query.codeNo != ''">
AND code_no like '%' + #{query.codeNo} + '%'
</if>
<if test="query.codeDesc != null and query.codeDesc != ''">
AND code_desc like '%' + #{query.codeDesc} + '%'
</if>
<if test="query.active != null and query.active != ''">
AND active = #{query.active}
</if>
<if test="query.buNo != null and query.buNo != ''">
AND bu_no = #{query.buNo}
</if>
<if test="query.functionType != null and query.functionType != ''">
and function_type = #{query.functionType}
</if>
<if test="query.editFlag != null and query.editFlag != ''">
and edit_flag = #{query.editFlag}
</if>
<if test="query.username != null and query.username != '' and query.username != 'admin'">
AND bu_no in (select bu_no from AccessBu where site = #{query.site} and username = #{query.username})
</if>
</where>
order by bu_no, order_id
</select>
<select id="searchModalDetailsForBM" resultType="PlmBmModelDetailData">
SELECT a.site,
a.function_type,
a.code_no,
pd.properties_item_no itemNo,
pd.seq_no,
b.ItemDesc,
b.DefaultValue,
b.ValueType,
b.ValueType_DB,
b.ValueChooseFlag,
b.MaxValue,
b.MinValue,
a.bu_no,
b.ItemType,
pd.order_id
FROM plm_bm_model_header a
left join plm_properties_model_detail pd
on a.site = pd.site and pd.function_type = 'BM' and a.properties_code_no = pd.code_no
left join plm_properties_item b
on pd.function_type = b.itemType and pd.properties_item_no = b.itemNo and pd.site = b.site
where a.function_type = #{functionType}
and a.code_no = #{codeNo}
and a.site = #{site}
and a.bu_No = #{buNo}
and pd.properties_item_no is not null
order by order_id
</select>
<select id="getItemListsForBM" resultType="PlmPropertiesItemData">
SELECT a.itemNo,
a.ItemDesc
FROM plm_properties_item a
LEFT JOIN plm_bm_model_detail b on b.function_type = #{functionType} and b.code_no = #{codeNo} and
b.properties_item_no = a.ItemNo and a.site = b.site and
b.bu_no = #{buNo}
<where>
a.ItemType = #{functionType}
and a.site = #{site}
AND b.code_no is null
<if test="itemNo != null and itemNo != ''">
AND a.ItemNo LIKE '%' + #{itemNo} + '%'
</if>
<if test="itemDesc != null and itemDesc != ''">
AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
</if>
</where>
</select>
<select id="getModelItemListsForBM" resultType="PlmPropertiesItemData">
select a.properties_item_no itemNo,
b.ItemDesc
from plm_bm_model_detail a
left join plm_properties_item b
on a.properties_item_no = b.ItemNo and a.function_type = b.ItemType and a.site = b.site
where a.code_no = #{codeNo}
and a.function_type = #{functionType}
and a.site = #{site}
and a.bu_no = #{buNo}
</select>
<select id="checkModalDetailsForBM" resultType="PlmBmModelDetailData">
SELECT function_type,
code_no,
properties_item_no itemNo,
seq_no
FROM plm_bm_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and properties_item_no = #{itemNo}
and site = #{site}
and bu_No = #{buNo}
</select>
<select id="getModalDetailSeqNoForBM" resultType="Integer">
SELECT isnull(max(seq_no), 0) + 1
from plm_bm_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and site = #{site}
and bu_no = #{buNo}
</select>
<select id="getModalDetailOrderId" resultType="Integer">
SELECT isnull(max(order_id), 0) + 1
from plm_properties_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and site = #{site}
</select>
<insert id="saveModalDetailsForBM">
insert into plm_bm_model_detail
(function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site, bu_no,
order_id)
values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site}, #{buNo},
#{orderId})
</insert>
<select id="getPropertiesListByPartAndCodeNo" 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 ItemDesc
, b.ValueType
, b.ValueType_DB
, b.ValueChooseFlag
FROM PartSubPropertiesValue a
left join plm_properties_item b
on a.PropertiesItemNo = b.ItemNo and a.site = b.site and a.RecordType = b.ItemType
<where>
AND a.site = #{site}
and a.RecordType = #{recordType}
and a.codeNo = #{codeNo}
AND a.PartNo = #{partNo,jdbcType=VARCHAR}
</where>
order by a.order_id
</select>
<update id="updatePropertiesList">
update PartSubPropertiesValue
set TextValue=#{textValue},
NumValue=#{numValue,jdbcType=DOUBLE}
where Site = #{site}
and CodeNo = #{codeNo}
and PartNo = #{partNo}
and SubCodeSeqNo = #{subCodeSeqNo}
and itemNo = #{itemNo}
</update>
<delete id="deleteModalDetailsForBM">
delete
from plm_bm_model_detail
where function_type = #{functionType}
and code_no = #{codeNo}
and properties_item_no = #{itemNo}
and site = #{site}
and bu_no = #{buNo}
</delete>
<select id="getUpItemdata" resultType="com.spring.modules.base.entity.PlmPropertiesModelDetail">
select top 1 site,
function_type,
code_no,
properties_item_no,
seq_no,
created_date,
created_by,
update_date,
update_by,
delflag,
version,
order_id
from plm_properties_model_detail
where #{orderId} > order_id
and site = #{site}
and code_no = #{codeNo}
and function_type = #{functionType}
order by order_id desc
</select>
<select id="getDownItemdata" resultType="com.spring.modules.base.entity.PlmPropertiesModelDetail">
select top 1 site,
function_type,
code_no,
properties_item_no,
seq_no,
created_date,
created_by,
update_date,
update_by,
delflag,
version,
order_id
from plm_properties_model_detail
where order_id > #{orderId}
and site = #{site}
and code_no = #{codeNo}
and function_type = #{functionType}
order by order_id
</select>
<update id="updatePlmPropertiesModelDetailOrder">
update plm_properties_model_detail
set order_id=#{orderId}
where site = #{site}
and code_no = #{codeNo}
and function_type = #{functionType}
and seq_no = #{seqNo}
</update>
<select id="propertiesListSearch" resultType="com.spring.modules.base.entity.PlmPropertiesModelHeader">
SELECT site,
function_type,
code_no,
code_desc,
active,
created_date,
created_by,
update_date,
update_by,
delflag,
version
FROM plm_properties_model_header
<where>
site = #{site}
and active = 'Y'
<if test="codeNo != null and codeNo != ''">
AND code_no like '%' + #{codeNo} + '%'
</if>
<if test="codeDesc != null and codeDesc != ''">
AND code_desc like '%' + #{codeDesc} + '%'
</if>
<if test="functionType != null and functionType != ''">
and function_type = #{functionType}
</if>
</where>
</select>
<select id="searchWorkCenterBMType" resultType="WorkCenterBMTypeData">
select a.site, a.work_center_no, a.work_center_desc, b.itemType, c.type_desc
from work_center a
left join WorkCenter_BMType b on a.site = b.site and a.work_center_no = b.workCenterNo
left join plm_route_itemType c on b.itemType = c.item_type
where a.site = #{site}
</select>
<delete id="deleteWorkCenterBMType">
delete
from WorkCenter_BMType
where site = #{site}
and workCenterNo = #{workCenterNo}
</delete>
<update id="updateWorkCenterBMType">
update WorkCenter_BMType
set itemType=#{itemType},
update_by=#{updateBy},
update_date=GetDate()
where site = #{site}
and workCenterNo = #{workCenterNo}
</update>
<insert id="insertWorkCenterBMType">
insert into WorkCenter_BMType (site, workCenterNo, itemType, update_by, update_date)
values (#{site}, #{workCenterNo}, #{itemType}, #{updateBy}, GetDate())
</insert>
<select id="getPlmRouteItemType" resultType="PlmRouteItemType">
select item_type, type_desc
from plm_route_itemType
</select>
<select id="searchMenuAllListId" resultType="com.spring.modules.sys.entity.SysMenuEntity">
select menu_id, name
from sys_menu
where parent_id = 0
and menu_id not in (999)
and menu_type = 'pc'
</select>
<select id="searchBUList" resultType="com.spring.modules.base.entity.Bu">
select bu_no, bu_desc
from BU
where site = #{site}
and active = 'Y'
</select>
<select id="searchBUPropertiesList" resultType="com.spring.modules.base.entity.Bu">
select a.bu_no, b.bu_desc
from properties_bu a
left join BU b on a.site = b.site and a.bu_no = b.bu_no
<where>
<if test="functionType != null and functionType != ''">
and a.function_type = #{functionType}
</if>
<if test="codeNo != null and codeNo != ''">
and a.code_no = #{codeNo}
</if>
<if test="site != null and site != ''">
and a.site = #{site}
</if>
</where>
</select>
<select id="searchAllItemTypeList" resultType="com.spring.modules.sys.entity.DictData">
select dict_label, dict_value
from sys_dict_data
where site = #{site}
and dict_type in
(select menu_id from sys_menu where parent_id = 0 and menu_id not in (999) and menu_type = 'pc')
</select>
<select id="searchAllTypeList" resultType="java.util.Map">
select function_type as functionType, function_type_desc as functionTypeDesc
from properties_type
</select>
<select id="searchAllTypeRelationshipList" resultType="java.util.Map">
select function_group as functionGroup, function_group_desc as functionGroupDesc
from properties_relationship
where function_type = #{type}
</select>
<insert id="saveSubPropertiesValue">
insert into PartSubPropertiesValue ( PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc
, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id)
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},
isnull(b.order_id, 999)
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>
<insert id="saveSubPropertiesValueHeader">
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="saveSubPropertiesValueForAlone">
insert into PartSubPropertiesValue ( PartNo, Site, CodeNo, SubCodeSeqNo, SubCodeDesc
, ItemNo, PropertiesItemNo, TextValue, NumValue, RecordType, order_id)
select #{partNo},
#{site},
#{codeNo},
1,
d.SubCodeDesc,
#{itemNo,jdbcType=DOUBLE},
#{propertiesItemNo},
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},
#{itemNo,jdbcType=DOUBLE}
from plm_properties_item c
left join PartSubPropertiesValueHeader d
on d.PartNo = #{partNo} and d.site = #{site} and CodeNo = #{codeNo} and
RecordType = #{recordType}
where c.ItemNo = #{propertiesItemNo}
and c.site = #{site}
and c.itemType = #{recordType}
</insert>
<delete id="deleteSubPropertiesValueForAlone">
delete
from PartSubPropertiesValue
where Site = #{site}
and PartNo = #{partNo}
and CodeNo = #{codeNo}
and PropertiesItemNo = #{propertiesItemNo}
and RecordType = #{recordType}
</delete>
<select id="getNewSeqNoForAlone" resultType="Double">
select isnull(Max(itemNo) + 1, 1)
from PartSubPropertiesValue
where Site = #{site}
and PartNo = #{partNo}
and CodeNo = #{codeNo}
and RecordType = #{recordType}
</select>
<delete id="removeSubPropertiesValue">
delete
from PartSubPropertiesValue
where Site = #{site}
and PartNo = #{partNo}
and CodeNo = #{codeNo}
and RecordType = #{recordType}
</delete>
<delete id="removeSubPropertiesValueHeader">
delete from PartSubPropertiesValueHeader
where Site = #{site}
and PartNo = #{partNo}
and CodeNo = #{codeNo}
and RecordType = #{recordType}
</delete>
</mapper>